Skip to content

Update Template package versions #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -328,3 +328,5 @@ ASALocalRun/

# MFractors (Xamarin productivity tool) working folder
.mfractor/

.idea/
8 changes: 4 additions & 4 deletions TemplateBundle/content/BasicTemplate/BasicTemplate.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
<ItemGroup />

<ItemGroup>
<PackageReference Include="Avalonia.Desktop" Version="0.9.11" />
<PackageReference Include="JaggerJo.Avalonia.FuncUI" Version="0.4.1" />
<PackageReference Include="JaggerJo.Avalonia.FuncUI.DSL" Version="0.4.3" />
<PackageReference Include="JaggerJo.Avalonia.FuncUI.Elmish" Version="0.4.0" />
<PackageReference Include="Avalonia.Desktop" Version="0.10.0-rc1" />
<PackageReference Include="JaggerJo.Avalonia.FuncUI" Version="0.5.0-beta" />
<PackageReference Include="JaggerJo.Avalonia.FuncUI.DSL" Version="0.5.0-beta" />
<PackageReference Include="JaggerJo.Avalonia.FuncUI.Elmish" Version="0.5.0-beta" />
</ItemGroup>

<ItemGroup>
Expand Down
17 changes: 10 additions & 7 deletions TemplateBundle/content/BasicTemplate/Counter.fs
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,29 @@ module Counter =
open Avalonia.Controls
open Avalonia.FuncUI.DSL
open Avalonia.Layout
type State = { count : int }

type State = { count: int }
let init = { count = 0 }

type Msg = Increment | Decrement | Reset
type Msg =
| Increment
| Decrement
| Reset

let update (msg: Msg) (state: State) : State =
let update (msg: Msg) (state: State): State =
match msg with
| Increment -> { state with count = state.count + 1 }
| Decrement -> { state with count = state.count - 1 }
| Reset -> init

let view (state: State) (dispatch) =
DockPanel.create [
DockPanel.children [
Button.create [
Button.dock Dock.Bottom
Button.onClick (fun _ -> dispatch Reset)
Button.content "reset"
]
]
Button.create [
Button.dock Dock.Bottom
Button.onClick (fun _ -> dispatch Decrement)
Expand All @@ -42,4 +45,4 @@ module Counter =
TextBlock.text (string state.count)
]
]
]
]
20 changes: 11 additions & 9 deletions TemplateBundle/content/BasicTemplate/Program.fs
Original file line number Diff line number Diff line change
Expand Up @@ -10,45 +10,47 @@ open Avalonia.FuncUI.Components.Hosts

type MainWindow() as this =
inherit HostWindow()

do
base.Title <- "BasicTemplate"
base.Width <- 400.0
base.Height <- 400.0

//this.VisualRoot.VisualRoot.Renderer.DrawFps <- true
//this.VisualRoot.VisualRoot.Renderer.DrawDirtyRects <- true

//-:cnd:noEmit
#if DEBUG
this.AttachDevTools(KeyGesture(Key.F12))
#endif
//+:cnd:noEmit

Elmish.Program.mkSimple (fun () -> Counter.init) Counter.update Counter.view
|> Program.withHost this
//-:cnd:noEmit
#if DEBUG
|> Program.withConsoleTrace
#endif
//+:cnd:noEmit
|> Program.run


type App() =
inherit Application()

override this.Initialize() =
this.Styles.Load "avares://Avalonia.Themes.Default/DefaultTheme.xaml"
this.Styles.Load "avares://Avalonia.Themes.Default/Accents/BaseDark.xaml"
this.Styles.Load "avares://Avalonia.Themes.Fluent/FluentDark.xaml"

override this.OnFrameworkInitializationCompleted() =
match this.ApplicationLifetime with
| :? IClassicDesktopStyleApplicationLifetime as desktopLifetime ->
desktopLifetime.MainWindow <- MainWindow()
| :? IClassicDesktopStyleApplicationLifetime as desktopLifetime -> desktopLifetime.MainWindow <- MainWindow()
| _ -> ()

module Program =

[<EntryPoint>]
let main(args: string[]) =
let main (args: string []) =
AppBuilder
.Configure<App>()
.UsePlatformDetect()
.UseSkia()
.StartWithClassicDesktopLifetime(args)
.StartWithClassicDesktopLifetime(args)
69 changes: 37 additions & 32 deletions TemplateBundle/content/FullTemplate/About.fs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ module About =
open Avalonia.FuncUI.DSL


