feat: add PopConfirm resource dictionary and update styles.

This commit is contained in:
Zhang Dian
2025-04-25 00:25:03 +08:00
parent 5bfa472c1e
commit 3035a519ec
7 changed files with 61 additions and 40 deletions

View File

@@ -20,9 +20,14 @@
Name="{x:Static u:PopConfirm.PART_Popup}" Name="{x:Static u:PopConfirm.PART_Popup}"
Placement="{TemplateBinding Placement}"> Placement="{TemplateBinding Placement}">
<Border <Border
Theme="{DynamicResource CardBorder}" MaxWidth="{DynamicResource PopConfirmBorderMaxWidth}"
MinHeight="160" Padding="{DynamicResource PopConfirmBorderPadding}"
MinWidth="280"> Margin="{DynamicResource PopConfirmBorderMargin}"
Background="{DynamicResource PopConfirmBackground}"
BorderBrush="{DynamicResource PopConfirmBorderBrush}"
BorderThickness="{DynamicResource PopConfirmBorderThickness}"
CornerRadius="{DynamicResource PopConfirmBorderCornerRadius}"
BoxShadow="{DynamicResource PopConfirmBorderBoxShadows}">
<Grid <Grid
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
RowDefinitions="*, Auto" RowDefinitions="*, Auto"
@@ -30,41 +35,44 @@
<!-- Icon Area --> <!-- Icon Area -->
<Panel <Panel
Grid.Column="0" Grid.Column="0"
Margin="{DynamicResource BannerIconMargin}" Margin="{DynamicResource PopConfirmIconMargin}"
VerticalAlignment="Top"> VerticalAlignment="Top">
<ContentPresenter <ContentPresenter
Content="{TemplateBinding Icon}" /> Content="{TemplateBinding Icon}" />
<PathIcon <PathIcon
Name="PART_BuildInIcon" Name="PART_BuildInIcon"
Theme="{DynamicResource InnerPathIcon}" Theme="{DynamicResource InnerPathIcon}"
Classes="ExtraLarge"
Data="{DynamicResource BannerWarningIconGeometry}" Data="{DynamicResource BannerWarningIconGeometry}"
Foreground="{DynamicResource BannerWarningBorderBrush}" Foreground="{DynamicResource BannerWarningBorderBrush}"
Classes="Large"
IsVisible="{TemplateBinding Icon, Converter={x:Static ObjectConverters.IsNull}}" /> IsVisible="{TemplateBinding Icon, Converter={x:Static ObjectConverters.IsNull}}" />
</Panel> </Panel>
<StackPanel Grid.Row="0" <StackPanel
Grid.Row="0"
Grid.Column="1" Grid.Column="1"
Spacing="2"> Spacing="8">
<ContentPresenter <ContentPresenter
Content="{TemplateBinding PopupHeader}" Content="{TemplateBinding PopupHeader}"
ContentTemplate="{TemplateBinding PopupHeaderTemplate}" ContentTemplate="{TemplateBinding PopupHeaderTemplate}"
TextTrimming="CharacterEllipsis" TextTrimming="CharacterEllipsis"
TextElement.FontSize="{DynamicResource BannerTitleFontSize}" TextElement.FontSize="{DynamicResource PopConfirmTitleFontSize}"
TextElement.FontWeight="{DynamicResource TextBlockTitleFontWeight}" /> TextElement.FontWeight="{DynamicResource PopConfirmTitleFontWeight}" />
<ContentPresenter <ContentPresenter
Content="{TemplateBinding PopupContent}" Content="{TemplateBinding PopupContent}"
ContentTemplate="{TemplateBinding PopupContentTemplate}" ContentTemplate="{TemplateBinding PopupContentTemplate}"
Foreground="{DynamicResource PopConfirmContentForeground}"
TextWrapping="Wrap" /> TextWrapping="Wrap" />
</StackPanel> </StackPanel>
<StackPanel Grid.Row="1" <StackPanel
Grid.Row="1"
Grid.Column="0" Grid.Column="0"
Margin="0 8 0 0"
Grid.ColumnSpan="2" Grid.ColumnSpan="2"
Margin="0 25 0 0"
Spacing="8"
Orientation="Horizontal" Orientation="Horizontal"
HorizontalAlignment="Right"> HorizontalAlignment="Right">
<Button <Button
Name="{x:Static u:PopConfirm.PART_CancelButton}" Name="{x:Static u:PopConfirm.PART_CancelButton}"
Margin="0 0 8 0"
Content="{DynamicResource STRING_MENU_DIALOG_CANCEL}" Content="{DynamicResource STRING_MENU_DIALOG_CANCEL}"
Command="{TemplateBinding CancelCommand}" Command="{TemplateBinding CancelCommand}"
CommandParameter="{TemplateBinding CancelCommandParameter}" /> CommandParameter="{TemplateBinding CancelCommandParameter}" />
@@ -74,7 +82,6 @@
Content="{DynamicResource STRING_MENU_DIALOG_OK}" Content="{DynamicResource STRING_MENU_DIALOG_OK}"
Command="{TemplateBinding ConfirmCommand}" Command="{TemplateBinding ConfirmCommand}"
CommandParameter="{TemplateBinding ConfirmCommandParameter}" /> CommandParameter="{TemplateBinding ConfirmCommandParameter}" />
</StackPanel> </StackPanel>
</Grid> </Grid>
</Border> </Border>
@@ -82,49 +89,37 @@
</Panel> </Panel>
</ControlTemplate> </ControlTemplate>
</Setter> </Setter>
<Style Selector="^ /template/ Button#PART_CancelButton"> <Style Selector="^ /template/ Button#PART_CancelButton">
<Setter Property="helpers:ClassHelper.Classes" Value="Tertiary" /> <Setter Property="helpers:ClassHelper.Classes" Value="Tertiary" />
</Style> </Style>
<Style Selector="^ /template/ Button#PART_ConfirmButton"> <Style Selector="^ /template/ Button#PART_ConfirmButton">
<Setter Property="helpers:ClassHelper.Classes" Value="Primary" /> <Setter Property="helpers:ClassHelper.Classes" Value="Primary" />
</Style> </Style>
<Style Selector="^.Information"> <Style Selector="^.Information">
<Style <Style Selector="^ /template/ PathIcon#PART_BuildInIcon">
Selector="^ /template/ PathIcon#PART_BuildInIcon"> <Setter Property="Data" Value="{DynamicResource BannerInformationIconGeometry}" />
<Setter Property="Data" <Setter Property="Foreground" Value="{DynamicResource BannerInformationBorderBrush}" />
Value="{DynamicResource BannerInformationIconGeometry}" />
<Setter Property="Foreground"
Value="{DynamicResource BannerInformationBorderBrush}" />
</Style> </Style>
</Style> </Style>
<Style Selector="^.Success"> <Style Selector="^.Success">
<Style <Style Selector="^ /template/ PathIcon#PART_BuildInIcon">
Selector="^ /template/ PathIcon#PART_BuildInIcon"> <Setter Property="Data" Value="{DynamicResource BannerSuccessIconGeometry}" />
<Setter Property="Data" <Setter Property="Foreground" Value="{DynamicResource BannerSuccessBorderBrush}" />
Value="{DynamicResource BannerSuccessIconGeometry}" />
<Setter Property="Foreground"
Value="{DynamicResource BannerSuccessBorderBrush}" />
</Style> </Style>
</Style> </Style>
<Style Selector="^.Warning"> <Style Selector="^.Warning">
<Style <Style Selector="^ /template/ PathIcon#PART_BuildInIcon">
Selector="^ /template/ PathIcon#PART_BuildInIcon"> <Setter Property="Data" Value="{DynamicResource BannerWarningIconGeometry}" />
<Setter Property="Data" <Setter Property="Foreground" Value="{DynamicResource BannerWarningBorderBrush}" />
Value="{DynamicResource BannerWarningIconGeometry}" />
<Setter Property="Foreground"
Value="{DynamicResource BannerWarningBorderBrush}" />
</Style> </Style>
</Style> </Style>
<Style Selector="^.Error"> <Style Selector="^.Error">
<Style <Style Selector="^ /template/ PathIcon#PART_BuildInIcon">
Selector="^ /template/ PathIcon#PART_BuildInIcon"> <Setter Property="Data" Value="{DynamicResource BannerErrorIconGeometry}" />
<Setter Property="Data" <Setter Property="Foreground" Value="{DynamicResource BannerErrorBorderBrush}" />
Value="{DynamicResource BannerErrorIconGeometry}" />
<Setter Property="Foreground"
Value="{DynamicResource BannerErrorBorderBrush}" />
</Style> </Style>
</Style> </Style>
</ControlTheme> </ControlTheme>

