meilleur gestion des statuts + à lire plus tard

master
Lucas Evard 1 year ago
parent ca5debb924
commit 5df7c6edb8

BIN
.DS_Store vendored

Binary file not shown.

BIN
sources/.DS_Store vendored

Binary file not shown.

@ -1,4 +1,4 @@
using System;
 using System;
namespace MyToolkitMVVM
{

@ -7,7 +7,7 @@ public partial class AppShell : Shell
Routing.RegisterRoute("TousPage",typeof(TousPage));
Routing.RegisterRoute("StatutPage", typeof(StatutPage));
Routing.RegisterRoute("SharePage", typeof(SharePage));
Routing.RegisterRoute("LaterPage", typeof(SharePage));
Routing.RegisterRoute("LaterPage", typeof(LaterPage));
Routing.RegisterRoute("LikePage", typeof(LikePage));
Routing.RegisterRoute("Auteur", typeof(SharePage));
Routing.RegisterRoute("DatePublic", typeof(DatePublic));

@ -10,6 +10,7 @@ namespace PocketBook.Applicative_VM
{
public ManagerVM Manager { get; private set; }
public ICommand ChangeStatus { get; private set; }
public ICommand AddReadLaterList { get; private set; }
public DetailPageVM(ManagerVM manager)
{
@ -22,7 +23,13 @@ namespace PocketBook.Applicative_VM
_ = Toast.Make("Changement du status: " + Manager.SelectedBook.BookStatus, ToastDuration.Short, 14).Show(new CancellationTokenSource().Token);
});
}
AddReadLaterList = new Command( o =>
{
Manager.ChangeStatut("À lire");
_ = Toast.Make("Ajout dans la liste de livre à lire plus tard", ToastDuration.Short, 14).Show(new CancellationTokenSource().Token);
});
}
}
}

@ -0,0 +1,32 @@
using System;
using System.Diagnostics;
using System.Windows.Input;
using ViewModel;
namespace PocketBook.Applicative_VM
{
public class LaterPageVM
{
public ICommand NavigateDetailPage { get; private set; }
public NavigatorVM NavigateCommandBooks { get; private set; }
public ScanMenuVM ScanMenuVM { get; private set; }
public ManagerVM Manager { get; private set; }
public PaginationVM PaginationVM { get; private set; }
public LaterPageVM(NavigatorVM navigation, ManagerVM manager, ScanMenuVM scanMenuVM, PaginationVM paginationVM)
{
ScanMenuVM = scanMenuVM;
Manager = manager;
PaginationVM = paginationVM;
NavigateCommandBooks = navigation;
Manager.LoadBooksReadLaterFromManager();
NavigateDetailPage = new Command<BookVM>(book =>
{
Manager.SelectedBook = book;
NavigateCommandBooks.Navigateto.Execute("BookDetail");
});
}
}
}

@ -2,6 +2,7 @@
using System.Windows.Input;
using System.Threading.Tasks;
using System.Reflection;
using ViewModel;
namespace PocketBook.Applicative_VM
{
@ -11,9 +12,9 @@ namespace PocketBook.Applicative_VM
public NavigatorVM()
{
Navigateto = new Command<string>(
async (string page) => await Shell.Current.GoToAsync(page)
);
Navigateto = new Command<string>(execute:async page => {
await Shell.Current.GoToAsync(page);
});
}
}
}

