WIP
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
|
||||
import Foundation
|
||||
import UIKit
|
||||
import SwiftUI
|
||||
|
||||
extension Dictionary {
|
||||
func percentEncoded() -> Data? {
|
||||
@@ -121,3 +122,20 @@ extension Double {
|
||||
return formatter.string(from: self) ?? ""
|
||||
}
|
||||
}
|
||||
|
||||
extension View {
|
||||
func cornerRadius(_ radius: CGFloat, corners: UIRectCorner) -> some View {
|
||||
clipShape( RoundedCorner(radius: radius, corners: corners) )
|
||||
}
|
||||
}
|
||||
|
||||
struct RoundedCorner: Shape {
|
||||
|
||||
var radius: CGFloat = .infinity
|
||||
var corners: UIRectCorner = .allCorners
|
||||
|
||||
func path(in rect: CGRect) -> Path {
|
||||
let path = UIBezierPath(roundedRect: rect, byRoundingCorners: corners, cornerRadii: CGSize(width: radius, height: radius))
|
||||
return Path(path.cgPath)
|
||||
}
|
||||
}
|
||||
|
||||
2974
Werkout_ios/JSON/WorkoutDetail.json
Normal file
2974
Werkout_ios/JSON/WorkoutDetail.json
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,162 +0,0 @@
|
||||
{
|
||||
"id": 1,
|
||||
"name": "test workout",
|
||||
"description": null,
|
||||
"exercises": [
|
||||
{
|
||||
"workout": 1,
|
||||
"exercise": {
|
||||
"id": 1080,
|
||||
"muscles": [
|
||||
{
|
||||
"id": 7267,
|
||||
"created_at": "2023-06-28T04:04:39.263974Z",
|
||||
"updated_at": "2023-06-28T04:04:39.263986Z",
|
||||
"exercise": 1080,
|
||||
"muscle": 4
|
||||
},
|
||||
{
|
||||
"id": 7266,
|
||||
"created_at": "2023-06-28T04:04:39.268881Z",
|
||||
"updated_at": "2023-06-28T04:04:39.268893Z",
|
||||
"exercise": 1080,
|
||||
"muscle": 5
|
||||
}
|
||||
],
|
||||
"equipment": [
|
||||
{
|
||||
"id": 942,
|
||||
"created_at": "2023-06-28T14:18:59.650301Z",
|
||||
"updated_at": "2023-06-28T14:18:59.650313Z",
|
||||
"exercise": 1080,
|
||||
"equipment": 1091
|
||||
}
|
||||
],
|
||||
"audio_url": "/media/exercise_audio/2_Dumbbell_Lateral_Lunges.m4a",
|
||||
"video_url": "/media/exercise_videos/2_Dumbbell_Lateral_Lunges.mp4",
|
||||
"nsfw_video_url": "/media/nsfw_exercise_videos/2_Dumbbell_Lateral_Lunges.mp4",
|
||||
"created_at": "2023-06-26T20:52:33.576028Z",
|
||||
"updated_at": "2023-06-26T20:52:33.576040Z",
|
||||
"name": "2 Dumbbell Lateral Lunges",
|
||||
"description": "With dumbbells by your sides, step out to the side.. Reach your hips back like you're sitting in a chair.. Drive back up to the starting position, and repeat on the other side.",
|
||||
"side": "",
|
||||
"is_two_dumbbells": true,
|
||||
"is_trackable_distance": false,
|
||||
"is_alternating": true,
|
||||
"is_weight": true,
|
||||
"is_distance": false,
|
||||
"is_duration": true,
|
||||
"is_reps": true,
|
||||
"joints_used": "ankle,hip,knee,lumbar spine,wrist",
|
||||
"movement_patterns": "lower push,lower push - lunge",
|
||||
"equipment_required": "Dumbbell",
|
||||
"muscle_groups": "quads,glutes",
|
||||
"synonyms": ""
|
||||
},
|
||||
"weight": null,
|
||||
"reps": null,
|
||||
"duration": null,
|
||||
"duration_audio": null,
|
||||
"weight_audio": null,
|
||||
"created_at": "2023-06-27T12:18:54.998026Z"
|
||||
},
|
||||
{
|
||||
"workout": 1,
|
||||
"exercise": {
|
||||
"id": 798,
|
||||
"muscles": [],
|
||||
"equipment": [],
|
||||
"audio_url": "/media/exercise_audio/Recover.m4a",
|
||||
"video_url": "/media/exercise_videos/Recover.mp4",
|
||||
"nsfw_video_url": "/media/nsfw_exercise_videos/Recover_5.mp4",
|
||||
"created_at": "2023-06-26T20:52:36.446337Z",
|
||||
"updated_at": "2023-06-26T20:52:36.446348Z",
|
||||
"name": "Recover",
|
||||
"description": "Use this time to catch your breath. It will help you get more out of what's next",
|
||||
"side": "",
|
||||
"is_two_dumbbells": false,
|
||||
"is_trackable_distance": false,
|
||||
"is_alternating": false,
|
||||
"is_weight": false,
|
||||
"is_distance": false,
|
||||
"is_duration": true,
|
||||
"is_reps": false,
|
||||
"joints_used": "",
|
||||
"movement_patterns": "",
|
||||
"equipment_required": "",
|
||||
"muscle_groups": "",
|
||||
"synonyms": ""
|
||||
},
|
||||
"weight": null,
|
||||
"reps": null,
|
||||
"duration": null,
|
||||
"duration_audio": null,
|
||||
"weight_audio": null,
|
||||
"created_at": "2023-06-27T12:18:54.999424Z"
|
||||
},
|
||||
{
|
||||
"workout": 1,
|
||||
"exercise": {
|
||||
"id": 130,
|
||||
"muscles": [
|
||||
{
|
||||
"id": 7282,
|
||||
"created_at": "2023-06-28T04:04:39.194997Z",
|
||||
"updated_at": "2023-06-28T04:04:39.195009Z",
|
||||
"exercise": 130,
|
||||
"muscle": 5
|
||||
},
|
||||
{
|
||||
"id": 7281,
|
||||
"created_at": "2023-06-28T04:04:39.199685Z",
|
||||
"updated_at": "2023-06-28T04:04:39.199697Z",
|
||||
"exercise": 130,
|
||||
"muscle": 1
|
||||
}
|
||||
],
|
||||
"equipment": [
|
||||
{
|
||||
"id": 948,
|
||||
"created_at": "2023-06-28T14:18:59.622982Z",
|
||||
"updated_at": "2023-06-28T14:18:59.622994Z",
|
||||
"exercise": 130,
|
||||
"equipment": 1088
|
||||
}
|
||||
],
|
||||
"audio_url": "/media/exercise_audio/2_Kettlebell_Push_Press.m4a",
|
||||
"video_url": "/media/exercise_videos/2_Kettlebell_Push_Press.mp4",
|
||||
"nsfw_video_url": "/media/nsfw_exercise_videos/2_Kettlebell_Push_Press.mp4",
|
||||
"created_at": "2023-06-26T20:52:33.599643Z",
|
||||
"updated_at": "2023-06-26T20:52:33.599655Z",
|
||||
"name": "2 Kettlebell Push Press",
|
||||
"description": "Stand with feet in a shoulder width stance and kettlebells in the front rack position. \nDip quickly at the knees into a quarter squat and then explode straight up as you press the kettlebells overhead.\nLower the kettlebells under control back to the starting position",
|
||||
"side": "",
|
||||
"is_two_dumbbells": false,
|
||||
"is_trackable_distance": false,
|
||||
"is_alternating": false,
|
||||
"is_weight": true,
|
||||
"is_distance": false,
|
||||
"is_duration": true,
|
||||
"is_reps": true,
|
||||
"joints_used": "knee,hip,shoulder,wrist,elbow",
|
||||
"movement_patterns": "upper push - vertical,upper push",
|
||||
"equipment_required": "Kettlebell",
|
||||
"muscle_groups": "deltoids,quads",
|
||||
"synonyms": ""
|
||||
},
|
||||
"weight": null,
|
||||
"reps": null,
|
||||
"duration": null,
|
||||
"duration_audio": null,
|
||||
"weight_audio": null,
|
||||
"created_at": "2023-06-27T12:18:54.999935Z"
|
||||
}
|
||||
],
|
||||
"registered_user": {
|
||||
"id": 1,
|
||||
"first_name": "User1",
|
||||
"last_name": "user1",
|
||||
"image": "",
|
||||
"nick_name": "test user1"
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,7 @@ import Foundation
|
||||
|
||||
class PreviewData {
|
||||
class func workout() -> Workout {
|
||||
let filepath = Bundle.main.path(forResource: "WorkoutOne", ofType: "json")!
|
||||
let filepath = Bundle.main.path(forResource: "WorkoutDetail", ofType: "json")!
|
||||
let data = try! Data(NSData(contentsOfFile: filepath))
|
||||
let workout = try! JSONDecoder().decode(Workout.self, from: data)
|
||||
return workout
|
||||
|
||||
@@ -87,6 +87,7 @@ struct AllWorkoutsView: View {
|
||||
// UserStore.shared.logout()
|
||||
maybeUpdateShit()
|
||||
}
|
||||
.background(Color(uiColor: .systemGroupedBackground))
|
||||
.sheet(item: $selectedWorkout) { item in
|
||||
let viewModel = WorkoutDetailViewModel(workout: item)
|
||||
WorkoutDetailView(viewModel: viewModel)
|
||||
@@ -191,7 +192,7 @@ struct AllWorkoutPickerView: View {
|
||||
}
|
||||
}
|
||||
.pickerStyle(.segmented)
|
||||
.padding()
|
||||
.padding([.top, .leading, .trailing])
|
||||
|
||||
if bridgeModule.isInWorkout {
|
||||
Button(action: {
|
||||
@@ -274,12 +275,14 @@ struct AllWorkoutsListView: View {
|
||||
refresh()
|
||||
}
|
||||
|
||||
TextField("Filter", text: $searchString)
|
||||
.frame(height: 55)
|
||||
.textFieldStyle(PlainTextFieldStyle())
|
||||
.padding([.horizontal], 4)
|
||||
.overlay(RoundedRectangle(cornerRadius: 16).stroke(Color(uiColor: .clear))).background(Color(uiColor: .init(red: 200/255, green: 200/255, blue: 200/255, alpha: 0.2)))
|
||||
// .cornerRadius(8)
|
||||
TextField("Filter" ,text: $searchString)
|
||||
.padding()
|
||||
.textFieldStyle(OvalTextFieldStyle())
|
||||
// TextField("Filter", text: $searchString)
|
||||
// .padding()
|
||||
// .overlay(RoundedRectangle(cornerRadius: 10.0).strokeBorder(Color(uiColor: .darkGray), style: StrokeStyle(lineWidth: 1.0)))
|
||||
// .padding()
|
||||
// .background(Color(uiColor: .systemGroupedBackground))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,21 +14,16 @@ struct CreateWorkoutMainView: View {
|
||||
|
||||
var body: some View {
|
||||
VStack {
|
||||
Divider()
|
||||
|
||||
TextField("Title", text: $viewModel.title)
|
||||
.padding()
|
||||
.frame(height: 55)
|
||||
.textFieldStyle(PlainTextFieldStyle())
|
||||
.padding([.horizontal], 4)
|
||||
.overlay(RoundedRectangle(cornerRadius: 16).stroke(Color(uiColor: .clear))).background(Color(uiColor: .init(red: 200/255, green: 200/255, blue: 200/255, alpha: 0.2)))
|
||||
// .cornerRadius(8)
|
||||
.textFieldStyle(OvalTextFieldStyle())
|
||||
|
||||
TextField("Description", text: $viewModel.description)
|
||||
.padding()
|
||||
.frame(height: 55)
|
||||
.textFieldStyle(PlainTextFieldStyle())
|
||||
.padding([.horizontal], 4)
|
||||
.overlay(RoundedRectangle(cornerRadius: 16).stroke(Color(uiColor: .clear))).background(Color(uiColor: .init(red: 200/255, green: 200/255, blue: 200/255, alpha: 0.2)))
|
||||
// .cornerRadius(8)
|
||||
.textFieldStyle(OvalTextFieldStyle())
|
||||
|
||||
List() {
|
||||
ForEach($viewModel.superSets, id: \.id) { superset in
|
||||
@@ -72,6 +67,16 @@ struct CreateWorkoutMainView: View {
|
||||
}
|
||||
.listRowSeparator(.hidden)
|
||||
}
|
||||
.background(Color(uiColor: .secondarySystemBackground))
|
||||
.overlay(Group {
|
||||
if($viewModel.superSets.isEmpty) {
|
||||
ZStack() {
|
||||
Color(uiColor: .secondarySystemBackground)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
Divider()
|
||||
|
||||
HStack {
|
||||
Button("Add Superset", action: {
|
||||
@@ -101,7 +106,9 @@ struct CreateWorkoutMainView: View {
|
||||
}
|
||||
.frame(height: 44)
|
||||
.padding(.bottom)
|
||||
.background(Color(uiColor: .systemGroupedBackground))
|
||||
}
|
||||
.background(Color(uiColor: .systemGroupedBackground))
|
||||
.sheet(isPresented: $showAddExercise) {
|
||||
AddExerciseView(selectedExercise: { exercise in
|
||||
let workoutExercise = CreateWorkoutExercise(exercise: exercise)
|
||||
|
||||
18
Werkout_ios/Views/OvalTextFieldStyle.swift
Normal file
18
Werkout_ios/Views/OvalTextFieldStyle.swift
Normal file
@@ -0,0 +1,18 @@
|
||||
//
|
||||
// OvalTextFieldStyle.swift
|
||||
// Werkout_ios
|
||||
//
|
||||
// Created by Trey Tartt on 7/6/23.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct OvalTextFieldStyle: TextFieldStyle {
|
||||
func _body(configuration: TextField<Self._Label>) -> some View {
|
||||
configuration
|
||||
.padding(10)
|
||||
.background(LinearGradient(gradient: Gradient(colors: [Color(uiColor: .secondarySystemBackground), Color(uiColor: .secondarySystemBackground)]), startPoint: .topLeading, endPoint: .bottomTrailing))
|
||||
.cornerRadius(20)
|
||||
.shadow(color: Color(red: 120/255, green: 120/255, blue: 120/255, opacity: 1), radius: 5)
|
||||
}
|
||||
}
|
||||
@@ -31,13 +31,14 @@ struct WorkoutDetailView: View {
|
||||
case .loading:
|
||||
Text("Loading")
|
||||
case .showWorkout(let workout):
|
||||
VStack {
|
||||
VStack(spacing: 0) {
|
||||
if bridgeModule.isInWorkout {
|
||||
HStack {
|
||||
CurrentWorkoutElapsedTimeView()
|
||||
CountdownView()
|
||||
}
|
||||
.padding()
|
||||
.background(Color(uiColor: .systemBackground))
|
||||
|
||||
GeometryReader { metrics in
|
||||
PlayerView(player: $avPlayer)
|
||||
@@ -45,12 +46,16 @@ struct WorkoutDetailView: View {
|
||||
.onAppear{
|
||||
avPlayer.play()
|
||||
}
|
||||
.background(Color(uiColor: .secondarySystemBackground))
|
||||
}
|
||||
}
|
||||
|
||||
InfoView(workout: workout)
|
||||
Divider()
|
||||
.padding([.leading, .trailing])
|
||||
.padding(.bottom)
|
||||
.background(Color(uiColor: .secondarySystemBackground))
|
||||
|
||||
ExerciseListView(workout: workout)
|
||||
|
||||
ActionsView(completedWorkout: {
|
||||
bridgeModule.completeWorkout()
|
||||
}, planWorkout: { workout in
|
||||
@@ -59,6 +64,7 @@ struct WorkoutDetailView: View {
|
||||
.frame(height: 44)
|
||||
|
||||
}
|
||||
.background(Color(uiColor: .secondarySystemBackground))
|
||||
.sheet(item: $presentedSheet) { item in
|
||||
switch item {
|
||||
case .completedWorkout(let data):
|
||||
@@ -263,7 +269,7 @@ struct CurrentWorkoutElapsedTimeView: View {
|
||||
|
||||
var body: some View {
|
||||
if bridgeModule.currentWorkoutRunTimeInSeconds > -1 {
|
||||
Text("\(bridgeModule.currentWorkoutRunTimeInSeconds)")
|
||||
Text("\(Double(bridgeModule.currentWorkoutRunTimeInSeconds).asString(style: .positional))")
|
||||
.font(.title2)
|
||||
}
|
||||
}
|
||||
@@ -304,24 +310,41 @@ struct ExerciseListView: View {
|
||||
Text(obj.exercise.name)
|
||||
.id(i)
|
||||
|
||||
Spacer()
|
||||
|
||||
if let reps = obj.reps,
|
||||
reps > 0 {
|
||||
Text("Reps: \(reps)")
|
||||
.frame(maxWidth: .infinity, alignment: .trailing)
|
||||
}
|
||||
if let weight = obj.weight,
|
||||
weight > 0 {
|
||||
Text(" - Weight: \(weight)")
|
||||
.frame(maxWidth: .infinity, alignment: .trailing)
|
||||
HStack {
|
||||
Image(systemName: "number")
|
||||
.foregroundColor(.white)
|
||||
.frame(width: 20, alignment: .leading)
|
||||
Text("\(reps)")
|
||||
.foregroundColor(.white)
|
||||
.frame(width: 30, alignment: .trailing)
|
||||
|
||||
}
|
||||
.padding(5)
|
||||
.background(.blue)
|
||||
.cornerRadius(5, corners: [.topLeft, .bottomLeft])
|
||||
.frame(alignment: .trailing)
|
||||
}
|
||||
|
||||
if let duration = obj.duration,
|
||||
duration > 0 {
|
||||
Text("Duration: \(duration)")
|
||||
.frame(maxWidth: .infinity, alignment: .trailing)
|
||||
HStack {
|
||||
Image(systemName: "stopwatch")
|
||||
.foregroundColor(.white)
|
||||
.frame(width: 20, alignment: .leading)
|
||||
Text("\(duration)")
|
||||
.foregroundColor(.white)
|
||||
.frame(width: 30, alignment: .trailing)
|
||||
}
|
||||
.padding(5)
|
||||
.background(.green)
|
||||
.cornerRadius(5, corners: [.topLeft, .bottomLeft])
|
||||
}
|
||||
|
||||
Spacer()
|
||||
}
|
||||
.padding(.trailing, -20)
|
||||
.contentShape(Rectangle())
|
||||
.onTapGesture {
|
||||
if bridgeModule.isInWorkout {
|
||||
|
||||
Reference in New Issue
Block a user