A state object that can be used to control the resizing behavior of a pane.
/**
* This sample shows how to create a [SupportingPaneScaffold] that shows the extra pane as a bottom
* sheet when it's a single-pane layout and the extra pane is the current destination.
*
* @see levitateAsDialogSample for more usage samples of [AdaptStrategy.Levitate].
*/
@OptIn(ExperimentalMaterial3AdaptiveApi::class, ExperimentalMaterial3Api::class)
@Preview
@Composable
fun SupportingPaneScaffoldSampleWithExtraPaneLevitatedAsBottomSheet() {
val coroutineScope = rememberCoroutineScope()
val scaffoldNavigator = levitateAsBottomSheetSample<NavItemData>()
val extraItems = listOf("Extra content")
val selectedItem = NavItemData(index = 0, showExtra = true)
SupportingPaneScaffold(
directive = scaffoldNavigator.scaffoldDirective,
scaffoldState = scaffoldNavigator.scaffoldState,
mainPane = {
AnimatedPane {
MainPaneContent(
scaffoldNavigator = scaffoldNavigator,
hasExtraPane = true,
coroutineScope = coroutineScope,
)
}
},
supportingPane = {
AnimatedPane(modifier = Modifier.preferredWidth(200.dp)) { SupportingPaneContent() }
},
extraPane = {
AnimatedPane(
modifier =
Modifier.preferredWidth(1f)
.preferredHeight(0.5f)
.background(MaterialTheme.colorScheme.surface),
dragToResizeHandle = { BottomSheetDefaults.DragHandle() },
) {
ExtraPaneContent(
extraItems = extraItems,
selectedItem = selectedItem,
scaffoldNavigator = scaffoldNavigator,
coroutineScope = coroutineScope,
)
}
},
paneExpansionState =
rememberPaneExpansionState(
keyProvider = scaffoldNavigator.scaffoldValue,
anchors = PaneExpansionAnchors,
),
paneExpansionDragHandle = { state -> PaneExpansionDragHandleSample(state) },
)
}