ADD : Order Books By Author, Loaner or Owner & Status in different pages (Header Style ToFix)

commands-19-09
Lou BRODA 1 year ago
parent 5c9c0e67fb
commit c13bcb1ffa

@ -125,7 +125,7 @@
<DataTemplate x:DataType="viewModel:AuthorVM">
<Label Text="{Binding Name}"
Style="{StaticResource DetailsLivreBody}"
Margin="0,0,5,0"
Margin="0,0,1,0"
Grid.Row="1"/>
</DataTemplate>
</CollectionView.ItemTemplate>
@ -145,10 +145,7 @@
Style="{StaticResource DetailsLivreTitle}"
Grid.Row="0"/>
<Grid Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
</Grid.ColumnDefinitions>
<HorizontalStackLayout>
<CollectionView ItemsSource="{Binding DetailsLivreVM.Book.Publishers}"
Grid.Column="0">
<CollectionView.ItemsLayout>
@ -158,13 +155,14 @@
<DataTemplate>
<Label Text="{Binding .}"
Style="{StaticResource DetailsLivreBody}"
Margin="0,0,5,0"
Margin="0,0,1,0"
Grid.Row="1"/>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
<Label Text="{Binding DetailsLivreVM.Book.PublishDate,StringFormat=' ({0:yyyy})'}"
Grid.Column="1"/>
</HorizontalStackLayout>
</Grid>
</Grid>

@ -32,12 +32,35 @@
EmpruntsButtonCommand="{Binding EmpruntsPretsVM.EmpruntsButtonCommand}"/>
<ScrollView Grid.Row="4">
<Grid>
<CollectionView ItemsSource="{Binding EmpruntsPretsVM.Manager.AllCurrentLoans}"
<CollectionView ItemsSource="{Binding EmpruntsPretsVM.Manager.AllCurrentGroupedLoans}"
SelectedItem="{Binding EmpruntsPretsVM.Manager.SelectedLoan}"
SelectionMode="Single"
SelectionChangedCommand="{Binding EmpruntsPretsVM.OnSelectionLoanChangedCommand}"
SelectionChangedCommandParameter="{Binding EmpruntsPretsVM.Manager.SelectedBook}"
IsVisible="{Binding EmpruntsPretsVM.PretCollectionIsVisible}">
IsVisible="{Binding EmpruntsPretsVM.PretCollectionIsVisible}"
IsGrouped="True">
<CollectionView.GroupHeaderTemplate>
<DataTemplate>
<Grid BackgroundColor="{AppThemeBinding Light={StaticResource HeaderGray}, Dark={StaticResource Gray900}}"
Grid.Row="0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="10"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Label VerticalOptions="Center"
Style="{StaticResource HeaderCollectionViewText}"
Grid.Column="1">
<Label.Text>
<MultiBinding StringFormat="{}{0} {1}">
<Binding Path="Key.FirstName" />
<Binding Path="Key.LastName" />
</MultiBinding>
</Label.Text>
</Label>
</Grid>
</DataTemplate>
</CollectionView.GroupHeaderTemplate>
<CollectionView.ItemTemplate>
<DataTemplate x:DataType="viewModel:LoanVM">
<VerticalStackLayout Margin="10"
@ -110,12 +133,35 @@
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
<CollectionView ItemsSource="{Binding EmpruntsPretsVM.Manager.AllCurrentBorrowings}"
<CollectionView ItemsSource="{Binding EmpruntsPretsVM.Manager.AllCurrentGroupedBorrowings}"
SelectedItem="{Binding EmpruntsPretsVM.Manager.SelectedBorrowing}"
SelectionMode="Single"
SelectionChangedCommand="{Binding EmpruntsPretsVM.OnSelectionBorrowingChangedCommand}"
SelectionChangedCommandParameter="{Binding EmpruntsPretsVM.Manager.SelectedBorrowing}"
IsVisible="{Binding EmpruntsPretsVM.EmpruntCollectionIsVisible}">
IsVisible="{Binding EmpruntsPretsVM.EmpruntCollectionIsVisible}"
IsGrouped="True">
<CollectionView.GroupHeaderTemplate>
<DataTemplate>
<Grid BackgroundColor="{AppThemeBinding Light={StaticResource HeaderGray}, Dark={StaticResource Gray900}}"
Grid.Row="0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="10"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Label VerticalOptions="Center"
Style="{StaticResource HeaderCollectionViewText}"
Grid.Column="1">
<Label.Text>
<MultiBinding StringFormat="{}{0} {1}">
<Binding Path="Key.FirstName" />
<Binding Path="Key.LastName" />
</MultiBinding>
</Label.Text>
</Label>
</Grid>
</DataTemplate>
</CollectionView.GroupHeaderTemplate>
<CollectionView.ItemTemplate>
<DataTemplate x:DataType="viewModel:BorrowingVM">
<VerticalStackLayout Margin="10"

