fix settings view
This commit is contained in:
parent
5ab94163a6
commit
81ae103730
@ -4,34 +4,138 @@
|
||||
//
|
||||
// Created by 安礼成 on 2026/1/19.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct SettingsAboutView: View {
|
||||
@Environment(\.openURL) private var openURL
|
||||
|
||||
var body: some View {
|
||||
VStack(alignment: .leading, spacing: 8) {
|
||||
Text("关于PunchNet")
|
||||
ScrollView(.vertical, showsIndicators: false) {
|
||||
VStack(alignment: .leading, spacing: 32) {
|
||||
|
||||
HStack {
|
||||
Text("当前版本")
|
||||
Text("v1.25(arm64)")
|
||||
// MARK: - 品牌展示区 (左对齐)
|
||||
HStack(spacing: 20) {
|
||||
// App Icon 保持精致的圆角和阴影
|
||||
ZStack {
|
||||
RoundedRectangle(cornerRadius: 16, style: .continuous)
|
||||
.fill(Color.blue.gradient)
|
||||
.frame(width: 64, height: 64)
|
||||
.shadow(color: .blue.opacity(0.2), radius: 8, x: 0, y: 4)
|
||||
|
||||
Text("检查更新")
|
||||
Image(systemName: "bolt.shield.fill")
|
||||
.font(.system(size: 32))
|
||||
.foregroundColor(.white)
|
||||
}
|
||||
|
||||
VStack(alignment: .leading, spacing: 4) {
|
||||
Text("PunchNet")
|
||||
.font(.system(size: 22, weight: .bold))
|
||||
|
||||
Text("版本 \(SystemConfig.version_name)")
|
||||
.font(.subheadline)
|
||||
.foregroundColor(.secondary)
|
||||
|
||||
Text(SystemConfig.systemInfo)
|
||||
.font(.caption2)
|
||||
.padding(.horizontal, 6)
|
||||
.padding(.vertical, 2)
|
||||
.background(Color.primary.opacity(0.05))
|
||||
.cornerRadius(4)
|
||||
}
|
||||
}
|
||||
.padding(.top, 10)
|
||||
|
||||
// MARK: - 核心操作卡片
|
||||
VStack(alignment: .leading, spacing: 0) {
|
||||
AboutRow(title: "检查更新", icon: "arrow.clockwise.circle") {
|
||||
Button("立即检查") {
|
||||
// 检查更新逻辑
|
||||
}
|
||||
.buttonStyle(.plain)
|
||||
.foregroundColor(.blue)
|
||||
.font(.subheadline.bold())
|
||||
}
|
||||
|
||||
Divider().padding(.leading, 44)
|
||||
|
||||
AboutRow(title: "用户反馈", icon: "bubble.left.and.exclamationmark.bubble.right") {
|
||||
Image(systemName: "chevron.right")
|
||||
.font(.caption)
|
||||
.foregroundColor(.secondary)
|
||||
}
|
||||
.onTapGesture {
|
||||
if let url = URL(string: "https://yourfeedbacklink.com") {
|
||||
openURL(url)
|
||||
}
|
||||
}
|
||||
}
|
||||
.background(Color.primary.opacity(0.03))
|
||||
.cornerRadius(12)
|
||||
.overlay(RoundedRectangle(cornerRadius: 12).stroke(Color.primary.opacity(0.05), lineWidth: 1))
|
||||
|
||||
// MARK: - 法律文档卡片
|
||||
VStack(alignment: .leading, spacing: 0) {
|
||||
AboutRow(title: "隐私政策", icon: "doc.text.magnifyingglass") {
|
||||
Image(systemName: "arrow.up.right")
|
||||
.font(.caption)
|
||||
.foregroundColor(.secondary)
|
||||
}
|
||||
.onTapGesture {
|
||||
/* 跳转隐私协议 */
|
||||
}
|
||||
|
||||
Divider().padding(.leading, 44)
|
||||
|
||||
AboutRow(title: "服务条款", icon: "scroll") {
|
||||
Image(systemName: "arrow.up.right")
|
||||
.font(.caption)
|
||||
.foregroundColor(.secondary)
|
||||
}
|
||||
.onTapGesture {
|
||||
/* 跳转服务条款 */
|
||||
}
|
||||
}
|
||||
.background(Color.primary.opacity(0.03))
|
||||
.cornerRadius(12)
|
||||
|
||||
// MARK: - 底部版权
|
||||
VStack(alignment: .leading, spacing: 4) {
|
||||
Text("© 2024-2026 PunchNet Inc.")
|
||||
Text("保留所有权利。")
|
||||
}
|
||||
.font(.caption2)
|
||||
.foregroundColor(.secondary)
|
||||
.padding(.leading, 4)
|
||||
}
|
||||
|
||||
Button {
|
||||
|
||||
} label: {
|
||||
Text("用户反馈")
|
||||
}
|
||||
|
||||
HStack {
|
||||
Text("隐私政策")
|
||||
Text("服务条款")
|
||||
}
|
||||
|
||||
.padding(32)
|
||||
.frame(maxWidth: 600, alignment: .leading)
|
||||
}
|
||||
.padding()
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - 复用之前的行组件
|
||||
struct AboutRow<Content: View>: View {
|
||||
let title: String
|
||||
let icon: String
|
||||
let trailingContent: () -> Content
|
||||
|
||||
var body: some View {
|
||||
HStack(spacing: 12) {
|
||||
Image(systemName: icon)
|
||||
.foregroundColor(.blue)
|
||||
.font(.system(size: 14))
|
||||
.frame(width: 20)
|
||||
|
||||
Text(title)
|
||||
.font(.system(size: 14, weight: .medium))
|
||||
|
||||
Spacer()
|
||||
|
||||
trailingContent()
|
||||
}
|
||||
.padding(.horizontal, 16)
|
||||
.padding(.vertical, 14)
|
||||
.contentShape(Rectangle())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -4,22 +4,105 @@
|
||||
//
|
||||
// Created by 安礼成 on 2026/1/19.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct SettingsSystemView: View {
|
||||
@State private var isOn: Bool = false
|
||||
// 为每个设置项提供独立的状态
|
||||
@State private var launchAtLogin: Bool = false
|
||||
@State private var autoConnect: Bool = false
|
||||
@State private var showMainUI: Bool = true
|
||||
@State private var autoUpdate: Bool = true
|
||||
|
||||
var body: some View {
|
||||
VStack(alignment: .leading) {
|
||||
Toggle("开机时启动", isOn: $isOn)
|
||||
Toggle("启动时候自动连接", isOn: $isOn)
|
||||
Toggle("启动时显示主界面", isOn: $isOn)
|
||||
Toggle("自动安装更新", isOn: $isOn)
|
||||
ScrollView(.vertical, showsIndicators: false) {
|
||||
VStack(alignment: .leading, spacing: 28) {
|
||||
|
||||
// MARK: - 启动行为设置
|
||||
systemSectionHeader(title: "启动与运行", icon: "power.circle.fill")
|
||||
|
||||
VStack(spacing: 0) {
|
||||
ToggleRow(icon: "macwindow.badge.plus", title: "开机时自动启动", isOn: $launchAtLogin)
|
||||
|
||||
Divider().padding(.leading, 48) // 为图标留出间距
|
||||
|
||||
ToggleRow(icon: "bolt.horizontal.icloud.fill", title: "应用启动后自动连接", isOn: $autoConnect)
|
||||
|
||||
Divider().padding(.leading, 48)
|
||||
|
||||
ToggleRow(icon: "macwindow", title: "启动时显示主界面", isOn: $showMainUI)
|
||||
}
|
||||
.background(Color.primary.opacity(0.03))
|
||||
.cornerRadius(12)
|
||||
.overlay(RoundedRectangle(cornerRadius: 12).stroke(Color.primary.opacity(0.05), lineWidth: 1))
|
||||
|
||||
// MARK: - 软件维护
|
||||
systemSectionHeader(title: "软件更新", icon: "arrow.clockwise.circle.fill")
|
||||
|
||||
VStack(spacing: 0) {
|
||||
ToggleRow(icon: "arrow.down.circle.fill", title: "自动下载并安装更新", isOn: $autoUpdate)
|
||||
}
|
||||
.background(Color.primary.opacity(0.03))
|
||||
.cornerRadius(12)
|
||||
.overlay(RoundedRectangle(cornerRadius: 12).stroke(Color.primary.opacity(0.05), lineWidth: 1))
|
||||
|
||||
// MARK: - 底部版本提示
|
||||
Text("当前版本:1.0.4 (Build 202603) - 已是最新版本")
|
||||
.font(.caption)
|
||||
.foregroundColor(.secondary)
|
||||
.padding(.horizontal, 4)
|
||||
|
||||
Spacer()
|
||||
}
|
||||
.padding(32)
|
||||
.frame(maxWidth: 600, alignment: .leading)
|
||||
}
|
||||
.padding()
|
||||
}
|
||||
|
||||
// 辅助头部
|
||||
private func systemSectionHeader(title: String, icon: String) -> some View {
|
||||
HStack {
|
||||
Image(systemName: icon)
|
||||
.foregroundColor(.blue)
|
||||
.font(.system(size: 14, weight: .semibold))
|
||||
Text(title)
|
||||
.font(.system(size: 15, weight: .bold))
|
||||
.foregroundColor(.secondary)
|
||||
}
|
||||
.padding(.leading, 4)
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - 子组件:开关行
|
||||
struct ToggleRow: View {
|
||||
let icon: String
|
||||
let title: String
|
||||
@Binding var isOn: Bool
|
||||
|
||||
var body: some View {
|
||||
HStack(spacing: 16) {
|
||||
// 图标容器
|
||||
ZStack {
|
||||
RoundedRectangle(cornerRadius: 6, style: .continuous)
|
||||
.fill(Color.blue.opacity(0.1))
|
||||
.frame(width: 28, height: 28)
|
||||
|
||||
Image(systemName: icon)
|
||||
.font(.system(size: 14, weight: .medium))
|
||||
.foregroundColor(.blue)
|
||||
}
|
||||
|
||||
Text(title)
|
||||
.font(.system(size: 14))
|
||||
|
||||
Spacer()
|
||||
|
||||
Toggle("", isOn: $isOn)
|
||||
.toggleStyle(.switch) // 强制使用 macOS 切换样式
|
||||
.labelsHidden() // 隐藏自带的 Label 以便我们自定义布局
|
||||
}
|
||||
.padding(.horizontal, 16)
|
||||
.padding(.vertical, 12)
|
||||
}
|
||||
}
|
||||
|
||||
#Preview {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user