Skip to content

Commit 76c2008

Browse files
stats and miscellaneous
1 parent 6b488d6 commit 76c2008

File tree

9 files changed

+103
-2
lines changed

9 files changed

+103
-2
lines changed

APIConstruct.swift

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,34 @@ class APIConstruct {
211211
return finalResult
212212
}
213213

214+
func getGraph(name: String) async -> Data? {
215+
var finalResult: Data?
216+
let url = URL(string: host + "/user/" + String(sessionID) + "/" + name)!
217+
var request = URLRequest(url: url)
218+
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
219+
request.httpMethod = "GET"
220+
let semaphore = DispatchSemaphore(value: 0)
221+
let task = URLSession.shared.dataTask(with: request) { data, response, error in
222+
if let error = error {
223+
print("Error took place \(error)")
224+
}
225+
if let response = response as? HTTPURLResponse {
226+
print("Response HTTP Status code: \(response.statusCode)")
227+
}
228+
229+
if let imageData = data {
230+
finalResult = imageData
231+
232+
} else {
233+
print("Couldn't get image: Image is nil")
234+
}
235+
}
236+
task.resume()
237+
semaphore.wait()
238+
print("HERE")
239+
return finalResult
240+
}
241+
214242
func getRoutines() async {
215243
let url = URL(string: host + "/user/" + String(sessionID) + "/routine")!
216244
var request = URLRequest(url: url)

FitForm.xcodeproj/project.pbxproj

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
5988B2F428B195BA00B0DA4E /* WorkoutView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5988B2F328B195BA00B0DA4E /* WorkoutView.swift */; };
1919
5988B2F828B19E0500B0DA4E /* WorkoutController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5988B2F728B19E0500B0DA4E /* WorkoutController.swift */; };
2020
5988B2FE28B1D03300B0DA4E /* ding-sound-effect_2.mp3 in Resources */ = {isa = PBXBuildFile; fileRef = 5988B2FD28B1D03300B0DA4E /* ding-sound-effect_2.mp3 */; };
21+
5988B30028B1F1D500B0DA4E /* StatView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5988B2FF28B1F1D500B0DA4E /* StatView.swift */; };
22+
5988B30228B1FA8F00B0DA4E /* chart.png in Resources */ = {isa = PBXBuildFile; fileRef = 5988B30128B1FA8F00B0DA4E /* chart.png */; };
2123
835C286B28B09460002662F8 /* BodySkeleton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 835C286A28B09460002662F8 /* BodySkeleton.swift */; };
2224
835C286F28B0B3D7002662F8 /* APIConstruct.swift in Sources */ = {isa = PBXBuildFile; fileRef = 835C286E28B0B3D7002662F8 /* APIConstruct.swift */; };
2325
83D7970728B07E1A00D1ED66 /* ARViewContainer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 83D7970628B07E1A00D1ED66 /* ARViewContainer.swift */; };
@@ -39,7 +41,8 @@
3941
5988B2F328B195BA00B0DA4E /* WorkoutView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WorkoutView.swift; sourceTree = "<group>"; };
4042
5988B2F728B19E0500B0DA4E /* WorkoutController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WorkoutController.swift; sourceTree = "<group>"; };
4143
5988B2FD28B1D03300B0DA4E /* ding-sound-effect_2.mp3 */ = {isa = PBXFileReference; lastKnownFileType = audio.mp3; path = "ding-sound-effect_2.mp3"; sourceTree = "<group>"; };
42-
82DDDB43702B56743441BA48 /* Pods-FitForm.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-FitForm.release.xcconfig"; path = "Target Support Files/Pods-FitForm/Pods-FitForm.release.xcconfig"; sourceTree = "<group>"; };
44+
5988B2FF28B1F1D500B0DA4E /* StatView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StatView.swift; sourceTree = "<group>"; };
45+
5988B30128B1FA8F00B0DA4E /* chart.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = chart.png; sourceTree = "<group>"; };
4346
835C286A28B09460002662F8 /* BodySkeleton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BodySkeleton.swift; sourceTree = "<group>"; };
4447
835C286E28B0B3D7002662F8 /* APIConstruct.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = APIConstruct.swift; sourceTree = "<group>"; };
4548
83D7970628B07E1A00D1ED66 /* ARViewContainer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ARViewContainer.swift; sourceTree = "<group>"; };
@@ -88,13 +91,15 @@
8891
835C286A28B09460002662F8 /* BodySkeleton.swift */,
8992
83D7970A28B0802E00D1ED66 /* SkeletonBone.swift */,
9093
83D7970628B07E1A00D1ED66 /* ARViewContainer.swift */,
94+
5988B30128B1FA8F00B0DA4E /* chart.png */,
9195
5988B2DA28B077A600B0DA4E /* Assets.xcassets */,
9296
5988B2DC28B077A600B0DA4E /* Preview Content */,
9397
5988B2E828B0904E00B0DA4E /* SelectWorkoutView.swift */,
9498
5988B2EA28B091BA00B0DA4E /* LoginView.swift */,
9599
5988B2EE28B0B24A00B0DA4E /* RegisterView.swift */,
96100
5988B2F328B195BA00B0DA4E /* WorkoutView.swift */,
97101
5988B2F728B19E0500B0DA4E /* WorkoutController.swift */,
102+
5988B2FF28B1F1D500B0DA4E /* StatView.swift */,
98103
);
99104
path = FitForm;
100105
sourceTree = "<group>";
@@ -167,6 +172,7 @@
167172
files = (
168173
5988B2DE28B077A600B0DA4E /* Preview Assets.xcassets in Resources */,
169174
5988B2FE28B1D03300B0DA4E /* ding-sound-effect_2.mp3 in Resources */,
175+
5988B30228B1FA8F00B0DA4E /* chart.png in Resources */,
170176
5988B2DB28B077A600B0DA4E /* Assets.xcassets in Resources */,
171177
);
172178
runOnlyForDeploymentPostprocessing = 0;
@@ -178,6 +184,7 @@
178184
isa = PBXSourcesBuildPhase;
179185
buildActionMask = 2147483647;
180186
files = (
187+
5988B30028B1F1D500B0DA4E /* StatView.swift in Sources */,
181188
5988B2F428B195BA00B0DA4E /* WorkoutView.swift in Sources */,
182189
835C286F28B0B3D7002662F8 /* APIConstruct.swift in Sources */,
183190
5988B2E928B0904E00B0DA4E /* SelectWorkoutView.swift in Sources */,

FitForm.xcworkspace/contents.xcworkspacedata

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>IDEDidComputeMac32BitWarning</key>
6+
<true/>
7+
</dict>
8+
</plist>

FitForm/Assets.xcassets/AppIcon.appiconset/Contents.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,11 @@
7070
"scale" : "2x",
7171
"size" : "40x40"
7272
},
73+
{
74+
"idiom" : "ipad",
75+
"scale" : "1x",
76+
"size" : "76x76"
77+
},
7378
{
7479
"idiom" : "ipad",
7580
"scale" : "2x",

FitForm/HomeView.swift

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,22 @@ struct HomeView: View {
1212
VStack {
1313
NavigationLink(destination: SelectWorkoutView()) {
1414
Text("Start Workout")
15+
.padding()
16+
.foregroundColor(.white)
17+
.frame(width: 300, height: 50)
18+
.contentShape(Rectangle())
19+
.background(Color.blue)
20+
.cornerRadius(10)
21+
}
22+
23+
NavigationLink(destination: StatView()) {
24+
Text("Stats")
25+
.padding()
26+
.foregroundColor(.white)
27+
.frame(width: 300, height: 50)
28+
.contentShape(Rectangle())
29+
.background(Color.blue)
30+
.cornerRadius(10)
1531
}
1632
}
1733
}

FitForm/SelectWorkoutView.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ struct SelectWorkoutView: View {
139139
.multilineTextAlignment(.leading)
140140
}
141141
Spacer()
142-
Text("Insert Image")
142+
Text(workout.workoutType)
143143
}
144144
.padding(/*@START_MENU_TOKEN@*/ .all/*@END_MENU_TOKEN@*/).border(.orange, width: 2)
145145
}.buttonStyle(.plain)
@@ -169,6 +169,7 @@ struct SelectWorkoutView: View {
169169
w = Int(weight)!
170170
}
171171
await construct.createWorkout(data: WorkoutTemplate(name: workoutName, repCount: Int(amountReps)!, type: selectedType, weight: w))
172+
getWorkouts()
172173
createPopup = false
173174
}
174175
}

FitForm/StatView.swift

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
//
2+
// StatView.swift
3+
// FitForm
4+
//
5+
// Created by Nithin Muthukumar on 2022-08-21.
6+
//
7+
8+
import SwiftUI
9+
10+
struct StatView: View {
11+
@State var timeGraph: Data? = nil
12+
var body: some View {
13+
Image(uiImage: UIImage(data: timeGraph!) ?? UIImage(contentsOfFile: "chart.png")!)
14+
.onAppear {
15+
Task {
16+
timeGraph = await construct.getGraph(name: "time")
17+
}
18+
}
19+
}
20+
}
21+
22+
struct StatView_Previews: PreviewProvider {
23+
static var previews: some View {
24+
StatView()
25+
}
26+
}

FitForm/chart.png

10.8 KB
Loading

0 commit comments

Comments
 (0)