-
-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(marked as experimental) Adds `StaticComponent` Adds `IReadabble.ImmediateObservable` and `IReadabble.ImmediateObservableAny` Adds `IAvaloniaObject.Bind` Adds `IAvaliniaObject.init` / Init function attribute --------- Co-authored-by: JaggerJo <ail@jaggerjo.com>
- Loading branch information
Showing
12 changed files
with
290 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation"> | ||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Adorner/@EntryIndexedValue">True</s:Boolean> | ||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Avalonia/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary> | ||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Avalonia/@EntryIndexedValue">True</s:Boolean> | ||
<s:Boolean x:Key="/Default/UserDictionary/Words/=seealso/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
namespace Avalonia.FuncUI | ||
|
||
open Avalonia | ||
open Avalonia.Controls | ||
open Avalonia.FuncUI.Types | ||
open Avalonia.Styling | ||
|
||
[<AbstractClass>] | ||
[<Experimental "Statically construct views with F#">] | ||
type StaticComponent () = | ||
inherit Border () | ||
|
||
override this.OnInitialized () = | ||
base.OnInitialized () | ||
|
||
this.DataContext <- this | ||
this.Child <- | ||
() | ||
|> this.Build | ||
|> VirtualDom.VirtualDom.create | ||
|
||
abstract member Build: unit -> IView | ||
|
||
interface IStyleable with | ||
member this.StyleKey = typeof<Border> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
namespace Avalonia.FuncUI.DSL | ||
|
||
open Avalonia | ||
open Avalonia.FuncUI | ||
open Avalonia.FuncUI.Types | ||
|
||
[<AutoOpen>] | ||
module AvaloniaObject = | ||
|
||
type IAvaloniaObject with | ||
|
||
/// <summary> | ||
/// Hook into the controls lifetime. This is called when the backing avalonia control is created. | ||
/// <example> | ||
/// <code> | ||
/// TextBlock.create [ | ||
/// TextBlock.init (fun textBlock -> | ||
/// textBlock.Bind(TextBlock.TextProperty, counter.Map string) | ||
/// textBlock.Bind(TextBlock.ForegroundProperty, counter.Map (fun c -> | ||
/// if c < 0 | ||
/// then Brushes.Red :> IBrush | ||
/// else Brushes.Green :> IBrush | ||
/// )) | ||
/// ) | ||
/// ] | ||
/// </code> | ||
/// </example> | ||
/// </summary> | ||
static member init<'t when 't :> AvaloniaObject>(func: 't -> unit) : IAttr<'t> = | ||
Attr.InitFunction { | ||
InitFunction.Function = (fun (control: obj) -> func (control :?> 't)) | ||
} | ||
|
||
member this.Bind(prop: DirectPropertyBase<'value>, readable: #IReadable<'value>) : unit = | ||
let _ = this.Bind(property = prop, source = readable.ImmediateObservable) | ||
() | ||
|
||
member this.Bind(prop: StyledPropertyBase<'value>, readable: #IReadable<'value>) : unit = | ||
let _ = this.Bind(property = prop, source = readable.ImmediateObservable) | ||
() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
...ples/Examples.ViewModelComponent.CounterApp/Examples.ViewModelComponent.CounterApp.fsproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net6.0</TargetFramework> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<Compile Include="Program.fs"/> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Avalonia.Desktop" Version="$(AvaloniaVersion)" /> | ||
<PackageReference Include="Avalonia.Themes.Fluent" Version="$(AvaloniaVersion)" /> | ||
<ProjectReference Include="..\..\..\Avalonia.FuncUI\Avalonia.FuncUI.fsproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
Oops, something went wrong.