From a985873ac056b235e2fd98f4b4361e004b8df130 Mon Sep 17 00:00:00 2001 From: Alexis DRAI Date: Tue, 16 May 2023 21:20:33 +0200 Subject: [PATCH] :lipstick: Finish album detail view --- AD_MAUI/Model/Album.cs | 3 +++ AD_MAUI/Resources/Styles/Styles.xaml | 6 +++++ AD_MAUI/ViewModel/AlbumViewModel.cs | 33 ++++++++++++--------------- AD_MAUI/ViewModel/SongViewModel.cs | 15 +++--------- AD_MAUI/Views/AlbumPage.xaml | 34 ++++++++++++++++++++++------ 5 files changed, 54 insertions(+), 37 deletions(-) diff --git a/AD_MAUI/Model/Album.cs b/AD_MAUI/Model/Album.cs index 1444ecf..aea8080 100644 --- a/AD_MAUI/Model/Album.cs +++ b/AD_MAUI/Model/Album.cs @@ -8,6 +8,9 @@ public string CoverImage { get; set; } public string Genre { get; set; } public int Year { get; set; } + public DateTime ReleaseDate { get; set; } + public int CopyrightYear { get; set; } + public string ProducerBlurb { get; set; } public List Songs { get; set; } } diff --git a/AD_MAUI/Resources/Styles/Styles.xaml b/AD_MAUI/Resources/Styles/Styles.xaml index 9e974be..f82e852 100644 --- a/AD_MAUI/Resources/Styles/Styles.xaml +++ b/AD_MAUI/Resources/Styles/Styles.xaml @@ -4,6 +4,12 @@ xmlns="http://schemas.microsoft.com/dotnet/2021/maui" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"> + + diff --git a/AD_MAUI/ViewModel/AlbumViewModel.cs b/AD_MAUI/ViewModel/AlbumViewModel.cs index e022978..c122091 100644 --- a/AD_MAUI/ViewModel/AlbumViewModel.cs +++ b/AD_MAUI/ViewModel/AlbumViewModel.cs @@ -10,29 +10,23 @@ namespace AD_MAUI.ViewModel private readonly Album album = new(); - public int Id { get => album.Id; } + public int Id => album.Id; - public string Title - { - get => album.Title; - } + public string Title => album.Title; - public string Artist - { - get => album.Artist; - } + public string Artist => album.Artist; - public string CoverImage - { - get => album.CoverImage; - } + public string CoverImage => album.CoverImage; - public string Details - { - get => $"{album.Genre} · {album.Year}"; - } + public string Details => $"{album.Genre} · {album.Year}"; + + public string ReleaseDate => album.ReleaseDate.ToString("d MMMM yyyy"); + + public string SongsInfo => $"{album.Songs.Count} songs, {album.Songs.Sum(song => song.Duration) / 60} minutes"; + + public string CopyrightInfo => $"℗ {album.CopyrightYear} {album.ProducerBlurb}"; - public ReadOnlyObservableCollection Songs { get => new(songs); } + public ReadOnlyObservableCollection Songs => new(songs); private readonly ObservableCollection songs; @@ -48,6 +42,9 @@ namespace AD_MAUI.ViewModel CoverImage = "macroblank.png", Genre = "Test genre", Year = 1970, + ReleaseDate = new DateTime(1970, 01, 01), + CopyrightYear = 1996, + ProducerBlurb = "Test Records Ltd", Songs = new List { new Song { Id = 1, Title = "Test Song 1", Duration = 210 }, diff --git a/AD_MAUI/ViewModel/SongViewModel.cs b/AD_MAUI/ViewModel/SongViewModel.cs index ab62feb..12b17ff 100644 --- a/AD_MAUI/ViewModel/SongViewModel.cs +++ b/AD_MAUI/ViewModel/SongViewModel.cs @@ -9,20 +9,11 @@ namespace AD_MAUI.ViewModel public event PropertyChangedEventHandler? PropertyChanged; - public string Title - { - get => song.Title; - } + public string Title => song.Title; - public int Duration - { - get => song.Duration; - } + public int Duration => song.Duration; - public int? Index - { - get => song?.Index; - } + public int? Index => song?.Index; public SongViewModel(Song? song) { diff --git a/AD_MAUI/Views/AlbumPage.xaml b/AD_MAUI/Views/AlbumPage.xaml index 8943473..5e7b801 100644 --- a/AD_MAUI/Views/AlbumPage.xaml +++ b/AD_MAUI/Views/AlbumPage.xaml @@ -13,6 +13,10 @@ + + + + - + - + - + @@ -79,14 +85,16 @@ FontSize="16" TextColor="{StaticResource Gray}" Margin="0,0,8,0" + HorizontalTextAlignment="Center" + HorizontalOptions="Center" Grid.Column="0"/> - + - + + Margin="36,0,8,0"/> + +