split views into subview
This commit is contained in:
@@ -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)
|
||||
}
|
||||
@@ -113,46 +114,7 @@ struct AllWorkoutsView: View {
|
||||
maybeUpdateShit()
|
||||
}
|
||||
}
|
||||
|
||||
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 {
|
||||
|
||||
Reference in New Issue
Block a user