Merge pull request #431 from irihitech/notification

fix Notification issues
This commit is contained in:
Dong Bin 2024-09-11 21:58:22 +08:00 committed by GitHub
commit 0974bbd580
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 40 additions and 21 deletions

View File

@ -8,7 +8,7 @@
d:DesignWidth="800" d:DesignWidth="800"
mc:Ignorable="d"> mc:Ignorable="d">
<StackPanel Spacing="20"> <StackPanel Spacing="20">
<UniformGrid Rows="3" Columns="3" Width="500" HorizontalAlignment="Left"> <UniformGrid Rows="2" Columns="3" Width="500" HorizontalAlignment="Left">
<UniformGrid.Styles> <UniformGrid.Styles>
<Style Selector="RadioButton"> <Style Selector="RadioButton">
<Setter Property="Theme" Value="{DynamicResource PureCardRadioButton}" /> <Setter Property="Theme" Value="{DynamicResource PureCardRadioButton}" />

View File

@ -5,16 +5,17 @@
<Design.PreviewWith> <Design.PreviewWith>
<ThemeVariantScope RequestedThemeVariant="Dark"> <ThemeVariantScope RequestedThemeVariant="Dark">
<StackPanel> <StackPanel>
<NotificationCard />
<NotificationCard> <NotificationCard>
Hello, Semi.Avalonia! Hello, Semi.Avalonia!
</NotificationCard> </NotificationCard>
<NotificationCard NotificationType="Success"> <NotificationCard NotificationType="Success">
<Notification Title="Welcome" Message="Hello, Semi.Avalonia!" /> <Notification Title="Welcome" Message="Hello, Semi.Avalonia!" />
</NotificationCard> </NotificationCard>
<NotificationCard NotificationType="Warning"> <NotificationCard NotificationType="Warning" Classes="Light">
<Notification Title="" Message="Hello, Semi.Avalonia!" /> <Notification Title="Welcome" />
</NotificationCard> </NotificationCard>
<NotificationCard NotificationType="Error"> <NotificationCard NotificationType="Error" Classes="Light">
<Notification Message="Hello, Semi.Avalonia!" /> <Notification Message="Hello, Semi.Avalonia!" />
</NotificationCard> </NotificationCard>
</StackPanel> </StackPanel>
@ -22,10 +23,7 @@
</Design.PreviewWith> </Design.PreviewWith>
<ControlTheme x:Key="{x:Type NotificationCard}" TargetType="NotificationCard"> <ControlTheme x:Key="{x:Type NotificationCard}" TargetType="NotificationCard">
<Setter Property="UseLayoutRounding" Value="True" /> <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="BorderThickness" Value="{DynamicResource NotificationCardBorderThickness}" />
<Setter Property="BorderBrush" Value="{DynamicResource NotificationCardBorderBrush}" />
<Setter Property="Background" Value="{DynamicResource NotificationCardBackground}" /> <Setter Property="Background" Value="{DynamicResource NotificationCardBackground}" />
<Setter Property="CornerRadius" Value="{DynamicResource NotificationCardCornerRadius}" /> <Setter Property="CornerRadius" Value="{DynamicResource NotificationCardCornerRadius}" />
<Setter Property="Template"> <Setter Property="Template">
@ -38,11 +36,11 @@
<Border <Border
x:Name="PART_RootBorder" x:Name="PART_RootBorder"
Padding="{DynamicResource NotificationCardPadding}" Padding="{DynamicResource NotificationCardPadding}"
BoxShadow="{DynamicResource NotificationCardBoxShadow}" BoxShadow="{DynamicResource NotificationCardBoxShadows}"
BorderBrush="{TemplateBinding BorderBrush}" BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}" BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="{TemplateBinding CornerRadius}"> CornerRadius="{TemplateBinding CornerRadius}">
<DockPanel> <DockPanel MinWidth="{DynamicResource NotificationCardMinWidth}">
<PathIcon <PathIcon
Name="NotificationIcon" Name="NotificationIcon"
Width="{DynamicResource NotificationCardIconWidth}" Width="{DynamicResource NotificationCardIconWidth}"
@ -67,6 +65,7 @@
Foreground="{DynamicResource NotificationCardMessageForeground}" Foreground="{DynamicResource NotificationCardMessageForeground}"
FontSize="{DynamicResource NotificationCardMessageFontSize}" FontSize="{DynamicResource NotificationCardMessageFontSize}"
FontWeight="{DynamicResource NotificationCardMessageFontWeight}" FontWeight="{DynamicResource NotificationCardMessageFontWeight}"
IsVisible="{Binding Message, Converter={x:Static StringConverters.IsNotNullOrEmpty}}"
Text="{Binding Message}" Text="{Binding Message}"
TextWrapping="Wrap" /> TextWrapping="Wrap" />
</StackPanel> </StackPanel>
@ -169,22 +168,22 @@
</Style> </Style>
<Style Selector="^.Light"> <Style Selector="^.Light">
<Setter Property="Background" Value="{DynamicResource SemiColorBackground0}" /> <Setter Property="Background" Value="{DynamicResource NotificationCardLightBackground}" />
<Style Selector="^:information /template/ Border#PART_RootBorder"> <Style Selector="^:information /template/ Border#PART_RootBorder">
<Setter Property="BorderBrush" Value="{DynamicResource SemiColorInformation}" /> <Setter Property="BorderBrush" Value="{DynamicResource NotificationCardLightInformationBorderBrush}" />
<Setter Property="Background" Value="{DynamicResource SemiColorInformationLight}" /> <Setter Property="Background" Value="{DynamicResource NotificationCardLightInformationBackground}"/>
</Style> </Style>
<Style Selector="^:success /template/ Border#PART_RootBorder"> <Style Selector="^:success /template/ Border#PART_RootBorder">
<Setter Property="BorderBrush" Value="{DynamicResource SemiColorSuccess}" /> <Setter Property="BorderBrush" Value="{DynamicResource NotificationCardLightSuccessBorderBrush}" />
<Setter Property="Background" Value="{DynamicResource SemiColorSuccessLight}" /> <Setter Property="Background" Value="{DynamicResource NotificationCardLightSuccessBackground}" />
</Style> </Style>
<Style Selector="^:warning /template/ Border#PART_RootBorder"> <Style Selector="^:warning /template/ Border#PART_RootBorder">
<Setter Property="BorderBrush" Value="{DynamicResource SemiColorWarning}" /> <Setter Property="BorderBrush" Value="{DynamicResource NotificationCardLightWarningBorderBrush}" />
<Setter Property="Background" Value="{DynamicResource SemiColorWarningLight}" /> <Setter Property="Background" Value="{DynamicResource NotificationCardLightWarningBackground}" />
</Style> </Style>
<Style Selector="^:error /template/ Border#PART_RootBorder"> <Style Selector="^:error /template/ Border#PART_RootBorder">
<Setter Property="BorderBrush" Value="{DynamicResource SemiColorDanger}" /> <Setter Property="BorderBrush" Value="{DynamicResource NotificationCardLightErrorBorderBrush}" />
<Setter Property="Background" Value="{DynamicResource SemiColorDangerLight}" /> <Setter Property="Background" Value="{DynamicResource NotificationCardLightErrorBackground}" />
</Style> </Style>
</Style> </Style>
</ControlTheme> </ControlTheme>

