From 988f7862668c10da1a552ad32e1f8a404a5c29ef Mon Sep 17 00:00:00 2001 From: Corentin LEMAIRE Date: Tue, 23 May 2023 22:54:15 +0200 Subject: [PATCH] Add InfoTitle Page and Databinding --- Sources/Linaris/AlbumPage.xaml | 3 +++ Sources/Linaris/AlbumPage.xaml.cs | 12 ++++++++++ Sources/Linaris/InfoTitlePage.xaml | 34 +++++++++++++++++++++++++++ Sources/Linaris/InfoTitlePage.xaml.cs | 19 +++++++++++++++ Sources/Linaris/Linaris.csproj | 3 +++ Sources/Linaris/PlaylistPage.xaml | 2 +- Sources/Model/Artist.cs | 2 +- Sources/Model/Manager.cs | 12 ++++++++++ 8 files changed, 85 insertions(+), 2 deletions(-) create mode 100644 Sources/Linaris/InfoTitlePage.xaml create mode 100644 Sources/Linaris/InfoTitlePage.xaml.cs diff --git a/Sources/Linaris/AlbumPage.xaml b/Sources/Linaris/AlbumPage.xaml index 02d51dc..79bcdc6 100644 --- a/Sources/Linaris/AlbumPage.xaml +++ b/Sources/Linaris/AlbumPage.xaml @@ -44,6 +44,9 @@ FontSize="20" TextColor="white" HorizontalTextAlignment="Center"/> + + + diff --git a/Sources/Linaris/AlbumPage.xaml.cs b/Sources/Linaris/AlbumPage.xaml.cs index 722fec8..07381dd 100644 --- a/Sources/Linaris/AlbumPage.xaml.cs +++ b/Sources/Linaris/AlbumPage.xaml.cs @@ -20,4 +20,16 @@ public partial class AlbumPage : ContentPage album = (Application.Current as App).Manager.CurrentAlbum; BindingContext = album; } + + private async void GoToInfoTitle(object sender, EventArgs e) + { + if (sender is Frame frame) + { + if (frame.BindingContext is InfoTitle infoTitle) + { + (Application.Current as App).Manager.CurrentInfoTitle = infoTitle; + } + } + await Navigation.PushAsync(new InfoTitlePage()); + } } \ No newline at end of file diff --git a/Sources/Linaris/InfoTitlePage.xaml b/Sources/Linaris/InfoTitlePage.xaml new file mode 100644 index 0000000..e4a16f5 --- /dev/null +++ b/Sources/Linaris/InfoTitlePage.xaml @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Sources/Linaris/InfoTitlePage.xaml.cs b/Sources/Linaris/InfoTitlePage.xaml.cs new file mode 100644 index 0000000..ee27ca9 --- /dev/null +++ b/Sources/Linaris/InfoTitlePage.xaml.cs @@ -0,0 +1,19 @@ +using Model; + +namespace Linaris; + +public partial class InfoTitlePage : ContentPage +{ + private InfoTitle infoTitle; + + public InfoTitle InfoTitle + { + get => infoTitle; + } + public InfoTitlePage() + { + InitializeComponent(); + infoTitle = (Application.Current as App).Manager.CurrentInfoTitle; + BindingContext = infoTitle; + } +} \ No newline at end of file diff --git a/Sources/Linaris/Linaris.csproj b/Sources/Linaris/Linaris.csproj index 11201ac..38765d1 100644 --- a/Sources/Linaris/Linaris.csproj +++ b/Sources/Linaris/Linaris.csproj @@ -85,6 +85,9 @@ MSBuild:Compile + + MSBuild:Compile + MSBuild:Compile diff --git a/Sources/Linaris/PlaylistPage.xaml b/Sources/Linaris/PlaylistPage.xaml index 426d75d..1f44cc0 100644 --- a/Sources/Linaris/PlaylistPage.xaml +++ b/Sources/Linaris/PlaylistPage.xaml @@ -1,8 +1,8 @@ diff --git a/Sources/Model/Artist.cs b/Sources/Model/Artist.cs index 936131d..ac71c24 100644 --- a/Sources/Model/Artist.cs +++ b/Sources/Model/Artist.cs @@ -45,6 +45,6 @@ public class Artist public override string ToString() { - return $"Name : {Name}"; + return $"{Name}"; } } diff --git a/Sources/Model/Manager.cs b/Sources/Model/Manager.cs index 7d2d8a9..225d99f 100644 --- a/Sources/Model/Manager.cs +++ b/Sources/Model/Manager.cs @@ -93,6 +93,17 @@ public class Manager } } + private InfoTitle? currentInfoTitle; + + public InfoTitle? CurrentInfoTitle + { + get => currentInfoTitle; + set + { + currentInfoTitle = value; + } + } + public Manager(IDataManager dataManager) { DataManager = dataManager; @@ -105,6 +116,7 @@ public class Manager currentAlbum = albums.FirstOrDefault(); currentPlaylist = playlists.FirstOrDefault(); + currentInfoTitle = infoTitles.FirstOrDefault(); } public void AddAlbum(Album album)