ADD : Avancement page Détails Book + Filtrage Auteur

commands-19-09
Lou BRODA 1 year ago
parent a37283cabd
commit cfe11f537b

@ -25,6 +25,7 @@ public static class MauiProgram
builder.Services builder.Services
.AddSingleton<BibliothequeView>() .AddSingleton<BibliothequeView>()
.AddSingleton<TousView>() .AddSingleton<TousView>()
.AddSingleton<FiltrageAuteurView>()
.AddSingleton<NavigatorVM>() .AddSingleton<NavigatorVM>()
@ -34,7 +35,8 @@ public static class MauiProgram
.AddSingleton<ManagerVM>() .AddSingleton<ManagerVM>()
.AddSingleton<TousVM>(); .AddSingleton<TousVM>()
.AddSingleton<FiltrageAuteurVM>();
#if DEBUG #if DEBUG
builder.Logging.AddDebug(); builder.Logging.AddDebug();

@ -17,6 +17,6 @@ public partial class ALirePlusTardView : ContentPage
void OnSelectionChanged(object sender, SelectionChangedEventArgs e) void OnSelectionChanged(object sender, SelectionChangedEventArgs e)
{ {
App.Current.MainPage.Navigation.PushAsync(new DetailsLivreView()); //App.Current.MainPage.Navigation.PushAsync(new DetailsLivreView());
} }
} }

@ -58,7 +58,7 @@
Stroke="{StaticResource Gray}" Stroke="{StaticResource Gray}"
StrokeShape="RoundRectangle 3" StrokeShape="RoundRectangle 3"
StrokeThickness="3"> StrokeThickness="3">
<Image Source="couverture_la_horde_du_contrevent.png" <Image Source="{Binding DetailsLivreVM.Book.ImageSmall}"
Aspect="AspectFill" Aspect="AspectFill"
Grid.Column="0" Grid.Column="0"
Grid.RowSpan="5"/> Grid.RowSpan="5"/>
@ -70,7 +70,7 @@
Margin="0,97,20,0" Margin="0,97,20,0"
VerticalOptions="End"/> VerticalOptions="End"/>
</Grid> </Grid>
<Label Text="La horde du contrevent" <Label Text="{Binding DetailsLivreVM.Book.Title}"
Grid.Column="2" Grid.Column="2"
Grid.Row="0"/> Grid.Row="0"/>
<contentView:StarNotationView Grid.Column="2" <contentView:StarNotationView Grid.Column="2"
@ -112,7 +112,7 @@
<Label Text="Auteur" <Label Text="Auteur"
Style="{StaticResource DetailsLivreTitle}" Style="{StaticResource DetailsLivreTitle}"
Grid.Row="0"/> Grid.Row="0"/>
<Label Text="Alain Damasio" <Label Text="{Binding DetailsLivreVM.Book.Author}"
Style="{StaticResource DetailsLivreBody}" Style="{StaticResource DetailsLivreBody}"
Grid.Row="1"/> Grid.Row="1"/>
</Grid> </Grid>
@ -129,9 +129,14 @@
<Label Text="Maison d'édition" <Label Text="Maison d'édition"
Style="{StaticResource DetailsLivreTitle}" Style="{StaticResource DetailsLivreTitle}"
Grid.Row="0"/> Grid.Row="0"/>
<Label Text="Gallimard (2015)" <Label>
Style="{StaticResource DetailsLivreBody}" <Label.FormattedText>
Grid.Row="1"/> <FormattedString>
<Span Text="Gallimard"/>
<Span Text="{Binding DetailsLivreVM.Book.PublishDate,StringFormat='({0})'}"/>
</FormattedString>
</Label.FormattedText>
</Label>
</Grid> </Grid>
<contentView:SeparatorCutStartView/> <contentView:SeparatorCutStartView/>
@ -175,7 +180,7 @@
<Label Text="Nombre de pages" <Label Text="Nombre de pages"
Style="{StaticResource DetailsLivreBody}" Style="{StaticResource DetailsLivreBody}"
Grid.Column="0"/> Grid.Column="0"/>
<Label Text="700" <Label Text="{Binding DetailsLivreVM.Book.NbPages}"
Style="{StaticResource DetailsLivreBody}" Style="{StaticResource DetailsLivreBody}"
Grid.Column="2"/> Grid.Column="2"/>
</Grid> </Grid>
@ -203,7 +208,7 @@
<Label Text="ISBN" <Label Text="ISBN"
Style="{StaticResource DetailsLivreBody}" Style="{StaticResource DetailsLivreBody}"
Grid.Column="0"/> Grid.Column="0"/>
<Label Text="9782070464234" <Label Text="{Binding DetailsLivreVM.Book.ISBN13}"
Style="{StaticResource DetailsLivreBody}" Style="{StaticResource DetailsLivreBody}"
Grid.Column="2"/> Grid.Column="2"/>
</Grid> </Grid>
@ -231,7 +236,7 @@
<Label Text="Statut" <Label Text="Statut"
Style="{StaticResource DetailsLivreBody}" Style="{StaticResource DetailsLivreBody}"
Grid.Column="0"/> Grid.Column="0"/>
<Label Text="Non lu" <Label Text="{Binding DetailsLivreVM.Book.Status}"
Style="{StaticResource DetailsLivreBody}" Style="{StaticResource DetailsLivreBody}"
Grid.Column="2"/> Grid.Column="2"/>
</Grid> </Grid>

