Files
e-party-iOS/yana/Views/LanguageSettingsView.swift
edwinQQQ c470dba79c feat: 更新项目配置和功能模块
- 修改Package.swift以支持iOS 15和macOS 12。
- 更新swift-tca-architecture-guidelines.mdc中的alwaysApply设置为false。
- 注释掉AppDelegate中的NIMSDK导入,移除不再使用的NIMConfigurationManager和NIMSessionManager文件。
- 添加新的API相关文件,包括EMailLoginFeature、IDLoginFeature和相关视图,增强登录功能。
- 更新APIConstants和APIEndpoints以反映新的API路径。
- 添加本地化支持文件,包含英文和中文简体的本地化字符串。
- 新增字体管理和安全工具类,支持AES和DES加密。
- 更新Xcode项目配置,调整版本号和启动画面设置。
2025-07-09 16:14:19 +08:00

96 lines
3.1 KiB
Swift

import SwiftUI
import ComposableArchitecture
struct LanguageSettingsView: View {
@ObservedObject private var localizationManager = LocalizationManager.shared
@Binding var isPresented: Bool
init(isPresented: Binding<Bool> = .constant(true)) {
self._isPresented = isPresented
}
var body: some View {
NavigationView {
List {
Section {
ForEach(LocalizationManager.SupportedLanguage.allCases, id: \.rawValue) { language in
LanguageRow(
language: language,
isSelected: localizationManager.currentLanguage == language
) {
localizationManager.switchLanguage(to: language)
}
}
} header: {
Text("选择语言 / Select Language")
.font(.caption)
.foregroundColor(.secondary)
}
Section {
HStack {
Text("当前语言 / Current Language")
.font(.body)
Spacer()
Text(localizationManager.currentLanguage.localizedDisplayName)
.font(.body)
.foregroundColor(.blue)
}
} header: {
Text("语言信息 / Language Info")
.font(.caption)
.foregroundColor(.secondary)
}
}
.navigationTitle("语言设置 / Language")
.navigationBarTitleDisplayMode(.inline)
.navigationBarBackButtonHidden(true)
.toolbar {
ToolbarItem(placement: .navigationBarLeading) {
Button("返回 / Back") {
isPresented = false
}
}
}
}
}
}
struct LanguageRow: View {
let language: LocalizationManager.SupportedLanguage
let isSelected: Bool
let onTap: () -> Void
var body: some View {
Button(action: onTap) {
HStack {
VStack(alignment: .leading, spacing: 4) {
Text(language.localizedDisplayName)
.font(.body)
.foregroundColor(.primary)
Text(language.displayName)
.font(.caption)
.foregroundColor(.secondary)
}
Spacer()
if isSelected {
Image(systemName: "checkmark.circle.fill")
.foregroundColor(.blue)
.font(.system(size: 20))
}
}
.contentShape(Rectangle())
}
.buttonStyle(PlainButtonStyle())
}
}
// MARK: - Preview
#Preview {
LanguageSettingsView(isPresented: .constant(true))
}