This commit is contained in:
Trey t
2023-07-02 16:42:17 -05:00
parent fbc1ada8c9
commit 9d38a33b80
2 changed files with 26 additions and 12 deletions

View File

@@ -34,7 +34,12 @@ struct AllWorkoutsView: View {
@State private var selectedWorkout: Workout? {
didSet {
bridgeModule.currentWorkout = selectedWorkout
showWorkoutDetail = true
}
}
@State private var selectedPlannedWorkout: Workout? {
didSet {
bridgeModule.currentWorkout = selectedPlannedWorkout
}
}
@@ -80,6 +85,10 @@ struct AllWorkoutsView: View {
let viewModel = WorkoutDetailViewModel(workout: item)
WorkoutDetailView(viewModel: viewModel)
}
.sheet(item: $selectedPlannedWorkout) { item in
let viewModel = WorkoutDetailViewModel(workout: item)
WorkoutDetailView(viewModel: viewModel, showAddToCalendar: false)
}
.sheet(isPresented: $showLoginView) {
LoginView(completion: {
self.needsUpdating = true
@@ -142,6 +151,7 @@ struct AllWorkoutsView: View {
}
.contentShape(Rectangle())
.onTapGesture {
selectedPlannedWorkout = plannedWorkout.workout
}
}
}

View File

@@ -19,6 +19,7 @@ struct WorkoutDetailView: View {
@State var presentedSheet: Sheet?
@State var workoutToPlan: Workout?
var showAddToCalendar = true
var body: some View {
ZStack {
@@ -38,7 +39,7 @@ struct WorkoutDetailView: View {
bridgeModule.sendWorkoutCompleteToWatch()
}, planWorkout: { workout in
workoutToPlan = workout
}, workout: workout)
}, workout: workout, showAddToCalendar: showAddToCalendar)
.frame(height: 44)
}
@@ -119,6 +120,7 @@ struct ActionsView: View {
var workout: Workout
@Environment(\.dismiss) var dismiss
var showAddToCalendar: Bool
var body: some View {
HStack {
@@ -135,16 +137,18 @@ struct ActionsView: View {
.background(.red)
.foregroundColor(.white)
Button(action: {
planWorkout?(workout)
}, label: {
Image(systemName: "calendar.badge.plus")
.font(.title)
.frame(maxWidth: .infinity, maxHeight: .infinity)
})
.frame(maxWidth: .infinity, maxHeight: .infinity)
.background(.blue)
.foregroundColor(.white)
if showAddToCalendar {
Button(action: {
planWorkout?(workout)
}, label: {
Image(systemName: "calendar.badge.plus")
.font(.title)
.frame(maxWidth: .infinity, maxHeight: .infinity)
})
.frame(maxWidth: .infinity, maxHeight: .infinity)
.background(.blue)
.foregroundColor(.white)
}
Button(action: {
startWorkout()