@ -26,14 +26,15 @@
<contentView:SearchBarView Grid.Row="2"/>
<ScrollView Grid.Row="4">
<Grid>
<CollectionView ItemsSource="{Binding StatutLectureVM.Manager.AllBooks}"
<CollectionView ItemsSource="{Binding StatutLectureVM.Manager.GroupedStatusBooks}"
SelectedItem="{Binding StatutLectureVM.Manager.SelectedBook}"
SelectionMode="Single"
SelectionChangedCommand="{Binding StatutLectureVM.OnSelectionChangedCommand}"
SelectionChangedCommandParameter="{Binding StatutLectureVM.Manager.SelectedBook}"
IsGrouped="True"
Grid.Row="2">
<CollectionView.GroupHeaderTemplate>
<DataTemplate x:DataType="viewModel:BookVM">
<DataTemplate>
<Grid BackgroundColor="{AppThemeBinding Light={StaticResource HeaderGray}, Dark={StaticResource Gray900}}"
Grid.Row="0">
<Grid.ColumnDefinitions>
@ -41,8 +42,7 @@
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Label Text="{Binding Status}"
<Label Text="{Binding Key}"
VerticalOptions="Center"
Style="{StaticResource HeaderCollectionViewText}"
Grid.Column="1"/>

@ -36,14 +36,15 @@
<RowDefinition Height="10"/>
<RowDefinition Height="auto"/>
</Grid.RowDefinitions>
<CollectionView ItemsSource="{Binding TousVM.Manager.AllBooks}"
<CollectionView ItemsSource="{Binding TousVM.Manager.GroupedBooks}"
SelectedItem="{Binding TousVM.Manager.SelectedBook}"
SelectionMode="Single"
SelectionChangedCommand="{Binding TousVM.OnSelectionChangedCommand}"
SelectionChangedCommandParameter="{Binding TousVM.Manager.SelectedBook}"
IsGrouped="True"
Grid.Row="2">
<CollectionView.GroupHeaderTemplate>
<DataTemplate x:DataType="viewModel:BookVM">
<DataTemplate>
<Grid BackgroundColor="{AppThemeBinding Light={StaticResource HeaderGray}, Dark={StaticResource Gray900}}"
Grid.Row="0">
<Grid.ColumnDefinitions>
@ -51,7 +52,7 @@
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Label Text="Alain Damasio"
<Label Text="{Binding Key}"
VerticalOptions="Center"
Style="{StaticResource HeaderCollectionViewText}"
Grid.Column="1"/>

