
- 将SplashV2替换为SplashPage,优化应用启动流程。 - 在LoginModels中将用户ID参数更改为加密后的ID,增强安全性。 - 更新AppConfig中的API基础URL,确保与生产环境一致。 - 在CommonComponents中添加底部Tab栏图标映射逻辑,提升用户体验。 - 新增NineGridImagePicker组件,支持多图选择功能,优化CreateFeedPage的图片选择逻辑。 - 移除冗余的BottomTabView组件,简化视图结构,提升代码整洁性。 - 在MainPage中整合创建动态页面的逻辑,优化导航体验。 - 新增MePage视图,提供用户信息管理功能,增强应用的可用性。
72 lines
2.8 KiB
Swift
72 lines
2.8 KiB
Swift
import SwiftUI
|
||
|
||
// MARK: - Main View
|
||
|
||
struct MainPage: View {
|
||
@StateObject private var viewModel = MainViewModel()
|
||
let onLogout: () -> Void
|
||
@State private var isPresentingCreatePage: Bool = false
|
||
|
||
var body: some View {
|
||
NavigationStack(path: $viewModel.navigationPath) {
|
||
GeometryReader { geometry in
|
||
ZStack {
|
||
// 背景图片
|
||
LoginBackgroundView()
|
||
|
||
// 主内容:使用 TabView 常驻子树
|
||
TabView(selection: $viewModel.selectedTab) {
|
||
MomentListHomePage(onCreateTapped: { isPresentingCreatePage = true })
|
||
.tag(MainViewModel.Tab.feed)
|
||
MePage(onLogout: onLogout)
|
||
.tag(MainViewModel.Tab.me)
|
||
}
|
||
.tabViewStyle(.page(indexDisplayMode: .never))
|
||
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
||
|
||
VStack {
|
||
Spacer()
|
||
// 底部导航栏(组件化)
|
||
BottomTabBar(
|
||
items: [
|
||
TabBarItem(id: MainViewModel.Tab.feed.rawValue, title: MainViewModel.Tab.feed.title, systemIconName: MainViewModel.Tab.feed.iconName),
|
||
TabBarItem(id: MainViewModel.Tab.me.rawValue, title: MainViewModel.Tab.me.title, systemIconName: MainViewModel.Tab.me.iconName)
|
||
],
|
||
selectedId: Binding(
|
||
get: { viewModel.selectedTab.rawValue },
|
||
set: { raw in
|
||
if let tab = MainViewModel.Tab(rawValue: raw) {
|
||
viewModel.onTabChanged(tab)
|
||
}
|
||
}
|
||
),
|
||
onSelect: { _ in }
|
||
)
|
||
.frame(height: 80)
|
||
.padding(.horizontal, 24)
|
||
.padding(.bottom, 100)
|
||
}
|
||
}
|
||
}
|
||
}
|
||
.onAppear {
|
||
viewModel.onLogout = onLogout
|
||
viewModel.onAddButtonTapped = {
|
||
// TODO: 处理添加按钮点击事件
|
||
debugInfoSync("➕ 添加按钮被点击")
|
||
}
|
||
viewModel.onAppear()
|
||
}
|
||
.fullScreenCover(isPresented: $isPresentingCreatePage) {
|
||
CreateFeedPage {
|
||
isPresentingCreatePage = false
|
||
}
|
||
}
|
||
.onChange(of: viewModel.isLoggedOut) { _, isLoggedOut in
|
||
if isLoggedOut {
|
||
onLogout()
|
||
}
|
||
}
|
||
}
|
||
}
|