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

Added closeToasts attribute to the nagivateModal and navigateScreen #1499

Merged
merged 2 commits into from
Jul 23, 2024

Conversation

hemish11
Copy link
Contributor

Closes #1493

@hemish11 hemish11 self-assigned this Jul 21, 2024
@hemish11
Copy link
Contributor Author

Sample EDL:

View:
  title: "Action: navigateScreen"
  styles:
    scrollableView: true

  body:
    Column:
      styles:
        gap: 16
        padding: 24
      children:
        - Button:
            label: Show Success
            onTap:
              showToast:
                message: Success! by default at screen's top right
                options:
                  dismissable: true
                  type: success
                  duration: 3
                styles:
                  backgroundColor: 0xFFEDEDED
                  padding: 16 24

        - Button:
            label: Show Modal
            onTap:
              navigateModalScreen:
                name: Hello Home

        - Button:
            label: Navigate and clear all screen history
            onTap:
              navigateScreen:
                name: Hello Home
                options:
                  clearAllScreens: true
                  closeToasts: true

@@ -28,6 +28,10 @@ class ToastController {
return _instance;
}

void closeToast() {
_toast.removeQueuedCustomToasts();
Copy link
Collaborator

@kmahmood74 kmahmood74 Jul 22, 2024

Choose a reason for hiding this comment

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

this will only get rid of the queued ones, what about the present one?
I believe you will have to call Fluttertoast.cancel() and then call _toast.removeQueuedCustomToasts(); and that would get rid of the current one and the ones in the queue right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, I thought the same at first, but then I looked at the code and we are using FToast and not Fluttertoast, so the package provides two different classes. And due to that I was using the FToast one, and the _toast is the object of the same. Also, I tested and it does remove all the toasts

Copy link
Collaborator

Choose a reason for hiding this comment

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

got it, I see that the OverlayEntry.remove will get rid of the overlay. Thanks for explaining.

@@ -194,6 +194,16 @@ class ScreenController {
} else if (action.options?['replaceCurrentScreen'] == true) {
routeOption = RouteOption.replaceCurrentScreen;
}

if (action.options?['closeToasts'] ?? true) {
ToastController().closeToast();
Copy link
Collaborator

Choose a reason for hiding this comment

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

@hemish11 we talked about it in the standup that the default should be true for both navigateScreen and navigateModalScreen

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it defaults to true. So the ?? true verifies that if the action.options?['closeToasts'] is null and when we don't pass any it null then it will default to true.

Copy link
Collaborator

Choose a reason for hiding this comment

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

got it, thanks


// No code for NavigateModalScreenAction so need to add this
if (action is NavigateModalScreenAction &&
(action.options?['closeToasts'] ?? true)) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

default should be true for both navigateScreen and navigateModalScreen

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same as the above comment

@amin-nas
Copy link
Contributor

@hemish11 we need this before end of this week. Anything left to do so you can merge?

@kmahmood74
Copy link
Collaborator

@hemish11 please get in the habbit of merging immediately after approval, merging now

@kmahmood74 kmahmood74 merged commit 1a64a52 into main Jul 23, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ability to dismiss toast when view changes
3 participants