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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
import SwiftUI
struct ContentView: View {
@EnvironmentObject var proofViewModel: ProofViewModel
@EnvironmentObject var permissionService: PermissionService
@State private var selectedTab = 0
@State private var showingImagePicker = false
@State private var showingCamera = false
@State private var selectedProof: Proof?
var body: some View {
TabView(selection: $selectedTab) {
// Generate Tab
NavigationStack {
VStack(spacing: 20) {
Text("Generate Proof")
.font(.largeTitle)
.fontWeight(.bold)
.padding(.top)
Text("Create cryptographic proofs for your photos")
.font(.subheadline)
.foregroundColor(.secondary)
.multilineTextAlignment(.center)
.padding(.horizontal)
Spacer()
VStack(spacing: 16) {
// Camera Button
Button(action: {
checkCameraPermissionAndShow()
}) {
HStack {
Image(systemName: "camera.fill")
.font(.title2)
Text("Take Photo")
.font(.headline)
}
.frame(maxWidth: .infinity)
.padding()
.background(Color.blue)
.foregroundColor(.white)
.cornerRadius(12)
}
// Photo Library Button
Button(action: {
checkPhotoLibraryPermissionAndShow()
}) {
HStack {
Image(systemName: "photo.on.rectangle")
.font(.title2)
Text("Choose from Library")
.font(.headline)
}
.frame(maxWidth: .infinity)
.padding()
.background(Color.green)
.foregroundColor(.white)
.cornerRadius(12)
}
}
.padding(.horizontal)
Spacer()
// Progress View
if proofViewModel.isGenerating {
VStack(spacing: 12) {
ProgressView()
.scaleEffect(1.5)
Text("Generating proof...")
.font(.headline)
if !proofViewModel.currentStatus.isEmpty {
Text(proofViewModel.currentStatus)
.font(.caption)
.foregroundColor(.secondary)
}
}
.padding()
.background(Color.gray.opacity(0.1))
.cornerRadius(12)
.padding(.horizontal)
}
Spacer()
}
.navigationBarHidden(true)
}
.tabItem {
Label("Generate", systemImage: "plus.circle")
}
.tag(0)
// Verify Tab
NavigationStack {
VerifyView(selectedProof: $selectedProof)
.navigationTitle("Verify")
}
.tabItem {
Label("Verify", systemImage: "checkmark.shield")
}
.tag(1)
// Settings Tab
NavigationStack {
SettingsView()
.navigationTitle("Settings")
}
.tabItem {
Label("Settings", systemImage: "gear")
}
.tag(2)
}
.sheet(isPresented: $showingImagePicker) {
ImagePicker(sourceType: .photoLibrary) { image in
proofViewModel.createProof(for: image)
}
}
.fullScreenCover(isPresented: $showingCamera) {
CameraView { image in
showingCamera = false
proofViewModel.createProof(for: image)
}
}
.sheet(item: $selectedProof) { proof in
NavigationStack {
ProofDetailView(proof: proof)
.navigationTitle("Proof Details")
.navigationBarTitleDisplayMode(.inline)
.toolbar {
ToolbarItem(placement: .navigationBarTrailing) {
Button("Done") {
selectedProof = nil
}
}
}
}
}
.alert("Success", isPresented: $proofViewModel.showingSuccess) {
Button("OK") {
selectedTab = 1 // Switch to Verify tab
}
} message: {
Text(proofViewModel.successMessage)
}
.alert("Error", isPresented: $proofViewModel.showingError) {
Button("OK") { }
} message: {
Text(proofViewModel.errorMessage)
}
}
private func checkCameraPermissionAndShow() {
permissionService.requestCameraPermission { granted in
if granted {
showingCamera = true
}
}
}
private func checkPhotoLibraryPermissionAndShow() {
permissionService.requestPhotoLibraryPermission { granted in
if granted {
showingImagePicker = true
}
}
}
}
struct SettingsView: View {
@EnvironmentObject var proofViewModel: ProofViewModel
@AppStorage("includeLocation") private var includeLocation = true
@AppStorage("includeDeviceInfo") private var includeDeviceInfo = true
@AppStorage("includeNetworkInfo") private var includeNetworkInfo = true
var body: some View {
Form {
Section("Proof Options") {
Toggle("Include Location", isOn: $includeLocation)
Toggle("Include Device Info", isOn: $includeDeviceInfo)
Toggle("Include Network Info", isOn: $includeNetworkInfo)
}
Section("Storage") {
HStack {
Text("Proof Count")
Spacer()
Text("\(proofViewModel.proofs.count)")
.foregroundColor(.secondary)
}
Button("Clear All Proofs") {
proofViewModel.clearAllProofs()
}
.foregroundColor(.red)
}
Section("About") {
HStack {
Text("Version")
Spacer()
Text(getVersion())
.foregroundColor(.secondary)
}
Link("Guardian Project", destination: URL(string: "https://guardianproject.info")!)
Link("ProofMode Documentation", destination: URL(string: "https://proofmode.org")!)
}
}
}
}
#Preview {
ContentView()
.environmentObject(ProofViewModel())
.environmentObject(PermissionService())
}