From 0a2a1b7d9396b062a8d110344922f5bec021749e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolf-Martell=20Montw=C3=A9?= Date: Wed, 19 Jul 2023 18:42:58 +0200 Subject: [PATCH] Change WizardNavigationBar to enable next and back button based on given state --- .../account/common/ui/WizardNavigationBar.kt | 26 ++++++++++++++++--- .../common/ui/WizardNavigationBarState.kt | 6 +++++ 2 files changed, 29 insertions(+), 3 deletions(-) create mode 100644 feature/account/common/src/main/kotlin/app/k9mail/feature/account/common/ui/WizardNavigationBarState.kt diff --git a/feature/account/common/src/main/kotlin/app/k9mail/feature/account/common/ui/WizardNavigationBar.kt b/feature/account/common/src/main/kotlin/app/k9mail/feature/account/common/ui/WizardNavigationBar.kt index df2771950..d150efb97 100644 --- a/feature/account/common/src/main/kotlin/app/k9mail/feature/account/common/ui/WizardNavigationBar.kt +++ b/feature/account/common/src/main/kotlin/app/k9mail/feature/account/common/ui/WizardNavigationBar.kt @@ -12,7 +12,7 @@ import app.k9mail.core.ui.compose.designsystem.atom.button.ButtonOutlined import app.k9mail.core.ui.compose.designsystem.template.ResponsiveWidthContainer import app.k9mail.core.ui.compose.theme.K9Theme import app.k9mail.core.ui.compose.theme.MainTheme -import app.k9mail.core.ui.compose.theme.ThunderbirdTheme +import app.k9mail.core.ui.compose.theme.PreviewWithThemes @Composable fun WizardNavigationBar( @@ -21,6 +21,7 @@ fun WizardNavigationBar( onNextClick: () -> Unit, onBackClick: () -> Unit, modifier: Modifier = Modifier, + state: WizardNavigationBarState = WizardNavigationBarState(), ) { ResponsiveWidthContainer( modifier = Modifier @@ -41,10 +42,12 @@ fun WizardNavigationBar( ButtonOutlined( text = backButtonText, onClick = onBackClick, + enabled = state.isBackEnabled, ) Button( text = nextButtonText, onClick = onNextClick, + enabled = state.isNextEnabled, ) } } @@ -65,8 +68,8 @@ internal fun WizardNavigationBarK9Preview() { @DevicePreviews @Composable -internal fun WizardNavigationBarThunderbirdPreview() { - ThunderbirdTheme { +internal fun WizardNavigationBarPreview() { + PreviewWithThemes { WizardNavigationBar( nextButtonText = "Next", backButtonText = "Back", @@ -75,3 +78,20 @@ internal fun WizardNavigationBarThunderbirdPreview() { ) } } + +@DevicePreviews +@Composable +internal fun WizardNavigationBarDisabledPreview() { + PreviewWithThemes { + WizardNavigationBar( + nextButtonText = "Next", + backButtonText = "Back", + onNextClick = {}, + onBackClick = {}, + state = WizardNavigationBarState( + isNextEnabled = false, + isBackEnabled = false, + ), + ) + } +} diff --git a/feature/account/common/src/main/kotlin/app/k9mail/feature/account/common/ui/WizardNavigationBarState.kt b/feature/account/common/src/main/kotlin/app/k9mail/feature/account/common/ui/WizardNavigationBarState.kt new file mode 100644 index 000000000..d03875d24 --- /dev/null +++ b/feature/account/common/src/main/kotlin/app/k9mail/feature/account/common/ui/WizardNavigationBarState.kt @@ -0,0 +1,6 @@ +package app.k9mail.feature.account.common.ui + +data class WizardNavigationBarState( + val isNextEnabled: Boolean = true, + val isBackEnabled: Boolean = true, +)