
- 在Package.swift中注释掉旧的swift-composable-architecture依赖,并添加swift-case-paths依赖。 - 在Podfile中将iOS平台版本更新至16.0,并移除QCloudCOSXML/Transfer依赖,改为使用QCloudCOSXML。 - 更新Podfile.lock以反映依赖变更,确保项目依赖的准确性。 - 新增架构分析需求文档,明确项目架构评估和改进建议。 - 在多个文件中实现async/await语法,提升异步操作的可读性和性能。 - 更新日志输出方法,确保在调试模式下提供一致的调试信息。 - 优化多个视图组件,提升用户体验和代码可维护性。
89 lines
2.9 KiB
Swift
89 lines
2.9 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 {
|
|
NavigationStack {
|
|
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)
|
|
}
|
|
}
|
|
}
|
|
|
|
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))
|
|
} |