@ -0,0 +1,70 @@
using System;
using System.Diagnostics;
using System.Windows.Input;
using ViewModel;
namespace PocketBook.Applicative_VM
{
public class PaginationVM
{
public ManagerVM Manager { get; private set; }
public ICommand NormalIncreasePage { get; private set; }
public ICommand NormalDecreasePage { get; private set; }
public ICommand LaterIncreasePage { get; private set; }
public ICommand LaterDecreasePage { get; private set; }
public PaginationVM(ManagerVM managerVM)
{
Manager = managerVM;
NormalIncreasePage = new Command(execute: () =>
{
Manager.Index++;
Manager.LoadBooksFromManager();
((Command)NormalIncreasePage).ChangeCanExecute();
((Command)NormalDecreasePage).ChangeCanExecute();
},
canExecute: () => {
return Manager.NbBook / 5 > Manager.Index;
});
NormalDecreasePage = new Command(execute:() =>
{
if (Manager.Index > 0)
{
Manager.Index--;
Manager.LoadBooksFromManager();
((Command)NormalIncreasePage).ChangeCanExecute();
((Command)NormalDecreasePage).ChangeCanExecute();
}
},
canExecute: () => {
return Manager.Index > 0;
});
LaterIncreasePage = new Command(execute: () =>
{
if(Manager.NbBookLater / 5 > Manager.IndexLater) {
Manager.IndexLater++;
Manager.LoadBooksFromManager();
((Command)LaterIncreasePage).ChangeCanExecute();
((Command)LaterDecreasePage).ChangeCanExecute();
}
},
canExecute: () =>
{
return Manager.NbBookLater / 5 > Manager.IndexLater;
});
LaterDecreasePage = new Command(execute: () =>
{
Manager.IndexLater--;
Manager.LoadBooksFromManager();
((Command)LaterIncreasePage).ChangeCanExecute();
((Command)LaterDecreasePage).ChangeCanExecute();
},
canExecute: () => {
return Manager.IndexLater > 0;
});
}
}
}

@ -12,18 +12,20 @@ namespace PocketBook.Applicative_VM
public NavigatorVM NavigateCommandBooks { get; private set; }
public ScanMenuVM ScanMenuVM { get; private set; }
public ManagerVM Manager { get; private set; }
public PaginationVM PaginationVM { get; private set; }
public TousPageVM(NavigatorVM navigation,ManagerVM manager, ScanMenuVM scanMenuVM)
public TousPageVM(NavigatorVM navigation,ManagerVM manager, ScanMenuVM scanMenuVM, PaginationVM paginationVM)
{
ScanMenuVM = scanMenuVM;
Manager = manager;
PaginationVM = paginationVM;
Manager.LoadBooksFromManager();
NavigateCommandBooks = navigation;
NavigateDetailPage = new Command<BookVM>(book =>
{
Debug.WriteLine(book.Id);
Manager.LoadBookFromManager(book.Id);
Debug.WriteLine(Manager.SelectedBook.Title);
Manager.SelectedBook = book;
NavigateCommandBooks.Navigateto.Execute("BookDetail");
});
}

@ -51,6 +51,8 @@ public static class MauiProgram
.AddSingleton<TousPage>()
.AddSingleton<BookDetail>()
.AddSingleton<DetailPageVM>()
.AddSingleton<PaginationVM>()
.AddSingleton<LaterPageVM>()
.AddSingleton<DatePublic>()
.AddSingleton<LikePage>()
.AddSingleton<LaterPage>()

