Reorganization

This commit is contained in:
watsonb8
2019-07-05 14:17:09 -04:00
parent a01d399a1f
commit ec6a7586c7
76 changed files with 475 additions and 296 deletions

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<ContentView
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Aurora.Design.Views.Albums.AlbumsView">
<ContentPage.Content>
<Grid></Grid>
</ContentPage.Content>
</ContentView>

View File

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using Xamarin.Forms;
namespace Aurora.Design.Views.Albums
{
public partial class AlbumsView : ContentView
{
public AlbumsView()
{
InitializeComponent();
}
}
}

View File

@ -0,0 +1,10 @@
using System;
namespace Aurora.Design.Views.Albums
{
public class AlbumsViewModel
{
public AlbumsViewModel()
{
}
}
}

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<ContentView
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Aurora.Design.Views.Artists.ArtistsView">
<ContentPage.Content></ContentPage.Content>
</ContentView>

View File

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using Xamarin.Forms;
namespace Aurora.Design.Views.Artists
{
public partial class ArtistsView : ContentView
{
public ArtistsView()
{
InitializeComponent();
}
}
}

View File

@ -0,0 +1,10 @@
using System;
namespace Aurora.Design.Views.Artists
{
public class ArtistsViewModel
{
public ArtistsViewModel()
{
}
}
}

View File

@ -0,0 +1,34 @@
using System;
using System.ComponentModel;
using System.Runtime.CompilerServices;
namespace Aurora.Design.Views
{
public class BaseViewModel : INotifyPropertyChanged
{
public BaseViewModel()
{
}
#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
}
}

View File

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<MasterDetailPage
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:views="clr-namespace:Aurora.Design.Views.MainView"
xmlns:navigation="clr-namespace:Aurora.Design.Components.NavigationMenu"
x:Class="Aurora.Design.Views.Main.MainView"
MasterBehavior="Split">
<MasterDetailPage.Master>
<navigation:NavigationMenu
x:Name="MasterPage"
Items="{Binding Pages}"/>
</MasterDetailPage.Master>
<MasterDetailPage.Detail>
<NavigationPage>
<x:Arguments>
<views:PageContainer
x:Name="ContentPage"/>
</x:Arguments>
</NavigationPage>
</MasterDetailPage.Detail>
</MasterDetailPage>

View File

@ -0,0 +1,59 @@
using System;
using System.Collections.ObjectModel;
using System.Linq;
using Aurora.Design.Components.NavigationMenu;
using Aurora.Design.Views.MainView;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;
namespace Aurora.Design.Views.Main
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class MainView : MasterDetailPage
{
public MainView()
{
InitializeComponent();
BindingContext = new MainViewModel();
MasterPage.ListView.ItemSelected += ListView_ItemSelected;
Appearing += OnAppearing;
}
~MainView()
{
Appearing -= OnAppearing;
}
private void ListView_ItemSelected(object sender, SelectedItemChangedEventArgs e)
{
var item = e.SelectedItem as NavigationItem;
if (item == null)
return;
var view = (View)Activator.CreateInstance(item.TargetType);
ContentPresenter viewContent = (ContentPresenter)ContentPage.Content.FindByName("ViewContent");
viewContent.Content = view;
MasterPage.ListView.SelectedItem = null;
}
/// <summary>
/// Event handler for page appearing.
/// </summary>
/// <param name="sender">The object that fired the event.</param>
/// <param name="args">The event arguments</param>
private void OnAppearing(object sender, EventArgs args)
{
//Set initial view from first item in list
ObservableCollection<NavigationGroupItem> screenList = (ObservableCollection<NavigationGroupItem>)MasterPage.ListView.ItemsSource;
var view = (View)Activator.CreateInstance(screenList.FirstOrDefault().FirstOrDefault().TargetType);
ContentPresenter viewContent = (ContentPresenter)ContentPage.Content.FindByName("ViewContent");
viewContent.Content = view;
MasterPage.ListView.SelectedItem = screenList.FirstOrDefault();
}
}
}

