Add (Back-End): Navigation terminer
continuous-integration/drone/push Build is failing Details

Back-End
Louis DUFOUR 2 years ago
parent d87d16c481
commit 080b2702f8

@ -15,19 +15,21 @@
</Tab> </Tab>
<Tab Title="My lists" <Tab Title="My lists"
Icon="list_bullet.svg"> Icon="list_bullet.svg">
<ShellContent ContentTemplate="{DataTemplate pages:EmpruntsPrets}"/> <ShellContent ContentTemplate="{DataTemplate local:MainPage}" Route="Mainpage"/>
</Tab> </Tab>
<Tab Title="My Readings" <Tab Title="My Readings"
Icon="bookmark_fill.svg"> Icon="bookmark_fill.svg">
<ShellContent ContentTemplate="{DataTemplate pages:Tous}" /> <ShellContent ContentTemplate="{DataTemplate local:MainPage}" Route="Mainpage"/>
</Tab> </Tab>
<Tab Title="Search" <Tab Title="Search"
Icon="magnifyingglass.svg"> Icon="magnifyingglass.svg">
<ShellContent ContentTemplate="{DataTemplate pages:Filtrage}" /> <ShellContent ContentTemplate="{DataTemplate local:MainPage}" Route="Mainpage"/>
</Tab> </Tab>
</TabBar> </TabBar>
<ShellContent Route="FiltragePage" ContentTemplate="{DataTemplate pages:Filtrage}" /> <ShellContent Route="FiltragePage" ContentTemplate="{DataTemplate pages:Filtrage}" />
<ShellContent Route="TousPage" ContentTemplate="{DataTemplate pages:Tous}" /> <ShellContent Route="TousPage" ContentTemplate="{DataTemplate pages:Tous}" />
<ShellContent Route="EmpruntsPretsPage" ContentTemplate="{DataTemplate pages:EmpruntsPrets}" />
<ShellContent Route="DetailBookPage" ContentTemplate="{DataTemplate pages:DetailBook}" />
</Shell> </Shell>

@ -10,7 +10,8 @@ namespace BookApp
Routing.RegisterRoute("FiltragePage", typeof(Filtrage)); Routing.RegisterRoute("FiltragePage", typeof(Filtrage));
Routing.RegisterRoute("TousPage", typeof(Tous)); Routing.RegisterRoute("TousPage", typeof(Tous));
Routing.RegisterRoute("Mainpage", typeof(MainPage)); Routing.RegisterRoute("Mainpage", typeof(MainPage));
Routing.RegisterRoute("EmpruntsPrets", typeof(EmpruntsPrets)); Routing.RegisterRoute("EmpruntsPretsPage", typeof(EmpruntsPrets));
Routing.RegisterRoute("DetailBookPage", typeof(DetailBook));
} }
} }
} }

@ -6,7 +6,7 @@
xmlns:model="clr-namespace:Model;assembly=Model" xmlns:model="clr-namespace:Model;assembly=Model"
x:DataType="vm:ViewModelManager" x:DataType="vm:ViewModelManager"
x:Class="BookApp.Composants.CollectionFiltrage"> x:Class="BookApp.Composants.CollectionFiltrage">
<CollectionView ItemsSource="{Binding Authors}"> <CollectionView ItemsSource="{Binding bookViewModel.authorList}">
<CollectionView.ItemTemplate> <CollectionView.ItemTemplate>
<DataTemplate x:DataType="model:Author"> <DataTemplate x:DataType="model:Author">
<StackLayout Padding="5"> <StackLayout Padding="5">

@ -2,6 +2,7 @@
<ContentView xmlns="http://schemas.microsoft.com/dotnet/2021/maui" <ContentView xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:composants="clr-namespace:BookApp.Composants" xmlns:composants="clr-namespace:BookApp.Composants"
xmlns:model="clr-namespace:Model;assembly=Model"
x:Class="BookApp.Composants.GroupCollection"> x:Class="BookApp.Composants.GroupCollection">
<ContentView.Resources> <ContentView.Resources>
<Style TargetType="StackLayout"> <Style TargetType="StackLayout">
@ -20,7 +21,9 @@
</Setter> </Setter>
</Style> </Style>
</ContentView.Resources> </ContentView.Resources>
<CollectionView ItemsSource="{Binding AuteurGroups}" IsGrouped="True" SelectionMode="Single" SelectionChanged="OnSelectionChanged"> <CollectionView ItemsSource="{Binding bookViewModel.AuteurGroups}" IsGrouped="True" SelectionMode="Single"
SelectionChangedCommand="{Binding ViewModelNavigation.BookSelected}"
SelectedItem="{Binding ViewModelNavigation.SelectedBook}">
<CollectionView.GroupHeaderTemplate> <CollectionView.GroupHeaderTemplate>
<DataTemplate> <DataTemplate>
<Label Text="{Binding Name}" <Label Text="{Binding Name}"

