WIP
This commit is contained in:
@@ -21,6 +21,8 @@ class BridgeModule: ObservableObject {
|
|||||||
@Published var currentWorkoutRunTimeInSeconds: Int = -1
|
@Published var currentWorkoutRunTimeInSeconds: Int = -1
|
||||||
private var currentWorkoutRunTimer: Timer?
|
private var currentWorkoutRunTimer: Timer?
|
||||||
|
|
||||||
|
@Published var isInWorkout = false
|
||||||
|
|
||||||
func start(workout: Workout, atExerciseIndex: Int = 0) {
|
func start(workout: Workout, atExerciseIndex: Int = 0) {
|
||||||
self.currentWorkout = workout
|
self.currentWorkout = workout
|
||||||
currentWorkoutRunTimeInSeconds = 0
|
currentWorkoutRunTimeInSeconds = 0
|
||||||
@@ -31,6 +33,7 @@ class BridgeModule: ObservableObject {
|
|||||||
let exercise = workout.exercises[currentExerciseIdx]
|
let exercise = workout.exercises[currentExerciseIdx]
|
||||||
updateCurrent(exercise: exercise)
|
updateCurrent(exercise: exercise)
|
||||||
startWorkoutTimer()
|
startWorkoutTimer()
|
||||||
|
isInWorkout = true
|
||||||
}
|
}
|
||||||
|
|
||||||
func completeWorkout() {
|
func completeWorkout() {
|
||||||
@@ -46,6 +49,8 @@ class BridgeModule: ObservableObject {
|
|||||||
|
|
||||||
currentExercise = nil
|
currentExercise = nil
|
||||||
currentWorkout = nil
|
currentWorkout = nil
|
||||||
|
|
||||||
|
isInWorkout = false
|
||||||
}
|
}
|
||||||
|
|
||||||
private func startWorkoutTimer() {
|
private func startWorkoutTimer() {
|
||||||
|
|||||||
@@ -19,19 +19,15 @@ struct WorkoutDetailView: View {
|
|||||||
Text("Loading")
|
Text("Loading")
|
||||||
case .showWorkout(let workout):
|
case .showWorkout(let workout):
|
||||||
VStack {
|
VStack {
|
||||||
|
InfoView(workout: workout)
|
||||||
Text(workout.name)
|
Divider()
|
||||||
.font(.title3)
|
|
||||||
.padding()
|
|
||||||
if let desc = workout.description {
|
|
||||||
Text(desc)
|
|
||||||
.font(.body)
|
|
||||||
}
|
|
||||||
CurrentWorkoutElapsedTimeView()
|
CurrentWorkoutElapsedTimeView()
|
||||||
|
.padding(.top)
|
||||||
|
CountdownView()
|
||||||
ExerciseListView(workout: workout)
|
ExerciseListView(workout: workout)
|
||||||
ActionsView(workout: workout)
|
ActionsView(workout: workout)
|
||||||
.frame(height: 44)
|
.frame(height: 44)
|
||||||
CountdownView()
|
|
||||||
}
|
}
|
||||||
.interactiveDismissDisabled()
|
.interactiveDismissDisabled()
|
||||||
}
|
}
|
||||||
@@ -39,6 +35,28 @@ struct WorkoutDetailView: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct InfoView: View {
|
||||||
|
@ObservedObject var bridgeModule = BridgeModule.shared
|
||||||
|
var workout: Workout
|
||||||
|
|
||||||
|
var body: some View {
|
||||||
|
VStack {
|
||||||
|
if bridgeModule.isInWorkout == false {
|
||||||
|
Text(workout.name)
|
||||||
|
.frame(maxWidth: .infinity, alignment: .leading)
|
||||||
|
.font(.title3)
|
||||||
|
.padding()
|
||||||
|
if let desc = workout.description {
|
||||||
|
Text(desc)
|
||||||
|
.frame(maxWidth: .infinity, alignment: .leading)
|
||||||
|
.font(.body)
|
||||||
|
.padding([.leading, .trailing])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
struct ActionsView: View {
|
struct ActionsView: View {
|
||||||
@ObservedObject var bridgeModule = BridgeModule.shared
|
@ObservedObject var bridgeModule = BridgeModule.shared
|
||||||
var workout: Workout
|
var workout: Workout
|
||||||
@@ -46,9 +64,9 @@ struct ActionsView: View {
|
|||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
HStack {
|
HStack {
|
||||||
if bridgeModule.currentWorkoutRunTimeInSeconds == -1 {
|
if bridgeModule.isInWorkout == false {
|
||||||
Button(action: {
|
Button(action: {
|
||||||
bridgeModule.completeWorkout()
|
completeWorkout()
|
||||||
dismiss()
|
dismiss()
|
||||||
}, label: {
|
}, label: {
|
||||||
Image(systemName: "xmark.octagon.fill")
|
Image(systemName: "xmark.octagon.fill")
|
||||||
@@ -60,7 +78,7 @@ struct ActionsView: View {
|
|||||||
.foregroundColor(.white)
|
.foregroundColor(.white)
|
||||||
|
|
||||||
Button(action: {
|
Button(action: {
|
||||||
bridgeModule.start(workout: workout)
|
startWorkout()
|
||||||
}, label: {
|
}, label: {
|
||||||
Image(systemName: "arrowtriangle.forward.fill")
|
Image(systemName: "arrowtriangle.forward.fill")
|
||||||
.font(.title)
|
.font(.title)
|
||||||
@@ -71,7 +89,7 @@ struct ActionsView: View {
|
|||||||
.foregroundColor(.white)
|
.foregroundColor(.white)
|
||||||
} else {
|
} else {
|
||||||
Button(action: {
|
Button(action: {
|
||||||
bridgeModule.nextExercise()
|
nextExercise()
|
||||||
}, label: {
|
}, label: {
|
||||||
Image(systemName: "arrow.forward")
|
Image(systemName: "arrow.forward")
|
||||||
.font(.title)
|
.font(.title)
|
||||||
@@ -82,7 +100,7 @@ struct ActionsView: View {
|
|||||||
.foregroundColor(.white)
|
.foregroundColor(.white)
|
||||||
|
|
||||||
Button(action: {
|
Button(action: {
|
||||||
bridgeModule.completeWorkout()
|
completeWorkout()
|
||||||
dismiss()
|
dismiss()
|
||||||
}, label: {
|
}, label: {
|
||||||
Image(systemName: "checkmark")
|
Image(systemName: "checkmark")
|
||||||
@@ -95,6 +113,18 @@ struct ActionsView: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func completeWorkout() {
|
||||||
|
bridgeModule.completeWorkout()
|
||||||
|
}
|
||||||
|
|
||||||
|
func nextExercise() {
|
||||||
|
bridgeModule.nextExercise()
|
||||||
|
}
|
||||||
|
|
||||||
|
func startWorkout() {
|
||||||
|
bridgeModule.start(workout: workout)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct CurrentWorkoutElapsedTimeView: View {
|
struct CurrentWorkoutElapsedTimeView: View {
|
||||||
@@ -103,6 +133,7 @@ struct CurrentWorkoutElapsedTimeView: View {
|
|||||||
var body: some View {
|
var body: some View {
|
||||||
if bridgeModule.currentWorkoutRunTimeInSeconds > -1 {
|
if bridgeModule.currentWorkoutRunTimeInSeconds > -1 {
|
||||||
Text("\(bridgeModule.currentWorkoutRunTimeInSeconds)")
|
Text("\(bridgeModule.currentWorkoutRunTimeInSeconds)")
|
||||||
|
.font(.title2)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user