
- 在CreateFeedFeature中新增isPresented依赖,确保在适当的上下文中执行视图关闭操作。 - 在FeedFeature中优化状态管理,简化CreateFeedView的呈现逻辑。 - 新增FeedListFeature和MainFeature,整合FeedListView和底部导航功能,提升用户体验。 - 更新HomeView和SplashView以集成MainView,确保应用结构一致性。 - 在多个视图中调整状态管理和导航逻辑,增强可维护性和用户体验。
86 lines
2.6 KiB
Swift
86 lines
2.6 KiB
Swift
import SwiftUI
|
||
import ComposableArchitecture
|
||
|
||
struct SplashView: View {
|
||
let store: StoreOf<SplashFeature>
|
||
|
||
var body: some View {
|
||
WithPerceptionTracking {
|
||
Group {
|
||
// 根据导航目标显示不同页面
|
||
if let navigationDestination = store.navigationDestination {
|
||
switch navigationDestination {
|
||
case .login:
|
||
// 显示登录页面
|
||
LoginView(
|
||
store: Store(
|
||
initialState: LoginFeature.State()
|
||
) {
|
||
LoginFeature()
|
||
},
|
||
onLoginSuccess: {
|
||
// 登录成功后导航到主页面
|
||
store.send(.navigateToMain)
|
||
}
|
||
)
|
||
case .main:
|
||
// 显示主应用页面
|
||
MainView(
|
||
store: Store(
|
||
initialState: MainFeature.State()
|
||
) {
|
||
MainFeature()
|
||
}
|
||
)
|
||
}
|
||
} else {
|
||
// 显示启动画面
|
||
splashContent
|
||
}
|
||
}
|
||
.onAppear {
|
||
store.send(.onAppear)
|
||
}
|
||
}
|
||
}
|
||
|
||
// 启动画面内容
|
||
private var splashContent: some View {
|
||
ZStack {
|
||
// 背景图片 - 全屏显示
|
||
Image("bg")
|
||
.resizable()
|
||
.aspectRatio(contentMode: .fill)
|
||
.ignoresSafeArea(.all)
|
||
|
||
VStack(spacing: 32) {
|
||
Spacer()
|
||
.frame(height: 200) // 与 storyboard 中的约束对应
|
||
|
||
// Logo 图片 - 100x100
|
||
Image("logo")
|
||
.resizable()
|
||
.aspectRatio(contentMode: .fit)
|
||
.frame(width: 100, height: 100)
|
||
|
||
// 应用标题 - 白色,40pt字体
|
||
Text("E-Parti")
|
||
.font(.system(size: 40, weight: .regular))
|
||
.foregroundColor(.white)
|
||
|
||
Spacer()
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
//#Preview {
|
||
// SplashView(
|
||
// store: Store(
|
||
// initialState: SplashFeature.State()
|
||
// ) {
|
||
// SplashFeature()
|
||
// }
|
||
// )
|
||
//}
|