113 lines
3.4 KiB
Swift
113 lines
3.4 KiB
Swift
import SwiftUI
|
|
|
|
/// 设置页面视图
|
|
struct AccountView: View {
|
|
// MARK: - 属性
|
|
|
|
/// 环境变量 - 用于dismiss视图
|
|
@Environment(\.dismiss) private var dismiss
|
|
|
|
/// 状态 - 控制视图显示/隐藏
|
|
@Binding var isAccountPresented: Bool
|
|
|
|
// MARK: - 动画配置
|
|
|
|
/// 动画配置
|
|
private let animation = Animation.spring(
|
|
response: 0.6, // 响应时间
|
|
dampingFraction: 0.9, // 阻尼系数
|
|
blendDuration: 0.8 // 混合时间
|
|
)
|
|
|
|
// MARK: - 主体视图
|
|
|
|
var body: some View {
|
|
ZStack {
|
|
// Theme background color
|
|
Color.themeTextWhiteSecondary.edgesIgnoringSafeArea(.all)
|
|
|
|
VStack(spacing: 0) {
|
|
// 简洁导航头
|
|
SimpleNaviHeader(title: "Account & Security") {
|
|
withAnimation(animation) {
|
|
isAccountPresented = false
|
|
}
|
|
}
|
|
|
|
// 设置项列表
|
|
List {
|
|
// 账号与安全
|
|
settingRow(
|
|
icon: "Account",
|
|
title: "Account & Security",
|
|
action: {}
|
|
)
|
|
|
|
|
|
}
|
|
.background(Color.white)
|
|
.cornerRadius(12)
|
|
.padding()
|
|
.listStyle(PlainListStyle())
|
|
.listRowSeparator(.hidden)
|
|
.listRowInsets(EdgeInsets())
|
|
}
|
|
}
|
|
.background(Color.themeTextWhiteSecondary.edgesIgnoringSafeArea(.all))
|
|
.environment(\.horizontalSizeClass, .regular)
|
|
}
|
|
|
|
// MARK: - 私有方法
|
|
|
|
/// 配置TableView外观
|
|
private func configureTableView() {
|
|
// 移除列表底部分隔线
|
|
UITableView.appearance().tableFooterView = UIView()
|
|
// 移除列表顶部分隔线
|
|
UITableView.appearance().tableHeaderView = UIView(frame: CGRect(x: 0, y: 0, width: 0, height: CGFloat.leastNonzeroMagnitude))
|
|
// 移除分隔线缩进
|
|
UITableView.appearance().separatorInset = .zero
|
|
// 移除列表顶部额外间距
|
|
UITableView.appearance().contentInset = .zero
|
|
}
|
|
|
|
/// 创建设置项行视图
|
|
/// - Parameters:
|
|
/// - icon: 图标名称
|
|
/// - title: 标题
|
|
/// - action: 点击动作
|
|
/// - Returns: 返回设置项行视图
|
|
private func settingRow(icon: String, title: String, action: @escaping () -> Void) -> some View {
|
|
Button(action: action) {
|
|
HStack {
|
|
// 左侧图标
|
|
SVGImage(svgName: icon)
|
|
.frame(width: 24, height: 24)
|
|
|
|
// 标题
|
|
Text(title)
|
|
.foregroundColor(.primary)
|
|
|
|
Spacer()
|
|
|
|
// 右侧箭头
|
|
Image(systemName: "chevron.right")
|
|
.font(.system(size: 14))
|
|
.foregroundColor(.gray)
|
|
}
|
|
.padding(.vertical, 12) // 增加垂直内边距
|
|
.background(Color.white)
|
|
}
|
|
.buttonStyle(PlainButtonStyle())
|
|
.listRowBackground(Color.white)
|
|
.listRowSeparator(.hidden)
|
|
}
|
|
}
|
|
|
|
// MARK: - 预览
|
|
#Preview {
|
|
NavigationView {
|
|
AccountView(isAccountPresented: .constant(true))
|
|
}
|
|
}
|