@ -1,4 +1,5 @@
using BookApp.Pages; using BookApp.Pages;
using BookApp.ViewModel;
using Model; using Model;
namespace BookApp.Composants namespace BookApp.Composants
@ -10,12 +11,10 @@ namespace BookApp.Composants
InitializeComponent(); InitializeComponent();
} }
private async void OnSelectionChanged(object sender, SelectionChangedEventArgs e) public GroupCollection(ViewModelManager data)
: this()
{ {
if (e.CurrentSelection.FirstOrDefault() is Book selectedItem) BindingContext = data;
{
await Navigation.PushAsync(new DetailBook(selectedItem));
}
} }
} }
} }

@ -61,7 +61,7 @@
<Label FontSize="35" FontFamily="SF-Pro-Display-Bold" Padding="10">Mes livres</Label> <Label FontSize="35" FontFamily="SF-Pro-Display-Bold" Padding="10">Mes livres</Label>
<Rectangle HeightRequest="1" BackgroundColor="black" VerticalOptions="End" /> <Rectangle HeightRequest="1" BackgroundColor="black" VerticalOptions="End" />
<CollectionView ItemsSource="{Binding ViewModelMenu.MenuItemsLivre}" <CollectionView ItemsSource="{Binding ViewModelMenu.MenuItemsLivre}"
SelectionChangedCommand="{Binding ViewModelNavigation.ItemSelectedCommand}" SelectionChangedCommand="{Binding ViewModelNavigation.ItemSelectedCommandMain}"
SelectedItem="{Binding ViewModelNavigation.SelectedItem, Mode=TwoWay}" SelectedItem="{Binding ViewModelNavigation.SelectedItem, Mode=TwoWay}"
SelectionMode="Single" Margin="25,0,0,0" BackgroundColor="#F9F9F9"> SelectionMode="Single" Margin="25,0,0,0" BackgroundColor="#F9F9F9">
@ -116,9 +116,9 @@
<Rectangle HeightRequest="1" BackgroundColor="black" VerticalOptions="End"/> <Rectangle HeightRequest="1" BackgroundColor="black" VerticalOptions="End"/>
<CollectionView ItemsSource="{Binding ViewModelMenu.MenuItemsFiltre}" <CollectionView ItemsSource="{Binding ViewModelMenu.MenuItemsFiltre}"
SelectionChangedCommand="{Binding ViewModelNavigation.ItemSelectedCommand}" SelectionChangedCommand="{Binding ViewModelNavigation.ItemSelectedCommandFiltre}"
SelectedItem="{Binding ViewModelNavigation.SelectedItem, Mode=TwoWay}" SelectedItem="{Binding ViewModelNavigation.SelectedItem, Mode=TwoWay}"
Margin="25,0,0,0" BackgroundColor="#F9F9F9"> SelectionMode="Single" Margin="25,0,0,0" BackgroundColor="#F9F9F9">
<CollectionView.ItemTemplate> <CollectionView.ItemTemplate>
<DataTemplate x:DataType="vm:ViewModelMenuItem"> <DataTemplate x:DataType="vm:ViewModelMenuItem">
<Grid RowDefinitions="Auto" > <Grid RowDefinitions="Auto" >
@ -147,11 +147,10 @@
VerticalOptions="Center" VerticalOptions="Center"
Margin="0,0,40,0" Margin="0,0,40,0"
HorizontalOptions="End"/> HorizontalOptions="End"/>
<Button Grid.Column="2" <Image Grid.Column="2"
ImageSource="chevron_right.svg" Source="chevron_right.svg"
HeightRequest="35" HeightRequest="25"
WidthRequest="35" WidthRequest="25"
BackgroundColor="#F9F9F9"
HorizontalOptions="End"/> HorizontalOptions="End"/>
</Grid> </Grid>
<Rectangle Grid.ColumnSpan="4" HeightRequest="1" BackgroundColor="LightGray" VerticalOptions="End"> <Rectangle Grid.ColumnSpan="4" HeightRequest="1" BackgroundColor="LightGray" VerticalOptions="End">

