Repository navigation
Expand file tree
/
Copy pathVariantTestApp.swift
More file actions
133 lines (114 loc) · 4.56 KB
/
Copy pathVariantTestApp.swift
File metadata and controls
133 lines (114 loc) · 4.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
//
// Whisperer
// Copyright (c) 2024-2026 Alex Spaulding. All rights reserved.
//
// Source-available for review and contribution only. Not open source.
// Commercial use, redistribution, and reuse are prohibited. See LICENSE.
//
import SwiftUI
import TintedThemingSwift
@main
struct VariantTestApp: App {
var body: some Scene {
WindowGroup {
ContentView()
}
}
}
struct ContentView: View {
@State private var allThemes: [Base16Theme] = []
@State private var lightThemes: [Base16Theme] = []
@State private var darkThemes: [Base16Theme] = []
@State private var isLoading = false
var body: some View {
NavigationView {
VStack(spacing: 20) {
Text("Theme Variant Test")
.font(.title)
.padding()
if isLoading {
ProgressView("Loading themes...")
.padding()
} else {
VStack(alignment: .leading, spacing: 10) {
Text("Total themes: \(allThemes.count)")
Text("Light themes: \(lightThemes.count)")
Text("Dark themes: \(darkThemes.count)")
}
.padding()
.background(Color.gray.opacity(0.1))
.cornerRadius(10)
Button("Load Themes") {
loadThemes()
}
.padding()
.background(Color.blue)
.foregroundColor(.white)
.cornerRadius(10)
if !lightThemes.isEmpty {
Text("Sample Light Themes:")
.font(.headline)
ForEach(Array(lightThemes.prefix(3)), id: \.name) { theme in
HStack {
Text(theme.name)
Spacer()
Text("(\(theme.variant))")
.foregroundColor(.secondary)
}
.padding(.horizontal)
}
}
if !darkThemes.isEmpty {
Text("Sample Dark Themes:")
.font(.headline)
ForEach(Array(darkThemes.prefix(3)), id: \.name) { theme in
HStack {
Text(theme.name)
Spacer()
Text("(\(theme.variant))")
.foregroundColor(.secondary)
}
.padding(.horizontal)
}
}
}
Spacer()
}
.navigationTitle("Variant Test")
}
}
private func loadThemes() {
isLoading = true
Task {
do {
let loader = TintedThemesLoader.shared
// Load all themes
let themes = try await loader.loadAllBase16Themes()
// Filter by variant
let light = try await loader.loadLightThemes()
let dark = try await loader.loadDarkThemes()
await MainActor.run {
self.allThemes = themes
self.lightThemes = light
self.darkThemes = dark
self.isLoading = false
}
print("INFO: Loaded \(themes.count) total themes")
print("INFO: Found \(light.count) light themes")
print("INFO: Found \(dark.count) dark themes")
// Print some examples
if let firstLight = light.first {
print("Example light theme: \(firstLight.name) - variant: \(firstLight.variant)")
}
if let firstDark = dark.first {
print("Example dark theme: \(firstDark.name) - variant: \(firstDark.variant)")
}
} catch {
print("ERROR: Error loading themes: \(error)")
await MainActor.run {
self.isLoading = false
}
}
}
}
}