initial pre-viable version of watch app
This commit is contained in:
@ -8,16 +8,19 @@ final class Exercise {
|
||||
var sets: Int = 0
|
||||
var reps: Int = 0
|
||||
var weight: Int = 0
|
||||
var weightLastUpdated: Date = Date()
|
||||
var weightReminderTimeIntervalWeeks: Int = 2
|
||||
|
||||
@Relationship(deleteRule: .nullify)
|
||||
var split: Split?
|
||||
|
||||
init(split: Split, exerciseName: String, order: Int, sets: Int, reps: Int, weight: Int) {
|
||||
init(split: Split, exerciseName: String, order: Int, sets: Int, reps: Int, weight: Int, weightReminderTimeIntervalWeeks: Int = 2) {
|
||||
self.split = split
|
||||
self.name = exerciseName
|
||||
self.order = order
|
||||
self.sets = sets
|
||||
self.reps = reps
|
||||
self.weight = weight
|
||||
self.weightReminderTimeIntervalWeeks = weightReminderTimeIntervalWeeks
|
||||
}
|
||||
}
|
||||
|
@ -31,29 +31,6 @@ final class Split {
|
||||
static let unnamed = "Unnamed Split"
|
||||
}
|
||||
|
||||
// MARK: - EditableEntity Conformance
|
||||
|
||||
extension Split: EditableEntity {
|
||||
var count: Int? {
|
||||
return self.exercises?.count
|
||||
}
|
||||
|
||||
static func createNew() -> Split {
|
||||
return Split(name: "")
|
||||
}
|
||||
|
||||
static var navigationTitle: String {
|
||||
return "Splits"
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
static func formView(for model: Split) -> some View {
|
||||
EntityAddEditView(model: model) { $model in
|
||||
SplitFormView(model: $model)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Identifiable Conformance
|
||||
|
||||
extension Split: Identifiable {
|
||||
@ -64,58 +41,58 @@ extension Split: Identifiable {
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Private Form View
|
||||
|
||||
fileprivate struct SplitFormView: View {
|
||||
@Binding var model: Split
|
||||
|
||||
// Available colors for splits
|
||||
private let availableColors = ["red", "orange", "yellow", "green", "mint", "teal", "cyan", "blue", "indigo", "purple", "pink", "brown"]
|
||||
|
||||
// Available system images for splits
|
||||
private let availableIcons = ["dumbbell.fill", "figure.strengthtraining.traditional", "figure.run", "figure.hiking", "figure.cooldown", "figure.boxing", "figure.wrestling", "figure.gymnastics", "figure.handball", "figure.core.training", "heart.fill", "bolt.fill"]
|
||||
|
||||
var body: some View {
|
||||
Section(header: Text("Name")) {
|
||||
TextField("Name", text: $model.name)
|
||||
.bold()
|
||||
}
|
||||
|
||||
Section(header: Text("Appearance")) {
|
||||
Picker("Color", selection: $model.color) {
|
||||
ForEach(availableColors, id: \.self) { colorName in
|
||||
let tempSplit = Split(name: "", color: colorName)
|
||||
HStack {
|
||||
Circle()
|
||||
.fill(tempSplit.getColor())
|
||||
.frame(width: 20, height: 20)
|
||||
Text(colorName.capitalized)
|
||||
}
|
||||
.tag(colorName)
|
||||
}
|
||||
}
|
||||
|
||||
Picker("Icon", selection: $model.systemImage) {
|
||||
ForEach(availableIcons, id: \.self) { iconName in
|
||||
HStack {
|
||||
Image(systemName: iconName)
|
||||
.frame(width: 24, height: 24)
|
||||
Text(iconName.replacingOccurrences(of: ".fill", with: "").replacingOccurrences(of: "figure.", with: "").capitalized)
|
||||
}
|
||||
.tag(iconName)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Section(header: Text("Exercises")) {
|
||||
NavigationLink {
|
||||
ExerciseListView(split: model)
|
||||
} label: {
|
||||
ListItem(
|
||||
text: "Exercises",
|
||||
count: model.exercises?.count ?? 0
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//// MARK: - Private Form View
|
||||
//
|
||||
//fileprivate struct SplitFormView: View {
|
||||
// @Binding var model: Split
|
||||
//
|
||||
// // Available colors for splits
|
||||
// private let availableColors = ["red", "orange", "yellow", "green", "mint", "teal", "cyan", "blue", "indigo", "purple", "pink", "brown"]
|
||||
//
|
||||
// // Available system images for splits
|
||||
// private let availableIcons = ["dumbbell.fill", "figure.strengthtraining.traditional", "figure.run", "figure.hiking", "figure.cooldown", "figure.boxing", "figure.wrestling", "figure.gymnastics", "figure.handball", "figure.core.training", "heart.fill", "bolt.fill"]
|
||||
//
|
||||
// var body: some View {
|
||||
// Section(header: Text("Name")) {
|
||||
// TextField("Name", text: $model.name)
|
||||
// .bold()
|
||||
// }
|
||||
//
|
||||
// Section(header: Text("Appearance")) {
|
||||
// Picker("Color", selection: $model.color) {
|
||||
// ForEach(availableColors, id: \.self) { colorName in
|
||||
// let tempSplit = Split(name: "", color: colorName)
|
||||
// HStack {
|
||||
// Circle()
|
||||
// .fill(tempSplit.getColor())
|
||||
// .frame(width: 20, height: 20)
|
||||
// Text(colorName.capitalized)
|
||||
// }
|
||||
// .tag(colorName)
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// Picker("Icon", selection: $model.systemImage) {
|
||||
// ForEach(availableIcons, id: \.self) { iconName in
|
||||
// HStack {
|
||||
// Image(systemName: iconName)
|
||||
// .frame(width: 24, height: 24)
|
||||
// Text(iconName.replacingOccurrences(of: ".fill", with: "").replacingOccurrences(of: "figure.", with: "").capitalized)
|
||||
// }
|
||||
// .tag(iconName)
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// Section(header: Text("Exercises")) {
|
||||
// NavigationLink {
|
||||
// ExerciseListView(split: model)
|
||||
// } label: {
|
||||
// ListItem(
|
||||
// text: "Exercises",
|
||||
// count: model.exercises?.count ?? 0
|
||||
// )
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
Reference in New Issue
Block a user