### Add FlexibleBottomSheet Dependency (Gradle) Source: https://github.com/skydoves/flexiblebottomsheet/blob/main/docs/getting-started.md Add the FlexibleBottomSheet dependency to your module's build.gradle file. Supports both Material 3 and Material Design. ```gradle dependencies { implementation("com.github.skydoves:flexible-bottomsheet-material3:$version") } ``` ```gradle dependencies { implementation("com.github.skydoves:flexible-bottomsheet-material:$version") } ``` -------------------------------- ### Basic FlexibleBottomSheet Composable Example (Kotlin) Source: https://context7.com/skydoves/flexiblebottomsheet/llms.txt Demonstrates the basic usage of the `FlexibleBottomSheet` composable. It shows how to configure its state, size, and appearance, including setting expansion ratios and container color. This example is suitable for standard bottom sheet implementations. ```kotlin @Composable fun BasicBottomSheetExample( showSheet: Boolean, onDismiss: () -> Unit ) { if (showSheet) { FlexibleBottomSheet( onDismissRequest = onDismiss, sheetState = rememberFlexibleBottomSheetState( flexibleSheetSize = FlexibleSheetSize( fullyExpanded = 0.9f, intermediatelyExpanded = 0.5f, slightlyExpanded = 0.15f, ), isModal = true, skipSlightlyExpanded = false, ), containerColor = Color.Black, shape = RoundedCornerShape(topStart = 16.dp, topEnd = 16.dp), ) { Column( modifier = Modifier .fillMaxWidth() .padding(16.dp), horizontalAlignment = Alignment.CenterHorizontally ) { Text( text = "Flexible Bottom Sheet", color = Color.White, fontSize = 20.sp, fontWeight = FontWeight.Bold ) Spacer(modifier = Modifier.height(16.dp)) Text( text = "Swipe up to expand, down to collapse", color = Color.White.copy(alpha = 0.7f) ) } } } } ``` -------------------------------- ### Combine WrapContent with Initial Value for FlexibleBottomSheet (Kotlin) Source: https://github.com/skydoves/flexiblebottomsheet/blob/main/docs/sheet-sizes.md This example demonstrates initializing a FlexibleBottomSheet to a specific wrap-content state using `initialValue` and `FlexibleSheetSize.WrapContent`. It ensures the sheet starts fully expanded and wraps its content. This requires the `FlexibleBottomSheet` composable, `rememberFlexibleBottomSheetState`, and relevant Material Design components. ```kotlin FlexibleBottomSheet( onDismissRequest = onDismissRequest, sheetState = rememberFlexibleBottomSheetState( initialValue = FlexibleSheetValue.FullyExpanded, flexibleSheetSize = FlexibleSheetSize( fullyExpanded = FlexibleSheetSize.WrapContent, intermediatelyExpanded = 0.5f, slightlyExpanded = 0.15f, ), ) ) { // Sheet starts fully expanded, wrapping its content Column(modifier = Modifier.padding(16.dp)) { Text("Welcome!", style = MaterialTheme.typography.headlineMedium) Spacer(modifier = Modifier.height(8.dp)) Text("This sheet wraps its content.") } } ``` -------------------------------- ### Handle Window Insets in FlexibleBottomSheet Source: https://github.com/skydoves/flexiblebottomsheet/blob/main/docs/customization.md Demonstrates how to manage system bars and window insets within the FlexibleBottomSheet using the `windowInsets` parameter. This example applies system bar insets to the content. ```kotlin FlexibleBottomSheet( onDismissRequest = onDismissRequest, windowInsets = WindowInsets.systemBars, ) { // content respects system bars } ``` -------------------------------- ### Add FlexibleBottomSheet Dependency (Kotlin Multiplatform) Source: https://github.com/skydoves/flexiblebottomsheet/blob/main/docs/getting-started.md Add the FlexibleBottomSheet dependency for Kotlin Multiplatform projects to your module's build.gradle.kts file. Supports both Material 3 and Material Design. ```kotlin sourceSets { val commonMain by getting { dependencies { implementation("com.github.skydoves:flexible-bottomsheet-material3:$version") } } } ``` ```kotlin sourceSets { val commonMain by getting { dependencies { implementation("com.github.skydoves:flexible-bottomsheet-material:$version") } } } ``` -------------------------------- ### Customize FlexibleBottomSheet Shape Source: https://github.com/skydoves/flexiblebottomsheet/blob/main/docs/customization.md Demonstrates how to customize the shape of the FlexibleBottomSheet using the `shape` parameter. This example applies a rounded corner shape to the top start and top end. ```kotlin FlexibleBottomSheet( onDismissRequest = onDismissRequest, shape = RoundedCornerShape(topStart = 24.dp, topEnd = 24.dp), ) { // content } ``` -------------------------------- ### Customize FlexibleBottomSheet Scrim Color (Modal) Source: https://github.com/skydoves/flexiblebottomsheet/blob/main/docs/customization.md Shows how to customize the scrim (overlay) color for modal FlexibleBottomSheet instances using the `scrimColor` parameter. The example sets a semi-transparent black scrim. ```kotlin FlexibleBottomSheet( onDismissRequest = onDismissRequest, scrimColor = Color.Black.copy(alpha = 0.5f), sheetState = rememberFlexibleBottomSheetState( isModal = true ), ) { // content } ``` -------------------------------- ### FlexibleBottomSheet: Dynamic Content by Monitoring Value Changes (Kotlin) Source: https://github.com/skydoves/flexiblebottomsheet/blob/main/README.md Illustrates how to dynamically compose bottom sheet content by observing sheet state changes. The example adjusts text size based on the current `FlexibleSheetValue` (FullyExpanded, IntermediatelyExpanded, etc.). ```kotlin var currentSheetTarget by remember { mutableStateOf(FlexibleSheetValue.IntermediatelyExpanded) } FlexibleBottomSheet( onDismissRequest = onDismissRequest, sheetState = rememberFlexibleBottomSheetState( skipSlightlyExpanded = false ), onTargetChanges = { sheetValue -> currentSheetTarget = sheetValue }, containerColor = Color.Black, ) { Text( modifier = Modifier .fillMaxWidth() .padding(8.dp), text = "This is Flexible Bottom Sheet", textAlign = TextAlign.Center, color = Color.White, fontSize = when (currentSheetTarget) { FlexibleSheetValue.FullyExpanded -> 28.sp FlexibleSheetValue.IntermediatelyExpanded -> 20.sp else -> 12.sp }, ) } ``` -------------------------------- ### Customize FlexibleBottomSheet Container Color Source: https://github.com/skydoves/flexiblebottomsheet/blob/main/docs/customization.md Illustrates how to change the background color of the FlexibleBottomSheet using the `containerColor` parameter. This example sets the container color to black. ```kotlin FlexibleBottomSheet( onDismissRequest = onDismissRequest, containerColor = Color.Black, ) { // content with white text for contrast } ``` -------------------------------- ### Dynamically Update Content Based on FlexibleBottomSheet State Source: https://github.com/skydoves/flexiblebottomsheet/blob/main/docs/customization.md Shows how to dynamically compose bottom sheet content by tracking state changes using the `onTargetChanges` callback. The example updates text size based on the `FlexibleSheetValue` (e.g., `FullyExpanded`, `IntermediatelyExpanded`). ```kotlin var currentSheetTarget by remember { mutableStateOf(FlexibleSheetValue.IntermediatelyExpanded) } FlexibleBottomSheet( onDismissRequest = onDismissRequest, sheetState = rememberFlexibleBottomSheetState( skipSlightlyExpanded = false ), onTargetChanges = { sheetValue -> currentSheetTarget = sheetValue }, containerColor = Color.Black, ) { Text( modifier = Modifier .fillMaxWidth() .padding(8.dp), text = "This is Flexible Bottom Sheet", textAlign = TextAlign.Center, color = Color.White, fontSize = when (currentSheetTarget) { FlexibleSheetValue.FullyExpanded -> 28.sp FlexibleSheetValue.IntermediatelyExpanded -> 20.sp else -> 12.sp }, ) } ``` -------------------------------- ### Set Initial Expanded State for Bottom Sheet Source: https://github.com/skydoves/flexiblebottomsheet/blob/main/README.md Demonstrates how to specify the initial expanded state of the FlexibleBottomSheet when it first appears. The `initialValue` parameter allows you to set the starting state (e.g., FullyExpanded, IntermediatelyExpanded) without animation. ```kotlin FlexibleBottomSheet( onDismissRequest = onDismissRequest, sheetState = rememberFlexibleBottomSheetState( initialValue = FlexibleSheetValue.FullyExpanded, skipSlightlyExpanded = false, ) ) { .. // Content of the bottom sheet } ``` -------------------------------- ### Basic Non-Modal Bottom Sheet Usage (Kotlin) Source: https://github.com/skydoves/flexiblebottomsheet/blob/main/docs/non-modal.md Demonstrates the fundamental setup for a non-modal bottom sheet. It requires setting `isModal` to `false` in the `rememberFlexibleBottomSheetState` function. The content of the sheet is provided within the lambda. ```kotlin FlexibleBottomSheet( onDismissRequest = onDismissRequest, sheetState = rememberFlexibleBottomSheetState( isModal = false, skipSlightlyExpanded = false, ) ) { // content } ``` -------------------------------- ### Manually Control Bottom Sheet Expansion and Hiding Source: https://github.com/skydoves/flexiblebottomsheet/blob/main/docs/sheet-state.md Provides an example of manually controlling the FlexibleBottomSheet's state (expanding or hiding) using coroutines and the `FlexibleBottomSheetState` methods. It demonstrates switching between different expanded states. ```kotlin val scope = rememberCoroutineScope() val sheetState = rememberFlexibleBottomSheetState( flexibleSheetSize = FlexibleSheetSize(fullyExpanded = 0.9f), isModal = true, skipSlightlyExpanded = false, ) FlexibleBottomSheet( sheetState = sheetState, containerColor = Color.Black, onDismissRequest = onDismissRequest ) { Button( modifier = Modifier.align(Alignment.CenterHorizontally), onClick = { scope.launch { when (sheetState.swipeableState.currentValue) { FlexibleSheetValue.SlightlyExpanded -> sheetState.intermediatelyExpand() FlexibleSheetValue.IntermediatelyExpanded -> sheetState.fullyExpand() else -> sheetState.hide() } } }, ) { Text(text = "Expand Or Hide") } } ``` -------------------------------- ### Customize or Hide FlexibleBottomSheet Drag Handle Source: https://github.com/skydoves/flexiblebottomsheet/blob/main/docs/customization.md Provides examples for customizing the drag handle of the FlexibleBottomSheet by providing a custom composable to the `dragHandle` parameter. It also shows how to hide the drag handle by setting `dragHandle` to `null`. ```kotlin FlexibleBottomSheet( onDismissRequest = onDismissRequest, dragHandle = { // Custom drag handle Box( modifier = Modifier .padding(vertical = 8.dp) .width(40.dp) .height(4.dp) .background(Color.Gray, RoundedCornerShape(2.dp)) ) }, ) { // content } ``` ```kotlin FlexibleBottomSheet( onDismissRequest = onDismissRequest, dragHandle = null, ) { // content } ``` -------------------------------- ### Set Initial Expanded State for Bottom Sheet Source: https://github.com/skydoves/flexiblebottomsheet/blob/main/docs/sheet-state.md Illustrates how to set the initial expanded state of the FlexibleBottomSheet when it first appears using the `initialValue` parameter. This example sets the initial state to FullyExpanded. ```kotlin FlexibleBottomSheet( onDismissRequest = onDismissRequest, sheetState = rememberFlexibleBottomSheetState( initialValue = FlexibleSheetValue.FullyExpanded, skipSlightlyExpanded = false, ) ) { // content } ``` -------------------------------- ### Non-Modal Bottom Sheet with Initial State (Kotlin) Source: https://github.com/skydoves/flexiblebottomsheet/blob/main/docs/non-modal.md Demonstrates how to set the initial expanded state for a non-modal bottom sheet. By specifying `initialValue` in `rememberFlexibleBottomSheetState`, the sheet will start in the desired state (e.g., `FlexibleSheetValue.SlightlyExpanded`). ```kotlin FlexibleBottomSheet( onDismissRequest = onDismissRequest, sheetState = rememberFlexibleBottomSheetState( isModal = false, initialValue = FlexibleSheetValue.SlightlyExpanded, skipSlightlyExpanded = false, ) ) { // Sheet starts at slightly expanded state } ``` -------------------------------- ### Configure FlexibleBottomSheet Sizes Source: https://context7.com/skydoves/flexiblebottomsheet/llms.txt Demonstrates how to define different height ratios for FlexibleBottomSheet expansion states using FlexibleSheetSize. Supports fixed ratios or wrap content behavior. Requires Jetpack Compose and FlexibleBottomSheet library. ```kotlin import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.padding import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp import com.skydoves.flexiblebottomsheet.FlexibleBottomSheet import com.skydoves.flexiblebottomsheet.foundation.rememberFlexibleBottomSheetState import com.skydoves.flexiblebottomsheet.foundation.sheet.FlexibleSheetSize @Composable fun SheetSizeExamples() { // Fixed ratio sizes val fixedSizeState = rememberFlexibleBottomSheetState( flexibleSheetSize = FlexibleSheetSize( fullyExpanded = 0.85f, // 85% of screen intermediatelyExpanded = 0.45f, // 45% of screen slightlyExpanded = 0.15f, // 15% of screen ), skipSlightlyExpanded = false, ) // Wrap content mode - sheet sizes itself based on content val wrapContentState = rememberFlexibleBottomSheetState( flexibleSheetSize = FlexibleSheetSize( fullyExpanded = FlexibleSheetSize.WrapContent, // Wraps content intermediatelyExpanded = 0.5f, slightlyExpanded = 0.15f, ), ) FlexibleBottomSheet( onDismissRequest = {}, sheetState = wrapContentState, ) { // Sheet will automatically size to fit this content Column(modifier = Modifier.padding(16.dp)) { Text("Item 1", fontSize = 18.sp) Text("Item 2", fontSize = 18.sp) Text("Item 3", fontSize = 18.sp) } } } ``` -------------------------------- ### Format Code with Spotless Source: https://github.com/skydoves/flexiblebottomsheet/blob/main/CONTRIBUTING.md Ensures code is properly formatted according to project standards by running the Spotless Gradle task. This is a prerequisite for submitting changes. ```gradle ./gradlew spotlessApply ``` -------------------------------- ### Initialize FlexibleBottomSheetState with Custom Sizes Source: https://github.com/skydoves/flexiblebottomsheet/blob/main/docs/sheet-state.md Demonstrates how to initialize FlexibleBottomSheetState with custom sizes for fully, intermediately, and slightly expanded states. It also shows how to control modal behavior and nested scrolling. ```kotlin FlexibleBottomSheet( onDismissRequest = onDismissRequest, sheetState = rememberFlexibleBottomSheetState( skipSlightlyExpanded = false, skipIntermediatelyExpanded = false, isModal = true, allowNestedScroll = true, flexibleSheetSize = FlexibleSheetSize( fullyExpanded = 1.0f, intermediatelyExpanded = 0.5f, slightlyExpanded = 0.25f ) ) ) { // content } ``` -------------------------------- ### Initialize FlexibleBottomSheetState with Custom Sizes Source: https://github.com/skydoves/flexiblebottomsheet/blob/main/README.md Demonstrates how to initialize FlexibleBottomSheetState with custom sizes for fully, intermediately, and slightly expanded states. This allows fine-grained control over the sheet's dimensions at different expansion levels. ```kotlin FlexibleBottomSheet( onDismissRequest = onDismissRequest, sheetState = rememberFlexibleBottomSheetState( skipSlightlyExpanded = false, skipIntermediatelyExpanded = false, isModal = true, allowNestedScroll = true, flexibleSheetSize = FlexibleSheetSize( fullyExpanded = 1.0f, intermediatelyExpanded = 0.5f, slightlyExpanded = 0.25f ) ) ) { .. // Content of the bottom sheet } ``` -------------------------------- ### Dump Binary API for Compatibility Check Source: https://github.com/skydoves/flexiblebottomsheet/blob/main/CONTRIBUTING.md Generates a dump of the public binary API of the library to ensure that changes do not introduce binary incompatibilities. This is checked using the apiDump Gradle task. ```gradle ./gradlew apiDump ``` -------------------------------- ### Configure FlexibleBottomSheetState (Kotlin) Source: https://context7.com/skydoves/flexiblebottomsheet/llms.txt Illustrates how to configure `rememberFlexibleBottomSheetState` for advanced control over the bottom sheet's behavior. This includes managing skip states, initial expansion, modal presentation, nested scrolling, sheet sizes, and confirming state changes. ```kotlin @Composable fun SheetStateConfigurationExample() { val sheetState = rememberFlexibleBottomSheetState( // Skip settings - control which states are available skipHiddenState = false, // Allow sheet to be hidden skipSlightlyExpanded = false, // Enable slightly expanded state skipIntermediatelyExpanded = false, // Enable intermediately expanded state // Initial state when sheet first appears initialValue = FlexibleSheetValue.IntermediatelyExpanded, // Modal vs non-modal behavior isModal = true, // true = shows scrim, blocks interaction // Nested scroll support for LazyColumn, etc. allowNestedScroll = true, // Sheet sizes as ratios of screen height flexibleSheetSize = FlexibleSheetSize( fullyExpanded = 0.9f, // 90% of screen height intermediatelyExpanded = 0.5f, // 50% of screen height slightlyExpanded = 0.25f, // 25% of screen height ), // Callback to confirm or veto state changes confirmValueChange = { newValue -> // Return false to prevent certain state changes newValue != FlexibleSheetValue.Hidden // Prevent dismissal } ) FlexibleBottomSheet( onDismissRequest = { /* won't be called due to confirmValueChange */ }, sheetState = sheetState, ) { Text("Sheet content here") } } ``` -------------------------------- ### Programmatically Control FlexibleBottomSheet State Source: https://context7.com/skydoves/flexiblebottomsheet/llms.txt Illustrates how to control the FlexibleBottomSheet's state (expand, collapse, show, hide) programmatically using coroutines and FlexibleSheetState methods. Requires Jetpack Compose and FlexibleBottomSheet library. ```kotlin import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.material3.Button import androidx.compose.material3.ButtonDefaults import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.unit.dp import com.skydoves.flexiblebottomsheet.FlexibleBottomSheet import com.skydoves.flexiblebottomsheet.foundation.rememberFlexibleBottomSheetState import com.skydoves.flexiblebottomsheet.foundation.sheet.FlexibleSheetSize import kotlinx.coroutines.launch @Composable fun ProgrammaticControlExample() { val scope = rememberCoroutineScope() val sheetState = rememberFlexibleBottomSheetState( flexibleSheetSize = FlexibleSheetSize(fullyExpanded = 0.9f), isModal = true, skipSlightlyExpanded = false, ) FlexibleBottomSheet( sheetState = sheetState, onDismissRequest = { scope.launch { sheetState.hide() } }, containerColor = MaterialTheme.colorScheme.surface, ) { Column( modifier = Modifier .fillMaxWidth() .padding(16.dp), horizontalAlignment = Alignment.CenterHorizontally ) { // Display current state Text( text = "Current: ${sheetState.currentValue}", style = MaterialTheme.typography.titleMedium ) Spacer(modifier = Modifier.height(16.dp)) // Control buttons Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) { Button(onClick = { scope.launch { sheetState.slightlyExpand() } }) { Text("Slightly") } Button(onClick = { scope.launch { sheetState.intermediatelyExpand() } }) { Text("Intermediate") } Button(onClick = { scope.launch { sheetState.fullyExpand() } }) { Text("Fully") } } Spacer(modifier = Modifier.height(8.dp)) Button( onClick = { scope.launch { sheetState.hide() } }, colors = ButtonDefaults.buttonColors( containerColor = MaterialTheme.colorScheme.error ) ) { Text("Hide Sheet") } } } } ``` -------------------------------- ### Custom Styling and Drag Handle for FlexibleBottomSheet (Kotlin) Source: https://context7.com/skydoves/flexiblebottomsheet/llms.txt Illustrates how to customize the appearance of FlexibleBottomSheet, including its shape, container and content colors, scrim color for modal sheets, tonal elevation, and the drag handle. It also shows how to hide the drag handle entirely. ```kotlin import androidx.compose.foundation.background import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.WindowInsets import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.systemBars import androidx.compose.foundation.layout.width import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp import com.skydoves.flexiblebottomsheet.FlexibleBottomSheet import com.skydoves.flexiblebottomsheet.foundation.rememberFlexibleBottomSheetState @Composable fun CustomStyledBottomSheet() { FlexibleBottomSheet( onDismissRequest = {}, sheetState = rememberFlexibleBottomSheetState(isModal = true), // Custom shape shape = RoundedCornerShape(topStart = 24.dp, topEnd = 24.dp), // Custom colors containerColor = Color(0xFF1E1E2E), contentColor = Color.White, // Custom scrim for modal sheets scrimColor = Color.Black.copy(alpha = 0.6f), // Tonal elevation tonalElevation = 8.dp, // Custom drag handle dragHandle = { Box( modifier = Modifier .padding(vertical = 12.dp) .width(48.dp) .height(4.dp) .background( color = Color.White.copy(alpha = 0.4f), shape = RoundedCornerShape(2.dp) ) ) }, // Window insets handling windowInsets = WindowInsets.systemBars, ) { Column( modifier = Modifier .fillMaxWidth() .padding(24.dp) ) { Text( text = "Custom Styled Sheet", fontSize = 24.sp, fontWeight = FontWeight.Bold ) Spacer(modifier = Modifier.height(16.dp)) Text("With custom colors, shape, and drag handle") } } } // Hide the drag handle entirely @Composable fun NoDragHandleExample() { FlexibleBottomSheet( onDismissRequest = {}, dragHandle = null, // No drag handle ) { Text("Sheet without drag handle", modifier = Modifier.padding(16.dp)) } } ``` -------------------------------- ### Implement FlexibleBottomSheet with Segmented Sizing (Kotlin) Source: https://github.com/skydoves/flexiblebottomsheet/blob/main/docs/index.md This code snippet demonstrates how to implement a FlexibleBottomSheet in Kotlin. It configures segmented sizing with fully, intermediately, and slightly expanded states, sets the sheet to be modal, and skips the slightly expanded state. It also defines custom container color and content for the bottom sheet. ```kotlin FlexibleBottomSheet( onDismissRequest = onDismissRequest, sheetState = rememberFlexibleBottomSheetState( flexibleSheetSize = FlexibleSheetSize( fullyExpanded = 0.9f, intermediatelyExpanded = 0.5f, slightlyExpanded = 0.15f, ), isModal = true, skipSlightlyExpanded = false, ), containerColor = Color.Black, ) { Text( modifier = Modifier .fillMaxWidth() .padding(8.dp), text = "This is Flexible Bottom Sheet", textAlign = TextAlign.Center, color = Color.White, ) } ``` -------------------------------- ### Use WrapContent for Multiple FlexibleBottomSheet States (Kotlin) Source: https://github.com/skydoves/flexiblebottomsheet/blob/main/docs/sheet-sizes.md This snippet illustrates using `FlexibleSheetSize.WrapContent` for multiple expansion states of the FlexibleBottomSheet. It also shows how to disable skipping the slightly expanded state. This configuration allows the sheet to adapt its height to content for different states, provided the content height is manageable. Requires `FlexibleBottomSheet` and `rememberFlexibleBottomSheetState`. ```kotlin FlexibleBottomSheet( onDismissRequest = onDismissRequest, sheetState = rememberFlexibleBottomSheetState( flexibleSheetSize = FlexibleSheetSize( fullyExpanded = FlexibleSheetSize.WrapContent, intermediatelyExpanded = FlexibleSheetSize.WrapContent, slightlyExpanded = 0.15f, ), skipSlightlyExpanded = false, ) ) { // content } ``` -------------------------------- ### Customize FlexibleBottomSheet Expanded Sizes with Ratios (Kotlin) Source: https://github.com/skydoves/flexiblebottomsheet/blob/main/docs/sheet-sizes.md This snippet demonstrates how to customize the expanded sizes of a FlexibleBottomSheet using `FlexibleSheetSize` with ratio values. The ratios are multiplied by the available screen height, excluding system bars. This requires the `FlexibleBottomSheet` composable and `rememberFlexibleBottomSheetState`. ```kotlin FlexibleBottomSheet( onDismissRequest = onDismissRequest, sheetState = rememberFlexibleBottomSheetState( flexibleSheetSize = FlexibleSheetSize( fullyExpanded = 0.85f, intermediatelyExpanded = 0.45f, slightlyExpanded = 0.15f, ), ) ) { // content } ``` -------------------------------- ### Configure Skippable Bottom Sheet Expansion States Source: https://github.com/skydoves/flexiblebottomsheet/blob/main/README.md Illustrates how to configure which expansion states of the FlexibleBottomSheet can be skipped. By setting `skipSlightlyExpanded` and `skipIntermediatelyExpanded` to `true` or `false`, you can control the available states for the user. ```kotlin FlexibleBottomSheet( onDismissRequest = onDismissRequest, sheetState = rememberFlexibleBottomSheetState( skipSlightlyExpanded = false, skipIntermediatelyExpanded = false ) ) { .. // Content of the bottom sheet } ``` -------------------------------- ### Make FlexibleBottomSheet Wrap Content Height (Kotlin) Source: https://github.com/skydoves/flexiblebottomsheet/blob/main/docs/sheet-sizes.md This code shows how to configure a FlexibleBottomSheet to adjust its size based on its content height using `FlexibleSheetSize.WrapContent`. This is useful when the sheet should automatically fit its content, but it's best used with content of known, static height. It requires the `FlexibleBottomSheet` composable and `rememberFlexibleBottomSheetState`. ```kotlin FlexibleBottomSheet( onDismissRequest = onDismissRequest, sheetState = rememberFlexibleBottomSheetState( flexibleSheetSize = FlexibleSheetSize( fullyExpanded = FlexibleSheetSize.WrapContent, intermediatelyExpanded = 0.5f, slightlyExpanded = 0.15f, ), ) ) { // The sheet will wrap this content when fully expanded Column { Text("Item 1") Text("Item 2") Text("Item 3") } } ``` -------------------------------- ### Customize FlexibleBottomSheet Expanded Sizes Source: https://github.com/skydoves/flexiblebottomsheet/blob/main/README.md Explains how to customize the expanded sizes of the FlexibleBottomSheet content based on its states. The `FlexibleSheetSize` composable allows you to define ratios for fully, intermediately, and slightly expanded states, calculated against the maximum display height excluding system bars. ```kotlin FlexibleBottomSheet( onDismissRequest = onDismissRequest, sheetState = rememberFlexibleBottomSheetState( flexibleSheetSize = FlexibleSheetSize( fullyExpanded = 0.85f, intermediatelyExpanded = 0.45f, slightlyExpanded = 0.15f, ), ) ) { .. // Content of the bottom sheet } ``` -------------------------------- ### Google Maps Style Non-Modal Bottom Sheet (Kotlin) Source: https://github.com/skydoves/flexiblebottomsheet/blob/main/docs/non-modal.md Illustrates a common pattern for non-modal sheets, mimicking the Google Maps UI. This involves placing the bottom sheet within a `Box` alongside other content (like a `MapView`) and configuring the `FlexibleBottomSheetState` with specific expansion sizes. ```kotlin Box(modifier = Modifier.fillMaxSize()) { // Your map or main content MapView( modifier = Modifier.fillMaxSize() ) // Non-modal bottom sheet FlexibleBottomSheet( onDismissRequest = { /* handle dismiss */ }, sheetState = rememberFlexibleBottomSheetState( isModal = false, skipSlightlyExpanded = false, flexibleSheetSize = FlexibleSheetSize( fullyExpanded = 0.9f, intermediatelyExpanded = 0.5f, slightlyExpanded = 0.15f, ), ), ) { // Location details, search results, etc. LocationDetailsContent() } } ``` -------------------------------- ### Add FlexibleBottomSheet Dependency (Gradle) Source: https://github.com/skydoves/flexiblebottomsheet/blob/main/README.md Instructions for adding the FlexibleBottomSheet dependency to your Android module's build.gradle file. It supports both Compose Material and Material 3. ```gradle dependencies { // compose material implementation("com.github.skydoves:flexible-bottomsheet-material:0.2.0") // compose material3 implementation("com.github.skydoves:flexible-bottomsheet-material3:0.2.0") } ``` -------------------------------- ### Enable Intermediate and Slight Expanded States Source: https://github.com/skydoves/flexiblebottomsheet/blob/main/docs/sheet-state.md Shows how to enable the intermediately and slightly expanded states for the FlexibleBottomSheet by setting `skipSlightlyExpanded` and `skipIntermediatelyExpanded` to false. ```kotlin FlexibleBottomSheet( onDismissRequest = onDismissRequest, sheetState = rememberFlexibleBottomSheetState( skipSlightlyExpanded = false, // Enable slightly expanded skipIntermediatelyExpanded = false // Enable intermediately expanded ) ) { // content } ``` -------------------------------- ### Add FlexibleBottomSheet Dependency (Kotlin) Source: https://context7.com/skydoves/flexiblebottomsheet/llms.txt Adds the FlexibleBottomSheet library dependency to your module's build.gradle file for Material 3 or legacy Material UI. This is the primary step for integrating the library into your project. ```kotlin dependencies { // For Material 3 implementation("com.github.skydoves:flexible-bottomsheet-material3:0.2.0") // Or for Material (legacy) implementation("com.github.skydoves:flexible-bottomsheet-material:0.2.0") } ``` ```kotlin sourceSets { val commonMain by getting { dependencies { implementation("com.github.skydoves:flexible-bottomsheet-material3:0.2.0") } } } ``` -------------------------------- ### Create Non-Modal Bottom Sheet Source: https://context7.com/skydoves/flexiblebottomsheet/llms.txt Demonstrates creating a non-modal bottom sheet that allows interaction with the content behind it. This is achieved by setting `isModal = false` in `rememberFlexibleBottomSheetState`. The background content remains interactive, and touch events can pass through the sheet when it's not fully obscuring the content. ```kotlin import androidx.compose.foundation.background import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.* import androidx.compose.material3.* import androidx.compose.runtime.* import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp import com.skydoves.flexiblebottomsheet.* @Composable fun NonModalBottomSheetExample() { Box(modifier = Modifier.fillMaxSize()) { // Background content - remains interactive Column( modifier = Modifier .fillMaxSize() .padding(16.dp) ) { Text("Main Content", style = MaterialTheme.typography.headlineMedium) Spacer(modifier = Modifier.height(16.dp)) Button(onClick = { /* This button is clickable! */ }) { Text("Interactive Button Behind Sheet") } // Map or other interactive content would go here Box( modifier = Modifier .fillMaxWidth() .weight(1f) .background(Color.LightGray) .clickable { /* Map interactions */ }, contentAlignment = Alignment.Center ) { Text("Interactive Map Area") } } // Non-modal bottom sheet - no scrim, touch passthrough enabled FlexibleBottomSheet( onDismissRequest = { /* Handle dismiss */ }, sheetState = rememberFlexibleBottomSheetState( isModal = false, // Key: enables non-modal behavior skipSlightlyExpanded = false, skipHiddenState = true, // Keep sheet always visible initialValue = FlexibleSheetValue.SlightlyExpanded, flexibleSheetSize = FlexibleSheetSize( fullyExpanded = 0.9f, intermediatelyExpanded = 0.5f, slightlyExpanded = 0.15f, ), ), containerColor = MaterialTheme.colorScheme.surface, ) { Column(modifier = Modifier.padding(16.dp)) { Text( text = "Location Details", style = MaterialTheme.typography.titleLarge ) Text("123 Main Street") Text("Rating: 4.5 stars") } } } } ``` -------------------------------- ### Monitor Bottom Sheet State Changes with onTargetChanges Source: https://context7.com/skydoves/flexiblebottomsheet/llms.txt Shows how to track the state changes of the FlexibleBottomSheet using the `onTargetChanges` callback. This allows for dynamic content updates or triggering side effects based on the sheet's current state (e.g., FullyExpanded, IntermediatelyExpanded). The `currentTarget` state variable is updated with the new sheet value. ```kotlin import androidx.compose.foundation.layout.* import androidx.compose.material3.* import androidx.compose.runtime.* import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp import com.skydoves.flexiblebottomsheet.* @Composable fun StateMonitoringExample() { var currentTarget by remember { mutableStateOf(FlexibleSheetValue.IntermediatelyExpanded) } FlexibleBottomSheet( onDismissRequest = { /* Handle dismiss */ }, sheetState = rememberFlexibleBottomSheetState( skipSlightlyExpanded = false ), onTargetChanges = { currentTarget = it // Trigger analytics, load data, etc. when (it) { FlexibleSheetValue.FullyExpanded -> { // Load full content } FlexibleSheetValue.IntermediatelyExpanded -> { // Load preview content } FlexibleSheetValue.SlightlyExpanded -> { // Show minimal info } FlexibleSheetValue.Hidden -> { // Cleanup } } }, containerColor = Color.Black, ) { // Dynamic content based on current state Text( modifier = Modifier .fillMaxWidth() .padding(16.dp), text = when (currentTarget) { FlexibleSheetValue.FullyExpanded -> "Full Details View" FlexibleSheetValue.IntermediatelyExpanded -> "Preview Mode" FlexibleSheetValue.SlightlyExpanded -> "Peek" FlexibleSheetValue.Hidden -> "" }, textAlign = TextAlign.Center, color = Color.White, fontSize = when (currentTarget) { FlexibleSheetValue.FullyExpanded -> 28.sp FlexibleSheetValue.IntermediatelyExpanded -> 20.sp else -> 14.sp }, ) } } ``` -------------------------------- ### Manually Control Bottom Sheet Expansion and Hiding Source: https://github.com/skydoves/flexiblebottomsheet/blob/main/README.md Shows how to manually expand or hide the FlexibleBottomSheet using its state. It utilizes a CoroutineScope to launch state change operations based on the current sheet value, allowing for programmatic control over the sheet's visibility. ```kotlin val scope = rememberCoroutineScope() val sheetState = rememberFlexibleBottomSheetState( flexibleSheetSize = FlexibleSheetSize(fullyExpanded = 0.9f), isModal = true, skipSlightlyExpanded = false, ) FlexibleBottomSheet( sheetState = sheetState, containerColor = Color.Black, onDismissRequest = onDismissRequest ) { Button( modifier = Modifier.align(Alignment.CenterHorizontally), onClick = { scope.launch { when (sheetState.swipeableState.currentValue) { FlexibleSheetValue.SlightlyExpanded -> sheetState.intermediatelyExpand() FlexibleSheetValue.IntermediatelyExpanded -> sheetState.fullyExpand() else -> sheetState.hide() } } }, ) { Text(text = "Expand Or Hide") } } ``` -------------------------------- ### FlexibleBottomSheet: Non-Modal Behavior (Kotlin) Source: https://github.com/skydoves/flexiblebottomsheet/blob/main/README.md Shows how to enable interaction outside the bottom sheet while it's displayed by setting the `isModal` property to `false`. This mimics the behavior of Google Maps style bottom sheets. ```kotlin FlexibleBottomSheet( onDismissRequest = onDismissRequest, sheetState = rememberFlexibleBottomSheetState( isModal = false, skipSlightlyExpanded = false, ) ) { .. // Content of the bottom sheet } ``` -------------------------------- ### FlexibleSheetValue Enum and State Checking (Kotlin) Source: https://context7.com/skydoves/flexiblebottomsheet/llms.txt Explains the FlexibleSheetValue enum, which defines the possible states of a FlexibleBottomSheet (Hidden, FullyExpanded, IntermediatelyExpanded, SlightlyExpanded). It also shows how to check the current and target values, visibility, and available states of the sheet. ```kotlin // FlexibleSheetValue defines the expansion states: enum class FlexibleSheetValue { Hidden, // Sheet is not visible FullyExpanded, // Sheet is at maximum height IntermediatelyExpanded, // Sheet is at intermediate height SlightlyExpanded, // Sheet is at minimum visible height } // Usage in state checking and control: import androidx.compose.material3.Text import androidx.compose.runtime.Composable import com.skydoves.flexiblebottomsheet.FlexibleBottomSheet import com.skydoves.flexiblebottomsheet.foundation.rememberFlexibleBottomSheetState @Composable fun SheetValueExample() { val sheetState = rememberFlexibleBottomSheetState( skipSlightlyExpanded = false ) // Check current and target values val currentValue: FlexibleSheetValue = sheetState.currentValue val targetValue: FlexibleSheetValue = sheetState.targetValue val isVisible: Boolean = sheetState.isVisible // Check if specific states are available val hasFullyExpanded: Boolean = sheetState.hasFullyExpandedState val hasIntermediate: Boolean = sheetState.hasIntermediatelyExpandedState val hasSlightly: Boolean = sheetState.hasSlightlyExpandedState FlexibleBottomSheet( onDismissRequest = {}, sheetState = sheetState, ) { Text("Current: $currentValue, Target: $targetValue") } } ``` -------------------------------- ### Nested Scrolling with LazyColumn in FlexibleBottomSheet (Kotlin) Source: https://context7.com/skydoves/flexiblebottomsheet/llms.txt Demonstrates how to enable and disable nested scrolling for scrollable content like LazyColumn within a FlexibleBottomSheet. Nested scrolling allows the sheet to scroll its content independently when dragged. ```kotlin import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.material3.Card import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.unit.dp import com.skydoves.flexiblebottomsheet.FlexibleBottomSheet import com.skydoves.flexiblebottomsheet.foundation.rememberFlexibleBottomSheetState import com.skydoves.flexiblebottomsheet.foundation.sheet.FlexibleSheetSize @Composable fun NestedScrollExample() { FlexibleBottomSheet( onDismissRequest = {}, sheetState = rememberFlexibleBottomSheetState( allowNestedScroll = true, // Enable nested scroll (default) flexibleSheetSize = FlexibleSheetSize( fullyExpanded = 0.9f, intermediatelyExpanded = 0.5f, slightlyExpanded = 0.2f, ), skipSlightlyExpanded = false, ), ) { LazyColumn( modifier = Modifier.fillMaxWidth(), contentPadding = PaddingValues(16.dp), verticalArrangement = Arrangement.spacedBy(8.dp) ) { items(50) { Card( modifier = Modifier.fillMaxWidth(), ) { Text( text = "Item $it", modifier = Modifier.padding(16.dp) ) } } } } } // To disable nested scrolling: @Composable fun DisabledNestedScrollExample() { FlexibleBottomSheet( onDismissRequest = {}, sheetState = rememberFlexibleBottomSheetState( allowNestedScroll = false, // Disable nested scroll ), ) { // Content scrolls independently of sheet drag LazyColumn { items(100) { Text("Item $it", modifier = Modifier.padding(16.dp)) } } } } ``` -------------------------------- ### Preventing Dismissal of Non-Modal Bottom Sheet (Kotlin) Source: https://github.com/skydoves/flexiblebottomsheet/blob/main/docs/non-modal.md Shows how to create a persistent non-modal bottom sheet that cannot be dismissed by the user. This is achieved by setting `skipHiddenState` to `true` in the `rememberFlexibleBottomSheetState` function, ensuring `onDismissRequest` is never called. ```kotlin FlexibleBottomSheet( onDismissRequest = { /* won't be called */ }, sheetState = rememberFlexibleBottomSheetState( isModal = false, skipHiddenState = true, // Sheet cannot be dismissed skipSlightlyExpanded = false, ) ) { // Persistent panel content } ``` -------------------------------- ### Disable Nested Scroll in FlexibleBottomSheet Source: https://github.com/skydoves/flexiblebottomsheet/blob/main/docs/customization.md Demonstrates how to disable nested scrolling in FlexibleBottomSheet by setting the `allowNestedScroll` parameter to `false`. This is useful when integrating with scrollable components like LazyColumn to prevent conflicting scroll behaviors. ```kotlin FlexibleBottomSheet( onDismissRequest = onDismissRequest, sheetState = rememberFlexibleBottomSheetState( allowNestedScroll = false ), ) { LazyColumn { items(100) { Text("Item $it") } } } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.