Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/pull-requests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@ concurrency:
jobs:
build:

runs-on: macos-14
runs-on: macos-15

steps:
- name: xCode
run: sudo xcode-select -s /Applications/Xcode_16.1.app/Contents/Developer/
run: sudo xcode-select -s /Applications/Xcode_26.2.app/Contents/Developer/

- uses: actions/checkout@v4

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
8.x.x
10.x.x

- name: Install workloads
run: dotnet workload restore src/Avalonia.FuncUI.sln
Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "8.0.400",
"version": "10.0.100",
"rollForward": "minor"
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0-browser</TargetFramework>
<TargetFramework>net10.0-browser</TargetFramework>
<RuntimeIdentifier>browser-wasm</RuntimeIdentifier>
<WasmMainJSPath>wwwroot\main.js</WasmMainJSPath>
<WasmRuntimeAssetsLocation>./_framework</WasmRuntimeAssetsLocation>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ module DragDropDemo =

let doDrag (e, dragCount) =
async {
let dragData = DataObject()
dragData.Set(DataFormats.Text, $"You have dragged text %d{dragCount} times")
use dragData = new DataTransfer()
dragData.Add(DataTransferItem.Create(DataFormat.Text, $"You have dragged text %d{dragCount} times"))

let! result = Dispatcher.UIThread.InvokeAsync<DragDropEffects>
(fun _ -> DragDrop.DoDragDrop(e, dragData, DragDropEffects.Copy)) |> Async.AwaitTask
(fun _ -> DragDrop.DoDragDropAsync(e, dragData, DragDropEffects.Copy)) |> Async.AwaitTask
return match result with
| DragDropEffects.Copy -> "The text was copied"
| DragDropEffects.Link -> "The text was linked"
Expand Down Expand Up @@ -83,19 +83,19 @@ module DragDropDemo =
(TextBlock.create
[ TextBlock.text state.dropText
Control.onDrop (fun e ->
if e.Data.Contains(DataFormats.Text) then
Dropped(e.Data.GetText()) |> dispatch
elif e.Data.Contains(DataFormats.Files) then
if e.DataTransfer.Contains(DataFormat.Text) then
Dropped(e.DataTransfer.TryGetText()) |> dispatch
elif e.DataTransfer.Contains(DataFormat.File) then
Dropped
(e.Data.GetFiles()
(e.DataTransfer.TryGetFiles()
|> Seq.map (fun item -> item.Name)
|> String.concat Environment.NewLine)
|> dispatch
)
Control.onDragOver (fun e ->
e.DragEffects <-
if e.Data.Contains(DataFormats.Text)
|| e.Data.Contains(DataFormats.Files) then
if e.DataTransfer.Contains(DataFormat.Text)
|| e.DataTransfer.Contains(DataFormat.File) then
e.DragEffects
&&& (DragDropEffects.Copy ||| DragDropEffects.Link)
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ open Avalonia
open Avalonia.Controls
open Avalonia.FuncUI.DSL
open Avalonia.FuncUI.Types
open Avalonia.Input.Platform
open Avalonia.Layout
open Avalonia.Media

Expand Down
2 changes: 1 addition & 1 deletion src/Avalonia.FuncUI/Avalonia.FuncUI.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@
<Compile Include="DSL\ItemsControl.fs" />
<Compile Include="DSL\ContentControl.fs" />
<Compile Include="DSL\TransitioningContentControl.fs" />
<Compile Include="DSL\BindingEvaluator.fs" />

<Compile Include="DSL\AutoCompleteBox.fs" />
<Compile Include="DSL\NumericUpDown.fs" />
<Compile Include="DSL\Decorator.fs" />
Expand Down
11 changes: 4 additions & 7 deletions src/Avalonia.FuncUI/DSL/AutoCompleteBox.fs
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,8 @@ module AutoCompleteBox =
static member isDropDownOpen<'t when 't :> AutoCompleteBox>(value: bool) : IAttr<'t> =
AttrBuilder<'t>.CreateProperty<bool>(AutoCompleteBox.IsDropDownOpenProperty, value, ValueNone)

static member valueMemberBinding<'t when 't :> AutoCompleteBox>(binding: IBinding) : IAttr<'t> =
let name = nameof Unchecked.defaultof<'t>.ValueMemberBinding
let getter: 't -> IBinding = (fun control -> control.ValueMemberBinding)
let setter: 't * IBinding -> unit = (fun (control, value) -> control.ValueMemberBinding <- value)

AttrBuilder<'t>.CreateProperty<IBinding>(name, binding, ValueSome getter, ValueSome setter, ValueNone)
static member valueMemberBinding<'t when 't :> AutoCompleteBox>(binding: BindingBase) : IAttr<'t> =
AttrBuilder<'t>.CreateProperty<_>(AutoCompleteBox.ValueMemberBindingProperty, binding, ValueNone)

static member selectedItem<'t when 't :> AutoCompleteBox>(value: obj) : IAttr<'t> =
AttrBuilder<'t>.CreateProperty<obj>(AutoCompleteBox.SelectedItemProperty, value, ValueNone)
Expand Down Expand Up @@ -166,4 +162,5 @@ module AutoCompleteBox =
AttrBuilder<'t>.CreateProperty<IEnumerable>(AutoCompleteBox.ItemsSourceProperty, items, ValueNone)

static member asyncPopulator<'t when 't :> AutoCompleteBox>(populator: Func<string, CancellationToken, Task<seq<obj>>>) : IAttr<'t> =
AttrBuilder<'t>.CreateProperty<_>(AutoCompleteBox.AsyncPopulatorProperty, populator, ValueNone)
AttrBuilder<'t>.CreateProperty<_>(AutoCompleteBox.AsyncPopulatorProperty, populator, ValueNone)

36 changes: 0 additions & 36 deletions src/Avalonia.FuncUI/DSL/BindingEvaluator.fs

This file was deleted.

12 changes: 11 additions & 1 deletion src/Avalonia.FuncUI/DSL/Buttons/RadioButton.fs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ module RadioButton =
open Avalonia.Controls
open Avalonia.FuncUI.Types
open Avalonia.FuncUI.Builder
open Avalonia.Interactivity

let create (attrs: IAttr<RadioButton> list): IView<RadioButton> =
ViewBuilder.Create<RadioButton>(attrs)
Expand All @@ -13,4 +14,13 @@ module RadioButton =

static member groupName<'t when 't :> RadioButton>(value: string) : IAttr<'t> =
AttrBuilder<'t>.CreateProperty<string>(RadioButton.GroupNameProperty, value, ValueNone)


static member onChecked<'t when 't :> RadioButton>(func: RoutedEventArgs -> unit, ?subPatchOptions) : IAttr<'t> =

let onCheckedHandler (args: RoutedEventArgs) =
match args.Source with
| :? RadioButton as selection when selection.IsChecked.GetValueOrDefault() = true ->
func(args)
| _ -> ()

AttrBuilder<'t>.CreateSubscription<RoutedEventArgs>(RadioButton.IsCheckedChangedEvent, onCheckedHandler, ?subPatchOptions = subPatchOptions)
12 changes: 0 additions & 12 deletions src/Avalonia.FuncUI/DSL/Buttons/ToggleButton.fs
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,3 @@ module ToggleButton =

static member onIsCheckedChanged<'t when 't :> ToggleButton>(func: RoutedEventArgs -> unit, ?subPatchOptions) : IAttr<'t> =
AttrBuilder<'t>.CreateSubscription<RoutedEventArgs>(ToggleButton.IsCheckedChangedEvent, func, ?subPatchOptions = subPatchOptions)

[<Obsolete "This construct is deprecated. Use IsCheckedChangedEvent instead.">]
static member onChecked<'t when 't :> ToggleButton>(func: RoutedEventArgs -> unit, ?subPatchOptions) : IAttr<'t> =
AttrBuilder<'t>.CreateSubscription<RoutedEventArgs>(ToggleButton.CheckedEvent, func, ?subPatchOptions = subPatchOptions)

[<Obsolete "This construct is deprecated. Use IsCheckedChangedEvent instead.">]
static member onUnchecked<'t when 't :> ToggleButton>(func: RoutedEventArgs -> unit, ?subPatchOptions) : IAttr<'t> =
AttrBuilder<'t>.CreateSubscription<RoutedEventArgs>(ToggleButton.UncheckedEvent, func, ?subPatchOptions = subPatchOptions)

[<Obsolete "This construct is deprecated. Use IsCheckedChangedEvent instead.">]
static member onIndeterminate<'t when 't :> ToggleButton>(func : RoutedEventArgs -> unit, ?subPatchOptions) : IAttr<'t> =
AttrBuilder<'t>.CreateSubscription<RoutedEventArgs>(ToggleButton.IndeterminateEvent, func, ?subPatchOptions = subPatchOptions)
8 changes: 4 additions & 4 deletions src/Avalonia.FuncUI/DSL/DataGrid.fs
Original file line number Diff line number Diff line change
Expand Up @@ -105,17 +105,17 @@ module DataGridBoundColumn =

type DataGridBoundColumn with

static member binding<'t when 't :> DataGridBoundColumn>(binding: IBinding) : IAttr<'t> =
AttrBuilder<'t>.CreateProperty<IBinding>(
static member binding<'t when 't :> DataGridBoundColumn>(binding: BindingBase) : IAttr<'t> =
AttrBuilder<'t>.CreateProperty<BindingBase>(
name = "Binding",
value = binding,
getter = ValueSome (fun column -> column.Binding),
setter = ValueSome (fun (column, value) -> column.Binding <- value),
comparer = ValueNone
)

static member clipboardContentBinding<'t when 't :> DataGridBoundColumn>(binding: IBinding) : IAttr<'t> =
AttrBuilder<'t>.CreateProperty<IBinding>(
static member clipboardContentBinding<'t when 't :> DataGridBoundColumn>(binding: BindingBase) : IAttr<'t> =
AttrBuilder<'t>.CreateProperty<BindingBase>(
name = "ClipboardContentBinding",
value = binding,
getter = ValueSome (fun column -> column.ClipboardContentBinding),
Expand Down
4 changes: 2 additions & 2 deletions src/Avalonia.FuncUI/DSL/ItemsControl.fs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ module ItemsControl =

type ItemsControl with

static member displayMemberBinding<'t when 't :> ItemsControl>(value: IBinding) : IAttr<'t> =
AttrBuilder<'t>.CreateProperty<IBinding>(ItemsControl.DisplayMemberBindingProperty, value, ValueNone)
static member displayMemberBinding<'t when 't :> ItemsControl>(value: BindingBase) : IAttr<'t> =
AttrBuilder<'t>.CreateProperty<BindingBase>(ItemsControl.DisplayMemberBindingProperty, value, ValueNone)

static member viewItems<'t when 't :> ItemsControl>(views: IView list) : IAttr<'t> =
let getter : ('t -> obj) = (fun control -> control.Items :> obj)
Expand Down
5 changes: 0 additions & 5 deletions src/Avalonia.FuncUI/DSL/Primitives/Popup.fs
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,6 @@ module Popup =

static member placementRect<'t when 't :> Popup>(value: Rect option) : IAttr<'t> =
value |> Option.toNullable |> Popup.placementRect

[<Obsolete "use 'placement' instead">]
static member placementMode<'t when 't :> Popup>(value: PlacementMode) : IAttr<'t> =
AttrBuilder<'t>.CreateProperty<PlacementMode>(Popup.PlacementModeProperty, value, ValueNone)

static member placementTarget<'t when 't :> Popup>(value: Control) : IAttr<'t> =
AttrBuilder<'t>.CreateProperty<Control>(Popup.PlacementTargetProperty, value, ValueNone)

Expand Down
4 changes: 2 additions & 2 deletions src/Avalonia.FuncUI/DSL/Primitives/SelectingItemsControl.fs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ module SelectingItemsControl =
static member selectedItem<'t when 't :> SelectingItemsControl>(item: obj) : IAttr<'t> =
AttrBuilder<'t>.CreateProperty<obj>(SelectingItemsControl.SelectedItemProperty, item, ValueNone)

static member selectedValueBinding<'t when 't :> SelectingItemsControl>(binding: IBinding) : IAttr<'t> =
AttrBuilder<'t>.CreateProperty<IBinding>(SelectingItemsControl.SelectedValueBindingProperty, binding, ValueNone)
static member selectedValueBinding<'t when 't :> SelectingItemsControl>(binding: BindingBase) : IAttr<'t> =
AttrBuilder<'t>.CreateProperty<BindingBase>(SelectingItemsControl.SelectedValueBindingProperty, binding, ValueNone)

static member selectedValue<'t when 't :> SelectingItemsControl>(value: obj) : IAttr<'t> =
AttrBuilder<'t>.CreateProperty<obj>(SelectingItemsControl.SelectedValueProperty, value, ValueNone)
Expand Down
6 changes: 4 additions & 2 deletions src/Avalonia.FuncUI/DataTemplateView.fs
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,15 @@ type DataTemplateView<'data, 'childData, 'view when 'view :> IView>
(this.ViewFunc.GetType(), this.SupportsRecycling).GetHashCode()

interface ITreeDataTemplate with
member this.ItemsSelector (item: obj) : InstancedBinding =
// member this.ItemsSelector (item: obj) : InstancedBinding =
member this.BindChildren(target: AvaloniaObject, targetProperty: AvaloniaProperty, item) : IDisposable =
match this.ItemsSource with
| ValueNone -> null
| ValueSome expression ->
match item with
| :? 'data as data ->
InstancedBinding.OneTime(expression.Invoke(data))
target.SetCurrentValue(targetProperty, expression.Invoke(data))
{ new IDisposable with member this.Dispose() = () }
| _ -> null

member this.Match (data: obj) : bool =
Expand Down
3 changes: 2 additions & 1 deletion src/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<Project>
<PropertyGroup>
<AvaloniaVersion>11.3.0</AvaloniaVersion>
<AvaloniaVersion>12.0.0-preview1</AvaloniaVersion>
<AvaloniaDiagnosticsVersion>11.3.12</AvaloniaDiagnosticsVersion>
<FuncUIVersion>1.5.2</FuncUIVersion>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<ItemGroup>
<PackageReference Include="Avalonia.Desktop" Version="$(AvaloniaVersion)" />
<PackageReference Include="Avalonia.Themes.Fluent" Version="$(AvaloniaVersion)" />
<PackageReference Include="Avalonia.Diagnostics" Version="$(AvaloniaVersion)" />
<PackageReference Include="Avalonia.Diagnostics" Version="$(AvaloniaDiagnosticsVersion)" />
<PackageReference Include="VideoLAN.LibVLC.Mac" Version="3.1.3.1" />
<ProjectReference Include="..\..\..\Avalonia.FuncUI.Elmish\Avalonia.FuncUI.Elmish.fsproj" />
<ProjectReference Include="..\..\..\Avalonia.FuncUI\Avalonia.FuncUI.fsproj" />
Expand Down
3 changes: 0 additions & 3 deletions src/Examples/Elmish/Examples.Elmish.Presso/Main.fs
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
namespace Examples.Presso

open Avalonia.Controls.Shapes
open Avalonia.Media

module Main =
open Avalonia.Controls
open Avalonia.Controls.Primitives
Expand Down
4 changes: 2 additions & 2 deletions src/Examples/Examples.DataGridPlayground/Program.fs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ type Views =
DataGrid.columns [
DataGridTextColumn.create [
DataGridTextColumn.header "Name"
DataGridTextColumn.binding (Binding ("Name", BindingMode.TwoWay))
DataGridTextColumn.binding (ReflectionBinding ("Name", Mode = BindingMode.TwoWay))
DataGridTextColumn.width (DataGridLength(2, DataGridLengthUnitType.Star))
]
DataGridTemplateColumn.create [
Expand All @@ -68,7 +68,7 @@ type Views =
DataTemplateView<_>.create (fun (data: Person) ->
TextBox.create [
TextBox.init (fun t ->
t.Bind(TextBox.TextProperty, Binding("Name", BindingMode.TwoWay)) |> ignore
t.Bind(TextBox.TextProperty, ReflectionBinding("Name", Mode = BindingMode.TwoWay)) |> ignore
)
]
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<ProvisioningType>manual</ProvisioningType>
<TargetFramework>net8.0-ios</TargetFramework>
<TargetFramework>net10.0-ios</TargetFramework>
<SupportedOSPlatformVersion>13.0</SupportedOSPlatformVersion>

<!-- temporal workaround for our GL interface backend -->
Expand Down
2 changes: 2 additions & 0 deletions src/NuGet.config
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@
<configuration>
<packageSources>
<add key="NuGet official package source" value="https://api.nuget.org/v3/index.json" />
<add key="avalonia-nightly" value="https://nuget-feed-nightly.avaloniaui.net/v3/index.json" protocolVersion="3" />
<add key="avalonia-all" value="https://nuget-feed-all.avaloniaui.net/v3/index.json" protocolVersion="3" />
</packageSources>
</configuration>
Loading