fsprojects / Avalonia.FuncUI

Develop cross-plattform GUI Applications using F# and Avalonia!
https://funcui.avaloniaui.net/
MIT License
948 stars 74 forks source link

Avalonia.FuncUI v1.0 release #222

Closed sleepyfran closed 1 year ago

sleepyfran commented 1 year ago

Opening this issue to track the work needed before we release the non-pre-release version of v0.6

Before release

Since 4564a6d98c55e3b9e0437e4d8aecfb41bfed9b5b the DSL project lives inside of the main FuncUI package and upgrading from a previous version that has the a package reference to the DSL makes all this funky errors where half of the imports seem unused and all the controls stop working:

image

The fix is, of course, to remove the package reference to the DSL but I think we should make this clearer to the user.

After release

JaggerJo commented 1 year ago

Like the Party 🎉 part of it 😁

JaggerJo commented 1 year ago

I can deprecate the DSL package shortly before we plan to release the new version 👍

JaggerJo commented 1 year ago

I'm not happy at all with the documentation situation right now. 🙃

sleepyfran commented 1 year ago

I'm not happy at all with the documentation situation right now. 🙃

Yeah, actually I just realized that we have the GitBook under the Avalonia's domain up and working, I'll add another task here to sunset the current one we have (https://avaloniacommunity.github.io/Avalonia.FuncUI.Docs/) and add the one under Avalonia's domain to the README. What else do you think we should do to improve it? I'm all up for making the docs better, it's true that we're lacking a bit here.

JaggerJo commented 1 year ago

Yes exactly, that's a good first step! (copying our docs over) 👍

I think we have a lot of good stuff in the docs, but it could use some polishing.

Getting started: I don't think templates should be recommended that much. I personally prefer to install some packages and pasting a few lines of code. Might be just me tho.

Why? Needing templates implies complexity and for FuncUI all you really need is this (and the view could be reduced to a lot less code):

namespace Examples.CounterApp

open Avalonia
open Avalonia.Controls
open Avalonia.Controls.ApplicationLifetimes
open Avalonia.FuncUI
open Avalonia.FuncUI.DSL
open Avalonia.Layout
open Avalonia.Themes.Fluent
open Avalonia.FuncUI.Hosts

module Views =
    let counter =
        Component
            (fun ctx ->
                let state = ctx.useState 0

                DockPanel.create [
                    DockPanel.children [
                        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
                        ]
                        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)
                        ]
                    ]
                ])

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)
Numpsy commented 1 year ago

Hi,

As I mentioned in #232, it looks like version 11 of Avalonia.Web only supports .NET 7.0, so I guess that the FuncUI WebAssembly sample will need to be the same - and that would also mean that the CI builds would need changing to use the .NET 7 SDK rather than 6 - so, is that possible/acceptable? (I'm not sure if the github build pipelines have the new SDK available by default yet though)

Numpsy commented 1 year ago

fyi, the Avalonia change at https://github.com/AvaloniaUI/Avalonia/pull/9553 has removed a load of interfaces that FuncUI uses, apparently in favour of just using the base classes instead, which is an ever so slightly breaking change over here.

I had a quick go at changing the lib to just use the base clases instead of interfaces and the control catalogue seems to still run, but I didn't check anything beyond that

sleepyfran commented 1 year ago

fyi, the Avalonia change at https://github.com/AvaloniaUI/Avalonia/pull/9553 has removed a load of interfaces that FuncUI uses, apparently in favour of just using the base classes instead, which is an ever so slightly breaking change over here.

I had a quick go at changing the lib to just use the base clases instead of interfaces and the control catalogue seems to still run, but I didn't check anything beyond that

Oh, boy. Thanks for the heads up! I guess a search and replace of I.* should do the trick 😆 Adding that to the checklist

Numpsy commented 1 year ago

Small nit about the nuget packages - the package description fields shown on nuget.org are just 'Package Description' - I think it'd look nicer if there were something useful there?

image

Numpsy commented 1 year ago