@ -1,9 +1,23 @@
using LivreLand.ViewModel;
namespace LivreLand.View; namespace LivreLand.View;
public partial class DetailsLivreView : ContentPage public partial class DetailsLivreView : ContentPage
{ {
public DetailsLivreView() #region Properties
public DetailsLivreVM DetailsLivreVM { get; set; }
#endregion
#region Constructor
public DetailsLivreView(DetailsLivreVM detailsLivreVM)
{ {
DetailsLivreVM = detailsLivreVM;
InitializeComponent(); InitializeComponent();
BindingContext = this;
} }
#endregion
} }

@ -22,6 +22,6 @@ public partial class EmpruntsPretsView : ContentPage
void OnSelectionChanged(object sender, SelectionChangedEventArgs e) void OnSelectionChanged(object sender, SelectionChangedEventArgs e)
{ {
App.Current.MainPage.Navigation.PushAsync(new DetailsLivreView()); //App.Current.MainPage.Navigation.PushAsync(new DetailsLivreView());
} }
} }

@ -18,6 +18,6 @@ public partial class FavorisView : ContentPage
void OnSelectionChanged(object sender, SelectionChangedEventArgs e) void OnSelectionChanged(object sender, SelectionChangedEventArgs e)
{ {
App.Current.MainPage.Navigation.PushAsync(new DetailsLivreView()); //App.Current.MainPage.Navigation.PushAsync(new DetailsLivreView());
} }
} }

@ -4,6 +4,7 @@
xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit" xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit"
xmlns:view="clr-namespace:LivreLand.View" xmlns:view="clr-namespace:LivreLand.View"
xmlns:contentView="clr-namespace:LivreLand.View.ContentViews" xmlns:contentView="clr-namespace:LivreLand.View.ContentViews"
xmlns:viewModel="clr-namespace:ViewModels;assembly=ViewModels"
x:Class="LivreLand.View.FiltrageAuteurView" x:Class="LivreLand.View.FiltrageAuteurView"
Title="FiltrageAuteurView"> Title="FiltrageAuteurView">
@ -34,104 +35,20 @@
<VerticalStackLayout Grid.Row="2"> <VerticalStackLayout Grid.Row="2">
<contentView:SeparatorEntireView/> <contentView:SeparatorEntireView/>
<!--Alain Damasio--> <CollectionView ItemsSource="{Binding FiltrageAuteurVM.Manager.AllAuthors}">
<contentView:HomeButtonView ButtonTitle="Alain Damasio" <CollectionView.ItemTemplate>
<DataTemplate x:DataType="viewModel:AuthorVM">
<VerticalStackLayout>
<contentView:HomeButtonView ButtonTitle="{Binding Name}"
ButtonIcon="book.png" ButtonIcon="book.png"
ButtonNumber="2" ButtonNumber="2"
ButtonRedIconVisible="True" ButtonRedIconVisible="True"
ButtonBlackIconVisible="False"/> ButtonBlackIconVisible="False"/>
<contentView:SeparatorBigCutStartView/>
<!--Cixin Liu-->
<contentView:HomeButtonView ButtonTitle="Cixin Liu"
ButtonIcon="book.png"
ButtonNumber="3"
ButtonRedIconVisible="True"
ButtonBlackIconVisible="False"/>
<contentView:SeparatorBigCutStartView/>
<!--Daniel Pennac-->
<contentView:HomeButtonView ButtonTitle="Daniel Pennac"
ButtonIcon="book.png"
ButtonNumber="2"
ButtonRedIconVisible="True"
ButtonBlackIconVisible="False"/>
<contentView:SeparatorBigCutStartView/>
<!--Evgenij Ivanovič Zamâtin-->
<contentView:HomeButtonView ButtonTitle="Evgenij Ivanovič Zamâtin"
ButtonIcon="book.png"
ButtonNumber="1"
ButtonRedIconVisible="True"
ButtonBlackIconVisible="False"/>
<contentView:SeparatorBigCutStartView/>
<!--Frank Herbert-->
<contentView:HomeButtonView ButtonTitle="Frank Herbert"
ButtonIcon="book.png"
ButtonNumber="6"
ButtonRedIconVisible="True"
ButtonBlackIconVisible="False"/>
<contentView:SeparatorBigCutStartView/>
<!--Herbert George Wells-->
<contentView:HomeButtonView ButtonTitle="Herbert George Wells"
ButtonIcon="book.png"
ButtonNumber="3"
ButtonRedIconVisible="True"
ButtonBlackIconVisible="False"/>
<contentView:SeparatorBigCutStartView/>
<!--James S. A. Corey-->
<contentView:HomeButtonView ButtonTitle="James S. A. Corey"
ButtonIcon="book.png"
ButtonNumber="6"
ButtonRedIconVisible="True"
ButtonBlackIconVisible="False"/>
<contentView:SeparatorBigCutStartView/>
<!--James Tynion-->
<contentView:HomeButtonView ButtonTitle="James Tynion"
ButtonIcon="book.png"
ButtonNumber="1"
ButtonRedIconVisible="True"
ButtonBlackIconVisible="False"/>
<contentView:SeparatorBigCutStartView/>
<!--James Tynion (IV)-->
<contentView:HomeButtonView ButtonTitle="James Tynion (IV)"
ButtonIcon="book.png"
ButtonNumber="1"
ButtonRedIconVisible="True"
ButtonBlackIconVisible="False"/>
<contentView:SeparatorBigCutStartView/>
<!--Ken Kesey-->
<contentView:HomeButtonView ButtonTitle="Ken Kesey"
ButtonIcon="book.png"
ButtonNumber="1"
ButtonRedIconVisible="True"
ButtonBlackIconVisible="False"/>
<contentView:SeparatorBigCutStartView/>
<!--Ken Liu-->
<contentView:HomeButtonView ButtonTitle="Ken Liu"
ButtonIcon="book.png"
ButtonNumber="1"
ButtonRedIconVisible="True"
ButtonBlackIconVisible="False"/>
<contentView:SeparatorBigCutStartView/> <contentView:SeparatorBigCutStartView/>
</VerticalStackLayout>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
</VerticalStackLayout> </VerticalStackLayout>
</ScrollView> </ScrollView>