type State =
{ noop: bool }
type State = { noop: bool }

type Links =
| AvaloniaRepository
Expand All @@ -33,9 +32,9 @@ module About =

let update (msg: Msg) (state: State) =
match msg with
| OpenUrl link ->
let url =
match link with
| OpenUrl link ->
let url =
match link with
| AvaloniaRepository -> "https://github.com/AvaloniaUI/Avalonia"
| AvaloniaAwesome -> "https://github.com/AvaloniaCommunity/awesome-avalonia"
| AvaloniaGitter -> "https://gitter.im/AvaloniaUI"
Expand All @@ -44,17 +43,21 @@ module About =
| FuncUIGitter -> "https://gitter.im/Avalonia-FuncUI"
| FuncUINetTemplates -> "https://github.com/AvaloniaCommunity/Avalonia.FuncUI.ProjectTemplates"
| FuncUISamples -> "https://github.com/AvaloniaCommunity/Avalonia.FuncUI/tree/master/src/Examples"

if RuntimeInformation.IsOSPlatform(OSPlatform.Windows) then
let start = sprintf "/c start %s" url
Process.Start(ProcessStartInfo("cmd", start)) |> ignore

Process.Start(ProcessStartInfo("cmd", start))
|> ignore
else if RuntimeInformation.IsOSPlatform(OSPlatform.Linux) then
Process.Start("xdg-open", url) |> ignore
else if RuntimeInformation.IsOSPlatform(OSPlatform.OSX) then
Process.Start("open", url) |> ignore


state, Cmd.none

let headerView (dock: Dock): IView =
let headerView (dock: Dock): IView =
StackPanel.create [
StackPanel.dock dock
StackPanel.verticalAlignment VerticalAlignment.Top
Expand All @@ -65,17 +68,17 @@ module About =
]
TextBlock.create [
TextBlock.classes [ "subtitle" ]
TextBlock.text (
"Avalonia.FuncUI is a project that provides you with an Elmish DSL for Avalonia Controls\n" +
"for you to use in an F# idiomatic way. We hope you like the project and spread the word :)\n" +
"Questions ? Reach to us on Gitter, also check the links below"
)
TextBlock.text
("Avalonia.FuncUI is a project that provides you with an Elmish DSL for Avalonia Controls\n"
+ "for you to use in an F# idiomatic way. We hope you like the project and spread the word :)\n"
+ "Questions ? Reach to us on Gitter, also check the links below")
]
]
] |> Helpers.generalize


let avaloniaLinksView (dock: Dock) (dispatch: Msg -> unit) : IView =
]
|> Helpers.generalize


let avaloniaLinksView (dock: Dock) (dispatch: Msg -> unit): IView =
StackPanel.create [
StackPanel.dock dock
StackPanel.horizontalAlignment HorizontalAlignment.Left
Expand All @@ -86,28 +89,29 @@ module About =
]
TextBlock.create [
TextBlock.classes [ "link" ]
TextBlock.onTapped(fun _ -> dispatch (OpenUrl AvaloniaRepository))
TextBlock.onTapped (fun _ -> dispatch (OpenUrl AvaloniaRepository))
TextBlock.text "Avalonia Repository"
]
TextBlock.create [
TextBlock.classes [ "link" ]
TextBlock.onTapped(fun _ -> dispatch (OpenUrl AvaloniaAwesome))
TextBlock.onTapped (fun _ -> dispatch (OpenUrl AvaloniaAwesome))
TextBlock.text "Awesome Avalonia"
]
TextBlock.create [
TextBlock.classes [ "link" ]
TextBlock.onTapped(fun _ -> dispatch (OpenUrl AvaloniaGitter))
TextBlock.onTapped (fun _ -> dispatch (OpenUrl AvaloniaGitter))
TextBlock.text "Gitter"
]
TextBlock.create [
TextBlock.classes [ "link" ]
TextBlock.onTapped(fun _ -> dispatch (OpenUrl AvaloniaCommunity))
TextBlock.onTapped (fun _ -> dispatch (OpenUrl AvaloniaCommunity))
TextBlock.text "Avalonia Community"
]
]
] |> Helpers.generalize

