Skip to content

Commit

Permalink
Merge pull request #335 from sirdoombox/main
Browse files Browse the repository at this point in the history
Add styled buttons to dialogs, bump dependencies.
  • Loading branch information
sirdoombox authored Nov 22, 2024
2 parents 3bd45c2 + 6eb2b8e commit c6ce6b9
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ private void OpenMessageBoxStyleDialog()
.OfType(SelectedType)
.WithTitle("MessageBox style dialog.")
.WithContent("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.")
.WithActionButton("Close " + SelectedType.ToString(), _ => { }, true)
.WithActionButton("Close " + SelectedType.ToString(), _ => { }, true, "Flat", "Accent")
.Dismiss().ByClickingBackground()
.TryShow();
}
Expand Down
22 changes: 11 additions & 11 deletions SukiUI.Demo/SukiUI.Demo.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,21 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Avalonia" Version="11.2.0-beta1" />
<PackageReference Include="Avalonia" Version="11.2.1" />
<PackageReference Include="Avalonia.AvaloniaEdit" Version="11.1.0" />
<PackageReference Include="Avalonia.Controls.ColorPicker" Version="11.2.0-beta1" />
<PackageReference Include="Avalonia.Desktop" Version="11.2.0-beta1" />
<PackageReference Include="Avalonia.Fonts.Inter" Version="11.2.0-beta1" />
<PackageReference Include="Avalonia.Controls.ColorPicker" Version="11.2.1" />
<PackageReference Include="Avalonia.Desktop" Version="11.2.1" />
<PackageReference Include="Avalonia.Fonts.Inter" Version="11.2.1" />
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.2.0-beta1" />
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.2.0-beta1" />
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.2.1" />
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.2.1" />
<PackageReference Include="AvaloniaEdit.TextMate" Version="11.1.0" />
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.2" />
<PackageReference Include="Dock.Avalonia" Version="11.1.0.1" />
<PackageReference Include="Dock.Model" Version="11.1.0.1" />
<PackageReference Include="Dock.Model.Avalonia" Version="11.1.0.1" />
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.3.2" />
<PackageReference Include="Dock.Avalonia" Version="11.2.0" />
<PackageReference Include="Dock.Model" Version="11.2.0" />
<PackageReference Include="Dock.Model.Avalonia" Version="11.2.0" />
<PackageReference Include="Material.Icons.Avalonia" Version="2.1.10" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="9.0.0-preview.3.24172.9" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="9.0.0" />
<PackageReference Include="ShowMeTheXaml.Avalonia" Version="1.5.1" />
<PackageReference Include="ShowMeTheXaml.Avalonia.Generator" Version="1.5.1" />
</ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions SukiUI.Dock/SukiUI.Dock.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Dock.Avalonia" Version="11.1.0.1" />
<PackageReference Include="Dock.Model.Avalonia" Version="11.1.0.1" />
<PackageReference Include="Dock.Avalonia" Version="11.2.0" />
<PackageReference Include="Dock.Model.Avalonia" Version="11.2.0" />
</ItemGroup>

<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions SukiUI/Dialogs/FluentSukiDialogBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ public static SukiDialogBuilder ByClickingBackground(this SukiDialogBuilder.Dism
/// Any number of buttons can be added to the dialog.
/// </summary>
public static SukiDialogBuilder WithActionButton(this SukiDialogBuilder builder, object? content, Action<ISukiDialog> onClicked,
bool dismissOnClick = false)
bool dismissOnClick = false, params string[] classes)
{
builder.AddActionButton(content, onClicked, dismissOnClick);
builder.AddActionButton(content, onClicked, dismissOnClick, classes);
return builder;
}

Expand Down
15 changes: 9 additions & 6 deletions SukiUI/Dialogs/SukiDialogBuilder.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Linq;
using Avalonia.Controls;
using Avalonia.Controls.Notifications;
using SukiUI.ColorTheme;
Expand Down Expand Up @@ -57,13 +58,15 @@ public void SetCanDismissWithBackgroundClick(bool canDismissWithBackgroundClick)

public void SetOnDismissed(Action<ISukiDialog> onDismissed) => Dialog.OnDismissed = onDismissed;

public void AddActionButton(object? buttonContent, Action<ISukiDialog> onClicked, bool dismissOnClick)
public void AddActionButton(object? buttonContent, Action<ISukiDialog> onClicked, bool dismissOnClick, string[] classes)
{
var btn = new Button()
{
Content = buttonContent,
Classes = { "Flat" }
};
if(classes.Length == 0)
classes = new[] { "Flat" };

var btn = new Button { Content = buttonContent };
foreach(var @class in classes)
btn.Classes.Add(@class);

btn.Click += (_,_) =>
{
onClicked(Dialog);
Expand Down
8 changes: 4 additions & 4 deletions SukiUI/SukiUI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Avalonia" Version="11.2.0-beta1" />
<PackageReference Include="Avalonia.Skia" Version="11.2.0-beta1" />
<PackageReference Include="Avalonia" Version="11.2.1" />
<PackageReference Include="Avalonia.Skia" Version="11.2.1" />
<PackageReference Include="SkiaSharp" Version="2.88.8" />
<PackageReference Include="Avalonia.Controls.DataGrid" Version="11.2.0-beta1" />
<PackageReference Include="Avalonia.Themes.Simple" Version="11.2.0-beta1" />
<PackageReference Include="Avalonia.Controls.DataGrid" Version="11.2.1" />
<PackageReference Include="Avalonia.Themes.Simple" Version="11.2.1" />
</ItemGroup>

<ItemGroup>
Expand Down
13 changes: 13 additions & 0 deletions docs/docs/documentation/hosts/dialog.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,19 @@ public void DisplayDialog()
}
```

Buttons can also have their class or classes specified as the last optional parameter, by default the `Flat` style is used, however any one of the standard [button styles](/documentation/controls/inputs/button)

In the following example, the dialog will have the flat style button, with the accent color:

```cs
public void DisplayDialog()
{
dialogManager.CreateDialog()
.WithActionButton("Styled Button ", _ => { }, true, "Flat", "Accent")
.TryShow();
}
```

![dialogclose](https://github.com/user-attachments/assets/3d07344f-c302-400a-b2cf-88865e7713ba)

## MessageBox Style
Expand Down

0 comments on commit c6ce6b9

Please sign in to comment.