refactor: Clean up PhoneTabView and improve code organization
- Remove unused state: selectedMoreTab, searchPath - Remove obsolete navigation callbacks (.onAppear, .onDisappear) - Hide disclosure indicators in search results using ZStack pattern - Add computed properties for cardLayoutStyle and badge count - Mark .search case as EmptyView (now directly implemented) - Hide tab bar in more menu detail views
This commit is contained in:
parent
080c5aa4d2
commit
ad7ac19d79
@ -11,7 +11,6 @@ struct PhoneTabView: View {
|
|||||||
private let mainTabs: [SidebarTab] = [.all, .unread, .favorite, .archived]
|
private let mainTabs: [SidebarTab] = [.all, .unread, .favorite, .archived]
|
||||||
private let moreTabs: [SidebarTab] = [.article, .videos, .pictures, .tags, .settings]
|
private let moreTabs: [SidebarTab] = [.article, .videos, .pictures, .tags, .settings]
|
||||||
|
|
||||||
@State private var selectedMoreTab: SidebarTab? = nil
|
|
||||||
@State private var selectedTab: SidebarTab = .unread
|
@State private var selectedTab: SidebarTab = .unread
|
||||||
@State private var offlineBookmarksViewModel = OfflineBookmarksViewModel(syncUseCase: DefaultUseCaseFactory.shared.makeOfflineBookmarkSyncUseCase())
|
@State private var offlineBookmarksViewModel = OfflineBookmarksViewModel(syncUseCase: DefaultUseCaseFactory.shared.makeOfflineBookmarkSyncUseCase())
|
||||||
|
|
||||||
@ -20,7 +19,6 @@ struct PhoneTabView: View {
|
|||||||
@State private var unreadPath = NavigationPath()
|
@State private var unreadPath = NavigationPath()
|
||||||
@State private var favoritePath = NavigationPath()
|
@State private var favoritePath = NavigationPath()
|
||||||
@State private var archivedPath = NavigationPath()
|
@State private var archivedPath = NavigationPath()
|
||||||
@State private var searchPath = NavigationPath()
|
|
||||||
@State private var morePath = NavigationPath()
|
@State private var morePath = NavigationPath()
|
||||||
|
|
||||||
// Search functionality
|
// Search functionality
|
||||||
@ -29,6 +27,14 @@ struct PhoneTabView: View {
|
|||||||
|
|
||||||
@EnvironmentObject var appSettings: AppSettings
|
@EnvironmentObject var appSettings: AppSettings
|
||||||
|
|
||||||
|
private var cardLayoutStyle: CardLayoutStyle {
|
||||||
|
appSettings.settings?.cardLayoutStyle ?? .compact
|
||||||
|
}
|
||||||
|
|
||||||
|
private var offlineBookmarksBadgeCount: Int {
|
||||||
|
offlineBookmarksViewModel.state.localBookmarkCount > 0 ? offlineBookmarksViewModel.state.localBookmarkCount : 0
|
||||||
|
}
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
GlobalPlayerContainerView {
|
GlobalPlayerContainerView {
|
||||||
TabView(selection: $selectedTab) {
|
TabView(selection: $selectedTab) {
|
||||||
@ -73,7 +79,7 @@ struct PhoneTabView: View {
|
|||||||
.searchable(text: $searchViewModel.searchQuery, prompt: "Search bookmarks...")
|
.searchable(text: $searchViewModel.searchQuery, prompt: "Search bookmarks...")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.badge(offlineBookmarksViewModel.state.localBookmarkCount > 0 ? offlineBookmarksViewModel.state.localBookmarkCount : 0)
|
.badge(offlineBookmarksBadgeCount)
|
||||||
} else {
|
} else {
|
||||||
Tab(value: SidebarTab.settings) {
|
Tab(value: SidebarTab.settings) {
|
||||||
NavigationStack(path: $morePath) {
|
NavigationStack(path: $morePath) {
|
||||||
@ -108,19 +114,14 @@ struct PhoneTabView: View {
|
|||||||
moreTabsFooter
|
moreTabsFooter
|
||||||
}
|
}
|
||||||
.navigationTitle("More")
|
.navigationTitle("More")
|
||||||
.onAppear {
|
|
||||||
selectedMoreTab = nil
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} label: {
|
} label: {
|
||||||
Label("More", systemImage: "ellipsis")
|
Label("More", systemImage: "ellipsis")
|
||||||
}
|
}
|
||||||
.badge(offlineBookmarksViewModel.state.localBookmarkCount > 0 ? offlineBookmarksViewModel.state.localBookmarkCount : 0)
|
.badge(offlineBookmarksBadgeCount)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.accentColor(.accentColor)
|
.accentColor(.accentColor)
|
||||||
|
|
||||||
// .tabBarMinimizeBehavior(.onScrollDown)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -147,32 +148,37 @@ struct PhoneTabView: View {
|
|||||||
.padding()
|
.padding()
|
||||||
} else if let bookmarks = searchViewModel.bookmarks?.bookmarks, !bookmarks.isEmpty {
|
} else if let bookmarks = searchViewModel.bookmarks?.bookmarks, !bookmarks.isEmpty {
|
||||||
List(bookmarks) { bookmark in
|
List(bookmarks) { bookmark in
|
||||||
|
// Hidden NavigationLink to remove disclosure indicator
|
||||||
|
// To restore: uncomment block below and remove ZStack
|
||||||
ZStack {
|
ZStack {
|
||||||
NavigationLink {
|
NavigationLink {
|
||||||
BookmarkDetailView(bookmarkId: bookmark.id)
|
BookmarkDetailView(bookmarkId: bookmark.id)
|
||||||
.toolbar(.hidden, for: .tabBar)
|
.toolbar(.hidden, for: .tabBar)
|
||||||
.navigationBarBackButtonHidden(false)
|
.navigationBarBackButtonHidden(false)
|
||||||
} label: {
|
} label: {
|
||||||
|
EmptyView()
|
||||||
|
}
|
||||||
|
.opacity(0)
|
||||||
|
|
||||||
BookmarkCardView(
|
BookmarkCardView(
|
||||||
bookmark: bookmark,
|
bookmark: bookmark,
|
||||||
currentState: .all,
|
currentState: .all,
|
||||||
layout: appSettings.settings?.cardLayoutStyle ?? .compact,
|
layout: cardLayoutStyle,
|
||||||
onArchive: { _ in },
|
onArchive: { _ in },
|
||||||
onDelete: { _ in },
|
onDelete: { _ in },
|
||||||
onToggleFavorite: { _ in }
|
onToggleFavorite: { _ in }
|
||||||
)
|
)
|
||||||
.listRowBackground(Color(R.color.bookmark_list_bg))
|
.contentShape(Rectangle())
|
||||||
}
|
}
|
||||||
.listRowInsets(EdgeInsets(
|
.listRowInsets(EdgeInsets(
|
||||||
top: appSettings.settings?.cardLayoutStyle == .compact ? 8 : 12,
|
top: cardLayoutStyle == .compact ? 8 : 12,
|
||||||
leading: 16,
|
leading: 16,
|
||||||
bottom: appSettings.settings?.cardLayoutStyle == .compact ? 8 : 12,
|
bottom: cardLayoutStyle == .compact ? 8 : 12,
|
||||||
trailing: 16
|
trailing: 16
|
||||||
))
|
))
|
||||||
.listRowSeparator(.hidden)
|
.listRowSeparator(.hidden)
|
||||||
.listRowBackground(Color(R.color.bookmark_list_bg))
|
.listRowBackground(Color(R.color.bookmark_list_bg))
|
||||||
}
|
}
|
||||||
}
|
|
||||||
.scrollContentBackground(.hidden)
|
.scrollContentBackground(.hidden)
|
||||||
.background(Color(R.color.bookmark_list_bg))
|
.background(Color(R.color.bookmark_list_bg))
|
||||||
.listStyle(.plain)
|
.listStyle(.plain)
|
||||||
@ -190,12 +196,6 @@ struct PhoneTabView: View {
|
|||||||
tabView(for: tab)
|
tabView(for: tab)
|
||||||
.navigationTitle(tab.label)
|
.navigationTitle(tab.label)
|
||||||
.navigationBarTitleDisplayMode(.large)
|
.navigationBarTitleDisplayMode(.large)
|
||||||
.onDisappear {
|
|
||||||
// tags and search handle navigation by own
|
|
||||||
if tab != .tags && tab != .search {
|
|
||||||
selectedMoreTab = nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} label: {
|
} label: {
|
||||||
Label(tab.label, systemImage: tab.systemImage)
|
Label(tab.label, systemImage: tab.systemImage)
|
||||||
}
|
}
|
||||||
@ -241,17 +241,22 @@ struct PhoneTabView: View {
|
|||||||
case .archived:
|
case .archived:
|
||||||
BookmarksView(state: .archived, type: [.article], selectedBookmark: .constant(nil))
|
BookmarksView(state: .archived, type: [.article], selectedBookmark: .constant(nil))
|
||||||
case .search:
|
case .search:
|
||||||
SearchBookmarksView(selectedBookmark: .constant(nil))
|
EmptyView() // search is directly implemented
|
||||||
case .settings:
|
case .settings:
|
||||||
SettingsView()
|
SettingsView()
|
||||||
|
.toolbar(.hidden, for: .tabBar)
|
||||||
case .article:
|
case .article:
|
||||||
BookmarksView(state: .all, type: [.article], selectedBookmark: .constant(nil))
|
BookmarksView(state: .all, type: [.article], selectedBookmark: .constant(nil))
|
||||||
|
.toolbar(.hidden, for: .tabBar)
|
||||||
case .videos:
|
case .videos:
|
||||||
BookmarksView(state: .all, type: [.video], selectedBookmark: .constant(nil))
|
BookmarksView(state: .all, type: [.video], selectedBookmark: .constant(nil))
|
||||||
|
.toolbar(.hidden, for: .tabBar)
|
||||||
case .pictures:
|
case .pictures:
|
||||||
BookmarksView(state: .all, type: [.photo], selectedBookmark: .constant(nil))
|
BookmarksView(state: .all, type: [.photo], selectedBookmark: .constant(nil))
|
||||||
|
.toolbar(.hidden, for: .tabBar)
|
||||||
case .tags:
|
case .tags:
|
||||||
LabelsView(selectedTag: .constant(nil))
|
LabelsView(selectedTag: .constant(nil))
|
||||||
|
.toolbar(.hidden, for: .tabBar)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user