fix(android): extract PlaylistCardCover to clear detekt LongMethod
Adding the play-button overlay in the previous commit pushed PlaylistCard from 49 to 62 lines, two over detekt's 60-line cap. Splitting the cover stack into its own private composable (PlaylistCardCover) brings the outer function back under the limit while keeping the call site readable. Behavior identical to f17610ec; pure refactor for lint compliance.
This commit is contained in:
+49
-31
@@ -60,37 +60,10 @@ fun PlaylistCard(
|
|||||||
color = Color.Transparent,
|
color = Color.Transparent,
|
||||||
) {
|
) {
|
||||||
Column(modifier = Modifier.padding(horizontal = 8.dp)) {
|
Column(modifier = Modifier.padding(horizontal = 8.dp)) {
|
||||||
CoverTile(
|
PlaylistCardCover(
|
||||||
url = playlist.coverUrl,
|
playlist = playlist,
|
||||||
contentDescription = playlist.name,
|
onPlay = onPlay,
|
||||||
size = 144.dp,
|
playEnabled = playEnabled,
|
||||||
fallback = {
|
|
||||||
Icon(
|
|
||||||
imageVector = Lucide.ListMusic,
|
|
||||||
contentDescription = null,
|
|
||||||
tint = MaterialTheme.colorScheme.onSurfaceVariant,
|
|
||||||
modifier = Modifier.size(56.dp),
|
|
||||||
)
|
|
||||||
},
|
|
||||||
overlay = {
|
|
||||||
if (playlist.isSystem) {
|
|
||||||
VariantPill(
|
|
||||||
label = systemLabelFor(playlist.systemVariant),
|
|
||||||
modifier = Modifier
|
|
||||||
.align(Alignment.TopStart)
|
|
||||||
.padding(6.dp),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
if (onPlay != null) {
|
|
||||||
PlayCircleButton(
|
|
||||||
onPlay = onPlay,
|
|
||||||
enabled = playEnabled,
|
|
||||||
modifier = Modifier
|
|
||||||
.align(Alignment.BottomEnd)
|
|
||||||
.padding(6.dp),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
)
|
)
|
||||||
Spacer(Modifier.height(8.dp))
|
Spacer(Modifier.height(8.dp))
|
||||||
Text(
|
Text(
|
||||||
@@ -111,6 +84,51 @@ fun PlaylistCard(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 144dp cover with the system-variant pill (top-start) and play
|
||||||
|
* overlay (bottom-end) stacked on top. Pulled out of [PlaylistCard]
|
||||||
|
* to keep that composable under detekt's 60-line LongMethod cap.
|
||||||
|
*/
|
||||||
|
@Composable
|
||||||
|
private fun PlaylistCardCover(
|
||||||
|
playlist: PlaylistRef,
|
||||||
|
onPlay: (suspend () -> Unit)?,
|
||||||
|
playEnabled: Boolean,
|
||||||
|
) {
|
||||||
|
CoverTile(
|
||||||
|
url = playlist.coverUrl,
|
||||||
|
contentDescription = playlist.name,
|
||||||
|
size = 144.dp,
|
||||||
|
fallback = {
|
||||||
|
Icon(
|
||||||
|
imageVector = Lucide.ListMusic,
|
||||||
|
contentDescription = null,
|
||||||
|
tint = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||||
|
modifier = Modifier.size(56.dp),
|
||||||
|
)
|
||||||
|
},
|
||||||
|
overlay = {
|
||||||
|
if (playlist.isSystem) {
|
||||||
|
VariantPill(
|
||||||
|
label = systemLabelFor(playlist.systemVariant),
|
||||||
|
modifier = Modifier
|
||||||
|
.align(Alignment.TopStart)
|
||||||
|
.padding(6.dp),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
if (onPlay != null) {
|
||||||
|
PlayCircleButton(
|
||||||
|
onPlay = onPlay,
|
||||||
|
enabled = playEnabled,
|
||||||
|
modifier = Modifier
|
||||||
|
.align(Alignment.BottomEnd)
|
||||||
|
.padding(6.dp),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
/** Small label chip overlaid on a system playlist's cover. */
|
/** Small label chip overlaid on a system playlist's cover. */
|
||||||
@Composable
|
@Composable
|
||||||
private fun VariantPill(label: String, modifier: Modifier = Modifier) {
|
private fun VariantPill(label: String, modifier: Modifier = Modifier) {
|
||||||
|
|||||||
Reference in New Issue
Block a user