Update(Back-End): Converter Autors
continuous-integration/drone/push Build is failing Details

Back-End
Louis DUFOUR 1 year ago
parent c2d12ad647
commit 82d7f54182

@ -3,9 +3,16 @@
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:composants="clr-namespace:BookApp.Composants"
xmlns:model="clr-namespace:Model;assembly=Model"
xmlns:usecase="clr-namespace:BookApp.UseCase"
x:Name="ThisPage"
x:Class="BookApp.Composants.GroupCollection">
<ContentView.Resources>
<ResourceDictionary>
<usecase:AuthorsListToStringConverter x:Key="authorsConverter"/>
</ResourceDictionary>
</ContentView.Resources>
<CollectionView ItemsSource="{Binding AuteurGroups}" IsGrouped="True" SelectionMode="Single">
<CollectionView.GroupHeaderTemplate>
<DataTemplate x:DataType="model:Author">
@ -52,7 +59,7 @@
FontFamily="SF-Compact-Display-Bold"
FontSize="18"
TextColor="Black"/>
<!-- <Label Text="{Binding Authors, Converter=}" FontFamily="SF-Compact-Display-Semibold" TextColor="Black"/> -->
<Label Text="{Binding Authors, Converter={StaticResource authorsConverter}}" FontFamily="SF-Compact-Display-Semibold" TextColor="Black"/>
<Label
TextColor="SlateGray"
Text="{Binding Status}"/>

@ -4,6 +4,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit"
xmlns:vm="clr-namespace:BookApp.ViewModel"
xmlns:usecase="clr-namespace:BookApp.UseCase"
x:Name="ThisPage"
x:Class="BookApp.Pages.DetailBook">
@ -49,6 +50,13 @@
Grid.Column="1" />
</Grid>
</Shell.TitleView>
<ContentView.Resources>
<ResourceDictionary>
<usecase:AuthorsListToStringConverter x:Key="authorsConverter"/>
</ResourceDictionary>
</ContentView.Resources>
<ContentPage.Content>
<ScrollView>
<StackLayout>
@ -85,7 +93,7 @@
</Grid>
<Rectangle Margin="25,0,0,10" HeightRequest="1" BackgroundColor="LightGray" VerticalOptions="End"/>
<Label FontAttributes="Bold" Margin="25,0,0,0" VerticalTextAlignment="Center" Text="Auteur"/>
<Label Margin="25,0,0,0" VerticalTextAlignment="Center" Text="{Binding BookDetail.Authors}"/>
<Label Margin="25,0,0,0" VerticalTextAlignment="Center" Text="{Binding BookDetail.Authors, Converter={StaticResource authorsConverter}}"/>
<Rectangle Margin="25,10,0,10" HeightRequest="1" BackgroundColor="LightGray" VerticalOptions="End"/>
<Label FontAttributes="Bold" Margin="25,0,0,0" VerticalTextAlignment="Center" Text="Maison d'édition"/>
<Label Margin="25,0,0,0" VerticalTextAlignment="Center" Text="{Binding BookDetail.Authors}"/>

@ -0,0 +1,28 @@
using Model;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BookApp.UseCase
{
public class AuthorsListToStringConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is List<Author> authorsList && authorsList.Any())
{
return string.Join(", ", authorsList.Select(a => a.Name));
}
return string.Empty;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}
Loading…
Cancel
Save