feat: Notification size.

This commit is contained in:
Zhang Dian
2024-09-11 14:25:37 +08:00
parent 01c2133012
commit 88f6bb138b
5 changed files with 20 additions and 11 deletions

View File

@@ -5,10 +5,17 @@
<ThemeVariantScope RequestedThemeVariant="Dark"> <ThemeVariantScope RequestedThemeVariant="Dark">
<StackPanel Orientation="Vertical"> <StackPanel Orientation="Vertical">
<u:NotificationCard ShowClose="False" /> <u:NotificationCard ShowClose="False" />
<u:NotificationCard> <u:NotificationCard />
<u:NotificationCard NotificationType="Information">
Hello, Ursa! Hello, Ursa!
</u:NotificationCard> </u:NotificationCard>
<u:NotificationCard NotificationType="Success"> <u:NotificationCard NotificationType="Success">
<u:Notification Title="Welcome" />
</u:NotificationCard>
<u:NotificationCard NotificationType="Warning">
<u:Notification Content="Hello, Ursa!" />
</u:NotificationCard>
<u:NotificationCard NotificationType="Error">
<u:Notification Title="Welcome" Content="Hello, Ursa!" /> <u:Notification Title="Welcome" Content="Hello, Ursa!" />
</u:NotificationCard> </u:NotificationCard>
</StackPanel> </StackPanel>
@@ -61,9 +68,7 @@
<ControlTheme x:Key="{x:Type u:NotificationCard}" TargetType="u:NotificationCard"> <ControlTheme x:Key="{x:Type u:NotificationCard}" TargetType="u:NotificationCard">
<Setter Property="UseLayoutRounding" Value="True" /> <Setter Property="UseLayoutRounding" Value="True" />
<Setter Property="MinWidth" Value="{DynamicResource NotificationCardMinWidth}" />
<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">
@@ -76,14 +81,13 @@
<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}">
<Grid ColumnDefinitions="Auto,*,Auto"> <DockPanel MinWidth="{DynamicResource NotificationCardMinWidth}">
<PathIcon <PathIcon
x:Name="NotificationIcon" x:Name="NotificationIcon"
Grid.Column="0"
Width="{DynamicResource NotificationCardIconWidth}" Width="{DynamicResource NotificationCardIconWidth}"
Height="{DynamicResource NotificationCardIconHeight}" Height="{DynamicResource NotificationCardIconHeight}"
Margin="{DynamicResource NotificationCardIconMargin}" Margin="{DynamicResource NotificationCardIconMargin}"
@@ -92,7 +96,6 @@
Data="{DynamicResource NotificationCardInformationIconPathData}" /> Data="{DynamicResource NotificationCardInformationIconPathData}" />
<ContentControl <ContentControl
x:Name="PART_Content" x:Name="PART_Content"
Grid.Column="1"
VerticalContentAlignment="Center" VerticalContentAlignment="Center"
Content="{TemplateBinding Content}"> Content="{TemplateBinding Content}">
<ContentControl.DataTemplates> <ContentControl.DataTemplates>
@@ -108,6 +111,7 @@
Foreground="{DynamicResource NotificationCardMessageForeground}" Foreground="{DynamicResource NotificationCardMessageForeground}"
FontSize="{DynamicResource NotificationCardMessageFontSize}" FontSize="{DynamicResource NotificationCardMessageFontSize}"
FontWeight="{DynamicResource NotificationCardMessageFontWeight}" FontWeight="{DynamicResource NotificationCardMessageFontWeight}"
IsVisible="{Binding Content, Converter={x:Static StringConverters.IsNotNullOrEmpty}}"
Text="{Binding Content}" Text="{Binding Content}"
TextWrapping="Wrap" /> TextWrapping="Wrap" />
</StackPanel> </StackPanel>
@@ -124,13 +128,12 @@
</ContentControl> </ContentControl>
<Button <Button
x:Name="PART_CloseButton" x:Name="PART_CloseButton"
Grid.Column="2"
VerticalAlignment="Top" VerticalAlignment="Top"
HorizontalAlignment="Right" HorizontalAlignment="Right"
Theme="{StaticResource NotificationCloseButton}" Theme="{StaticResource NotificationCloseButton}"
IsVisible="{TemplateBinding ShowClose}" IsVisible="{TemplateBinding ShowClose}"
u:MessageCard.CloseOnClick="True" /> u:MessageCard.CloseOnClick="True" />
</Grid> </DockPanel>
</Border> </Border>
</Border> </Border>
</LayoutTransformControl> </LayoutTransformControl>
@@ -409,6 +412,7 @@
<Setter Property="Height" Value="24" /> <Setter Property="Height" Value="24" />
<Setter Property="Width" Value="24" /> <Setter Property="Width" Value="24" />
<Setter Property="Cursor" Value="Hand" /> <Setter Property="Cursor" Value="Hand" />
<Setter Property="Foreground" Value="{DynamicResource SemiColorText1}" />
<Setter Property="Template"> <Setter Property="Template">
<ControlTemplate TargetType="Button"> <ControlTemplate TargetType="Button">
<Border <Border

