1 /* <lambda>null2 * Copyright (C) 2022 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 * http://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.android.settingslib.spa.widget.scaffold 18 19 import androidx.compose.foundation.layout.Column 20 import androidx.compose.foundation.layout.RowScope 21 import androidx.compose.foundation.layout.Spacer 22 import androidx.compose.foundation.layout.height 23 import androidx.compose.foundation.rememberScrollState 24 import androidx.compose.foundation.verticalScroll 25 import androidx.compose.material3.Scaffold 26 import androidx.compose.runtime.Composable 27 import androidx.compose.ui.Modifier 28 import androidx.compose.ui.tooling.preview.Preview 29 import com.android.settingslib.spa.framework.theme.SettingsTheme 30 import com.android.settingslib.spa.widget.preference.Preference 31 import com.android.settingslib.spa.widget.preference.PreferenceModel 32 33 /** 34 * A [Scaffold] which content is scrollable and wrapped in a [Column]. 35 * 36 * For example, this is for the pages with some preferences and is scrollable when the items out of 37 * the screen. 38 */ 39 @Composable 40 fun RegularScaffold( 41 title: String, 42 actions: @Composable RowScope.() -> Unit = {}, 43 content: @Composable () -> Unit, 44 ) { paddingValuesnull45 SettingsScaffold(title, actions) { paddingValues -> 46 Column(Modifier.verticalScroll(rememberScrollState())) { 47 Spacer(Modifier.height(paddingValues.calculateTopPadding())) 48 content() 49 Spacer(Modifier.height(paddingValues.calculateBottomPadding())) 50 } 51 } 52 } 53 54 @Preview 55 @Composable RegularScaffoldPreviewnull56private fun RegularScaffoldPreview() { 57 SettingsTheme { 58 RegularScaffold(title = "Display") { 59 Preference(object : PreferenceModel { 60 override val title = "Item 1" 61 }) 62 Preference(object : PreferenceModel { 63 override val title = "Item 2" 64 }) 65 } 66 } 67 } 68