@@ -196,43 +196,76 @@ class MainActivity : ComponentActivity() {
196
196
val updatesViewModel = mainViewModel.updates
197
197
val rebootViewModel = mainViewModel.reboot
198
198
BackHandler (enabled = mainViewModel.isRefreshing, onBack = {})
199
- val slotContent: @Composable AnimatedVisibilityScope .(NavBackStackEntry ) -> Unit = { backStackEntry ->
200
- val slotSuffix = backStackEntry.arguments?.getString(" slotSuffix" ) ? : " "
201
- val slotViewModel = if (slotSuffix == " _b" ) slotViewModelB else slotViewModelA
202
- if (slotViewModel!! .wasFlashSuccess != null && listOf (" slot{slotSuffix}" , " slot" ).any { navController.currentDestination!! .route.equals(it) }) {
199
+ val slotContentA: @Composable AnimatedVisibilityScope .(NavBackStackEntry ) -> Unit = { backStackEntry ->
200
+ val slotViewModel = slotViewModelA
201
+ if (slotViewModel!! .wasFlashSuccess != null && listOf (" slot_a" , " slot" ).any { navController.currentDestination!! .route.equals(it) }) {
203
202
slotViewModel.clearFlash(this @MainActivity)
204
203
}
205
204
RefreshableScreen (mainViewModel, navController, swipeEnabled = true ) {
206
- SlotContent (slotViewModel, slotSuffix , navController)
205
+ SlotContent (slotViewModel, " _a " , navController)
207
206
}
208
207
209
208
}
210
- val slotFlashContent: @Composable AnimatedVisibilityScope .(NavBackStackEntry ) -> Unit = { backStackEntry ->
211
- val slotSuffix = backStackEntry.arguments?.getString(" slotSuffix" ) ? : " "
212
- val slotViewModel = if (slotSuffix == " _b" ) slotViewModelB else slotViewModelA
209
+ val slotContentB: @Composable AnimatedVisibilityScope .(NavBackStackEntry ) -> Unit = { backStackEntry ->
210
+ val slotViewModel = slotViewModelB
211
+ if (slotViewModel!! .wasFlashSuccess != null && listOf (" slot_b" , " slot" ).any { navController.currentDestination!! .route.equals(it) }) {
212
+ slotViewModel.clearFlash(this @MainActivity)
213
+ }
214
+ RefreshableScreen (mainViewModel, navController, swipeEnabled = true ) {
215
+ SlotContent (slotViewModel, " _b" , navController)
216
+ }
217
+
218
+ }
219
+ val slotFlashContentA: @Composable AnimatedVisibilityScope .(NavBackStackEntry ) -> Unit = { backStackEntry ->
220
+ val slotViewModel = slotViewModelA
213
221
RefreshableScreen (mainViewModel, navController) {
214
- SlotFlashContent (slotViewModel!! , slotSuffix , navController)
222
+ SlotFlashContent (slotViewModel!! , " _a " , navController)
215
223
}
216
224
}
217
- val slotBackupsContent: @Composable AnimatedVisibilityScope .(NavBackStackEntry ) -> Unit = { backStackEntry ->
218
- val slotSuffix = backStackEntry.arguments?.getString(" slotSuffix" ) ? : " "
219
- val slotViewModel = if (slotSuffix == " _b" ) slotViewModelB else slotViewModelA
225
+ val slotFlashContentB: @Composable AnimatedVisibilityScope .(NavBackStackEntry ) -> Unit = { backStackEntry ->
226
+ val slotViewModel = slotViewModelB
227
+ RefreshableScreen (mainViewModel, navController) {
228
+ SlotFlashContent (slotViewModel!! , " _b" , navController)
229
+ }
230
+ }
231
+ val slotBackupsContentA: @Composable AnimatedVisibilityScope .(NavBackStackEntry ) -> Unit = { backStackEntry ->
232
+ val slotViewModel = slotViewModelA
220
233
if (backStackEntry.arguments?.getString(" backupId" ) != null ) {
221
234
backupsViewModel.currentBackup = backStackEntry.arguments?.getString(" backupId" )
222
235
} else {
223
236
backupsViewModel.clearCurrent()
224
237
}
225
238
RefreshableScreen (mainViewModel, navController) {
226
- SlotBackupsContent (slotViewModel!! , backupsViewModel, slotSuffix , navController)
239
+ SlotBackupsContent (slotViewModel!! , backupsViewModel, " _a " , navController)
227
240
}
228
241
}
229
- val slotBackupFlashContent: @Composable AnimatedVisibilityScope .(NavBackStackEntry ) -> Unit = { backStackEntry ->
230
- val slotSuffix = backStackEntry.arguments?.getString(" slotSuffix" ) ? : " "
231
- val slotViewModel = if (slotSuffix == " _b" ) slotViewModelB else slotViewModelA
242
+ val slotBackupsContentB: @Composable AnimatedVisibilityScope .(NavBackStackEntry ) -> Unit = { backStackEntry ->
243
+ val slotViewModel = slotViewModelB
244
+ if (backStackEntry.arguments?.getString(" backupId" ) != null ) {
245
+ backupsViewModel.currentBackup = backStackEntry.arguments?.getString(" backupId" )
246
+ } else {
247
+ backupsViewModel.clearCurrent()
248
+ }
249
+ RefreshableScreen (mainViewModel, navController) {
250
+ SlotBackupsContent (slotViewModel!! , backupsViewModel, " _b" , navController)
251
+ }
252
+ }
253
+ val slotBackupFlashContentA: @Composable AnimatedVisibilityScope .(NavBackStackEntry ) -> Unit = { backStackEntry ->
254
+ val slotViewModel = slotViewModelA
255
+ backupsViewModel.currentBackup = backStackEntry.arguments?.getString(" backupId" )
256
+ if (backupsViewModel.backups.containsKey(backupsViewModel.currentBackup)) {
257
+ RefreshableScreen (mainViewModel, navController) {
258
+ SlotFlashContent (slotViewModel!! , " _a" , navController)
259
+ }
260
+ }
261
+
262
+ }
263
+ val slotBackupFlashContentB: @Composable AnimatedVisibilityScope .(NavBackStackEntry ) -> Unit = { backStackEntry ->
264
+ val slotViewModel = slotViewModelB
232
265
backupsViewModel.currentBackup = backStackEntry.arguments?.getString(" backupId" )
233
266
if (backupsViewModel.backups.containsKey(backupsViewModel.currentBackup)) {
234
267
RefreshableScreen (mainViewModel, navController) {
235
- SlotFlashContent (slotViewModel!! , slotSuffix , navController)
268
+ SlotFlashContent (slotViewModel!! , " _b " , navController)
236
269
}
237
270
}
238
271
@@ -244,18 +277,31 @@ class MainActivity : ComponentActivity() {
244
277
}
245
278
}
246
279
if (mainViewModel.isAb) {
247
- composable(" slot{slotSuffix}" , content = slotContent)
248
- composable(" slot{slotSuffix}/flash" , content = slotFlashContent)
249
- composable(" slot{slotSuffix}/flash/ak3" , content = slotFlashContent)
250
- composable(" slot{slotSuffix}/flash/image" , content = slotFlashContent)
251
- composable(" slot{slotSuffix}/flash/image/flash" , content = slotFlashContent)
252
- composable(" slot{slotSuffix}/backup" , content = slotFlashContent)
253
- composable(" slot{slotSuffix}/backup/backup" , content = slotFlashContent)
254
- composable(" slot{slotSuffix}/backups" , content = slotBackupsContent)
255
- composable(" slot{slotSuffix}/backups/{backupId}" , content = slotBackupsContent)
256
- composable(" slot{slotSuffix}/backups/{backupId}/restore" , content = slotBackupsContent)
257
- composable(" slot{slotSuffix}/backups/{backupId}/restore/restore" , content = slotBackupsContent)
258
- composable(" slot{slotSuffix}/backups/{backupId}/flash/ak3" , content = slotBackupFlashContent)
280
+ composable(" slot_a" , content = slotContentA)
281
+ composable(" slot_a/flash" , content = slotFlashContentA)
282
+ composable(" slot_a/flash/ak3" , content = slotFlashContentA)
283
+ composable(" slot_a/flash/image" , content = slotFlashContentA)
284
+ composable(" slot_a/flash/image/flash" , content = slotFlashContentA)
285
+ composable(" slot_a/backup" , content = slotFlashContentA)
286
+ composable(" slot_a/backup/backup" , content = slotFlashContentA)
287
+ composable(" slot_a/backups" , content = slotBackupsContentA)
288
+ composable(" slot_a/backups/{backupId}" , content = slotBackupsContentA)
289
+ composable(" slot_a/backups/{backupId}/restore" , content = slotBackupsContentA)
290
+ composable(" slot_a/backups/{backupId}/restore/restore" , content = slotBackupsContentA)
291
+ composable(" slot_a/backups/{backupId}/flash/ak3" , content = slotBackupFlashContentA)
292
+
293
+ composable(" slot_b" , content = slotContentB)
294
+ composable(" slot_b/flash" , content = slotFlashContentB)
295
+ composable(" slot_b/flash/ak3" , content = slotFlashContentB)
296
+ composable(" slot_b/flash/image" , content = slotFlashContentB)
297
+ composable(" slot_b/flash/image/flash" , content = slotFlashContentB)
298
+ composable(" slot_b/backup" , content = slotFlashContentB)
299
+ composable(" slot_b/backup/backup" , content = slotFlashContentB)
300
+ composable(" slot_b/backups" , content = slotBackupsContentB)
301
+ composable(" slot_b/backups/{backupId}" , content = slotBackupsContentB)
302
+ composable(" slot_b/backups/{backupId}/restore" , content = slotBackupsContentB)
303
+ composable(" slot_b/backups/{backupId}/restore/restore" , content = slotBackupsContentB)
304
+ composable(" slot_b/backups/{backupId}/flash/ak3" , content = slotBackupFlashContentB)
259
305
} else {
260
306
composable(" slot" , content = slotContent)
261
307
composable(" slot/flash" , content = slotFlashContent)
0 commit comments