|
|
//
|
|
|
// ContentView.swift
|
|
|
// MyQrCode
|
|
|
//
|
|
|
// Created by dev on 2025/8/19.
|
|
|
//
|
|
|
|
|
|
import SwiftUI
|
|
|
|
|
|
struct ContentView: View {
|
|
|
var body: some View {
|
|
|
NavigationView {
|
|
|
ZStack {
|
|
|
// 背景渐变
|
|
|
LinearGradient(
|
|
|
gradient: Gradient(colors: [
|
|
|
Color(.systemBackground),
|
|
|
Color(.systemGray6).opacity(0.3)
|
|
|
]),
|
|
|
startPoint: .top,
|
|
|
endPoint: .bottom
|
|
|
)
|
|
|
.ignoresSafeArea()
|
|
|
|
|
|
VStack(spacing: 24) {
|
|
|
// 页面标题
|
|
|
VStack(spacing: 12) {
|
|
|
Text("QR Code Creator")
|
|
|
.font(.system(size: 34, weight: .bold, design: .rounded))
|
|
|
.foregroundColor(.primary)
|
|
|
|
|
|
Text("快速创建和扫描二维码")
|
|
|
.font(.system(size: 16, weight: .medium))
|
|
|
.foregroundColor(.secondary)
|
|
|
.multilineTextAlignment(.center)
|
|
|
}
|
|
|
.padding(.top, 0)
|
|
|
|
|
|
// 功能卡片布局
|
|
|
VStack(spacing: 18) {
|
|
|
// 主功能 - 创建二维码(大卡片)
|
|
|
NavigationLink(destination: CreateCodeView()) {
|
|
|
VStack(alignment: .leading, spacing: 20) {
|
|
|
HStack {
|
|
|
Image(systemName: "qrcode")
|
|
|
.font(.system(size: 32, weight: .bold))
|
|
|
.foregroundColor(.white)
|
|
|
|
|
|
Spacer()
|
|
|
|
|
|
Image(systemName: "arrow.up.right")
|
|
|
.font(.system(size: 22, weight: .medium))
|
|
|
.foregroundColor(.white.opacity(0.8))
|
|
|
}
|
|
|
|
|
|
VStack(alignment: .leading, spacing: 12) {
|
|
|
Text("创建二维码")
|
|
|
.font(.system(size: 28, weight: .bold))
|
|
|
.foregroundColor(.white)
|
|
|
|
|
|
Text("生成文本、链接、WiFi、联系人等各种二维码")
|
|
|
.font(.system(size: 16))
|
|
|
.foregroundColor(.white.opacity(0.9))
|
|
|
.lineLimit(2)
|
|
|
}
|
|
|
}
|
|
|
.padding(24)
|
|
|
.frame(maxWidth: .infinity, minHeight: 160)
|
|
|
.background(
|
|
|
LinearGradient(
|
|
|
gradient: Gradient(colors: [
|
|
|
Color.purple,
|
|
|
Color.blue,
|
|
|
Color.purple.opacity(0.8)
|
|
|
]),
|
|
|
startPoint: .topLeading,
|
|
|
endPoint: .bottomTrailing
|
|
|
)
|
|
|
)
|
|
|
.cornerRadius(24)
|
|
|
.shadow(color: .purple.opacity(0.4), radius: 20, x: 0, y: 10)
|
|
|
}
|
|
|
.padding(.horizontal, 20)
|
|
|
|
|
|
// 第二行 - 两个辅助功能卡片
|
|
|
HStack(spacing: 14) {
|
|
|
// 扫描功能卡片
|
|
|
NavigationLink(destination: ScannerView()) {
|
|
|
VStack(alignment: .leading, spacing: 12) {
|
|
|
HStack {
|
|
|
Image(systemName: "camera.fill")
|
|
|
.font(.system(size: 22, weight: .medium))
|
|
|
.foregroundColor(.white)
|
|
|
|
|
|
Spacer()
|
|
|
}
|
|
|
|
|
|
VStack(alignment: .leading, spacing: 6) {
|
|
|
Text("扫描识别")
|
|
|
.font(.system(size: 16, weight: .bold))
|
|
|
.foregroundColor(.white)
|
|
|
|
|
|
Text("扫描二维码")
|
|
|
.font(.system(size: 13))
|
|
|
.foregroundColor(.white.opacity(0.9))
|
|
|
}
|
|
|
}
|
|
|
.padding(16)
|
|
|
.frame(maxWidth: .infinity, minHeight: 100)
|
|
|
.background(
|
|
|
LinearGradient(
|
|
|
gradient: Gradient(colors: [
|
|
|
Color.blue,
|
|
|
Color.blue.opacity(0.8)
|
|
|
]),
|
|
|
startPoint: .topLeading,
|
|
|
endPoint: .bottomTrailing
|
|
|
)
|
|
|
)
|
|
|
.cornerRadius(16)
|
|
|
.shadow(color: .blue.opacity(0.25), radius: 8, x: 0, y: 4)
|
|
|
}
|
|
|
|
|
|
// 历史记录卡片
|
|
|
NavigationLink(destination: HistoryView()) {
|
|
|
VStack(alignment: .leading, spacing: 12) {
|
|
|
HStack {
|
|
|
Image(systemName: "clock.arrow.circlepath")
|
|
|
.font(.system(size: 22, weight: .medium))
|
|
|
.foregroundColor(.white)
|
|
|
|
|
|
Spacer()
|
|
|
}
|
|
|
|
|
|
VStack(alignment: .leading, spacing: 6) {
|
|
|
Text("历史记录")
|
|
|
.font(.system(size: 16, weight: .bold))
|
|
|
.foregroundColor(.white)
|
|
|
|
|
|
Text("查看历史")
|
|
|
.font(.system(size: 13))
|
|
|
.foregroundColor(.white.opacity(0.9))
|
|
|
}
|
|
|
}
|
|
|
.padding(16)
|
|
|
.frame(maxWidth: .infinity, minHeight: 100)
|
|
|
.background(
|
|
|
LinearGradient(
|
|
|
gradient: Gradient(colors: [
|
|
|
Color.orange,
|
|
|
Color.orange.opacity(0.8)
|
|
|
]),
|
|
|
startPoint: .topLeading,
|
|
|
endPoint: .bottomTrailing
|
|
|
)
|
|
|
)
|
|
|
.cornerRadius(16)
|
|
|
.shadow(color: .orange.opacity(0.25), radius: 8, x: 0, y: 4)
|
|
|
}
|
|
|
}
|
|
|
.padding(.horizontal, 20)
|
|
|
}
|
|
|
|
|
|
Spacer(minLength: 0)
|
|
|
}
|
|
|
.padding(.top, 0)
|
|
|
}
|
|
|
.toolbar {
|
|
|
ToolbarItem(placement: .navigationBarTrailing) {
|
|
|
NavigationLink(destination: SettingsView()) {
|
|
|
Image(systemName: "gearshape.fill")
|
|
|
.font(.system(size: 18, weight: .medium))
|
|
|
.foregroundColor(.primary)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
#if DEBUG
|
|
|
struct ContentView_Previews: PreviewProvider {
|
|
|
static var previews: some View {
|
|
|
ContentView()
|
|
|
}
|
|
|
}
|
|
|
#endif
|