@@ -196,9 +196,31 @@ class MainActivity : ComponentActivity() {
196
196
val updatesViewModel = mainViewModel.updates
197
197
val rebootViewModel = mainViewModel.reboot
198
198
BackHandler (enabled = mainViewModel.isRefreshing, onBack = {})
199
+ val slotContentA: @Composable AnimatedVisibilityScope .(NavBackStackEntry ) -> Unit = { backStackEntry ->
200
+ val slotSuffix = " _a"
201
+ val slotViewModel = slotViewModelA
202
+ if (slotViewModel!! .wasFlashSuccess != null && listOf (" slot{slotSuffix}" , " slot" ).any { navController.currentDestination!! .route.equals(it) }) {
203
+ slotViewModel.clearFlash(this @MainActivity)
204
+ }
205
+ RefreshableScreen (mainViewModel, navController, swipeEnabled = true ) {
206
+ SlotContent (slotViewModel, slotSuffix, navController)
207
+ }
208
+
209
+ }
210
+ val slotContentB: @Composable AnimatedVisibilityScope .(NavBackStackEntry ) -> Unit = { backStackEntry ->
211
+ val slotSuffix = " _b"
212
+ val slotViewModel = slotViewModelB
213
+ if (slotViewModel!! .wasFlashSuccess != null && listOf (" slot{slotSuffix}" , " slot" ).any { navController.currentDestination!! .route.equals(it) }) {
214
+ slotViewModel.clearFlash(this @MainActivity)
215
+ }
216
+ RefreshableScreen (mainViewModel, navController, swipeEnabled = true ) {
217
+ SlotContent (slotViewModel, slotSuffix, navController)
218
+ }
219
+
220
+ }
199
221
val slotContent: @Composable AnimatedVisibilityScope .(NavBackStackEntry ) -> Unit = { backStackEntry ->
200
- val slotSuffix = backStackEntry.arguments?.getString( " slotSuffix " ) ? : " "
201
- val slotViewModel = if (slotSuffix == " _b " ) slotViewModelB else slotViewModelA
222
+ val slotSuffix = " "
223
+ val slotViewModel = slotViewModelA
202
224
if (slotViewModel!! .wasFlashSuccess != null && listOf (" slot{slotSuffix}" , " slot" ).any { navController.currentDestination!! .route.equals(it) }) {
203
225
slotViewModel.clearFlash(this @MainActivity)
204
226
}
@@ -207,16 +229,54 @@ class MainActivity : ComponentActivity() {
207
229
}
208
230
209
231
}
232
+ val slotFlashContentA: @Composable AnimatedVisibilityScope .(NavBackStackEntry ) -> Unit = { backStackEntry ->
233
+ val slotSuffix = " _a"
234
+ val slotViewModel = slotViewModelA
235
+ RefreshableScreen (mainViewModel, navController) {
236
+ SlotFlashContent (slotViewModel!! , slotSuffix, navController)
237
+ }
238
+ }
239
+ val slotFlashContentB: @Composable AnimatedVisibilityScope .(NavBackStackEntry ) -> Unit = { backStackEntry ->
240
+ val slotSuffix = " _b"
241
+ val slotViewModel = slotViewModelB
242
+ RefreshableScreen (mainViewModel, navController) {
243
+ SlotFlashContent (slotViewModel!! , slotSuffix, navController)
244
+ }
245
+ }
210
246
val slotFlashContent: @Composable AnimatedVisibilityScope .(NavBackStackEntry ) -> Unit = { backStackEntry ->
211
- val slotSuffix = backStackEntry.arguments?.getString( " slotSuffix " ) ? : " "
212
- val slotViewModel = if (slotSuffix == " _b " ) slotViewModelB else slotViewModelA
247
+ val slotSuffix = " "
248
+ val slotViewModel = slotViewModelA
213
249
RefreshableScreen (mainViewModel, navController) {
214
250
SlotFlashContent (slotViewModel!! , slotSuffix, navController)
215
251
}
216
252
}
253
+ val slotBackupsContentA: @Composable AnimatedVisibilityScope .(NavBackStackEntry ) -> Unit = { backStackEntry ->
254
+ val slotSuffix = " _a"
255
+ val slotViewModel = slotViewModelA
256
+ if (backStackEntry.arguments?.getString(" backupId" ) != null ) {
257
+ backupsViewModel.currentBackup = backStackEntry.arguments?.getString(" backupId" )
258
+ } else {
259
+ backupsViewModel.clearCurrent()
260
+ }
261
+ RefreshableScreen (mainViewModel, navController) {
262
+ SlotBackupsContent (slotViewModel!! , backupsViewModel, slotSuffix, navController)
263
+ }
264
+ }
265
+ val slotBackupsContentB: @Composable AnimatedVisibilityScope .(NavBackStackEntry ) -> Unit = { backStackEntry ->
266
+ val slotSuffix = " _b"
267
+ val slotViewModel = slotViewModelB
268
+ if (backStackEntry.arguments?.getString(" backupId" ) != null ) {
269
+ backupsViewModel.currentBackup = backStackEntry.arguments?.getString(" backupId" )
270
+ } else {
271
+ backupsViewModel.clearCurrent()
272
+ }
273
+ RefreshableScreen (mainViewModel, navController) {
274
+ SlotBackupsContent (slotViewModel!! , backupsViewModel, slotSuffix, navController)
275
+ }
276
+ }
217
277
val slotBackupsContent: @Composable AnimatedVisibilityScope .(NavBackStackEntry ) -> Unit = { backStackEntry ->
218
- val slotSuffix = backStackEntry.arguments?.getString( " slotSuffix " ) ? : " "
219
- val slotViewModel = if (slotSuffix == " _b " ) slotViewModelB else slotViewModelA
278
+ val slotSuffix = " "
279
+ val slotViewModel = slotViewModelA
220
280
if (backStackEntry.arguments?.getString(" backupId" ) != null ) {
221
281
backupsViewModel.currentBackup = backStackEntry.arguments?.getString(" backupId" )
222
282
} else {
@@ -226,9 +286,31 @@ class MainActivity : ComponentActivity() {
226
286
SlotBackupsContent (slotViewModel!! , backupsViewModel, slotSuffix, navController)
227
287
}
228
288
}
289
+ val slotBackupFlashContentA: @Composable AnimatedVisibilityScope .(NavBackStackEntry ) -> Unit = { backStackEntry ->
290
+ val slotSuffix = " _a"
291
+ val slotViewModel = slotViewModelA
292
+ backupsViewModel.currentBackup = backStackEntry.arguments?.getString(" backupId" )
293
+ if (backupsViewModel.backups.containsKey(backupsViewModel.currentBackup)) {
294
+ RefreshableScreen (mainViewModel, navController) {
295
+ SlotFlashContent (slotViewModel!! , slotSuffix, navController)
296
+ }
297
+ }
298
+
299
+ }
300
+ val slotBackupFlashContentB: @Composable AnimatedVisibilityScope .(NavBackStackEntry ) -> Unit = { backStackEntry ->
301
+ val slotSuffix = " _b"
302
+ val slotViewModel = slotViewModelB
303
+ backupsViewModel.currentBackup = backStackEntry.arguments?.getString(" backupId" )
304
+ if (backupsViewModel.backups.containsKey(backupsViewModel.currentBackup)) {
305
+ RefreshableScreen (mainViewModel, navController) {
306
+ SlotFlashContent (slotViewModel!! , slotSuffix, navController)
307
+ }
308
+ }
309
+
310
+ }
229
311
val slotBackupFlashContent: @Composable AnimatedVisibilityScope .(NavBackStackEntry ) -> Unit = { backStackEntry ->
230
- val slotSuffix = backStackEntry.arguments?.getString( " slotSuffix " ) ? : " "
231
- val slotViewModel = if (slotSuffix == " _b " ) slotViewModelB else slotViewModelA
312
+ val slotSuffix = " "
313
+ val slotViewModel = slotViewModelA
232
314
backupsViewModel.currentBackup = backStackEntry.arguments?.getString(" backupId" )
233
315
if (backupsViewModel.backups.containsKey(backupsViewModel.currentBackup)) {
234
316
RefreshableScreen (mainViewModel, navController) {
@@ -244,18 +326,31 @@ class MainActivity : ComponentActivity() {
244
326
}
245
327
}
246
328
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)
329
+ composable(" slot_a" , content = slotContentA)
330
+ composable(" slot_a/flash" , content = slotFlashContentA)
331
+ composable(" slot_a/flash/ak3" , content = slotFlashContentA)
332
+ composable(" slot_a/flash/image" , content = slotFlashContentA)
333
+ composable(" slot_a/flash/image/flash" , content = slotFlashContentA)
334
+ composable(" slot_a/backup" , content = slotFlashContentA)
335
+ composable(" slot_a/backup/backup" , content = slotFlashContentA)
336
+ composable(" slot_a/backups" , content = slotBackupsContentA)
337
+ composable(" slot_a/backups/{backupId}" , content = slotBackupsContentA)
338
+ composable(" slot_a/backups/{backupId}/restore" , content = slotBackupsContentA)
339
+ composable(" slot_a/backups/{backupId}/restore/restore" , content = slotBackupsContentA)
340
+ composable(" slot_a/backups/{backupId}/flash/ak3" , content = slotBackupFlashContentA)
341
+
342
+ composable(" slot_b" , content = slotContentB)
343
+ composable(" slot_b/flash" , content = slotFlashContentB)
344
+ composable(" slot_b/flash/ak3" , content = slotFlashContentB)
345
+ composable(" slot_b/flash/image" , content = slotFlashContentB)
346
+ composable(" slot_b/flash/image/flash" , content = slotFlashContentB)
347
+ composable(" slot_b/backup" , content = slotFlashContentB)
348
+ composable(" slot_b/backup/backup" , content = slotFlashContentB)
349
+ composable(" slot_b/backups" , content = slotBackupsContentB)
350
+ composable(" slot_b/backups/{backupId}" , content = slotBackupsContentB)
351
+ composable(" slot_b/backups/{backupId}/restore" , content = slotBackupsContentB)
352
+ composable(" slot_b/backups/{backupId}/restore/restore" , content = slotBackupsContentB)
353
+ composable(" slot_b/backups/{backupId}/flash/ak3" , content = slotBackupFlashContentB)
259
354
} else {
260
355
composable(" slot" , content = slotContent)
261
356
composable(" slot/flash" , content = slotFlashContent)
0 commit comments