Skip to content

Commit 8cf919c

Browse files
committed
ux: alert the user that an exercise cannot be started while disconnected
1 parent 7e3af2d commit 8cf919c

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

InfiniLink/Core/Exercise/Views/ExerciseView.swift

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import CoreData
1010

1111
struct 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
}

0 commit comments

Comments
 (0)