@@ -12,26 +12,34 @@ module TimePickerDemo =
1212 { time: TimeSpan Nullable
1313 header: string
1414 minuteIncrement: int
15- clockIdentifier: string }
15+ clockIdentifier: string
16+ secondIncrement: int
17+ useSeconds: bool }
1618
1719 let init () =
1820 { time = Nullable( DateTime.Today.TimeOfDay)
1921 header = " Header"
2022 minuteIncrement = 1
21- clockIdentifier = " 12HourClock" }
23+ clockIdentifier = " 12HourClock"
24+ secondIncrement = 1
25+ useSeconds = false }
2226
2327 type Msg =
2428 | SetTime of TimeSpan Nullable
2529 | SetHeader of string
2630 | SetMinuteIncrement of int
2731 | SetClockIdentifier of string
32+ | SetSecondIncrement of int
33+ | SetUseSeconds of bool
2834
2935 let update ( msg : Msg ) ( state : State ) : State =
3036 match msg with
3137 | SetTime time -> { state with time = time }
3238 | SetHeader header -> { state with header = header }
3339 | SetMinuteIncrement m -> { state with minuteIncrement = m }
3440 | SetClockIdentifier ci -> { state with clockIdentifier = ci }
41+ | SetSecondIncrement s -> { state with secondIncrement = s }
42+ | SetUseSeconds b -> { state with useSeconds = b }
3543
3644 let view ( state : State ) ( dispatch ) =
3745 StackPanel.create [
@@ -44,8 +52,10 @@ module TimePickerDemo =
4452 TimePicker.create [
4553 TimePicker.clockIdentifier state.clockIdentifier
4654 TimePicker.minuteIncrement state.minuteIncrement
55+ TimePicker.secondIncrement state.secondIncrement
4756
4857 TimePicker.selectedTime state.time
58+ TimePicker.useSeconds state.useSeconds
4959
5060 TimePicker.onSelectedTimeChanged (
5161 Msg.SetTime >> dispatch
@@ -68,6 +78,22 @@ module TimePickerDemo =
6878 )
6979 ]
7080
81+ TextBlock.create [
82+ TextBlock.text " Seconds increment:"
83+ ]
84+
85+ TextBox.create [
86+ TextBox.text ( state.secondIncrement |> string)
87+ TextBox.onTextChanged ( fun txt ->
88+ match Int32.TryParse txt with
89+ | true , i ->
90+ i
91+ |> Msg.SetSecondIncrement
92+ |> dispatch
93+ | _ -> ()
94+ )
95+ ]
96+
7197 TextBox.create [
7298 TextBox.watermark " Header"
7399 TextBox.text state.header
@@ -98,6 +124,19 @@ module TimePickerDemo =
98124 >> Option.iter( Msg.SetClockIdentifier >> dispatch)
99125 )
100126 ]
127+
128+ CheckBox.create [
129+ CheckBox.content " Use Seconds"
130+ CheckBox.isChecked state.useSeconds
131+
132+ CheckBox.onIsCheckedChanged (( fun args ->
133+ state.useSeconds
134+ |> not
135+ |> Msg.SetUseSeconds
136+ |> dispatch),
137+ SubPatchOptions.OnChangeOf state
138+ )
139+ ]
101140 ]
102141 ]
103142
0 commit comments