View File

@ -5,7 +5,17 @@
<SolidColorBrush x:Key="NotificationCardSuccessIconForeground" Color="#5DC264" /> <SolidColorBrush x:Key="NotificationCardSuccessIconForeground" Color="#5DC264" />
<SolidColorBrush x:Key="NotificationCardWarningIconForeground" Color="#FFAE43" /> <SolidColorBrush x:Key="NotificationCardWarningIconForeground" Color="#FFAE43" />
<SolidColorBrush x:Key="NotificationCardErrorIconForeground" Color="#FC725A" /> <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="NotificationCardTitleForeground" Color="#F9F9F9" />
<SolidColorBrush x:Key="NotificationCardMessageForeground" Opacity="0.8" Color="#F9F9F9" /> <SolidColorBrush x:Key="NotificationCardMessageForeground" Opacity="0.8" Color="#F9F9F9" />
<SolidColorBrush x:Key="NotificationCardLightBackground" Color="#16161A" />
<SolidColorBrush x:Key="NotificationCardLightInformationBorderBrush" Color="#54A9FF" />
<SolidColorBrush x:Key="NotificationCardLightInformationBackground" Opacity="0.2" Color="#54A9FF" />
<SolidColorBrush x:Key="NotificationCardLightSuccessBorderBrush" Color="#5DC264" />
<SolidColorBrush x:Key="NotificationCardLightSuccessBackground" Opacity="0.2" Color="#5DC264" />
<SolidColorBrush x:Key="NotificationCardLightWarningBorderBrush" Color="#FFAE43" />
<SolidColorBrush x:Key="NotificationCardLightWarningBackground" Opacity="0.2" Color="#FFAE43" />
<SolidColorBrush x:Key="NotificationCardLightErrorBorderBrush" Color="#FC725A" />
<SolidColorBrush x:Key="NotificationCardLightErrorBackground" Opacity="0.2" Color="#FC725A" />
</ResourceDictionary> </ResourceDictionary>