View File

@ -0,0 +1,46 @@
using System;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using Aurora.Design.Components.NavigationMenu;
using Aurora.Design.Views.Albums;
using Aurora.Design.Views.Artists;
using Aurora.Design.Views.Songs;
using Aurora.Design.Views.Stations;
using Aurora.Design.Views.Party;
using Aurora.Design.Views.Profile;
namespace Aurora.Design.Views.MainView
{
public class MainViewModel : BaseViewModel
{
private ObservableCollection<NavigationItem> _pages;
public ObservableCollection<NavigationItem> Pages
{
get { return _pages; }
set
{
if (value != _pages)
{
_pages = value;
OnPropertyChanged("Pages");
}
}
}
public MainViewModel()
{
_pages = new ObservableCollection<NavigationItem>(new[]
{
new NavigationItem { Id = 4, Title = "Party", Group="Social", TargetType = typeof(PartyView)},
new NavigationItem { Id = 5, Title = "Profile", Group="Social", TargetType = typeof(ProfileView)},
new NavigationItem { Id = 0, Title = "Songs", Group="Library", TargetType = typeof(SongsView) },
new NavigationItem { Id = 1, Title = "Artists", Group="Library", TargetType = typeof(ArtistsView)},
new NavigationItem { Id = 2, Title = "Albums", Group="Library", TargetType = typeof(AlbumsView)},
new NavigationItem { Id = 3, Title = "Stations", Group="Library", TargetType = typeof(StationsView)},
});
}
}
}

View File

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<ContentPage
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:components="clr-namespace:Aurora.Design.Components"
xmlns:mp="clr-namespace:Aurora.Design.Components.MediaPlayer"
x:Class="Aurora.Design.Views.MainView.PageContainer">
<ContentPage.Content>
<Grid>
<Grid.RowDefinitions>
<RowDefinition
Height="*"/>
<RowDefinition
Height="50"/>
</Grid.RowDefinitions>
<ContentPresenter
Grid.Row="0"
x:Name="ViewContent"/>
<mp:Player
Grid.Row="1"
HorizontalOptions="CenterAndExpand"
VerticalOptions="End"
HeightRequest="200"/>
</Grid>
</ContentPage.Content>
</ContentPage>

View File

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using Xamarin.Forms;
namespace Aurora.Design.Views.MainView
{
public partial class PageContainer : ContentPage
{
public PageContainer()
{
InitializeComponent();
}
}
}

View File

@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<ContentView
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:hs="clr-namespace:Aurora.Design.Components.HostSelector"
xmlns:ml="clr-namespace:Aurora.Design.Components.MemberList"
xmlns:qu="clr-namespace:Aurora.Design.Components.Queue"
x:Class="Aurora.Design.Views.Party.PartyView">
<ContentView.Content>
<Grid>
<Grid.RowDefinitions>
<RowDefinition
Height="*"/>
</Grid.RowDefinitions>
<StackLayout
Grid.Row="0"
IsVisible="{Binding IsNotSelectingHost}">
<Label
Text="Party Members"/>
<ml:MemberList
VerticalOptions="FillAndExpand"
Members="{Binding Members}"/>
<Label
Text="Queue"/>
<qu:Queue/>
</StackLayout>
<hs:HostSelector
Grid.Row="0"
Hostname="{Binding Hostname}"
Port="{Binding Port}"
HostCommand="{Binding HostCommand}"
JoinCommand="{Binding JoinCommand}"
IsVisible="{Binding IsSelectingHost}"/>
</Grid>
</ContentView.Content>
</ContentView>

View File

@ -0,0 +1,14 @@
using System;
using Xamarin.Forms;
namespace Aurora.Design.Views.Party
{
public partial class PartyView : ContentView
{
public PartyView()
{
InitializeComponent();
BindingContext = new PartyViewModel();
}
}
}

