mirror of
https://github.com/d4rken-org/capod.git
synced 2026-09-14 18:26:11 -04:00
fix(ui): Determine start destination before composing backstack
Check onboarding state in MainActivity before creating the NavBackStack, so the correct screen is shown from the first frame. Removes the redundant async check from OverviewViewModel that caused the dashboard to briefly flash before redirecting to onboarding on fresh installs.
This commit is contained in:
@@ -18,6 +18,7 @@ import eu.darken.capod.common.navigation.NavigationController
|
||||
import eu.darken.capod.common.navigation.NavigationEntry
|
||||
import eu.darken.capod.common.theming.CapodTheme
|
||||
import eu.darken.capod.common.uix.Activity2
|
||||
import eu.darken.capod.main.core.GeneralSettings
|
||||
import javax.inject.Inject
|
||||
|
||||
@AndroidEntryPoint
|
||||
@@ -25,14 +26,21 @@ class MainActivity : Activity2() {
|
||||
|
||||
@Inject lateinit var navCtrl: NavigationController
|
||||
@Inject lateinit var navigationEntries: Set<@JvmSuppressWildcards NavigationEntry>
|
||||
@Inject lateinit var generalSettings: GeneralSettings
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
installSplashScreen()
|
||||
enableEdgeToEdge()
|
||||
|
||||
val startDestination: NavKey = if (generalSettings.isOnboardingDone.value) {
|
||||
Nav.Main.Overview
|
||||
} else {
|
||||
Nav.Main.Onboarding
|
||||
}
|
||||
|
||||
setContent {
|
||||
val backStack = rememberNavBackStack(Nav.Main.Overview)
|
||||
val backStack = rememberNavBackStack(startDestination)
|
||||
navCtrl.setup(backStack)
|
||||
|
||||
CapodTheme {
|
||||
|
||||
@@ -49,12 +49,6 @@ class OverviewViewModel @Inject constructor(
|
||||
private val profilesRepo: DeviceProfilesRepo,
|
||||
) : ViewModel4(dispatcherProvider) {
|
||||
|
||||
init {
|
||||
if (!generalSettings.isOnboardingDone.value) {
|
||||
navTo(Nav.Main.Onboarding, popUpTo = Nav.Main.Overview, inclusive = true)
|
||||
}
|
||||
}
|
||||
|
||||
val requestPermissionEvent = SingleEventFlow<Permission>()
|
||||
val launchUpgradeFlow = SingleEventFlow<(Activity) -> Unit>()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user