From 6e054fc169a10dd7a0bb94c78bc31148a032889b Mon Sep 17 00:00:00 2001 From: anlicheng <244108715@qq.com> Date: Mon, 19 Jan 2026 11:36:45 +0800 Subject: [PATCH] add view --- .../Views/Settings/SettingsAboutView.swift | 40 +++++++++ .../Views/Settings/SettingsAccountView.swift | 1 + .../Views/Settings/SettingsDeviceView.swift | 43 ++++++++++ .../Views/Settings/SettingsNetworkView.swift | 83 +++++++++++++++++++ punchnet/Views/Settings/SettingsState.swift | 24 +++++- .../Views/Settings/SettingsSystemView.swift | 27 ++++++ .../Settings/SettingsUserIssueView.swift | 53 ++++++++++++ 7 files changed, 270 insertions(+), 1 deletion(-) create mode 100644 punchnet/Views/Settings/SettingsAboutView.swift create mode 100644 punchnet/Views/Settings/SettingsDeviceView.swift create mode 100644 punchnet/Views/Settings/SettingsNetworkView.swift create mode 100644 punchnet/Views/Settings/SettingsSystemView.swift create mode 100644 punchnet/Views/Settings/SettingsUserIssueView.swift diff --git a/punchnet/Views/Settings/SettingsAboutView.swift b/punchnet/Views/Settings/SettingsAboutView.swift new file mode 100644 index 0000000..c67c5f4 --- /dev/null +++ b/punchnet/Views/Settings/SettingsAboutView.swift @@ -0,0 +1,40 @@ +// +// SettingsAboutView.swift +// punchnet +// +// Created by 安礼成 on 2026/1/19. +// + +import SwiftUI + +struct SettingsAboutView: View { + var body: some View { + VStack(alignment: .leading, spacing: 8) { + Text("关于PunchNet") + + HStack { + Text("当前版本") + Text("v1.25(arm64)") + + Text("检查更新") + } + + Button { + + } label: { + Text("用户反馈") + } + + HStack { + Text("隐私政策") + Text("服务条款") + } + + } + .padding() + } +} + +#Preview { + SettingsAboutView() +} diff --git a/punchnet/Views/Settings/SettingsAccountView.swift b/punchnet/Views/Settings/SettingsAccountView.swift index d2b864a..f390194 100644 --- a/punchnet/Views/Settings/SettingsAccountView.swift +++ b/punchnet/Views/Settings/SettingsAccountView.swift @@ -40,6 +40,7 @@ struct SettingsAccountView: View { .background(Color.gray.opacity(0.2)) .cornerRadius(5) } + Button { } label: { diff --git a/punchnet/Views/Settings/SettingsDeviceView.swift b/punchnet/Views/Settings/SettingsDeviceView.swift new file mode 100644 index 0000000..8a2cc87 --- /dev/null +++ b/punchnet/Views/Settings/SettingsDeviceView.swift @@ -0,0 +1,43 @@ +// +// SettingsDeviceView.swift +// punchnet +// +// Created by 安礼成 on 2026/1/19. +// + +import SwiftUI + +struct SettingsDeviceView: View { + var body: some View { + VStack(alignment: .leading) { + Text("设备") + + HStack { + Text("设备名称") + Text("史蒂夫的air") + + Button { + + } label: { + Text("修改") + } + } + + HStack { + Text("虚拟IPv4") + Text("192.168.1.1") + } + + HStack { + Text("虚拟IPv6") + Text("ab:ef:1") + } + + Spacer() + } + } +} + +#Preview { + SettingsDeviceView() +} diff --git a/punchnet/Views/Settings/SettingsNetworkView.swift b/punchnet/Views/Settings/SettingsNetworkView.swift new file mode 100644 index 0000000..5de6a96 --- /dev/null +++ b/punchnet/Views/Settings/SettingsNetworkView.swift @@ -0,0 +1,83 @@ +// +// SettingsNetworkView.swift +// punchnet +// +// Created by 安礼成 on 2026/1/19. +// + +import SwiftUI + +struct SettingsNetworkView: View { + @State var state: SettingsState = SettingsState() + + var body: some View { + VStack(alignment: .leading) { + 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("详情") + } + + } + + + HStack { + Text("出口节点") + + Menu { + ForEach(state.exitNodes, id: \.id) { node in + Button(node.name) { + self.state.selectedExitNode = node + } + } + + } label: { + Text(state.selectedExitNode.name) + } + } + + HStack { + Text("授权状态") + Text("有效") + } + + HStack { + Text("授权有效期") + Text("临时(至断开连接)") + } + + } + + } + +} + +#Preview { + SettingsNetworkView() +} diff --git a/punchnet/Views/Settings/SettingsState.swift b/punchnet/Views/Settings/SettingsState.swift index 2476f04..0efa034 100644 --- a/punchnet/Views/Settings/SettingsState.swift +++ b/punchnet/Views/Settings/SettingsState.swift @@ -15,10 +15,20 @@ class SettingsState { var name: String } - var networks: [Network] + struct ExitNode { + var id: Int + var name: String + } + + var networks: [Network] var selectedNetwork: Network + + var exitNodes: [ExitNode] + var selectedExitNode: ExitNode + + init() { let networks: [Network] = [ .init(id: 1, name: "测试网络12"), @@ -30,6 +40,18 @@ class SettingsState { self.selectedNetwork = networks[0] self.networks = networks + + + let exitNodes: [ExitNode] = [ + .init(id: 1, name: "出口节点1"), + .init(id: 2, name: "出口节点12"), + .init(id: 3, name: "出口节点13"), + .init(id: 4, name: "出口节点14"), + .init(id: 5, name: "出口节点15"), + ] + self.selectedExitNode = exitNodes[0] + self.exitNodes = exitNodes + } } diff --git a/punchnet/Views/Settings/SettingsSystemView.swift b/punchnet/Views/Settings/SettingsSystemView.swift new file mode 100644 index 0000000..e1acb0e --- /dev/null +++ b/punchnet/Views/Settings/SettingsSystemView.swift @@ -0,0 +1,27 @@ +// +// SettingsSystemView.swift +// punchnet +// +// Created by 安礼成 on 2026/1/19. +// + +import SwiftUI + +struct SettingsSystemView: View { + @State private var isOn: Bool = false + + var body: some View { + VStack(alignment: .leading) { + Toggle("开机时启动", isOn: $isOn) + Toggle("启动时候自动连接", isOn: $isOn) + Toggle("启动时显示主界面", isOn: $isOn) + Toggle("自动安装更新", isOn: $isOn) + } + .padding() + } + +} + +#Preview { + SettingsSystemView() +} diff --git a/punchnet/Views/Settings/SettingsUserIssueView.swift b/punchnet/Views/Settings/SettingsUserIssueView.swift new file mode 100644 index 0000000..847c429 --- /dev/null +++ b/punchnet/Views/Settings/SettingsUserIssueView.swift @@ -0,0 +1,53 @@ +// +// SettingsUserIssueView.swift +// punchnet +// +// Created by 安礼成 on 2026/1/19. +// + +import SwiftUI + +struct SettingsUserIssueView: View { + @State private var account: String = "" + @State private var text: String = "" + + var body: some View { + VStack { + Text("用户反馈") + + TextField("", text: $account) + .multilineTextAlignment(.leading) + .textFieldStyle(PlainTextFieldStyle()) + .frame(width: 200, height: 25) + .background(Color.clear) + .foregroundColor(Color.black) + .overlay( + Rectangle() + .frame(height: 1) + .foregroundColor(.blue) + .padding(.top, 25) + , alignment: .topLeading) + + TextEditor(text: $text) + .padding(4) + .overlay(alignment: .topLeading) { + if text.isEmpty { + Text("请输入内容") + .foregroundColor(.gray) + .padding(.leading, 8) + } + } + .frame(minHeight: 120) + .overlay( + RoundedRectangle(cornerRadius: 6) + .stroke(Color.gray.opacity(0.4)) + ) + + } + .padding() + } +} + +#Preview { + SettingsUserIssueView() +}