You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

201 lines
10 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

//
// ContentView.swift
// MyQrCode
//
// Created by dev on 2025/8/19.
//
import SwiftUI
struct ContentView: View {
@EnvironmentObject var coreDataManager: CoreDataManager
@EnvironmentObject var languageManager: LanguageManager
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".localized)
.font(.system(size: 34, weight: .bold, design: .rounded))
.foregroundColor(.primary)
.id(languageManager.refreshTrigger)
Text("quick_create_scan".localized)
.id(languageManager.refreshTrigger)
.font(.system(size: 16, weight: .medium))
.foregroundColor(.secondary)
.multilineTextAlignment(.center)
}
.padding(.top, 0)
//
VStack(spacing: 18) {
// -
NavigationLink(destination: CodeTypeSelectionView()) {
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("create_qr_code".localized)
.font(.system(size: 28, weight: .bold))
.foregroundColor(.white)
.id(languageManager.refreshTrigger)
Text("generate_various_codes".localized)
.id(languageManager.refreshTrigger)
.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("scan_recognize".localized)
.font(.system(size: 16, weight: .bold))
.foregroundColor(.white)
.id(languageManager.refreshTrigger)
Text("scan_qr_code".localized)
.id(languageManager.refreshTrigger)
.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("history_records".localized)
.font(.system(size: 16, weight: .bold))
.foregroundColor(.white)
.id(languageManager.refreshTrigger)
Text("view_history".localized)
.id(languageManager.refreshTrigger)
.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()
.environmentObject(CoreDataManager.shared)
.environmentObject(LanguageManager.shared)
}
}
#endif