1 /* 2 * 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.credentialmanager.common.ui 18 19 import androidx.compose.foundation.layout.Arrangement 20 import androidx.compose.foundation.layout.ColumnScope 21 import androidx.compose.foundation.layout.fillMaxWidth 22 import androidx.compose.foundation.layout.padding 23 import androidx.compose.foundation.layout.wrapContentHeight 24 import androidx.compose.foundation.lazy.LazyColumn 25 import androidx.compose.foundation.lazy.LazyListScope 26 import androidx.compose.material3.Card 27 import androidx.compose.material3.CardDefaults 28 import androidx.compose.runtime.Composable 29 import androidx.compose.ui.Alignment 30 import androidx.compose.ui.Modifier 31 import androidx.compose.ui.graphics.Color 32 import androidx.compose.ui.unit.dp 33 import com.android.credentialmanager.ui.theme.Shapes 34 import com.android.credentialmanager.ui.theme.LocalAndroidColorScheme 35 36 /** 37 * Container card for the whole sheet. 38 * 39 * Surface 1 color. No vertical padding. 24dp horizontal padding. 24dp bottom padding. 24dp top 40 * padding if [topAppBar] is not present, and none otherwise. 41 */ 42 @Composable 43 fun SheetContainerCard( 44 topAppBar: (@Composable () -> Unit)? = null, 45 modifier: Modifier = Modifier, 46 contentVerticalArrangement: Arrangement.Vertical = Arrangement.Top, 47 content: LazyListScope.() -> Unit, 48 ) { 49 Card( 50 modifier = modifier.fillMaxWidth().wrapContentHeight(), 51 border = null, 52 colors = CardDefaults.cardColors( 53 containerColor = LocalAndroidColorScheme.current.colorSurfaceBright, 54 ), 55 ) { 56 if (topAppBar != null) { 57 topAppBar() 58 } 59 LazyColumn( 60 modifier = Modifier.padding( 61 start = 24.dp, 62 end = 24.dp, 63 bottom = 18.dp, 64 top = if (topAppBar == null) 24.dp else 0.dp 65 ).fillMaxWidth().wrapContentHeight(), 66 horizontalAlignment = Alignment.CenterHorizontally, 67 content = content, 68 verticalArrangement = contentVerticalArrangement, 69 ) 70 } 71 } 72 73 /** 74 * Container card for the entries. 75 * 76 * Surface 3 color. No padding. Four rounded corner shape. 77 */ 78 @Composable 79 fun CredentialContainerCard( 80 modifier: Modifier = Modifier, 81 content: @Composable ColumnScope.() -> Unit, 82 ) { 83 Card( 84 modifier = modifier.fillMaxWidth().wrapContentHeight(), 85 shape = Shapes.medium, 86 border = null, 87 colors = CardDefaults.cardColors( 88 containerColor = Color.Transparent, 89 ), 90 content = content, 91 ) 92 }