Merge branch 'feature/party_view'

This commit is contained in:
watsonb8 2019-06-03 10:57:36 -04:00
commit 3d92926922
15 changed files with 374 additions and 56 deletions

View File

@ -30,10 +30,12 @@
<Folder Include="Frontend\Views\Albums\" />
<Folder Include="Frontend\Views\Artists\" />
<Folder Include="Frontend\Views\Stations\" />
<Folder Include="Frontend\Components\MusicPlayer\" />
<Folder Include="Backend\Utils\" />
<Folder Include="Backend\Models\" />
<Folder Include="Backend\Services\" />
<Folder Include="Frontend\Views\Party\" />
<Folder Include="Frontend\Components\HostSelector\" />
<Folder Include="Frontend\Components\MemberList\" />
</ItemGroup>
<ItemGroup>
<Compile Update="Frontend\Components\MusicPlayer\Player.xaml.cs">

View File

@ -1,38 +0,0 @@
using System;
using Xamarin.Forms;
namespace Aurora.Frontend.Components
{
public class ContentPresenter : ContentView
{
public static readonly BindableProperty ItemTemplateProperty = BindableProperty.Create("ItemTemplate", typeof(DataTemplate), typeof(ContentPresenter), null, propertyChanged: OnItemTemplateChanged);
private static void OnItemTemplateChanged(BindableObject bindable, object oldvalue, object newvalue)
{
var cp = (ContentPresenter)bindable;
var template = cp.ItemTemplate;
if (template != null)
{
var content = (View)template.CreateContent();
cp.Content = content;
}
else
{
cp.Content = null;
}
}
public DataTemplate ItemTemplate
{
get
{
return (DataTemplate)GetValue(ItemTemplateProperty);
}
set
{
SetValue(ItemTemplateProperty, value);
}
}
}
}

View File