@ -1,9 +1,34 @@
using LivreLand.ViewModel;
namespace LivreLand.View; namespace LivreLand.View;
public partial class FiltrageAuteurView : ContentPage public partial class FiltrageAuteurView : ContentPage
{ {
public FiltrageAuteurView() #region Properties
public FiltrageAuteurVM FiltrageAuteurVM { get; set; }
#endregion
#region Constructor
public FiltrageAuteurView(FiltrageAuteurVM filtrageAuteurVM)
{ {
FiltrageAuteurVM = filtrageAuteurVM;
InitializeComponent(); InitializeComponent();
BindingContext = this;
}
#endregion
#region Methods
protected override void OnAppearing()
{
base.OnAppearing();
FiltrageAuteurVM.Manager.GetAllAuthorsCommand.Execute(null);
} }
#endregion
} }

@ -25,6 +25,6 @@ public partial class StatutLectureView : ContentPage
void OnSelectionChanged(object sender, SelectionChangedEventArgs e) void OnSelectionChanged(object sender, SelectionChangedEventArgs e)
{ {
App.Current.MainPage.Navigation.PushAsync(new DetailsLivreView()); //App.Current.MainPage.Navigation.PushAsync(new DetailsLivreView());
} }
} }

@ -52,6 +52,7 @@
</Grid> </Grid>
<CollectionView ItemsSource="{Binding TousVM.Manager.AllBooks}" <CollectionView ItemsSource="{Binding TousVM.Manager.AllBooks}"
SelectionMode="Single" SelectionMode="Single"
SelectionChanged="OnSelectionChanged"
Grid.Row="2"> Grid.Row="2">
<CollectionView.ItemTemplate> <CollectionView.ItemTemplate>
<DataTemplate x:DataType="viewModel:BookVM"> <DataTemplate x:DataType="viewModel:BookVM">
@ -162,8 +163,15 @@
Rotation="180" Rotation="180"
Command="{Binding TousVM.Manager.PreviousCommand}" Command="{Binding TousVM.Manager.PreviousCommand}"
Grid.Column="1"/> Grid.Column="1"/>
<Label Text="{Binding TousVM.Manager.Index, TousVM.Manager.NbPages, StringFormat='{0}/{1}'}" <Label Grid.Column="3">
Grid.Column="3"/> <Label.FormattedText>
<FormattedString>
<Span Text="{Binding TousVM.Manager.Index}"/>
<Span Text="/"/>
<Span Text="{Binding TousVM.Manager.NbPages}"/>
</FormattedString>
</Label.FormattedText>
</Label>
<ImageButton Source="chevron_right.png" <ImageButton Source="chevron_right.png"
Command="{Binding TousVM.Manager.NextCommand}" Command="{Binding TousVM.Manager.NextCommand}"
Grid.Column="5"/> Grid.Column="5"/>

