From 2361651d6bd38dbb6b9b2ca3c2a04d003e48161c Mon Sep 17 00:00:00 2001 From: Hyobeen-Park Date: Thu, 16 Jan 2025 08:54:15 +0900 Subject: [PATCH] =?UTF-8?q?[FEAT/#24]=20flexibleBottomSheet=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bottomsheet/SpoonyFlexibleBottomSheet.kt | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 app/src/main/java/com/spoony/spoony/core/designsystem/component/bottomsheet/SpoonyFlexibleBottomSheet.kt 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() + } +}