@ -4,7 +4,7 @@ using System.Collections.Generic;
using System.Windows.Input;
using Xamarin.Forms;
namespace Movies.Controls
namespace Aurora.Frontend.Components.HorizontalList
{
public class HorizontalList : Grid
{
@ -62,7 +62,7 @@ namespace Movies.Controls
public HorizontalList()
{
BackgroundColor = Color.FromHex("#1E2634");
// BackgroundColor = Color.FromHex("#1E2634");
Spacing = 6;
_scrollView = new ScrollView();
_itemsStackLayout = new StackLayout

View File

@ -0,0 +1,13 @@
<?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.Frontend.Components.HostSelector.HostSelector">
<ContentView.Content>
<StackLayout HorizontalOptions="Center"
VerticalOptions="Center"
BackgroundColor="Red">
<Button Text="Host Session"/>
<Button Text="Join Session"/>
</StackLayout>
</ContentView.Content>
</ContentView>

View File

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using Xamarin.Forms;
namespace Aurora.Frontend.Components.HostSelector
{
public partial class HostSelector : ContentView
{
public HostSelector()
{
InitializeComponent();
}
}
}

View File

@ -0,0 +1,24 @@
<?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:hl="clr-namespace:Aurora.Frontend.Components.HorizontalList"
x:Class="Aurora.Frontend.Components.MemberList.MemberList">
<ContentView.Content>
<StackLayout>
<hl:HorizontalList
x:Name="MembersHorizontalList"
ListOrientation="Horizontal"
VerticalOptions="Start">
<hl:HorizontalList.ItemTemplate>
<DataTemplate>
<Frame>
<Label
Text="{Binding .}"/>
</Frame>
</DataTemplate>
</hl:HorizontalList.ItemTemplate>
</hl:HorizontalList>
</StackLayout>
</ContentView.Content>
</ContentView>

View File

@ -0,0 +1,61 @@
using System;
using System.Collections.Generic;
using Xamarin.Forms;
using Aurora.Frontend.Components.HorizontalList;
namespace Aurora.Frontend.Components.MemberList
{
public partial class MemberList : ContentView
{
public MemberList()
{
InitializeComponent();
}
/// <summary>
/// Bindable property for members list.
/// </summary>
/// <param name=""Members""></param>
/// <param name="typeof(IEnumerable<string>"></param>
/// <returns></returns>
public static readonly BindableProperty MembersProperty =
BindableProperty.Create(propertyName: "Members",
returnType: typeof(IEnumerable<string>),
declaringType: typeof(MemberList),
defaultBindingMode: BindingMode.Default,
propertyChanged: OnMembersChanged);
/// <summary>
/// Backing property for MembersProperty
/// </summary>
/// <value></value>
public IEnumerable<string> Members
{
get
{
return (IEnumerable<string>)GetValue(MembersProperty);
}
set
{
SetValue(MembersProperty, value);
}
}
/// <summary>
/// Memberes changed event handler. Assign member list source.
/// </summary>
/// <param name="bindable"></param>
/// <param name="oldValue"></param>
/// <param name="newValue"></param>
private static void OnMembersChanged(BindableObject bindable, object oldValue, object newValue)
{
var control = (MemberList)bindable;
var membersList = control.FindByName("MembersHorizontalList") as HorizontalList.HorizontalList;
if (membersList != null)
{
membersList.ItemsSource = newValue as IEnumerable<string>;
}
}
}
}

View File

@ -34,6 +34,12 @@ namespace Aurora.Frontend.Components.NavigationMenu
}
}
/// <summary>
/// Items changed event handler. Organizes items in groups for display.
/// </summary>
/// <param name="bindable">The changed Item.</param>
/// <param name="oldValue">The previous value.</param>
/// <param name="newValue">The new value.</param>
private static void OnItemsChanged(BindableObject bindable, object oldValue, object newValue)
{
var control = (NavigationMenu)bindable;
@ -41,9 +47,9 @@ namespace Aurora.Frontend.Components.NavigationMenu
Dictionary<string, NavigationGroupItem> groupDictioanry = new Dictionary<string, NavigationGroupItem>();
//Populate dictionary where group heading is the key
foreach(NavigationItem item in items)
foreach (NavigationItem item in items)
{
if(groupDictioanry.ContainsKey(item.Group))
if (groupDictioanry.ContainsKey(item.Group))
{
groupDictioanry.TryGetValue(item.Group, out var groupItem);
groupItem.Items.Add(item);
@ -58,7 +64,7 @@ namespace Aurora.Frontend.Components.NavigationMenu
}
ObservableCollection<NavigationGroupItem> groups = new ObservableCollection<NavigationGroupItem>();
foreach(string groupHeading in groupDictioanry.Keys)
foreach (string groupHeading in groupDictioanry.Keys)
{
groupDictioanry.TryGetValue(groupHeading, out var groupItem);
groups.Add(groupItem);

View File

@ -0,0 +1,48 @@
<?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:dg="clr-namespace:Xamarin.Forms.DataGrid;assembly=Xamarin.Forms.DataGrid"
x:Class="Aurora.Frontend.Components.Queue.Queue">
<ContentView.Content>
<dg:DataGrid
x:Name="QueueDataGrid"
SelectionEnabled="True"
RowHeight="25"
HeaderHeight="40"
BorderColor="#CCCCCC"
HeaderBackground="#E0E6F8">
<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>
<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>
<dg:DataGrid.RowsBackgroundColorPalette>
<dg:PaletteCollection>
<Color>#F2F2F2</Color>
<Color>#FFFFFF</Color>
</dg:PaletteCollection>
</dg:DataGrid.RowsBackgroundColorPalette>
</dg:DataGrid>
</ContentView.Content>
</ContentView>

View File

@ -0,0 +1,109 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Xamarin.Forms;
using Xamarin.Forms.DataGrid;
using Aurora.Backend.Models.Media;
namespace Aurora.Frontend.Components.Queue
{
public partial class Queue : ContentView
{
public Queue()
{
InitializeComponent();
}
#region ItemsSource Property
/// <summary>
/// Bindable Property for the ItemsSource of the datagrid.
/// </summary>
/// <param name=""ItemsSource""></param>
/// <param name="typeof(IEnumerable<object>"></param>
/// <returns></returns>
public static readonly BindableProperty ItemsSourceProperty =
BindableProperty.Create(propertyName: "ItemsSource",
returnType: typeof(IEnumerable<object>),
declaringType: typeof(Queue),
defaultBindingMode: BindingMode.Default,
propertyChanged: OnItemsSourceChanged);
/// <summary>
/// Backing property for the ItemsSource property.
/// </summary>
/// <value></value>
public IEnumerable<object> ItemsSource
{
get
{
return (IEnumerable<object>)GetValue(ItemsSourceProperty);
}
set
{
SetValue(ItemsSourceProperty, value);
}
}
/// <summary>
/// ItemsSource Changed event handler
/// </summary>
/// <param name="bindable"></param>
/// <param name="oldValue"></param>
/// <param name="newValue"></param>
private static void OnItemsSourceChanged(BindableObject bindable, object oldValue, object newValue)
{
Queue control = bindable as Queue;
var queueDataGrid = control.FindByName("QueueDataGrid") as DataGrid;
queueDataGrid.ItemsSource = newValue as IEnumerable<object>;
}
#endregion ItemsSource Property
/// <summary>
/// Bindable property for the selected item field on the datagrid.
/// </summary>
/// <param name=""SelectedItem""></param>
/// <param name="typeof(BaseMetadata"></param>
/// <returns></returns>
public static readonly BindableProperty SelectedItemProperty =
BindableProperty.Create(propertyName: "SelectedItem",
returnType: typeof(object),
declaringType: typeof(Queue),
defaultBindingMode: BindingMode.TwoWay,
propertyChanged: OnSelectedItemChanged);
/// <summary>
/// Backing property for the SelectedItem property.
/// </summary>
/// <value></value>
public object SelectedItem
{
get
{
return ((object)GetValue(SelectedItemProperty));
}
set
{
SetValue(SelectedItemProperty, value);
}
}
/// <summary>
/// Handles selection change events.
/// </summary>
/// <param name="bindable">The bindable object.</param>
/// <param name="newValue"></param>
/// <param name="oldValue"></param>
private static void OnSelectedItemChanged(BindableObject bindable, object newValue, object oldValue)
{
Queue control = bindable as Queue;
var queueDataGrid = control.FindByName("QueueDataGrid") as DataGrid;
IEnumerable<object> source = (IEnumerable<object>)queueDataGrid.ItemsSource;
if (source.Contains(newValue))
{
queueDataGrid.SelectedItem = newValue;
}
}
}
}

View File

@ -1,6 +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.Frontend.Views.Albums.AlbumsView">
<ContentView
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Aurora.Frontend.Views.Albums.AlbumsView">
<ContentPage.Content>
<Label Text="Albums" />
<Grid></Grid>
</ContentPage.Content>
</ContentView>

View File

@ -7,6 +7,7 @@ using Aurora.Frontend.Views.Albums;
using Aurora.Frontend.Views.Artists;
using Aurora.Frontend.Views.Songs;
using Aurora.Frontend.Views.Stations;
using Aurora.Frontend.Views.Party;
namespace Aurora.Frontend.Views.MainView
{
@ -30,7 +31,7 @@ namespace Aurora.Frontend.Views.MainView
{
_pages = new ObservableCollection<NavigationItem>(new[]
{
new NavigationItem { Id = 4, Title = "Party", Group="Social", TargetType = typeof(ArtistsView)},
new NavigationItem { Id = 4, Title = "Party", Group="Social", TargetType = typeof(PartyView)},
new NavigationItem { Id = 5, Title = "Profile", Group="Social", TargetType = typeof(ArtistsView)},
new NavigationItem { Id = 0, Title = "Songs", Group="Library", TargetType = typeof(SongsView) },
new NavigationItem { Id = 1, Title = "Artists", Group="Library", TargetType = typeof(ArtistsView)},

View File

@ -0,0 +1,29 @@
<?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.Frontend.Components.HostSelector"
xmlns:ml="clr-namespace:Aurora.Frontend.Components.MemberList"
xmlns:qu="clr-namespace:Aurora.Frontend.Components.Queue"
x:Class="Aurora.Frontend.Views.Party.PartyView">
<ContentView.Content>
<AbsoluteLayout
VerticalOptions="FillAndExpand"
HorizontalOptions="FillAndExpand">
<StackLayout>
<Label
Text="Party Members"/>
<ml:MemberList
Members="{Binding Members}"/>
<Label
Text="Queue"/>
<qu:Queue/>
</StackLayout>
<hs:HostSelector
AbsoluteLayout.LayoutFlags="All"
AbsoluteLayout.LayoutBounds="0.5,0.5,0.7,0.7"
BackgroundColor="Green"
IsVisible="False"/>
</AbsoluteLayout>
</ContentView.Content>
</ContentView>

View File

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

View File

@ -0,0 +1,31 @@
using System;
using System.Collections.ObjectModel;
namespace Aurora.Frontend.Views.Party
{
public class PartyViewModel : BaseViewModel
{
private ObservableCollection<string> _members;
public PartyViewModel()
{
_members = new ObservableCollection<string>()
{
"Kevin",
"Brandon",
"Sheila",
"Dale",
"Austin",
"Tori",
"Ashley",
"Spencer",
};
OnPropertyChanged("Members");
}
public ObservableCollection<string> Members
{
get { return _members; }
set { SetProperty(ref _members, value); }
}
}
}