@ -14,7 +14,7 @@
<Image Source="{Binding Manager.SelectedBook.Image}" Margin="0,0,10,0" WidthRequest="90" HeightRequest="160"/>
<StackLayout Orientation="Vertical">
<Label Text="{Binding Manager.SelectedBook.Title}" FontFamily="Pro-Display-Semibold" FontSize="17" Margin="0,15,0,0"/>
<local:Stars NbStars="{Binding Manager.SelectedBook.IntNbPages}" Margin="0,90,0,0"/>
<local:Stars NombreEtoile="{Binding Manager.SelectedBook.StarsNumber}" Margin="0,90,0,0"/>
</StackLayout>
</StackLayout>
<StackLayout Margin="15,0,0,0">
@ -26,12 +26,24 @@
<Line BackgroundColor="{StaticResource LineColor1}"/>
<StackLayout >
<Label Text="Auteur" Style="{StaticResource LabelStyleDetailBook3}"/>
<Label Text="{Binding Manager.SelectedBook.BookFirstAuthor}" Style="{StaticResource LabelStyleDetailBook4}"/>
<CollectionView HeightRequest="30" ItemsLayout="HorizontalList" ItemsSource="{Binding Manager.SelectedBook.BookAuthors}" Margin="10,0,0,0">
<CollectionView.ItemTemplate>
<DataTemplate>
<Label Text="{Binding Name}" Style="{StaticResource LabelStyleDetailBook4}"/>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
</StackLayout>
<Line BackgroundColor="{StaticResource LineColor1}"/>
<StackLayout>
<Label Text="Maison d'édition" Style="{StaticResource LabelStyleDetailBook3}"/>
<Label Text="{Binding Manager.SelectedBook.BookFirstPublisher}" Style="{StaticResource LabelStyleDetailBook4}"/>
<Label Text="Maison d'édition" Style="{StaticResource LabelStyleDetailBook3}"/>
<CollectionView HeightRequest="30" ItemsLayout="HorizontalList" ItemsSource="{Binding Manager.SelectedBook.BookPublishers}" Margin="10,0,0,0">
<CollectionView.ItemTemplate>
<DataTemplate>
<Label Text="{Binding .}" Style="{StaticResource LabelStyleDetailBook4}"/>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
</StackLayout>
<Line BackgroundColor="{StaticResource LineColor1}"/>
<StackLayout Margin="0,0,0,10">
@ -64,14 +76,14 @@
<Label Text="Bibliothèque" Style="{StaticResource LabelStyleDetailBook3}"/>
<StackLayout Orientation="Horizontal">
<Label Text="Ajouté le" Style="{StaticResource LabelStyleDetailBook4}"/>
<Label x:Name="bookAdd" Style="{StaticResource LabelStyleDetailBook2}"/>
<Label Text="{Binding Manager.SelectedBook.PublishDate}" Style="{StaticResource LabelStyleDetailBook2}"/>
</StackLayout>
<Line BackgroundColor="{StaticResource LineColor1}"/>
<StackLayout Padding="50"/>
<Line BackgroundColor="{StaticResource LineColor1}"/>
<local:BookChange PropertyName="Déplacer le livre" ImageName="folder.png"/>
<Line BackgroundColor="{StaticResource LineColor1}"/>
<local:BookChange PropertyName="Ajouter à la liste à lire plus tard" ImageName="plus_round.png"/>
<local:BookChange Command="{Binding AddReadLaterList}" PropertyName="Ajouter à la liste à lire plus tard" ImageName="plus_round.png"/>
<Line BackgroundColor="{StaticResource LineColor1}"/>
<local:BookChange Command="{Binding ChangeStatus}" PropertyName="Changer le statut de lecture" ImageName="eyeglasses.png"/>
<Line BackgroundColor="{StaticResource LineColor1}"/>

@ -12,7 +12,7 @@
<Label x:Name="autorName" Text="{Binding AutorName, Source={x:Reference root}}" FontFamily="Pro-Text-Semibold" FontSize="12"/>
<Label x:Name="bookStatus" Text="{Binding BookStatus, Source={x:Reference root}}" FontFamily="Pro-Text-Semibold" FontSize="12" TextColor="#AFAFAF"/>
<StackLayout Orientation="Horizontal" Margin="0,30,0,0">
<local:Stars NbStars="{Binding Nbstars, Source={x:Reference root}}" Margin="0,0,0,5"/>
<local:Stars NombreEtoile="{Binding NombreEtoile, Source={x:Reference root}}" Margin="0,0,0,5"/>
</StackLayout>
</StackLayout>
</StackLayout>

@ -19,22 +19,22 @@ public partial class ContentViewBook : ContentView
public static readonly BindableProperty CommandProperty =
BindableProperty.Create(nameof(Command), typeof(ICommand), typeof(ContentViewBook));
public static readonly BindableProperty StarsProperty =
BindableProperty.Create(nameof(Nbstars), typeof(int), typeof(ContentViewBook));
public static readonly BindableProperty CommandParameterProperty =
BindableProperty.Create(nameof(CommandParameter), typeof(string), typeof(ContentViewBook));
public ICommand Command
public static readonly BindableProperty NombreEtoileProperty =
BindableProperty.Create(nameof(NombreEtoile), typeof(int), typeof(ContentViewBook), defaultValue: 0);
public int NombreEtoile
{
get { return (ICommand)GetValue(CommandProperty); }
set { SetValue(CommandProperty, value); }
get { return (int)GetValue(NombreEtoileProperty); }
set { SetValue(NombreEtoileProperty, value); }
}
public int Nbstars
public ICommand Command
{
get { return (int)GetValue(StarsProperty); }
set { SetValue(StarsProperty, value); }
get { return (ICommand)GetValue(CommandProperty); }
set { SetValue(CommandProperty, value); }
}
public string CommandParameter