View File

@ -5,7 +5,17 @@
<SolidColorBrush x:Key="NotificationCardSuccessIconForeground" Color="#3BB346" /> <SolidColorBrush x:Key="NotificationCardSuccessIconForeground" Color="#3BB346" />
<SolidColorBrush x:Key="NotificationCardWarningIconForeground" Color="#FC8800" /> <SolidColorBrush x:Key="NotificationCardWarningIconForeground" Color="#FC8800" />
<SolidColorBrush x:Key="NotificationCardErrorIconForeground" Color="#F93920" /> <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="NotificationCardTitleForeground" Color="#1C1F23" />
<SolidColorBrush x:Key="NotificationCardMessageForeground" Opacity="0.8" Color="#1C1F23" /> <SolidColorBrush x:Key="NotificationCardMessageForeground" Opacity="0.8" Color="#1C1F23" />
<SolidColorBrush x:Key="NotificationCardLightBackground" Color="White" />
<SolidColorBrush x:Key="NotificationCardLightInformationBorderBrush" Color="#0077FA" />
<SolidColorBrush x:Key="NotificationCardLightInformationBackground" Color="#EAF5FF" />
<SolidColorBrush x:Key="NotificationCardLightSuccessBorderBrush" Color="#3BB346" />
<SolidColorBrush x:Key="NotificationCardLightSuccessBackground" Color="#ECF7EC" />
<SolidColorBrush x:Key="NotificationCardLightWarningBorderBrush" Color="#FC8800" />
<SolidColorBrush x:Key="NotificationCardLightWarningBackground" Color="#FFF8EA" />
<SolidColorBrush x:Key="NotificationCardLightErrorBorderBrush" Color="#F93920" />
<SolidColorBrush x:Key="NotificationCardLightErrorBackground" Color="#FEF2ED" />
</ResourceDictionary> </ResourceDictionary>

View File

@ -3,7 +3,7 @@
<Thickness x:Key="NotificationCardBorderThickness">1</Thickness> <Thickness x:Key="NotificationCardBorderThickness">1</Thickness>
<CornerRadius x:Key="NotificationCardCornerRadius">6</CornerRadius> <CornerRadius x:Key="NotificationCardCornerRadius">6</CornerRadius>
<Thickness x:Key="NotificationCardMargin">8</Thickness> <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="NotificationCardIconWidth">18</x:Double>
<x:Double x:Key="NotificationCardIconHeight">18</x:Double> <x:Double x:Key="NotificationCardIconHeight">18</x:Double>