[go: nahoru, domu]

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

Tab bar tap to return to main page #38

Open
MadeiraAlexandre opened this issue May 20, 2024 · 5 comments
Open

Tab bar tap to return to main page #38

MadeiraAlexandre opened this issue May 20, 2024 · 5 comments
Assignees

Comments

@MadeiraAlexandre
Copy link
Member

UIKit TabView should fix it, tap to return to root doesn't seem supported yet by SwiftUI TabView.

@MadeiraAlexandre MadeiraAlexandre self-assigned this May 20, 2024
MadeiraAlexandre referenced this issue May 20, 2024
Tab Bar can now go to root if navigation path isn't empty. On SearchView it can open the search field if the navigation path is empty.
Tested on: iOS.

Update packages to their latest versions.
@MadeiraAlexandre
Copy link
Member Author

Set to release on the App Store as version 2.7.3.

@kevinm6
Copy link
Contributor
kevinm6 commented Jun 2, 2024

@MadeiraAlexandre Do you think that's fine to add a scrollToTop if a tap in the TabBarItem is performed and the TabPage is the same (as the item)?

I checked but I’m not really into SwiftUI and I can’t find an easy implementation of that feature.

The idea is common to other apps that uses a TabBar: when you are already on the main page (popToRoot alike) and you tap again the current TabBarItem, the UI scroll to the top

@MadeiraAlexandre
Copy link
Member Author

@MadeiraAlexandre Do you think is fine to add a scrollToTop if a tap in the TabBarItem is performed and the TabPage is the same (as the item).

I checked but I’m not really into SwiftUI and I can’t find an easy implementation of that feature.

Yes, it is fine. I've done it for Kitsune for MyAnimeList (on the Season and Profile page, on the others tabs I'll do it in a future update).
You can control it by using a ScrollViewReader and use a binding to trigger the scroll to the top.
I've done something like this on the computed property:
if seasonPath.isEmpty { scrollSeasonToTop.toggle() } else { seasonPath = .init() }
I pass this bool binding to the SeasonView and it can trigger the scrolling to the top, usually using a hidden circle on the top of the view like this one:
Circle().fill(.clear).frame(width: 0, height: 0).hidden().id("top_view").onChange(of: scrollToTop) { withAnimation { proxy.scrollTo("top_view", anchor: .top) } }
On tabs with search field, you could even scroll to the top and then trigger the search field (like Apple does on Apple Music app).
On Cronica I've set it to open the search field only on the Search page, but you could adapt it to make it work with scrolling too and even bring the same behavior to Watchlist tab. (The file used is TabBarView.swift).
I'll reopen this issue as a reminder to do it in a future update.

@kevinm6
Copy link
Contributor
kevinm6 commented Jun 2, 2024

Thanks @MadeiraAlexandre , that's awesome!

Yes, I saw what you've done in the SearchView to trigger the search-on-tap with the Boolean var.

@MadeiraAlexandre
Copy link
Member Author

There's some big changes to how TabView operates on iOS and iPadOS 18. Some of this changes could also reduce code for the macOS side.
Some changes will be likely require on the iPadOS side.
New documentation:
https://developer.apple.com/wwdc24/10147
https://developer.apple.com/documentation/SwiftUI/Enhancing-your-app-content-with-tab-navigation

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

No branches or pull requests

2 participants