Reorganization
This commit is contained in:
59
Aurora/Design/Views/Songs/SongsView.xaml
Normal file
59
Aurora/Design/Views/Songs/SongsView.xaml
Normal 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>
|
15
Aurora/Design/Views/Songs/SongsView.xaml.cs
Normal file
15
Aurora/Design/Views/Songs/SongsView.xaml.cs
Normal 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();
|
||||
}
|
||||
}
|
||||
}
|
60
Aurora/Design/Views/Songs/SongsViewModel.cs
Normal file
60
Aurora/Design/Views/Songs/SongsViewModel.cs
Normal 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
|
||||
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user