feat: improve icon and theme.
This commit is contained in:
@@ -1,49 +1,131 @@
|
||||
<ResourceDictionary xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:u="https://irihi.tech/ursa">
|
||||
xmlns:u="https://irihi.tech/ursa"
|
||||
xmlns:helpers="clr-namespace:Irihi.Avalonia.Shared.Helpers;assembly=Irihi.Avalonia.Shared">
|
||||
<!-- Add Resources Here -->
|
||||
<ControlTheme x:Key="{x:Type u:PopConfirm}" TargetType="u:PopConfirm">
|
||||
<ControlTheme x:Key="{x:Type u:PopConfirm}"
|
||||
TargetType="u:PopConfirm">
|
||||
<Setter Property="Placement" Value="TopEdgeAlignedLeft" />
|
||||
<Setter Property="Template">
|
||||
<ControlTemplate TargetType="u:PopConfirm">
|
||||
<Panel>
|
||||
<ContentPresenter
|
||||
Name="PART_ContentPresenter"
|
||||
Content="{TemplateBinding Content}"
|
||||
<ContentPresenter
|
||||
Name="PART_ContentPresenter"
|
||||
Content="{TemplateBinding Content}"
|
||||
ContentTemplate="{TemplateBinding ContentTemplate}" />
|
||||
<Popup
|
||||
IsLightDismissEnabled="True"
|
||||
IsOpen="{Binding IsDropdownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
|
||||
OverlayInputPassThroughElement="{Binding #PART_ContentPresenter}"
|
||||
Name="{x:Static u:PopConfirm.PART_Popup}"
|
||||
Placement="{TemplateBinding Placement}" >
|
||||
<Border Theme="{DynamicResource CardBorder}">
|
||||
<StackPanel>
|
||||
<ContentPresenter
|
||||
Content="{TemplateBinding PopupHeader}"
|
||||
ContentTemplate="{TemplateBinding PopupHeaderTemplate}"/>
|
||||
<ContentPresenter
|
||||
Content="{TemplateBinding PopupContent}"
|
||||
ContentTemplate="{TemplateBinding PopupContentTemplate}"/>
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
|
||||
<Button
|
||||
Placement="{TemplateBinding Placement}">
|
||||
<Border
|
||||
Theme="{DynamicResource CardBorder}"
|
||||
MinHeight="160"
|
||||
MinWidth="280">
|
||||
<Grid
|
||||
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
|
||||
RowDefinitions="*, Auto"
|
||||
ColumnDefinitions="Auto, *">
|
||||
<!-- Icon Area -->
|
||||
<Panel
|
||||
Grid.Column="0"
|
||||
Margin="{DynamicResource BannerIconMargin}"
|
||||
VerticalAlignment="Top">
|
||||
<ContentPresenter
|
||||
Content="{TemplateBinding Icon}" />
|
||||
<PathIcon
|
||||
Name="PART_BuildInIcon"
|
||||
Theme="{DynamicResource InnerPathIcon}"
|
||||
Data="{DynamicResource BannerWarningIconGeometry}"
|
||||
Foreground="{DynamicResource BannerWarningBorderBrush}"
|
||||
Classes="Large"
|
||||
IsVisible="{TemplateBinding Icon, Converter={x:Static ObjectConverters.IsNull}}" />
|
||||
</Panel>
|
||||
<StackPanel Grid.Row="0"
|
||||
Grid.Column="1"
|
||||
Spacing="2">
|
||||
<ContentPresenter
|
||||
Content="{TemplateBinding PopupHeader}"
|
||||
ContentTemplate="{TemplateBinding PopupHeaderTemplate}"
|
||||
TextTrimming="CharacterEllipsis"
|
||||
TextElement.FontSize="{DynamicResource BannerTitleFontSize}"
|
||||
TextElement.FontWeight="{DynamicResource TextBlockTitleFontWeight}" />
|
||||
<ContentPresenter
|
||||
Content="{TemplateBinding PopupContent}"
|
||||
ContentTemplate="{TemplateBinding PopupContentTemplate}"
|
||||
TextWrapping="Wrap" />
|
||||
</StackPanel>
|
||||
<StackPanel Grid.Row="1"
|
||||
Grid.Column="0"
|
||||
Margin="0 8 0 0"
|
||||
Grid.ColumnSpan="2"
|
||||
Orientation="Horizontal"
|
||||
HorizontalAlignment="Right">
|
||||
<Button
|
||||
Name="{x:Static u:PopConfirm.PART_CancelButton}"
|
||||
Margin="0 0 8 0"
|
||||
Content="{DynamicResource STRING_MENU_DIALOG_CANCEL}"
|
||||
Command="{TemplateBinding CancelCommand}"
|
||||
CommandParameter="{TemplateBinding CancelCommandParameter}"/>
|
||||
<Button
|
||||
Content="{DynamicResource STRING_MENU_DIALOG_CANCEL}"
|
||||
Command="{TemplateBinding CancelCommand}"
|
||||
CommandParameter="{TemplateBinding CancelCommandParameter}" />
|
||||
<Button
|
||||
Name="{x:Static u:PopConfirm.PART_ConfirmButton}"
|
||||
Theme="{DynamicResource SolidButton}"
|
||||
Content="{DynamicResource STRING_MENU_DIALOG_OK}"
|
||||
Command="{TemplateBinding ConfirmCommand}"
|
||||
CommandParameter="{TemplateBinding ConfirmCommandParameter}"/>
|
||||
|
||||
Content="{DynamicResource STRING_MENU_DIALOG_OK}"
|
||||
Command="{TemplateBinding ConfirmCommand}"
|
||||
CommandParameter="{TemplateBinding ConfirmCommandParameter}" />
|
||||
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Border>
|
||||
</Popup>
|
||||
</Panel>
|
||||
</ControlTemplate>
|
||||
</Setter>
|
||||
|
||||
<Style Selector="^ /template/ Button#PART_CancelButton">
|
||||
<Setter Property="helpers:ClassHelper.Classes" Value="Tertiary" />
|
||||
</Style>
|
||||
|
||||
<Style Selector="^ /template/ Button#PART_ConfirmButton">
|
||||
<Setter Property="helpers:ClassHelper.Classes" Value="Primary" />
|
||||
</Style>
|
||||
|
||||
<Style Selector="^.Information">
|
||||
<Style
|
||||
Selector="^ /template/ PathIcon#PART_BuildInIcon">
|
||||
<Setter Property="Data"
|
||||
Value="{DynamicResource BannerInformationIconGeometry}" />
|
||||
<Setter Property="Foreground"
|
||||
Value="{DynamicResource BannerInformationBorderBrush}" />
|
||||
</Style>
|
||||
</Style>
|
||||
<Style Selector="^.Success">
|
||||
<Style
|
||||
Selector="^ /template/ PathIcon#PART_BuildInIcon">
|
||||
<Setter Property="Data"
|
||||
Value="{DynamicResource BannerSuccessIconGeometry}" />
|
||||
<Setter Property="Foreground"
|
||||
Value="{DynamicResource BannerSuccessBorderBrush}" />
|
||||
</Style>
|
||||
</Style>
|
||||
<Style Selector="^.Warning">
|
||||
<Style
|
||||
Selector="^ /template/ PathIcon#PART_BuildInIcon">
|
||||
<Setter Property="Data"
|
||||
Value="{DynamicResource BannerWarningIconGeometry}" />
|
||||
<Setter Property="Foreground"
|
||||
Value="{DynamicResource BannerWarningBorderBrush}" />
|
||||
</Style>
|
||||
</Style>
|
||||
<Style Selector="^.Error">
|
||||
<Style
|
||||
Selector="^ /template/ PathIcon#PART_BuildInIcon">
|
||||
<Setter Property="Data"
|
||||
Value="{DynamicResource BannerErrorIconGeometry}" />
|
||||
<Setter Property="Foreground"
|
||||
Value="{DynamicResource BannerErrorBorderBrush}" />
|
||||
</Style>
|
||||
</Style>
|
||||
</ControlTheme>
|
||||
</ResourceDictionary>
|
||||
</ResourceDictionary>
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Windows.Input;
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
@@ -13,13 +14,14 @@ using Irihi.Avalonia.Shared.Helpers;
|
||||
|
||||
namespace Ursa.Controls;
|
||||
|
||||
[PseudoClasses(PC_DropdownOpen)]
|
||||
[PseudoClasses(PC_DropdownOpen, PC_Icon)]
|
||||
public class PopConfirm : ContentControl
|
||||
{
|
||||
public const string PART_ConfirmButton = "PART_ConfirmButton";
|
||||
public const string PART_CancelButton = "PART_CancelButton";
|
||||
public const string PART_Popup = "PART_Popup";
|
||||
public const string PC_DropdownOpen = ":dropdownopen";
|
||||
public const string PC_Icon = ":icon";
|
||||
|
||||
public static readonly StyledProperty<object?> PopupHeaderProperty = AvaloniaProperty.Register<PopConfirm, object?>(
|
||||
nameof(PopupHeader));
|
||||
@@ -64,7 +66,15 @@ public class PopConfirm : ContentControl
|
||||
nameof(IsDropdownOpen));
|
||||
|
||||
public static readonly StyledProperty<PlacementMode> PlacementProperty =
|
||||
Popup.PlacementProperty.AddOwner<PopConfirm>();
|
||||
Popup.PlacementProperty.AddOwner<PopConfirm>(new StyledPropertyMetadata<PlacementMode>());
|
||||
|
||||
public static readonly StyledProperty<object?> IconProperty = Banner.IconProperty.AddOwner<PopConfirm>();
|
||||
|
||||
public object? Icon
|
||||
{
|
||||
get => GetValue(IconProperty);
|
||||
set => SetValue(IconProperty, value);
|
||||
}
|
||||
|
||||
private Button? _cancelButton;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user