Skip to content

Commit

Permalink
feat: Avoid prompting the user when not needed
Browse files Browse the repository at this point in the history
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
  • Loading branch information
LunarX committed Dec 17, 2024
1 parent 0a39bc9 commit a2fd0bf
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<ImportFilesDestination> {
Expand All @@ -48,7 +52,7 @@ fun NewTransferNavHost(navController: NavHostController, closeActivity: () -> Un
composable<ValidateUserEmailDestination> {
val args = it.toRoute<ValidateUserEmailDestination>()
ValidateUserEmailScreen(
closeActivity = closeActivity,
closeActivity = closeActivityAndPromptForValidation,
navigateBack = { navController.popBackStack() },
emailToValidate = args.userEmail,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 })
}
Expand Down

0 comments on commit a2fd0bf

Please sign in to comment.