Update (Back-end): Ajout de VM
continuous-integration/drone/push Build is failing Details

Back-End
Louis DUFOUR 2 years ago
parent d4e4958c1b
commit 25445b6f1b

@ -19,11 +19,11 @@
</Tab> </Tab>
<Tab Title="My Readings" <Tab Title="My Readings"
Icon="bookmark_fill.svg"> Icon="bookmark_fill.svg">
<ShellContent ContentTemplate="{DataTemplate local:MainPage}" /> <ShellContent ContentTemplate="{DataTemplate pages:Tous}" />
</Tab> </Tab>
<Tab Title="Search" <Tab Title="Search"
Icon="magnifyingglass.svg"> Icon="magnifyingglass.svg">
<ShellContent ContentTemplate="{DataTemplate local:MainPage}" /> <ShellContent ContentTemplate="{DataTemplate pages:Filtrage}" />
</Tab> </Tab>
</TabBar> </TabBar>

@ -76,6 +76,7 @@
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\Model\Model.csproj" /> <ProjectReference Include="..\Model\Model.csproj" />
<ProjectReference Include="..\Stub\Stub.csproj" /> <ProjectReference Include="..\Stub\Stub.csproj" />
<ProjectReference Include="..\ToolKit\ToolKit.csproj" />
<ProjectReference Include="..\VMWrapper\VMWrapper.csproj" /> <ProjectReference Include="..\VMWrapper\VMWrapper.csproj" />
</ItemGroup> </ItemGroup>

@ -43,21 +43,21 @@
<ColumnDefinition Width="*"/> <ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<Image Grid.Column="0" <Image Grid.Column="0"
Source="{Binding ImageBook}" Source="{Binding ImageLarge}"
HeightRequest="125" HeightRequest="125"
WidthRequest="125" WidthRequest="125"
Margin="0,10,0,10"/> Margin="0,10,0,10"/>
<StackLayout Grid.Column="1"> <StackLayout Grid.Column="1">
<Label Text="{Binding Name}" <Label Text="{Binding Title}"
FontFamily="SF-Compact-Display-Bold" FontFamily="SF-Compact-Display-Bold"
FontSize="18" FontSize="18"
TextColor="Black"/> TextColor="Black"/>
<Label Text="{Binding Auteur.Name}" <Label Text="{Binding Authors}"
FontFamily="SF-Compact-Display-Semibold" FontFamily="SF-Compact-Display-Semibold"
TextColor="Black"/> TextColor="Black"/>
<Label <Label
TextColor="SlateGray" TextColor="SlateGray"
Text="{Binding Statut}"/> Text="{Binding Status}"/>
<StackLayout Margin="0,10" Orientation="Horizontal" VerticalOptions="EndAndExpand"> <StackLayout Margin="0,10" Orientation="Horizontal" VerticalOptions="EndAndExpand">
<Image Source="empty_star.svg" WidthRequest="25" HeightRequest="25"/> <Image Source="empty_star.svg" WidthRequest="25" HeightRequest="25"/>

@ -1,5 +1,5 @@
using BookApp.Pages; using BookApp.Pages;
using BookApp.ViewModel; using Model;
namespace BookApp.Composants namespace BookApp.Composants
{ {
@ -12,10 +12,10 @@ namespace BookApp.Composants
private async void OnSelectionChanged(object sender, SelectionChangedEventArgs e) 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)); await Navigation.PushAsync(new DetailBook(selectedItem));
}*/ }
} }
} }
} }

@ -40,7 +40,8 @@
<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 MyCollections1}" Margin="25,0,0,0" BackgroundColor="#F9F9F9"> <CollectionView ItemsSource="{Binding MyCollections1}" SelectionMode="Single" SelectionChanged="OnSelectionChanged" Margin="25,0,0,0" BackgroundColor="#F9F9F9">
<CollectionView.ItemTemplate> <CollectionView.ItemTemplate>
<DataTemplate> <DataTemplate>
<Grid RowDefinitions="Auto" > <Grid RowDefinitions="Auto" >
@ -69,12 +70,10 @@
VerticalOptions="Center" VerticalOptions="Center"
Margin="0,0,40,0" Margin="0,0,40,0"
HorizontalOptions="End"/> HorizontalOptions="End"/>
<Button Grid.Column="2" <Image Grid.Column="2"
ImageSource="chevron_right.svg" Source="chevron_right.svg"
HeightRequest="35" HeightRequest="25"
WidthRequest="35" WidthRequest="25"
BackgroundColor="#F9F9F9"
Clicked="ButtonTous"
HorizontalOptions="End"/> HorizontalOptions="End"/>
</Grid> </Grid>
<Rectangle Grid.ColumnSpan="4" HeightRequest="1" BackgroundColor="LightGray" VerticalOptions="End"> <Rectangle Grid.ColumnSpan="4" HeightRequest="1" BackgroundColor="LightGray" VerticalOptions="End">
@ -127,7 +126,6 @@
HeightRequest="35" HeightRequest="35"
WidthRequest="35" WidthRequest="35"
BackgroundColor="#F9F9F9" BackgroundColor="#F9F9F9"
Clicked="ButtonAuteur"
HorizontalOptions="End"/> HorizontalOptions="End"/>
</Grid> </Grid>
<Rectangle Grid.ColumnSpan="4" HeightRequest="1" BackgroundColor="LightGray" VerticalOptions="End"> <Rectangle Grid.ColumnSpan="4" HeightRequest="1" BackgroundColor="LightGray" VerticalOptions="End">

