You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
80 lines
3.3 KiB
80 lines
3.3 KiB
/* |
|
* Copyright 2020 The Android Open Source Project |
|
* |
|
* 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 |
|
* |
|
* https://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 com.example.jetsnack.ui.components |
|
|
|
import androidx.compose.foundation.layout.ColumnScope |
|
import androidx.compose.foundation.layout.PaddingValues |
|
import androidx.compose.material.DrawerDefaults |
|
import androidx.compose.material.ExperimentalMaterialApi |
|
import androidx.compose.material.FabPosition |
|
import androidx.compose.material.MaterialTheme |
|
import androidx.compose.material.Scaffold |
|
import androidx.compose.material.ScaffoldState |
|
import androidx.compose.material.SnackbarHost |
|
import androidx.compose.material.SnackbarHostState |
|
import androidx.compose.material.rememberScaffoldState |
|
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 |
|
import com.example.jetsnack.ui.theme.JetsnackTheme |
|
|
|
/** |
|
* Wrap Material [androidx.compose.material.Scaffold] and set [JetsnackTheme] colors. |
|
*/ |
|
@OptIn(ExperimentalMaterialApi::class) |
|
@Composable |
|
fun JetsnackScaffold( |
|
modifier: Modifier = Modifier, |
|
scaffoldState: ScaffoldState = rememberScaffoldState(), |
|
topBar: @Composable (() -> Unit) = {}, |
|
bottomBar: @Composable (() -> Unit) = {}, |
|
snackbarHost: @Composable (SnackbarHostState) -> Unit = { SnackbarHost(it) }, |
|
floatingActionButton: @Composable (() -> Unit) = {}, |
|
floatingActionButtonPosition: FabPosition = FabPosition.End, |
|
isFloatingActionButtonDocked: Boolean = false, |
|
drawerContent: @Composable (ColumnScope.() -> Unit)? = null, |
|
drawerShape: Shape = MaterialTheme.shapes.large, |
|
drawerElevation: Dp = DrawerDefaults.Elevation, |
|
drawerBackgroundColor: Color = JetsnackTheme.colors.uiBackground, |
|
drawerContentColor: Color = JetsnackTheme.colors.textSecondary, |
|
drawerScrimColor: Color = JetsnackTheme.colors.uiBorder, |
|
backgroundColor: Color = JetsnackTheme.colors.uiBackground, |
|
contentColor: Color = JetsnackTheme.colors.textSecondary, |
|
content: @Composable (PaddingValues) -> Unit |
|
) { |
|
Scaffold( |
|
modifier = modifier, |
|
scaffoldState = scaffoldState, |
|
topBar = topBar, |
|
bottomBar = bottomBar, |
|
snackbarHost = snackbarHost, |
|
floatingActionButton = floatingActionButton, |
|
floatingActionButtonPosition = floatingActionButtonPosition, |
|
isFloatingActionButtonDocked = isFloatingActionButtonDocked, |
|
drawerContent = drawerContent, |
|
drawerShape = drawerShape, |
|
drawerElevation = drawerElevation, |
|
drawerBackgroundColor = drawerBackgroundColor, |
|
drawerContentColor = drawerContentColor, |
|
drawerScrimColor = drawerScrimColor, |
|
backgroundColor = backgroundColor, |
|
contentColor = contentColor, |
|
content = content |
|
) |
|
}
|
|
|