From c63ed977faa7f4d947731f2f5c3c0460b2d3ad9b Mon Sep 17 00:00:00 2001 From: lobroda Date: Sun, 22 Oct 2023 11:19:57 +0100 Subject: [PATCH] ADD : Changement Status Working + Navigation Status bug fixed --- LivreLand/Platforms/iOS/Info.plist | 2 ++ LivreLand/View/FavorisView.xaml | 6 ++++-- LivreLand/View/FavorisView.xaml.cs | 5 ----- LivreLand/ViewModel/DetailsLivreVM.cs | 2 +- LivreLand/ViewModel/FavorisVM.cs | 20 +++++++++++++++++++- ViewModels/BookVM.cs | 1 + ViewModels/ManagerVM.cs | 4 ++-- 7 files changed, 29 insertions(+), 11 deletions(-) diff --git a/LivreLand/Platforms/iOS/Info.plist b/LivreLand/Platforms/iOS/Info.plist index 0004a4f..26634ab 100644 --- a/LivreLand/Platforms/iOS/Info.plist +++ b/LivreLand/Platforms/iOS/Info.plist @@ -28,5 +28,7 @@ XSAppIconAssets Assets.xcassets/appicon.appiconset + NSCameraUsageDescription + This app uses camera for scanning barcodes diff --git a/LivreLand/View/FavorisView.xaml b/LivreLand/View/FavorisView.xaml index 25fcc0d..f2b70e7 100644 --- a/LivreLand/View/FavorisView.xaml +++ b/LivreLand/View/FavorisView.xaml @@ -42,8 +42,10 @@ Grid.Column="1"/> diff --git a/LivreLand/View/FavorisView.xaml.cs b/LivreLand/View/FavorisView.xaml.cs index 7d635a7..a931e4e 100644 --- a/LivreLand/View/FavorisView.xaml.cs +++ b/LivreLand/View/FavorisView.xaml.cs @@ -24,10 +24,5 @@ public partial class FavorisView : ContentPage #region Methods - void OnSelectionChanged(object sender, SelectionChangedEventArgs e) - { - //App.Current.MainPage.Navigation.PushAsync(new DetailsLivreView()); - } - #endregion } \ No newline at end of file diff --git a/LivreLand/ViewModel/DetailsLivreVM.cs b/LivreLand/ViewModel/DetailsLivreVM.cs index 26f4851..1465e49 100644 --- a/LivreLand/ViewModel/DetailsLivreVM.cs +++ b/LivreLand/ViewModel/DetailsLivreVM.cs @@ -106,7 +106,7 @@ namespace LivreLand.ViewModel private void ShowPicker() { Manager.GetAllStatusCommand.Execute(null); - Manager.SelectedStatus = this.Book.Status; + Manager.SelectedStatus = Book.Status; IsPickerVisible = true; } diff --git a/LivreLand/ViewModel/FavorisVM.cs b/LivreLand/ViewModel/FavorisVM.cs index c69ae28..2963da9 100644 --- a/LivreLand/ViewModel/FavorisVM.cs +++ b/LivreLand/ViewModel/FavorisVM.cs @@ -1,9 +1,11 @@ -using PersonalMVVMToolkit; +using LivreLand.View; +using PersonalMVVMToolkit; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using System.Windows.Input; using ViewModels; namespace LivreLand.ViewModel @@ -16,6 +18,8 @@ namespace LivreLand.ViewModel public ManagerVM Manager { get; private set; } + public ICommand OnSelectionChangedCommand { get; private set; } + #endregion #region Constructor @@ -24,6 +28,20 @@ namespace LivreLand.ViewModel { Navigator = navigatorVM; Manager = managerVM; + OnSelectionChangedCommand = new RelayCommand((bookVM) => OnSelectionChanged(bookVM)); + } + + #endregion + + #region Methods + + private void OnSelectionChanged(BookVM bookVM) + { + if (bookVM != null) + { + var result = new DetailsLivreVM(Manager, Navigator, bookVM); + App.Current.MainPage.Navigation.PushAsync(new DetailsLivreView(result)); + } } #endregion diff --git a/ViewModels/BookVM.cs b/ViewModels/BookVM.cs index 6b38162..982554c 100644 --- a/ViewModels/BookVM.cs +++ b/ViewModels/BookVM.cs @@ -52,6 +52,7 @@ namespace ViewModels public Status Status { get => Model.Status; + set => SetProperty(Model.Status, value, status => Model.Status = status); } public int NbPages diff --git a/ViewModels/ManagerVM.cs b/ViewModels/ManagerVM.cs index 621bd5d..20ced0a 100644 --- a/ViewModels/ManagerVM.cs +++ b/ViewModels/ManagerVM.cs @@ -487,8 +487,8 @@ namespace ViewModels book.Status = SelectedStatus; await Model.UpdateBook(book); var updatedBook = new BookVM(book); - bookVM = updatedBook; - OnPropertyChanged(nameof(bookVM)); + SelectedBook.Status = updatedBook.Status; + OnPropertyChanged(nameof(SelectedBook)); } private async Task UpdateToBeReadBook(BookVM bookVM)