@ -1,59 +1,17 @@
using BookApp.Pages; using BookApp.Pages;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using BookApp.ViewModel;
namespace BookApp namespace BookApp
{ {
public partial class MainPage : ContentPage public partial class MainPage : ContentPage
{ {
public class ObjetTemp public MainPage(NavigationViewModel data)
{
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<ObjetTemp> MyCollections1 { get; set; }
public ObservableCollection<ObjetTemp> MyCollections2 { get; set; }
public MainPage()
{ {
InitializeComponent(); InitializeComponent();
MyCollections1 = new ObservableCollection<ObjetTemp>() BindingContext = data;
{
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<ObjetTemp>()
{
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;
} }
async void ButtonTous(object sender, EventArgs args) private async void OnSelectionChanged(object sender, SelectionChangedEventArgs e) { }
{
await Shell.Current.GoToAsync("TousPage");
}
async void ButtonAuteur(object sender, EventArgs args)
{
await Shell.Current.GoToAsync("FiltragePage");
}
} }
} }

@ -30,9 +30,12 @@ namespace BookApp
#endif #endif
builder.Services.AddSingleton<ILibraryManager, LibraryStub>(); builder.Services.AddSingleton<ILibraryManager, LibraryStub>();
builder.Services.AddSingleton<BookViewModel>(); builder.Services.AddSingleton<BookViewModel>();
builder.Services.AddSingleton<ViewModel.ViewModelManager>(); builder.Services.AddSingleton<ViewModelManager>();
builder.Services.AddSingleton<Filtrage>(); builder.Services.AddSingleton<Filtrage>();
builder.Services.AddSingleton<CollectionFiltrage>(); builder.Services.AddSingleton<CollectionFiltrage>();
builder.Services.AddSingleton<Tous>();
builder.Services.AddSingleton<MainPage>();
builder.Services.AddSingleton<NavigationViewModel>();
// transient pour recharger la data à l'execute // transient pour recharger la data à l'execute

@ -9,7 +9,7 @@ public partial class DetailBook : ContentPage
public Book BookDetail { get; set; } public Book BookDetail { get; set; }
*/ */
public DetailBook() //Book ItemBook) public DetailBook(Model.Book selectedItem) //Book ItemBook)
{ {
InitializeComponent(); InitializeComponent();

@ -1,13 +1,14 @@
using BookApp.ViewModel; using BookApp.ViewModel;
using VMWrapper;
namespace BookApp.Pages namespace BookApp.Pages
{ {
public partial class Tous : ContentPage public partial class Tous : ContentPage
{ {
public Tous() public Tous(BookViewModel data)
{ {
InitializeComponent(); InitializeComponent();
//BindingContext = new TousViewModel(); BindingContext = data;
} }
async void BackButton(object sender, EventArgs args) async void BackButton(object sender, EventArgs args)

@ -10,40 +10,8 @@ public class ViewModelManager
BookViewModel _viewModel; BookViewModel _viewModel;
public ObservableCollection<Author> Authors { get; set; } = new ObservableCollection<Author>(); public ObservableCollection<Author> Authors { get; set; } = new ObservableCollection<Author>();
/* public ObservableCollection<AuteurGroup> AuteurGroups { get; private set; } =
new ObservableCollection<AuteurGroup>();*/
public ViewModelManager(BookViewModel viewModel) public ViewModelManager(BookViewModel viewModel)
{ {
_viewModel = viewModel; _viewModel = viewModel;
//GetAuthors();
/* ObservableCollection<Auteur> 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<Book>
{
public string Name { get; private set; }
public AuteurGroup(string name, ObservableCollection<Book> books)
: base(books)
{
Name = name;
}
}*/

@ -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<ViewModelMenu> MyCollections1 { get; set; } =
new ObservableCollection<ViewModelMenu>()
{
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<ViewModelMenu> MyCollections2 { get; set; } =
new ObservableCollection<ViewModelMenu>()
{
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),
};
}
}

@ -1,10 +1,43 @@
using System; using ToolKit;
using System.Collections.Generic; using System.Windows.Input;
using System.Linq; using System.Collections.ObjectModel;
using System.Text;
using System.Threading.Tasks;
namespace BookApp.ViewModel 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");
}
}
} }

@ -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<T>(
ref T backingField,
T value,
[CallerMemberName] string propertyName = null
)
{
if (EqualityComparer<T>.Default.Equals(backingField, value))
return false;
backingField = value;
OnPropertyChanged(propertyName);
return true;
}
}
}

@ -1,4 +0,0 @@
namespace ToolKit
{
public class Class1 { }
}

@ -8,7 +8,7 @@ using System.Xml.Linq;
namespace VMWrapper namespace VMWrapper
{ {
// All the code in this file is included in all platforms. // All the code in this file is included in all platforms.
public class BookViewModel : INotifyPropertyChanged public class BookViewModel
{ {
private readonly ILibraryManager data; private readonly ILibraryManager data;
@ -66,12 +66,5 @@ namespace VMWrapper
authorList.Add(author); authorList.Add(author);
} }
} }
public event PropertyChangedEventHandler PropertyChanged;
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
} }
} }

Loading…
Cancel
Save