@ -36,6 +36,9 @@ namespace BookApp
builder.Services.AddSingleton<Tous>(); builder.Services.AddSingleton<Tous>();
builder.Services.AddSingleton<MainPage>(); builder.Services.AddSingleton<MainPage>();
builder.Services.AddSingleton<ViewModelNavigation>(); builder.Services.AddSingleton<ViewModelNavigation>();
builder.Services.AddSingleton<EmpruntsPrets>();
builder.Services.AddSingleton<GroupCollection>();
builder.Services.AddSingleton<DetailBook>();
builder.Services.AddTransient<ViewModelMenu>(); builder.Services.AddTransient<ViewModelMenu>();

@ -3,6 +3,7 @@
xmlns="http://schemas.microsoft.com/dotnet/2021/maui" xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit" xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit"
xmlns:vm="clr-namespace:BookApp.ViewModel"
x:Class="BookApp.Pages.DetailBook"> x:Class="BookApp.Pages.DetailBook">
<Shell.BackButtonBehavior> <Shell.BackButtonBehavior>
<BackButtonBehavior IsVisible="False" IsEnabled="False"/> <BackButtonBehavior IsVisible="False" IsEnabled="False"/>
@ -18,7 +19,9 @@
Source="Chevron_left.svg" Source="Chevron_left.svg"
HorizontalOptions="Start"> HorizontalOptions="Start">
<Image.GestureRecognizers> <Image.GestureRecognizers>
<!-- <TapGestureRecognizer Tapped="BackButton" NumberOfTapsRequired="1"/> --> <TapGestureRecognizer
Command="{Binding ViewModelNavigation.BackButtonCommand}"
NumberOfTapsRequired="1" />
</Image.GestureRecognizers> </Image.GestureRecognizers>
<Image.Behaviors> <Image.Behaviors>
<toolkit:IconTintColorBehavior TintColor="Red" /> <toolkit:IconTintColorBehavior TintColor="Red" />
@ -54,9 +57,9 @@
<ColumnDefinition Width="125"/> <ColumnDefinition Width="125"/>
<ColumnDefinition Width="*"/> <ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<Image Margin="10,10,10,0" Grid.Column="0" Source="{Binding BookDetail.ImageBook}"/> <Image Margin="10,10,10,0" Grid.Column="0" Source="{Binding ViewModelNavigation.SelectedBook.ImageLarge}"/>
<StackLayout Grid.Column="1"> <StackLayout Grid.Column="1">
<Label FontAttributes="Bold" FontSize="20" Text="{Binding BookDetail.Name}"/> <Label FontAttributes="Bold" FontSize="20" Text="{Binding ViewModelNavigation.SelectedBook.Title }"/>
<Grid RowDefinitions="auto" VerticalOptions="EndAndExpand"> <Grid RowDefinitions="auto" VerticalOptions="EndAndExpand">
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/> <ColumnDefinition Width="*"/>
@ -81,13 +84,13 @@
</Grid> </Grid>
<Rectangle Margin="25,0,0,10" HeightRequest="1" BackgroundColor="LightGray" VerticalOptions="End"/> <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 FontAttributes="Bold" Margin="25,0,0,0" VerticalTextAlignment="Center" Text="Auteur"/>
<Label Margin="25,0,0,0" VerticalTextAlignment="Center" Text="{Binding BookDetail.Auteur.Name}"/> <Label Margin="25,0,0,0" VerticalTextAlignment="Center" Text="{Binding ViewModelNavigation.SelectedBook.Authors}"/>
<Rectangle Margin="25,10,0,10" HeightRequest="1" BackgroundColor="LightGray" VerticalOptions="End"/> <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 FontAttributes="Bold" Margin="25,0,0,0" VerticalTextAlignment="Center" Text="Maison d'édition"/>
<Label Margin="25,0,0,0" VerticalTextAlignment="Center" Text="{Binding BookDetail.MaisonEdit}"/> <Label Margin="25,0,0,0" VerticalTextAlignment="Center" Text="{Binding ViewModelNavigation.SelectedBook.MaisonEdit}"/>
<Rectangle Margin="25,10,0,10" HeightRequest="1" BackgroundColor="LightGray" VerticalOptions="End"/> <Rectangle Margin="25,10,0,10" HeightRequest="1" BackgroundColor="LightGray" VerticalOptions="End"/>
<Label FontAttributes="Bold" Margin="25,0,0,0" VerticalTextAlignment="Center" Text="Résumer"/> <Label FontAttributes="Bold" Margin="25,0,0,0" VerticalTextAlignment="Center" Text="Résumer"/>
<Label Margin="25,0,0,0" VerticalTextAlignment="Center" Text="Le Lorem Ipsum est simplement du faux texte employé dans la composition et la mise en page avant impression. Le Lorem Ipsum est le faux texte standard de l'imprimerie depuis les années 1500, quand un imprimeur anonyme assembla ensemble des morceaux de texte pour réaliser un livre spécimen de polices de texte. Il n'a pas fait que survivre cinq siècles, mais s'est aussi adapté à la bureautique informatique, sans que son contenu n'en soit modifié. Il a été popularisé dans les années 1960 grâce à la vente de feuilles Letraset contenant des passages du Lorem Ipsum, et, plus récemment, par son inclusion dans des applications de mise en page de texte, comme Aldus PageMaker."/> <Label Margin="25,0,0,0" VerticalTextAlignment="Center" Text="{Binding ViewModelNavigation.SelectedBook.Format}"/>
<Rectangle Margin="25,10,0,10" HeightRequest="1" BackgroundColor="LightGray" VerticalOptions="End" /> <Rectangle Margin="25,10,0,10" HeightRequest="1" BackgroundColor="LightGray" VerticalOptions="End" />
<Label FontAttributes="Bold" Margin="25,0,0,0" VerticalTextAlignment="Center" Text="Details"/> <Label FontAttributes="Bold" Margin="25,0,0,0" VerticalTextAlignment="Center" Text="Details"/>
<Grid Margin="25,0,20,0"> <Grid Margin="25,0,20,0">
@ -101,11 +104,11 @@
<ColumnDefinition Width="*"/> <ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<Label Grid.Row="0" Grid.Column="0" Text="Nombre de pages"/> <Label Grid.Row="0" Grid.Column="0" Text="Nombre de pages"/>
<Label Grid.Row="0" Grid.Column="1" HorizontalTextAlignment="End" Text="{Binding BookDetail.NbPage}"/> <Label Grid.Row="0" Grid.Column="1" HorizontalTextAlignment="End" Text="{Binding ViewModelNavigation.SelectedBook.NbPages}"/>
<Label Grid.Row="1" Grid.Column="0" Text="Langue"/> <Label Grid.Row="1" Grid.Column="0" Text="Langue"/>
<Label Grid.Row="1" Grid.Column="1" HorizontalTextAlignment="End" Text="{Binding BookDetail.Langue}"/> <Label Grid.Row="1" Grid.Column="1" HorizontalTextAlignment="End" Text="{Binding ViewModelNavigation.SelectedBook.Language}"/>
<Label Grid.Row="2" Grid.Column="0" Text="ISBN"/> <Label Grid.Row="2" Grid.Column="0" Text="ISBN"/>
<Label Grid.Row="2" Grid.Column="1" HorizontalTextAlignment="End" Text="{Binding BookDetail.ISBN}"/> <Label Grid.Row="2" Grid.Column="1" HorizontalTextAlignment="End" Text="{Binding ViewModelNavigation.SelectedBook.Status}"/>
</Grid> </Grid>
<Rectangle Margin="25,10,0,10" HeightRequest="1" BackgroundColor="LightGray" VerticalOptions="End" /> <Rectangle Margin="25,10,0,10" HeightRequest="1" BackgroundColor="LightGray" VerticalOptions="End" />
<Label FontAttributes="Bold" Margin="25,0,0,0" VerticalTextAlignment="Center" Text="Status de lecture"/> <Label FontAttributes="Bold" Margin="25,0,0,0" VerticalTextAlignment="Center" Text="Status de lecture"/>
@ -115,7 +118,7 @@
<ColumnDefinition Width="*"/> <ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<Label Grid.Column="0" Text="Status"/> <Label Grid.Column="0" Text="Status"/>
<Label Grid.Column="1" HorizontalTextAlignment="End" Text="{Binding BookDetail.Statut}"/> <Label Grid.Column="1" HorizontalTextAlignment="End" Text="{Binding ViewModelNavigation.SelectedBook.Status}"/>
</Grid> </Grid>
<Rectangle Margin="25,10,0,10" HeightRequest="1" BackgroundColor="LightGray" VerticalOptions="End" /> <Rectangle Margin="25,10,0,10" HeightRequest="1" BackgroundColor="LightGray" VerticalOptions="End" />
<Label FontAttributes="Bold" Margin="25,0,0,0" VerticalTextAlignment="Center" Text="biliothèque"/> <Label FontAttributes="Bold" Margin="25,0,0,0" VerticalTextAlignment="Center" Text="biliothèque"/>
@ -125,7 +128,7 @@
<ColumnDefinition Width="*"/> <ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<Label Grid.Column="0" Text="Ajouter le"/> <Label Grid.Column="0" Text="Ajouter le"/>
<Label Grid.Column="1" HorizontalTextAlignment="End" Text="{Binding BookDetail.dateAjout}"/> <Label Grid.Column="1" HorizontalTextAlignment="End" Text="{Binding ViewModelNavigation.SelectedBook.PublishDate}"/>
</Grid> </Grid>
<Rectangle Margin="25,10,0,10" HeightRequest="1" BackgroundColor="LightGray" VerticalOptions="End" /> <Rectangle Margin="25,10,0,10" HeightRequest="1" BackgroundColor="LightGray" VerticalOptions="End" />
<Rectangle HeightRequest="100" Fill="Transparent"/> <Rectangle HeightRequest="100" Fill="Transparent"/>