let avaloniaFuncUILinksView (dock: Dock) (dispatch: Msg -> unit) : IView =
]
|> Helpers.generalize

let avaloniaFuncUILinksView (dock: Dock) (dispatch: Msg -> unit): IView =
StackPanel.create [
StackPanel.dock dock
StackPanel.horizontalAlignment HorizontalAlignment.Right
Expand All @@ -118,27 +122,28 @@ module About =
]
TextBlock.create [
TextBlock.classes [ "link" ]
TextBlock.onTapped(fun _ -> dispatch (OpenUrl FuncUIRepository))
TextBlock.onTapped (fun _ -> dispatch (OpenUrl FuncUIRepository))
TextBlock.text "Avalonia.FuncUI Repository"
]
TextBlock.create [
TextBlock.classes [ "link" ]
TextBlock.onTapped(fun _ -> dispatch (OpenUrl FuncUIGitter))
TextBlock.onTapped (fun _ -> dispatch (OpenUrl FuncUIGitter))
TextBlock.text "Gitter"
]
TextBlock.create [
TextBlock.classes [ "link" ]
TextBlock.onTapped(fun _ -> dispatch (OpenUrl FuncUINetTemplates))
TextBlock.onTapped (fun _ -> dispatch (OpenUrl FuncUINetTemplates))
TextBlock.text ".Net Templates"
]
TextBlock.create [
TextBlock.classes [ "link" ]
TextBlock.onTapped(fun _ -> dispatch (OpenUrl FuncUISamples))
TextBlock.onTapped (fun _ -> dispatch (OpenUrl FuncUISamples))
TextBlock.text "Samples"
]
]
]
] |> Helpers.generalize

]
|> Helpers.generalize

let view (state: State) (dispatch: Msg -> unit) =
DockPanel.create [
DockPanel.horizontalAlignment HorizontalAlignment.Center
Expand All @@ -149,4 +154,4 @@ module About =
avaloniaLinksView Dock.Left dispatch
avaloniaFuncUILinksView Dock.Right dispatch
]
]
]
17 changes: 10 additions & 7 deletions TemplateBundle/content/FullTemplate/Counter.fs
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,21 @@ module Counter =
open Avalonia.Controls
open Avalonia.FuncUI.DSL
open Avalonia.Layout
type State = { count : int }

type State = { count: int }
let init = { count = 0 }

type Msg = Increment | Decrement | Reset
type Msg =
| Increment
| Decrement
| Reset

let update (msg: Msg) (state: State) : State =
let update (msg: Msg) (state: State): State =
match msg with
| Increment -> { state with count = state.count + 1 }
| Decrement -> { state with count = state.count - 1 }
| Reset -> init

let view (state: State) (dispatch) =
DockPanel.create [
DockPanel.children [
Expand All @@ -37,7 +40,7 @@ module Counter =
Button.create [
Button.onClick (fun _ -> dispatch Reset)
Button.content "reset"
]
]
]
]

Expand All @@ -49,4 +52,4 @@ module Counter =
TextBlock.text (string state.count)
]
]
]
]
8 changes: 4 additions & 4 deletions TemplateBundle/content/FullTemplate/FullTemplate.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Avalonia.Desktop" Version="0.9.11" />
<PackageReference Include="JaggerJo.Avalonia.FuncUI" Version="0.4.1" />
<PackageReference Include="JaggerJo.Avalonia.FuncUI.DSL" Version="0.4.3" />
<PackageReference Include="JaggerJo.Avalonia.FuncUI.Elmish" Version="0.4.0" />
<PackageReference Include="Avalonia.Desktop" Version="0.10.0-rc1" />
<PackageReference Include="JaggerJo.Avalonia.FuncUI" Version="0.5.0-beta" />
<PackageReference Include="JaggerJo.Avalonia.FuncUI.DSL" Version="0.5.0-beta" />
<PackageReference Include="JaggerJo.Avalonia.FuncUI.Elmish" Version="0.5.0-beta" />
</ItemGroup>

<ItemGroup>
Expand Down
3 changes: 2 additions & 1 deletion TemplateBundle/content/FullTemplate/Program.fs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ module Program =

[<EntryPoint>]
let main (args: string []) =
AppBuilder.Configure<App>()
AppBuilder
.Configure<App>()
.UsePlatformDetect()
.UseSkia()
.StartWithClassicDesktopLifetime(args)
Loading