1 /*
2 * Copyright 2021 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * https://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 package com.google.accompanist.navigation.material
18
19 import androidx.compose.material.ExperimentalMaterialApi
20 import androidx.compose.material.MaterialTheme
21 import androidx.compose.material.ModalBottomSheetDefaults
22 import androidx.compose.material.ModalBottomSheetLayout
23 import androidx.compose.material.contentColorFor
24 import androidx.compose.runtime.Composable
25 import androidx.compose.ui.Modifier
26 import androidx.compose.ui.graphics.Color
27 import androidx.compose.ui.graphics.Shape
28 import androidx.compose.ui.unit.Dp
29
30 /**
31 * Helper function to create a [ModalBottomSheetLayout] from a [BottomSheetNavigator].
32 *
33 * @see [ModalBottomSheetLayout]
34 */
35 @ExperimentalMaterialNavigationApi
36 @OptIn(ExperimentalMaterialApi::class)
37 @Composable
ModalBottomSheetLayoutnull38 public fun ModalBottomSheetLayout(
39 bottomSheetNavigator: BottomSheetNavigator,
40 modifier: Modifier = Modifier,
41 sheetShape: Shape = MaterialTheme.shapes.large,
42 sheetElevation: Dp = ModalBottomSheetDefaults.Elevation,
43 sheetBackgroundColor: Color = MaterialTheme.colors.surface,
44 sheetContentColor: Color = contentColorFor(sheetBackgroundColor),
45 scrimColor: Color = ModalBottomSheetDefaults.scrimColor,
46 content: @Composable () -> Unit
47 ) {
48 ModalBottomSheetLayout(
49 sheetState = bottomSheetNavigator.sheetState,
50 sheetContent = bottomSheetNavigator.sheetContent,
51 modifier = modifier,
52 sheetShape = sheetShape,
53 sheetElevation = sheetElevation,
54 sheetBackgroundColor = sheetBackgroundColor,
55 sheetContentColor = sheetContentColor,
56 scrimColor = scrimColor,
57 content = content
58 )
59 }
60