View File

@@ -0,0 +1,6 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<SolidColorBrush x:Key="PopConfirmBackground">#43444A</SolidColorBrush>
<SolidColorBrush x:Key="PopConfirmBorderBrush" Opacity="0.08" Color="White" />
<SolidColorBrush x:Key="PopConfirmContentForeground" Opacity="0.6" Color="#F9F9F9" />
<BoxShadows x:Key="PopConfirmBorderBoxShadows">inset 0 0 0 1 #1AFFFFFF, 0 4 14 #40000000</BoxShadows>
</ResourceDictionary>

View File

@@ -15,6 +15,7 @@
<ResourceInclude Source="NavigationMenu.axaml" /> <ResourceInclude Source="NavigationMenu.axaml" />
<ResourceInclude Source="NotificationShared.axaml" /> <ResourceInclude Source="NotificationShared.axaml" />
<ResourceInclude Source="Pagination.axaml" /> <ResourceInclude Source="Pagination.axaml" />
<ResourceInclude Source="PopConfirm.axaml" />
<ResourceInclude Source="Rating.axaml" /> <ResourceInclude Source="Rating.axaml" />
<ResourceInclude Source="SelectionList.axaml" /> <ResourceInclude Source="SelectionList.axaml" />
<ResourceInclude Source="Skeleton.axaml" /> <ResourceInclude Source="Skeleton.axaml" />

