chromium-certificate/ChromiumCertificate/ContentView.swift
Astrian Zheng d8d2ad48e5
feat: 添加应用多语言国际化支持
- 新增英文、日文、粤语支持
- 添加本地化图片资源
- 更新 Xcode 项目配置支持多语言
- 重构代码使用本地化字符串

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-24 11:11:17 +11:00

78 lines
1.7 KiB
Swift

//
// ContentView.swift
// ChromiumCertificate
//
// Created by Astrian Zheng on 14/7/2025.
//
import SwiftUI
struct StrokeText: ViewModifier {
var strokeSize: CGFloat = 1
var strokeColor: Color = .black
func body(content: Content) -> some View {
content
.background(
Rectangle()
.foregroundColor(strokeColor)
.mask(content)
.blur(radius: strokeSize)
)
}
}
extension View {
func stroke(color: Color = .black, width: CGFloat = 1) -> some View {
modifier(StrokeText(strokeSize: width, strokeColor: color))
}
}
struct ContentView: View {
let count = ChromiumDetector.getChromiumAppCount()
@State private var presentSheet: Bool = false
@Environment(\.locale) private var locale
var body: some View {
ZStack {
Image("AnnouncementBg").resizable().frame(width: 640, height: 480)
VStack {
Text("MAINVIEW_CHROMIUM_COUNTER \(count)")
.multilineTextAlignment(.center)
.font(.system(size: 35, weight: .semibold))
.foregroundColor(Color("TextColor"))
.stroke(color: Color("TextBorderColor"), width: 5)
.padding(.horizontal)
Button {
self.presentSheet.toggle()
} label: {
Text("MAINVIEW_SEE_LIST").font(.system(size: 20)).padding(.horizontal).padding(.vertical, 8)
}
.buttonStyle(.borderedProminent)
.tint(.red)
.sheet(isPresented: self.$presentSheet) {
ChromiumBasedAppListView(isPresented: self.$presentSheet)
}
}
}
.frame(width: 640, height: 420)
}
}
#Preview("中文") {
ContentView()
.environment(\.locale, Locale(identifier: "zh-Hans"))
}
#Preview("English") {
ContentView()
.environment(\.locale, Locale(identifier: "en"))
}
#Preview("日本語") {
ContentView()
.environment(\.locale, Locale(identifier: "ja"))
}