feat: add Light class to NotificationCard.

This commit is contained in:
Zhang Dian
2024-08-14 20:00:43 +08:00
parent 38b9494aaf
commit a328e2bb99
4 changed files with 117 additions and 55 deletions

View File

@@ -9,6 +9,7 @@
mc:Ignorable="d">
<StackPanel Spacing="20">
<StackPanel>
<Slider Name="SliderTest" Maximum="400" Minimum="0" TickFrequency="1" IsSnapToTickEnabled="True" />
<Expander Header="Expander 1">
<TextBlock Text="Hello Avalonia!" />
</Expander>
@@ -36,4 +37,4 @@
</Expander>
</Grid>
</StackPanel>
</UserControl>
</UserControl>

View File

@@ -7,18 +7,33 @@
d:DesignHeight="450"
d:DesignWidth="800"
mc:Ignorable="d">
<StackPanel HorizontalAlignment="Left" Spacing="20">
<StackPanel.Styles>
<Style Selector="Button">
<Setter Property="Theme" Value="{DynamicResource SolidButton}" />
<Setter Property="HorizontalAlignment" Value="Stretch" />
</Style>
</StackPanel.Styles>
<Button Click="InfoButton_OnClick" Content="Default" />
<Button Click="InfoButton_OnClick" Content="Information" />
<Button Click="InfoButton_OnClick" Content="Success" Classes="Success" />
<Button Click="InfoButton_OnClick" Content="Warning" Classes="Warning" />
<Button Click="InfoButton_OnClick" Content="Error" Classes="Danger" />
<StackPanel Spacing="20">
<StackPanel Orientation="Horizontal" Spacing="20">
<Button Click="NormalButton_OnClick" Content="Information" />
<Button Click="NormalButton_OnClick" Content="Success" Classes="Success" />
<Button Click="NormalButton_OnClick" Content="Warning" Classes="Warning" />
<Button Click="NormalButton_OnClick" Content="Error" Classes="Danger" />
</StackPanel>
<StackPanel Orientation="Horizontal">
<Button Click="PositionButton_OnClick" Content="TopLeft" />
<Button Click="PositionButton_OnClick" Content="TopCenter" />
<Button Click="PositionButton_OnClick" Content="TopRight" />
</StackPanel>
<StackPanel Orientation="Horizontal">
<Button Click="PositionButton_OnClick" Content="BottomLeft" />
<Button Click="PositionButton_OnClick" Content="BottomCenter" />
<Button Click="PositionButton_OnClick" Content="BottomRight" />
</StackPanel>
<StackPanel Orientation="Horizontal" Spacing="20">
<StackPanel.Styles>
<Style Selector="Button">
<Setter Property="Theme" Value="{DynamicResource SolidButton}" />
</Style>
</StackPanel.Styles>
<Button Click="LightButton_OnClick" Content="Information" />
<Button Click="LightButton_OnClick" Content="Success" Classes="Success" />
<Button Click="LightButton_OnClick" Content="Warning" Classes="Warning" />
<Button Click="LightButton_OnClick" Content="Error" Classes="Danger" />
</StackPanel>
</StackPanel>
</UserControl>

View File

@@ -22,13 +22,35 @@ public partial class NotificationDemo : UserControl
_manager = new WindowNotificationManager(topLevel) { MaxItems = 3 };
}
private void InfoButton_OnClick(object? sender, RoutedEventArgs e)
private void NormalButton_OnClick(object? sender, RoutedEventArgs e)
{
if (sender is Button b && b.Content is string s)
{
_manager?.Show(Enum.TryParse<NotificationType>(s, out NotificationType t)
_manager?.Show(Enum.TryParse<NotificationType>(s, out var t)
? new Notification(t.ToString(), "This is message", t)
: new Notification(s, "This is message"));
}
}
private void PositionButton_OnClick(object? sender, RoutedEventArgs e)
{
if (sender is Button b && b.Content is string s)
{
Enum.TryParse<NotificationPosition>(s, out var t);
_manager.Position = t;
_manager?.Show(new Notification(t.ToString(), "This is message"));
}
}
private void LightButton_OnClick(object? sender, RoutedEventArgs e)
{
if (sender is Button b && b.Content is string s)
{
Enum.TryParse<NotificationType>(s, out var notificationType);
_manager?.Show(
new Notification(notificationType.ToString(), "This is message"),
type: notificationType,
classes: ["Light"]);
}
}
}