@ -1,67 +1,14 @@
using BookApp.ViewModel;
using Model;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
namespace BookApp.Pages; namespace BookApp.Pages;
public partial class DetailBook : ContentPage public partial class DetailBook : ContentPage
{ {
/*private int maxStars = 5; public DetailBook(ViewModelManager data)
private int currentRating = 0;
public Book BookDetail { get; set; }
*/
public DetailBook(Model.Book selectedItem) //Book ItemBook)
{ {
InitializeComponent(); InitializeComponent();
BindingContext = data;
/* for (int i = 1; i <= maxStars; i++)
{
var star = new Image
{
Source = "empty_star.svg", // image d'une étoile vide
WidthRequest = 25,
HeightRequest = 25
};
int currentStar = i;
star.GestureRecognizers.Add(
new TapGestureRecognizer { Command = new Command(() => StarTapped(currentStar)), }
);
StarLayout.Children.Add(star);
}
UpdateStars();
BookDetail = ItemBook;
BindingContext = this;*/
}
/*
private void StarTapped(int rating)
{
if (rating > maxStars)
{
System.Diagnostics.Debug.WriteLine("Erreur : rating trop élevé!");
return;
}
currentRating = rating;
UpdateStars();
RatingLabel.Text = $"Note: {currentRating}/{maxStars}";
} }
private void UpdateStars()
{
for (int i = 0; i < maxStars; i++)
{
var star = (Image)StarLayout.Children[i];
if (i < currentRating)
star.Source = "filled_star.svg"; // image d'une étoile remplie
else
star.Source = "empty_star.svg";
}
}
async void BackButton(object sender, EventArgs args)
{
await Shell.Current.Navigation.PopAsync();
}*/
} }

@ -1,9 +1,9 @@
<?xml version="1.0" encoding="utf-8" ?> <?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui" <ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="BookApp.Pages.EmpruntsPrets"
xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit" xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit"
Title="EmpruntsPrets"> xmlns:vm="clr-namespace:BookApp.ViewModel"
x:Class="BookApp.Pages.EmpruntsPrets">
<Shell.BackButtonBehavior> <Shell.BackButtonBehavior>
<BackButtonBehavior IsVisible="False" IsEnabled="False"/> <BackButtonBehavior IsVisible="False" IsEnabled="False"/>
</Shell.BackButtonBehavior> </Shell.BackButtonBehavior>
@ -19,7 +19,9 @@
Source="Chevron_left.svg" Source="Chevron_left.svg"
HorizontalOptions="Start"> HorizontalOptions="Start">
<Image.GestureRecognizers> <Image.GestureRecognizers>
<TapGestureRecognizer Tapped="BackButton" NumberOfTapsRequired="1"/> <TapGestureRecognizer
Command="{Binding ViewModelNavigation.BackButtonCommand}"
NumberOfTapsRequired="1" />
</Image.GestureRecognizers> </Image.GestureRecognizers>
<Image.Behaviors> <Image.Behaviors>
<toolkit:IconTintColorBehavior TintColor="Red" /> <toolkit:IconTintColorBehavior TintColor="Red" />
@ -71,7 +73,7 @@
<StackLayout> <StackLayout>
<ContentView> <ContentView>
<ContentView.GestureRecognizers> <ContentView.GestureRecognizers>
<TapGestureRecognizer Command="{Binding TapCommand}" NumberOfTapsRequired="1" /> <!-- <TapGestureRecognizer Command="{Binding TapCommand}" NumberOfTapsRequired="1" /> -->
</ContentView.GestureRecognizers> </ContentView.GestureRecognizers>
<Grid WidthRequest="150" HeightRequest="50" <Grid WidthRequest="150" HeightRequest="50"
@ -79,10 +81,8 @@
VerticalOptions="Center" VerticalOptions="Center"
HorizontalOptions="Center"> HorizontalOptions="Center">
<!-- Le Switch -->
<Switch x:Name="MySwitch" IsToggled="{Binding IsToggled}" <!-- Le Switch <Switch x:Name="MySwitch" IsToggled="{Binding IsToggled}" HorizontalOptions="Start" VerticalOptions="Center"/> -->
HorizontalOptions="Start"
VerticalOptions="Center"/>
<!-- Le Texte --> <!-- Le Texte -->
<Label Text="Mon Switch" <Label Text="Mon Switch"

@ -1,35 +1,33 @@
using BookApp.ViewModel;
using System.Windows.Input; using System.Windows.Input;
namespace BookApp.Pages; namespace BookApp.Pages
public partial class EmpruntsPrets : ContentPage
{ {
public ICommand TapCommand => new Command(ToggleSwitch); public partial class EmpruntsPrets : ContentPage
private bool _isToggled;
public bool IsToggled
{ {
get => _isToggled; /* public ICommand TapCommand => new Command(ToggleSwitch);
set
private bool _isToggled;
public bool IsToggled
{
get => _isToggled;
set
{
_isToggled = value;
OnPropertyChanged();
}
}*/
public EmpruntsPrets(ViewModelManager data)
{ {
_isToggled = value; InitializeComponent();
OnPropertyChanged(); BindingContext = data;
} }
}
public EmpruntsPrets() /*private void ToggleSwitch()
{ {
InitializeComponent(); IsToggled = !IsToggled;
} }*/
async void BackButton(object sender, EventArgs args)
{
await Shell.Current.Navigation.PopAsync();
}
private void ToggleSwitch()
{
IsToggled = !IsToggled;
} }
} }

@ -5,8 +5,8 @@
xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit" xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit"
xmlns:composants="clr-namespace:BookApp.Composants" xmlns:composants="clr-namespace:BookApp.Composants"
xmlns:model="clr-namespace:Model;assembly=Model" xmlns:model="clr-namespace:Model;assembly=Model"
xmlns:vm="clr-namespace:BookApp.ViewModel"
xmlns:vmw="clr-namespace:VMWrapper;assembly=VMWrapper" xmlns:vmw="clr-namespace:VMWrapper;assembly=VMWrapper"
x:DataType="vmw:BookViewModel"
x:Class="BookApp.Pages.Filtrage"> x:Class="BookApp.Pages.Filtrage">
<Shell.BackButtonBehavior> <Shell.BackButtonBehavior>
<BackButtonBehavior IsVisible="False" IsEnabled="False"/> <BackButtonBehavior IsVisible="False" IsEnabled="False"/>
@ -23,7 +23,9 @@
Source="Chevron_left.svg" Source="Chevron_left.svg"
HorizontalOptions="Start"> HorizontalOptions="Start">
<Image.GestureRecognizers> <Image.GestureRecognizers>
<TapGestureRecognizer Tapped="BackButton" NumberOfTapsRequired="1"/> <TapGestureRecognizer
Command="{Binding ViewModelNavigation.BackButtonCommand}"
NumberOfTapsRequired="1" />
</Image.GestureRecognizers> </Image.GestureRecognizers>
<Image.Behaviors> <Image.Behaviors>
<toolkit:IconTintColorBehavior TintColor="Red" /> <toolkit:IconTintColorBehavior TintColor="Red" />
@ -66,7 +68,7 @@
<StackLayout> <StackLayout>
<Rectangle HeightRequest="1" BackgroundColor="LightGray"/> <Rectangle HeightRequest="1" BackgroundColor="LightGray"/>
<SearchBar Placeholder="Search items..."/> <SearchBar Placeholder="Search items..."/>
<CollectionView ItemsSource="{Binding authorList}" VerticalOptions="FillAndExpand"> <CollectionView ItemsSource="{Binding bookViewModel.authorList}" VerticalOptions="FillAndExpand">
<CollectionView.ItemTemplate> <CollectionView.ItemTemplate>
<DataTemplate x:DataType="model:Author"> <DataTemplate x:DataType="model:Author">
<StackLayout Padding="5"> <StackLayout Padding="5">

@ -7,15 +7,10 @@ namespace BookApp.Pages
{ {
SearchBar searchBar = new SearchBar { Placeholder = "Search items..." }; SearchBar searchBar = new SearchBar { Placeholder = "Search items..." };
public Filtrage(BookViewModel data) public Filtrage(ViewModelManager data)
{ {
InitializeComponent(); InitializeComponent();
BindingContext = data; BindingContext = data;
} }
async void BackButton(object sender, EventArgs args)
{
await Shell.Current.Navigation.PopAsync();
}
} }
} }

