Skip to content

Commit

Permalink
Update to use Fabulous 3.0.0-pre19
Browse files Browse the repository at this point in the history
  • Loading branch information
TimLariviere committed Jan 16, 2025
1 parent fdc1fa5 commit e03076d
Show file tree
Hide file tree
Showing 39 changed files with 207 additions and 224 deletions.
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<DisableImplicitSystemValueTupleReference>true</DisableImplicitSystemValueTupleReference>
<ProduceReferenceAssembly>true</ProduceReferenceAssembly>
<AvaloniaVersion>11.2.2</AvaloniaVersion>
<FabulousVersion>3.0.0-pre17</FabulousVersion>
<FabulousVersion>3.0.0-pre19</FabulousVersion>
</PropertyGroup>

<!-- Shared NuGet Package info -->
Expand Down
12 changes: 6 additions & 6 deletions extensions/Fabulous.Avalonia.DataGrid/DataGridCheckBoxColumn.fs
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ module DataGridCheckBoxColumnBuilders =
DataGridCheckBoxColumn.WidgetKey,
AttributesBundle(
StackList.one(DataGridBoundColumn.Binding.WithValue(binding)),
ValueSome [| DataGridColumn.HeaderWidget.WithValue(header.Compile()) |],
ValueNone,
ValueNone
[| DataGridColumn.HeaderWidget.WithValue(header.Compile()) |],
[||],
[||]
)
)

Expand All @@ -62,9 +62,9 @@ module DataGridCheckBoxColumnBuilders =
DataGridCheckBoxColumn.WidgetKey,
AttributesBundle(
StackList.one(DataGridBoundColumn.Binding.WithValue(Binding(binding))),
ValueSome [| DataGridColumn.HeaderWidget.WithValue(header.Compile()) |],
ValueNone,
ValueNone
[| DataGridColumn.HeaderWidget.WithValue(header.Compile()) |],
[||],
[||]
)
)

Expand Down
12 changes: 6 additions & 6 deletions extensions/Fabulous.Avalonia.DataGrid/DataGridTextColumn.fs
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ module DataGridTextColumnBuilders =
DataGridTextColumn.WidgetKey,
AttributesBundle(
StackList.one(DataGridBoundColumn.Binding.WithValue(binding)),
ValueSome [| DataGridColumn.HeaderWidget.WithValue(header.Compile()) |],
ValueNone,
ValueNone
[| DataGridColumn.HeaderWidget.WithValue(header.Compile()) |],
[||],
[||]
)
)

Expand All @@ -81,9 +81,9 @@ module DataGridTextColumnBuilders =
DataGridTextColumn.WidgetKey,
AttributesBundle(
StackList.one(DataGridBoundColumn.Binding.WithValue(Binding(binding))),
ValueSome [| DataGridColumn.HeaderWidget.WithValue(header.Compile()) |],
ValueNone,
ValueNone
[| DataGridColumn.HeaderWidget.WithValue(header.Compile()) |],
[||],
[||]
)
)

Expand Down
64 changes: 30 additions & 34 deletions src/Fabulous.Avalonia.Tests/ViewHelperTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@ type ViewHelpers() =

let prev: Widget =
{ Key = widgetKey
ScalarAttributes = ValueNone
WidgetAttributes = ValueNone
WidgetCollectionAttributes = ValueNone
EnvironmentAttributes = ValueNone }
ScalarAttributes = [||]
WidgetAttributes = [||]
WidgetCollectionAttributes = [||]
EnvironmentAttributes = [||] }

let curr: Widget =
{ Key = widgetKey
ScalarAttributes = ValueNone
WidgetAttributes = ValueNone
WidgetCollectionAttributes = ValueNone
EnvironmentAttributes = ValueNone }
ScalarAttributes = [||]
WidgetAttributes = [||]
WidgetCollectionAttributes = [||]
EnvironmentAttributes = [||] }

let actual = ViewHelpers.canReuseView prev curr

