feat: adjust margin & padding.

This commit is contained in:
Zhang Dian
2024-09-05 16:17:16 +08:00
parent f52d62f9f5
commit 22fc7f5424
3 changed files with 33 additions and 18 deletions

View File

@@ -37,54 +37,58 @@
<Setter Property="CornerRadius" Value="{DynamicResource NotificationCardCornerRadius}" /> <Setter Property="CornerRadius" Value="{DynamicResource NotificationCardCornerRadius}" />
<Setter Property="Template"> <Setter Property="Template">
<ControlTemplate TargetType="u:ToastCard"> <ControlTemplate TargetType="u:ToastCard">
<LayoutTransformControl Name="PART_LayoutTransformControl" UseRenderTransform="True"> <LayoutTransformControl x:Name="PART_LayoutTransformControl" UseRenderTransform="True">
<Border <Border
Margin="{DynamicResource NotificationCardMargin}" Margin="{DynamicResource ToastCardMargin}"
Background="{TemplateBinding Background}" Background="{TemplateBinding Background}"
CornerRadius="{TemplateBinding CornerRadius}"> CornerRadius="{TemplateBinding CornerRadius}">
<Border <Border
x:Name="PART_RootBorder" x:Name="PART_RootBorder"
Padding="{DynamicResource NotificationCardPadding}"
BoxShadow="{DynamicResource NotificationCardBoxShadow}"
BorderBrush="{TemplateBinding BorderBrush}"
VerticalAlignment="Stretch"
BorderThickness="{TemplateBinding BorderThickness}" BorderThickness="{TemplateBinding BorderThickness}"
BorderBrush="{TemplateBinding BorderBrush}"
MinHeight="{DynamicResource ToastCardMinHeight}"
Padding="{DynamicResource ToastCardPadding}"
BoxShadow="{DynamicResource NotificationCardBoxShadow}"
CornerRadius="{TemplateBinding CornerRadius}"> CornerRadius="{TemplateBinding CornerRadius}">
<StackPanel Orientation="Horizontal"> <Grid ColumnDefinitions="Auto,*,Auto">
<PathIcon <PathIcon
Name="NotificationIcon" x:Name="ToastIcon"
Grid.Column="0"
Width="{DynamicResource NotificationCardIconWidth}" Width="{DynamicResource NotificationCardIconWidth}"
Height="{DynamicResource NotificationCardIconHeight}" Height="{DynamicResource NotificationCardIconHeight}"
Margin="{DynamicResource NotificationCardIconMargin}"
IsVisible="False" IsVisible="False"
Data="{DynamicResource NotificationCardInformationIconPathData}" /> Data="{DynamicResource NotificationCardInformationIconPathData}" />
<ContentControl <ContentControl
Name="PART_Content" x:Name="PART_Content"
Margin="12 0" Grid.Column="1"
Margin="{DynamicResource ToastCardContentMargin}"
VerticalContentAlignment="Center" VerticalContentAlignment="Center"
MaxWidth="{DynamicResource ToastCardContentMaxWidth}"
Content="{TemplateBinding Content}"> Content="{TemplateBinding Content}">
<ContentControl.DataTemplates> <ContentControl.DataTemplates>
<DataTemplate DataType="u:IToast"> <DataTemplate DataType="u:IToast">
<SelectableTextBlock <SelectableTextBlock
Foreground="{DynamicResource NotificationCardTitleForeground}" Foreground="{DynamicResource NotificationCardTitleForeground}"
FontWeight="{DynamicResource NotificationCardTitleFontWeight}" FontWeight="{DynamicResource ToastCardContentFontWeight}"
Text="{Binding Content}" Text="{Binding Content}"
TextWrapping="Wrap" /> TextWrapping="Wrap" />
</DataTemplate> </DataTemplate>
<DataTemplate DataType="x:String"> <DataTemplate DataType="x:String">
<SelectableTextBlock <SelectableTextBlock
Foreground="{DynamicResource NotificationCardTitleForeground}" Foreground="{DynamicResource NotificationCardTitleForeground}"
FontWeight="{DynamicResource NotificationCardTitleFontWeight}" FontWeight="{DynamicResource ToastCardContentFontWeight}"
Text="{Binding}" Text="{Binding}"
TextWrapping="Wrap" /> TextWrapping="Wrap" />
</DataTemplate> </DataTemplate>
</ContentControl.DataTemplates> </ContentControl.DataTemplates>
</ContentControl> </ContentControl>
<Button <Button
x:Name="PART_CloseButton"
Grid.Column="2"
Theme="{StaticResource ToastCloseButton}" Theme="{StaticResource ToastCloseButton}"
IsVisible="{TemplateBinding ShowClose}" IsVisible="{TemplateBinding ShowClose}"
u:ToastCard.CloseOnClick="True" /> u:ToastCard.CloseOnClick="True" />
</StackPanel> </Grid>
</Border> </Border>
</Border> </Border>
</LayoutTransformControl> </LayoutTransformControl>
@@ -150,22 +154,22 @@
</Style.Animations> </Style.Animations>
</Style> </Style>
<Style Selector="^:information /template/ PathIcon#NotificationIcon"> <Style Selector="^:information /template/ PathIcon#ToastIcon">
<Setter Property="IsVisible" Value="True" /> <Setter Property="IsVisible" Value="True" />
<Setter Property="Foreground" Value="{DynamicResource NotificationCardInformationIconForeground}" /> <Setter Property="Foreground" Value="{DynamicResource NotificationCardInformationIconForeground}" />
<Setter Property="Data" Value="{DynamicResource NotificationCardInformationIconPathData}" /> <Setter Property="Data" Value="{DynamicResource NotificationCardInformationIconPathData}" />
</Style> </Style>
<Style Selector="^:success /template/ PathIcon#NotificationIcon"> <Style Selector="^:success /template/ PathIcon#ToastIcon">
<Setter Property="IsVisible" Value="True" /> <Setter Property="IsVisible" Value="True" />
<Setter Property="Foreground" Value="{DynamicResource NotificationCardSuccessIconForeground}" /> <Setter Property="Foreground" Value="{DynamicResource NotificationCardSuccessIconForeground}" />
<Setter Property="Data" Value="{DynamicResource NotificationCardSuccessIconPathData}" /> <Setter Property="Data" Value="{DynamicResource NotificationCardSuccessIconPathData}" />
</Style> </Style>
<Style Selector="^:warning /template/ PathIcon#NotificationIcon"> <Style Selector="^:warning /template/ PathIcon#ToastIcon">
<Setter Property="IsVisible" Value="True" /> <Setter Property="IsVisible" Value="True" />
<Setter Property="Foreground" Value="{DynamicResource NotificationCardWarningIconForeground}" /> <Setter Property="Foreground" Value="{DynamicResource NotificationCardWarningIconForeground}" />
<Setter Property="Data" Value="{DynamicResource NotificationCardWarningIconPathData}" /> <Setter Property="Data" Value="{DynamicResource NotificationCardWarningIconPathData}" />
</Style> </Style>
<Style Selector="^:error /template/ PathIcon#NotificationIcon"> <Style Selector="^:error /template/ PathIcon#ToastIcon">
<Setter Property="IsVisible" Value="True" /> <Setter Property="IsVisible" Value="True" />
<Setter Property="Foreground" Value="{DynamicResource NotificationCardErrorIconForeground}" /> <Setter Property="Foreground" Value="{DynamicResource NotificationCardErrorIconForeground}" />
<Setter Property="Data" Value="{DynamicResource NotificationCardErrorIconPathData}" /> <Setter Property="Data" Value="{DynamicResource NotificationCardErrorIconPathData}" />

