
- 在APIEndpoints.swift中新增publishFeed端点以支持发布动态。 - 新增PublishFeedRequest和PublishFeedResponse模型,处理发布请求和响应。 - 在EditFeedFeature中实现动态编辑功能,支持用户输入和发布内容。 - 更新CreateFeedView和EditFeedView以集成新的发布功能,提升用户体验。 - 在Localizable.strings中添加相关文本的本地化支持,确保多语言兼容性。 - 优化FeedListView和FeedView以展示最新动态,增强用户交互体验。
227 lines
7.6 KiB
Swift
227 lines
7.6 KiB
Swift
import SwiftUI
|
||
import ComposableArchitecture
|
||
|
||
struct SettingView: View {
|
||
let store: StoreOf<SettingFeature>
|
||
@ObservedObject private var localizationManager = LocalizationManager.shared
|
||
|
||
var body: some View {
|
||
WithPerceptionTracking {
|
||
GeometryReader { geometry in
|
||
ZStack {
|
||
// 背景图片 - 使用"bg"图片,全屏显示
|
||
Image("bg")
|
||
.resizable()
|
||
.aspectRatio(contentMode: .fill)
|
||
.ignoresSafeArea(.all)
|
||
|
||
VStack(spacing: 0) {
|
||
// Navigation Bar
|
||
HStack {
|
||
// 返回按钮
|
||
Button(action: {
|
||
store.send(.dismissTapped)
|
||
}) {
|
||
Image(systemName: "chevron.left")
|
||
.font(.title2)
|
||
.foregroundColor(.white)
|
||
}
|
||
.padding(.leading, 16)
|
||
|
||
Spacer()
|
||
|
||
// 标题
|
||
Text(NSLocalizedString("setting.title", comment: "Settings"))
|
||
.font(.custom("PingFang SC-Semibold", size: 16))
|
||
.foregroundColor(.white)
|
||
|
||
Spacer()
|
||
|
||
// 占位符,保持标题居中
|
||
Color.clear
|
||
.frame(width: 44, height: 44)
|
||
}
|
||
.padding(.top, 8)
|
||
.padding(.horizontal)
|
||
|
||
// 内容区域
|
||
ScrollView {
|
||
VStack(spacing: 24) {
|
||
UserInfoCardView(userInfo: store.userInfo, accountModel: store.accountModel)
|
||
// .padding()
|
||
.padding(.top, 32)
|
||
|
||
SettingOptionsView(
|
||
onLanguageTapped: {
|
||
// TODO: 实现语言设置
|
||
},
|
||
onAboutTapped: {
|
||
// TODO: 实现关于页面
|
||
}
|
||
)
|
||
|
||
Spacer(minLength: 50)
|
||
|
||
LogoutButtonView {
|
||
store.send(.logoutTapped)
|
||
}
|
||
.padding(.bottom, 50)
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
.onAppear {
|
||
store.send(.onAppear)
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
// MARK: - User Info Card View
|
||
struct UserInfoCardView: View {
|
||
let userInfo: UserInfo?
|
||
let accountModel: AccountModel?
|
||
|
||
var body: some View {
|
||
VStack(spacing: 16) {
|
||
// 头像区域
|
||
Image(systemName: "person.circle.fill")
|
||
.font(.system(size: 60))
|
||
.foregroundColor(.white.opacity(0.8))
|
||
|
||
// 用户信息
|
||
VStack(spacing: 8) {
|
||
if let userInfo = userInfo, let userName = userInfo.username {
|
||
Text(userName)
|
||
.font(.title2.weight(.semibold))
|
||
.foregroundColor(.white)
|
||
} else {
|
||
Text(NSLocalizedString("setting.user", comment: "User"))
|
||
.font(.title2.weight(.semibold))
|
||
.foregroundColor(.white)
|
||
}
|
||
|
||
// 显示用户ID
|
||
if let userInfo = userInfo, let userId = userInfo.userId {
|
||
Text("ID: \(userId)")
|
||
.font(.caption)
|
||
.foregroundColor(.white.opacity(0.8))
|
||
} else if let accountModel = accountModel, let uid = accountModel.uid {
|
||
Text("UID: \(uid)")
|
||
.font(.caption)
|
||
.foregroundColor(.white.opacity(0.8))
|
||
}
|
||
}
|
||
}
|
||
.padding(.vertical, 24)
|
||
.padding(.horizontal, 20)
|
||
.background(Color.black.opacity(0.3))
|
||
.cornerRadius(16)
|
||
.padding(.horizontal, 24)
|
||
}
|
||
}
|
||
|
||
// MARK: - Setting Options View
|
||
struct SettingOptionsView: View {
|
||
let onLanguageTapped: () -> Void
|
||
let onAboutTapped: () -> Void
|
||
|
||
var body: some View {
|
||
VStack(spacing: 12) {
|
||
SettingRowView(
|
||
icon: "globe",
|
||
title: NSLocalizedString("setting.language", comment: "Language Settings"),
|
||
action: onLanguageTapped
|
||
)
|
||
|
||
SettingRowView(
|
||
icon: "info.circle",
|
||
title: NSLocalizedString("setting.about", comment: "About Us"),
|
||
action: onAboutTapped
|
||
)
|
||
|
||
HStack {
|
||
Image(systemName: "app.badge")
|
||
.foregroundColor(.white.opacity(0.8))
|
||
.frame(width: 24)
|
||
|
||
Text(NSLocalizedString("setting.version", comment: "Version Info"))
|
||
.foregroundColor(.white)
|
||
|
||
Spacer()
|
||
|
||
Text("1.0.0")
|
||
.foregroundColor(.white.opacity(0.6))
|
||
.font(.caption)
|
||
}
|
||
.padding(.horizontal, 20)
|
||
.padding(.vertical, 16)
|
||
.background(Color.black.opacity(0.2))
|
||
.cornerRadius(12)
|
||
}
|
||
.padding(.horizontal, 24)
|
||
}
|
||
}
|
||
|
||
// MARK: - Logout Button View
|
||
struct LogoutButtonView: View {
|
||
let action: () -> Void
|
||
|
||
var body: some View {
|
||
Button(action: action) {
|
||
HStack {
|
||
Image(systemName: "arrow.right.square")
|
||
Text(NSLocalizedString("setting.logout", comment: "Logout"))
|
||
}
|
||
.font(.body.weight(.medium))
|
||
.foregroundColor(.white)
|
||
.frame(maxWidth: .infinity)
|
||
.padding(.vertical, 16)
|
||
.background(Color.red.opacity(0.7))
|
||
.cornerRadius(12)
|
||
}
|
||
.padding(.horizontal, 24)
|
||
}
|
||
}
|
||
|
||
// MARK: - Setting Row View
|
||
struct SettingRowView: View {
|
||
let icon: String
|
||
let title: String
|
||
let action: () -> Void
|
||
|
||
var body: some View {
|
||
Button(action: action) {
|
||
HStack {
|
||
Image(systemName: icon)
|
||
.foregroundColor(.white.opacity(0.8))
|
||
.frame(width: 24)
|
||
|
||
Text(title)
|
||
.foregroundColor(.white)
|
||
|
||
Spacer()
|
||
|
||
Image(systemName: "chevron.right")
|
||
.foregroundColor(.white.opacity(0.6))
|
||
.font(.caption)
|
||
}
|
||
.padding(.horizontal, 20)
|
||
.padding(.vertical, 16)
|
||
.background(Color.black.opacity(0.2))
|
||
.cornerRadius(12)
|
||
}
|
||
}
|
||
}
|
||
|
||
//#Preview {
|
||
// SettingView(
|
||
// store: Store(
|
||
// initialState: SettingFeature.State()
|
||
// ) {
|
||
// SettingFeature()
|
||
// }
|
||
// )
|
||
//}
|