Expand All @@ -39,23 +39,21 @@ type ViewHelpers() =
let prev =
{ Key = TextBlock.WidgetKey
ScalarAttributes =
ValueSome
[| { Key = TextBlock.Text.Key
Value = text
NumericValue = 0uL } |]
WidgetAttributes = ValueNone
WidgetCollectionAttributes = ValueNone
EnvironmentAttributes = ValueNone }
[| { Key = TextBlock.Text.Key
Value = text
NumericValue = 0uL } |]
WidgetAttributes = [||]
WidgetCollectionAttributes = [||]
EnvironmentAttributes = [||] }

let curr =
{ Key = TextBlock.WidgetKey
ScalarAttributes = ValueNone
WidgetAttributes = ValueNone
ScalarAttributes = [||]
WidgetAttributes = [||]
WidgetCollectionAttributes =
ValueSome
[| { Key = TextBlock.Inlines.Key
Value = ArraySlice.emptyWithNull() } |]
EnvironmentAttributes = ValueNone }
[| { Key = TextBlock.Inlines.Key
Value = ArraySlice.emptyWithNull() } |]
EnvironmentAttributes = [||] }

let actual = ViewHelpers.canReuseView prev curr

Expand All @@ -68,24 +66,22 @@ type ViewHelpers() =
Prop.forAll arb (fun text ->
let prev =
{ Key = TextBlock.WidgetKey
ScalarAttributes = ValueNone
WidgetAttributes = ValueNone
ScalarAttributes = [||]
WidgetAttributes = [||]
WidgetCollectionAttributes =
ValueSome
[| { Key = TextBlock.Inlines.Key
Value = ArraySlice.emptyWithNull() } |]
EnvironmentAttributes = ValueNone }
[| { Key = TextBlock.Inlines.Key
Value = ArraySlice.emptyWithNull() } |]
EnvironmentAttributes = [||] }

let curr =
{ Key = TextBlock.WidgetKey
ScalarAttributes =
ValueSome
[| { Key = TextBlock.Text.Key
Value = text
NumericValue = 0uL } |]
WidgetAttributes = ValueNone
WidgetCollectionAttributes = ValueNone
EnvironmentAttributes = ValueNone }
[| { Key = TextBlock.Text.Key
Value = text
NumericValue = 0uL } |]
WidgetAttributes = [||]
WidgetCollectionAttributes = [||]
EnvironmentAttributes = [||] }

let actual = ViewHelpers.canReuseView prev curr

Expand Down
2 changes: 1 addition & 1 deletion src/Fabulous.Avalonia/Fabulous.Avalonia.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@
<Compile Include="Views\Imaging\TrayIcon.Mvu.fs" />
<Compile Include="Views\Imaging\TrayIcon.Components.fs" />
<Compile Include="Views\Imaging\PathIcon.fs" />
<Compile Include="Views\Layouts\SliptView.fs" />
<Compile Include="Views\Layouts\SplitView.fs" />
<Compile Include="Views\Layouts\SliptView.Mvu.fs" />
<Compile Include="Views\Layouts\SliptView.Components.fs" />
<Compile Include="Views\Layouts\ScrollViewer.fs" />
Expand Down
18 changes: 6 additions & 12 deletions src/Fabulous.Avalonia/Program.fs
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,14 @@ open Fabulous.WidgetCollectionAttributeDefinitions