@ -41,7 +41,11 @@ public partial class TousView : ContentPage
void OnSelectionChanged(object sender, SelectionChangedEventArgs e) void OnSelectionChanged(object sender, SelectionChangedEventArgs e)
{ {
App.Current.MainPage.Navigation.PushAsync(new DetailsLivreView()); if (e.CurrentSelection.FirstOrDefault() is BookVM)
{
var result = new DetailsLivreVM(e.CurrentSelection.FirstOrDefault() as BookVM);
App.Current.MainPage.Navigation.PushAsync(new DetailsLivreView(result));
}
} }
protected override void OnAppearing() protected override void OnAppearing()

@ -0,0 +1,28 @@
using PersonalMVVMToolkit;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ViewModels;
namespace LivreLand.ViewModel
{
public class DetailsLivreVM : BaseViewModel
{
#region Properties
public BookVM Book { get; private set; }
#endregion
#region Constructor
public DetailsLivreVM(BookVM bookVM)
{
Book = bookVM;
}
#endregion
}
}

@ -0,0 +1,31 @@
using PersonalMVVMToolkit;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ViewModels;
namespace LivreLand.ViewModel
{
public class FiltrageAuteurVM : BaseViewModel
{
#region Properties
public NavigatorVM Navigator { get; private set; }
public ManagerVM Manager { get; private set; }
#endregion
#region Constructor
public FiltrageAuteurVM(NavigatorVM navigatorVM, ManagerVM managerVM)
{
Navigator = navigatorVM;
Manager = managerVM;
}
#endregion
}
}

@ -11,6 +11,7 @@ namespace ViewModels
#region Fields #region Fields
private readonly ObservableCollection<BookVM> books = new ObservableCollection<BookVM>(); private readonly ObservableCollection<BookVM> books = new ObservableCollection<BookVM>();
private readonly ObservableCollection<AuthorVM> authors = new ObservableCollection<AuthorVM>();
private int index; private int index;
private long nbBooks; private long nbBooks;
@ -23,6 +24,11 @@ namespace ViewModels
get => books; get => books;
} }
public ObservableCollection<AuthorVM> AllAuthors
{
get => authors;
}
public string SearchTitle { get; private set; } public string SearchTitle { get; private set; }
public int Index public int Index
@ -52,6 +58,8 @@ namespace ViewModels
public ICommand GetBooksFromCollectionCommand { get; private set; } public ICommand GetBooksFromCollectionCommand { get; private set; }
public ICommand GetAllAuthorsCommand { get; private set; }
#endregion #endregion
#region Constructor #region Constructor
@ -61,6 +69,7 @@ namespace ViewModels
PreviousCommand = new RelayCommand(() => Previous()); PreviousCommand = new RelayCommand(() => Previous());
NextCommand = new RelayCommand(() => Next()); NextCommand = new RelayCommand(() => Next());
GetBooksFromCollectionCommand = new RelayCommand(() => GetBooksFromCollection()); GetBooksFromCollectionCommand = new RelayCommand(() => GetBooksFromCollection());
GetAllAuthorsCommand = new RelayCommand(() => GetAllAuthors());
//GetBooksByTitleCommand = new RelayCommand(() => AllBooks = model.GetBooksByTitle(SearchTitle, Index, Count).Result.books.Select(book => new BookVM(book))); //GetBooksByTitleCommand = new RelayCommand(() => AllBooks = model.GetBooksByTitle(SearchTitle, Index, Count).Result.books.Select(book => new BookVM(book)));
} }
@ -101,6 +110,22 @@ namespace ViewModels
OnPropertyChanged(nameof(AllBooks)); OnPropertyChanged(nameof(AllBooks));
} }
private async Task GetAllAuthors()
{
var result = await Model.GetBooksFromCollection(0, 20);
IEnumerable<Book> someBooks = result.books;
books.Clear();
authors.Clear();
foreach (var b in someBooks.Select(b => new BookVM(b)))
{
foreach (var a in b.Authors)
{
authors.Add(a);
}
}
OnPropertyChanged(nameof(AllAuthors));
}
#endregion #endregion
} }
} }
Loading…
Cancel
Save