@ -20,31 +20,26 @@ namespace ViewModels
public string Id
{
get => Model.Id;
set => SetProperty(Model.Id, value, v => Model.Id = value);
}
public string ISBN13
{
get => Model.ISBN13;
set => SetProperty(Model.ISBN13, value, v => Model.ISBN13 = value);
}
public string Title
{
get => Model.Title;
set => SetProperty(Model.Title, value, v => Model.Title = value);
}
public List<string> Publishers
{
get => Model.Publishers;
set => SetProperty(Model.Publishers, value, v => Model.Publishers = value);
}
public DateTime PublishDate
{
get => Model.PublishDate;
set => SetProperty(Model.PublishDate, value, v => Model.PublishDate = value);
}
public List<AuthorVM> Authors
@ -52,22 +47,21 @@ namespace ViewModels
get => Model.Authors.Select(a => new AuthorVM(a)).ToList();
}
public string Author => Model.Authors.Count > 0 ? Model.Authors.First().Name : "Auteur inconnu";
public Status Status
{
get => Model.Status;
set => SetProperty(Model.Status, value, v => Model.Status = value);
}
public int NbPages
{
get => Model.NbPages;
set => SetProperty(Model.NbPages, value, v => Model.NbPages = value);
}
public Languages Language
{
get => Model.Language;
set => SetProperty(Model.Language, value, v => Model.Language = value);
}
public string ImageSmall

