fix: fix Notification BoxShadows & MinWidth.

This commit is contained in:
Zhang Dian 2024-09-11 12:22:20 +08:00
parent 16e8c475a1
commit b0b06b4edc
4 changed files with 10 additions and 11 deletions

View File

@ -5,16 +5,17 @@
<Design.PreviewWith>
<ThemeVariantScope RequestedThemeVariant="Dark">
<StackPanel>
<NotificationCard />
<NotificationCard>
Hello, Semi.Avalonia!
</NotificationCard>
<NotificationCard NotificationType="Success">
<Notification Title="Welcome" Message="Hello, Semi.Avalonia!" />
</NotificationCard>
<NotificationCard NotificationType="Warning">
<Notification Title="" Message="Hello, Semi.Avalonia!" />
<NotificationCard NotificationType="Warning" Classes="Light">
<Notification Title="Welcome" />
</NotificationCard>
<NotificationCard NotificationType="Error">
<NotificationCard NotificationType="Error" Classes="Light">
<Notification Message="Hello, Semi.Avalonia!" />
</NotificationCard>
</StackPanel>
@ -22,10 +23,7 @@
</Design.PreviewWith>
<ControlTheme x:Key="{x:Type NotificationCard}" TargetType="NotificationCard">
<Setter Property="UseLayoutRounding" Value="True" />
<Setter Property="MinWidth" Value="{DynamicResource NotificationCardMinWidth}" />
<Setter Property="RenderTransformOrigin" Value="50%,75%" />
<Setter Property="BorderThickness" Value="{DynamicResource NotificationCardBorderThickness}" />
<Setter Property="BorderBrush" Value="{DynamicResource NotificationCardBorderBrush}" />
<Setter Property="Background" Value="{DynamicResource NotificationCardBackground}" />
<Setter Property="CornerRadius" Value="{DynamicResource NotificationCardCornerRadius}" />
<Setter Property="Template">
@ -38,11 +36,11 @@
<Border
x:Name="PART_RootBorder"
Padding="{DynamicResource NotificationCardPadding}"
BoxShadow="{DynamicResource NotificationCardBoxShadow}"
BoxShadow="{DynamicResource NotificationCardBoxShadows}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="{TemplateBinding CornerRadius}">
<DockPanel>
<DockPanel MinWidth="{DynamicResource NotificationCardMinWidth}">
<PathIcon
Name="NotificationIcon"
Width="{DynamicResource NotificationCardIconWidth}"
@ -67,6 +65,7 @@
Foreground="{DynamicResource NotificationCardMessageForeground}"
FontSize="{DynamicResource NotificationCardMessageFontSize}"
FontWeight="{DynamicResource NotificationCardMessageFontWeight}"
IsVisible="{Binding Message, Converter={x:Static StringConverters.IsNotNullOrEmpty}}"
Text="{Binding Message}"
TextWrapping="Wrap" />
</StackPanel>

View File

@ -5,7 +5,7 @@
<SolidColorBrush x:Key="NotificationCardSuccessIconForeground" Color="#5DC264" />
<SolidColorBrush x:Key="NotificationCardWarningIconForeground" Color="#FFAE43" />
<SolidColorBrush x:Key="NotificationCardErrorIconForeground" Color="#FC725A" />
<BoxShadows x:Key="NotificationCardBoxShadows">0 0 8 0 #1AFFFFFF</BoxShadows>
<BoxShadows x:Key="NotificationCardBoxShadows">inset 0 0 0 1 #1AFFFFFF, 0 4 14 0 #40000000</BoxShadows>
<SolidColorBrush x:Key="NotificationCardTitleForeground" Color="#F9F9F9" />
<SolidColorBrush x:Key="NotificationCardMessageForeground" Opacity="0.8" Color="#F9F9F9" />
</ResourceDictionary>

View File

@ -5,7 +5,7 @@
<SolidColorBrush x:Key="NotificationCardSuccessIconForeground" Color="#3BB346" />
<SolidColorBrush x:Key="NotificationCardWarningIconForeground" Color="#FC8800" />
<SolidColorBrush x:Key="NotificationCardErrorIconForeground" Color="#F93920" />
<BoxShadows x:Key="NotificationCardBoxShadows">0 0 8 0 #1A000000</BoxShadows>
<BoxShadows x:Key="NotificationCardBoxShadows">0 0 1 0 #4A000000, 0 4 14 0 #1A000000</BoxShadows>
<SolidColorBrush x:Key="NotificationCardTitleForeground" Color="#1C1F23" />
<SolidColorBrush x:Key="NotificationCardMessageForeground" Opacity="0.8" Color="#1C1F23" />
</ResourceDictionary>

View File

@ -3,7 +3,7 @@
<Thickness x:Key="NotificationCardBorderThickness">1</Thickness>
<CornerRadius x:Key="NotificationCardCornerRadius">6</CornerRadius>
<Thickness x:Key="NotificationCardMargin">8</Thickness>
<Thickness x:Key="NotificationCardPadding">16 12</Thickness>
<Thickness x:Key="NotificationCardPadding">20 16 12 16</Thickness>
<x:Double x:Key="NotificationCardIconWidth">18</x:Double>
<x:Double x:Key="NotificationCardIconHeight">18</x:Double>