This repository has been archived on 2020-12-20. You can view files and clone it, but cannot push or open issues or pull requests.
aurora-sharp-desktop/Aurora/Design/Views/BaseViewModel.cs
2020-01-18 18:07:31 -05:00

105 lines
2.9 KiB
C#

using System;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
using Aurora.Models.Media;
using Xamarin.Forms;
using Aurora.Design.Views.Main;
namespace Aurora.Design.Views
{
public class BaseViewModel : INotifyPropertyChanged
{
public BaseViewModel()
{
}
#region Player
/// <summary>
/// Command event handler for player play button
/// </summary>
public virtual void OnPlayButtonCommandExecute() { }
public virtual bool CanPlayButtonCommandExecute()
{
return true;
}
/// <summary>
/// Command event handler for player next button
/// </summary>
public virtual void OnNextButtonExecute() { }
public virtual bool CanNextButtonCommandExecute()
{
return true;
}
/// <summary>
/// Command event handler for player previous button
/// </summary>
public virtual void OnPreviousButtonExecute() { }
public virtual bool CanPreviousButtonCommandExecute()
{
return true;
}
/// <summary>
/// Delegate for interacting with main screen player control
/// </summary>
/// <value></value>
public SetPlayerDelegate ChangePlayerState { get; set; }
/// <summary>
/// Delegate for checking if main screen player control is currently playing
/// </summary>
/// <value></value>
public GetIsPlayingDelegate IsPlaying { get; set; }
public ShowModalDelegate ShowModal { get; set; }
public HideModalDelegate HideModal { get; set; }
#endregion Player
#region Lifecycle
/// <summary>
/// Called by main screen on view appearing
/// </summary>
/// <typeparam name="object"></typeparam>
/// <returns></returns>
public virtual Task OnActive() { return Task.FromResult<object>(null); }
/// <summary>
/// Called by main screen on view disappearing
/// </summary>
/// <typeparam name="object"></typeparam>
/// <returns></returns>
public virtual Task OnInactive() { return Task.FromResult<object>(null); }
#endregion
#region INotifyPropertyChanged Implementation
public bool SetProperty<T>(ref T storage, T value, [CallerMemberName] string propertyName = null)
{
if (Object.Equals(storage, value))
return false;
storage = value;
OnPropertyChanged(propertyName);
return true;
}
public event PropertyChangedEventHandler PropertyChanged;
public void OnPropertyChanged([CallerMemberName] string propertyName = "")
{
if (PropertyChanged == null)
return;
PropertyChanged.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
#endregion
}
}