Skip to content

Introducing Dialog builder API, some minor reworks#456

Closed
appleneko2001 wants to merge 5 commits intoAvaloniaCommunity:masterfrom
appleneko2001:dialog-builder-impl
Closed

Introducing Dialog builder API, some minor reworks#456
appleneko2001 wants to merge 5 commits intoAvaloniaCommunity:masterfrom
appleneko2001:dialog-builder-impl

Conversation

@appleneko2001
Copy link
Copy Markdown
Contributor

@appleneko2001 appleneko2001 commented May 17, 2025

Closed

Due to some issues I have closed this PR. new conversations should be appear in PR #458

Details

This PR will add Dialog builder API, which allows you to create dialog control / window easily and flexible to put elements freely, and no more limited for standalone window use. You can use dialog layout whatever you want. Also, I noticed that there have missing control theme for HeaderedContentControl, and I have added my control theme implementation for it. its in PR #457

Exposed API

Warning

Those API is pretty sketchy, some of them would be questionable for further use. Please leave comments for trending about them!

  • DialogBuilder
    • SetTitle(string text)

    Set dialog content title text

    • SetTitleIcon(DialogIconKind icon)

    Set title icon with integrated coloured icon (not appending!, you can use custom control if you want do that.)

    • SetTitleIcon(Bitmap bitmap, Stretch stretch = Stretch.Uniform)

    Set title icon with bitmap object.

    • Text(string text)

    Append supporting text to dialog.

    • Control(Control control)

    Append custom control to dialog.

    • PositiveButton(object content, object returnValue, Func<bool>? shouldClose = null)

    Add a button that close dialog with positive result, also it would take higher priority (sorting)

    • NeutralButton(object content, object returnValue, Action? onClick = null)

    Add a button that won't close dialog, only providing dialog state.

    • NegativeButton(object content, object returnValue, Func<bool>? shouldClose = null)

    Add a button that close dialog with negative result, also it would lower priority (sorting)

    • Style(IStyle style)

    Add custom style to dialog for affecting decoration or visual style of controls or elements of dialog

    • Build()

    Build the dialog control with attached parameters.

    • BuildWithStateAccessor()

    Build the dialog control with attached parameters, also you will get an async accessor for access dialog state

    • BuildWindow()

    Build the standalone dialog window with attached parameters.

    • BuildAndShowDialogAsync(Window owner, CancellationToken cancellationToken = default, Action<Window>? modifier = null)

    Build a standalone window, show dialog with constantly receiving dialog state.

    • BuildAndShowAsync(Window? owner = null, CancellationToken cancellationToken = default, Action<Window>? modifier = null)

    Build a standalone window, show as window with constantly receiving dialog state.

Changes

  • Moving Avalonia.Controls.ItemsRepeater usage to Demo instead. Material.Dialog package will no more use it since I have added CompositeDataTemplate that works more easily to pick a suitable DataTemplate from a set.
  • Fix: about avaloniaUI dialog layout brokened. It was avaloniaUI issue but I have found a workaround for it. I'm not that good to submit such fix to their repository so I'll leave it here.
  • Add: ControlTheme for HeaderedContentControl PR Add missing HeaderedContentControl control theme #457

Screenshots

image
image

@appleneko2001
Copy link
Copy Markdown
Contributor Author

btw this API can be used for replacing current DialogHelper implementation and keep DialogHelper API until next major update or considering to keep it

@SKProCH
Copy link
Copy Markdown
Collaborator

SKProCH commented May 17, 2025

Can you extract HeaderedContentControl to separate PR, to merge them separately sooner?

@appleneko2001
Copy link
Copy Markdown
Contributor Author

Can you extract HeaderedContentControl to separate PR, to merge them separately sooner?

HeaderedContentControl commit have been extracted as new PR #457
I guess I need to do smth to resolve existed commits here

@appleneko2001 appleneko2001 changed the title Introducing Dialog builder API, add missing theme: HeaderedContentControl.axaml, some minor reworks Introducing Dialog builder API, some minor reworks May 17, 2025
@appleneko2001
Copy link
Copy Markdown
Contributor Author

yea im gonna rebase but github refuses
i have to create new branch and abandon current attempt

@AvaloniaCommunity AvaloniaCommunity locked as resolved and limited conversation to collaborators May 17, 2025
@appleneko2001 appleneko2001 deleted the dialog-builder-impl branch May 18, 2025 09:17
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants