chromium-certificate/ChromiumCertificate/ContentView.swift
Astrian Zheng e23b60296c
feat: 实现 Chromium 喜报应用
- 创建 Chromium/Electron 应用检测器
- 设计喜报风格的 UI 界面
- 添加应用列表查看功能
- 配置应用图标和颜色资源
- 添加 README 文档

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-14 14:09:53 +10:00

64 lines
1.4 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
var body: some View {
ZStack {
Image("AnnouncementBg").resizable().frame(width: 640, height: 480)
VStack {
Text(count != 0 ? "这台 Mac 上一共有 \(count) 个 Chromium" : "这台 Mac 一个 Chromium 都没有!")
.font(.system(size: 35, weight: .semibold))
.foregroundColor(Color("TextColor"))
.stroke(color: Color("TextBorderColor"), width: 5)
Button {
self.presentSheet.toggle()
} label: {
Text("查看列表").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()
}