/* TODO: Refactor as popup, detach from the window renderer */
using System.Windows.Controls;
using WPFluent.Input;
// ReSharper disable once CheckNamespace
namespace WPFluent.Controls;
///
/// Snackbar inform user of a process that an app has performed or will perform. It appears temporarily, towards the
/// bottom of the window.
///
public class Snackbar : ContentControl, IAppearanceControl, IIconControl
{
///
/// Identifies the dependency property.
///
public static readonly DependencyProperty AppearanceProperty = DependencyProperty.Register(
nameof(Appearance),
typeof(ControlAppearance),
typeof(Snackbar),
new PropertyMetadata(ControlAppearance.Secondary));
///
/// Identifies the routed event.
///
public static readonly RoutedEvent ClosedEvent = EventManager.RegisterRoutedEvent(
nameof(Closed),
RoutingStrategy.Bubble,
typeof(TypedEventHandler),
typeof(Snackbar));
///
/// Identifies the dependency property.
///
public static readonly DependencyProperty ContentForegroundProperty = DependencyProperty.Register(
nameof(ContentForeground),
typeof(Brush),
typeof(Snackbar),
new FrameworkPropertyMetadata(SystemColors.ControlTextBrush, FrameworkPropertyMetadataOptions.Inherits));
///
/// Identifies the dependency property.
///
public static readonly DependencyProperty IconProperty = DependencyProperty.Register(
nameof(Icon),
typeof(IconElement),
typeof(Snackbar),
new PropertyMetadata(null, null, IconElement.Coerce));
///
/// Identifies the dependency property.
///
public static readonly DependencyProperty IsCloseButtonEnabledProperty = DependencyProperty.Register(
nameof(IsCloseButtonEnabled),
typeof(bool),
typeof(Snackbar),
new PropertyMetadata(true));
///
/// Identifies the dependency property.
///
public static readonly DependencyProperty IsShownProperty = DependencyProperty.Register(
nameof(IsShown),
typeof(bool),
typeof(Snackbar),
new PropertyMetadata(false, (d, e) => (d as Snackbar)?.OnIsShownChanged(e)));
///
/// Identifies the routed event.
///
public static readonly RoutedEvent OpenedEvent = EventManager.RegisterRoutedEvent(
nameof(Opened),
RoutingStrategy.Bubble,
typeof(TypedEventHandler),
typeof(Snackbar));
///
/// Identifies the dependency property.
///
public static readonly DependencyProperty SlideTransformProperty = DependencyProperty.Register(
nameof(SlideTransform),
typeof(TranslateTransform),
typeof(Snackbar),
new PropertyMetadata(null));
///
/// Identifies the dependency property.
///
public static readonly DependencyProperty TemplateButtonCommandProperty = DependencyProperty.Register(
nameof(TemplateButtonCommand),
typeof(IRelayCommand),
typeof(Snackbar),
new PropertyMetadata(null));
///
/// Identifies the dependency property.
///
public static readonly DependencyProperty TimeoutProperty = DependencyProperty.Register(
nameof(Timeout),
typeof(TimeSpan),
typeof(Snackbar),
new PropertyMetadata(TimeSpan.FromSeconds(2)));
///
/// Identifies the dependency property.
///
public static readonly DependencyProperty TitleProperty = DependencyProperty.Register(
nameof(Title),
typeof(object),
typeof(Snackbar),
new PropertyMetadata(null));
///
/// Identifies the dependency property.
///
public static readonly DependencyProperty TitleTemplateProperty = DependencyProperty.Register(
nameof(TitleTemplate),
typeof(DataTemplate),
typeof(Snackbar),
new PropertyMetadata(null));
///
/// Initializes a new instance of the class with a specified presenter.
///
/// The to manage the snackbar's display and interactions.
public Snackbar(SnackbarPresenter presenter)
{
Presenter = presenter;
SetValue(TemplateButtonCommandProperty, new RelayCommand