Files
e-party-iOS/yana/Views/AppRootView.swift
edwinQQQ 4ff92c8c4d feat: 修复MainView Tab切换问题并优化MeView逻辑
- 新增MainView Tab切换问题分析文档,详细描述问题原因及解决方案。
- 优化BottomTabView的绑定逻辑,简化状态管理,确保Tab切换时状态正确更新。
- 在MeView中实现用户信息加载逻辑调整,确保动态列表仅在首次进入时加载,并添加错误处理视图。
- 创建EmptyStateView组件,提供统一的空状态展示和重试功能。
- 增强调试信息输出,便于后续问题排查和用户体验提升。
2025-08-05 15:51:07 +08:00

56 lines
1.7 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
import ComposableArchitecture
struct AppRootView: View {
@State private var isLoggedIn = false
@State private var mainStore: StoreOf<MainFeature>?
var body: some View {
Group {
if isLoggedIn {
if let mainStore = mainStore {
MainView(store: mainStore)
.onAppear {
debugInfoSync("🔄 AppRootView: 使用已存在的MainStore")
}
} else {
// MainStore
let store = createMainStore()
let _ = debugInfoSync("🆕 AppRootView: 创建MainStore")
let _ = { mainStore = store }()
MainView(store: store)
.onAppear {
debugInfoSync("💾 AppRootView: MainStore已保存")
}
}
} else {
LoginView(
store: Store(
initialState: LoginFeature.State()
) {
LoginFeature()
},
onLoginSuccess: {
debugInfoSync("🔐 AppRootView: 登录成功准备创建MainStore")
isLoggedIn = true
}
)
}
}
}
private func createMainStore() -> StoreOf<MainFeature> {
debugInfoSync("🏗️ AppRootView: 创建新的MainStore实例")
return Store(
initialState: MainFeature.State()
) {
MainFeature()
}
}
}
//
//#Preview {
// AppRootView()
//}