86 lines
2.2 KiB
C#
86 lines
2.2 KiB
C#
using System.Windows.Input;
|
|
using ytLive.Helpers;
|
|
|
|
namespace ytLive.ViewModels;
|
|
|
|
public class GoLiveViewModel : ViewModelBase
|
|
{
|
|
private bool _isSignedIn;
|
|
private string _accountName = string.Empty;
|
|
private string _streamTitle = string.Empty;
|
|
private string _streamDescription = string.Empty;
|
|
private string _visibility = "Public";
|
|
|
|
public bool IsSignedIn
|
|
{
|
|
get => _isSignedIn;
|
|
set
|
|
{
|
|
if (SetProperty(ref _isSignedIn, value))
|
|
{
|
|
OnPropertyChanged(nameof(ShowSignIn));
|
|
OnPropertyChanged(nameof(ShowAccount));
|
|
}
|
|
}
|
|
}
|
|
|
|
public bool ShowSignIn => !IsSignedIn;
|
|
public bool ShowAccount => IsSignedIn;
|
|
|
|
public string AccountName
|
|
{
|
|
get => _accountName;
|
|
set => SetProperty(ref _accountName, value);
|
|
}
|
|
|
|
public string StreamTitle
|
|
{
|
|
get => _streamTitle;
|
|
set => SetProperty(ref _streamTitle, value);
|
|
}
|
|
|
|
public string StreamDescription
|
|
{
|
|
get => _streamDescription;
|
|
set => SetProperty(ref _streamDescription, value);
|
|
}
|
|
|
|
public string Visibility
|
|
{
|
|
get => _visibility;
|
|
set => SetProperty(ref _visibility, value);
|
|
}
|
|
|
|
public string[] Visibilities { get; } = { "Public", "Unlisted", "Private" };
|
|
|
|
public ICommand SignInCommand { get; }
|
|
public ICommand ChangeAccountCommand { get; }
|
|
public ICommand StartCommand { get; }
|
|
public ICommand CancelCommand { get; }
|
|
|
|
public GoLiveViewModel()
|
|
{
|
|
SignInCommand = new RelayCommand(_ => SignIn());
|
|
ChangeAccountCommand = new RelayCommand(_ => ChangeAccount());
|
|
StartCommand = new RelayCommand(_ => StartRequested?.Invoke(), _ => IsSignedIn);
|
|
CancelCommand = new RelayCommand(_ => CancelRequested?.Invoke());
|
|
}
|
|
|
|
public event Action? StartRequested;
|
|
public event Action? CancelRequested;
|
|
|
|
private void SignIn()
|
|
{
|
|
// TODO: OAuth2 flow; for now simulate a successful sign-in
|
|
AccountName = "Connected Channel";
|
|
IsSignedIn = true;
|
|
}
|
|
|
|
private void ChangeAccount()
|
|
{
|
|
// TODO: re-run OAuth2; for now simulate signing out
|
|
IsSignedIn = false;
|
|
AccountName = string.Empty;
|
|
}
|
|
}
|