feat: Modernize PhoneTabView with iOS 18+ Tab API
- Add support for new SwiftUI Tab API (iOS 18+) alongside legacy tabItem - Implement mainTabsContentNew and moreTabContentNew with modern Tab() syntax - Maintain backward compatibility with iOS versions < 18 - Use @available annotations for version-specific implementations - Replace deprecated .tabItem with cleaner Tab(..., value:) approach - Keep all existing functionality including badges and navigation
This commit is contained in:
parent
99ef722e7d
commit
62f2f07f38
@ -20,6 +20,13 @@ struct PhoneTabView: View {
|
||||
var body: some View {
|
||||
NavigationStack {
|
||||
GlobalPlayerContainerView {
|
||||
if #available(iOS 18.0, *) {
|
||||
TabView(selection: $selectedTabIndex) {
|
||||
mainTabsContentNew
|
||||
moreTabContentNew
|
||||
}
|
||||
.accentColor(.accentColor)
|
||||
} else {
|
||||
TabView(selection: $selectedTabIndex) {
|
||||
mainTabsContent
|
||||
moreTabContent
|
||||
@ -28,10 +35,38 @@ struct PhoneTabView: View {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Tab Content (iOS 18+)
|
||||
|
||||
@available(iOS 18.0, *)
|
||||
@ViewBuilder
|
||||
private var mainTabsContentNew: some View {
|
||||
ForEach(Array(mainTabs.enumerated()), id: \.element) { idx, tab in
|
||||
Tab(tab.label, systemImage: tab.systemImage, value: idx) {
|
||||
tabView(for: tab)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Tab Content
|
||||
@available(iOS 18.0, *)
|
||||
@ViewBuilder
|
||||
private var moreTabContentNew: some View {
|
||||
Tab("More", systemImage: "ellipsis", value: mainTabs.count) {
|
||||
VStack(spacing: 0) {
|
||||
moreTabsList
|
||||
moreTabsFooter
|
||||
}
|
||||
.onAppear {
|
||||
if selectedTabIndex == mainTabs.count && selectedMoreTab != nil {
|
||||
selectedMoreTab = nil
|
||||
}
|
||||
}
|
||||
}
|
||||
.badge(offlineBookmarksViewModel.state.localBookmarkCount > 0 ? offlineBookmarksViewModel.state.localBookmarkCount : 0)
|
||||
}
|
||||
|
||||
// MARK: - Tab Content (Legacy)
|
||||
|
||||
@ViewBuilder
|
||||
private var mainTabsContent: some View {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user