You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 660b727
Browse filesBrowse the repository at this point in the historyBrowse files
refactor: Introduce nested navigation graphs and share ViewModels
This commit refactors the navigation structure to use nested navigation graphs, improving organization and state management. It also modifies how ViewModels are scoped to share instances between screens within the same navigation graph, preserving UI state across tabs.
### Key Changes:
* **Nested Navigation Graphs (`AppNavigation.kt`, `AppRoute.kt`):**
* Introduced a `MainGraph` to encapsulate the primary application screens (`ProjectAnalyzer`, `StorageAnalyzer`) and a `SplashGraph` for the initial launch flow (`Splash`, `Onboarding`).
* This groups related destinations, simplifying navigation logic and making the flow more robust.
* **ViewModel Sharing (`ProjectAnalyzerScreen.kt`, `StorageAnalyzerScreen.kt`):**
* `ProjectAnalyzerViewModel` and `StorageAnalyzerViewModel` are now scoped to the `MainGraph`.
* This is achieved by passing the `NavBackStackEntry` of the parent graph (`MainGraph`) to the `koinViewModel` factory.
* As a result, the ViewModels are shared across the composables within the `MainGraph`, preserving the state of each screen when switching between the "Project" and "Storage" tabs.
* **Navigation Logic Cleanup (`AppNavigation.kt`):**
* Removed manual `popUpTo` logic with `findStartDestination()`. The new navigation structure with `launchSingleTop = true` and `restoreState = true` handles this more cleanly.
* **UI Enhancements (`TopAppBar.kt`):**
* The `TopAppBar` now supports an optional back navigation icon, which can be enabled by providing a `navigationOnClick` lambda.
Copy file name to clipboardExpand all lines: composeApp/src/jvmMain/kotlin/com/meet/dev/analyzer/presentation/screen/project/ProjectAnalyzerViewModel.kt
+4Lines changed: 4 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -26,6 +26,10 @@ class ProjectAnalyzerViewModel(
Copy file name to clipboardExpand all lines: composeApp/src/jvmMain/kotlin/com/meet/dev/analyzer/presentation/screen/storage/StorageAnalyzerViewModel.kt
0 commit comments