diff --git a/Sources/BookApp/AppShell.xaml b/Sources/BookApp/AppShell.xaml
index 17d3960..8ea0eb9 100644
--- a/Sources/BookApp/AppShell.xaml
+++ b/Sources/BookApp/AppShell.xaml
@@ -19,11 +19,11 @@
-
+
-
+
diff --git a/Sources/BookApp/BookApp.csproj b/Sources/BookApp/BookApp.csproj
index 088bf6f..f1d4c4b 100644
--- a/Sources/BookApp/BookApp.csproj
+++ b/Sources/BookApp/BookApp.csproj
@@ -76,6 +76,7 @@
+
diff --git a/Sources/BookApp/Composants/GroupCollection.xaml b/Sources/BookApp/Composants/GroupCollection.xaml
index bca8719..79bcd7d 100644
--- a/Sources/BookApp/Composants/GroupCollection.xaml
+++ b/Sources/BookApp/Composants/GroupCollection.xaml
@@ -43,21 +43,21 @@
-
-
+ Text="{Binding Status}"/>
diff --git a/Sources/BookApp/Composants/GroupCollection.xaml.cs b/Sources/BookApp/Composants/GroupCollection.xaml.cs
index 294a032..799be4d 100644
--- a/Sources/BookApp/Composants/GroupCollection.xaml.cs
+++ b/Sources/BookApp/Composants/GroupCollection.xaml.cs
@@ -1,5 +1,5 @@
using BookApp.Pages;
-using BookApp.ViewModel;
+using Model;
namespace BookApp.Composants
{
@@ -12,10 +12,10 @@ namespace BookApp.Composants
private async void OnSelectionChanged(object sender, SelectionChangedEventArgs e)
{
- /*if (e.CurrentSelection.FirstOrDefault() is Book selectedItem)
+ if (e.CurrentSelection.FirstOrDefault() is Book selectedItem)
{
await Navigation.PushAsync(new DetailBook(selectedItem));
- }*/
+ }
}
}
}
diff --git a/Sources/BookApp/MainPage.xaml b/Sources/BookApp/MainPage.xaml
index 10377b8..7c226a6 100644
--- a/Sources/BookApp/MainPage.xaml
+++ b/Sources/BookApp/MainPage.xaml
@@ -40,7 +40,8 @@
-
+
+
@@ -69,12 +70,10 @@
VerticalOptions="Center"
Margin="0,0,40,0"
HorizontalOptions="End"/>
-
@@ -127,7 +126,6 @@
HeightRequest="35"
WidthRequest="35"
BackgroundColor="#F9F9F9"
- Clicked="ButtonAuteur"
HorizontalOptions="End"/>
diff --git a/Sources/BookApp/MainPage.xaml.cs b/Sources/BookApp/MainPage.xaml.cs
index 8a7d433..a588588 100644
--- a/Sources/BookApp/MainPage.xaml.cs
+++ b/Sources/BookApp/MainPage.xaml.cs
@@ -1,59 +1,17 @@
using BookApp.Pages;
using System.Collections.ObjectModel;
+using BookApp.ViewModel;
namespace BookApp
{
public partial class MainPage : ContentPage
{
- public class ObjetTemp
- {
- public string Name { get; set; }
- public string Icone { get; set; }
- public int Number { get; set; }
- public bool IsLastItem { get; set; }
-
- public ObjetTemp(string name, string icone, int number, bool isLastItem = false)
- {
- Name = name;
- Icone = icone;
- Number = number;
- IsLastItem = isLastItem;
- }
- }
-
- public ObservableCollection MyCollections1 { get; set; }
- public ObservableCollection MyCollections2 { get; set; }
-
- public MainPage()
+ public MainPage(NavigationViewModel data)
{
InitializeComponent();
- MyCollections1 = new ObservableCollection()
- {
- new ObjetTemp("Tous", "./Reources/Images/tray_2_fill.svg", 250),
- new ObjetTemp("En prêt", "./Reources/Images/person_badge_clock_fill.svg", 250),
- new ObjetTemp("À lire plus tard", "./Reources/Images/arrow_forward.svg", 250),
- new ObjetTemp("Statut de lecture", "./Reources/Images/eyeglasses.svg", 250),
- new ObjetTemp("Favoris", "./Reources/Images/heart_fill.svg", 250),
- new ObjetTemp("Étiquettes", "./Reources/Images/tag_fill.svg", 250, true),
- };
-
- MyCollections2 = new ObservableCollection()
- {
- new ObjetTemp("Auteur", "./Reources/Images/person_fill.svg", 250),
- new ObjetTemp("Date de publication", "./Reources/Images/calendar.svg", 250),
- new ObjetTemp("Note", "./Reources/Images/sparkles.svg", 250, true),
- };
- BindingContext = this;
+ BindingContext = data;
}
- async void ButtonTous(object sender, EventArgs args)
- {
- await Shell.Current.GoToAsync("TousPage");
- }
-
- async void ButtonAuteur(object sender, EventArgs args)
- {
- await Shell.Current.GoToAsync("FiltragePage");
- }
+ private async void OnSelectionChanged(object sender, SelectionChangedEventArgs e) { }
}
}
diff --git a/Sources/BookApp/MauiProgram.cs b/Sources/BookApp/MauiProgram.cs
index 65162e4..ca42509 100644
--- a/Sources/BookApp/MauiProgram.cs
+++ b/Sources/BookApp/MauiProgram.cs
@@ -30,9 +30,12 @@ namespace BookApp
#endif
builder.Services.AddSingleton();
builder.Services.AddSingleton();
- builder.Services.AddSingleton();
+ builder.Services.AddSingleton();
builder.Services.AddSingleton();
builder.Services.AddSingleton();
+ builder.Services.AddSingleton();
+ builder.Services.AddSingleton();
+ builder.Services.AddSingleton();
// transient pour recharger la data à l'execute
diff --git a/Sources/BookApp/Pages/DetailBook.xaml.cs b/Sources/BookApp/Pages/DetailBook.xaml.cs
index 666661a..561a6c0 100644
--- a/Sources/BookApp/Pages/DetailBook.xaml.cs
+++ b/Sources/BookApp/Pages/DetailBook.xaml.cs
@@ -9,7 +9,7 @@ public partial class DetailBook : ContentPage
public Book BookDetail { get; set; }
*/
- public DetailBook() //Book ItemBook)
+ public DetailBook(Model.Book selectedItem) //Book ItemBook)
{
InitializeComponent();
diff --git a/Sources/BookApp/Pages/Tous.xaml.cs b/Sources/BookApp/Pages/Tous.xaml.cs
index d461ffd..3158f1d 100644
--- a/Sources/BookApp/Pages/Tous.xaml.cs
+++ b/Sources/BookApp/Pages/Tous.xaml.cs
@@ -1,13 +1,14 @@
using BookApp.ViewModel;
+using VMWrapper;
namespace BookApp.Pages
{
public partial class Tous : ContentPage
{
- public Tous()
+ public Tous(BookViewModel data)
{
InitializeComponent();
- //BindingContext = new TousViewModel();
+ BindingContext = data;
}
async void BackButton(object sender, EventArgs args)
diff --git a/Sources/BookApp/ViewModel/ViewModelManager.cs b/Sources/BookApp/ViewModel/ViewModelManager.cs
index 1096cda..c52ac5c 100644
--- a/Sources/BookApp/ViewModel/ViewModelManager.cs
+++ b/Sources/BookApp/ViewModel/ViewModelManager.cs
@@ -10,40 +10,8 @@ public class ViewModelManager
BookViewModel _viewModel;
public ObservableCollection Authors { get; set; } = new ObservableCollection();
- /* public ObservableCollection AuteurGroups { get; private set; } =
- new ObservableCollection();*/
-
public ViewModelManager(BookViewModel viewModel)
{
_viewModel = viewModel;
- //GetAuthors();
- /* ObservableCollection auteurs = new Stub().CreateStubData();
- foreach (Auteur auteur in auteurs)
- {
- AuteurGroups.Add(new AuteurGroup(auteur.Name, auteur.Books));
- }*/
}
-
- //fireandforget
- /*public async void GetAuthors()
- {
-
- var authors1 = await _viewModel.GetAuthors();
- Authors.Clear();
- foreach (var author in authors1)
- {
- Authors.Add(author);
- }
- }*/
}
-
-/*public class AuteurGroup : ObservableCollection
-{
- public string Name { get; private set; }
-
- public AuteurGroup(string name, ObservableCollection books)
- : base(books)
- {
- Name = name;
- }
-}*/
diff --git a/Sources/BookApp/ViewModel/ViewModelMenu.cs b/Sources/BookApp/ViewModel/ViewModelMenu.cs
new file mode 100644
index 0000000..eaf5952
--- /dev/null
+++ b/Sources/BookApp/ViewModel/ViewModelMenu.cs
@@ -0,0 +1,67 @@
+using System.Collections.ObjectModel;
+
+namespace BookApp.ViewModel
+{
+ public class ViewModelMenu
+ {
+ public string Name { get; set; }
+ public string Icone { get; set; }
+ public int Number { get; set; }
+ public string Route { get; set; }
+ public bool IsLastItem { get; set; }
+
+ public ViewModelMenu(
+ string name,
+ string icone,
+ int number,
+ string route,
+ bool isLastItem = false
+ )
+ {
+ Name = name;
+ Icone = icone;
+ Number = number;
+ Route = route;
+ IsLastItem = isLastItem;
+ }
+
+ public ObservableCollection MyCollections1 { get; set; } =
+ new ObservableCollection()
+ {
+ new ViewModelMenu("Tous", "./Resources/Images/tray_2_fill.svg", 250, "Tous"),
+ new ViewModelMenu(
+ "En prêt",
+ "./Resources/Images/person_badge_clock_fill.svg",
+ 250,
+ "EmpruntsPrets"
+ ),
+ new ViewModelMenu(
+ "À lire plus tard",
+ "./Resources/Images/arrow_forward.svg",
+ 250,
+ ""
+ ),
+ new ViewModelMenu(
+ "Statut de lecture",
+ "./Resources/Images/eyeglasses.svg",
+ 250,
+ ""
+ ),
+ new ViewModelMenu("Favoris", "./Resources/Images/heart_fill.svg", 250, ""),
+ new ViewModelMenu("Étiquettes", "./Resources/Images/tag_fill.svg", 250, "", true),
+ };
+
+ public ObservableCollection MyCollections2 { get; set; } =
+ new ObservableCollection()
+ {
+ new ViewModelMenu("Auteur", "./Resources/Images/person_fill.svg", 250, "Filtrage"),
+ new ViewModelMenu(
+ "Date de publication",
+ "./Resources/Images/calendar.svg",
+ 250,
+ ""
+ ),
+ new ViewModelMenu("Note", "./Resources/Images/sparkles.svg", 250, "", true),
+ };
+ }
+}
diff --git a/Sources/BookApp/ViewModel/ViewModelNavigation.cs b/Sources/BookApp/ViewModel/ViewModelNavigation.cs
index f920b45..ba3489f 100644
--- a/Sources/BookApp/ViewModel/ViewModelNavigation.cs
+++ b/Sources/BookApp/ViewModel/ViewModelNavigation.cs
@@ -1,10 +1,43 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
+using ToolKit;
+using System.Windows.Input;
+using System.Collections.ObjectModel;
namespace BookApp.ViewModel
{
- internal class ViewModelNavigation { }
+ public class NavigationViewModel : BaseViewModel
+ {
+ public NavigationViewModel() { }
+
+ private async void OnSelectionChanged(object sender, SelectionChangedEventArgs e)
+ {
+ if (e.CurrentSelection.FirstOrDefault() is ViewModelMenu selectedItem)
+ {
+ if (!string.IsNullOrWhiteSpace(selectedItem.Route))
+ {
+ Type pageType = Type.GetType("BookApp.Pages." + selectedItem.Route);
+ if (pageType == null)
+ {
+ return;
+ }
+
+ Page pageInstance = (Page)Activator.CreateInstance(pageType);
+ // await Navigation.PushAsync(pageInstance);
+ }
+ else
+ {
+ Console.WriteLine("Erreur trouvé");
+ }
+ }
+ }
+
+ async void ButtonTous(object sender, EventArgs args)
+ {
+ await Shell.Current.GoToAsync("TousPage");
+ }
+
+ async void ButtonAuteur(object sender, EventArgs args)
+ {
+ await Shell.Current.GoToAsync("FiltragePage");
+ }
+ }
}
diff --git a/Sources/ToolKit/BaseViewModel.cs b/Sources/ToolKit/BaseViewModel.cs
new file mode 100644
index 0000000..e5f5dd4
--- /dev/null
+++ b/Sources/ToolKit/BaseViewModel.cs
@@ -0,0 +1,29 @@
+using System.ComponentModel;
+using System.Runtime.CompilerServices;
+
+namespace ToolKit
+{
+ public class BaseViewModel : INotifyPropertyChanged
+ {
+ public event PropertyChangedEventHandler PropertyChanged;
+
+ protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
+ {
+ PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
+ }
+
+ protected bool SetProperty(
+ ref T backingField,
+ T value,
+ [CallerMemberName] string propertyName = null
+ )
+ {
+ if (EqualityComparer.Default.Equals(backingField, value))
+ return false;
+
+ backingField = value;
+ OnPropertyChanged(propertyName);
+ return true;
+ }
+ }
+}
diff --git a/Sources/ToolKit/Class1.cs b/Sources/ToolKit/Class1.cs
deleted file mode 100644
index afab435..0000000
--- a/Sources/ToolKit/Class1.cs
+++ /dev/null
@@ -1,4 +0,0 @@
-namespace ToolKit
-{
- public class Class1 { }
-}
diff --git a/Sources/VMWrapper/BookViewModel.cs b/Sources/VMWrapper/BookViewModel.cs
index 2e21e82..217102f 100644
--- a/Sources/VMWrapper/BookViewModel.cs
+++ b/Sources/VMWrapper/BookViewModel.cs
@@ -8,7 +8,7 @@ using System.Xml.Linq;
namespace VMWrapper
{
// All the code in this file is included in all platforms.
- public class BookViewModel : INotifyPropertyChanged
+ public class BookViewModel
{
private readonly ILibraryManager data;
@@ -66,12 +66,5 @@ namespace VMWrapper
authorList.Add(author);
}
}
-
- public event PropertyChangedEventHandler PropertyChanged;
-
- protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
- {
- PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
- }
}
}