diff --git a/Sources/Linaris/AlbumPage.xaml b/Sources/Linaris/AlbumPage.xaml index 3b22134..9896da1 100644 --- a/Sources/Linaris/AlbumPage.xaml +++ b/Sources/Linaris/AlbumPage.xaml @@ -26,7 +26,7 @@ - + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Sources/Linaris/EditPlaylistPage.xaml.cs b/Sources/Linaris/EditPlaylistPage.xaml.cs new file mode 100644 index 0000000..2b52ba4 --- /dev/null +++ b/Sources/Linaris/EditPlaylistPage.xaml.cs @@ -0,0 +1,62 @@ +using Model; +using Model.Stub; + +namespace Linaris; + +public partial class EditPlaylistPage : ContentPage +{ + + private Playlist playlist; + + public Playlist Playlist { get => playlist; } + + public EditPlaylistPage() + { + InitializeComponent(); + CopyCurrent(); + BindingContext = Playlist; + } + + private void CopyCurrent() + { + playlist = new Playlist(); + playlist.Name = (Application.Current as App).Manager.CurrentPlaylist.Name; + playlist.Description = (Application.Current as App).Manager.CurrentPlaylist.Description; + playlist.ImageURL = (Application.Current as App).Manager.CurrentPlaylist.ImageURL; + } + + private async void ChangeImage(object sender, EventArgs e) + { + var result = await FilePicker.PickAsync(new PickOptions + { + PickerTitle = "Choisissez une nouvelle image !", + FileTypes = FilePickerFileType.Images + }); + + if (result == null) + { + return; + } + + if (sender is Image image) + { + if (image.BindingContext is Playlist playlist) + { + playlist.ImageURL = result.FullPath; + } + } + } + + private void Cancel(object sender, EventArgs e) + { + Navigation.PopModalAsync(); + } + + private void EditPlaylist(object sender, EventArgs e) + { + (Application.Current as App).Manager.CurrentPlaylist.Name = playlist.Name; + (Application.Current as App).Manager.CurrentPlaylist.Description = playlist.Description; + (Application.Current as App).Manager.CurrentPlaylist.ImageURL = playlist.ImageURL; + Navigation.PopModalAsync(); + } +} \ No newline at end of file diff --git a/Sources/Linaris/PlaylistPage.xaml b/Sources/Linaris/PlaylistPage.xaml index de2b10d..4bf42e5 100644 --- a/Sources/Linaris/PlaylistPage.xaml +++ b/Sources/Linaris/PlaylistPage.xaml @@ -1,16 +1,12 @@ + - - - - @@ -21,75 +17,31 @@ - - - - - - - + + + + + + - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + diff --git a/Sources/Linaris/PlaylistPage.xaml.cs b/Sources/Linaris/PlaylistPage.xaml.cs index cb8f24b..e95a23b 100644 --- a/Sources/Linaris/PlaylistPage.xaml.cs +++ b/Sources/Linaris/PlaylistPage.xaml.cs @@ -5,5 +5,11 @@ public partial class PlaylistPage : ContentPage public PlaylistPage() { InitializeComponent(); + BindingContext = (Application.Current as App).Manager.CurrentPlaylist; } + + private async void EditPlaylist(object sender, EventArgs e) + { + await Navigation.PushModalAsync(new EditPlaylistPage()); + } } \ No newline at end of file diff --git a/Sources/Linaris/PlaylistsPage.xaml.cs b/Sources/Linaris/PlaylistsPage.xaml.cs index a5b058c..00a74eb 100644 --- a/Sources/Linaris/PlaylistsPage.xaml.cs +++ b/Sources/Linaris/PlaylistsPage.xaml.cs @@ -103,6 +103,13 @@ public partial class PlaylistsPage : ContentPage async void GoToPlaylist(object sender, EventArgs e) { + if (sender is Button button) + { + if (button.BindingContext is Playlist playlist) + { + (Application.Current as App).Manager.CurrentPlaylist = playlist; + } + } await Navigation.PushAsync(new PlaylistPage()); } } \ No newline at end of file diff --git a/Sources/Model/IDataManager.cs b/Sources/Model/IDataManager.cs index 8cfc498..18dc8d1 100644 --- a/Sources/Model/IDataManager.cs +++ b/Sources/Model/IDataManager.cs @@ -28,7 +28,7 @@ public interface IDataManager // Read ObservableCollection GetCustomTitles(); - CustomTitle? GetCustomTitleByName(string custom); + CustomTitle? GetCustomTitleByUrl(string custom); ObservableCollection GetInfoTitles(); @@ -50,7 +50,7 @@ public interface IDataManager // Update void UpdateCustomTitle(CustomTitle title, string name, string url, string info, string path); - void UpdateCustomTitleByName(string name, string newUrl, string info, string path); + void UpdateCustomTitleByUrl(string url, string name, string newUrl, string info, string path); void UpdateInfoTitle(InfoTitle title, string name, string url, string info, Artist artist, string description, Genre genre); diff --git a/Sources/Model/Manager.cs b/Sources/Model/Manager.cs index d2bd8f7..bef139d 100644 --- a/Sources/Model/Manager.cs +++ b/Sources/Model/Manager.cs @@ -68,6 +68,17 @@ public class Manager } } + private Playlist? currentPlaylist; + + public Playlist? CurrentPlaylist + { + get => currentPlaylist; + set + { + currentPlaylist = value; + } + } + public Manager(IDataManager dataManager) { DataManager = dataManager; @@ -77,6 +88,8 @@ public class Manager infoTitles = DataManager.GetInfoTitles(); playlists = DataManager.GetPlaylists(); artists = DataManager.GetArtists(); + + currentPlaylist = playlists.FirstOrDefault(); } public void AddAlbum(Album album) diff --git a/Sources/Model/Serialization/LINQ_XML_Serialization.cs b/Sources/Model/Serialization/LINQ_XML_Serialization.cs index 5d4d623..5e3db86 100644 --- a/Sources/Model/Serialization/LINQ_XML_Serialization.cs +++ b/Sources/Model/Serialization/LINQ_XML_Serialization.cs @@ -258,7 +258,7 @@ public class LinqXmlSerialization : IDataManager foreach(var custom in customsList) { - CustomTitle? customTitle = GetCustomTitleByName(custom); + CustomTitle? customTitle = GetCustomTitleByUrl(custom); if (customTitle == null) { @@ -741,11 +741,11 @@ public class LinqXmlSerialization : IDataManager return null; } - public CustomTitle? GetCustomTitleByName(string custom) + public CustomTitle? GetCustomTitleByUrl(string custom) { foreach(CustomTitle customTitle in customTitles) { - if(customTitle.Name == custom) + if(customTitle.ImageURL == custom) { return customTitle; } @@ -813,9 +813,9 @@ public class LinqXmlSerialization : IDataManager title.Path = path; } - public void UpdateCustomTitleByName(string name, string newUrl, string info, string path) + public void UpdateCustomTitleByUrl(string url, string name, string newUrl, string info, string path) { - CustomTitle? title = GetCustomTitleByName(name); + CustomTitle? title = GetCustomTitleByUrl(url); if (title != null) { title.Name = name; diff --git a/Sources/Model/Stub/StubManager.cs b/Sources/Model/Stub/StubManager.cs index 56ba7e9..5456910 100644 --- a/Sources/Model/Stub/StubManager.cs +++ b/Sources/Model/Stub/StubManager.cs @@ -236,11 +236,11 @@ public class StubManager : IDataManager // Doesn't do anything because it's Stubs } - public CustomTitle? GetCustomTitleByName(string custom) + public CustomTitle? GetCustomTitleByUrl(string custom) { foreach (CustomTitle customTitle in StubCustomTitle.GetCustomTitles()) { - if (customTitle.Name == custom) + if (customTitle.ImageURL == custom) { return customTitle; } @@ -344,9 +344,9 @@ public class StubManager : IDataManager title.Path = path; } - public void UpdateCustomTitleByName(string name, string newUrl, string info, string path) + public void UpdateCustomTitleByUrl(string url, string name, string newUrl, string info, string path) { - CustomTitle? title = GetCustomTitleByName(name); + CustomTitle? title = GetCustomTitleByUrl(url); if (title != null) { title.Name = name;