You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
247 lines
11 KiB
247 lines
11 KiB
import SwiftUI
|
|
|
|
struct SettingsView: View {
|
|
@EnvironmentObject private var languageManager: LanguageManager
|
|
@Environment(\.dismiss) private var dismiss
|
|
|
|
var body: some View {
|
|
NavigationView {
|
|
ZStack {
|
|
// 背景渐变
|
|
LinearGradient(
|
|
gradient: Gradient(colors: [
|
|
Color(.systemBackground),
|
|
Color(.systemGray6).opacity(0.2)
|
|
]),
|
|
startPoint: .top,
|
|
endPoint: .bottom
|
|
)
|
|
.ignoresSafeArea()
|
|
|
|
ScrollView {
|
|
VStack(spacing: 24) {
|
|
// 顶部图标
|
|
VStack(spacing: 16) {
|
|
ZStack {
|
|
Circle()
|
|
.fill(
|
|
LinearGradient(
|
|
gradient: Gradient(colors: [
|
|
Color.blue.opacity(0.1),
|
|
Color.blue.opacity(0.05)
|
|
]),
|
|
startPoint: .topLeading,
|
|
endPoint: .bottomTrailing
|
|
)
|
|
)
|
|
.frame(width: 80, height: 80)
|
|
|
|
Image(systemName: "gearshape.fill")
|
|
.font(.system(size: 36, weight: .light))
|
|
.foregroundColor(.blue)
|
|
}
|
|
|
|
Text("settings".localized)
|
|
.font(.system(size: 28, weight: .bold, design: .rounded))
|
|
.foregroundColor(.primary)
|
|
.id(languageManager.refreshTrigger)
|
|
}
|
|
.padding(.top, 20)
|
|
|
|
// 语言设置卡片
|
|
VStack(alignment: .leading, spacing: 16) {
|
|
HStack {
|
|
Image(systemName: "globe")
|
|
.font(.system(size: 20, weight: .medium))
|
|
.foregroundColor(.blue)
|
|
.frame(width: 32)
|
|
|
|
VStack(alignment: .leading, spacing: 4) {
|
|
Text("language_settings".localized)
|
|
.font(.system(size: 18, weight: .semibold))
|
|
.id(languageManager.refreshTrigger)
|
|
Text("select_app_language".localized)
|
|
.id(languageManager.refreshTrigger)
|
|
.font(.system(size: 14))
|
|
.foregroundColor(.secondary)
|
|
}
|
|
|
|
Spacer()
|
|
}
|
|
|
|
Picker("language".localized, selection: $languageManager.currentLanguage) {
|
|
ForEach(Language.allCases, id: \.self) { language in
|
|
Text(language.displayName).tag(language)
|
|
}
|
|
}
|
|
.pickerStyle(SegmentedPickerStyle())
|
|
.onChange(of: languageManager.currentLanguage) { newLanguage in
|
|
languageManager.switchLanguage(to: newLanguage)
|
|
}
|
|
}
|
|
.padding(20)
|
|
.background(
|
|
RoundedRectangle(cornerRadius: 16)
|
|
.fill(Color(.systemBackground))
|
|
.shadow(color: .black.opacity(0.05), radius: 8, x: 0, y: 2)
|
|
)
|
|
.padding(.horizontal, 20)
|
|
|
|
// 应用信息卡片
|
|
VStack(alignment: .leading, spacing: 16) {
|
|
HStack {
|
|
Image(systemName: "info.circle")
|
|
.font(.system(size: 20, weight: .medium))
|
|
.foregroundColor(.green)
|
|
.frame(width: 32)
|
|
|
|
Text("app_info".localized)
|
|
.font(.system(size: 18, weight: .semibold))
|
|
|
|
Spacer()
|
|
}
|
|
|
|
VStack(spacing: 12) {
|
|
HStack {
|
|
Text("version".localized)
|
|
.font(.system(size: 16))
|
|
.foregroundColor(.secondary)
|
|
Spacer()
|
|
Text("version_number".localized)
|
|
.font(.system(size: 16, weight: .medium))
|
|
}
|
|
|
|
HStack {
|
|
Text("build_version".localized)
|
|
.font(.system(size: 16))
|
|
.foregroundColor(.secondary)
|
|
Spacer()
|
|
Text("build_number".localized)
|
|
.font(.system(size: 16, weight: .medium))
|
|
}
|
|
}
|
|
}
|
|
.padding(20)
|
|
.background(
|
|
RoundedRectangle(cornerRadius: 16)
|
|
.fill(Color(.systemBackground))
|
|
.shadow(color: .black.opacity(0.05), radius: 8, x: 0, y: 2)
|
|
)
|
|
.padding(.horizontal, 20)
|
|
|
|
// 功能说明卡片
|
|
VStack(alignment: .leading, spacing: 16) {
|
|
HStack {
|
|
Image(systemName: "star.fill")
|
|
.font(.system(size: 20, weight: .medium))
|
|
.foregroundColor(.orange)
|
|
.frame(width: 32)
|
|
|
|
Text("features".localized)
|
|
.font(.system(size: 18, weight: .semibold))
|
|
|
|
Spacer()
|
|
}
|
|
|
|
VStack(spacing: 16) {
|
|
FeatureRow(
|
|
icon: "camera.fill",
|
|
iconColor: .blue,
|
|
title: "scan_feature_title".localized,
|
|
description: "scan_feature_description".localized
|
|
)
|
|
|
|
FeatureRow(
|
|
icon: "plus.circle.fill",
|
|
iconColor: .green,
|
|
title: "create_feature_title".localized,
|
|
description: "create_feature_description".localized
|
|
)
|
|
|
|
FeatureRow(
|
|
icon: "clock.arrow.circlepath",
|
|
iconColor: .orange,
|
|
title: "history_feature_title".localized,
|
|
description: "history_feature_description".localized
|
|
)
|
|
}
|
|
}
|
|
.padding(20)
|
|
.background(
|
|
RoundedRectangle(cornerRadius: 16)
|
|
.fill(Color(.systemBackground))
|
|
.shadow(color: .black.opacity(0.05), radius: 8, x: 0, y: 2)
|
|
)
|
|
.padding(.horizontal, 20)
|
|
|
|
// 关于卡片
|
|
VStack(alignment: .leading, spacing: 16) {
|
|
HStack {
|
|
Image(systemName: "heart.fill")
|
|
.font(.system(size: 20, weight: .medium))
|
|
.foregroundColor(.red)
|
|
.frame(width: 32)
|
|
|
|
Text("about".localized)
|
|
.font(.system(size: 18, weight: .semibold))
|
|
|
|
Spacer()
|
|
}
|
|
|
|
Text("app_description_long".localized)
|
|
.font(.system(size: 14))
|
|
.foregroundColor(.secondary)
|
|
.lineLimit(nil)
|
|
}
|
|
.padding(20)
|
|
.background(
|
|
RoundedRectangle(cornerRadius: 16)
|
|
.fill(Color(.systemBackground))
|
|
.shadow(color: .black.opacity(0.05), radius: 8, x: 0, y: 2)
|
|
)
|
|
.padding(.horizontal, 20)
|
|
|
|
Spacer(minLength: 30)
|
|
}
|
|
}
|
|
}
|
|
.navigationTitle("")
|
|
.navigationBarTitleDisplayMode(.inline)
|
|
.navigationBarBackButtonHidden(false)
|
|
}
|
|
}
|
|
}
|
|
|
|
// MARK: - 功能行组件
|
|
struct FeatureRow: View {
|
|
let icon: String
|
|
let iconColor: Color
|
|
let title: String
|
|
let description: String
|
|
|
|
var body: some View {
|
|
HStack(alignment: .top, spacing: 12) {
|
|
Image(systemName: icon)
|
|
.font(.system(size: 16, weight: .medium))
|
|
.foregroundColor(iconColor)
|
|
.frame(width: 20)
|
|
|
|
VStack(alignment: .leading, spacing: 4) {
|
|
Text(title)
|
|
.font(.system(size: 16, weight: .medium))
|
|
|
|
Text(description)
|
|
.font(.system(size: 14))
|
|
.foregroundColor(.secondary)
|
|
.lineLimit(3)
|
|
}
|
|
|
|
Spacer()
|
|
}
|
|
}
|
|
}
|
|
|
|
#Preview {
|
|
SettingsView()
|
|
.environmentObject(LanguageManager.shared)
|
|
} |