@ -3,6 +3,7 @@
xmlns="http://schemas.microsoft.com/dotnet/2021/maui" xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:composants="clr-namespace:BookApp.Composants" xmlns:composants="clr-namespace:BookApp.Composants"
xmlns:vm="clr-namespace:BookApp.ViewModel"
xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit" xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit"
x:Class="BookApp.Pages.Tous"> x:Class="BookApp.Pages.Tous">
<Shell.BackButtonBehavior> <Shell.BackButtonBehavior>
@ -20,7 +21,9 @@
Source="Chevron_left.svg" Source="Chevron_left.svg"
HorizontalOptions="Start"> HorizontalOptions="Start">
<Image.GestureRecognizers> <Image.GestureRecognizers>
<TapGestureRecognizer Tapped="BackButton" NumberOfTapsRequired="1"/> <TapGestureRecognizer
Command="{Binding ViewModelNavigation.BackButtonCommand}"
NumberOfTapsRequired="1" />
</Image.GestureRecognizers> </Image.GestureRecognizers>
<Image.Behaviors> <Image.Behaviors>
<toolkit:IconTintColorBehavior TintColor="Red" /> <toolkit:IconTintColorBehavior TintColor="Red" />

@ -1,21 +1,15 @@
using BookApp.ViewModel; using BookApp.ViewModel;
using System.Collections.ObjectModel;
using System.Diagnostics; using System.Diagnostics;
using VMWrapper;
namespace BookApp.Pages namespace BookApp.Pages
{ {
public partial class Tous : ContentPage public partial class Tous : ContentPage
{ {
public Tous(BookViewModel data) public Tous(ViewModelManager data)
{ {
InitializeComponent(); InitializeComponent();
Debug.WriteLine("TousPage is initialized.");
BindingContext = data; BindingContext = data;
} }
async void BackButton(object sender, EventArgs args)
{
await Shell.Current.Navigation.PopAsync();
}
} }
} }

