Skip to content

Commit a395e91

Browse files
refactor: simplify BottomSheet collapsed content rendering
1 parent 3eebf3c commit a395e91

File tree

1 file changed

+10
-24
lines changed

1 file changed

+10
-24
lines changed

app/src/main/kotlin/com/metrolist/music/ui/component/BottomSheet.kt

Lines changed: 10 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ fun BottomSheet(
7070
background: @Composable (BoxScope.() -> Unit) = { },
7171
onDismiss: (() -> Unit)? = null,
7272
collapsedContent: @Composable BoxScope.() -> Unit,
73-
collapsedBackgroundColor: Color = Color.Transparent,
7473
content: @Composable BoxScope.() -> Unit,
7574
) {
7675
val density = LocalDensity.current
@@ -135,32 +134,19 @@ fun BottomSheet(
135134
)
136135
}
137136

138-
// collapsed content
139-
if (!state.isExpanded) {
140-
// startY must be < state.collapsedBound
141-
val startY = with(density) { (MiniPlayerHeight + MinMiniPlayerHeight - 1.dp).toPx() }
142-
val colors = mutableListOf(collapsedBackgroundColor, Color.Transparent)
143-
// no visible gradient if no bottom content to hide it
144-
if (MiniPlayerHeight + MinMiniPlayerHeight >= state.collapsedBound) {
145-
colors[1] = collapsedBackgroundColor
146-
}
137+
if (!state.isExpanded && (onDismiss == null || !state.isDismissed)) {
147138
Box(
148-
modifier = Modifier
139+
modifier =
140+
Modifier
149141
.graphicsLayer {
150142
alpha = 1f - (state.progress * 4).coerceAtMost(1f)
151-
}
152-
.clickable(
153-
onClick = state::expandSoft
154-
)
155-
.fillMaxWidth()
156-
.height(state.collapsedBound)
157-
.background(
158-
Brush.verticalGradient(
159-
colors = colors,
160-
startY = startY,
161-
)
162-
),
163-
content = collapsedContent
143+
}.clickable(
144+
interactionSource = remember { MutableInteractionSource() },
145+
indication = null,
146+
onClick = state::expandSoft,
147+
).fillMaxWidth()
148+
.height(state.collapsedBound),
149+
content = collapsedContent,
164150
)
165151
}
166152
}

0 commit comments

Comments
 (0)