Add account common module to host shared code for reuse in oauth module

This commit is contained in:
Wolf-Martell Montwé 2023-07-04 11:52:39 +02:00 committed by Wolf-Martell Montwé
parent e6b2c66f44
commit 23b0e79a0e
No known key found for this signature in database
GPG key ID: 6D45B21512ACBF72
23 changed files with 71 additions and 53 deletions

View file

@ -0,0 +1,15 @@
plugins {
id(ThunderbirdPlugins.Library.androidCompose)
}
android {
namespace = "app.k9mail.feature.account.common"
resourcePrefix = "account_common_"
}
dependencies {
implementation(projects.core.ui.compose.designsystem)
implementation(projects.core.common)
testImplementation(projects.core.ui.compose.testing)
}

View file

@ -1,4 +1,4 @@
package app.k9mail.feature.account.setup.ui.common
package app.k9mail.feature.account.common.ui
import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.Arrangement
@ -9,7 +9,6 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.SpanStyle
import androidx.compose.ui.text.buildAnnotatedString
import androidx.compose.ui.text.font.FontWeight
@ -19,10 +18,10 @@ import app.k9mail.core.ui.compose.designsystem.atom.text.TextHeadline2
import app.k9mail.core.ui.compose.designsystem.template.ResponsiveWidthContainer
import app.k9mail.core.ui.compose.theme.MainTheme
import app.k9mail.core.ui.compose.theme.PreviewWithThemes
import app.k9mail.feature.account.setup.R.string
@Composable
internal fun AccountSetupTopHeader(
fun AppTitleTopHeader(
title: String,
modifier: Modifier = Modifier,
) {
ResponsiveWidthContainer(
@ -53,7 +52,7 @@ internal fun AccountSetupTopHeader(
TextHeadline2(
text = buildAnnotatedString {
withStyle(style = SpanStyle(fontWeight = FontWeight.Bold)) {
append(stringResource(id = string.account_setup_title))
append(title)
}
},
)
@ -63,8 +62,8 @@ internal fun AccountSetupTopHeader(
@Preview
@Composable
internal fun AccountSetupTopHeaderPreview() {
internal fun AppTitleTopHeaderPreview() {
PreviewWithThemes {
AccountSetupTopHeader()
AppTitleTopHeader("Title")
}
}

View file

@ -1,4 +1,4 @@
package app.k9mail.feature.account.setup.ui.common
package app.k9mail.feature.account.common.ui
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Row
@ -15,7 +15,7 @@ import app.k9mail.core.ui.compose.theme.MainTheme
import app.k9mail.core.ui.compose.theme.ThunderbirdTheme
@Composable
internal fun AccountSetupBottomBar(
fun WizardNavigationBar(
nextButtonText: String,
backButtonText: String,
onNextClick: () -> Unit,
@ -52,9 +52,9 @@ internal fun AccountSetupBottomBar(
@DevicePreviews
@Composable
internal fun AccountSetupBottomBarK9Preview() {
internal fun WizardNavigationBarK9Preview() {
K9Theme {
AccountSetupBottomBar(
WizardNavigationBar(
nextButtonText = "Next",
backButtonText = "Back",
onNextClick = {},
@ -65,9 +65,9 @@ internal fun AccountSetupBottomBarK9Preview() {
@DevicePreviews
@Composable
internal fun AccountSetupBottomBarThunderbirdPreview() {
internal fun WizardNavigationBarThunderbirdPreview() {
ThunderbirdTheme {
AccountSetupBottomBar(
WizardNavigationBar(
nextButtonText = "Next",
backButtonText = "Back",
onNextClick = {},

View file

@ -1,4 +1,4 @@
package app.k9mail.feature.account.setup.ui.common.item
package app.k9mail.feature.account.common.ui.item
import androidx.compose.foundation.lazy.LazyItemScope
import androidx.compose.runtime.Composable
@ -6,7 +6,7 @@ import androidx.compose.ui.Modifier
import app.k9mail.core.ui.compose.designsystem.molecule.ErrorView
@Composable
internal fun LazyItemScope.ErrorItem(
fun LazyItemScope.ErrorItem(
title: String,
modifier: Modifier = Modifier,
message: String? = null,

View file

@ -1,11 +1,11 @@
package app.k9mail.feature.account.setup.ui.common.item
package app.k9mail.feature.account.common.ui.item
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.runtime.Composable
import app.k9mail.core.ui.compose.theme.MainTheme
@Composable
internal fun defaultHeadlineItemPadding() = PaddingValues(
fun defaultHeadlineItemPadding() = PaddingValues(
start = MainTheme.spacings.quadruple,
top = MainTheme.spacings.triple,
end = MainTheme.spacings.quadruple,
@ -13,7 +13,7 @@ internal fun defaultHeadlineItemPadding() = PaddingValues(
)
@Composable
internal fun defaultItemPadding() = PaddingValues(
fun defaultItemPadding() = PaddingValues(
horizontal = MainTheme.spacings.quadruple,
vertical = MainTheme.spacings.zero,
)

View file

@ -1,4 +1,4 @@
package app.k9mail.feature.account.setup.ui.common.item
package app.k9mail.feature.account.common.ui.item
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.layout.Box
@ -11,7 +11,7 @@ import androidx.compose.ui.Modifier
@OptIn(ExperimentalFoundationApi::class)
@Composable
internal fun LazyItemScope.ListItem(
fun LazyItemScope.ListItem(
modifier: Modifier = Modifier,
contentPaddingValues: PaddingValues = defaultItemPadding(),
content: @Composable () -> Unit,

View file

@ -1,4 +1,4 @@
package app.k9mail.feature.account.setup.ui.common.item
package app.k9mail.feature.account.common.ui.item
import androidx.compose.foundation.lazy.LazyItemScope
import androidx.compose.runtime.Composable
@ -6,7 +6,7 @@ import androidx.compose.ui.Modifier
import app.k9mail.core.ui.compose.designsystem.molecule.LoadingView
@Composable
internal fun LazyItemScope.LoadingItem(
fun LazyItemScope.LoadingItem(
modifier: Modifier = Modifier,
message: String? = null,
) {

View file

@ -1,12 +1,12 @@
package app.k9mail.feature.account.setup.ui.common.item
package app.k9mail.feature.account.common.ui.item
import androidx.compose.foundation.lazy.LazyItemScope
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import app.k9mail.feature.account.setup.ui.common.view.SuccessView
import app.k9mail.feature.account.common.ui.view.SuccessView
@Composable
internal fun LazyItemScope.SuccessItem(
fun LazyItemScope.SuccessItem(
message: String,
modifier: Modifier = Modifier,
) {

View file

@ -1,4 +1,4 @@
package app.k9mail.feature.account.setup.ui.common.view
package app.k9mail.feature.account.common.ui.view
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
@ -17,7 +17,7 @@ import app.k9mail.core.ui.compose.theme.MainTheme
import app.k9mail.core.ui.compose.theme.PreviewWithThemes
@Composable
fun SuccessView(
internal fun SuccessView(
message: String,
modifier: Modifier = Modifier,
) {

View file

@ -25,6 +25,7 @@ dependencies {
implementation(projects.mail.protocols.smtp)
implementation(projects.feature.autodiscovery.service)
implementation(projects.feature.account.common)
implementation(projects.feature.account.oauth)
testImplementation(projects.core.ui.compose.testing)

View file

@ -18,12 +18,12 @@ 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.feature.account.common.ui.item.ErrorItem
import app.k9mail.feature.account.common.ui.item.LoadingItem
import app.k9mail.feature.account.setup.R
import app.k9mail.feature.account.setup.ui.autodiscovery.AccountAutoDiscoveryContract.Event
import app.k9mail.feature.account.setup.ui.autodiscovery.AccountAutoDiscoveryContract.State
import app.k9mail.feature.account.setup.ui.autodiscovery.item.contentItems
import app.k9mail.feature.account.setup.ui.common.item.ErrorItem
import app.k9mail.feature.account.setup.ui.common.item.LoadingItem
@Composable
internal fun AccountAutoDiscoveryContent(

View file

@ -10,13 +10,13 @@ import app.k9mail.core.ui.compose.common.mvi.observe
import app.k9mail.core.ui.compose.designsystem.template.Scaffold
import app.k9mail.core.ui.compose.theme.K9Theme
import app.k9mail.core.ui.compose.theme.ThunderbirdTheme
import app.k9mail.feature.account.common.ui.AppTitleTopHeader
import app.k9mail.feature.account.common.ui.WizardNavigationBar
import app.k9mail.feature.account.setup.R
import app.k9mail.feature.account.setup.ui.autodiscovery.AccountAutoDiscoveryContract.Effect
import app.k9mail.feature.account.setup.ui.autodiscovery.AccountAutoDiscoveryContract.Event
import app.k9mail.feature.account.setup.ui.autodiscovery.AccountAutoDiscoveryContract.State
import app.k9mail.feature.account.setup.ui.autodiscovery.AccountAutoDiscoveryContract.ViewModel
import app.k9mail.feature.account.setup.ui.common.AccountSetupBottomBar
import app.k9mail.feature.account.setup.ui.common.AccountSetupTopHeader
@Composable
internal fun AccountAutoDiscoveryScreen(
@ -38,10 +38,12 @@ internal fun AccountAutoDiscoveryScreen(
Scaffold(
topBar = {
AccountSetupTopHeader()
AppTitleTopHeader(
title = stringResource(id = R.string.account_setup_title),
)
},
bottomBar = {
AccountSetupBottomBar(
WizardNavigationBar(
nextButtonText = stringResource(id = R.string.account_setup_button_next),
backButtonText = stringResource(id = R.string.account_setup_button_back),
onNextClick = { dispatch(Event.OnNextClicked) },

View file

@ -4,8 +4,8 @@ import androidx.compose.foundation.lazy.LazyItemScope
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import app.k9mail.autodiscovery.api.AutoDiscoveryResult
import app.k9mail.feature.account.common.ui.item.ListItem
import app.k9mail.feature.account.setup.ui.autodiscovery.view.AutoDiscoveryStatusView
import app.k9mail.feature.account.setup.ui.common.item.ListItem
@Composable
internal fun LazyItemScope.AutoDiscoveryStatusItem(

View file

@ -3,9 +3,9 @@ package app.k9mail.feature.account.setup.ui.autodiscovery.item
import androidx.compose.foundation.lazy.LazyItemScope
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import app.k9mail.feature.account.common.ui.item.ListItem
import app.k9mail.feature.account.setup.domain.input.BooleanInputField
import app.k9mail.feature.account.setup.ui.autodiscovery.view.ConfigurationApprovalView
import app.k9mail.feature.account.setup.ui.common.item.ListItem
@Composable
internal fun LazyItemScope.ConfigurationApprovalItem(

View file

@ -7,7 +7,7 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import app.k9mail.core.common.domain.usecase.validation.ValidationError
import app.k9mail.core.ui.compose.designsystem.molecule.input.EmailAddressInput
import app.k9mail.feature.account.setup.ui.common.item.ListItem
import app.k9mail.feature.account.common.ui.item.ListItem
import app.k9mail.feature.account.setup.ui.common.toResourceString
@Composable

View file

@ -7,7 +7,7 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import app.k9mail.core.common.domain.usecase.validation.ValidationError
import app.k9mail.core.ui.compose.designsystem.molecule.input.PasswordInput
import app.k9mail.feature.account.setup.ui.common.item.ListItem
import app.k9mail.feature.account.common.ui.item.ListItem
import app.k9mail.feature.account.setup.ui.common.toResourceString
@Composable

View file

@ -25,13 +25,13 @@ 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.feature.account.common.ui.item.ErrorItem
import app.k9mail.feature.account.common.ui.item.LoadingItem
import app.k9mail.feature.account.common.ui.item.SuccessItem
import app.k9mail.feature.account.common.ui.item.defaultItemPadding
import app.k9mail.feature.account.setup.R
import app.k9mail.feature.account.setup.domain.entity.ConnectionSecurity
import app.k9mail.feature.account.setup.domain.entity.IncomingProtocolType
import app.k9mail.feature.account.setup.ui.common.item.ErrorItem
import app.k9mail.feature.account.setup.ui.common.item.LoadingItem
import app.k9mail.feature.account.setup.ui.common.item.SuccessItem
import app.k9mail.feature.account.setup.ui.common.item.defaultItemPadding
import app.k9mail.feature.account.setup.ui.common.mapper.toResourceString
import app.k9mail.feature.account.setup.ui.common.toResourceString
import app.k9mail.feature.account.setup.ui.incoming.AccountIncomingConfigContract.Event

View file

@ -9,8 +9,8 @@ import app.k9mail.core.ui.compose.common.mvi.observe
import app.k9mail.core.ui.compose.designsystem.template.Scaffold
import app.k9mail.core.ui.compose.theme.K9Theme
import app.k9mail.core.ui.compose.theme.ThunderbirdTheme
import app.k9mail.feature.account.common.ui.WizardNavigationBar
import app.k9mail.feature.account.setup.R
import app.k9mail.feature.account.setup.ui.common.AccountSetupBottomBar
import app.k9mail.feature.account.setup.ui.common.AccountSetupTopAppBar
import app.k9mail.feature.account.setup.ui.incoming.AccountIncomingConfigContract.Effect
import app.k9mail.feature.account.setup.ui.incoming.AccountIncomingConfigContract.Event
@ -42,7 +42,7 @@ internal fun AccountIncomingConfigScreen(
)
},
bottomBar = {
AccountSetupBottomBar(
WizardNavigationBar(
nextButtonText = stringResource(id = R.string.account_setup_button_next),
backButtonText = stringResource(id = R.string.account_setup_button_back),
onNextClick = { dispatch(Event.OnNextClicked) },

View file

@ -26,11 +26,11 @@ 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.feature.account.common.ui.item.defaultHeadlineItemPadding
import app.k9mail.feature.account.common.ui.item.defaultItemPadding
import app.k9mail.feature.account.setup.R
import app.k9mail.feature.account.setup.domain.entity.EmailCheckFrequency
import app.k9mail.feature.account.setup.domain.entity.EmailDisplayCount
import app.k9mail.feature.account.setup.ui.common.item.defaultHeadlineItemPadding
import app.k9mail.feature.account.setup.ui.common.item.defaultItemPadding
import app.k9mail.feature.account.setup.ui.options.AccountOptionsContract.Event
import app.k9mail.feature.account.setup.ui.options.AccountOptionsContract.State

View file

@ -9,8 +9,8 @@ import app.k9mail.core.ui.compose.common.mvi.observe
import app.k9mail.core.ui.compose.designsystem.template.Scaffold
import app.k9mail.core.ui.compose.theme.K9Theme
import app.k9mail.core.ui.compose.theme.ThunderbirdTheme
import app.k9mail.feature.account.common.ui.WizardNavigationBar
import app.k9mail.feature.account.setup.R.string
import app.k9mail.feature.account.setup.ui.common.AccountSetupBottomBar
import app.k9mail.feature.account.setup.ui.common.AccountSetupTopAppBar
import app.k9mail.feature.account.setup.ui.options.AccountOptionsContract.Effect
import app.k9mail.feature.account.setup.ui.options.AccountOptionsContract.Event
@ -41,7 +41,7 @@ internal fun AccountOptionsScreen(
)
},
bottomBar = {
AccountSetupBottomBar(
WizardNavigationBar(
nextButtonText = stringResource(id = string.account_setup_button_finish),
backButtonText = stringResource(id = string.account_setup_button_back),
onNextClick = { dispatch(Event.OnNextClicked) },

View file

@ -24,13 +24,13 @@ 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.feature.account.common.ui.item.ErrorItem
import app.k9mail.feature.account.common.ui.item.LoadingItem
import app.k9mail.feature.account.common.ui.item.SuccessItem
import app.k9mail.feature.account.common.ui.item.defaultItemPadding
import app.k9mail.feature.account.setup.R
import app.k9mail.feature.account.setup.domain.entity.AuthenticationType
import app.k9mail.feature.account.setup.domain.entity.ConnectionSecurity
import app.k9mail.feature.account.setup.ui.common.item.ErrorItem
import app.k9mail.feature.account.setup.ui.common.item.LoadingItem
import app.k9mail.feature.account.setup.ui.common.item.SuccessItem
import app.k9mail.feature.account.setup.ui.common.item.defaultItemPadding
import app.k9mail.feature.account.setup.ui.common.mapper.toResourceString
import app.k9mail.feature.account.setup.ui.common.toResourceString
import app.k9mail.feature.account.setup.ui.outgoing.AccountOutgoingConfigContract.Event

View file

@ -9,8 +9,8 @@ import app.k9mail.core.ui.compose.common.mvi.observe
import app.k9mail.core.ui.compose.designsystem.template.Scaffold
import app.k9mail.core.ui.compose.theme.K9Theme
import app.k9mail.core.ui.compose.theme.ThunderbirdTheme
import app.k9mail.feature.account.common.ui.WizardNavigationBar
import app.k9mail.feature.account.setup.R
import app.k9mail.feature.account.setup.ui.common.AccountSetupBottomBar
import app.k9mail.feature.account.setup.ui.common.AccountSetupTopAppBar
import app.k9mail.feature.account.setup.ui.outgoing.AccountOutgoingConfigContract.Effect
import app.k9mail.feature.account.setup.ui.outgoing.AccountOutgoingConfigContract.Event
@ -42,7 +42,7 @@ internal fun AccountOutgoingConfigScreen(
)
},
bottomBar = {
AccountSetupBottomBar(
WizardNavigationBar(
nextButtonText = stringResource(id = R.string.account_setup_button_next),
backButtonText = stringResource(id = R.string.account_setup_button_back),
onNextClick = { dispatch(Event.OnNextClicked) },

View file

@ -40,6 +40,7 @@ include(
include(
":feature:launcher",
":feature:account:common",
":feature:account:setup",
":feature:account:oauth",
":feature:onboarding",