module ViewHelpers =
let private tryGetScalarValue (widget: Widget) (def: SimpleScalarAttributeDefinition<'data>) =
match widget.ScalarAttributes with
| ValueNone -> ValueNone
| ValueSome scalarAttrs ->
match Array.tryFind (fun (attr: ScalarAttribute) -> attr.Key = def.Key) scalarAttrs with
| None -> ValueNone
| Some attr -> ValueSome(unbox<'data> attr.Value)
match Array.tryFind (fun (attr: ScalarAttribute) -> attr.Key = def.Key) widget.ScalarAttributes with
| None -> ValueNone
| Some attr -> ValueSome(unbox<'data> attr.Value)

let private tryGetWidgetCollectionValue (widget: Widget) (def: WidgetCollectionAttributeDefinition) =
match widget.WidgetCollectionAttributes with
| ValueNone -> ValueNone
| ValueSome collectionAttrs ->
match Array.tryFind (fun (attr: WidgetCollectionAttribute) -> attr.Key = def.Key) collectionAttrs with
| None -> ValueNone
| Some attr -> ValueSome attr.Value
match Array.tryFind (fun (attr: WidgetCollectionAttribute) -> attr.Key = def.Key) widget.WidgetCollectionAttributes with
| None -> ValueNone
| Some attr -> ValueSome attr.Value

/// Extend the canReuseView function to check AvaloniaUI specific constraints
let rec canReuseView (prev: Widget) (curr: Widget) =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ module ComponentButtonBuilders =
Button.WidgetKey,
AttributesBundle(
StackList.one(ComponentButton.Clicked.WithValue(fn)),
ValueSome [| ContentControl.ContentWidget.WithValue(content.Compile()) |],
ValueNone,
ValueNone
[| ContentControl.ContentWidget.WithValue(content.Compile()) |],
[||],
[||]
)
)
6 changes: 3 additions & 3 deletions src/Fabulous.Avalonia/Views/Controls/Buttons/Button.Mvu.fs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ module MvuButtonBuilders =
Button.WidgetKey,
AttributesBundle(
StackList.one(MvuButton.Clicked.WithValue(fun _ -> fn)),
ValueSome [| ContentControl.ContentWidget.WithValue(content.Compile()) |],
ValueNone,
ValueNone
[| ContentControl.ContentWidget.WithValue(content.Compile()) |],
[||],
[||]
)
)
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ module ComponentDropDownButtonBuilders =
DropDownButton.WidgetKey,
AttributesBundle(
StackList.one(ComponentButton.Clicked.WithValue(msg)),
ValueSome [| ContentControl.ContentWidget.WithValue(content.Compile()) |],
ValueNone,
ValueNone
[| ContentControl.ContentWidget.WithValue(content.Compile()) |],
[||],
[||]
)
)
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ module MvuDropDownButtonBuilders =
DropDownButton.WidgetKey,
AttributesBundle(
StackList.one(MvuButton.Clicked.WithValue(fn)),
ValueSome [| ContentControl.ContentWidget.WithValue(content.Compile()) |],
ValueNone,
ValueNone
[| ContentControl.ContentWidget.WithValue(content.Compile()) |],
[||],
[||]
)
)
12 changes: 6 additions & 6 deletions src/Fabulous.Avalonia/Views/Controls/Buttons/HyperlinkButton.fs
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ module HyperlinkButtonBuilders =
HyperlinkButton.WidgetKey,
AttributesBundle(
StackList.one(HyperlinkButton.NavigateUri.WithValue(uri)),
ValueSome [| ContentControl.ContentWidget.WithValue(content.Compile()) |],
ValueNone,
ValueNone
[| ContentControl.ContentWidget.WithValue(content.Compile()) |],
[||],
[||]
)
)

Expand All @@ -64,9 +64,9 @@ module HyperlinkButtonBuilders =
HyperlinkButton.WidgetKey,
AttributesBundle(
StackList.one(HyperlinkButton.NavigateUri.WithValue(Uri(uri))),
ValueSome [| ContentControl.ContentWidget.WithValue(content.Compile()) |],
ValueNone,
ValueNone
[| ContentControl.ContentWidget.WithValue(content.Compile()) |],
[||],
[||]
)
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ module RadioButtonBuilders =
RadioButton.WidgetKey,
AttributesBundle(
StackList.one(ComponentToggleButton.CheckedChanged.WithValue(ComponentValueEventData.create isChecked fn)),
ValueSome [| ContentControl.ContentWidget.WithValue(content.Compile()) |],
ValueNone,
ValueNone
[| ContentControl.ContentWidget.WithValue(content.Compile()) |],
[||],
[||]
)
)

