|
| 1 | +package com.redmadrobot.debug.uikit.components |
| 2 | + |
| 3 | +import androidx.compose.foundation.background |
| 4 | +import androidx.compose.foundation.layout.Box |
| 5 | +import androidx.compose.foundation.layout.Column |
| 6 | +import androidx.compose.foundation.layout.ColumnScope |
| 7 | +import androidx.compose.foundation.layout.fillMaxWidth |
| 8 | +import androidx.compose.foundation.layout.padding |
| 9 | +import androidx.compose.foundation.layout.size |
| 10 | +import androidx.compose.foundation.shape.RoundedCornerShape |
| 11 | +import androidx.compose.material3.ExperimentalMaterial3Api |
| 12 | +import androidx.compose.material3.ModalBottomSheet |
| 13 | +import androidx.compose.material3.Text |
| 14 | +import androidx.compose.material3.rememberModalBottomSheetState |
| 15 | +import androidx.compose.runtime.Composable |
| 16 | +import androidx.compose.ui.Modifier |
| 17 | +import androidx.compose.ui.unit.dp |
| 18 | +import com.redmadrobot.debug.uikit.theme.DebugPanelTheme |
| 19 | +import com.redmadrobot.debug.uikit.theme.SystemBarsColors |
| 20 | +import com.redmadrobot.debug.uikit.theme.SystemBarsEffect |
| 21 | + |
| 22 | +@OptIn(ExperimentalMaterial3Api::class) |
| 23 | +@Composable |
| 24 | +public fun PanelBottomSheet( |
| 25 | + title: String, |
| 26 | + onDismiss: () -> Unit, |
| 27 | + modifier: Modifier = Modifier, |
| 28 | + content: @Composable ColumnScope.() -> Unit, |
| 29 | +) { |
| 30 | + val sheetState = rememberModalBottomSheetState(skipPartiallyExpanded = true) |
| 31 | + |
| 32 | + ModalBottomSheet( |
| 33 | + onDismissRequest = onDismiss, |
| 34 | + sheetState = sheetState, |
| 35 | + shape = RoundedCornerShape(topStart = 20.dp, topEnd = 20.dp), |
| 36 | + containerColor = DebugPanelTheme.colors.surface.secondary, |
| 37 | + modifier = modifier, |
| 38 | + dragHandle = { SheetHandle() }, |
| 39 | + ) { |
| 40 | + SystemBarsEffect( |
| 41 | + systemBarsColors = SystemBarsColors( |
| 42 | + statusBarColor = DebugPanelTheme.colors.background.primary, |
| 43 | + navigationBarColor = DebugPanelTheme.colors.surface.secondary, |
| 44 | + ), |
| 45 | + ) |
| 46 | + |
| 47 | + Column( |
| 48 | + modifier = Modifier |
| 49 | + .fillMaxWidth() |
| 50 | + .padding(horizontal = 20.dp), |
| 51 | + ) { |
| 52 | + Text( |
| 53 | + text = title, |
| 54 | + style = DebugPanelTheme.typography.titleLarge, |
| 55 | + color = DebugPanelTheme.colors.content.primary, |
| 56 | + modifier = Modifier.padding(bottom = 20.dp), |
| 57 | + ) |
| 58 | + content() |
| 59 | + } |
| 60 | + } |
| 61 | +} |
| 62 | + |
| 63 | +@Composable |
| 64 | +private fun SheetHandle(modifier: Modifier = Modifier) { |
| 65 | + Box( |
| 66 | + modifier = modifier |
| 67 | + .padding(top = 12.dp, bottom = 20.dp) |
| 68 | + .size(width = 32.dp, height = 4.dp) |
| 69 | + .background( |
| 70 | + color = DebugPanelTheme.colors.stroke.secondary, |
| 71 | + shape = RoundedCornerShape(2.dp), |
| 72 | + ), |
| 73 | + ) |
| 74 | +} |
0 commit comments