Skip to content

Commit ee00ed4

Browse files
committed
chore: update UI
1 parent 62ccc45 commit ee00ed4

File tree

1 file changed

+38
-28
lines changed

1 file changed

+38
-28
lines changed

mopro-example-app/ios/ExampleApp/ExampleApp/BenchmarkView.swift

+38-28
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ struct BenchmarkView: View {
5151

5252
@State private var witness = [
5353
WitnessTable(circuit: "keccak256", witnessRs: "0 ms", witnessCalc: "0 ms"),
54-
WitnessTable(circuit: "sha256", witnessRs: "0 ms", witnessCalc: "0 ms"),
55-
WitnessTable(circuit: "rsa", witnessRs: "0 ms", witnessCalc: "0 ms"),
54+
WitnessTable(circuit: "SHA256", witnessRs: "0 ms", witnessCalc: "0 ms"),
55+
WitnessTable(circuit: "RSA", witnessRs: "0 ms", witnessCalc: "0 ms"),
5656
]
5757

5858
struct ProofGenTable: Identifiable {
@@ -64,8 +64,8 @@ struct BenchmarkView: View {
6464

6565
@State private var proofData = [
6666
ProofGenTable(circuit: "keccak256", arkWorks: "0 ms", rapidSnark: "0 ms"),
67-
ProofGenTable(circuit: "sha256", arkWorks: "0 ms", rapidSnark: "0 ms"),
68-
ProofGenTable(circuit: "rsa", arkWorks: "0 ms", rapidSnark: "0 ms"),
67+
ProofGenTable(circuit: "SHA256", arkWorks: "0 ms", rapidSnark: "0 ms"),
68+
ProofGenTable(circuit: "RSA", arkWorks: "0 ms", rapidSnark: "0 ms"),
6969
]
7070

7171
let rsaZkeyUrl = URL(string: "https://ci-keys.zkmopro.org/rsa_main_final.zkey")
@@ -85,17 +85,9 @@ struct BenchmarkView: View {
8585
NavigationStack {
8686
VStack {
8787
HStack {
88-
if self.filesNum != self.totalFile {
89-
Button(action: {
90-
download()
91-
}) {
92-
Text("Download")
93-
}.disabled(self.filesNum == self.totalFile).foregroundColor(.yellow)
94-
Spacer()
95-
Text("Files downloaded: \(filesNum) / \(totalFile)").foregroundColor(.white)
96-
}
97-
}.padding(.horizontal).background(Color(red: 37 / 255, green: 18 / 255, blue: 0 / 255))
98-
.edgesIgnoringSafeArea(.all)
88+
Spacer()
89+
Text("Files downloaded: \(filesNum) / \(totalFile)").foregroundColor(.white)
90+
}.padding(.horizontal)
9991
HStack {
10092
if self.runningBenchmark {
10193
LoadingIndicator(animation: .threeBalls, color: .white).fontWeight(.bold)
@@ -105,14 +97,27 @@ struct BenchmarkView: View {
10597
.cornerRadius(10)
10698
.shadow(color: Color.blue.opacity(0.3), radius: 10, x: 0, y: 5)
10799
.padding(.horizontal, 10) // Adds padding on the sides
100+
101+
} else if self.filesNum != self.totalFile {
102+
Button(action: {
103+
download()
104+
}) {
105+
Text("Download Files").fontWeight(.bold)
106+
}.padding()
107+
.frame(maxWidth: .infinity)
108+
.background(Color.yellow)
109+
.foregroundColor(.white)
110+
.cornerRadius(10)
111+
.shadow(color: Color.blue.opacity(0.3), radius: 10, x: 0, y: 5)
112+
.disabled(self.filesNum == self.totalFile)
113+
.padding([.leading], 10)
108114
} else {
109115
HStack {
110116
Button(action: {
111117
runBenchmark()
112118
}) {
113-
Text("Run Benchmark!")
119+
Text("Run Benchmark")
114120
.fontWeight(.bold)
115-
116121
}
117122
.padding()
118123
.frame(maxWidth: .infinity)
@@ -139,6 +144,7 @@ struct BenchmarkView: View {
139144
.padding(.horizontal, 10) // Adds padding on the sides
140145
}
141146
Text("Witness Calculation")
147+
.padding(.top, 5)
142148
.fontWeight(.bold)
143149
.frame(maxWidth: .infinity)
144150
.foregroundColor(.white)
@@ -148,22 +154,22 @@ struct BenchmarkView: View {
148154
header: HStack {
149155
Text("Circuit")
150156
.font(.system(size: 14))
151-
.frame(maxWidth: .infinity, alignment: .leading)
157+
.frame(maxWidth: .infinity, alignment: .center)
152158
.font(.headline)
153159
Text("Witness-rs")
154160
.font(.system(size: 14))
155-
.frame(maxWidth: .infinity, alignment: .leading)
161+
.frame(maxWidth: .infinity, alignment: .trailing)
156162
.font(.headline)
157163
Text("WitnessCalc")
158164
.font(.system(size: 14))
159-
.frame(maxWidth: .infinity, alignment: .leading)
165+
.frame(maxWidth: .infinity, alignment: .trailing)
160166
.font(.headline)
161167
}
162168
) {
163169
ForEach(witness) { wit in
164170
HStack {
165171
Text(wit.circuit)
166-
.frame(maxWidth: .infinity, alignment: .trailing)
172+
.frame(maxWidth: .infinity, alignment: .center)
167173
Text(wit.witnessRs)
168174
.frame(maxWidth: .infinity, alignment: .trailing)
169175
Text(wit.witnessCalc)
@@ -173,6 +179,7 @@ struct BenchmarkView: View {
173179
}.listRowBackground(Color.gray) // Background color for Section 1
174180
}.listStyle(InsetGroupedListStyle()) // Apply a list style if desired
175181
Text("Proof Generation")
182+
.padding(.top, 5)
176183
.fontWeight(.bold)
177184
.frame(maxWidth: .infinity)
178185
.foregroundColor(.white)
@@ -182,22 +189,22 @@ struct BenchmarkView: View {
182189
header: HStack {
183190
Text("Circuit")
184191
.font(.system(size: 14))
185-
.frame(maxWidth: .infinity, alignment: .leading)
192+
.frame(maxWidth: .infinity, alignment: .center)
186193
.font(.headline)
187194
Text("ark-works")
188195
.font(.system(size: 14))
189-
.frame(maxWidth: .infinity, alignment: .leading)
196+
.frame(maxWidth: .infinity, alignment: .trailing)
190197
.font(.headline)
191198
Text("rapidsnark")
192199
.font(.system(size: 14))
193-
.frame(maxWidth: .infinity, alignment: .leading)
200+
.frame(maxWidth: .infinity, alignment: .trailing)
194201
.font(.headline)
195202
}
196203
) {
197204
ForEach(proofData) { pf in
198205
HStack {
199206
Text(pf.circuit)
200-
.frame(maxWidth: .infinity, alignment: .trailing)
207+
.frame(maxWidth: .infinity, alignment: .center)
201208
Text(pf.arkWorks)
202209
.frame(maxWidth: .infinity, alignment: .trailing)
203210
Text(pf.rapidSnark)
@@ -239,8 +246,7 @@ struct BenchmarkView: View {
239246
.disabled(!self.finishRunning)
240247
}
241248
//Text("non-linear constraints: 59281")
242-
}
243-
Spacer()
249+
}.padding(.bottom, 60)
244250

245251
// Text("non-linear constraints: 150848")
246252

@@ -282,11 +288,14 @@ extension BenchmarkView {
282288
self.filesNum += 1
283289
if self.filesNum == self.totalFile {
284290
self.isVisible = false
291+
self.runningBenchmark = false
292+
} else {
293+
self.runningBenchmark = true
285294
}
286295
}
287296

288297
func download() {
289-
298+
self.runningBenchmark = true
290299
FileDownloader.loadFileAsync(url: rsaZkeyUrl!) { (path, error) in
291300
print("RSA Zkey File downloaded to : \(path!)")
292301
handleVisibility()
@@ -350,6 +359,7 @@ extension BenchmarkView {
350359

351360
func reset() {
352361
for i in 0...2 {
362+
self.finishRunning = false
353363
self.witness[i].witnessRs = "0 ms"
354364
self.witness[i].witnessCalc = "0 ms"
355365
self.proofData[i].arkWorks = "0 ms"

0 commit comments

Comments
 (0)