💄 Finish album detail view

pull/1/head
Alexis Drai 2 years ago
parent a8dd472e6e
commit a985873ac0

@ -8,6 +8,9 @@
public string CoverImage { get; set; } public string CoverImage { get; set; }
public string Genre { get; set; } public string Genre { get; set; }
public int Year { get; set; } public int Year { get; set; }
public DateTime ReleaseDate { get; set; }
public int CopyrightYear { get; set; }
public string ProducerBlurb { get; set; }
public List<Song> Songs { get; set; } public List<Song> Songs { get; set; }
} }

@ -4,6 +4,12 @@
xmlns="http://schemas.microsoft.com/dotnet/2021/maui" xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"> xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml">
<Style TargetType="Label" x:Key="FooterLabel">
<Setter Property="FontSize" Value="12" />
<Setter Property="TextColor" Value="{StaticResource Gray}" />
<Setter Property="HorizontalTextAlignment" Value="Start" />
</Style>
<Style TargetType="ActivityIndicator"> <Style TargetType="ActivityIndicator">
<Setter Property="Color" Value="{AppThemeBinding Light={StaticResource Primary}, Dark={StaticResource White}}" /> <Setter Property="Color" Value="{AppThemeBinding Light={StaticResource Primary}, Dark={StaticResource White}}" />
</Style> </Style>

@ -10,29 +10,23 @@ namespace AD_MAUI.ViewModel
private readonly Album album = new(); private readonly Album album = new();
public int Id { get => album.Id; } public int Id => album.Id;
public string Title public string Title => album.Title;
{
get => album.Title;
}
public string Artist public string Artist => album.Artist;
{
get => album.Artist;
}
public string CoverImage public string CoverImage => album.CoverImage;
{
get => album.CoverImage;
}
public string Details public string Details => $"{album.Genre} · {album.Year}";
{
get => $"{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<SongViewModel> Songs { get => new(songs); } public ReadOnlyObservableCollection<SongViewModel> Songs => new(songs);
private readonly ObservableCollection<SongViewModel> songs; private readonly ObservableCollection<SongViewModel> songs;
@ -48,6 +42,9 @@ namespace AD_MAUI.ViewModel
CoverImage = "macroblank.png", CoverImage = "macroblank.png",
Genre = "Test genre", Genre = "Test genre",
Year = 1970, Year = 1970,
ReleaseDate = new DateTime(1970, 01, 01),
CopyrightYear = 1996,
ProducerBlurb = "Test Records Ltd",
Songs = new List<Song> Songs = new List<Song>
{ {
new Song { Id = 1, Title = "Test Song 1", Duration = 210 }, new Song { Id = 1, Title = "Test Song 1", Duration = 210 },

@ -9,20 +9,11 @@ namespace AD_MAUI.ViewModel
public event PropertyChangedEventHandler? PropertyChanged; public event PropertyChangedEventHandler? PropertyChanged;
public string Title public string Title => song.Title;
{
get => song.Title;
}
public int Duration public int Duration => song.Duration;
{
get => song.Duration;
}
public int? Index public int? Index => song?.Index;
{
get => song?.Index;
}
public SongViewModel(Song? song) public SongViewModel(Song? song)
{ {

@ -13,6 +13,10 @@
<RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/>
<RowDefinition Height="*"/> <RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<Image Source="{Binding CoverImage}" <Image Source="{Binding CoverImage}"
@ -64,13 +68,15 @@
Margin="8" Margin="8"
Grid.Row="3" /> Grid.Row="3" />
<CollectionView ItemsSource="{Binding Songs}" Grid.Row="4"> <CollectionView ItemsSource="{Binding Songs}"
Margin="0,0,0,16"
Grid.Row="4">
<CollectionView.ItemTemplate> <CollectionView.ItemTemplate>
<DataTemplate x:DataType="local:SongViewModel"> <DataTemplate x:DataType="local:SongViewModel">
<StackLayout> <StackLayout>
<Grid Margin="0,8,0,0"> <Grid Margin="0,8,0,8">
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/> <ColumnDefinition Width="36"/>
<ColumnDefinition Width="*"/> <ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/> <ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
@ -79,6 +85,8 @@
FontSize="16" FontSize="16"
TextColor="{StaticResource Gray}" TextColor="{StaticResource Gray}"
Margin="0,0,8,0" Margin="0,0,8,0"
HorizontalTextAlignment="Center"
HorizontalOptions="Center"
Grid.Column="0"/> Grid.Column="0"/>
<Label Text="{Binding Title}" <Label Text="{Binding Title}"
@ -99,11 +107,23 @@
<BoxView HeightRequest="1" <BoxView HeightRequest="1"
Color="{StaticResource Gray300}" Color="{StaticResource Gray300}"
HorizontalOptions="FillAndExpand" HorizontalOptions="FillAndExpand"
Margin="16,0,8,0"/> Margin="36,0,8,0"/>
</StackLayout> </StackLayout>
</DataTemplate> </DataTemplate>
</CollectionView.ItemTemplate> </CollectionView.ItemTemplate>
</CollectionView> </CollectionView>
<Label Text="{Binding ReleaseDate}"
Style="{StaticResource FooterLabel}"
Grid.Row="5" />
<Label Text="{Binding SongsInfo}"
Style="{StaticResource FooterLabel}"
Grid.Row="6" />
<Label Text="{Binding CopyrightInfo}"
Style="{StaticResource FooterLabel}"
Grid.Row="7" />
</Grid> </Grid>
</ScrollView> </ScrollView>
</ContentPage> </ContentPage>

Loading…
Cancel
Save