-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7354 from thunderbird/change_account_setup_naviga…
…tion Replace `AccountSetupScreen` with `AccountSetupNavHost`
- Loading branch information
Showing
12 changed files
with
139 additions
and
765 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
128 changes: 128 additions & 0 deletions
128
.../setup/src/main/kotlin/app/k9mail/feature/account/setup/navigation/AccountSetupNavHost.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
package app.k9mail.feature.account.setup.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.compose.NavHost | ||
import androidx.navigation.compose.composable | ||
import androidx.navigation.compose.rememberNavController | ||
import app.k9mail.feature.account.server.settings.ui.incoming.IncomingServerSettingsScreen | ||
import app.k9mail.feature.account.server.settings.ui.incoming.IncomingServerSettingsViewModel | ||
import app.k9mail.feature.account.server.settings.ui.outgoing.OutgoingServerSettingsScreen | ||
import app.k9mail.feature.account.server.settings.ui.outgoing.OutgoingServerSettingsViewModel | ||
import app.k9mail.feature.account.server.validation.ui.IncomingServerValidationViewModel | ||
import app.k9mail.feature.account.server.validation.ui.OutgoingServerValidationViewModel | ||
import app.k9mail.feature.account.server.validation.ui.ServerValidationScreen | ||
import app.k9mail.feature.account.setup.ui.autodiscovery.AccountAutoDiscoveryScreen | ||
import app.k9mail.feature.account.setup.ui.autodiscovery.AccountAutoDiscoveryViewModel | ||
import app.k9mail.feature.account.setup.ui.createaccount.CreateAccountScreen | ||
import app.k9mail.feature.account.setup.ui.createaccount.CreateAccountViewModel | ||
import app.k9mail.feature.account.setup.ui.options.AccountOptionsScreen | ||
import app.k9mail.feature.account.setup.ui.options.AccountOptionsViewModel | ||
import org.koin.androidx.compose.koinViewModel | ||
|
||
private const val NESTED_NAVIGATION_AUTO_CONFIG = "autoconfig" | ||
private const val NESTED_NAVIGATION_INCOMING_SERVER_CONFIG = "incoming-server/config" | ||
private const val NESTED_NAVIGATION_INCOMING_SERVER_VALIDATION = "incoming-server/validation" | ||
private const val NESTED_NAVIGATION_OUTGOING_SERVER_CONFIG = "outgoing-server/config" | ||
private const val NESTED_NAVIGATION_OUTGOING_SERVER_VALIDATION = "outgoing-server/validation" | ||
private const val NESTED_NAVIGATION_ACCOUNT_OPTIONS = "account-options" | ||
private const val NESTED_NAVIGATION_CREATE_ACCOUNT = "create-account" | ||
|
||
@Suppress("LongMethod") | ||
@Composable | ||
fun AccountSetupNavHost( | ||
onBack: () -> Unit, | ||
onFinish: (String) -> Unit, | ||
) { | ||
val navController = rememberNavController() | ||
var isAutomaticConfig by rememberSaveable { mutableStateOf(false) } | ||
|
||
NavHost( | ||
navController = navController, | ||
startDestination = NESTED_NAVIGATION_AUTO_CONFIG, | ||
) { | ||
composable(route = NESTED_NAVIGATION_AUTO_CONFIG) { | ||
AccountAutoDiscoveryScreen( | ||
onNext = { automaticConfig -> | ||
isAutomaticConfig = automaticConfig | ||
if (isAutomaticConfig) { | ||
navController.navigate(NESTED_NAVIGATION_INCOMING_SERVER_VALIDATION) | ||
} else { | ||
navController.navigate(NESTED_NAVIGATION_INCOMING_SERVER_CONFIG) | ||
} | ||
}, | ||
onBack = onBack, | ||
viewModel = koinViewModel<AccountAutoDiscoveryViewModel>(), | ||
) | ||
} | ||
|
||
composable(route = NESTED_NAVIGATION_INCOMING_SERVER_CONFIG) { | ||
IncomingServerSettingsScreen( | ||
onNext = { navController.navigate(NESTED_NAVIGATION_INCOMING_SERVER_VALIDATION) }, | ||
onBack = { navController.popBackStack() }, | ||
viewModel = koinViewModel<IncomingServerSettingsViewModel>(), | ||
) | ||
} | ||
|
||
composable(route = NESTED_NAVIGATION_INCOMING_SERVER_VALIDATION) { | ||
ServerValidationScreen( | ||
onNext = { | ||
if (isAutomaticConfig) { | ||
navController.navigate(NESTED_NAVIGATION_OUTGOING_SERVER_VALIDATION) { | ||
popUpTo(NESTED_NAVIGATION_AUTO_CONFIG) | ||
} | ||
} else { | ||
navController.navigate(NESTED_NAVIGATION_OUTGOING_SERVER_CONFIG) { | ||
popUpTo(NESTED_NAVIGATION_INCOMING_SERVER_CONFIG) | ||
} | ||
} | ||
}, | ||
onBack = { navController.popBackStack() }, | ||
viewModel = koinViewModel<IncomingServerValidationViewModel>(), | ||
) | ||
} | ||
|
||
composable(route = NESTED_NAVIGATION_OUTGOING_SERVER_CONFIG) { | ||
OutgoingServerSettingsScreen( | ||
onNext = { navController.navigate(NESTED_NAVIGATION_OUTGOING_SERVER_VALIDATION) }, | ||
onBack = { navController.popBackStack() }, | ||
viewModel = koinViewModel<OutgoingServerSettingsViewModel>(), | ||
) | ||
} | ||
|
||
composable(route = NESTED_NAVIGATION_OUTGOING_SERVER_VALIDATION) { | ||
ServerValidationScreen( | ||
onNext = { | ||
navController.navigate(NESTED_NAVIGATION_ACCOUNT_OPTIONS) { | ||
if (isAutomaticConfig) { | ||
popUpTo(NESTED_NAVIGATION_AUTO_CONFIG) | ||
} else { | ||
popUpTo(NESTED_NAVIGATION_OUTGOING_SERVER_CONFIG) | ||
} | ||
} | ||
}, | ||
onBack = { navController.popBackStack() }, | ||
viewModel = koinViewModel<OutgoingServerValidationViewModel>(), | ||
) | ||
} | ||
|
||
composable(route = NESTED_NAVIGATION_ACCOUNT_OPTIONS) { | ||
AccountOptionsScreen( | ||
onNext = { navController.navigate(NESTED_NAVIGATION_CREATE_ACCOUNT) }, | ||
onBack = { navController.popBackStack() }, | ||
viewModel = koinViewModel<AccountOptionsViewModel>(), | ||
) | ||
} | ||
|
||
composable(route = NESTED_NAVIGATION_CREATE_ACCOUNT) { | ||
CreateAccountScreen( | ||
onNext = { accountUuid -> onFinish(accountUuid.value) }, | ||
onBack = { navController.popBackStack() }, | ||
viewModel = koinViewModel<CreateAccountViewModel>(), | ||
) | ||
} | ||
} | ||
} |
23 changes: 1 addition & 22 deletions
23
...tup/src/main/kotlin/app/k9mail/feature/account/setup/navigation/AccountSetupNavigation.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 0 additions & 44 deletions
44
...account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/AccountSetupContract.kt
This file was deleted.
Oops, something went wrong.
126 changes: 0 additions & 126 deletions
126
...e/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/ui/AccountSetupScreen.kt
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.