Files
e-party-iOS/yana/MVVM/MainPage.swift
edwinQQQ 6b960f53b4 feat: 更新Splash视图及登录模型逻辑
- 将SplashV2替换为SplashPage,优化应用启动流程。
- 在LoginModels中将用户ID参数更改为加密后的ID,增强安全性。
- 更新AppConfig中的API基础URL,确保与生产环境一致。
- 在CommonComponents中添加底部Tab栏图标映射逻辑,提升用户体验。
- 新增NineGridImagePicker组件,支持多图选择功能,优化CreateFeedPage的图片选择逻辑。
- 移除冗余的BottomTabView组件,简化视图结构,提升代码整洁性。
- 在MainPage中整合创建动态页面的逻辑,优化导航体验。
- 新增MePage视图,提供用户信息管理功能,增强应用的可用性。
2025-09-26 10:53:00 +08:00

72 lines
2.8 KiB
Swift
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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()
}
}
}
}