Adds M3's BottomSheetScaffold wrapper to designsystem module (#711)
Needed for the share location screen.
This commit is contained in:
parent
9e8257cc4c
commit
911403dfdd
1 changed files with 73 additions and 0 deletions
|
|
@ -0,0 +1,73 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2023 New Vector Ltd
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package io.element.android.libraries.designsystem.theme.components
|
||||||
|
|
||||||
|
import androidx.compose.foundation.layout.ColumnScope
|
||||||
|
import androidx.compose.foundation.layout.PaddingValues
|
||||||
|
import androidx.compose.material3.BottomSheetDefaults
|
||||||
|
import androidx.compose.material3.BottomSheetScaffoldState
|
||||||
|
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||||
|
import androidx.compose.material3.MaterialTheme
|
||||||
|
import androidx.compose.material3.SnackbarHost
|
||||||
|
import androidx.compose.material3.SnackbarHostState
|
||||||
|
import androidx.compose.material3.contentColorFor
|
||||||
|
import androidx.compose.material3.rememberBottomSheetScaffoldState
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.graphics.Color
|
||||||
|
import androidx.compose.ui.graphics.Shape
|
||||||
|
import androidx.compose.ui.unit.Dp
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
@ExperimentalMaterial3Api
|
||||||
|
fun BottomSheetScaffold(
|
||||||
|
sheetContent: @Composable ColumnScope.() -> Unit,
|
||||||
|
modifier: Modifier = Modifier,
|
||||||
|
scaffoldState: BottomSheetScaffoldState = rememberBottomSheetScaffoldState(),
|
||||||
|
sheetPeekHeight: Dp = BottomSheetDefaults.SheetPeekHeight,
|
||||||
|
sheetShape: Shape = BottomSheetDefaults.ExpandedShape,
|
||||||
|
sheetContainerColor: Color = BottomSheetDefaults.ContainerColor,
|
||||||
|
sheetContentColor: Color = contentColorFor(sheetContainerColor),
|
||||||
|
sheetTonalElevation: Dp = BottomSheetDefaults.Elevation,
|
||||||
|
sheetShadowElevation: Dp = BottomSheetDefaults.Elevation,
|
||||||
|
sheetDragHandle: @Composable (() -> Unit)? = { BottomSheetDefaults.DragHandle() },
|
||||||
|
sheetSwipeEnabled: Boolean = true,
|
||||||
|
topBar: @Composable (() -> Unit)? = null,
|
||||||
|
snackbarHost: @Composable (SnackbarHostState) -> Unit = { SnackbarHost(it) },
|
||||||
|
containerColor: Color = MaterialTheme.colorScheme.surface,
|
||||||
|
contentColor: Color = contentColorFor(containerColor),
|
||||||
|
content: @Composable (PaddingValues) -> Unit
|
||||||
|
) {
|
||||||
|
androidx.compose.material3.BottomSheetScaffold(
|
||||||
|
sheetContent = sheetContent,
|
||||||
|
modifier = modifier,
|
||||||
|
scaffoldState = scaffoldState,
|
||||||
|
sheetPeekHeight = sheetPeekHeight,
|
||||||
|
sheetShape = sheetShape,
|
||||||
|
sheetContainerColor = sheetContainerColor,
|
||||||
|
sheetContentColor = sheetContentColor,
|
||||||
|
sheetTonalElevation = sheetTonalElevation,
|
||||||
|
sheetShadowElevation = sheetShadowElevation,
|
||||||
|
sheetDragHandle = sheetDragHandle,
|
||||||
|
sheetSwipeEnabled = sheetSwipeEnabled,
|
||||||
|
topBar = topBar,
|
||||||
|
snackbarHost = snackbarHost,
|
||||||
|
containerColor = containerColor,
|
||||||
|
contentColor = contentColor,
|
||||||
|
content = content
|
||||||
|
)
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue