Nexus-Mods / NexusMods.App

Home of the development of the Nexus Mods App
https://nexus-mods.github.io/NexusMods.App/
GNU General Public License v3.0
713 stars 44 forks source link

Spike - Implement `FlexPanel` or import a package #1451

Open erri120 opened 1 month ago

erri120 commented 1 month ago

WPF, and sadly Avalonia, are missing a very important panel type: a simple flex container.

See https://css-tricks.com/snippets/css/a-guide-to-flexbox/ for details on how this is used to style components in CSS.

halgari commented 1 month ago

Few projects in this space:

https://github.com/Athari/Alba.Avalonia.FlexPanel

https://github.com/AvaloniaUI/Avalonia.Labs/pull/45

https://github.com/HandyOrg/HandyControl

LukeNexusMods commented 1 month ago

Figma designs expects flexbox, Avalonia doesnt have this, we use long solutions to get round this. Allow us to implement new designs twice as fast. Can help with dynamic scaling.

LukeNexusMods commented 1 month ago

The investigation will be to figure out which solution we will use and then how to implement it. What is the effort involved?

Al12rs commented 6 days ago

Spike results:

Tested FlexPanel from Avalonia.Labs.

Avalonia.Labs version was chosen as the most up to date version of the third party libraries available and the most likely to get future updates and eventually be integrated into Avalonia project proper.

Cons:

Pros:

Conclusions:

We are going to use Avalonia.Labs FlexPanel going forwards.

Appendix:

Define properties for children in Styles:

    <!-- FlexPanel Styles -->
    <Style Selector="panels|FlexPanel">

        <Style Selector="^ > :is(Control)">
            <Setter Property="HorizontalAlignment" Value="Stretch" />
            <Setter Property="VerticalAlignment" Value="Stretch" />
            <Setter Property="panels:Flex.Grow" Value="1" />
        </Style>
    </Style>

It is possible to reference generic children using ^ > :is(Control). the :is() syntax is necessary because targeting Control directly would not actually work for subclasses that don't explicitly inherit the styling from Control.

Al12rs commented 6 days ago

My own opinion after using and dealing with the initial issues of FlexPanel I'm quite inclined in using it going forward. It is making the implementations of the Designs much simpler and more accurate on top of better scaling behavior in different size conditions.

The problems all seem solvable and within our control to do so.

I would go for it.

Al12rs commented 4 days ago

Do we want an ADR for this or is this enough?

halgari commented 4 days ago

An ADR would be nice, but it can mostly be a copy of the text in this ticket

On Thu, Jul 11, 2024 at 9:42 AM Al @.***> wrote:

Do we want an ADR for this or is this enough?

— Reply to this email directly, view it on GitHub https://github.com/Nexus-Mods/NexusMods.App/issues/1451#issuecomment-2223280008, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAE72HJT6OFEOY7GPASLCLDZL2RXBAVCNFSM6AAAAABILB65M6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEMRTGI4DAMBQHA . You are receiving this because you commented.Message ID: @.***>