Initial commit for a party view which displays members and the shared queue

This commit is contained in:
watsonb8 2019-05-27 11:23:14 -05:00
parent 9354c0b27b
commit d3f51371dd
12 changed files with 207 additions and 53 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,26 @@
<?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>
<Label
Text="Party Members"/>
<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

@ -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,23 @@
<?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"
x:Class="Aurora.Frontend.Views.Party.PartyView">
<ContentView.Content>
<AbsoluteLayout
VerticalOptions="FillAndExpand"
HorizontalOptions="FillAndExpand">
<StackLayout>
<ml:MemberList
Members="{Binding Members}"/>
</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); }
}
}
}