diff --git a/src/Wpf.Ui/ISnackbarService.cs b/src/Wpf.Ui/ISnackbarService.cs
index 127e889d38d29ceda60910f88e4bdbc47c5e5b52..42a503e64d8b0d76e67fd998442014f60647e3c9 100644
--- a/src/Wpf.Ui/ISnackbarService.cs
+++ b/src/Wpf.Ui/ISnackbarService.cs
@@ -22,28 +22,102 @@ public interface ISnackbarService
///
/// Sets the
///
- ///
+ /// inside of which the snackbar will be placed. The new will replace the current .
void SetSnackbarPresenter(SnackbarPresenter contentPresenter);
///
/// Provides direct access to the
///
- ///
+ /// currently in use.
SnackbarPresenter GetSnackbarPresenter();
///
/// Shows the snackbar. If it is already visible, firstly hides it for a moment, changes its content, and then shows it again.
///
- ///
- ///
- ///
- ///
- ///
+ /// Name displayed on top of snackbar.
+ /// Message inside the snackbar.
+ void Show(
+ string title,
+ string message
+ );
+
+ ///
+ /// Shows the snackbar. If it is already visible, firstly hides it for a moment, changes its content, and then shows it again.
+ ///
+ /// Name displayed on top of snackbar.
+ /// Message inside the snackbar.
+ /// Display style.
+ void Show(
+ string title,
+ string message,
+ ControlAppearance appearance
+ );
+
+ ///
+ /// Shows the snackbar. If it is already visible, firstly hides it for a moment, changes its content, and then shows it again.
+ ///
+ /// Name displayed on top of snackbar.
+ /// Message inside the snackbar.
+ /// Additional icon on the left.
+ void Show(
+ string title,
+ string message,
+ IconElement icon
+ );
+
+ ///
+ /// Shows the snackbar. If it is already visible, firstly hides it for a moment, changes its content, and then shows it again.
+ ///
+ /// Name displayed on top of snackbar.
+ /// Message inside the snackbar.
+ /// The time after which the snackbar should disappear.
+ void Show(
+ string title,
+ string message,
+ TimeSpan timeout
+ );
+
+ ///
+ /// Shows the snackbar. If it is already visible, firstly hides it for a moment, changes its content, and then shows it again.
+ ///
+ /// Name displayed on top of snackbar.
+ /// Message inside the snackbar.
+ /// Display style.
+ /// The time after which the snackbar should disappear.
+ void Show(
+ string title,
+ string message,
+ ControlAppearance appearance,
+ TimeSpan timeout
+ );
+
+ ///
+ /// Shows the snackbar. If it is already visible, firstly hides it for a moment, changes its content, and then shows it again.
+ ///
+ /// Name displayed on top of snackbar.
+ /// Message inside the snackbar.
+ /// Additional icon on the left.
+ /// The time after which the snackbar should disappear.
+ void Show(
+ string title,
+ string message,
+ IconElement icon,
+ TimeSpan timeout
+ );
+
+ ///
+ /// Shows the snackbar. If it is already visible, firstly hides it for a moment, changes its content, and then shows it again.
+ ///
+ /// Name displayed on top of snackbar.
+ /// Message inside the snackbar.
+ /// Display style.
+ /// Additional icon on the left.
+ /// The time after which the snackbar should disappear.
void Show(
string title,
string message,
- ControlAppearance appearance = ControlAppearance.Secondary,
- IconElement? icon = null,
- TimeSpan timeout = default
+ ControlAppearance appearance,
+ IconElement? icon,
+ TimeSpan timeout
);
}
diff --git a/src/Wpf.Ui/SnackbarService.cs b/src/Wpf.Ui/SnackbarService.cs
index e95dcff6e8d0477e85f46cda3fe3e8e90b47e44f..7b8399d6bd20b3b18d576ba377584f72376e91f3 100644
--- a/src/Wpf.Ui/SnackbarService.cs
+++ b/src/Wpf.Ui/SnackbarService.cs
@@ -4,7 +4,6 @@
// All Rights Reserved.
using System;
-using Wpf.Ui.Contracts;
using Wpf.Ui.Controls;
namespace Wpf.Ui;
@@ -15,6 +14,7 @@ namespace Wpf.Ui;
public class SnackbarService : ISnackbarService
{
private SnackbarPresenter? _presenter;
+
private Snackbar? _snackbar;
///
@@ -30,31 +30,72 @@ public void SetSnackbarPresenter(SnackbarPresenter contentPresenter)
public SnackbarPresenter GetSnackbarPresenter()
{
if (_presenter is null)
+ {
throw new ArgumentNullException($"The SnackbarPresenter didn't set previously.");
+ }
return _presenter;
}
+ ///
+ public void Show(string title, string message)
+ {
+ Show(title, message, ControlAppearance.Secondary, null, new TimeSpan(2));
+ }
+
+ ///
+ public void Show(string title, string message, ControlAppearance appearance)
+ {
+ Show(title, message, appearance, null, new TimeSpan(2));
+ }
+
+ ///
+ public void Show(string title, string message, IconElement icon)
+ {
+ Show(title, message, ControlAppearance.Secondary, icon, new TimeSpan(2));
+ }
+
+ ///
+ public void Show(string title, string message, TimeSpan timeout)
+ {
+ Show(title, message, ControlAppearance.Secondary, null, timeout);
+ }
+
+ ///
+ public void Show(string title, string message, ControlAppearance appearance, TimeSpan timeout)
+ {
+ Show(title, message, appearance, null, timeout);
+ }
+
+ ///
+ public void Show(string title, string message, IconElement icon, TimeSpan timeout)
+ {
+ Show(title, message, ControlAppearance.Secondary, icon, timeout);
+ }
+
///
public void Show(
string title,
string message,
- ControlAppearance appearance = ControlAppearance.Secondary,
- IconElement? icon = null,
- TimeSpan timeout = default
+ ControlAppearance appearance,
+ IconElement? icon,
+ TimeSpan timeout
)
{
if (_presenter is null)
+ {
throw new ArgumentNullException($"The SnackbarPresenter didn't set previously.");
+ }
_snackbar ??= new Snackbar(_presenter);
- _snackbar.Title = title;
- _snackbar.Content = message;
- _snackbar.Appearance = appearance;
- _snackbar.Icon = icon;
- _snackbar.Timeout = timeout.TotalSeconds == 0 ? DefaultTimeOut : timeout;
+ _snackbar.SetCurrentValue(Snackbar.TitleProperty, title);
+ _snackbar.SetCurrentValue(System.Windows.Controls.ContentControl.ContentProperty, message);
+ _snackbar.SetCurrentValue(Snackbar.AppearanceProperty, appearance);
+ _snackbar.SetCurrentValue(Snackbar.IconProperty, icon);
+ _snackbar.SetCurrentValue(Snackbar.TimeoutProperty, timeout.TotalSeconds == 0 ? DefaultTimeOut : timeout);
_snackbar.Show(true);
}
+
}