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
4 changes: 0 additions & 4 deletions V2er.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
4EC32AF229D818FC003A3BD4 /* WebBrowserView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4EC32AF129D818FC003A3BD4 /* WebBrowserView.swift */; };
5D02BD5F26909146007B6A1B /* LoadmoreIndicatorView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5D02BD5E26909146007B6A1B /* LoadmoreIndicatorView.swift */; };
5D04BF9726C9FB6E0005F7E3 /* FeedInfo.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5D04BF9626C9FB6E0005F7E3 /* FeedInfo.swift */; };
5D096A08247ABF5E00EF3E47 /* TabBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5D096A07247ABF5E00EF3E47 /* TabBar.swift */; };
5D0A513726E0CBFC006F3D9B /* ExploreActions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5D0A513626E0CBFC006F3D9B /* ExploreActions.swift */; };
5D0A513926E26473006F3D9B /* FeedDetailReducer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5D0A513826E26473006F3D9B /* FeedDetailReducer.swift */; };
5D0A513B26E26505006F3D9B /* FeedDetailInfo.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5D0A513A26E26505006F3D9B /* FeedDetailInfo.swift */; };
Expand Down Expand Up @@ -173,7 +172,6 @@
4EC32AF129D818FC003A3BD4 /* WebBrowserView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WebBrowserView.swift; sourceTree = "<group>"; };
5D02BD5E26909146007B6A1B /* LoadmoreIndicatorView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoadmoreIndicatorView.swift; sourceTree = "<group>"; };
5D04BF9626C9FB6E0005F7E3 /* FeedInfo.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FeedInfo.swift; sourceTree = "<group>"; };
5D096A07247ABF5E00EF3E47 /* TabBar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TabBar.swift; sourceTree = "<group>"; };
5D0A513626E0CBFC006F3D9B /* ExploreActions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExploreActions.swift; sourceTree = "<group>"; };
5D0A513826E26473006F3D9B /* FeedDetailReducer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FeedDetailReducer.swift; sourceTree = "<group>"; };
5D0A513A26E26505006F3D9B /* FeedDetailInfo.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FeedDetailInfo.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -350,7 +348,6 @@
children = (
5D73FBD827284ACA004558E9 /* RichText */,
5DE5B4CB268466AF00569684 /* Updatable */,
5D096A07247ABF5E00EF3E47 /* TabBar.swift */,
5D1F4264249713640043F604 /* VEBlur.swift */,
5DE5B4C92684601A00569684 /* TopBar.swift */,
5D4E43FB2699E20400650714 /* AvatarView.swift */,
Expand Down Expand Up @@ -985,7 +982,6 @@
5D1D7B8726FC9B61008E0C08 /* LoginReducer.swift in Sources */,
5DA2AD4826C18232007FB1EF /* MessageState.swift in Sources */,
5D0CFA8226B9935B001A8A7F /* UserFeedPage.swift in Sources */,
5D096A08247ABF5E00EF3E47 /* TabBar.swift in Sources */,
5D91F8D926F22CEC0089D72E /* TagDetailReducer.swift in Sources */,
5D45FC2B26CD3FCF0055C336 /* SwiftSoupExtention.swift in Sources */,
);
Expand Down
23 changes: 0 additions & 23 deletions V2er/Assets.xcassets/explore_tab.imageset/Contents.json

This file was deleted.

Binary file not shown.
Binary file not shown.
Binary file not shown.
23 changes: 0 additions & 23 deletions V2er/Assets.xcassets/feed_tab.imageset/Contents.json

This file was deleted.

Binary file removed V2er/Assets.xcassets/feed_tab.imageset/feed_tab.png
Binary file not shown.
Binary file not shown.
Binary file not shown.
23 changes: 0 additions & 23 deletions V2er/Assets.xcassets/me_tab.imageset/Contents.json

This file was deleted.

Binary file removed V2er/Assets.xcassets/me_tab.imageset/me_tab.png
Binary file not shown.
Binary file removed V2er/Assets.xcassets/me_tab.imageset/me_tab@2x.png
Binary file not shown.
Binary file removed V2er/Assets.xcassets/me_tab.imageset/me_tab@3x.png
Binary file not shown.
23 changes: 0 additions & 23 deletions V2er/Assets.xcassets/message_tab.imageset/Contents.json

This file was deleted.

Binary file not shown.
Binary file not shown.
Binary file not shown.
7 changes: 6 additions & 1 deletion V2er/State/DataFlow/State/GlobalState.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@
import Foundation
import SwiftUI

enum TabId: String {
case none
case feed, explore, message, me
}

struct GlobalState: FluxState {
var selectedTab: TabId = .feed
var lastSelectedTab: TabId = .none
Expand All @@ -18,7 +23,7 @@ struct GlobalState: FluxState {
static var account: AccountInfo? {
AccountState.getAccount()
}

static var hasSignIn: Bool {
AccountState.hasSignIn()
}
Expand Down
6 changes: 5 additions & 1 deletion V2er/View/Explore/ExplorePage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,11 @@ struct ExplorePage: BaseHomePageView {
await run(action: ExploreActions.FetchData.Start())
}
.background(Color.bgColor)
.hide(!isSelected)
.onAppear {
if !state.hasLoadedOnce {
dispatch(ExploreActions.FetchData.Start(autoLoad: true))
}
}
Comment on lines +93 to +97
Copy link

Copilot AI Oct 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ExplorePage already dispatches the same initial fetch inside isSelected when the tab becomes active; this added onAppear block duplicates that logic and can cause redundant requests. Consolidate to a single initiation point.

Suggested change
.onAppear {
if !state.hasLoadedOnce {
dispatch(ExploreActions.FetchData.Start(autoLoad: true))
}
}

Copilot uses AI. Check for mistakes.
}
}

