-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b80281e
commit 2361651
Showing
1 changed file
with
44 additions
and
0 deletions.
There are no files selected for viewing
44 changes: 44 additions & 0 deletions
44
...va/com/spoony/spoony/core/designsystem/component/bottomsheet/SpoonyFlexibleBottomSheet.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
} | ||
} |