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

[ios] Fix isolines reminder being displayed on top of other dialogs #7694

Merged
merged 3 commits into from
Apr 5, 2024

Conversation

v-lozko
Copy link
Contributor

@v-lozko v-lozko commented Mar 26, 2024

Fixing issue #7555 by adding capability to hide toast when view disappears. Also addressed potential other cases.

Simulator.Screen.Recording.-.iPhone.15.-.2024-03-25.at.18.10.04.mp4

Tested on iPhone 15 simulator

Copy link
Member

@biodranik biodranik left a comment

Choose a reason for hiding this comment

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

Great!

Please also check DCO. If you need to set a different email for OM, you can edit .git/config file in organicmaps repo.

…Issue organicmaps#7555

Signed-off-by: Valery Lozko <valerylozko@gmail.com>
@v-lozko
Copy link
Contributor Author

v-lozko commented Mar 27, 2024

I amended the commit and looks like DCO now passes, sorry about that.

Copy link
Member

@biodranik biodranik left a comment

Choose a reason for hiding this comment

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

Thanks! @kirylkaveryn WDYT?

@biodranik
Copy link
Member

@kirylkaveryn thanks! Can you please also review this PR? I think you replied to a comment from another issue/PR )

repeats: false)
timer = Timer.scheduledTimer(timeInterval: 3,
target: self,
selector: #selector(onTimer),
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems like the onTimer() method can be removed now and you can pass the hide in selector.

@@ -36,6 +36,7 @@ @interface MWMTrafficButtonViewController () <MWMMapOverlayManagerObserver, Them
@property(nonatomic) NSLayoutConstraint *topOffset;
@property(nonatomic) NSLayoutConstraint *leftOffset;
@property(nonatomic) CGRect availableArea;
@property(nonatomic) MWMToast *toast;
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure about this approach... to store toast on every controller that we have in the project (where it needed of cours). And the other issue can happen: sometimes we can have 2-3 toasts at the same time (not in the current place, but in the PlacePage) and when we call hide() manually we will close only the last toast stored in the property.
Maybe it would be better to incapsulate toast logic inside of Toast class and store toasts in the static property?
With this approach we can hide all toasts from every place we want.
Some kine of:

class Toast {
// ...
static private var toasts: [Toast] = []
static func hideAll() {
  toasts.forEach { $0.hide }
}
func show(...) {
  Toast.appent(toast)
  // ... showing code ... 
}

func hide(...) {
  //... hiding code ...
  Toast.remove(toast)
}

@biodranik what do you think?

Copy link
Member

Choose a reason for hiding this comment

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

In the long term, it would be great if users could read all toasts without overlapping each other if they appear simultaneously (e.g. stack them, or show one after another). A simpler way to control toast visibility is also great.

How does Apple solve toast issue?

Copy link
Contributor

Choose a reason for hiding this comment

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

Apple doesn't have toasts at all. Only push notifications.
This is why toasts are so different from an app to app.

Storing all toasts logic inside the Toast class helps us in the future to handle the toasts queue properly with animations and gesture recognizers.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So, what are the next steps regarding this issue? Would you like me to edit the commit and remove the onTimer method?

Copy link
Member

Choose a reason for hiding this comment

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

@v-lozko is it hard to implement it in a way described by @kirylkaveryn ? What do you think about that approach?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can give it a go

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@biodranik , @kirylkaveryn I made the changes as suggested. Seems to work correctly

Simulator.Screen.Recording.-.iPhone.13.Pro.-.2024-04-03.at.16.27.26.mp4

Signed-off-by: Valery Lozko <valerylozko@gmail.com>


@objc static func hideAll(){
var toastsCopy = toasts
Copy link
Member

Choose a reason for hiding this comment

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

Why a copy is needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Was afraid of mutating the array while iterating over it. Doing a little looking it seems like it doesn't matter so i can make the change

}


@objc static func hideAll(){
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
@objc static func hideAll(){
@objc static func hideAll() {

@objc private func onTimer() {
hide()

Self.toasts.removeAll(where: { $0 === self })
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's better to try to place this line into the UIView.animate's completion handler to remove the toast instance as a final step.

Comment on lines 22 to 24
toastsCopy.forEach {
$0.hide()
}
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: it's better to write in single line easy iterations toastsCopy.forEach { $0.hide() }

@Jean-BaptisteC Jean-BaptisteC changed the title [ios] Fix isolines reminder being displayed on top of other dialogs, Issue #7555 [ios] Fix isolines reminder being displayed on top of other dialogs Apr 5, 2024
Signed-off-by: Valery Lozko <valerylozko@gmail.com>
@v-lozko
Copy link
Contributor Author

v-lozko commented Apr 5, 2024

Thanks for the review and comments. I made the changes

Copy link
Member

@biodranik biodranik left a comment

Choose a reason for hiding this comment

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

Great, thanks for your contribution!

@biodranik biodranik merged commit 706f0fa into organicmaps:master Apr 5, 2024
5 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.

None yet

3 participants