@ -4,6 +4,7 @@ using System.Collections.ObjectModel;
using System.Linq;
using System.Text.RegularExpressions;
using System.Windows.Input;
using static System.Reflection.Metadata.BlobBuilder;
namespace ViewModels
{
@ -13,17 +14,29 @@ namespace ViewModels
#region Fields
private readonly ObservableCollection<BookVM> books = new ObservableCollection<BookVM>();
private IEnumerable<IGrouping<string, BookVM>> groupedBooks;
private IEnumerable<IGrouping<Status, BookVM>> groupedStatusBooks;
private readonly ObservableCollection<AuthorVM> authors = new ObservableCollection<AuthorVM>();
private readonly ObservableCollection<PublishDateVM> publishDates = new ObservableCollection<PublishDateVM>();
private readonly ObservableCollection<RatingsVM> ratings = new ObservableCollection<RatingsVM>();
private readonly ObservableCollection<BookVM> toBeReadBooks = new ObservableCollection<BookVM>();
private readonly ObservableCollection<BookVM> favoriteBooks = new ObservableCollection<BookVM>();
private readonly ObservableCollection<LoanVM> currentLoans = new ObservableCollection<LoanVM>();
private IEnumerable<IGrouping<ContactVM, LoanVM>> currentGroupedLoans;
private readonly ObservableCollection<LoanVM> pastLoans = new ObservableCollection<LoanVM>();
private readonly ObservableCollection<BorrowingVM> pastBorrowings = new ObservableCollection<BorrowingVM>();
private IEnumerable<IGrouping<ContactVM, LoanVM>> pastGroupedLoans;
private readonly ObservableCollection<BorrowingVM> currentBorrowings = new ObservableCollection<BorrowingVM>();
private IEnumerable<IGrouping<ContactVM, BorrowingVM>> currentGroupedBorrowings;
private readonly ObservableCollection<BorrowingVM> pastBorrowings = new ObservableCollection<BorrowingVM>();
private IEnumerable<IGrouping<ContactVM, BorrowingVM>> pastGroupedBorrowings;
private readonly ObservableCollection<ContactVM> contacts = new ObservableCollection<ContactVM>();
private readonly ObservableCollection<Status> status = new ObservableCollection<Status>();
private int index;
private long nbBooks;
@ -49,6 +62,18 @@ namespace ViewModels
get => books;
}
public IEnumerable<IGrouping<string, BookVM>> GroupedBooks
{
get => groupedBooks;
set => SetProperty(ref groupedBooks, value);
}
public IEnumerable<IGrouping<Status, BookVM>> GroupedStatusBooks
{
get => groupedStatusBooks;
set => SetProperty(ref groupedStatusBooks, value);
}
public ObservableCollection<AuthorVM> AllAuthors
{
get => authors;
@ -79,21 +104,45 @@ namespace ViewModels
get => currentLoans;
}
public IEnumerable<IGrouping<ContactVM, LoanVM>> AllCurrentGroupedLoans
{
get => currentGroupedLoans;
set => SetProperty(ref currentGroupedLoans, value);
}
public ObservableCollection<LoanVM> AllPastLoans
{
get => pastLoans;
}
public IEnumerable<IGrouping<ContactVM, LoanVM>> AllPastGroupedLoans
{
get => pastGroupedLoans;
set => SetProperty(ref pastGroupedLoans, value);
}
public ObservableCollection<BorrowingVM> AllCurrentBorrowings
{
get => currentBorrowings;
}
public IEnumerable<IGrouping<ContactVM, BorrowingVM>> AllCurrentGroupedBorrowings
{
get => currentGroupedBorrowings;
set => SetProperty(ref currentGroupedBorrowings, value);
}
public ObservableCollection<BorrowingVM> AllPastBorrowings
{
get => pastBorrowings;
}
public IEnumerable<IGrouping<ContactVM, BorrowingVM>> AllPastGroupedBorrowings
{
get => pastGroupedBorrowings;
set => SetProperty(ref pastGroupedBorrowings, value);
}
public ObservableCollection<ContactVM> AllContacts
{
get => contacts;
@ -267,7 +316,7 @@ namespace ViewModels
}
}
public int NbPages => (int)(NbBooks / Count);
public int NbPages => (int)((NbBooks - 1) / Count);
public ICommand PreviousCommand { get; private set; }
@ -395,6 +444,8 @@ namespace ViewModels
foreach (var b in someBooks.Select(b => new BookVM(b)))
{
books.Add(b);
GroupedBooks = AllBooks.GroupBy(b => b.Author).OrderBy(group => group.Key);
GroupedStatusBooks = AllBooks.GroupBy(b => b.Status).OrderBy(group => group.Key);
}
OnPropertyChanged(nameof(AllBooks));
}
@ -628,48 +679,52 @@ namespace ViewModels
private async Task GetCurrentLoans()
{
var result = await Model.GetCurrentLoans(0, 20);
var result = await Model.GetCurrentLoans(0, 1000);
IEnumerable<Loan> someLoans = result.loans;
currentLoans.Clear();
foreach (var l in someLoans.Select(l => new LoanVM(l)))
{
currentLoans.Add(l);
AllCurrentGroupedLoans = AllCurrentLoans.GroupBy(l => l.Loaner).OrderBy(group => group.Key);
}
OnPropertyChanged(nameof(AllCurrentLoans));
}
private async Task GetPastLoans()
{
var result = await Model.GetPastLoans(0, 20);
var result = await Model.GetPastLoans(0, 1000);
IEnumerable<Loan> someLoans = result.loans;
pastLoans.Clear();
foreach (var l in someLoans.Select(l => new LoanVM(l)))
{
pastLoans.Add(l);
AllPastGroupedLoans = AllPastLoans.GroupBy(l => l.Loaner).OrderBy(group => group.Key);
}
OnPropertyChanged(nameof(AllPastLoans));
}
private async Task GetCurrentBorrowings()
{
var result = await Model.GetCurrentBorrowings(0, 20);
var result = await Model.GetCurrentBorrowings(0, 1000);
IEnumerable<Borrowing> someBorrowings = result.borrowings;
currentBorrowings.Clear();
foreach (var b in someBorrowings.Select(b => new BorrowingVM(b)))
{
currentBorrowings.Add(b);
AllCurrentGroupedBorrowings = AllCurrentBorrowings.GroupBy(b => b.Owner).OrderBy(group => group.Key);
}
OnPropertyChanged(nameof(AllCurrentBorrowings));
}
private async Task GetPastBorrowings()
{
var result = await Model.GetPastBorrowings(0, 20);
var result = await Model.GetPastBorrowings(0, 1000);
IEnumerable<Borrowing> someBorrowings = result.borrowings;
pastBorrowings.Clear();
foreach (var b in someBorrowings.Select(b => new BorrowingVM(b)))
{
pastBorrowings.Add(b);
AllPastGroupedBorrowings = AllPastBorrowings.GroupBy(b => b.Owner).OrderBy(group => group.Key);
}
OnPropertyChanged(nameof(AllPastBorrowings));
}

Loading…
Cancel
Save