See commit description for changes

Added PageContainer to dynamically load pages within the main content. Added player component to control music playback(Half functional). Added playback changed event not the player service.
This commit is contained in:
watsonb8
2019-05-24 10:27:19 -04:00
parent 2dbe9cead9
commit 93be6dc100
26 changed files with 357 additions and 86 deletions
+2 -2
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<ContentPage 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" />
</ContentPage.Content>
</ContentPage>
</ContentView>
@@ -5,7 +5,7 @@ using Xamarin.Forms;
namespace Aurora.Frontend.Views.Albums
{
public partial class AlbumsView : ContentPage
public partial class AlbumsView : ContentView
{
public AlbumsView()
{
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="Aurora.Frontend.Views.Artists.ArtistsView">
<ContentView xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="Aurora.Frontend.Views.Artists.ArtistsView">
<ContentPage.Content>
</ContentPage.Content>
</ContentPage>
</ContentView>
@@ -5,7 +5,7 @@ using Xamarin.Forms;
namespace Aurora.Frontend.Views.Artists
{
public partial class ArtistsView : ContentPage
public partial class ArtistsView : ContentView
{
public ArtistsView()
{
+12 -12
View File
@@ -1,21 +1,21 @@
<?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.Frontend.Views.Songs"
xmlns:views="clr-namespace:Aurora.Frontend.Views.MainView"
xmlns:navigation="clr-namespace:Aurora.Frontend.Components.NavigationMenu"
x:Class="Aurora.Frontend.Views.Main.MainView"
MasterBehavior="Split">
<MasterDetailPage.Master>
<navigation:NavigationMenu x:Name="MasterPage" Items="{Binding Pages}"/>
</MasterDetailPage.Master>
<MasterDetailPage.Detail>
<NavigationPage>
<x:Arguments>
<views:SongsView />
</x:Arguments>
</NavigationPage>
</MasterDetailPage.Detail>
<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>
@@ -1,12 +1,13 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using Aurora.Frontend.Components.NavigationMenu;
using Aurora.Frontend.Views.MainView;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;
namespace Aurora.Frontend.Views.Main
{
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class MainView : MasterDetailPage
{
@@ -15,6 +16,13 @@ namespace Aurora.Frontend.Views.Main
InitializeComponent();
BindingContext = new MainViewModel();
MasterPage.ListView.ItemSelected += ListView_ItemSelected;
//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;
}
private void ListView_ItemSelected(object sender, SelectedItemChangedEventArgs e)
@@ -23,10 +31,10 @@ namespace Aurora.Frontend.Views.Main
if (item == null)
return;
var page = (Page)Activator.CreateInstance(item.TargetType);
page.Title = item.Title;
var view = (View)Activator.CreateInstance(item.TargetType);
Detail = new NavigationPage(page);
ContentPresenter viewContent = (ContentPresenter)ContentPage.Content.FindByName("ViewContent");
viewContent.Content = view;
MasterPage.ListView.SelectedItem = null;
}
@@ -0,0 +1,9 @@
<?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.Frontend.Components" xmlns:mp="clr-namespace:Aurora.Frontend.Components.MediaPlayer" x:Class="Aurora.Frontend.Views.MainView.PageContainer">
<ContentPage.Content>
<StackLayout>
<ContentPresenter x:Name="ViewContent"/>
<mp:Player HorizontalOptions="CenterAndExpand" VerticalOptions="End" HeightRequest="200"/>
</StackLayout>
</ContentPage.Content>
</ContentPage>
@@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using Xamarin.Forms;
namespace Aurora.Frontend.Views.MainView
{
public partial class PageContainer : ContentPage
{
public PageContainer()
{
InitializeComponent();
}
}
}
+2 -2
View File
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
<ContentView xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:songs="clr-namespace:Aurora.Frontend.Views.Songs"
xmlns:dg="clr-namespace:Xamarin.Forms.DataGrid;assembly=Xamarin.Forms.DataGrid"
@@ -47,4 +47,4 @@
</dg:DataGrid>
</ContentPage.Content>
</ContentPage>
</ContentView>
@@ -5,7 +5,7 @@ using Xamarin.Forms;
namespace Aurora.Frontend.Views.Songs
{
public partial class SongsView : ContentPage
public partial class SongsView : ContentView
{
public SongsView()
{
@@ -1,6 +1,7 @@
using System.Collections.ObjectModel;
using Aurora.Backend.Models;
using Aurora.Backend.Services;
using Aurora.Backend.Services.PlayerService;
using Xamarin.Forms;
namespace Aurora.Frontend.Views.Songs
@@ -8,15 +9,15 @@ namespace Aurora.Frontend.Views.Songs
public class SongsViewModel : BaseViewModel
{
#region Fields
private ObservableCollection<BaseSong> _songsList;
private BaseSong _selectedSong;
private ObservableCollection<BaseMedia> _songsList;
private BaseMedia _selectedSong;
#endregion Fields
#region Constructor
public SongsViewModel()
{
_songsList = new ObservableCollection<BaseSong>();
_songsList = new ObservableCollection<BaseMedia>();
PlayCommand = new Command(PlayExecute);
Initialize();
}
@@ -24,13 +25,13 @@ namespace Aurora.Frontend.Views.Songs
#endregion Constructor
#region Properties
public ObservableCollection<BaseSong> SongsList
public ObservableCollection<BaseMedia> SongsList
{
get { return _songsList; }
set { SetProperty(ref _songsList, value); }
}
public BaseSong SelectedSong
public BaseMedia SelectedSong
{
get { return _selectedSong; }
set { SetProperty(ref _selectedSong, value); }
@@ -49,7 +50,8 @@ namespace Aurora.Frontend.Views.Songs
public void PlayExecute()
{
PlayerService.Instance.Play(_selectedSong);
PlayerService.Instance.LoadMedia(_selectedSong);
PlayerService.Instance.Play();
}
#endregion Methods
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="Aurora.Frontend.Views.Stations.StationsView">
<ContentView xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="Aurora.Frontend.Views.Stations.StationsView">
<ContentPage.Content>
</ContentPage.Content>
</ContentPage>
</ContentView>
@@ -5,7 +5,7 @@ using Xamarin.Forms;
namespace Aurora.Frontend.Views.Stations
{
public partial class StationsView : ContentPage
public partial class StationsView : ContentView
{
public StationsView()
{