View File

@ -0,0 +1,133 @@
using System;
using System.Collections.ObjectModel;
using Aurora.Executors;
using Aurora.Design.Components.HostSelector;
using Aurora.Services;
using Xamarin.Forms;
namespace Aurora.Design.Views.Party
{
enum PartyState
{
SelectingHost,
InParty,
Connecting,
}
public class PartyViewModel : BaseViewModel
{
private ObservableCollection<string> _members;
private PartyState _state;
private BaseExecutor _executor;
private string _hostname;
private string _port;
public PartyViewModel()
{
_members = new ObservableCollection<string>()
{
"Kevin",
"Brandon",
"Sheila",
"Dale",
"Austin",
"Tori",
"Ashley",
"Spencer",
};
OnPropertyChanged("Members");
this.JoinCommand = new Command(OnJoinExecute, CanJoinExecute);
this.HostCommand = new Command(OnHostExecute, CanHostExecute);
State(PartyState.SelectingHost);
}
#region Properties
public ObservableCollection<string> Members
{
get { return _members; }
set { SetProperty(ref _members, value); }
}
public bool IsSelectingHost
{
get { return _state == PartyState.SelectingHost; }
}
public bool IsNotSelectingHost
{
get { return _state != PartyState.SelectingHost; }
}
public Command JoinCommand { get; set; }
public Command HostCommand { get; set; }
public string Hostname
{
get { return _hostname; }
set { SetProperty(ref _hostname, value); }
}
public string Port
{
get { return _port; }
set { SetProperty(ref _port, value); }
}
#endregion Properties
private void State(PartyState state)
{
_state = state;
OnPropertyChanged("IsSelectingHost");
}
#region Commands
private void OnJoinExecute()
{
_executor = BaseExecutor.CreateExecutor<ClientExecutor>();
Int32.TryParse(this.Port, out int intPort);
_executor.Initialize();
State(PartyState.Connecting);
}
private bool CanJoinExecute()
{
return true;
}
private void OnHostExecute()
{
Int32.TryParse(this.Port, out int intPort);
//Init gRPC server
ServerService.Instance.Initialize(this.Hostname, intPort);
//Instantiate and initialize all executors
_executor = BaseExecutor.CreateExecutor<HostExecutor>();
_executor.Initialize();
//start gRPC server
ServerService.Instance.Start();
//Change state
State(PartyState.Connecting);
}
private bool CanHostExecute()
{
return true;
}
#endregion Commands
}
}

View File

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<ContentView
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Aurora.Design.Views.Profile.ProfileView">
<ContentView.Content>
<StackLayout
Orientation="Vertical">
<StackLayout
Orientation="Horizontal">
<Label
Text="Username"/>
<Entry
Text="{Binding Username}"/>
</StackLayout>
</StackLayout>
</ContentView.Content>
</ContentView>

View File

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using Xamarin.Forms;
namespace Aurora.Design.Views.Profile
{
public partial class ProfileView : ContentView
{
public ProfileView()
{
InitializeComponent();
BindingContext = new ProfileViewModel();
}
}
}

View File

@ -0,0 +1,23 @@
using System;
using Aurora.Services;
namespace Aurora.Design.Views.Profile
{
public class ProfileViewModel : BaseViewModel
{
public ProfileViewModel()
{
}
public string Username
{
get { return SettingsService.Instance.Username; }
set
{
SettingsService.Instance.Username = value;
OnPropertyChanged("Username");
}
}
}
}

View File

