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

Add a configuration to allow the display of the Toast above the mini-player #2555

Open
wants to merge 3 commits into
base: trunk
Choose a base branch
from

Conversation

SergioEstevao
Copy link
Contributor

| 📘 Part of: # |
|:---:|

Fixes #

1 2
Simulator Screenshot - iPhone 16 Pro - 2024-12-16 at 14 20 59 Simulator Screenshot - iPhone 16 Pro - 2024-12-16 at 14 20 49

To test

  • Start the app with a user with a subscription
  • Start playing an episode so the mini-player is visible
  • Go to UpNext tab
  • Activate UpNext Shuffle
  • See if the Toast shows above the Mini-Player
  • Tap on UpNext icon the mini-player
  • Activate UpNext Shuffle
    • See if the Toast shows at the regular position

Checklist

  • I have considered if this change warrants user-facing release notes and have added them to CHANGELOG.md if necessary.
  • I have considered adding unit tests for my changes.
  • I have updated (or requested that someone edit) the spreadsheet to reflect any new or changed analytics.

@SergioEstevao SergioEstevao requested a review from a team as a code owner December 16, 2024 14:36
@SergioEstevao SergioEstevao requested review from bjtitus and removed request for a team December 16, 2024 14:36
@SergioEstevao SergioEstevao added this to the 7.80 milestone Dec 16, 2024
@@ -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)
Copy link
Member

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:

  1. Detect mini player is visible;
  2. 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. 🤷

Copy link
Contributor Author

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?

Copy link
Contributor

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.

Copy link
Contributor

@bjtitus bjtitus Dec 20, 2024

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.

Copy link
Contributor

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

Copy link
Contributor Author

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants