-
Notifications
You must be signed in to change notification settings - Fork 16
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
Conversation
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(); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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)) { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
@hemish11 we need this before end of this week. Anything left to do so you can merge? |
@hemish11 please get in the habbit of merging immediately after approval, merging now |
Closes #1493