-
Notifications
You must be signed in to change notification settings - Fork 134
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
Add a configuration to allow the display of the Toast above the mini-player #2555
base: trunk
Are you sure you want to change the base?
Conversation
@@ -109,10 +109,10 @@ struct ToastView<Style: ToastTheme>: View { | |||
.shadow(color: .black.opacity(0.3), radius: 10) | |||
|
|||
// Animates the toast in from the bottom of the screen | |||
.miniPlayerSafeAreaInset(multiplier: viewModel.aboveMiniPlayer ? 1.5 : 0) |
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.
We'll probably forget this if we change the mini-player and the toast will probably appear incorrectly again. Also, given this is a property I see one of us repeating the same issue
I wonder if there's any way we can:
- Detect mini player is visible;
- Set this value based on the mini player height/position
However, such a solution still couple this to the mini-player and might require some additional hack code. 🤷
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.
The modifier actual ensures that the miniPlayer is taking in account the issue we have is the tabbar, while on the other places the standard safeInset ensure thats the bottom already takes in account the tab bar, on the toast because we are on another Window the tab bar is not taken in account.
Do you see a way to detect the tab bar presence and size from another window?
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.
@leandroalonso @SergioEstevao this solution it's similar to what Android team has implemented. In our codebase we have other classes, like the InsetAdjuster
, that takes the same argument to adjust the padding.
However, if we want to automatically adjust it without injecting any parameters, we can use the NavigationManager
(with some adjustments) as source to get the miniplayer and tabbar access.
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.
I think it should be possible to adjust using the MainTabBarController
at the ToastWindow
level but I wasn't quite able to get the values right:
if windowScene.keyWindow?.rootViewController?.presentedViewController == nil {
let tabBarController = (windowScene.keyWindow?.rootViewController as? MainTabBarController)
if let tabBarController, tabBarController.tabBar.isHidden == false {
let tabBarHeight = tabBarController.tabBar.bounds.height
controller.additionalSafeAreaInsets = UIEdgeInsets(top: 0, left: 0, bottom: tabBarHeight, right: 0)
}
}
I was hoping the keyWindow.safeAreaInset
would include the tab bar height but it does not seem to right now and adjusting that would probably mess with a bunch of things.
Would this make sense as an alternative? It's still somewhat messy to pull out that MainTabBarController
and make sure there's nothing presented.
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.
Would this make sense as an alternative? It's still somewhat messy to pull out that MainTabBarController and make sure there's nothing presented.
@bjtitus The NavigationManager
singleton has this information. AppDelegate
and the MainTabBarController
rely on this. If we want to have an auto position of the Toast I think we can use this as source.
Otherwise my suggestion is to use Sergio solution and align with Android
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.
@danielebogo and @leandroalonso I updated the code so that instead of hard-coding the miniplayer inset attribute on toast, I added a inset provider parameter that allows the customization of the inset depending of the screen.
By default it will use the safeAreaInset.bottom but customizations can be made to for example take in account the mini-player.
Give it a look and tell me what you think.
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.
@bjtitus ^
| 📘 Part of: # |
|:---:|
Fixes #
To test
Checklist
CHANGELOG.md
if necessary.