1 /*
2  * Copyright (C) 2023 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.Row
20 import androidx.compose.foundation.layout.fillMaxWidth
21 import androidx.compose.foundation.layout.padding
22 import androidx.compose.foundation.layout.wrapContentHeight
23 import androidx.compose.runtime.Composable
24 import androidx.compose.ui.Modifier
25 import androidx.compose.ui.graphics.Color
26 import androidx.compose.ui.unit.dp
27 import com.android.credentialmanager.ui.theme.LocalAndroidColorScheme
28 
29 @Composable
30 fun CredentialListSectionHeader(text: String, isFirstSection: Boolean) {
31     InternalSectionHeader(
32         text = text,
33         color = LocalAndroidColorScheme.current.colorOnSurfaceVariant,
34         applyTopPadding = !isFirstSection
35     )
36 }
37 
38 @Composable
39 fun MoreAboutPasskeySectionHeader(text: String) {
40     InternalSectionHeader(text, LocalAndroidColorScheme.current.colorOnSurface)
41 }
42 
43 @Composable
44 private fun InternalSectionHeader(text: String, color: Color, applyTopPadding: Boolean = false) {
45     Row(modifier = Modifier.fillMaxWidth().wrapContentHeight().padding(
46         top = if (applyTopPadding) 8.dp else 0.dp
47     )) {
48         SectionHeaderText(
49             text,
50             modifier = Modifier.padding(top = 20.dp, bottom = 8.dp),
51             color = color
52         )
53     }
54 }