ADD : Avancement page Détails Book + Filtrage Auteur

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

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

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

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

@ -22,6 +22,6 @@ public partial class EmpruntsPretsView : ContentPage
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)
{
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:view="clr-namespace:LivreLand.View"
xmlns:contentView="clr-namespace:LivreLand.View.ContentViews"
xmlns:viewModel="clr-namespace:ViewModels;assembly=ViewModels"
x:Class="LivreLand.View.FiltrageAuteurView"
Title="FiltrageAuteurView">
@ -34,104 +35,20 @@
<VerticalStackLayout Grid.Row="2">
<contentView:SeparatorEntireView/>
<!--Alain Damasio-->
<contentView:HomeButtonView ButtonTitle="Alain Damasio"
ButtonIcon="book.png"
ButtonNumber="2"
ButtonRedIconVisible="True"
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/>
<CollectionView ItemsSource="{Binding FiltrageAuteurVM.Manager.AllAuthors}">
<CollectionView.ItemTemplate>
<DataTemplate x:DataType="viewModel:AuthorVM">
<VerticalStackLayout>
<contentView:HomeButtonView ButtonTitle="{Binding Name}"
ButtonIcon="book.png"
ButtonNumber="2"
ButtonRedIconVisible="True"
ButtonBlackIconVisible="False"/>
<contentView:SeparatorBigCutStartView/>
</VerticalStackLayout>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
</VerticalStackLayout>
</ScrollView>

@ -1,9 +1,34 @@
using LivreLand.ViewModel;
namespace LivreLand.View;
public partial class FiltrageAuteurView : ContentPage
{
public FiltrageAuteurView()
#region Properties
public FiltrageAuteurVM FiltrageAuteurVM { get; set; }
#endregion
#region Constructor
public FiltrageAuteurView(FiltrageAuteurVM filtrageAuteurVM)
{
FiltrageAuteurVM = filtrageAuteurVM;
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)
{
App.Current.MainPage.Navigation.PushAsync(new DetailsLivreView());
//App.Current.MainPage.Navigation.PushAsync(new DetailsLivreView());
}
}

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

@ -41,7 +41,11 @@ public partial class TousView : ContentPage
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()

@ -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
private readonly ObservableCollection<BookVM> books = new ObservableCollection<BookVM>();
private readonly ObservableCollection<AuthorVM> authors = new ObservableCollection<AuthorVM>();
private int index;
private long nbBooks;
@ -23,6 +24,11 @@ namespace ViewModels
get => books;
}
public ObservableCollection<AuthorVM> AllAuthors
{
get => authors;
}
public string SearchTitle { get; private set; }
public int Index
@ -52,6 +58,8 @@ namespace ViewModels
public ICommand GetBooksFromCollectionCommand { get; private set; }
public ICommand GetAllAuthorsCommand { get; private set; }
#endregion
#region Constructor
@ -61,6 +69,7 @@ namespace ViewModels
PreviousCommand = new RelayCommand(() => Previous());
NextCommand = new RelayCommand(() => Next());
GetBooksFromCollectionCommand = new RelayCommand(() => GetBooksFromCollection());
GetAllAuthorsCommand = new RelayCommand(() => GetAllAuthors());
//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));
}
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
}
}
Loading…
Cancel
Save