Expand All @@ -62,8 +62,8 @@ module RadioButtonBuilders =
),
ToggleButton.IsThreeState.WithValue(true)
),
ValueSome [| ContentControl.ContentWidget.WithValue(content.Compile()) |],
ValueNone,
ValueNone
[| ContentControl.ContentWidget.WithValue(content.Compile()) |],
[||],
[||]
)
)
12 changes: 6 additions & 6 deletions src/Fabulous.Avalonia/Views/Controls/Buttons/RadioButton.Mvu.fs
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ module MvuRadioButtonBuilders =
RadioButton.WidgetKey,
AttributesBundle(
StackList.one(MvuToggleButton.CheckedChanged.WithValue(ValueEventData.create isChecked fn)),
ValueSome [| ContentControl.ContentWidget.WithValue(content.Compile()) |],
ValueNone,
ValueNone
[| ContentControl.ContentWidget.WithValue(content.Compile()) |],
[||],
[||]
)
)

Expand All @@ -60,8 +60,8 @@ module MvuRadioButtonBuilders =
),
ToggleButton.IsThreeState.WithValue(true)
),
ValueSome [| ContentControl.ContentWidget.WithValue(content.Compile()) |],
ValueNone,
ValueNone
[| ContentControl.ContentWidget.WithValue(content.Compile()) |],
[||],
[||]
)
)
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ module ComponentRepeatButtonBuilders =
RepeatButton.WidgetKey,
AttributesBundle(
StackList.one(ComponentButton.Clicked.WithValue(fn)),
ValueSome [| ContentControl.ContentWidget.WithValue(content.Compile()) |],
ValueNone,
ValueNone
[| ContentControl.ContentWidget.WithValue(content.Compile()) |],
[||],
[||]
)
)
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ module MvuRepeatButtonBuilders =
RepeatButton.WidgetKey,
AttributesBundle(
StackList.one(MvuButton.Clicked.WithValue(fn)),
ValueSome [| ContentControl.ContentWidget.WithValue(content.Compile()) |],
ValueNone,
ValueNone
[| ContentControl.ContentWidget.WithValue(content.Compile()) |],
[||],
[||]
)
)
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ module ComponentSplitButtonBuilders =
SplitButton.WidgetKey,
AttributesBundle(
StackList.one(ComponentSplitButton.Clicked.WithValue(fn)),
ValueSome [| ContentControl.ContentWidget.WithValue(content.Compile()) |],
ValueNone,
ValueNone
[| ContentControl.ContentWidget.WithValue(content.Compile()) |],
[||],
[||]
)
)
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ module MvuSplitButtonBuilders =
SplitButton.WidgetKey,
AttributesBundle(
StackList.one(MvuSplitButton.Clicked.WithValue(fn)),
ValueSome [| ContentControl.ContentWidget.WithValue(content.Compile()) |],
ValueNone,
ValueNone
[| ContentControl.ContentWidget.WithValue(content.Compile()) |],
[||],
[||]
)
)
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ module ComponentToggleButtonBuilders =
ToggleButton.WidgetKey,
AttributesBundle(
StackList.one(ComponentToggleButton.CheckedChanged.WithValue(ComponentValueEventData.create isChecked fn)),
ValueSome [| ContentControl.ContentWidget.WithValue(content.Compile()) |],
ValueNone,
ValueNone
[| ContentControl.ContentWidget.WithValue(content.Compile()) |],
[||],
[||]
)
)

Expand All @@ -72,8 +72,8 @@ module ComponentToggleButtonBuilders =
),
ToggleButton.IsThreeState.WithValue(true)
),
ValueSome [| ContentControl.ContentWidget.WithValue(content.Compile()) |],
ValueNone,
ValueNone
[| ContentControl.ContentWidget.WithValue(content.Compile()) |],
[||],
[||]
)
)
Loading

0 comments on commit e03076d

Please sign in to comment.