1 /*
2 * Copyright 2024 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 * https://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 @file:OptIn(ExperimentalHorologistApi::class)
18
19 package com.android.credentialmanager.ui.screens.single.password
20
21 import androidx.compose.foundation.layout.Column
22 import androidx.compose.runtime.Composable
23 import androidx.compose.ui.res.stringResource
24 import com.android.credentialmanager.FlowEngine
25 import com.android.credentialmanager.R
26 import com.android.credentialmanager.ui.components.PasswordRow
27 import com.android.credentialmanager.ui.components.ContinueChip
28 import com.android.credentialmanager.ui.components.DismissChip
29 import com.android.credentialmanager.ui.components.SignInHeader
30 import com.android.credentialmanager.ui.components.SignInOptionsChip
31 import com.android.credentialmanager.ui.screens.single.SingleAccountScreen
32 import com.android.credentialmanager.model.get.CredentialEntryInfo
33 import com.android.credentialmanager.ui.components.BottomSpacer
34 import com.android.credentialmanager.ui.components.CredentialsScreenChipSpacer
35 import com.google.android.horologist.annotations.ExperimentalHorologistApi
36 import com.google.android.horologist.compose.layout.ScalingLazyColumnState
37
38 /**
39 * Screen that shows password credential.
40 *
41 * @param entry The password entry.
42 * @param columnState ScalingLazyColumn configuration to be be applied to SingleAccountScreen
43 * @param modifier styling for composable
44 * @param flowEngine [FlowEngine] that updates ui state for this screen
45 */
46 @OptIn(ExperimentalHorologistApi::class)
47 @Composable
SinglePasswordScreennull48 fun SinglePasswordScreen(
49 entry: CredentialEntryInfo,
50 columnState: ScalingLazyColumnState,
51 flowEngine: FlowEngine,
52 ) {
53 val selectEntry = flowEngine.getEntrySelector()
54 SingleAccountScreen(
55 headerContent = {
56 SignInHeader(
57 icon = entry.icon,
58 title = stringResource(R.string.use_password_title),
59 )
60 },
61 accountContent = {
62 PasswordRow(
63 email = entry.userName,
64 )
65 },
66 columnState = columnState,
67 ) {
68 item {
69 Column {
70 ContinueChip { selectEntry(entry, false) }
71 CredentialsScreenChipSpacer()
72 SignInOptionsChip{ flowEngine.openSecondaryScreen() }
73 CredentialsScreenChipSpacer()
74 DismissChip { flowEngine.cancel() }
75 BottomSpacer()
76 }
77 }
78 }
79 }
80
81
82