diff --git a/LivreLand/AppShell.xaml b/LivreLand/AppShell.xaml index cacb6af..7d10a75 100644 --- a/LivreLand/AppShell.xaml +++ b/LivreLand/AppShell.xaml @@ -12,15 +12,15 @@ diff --git a/LivreLand/AppShell.xaml.cs b/LivreLand/AppShell.xaml.cs index cae19f0..f120441 100644 --- a/LivreLand/AppShell.xaml.cs +++ b/LivreLand/AppShell.xaml.cs @@ -1,9 +1,20 @@ -namespace LivreLand; +using LivreLand.View; + +namespace LivreLand; public partial class AppShell : Shell { public AppShell() { - InitializeComponent(); + Routing.RegisterRoute("library/tous/", typeof(TousView)); + Routing.RegisterRoute("library/pret/", typeof(EmpruntsPretsView)); + Routing.RegisterRoute("library/later/", typeof(ALirePlusTardView)); + Routing.RegisterRoute("library/statut/", typeof(StatutLectureView)); + Routing.RegisterRoute("library/favoris/", typeof(FavorisView)); + Routing.RegisterRoute("library/auteur/", typeof(FiltrageAuteurView)); + Routing.RegisterRoute("library/date/", typeof(FiltrageDateView)); + Routing.RegisterRoute("library/note/", typeof(FiltrageNoteView)); + Routing.RegisterRoute("library/tous/details/", typeof(DetailsLivreView)); + InitializeComponent(); } } diff --git a/LivreLand/MauiProgram.cs b/LivreLand/MauiProgram.cs index 3c8ca3b..7650bb5 100644 --- a/LivreLand/MauiProgram.cs +++ b/LivreLand/MauiProgram.cs @@ -24,8 +24,9 @@ public static class MauiProgram builder.Services .AddSingleton() + .AddSingleton() - .AddSingleton() + .AddSingleton() .AddSingleton() .AddSingleton() diff --git a/LivreLand/View/BibliothequeView.xaml b/LivreLand/View/BibliothequeView.xaml index e8a4ca0..ae6b9ed 100644 --- a/LivreLand/View/BibliothequeView.xaml +++ b/LivreLand/View/BibliothequeView.xaml @@ -55,7 +55,8 @@ ButtonNumber="45" ButtonRedIconVisible="False" ButtonBlackIconVisible="True" - ButtonTappedCommand="{Binding Navigator.TousNavigationCommand}"/> + ButtonTappedCommand="{Binding Navigator.NavigationCommand}" + CommandParameter="tous/"/> @@ -65,7 +66,8 @@ ButtonNumber="1" ButtonRedIconVisible="False" ButtonBlackIconVisible="True" - ButtonTappedCommand="{Binding Navigator.EmpruntsPretsNavigationCommand}"/> + ButtonTappedCommand="{Binding Navigator.NavigationCommand}" + CommandParameter="pret/"/> @@ -74,7 +76,8 @@ ButtonIcon="arrow_forward.png" ButtonRedIconVisible="False" ButtonBlackIconVisible="True" - ButtonTappedCommand="{Binding Navigator.ALirePlusTardNavigationCommand}"/> + ButtonTappedCommand="{Binding Navigator.NavigationCommand}" + CommandParameter="later/"/> @@ -83,7 +86,8 @@ ButtonIcon="eyeglasses.png" ButtonRedIconVisible="False" ButtonBlackIconVisible="True" - ButtonTappedCommand="{Binding Navigator.StatutLectureNavigationCommand}"/> + ButtonTappedCommand="{Binding Navigator.NavigationCommand}" + CommandParameter="statut/"/> @@ -92,7 +96,8 @@ ButtonIcon="heart_fill.png" ButtonRedIconVisible="False" ButtonBlackIconVisible="True" - ButtonTappedCommand="{Binding Navigator.FavorisNavigationCommand}"/> + ButtonTappedCommand="{Binding Navigator.NavigationCommand}" + CommandParameter="favoris/"/> @@ -114,7 +119,8 @@ ButtonIcon="person_fill.png" ButtonRedIconVisible="False" ButtonBlackIconVisible="True" - ButtonTappedCommand="{Binding Navigator.AuteurNavigationCommand}"/> + ButtonTappedCommand="{Binding Navigator.NavigationCommand}" + CommandParameter="auteur/"/> @@ -123,7 +129,8 @@ ButtonIcon="calendar.png" ButtonRedIconVisible="False" ButtonBlackIconVisible="True" - ButtonTappedCommand="{Binding Navigator.DatePublicationNavigationCommand}"/> + ButtonTappedCommand="{Binding Navigator.NavigationCommand}" + CommandParameter="date/"/> @@ -132,7 +139,8 @@ ButtonIcon="sparkles.png" ButtonRedIconVisible="False" ButtonBlackIconVisible="True" - ButtonTappedCommand="{Binding Navigator.NoteNavigationCommand}"/> + ButtonTappedCommand="{Binding Navigator.NavigationCommand}" + CommandParameter="note/"/> diff --git a/LivreLand/View/ContentViews/HomeButtonView.xaml b/LivreLand/View/ContentViews/HomeButtonView.xaml index 245bfde..fc7b27d 100644 --- a/LivreLand/View/ContentViews/HomeButtonView.xaml +++ b/LivreLand/View/ContentViews/HomeButtonView.xaml @@ -52,7 +52,7 @@ - + diff --git a/LivreLand/View/ContentViews/HomeButtonView.xaml.cs b/LivreLand/View/ContentViews/HomeButtonView.xaml.cs index 48d44da..416a027 100644 --- a/LivreLand/View/ContentViews/HomeButtonView.xaml.cs +++ b/LivreLand/View/ContentViews/HomeButtonView.xaml.cs @@ -47,6 +47,13 @@ public partial class HomeButtonView : ContentView set { SetValue(ButtonTappedCommandProperty, value); } } + public static readonly BindableProperty CommandParameterProperty = BindableProperty.Create(nameof(CommandParameter), typeof(string), typeof(HomeButtonView)); + public string CommandParameter + { + get { return (string)GetValue(CommandParameterProperty); } + set { SetValue(CommandParameterProperty, value); } + } + public HomeButtonView() { InitializeComponent(); diff --git a/LivreLand/View/TousView.xaml b/LivreLand/View/TousView.xaml index 029ff27..a35965d 100644 --- a/LivreLand/View/TousView.xaml +++ b/LivreLand/View/TousView.xaml @@ -3,6 +3,7 @@ xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:view="clr-namespace:LivreLand.View" xmlns:contentView="clr-namespace:LivreLand.View.ContentViews" + xmlns:viewModel="clr-namespace:ViewModels;assembly=ViewModels" xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit" x:Class="LivreLand.View.TousView" Title="TousView"> @@ -49,11 +50,11 @@ Style="{StaticResource HeaderCollectionViewText}" Grid.Column="1"/> - - + diff --git a/LivreLand/View/TousView.xaml.cs b/LivreLand/View/TousView.xaml.cs index f2f5505..62b22f5 100644 --- a/LivreLand/View/TousView.xaml.cs +++ b/LivreLand/View/TousView.xaml.cs @@ -1,5 +1,6 @@ using LivreLand.Model; using LivreLand.ViewModel; +using ViewModels; namespace LivreLand.View; @@ -9,6 +10,7 @@ public partial class TousView : ContentPage #region Properties public NavigatorVM Navigator { get; private set; } + public ManagerVM Manager { get; private set; } public List DamasioBooks { get; set; } = new List() { @@ -27,9 +29,10 @@ public partial class TousView : ContentPage #region Constructor - public TousView(NavigatorVM navigatorVM) + public TousView(NavigatorVM navigatorVM, ManagerVM managerVM) { Navigator = navigatorVM; + Manager = managerVM; InitializeComponent(); BindingContext = this; } diff --git a/LivreLand/ViewModel/NavigatorVM.cs b/LivreLand/ViewModel/NavigatorVM.cs index 41cf936..fef5cbb 100644 --- a/LivreLand/ViewModel/NavigatorVM.cs +++ b/LivreLand/ViewModel/NavigatorVM.cs @@ -14,15 +14,7 @@ namespace LivreLand.ViewModel { #region Properties - public INavigation Navigator => (App.Current as App).MainPage.Navigation; - public ICommand TousNavigationCommand { get; } - public ICommand EmpruntsPretsNavigationCommand { get; } - public ICommand ALirePlusTardNavigationCommand { get; } - public ICommand StatutLectureNavigationCommand { get; } - public ICommand FavorisNavigationCommand { get; } - public ICommand AuteurNavigationCommand { get; } - public ICommand DatePublicationNavigationCommand { get; } - public ICommand NoteNavigationCommand { get; } + public ICommand NavigationCommand { get; } public ICommand PopupHomePlusNavigationCommand { get; } public ICommand PopupISBNNavigationCommand { get; } public ICommand PopupBackButtonNavigationCommand { get; } @@ -33,14 +25,8 @@ namespace LivreLand.ViewModel public NavigatorVM() { - TousNavigationCommand = new Command(() => Navigator.PushAsync(new TousView(this))); - EmpruntsPretsNavigationCommand = new Command(() => Navigator.PushAsync(new EmpruntsPretsView())); - ALirePlusTardNavigationCommand = new Command(() => Navigator.PushAsync(new ALirePlusTardView())); - StatutLectureNavigationCommand = new Command(() => Navigator.PushAsync(new StatutLectureView())); - FavorisNavigationCommand = new Command(() => Navigator.PushAsync(new FavorisView())); - AuteurNavigationCommand = new Command(() => Navigator.PushAsync(new FiltrageAuteurView())); - DatePublicationNavigationCommand = new Command(() => Navigator.PushAsync(new FiltrageDateView())); - NoteNavigationCommand = new Command(() => Navigator.PushAsync(new FiltrageNoteView())); + NavigationCommand = new Command(async (target) => await Shell.Current.GoToAsync($"//library/{target}")); + PopupHomePlusNavigationCommand = new Command(() => App.Current.MainPage.ShowPopup(new PopupHomePlusButtonView(this))); PopupISBNNavigationCommand = new Command(() => App.Current.MainPage.ShowPopup(new PopupISBNView())); PopupBackButtonNavigationCommand = new Command(() => App.Current.MainPage.Navigation.PopAsync()); diff --git a/LivreLand/ViewModel/BookVM.cs b/ViewModels/BookVM.cs similarity index 87% rename from LivreLand/ViewModel/BookVM.cs rename to ViewModels/BookVM.cs index 946e71a..974c23a 100644 --- a/LivreLand/ViewModel/BookVM.cs +++ b/ViewModels/BookVM.cs @@ -5,9 +5,9 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace LivreLand.ViewModel +namespace ViewModels { - class BookVM + public class BookVM { #region Fields @@ -22,7 +22,7 @@ namespace LivreLand.ViewModel { get => model; set => model = value; - } + } public string Title { @@ -37,7 +37,7 @@ namespace LivreLand.ViewModel #region Constructor - public BookVM() + public BookVM(Book model) { Model = model; } diff --git a/ViewModels/ManagerVM.cs b/ViewModels/ManagerVM.cs index d55369d..32f3d7f 100644 --- a/ViewModels/ManagerVM.cs +++ b/ViewModels/ManagerVM.cs @@ -1,5 +1,7 @@ using Model; +using System.Collections.ObjectModel; using System.Windows.Input; +using ViewModels.LivreLand.ViewModel; namespace ViewModels { @@ -20,7 +22,17 @@ namespace ViewModels private set => model = value; } - public ICommand GetBooksByTitleCommand; + public IEnumerable AllBooks { get; private set; } = new ObservableCollection(); + + public string SearchTitle { get; private set; } + + public int Index { get; private set; } + + public int Count { get; private set; } + + public int NbPages { get; private set; } + + public ICommand GetBooksByTitleCommand { get; } #endregion @@ -29,8 +41,8 @@ namespace ViewModels public ManagerVM(Manager model) { Model = model; - //GetBooksByTitleCommand = new Command(async () =>) - } + GetBooksByTitleCommand = new Command(() => AllBooks = model.GetBooksByTitle(SearchTitle, Index, Count).Result.books.Select(book => new BookVM(book))); + } #endregion } diff --git a/ViewModels/ViewModels.csproj b/ViewModels/ViewModels.csproj index 4b28c7b..11e71c1 100644 --- a/ViewModels/ViewModels.csproj +++ b/ViewModels/ViewModels.csproj @@ -1,9 +1,10 @@ - + net7.0 enable enable + true