wake-ios/wake/View/Owner/SettingsView.swift
2025-08-15 16:05:50 +08:00

157 lines
4.9 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
///
struct SettingsView: View {
// MARK: -
/// - dismiss
@Environment(\.dismiss) private var dismiss
/// - /
@Binding var isPresented: Bool
// MARK: -
///
private let animation = Animation.spring(
response: 0.6, //
dampingFraction: 0.9, //
blendDuration: 0.8 //
)
// MARK: -
var body: some View {
VStack(spacing: 0) {
//
HStack {
//
Button(action: {
withAnimation(animation) {
isPresented = false
}
}) {
HStack(spacing: 4) {
Image(systemName: "chevron.left")
.font(.system(size: 16, weight: .medium))
.foregroundColor(.blue)
}
}
Spacer()
//
Text("Setting")
.font(.headline)
Spacer()
//
Color.clear
.frame(width: 44, height: 44)
}
.padding(.horizontal,16)
.padding(.vertical, 8)
//
List {
//
settingRow(
icon: "person.crop.circle",
title: "Account & Security",
action: {}
)
//
settingRow(
icon: "lock.shield",
title: "Permission Management",
action: {}
)
//
settingRow(
icon: "questionmark.circle",
title: "Support & Service",
action: {}
)
//
settingRow(
icon: "info.circle",
title: "About Us",
action: {}
)
}
//
.listStyle(PlainListStyle())
// 线
.listRowSeparator(.hidden)
//
.listRowInsets(EdgeInsets())
.background(Color(.systemGroupedBackground))
}
.frame(maxWidth: .infinity, maxHeight: .infinity)
.background(Color(.systemGroupedBackground))
// regular
.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 {
//
Image(systemName: icon)
.font(.system(size: 24))
.foregroundColor(.gray)
.frame(width: 40)
//
Text(title)
.foregroundColor(.primary)
Spacer()
//
Image(systemName: "chevron.right")
.font(.system(size: 14))
.foregroundColor(.gray)
}
.padding(.vertical, 6) //
.padding(.horizontal, 12)
.background(Color(.systemGroupedBackground))
}
.buttonStyle(PlainButtonStyle())
.listRowBackground(Color(.systemGroupedBackground))
.listRowSeparator(.hidden)
}
}
// MARK: -
#Preview {
NavigationView {
SettingsView(isPresented: .constant(true))
}
}