
- 在.gitignore中添加忽略项以排除不必要的文件。 - 删除架构分析需求文档以简化项目文档。 - 在APIEndpoints.swift和LoginModels.swift中移除调试信息的异步调用,提升代码简洁性。 - 在EMailLoginFeature.swift和HomeFeature.swift中新增登录流程状态管理,优化用户体验。 - 在多个视图中调整状态管理和导航逻辑,确保一致性和可维护性。 - 更新Xcode项目配置以增强调试信息的输出格式。
67 lines
2.2 KiB
Swift
67 lines
2.2 KiB
Swift
import SwiftUI
|
||
import ComposableArchitecture
|
||
|
||
struct HomeView: View {
|
||
let store: StoreOf<HomeFeature>
|
||
let onLogout: () -> Void // 新增:登出回调
|
||
@ObservedObject private var localizationManager = LocalizationManager.shared
|
||
@State private var selectedTab: Tab = .feed
|
||
|
||
var body: some View {
|
||
WithPerceptionTracking {
|
||
GeometryReader { geometry in
|
||
ZStack {
|
||
// 使用 "bg" 图片作为背景 - 全屏显示
|
||
Image("bg")
|
||
.resizable()
|
||
.aspectRatio(contentMode: .fill)
|
||
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
||
.clipped()
|
||
.ignoresSafeArea(.all)
|
||
|
||
// 主要内容区域 - 全屏显示
|
||
ZStack {
|
||
switch selectedTab {
|
||
case .feed:
|
||
FeedView(
|
||
store: store.scope(state: \.feedState, action: \.feed)
|
||
)
|
||
.transition(.opacity)
|
||
case .me:
|
||
MeView(onLogout: onLogout)
|
||
.transition(.opacity)
|
||
}
|
||
}
|
||
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
||
|
||
// 底部导航栏 - 悬浮在最上层
|
||
VStack {
|
||
Spacer()
|
||
BottomTabView(selectedTab: $selectedTab)
|
||
}
|
||
.padding(.bottom, geometry.safeAreaInsets.bottom + 100)
|
||
}
|
||
}
|
||
.onAppear {
|
||
store.send(.onAppear)
|
||
}
|
||
.sheet(isPresented: Binding(
|
||
get: { store.isSettingPresented },
|
||
set: { _ in store.send(.settingDismissed) }
|
||
)) {
|
||
SettingView(store: store.scope(state: \.settingState, action: \.setting))
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
#Preview {
|
||
HomeView(
|
||
store: Store(
|
||
initialState: HomeFeature.State()
|
||
) {
|
||
HomeFeature()
|
||
}, onLogout: {}
|
||
)
|
||
}
|