-
Notifications
You must be signed in to change notification settings - Fork 48
Replace custom tab bar with native iOS TabView #53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -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
|
||||||||||||||
| } | ||||||||||||||
|
Comment on lines
28
to
33
|
||||||||||||||
| .onAppear { | |
| log("FeedPage.onAppear") | |
| if !state.hasLoadedOnce { | |
| dispatch(FeedActions.FetchData.Start(autoLoad: true)) | |
| } | |
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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) | ||
|
||
| ) | ||
| .tabItem { | ||
| Label("最新", systemImage: "newspaper") | ||
| } | ||
| .tag(TabId.feed) | ||
|
|
||
| // Explore Tab | ||
| pageWithTopBar( | ||
| ExplorePage(selecedTab: state.selectedTab) | ||
|
||
| ) | ||
| .tabItem { | ||
| Label("发现", systemImage: "safari") | ||
| } | ||
| .tag(TabId.explore) | ||
|
|
||
| // Message Tab | ||
| pageWithTopBar( | ||
| MessagePage(selecedTab: state.selectedTab) | ||
|
||
| ) | ||
| .tabItem { | ||
| if unReadNums > 0 { | ||
| Label("通知", systemImage: "bell") | ||
| .badge(unReadNums) | ||
| } else { | ||
| Label("通知", systemImage: "bell") | ||
| } | ||
| } | ||
| .tag(TabId.message) | ||
|
|
||
| // Me Tab | ||
| pageWithTopBar( | ||
| MePage(selecedTab: state.selectedTab) | ||
|
||
| ) | ||
| .tabItem { | ||
| Label("我", systemImage: "person") | ||
| } | ||
| .tag(TabId.me) | ||
| } | ||
|
|
||
| // Filter menu overlay - only render when needed | ||
|
|
@@ -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) | ||
| } | ||
|
|
||
| } | ||
|
|
||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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
|
||
| } | ||
|
|
||
| @ViewBuilder | ||
|
|
||
There was a problem hiding this comment.
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.