Browse Source

Revert breaking change

pull/12178/head
Tim 3 years ago
parent
commit
eadf63ce45
  1. 8
      src/Avalonia.Controls/Notifications/IManagedNotificationManager.cs
  2. 21
      src/Avalonia.Controls/Notifications/WindowNotificationManager.cs

8
src/Avalonia.Controls/Notifications/IManagedNotificationManager.cs

@ -15,6 +15,12 @@ namespace Avalonia.Controls.Notifications
[NotClientImplementable]
public interface IManagedNotificationManager : INotificationManager
{
/// <summary>
/// Shows a notification.
/// </summary>
/// <param name="content">The content to be displayed.</param>
void Show(object content);
/// <summary>
/// Shows a notification.
/// </summary>
@ -25,7 +31,7 @@ namespace Avalonia.Controls.Notifications
/// <param name="onClose">an Action to be run when the notification is closed.</param>
/// <param name="classes">Style-classes to ba added to the notification card</param>
void Show(object content,
NotificationType type = NotificationType.Information,
NotificationType type,
TimeSpan? expiration = null,
Action? onClick = null,
Action? onClose = null,

21
src/Avalonia.Controls/Notifications/WindowNotificationManager.cs

@ -73,8 +73,8 @@ namespace Avalonia.Controls.Notifications
/// <summary>
/// Initializes a new instance of the <see cref="WindowNotificationManager"/> class.
/// </summary>
/// <param name="host">The visual that will host the control.</param>
public WindowNotificationManager(Visual? host) : this()
/// <param name="host">The TopLevel that will host the control.</param>
public WindowNotificationManager(TopLevel? host) : this()
{
Host = host;
}
@ -108,9 +108,22 @@ namespace Avalonia.Controls.Notifications
Show(content, content.Type, content.Expiration, content.OnClick, content.OnClose);
}
/// <inheritdoc/>
public async void Show(object content)
{
if (content is INotification notification)
{
Show(notification, notification.Type, notification.Expiration, notification.OnClick, notification.OnClose);
}
else
{
Show(content, NotificationType.Information);
}
}
/// <inheritdoc/>
public async void Show(object content,
NotificationType type = NotificationType.Information,
NotificationType type,
TimeSpan? expiration = null,
Action? onClick = null,
Action? onClose = null,
@ -202,7 +215,7 @@ namespace Avalonia.Controls.Notifications
if (adornerLayer is not null)
{
adornerLayer.Children.Add(this);
// adornerLayer.Children.Add(this);
AdornerLayer.SetAdornedElement(this, adornerLayer);
}
}

Loading…
Cancel
Save