@ -0,0 +1,59 @@
<?xml version="1.0" encoding="UTF-8"?>
<ContentView
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:songs="clr-namespace:Aurora.Design.Views.Songs"
xmlns:dg="clr-namespace:Xamarin.Forms.DataGrid;assembly=Xamarin.Forms.DataGrid"
x:Class="Aurora.Design.Views.Songs.SongsView">
<ContentPage.BindingContext>
<songs:SongsViewModel
x:Name="songsViewModel"/>
</ContentPage.BindingContext>
<ContentPage.Content>
<dg:DataGrid
ItemsSource="{Binding SongsList}"
SelectionEnabled="True"
SelectedItem="{Binding SelectedSong}"
RowHeight="30"
HeaderHeight="50"
BorderColor="#CCCCCC"
HeaderBackground="#E0E6F8">
<dg:DataGrid.GestureRecognizers>
<TapGestureRecognizer
Command="{Binding PlayCommand}"
NumberOfTapsRequired="2"/>
</dg:DataGrid.GestureRecognizers><!-- Header -->
<dg:DataGrid.HeaderFontSize>
<OnIdiom
x:TypeArguments="x:Double">
<OnIdiom.Tablet>15</OnIdiom.Tablet>
<OnIdiom.Phone>13</OnIdiom.Phone>
<OnIdiom.Desktop>20</OnIdiom.Desktop>
</OnIdiom>
</dg:DataGrid.HeaderFontSize><!-- Columns -->
<dg:DataGrid.Columns>
<dg:DataGridColumn
Title="Title"
PropertyName="Metadata.Title"
Width="2*"/>
<dg:DataGridColumn
Title="Album"
PropertyName="Metadata.Album"
Width="0.95*"/>
<dg:DataGridColumn
Title="Artist"
PropertyName="Metadata.Artist"
Width="1*"/>
<dg:DataGridColumn
Title="Duration"
PropertyName="Metadata.Duration"/>
</dg:DataGrid.Columns><!-- Row Colors -->
<dg:DataGrid.RowsBackgroundColorPalette>
<dg:PaletteCollection>
<Color>#F2F2F2</Color>
<Color>#FFFFFF</Color>
</dg:PaletteCollection>
</dg:DataGrid.RowsBackgroundColorPalette>
</dg:DataGrid>
</ContentPage.Content>
</ContentView>

View File

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using Xamarin.Forms;
namespace Aurora.Design.Views.Songs
{
public partial class SongsView : ContentView
{
public SongsView()
{
InitializeComponent();
}
}
}

View File

@ -0,0 +1,60 @@
using System.Collections.ObjectModel;
using Aurora.Models.Media;
using Aurora.Services;
using Aurora.Services.PlayerService;
using Xamarin.Forms;
namespace Aurora.Design.Views.Songs
{
public class SongsViewModel : BaseViewModel
{
#region Fields
private ObservableCollection<BaseMedia> _songsList;
private BaseMedia _selectedSong;
#endregion Fields
#region Constructor
public SongsViewModel()
{
_songsList = new ObservableCollection<BaseMedia>();
PlayCommand = new Command(PlayExecute);
Initialize();
}
#endregion Constructor
#region Properties
public ObservableCollection<BaseMedia> SongsList
{
get { return _songsList; }
set { SetProperty(ref _songsList, value); }
}
public BaseMedia SelectedSong
{
get { return _selectedSong; }
set { SetProperty(ref _selectedSong, value); }
}
public Command PlayCommand { get; private set; }
#endregion Properties
#region Methods
public void Initialize()
{
SongsList = LibraryService.Instance.GetLibrary();
}
public void PlayExecute()
{
PlayerService.Instance.LoadMedia(_selectedSong);
PlayerService.Instance.Play();
}
#endregion Methods
}
}

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<ContentView
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Aurora.Design.Views.Stations.StationsView">
<ContentPage.Content></ContentPage.Content>
</ContentView>

View File

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using Xamarin.Forms;
namespace Aurora.Design.Views.Stations
{
public partial class StationsView : ContentView
{
public StationsView()
{
InitializeComponent();
}
}
}

View File

@ -0,0 +1,10 @@
using System;
namespace Aurora.Design.Views.Stations
{
public class StationsViewModel
{
public StationsViewModel()
{
}
}
}