wake-ios/wake/View/Owner/AccountView.swift
2025-08-31 17:27:22 +08:00

188 lines
7.0 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 AccountView: View {
// MARK: -
/// - dismiss
@Environment(\.dismiss) private var dismiss
///
@State private var showDeleteConfirmation = false
// 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) {
Router.shared.pop()
}
}
.padding(.top, UIApplication.shared.windows.first?.safeAreaInsets.top)
//
ScrollView {
VStack(spacing: 0) {
//
settingRow(
title: "Delete Account",
action: {
withAnimation {
showDeleteConfirmation = true
}
}
)
.padding()
}
.background(Color.white)
.cornerRadius(12)
.padding(.horizontal)
}
.background(Color.themeTextWhiteSecondary)
}
.frame(maxWidth: .infinity, maxHeight: .infinity)
.edgesIgnoringSafeArea(.top)
}
.edgesIgnoringSafeArea(.all)
.frame(maxWidth: .infinity, maxHeight: .infinity)
.overlay(
//
Group {
if showDeleteConfirmation {
ZStack {
//
Color.black.opacity(0.6)
.edgesIgnoringSafeArea(.all)
.onTapGesture {
withAnimation {
showDeleteConfirmation = false
}
}
//
VStack(spacing: 20) {
Text("Are you sure you want to delete this account?")
.font(.headline)
.font(.system(size: 14, weight: .medium))
.foregroundColor(.themeTextMessageMain)
Text("Once deleted, you cant get it back.")
.multilineTextAlignment(.center)
.font(.subheadline)
.font(.system(size: 12))
.foregroundColor(.themeTextMessage)
HStack(spacing: 20) {
Button(action: {
withAnimation {
showDeleteConfirmation = false
}
}) {
Text("Cancel")
.font(Typography.font(for: .subtitle, family: .quicksandBold))
.foregroundColor(.themeTextMessageMain)
.frame(maxWidth: .infinity)
.padding()
.background(Color.themePrimary)
.cornerRadius(32)
}
Button(action: {
//
withAnimation {
showDeleteConfirmation = false
}
// TODO: API
}) {
Text("Confirm")
.foregroundColor(.themeTextMessage)
.font(.system(size: 12))
.frame(maxWidth: .infinity)
.padding()
.background(Color.white)
.cornerRadius(32)
}
}
}
.padding()
.frame(width: 300)
.background(Color.white)
.cornerRadius(12)
.shadow(radius: 10)
}
.transition(.opacity)
}
}
)
.navigationBarBackButtonHidden(true) //
.navigationBarHidden(true) //
}
// 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(title: String, action: @escaping () -> Void) -> some View {
Button(action: action) {
HStack {
//
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()
}
}