@ -7,14 +7,12 @@ namespace BookApp.ViewModel;
public class ViewModelManager : BaseViewModel public class ViewModelManager : BaseViewModel
{ {
BookViewModel _viewModel; public BookViewModel bookViewModel { get; }
public ObservableCollection<Author> Authors { get; set; } = new ObservableCollection<Author>();
public ViewModelMenu ViewModelMenu { get; } = new ViewModelMenu(); public ViewModelMenu ViewModelMenu { get; } = new ViewModelMenu();
public ViewModelNavigation ViewModelNavigation { get; } = new ViewModelNavigation(); public ViewModelNavigation ViewModelNavigation { get; } = new ViewModelNavigation();
public ViewModelManager(BookViewModel viewModel) public ViewModelManager(BookViewModel viewModel)
{ {
_viewModel = viewModel; bookViewModel = viewModel;
} }
} }

@ -21,7 +21,7 @@ namespace BookApp.ViewModel
"En prêt", "En prêt",
"../Resources/Images/person_badge_clock_fill.svg", "../Resources/Images/person_badge_clock_fill.svg",
250, 250,
"EmpruntsPrets" "EmpruntsPretsPage"
), ),
new ViewModelMenuItem( new ViewModelMenuItem(
"À lire plus tard", "À lire plus tard",
@ -51,7 +51,7 @@ namespace BookApp.ViewModel
"Auteur", "Auteur",
"../Resources/Images/person_fill.svg", "../Resources/Images/person_fill.svg",
250, 250,
"Filtrage" "FiltragePage"
), ),
new ViewModelMenuItem( new ViewModelMenuItem(
"Date de publication", "Date de publication",

@ -1,8 +1,7 @@
using ToolKit; using ToolKit;
using System.Windows.Input; using System.Windows.Input;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Diagnostics; using System.Diagnostics;
using Model;
namespace BookApp.ViewModel namespace BookApp.ViewModel
{ {
@ -15,11 +14,28 @@ namespace BookApp.ViewModel
set { SetProperty(ref _selectedItem, value); } set { SetProperty(ref _selectedItem, value); }
} }
public ICommand ItemSelectedCommand { get; private set; } private Book _selectedBook;
public Book SelectedBook
{
get { return _selectedBook; }
set { SetProperty(ref _selectedBook, value); }
}
public INavigation Navigation { get; set; }
public ICommand MenuItemsFiltre { get; private set; }
public ICommand ItemSelectedCommandMain { get; private set; }
public ICommand BookSelected { get; private set; }
public ICommand BackButtonCommand { get; private set; }
public ViewModelNavigation() public ViewModelNavigation()
{ {
ItemSelectedCommand = new Command(async () => await OnItemSelected(SelectedItem)); MenuItemsFiltre = new Command(async () => await OnItemSelected(SelectedItem));
ItemSelectedCommandMain = new Command(async () => await OnItemSelected(SelectedItem));
BackButtonCommand = new Command(async () => await BackButton(this, EventArgs.Empty));
BookSelected = new Command(async () => await OnBookSelected(SelectedBook));
} }
private async Task OnItemSelected(ViewModelMenuItem selectedItem) private async Task OnItemSelected(ViewModelMenuItem selectedItem)
@ -27,12 +43,12 @@ namespace BookApp.ViewModel
SelectedItem = selectedItem; SelectedItem = selectedItem;
if (string.IsNullOrEmpty(SelectedItem?.Route)) if (string.IsNullOrEmpty(SelectedItem?.Route))
{
return; return;
}
try try
{ {
await Shell.Current.GoToAsync(selectedItem.Route); await Shell.Current.GoToAsync(selectedItem.Route);
selectedItem = null;
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -40,14 +56,28 @@ namespace BookApp.ViewModel
} }
} }
async void ButtonTous(object sender, EventArgs args) private async Task OnBookSelected(Book SelectedBook)
{ {
await Shell.Current.GoToAsync("TousPage"); if (SelectedBook == null)
{
return;
}
try
{
await Shell.Current.GoToAsync("DetailBookPage");
}
catch (Exception ex)
{
Debug.WriteLine($"Navigation failed: {ex.Message}");
}
} }
async void ButtonAuteur(object sender, EventArgs args) async Task BackButton(object sender, EventArgs args)
{ {
await Shell.Current.GoToAsync("FiltragePage"); if (Shell.Current.Navigation.NavigationStack.Count > 1)
{
await Shell.Current.Navigation.PopAsync();
}
} }
} }
} }

Loading…
Cancel
Save