@ -1,54 +1,73 @@
using CommunityToolkit.Maui.Behaviors;
using Microsoft.Maui.Controls;
using System.Linq;
namespace PocketBook;
public partial class Stars : ContentView
namespace PocketBook
{
public static readonly BindableProperty NbStarsProperty =
BindableProperty.Create(nameof(NbStars), typeof(int), typeof(Stars), defaultValue: 0, propertyChanged: OnNbStarsChanged);
public int NbStars
public partial class Stars : ContentView
{
get { return (int)GetValue(NbStarsProperty); }
set { SetValue(NbStarsProperty, value); }
}
public static readonly BindableProperty NombreEtoileProperty =
BindableProperty.Create(nameof(NombreEtoile), typeof(int), typeof(Stars), defaultValue: 0, propertyChanged: OnNbStarsChanged);
public Stars()
{
InitializeComponent();
}
public int NombreEtoile
{
get => (int)GetValue(NombreEtoileProperty);
set => SetValue(NombreEtoileProperty, value);
}
private static void OnNbStarsChanged(BindableObject bindable, object oldValue, object newValue)
{
if (bindable is Stars stars)
public Stars()
{
stars.UpdateStars();
InitializeComponent();
InitializeStars();
}
}
private void UpdateStars()
{
int z = 0;
private void InitializeStars()
{
var behaviorGrey = new IconTintColorBehavior
{
TintColor = Color.FromArgb("#E6E6E6"),
};
var behaviorYellow = new IconTintColorBehavior
foreach (Image i in StarsList.Children.OfType<Image>())
{
i.Behaviors.Add(behaviorGrey);
}
}
private static void OnNbStarsChanged(BindableObject bindable, object oldValue, object newValue)
{
TintColor = Color.FromArgb("#FFFF00"),
};
if (bindable is Stars stars)
{
stars.UpdateStars();
}
}
var behaviorGrey = new IconTintColorBehavior
private void UpdateStars()
{
TintColor = Color.FromArgb("#E6E6E6"),
};
int z = 0;
var behaviorGrey = new IconTintColorBehavior
{
TintColor = Color.FromArgb("#E6E6E6"),
};
foreach (Image i in StarsList.Children.Where(c => c is Image))
{
if (z < NbStars)
var behaviorYellow = new IconTintColorBehavior
{
TintColor = Color.FromArgb("#FFFF00"),
};
foreach (Image i in StarsList.Children.OfType<Image>())
{
i.Behaviors.Add(behaviorYellow);
if (z < NombreEtoile)
{
i.Behaviors.Add(behaviorYellow);
}
else
{
i.Behaviors.Add(behaviorGrey);
}
z++;
}
else i.Behaviors.Add(behaviorGrey);
}
}
}
}

