// // AppSettingsView.swift // Keging // // 설정 — 앱 테마 등 // import SwiftUI struct AppSettingsView: View { @AppStorage("app.theme", store: AppGroup.defaults) private var themeMode = "system" @AppStorage("app.language", store: AppGroup.defaults) private var appLanguage = "system" @Environment(\.dismiss) private var dismiss var body: some View { NavigationStack { Form { Section("테마") { Picker("화면 모드", selection: $themeMode) { Text("시스템").tag("system") Text("라이트").tag("light") Text("다크").tag("dark") } .pickerStyle(.segmented) } Section { Picker("언어", selection: $appLanguage) { Text("시스템").tag("system") Text(verbatim: "한국어").tag("ko") Text(verbatim: "English").tag("en") Text(verbatim: "日本語").tag("ja") } } header: { Text("언어") } footer: { Text("언어를 바꾸면 앱을 완전히 종료했다가 다시 실행했을 때 적용돼요.") } Section { LabeledContent("버전", value: versionText) } footer: { Text("케깅은 광고와 결제가 없는 완전 무료 앱이에요.") } } .navigationTitle("설정") .navigationBarTitleDisplayMode(.inline) .toolbar { ToolbarItem(placement: .confirmationAction) { Button("완료") { dismiss() } } } .onChange(of: appLanguage) { // 시스템의 앱별 언어 오버라이드 — 다음 실행부터 적용 (하루 다님 검증 방식) if appLanguage == "system" { UserDefaults.standard.removeObject(forKey: "AppleLanguages") } else { UserDefaults.standard.set([appLanguage], forKey: "AppleLanguages") } } } } private var versionText: String { let version = Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as? String ?? "1.0" let build = Bundle.main.object(forInfoDictionaryKey: "CFBundleVersion") as? String ?? "1" return "\(version) (\(build))" } }