Skip to content

Commit

Permalink
[FEAT/#24] flexibleBottomSheet 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
Hyobeen-Park committed Jan 15, 2025
1 parent b80281e commit 2361651
Showing 1 changed file with 44 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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()
}
}

0 comments on commit 2361651

Please sign in to comment.