add ActiveWorkoutSession logic, refactor Home, add additional sample data, add isDebug

This commit is contained in:
Felix Förtsch
2024-09-14 17:01:20 +02:00
parent f45d6288dd
commit 0a400ff349
27 changed files with 710 additions and 189 deletions
+10 -10
View File
@@ -19,15 +19,13 @@ struct WorkoutLibrary: View {
@State private var searchText: String = ""
var filteredItems: [Workout] {
if searchText.isEmpty {
return workouts
} else {
return workouts.filter { $0.name.localizedCaseInsensitiveContains(searchText) }
if searchText.isEmpty { return workouts }
else { return workouts.filter { $0.name.localizedCaseInsensitiveContains(searchText) }
}
}
var body: some View {
NavigationView {
Group {
List {
ForEach(filteredItems) { workout in
@@ -53,13 +51,12 @@ struct WorkoutLibrary: View {
}
.searchable(text: $searchText)
}
.navigationBarTitle("Workouts")
.navigationTitle("Workouts")
.toolbar {
ToolbarItem() {
EditButton()
}
}
}
}
private func addWorkout() {
@@ -71,7 +68,6 @@ struct WorkoutLibrary: View {
}
}
// TODO: Brauchen wir das?
private func save(workout: Workout) {
withAnimation {
newWorkout.name = newWorkoutName
@@ -94,12 +90,16 @@ struct WorkoutLibrary: View {
}
#Preview("With Sample Data") {
WorkoutLibrary()
NavigationStack {
WorkoutLibrary()
}
.modelContainer(SampleData.shared.modelContainer)
}
#Preview("Empty Database") {
WorkoutLibrary()
NavigationStack {
WorkoutLibrary()
}
.modelContainer(for: Workout.self, inMemory: true)
}