diff --git a/V2er/View/Feed/FeedItemView.swift b/V2er/View/Feed/FeedItemView.swift index a6a2033..8ad87ea 100644 --- a/V2er/View/Feed/FeedItemView.swift +++ b/V2er/View/Feed/FeedItemView.swift @@ -24,9 +24,16 @@ struct FeedItemView: View { .lineLimit(1) .foregroundColor(Color.tintColor) Spacer() - Text(data.nodeName.safe) - .font(.footnote) - .foregroundColor(.gray) + NavigationLink(destination: TagDetailPage(tagId: data.nodeId.safe)) { + Text(data.nodeName.safe) + .font(.footnote) + .foregroundColor(Color.dynamic(light: .hex(0x666666), dark: .hex(0xCCCCCC))) + .lineLimit(1) + .padding(.horizontal, 10) + .padding(.vertical, 6) + .background(Color.dynamic(light: Color.hex(0xF5F5F5), dark: Color.hex(0x2C2C2E))) + } + .buttonStyle(.plain) } Text(data.title.safe) // .fontWeight(.medium) diff --git a/V2er/View/MainPage.swift b/V2er/View/MainPage.swift index d1fbb40..eb047e3 100644 --- a/V2er/View/MainPage.swift +++ b/V2er/View/MainPage.swift @@ -60,49 +60,47 @@ struct MainPage: StateView { var body: some View { NavigationStack { ZStack { - TabView(selection: tabSelection) { - // Feed Tab - pageWithTopBar( + VStack(spacing: 0) { + // TopBar outside TabView to ensure it updates immediately + TopBar(selectedTab: state.selectedTab, feedFilterTab: store.appState.feedState.selectedTab) + + TabView(selection: tabSelection) { + // Feed Tab FeedPage(selecedTab: state.selectedTab) - ) - .tabItem { - Label("最新", systemImage: "newspaper") - } - .tag(TabId.feed) + .tabItem { + Label("最新", systemImage: "newspaper") + } + .tag(TabId.feed) - // Explore Tab - pageWithTopBar( + // Explore Tab ExplorePage(selecedTab: state.selectedTab) - ) - .tabItem { - Label("发现", systemImage: "safari") - } - .tag(TabId.explore) + .tabItem { + Label("发现", systemImage: "safari") + } + .tag(TabId.explore) - // Message Tab - pageWithTopBar( + // Message Tab MessagePage(selecedTab: state.selectedTab) - ) - .tabItem { - if unReadNums > 0 { - Label("通知", systemImage: "bell") - .badge(unReadNums) - } else { - Label("通知", systemImage: "bell") - } - } - .tag(TabId.message) - - // Me Tab - pageWithTopBar( + .tabItem { + if unReadNums > 0 { + Label("通知", systemImage: "bell") + .badge(unReadNums) + } else { + Label("通知", systemImage: "bell") + } + } + .tag(TabId.message) + + // Me Tab MePage(selecedTab: state.selectedTab) - ) - .tabItem { - Label("我", systemImage: "person") + .tabItem { + Label("我", systemImage: "person") + } + .tag(TabId.me) } - .tag(TabId.me) + .accentColor(Color.primary) // This controls the selected icon color in TabView } - .accentColor(Color.primary) // This controls the selected icon color in TabView + .ignoresSafeArea(.container, edges: .top) // Filter menu overlay - only render when needed if state.selectedTab == .feed && store.appState.feedState.showFilterMenu { @@ -127,15 +125,6 @@ struct MainPage: StateView { } } - @ViewBuilder - private func pageWithTopBar(_ content: Content) -> some View { - VStack(spacing: 0) { - TopBar(selectedTab: state.selectedTab) - content - } - .ignoresSafeArea(.container, edges: .top) - } - } diff --git a/V2er/View/Me/MyRecentPage.swift b/V2er/View/Me/MyRecentPage.swift index 7dcab31..8ca41f7 100644 --- a/V2er/View/Me/MyRecentPage.swift +++ b/V2er/View/Me/MyRecentPage.swift @@ -55,9 +55,16 @@ struct RecentItemView: View { .foregroundColor(Color.tintColor) } Spacer() - Text(data.nodeName.safe) - .font(.footnote) - .foregroundColor(.gray) + NavigationLink(destination: TagDetailPage(tagId: data.nodeId.safe)) { + Text(data.nodeName.safe) + .font(.footnote) + .foregroundColor(Color.dynamic(light: .hex(0x666666), dark: .hex(0xCCCCCC))) + .lineLimit(1) + .padding(.horizontal, 10) + .padding(.vertical, 6) + .background(Color.dynamic(light: Color.hex(0xF5F5F5), dark: Color.hex(0x2C2C2E))) + } + .buttonStyle(.plain) } Text(data.title.safe) .greedyWidth(.leading) diff --git a/V2er/View/Me/UserFeedPage.swift b/V2er/View/Me/UserFeedPage.swift index 82ea3fd..3899cb1 100644 --- a/V2er/View/Me/UserFeedPage.swift +++ b/V2er/View/Me/UserFeedPage.swift @@ -65,15 +65,16 @@ struct UserFeedPage: StateView, InstanceIdentifiable { .foregroundColor(Color.tintColor) } Spacer() - NavigationLink(destination: TagDetailPage()) { + NavigationLink(destination: TagDetailPage(tagId: data.tagId)) { Text(data.tag) .font(.footnote) - .foregroundColor(.primaryText) + .foregroundColor(Color.dynamic(light: .hex(0x666666), dark: .hex(0xCCCCCC))) .lineLimit(1) - .padding(.horizontal, 14) - .padding(.vertical, 8) - .background(Color.lightGray) + .padding(.horizontal, 10) + .padding(.vertical, 6) + .background(Color.dynamic(light: Color.hex(0xF5F5F5), dark: Color.hex(0x2C2C2E))) } + .buttonStyle(.plain) } Text(data.title) .foregroundColor(.primaryText) diff --git a/V2er/View/Widget/TopBar.swift b/V2er/View/Widget/TopBar.swift index 3a37c1a..e166df3 100644 --- a/V2er/View/Widget/TopBar.swift +++ b/V2er/View/Widget/TopBar.swift @@ -10,18 +10,18 @@ import SwiftUI struct TopBar: View { @EnvironmentObject private var store: Store - var selectedTab : TabId + var selectedTab: TabId + var feedFilterTab: Tab // Explicit parameter to trigger SwiftUI re-render @State private var rotationAngle: Double = 0 - + private var isHomePage: Bool { return selectedTab == .feed } - + private var title: String { switch selectedTab { case .feed: - let selectedTab = store.appState.feedState.selectedTab - return selectedTab == .all ? "V2EX" : selectedTab.displayName() + return feedFilterTab == .all ? "V2EX" : feedFilterTab.displayName() case .explore: return "发现" case .message: @@ -104,10 +104,10 @@ struct TopBar: View { struct TopBar_Previews: PreviewProvider { // @State static var selecedTab = TabId.feed static var selecedTab = TabId.explore - + static var previews: some View { VStack { - TopBar(selectedTab: selecedTab) + TopBar(selectedTab: selecedTab, feedFilterTab: .all) Spacer() } .ignoresSafeArea(.container)