2019-05-18 17:25:36 -04:00
|
|
|
|
using System;
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.Runtime.CompilerServices;
|
2019-07-15 15:03:59 -04:00
|
|
|
|
using System.Threading.Tasks;
|
2019-11-06 22:32:43 -05:00
|
|
|
|
using Aurora.Models.Media;
|
|
|
|
|
using Xamarin.Forms;
|
2019-11-08 19:54:51 -05:00
|
|
|
|
using Aurora.Design.Views.Main;
|
2019-05-18 17:25:36 -04:00
|
|
|
|
|
2019-07-05 14:17:09 -04:00
|
|
|
|
namespace Aurora.Design.Views
|
2019-05-18 17:25:36 -04:00
|
|
|
|
{
|
2019-11-08 19:54:51 -05:00
|
|
|
|
|
2019-05-22 10:30:41 -04:00
|
|
|
|
public class BaseViewModel : INotifyPropertyChanged
|
2019-05-18 17:25:36 -04:00
|
|
|
|
{
|
|
|
|
|
public BaseViewModel()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2019-11-06 22:32:43 -05:00
|
|
|
|
#region Player
|
|
|
|
|
|
2019-11-08 19:54:51 -05:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Command event handler for player play button
|
|
|
|
|
/// </summary>
|
2019-11-09 14:55:09 -05:00
|
|
|
|
public virtual void OnPlayButtonExecute() { }
|
|
|
|
|
public virtual bool CanPlayButtonExecute()
|
2019-11-06 22:32:43 -05:00
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2019-11-08 19:54:51 -05:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Command event handler for player next button
|
|
|
|
|
/// </summary>
|
2019-11-09 14:55:09 -05:00
|
|
|
|
public virtual void OnNextButtonExecute() { }
|
|
|
|
|
public virtual bool CanNextButtonExecute()
|
2019-11-06 22:32:43 -05:00
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2019-11-08 19:54:51 -05:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Command event handler for player previous button
|
|
|
|
|
/// </summary>
|
2019-11-09 14:55:09 -05:00
|
|
|
|
public virtual void OnPreviousButtonExecute() { }
|
|
|
|
|
public virtual bool CanPreviousButtonExecute()
|
2019-11-06 22:32:43 -05:00
|
|
|
|
{
|
2019-11-08 19:54:51 -05:00
|
|
|
|
return true;
|
2019-11-06 22:32:43 -05:00
|
|
|
|
}
|
2019-11-08 19:54:51 -05:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
2019-12-04 20:42:23 -08:00
|
|
|
|
/// Delegate for interacting with main screen player control
|
2019-11-08 19:54:51 -05:00
|
|
|
|
/// </summary>
|
|
|
|
|
/// <value></value>
|
2019-12-04 20:42:23 -08:00
|
|
|
|
public SetPlayerDelegate ChangePlayerState { get; set; }
|
2019-11-06 22:32:43 -05:00
|
|
|
|
|
2019-12-04 20:42:23 -08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Delegate for checking if main screen player control is currently playing
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <value></value>
|
|
|
|
|
public GetIsPlayingDelegate IsPlaying { get; set; }
|
2019-11-09 14:55:09 -05:00
|
|
|
|
|
2019-12-18 22:32:08 -05:00
|
|
|
|
public ShowModalDelegate ShowModal { get; set; }
|
|
|
|
|
|
|
|
|
|
public HideModalDelegate HideModal { get; set; }
|
2019-12-07 13:47:45 -05:00
|
|
|
|
|
2019-12-04 14:53:49 -08:00
|
|
|
|
|
2019-11-06 22:32:43 -05:00
|
|
|
|
#endregion Player
|
|
|
|
|
|
2019-07-15 15:03:59 -04:00
|
|
|
|
#region Lifecycle
|
2019-12-04 20:42:23 -08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Called by main screen on view appearing
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <typeparam name="object"></typeparam>
|
|
|
|
|
/// <returns></returns>
|
2019-11-29 12:37:57 -05:00
|
|
|
|
public virtual Task OnActive() { return Task.FromResult<object>(null); }
|
2019-07-15 15:03:59 -04:00
|
|
|
|
|
2019-12-04 20:42:23 -08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Called by main screen on view disappearing
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <typeparam name="object"></typeparam>
|
|
|
|
|
/// <returns></returns>
|
2019-11-29 12:37:57 -05:00
|
|
|
|
public virtual Task OnInactive() { return Task.FromResult<object>(null); }
|
2019-07-15 15:03:59 -04:00
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
2019-05-18 17:25:36 -04:00
|
|
|
|
#region INotifyPropertyChanged Implementation
|
2019-05-22 10:30:41 -04:00
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2019-05-18 17:25:36 -04:00
|
|
|
|
public event PropertyChangedEventHandler PropertyChanged;
|
|
|
|
|
public void OnPropertyChanged([CallerMemberName] string propertyName = "")
|
|
|
|
|
{
|
|
|
|
|
if (PropertyChanged == null)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
PropertyChanged.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
}
|