ADD : Avancement VM avec Manager et première commande

commands-19-09
Lou BRODA 1 year ago
parent 66f813b98d
commit c14fce6983

@ -12,15 +12,15 @@
<TabBar>
<ShellContent Title="My Library"
ContentTemplate="{DataTemplate view:BibliothequeView}"
Route="library"
Icon="books_vertical_fill.png"/>
<ShellContent Title="My Lists"
ContentTemplate="{DataTemplate view:TousView}"
Route="tous"
Icon="list_bullet.svg"/>
<ShellContent Title="My Readings"
ContentTemplate="{DataTemplate view:EmpruntsPretsView}"
Icon="bookmark_fill"/>
<ShellContent Title="Search"
ContentTemplate="{DataTemplate view:FiltrageDateView}"
Icon="magnifying_glass.png"/>
</TabBar>

@ -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();
}
}

@ -24,8 +24,9 @@ public static class MauiProgram
builder.Services
.AddSingleton<BibliothequeView>()
.AddSingleton<TousView>()
.AddSingleton<NavigatorVM>()
.AddSingleton<NavigatorVM>()
.AddSingleton<ILibraryManager, LibraryStub>()
.AddSingleton<Manager>()

@ -55,7 +55,8 @@
ButtonNumber="45"
ButtonRedIconVisible="False"
ButtonBlackIconVisible="True"
ButtonTappedCommand="{Binding Navigator.TousNavigationCommand}"/>
ButtonTappedCommand="{Binding Navigator.NavigationCommand}"
CommandParameter="tous/"/>
<contentView:SeparatorCutStartView/>
@ -65,7 +66,8 @@
ButtonNumber="1"
ButtonRedIconVisible="False"
ButtonBlackIconVisible="True"
ButtonTappedCommand="{Binding Navigator.EmpruntsPretsNavigationCommand}"/>
ButtonTappedCommand="{Binding Navigator.NavigationCommand}"
CommandParameter="pret/"/>
<contentView:SeparatorCutStartView/>
@ -74,7 +76,8 @@
ButtonIcon="arrow_forward.png"
ButtonRedIconVisible="False"
ButtonBlackIconVisible="True"
ButtonTappedCommand="{Binding Navigator.ALirePlusTardNavigationCommand}"/>
ButtonTappedCommand="{Binding Navigator.NavigationCommand}"
CommandParameter="later/"/>
<contentView:SeparatorCutStartView/>
@ -83,7 +86,8 @@
ButtonIcon="eyeglasses.png"
ButtonRedIconVisible="False"
ButtonBlackIconVisible="True"
ButtonTappedCommand="{Binding Navigator.StatutLectureNavigationCommand}"/>
ButtonTappedCommand="{Binding Navigator.NavigationCommand}"
CommandParameter="statut/"/>
<contentView:SeparatorCutStartView/>
@ -92,7 +96,8 @@
ButtonIcon="heart_fill.png"
ButtonRedIconVisible="False"
ButtonBlackIconVisible="True"
ButtonTappedCommand="{Binding Navigator.FavorisNavigationCommand}"/>
ButtonTappedCommand="{Binding Navigator.NavigationCommand}"
CommandParameter="favoris/"/>
<contentView:SeparatorEntireView/>
</VerticalStackLayout>
@ -114,7 +119,8 @@
ButtonIcon="person_fill.png"
ButtonRedIconVisible="False"
ButtonBlackIconVisible="True"
ButtonTappedCommand="{Binding Navigator.AuteurNavigationCommand}"/>
ButtonTappedCommand="{Binding Navigator.NavigationCommand}"
CommandParameter="auteur/"/>
<contentView:SeparatorCutStartView/>
@ -123,7 +129,8 @@
ButtonIcon="calendar.png"
ButtonRedIconVisible="False"
ButtonBlackIconVisible="True"
ButtonTappedCommand="{Binding Navigator.DatePublicationNavigationCommand}"/>
ButtonTappedCommand="{Binding Navigator.NavigationCommand}"
CommandParameter="date/"/>
<contentView:SeparatorCutStartView/>
@ -132,7 +139,8 @@
ButtonIcon="sparkles.png"
ButtonRedIconVisible="False"
ButtonBlackIconVisible="True"
ButtonTappedCommand="{Binding Navigator.NoteNavigationCommand}"/>
ButtonTappedCommand="{Binding Navigator.NavigationCommand}"
CommandParameter="note/"/>
<contentView:SeparatorEntireView/>
</VerticalStackLayout>

@ -52,7 +52,7 @@
</Image.Behaviors>
</Image>
<Grid.GestureRecognizers>
<TapGestureRecognizer Command="{Binding ButtonTappedCommand}"/>
<TapGestureRecognizer Command="{Binding ButtonTappedCommand}" CommandParameter="{Binding CommandParameter}"/>
</Grid.GestureRecognizers>
</Grid>

@ -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();

@ -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"/>
</Grid>
<CollectionView ItemsSource="{Binding DamasioBooks}"
<CollectionView ItemsSource="{Binding Manager.AllBooks}"
SelectionMode="Single"
Grid.Row="2">
<CollectionView.ItemTemplate>
<DataTemplate>
<DataTemplate x:DataType="viewModel:BookVM">
<VerticalStackLayout Margin="10"
Spacing="20">
<VisualStateManager.VisualStateGroups x:Name="SelectionStates">

@ -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<BookModel> DamasioBooks { get; set; } = new List<BookModel>()
{
@ -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;
}

@ -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());

@ -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;
}

@ -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<BookVM> AllBooks { get; private set; } = new ObservableCollection<BookVM>();
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
}

@ -1,9 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<UseMaui>true</UseMaui>
</PropertyGroup>
<ItemGroup>

Loading…
Cancel
Save