From d91860af4975b54a3260be0774722c0595787320 Mon Sep 17 00:00:00 2001 From: anlicheng <244108715@qq.com> Date: Fri, 16 Jan 2026 18:01:42 +0800 Subject: [PATCH] add settings --- .../Views/Settings/SettingsAccountView.swift | 130 ++++++++++++++++++ punchnet/Views/Settings/SettingsState.swift | 35 +++++ punchnet/Views/Settings/SettingsView.swift | 18 +++ 3 files changed, 183 insertions(+) create mode 100644 punchnet/Views/Settings/SettingsAccountView.swift create mode 100644 punchnet/Views/Settings/SettingsState.swift create mode 100644 punchnet/Views/Settings/SettingsView.swift diff --git a/punchnet/Views/Settings/SettingsAccountView.swift b/punchnet/Views/Settings/SettingsAccountView.swift new file mode 100644 index 0000000..d2b864a --- /dev/null +++ b/punchnet/Views/Settings/SettingsAccountView.swift @@ -0,0 +1,130 @@ +// +// SettingsAccountView.swift +// punchnet +// +// Created by 安礼成 on 2026/1/16. +// + +import SwiftUI + +struct SettingsAccountView: View { + @State var state: SettingsState = SettingsState() + + var body: some View { + + ScrollView(.vertical, showsIndicators: false) { + VStack(alignment: .leading) { + Text("账户") + + AccountCreditView() + AccountCreditView() + TokenCreditView() + AccountCreditView() + TokenCreditView() + + Text("网络") + + HStack(alignment: .top) { + Text("默认网络") + + VStack(alignment: .leading) { + Menu { + ForEach(state.networks, id: \.id) { network in + Button(network.name) { + self.state.selectedNetwork = network + } + } + } label: { + Text(state.selectedNetwork.name) + .padding() + .background(Color.gray.opacity(0.2)) + .cornerRadius(5) + } + Button { + + } label: { + Text("进入管理平台") + } + + } + + Button { + + } label: { + Text("详情") + } + } + + } + } + .padding() + + } + +} + +extension SettingsAccountView { + + // 基于账号密码的登陆 + struct AccountCreditView: View { + var body: some View { + HStack { + Image("logo") + .resizable() + .frame(width: 20, height: 20) + + Text("13012345678") + + Spacer() + + Button { + + } label: { + Text("修改密码") + } + + Button { + + } label: { + Text("退出登陆") + } + } + .frame(width: 400) + } + + } + + // 基于Token的登陆 + struct TokenCreditView: View { + + var body: some View { + HStack { + Image("logo") + .resizable() + .frame(width: 20, height: 20) + + Text("key_001") + + Spacer() + + Button { + + } label: { + Text("退出登陆") + } + + } + .frame(width: 400) + } + + } + + + +} + + + +#Preview { + SettingsAccountView() +} diff --git a/punchnet/Views/Settings/SettingsState.swift b/punchnet/Views/Settings/SettingsState.swift new file mode 100644 index 0000000..2476f04 --- /dev/null +++ b/punchnet/Views/Settings/SettingsState.swift @@ -0,0 +1,35 @@ +// +// SettingsState.swift +// punchnet +// +// Created by 安礼成 on 2026/1/16. +// + +import Foundation +import Observation + +@Observable +class SettingsState { + struct Network { + var id: Int + var name: String + } + + var networks: [Network] + + var selectedNetwork: Network + + init() { + let networks: [Network] = [ + .init(id: 1, name: "测试网络12"), + .init(id: 2, name: "测试网络13"), + .init(id: 3, name: "测试网络14"), + .init(id: 4, name: "测试网络15"), + .init(id: 5, name: "xyz"), + ] + + self.selectedNetwork = networks[0] + self.networks = networks + } + +} diff --git a/punchnet/Views/Settings/SettingsView.swift b/punchnet/Views/Settings/SettingsView.swift new file mode 100644 index 0000000..2dbce47 --- /dev/null +++ b/punchnet/Views/Settings/SettingsView.swift @@ -0,0 +1,18 @@ +// +// SettingsView.swift +// punchnet +// +// Created by 安礼成 on 2026/1/16. +// + +import SwiftUI + +struct SettingsView: View { + var body: some View { + Text(/*@START_MENU_TOKEN@*/"Hello, World!"/*@END_MENU_TOKEN@*/) + } +} + +#Preview { + SettingsView() +}