Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add confirmation when trying to leave the new transfer flow #255

Draft
wants to merge 6 commits into
base: mail-validation-ui
Choose a base branch
from

Conversation

LunarX
Copy link
Contributor

@LunarX LunarX commented Dec 16, 2024

Don't let them escape!

This required me to refactor the dialog composable we already have to have greater control over the buttons. I opted for a more standard interfacing logic instead of adding a lot of parameters. We can now compose the dialog with buttons. There's still two constant buttons already defined for the standard cases.

This PR also required to add stacking buttons in dialogs when the buttons are too wide which required to change the design of the buttons for plain text buttons like the native material theme so they are not misaligned when stacked.

Depends on #254

@LunarX LunarX added the enhancement New feature or request label Dec 16, 2024
@LunarX LunarX requested a review from a team December 16, 2024 08:44
@LunarX LunarX self-assigned this Dec 16, 2024
@LunarX LunarX force-pushed the mail-validation-ui branch from 4fe805d to 2f92daf Compare December 16, 2024 10:39
@LunarX LunarX force-pushed the ask-user-before-leaving-new-transfer branch 2 times, most recently from f8b8d2c to 87feb4a Compare December 16, 2024 11:31
@LunarX LunarX force-pushed the mail-validation-ui branch from 2f92daf to b9cff14 Compare December 16, 2024 11:31
Copy link
Contributor

@tevincent tevincent left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the screen is too small, the text is not visible on the right.

Capture d’écran 2024-12-16 à 12 43 54

And pressing the back button should also show the dialog right ?

Copy link

This PR/issue depends on:

@LunarX LunarX requested a review from tevincent December 16, 2024 13:15
@LunarX LunarX force-pushed the ask-user-before-leaving-new-transfer branch 4 times, most recently from becbb9b to f914928 Compare December 17, 2024 08:18
@LunarX LunarX force-pushed the ask-user-before-leaving-new-transfer branch 5 times, most recently from a2fd0bf to d270eac Compare December 17, 2024 15:52
@@ -107,6 +108,7 @@ private fun CoreButton(
showIndeterminateProgress,
progress,
onClick,
contentPadding = buttonSize.contentPadding
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
contentPadding = buttonSize.contentPadding
contentPadding = buttonSize.contentPadding,

fun confirmButton(isEnabled: () -> Boolean = { true }, onClick: () -> Unit) {
SmallButton(
style = ButtonType.TERTIARY,
title = stringResource(R.string.buttonConfirm),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could take this string to Core2 exaclty as the buttonCancel

@@ -31,15 +31,36 @@ import com.infomaniak.swisstransfer.ui.theme.Margin
import com.infomaniak.swisstransfer.ui.theme.SwissTransferTheme
import com.infomaniak.core2.R as RCore2

object SwissTransferAlertDialogDefaults {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is nice ! Adds real material component logic to this custom one

@@ -124,6 +124,12 @@ enum class ButtonType(val buttonColors: @Composable () -> ButtonColors) {
contentColor = SwissTransferTheme.materialColors.onError,
)
}),
ERROR_TEXT({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not really an error text, more of a destructive action button

@@ -97,6 +98,8 @@ fun ImportFilesScreen(

LaunchedEffect(Unit) { importFilesViewModel.initTransferOptionsValues() }

BackHandler { closeActivity() } // Closing the activity like other screens will prompt the user to be sure he wants to leave
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was a bit confuse with this sentence at first

Maybe we could rewrite this along the line of "We need to overwrite this to avoid prompting the user to be sure he wants to leave" ?

Comment on lines +61 to +62
positiveButton: @Composable () -> Unit,
negativeButton: @Composable () -> Unit,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should already use by default your newly created default buttons
I'd suggest to make this nullable all the way to ActionButton, and then manage it there

Copy link
Contributor Author

@LunarX LunarX Dec 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would've loved to as well, but we need to define the on click callbacks outside of it, so I can't set them as default values. The only option would be to provide two signatures for the SwissTransferAlertDialog; one that takes composables and one that takes only onClick callbacks. But this feels a bit too much :/

@LunarX LunarX force-pushed the ask-user-before-leaving-new-transfer branch from d270eac to 109e6b5 Compare December 18, 2024 09:12
@LunarX LunarX force-pushed the mail-validation-ui branch from 8cde32f to 3084096 Compare December 18, 2024 15:21
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
@LunarX LunarX force-pushed the ask-user-before-leaving-new-transfer branch from 109e6b5 to 9b62657 Compare December 18, 2024 15:27
}

@Composable
fun cancelButton(onClick: () -> Unit) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be Uppercase

@LunarX LunarX force-pushed the mail-validation-ui branch from 40e505e to 6ecf5a5 Compare December 20, 2024 16:06
@KevinBoulongne KevinBoulongne marked this pull request as draft December 24, 2024 09:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependent enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants