Add enabled state to OAuthView and propagate to buttons
This commit is contained in:
parent
dc1c8fd060
commit
86ed42713e
5 changed files with 13 additions and 0 deletions
|
@ -24,6 +24,7 @@ internal fun AccountOAuthContent(
|
|||
state: State,
|
||||
onEvent: (Event) -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
isEnabled: Boolean = true,
|
||||
) {
|
||||
val resources = LocalContext.current.resources
|
||||
|
||||
|
@ -47,6 +48,7 @@ internal fun AccountOAuthContent(
|
|||
SignInView(
|
||||
onSignInClick = { onEvent(Event.SignInClicked) },
|
||||
isGoogleSignIn = state.isGoogleSignIn,
|
||||
isEnabled = isEnabled,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@ fun AccountOAuthView(
|
|||
onOAuthResult: (OAuthResult) -> Unit,
|
||||
viewModel: ViewModel,
|
||||
modifier: Modifier = Modifier,
|
||||
isEnabled: Boolean = true,
|
||||
) {
|
||||
val oAuthLauncher = rememberLauncherForActivityResult(
|
||||
contract = ActivityResultContracts.StartActivityForResult(),
|
||||
|
@ -34,5 +35,6 @@ fun AccountOAuthView(
|
|||
state = state.value,
|
||||
onEvent = { dispatch(it) },
|
||||
modifier = modifier,
|
||||
isEnabled = isEnabled,
|
||||
)
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ internal fun SignInView(
|
|||
onSignInClick: () -> Unit,
|
||||
isGoogleSignIn: Boolean,
|
||||
modifier: Modifier = Modifier,
|
||||
isEnabled: Boolean = true,
|
||||
) {
|
||||
Column(
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
|
@ -32,11 +33,13 @@ internal fun SignInView(
|
|||
if (isGoogleSignIn) {
|
||||
SignInWithGoogleButton(
|
||||
onClick = onSignInClick,
|
||||
enabled = isEnabled,
|
||||
)
|
||||
} else {
|
||||
Button(
|
||||
text = stringResource(id = R.string.account_oauth_sign_in_button),
|
||||
onClick = onSignInClick,
|
||||
enabled = isEnabled,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,6 +40,7 @@ import app.k9mail.feature.account.oauth.R
|
|||
fun SignInWithGoogleButton(
|
||||
onClick: () -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
enabled: Boolean = true,
|
||||
isLight: Boolean = MaterialTheme.colors.isLight,
|
||||
) {
|
||||
OutlinedButton(
|
||||
|
@ -54,6 +55,7 @@ fun SignInWithGoogleButton(
|
|||
color = getBorderColor(isLight),
|
||||
),
|
||||
contentPadding = PaddingValues(all = 0.dp),
|
||||
enabled = enabled,
|
||||
) {
|
||||
Row(
|
||||
modifier = Modifier
|
||||
|
|
|
@ -49,9 +49,13 @@ internal fun LazyListScope.contentItems(
|
|||
} else if (state.configStep == ConfigStep.OAUTH) {
|
||||
item(key = "oauth") {
|
||||
ListItem {
|
||||
val isAutoDiscoverySettingsTrusted = state.autoDiscoverySettings?.isTrusted ?: false
|
||||
val isConfigurationApproved = state.configurationApproved.value ?: false
|
||||
|
||||
AccountOAuthView(
|
||||
onOAuthResult = { result -> onEvent(Event.OnOAuthResult(result)) },
|
||||
viewModel = oAuthViewModel,
|
||||
isEnabled = isAutoDiscoverySettingsTrusted || isConfigurationApproved,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue