Add permissions screen to onboarding flow
This commit is contained in:
parent
f3b06b9eb0
commit
fe33dd2cfa
9 changed files with 109 additions and 9 deletions
|
@ -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<TrustedSocketFactory> { DefaultTrustedSocketFactory(get(), get()) }
|
||||
single<OAuth2TokenProviderFactory> { RealOAuth2TokenProviderFactory(context = get()) }
|
||||
single(named("ClientIdAppName")) { "App Name" }
|
||||
single(named("ClientIdAppVersion")) { "App Version" }
|
||||
|
||||
includes(
|
||||
accountModule,
|
||||
featureOnboardingModule,
|
||||
featureAccountSetupModule,
|
||||
featureAccountEditModule,
|
||||
)
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
)
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
)
|
||||
}
|
|
@ -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<String?>(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)) },
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue