@@ -61,6 +61,7 @@ internal const val ARG_ADD_BY_IDENTIFIER = "addByIdentifierArg"
61
61
62
62
@Composable
63
63
internal fun DashboardRootPhoneNavigation (
64
+ collectionDefaultValue : String ,
64
65
onPickFile : (callPoint: EventBusConstants .FileWasSelected .CallPoint ) -> Unit ,
65
66
onOpenFile : (file: File , mimeType: String ) -> Unit ,
66
67
onOpenWebpage : (uri: Uri ) -> Unit ,
@@ -76,10 +77,11 @@ internal fun DashboardRootPhoneNavigation(
76
77
77
78
78
79
LaunchedEffect (key1 = viewEffect) {
79
- when (viewEffect?.consume()) {
80
+ val consumedEffect = viewEffect?.consume()
81
+ when (consumedEffect) {
80
82
null -> Unit
81
- DashboardViewEffect .NavigateToCollectionsScreen -> navigateToCollectionsScreen(
82
- navController
83
+ is DashboardViewEffect .NavigateToCollectionsScreen -> navigateToCollectionsScreen(
84
+ navController, consumedEffect.screenArgs
83
85
)
84
86
}
85
87
}
@@ -93,10 +95,11 @@ internal fun DashboardRootPhoneNavigation(
93
95
modifier = Modifier .navigationBarsPadding(), // do not draw behind nav bar
94
96
) {
95
97
collectionsScreen(
98
+ collectionDefaultValue = collectionDefaultValue,
96
99
onBack = navigation::onBack,
97
100
navigateToAllItems = {
98
101
toAllItems(
99
- navController = navController,
102
+ navController = navController,it
100
103
)
101
104
},
102
105
navigateToLibraries = {
@@ -106,7 +109,7 @@ internal fun DashboardRootPhoneNavigation(
106
109
)
107
110
librariesScreen(
108
111
navigateToCollectionsScreen = {
109
- navigateToCollectionsScreen(navController)
112
+ navigateToCollectionsScreen(navController, it )
110
113
},
111
114
onSettingsTapped = { navigation.toSettingsScreen() }
112
115
)
@@ -240,10 +243,10 @@ internal fun DashboardRootPhoneNavigation(
240
243
}
241
244
}
242
245
243
- private fun navigateToCollectionsScreen (navController : NavHostController ) {
246
+ private fun navigateToCollectionsScreen (navController : NavHostController , collectionArgs : String ) {
244
247
navController.popBackStack(navController.graph.id, inclusive = true )
245
248
navController.navigate(CommonScreenDestinations .LIBRARIES_SCREEN )
246
- navController.navigate(CommonScreenDestinations .COLLECTIONS_SCREEN )
249
+ navController.navigate(" ${ CommonScreenDestinations .COLLECTIONS_SCREEN } / $collectionArgs " )
247
250
}
248
251
249
252
private object DashboardRootPhoneDestinations {
@@ -257,8 +260,8 @@ private object DashboardRootPhoneDestinations {
257
260
258
261
}
259
262
260
- private fun ZoteroNavigation.toCollectionsScreen () {
261
- navController.navigate(CommonScreenDestinations .COLLECTIONS_SCREEN ) {
263
+ private fun ZoteroNavigation.toCollectionsScreen (params : String ) {
264
+ navController.navigate(" ${ CommonScreenDestinations .COLLECTIONS_SCREEN } / $params " ) {
262
265
launchSingleTop = true
263
266
}
264
267
}
@@ -289,9 +292,10 @@ private fun ZoteroNavigation.toRetrieveMetadata(args: String) {
289
292
290
293
private fun toAllItems (
291
294
navController : NavHostController ,
295
+ collectionArgs : String ,
292
296
) {
293
297
navController.popBackStack(navController.graph.id, inclusive = true )
294
- navController.navigate(CommonScreenDestinations .COLLECTIONS_SCREEN )
298
+ navController.navigate(" ${ CommonScreenDestinations .COLLECTIONS_SCREEN } / $collectionArgs " )
295
299
navController.navigate(CommonScreenDestinations .ALL_ITEMS )
296
300
}
297
301
0 commit comments