Improve navigation in 'More' tab: Use NavigationLink for native list navigation behavior in PhoneTabView (Phone TabView now consistent with Sidebar)
This commit is contained in:
parent
be68538da3
commit
a5ccc75036
@ -8,38 +8,70 @@
|
|||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
|
||||||
struct PhoneTabView: View {
|
struct PhoneTabView: View {
|
||||||
|
private let mainTabs: [SidebarTab] = [.all, .unread, .favorite, .archived]
|
||||||
|
private let moreTabs: [SidebarTab] = [.article, .videos, .pictures, .tags, .settings]
|
||||||
|
|
||||||
|
@State private var selectedMoreTab: SidebarTab? = nil
|
||||||
|
@State private var selectedTabIndex: Int = 0
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
TabView {
|
TabView(selection: $selectedTabIndex) {
|
||||||
|
ForEach(Array(mainTabs.enumerated()), id: \.element) { idx, tab in
|
||||||
NavigationStack {
|
NavigationStack {
|
||||||
BookmarksView(state: .unread, type: [.article, .video, .photo], selectedBookmark: .constant(nil))
|
tabView(for: tab)
|
||||||
}
|
}
|
||||||
.tabItem {
|
.tabItem {
|
||||||
Label("Alle", systemImage: "list.bullet")
|
Label(tab.label, systemImage: tab.systemImage)
|
||||||
|
}
|
||||||
|
.tag(idx)
|
||||||
}
|
}
|
||||||
|
|
||||||
NavigationStack {
|
NavigationStack {
|
||||||
BookmarksView(state: .unread, type: [.article], selectedBookmark: .constant(nil))
|
List(moreTabs, id: \.self, selection: $selectedMoreTab) { tab in
|
||||||
|
NavigationLink(tag: tab, selection: $selectedMoreTab) {
|
||||||
|
tabView(for: tab)
|
||||||
|
.navigationTitle(tab.label)
|
||||||
|
} label: {
|
||||||
|
Label(tab.label, systemImage: tab.systemImage)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.navigationTitle("Mehr")
|
||||||
}
|
}
|
||||||
.tabItem {
|
.tabItem {
|
||||||
Label("Ungelesen", systemImage: "house")
|
Label("Mehr", systemImage: "ellipsis")
|
||||||
}
|
}
|
||||||
|
.tag(mainTabs.count)
|
||||||
BookmarksView(state: .favorite, type: [.article], selectedBookmark: .constant(nil))
|
.onAppear {
|
||||||
.tabItem {
|
// Wenn der Mehr-Tab aktiv wird und wir in einer Detailansicht sind, zurücksetzen
|
||||||
Label("Favoriten", systemImage: "heart")
|
if selectedTabIndex == mainTabs.count && selectedMoreTab != nil {
|
||||||
}
|
selectedMoreTab = nil
|
||||||
|
|
||||||
BookmarksView(state: .archived, type: [.article], selectedBookmark: .constant(nil))
|
|
||||||
.tabItem {
|
|
||||||
Label("Archiv", systemImage: "archivebox")
|
|
||||||
}
|
|
||||||
|
|
||||||
SettingsView()
|
|
||||||
.tabItem {
|
|
||||||
Label("Settings", systemImage: "gear")
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
.accentColor(.accentColor)
|
.accentColor(.accentColor)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ViewBuilder
|
||||||
|
private func tabView(for tab: SidebarTab) -> some View {
|
||||||
|
switch tab {
|
||||||
|
case .all:
|
||||||
|
BookmarksView(state: .all, type: [.article, .video, .photo], selectedBookmark: .constant(nil))
|
||||||
|
case .unread:
|
||||||
|
BookmarksView(state: .unread, type: [.article], selectedBookmark: .constant(nil))
|
||||||
|
case .favorite:
|
||||||
|
BookmarksView(state: .favorite, type: [.article], selectedBookmark: .constant(nil))
|
||||||
|
case .archived:
|
||||||
|
BookmarksView(state: .archived, type: [.article], selectedBookmark: .constant(nil))
|
||||||
|
case .settings:
|
||||||
|
SettingsView()
|
||||||
|
case .article:
|
||||||
|
BookmarksView(state: .all, type: [.article], selectedBookmark: .constant(nil))
|
||||||
|
case .videos:
|
||||||
|
BookmarksView(state: .all, type: [.video], selectedBookmark: .constant(nil))
|
||||||
|
case .pictures:
|
||||||
|
BookmarksView(state: .all, type: [.photo], selectedBookmark: .constant(nil))
|
||||||
|
case .tags:
|
||||||
|
Text("Tags")
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user