@ -3,59 +3,36 @@
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="PocketBook.LaterPage"
xmlns:local="clr-namespace:PocketBook"
Title="À lire plus tard"
Shell.ForegroundColor="{StaticResource Primary}"
x:Name="root"
xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit">
<Grid RowDefinitions="auto, *">
<StackLayout Orientation="Vertical">
<StackLayout Orientation="Horizontal" Padding="5,10,0,10" >
<StackLayout Orientation="Horizontal" HorizontalOptions="StartAndExpand">
<Image Source="chevron_left.png">
<Image.Behaviors>
<toolkit:IconTintColorBehavior TintColor="{StaticResource Primary}"/>
</Image.Behaviors>
</Image>
<Label Text="Mes livres" Style="{StaticResource TitleLabelLeftStyle}"/>
</StackLayout>
<Label Text="À lire plus tard" Style="{StaticResource TitleLabelStyle}"/>
<StackLayout HorizontalOptions="EndAndExpand" Orientation="Horizontal">
<ImageButton Source="plus.png" Style="{StaticResource RightIconToolBar2}">
<ImageButton.Behaviors>
<toolkit:IconTintColorBehavior TintColor="{StaticResource Primary}"/>
</ImageButton.Behaviors>
</ImageButton>
<ImageButton x:Name="imageArrows" Style="{StaticResource RightIconToolBar}" Source="arrows.png">
<ImageButton.Behaviors>
<toolkit:IconTintColorBehavior TintColor="{StaticResource Primary}"/>
</ImageButton.Behaviors>
</ImageButton>
</StackLayout>
</StackLayout>
<Line BackgroundColor="#E6E6E6"/>
</StackLayout>
<ContentPage.Resources>
</ContentPage.Resources>
<ContentPage.ToolbarItems>
<ToolbarItem Text="Ajouter" Priority="1"
Order="Primary" IconImageSource="plus.png"/>
<ToolbarItem Text="Order" Priority="2"
Order="Primary" IconImageSource="arrows.png"/>
</ContentPage.ToolbarItems>
<ScrollView Grid.Row="1">
<VerticalStackLayout>
<local:ContentViewBook BookImage="buveurencre.jpg" BookName="La horde du contrevent" AutorName="Alain Damasio" BookStatus="À lire plus tard"/>
<Line Style="{StaticResource LineStyle3}"/>
<local:ContentViewBook BookImage="buveurencre.jpg" BookName="La zone du dehors" AutorName="Alain Damasio" BookStatus="À lire plus tard"/>
<Line Style="{StaticResource LineStyle3}"/>
<local:ContentViewBook BookImage="buveurencre.jpg" BookName="L'équateur d'Einstein" AutorName="Cixin Liu" BookStatus="À lire plus tard"/>
<Line Style="{StaticResource LineStyle3}"/>
<local:ContentViewBook BookImage="buveurencre.jpg" BookName="La forêt sombre" AutorName="Cixin Liu" BookStatus="À lire plus tard"/>
<Line Style="{StaticResource LineStyle3}"/>
<local:ContentViewBook BookImage="buveurencre.jpg" BookName="Le problème à trois corps" AutorName="Cixin Liu" BookStatus="À lire plus tard"/>
<Line Style="{StaticResource LineStyle3}"/>
<local:ContentViewBook BookImage="buveurencre.jpg" BookName="L'équateur d'Einstein" AutorName="Cixin Liu" BookStatus="À lire plus tard"/>
<Line Style="{StaticResource LineStyle3}"/>
<local:ContentViewBook BookImage="buveurencre.jpg" BookName="La forêt sombre" AutorName="Cixin Liu" BookStatus="À lire plus tard"/>
<Line Style="{StaticResource LineStyle3}"/>
<local:ContentViewBook BookImage="buveurencre.jpg" BookName="Le problème à trois corps" AutorName="Cixin Liu" BookStatus="À lire plus tard"/>
<CollectionView x:Name="collection" IsGrouped="True" GroupHeaderTemplate="{StaticResource groupHeaderTemplate}" SelectionMode="Single" SelectionChangedCommand="{Binding LaterPageVM.NavigateDetailPage, Source={x:Reference root}}" SelectionChangedCommandParameter="{Binding SelectedItem, Source={x:Reference collection}}" ItemsSource="{Binding LaterPageVM.Manager.GroupedLaterBooks}">
<CollectionView.ItemTemplate>
<DataTemplate>
<local:ContentViewBook Margin="0,5,0,0" NombreEtoile="2" BookImage="{Binding Image}" BookName="{Binding Title}" AutorName="{Binding BookFirstAuthor}" BookStatus="{Binding BookStatus}"/>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
<StackLayout Orientation="Horizontal" Margin="0,20,20,20" HorizontalOptions="CenterAndExpand" VerticalOptions="CenterAndExpand">
<Button Command="{Binding LaterPageVM.PaginationVM.LaterDecreasePage}" Text="Précédent"/>
<Label Text="{Binding LaterPageVM.Manager.IndexLater}" HorizontalOptions="CenterAndExpand" VerticalOptions="CenterAndExpand" Margin="10,0,10,0"/>
<Button Command="{Binding LaterPageVM.PaginationVM.LaterIncreasePage}" Text="Suivant"/>
</StackLayout>
</VerticalStackLayout>
</ScrollView>
</Grid>
</ContentPage>

@ -5,11 +5,12 @@ namespace PocketBook;
public partial class LaterPage : ContentPage
{
public NavigatorVM NavigateCommandBooks { get; private set; }
public LaterPageVM LaterPageVM { get; private set; }
public LaterPage(NavigatorVM navigator)
public LaterPage(LaterPageVM laterPageVM)
{
NavigateCommandBooks = navigator;
LaterPageVM = laterPageVM;
InitializeComponent();
BindingContext = this;
}
}

