From a2fd0bf31880fc05b08cd20eb63b62e509815ed2 Mon Sep 17 00:00:00 2001 From: Gibran Chevalley Date: Mon, 16 Dec 2024 14:54:43 +0100 Subject: [PATCH] feat: Avoid prompting the user when not needed When canceling an upload in progress, you'll be asked to confirm a first time and then when you're back on ImportFilesScreen, you'll need to confirm again to leave. This takes way too many clicks, the confirmation on ImportFilesScreen is not needed --- .../ui/screen/newtransfer/NewTransferNavHost.kt | 8 ++++++-- .../ui/screen/newtransfer/NewTransferScreen.kt | 6 +++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/NewTransferNavHost.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/NewTransferNavHost.kt index f767d3cc0..5a9e472e2 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/NewTransferNavHost.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/NewTransferNavHost.kt @@ -31,7 +31,11 @@ import com.infomaniak.swisstransfer.ui.screen.newtransfer.upload.UploadSuccessSc import com.infomaniak.swisstransfer.ui.screen.newtransfer.validateemail.ValidateUserEmailScreen @Composable -fun NewTransferNavHost(navController: NavHostController, closeActivity: () -> Unit) { +fun NewTransferNavHost( + navController: NavHostController, + closeActivity: () -> Unit, + closeActivityAndPromptForValidation: () -> Unit, +) { NavHost(navController, NewTransferNavigation.startDestination) { composable { @@ -48,7 +52,7 @@ fun NewTransferNavHost(navController: NavHostController, closeActivity: () -> Un composable { val args = it.toRoute() ValidateUserEmailScreen( - closeActivity = closeActivity, + closeActivity = closeActivityAndPromptForValidation, navigateBack = { navController.popBackStack() }, emailToValidate = args.userEmail, ) diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/NewTransferScreen.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/NewTransferScreen.kt index 14e5d4f2c..c8c2811fc 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/NewTransferScreen.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/NewTransferScreen.kt @@ -36,7 +36,11 @@ fun NewTransferScreen(closeActivity: () -> Unit) { val navController = rememberNavController() var displayConfirmationDialog by rememberSaveable { mutableStateOf(false) } - NewTransferNavHost(navController, closeActivity = { displayConfirmationDialog = true }) + NewTransferNavHost( + navController, + closeActivity = closeActivity, + closeActivityAndPromptForValidation = { displayConfirmationDialog = true }, + ) if (displayConfirmationDialog) ConfirmLeavingDialog(onLeave = closeActivity, onCancel = { displayConfirmationDialog = false }) }