Update(Back-End): pas de manager mais encore pas stable sans
continuous-integration/drone/push Build is failing Details

Back-End
lodufour1 2 years ago
parent 5f17b504a7
commit 58d1e5130a

@ -4,9 +4,8 @@
xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit"
xmlns:vm="clr-namespace:BookApp.ViewModel"
xmlns:model="clr-namespace:Model;assembly=Model"
x:DataType="vm:ViewModelManager"
x:Class="BookApp.Composants.CollectionFiltrage">
<CollectionView ItemsSource="{Binding VMMrg.filterVm.authorList}">
<CollectionView ItemsSource="{Binding authorList}">
<CollectionView.ItemTemplate>
<DataTemplate x:DataType="model:Author">
<StackLayout Padding="5">

@ -1,9 +1,8 @@
using Android.OS;
using BookApp.ViewModel;
using System.Collections.ObjectModel;
using VMWrapper;
namespace BookApp.Composants
{
{
public partial class CollectionFiltrage : ContentView
{
public CollectionFiltrage()
@ -11,7 +10,7 @@ namespace BookApp.Composants
InitializeComponent();
}
public CollectionFiltrage(ViewModelManager data)
public CollectionFiltrage(FilterViewModel data)
: this()
{
BindingContext = data;

@ -5,9 +5,7 @@
xmlns:model="clr-namespace:Model;assembly=Model"
x:Class="BookApp.Composants.GroupCollection">
<CollectionView ItemsSource="{Binding VMMrg.bookVm.AuteurGroups}" IsGrouped="True" SelectionMode="Single"
SelectionChangedCommand="{Binding VMNav.BookSelected}"
SelectedItem="{Binding VMNav.SelectedBook}">
<CollectionView ItemsSource="{Binding AuteurGroups}" IsGrouped="True" SelectionMode="Single">
<CollectionView.GroupHeaderTemplate>
<DataTemplate>
<Label Text="{Binding Name}"
@ -21,6 +19,9 @@
<DataTemplate>
<StackLayout Style="{StaticResource StyleCollectionStack}">
<Grid>
<Grid.GestureRecognizers>
<TapGestureRecognizer Command="{Binding SelectedBook}"/>
</Grid.GestureRecognizers>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>

@ -1,7 +1,5 @@
using BookApp.Pages;
using BookApp.ViewModel;
using Model;
using VMWrapper;
namespace BookApp.Composants
{
public partial class GroupCollection : ContentView
@ -11,7 +9,7 @@ namespace BookApp.Composants
InitializeComponent();
}
public GroupCollection(ViewModelManager data)
public GroupCollection(BookViewModel data)
: this()
{
BindingContext = data;

@ -4,6 +4,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:vm="clr-namespace:BookApp.ViewModel"
xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit"
x:Name="ThisPage"
x:Class="BookApp.MainPage">
<Shell.TitleView>
<Grid RowDefinitions="Auto">
@ -41,14 +42,13 @@
<StackLayout>
<Label FontSize="35" FontFamily="SF-Pro-Display-Bold" Padding="10">Mes livres</Label>
<Rectangle HeightRequest="1" BackgroundColor="black" VerticalOptions="End" />
<CollectionView ItemsSource="{Binding VMMenu.MenuItemsLivre}"
SelectionChangedCommand="{Binding VMNav.ItemSelectedCommandMain}"
SelectedItem="{Binding VMNav.SelectedItem, Mode=TwoWay}"
SelectionMode="Single" Margin="25,0,0,0" BackgroundColor="#F9F9F9">
<CollectionView ItemsSource="{Binding MenuItemsLivre}" Margin="25,0,0,0" BackgroundColor="#F9F9F9">
<CollectionView.ItemTemplate>
<DataTemplate x:DataType="vm:ViewModelMenuItem">
<DataTemplate>
<Grid RowDefinitions="Auto" Style="{StaticResource StyleCollectionGrid}" Padding="2">
<Grid.GestureRecognizers>
<TapGestureRecognizer Command="{Binding Source={x:Reference ThisPage}, Path=Nav.MenuItemsCommand}"/>
</Grid.GestureRecognizers>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="25"/>
<ColumnDefinition Width="*"/>
@ -97,10 +97,7 @@
<Label FontFamily="SF-Pro-Display-Heavy" FontSize="20" Padding="10">Filtres</Label>
<Rectangle HeightRequest="1" BackgroundColor="black" VerticalOptions="End"/>
<CollectionView ItemsSource="{Binding VMMenu.MenuItemsFiltre}"
SelectionChangedCommand="{Binding VMNav.ItemSelectedCommandFiltre}"
SelectedItem="{Binding VMNav.SelectedItem, Mode=TwoWay}"
SelectionMode="Single" Margin="25,0,0,0" BackgroundColor="#F9F9F9">
<CollectionView ItemsSource="{Binding MenuItemsFiltre}" Margin="25,0,0,0" BackgroundColor="#F9F9F9">
<CollectionView.ItemTemplate>
<DataTemplate x:DataType="vm:ViewModelMenuItem">
<Grid RowDefinitions="Auto" Style="{StaticResource StyleCollectionGrid}" Padding="2">

@ -5,11 +5,13 @@ using BookApp.ViewModel;
namespace BookApp
{
public partial class MainPage : ContentPage
{
public MainPage(ViewModelManager data)
{
InitializeComponent();
BindingContext = data;
}
{
public ViewModelNavigation Nav { get; }
public MainPage(ViewModelMenu data)
{
InitializeComponent();
BindingContext = data;
}
}
}

@ -33,11 +33,9 @@ namespace BookApp
builder.Services.AddSingleton<BookViewModel>();
builder.Services.AddSingleton<FilterViewModel>();
builder.Services.AddSingleton<SearchBarViewModel>();
builder.Services.AddSingleton<ManagerViewModel>();
builder.Services.AddSingleton<ViewModelManager>();
;
builder.Services.AddSingleton<ViewModelNavigation>();
builder.Services.AddTransient<ViewModelMenu>();
builder.Services.AddSingleton<ViewModelMenu>();
builder.Services.AddSingleton<GroupCollection>();
builder.Services.AddSingleton<CollectionFiltrage>();

@ -6,7 +6,7 @@ namespace BookApp.Pages;
public partial class DetailBook : ContentPage
{
public DetailBook(ViewModelManager data)
public DetailBook(DetailBook data)
{
InitializeComponent();
BindingContext = data;

@ -1,6 +1,7 @@
using BookApp.ViewModel;
using System.Windows.Input;
using VMWrapper;
namespace BookApp.Pages
{
public partial class EmpruntsPrets : ContentPage
@ -19,7 +20,7 @@ namespace BookApp.Pages
}
}*/
public EmpruntsPrets(ViewModelManager data)
public EmpruntsPrets(BookViewModel data)
{
InitializeComponent();
BindingContext = data;

@ -31,19 +31,10 @@
<toolkit:IconTintColorBehavior TintColor="Red" />
</Image.Behaviors>
</Image>
<Label
Text="Auteur"
FontFamily="Strande2"
TextColor="Red"
FontSize="Medium"
VerticalTextAlignment="Center"
HorizontalOptions="Start"
Grid.Column="0" />
</HorizontalStackLayout>
<Label
Text="Tous"
Text="{Binding VMNav.SelectedItem.Name}"
FontFamily="Strande2"
TextColor="Black"
FontSize="Medium"

@ -7,7 +7,7 @@ namespace BookApp.Pages
{
SearchBar searchBar = new SearchBar { Placeholder = "Search items..." };
public Filtrage(ViewModelManager data)
public Filtrage(FilterViewModel data)
{
InitializeComponent();
BindingContext = data;

@ -1,12 +1,14 @@
using BookApp.ViewModel;
using System.Collections.ObjectModel;
using System.Diagnostics;
using VMWrapper;
namespace BookApp.Pages
{
public partial class Tous : ContentPage
{
public Tous(ViewModelManager data)
public ViewModelNavigation VMNav { get; }
public Tous(BookViewModel data)
{
InitializeComponent();
BindingContext = data;

@ -1,18 +0,0 @@
using ToolKit;
using VMWrapper;
namespace BookApp.ViewModel;
public class ViewModelManager : BaseViewModel
{
public ManagerViewModel VMMrg { get; }
public ViewModelMenu VMMenu { get; }
public ViewModelNavigation VMNav { get; }
public ViewModelManager(ManagerViewModel vMMrg, ViewModelMenu viewModelMenu, ViewModelNavigation viewModelNavigation)
{
VMMrg = vMMrg;
VMMenu = viewModelMenu;
VMNav = viewModelNavigation;
}
}

@ -57,7 +57,7 @@ namespace BookApp.ViewModel
"Date de publication",
"../Resources/Images/calendar.svg",
250,
""
"FiltragePage"
),
new ViewModelMenuItem("Note", "../Resources/Images/sparkles.svg", 250, "", true),
};

@ -23,19 +23,19 @@ namespace BookApp.ViewModel
public INavigation Navigation { get; set; }
public ICommand MenuItemsFiltre { get; private set; }
public ICommand ItemSelectedCommandMain { get; private set; }
public ICommand MenuItemsCommand { get; private set; }
public ICommand BookSelected { get; private set; }
public ICommand BackButtonCommand { get; private set; }
public ViewModelNavigation()
{
MenuItemsFiltre = new Command(async () => await OnItemSelected(SelectedItem));
ItemSelectedCommandMain = new Command(async () => await OnItemSelected(SelectedItem));
MenuItemsFiltre = new CommandPersonnal(async () => await OnItemSelected(SelectedItem));
MenuItemsCommand = new CommandPersonnal(async () => await OnItemSelected(SelectedItem));
BackButtonCommand = new Command(async () => await BackButton(this, EventArgs.Empty));
BackButtonCommand = new CommandPersonnal(async () => await BackButton(this, EventArgs.Empty));
BookSelected = new Command(async () => await OnBookSelected(SelectedBook));
BookSelected = new CommandPersonnal(async () => await OnBookSelected(SelectedBook));
}
private async Task OnItemSelected(ViewModelMenuItem selectedItem)

@ -3,13 +3,10 @@ using System.Collections.ObjectModel;
namespace VMWrapper
{
// All the code in this file is included in all platforms.
public class BookViewModel
{
private readonly ILibraryManager data;
public ObservableCollection<Book> bookList { get; private set; } =
new ObservableCollection<Book>();
public ObservableCollection<AuteurGroup> AuteurGroups { get; private set; } =
new ObservableCollection<AuteurGroup>();

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace VMWrapper
{
public class DetailBookViewModel
{
public DetailBookViewModel()
{
}
}
}

@ -15,6 +15,9 @@ namespace VMWrapper
public ObservableCollection<Author> authorList { get; private set; } =
new ObservableCollection<Author>();
public ObservableCollection<Book> bookList { get; private set; } =
new ObservableCollection<Book>();
public FilterViewModel(ILibraryManager data)
{
@ -22,6 +25,26 @@ namespace VMWrapper
GetAuthors();
}
private async void GetDatePublish()
{
try
{
var books = data.GetBooksByAuthor("", 0, 5).Result.Item2;
foreach (Book book in books)
{
bookList.Add(book);
}
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine(ex.Message);
}
}
public void GetAuthors()
{
var objet = data.GetAuthorsByName("", 0, 10).Result.Item2;

@ -1,18 +0,0 @@
using Model;
namespace VMWrapper
{
public class ManagerViewModel
{
public FilterViewModel filterVm { get; }
public SearchBarViewModel searchBar { get; }
public BookViewModel bookVm { get; }
public ManagerViewModel(FilterViewModel filterVm, SearchBarViewModel searchBar, BookViewModel bookVm)
{
this.filterVm = filterVm;
this.searchBar = searchBar;
this.bookVm = bookVm;
}
}
}

@ -1,8 +1,12 @@
using Model;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using System.Windows.Input;
using ToolKit;
namespace VMWrapper
{
public class SearchBarViewModel
public class SearchBarViewModel : BaseViewModel
{
private readonly ILibraryManager data;
@ -11,6 +15,27 @@ namespace VMWrapper
this.data = data;
}
/* public ICommand PerformSearch => new Command<string>((string query) =>
{
SearchResults = DataService.GetSearchResults(query);
});
private List<string> searchResults = DataService.Fruits;
public List<string> SearchResults
{
get
{
return searchResults;
}
set
{
searchResults = value;
NotifyPropertyChanged();
}
}*/
public async void SearchAuthor(string nomSearch)
{
try

@ -23,6 +23,7 @@
<ItemGroup>
<ProjectReference Include="..\Model\Model.csproj" />
<ProjectReference Include="..\ToolKit\ToolKit.csproj" />
</ItemGroup>
</Project>

Loading…
Cancel
Save