Expand Down
4 changes: 3 additions & 1 deletion V2er/View/Feed/FeedPage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,11 @@ struct FeedPage: BaseHomePageView {

var body: some View {
contentView
.hide(!isSelected)
.onAppear {
log("FeedPage.onAppear")
if !state.hasLoadedOnce {
dispatch(FeedActions.FetchData.Start(autoLoad: true))
}
Comment on lines 29 to +32
Copy link

Copilot AI Oct 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fetch is already conditionally dispatched inside the existing isSelected computed property; adding the same conditional fetch in onAppear risks double dispatch and duplicate network requests. Remove one of the two triggers (prefer a single source, e.g. keep onAppear and simplify isSelected or vice versa).

Copilot uses AI. Check for mistakes.
}
Comment on lines 28 to 33
Copy link

Copilot AI Oct 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Initial fetch is already triggered in the existing isSelected computed property; this added onAppear block can cause duplicate dispatches (two initial network requests). Remove either the isSelected-triggered fetch or this onAppear block.

Suggested change
.onAppear {
log("FeedPage.onAppear")
if !state.hasLoadedOnce {
dispatch(FeedActions.FetchData.Start(autoLoad: true))
}
}

Copilot uses AI. Check for mistakes.
}

Expand Down
65 changes: 51 additions & 14 deletions V2er/View/MainPage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,47 @@ struct MainPage: StateView {
var body: some View {
NavigationView {
ZStack {
// Main content pages
ZStack {
FeedPage(selecedTab: state.selectedTab)
ExplorePage(selecedTab: state.selectedTab)
MessagePage(selecedTab: state.selectedTab)
MePage(selecedTab: state.selectedTab)
TabView(selection: selectedTab) {
// Feed Tab
pageWithTopBar(
FeedPage(selecedTab: state.selectedTab)
Copy link

Copilot AI Oct 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct the parameter label 'selecedTab' to 'selectedTab' to avoid propagating the typo; update the corresponding parameter name in each page's initializer.

Copilot uses AI. Check for mistakes.
Copy link

Copilot AI Oct 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The parameter name 'selecedTab' is misspelled; rename to 'selectedTab' for clarity and consistency.

Copilot uses AI. Check for mistakes.
)
.tabItem {
Label("最新", systemImage: "newspaper")
}
.tag(TabId.feed)

// Explore Tab
pageWithTopBar(
ExplorePage(selecedTab: state.selectedTab)
Copy link

Copilot AI Oct 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct the parameter label 'selecedTab' to 'selectedTab' to avoid propagating the typo; update the corresponding parameter name in each page's initializer.

Copilot uses AI. Check for mistakes.
Copy link

Copilot AI Oct 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The parameter name 'selecedTab' is misspelled; rename to 'selectedTab' for clarity and consistency.

Copilot uses AI. Check for mistakes.
)
.tabItem {
Label("发现", systemImage: "safari")
}
.tag(TabId.explore)

// Message Tab
pageWithTopBar(
MessagePage(selecedTab: state.selectedTab)
Copy link

Copilot AI Oct 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct the parameter label 'selecedTab' to 'selectedTab' to avoid propagating the typo; update the corresponding parameter name in each page's initializer.

Copilot uses AI. Check for mistakes.
Copy link

Copilot AI Oct 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The parameter name 'selecedTab' is misspelled; rename to 'selectedTab' for clarity and consistency.

Copilot uses AI. Check for mistakes.
)
.tabItem {
if unReadNums > 0 {
Label("通知", systemImage: "bell")
.badge(unReadNums)
} else {
Label("通知", systemImage: "bell")
}
}
.tag(TabId.message)

// Me Tab
pageWithTopBar(
MePage(selecedTab: state.selectedTab)
Copy link

Copilot AI Oct 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct the parameter label 'selecedTab' to 'selectedTab' to avoid propagating the typo; update the corresponding parameter name in each page's initializer.

Copilot uses AI. Check for mistakes.
Copy link

Copilot AI Oct 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The parameter name 'selecedTab' is misspelled; rename to 'selectedTab' for clarity and consistency.

Copilot uses AI. Check for mistakes.
)
.tabItem {
Label("", systemImage: "person")
}
.tag(TabId.me)
}

// Filter menu overlay - only render when needed
Expand All @@ -48,17 +83,19 @@ struct MainPage: StateView {
.zIndex(1000)
}
}
.safeAreaInset(edge: .top, spacing: 0) {
TopBar(selectedTab: state.selectedTab)
}
.safeAreaInset(edge: .bottom, spacing: 0) {
TabBar(unReadNums)
}
.ignoresSafeArea(.container)
.navigationBarHidden(true)
}
}


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

}


Expand Down
1 change: 0 additions & 1 deletion V2er/View/Me/MePage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ struct MePage: BaseHomePageView {
.background(Color.dim)
}
}
.hide(selecedTab != .me)
}

@ViewBuilder
Expand Down
6 changes: 5 additions & 1 deletion V2er/View/Message/MessagePage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@ struct MessagePage: BaseHomePageView {
var body: some View {
contentView
.background(Color.bgColor)
.hide(!isSelected)
.onAppear {
if !state.hasLoadedOnce {
dispatch(MessageActions.FetchStart(autoLoad: true))
}
}
Comment on lines +31 to +35
Copy link

Copilot AI Oct 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MessagePage also conditionally dispatches the same fetch in isSelected; retaining both paths may cause duplicate initial loads. Remove one of them to avoid unnecessary network calls.

Copilot uses AI. Check for mistakes.
}

@ViewBuilder
Expand Down
Loading
Loading