View File

@@ -30,7 +30,6 @@
<ControlTheme x:Key="{x:Type u:ToastCard}" TargetType="u:ToastCard"> <ControlTheme x:Key="{x:Type u:ToastCard}" TargetType="u:ToastCard">
<Setter Property="UseLayoutRounding" Value="True" /> <Setter Property="UseLayoutRounding" Value="True" />
<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="BorderBrush" Value="{DynamicResource NotificationCardBorderBrush}" />
<Setter Property="Background" Value="{DynamicResource NotificationCardBackground}" /> <Setter Property="Background" Value="{DynamicResource NotificationCardBackground}" />
@@ -48,7 +47,7 @@
BorderBrush="{TemplateBinding BorderBrush}" BorderBrush="{TemplateBinding BorderBrush}"
MinHeight="{DynamicResource ToastCardMinHeight}" MinHeight="{DynamicResource ToastCardMinHeight}"
Padding="{DynamicResource ToastCardPadding}" Padding="{DynamicResource ToastCardPadding}"
BoxShadow="{DynamicResource NotificationCardBoxShadow}" BoxShadow="{DynamicResource NotificationCardBoxShadows}"
CornerRadius="{TemplateBinding CornerRadius}"> CornerRadius="{TemplateBinding CornerRadius}">
<Grid ColumnDefinitions="Auto,*,Auto"> <Grid ColumnDefinitions="Auto,*,Auto">
<PathIcon <PathIcon

View File

@@ -0,0 +1,3 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Thickness x:Key="NotificationCardPadding">20 16 12 16</Thickness>
</ResourceDictionary>

View File

@@ -14,6 +14,7 @@
<MergeResourceInclude Source="KeyGestureInput.axaml" /> <MergeResourceInclude Source="KeyGestureInput.axaml" />
<MergeResourceInclude Source="MessageBox.axaml" /> <MergeResourceInclude Source="MessageBox.axaml" />
<MergeResourceInclude Source="NavigationMenu.axaml" /> <MergeResourceInclude Source="NavigationMenu.axaml" />
<MergeResourceInclude Source="Notification.axaml" />
<MergeResourceInclude Source="Pagination.axaml" /> <MergeResourceInclude Source="Pagination.axaml" />
<MergeResourceInclude Source="Rating.axaml" /> <MergeResourceInclude Source="Rating.axaml" />
<MergeResourceInclude Source="ScrollToButton.axaml" /> <MergeResourceInclude Source="ScrollToButton.axaml" />

View File

@@ -110,6 +110,8 @@ public class WindowNotificationManager : WindowMessageManager, INotificationMana
NotificationType = type, NotificationType = type,
ShowClose = showClose ShowClose = showClose
}; };
// this.Bind(PositionProperty,notificationControl.GetObservable(PositionProperty));
this[!PositionProperty] = notificationControl[!NotificationCard.PositionProperty];
// Add style classes if any // Add style classes if any
if (classes is not null) if (classes is not null)