diff --git a/sources/MyToolkitMVVM/ObservableObject.cs b/sources/MyToolkitMVVM/ObservableObject.cs index 8799abb..5be73e1 100644 --- a/sources/MyToolkitMVVM/ObservableObject.cs +++ b/sources/MyToolkitMVVM/ObservableObject.cs @@ -1,4 +1,5 @@ using System.ComponentModel; +using System.Diagnostics; using System.Runtime.CompilerServices; namespace MyToolkitMVVM; @@ -17,11 +18,13 @@ public class ObservableObject : INotifyPropertyChanged if (EqualityComparer.Default.Equals(member, value)) return; member = value; OnPropertyChanged(propertyName); + Debug.WriteLine("PropertyChanged "+propertyName); } protected void SetProperty(T member, T value,Action action, [CallerMemberName] string propertyName = null) { if (EqualityComparer.Default.Equals(member, value)) return; action(value); OnPropertyChanged(propertyName); + Debug.WriteLine("PropertyChanged " + propertyName); } } diff --git a/sources/PocketBook/Applicative_VM/NavigatorVM.cs b/sources/PocketBook/Applicative_VM/NavigatorVM.cs index 42dceee..2e9eb9f 100644 --- a/sources/PocketBook/Applicative_VM/NavigatorVM.cs +++ b/sources/PocketBook/Applicative_VM/NavigatorVM.cs @@ -8,17 +8,12 @@ namespace PocketBook.Applicative_VM public class NavigatorVM { public ICommand Navigateto { get; private set; } - public ICommand SeeDetailPage { get; private set; } public NavigatorVM() { Navigateto = new Command( async (string page) => await Shell.Current.GoToAsync(page) ); - - SeeDetailPage = new Command( - async () => await Shell.Current.GoToAsync("BookDetail") - ); } } } diff --git a/sources/PocketBook/Applicative_VM/TousPageVM.cs b/sources/PocketBook/Applicative_VM/TousPageVM.cs new file mode 100644 index 0000000..7e110f4 --- /dev/null +++ b/sources/PocketBook/Applicative_VM/TousPageVM.cs @@ -0,0 +1,33 @@ +using System; +using System.Diagnostics; +using System.Windows.Input; +using MyToolkitMVVM; +using ViewModel; + +namespace PocketBook.Applicative_VM +{ + public class TousPageVM : BaseViewModel + { + 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 TousPageVM(NavigatorVM navigation,ManagerVM manager, ScanMenuVM scanMenuVM) + { + ScanMenuVM = scanMenuVM; + Manager = manager; + NavigateCommandBooks = navigation; + + NavigateDetailPage = new Command(book => + { + Debug.WriteLine(book.Id); + Manager.LoadBookFromManager(book.Id); + Debug.WriteLine(Manager.SelectedBook.Title); + NavigateCommandBooks.Navigateto.Execute("BookDetail"); + }); + } + } +} + diff --git a/sources/PocketBook/MauiProgram.cs b/sources/PocketBook/MauiProgram.cs index 268316d..455e933 100644 --- a/sources/PocketBook/MauiProgram.cs +++ b/sources/PocketBook/MauiProgram.cs @@ -42,10 +42,11 @@ public static class MauiProgram }); builder.Services - .AddSingleton() - .AddSingleton() + .AddSingleton() + .AddSingleton() .AddSingleton() .AddSingleton() + .AddSingleton() .AddSingleton() .AddSingleton() .AddSingleton() diff --git a/sources/PocketBook/Pages/BookDetail.xaml b/sources/PocketBook/Pages/BookDetail.xaml index 85b0e30..8c02c9e 100644 --- a/sources/PocketBook/Pages/BookDetail.xaml +++ b/sources/PocketBook/Pages/BookDetail.xaml @@ -6,14 +6,14 @@ Title="Détails du livre" Shell.ForegroundColor="{StaticResource Primary}" Shell.BackgroundColor="{StaticResource TopBackgroundGrey}" - xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit"> + x:Name="root"> - + - @@ -26,12 +26,12 @@ @@ -44,21 +44,21 @@