diff --git a/app/src/main/java/com/spoony/spoony/core/designsystem/component/bottomsheet/SpoonyFlexibleBottomSheet.kt b/app/src/main/java/com/spoony/spoony/core/designsystem/component/bottomsheet/SpoonyFlexibleBottomSheet.kt new file mode 100644 index 0000000..9d1c7fa --- /dev/null +++ b/app/src/main/java/com/spoony/spoony/core/designsystem/component/bottomsheet/SpoonyFlexibleBottomSheet.kt @@ -0,0 +1,44 @@ +package com.spoony.spoony.core.designsystem.component.bottomsheet + +import androidx.compose.foundation.ExperimentalFoundationApi +import androidx.compose.material3.ExperimentalMaterial3Api +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import androidx.compose.ui.platform.LocalConfiguration +import androidx.compose.ui.unit.Dp +import androidx.compose.ui.unit.dp +import com.spoony.spoony.core.designsystem.type.AdvancedSheetState +import io.morfly.compose.bottomsheet.material3.rememberBottomSheetScaffoldState +import io.morfly.compose.bottomsheet.material3.rememberBottomSheetState + +@OptIn(ExperimentalMaterial3Api::class, ExperimentalFoundationApi::class) +@Composable +fun SpoonyFlexibleBottomSheet( + sheetContent: @Composable () -> Unit, + modifier: Modifier = Modifier, + minHeight: Dp = 50.dp, + dragHandle: @Composable () -> Unit = {}, + content: @Composable () -> Unit, +) { + val configuration = LocalConfiguration.current + val screenHeight = configuration.screenHeightDp.dp + val halfScreenHeight = screenHeight / 2 + + val sheetState = rememberBottomSheetState( + initialValue = AdvancedSheetState.Hidden, + defineValues = { + AdvancedSheetState.Hidden at height(minHeight) + AdvancedSheetState.PartiallyExpanded at height(halfScreenHeight) + AdvancedSheetState.Expanded at height(screenHeight) + } + ) + + SpoonyAdvancedBottomSheet( + sheetState = rememberBottomSheetScaffoldState(sheetState), + modifier = modifier, + dragHandle = dragHandle, + sheetContent = sheetContent + ) { + content() + } +}