View File

@@ -0,0 +1,10 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<x:Double x:Key="ToastCardMinHeight">40</x:Double>
<Thickness x:Key="ToastCardPadding">12 8</Thickness>
<Thickness x:Key="ToastCardMargin">12</Thickness>
<FontWeight x:Key="ToastCardContentFontWeight">600</FontWeight>
<Thickness x:Key="ToastCardContentMargin">12 0</Thickness>
<x:Double x:Key="ToastCardContentMaxWidth">450</x:Double>
</ResourceDictionary>

View File

@@ -20,6 +20,7 @@
<MergeResourceInclude Source="TagInput.axaml" /> <MergeResourceInclude Source="TagInput.axaml" />
<MergeResourceInclude Source="Skeleton.axaml" /> <MergeResourceInclude Source="Skeleton.axaml" />
<MergeResourceInclude Source="ThemeSelector.axaml" /> <MergeResourceInclude Source="ThemeSelector.axaml" />
<MergeResourceInclude Source="Toast.axaml" />
<MergeResourceInclude Source="ToolBar.axaml" /> <MergeResourceInclude Source="ToolBar.axaml" />
<MergeResourceInclude Source="TimeBox.axaml" /> <MergeResourceInclude Source="TimeBox.axaml" />
</ResourceDictionary.MergedDictionaries> </ResourceDictionary.MergedDictionaries>