From 49b422d3d0d23429e563da66c7abca98049fd341 Mon Sep 17 00:00:00 2001 From: Alexis Drai Date: Sat, 20 May 2023 02:13:50 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=92=84=20Create=20"master"=20view=20(#2)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## "master" view The view for an individual album. ## Basic Navigation To make sure that we could do it, and to allow for more sophisticated manual testing, we also implemented basic navigation. Co-authored-by: Alexis DRAI Reviewed-on: https://codefirst.iut.uca.fr/git/alexis.drai/AD_MAUI/pulls/2 --- AMC.Model/Models/Library.cs | 8 + AMC.Model/Models/Song.cs | 3 +- AMC.View/AMC.View.csproj | 19 +- AMC.View/App.xaml.cs | 4 +- AMC.View/AppShell.xaml | 6 +- AMC.View/Controls/LibraryCategoryItem.xaml | 25 + AMC.View/Controls/LibraryCategoryItem.xaml.cs | 50 + AMC.View/Converters/SongsInfoConverter.cs | 4 +- AMC.View/MainPage.xaml | 12 - AMC.View/MainPage.xaml.cs | 20 - AMC.View/Resources/Images/icon_albums.png | Bin 0 -> 6262 bytes AMC.View/Resources/Images/icon_artists.png | Bin 0 -> 12825 bytes .../Resources/Images/icon_chevron_right.png | Bin 0 -> 3612 bytes AMC.View/Resources/Images/icon_genres.png | Bin 0 -> 19135 bytes AMC.View/Resources/Images/icon_playlists.png | Bin 0 -> 10123 bytes AMC.View/Resources/Images/icon_songs.png | Bin 0 -> 8561 bytes AMC.View/Resources/Images/macroblank.svg | 1788 ----------------- AMC.View/Resources/Images/macroblank_1.png | Bin 0 -> 424231 bytes AMC.View/Resources/Images/macroblank_2.png | Bin 0 -> 128071 bytes AMC.View/Resources/Images/macroblank_3.png | Bin 0 -> 257388 bytes .../Resources/Strings/Strings.Designer.cs | 54 + AMC.View/Resources/Strings/Strings.fr.resx | 18 + AMC.View/Resources/Strings/Strings.resx | 18 + AMC.View/Resources/Styles/Styles.xaml | 7 + AMC.View/Views/AlbumPage.xaml | 18 +- AMC.View/Views/AlbumPage.xaml.cs | 4 +- AMC.View/Views/LibraryPage.xaml | 87 + AMC.View/Views/LibraryPage.xaml.cs | 32 + AMC.ViewModel/ViewModels/AlbumViewModel.cs | 34 +- AMC.ViewModel/ViewModels/LibraryViewModel.cs | 89 + 30 files changed, 431 insertions(+), 1869 deletions(-) create mode 100644 AMC.Model/Models/Library.cs create mode 100644 AMC.View/Controls/LibraryCategoryItem.xaml create mode 100644 AMC.View/Controls/LibraryCategoryItem.xaml.cs delete mode 100644 AMC.View/MainPage.xaml delete mode 100644 AMC.View/MainPage.xaml.cs create mode 100644 AMC.View/Resources/Images/icon_albums.png create mode 100644 AMC.View/Resources/Images/icon_artists.png create mode 100644 AMC.View/Resources/Images/icon_chevron_right.png create mode 100644 AMC.View/Resources/Images/icon_genres.png create mode 100644 AMC.View/Resources/Images/icon_playlists.png create mode 100644 AMC.View/Resources/Images/icon_songs.png delete mode 100644 AMC.View/Resources/Images/macroblank.svg create mode 100644 AMC.View/Resources/Images/macroblank_1.png create mode 100644 AMC.View/Resources/Images/macroblank_2.png create mode 100644 AMC.View/Resources/Images/macroblank_3.png create mode 100644 AMC.View/Views/LibraryPage.xaml create mode 100644 AMC.View/Views/LibraryPage.xaml.cs create mode 100644 AMC.ViewModel/ViewModels/LibraryViewModel.cs diff --git a/AMC.Model/Models/Library.cs b/AMC.Model/Models/Library.cs new file mode 100644 index 0000000..21f35a6 --- /dev/null +++ b/AMC.Model/Models/Library.cs @@ -0,0 +1,8 @@ + +namespace AMC.Model.Models +{ + public class Library + { + public List Albums { get; set; } + } +} diff --git a/AMC.Model/Models/Song.cs b/AMC.Model/Models/Song.cs index 5c55dc8..7ae595c 100644 --- a/AMC.Model/Models/Song.cs +++ b/AMC.Model/Models/Song.cs @@ -1,4 +1,5 @@ -namespace AMC.Model.Models { +namespace AMC.Model.Models +{ public class Song { public int Id { get; set; } diff --git a/AMC.View/AMC.View.csproj b/AMC.View/AMC.View.csproj index c9ad4b9..8eb9a2b 100644 --- a/AMC.View/AMC.View.csproj +++ b/AMC.View/AMC.View.csproj @@ -49,7 +49,14 @@ - + + + + + + + + @@ -82,6 +89,16 @@ MSBuild:Compile + + MSBuild:Compile + + + MSBuild:Compile + + + + + diff --git a/AMC.View/App.xaml.cs b/AMC.View/App.xaml.cs index d855210..4675ecb 100644 --- a/AMC.View/App.xaml.cs +++ b/AMC.View/App.xaml.cs @@ -1,6 +1,4 @@ -using System.Globalization; - -namespace AMC.View; +namespace AMC.View; public partial class App : Application { diff --git a/AMC.View/AppShell.xaml b/AMC.View/AppShell.xaml index 3e3e366..4e2e6ce 100644 --- a/AMC.View/AppShell.xaml +++ b/AMC.View/AppShell.xaml @@ -3,12 +3,12 @@ x:Class="AMC.View.AppShell" xmlns="http://schemas.microsoft.com/dotnet/2021/maui" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" - xmlns:local="clr-namespace:AMC.View" + xmlns:local="clr-namespace:AMC.View.Views" Shell.FlyoutBehavior="Disabled"> + ContentTemplate="{DataTemplate local:LibraryPage}" + Route="LibraryPage" /> diff --git a/AMC.View/Controls/LibraryCategoryItem.xaml b/AMC.View/Controls/LibraryCategoryItem.xaml new file mode 100644 index 0000000..25a7156 --- /dev/null +++ b/AMC.View/Controls/LibraryCategoryItem.xaml @@ -0,0 +1,25 @@ + + + + + + + + diff --git a/AMC.View/Controls/LibraryCategoryItem.xaml.cs b/AMC.View/Controls/LibraryCategoryItem.xaml.cs new file mode 100644 index 0000000..16817a7 --- /dev/null +++ b/AMC.View/Controls/LibraryCategoryItem.xaml.cs @@ -0,0 +1,50 @@ + +namespace AMC.View.Controls +{ + public partial class LibraryCategoryItem : ContentView + { + public static readonly BindableProperty CategoryTextProperty = BindableProperty.Create( + propertyName: nameof(CategoryText), + returnType: typeof(string), + declaringType: typeof(LibraryCategoryItem), + defaultValue: "", + propertyChanged: CategoryTextChanged); + + public static readonly BindableProperty IconSourceProperty = BindableProperty.Create( + propertyName: nameof(IconSource), + returnType: typeof(ImageSource), + declaringType: typeof(LibraryCategoryItem), + defaultValue: null, + propertyChanged: IconSourceChanged); + + public LibraryCategoryItem() + { + InitializeComponent(); + } + + public string CategoryText + { + get => (string)GetValue(CategoryTextProperty); + set => SetValue(CategoryTextProperty, value); + } + + public ImageSource IconSource + { + get => (ImageSource)GetValue(IconSourceProperty); + set => SetValue(IconSourceProperty, value); + } + + private static void CategoryTextChanged(BindableObject bindable, object oldValue, object newValue) + { + var control = (LibraryCategoryItem)bindable; + control.CategoryLabel.Text = (string)newValue; + } + + private static void IconSourceChanged(BindableObject bindable, object oldValue, object newValue) + { + var control = (LibraryCategoryItem)bindable; + control.IconImage.Source = (ImageSource)newValue; + } + } + +} diff --git a/AMC.View/Converters/SongsInfoConverter.cs b/AMC.View/Converters/SongsInfoConverter.cs index 6a63476..7c0a1a3 100644 --- a/AMC.View/Converters/SongsInfoConverter.cs +++ b/AMC.View/Converters/SongsInfoConverter.cs @@ -8,8 +8,8 @@ namespace AMC.View.Converters public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { var (songCount, totalDuration) = (ValueTuple)value; - var songLabel = songCount == 1 ? Strings.SongsLabelSingular : Strings.SongsLabelPlural; - var minutesLabel = totalDuration == 1 ? Strings.MinutesLabelSingular : Strings.MinutesLabelPlural; + var songLabel = int.Abs(songCount) < 2 ? Strings.SongsLabelSingular : Strings.SongsLabelPlural; + var minutesLabel = int.Abs(totalDuration) < 2 ? Strings.MinutesLabelSingular : Strings.MinutesLabelPlural; return string.Format( "{0} {1}, {2} {3}", songCount, diff --git a/AMC.View/MainPage.xaml b/AMC.View/MainPage.xaml deleted file mode 100644 index 113fea4..0000000 --- a/AMC.View/MainPage.xaml +++ /dev/null @@ -1,12 +0,0 @@ - - - -