feat: 添加设置功能和动态视图

- 新增设置功能模块,包含用户信息管理和设置选项。
- 实现动态视图,展示用户动态内容。
- 更新HomeView以支持设置页面的展示和动态视图的切换。
- 添加底部导航栏,增强用户体验。
- 更新相关视图和组件,确保一致的UI风格和交互体验。
This commit is contained in:
edwinQQQ
2025-07-11 10:42:28 +08:00
parent 4a1b814902
commit 9844289d72
23 changed files with 1036 additions and 86 deletions

View File

@@ -4,111 +4,70 @@ import ComposableArchitecture
struct HomeView: View {
let store: StoreOf<HomeFeature>
@ObservedObject private var localizationManager = LocalizationManager.shared
@State private var selectedTab: Tab = .feed
var body: some View {
WithPerceptionTracking {
GeometryReader { geometry in
ZStack {
// - 使"bg"
// 使 "bg"
Image("bg")
.resizable()
.aspectRatio(contentMode: .fill)
.frame(width: geometry.size.width, height: geometry.size.height)
.clipped()
.ignoresSafeArea(.all)
VStack(spacing: 0) {
// Navigation Bar
Text("home.title".localized)
.font(.custom("PingFang SC-Semibold", size: 16))
.foregroundColor(.white)
.frame(
width: 158,
height: 22,
alignment: .center
) //
.padding(.top, 8)
.padding(.horizontal)
//
VStack(spacing: 32) {
//
HStack {
Spacer()
//
VStack(spacing: 16) {
// UserInfo
if let userInfo = store.userInfo, let userName = userInfo.username {
Text("欢迎, \(userName)")
.font(.title2)
.foregroundColor(.white)
} else {
Text("欢迎")
.font(.title2)
.foregroundColor(.white)
}
// ID UserInfo AccountModel
if let userInfo = store.userInfo, let userId = userInfo.userId {
Text("ID: \(userId)")
.font(.caption)
.foregroundColor(.white.opacity(0.8))
} else if let accountModel = store.accountModel, let uid = accountModel.uid {
Text("UID: \(uid)")
.font(.caption)
.foregroundColor(.white.opacity(0.8))
}
// AccountModel
if let accountModel = store.accountModel {
VStack(spacing: 4) {
if accountModel.hasValidSession {
HStack {
Image(systemName: "checkmark.circle.fill")
.foregroundColor(.green)
Text("已登录")
.foregroundColor(.white.opacity(0.9))
}
.font(.caption)
} else if accountModel.hasValidAuthentication {
HStack {
Image(systemName: "clock.circle.fill")
.foregroundColor(.orange)
Text("认证中")
.foregroundColor(.white.opacity(0.9))
}
.font(.caption)
}
}
}
}
.padding()
.background(Color.black.opacity(0.3))
.cornerRadius(12)
.padding(.horizontal, 32)
Spacer()
//
//
Button(action: {
store.send(.logoutTapped)
//
}) {
HStack {
Image(systemName: "arrow.right.square")
Text("退出登录")
}
.font(.body)
.foregroundColor(.white)
.padding(.horizontal, 24)
.padding(.vertical, 12)
.background(Color.red.opacity(0.7))
.cornerRadius(8)
Image(systemName: "plus")
.font(.system(size: 20, weight: .medium))
.foregroundColor(.red)
.frame(width: 36, height: 36)
.background(
Color.white.opacity(0.2)
.cornerRadius(18)
)
}
.padding(.bottom, 50)
}
.padding(.horizontal, 20)
.padding(.top, 10)
//
ZStack {
// tab
switch selectedTab {
case .feed:
FeedView()
.transition(.opacity)
case .me:
MeView()
.transition(.opacity)
}
}
.frame(maxWidth: .infinity, maxHeight: .infinity)
//
BottomTabView(selectedTab: $selectedTab)
}
}
}
.onAppear {
store.send(.onAppear)
}
.sheet(isPresented: Binding(
get: { store.isSettingPresented },
set: { _ in store.send(.settingDismissed) }
)) {
SettingView(store: store.scope(state: \.settingState, action: \.setting))
}
}
}
}