Created
February 15, 2026 07:19
-
-
Save skydoves/24675ff9102551c082191c5d507a6510 to your computer and use it in GitHub Desktop.
FlexibleBottomSheet - Complete Google Maps style PlaceDetailScreen
This file contains hidden or 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
| @Composable | |
| fun PlaceDetailScreen() { | |
| var targetValue by remember { | |
| mutableStateOf(FlexibleSheetValue.SlightlyExpanded) | |
| } | |
| Box(modifier = Modifier.fillMaxSize()) { | |
| // Map content behind the sheet | |
| MapView(modifier = Modifier.fillMaxSize()) | |
| // Non-modal bottom sheet with three states | |
| FlexibleBottomSheet( | |
| onDismissRequest = { /* handle dismiss */ }, | |
| sheetState = rememberFlexibleBottomSheetState( | |
| flexibleSheetSize = FlexibleSheetSize( | |
| fullyExpanded = 0.9f, | |
| intermediatelyExpanded = 0.5f, | |
| slightlyExpanded = 0.15f, | |
| ), | |
| isModal = false, | |
| skipSlightlyExpanded = false, | |
| skipHiddenState = true, | |
| ), | |
| onTargetChanges = { targetValue = it }, | |
| containerColor = Color.White, | |
| shape = RoundedCornerShape(topStart = 16.dp, topEnd = 16.dp), | |
| ) { | |
| PlaceContent(targetValue = targetValue) | |
| } | |
| } | |
| } | |
| @Composable | |
| private fun ColumnScope.PlaceContent(targetValue: FlexibleSheetValue) { | |
| // Header: always visible | |
| Row( | |
| modifier = Modifier.fillMaxWidth().padding(16.dp), | |
| verticalAlignment = Alignment.CenterVertically, | |
| ) { | |
| Column(modifier = Modifier.weight(1f)) { | |
| Text( | |
| text = "Central Park", | |
| fontSize = 18.sp, | |
| fontWeight = FontWeight.Bold, | |
| maxLines = 1, | |
| ) | |
| Text( | |
| text = "4.8 stars - Park", | |
| fontSize = 14.sp, | |
| color = Color.Gray, | |
| ) | |
| } | |
| } | |
| // Details: visible when intermediately or fully expanded | |
| if (targetValue != FlexibleSheetValue.SlightlyExpanded) { | |
| ActionButtons() | |
| Spacer(modifier = Modifier.height(8.dp)) | |
| } | |
| // Full content: scrollable list when fully expanded | |
| if (targetValue == FlexibleSheetValue.FullyExpanded) { | |
| LazyColumn(modifier = Modifier.fillMaxSize()) { | |
| item { PlacePhotos() } | |
| item { PlaceReviews() } | |
| item { PlaceInfo() } | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment