File tree Expand file tree Collapse file tree
InfiniLink/Core/Exercise/Views Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ import CoreData
1010
1111struct ExerciseView : View {
1212 @ObservedObject var exerciseViewModel = ExerciseViewModel . shared
13+ @ObservedObject var bleManager = BLEManager . shared
1314
1415 @Environment ( \. managedObjectContext) var viewContext
1516
@@ -27,7 +28,7 @@ struct ExerciseView: View {
2728 } else {
2829 ForEach ( userExercises) { userExercise in
2930 let exercise = exerciseViewModel. exercises. first ( where: { $0. id == userExercise. exerciseId } ) !
30-
31+
3132 NavigationLink {
3233 ExerciseDetailView ( userExercise: userExercise)
3334 } label: {
@@ -46,13 +47,23 @@ struct ExerciseView: View {
4647 . onDelete ( perform: delete)
4748 }
4849 }
49- Section ( " All Exercises " ) {
50+ if !bleManager. hasLoadedCharacteristics {
51+ Section ( " All Exercises " ) {
52+ Text ( DeviceManager . shared. name + " needs to be connected before you can start an exercise. " )
53+ }
54+ }
55+ Section {
5056 ForEach ( exerciseViewModel. exercises) { exercise in
5157 Button {
5258 exerciseViewModel. startExercise ( exercise)
5359 } label: {
5460 Label ( exercise. name, systemImage: exercise. icon)
5561 }
62+ . disabled ( !bleManager. hasLoadedCharacteristics)
63+ }
64+ } header: {
65+ if bleManager. hasLoadedCharacteristics {
66+ Text ( " All Exercises " )
5667 }
5768 }
5869 }
You can’t perform that action at this time.
0 commit comments