|
|
|
@ -22,15 +22,36 @@ struct CountdownFormView : View { |
|
|
|
|
|
|
|
|
|
|
|
var textFieldIsFocused: FocusState<Bool>.Binding |
|
|
|
var textFieldIsFocused: FocusState<Bool>.Binding |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var intervalRepeatBinding: Binding<Int>? = nil |
|
|
|
|
|
|
|
|
|
|
|
var body: some View { |
|
|
|
var body: some View { |
|
|
|
Form { |
|
|
|
Form { |
|
|
|
Section(header: Text("Duration")) { |
|
|
|
Section { |
|
|
|
TextField("minutes", text: minutesBinding) |
|
|
|
TextField("minutes", text: minutesBinding) |
|
|
|
.keyboardType(.numberPad) |
|
|
|
.keyboardType(.numberPad) |
|
|
|
.focused(textFieldIsFocused) |
|
|
|
.focused(textFieldIsFocused) |
|
|
|
TextField("seconds", text: secondsBinding) |
|
|
|
TextField("seconds", text: secondsBinding) |
|
|
|
.keyboardType(.numberPad) |
|
|
|
.keyboardType(.numberPad) |
|
|
|
.focused(textFieldIsFocused) |
|
|
|
.focused(textFieldIsFocused) |
|
|
|
|
|
|
|
} header: { |
|
|
|
|
|
|
|
HStack { |
|
|
|
|
|
|
|
Text("Duration") |
|
|
|
|
|
|
|
Spacer() |
|
|
|
|
|
|
|
Button { |
|
|
|
|
|
|
|
self._addInterval() |
|
|
|
|
|
|
|
} label: { |
|
|
|
|
|
|
|
Label("add interval", image: "plus") |
|
|
|
|
|
|
|
// Image(systemName: "plus") |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} footer: { |
|
|
|
|
|
|
|
if intervalRepeatBinding != nil { |
|
|
|
|
|
|
|
HStack { |
|
|
|
|
|
|
|
Stepper("Repeat", value: intervalRepeatBinding!, in: 0...20) |
|
|
|
|
|
|
|
Text(self.intervalRepeatBinding!.wrappedValue.formatted()) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
Section(header: Text("Name for tracking the activity")) { |
|
|
|
Section(header: Text("Name for tracking the activity")) { |
|
|
|
TextField("name", text: nameBinding) |
|
|
|
TextField("name", text: nameBinding) |
|
|
|
@ -45,6 +66,10 @@ struct CountdownFormView : View { |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fileprivate func _addInterval() { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
struct CountdownFormView_Previews: PreviewProvider { |
|
|
|
struct CountdownFormView_Previews: PreviewProvider { |
|
|
|
@ -58,7 +83,8 @@ struct CountdownFormView_Previews: PreviewProvider { |
|
|
|
nameBinding: .constant(""), |
|
|
|
nameBinding: .constant(""), |
|
|
|
imageBinding: .constant(.pic3), |
|
|
|
imageBinding: .constant(.pic3), |
|
|
|
repeatCountBinding: .constant(2), |
|
|
|
repeatCountBinding: .constant(2), |
|
|
|
textFieldIsFocused: $textFieldIsFocused) |
|
|
|
textFieldIsFocused: $textFieldIsFocused, |
|
|
|
|
|
|
|
intervalRepeatBinding: .constant(2)) |
|
|
|
.environmentObject(TimerModel()) |
|
|
|
.environmentObject(TimerModel()) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|