Skip to content

Commit

Permalink
showcardbackground dialog property
Browse files Browse the repository at this point in the history
  • Loading branch information
kikipoulet committed Aug 23, 2024
1 parent 0038d92 commit 46c06dc
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 4 deletions.
2 changes: 2 additions & 0 deletions SukiUI.Demo/Features/Dashboard/DashboardViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ private Task Login()
private void ShowDialog()
{
_dialogManager.CreateDialog()
.ShowCardBackground(true)
.WithViewModel(dialog => new DialogViewModel(dialog))
.Dismiss().ByClickingBackground()
.TryShow();
}

Expand Down
11 changes: 8 additions & 3 deletions SukiUI/Controls/SukiDialog.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,19 @@
<Setter Property="Template">
<ControlTemplate>
<Panel>

<Border Padding="0" Margin="0,55,0,0"
ClipToBounds="True" MinWidth="450"
Background="{DynamicResource SukiCardBackground}"

CornerRadius="25">
<Panel>
<Panel Background="{DynamicResource PopupGradientBrush}" Margin="-5">

<Border IsVisible="{TemplateBinding ShowCardBackground}" CornerRadius="25" Background="{DynamicResource SukiCardBackground}">
<Panel Background="{DynamicResource PopupGradientBrush}" Margin="-5">

</Panel>
</Panel>

</Border>



Expand Down
8 changes: 8 additions & 0 deletions SukiUI/Controls/SukiDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,14 @@ public object? Icon
set => SetValue(IconProperty, value);
}

public static readonly StyledProperty<bool> ShowCardBackgroundProperty = AvaloniaProperty.Register<SukiDialog, bool>(nameof(ShowCardBackground), defaultValue: true);

public bool ShowCardBackground
{
get => GetValue(ShowCardBackgroundProperty);
set => SetValue(ShowCardBackgroundProperty, value);
}

public static readonly StyledProperty<IBrush?> IconColorProperty = AvaloniaProperty.Register<SukiDialog, IBrush?>(nameof(IconColor));

public IBrush? IconColor
Expand Down
9 changes: 9 additions & 0 deletions SukiUI/Dialogs/FluentSukiDialogBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,15 @@ public static SukiDialogBuilder WithContent(this SukiDialogBuilder builder, obje
builder.SetContent(content);
return builder;
}

/// <summary>
/// Hide Card background.
/// </summary>
public static SukiDialogBuilder ShowCardBackground(this SukiDialogBuilder builder, bool show)
{
builder.SetShowCardBackground(show);
return builder;
}

/// <summary>
/// Gives the dialog a ViewModel. If this is used, Title/Content are ignored and only the ViewModel is rendered - the View being located by the usual strategy.
Expand Down
1 change: 1 addition & 0 deletions SukiUI/Dialogs/ISukiDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public interface ISukiDialog
ObservableCollection<object> ActionButtons { get; }
Action<ISukiDialog>? OnDismissed { get; set; }
bool CanDismissWithBackgroundClick { get; set; }
bool ShowCardBackground { get; set; }
void Dismiss();
}
}
2 changes: 2 additions & 0 deletions SukiUI/Dialogs/SukiDialogBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ public SukiDialogBuilder(ISukiDialogManager manager)

public void SetTitle(string title) => Dialog.Title = title;

public void SetShowCardBackground(bool show) => Dialog.ShowCardBackground = show;

public void SetContent(object content) => Dialog.Content = content;

public void SetViewModel(Func<ISukiDialog,object> viewModel)
Expand Down
2 changes: 1 addition & 1 deletion SukiUI/SukiUI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<LangVersion>10</LangVersion>
<UserSecretsId>712f85e4-12d3-41b0-a417-5714a113666f</UserSecretsId>
<Description>https://github.com/kikipoulet/SukiUI</Description>
<PackageVersion>6.0.0-beta7</PackageVersion>
<PackageVersion>6.0.0-beta8</PackageVersion>
<Nullable>enable</Nullable>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<PackageIcon>OIG.N5o-removebg-preview.png</PackageIcon>
Expand Down

0 comments on commit 46c06dc

Please sign in to comment.