-
-
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.
Merge pull request #195 from fsprojects/sleepyfran/chores/0.5-upgrade
Avalonia.FuncUI 0.5 release
- Loading branch information
Showing
10 changed files
with
171 additions
and
8 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
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
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
20 changes: 20 additions & 0 deletions
20
src/Examples/Component Examples/Examples.CounterApp/Examples.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,20 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net6.0</TargetFramework> | ||
<RootNamespace>Examples.Components.CounterApp</RootNamespace> | ||
<PackageId>Examples.CounterApp</PackageId> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<Compile Include="Main.fs" /> | ||
<Compile Include="Program.fs" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\..\Avalonia.FuncUI.DSL\Avalonia.FuncUI.DSL.fsproj" /> | ||
<ProjectReference Include="..\..\..\Avalonia.FuncUI\Avalonia.FuncUI.fsproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
61 changes: 61 additions & 0 deletions
61
src/Examples/Component Examples/Examples.CounterApp/Main.fs
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,61 @@ | ||
namespace Examples.CounterApp | ||
|
||
module Main = | ||
open Avalonia.Controls | ||
open Avalonia.FuncUI | ||
open Avalonia.FuncUI.DSL | ||
open Avalonia.Layout | ||
|
||
let view = | ||
Component | ||
(fun ctx -> | ||
let state = ctx.useState 0 | ||
|
||
DockPanel.create [ | ||
DockPanel.children [ | ||
Button.create [ | ||
Button.dock Dock.Bottom | ||
Button.onClick (fun _ -> state.Set 0) | ||
Button.content "reset" | ||
Button.horizontalAlignment HorizontalAlignment.Stretch | ||
] | ||
Button.create [ | ||
Button.dock Dock.Bottom | ||
Button.onClick (fun _ -> state.Current - 1 |> state.Set) | ||
Button.content "-" | ||
Button.horizontalAlignment HorizontalAlignment.Stretch | ||
] | ||
Button.create [ | ||
Button.dock Dock.Bottom | ||
Button.onClick (fun _ -> state.Current + 1 |> state.Set) | ||
Button.content "+" | ||
Button.horizontalAlignment HorizontalAlignment.Stretch | ||
] | ||
Button.create [ | ||
Button.dock Dock.Bottom | ||
Button.onClick ( | ||
(fun _ -> state.Current * 2 |> state.Set), | ||
SubPatchOptions.OnChangeOf state.Current | ||
) | ||
Button.content "x2" | ||
Button.horizontalAlignment HorizontalAlignment.Stretch | ||
] | ||
TextBox.create [ | ||
TextBox.dock Dock.Bottom | ||
TextBox.onTextChanged ( | ||
(fun text -> | ||
let isNumber, number = System.Int32.TryParse text | ||
if isNumber then number |> state.Set) | ||
) | ||
TextBox.text (string state.Current) | ||
TextBox.horizontalAlignment HorizontalAlignment.Stretch | ||
] | ||
TextBlock.create [ | ||
TextBlock.dock Dock.Top | ||
TextBlock.fontSize 48.0 | ||
TextBlock.verticalAlignment VerticalAlignment.Center | ||
TextBlock.horizontalAlignment HorizontalAlignment.Center | ||
TextBlock.text (string state.Current) | ||
] | ||
] | ||
]) |
37 changes: 37 additions & 0 deletions
37
src/Examples/Component Examples/Examples.CounterApp/Program.fs
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,37 @@ | ||
namespace Examples.CounterApp | ||
|
||
open Avalonia | ||
open Avalonia.Controls.ApplicationLifetimes | ||
open Avalonia.Themes.Fluent | ||
open Avalonia.FuncUI.Hosts | ||
|
||
type MainWindow() = | ||
inherit HostWindow() | ||
do | ||
base.Title <- "Counter Example" | ||
base.Height <- 400.0 | ||
base.Width <- 400.0 | ||
base.Content <- Main.view | ||
|
||
type App() = | ||
inherit Application() | ||
|
||
override this.Initialize() = | ||
this.Styles.Add (FluentTheme(baseUri = null, Mode = FluentThemeMode.Dark)) | ||
|
||
override this.OnFrameworkInitializationCompleted() = | ||
match this.ApplicationLifetime with | ||
| :? IClassicDesktopStyleApplicationLifetime as desktopLifetime -> | ||
let mainWindow = MainWindow() | ||
desktopLifetime.MainWindow <- mainWindow | ||
| _ -> () | ||
|
||
module Program = | ||
|
||
[<EntryPoint>] | ||
let main(args: string[]) = | ||
AppBuilder | ||
.Configure<App>() | ||
.UsePlatformDetect() | ||
.UseSkia() | ||
.StartWithClassicDesktopLifetime(args) |