View File

@@ -0,0 +1,6 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<SolidColorBrush x:Key="PopConfirmBackground">White</SolidColorBrush>
<SolidColorBrush x:Key="PopConfirmBorderBrush" Opacity="0.08" Color="#1C1F23" />
<SolidColorBrush x:Key="PopConfirmContentForeground" Opacity="0.62" Color="#1C1F23" />
<BoxShadows x:Key="PopConfirmBorderBoxShadows">0 0 1 #4A000000, 0 4 14 #1A000000</BoxShadows>
</ResourceDictionary>

View File

@@ -15,6 +15,7 @@
<ResourceInclude Source="NavigationMenu.axaml" /> <ResourceInclude Source="NavigationMenu.axaml" />
<ResourceInclude Source="NotificationShared.axaml" /> <ResourceInclude Source="NotificationShared.axaml" />
<ResourceInclude Source="Pagination.axaml" /> <ResourceInclude Source="Pagination.axaml" />
<ResourceInclude Source="PopConfirm.axaml" />
<ResourceInclude Source="Rating.axaml" /> <ResourceInclude Source="Rating.axaml" />
<ResourceInclude Source="SelectionList.axaml" /> <ResourceInclude Source="SelectionList.axaml" />
<ResourceInclude Source="Skeleton.axaml" /> <ResourceInclude Source="Skeleton.axaml" />

View File

@@ -0,0 +1,11 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<x:Double x:Key="PopConfirmBorderMaxWidth">400</x:Double>
<Thickness x:Key="PopConfirmBorderPadding">20 24 24 24</Thickness>
<Thickness x:Key="PopConfirmBorderMargin">4</Thickness>
<Thickness x:Key="PopConfirmBorderThickness">1</Thickness>
<CornerRadius x:Key="PopConfirmBorderCornerRadius">6</CornerRadius>
<Thickness x:Key="PopConfirmIconMargin">0 0 12 0</Thickness>
<x:Double x:Key="PopConfirmTitleFontSize">16</x:Double>
<FontWeight x:Key="PopConfirmTitleFontWeight">600</FontWeight>
</ResourceDictionary>

View File

@@ -16,8 +16,9 @@
<ResourceInclude Source="NavigationMenu.axaml" /> <ResourceInclude Source="NavigationMenu.axaml" />
<ResourceInclude Source="Notification.axaml" /> <ResourceInclude Source="Notification.axaml" />
<ResourceInclude Source="Pagination.axaml" /> <ResourceInclude Source="Pagination.axaml" />
<ResourceInclude Source="PopConfirm.axaml" />
<ResourceInclude Source="Rating.axaml" /> <ResourceInclude Source="Rating.axaml" />
<ResourceInclude Source="Resizer.axaml"/> <ResourceInclude Source="Resizer.axaml" />
<ResourceInclude Source="ScrollToButton.axaml" /> <ResourceInclude Source="ScrollToButton.axaml" />
<ResourceInclude Source="TagInput.axaml" /> <ResourceInclude Source="TagInput.axaml" />
<ResourceInclude Source="Skeleton.axaml" /> <ResourceInclude Source="Skeleton.axaml" />