diff --git a/app-feature-preview/src/main/java/app/k9mail/feature/preview/FeatureModule.kt b/app-feature-preview/src/main/java/app/k9mail/feature/preview/FeatureModule.kt index aa80e7390..a5b1186ff 100644 --- a/app-feature-preview/src/main/java/app/k9mail/feature/preview/FeatureModule.kt +++ b/app-feature-preview/src/main/java/app/k9mail/feature/preview/FeatureModule.kt @@ -6,6 +6,7 @@ import app.k9mail.feature.account.edit.AccountEditExternalContract import app.k9mail.feature.account.edit.featureAccountEditModule import app.k9mail.feature.account.setup.AccountSetupExternalContract import app.k9mail.feature.account.setup.featureAccountSetupModule +import app.k9mail.feature.onboarding.main.featureOnboardingModule import app.k9mail.feature.preview.account.AccountOwnerNameProvider import app.k9mail.feature.preview.account.InMemoryAccountStore import app.k9mail.feature.preview.auth.AndroidKeyStoreDirectoryProvider @@ -18,6 +19,7 @@ import com.fsck.k9.mail.ssl.LocalKeyStore import com.fsck.k9.mail.ssl.TrustManagerFactory import com.fsck.k9.mail.ssl.TrustedSocketFactory import org.koin.core.module.Module +import org.koin.core.qualifier.named import org.koin.dsl.binds import org.koin.dsl.module @@ -41,9 +43,12 @@ val featureModule: Module = module { single { TrustManagerFactory.createInstance(get()) } single { DefaultTrustedSocketFactory(get(), get()) } single { RealOAuth2TokenProviderFactory(context = get()) } + single(named("ClientIdAppName")) { "App Name" } + single(named("ClientIdAppVersion")) { "App Version" } includes( accountModule, + featureOnboardingModule, featureAccountSetupModule, featureAccountEditModule, ) diff --git a/app-feature-preview/src/main/java/app/k9mail/feature/preview/navigation/FeatureNavHost.kt b/app-feature-preview/src/main/java/app/k9mail/feature/preview/navigation/FeatureNavHost.kt index 94b31fc51..20e0e7018 100644 --- a/app-feature-preview/src/main/java/app/k9mail/feature/preview/navigation/FeatureNavHost.kt +++ b/app-feature-preview/src/main/java/app/k9mail/feature/preview/navigation/FeatureNavHost.kt @@ -7,7 +7,6 @@ import androidx.navigation.compose.NavHost import app.k9mail.feature.account.edit.navigation.accountEditRoute import app.k9mail.feature.account.edit.navigation.navigateToAccountEditIncomingServerSettings import app.k9mail.feature.account.setup.navigation.accountSetupRoute -import app.k9mail.feature.account.setup.navigation.navigateToAccountSetup import app.k9mail.feature.onboarding.main.navigation.NAVIGATION_ROUTE_ONBOARDING import app.k9mail.feature.onboarding.main.navigation.navigateToOnboarding import app.k9mail.feature.onboarding.main.navigation.onboardingRoute @@ -24,8 +23,11 @@ fun FeatureNavHost( modifier = modifier, ) { onboardingRoute( - onStart = { navController.navigateToAccountSetup() }, onImport = { /* TODO */ }, + onBack = navController::popBackStack, + onFinish = { accountUuid -> + navController.navigateToAccountEditIncomingServerSettings(accountUuid) + }, ) accountSetupRoute( onBack = navController::popBackStack, diff --git a/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/navigation/AccountSetupNavigation.kt b/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/navigation/AccountSetupNavigation.kt index 5d4eb2ce8..740835675 100644 --- a/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/navigation/AccountSetupNavigation.kt +++ b/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/navigation/AccountSetupNavigation.kt @@ -3,6 +3,7 @@ package app.k9mail.feature.account.setup.navigation import androidx.navigation.NavController import androidx.navigation.NavGraphBuilder import androidx.navigation.NavOptions +import androidx.navigation.compose.composable import app.k9mail.core.ui.compose.common.navigation.deepLinkComposable import app.k9mail.feature.account.setup.ui.AccountSetupScreen @@ -23,3 +24,16 @@ fun NavGraphBuilder.accountSetupRoute( ) } } + +fun NavGraphBuilder.nestedAccountSetupRoute( + route: String, + onBack: () -> Unit, + onFinish: (String) -> Unit, +) { + composable(route) { + AccountSetupScreen( + onBack = onBack, + onFinish = onFinish, + ) + } +} diff --git a/feature/launcher/src/main/kotlin/app/k9mail/feature/launcher/di/FeatureLauncherModule.kt b/feature/launcher/src/main/kotlin/app/k9mail/feature/launcher/di/FeatureLauncherModule.kt index 1e5a5e473..ddab81965 100644 --- a/feature/launcher/src/main/kotlin/app/k9mail/feature/launcher/di/FeatureLauncherModule.kt +++ b/feature/launcher/src/main/kotlin/app/k9mail/feature/launcher/di/FeatureLauncherModule.kt @@ -2,10 +2,12 @@ package app.k9mail.feature.launcher.di import app.k9mail.feature.account.edit.featureAccountEditModule import app.k9mail.feature.account.setup.featureAccountSetupModule +import app.k9mail.feature.onboarding.main.featureOnboardingModule import org.koin.dsl.module val featureLauncherModule = module { includes( + featureOnboardingModule, featureAccountSetupModule, featureAccountEditModule, ) diff --git a/feature/launcher/src/main/kotlin/app/k9mail/feature/launcher/navigation/FeatureLauncherNavHost.kt b/feature/launcher/src/main/kotlin/app/k9mail/feature/launcher/navigation/FeatureLauncherNavHost.kt index b9a7d69ce..0ca3213db 100644 --- a/feature/launcher/src/main/kotlin/app/k9mail/feature/launcher/navigation/FeatureLauncherNavHost.kt +++ b/feature/launcher/src/main/kotlin/app/k9mail/feature/launcher/navigation/FeatureLauncherNavHost.kt @@ -7,7 +7,6 @@ import androidx.navigation.compose.NavHost import app.k9mail.core.ui.compose.common.activity.LocalActivity import app.k9mail.feature.account.edit.navigation.accountEditRoute import app.k9mail.feature.account.setup.navigation.accountSetupRoute -import app.k9mail.feature.account.setup.navigation.navigateToAccountSetup import app.k9mail.feature.launcher.FeatureLauncherExternalContract.AccountSetupFinishedLauncher import app.k9mail.feature.launcher.FeatureLauncherExternalContract.ImportSettingsLauncher import app.k9mail.feature.onboarding.main.navigation.NAVIGATION_ROUTE_ONBOARDING @@ -30,8 +29,9 @@ fun FeatureLauncherNavHost( modifier = modifier, ) { onboardingRoute( - onStart = { navController.navigateToAccountSetup() }, onImport = { importSettingsLauncher.launch() }, + onBack = onBack, + onFinish = { accountUuid -> accountSetupFinishedLauncher.launch(accountUuid) }, ) accountSetupRoute( onBack = onBack, diff --git a/feature/onboarding/main/build.gradle.kts b/feature/onboarding/main/build.gradle.kts index 1b82fa832..9b8070137 100644 --- a/feature/onboarding/main/build.gradle.kts +++ b/feature/onboarding/main/build.gradle.kts @@ -19,4 +19,6 @@ android { dependencies { implementation(projects.core.ui.compose.designsystem) implementation(projects.feature.onboarding.welcome) + implementation(projects.feature.account.setup) + implementation(projects.feature.onboarding.permissions) } diff --git a/feature/onboarding/main/src/main/kotlin/app/k9mail/feature/onboarding/main/OnboardingModule.kt b/feature/onboarding/main/src/main/kotlin/app/k9mail/feature/onboarding/main/OnboardingModule.kt new file mode 100644 index 000000000..fc02cc333 --- /dev/null +++ b/feature/onboarding/main/src/main/kotlin/app/k9mail/feature/onboarding/main/OnboardingModule.kt @@ -0,0 +1,11 @@ +package app.k9mail.feature.onboarding.main + +import app.k9mail.feature.onboarding.permissions.featureOnboardingPermissionsModule +import org.koin.core.module.Module +import org.koin.dsl.module + +val featureOnboardingModule: Module = module { + includes( + featureOnboardingPermissionsModule, + ) +} diff --git a/feature/onboarding/main/src/main/kotlin/app/k9mail/feature/onboarding/main/navigation/OnboardingNavHost.kt b/feature/onboarding/main/src/main/kotlin/app/k9mail/feature/onboarding/main/navigation/OnboardingNavHost.kt new file mode 100644 index 000000000..3d49d1da3 --- /dev/null +++ b/feature/onboarding/main/src/main/kotlin/app/k9mail/feature/onboarding/main/navigation/OnboardingNavHost.kt @@ -0,0 +1,63 @@ +package app.k9mail.feature.onboarding.main.navigation + +import androidx.compose.runtime.Composable +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.saveable.rememberSaveable +import androidx.compose.runtime.setValue +import androidx.navigation.NavController +import androidx.navigation.compose.NavHost +import androidx.navigation.compose.composable +import androidx.navigation.compose.rememberNavController +import app.k9mail.feature.account.setup.navigation.nestedAccountSetupRoute +import app.k9mail.feature.onboarding.permissions.ui.PermissionsScreen +import app.k9mail.feature.onboarding.welcome.ui.OnboardingScreen + +private const val NESTED_NAVIGATION_ROUTE_WELCOME = "welcome" +private const val NESTED_NAVIGATION_ROUTE_ACCOUNT_SETUP = "account_setup" +private const val NESTED_NAVIGATION_ROUTE_PERMISSIONS = "permissions" + +private fun NavController.navigateToAccountSetup() { + navigate(NESTED_NAVIGATION_ROUTE_ACCOUNT_SETUP) +} + +private fun NavController.navigateToPermissions() { + navigate(NESTED_NAVIGATION_ROUTE_PERMISSIONS) +} + +@Composable +fun OnboardingNavHost( + onImport: () -> Unit, + onBack: () -> Unit, + onFinish: (String) -> Unit, +) { + val navController = rememberNavController() + var accountUuid by rememberSaveable { mutableStateOf(null) } + + NavHost( + navController = navController, + startDestination = NESTED_NAVIGATION_ROUTE_WELCOME, + ) { + composable(route = NESTED_NAVIGATION_ROUTE_WELCOME) { + OnboardingScreen( + onStartClick = { navController.navigateToAccountSetup() }, + onImportClick = onImport, + ) + } + + nestedAccountSetupRoute( + route = NESTED_NAVIGATION_ROUTE_ACCOUNT_SETUP, + onBack = onBack, + onFinish = { createdAccountUuid -> + accountUuid = createdAccountUuid + navController.navigateToPermissions() + }, + ) + + composable(route = NESTED_NAVIGATION_ROUTE_PERMISSIONS) { + PermissionsScreen( + onNext = { onFinish(requireNotNull(accountUuid)) }, + ) + } + } +} diff --git a/feature/onboarding/main/src/main/kotlin/app/k9mail/feature/onboarding/main/navigation/OnboardingNavigation.kt b/feature/onboarding/main/src/main/kotlin/app/k9mail/feature/onboarding/main/navigation/OnboardingNavigation.kt index aa0082c5e..16cd0b3e7 100644 --- a/feature/onboarding/main/src/main/kotlin/app/k9mail/feature/onboarding/main/navigation/OnboardingNavigation.kt +++ b/feature/onboarding/main/src/main/kotlin/app/k9mail/feature/onboarding/main/navigation/OnboardingNavigation.kt @@ -4,7 +4,6 @@ import androidx.navigation.NavController import androidx.navigation.NavGraphBuilder import androidx.navigation.NavOptions import app.k9mail.core.ui.compose.common.navigation.deepLinkComposable -import app.k9mail.feature.onboarding.welcome.ui.OnboardingScreen const val NAVIGATION_ROUTE_ONBOARDING = "onboarding" @@ -15,13 +14,15 @@ fun NavController.navigateToOnboarding( } fun NavGraphBuilder.onboardingRoute( - onStart: () -> Unit, onImport: () -> Unit, + onBack: () -> Unit, + onFinish: (String) -> Unit, ) { deepLinkComposable(route = NAVIGATION_ROUTE_ONBOARDING) { - OnboardingScreen( - onStartClick = onStart, - onImportClick = onImport, + OnboardingNavHost( + onImport = onImport, + onBack = onBack, + onFinish = onFinish, ) } }