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

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

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

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

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

@ -6,7 +6,9 @@ namespace BookApp
{ {
public partial class MainPage : ContentPage public partial class MainPage : ContentPage
{ {
public MainPage(ViewModelManager data) public ViewModelNavigation Nav { get; }
public MainPage(ViewModelMenu data)
{ {
InitializeComponent(); InitializeComponent();
BindingContext = data; BindingContext = data;

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

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

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

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

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

@ -1,12 +1,14 @@
using BookApp.ViewModel; using BookApp.ViewModel;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Diagnostics; using System.Diagnostics;
using VMWrapper;
namespace BookApp.Pages namespace BookApp.Pages
{ {
public partial class Tous : ContentPage public partial class Tous : ContentPage
{ {
public Tous(ViewModelManager data) public ViewModelNavigation VMNav { get; }
public Tous(BookViewModel data)
{ {
InitializeComponent(); InitializeComponent();
BindingContext = data; 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", "Date de publication",
"../Resources/Images/calendar.svg", "../Resources/Images/calendar.svg",
250, 250,
"" "FiltragePage"
), ),
new ViewModelMenuItem("Note", "../Resources/Images/sparkles.svg", 250, "", true), new ViewModelMenuItem("Note", "../Resources/Images/sparkles.svg", 250, "", true),
}; };

@ -23,19 +23,19 @@ namespace BookApp.ViewModel
public INavigation Navigation { get; set; } public INavigation Navigation { get; set; }
public ICommand MenuItemsFiltre { get; private 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 BookSelected { get; private set; }
public ICommand BackButtonCommand { get; private set; } public ICommand BackButtonCommand { get; private set; }
public ViewModelNavigation() public ViewModelNavigation()
{ {
MenuItemsFiltre = new Command(async () => await OnItemSelected(SelectedItem)); MenuItemsFiltre = new CommandPersonnal(async () => await OnItemSelected(SelectedItem));
ItemSelectedCommandMain = new Command(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) private async Task OnItemSelected(ViewModelMenuItem selectedItem)

@ -3,13 +3,10 @@ using System.Collections.ObjectModel;
namespace VMWrapper namespace VMWrapper
{ {
// All the code in this file is included in all platforms.
public class BookViewModel public class BookViewModel
{ {
private readonly ILibraryManager data; private readonly ILibraryManager data;
public ObservableCollection<Book> bookList { get; private set; } =
new ObservableCollection<Book>();
public ObservableCollection<AuteurGroup> AuteurGroups { get; private set; } = public ObservableCollection<AuteurGroup> AuteurGroups { get; private set; } =
new ObservableCollection<AuteurGroup>(); 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; } = public ObservableCollection<Author> authorList { get; private set; } =
new ObservableCollection<Author>(); new ObservableCollection<Author>();
public ObservableCollection<Book> bookList { get; private set; } =
new ObservableCollection<Book>();
public FilterViewModel(ILibraryManager data) public FilterViewModel(ILibraryManager data)
{ {
@ -22,6 +25,26 @@ namespace VMWrapper
GetAuthors(); 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() public void GetAuthors()
{ {
var objet = data.GetAuthorsByName("", 0, 10).Result.Item2; 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 Model;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using System.Windows.Input;
using ToolKit;
namespace VMWrapper namespace VMWrapper
{ {
public class SearchBarViewModel public class SearchBarViewModel : BaseViewModel
{ {
private readonly ILibraryManager data; private readonly ILibraryManager data;
@ -11,6 +15,27 @@ namespace VMWrapper
this.data = data; 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) public async void SearchAuthor(string nomSearch)
{ {
try try

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

Loading…
Cancel
Save