On the subject of nuget packages - anyone have any opinions on adding SourceLink to the build?

JaggerJo commented 1 year ago

On the subject of nuget packages - anyone have any opinions on adding SourceLink to the build?

Great idea!

Numpsy commented 1 year ago

It looks like another breaking change has been made in Avalonia - the change at https://github.com/AvaloniaUI/Avalonia/pull/10112 has moved ItemsRepeater into a separate nuget package, which breaks the bindings in the core FuncUI library.

So - what would the preferred approach to handling that change be?

JaggerJo commented 1 year ago

Looks like we can get rid of the bindings.

Numpsy commented 1 year ago

Hmm, I went to update to the new preview10 release and Visual Studio wasn't listing it as an update, and it seems that nuget thinks that preview10 is older than preview9 :-(

image

JaggerJo commented 1 year ago

ahh, yeah :D everything after the - is string sorted. Changed the version to preview9.1

Numpsy commented 1 year ago

I see that Avalonia 11 preview 7 was released over night, with another set of breaking changes to the Items/ItemsSource properties (we can but hope that's the last ones).

I'll try to have a go with it, and see how many changes there are

JaggerJo commented 1 year ago

I see that Avalonia 11 preview 7 was released over night, with another set of breaking changes to the Items/ItemsSource properties (we can but hope that's the last ones).

I'll try to have a go with it, and see how many changes there are

Thanks for the ongoing effort, really appreciate it.

Numpsy commented 1 year ago

Avalonia 11 has finally hit a release candidate build: https://github.com/AvaloniaUI/Avalonia/discussions/11593

luojunyuan commented 1 year ago

I get exception after upgrading to rc1

Unhandled exception. System.MethodAccessException: Attempt by method 'Avalonia.FuncUI.VirtualDom.VirtualDom.updateRoot(Avalonia.Controls.IContentControl, Microsoft.FSharp.Core.FSharpOption`1<IView>, Microsoft.FSharp.Core.FSharpOption`1<IView>)' to access method 'Avalonia.Controls.IContentControl.get_Content()' failed.
   at Avalonia.FuncUI.VirtualDom.VirtualDom.updateRoot(IContentControl host, FSharpOption`1 last, FSharpOption`1 next)
Numpsy commented 1 year ago

The currently released FuncUI packages don't work with RC1 due to breaking API changes on the Avalonia side, it needs the changes in https://github.com/fsprojects/Avalonia.FuncUI/pull/308 to work

JaggerJo commented 1 year ago

Think we should use a version > 1 for the next release.

Numpsy commented 1 year ago

Is it possible to get an RC1 compatible nuget package published? (I've been hung up on updating some things because I was waiting for an RC1 compatible build of TreeDataGrid, and that just dropped)

JaggerJo commented 1 year ago

Is it possible to get an RC1 compatible nuget package published? (I've been hung up on updating some things because I was waiting for an RC1 compatible build of TreeDataGrid, and that just dropped)

Published a new version. If you'd be interested I could make you a co-maintainer. You have contributed quite a lot in the past - might make things easier.

Numpsy commented 1 year ago

Published a new version. If you'd be interested I could make you a co-maintainer. You have contributed quite a lot in the past - might make things easier.

I don't mind doing that, though I never know how much time I'll have to look at things

Numpsy commented 1 year ago

Does there need to be an updated version of the diagnostics package?

JaggerJo commented 1 year ago

Published a new version. If you'd be interested I could make you a co-maintainer. You have contributed quite a lot in the past - might make things easier.

I don't mind doing that, though I never know how much time I'll have to look at things

Sent you an invitation.

Does there need to be an updated version of the diagnostics package?

We've never even released it under the new Avalonia.FuncUI.* name. If there is demand we could definitely auto release that package with FuncUI "core" versions.

Numpsy commented 1 year ago

https://github.com/AvaloniaUI/Avalonia/discussions/12041

JaggerJo commented 1 year ago

I guess it's time to ship it 🚀

JordanMarr commented 1 year ago

Congrats on the release! You guys have been working hard. 👏