Skip to content

Commit f08da08

Browse files
authored
Merge pull request #485 from Numpsy/avalonia11_2
Update Avalonia to 11.2
2 parents 3f55879 + e187f80 commit f08da08

File tree

4 files changed

+56
-3
lines changed

4 files changed

+56
-3
lines changed

src/Avalonia.FuncUI.ControlCatalog/Avalonia.FuncUI.ControlCatalog/Views/Tabs/TimePickerDemo.fs

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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

src/Avalonia.FuncUI/DSL/TimePicker.fs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,15 @@ module TimePicker =
1717

1818
static member minuteIncrement<'t when 't :> TimePicker>(value: int) : IAttr<'t> =
1919
AttrBuilder<'t>.CreateProperty<int>(TimePicker.MinuteIncrementProperty, value, ValueNone)
20+
21+
static member secondIncrement<'t when 't :> TimePicker>(value: int) : IAttr<'t> =
22+
AttrBuilder<'t>.CreateProperty<int>(TimePicker.SecondIncrementProperty, value, ValueNone)
2023

2124
static member selectedTime<'t when 't :> TimePicker>(value: Nullable<TimeSpan>) : IAttr<'t> =
2225
AttrBuilder<'t>.CreateProperty<TimeSpan Nullable>(TimePicker.SelectedTimeProperty, value, ValueNone)
2326

2427
static member onSelectedTimeChanged<'t when 't :> TimePicker>(func: Nullable<TimeSpan> -> unit, ?subPatchOptions) : IAttr<'t> =
2528
AttrBuilder<'t>.CreateSubscription<TimeSpan Nullable>(TimePicker.SelectedTimeProperty, func, ?subPatchOptions = subPatchOptions)
29+
30+
static member useSeconds<'t when 't :> TimePicker>(value: bool) : IAttr<'t> =
31+
AttrBuilder<'t>.CreateProperty<bool>(TimePicker.UseSecondsProperty, value, ValueNone)

src/Avalonia.FuncUI/DSL/TimePickerPresenter.fs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,18 @@ module TimePickerPresenter =
1616
static member minuteIncrement<'t when 't :> TimePickerPresenter>(value: int) : IAttr<'t> =
1717
AttrBuilder<'t>.CreateProperty<int>(TimePickerPresenter.MinuteIncrementProperty, value, ValueNone)
1818

19+
/// Gets or sets the second increment in the selector
20+
static member secondIncrement<'t when 't :> TimePickerPresenter>(value: int) : IAttr<'t> =
21+
AttrBuilder<'t>.CreateProperty<int>(TimePickerPresenter.SecondIncrementProperty, value, ValueNone)
22+
1923
/// Gets or sets the current clock identifier, either 12HourClock or 24HourClock
2024
static member clockIdentifier<'t when 't :> TimePickerPresenter>(value: string) : IAttr<'t> =
2125
AttrBuilder<'t>.CreateProperty<string>(TimePickerPresenter.ClockIdentifierProperty, value, ValueNone)
2226

2327
/// Gets or sets the current time
2428
static member time<'t when 't :> TimePickerPresenter>(value: TimeSpan) : IAttr<'t> =
2529
AttrBuilder<'t>.CreateProperty<TimeSpan>(TimePickerPresenter.TimeProperty, value, ValueNone)
30+
31+
/// Gets or sets a value indicating whether seconds are displayed in the picker or not
32+
static member useSeconds<'t when 't :> TimePickerPresenter>(value: bool) : IAttr<'t> =
33+
AttrBuilder<'t>.CreateProperty<bool>(TimePickerPresenter.UseSecondsProperty, value, ValueNone)

src/Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project>
22
<PropertyGroup>
3-
<AvaloniaVersion>11.1.0</AvaloniaVersion>
3+
<AvaloniaVersion>11.2.0</AvaloniaVersion>
44
<FuncUIVersion>1.5.2</FuncUIVersion>
55
</PropertyGroup>
66

0 commit comments

Comments
 (0)