
- 创建SettingPage视图,包含用户信息管理、头像设置、昵称编辑等功能。 - 实现SettingViewModel,处理设置页面的业务逻辑,包括头像上传、昵称更新等。 - 添加相机和相册选择功能,支持头像更换。 - 更新MainPage和MainViewModel,添加导航逻辑以支持设置页面的访问。 - 完善本地化支持,确保多语言兼容性。 - 新增相关测试建议,确保功能完整性和用户体验。
75 lines
2.8 KiB
Swift
75 lines
2.8 KiB
Swift
import SwiftUI
|
|
|
|
// MARK: - BackgroundView
|
|
struct MomentListBackgroundView: View {
|
|
var body: some View {
|
|
Image("bg")
|
|
.resizable()
|
|
.aspectRatio(contentMode: .fill)
|
|
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
|
.clipped()
|
|
.ignoresSafeArea(.all)
|
|
}
|
|
}
|
|
|
|
// MARK: - MomentListHomePage
|
|
struct MomentListHomePage: View {
|
|
@StateObject private var viewModel = MomentListHomeViewModel()
|
|
|
|
var body: some View {
|
|
GeometryReader { geometry in
|
|
ZStack {
|
|
// 背景
|
|
MomentListBackgroundView()
|
|
|
|
VStack(alignment: .center, spacing: 0) {
|
|
// 标题
|
|
Text(LocalizedString("feedList.title", comment: "Enjoy your Life Time"))
|
|
.font(.system(size: 22, weight: .semibold))
|
|
.foregroundColor(.white)
|
|
.frame(maxWidth: .infinity, alignment: .center)
|
|
.padding(.top, 60)
|
|
|
|
// Volume 图标
|
|
Image("Volume")
|
|
.frame(width: 56, height: 41)
|
|
.padding(.top, 16)
|
|
|
|
// 标语
|
|
Text(LocalizedString("feedList.slogan", comment: "The disease is like a cruel ruler,\nand time is our most precious treasure.\nEvery moment we live is a victory\nagainst the inevitable."))
|
|
.font(.system(size: 16))
|
|
.multilineTextAlignment(.leading)
|
|
.foregroundColor(.white.opacity(0.9))
|
|
.padding(.horizontal, 30)
|
|
.padding(.bottom, 30)
|
|
|
|
// 动态列表内容
|
|
if !viewModel.moments.isEmpty {
|
|
// 显示第一个数据来测试效果
|
|
MomentListItem(moment: viewModel.moments[0])
|
|
.padding(.horizontal, 16)
|
|
.padding(.bottom, 20)
|
|
} else if viewModel.isLoading {
|
|
ProgressView()
|
|
.progressViewStyle(CircularProgressViewStyle(tint: .white))
|
|
.padding(.top, 20)
|
|
} else if let error = viewModel.error {
|
|
Text(error)
|
|
.font(.system(size: 14))
|
|
.foregroundColor(.red)
|
|
.multilineTextAlignment(.center)
|
|
.padding(.horizontal, 20)
|
|
.padding(.top, 20)
|
|
}
|
|
|
|
Spacer()
|
|
}
|
|
}
|
|
}
|
|
.ignoresSafeArea()
|
|
.onAppear {
|
|
viewModel.onAppear()
|
|
}
|
|
}
|
|
}
|