split views into subview
This commit is contained in:
@@ -50,6 +50,10 @@
|
||||
1CC092FD2C20B0A30004E1E6 /* ExtCountdownView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1CC092FC2C20B0A30004E1E6 /* ExtCountdownView.swift */; };
|
||||
1CC092FF2C20B0C80004E1E6 /* ExtExerciseList.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1CC092FE2C20B0C80004E1E6 /* ExtExerciseList.swift */; };
|
||||
1CC093012C20B0E90004E1E6 /* TitleView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1CC093002C20B0E90004E1E6 /* TitleView.swift */; };
|
||||
1CC7CBD52C221159001614B8 /* CaloriesBurnedView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1CC7CBD42C221159001614B8 /* CaloriesBurnedView.swift */; };
|
||||
1CC7CBD72C2211F0001614B8 /* RateWorkoutView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1CC7CBD62C2211F0001614B8 /* RateWorkoutView.swift */; };
|
||||
1CC7CBD92C221286001614B8 /* WorkoutInfoView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1CC7CBD82C221286001614B8 /* WorkoutInfoView.swift */; };
|
||||
1CC7CBDB2C221666001614B8 /* PlannedWorkoutView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1CC7CBDA2C221666001614B8 /* PlannedWorkoutView.swift */; };
|
||||
1CD0C6632A5AF62900970E52 /* WorkoutOverviewView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1CD0C6622A5AF62900970E52 /* WorkoutOverviewView.swift */; };
|
||||
1CD0C6672A5CA19600970E52 /* BaseURLs.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1CD0C6662A5CA19600970E52 /* BaseURLs.swift */; };
|
||||
1CD0C6682A5CA1A200970E52 /* BaseURLs.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1CD0C6662A5CA19600970E52 /* BaseURLs.swift */; };
|
||||
@@ -180,6 +184,10 @@
|
||||
1CC092FC2C20B0A30004E1E6 /* ExtCountdownView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExtCountdownView.swift; sourceTree = "<group>"; };
|
||||
1CC092FE2C20B0C80004E1E6 /* ExtExerciseList.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExtExerciseList.swift; sourceTree = "<group>"; };
|
||||
1CC093002C20B0E90004E1E6 /* TitleView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TitleView.swift; sourceTree = "<group>"; };
|
||||
1CC7CBD42C221159001614B8 /* CaloriesBurnedView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CaloriesBurnedView.swift; sourceTree = "<group>"; };
|
||||
1CC7CBD62C2211F0001614B8 /* RateWorkoutView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RateWorkoutView.swift; sourceTree = "<group>"; };
|
||||
1CC7CBD82C221286001614B8 /* WorkoutInfoView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WorkoutInfoView.swift; sourceTree = "<group>"; };
|
||||
1CC7CBDA2C221666001614B8 /* PlannedWorkoutView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlannedWorkoutView.swift; sourceTree = "<group>"; };
|
||||
1CD0C6622A5AF62900970E52 /* WorkoutOverviewView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WorkoutOverviewView.swift; sourceTree = "<group>"; };
|
||||
1CD0C6662A5CA19600970E52 /* BaseURLs.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BaseURLs.swift; sourceTree = "<group>"; };
|
||||
1CD0C66B2A5E4EA100970E52 /* LaunchScreen.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = LaunchScreen.storyboard; sourceTree = "<group>"; };
|
||||
@@ -275,24 +283,28 @@
|
||||
1CC092EB2C1FAC2A0004E1E6 /* subview */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
1C31C8862A55B2CC00350540 /* PlayerUIView.swift */,
|
||||
1C5190C12A57CA5F00885849 /* OvalTextFieldStyle.swift */,
|
||||
1CC092F62C1FAFD50004E1E6 /* AllMusclesView.swift */,
|
||||
1CC092EC2C1FAC730004E1E6 /* Logoutview.swift */,
|
||||
1CC092EE2C1FACFC0004E1E6 /* NameView.swift */,
|
||||
1CC092F02C1FAD1E0004E1E6 /* CompletedWorkoutsView.swift */,
|
||||
1CC092F22C1FADDA0004E1E6 /* ThotPreferenceView.swift */,
|
||||
1CC092F42C1FAE7B0004E1E6 /* ShowNextUpView.swift */,
|
||||
1CC092F82C1FB1420004E1E6 /* AllExerciseView.swift */,
|
||||
1CC092FA2C1FB3320004E1E6 /* AllEquipmentView.swift */,
|
||||
1CD0C6622A5AF62900970E52 /* WorkoutOverviewView.swift */,
|
||||
1C5190CD2A589D4100885849 /* AllWorkoutPickerView.swift */,
|
||||
1C5190C52A589CC100885849 /* ActionsView.swift */,
|
||||
1C5190C32A589CAC00885849 /* InfoView.swift */,
|
||||
1CC092FA2C1FB3320004E1E6 /* AllEquipmentView.swift */,
|
||||
1CC092F82C1FB1420004E1E6 /* AllExerciseView.swift */,
|
||||
1CC092F62C1FAFD50004E1E6 /* AllMusclesView.swift */,
|
||||
1C5190CD2A589D4100885849 /* AllWorkoutPickerView.swift */,
|
||||
1CC7CBD42C221159001614B8 /* CaloriesBurnedView.swift */,
|
||||
1CC092F02C1FAD1E0004E1E6 /* CompletedWorkoutsView.swift */,
|
||||
1C5190CB2A589D0000885849 /* CountdownView.swift */,
|
||||
1CC092FC2C20B0A30004E1E6 /* ExtCountdownView.swift */,
|
||||
1CC092FE2C20B0C80004E1E6 /* ExtExerciseList.swift */,
|
||||
1C5190C32A589CAC00885849 /* InfoView.swift */,
|
||||
1CC092EC2C1FAC730004E1E6 /* Logoutview.swift */,
|
||||
1CC092EE2C1FACFC0004E1E6 /* NameView.swift */,
|
||||
1C5190C12A57CA5F00885849 /* OvalTextFieldStyle.swift */,
|
||||
1CC7CBDA2C221666001614B8 /* PlannedWorkoutView.swift */,
|
||||
1C31C8862A55B2CC00350540 /* PlayerUIView.swift */,
|
||||
1CC7CBD62C2211F0001614B8 /* RateWorkoutView.swift */,
|
||||
1CC092F42C1FAE7B0004E1E6 /* ShowNextUpView.swift */,
|
||||
1CC092F22C1FADDA0004E1E6 /* ThotPreferenceView.swift */,
|
||||
1CC093002C20B0E90004E1E6 /* TitleView.swift */,
|
||||
1CC7CBD82C221286001614B8 /* WorkoutInfoView.swift */,
|
||||
1CD0C6622A5AF62900970E52 /* WorkoutOverviewView.swift */,
|
||||
);
|
||||
path = subview;
|
||||
sourceTree = "<group>";
|
||||
@@ -652,8 +664,10 @@
|
||||
1CF65A432A39FB410042FFBD /* Workout.swift in Sources */,
|
||||
1CF65A502A3A1EA90042FFBD /* BridgeModule.swift in Sources */,
|
||||
1CF65A592A3BF4B60042FFBD /* Muscle.swift in Sources */,
|
||||
1CC7CBD92C221286001614B8 /* WorkoutInfoView.swift in Sources */,
|
||||
1CC092F32C1FADDA0004E1E6 /* ThotPreferenceView.swift in Sources */,
|
||||
1C4AFF1E2A7579410027710B /* NSFWVideo.swift in Sources */,
|
||||
1CC7CBD52C221159001614B8 /* CaloriesBurnedView.swift in Sources */,
|
||||
1CC092F72C1FAFD50004E1E6 /* AllMusclesView.swift in Sources */,
|
||||
1C5190D02A589D5F00885849 /* AllWorkoutsListView.swift in Sources */,
|
||||
1C5190CA2A589CEC00885849 /* ExerciseListView.swift in Sources */,
|
||||
@@ -665,6 +679,7 @@
|
||||
1C31C8872A55B2CC00350540 /* PlayerUIView.swift in Sources */,
|
||||
1CEF74AB2A89937800C1AE6A /* HealthKitHelper.swift in Sources */,
|
||||
1CF65A2D2A3972840042FFBD /* MainView.swift in Sources */,
|
||||
1CC7CBDB2C221666001614B8 /* PlannedWorkoutView.swift in Sources */,
|
||||
1CF65A7D2A41275D0042FFBD /* Network.swift in Sources */,
|
||||
1C485C8A2A492BB400A6F896 /* LoginView.swift in Sources */,
|
||||
1C4AFF1B2A65FB190027710B /* CurrentWorkoutInfo.swift in Sources */,
|
||||
@@ -682,6 +697,7 @@
|
||||
1C5190C82A589CDA00885849 /* CurrentWorkoutElapsedTimeView.swift in Sources */,
|
||||
1CC092F92C1FB1420004E1E6 /* AllExerciseView.swift in Sources */,
|
||||
1CC093012C20B0E90004E1E6 /* TitleView.swift in Sources */,
|
||||
1CC7CBD72C2211F0001614B8 /* RateWorkoutView.swift in Sources */,
|
||||
1CF65A452A39FB550042FFBD /* Exercise.swift in Sources */,
|
||||
1CF65A612A3BF6020042FFBD /* AddExerciseView.swift in Sources */,
|
||||
1C485C872A4915C400A6F896 /* CreateWorkoutItemPickerView.swift in Sources */,
|
||||
|
||||
@@ -81,7 +81,8 @@ struct AllWorkoutsView: View {
|
||||
})
|
||||
Divider()
|
||||
case .MyWorkouts:
|
||||
plannedWorkout(workouts: UserStore.shared.plannedWorkouts)
|
||||
PlannedWorkoutView(workouts: UserStore.shared.plannedWorkouts,
|
||||
selectedPlannedWorkout: $selectedPlannedWorkout)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -93,7 +94,7 @@ struct AllWorkoutsView: View {
|
||||
maybeUpdateShit()
|
||||
}
|
||||
.sheet(item: $selectedWorkout) { item in
|
||||
var isPreview = item.id == bridgeModule.currentExerciseInfo.workout?.id
|
||||
let isPreview = item.id == bridgeModule.currentExerciseInfo.workout?.id
|
||||
let viewModel = WorkoutDetailViewModel(workout: item, isPreview: isPreview)
|
||||
WorkoutDetailView(viewModel: viewModel)
|
||||
}
|
||||
@@ -114,45 +115,6 @@ struct AllWorkoutsView: View {
|
||||
}
|
||||
}
|
||||
|
||||
func plannedWorkout(workouts: [PlannedWorkout]) -> some View {
|
||||
List {
|
||||
ForEach(workouts, id:\.workout.name) { plannedWorkout in
|
||||
HStack {
|
||||
VStack(alignment: .leading) {
|
||||
Text(plannedWorkout.onDate.plannedDate?.weekDay ?? "-")
|
||||
.font(.title)
|
||||
|
||||
Text(plannedWorkout.onDate.plannedDate?.monthString ?? "-")
|
||||
.font(.title)
|
||||
|
||||
Text(plannedWorkout.onDate.plannedDate?.dateString ?? "-")
|
||||
.font(.title)
|
||||
}
|
||||
|
||||
Divider()
|
||||
|
||||
VStack {
|
||||
Text(plannedWorkout.workout.name)
|
||||
.font(.title)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
|
||||
Text(plannedWorkout.workout.description ?? "")
|
||||
.font(.body)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
|
||||
Text(plannedWorkout.onDate)
|
||||
.font(.footnote)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
}
|
||||
.contentShape(Rectangle())
|
||||
.onTapGesture {
|
||||
selectedPlannedWorkout = plannedWorkout.workout
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func maybeUpdateShit() {
|
||||
if UserStore.shared.token != nil{
|
||||
if UserStore.shared.plannedWorkouts.isEmpty {
|
||||
|
||||
@@ -29,48 +29,18 @@ struct CompletedWorkoutView: View {
|
||||
ProgressView("Uploading")
|
||||
}
|
||||
VStack {
|
||||
topViews()
|
||||
WorkoutInfoView(workout: workout)
|
||||
|
||||
Divider()
|
||||
|
||||
HStack {
|
||||
if let calsBurned = healthKitWorkoutData?.caloriesBurned {
|
||||
HStack {
|
||||
HStack {
|
||||
Image(systemName: "flame.fill")
|
||||
.foregroundColor(.orange)
|
||||
.font(.title)
|
||||
VStack {
|
||||
Text("\(calsBurned, specifier: "%.0f")")
|
||||
}
|
||||
}
|
||||
.frame(maxWidth: .infinity)
|
||||
}
|
||||
|
||||
if let minHeart = healthKitWorkoutData?.minHeartRate,
|
||||
let maxHeart = healthKitWorkoutData?.maxHeartRate,
|
||||
let avgHeart = healthKitWorkoutData?.avgHeartRate {
|
||||
VStack {
|
||||
HStack {
|
||||
Image(systemName: "heart")
|
||||
.foregroundColor(.red)
|
||||
.font(.title)
|
||||
VStack {
|
||||
HStack {
|
||||
Text("\(minHeart, specifier: "%.0f")")
|
||||
Text("-")
|
||||
Text("\(maxHeart, specifier: "%.0f")")
|
||||
}
|
||||
Text("\(avgHeart, specifier: "%.0f")")
|
||||
}
|
||||
}
|
||||
}
|
||||
.frame(maxWidth: .infinity)
|
||||
}
|
||||
CaloriesBurnedView(healthKitWorkoutData: $healthKitWorkoutData,
|
||||
calsBurned: calsBurned)
|
||||
}
|
||||
}
|
||||
|
||||
rateWorkout()
|
||||
RateWorkoutView(difficulty: $difficulty)
|
||||
.frame(maxHeight: 88)
|
||||
|
||||
Divider()
|
||||
@@ -118,53 +88,6 @@ struct CompletedWorkoutView: View {
|
||||
})
|
||||
}
|
||||
|
||||
func topViews() -> some View {
|
||||
VStack {
|
||||
Text(workout.name)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
.font(.title3)
|
||||
.padding(.top
|
||||
)
|
||||
if let desc = workout.description {
|
||||
Text(desc)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
.font(.body)
|
||||
.padding(.top)
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func rateWorkout() -> some View {
|
||||
VStack {
|
||||
Divider()
|
||||
|
||||
HStack {
|
||||
Text("No Rate")
|
||||
.foregroundColor(.black)
|
||||
Text("Easy")
|
||||
.foregroundColor(.green)
|
||||
Spacer()
|
||||
Text("Death")
|
||||
.foregroundColor(.red)
|
||||
}
|
||||
|
||||
ZStack {
|
||||
LinearGradient(
|
||||
gradient: Gradient(colors: [.black, .green, .red]),
|
||||
startPoint: .leading,
|
||||
endPoint: .trailing
|
||||
)
|
||||
.mask(Slider(value: $difficulty, in: 0...5, step: 1))
|
||||
|
||||
// Dummy replicated slider, to allow sliding
|
||||
Slider(value: $difficulty, in: 0...5, step: 1)
|
||||
.opacity(0.05) // Opacity is the trick here.
|
||||
.accentColor(.clear)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func upload(postBody: [String: Any]) {
|
||||
var _postBody = postBody
|
||||
_postBody["difficulty"] = difficulty
|
||||
|
||||
54
iphone/Werkout_ios/subview/CaloriesBurnedView.swift
Normal file
54
iphone/Werkout_ios/subview/CaloriesBurnedView.swift
Normal file
@@ -0,0 +1,54 @@
|
||||
//
|
||||
// CaloriesBurnedView.swift
|
||||
// Werkout_ios
|
||||
//
|
||||
// Created by Trey Tartt on 6/18/24.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct CaloriesBurnedView: View {
|
||||
@Binding var healthKitWorkoutData: HealthKitWorkoutData?
|
||||
let calsBurned: Double
|
||||
|
||||
var body: some View {
|
||||
VStack {
|
||||
HStack {
|
||||
HStack {
|
||||
Image(systemName: "flame.fill")
|
||||
.foregroundColor(.orange)
|
||||
.font(.title)
|
||||
VStack {
|
||||
Text("\(calsBurned, specifier: "%.0f")")
|
||||
}
|
||||
}
|
||||
.frame(maxWidth: .infinity)
|
||||
}
|
||||
|
||||
if let minHeart = healthKitWorkoutData?.minHeartRate,
|
||||
let maxHeart = healthKitWorkoutData?.maxHeartRate,
|
||||
let avgHeart = healthKitWorkoutData?.avgHeartRate {
|
||||
VStack {
|
||||
HStack {
|
||||
Image(systemName: "heart")
|
||||
.foregroundColor(.red)
|
||||
.font(.title)
|
||||
VStack {
|
||||
HStack {
|
||||
Text("\(minHeart, specifier: "%.0f")")
|
||||
Text("-")
|
||||
Text("\(maxHeart, specifier: "%.0f")")
|
||||
}
|
||||
Text("\(avgHeart, specifier: "%.0f")")
|
||||
}
|
||||
}
|
||||
}
|
||||
.frame(maxWidth: .infinity)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//#Preview {
|
||||
// CaloriesBurnedView()
|
||||
//}
|
||||
56
iphone/Werkout_ios/subview/PlannedWorkoutView.swift
Normal file
56
iphone/Werkout_ios/subview/PlannedWorkoutView.swift
Normal file
@@ -0,0 +1,56 @@
|
||||
//
|
||||
// PlannedWorkoutView.swift
|
||||
// Werkout_ios
|
||||
//
|
||||
// Created by Trey Tartt on 6/18/24.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct PlannedWorkoutView: View {
|
||||
let workouts: [PlannedWorkout]
|
||||
@Binding var selectedPlannedWorkout: Workout?
|
||||
|
||||
var body: some View {
|
||||
List {
|
||||
ForEach(workouts, id:\.workout.name) { plannedWorkout in
|
||||
HStack {
|
||||
VStack(alignment: .leading) {
|
||||
Text(plannedWorkout.onDate.plannedDate?.weekDay ?? "-")
|
||||
.font(.title)
|
||||
|
||||
Text(plannedWorkout.onDate.plannedDate?.monthString ?? "-")
|
||||
.font(.title)
|
||||
|
||||
Text(plannedWorkout.onDate.plannedDate?.dateString ?? "-")
|
||||
.font(.title)
|
||||
}
|
||||
|
||||
Divider()
|
||||
|
||||
VStack {
|
||||
Text(plannedWorkout.workout.name)
|
||||
.font(.title)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
|
||||
Text(plannedWorkout.workout.description ?? "")
|
||||
.font(.body)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
|
||||
Text(plannedWorkout.onDate)
|
||||
.font(.footnote)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
}
|
||||
.contentShape(Rectangle())
|
||||
.onTapGesture {
|
||||
selectedPlannedWorkout = plannedWorkout.workout
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//#Preview {
|
||||
// PlannedWorkoutView()
|
||||
//}
|
||||
46
iphone/Werkout_ios/subview/RateWorkoutView.swift
Normal file
46
iphone/Werkout_ios/subview/RateWorkoutView.swift
Normal file
@@ -0,0 +1,46 @@
|
||||
//
|
||||
// RateWorkoutView.swift
|
||||
// Werkout_ios
|
||||
//
|
||||
// Created by Trey Tartt on 6/18/24.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct RateWorkoutView: View {
|
||||
@Binding var difficulty: Float
|
||||
|
||||
var body: some View {
|
||||
VStack {
|
||||
Divider()
|
||||
|
||||
HStack {
|
||||
Text("No Rate")
|
||||
.foregroundColor(.black)
|
||||
Text("Easy")
|
||||
.foregroundColor(.green)
|
||||
Spacer()
|
||||
Text("Death")
|
||||
.foregroundColor(.red)
|
||||
}
|
||||
|
||||
ZStack {
|
||||
LinearGradient(
|
||||
gradient: Gradient(colors: [.black, .green, .red]),
|
||||
startPoint: .leading,
|
||||
endPoint: .trailing
|
||||
)
|
||||
.mask(Slider(value: $difficulty, in: 0...5, step: 1))
|
||||
|
||||
// Dummy replicated slider, to allow sliding
|
||||
Slider(value: $difficulty, in: 0...5, step: 1)
|
||||
.opacity(0.05) // Opacity is the trick here.
|
||||
.accentColor(.clear)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//#Preview {
|
||||
// RateWorkoutView()
|
||||
//}
|
||||
33
iphone/Werkout_ios/subview/WorkoutInfoView.swift
Normal file
33
iphone/Werkout_ios/subview/WorkoutInfoView.swift
Normal file
@@ -0,0 +1,33 @@
|
||||
//
|
||||
// WorkoutInfoView.swift
|
||||
// Werkout_ios
|
||||
//
|
||||
// Created by Trey Tartt on 6/18/24.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct WorkoutInfoView: View {
|
||||
let workout: Workout
|
||||
|
||||
var body: some View {
|
||||
VStack {
|
||||
Text(workout.name)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
.font(.title3)
|
||||
.padding(.top
|
||||
)
|
||||
if let desc = workout.description {
|
||||
Text(desc)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
.font(.body)
|
||||
.padding(.top)
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//#Preview {
|
||||
// WorkoutInfoView()
|
||||
//}
|
||||
Reference in New Issue
Block a user