@ -3,39 +3,19 @@
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="PocketBook.LikePage"
xmlns:local="clr-namespace:PocketBook"
xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit">
Title="Favoris"
Shell.ForegroundColor="{StaticResource Primary}">
<Grid RowDefinitions="auto, *">
<VerticalStackLayout>
<StackLayout Orientation="Horizontal" Padding="5,10,0,10" >
<StackLayout Orientation="Horizontal" HorizontalOptions="StartAndExpand">
<Image Source="chevron_left.png">
<Image.Behaviors>
<toolkit:IconTintColorBehavior TintColor="{StaticResource Primary}"/>
</Image.Behaviors>
</Image>
<Label Text="Mes livres" Style="{StaticResource TitleLabelLeftStyle}"/>
</StackLayout>
<Label Text="Favoris" Style="{StaticResource TitleLabelStyle}"/>
<StackLayout HorizontalOptions="EndAndExpand" Orientation="Horizontal">
<ImageButton Style="{StaticResource RightIconToolBar2}" Source="plus.png">
<ImageButton.Behaviors>
<toolkit:IconTintColorBehavior TintColor="{StaticResource Primary}"/>
</ImageButton.Behaviors>
</ImageButton>
<ImageButton x:Name="imageArrows" Style="{StaticResource RightIconToolBar}" Source="arrows.png">
<ImageButton.Behaviors>
<toolkit:IconTintColorBehavior TintColor="{StaticResource Primary}"/>
</ImageButton.Behaviors>
</ImageButton>
</StackLayout>
</StackLayout>
<Line BackgroundColor="{StaticResource LineColor1}"/>
</VerticalStackLayout>
<ContentPage.Resources>
</ContentPage.Resources>
<ContentPage.ToolbarItems>
<ToolbarItem Text="Ajouter" Priority="1"
Order="Primary" IconImageSource="plus.png"/>
<ToolbarItem Text="Order" Priority="2"
Order="Primary" IconImageSource="arrows.png"/>
</ContentPage.ToolbarItems>
<ScrollView Grid.Row="1">
<VerticalStackLayout>
@ -57,5 +37,4 @@
</VerticalStackLayout>
</ScrollView>
</Grid>
</ContentPage>

@ -29,10 +29,15 @@
<CollectionView x:Name="collection" IsGrouped="True" GroupHeaderTemplate="{StaticResource groupHeaderTemplate}" SelectionMode="Single" SelectionChangedCommand="{Binding TousPageVM.NavigateDetailPage, Source={x:Reference root}}" SelectionChangedCommandParameter="{Binding SelectedItem, Source={x:Reference collection}}" ItemsSource="{Binding TousPageVM.Manager.GroupedBooks}">
<CollectionView.ItemTemplate>
<DataTemplate>
<local:ContentViewBook Margin="0,5,0,0" Nbstars="{Binding StarsNumber}" BookImage="{Binding Image}" BookName="{Binding Title}" AutorName="{Binding BookFirstAuthor}" BookStatus="{Binding BookStatus}"/>
<local:ContentViewBook Margin="0,5,0,0" NombreEtoile="{Binding StarsNumber}" BookImage="{Binding Image}" BookName="{Binding Title}" AutorName="{Binding BookFirstAuthor}" BookStatus="{Binding BookStatus}"/>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
<StackLayout Orientation="Horizontal" Margin="0,20,20,20" HorizontalOptions="CenterAndExpand" VerticalOptions="CenterAndExpand">
<Button Command="{Binding TousPageVM.PaginationVM.NormalDecreasePage}" Text="Précédent"/>
<Label Text="{Binding TousPageVM.Manager.Index}" HorizontalOptions="CenterAndExpand" VerticalOptions="CenterAndExpand" Margin="10,0,10,0"/>
<Button Command="{Binding TousPageVM.PaginationVM.NormalIncreasePage}" Text="Suivant"/>
</StackLayout>
</VerticalStackLayout>
</ScrollView>
</StackLayout>

