Browse Source

implement notifications page in control catalog

pull/2453/head
Dan Walmsley 7 years ago
parent
commit
96d912c46c
  1. 2
      samples/ControlCatalog/MainView.xaml
  2. 9
      samples/ControlCatalog/Pages/NotificationsPage.xaml
  3. 36
      samples/ControlCatalog/ViewModels/MainWindowViewModel.cs
  4. 2
      samples/ControlCatalog/Views/NotificationView.xaml

2
samples/ControlCatalog/MainView.xaml

@ -29,7 +29,7 @@
<TabItem Header="LayoutTransformControl"><pages:LayoutTransformControlPage/></TabItem>
<TabItem Header="ListBox"><pages:ListBoxPage/></TabItem>
<TabItem Header="Menu"><pages:MenuPage/></TabItem>
<TabItem Header="Notifications"><pages:NotificationPage/></TabItem>
<TabItem Header="Notifications"><pages:NotificationsPage/></TabItem>
<TabItem Header="NumericUpDown"><pages:NumericUpDownPage/></TabItem>
<TabItem Header="NumericUpDown"><pages:NumericUpDownPage/></TabItem>
<TabItem Header="ProgressBar"><pages:ProgressBarPage/></TabItem>

9
samples/ControlCatalog/Pages/NotificationsPage.xaml

@ -1,9 +1,10 @@
<UserControl xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="ControlCatalog.Pages.NotificationsPage">
<StackPanel Orientation="Vertical" Spacing="4">
<Button Content="Show Custom Managed Notification" />
<Button Content="Show Standard Managed Notification" />
<Button Content="Show Native Notification" />
<StackPanel Orientation="Vertical" Spacing="4" HorizontalAlignment="Left">
<TextBlock Classes="h1">Notifications</TextBlock>
<Button Content="Show Standard Managed Notification" Command="{Binding ShowManagedNotificationCommand}" />
<Button Content="Show Custom Managed Notification" Command="{Binding ShowCustomManagedNotificationCommand}" />
<Button Content="Show Native Notification" Command="{Binding ShowNativeNotificationCommand}" />
</StackPanel>
</UserControl>

36
samples/ControlCatalog/ViewModels/MainWindowViewModel.cs

@ -1,7 +1,9 @@
using System.Reactive;
using System.Threading.Tasks;
using Avalonia.Controls.Notifications;
using Avalonia.Diagnostics.ViewModels;
using Avalonia.Threading;
using ReactiveUI;
namespace ControlCatalog.ViewModels
{
@ -9,27 +11,19 @@ namespace ControlCatalog.ViewModels
{
public MainWindowViewModel()
{
Dispatcher.UIThread.InvokeAsync(async () =>
ShowCustomManagedNotificationCommand = ReactiveCommand.Create(() =>
{
await Task.Delay(5000);
NotificationManager.Show(new NotificationViewModel (NotificationManager) { Title = "Warning", Message = "Did you know that Avalonia now supports Notifications?" });
await Task.Delay(1500);
NotificationManager.Show(new NotificationContent { Title= "Title", Message = "Test2", Type = NotificationType.Error });
await Task.Delay(2000);
NotificationManager.Show(new NotificationContent { Title = "Title", Message = "Test3", Type = NotificationType.Warning });
await Task.Delay(2500);
NotificationManager.Show(new NotificationContent { Title = "Title", Message = "Test4", Type = NotificationType.Success });
await Task.Delay(2500);
NotificationManager.Show(new NotificationContent { Title = "Title", Message = "Test5", Type = NotificationType.Information });
NotificationManager.Show(new NotificationViewModel(NotificationManager) { Title = "Hey There!", Message = "Did you know that Avalonia now supports Custom In-Window Notifications?" });
});
await Task.Delay(500);
NotificationManager.Show("Test5");
ShowManagedNotificationCommand = ReactiveCommand.Create(() =>
{
NotificationManager.Show(new NotificationContent { Title = "Welcome", Message = "Avalonia now supports Notifications.", Type = NotificationType.Information });
});
ShowNativeNotificationCommand = ReactiveCommand.Create(() =>
{
NotificationManager.Show(new NotificationContent { Title = "Error", Message = "Native Notifications are not quite ready. Coming soon.", Type = NotificationType.Error });
});
}
@ -40,5 +34,11 @@ namespace ControlCatalog.ViewModels
get { return _notificationManager; }
set { this.RaiseAndSetIfChanged(ref _notificationManager, value); }
}
public ReactiveCommand<Unit, Unit> ShowCustomManagedNotificationCommand { get; }
public ReactiveCommand<Unit, Unit> ShowManagedNotificationCommand { get; }
public ReactiveCommand<Unit, Unit> ShowNativeNotificationCommand { get; }
}
}

2
samples/ControlCatalog/Views/NotificationView.xaml

@ -1,7 +1,7 @@
<UserControl xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="ControlCatalog.Views.NotificationView">
<Border Padding="12" MinHeight="20" Background="Teal">
<Border Padding="12" MinHeight="20" Background="DodgerBlue">
<Grid ColumnDefinitions="Auto,*">
<Panel Margin="0,0,12,0" Width="25" Height="25" VerticalAlignment="Top">
<TextBlock Text="&#xE115;" FontFamily="Segoe UI Symbol" FontSize="20" TextAlignment="Center" VerticalAlignment="Center"/>

Loading…
Cancel
Save