rajesh
08/25/2021, 1:34 PMrajesh
08/25/2021, 6:02 PMColton Idle
08/25/2021, 6:13 PMNick
08/25/2021, 11:00 PMColton Idle
08/25/2021, 11:29 PMrajesh
08/26/2021, 7:59 AMColton Idle
08/26/2021, 12:30 PMNick
08/31/2021, 3:14 PMprivate val sheetSize = 230.dp
enum class SheetState { Open, Closed }
@OptIn(ExperimentalMaterialApi::class)
@Composable
fun CustomBottomSheet(
swipeableState: SwipeableState<SheetState> = rememberSwipeableState(SheetState.Open),
content: @Composable () -> Unit,
) {
val sizePx = with(LocalDensity.current) { sheetSize.toPx() }
val anchors = mapOf(0f to SheetState.Open,
sizePx to SheetState.Closed)
Box(
modifier = Modifier
.swipeable(
state = swipeableState,
anchors = anchors,
thresholds = { _, _ -> FractionalThreshold(0.3f) },
orientation = Orientation.Vertical
)
.offset { IntOffset(0, swipeableState.offset.value.roundToInt()) }
) {
content()
}
}
Nick
08/31/2021, 3:14 PM