@ -13,10 +13,10 @@ namespace ViewModel
set =>SetProperty(Model.Title,value,v=>Model.Title=v);
}
public float? Nbpages
public int Nbpages
{
get => Model.UserRating;
set => SetProperty(Model.UserRating, value, v => Model.UserRating = v);
get => Model.NbPages;
set => SetProperty(Model.NbPages, value, v => Model.NbPages = v);
}
public float? UserRating
@ -25,6 +25,13 @@ namespace ViewModel
set => SetProperty(Model.UserRating, value,v=> Model.UserRating=v);
}
public DateTime PublishDate
{
get => Model.PublishDate;
set => SetProperty(Model.PublishDate, value, v => Model.PublishDate = v);
}
public Languages Language
{
get => Model.Language;
@ -96,8 +103,7 @@ namespace ViewModel
}
else BookFirstPublisher = "Unknown";
/* StarsNumber = (int)Math.Round(Nbpages ?? 0);
Debug.WriteLine(StarsNumber);*/
StarsNumber = (int)Math.Round(UserRating ?? 0);
}
}
}

@ -1,6 +1,7 @@
namespace ViewModel;
using System.Collections.ObjectModel;
using System.Diagnostics;
using Model;
using MyToolkitMVVM;
@ -12,8 +13,8 @@ public class ManagerVM : BaseViewModel<Manager>
public RelayCommand<string> LoadBooks { get; private set; }
public IEnumerable<IGrouping<string, BookVM>> GroupedBooks => Books.GroupBy(b => b.BookFirstAuthor).OrderBy(group => group.Key);
public IEnumerable<IGrouping<string, BookVM>> GroupedBooks => books.GroupBy(b => b.BookFirstAuthor).OrderBy(group => group.Key);
public IEnumerable<IGrouping<string, BookVM>> GroupedLaterBooks => books.Where(book => book.BookStatus == Status.ToBeRead).GroupBy(book => book.BookFirstAuthor).OrderBy(group => group.Key);
public BookVM SelectedBook
{
get => selectedBook;
@ -28,7 +29,7 @@ public class ManagerVM : BaseViewModel<Manager>
public async void LoadBooksFromManager()
{
var result = await Model.GetBooksFromCollection(index, 40, "");
var result = await Model.GetBooksFromCollection(index, 5, "");
NbBook = (int)result.count;
books.Clear();
@ -36,9 +37,26 @@ public class ManagerVM : BaseViewModel<Manager>
{
books.Add(new BookVM(book));
}
Refresh();
}
public async void LoadBooksReadLaterFromManager()
{
var result = await Model.GetBooksFromCollection(indexLater, 5, "");
books.Clear();
nbBookLater = 0;
foreach (Book book in result.books)
{
if (book.Status == Status.ToBeRead)
{
books.Add(new BookVM(book));
nbBookLater++;
}
}
Refresh();
}
public async void ChangeStatut(string statut)
public void ChangeStatut(string statut)
{
switch (statut)
{
@ -54,28 +72,36 @@ public class ManagerVM : BaseViewModel<Manager>
case "En lecture":
SelectedBook.BookStatus = Status.Reading;
break;
case "Unknown":
SelectedBook.BookStatus = Status.NotRead;
break;
}
Refresh();
}
public async void LoadBookFromManager(string id)
public void Refresh()
{
var result = await Model.GetBookById(id);
SelectedBook = new BookVM(result);
OnPropertyChanged(nameof(GroupedBooks));
OnPropertyChanged(nameof(GroupedLaterBooks));
//NbBookLater=books.Where(book => book.BookStatus == Status.ToBeRead).Count();
Debug.WriteLine(NbBookLater);
}
public ManagerVM(Manager model) : base(model)
{
LoadBooks = new RelayCommand<string>(o => LoadBooksFromManager());
LoadBooks.Execute();
Books = new ReadOnlyObservableCollection<BookVM>(books);
}
public int Index
{
get => index;
set => SetProperty(ref index, value);
set
{
SetProperty(ref index, value);
}
}
private int index;
public int Count
@ -95,5 +121,24 @@ public class ManagerVM : BaseViewModel<Manager>
private int nbBook;
public int NbBookLater
{
get => nbBookLater;
set => SetProperty(ref nbBookLater, value);
}
private int nbBookLater;
public int IndexLater
{
get => indexLater;
set
{
SetProperty(ref indexLater, value);
}
}
private int indexLater;
}

Loading…
Cancel
Save