Skip to content

Commit fa4d662

Browse files
committed
Share UserProfileViewModel between drawer and UserProfileView
Allow drawer to see user profile updates
1 parent fb0f748 commit fa4d662

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/app/src/main/java/com/couchbase/learningpath/InventoryNavGraph.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ fun InventoryNavGraph(
6666
navController: NavHostController = rememberNavController(),
6767
scaffoldState: ScaffoldState = rememberScaffoldState(),
6868
scope: CoroutineScope = rememberCoroutineScope(),
69+
userProfileViewModel: UserProfileViewModel,
6970
startDestination: String = MainDestinations.LOGIN_ROUTE) {
7071
val actions = remember(navController) { MainActions(navController) }
7172
NavHost(navController = navController,
@@ -192,7 +193,7 @@ fun InventoryNavGraph(
192193
UserProfileView(
193194
openDrawer = openDrawer,
194195
scaffoldState = scaffoldState,
195-
viewModel = getViewModel<UserProfileViewModel>())
196+
viewModel = userProfileViewModel)
196197
}
197198

198199
composable(MainDestinations.DEVELOPER_ROUTE){

src/app/src/main/java/com/couchbase/learningpath/ui/MainActivity.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,8 @@ class MainActivity : ComponentActivity() {
117117
openDrawer = { openDrawer() },
118118
navController = navController,
119119
scaffoldState = scaffoldState,
120-
scope = scope
120+
scope = scope,
121+
profileViewModel
121122
)
122123
}
123124
}

0 commit comments

Comments
 (0)