// Copyright (c) Arlo Godfrey. All Rights Reserved.
// Licensed under the GNU Lesser General Public License, Version 3.0 with additional terms.
// See the LICENSE, LICENSE.LESSER and LICENSE.ADDITIONAL files in the project root for more information.
using System.Collections.ObjectModel;
using System.ComponentModel;
using OwlCore.AbstractUI.Models;
using OwlCore.AbstractUI.ViewModels;
namespace StrixMusic.Sdk.ViewModels.Notifications
{
///
/// Wraps an intended for Notifications and parses supported elements for rendering.
///
[Bindable(true)]
public sealed class AbstractUINotificationViewModel : AbstractUICollectionViewModel
{
private const int MAX_BUTTONS = 3;
private readonly AbstractUICollection _model;
///
public AbstractUINotificationViewModel(AbstractUICollection model)
: base(model)
{
_model = model;
EvaluateSupportedItems();
}
private void EvaluateSupportedItems()
{
foreach (var value in _model)
{
if (value is AbstractProgressIndicator progressUIElement && ProgressIndicator is null)
{
ProgressIndicator = new AbstractProgressIndicatorViewModel(progressUIElement);
}
else if (value is AbstractButton buttonElement && Buttons.Count < MAX_BUTTONS)
{
Buttons.Add(new AbstractButtonViewModel(buttonElement));
}
else
{
UnsupportedItems.Add(value);
}
}
}
///
/// A list of s were given to the notification that aren't explicitly supported.
/// The can be displayed in popout window if desired.
///
public ObservableCollection UnsupportedItems { get; set; } = new ObservableCollection();
///
/// An that may appear in a notification.
///
public AbstractProgressIndicatorViewModel? ProgressIndicator { get; set; }
///
/// A list of s that may appear in a notification
///
public ObservableCollection Buttons { get; set; } = new ObservableCollection();
}
}