add settings
This commit is contained in:
parent
06682d113d
commit
d91860af49
130
punchnet/Views/Settings/SettingsAccountView.swift
Normal file
130
punchnet/Views/Settings/SettingsAccountView.swift
Normal file
@ -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()
|
||||||
|
}
|
||||||
35
punchnet/Views/Settings/SettingsState.swift
Normal file
35
punchnet/Views/Settings/SettingsState.swift
Normal file
@ -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
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
18
punchnet/Views/Settings/SettingsView.swift
Normal file
18
punchnet/Views/Settings/SettingsView.swift
Normal file
@ -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()
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user