
- 在CreateFeedFeature中新增isPresented依赖,确保在适当的上下文中执行视图关闭操作。 - 在FeedFeature中优化状态管理,简化CreateFeedView的呈现逻辑。 - 新增FeedListFeature和MainFeature,整合FeedListView和底部导航功能,提升用户体验。 - 更新HomeView和SplashView以集成MainView,确保应用结构一致性。 - 在多个视图中调整状态管理和导航逻辑,增强可维护性和用户体验。
50 lines
2.1 KiB
Swift
50 lines
2.1 KiB
Swift
import SwiftUI
|
||
import ComposableArchitecture
|
||
//import Components // 如果 BottomTabView 在 Components 命名空间,否则移除
|
||
|
||
struct MainView: View {
|
||
let store: StoreOf<MainFeature>
|
||
|
||
var body: some View {
|
||
WithViewStore(self.store, observe: { $0 }) { viewStore in
|
||
NavigationStack {
|
||
GeometryReader { geometry in
|
||
ZStack {
|
||
// 背景图片
|
||
Image("bg")
|
||
.resizable()
|
||
.aspectRatio(contentMode: .fill)
|
||
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
||
.clipped()
|
||
.ignoresSafeArea(.all)
|
||
// 主内容
|
||
ZStack {
|
||
switch viewStore.selectedTab {
|
||
case .feed:
|
||
FeedListView(store: store.scope(
|
||
state: \.feedList,
|
||
action: \.feedList
|
||
))
|
||
.transition(.opacity)
|
||
case .other:
|
||
MeView(onLogout: {}) // 这里可根据需要传递实际登出回调
|
||
.transition(.opacity)
|
||
}
|
||
}
|
||
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
||
// 底部导航栏
|
||
VStack {
|
||
Spacer()
|
||
BottomTabView(selectedTab: viewStore.binding(
|
||
get: { Tab(rawValue: $0.selectedTab.rawValue) ?? .feed },
|
||
send: { MainFeature.Action.selectTab(MainFeature.Tab(rawValue: $0.rawValue) ?? .feed) }
|
||
))
|
||
}
|
||
.padding(.bottom, geometry.safeAreaInsets.bottom + 60)
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|