🐛 Fix display bug

by reintroducing the old converters
main
Alexis Drai 2 years ago
parent e3b5bb04ad
commit 084b218ab0

@ -0,0 +1,22 @@
using System.Globalization;
namespace AMC.View.Converters
{
public class AlbumDetailsConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
var (genre, year) = (ValueTuple<string, int>)value;
return string.Format(
"{0} · {1}",
genre,
year
);
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}

@ -0,0 +1,22 @@
using System.Globalization;
namespace AMC.View.Converters
{
public class CopyrightInfoConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
var (copyrightYear, producerBlurb) = (ValueTuple<int, string>)value;
return string.Format(
"℗ {0} {1}",
copyrightYear,
producerBlurb
);
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}

@ -11,6 +11,8 @@
<ContentPage.Resources>
<ResourceDictionary>
<conv:SongsInfoConverter x:Key="SongsInfo" />
<conv:AlbumDetailsConverter x:Key="AlbumDetails" />
<conv:CopyrightInfoConverter x:Key="CopyrightInfo" />
</ResourceDictionary>
</ContentPage.Resources>
@ -56,9 +58,9 @@
HorizontalTextAlignment="Center" />
</StackLayout>
<Label Grid.Row="2"
Text="{Binding Details, StringFormat='\{0\} · \{1\}'}"
Text="{Binding Details, Converter={StaticResource AlbumDetails}}"
FontSize="{StaticResource DetailsFontSize}"
TextColor="{StaticResource Gray}"
HorizontalTextAlignment="Center"/>
@ -132,7 +134,7 @@
<Label Text="{Binding SongsInfo, Converter={StaticResource SongsInfo}}"
Style="{StaticResource FooterLabel}" />
<Label Text="{Binding CopyrightInfo, StringFormat='℗ \{0\} \{1\}'}"
<Label Text="{Binding CopyrightInfo, Converter={StaticResource CopyrightInfo}}"
Style="{StaticResource FooterLabel}" />
</StackLayout>

Loading…
Cancel
Save