Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions V2er/View/Feed/FeedItemView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,16 @@ struct FeedItemView<Data: FeedItemProtocol>: 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)
Expand Down
77 changes: 33 additions & 44 deletions V2er/View/MainPage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -127,15 +125,6 @@ struct MainPage: StateView {
}
}

@ViewBuilder
private func pageWithTopBar<Content: View>(_ content: Content) -> some View {
VStack(spacing: 0) {
TopBar(selectedTab: state.selectedTab)
content
}
.ignoresSafeArea(.container, edges: .top)
}

}


Expand Down
13 changes: 10 additions & 3 deletions V2er/View/Me/MyRecentPage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,16 @@ struct RecentItemView<Data: FeedItemProtocol>: 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)
Expand Down
11 changes: 6 additions & 5 deletions V2er/View/Me/UserFeedPage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
14 changes: 7 additions & 7 deletions V2er/View/Widget/TopBar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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)
Expand Down
Loading