Add the use provider for all your signins checking page

screencast: https://screencast.googleplex.com/cast/NTI0MDk5NDYxNTI2MzIzMnwzMDcxYTc0Zi0xZA

Test: deployed locally

Bug: 253157211
Change-Id: Ie3e1eb33fdb51b0b4483bb0b1e1c6168975fee92
This commit is contained in:
Qinmei Du
2022-10-19 04:43:16 +00:00
parent 1f0e116d1d
commit f1451fc3c4
3 changed files with 42 additions and 1 deletions

View File

@@ -1,4 +1,5 @@
<resources>
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="app_name">CredentialManager</string>
<string name="string_cancel">Cancel</string>
<string name="string_continue">Continue</string>
@@ -12,4 +13,7 @@
<string name="choose_create_option_title">Create a passkey at</string>
<string name="choose_sign_in_title">Use saved sign in</string>
<string name="create_passkey_at">Create passkey at</string>
<string name="use_provider_for_all_title">Use <xliff:g id="providerInfoName">%1$s</xliff:g> for all your sign-ins?</string>
<string name="set_as_default">Set as default</string>
<string name="use_once">Use once</string>
</resources>

View File

@@ -83,6 +83,8 @@ fun CreatePasskeyScreen(
onOptionSelected = {viewModel.onMoreOptionsRowSelected(it)}
)
CreateScreenState.MORE_OPTIONS_ROW_INTRO -> MoreOptionsRowIntroCard(
providerInfo = uiState.selectedProvider!!,
onDefaultOrNotSelected = {viewModel.onDefaultOrNotSelected(it)}
)
}
},
@@ -282,10 +284,37 @@ fun MoreOptionsSelectionCard(
@ExperimentalMaterialApi
@Composable
fun MoreOptionsRowIntroCard(
providerInfo: ProviderInfo,
onDefaultOrNotSelected: (String) -> Unit,
) {
Card(
backgroundColor = lightBackgroundColor,
) {
Column() {
Text(
text = stringResource(R.string.use_provider_for_all_title, providerInfo.name),
style = Typography.subtitle1,
modifier = Modifier.padding(all = 24.dp).align(alignment = Alignment.CenterHorizontally)
)
Row(
horizontalArrangement = Arrangement.SpaceBetween,
modifier = Modifier.fillMaxWidth().padding(horizontal = 24.dp)
) {
CancelButton(
stringResource(R.string.use_once),
onclick = { onDefaultOrNotSelected(providerInfo.name) }
)
ConfirmButton(
stringResource(R.string.set_as_default),
onclick = { onDefaultOrNotSelected(providerInfo.name) }
)
}
Divider(
thickness = 18.dp,
color = Color.Transparent,
modifier = Modifier.padding(bottom = 40.dp)
)
}
}
}

View File

@@ -112,4 +112,12 @@ class CreatePasskeyViewModel(
CredentialManagerRepo.getInstance().onCancel()
dialogResult.value = DialogResult(ResultState.CANCELED)
}
fun onDefaultOrNotSelected(providerName: String) {
uiState = uiState.copy(
currentScreenState = CreateScreenState.CREATION_OPTION_SELECTION,
selectedProvider = getProviderInfoByName(providerName)
)
// TODO: implement the if choose as default or not logic later
}
}