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