File tree Expand file tree Collapse file tree 3 files changed +10
-9
lines changed
core/common/src/main/java/com/yapp/common/navigation
feature/onboarding/src/main/java/com/yapp/onboarding Expand file tree Collapse file tree 3 files changed +10
-9
lines changed Original file line number Diff line number Diff line change 11package com.yapp.common.navigation
22
3+ import android.util.Log
34import androidx.compose.runtime.Composable
45import androidx.compose.runtime.remember
56import androidx.navigation.NavHostController
@@ -28,12 +29,12 @@ class OrbitNavigator(
2829 }
2930
3031 fun navigateToOnboardingNextStep (currentStep : Int , navOptions : NavOptions ? = null) {
31- val nextRouteClass = OnboardingDestination .nextRoute (currentStep + 1 ) ? : return
32-
33- val nextRouteInstance = nextRouteClass.objectInstance
34- ? : error( " Cannot get object instance of route class: $nextRouteClass " )
35-
36- navController.navigate(nextRouteInstance, navOptions)
32+ val instance = OnboardingDestination .getNextRouteForStep (currentStep)?.objectInstance
33+ if (instance != null ) {
34+ navController.navigate(instance, navOptions)
35+ } else {
36+ Log .e( " Navigator " , " Invalid route at step: $currentStep " )
37+ }
3738 }
3839
3940 fun navigateToAddAlarm (navOptions : NavOptions ? = null) {
Original file line number Diff line number Diff line change @@ -47,8 +47,8 @@ sealed class OnboardingDestination {
4747 Complete2 ::class ,
4848 )
4949
50- fun nextRoute (currentStep : Int ): KClass <out OnboardingDestination >? {
51- val nextRoute = routes.getOrNull(currentStep)
50+ fun getNextRouteForStep (currentStep : Int ): KClass <out OnboardingDestination >? {
51+ val nextRoute = routes.getOrNull(currentStep + 1 )
5252 return nextRoute
5353 }
5454 }
Original file line number Diff line number Diff line change @@ -96,7 +96,7 @@ class OnboardingViewModel @Inject constructor(
9696 private fun moveToNextStep () {
9797 val currentStep = container.stateFlow.value.currentStep
9898 val nextStep = currentStep + 1
99- val nextRoute = OnboardingDestination .nextRoute (currentStep)
99+ val nextRoute = OnboardingDestination .getNextRouteForStep (currentStep)
100100
101101 savedStateHandle[" birthDate" ] = currentState.birthDate
102102 savedStateHandle[" birthType" ] = currentState.birthType
You can’t perform that action at this time.
0 commit comments