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