gestion des information utilisateurs

pull/37/head
Vianney JOURDY 2 years ago
parent 4108d6cfad
commit 3451f220f8

@ -61,6 +61,7 @@
<None Remove="Resources\Images\account_circle.png" /> <None Remove="Resources\Images\account_circle.png" />
<None Remove="Resources\Images\Evangelion.jpg" /> <None Remove="Resources\Images\Evangelion.jpg" />
<None Remove="Resources\Images\logo.png" /> <None Remove="Resources\Images\logo.png" />
<None Remove="Resources\Images\OK.png" />
<None Remove="Resources\Images\settings.png" /> <None Remove="Resources\Images\settings.png" />
</ItemGroup> </ItemGroup>

@ -25,6 +25,10 @@ namespace MangaMap.Model
public ObservableCollection<Oeuvre> ListeOeuvrePourPlusTard { get; set; } public ObservableCollection<Oeuvre> ListeOeuvrePourPlusTard { get; set; }
[DataMember] [DataMember]
public ObservableCollection<Oeuvre> ListeOeuvreFavorites { get; set; } public ObservableCollection<Oeuvre> ListeOeuvreFavorites { get; set; }
[DataMember]
public Dictionary<string,int> notesOeuvres { get; set; }
[DataMember]
public Dictionary<string,int> episodesVus { get; set; }
public Utilisateur(string email, string pseudo, string mdp, string nom, string prenom, int age) public Utilisateur(string email, string pseudo, string mdp, string nom, string prenom, int age)
{ {
@ -39,6 +43,8 @@ namespace MangaMap.Model
ListeOeuvreDejaVu = new ObservableCollection<Oeuvre>(); ListeOeuvreDejaVu = new ObservableCollection<Oeuvre>();
ListeOeuvrePourPlusTard = new ObservableCollection<Oeuvre>(); ListeOeuvrePourPlusTard = new ObservableCollection<Oeuvre>();
ListeOeuvreFavorites = new ObservableCollection<Oeuvre>(); ListeOeuvreFavorites = new ObservableCollection<Oeuvre>();
notesOeuvres = new Dictionary<string, int>();
episodesVus = new Dictionary<string, int>();
} }
public Utilisateur() { public Utilisateur() {
@ -46,6 +52,8 @@ namespace MangaMap.Model
ListeOeuvreDejaVu = new ObservableCollection<Oeuvre>(); ListeOeuvreDejaVu = new ObservableCollection<Oeuvre>();
ListeOeuvrePourPlusTard = new ObservableCollection<Oeuvre>(); ListeOeuvrePourPlusTard = new ObservableCollection<Oeuvre>();
ListeOeuvreFavorites = new ObservableCollection<Oeuvre>(); ListeOeuvreFavorites = new ObservableCollection<Oeuvre>();
notesOeuvres = new Dictionary<string, int>();
episodesVus = new Dictionary<string, int>();
} }
public void SupprimerUtilisateur() public void SupprimerUtilisateur()

Binary file not shown.

After

Width:  |  Height:  |  Size: 572 B

@ -15,7 +15,7 @@
<RowDefinition Height="*" /> <RowDefinition Height="*" />
</Grid.RowDefinitions> </Grid.RowDefinitions>
<Grid Margin="20" Grid.Row="0" ColumnDefinitions="*,400,300"> <Grid Margin="20" Grid.Row="0" ColumnDefinitions="*,300,300">
<Label Grid.Column="0" <Label Grid.Column="0"
Text="Titre" FontSize="Large" TextColor="White" Text="Titre" FontSize="Large" TextColor="White"
HorizontalOptions="Start" VerticalOptions="Center"/> HorizontalOptions="Start" VerticalOptions="Center"/>
@ -31,10 +31,10 @@
<VerticalStackLayout BindableLayout.ItemsSource="{Binding UtilisateurActuel.ListeOeuvreEnVisionnage}" Spacing="10"> <VerticalStackLayout BindableLayout.ItemsSource="{Binding UtilisateurActuel.ListeOeuvreEnVisionnage}" Spacing="10">
<BindableLayout.ItemTemplate> <BindableLayout.ItemTemplate>
<DataTemplate> <DataTemplate>
<Grid Margin="20,0,20,20" ColumnDefinitions="*,*,300,300,40"> <Grid Margin="20,0,20,20" ColumnDefinitions="*,*,300,300">
<ImageButton Grid.Column="0" Source="{Binding Affiche}" Style="{StaticResource ImageAnime}" HorizontalOptions="Start" Clicked="AnimeImageClickedList"/> <ImageButton Grid.Column="0" Source="{Binding Affiche}" Style="{StaticResource ImageAnime}" HorizontalOptions="Start" Clicked="AnimeImageClickedList"/>
<Label Grid.Column="1" Text="{Binding Nom}" TextColor="White" FontSize="Medium" VerticalOptions="Center" Margin="15"/> <Label Grid.Column="1" Text="{Binding Nom}" TextColor="White" FontSize="Medium" VerticalOptions="Center" Margin="15"/>
<Label Grid.Column="2" Text="{Binding Note}" TextColor="White" FontSize="Medium" VerticalOptions="Center" HorizontalOptions="Center"/> <Label Grid.Column="2" Text="{Binding Note, StringFormat='{0}/5'}" TextColor="White" FontSize="Medium" VerticalOptions="Center" HorizontalOptions="Center"/>
<Label Grid.Column="3" Text="{Binding NbEpisodes}" TextColor="White" FontSize="Medium" VerticalOptions="Center" HorizontalOptions="End"/> <Label Grid.Column="3" Text="{Binding NbEpisodes}" TextColor="White" FontSize="Medium" VerticalOptions="Center" HorizontalOptions="End"/>
</Grid> </Grid>
</DataTemplate> </DataTemplate>
@ -73,7 +73,7 @@
<Grid Margin="20,0,20,20" ColumnDefinitions="*,*,300,300"> <Grid Margin="20,0,20,20" ColumnDefinitions="*,*,300,300">
<ImageButton Grid.Column="0" Source="{Binding Affiche}" Style="{StaticResource ImageAnime}" HorizontalOptions="Start" Clicked="AnimeImageClickedList"/> <ImageButton Grid.Column="0" Source="{Binding Affiche}" Style="{StaticResource ImageAnime}" HorizontalOptions="Start" Clicked="AnimeImageClickedList"/>
<Label Grid.Column="1" Text="{Binding Nom}" TextColor="White" FontSize="Medium" VerticalOptions="Center" Margin="15"/> <Label Grid.Column="1" Text="{Binding Nom}" TextColor="White" FontSize="Medium" VerticalOptions="Center" Margin="15"/>
<Label Grid.Column="2" Text="4/5" TextColor="White" FontSize="Medium" VerticalOptions="Center" HorizontalOptions="Center"/> <Label Grid.Column="2" Text="{Binding Note, StringFormat='{0}/5'}" TextColor="White" FontSize="Medium" VerticalOptions="Center" HorizontalOptions="Center"/>
<Label Grid.Column="3" Text="{Binding NbEpisodes}" TextColor="White" FontSize="Medium" VerticalOptions="Center" HorizontalOptions="End"/> <Label Grid.Column="3" Text="{Binding NbEpisodes}" TextColor="White" FontSize="Medium" VerticalOptions="Center" HorizontalOptions="End"/>
</Grid> </Grid>
</DataTemplate> </DataTemplate>
@ -112,7 +112,7 @@
<Grid Margin="20,0,20,20" ColumnDefinitions="*,*,300,300"> <Grid Margin="20,0,20,20" ColumnDefinitions="*,*,300,300">
<ImageButton Grid.Column="0" Source="{Binding Affiche}" Style="{StaticResource ImageAnime}" HorizontalOptions="Start" Clicked="AnimeImageClickedList"/> <ImageButton Grid.Column="0" Source="{Binding Affiche}" Style="{StaticResource ImageAnime}" HorizontalOptions="Start" Clicked="AnimeImageClickedList"/>
<Label Grid.Column="1" Text="{Binding Nom}" TextColor="White" FontSize="Medium" VerticalOptions="Center" Margin="15"/> <Label Grid.Column="1" Text="{Binding Nom}" TextColor="White" FontSize="Medium" VerticalOptions="Center" Margin="15"/>
<Label Grid.Column="2" Text="4/5" TextColor="White" FontSize="Medium" VerticalOptions="Center" HorizontalOptions="Center"/> <Label Grid.Column="2" Text="{Binding Note, StringFormat='{0}/5'}" TextColor="White" FontSize="Medium" VerticalOptions="Center" HorizontalOptions="Center"/>
<Label Grid.Column="3" Text="{Binding NbEpisodes}" TextColor="White" FontSize="Medium" VerticalOptions="Center" HorizontalOptions="End"/> <Label Grid.Column="3" Text="{Binding NbEpisodes}" TextColor="White" FontSize="Medium" VerticalOptions="Center" HorizontalOptions="End"/>
</Grid> </Grid>
</DataTemplate> </DataTemplate>
@ -151,8 +151,8 @@
<Grid Margin="20,0,20,20" ColumnDefinitions="*,*,300,300"> <Grid Margin="20,0,20,20" ColumnDefinitions="*,*,300,300">
<ImageButton Grid.Column="0" Source="{Binding Affiche}" Style="{StaticResource ImageAnime}" HorizontalOptions="Start" Clicked="AnimeImageClickedList"/> <ImageButton Grid.Column="0" Source="{Binding Affiche}" Style="{StaticResource ImageAnime}" HorizontalOptions="Start" Clicked="AnimeImageClickedList"/>
<Label Grid.Column="1" Text="{Binding Nom}" TextColor="White" FontSize="Medium" VerticalOptions="Center" Margin="15"/> <Label Grid.Column="1" Text="{Binding Nom}" TextColor="White" FontSize="Medium" VerticalOptions="Center" Margin="15"/>
<Label Grid.Column="2" Text="4/5" TextColor="White" FontSize="Medium" VerticalOptions="Center" HorizontalOptions="Center"/> <Label Grid.Column="2" Text="{Binding Note, StringFormat='{0}/5'}" TextColor="White" FontSize="Medium" VerticalOptions="Center" HorizontalOptions="Center"/>
<Label Grid.Column="2" Text="{Binding NbEpisodesVus}" TextColor="White" FontSize="Medium" VerticalOptions="Center" HorizontalOptions="End"/> <Label Grid.Column="3" Text="{Binding NbEpisodes}" TextColor="White" FontSize="Medium" VerticalOptions="Center" HorizontalOptions="End"/>
</Grid> </Grid>
</DataTemplate> </DataTemplate>
</BindableLayout.ItemTemplate> </BindableLayout.ItemTemplate>

@ -3,9 +3,6 @@ namespace MangaMap.Views;
using Model; using Model;
using System.ComponentModel; using System.ComponentModel;
using System.Diagnostics; using System.Diagnostics;
using System.Drawing;
using System.Windows.Input;
using System.Xml.Linq;
public partial class ficheAnime : ContentPage, INotifyPropertyChanged public partial class ficheAnime : ContentPage, INotifyPropertyChanged
@ -83,10 +80,29 @@ public partial class ficheAnime : ContentPage, INotifyPropertyChanged
private void SetNote() private void SetNote()
{ {
stars.Children.Clear(); stars.Children.Clear();
bool test = my_manager.UtilisateurActuel.notesOeuvres.ContainsKey(AnimeModel.Nom);
int x;
for (int i = 0; i < 5; i++) for (int i = 0; i < 5; i++)
{ {
if (i < AnimeModel.Note) if (my_manager.UtilisateurActuel.notesOeuvres.TryGetValue(AnimeModel.Nom,out x) && i<x)
{
ImageButton imageButton = new ImageButton
{
Source = "star_full.png",
WidthRequest = 50,
HeightRequest = 50,
AutomationId = i.ToString(),
Margin = 10,
};
imageButton.Clicked += StarClicked;
Grid.SetRow(imageButton, 0);
Grid.SetColumn(imageButton, i);
stars.Children.Add(imageButton);
}
else if (!test && i < AnimeModel.Note)
{ {
ImageButton imageButton = new ImageButton ImageButton imageButton = new ImageButton
{ {
@ -125,14 +141,39 @@ public partial class ficheAnime : ContentPage, INotifyPropertyChanged
private async void StarClicked(object sender, EventArgs e) private async void StarClicked(object sender, EventArgs e)
{ {
if (my_manager.UtilisateurActuel.Email == null)
{
await DisplayAlert("Erreur", "Vous n'êtes pas connecté.", "OK");
return;
}
var button = (ImageButton)sender; var button = (ImageButton)sender;
var idAutomation = button.AutomationId; var idAutomation = button.AutomationId;
if (int.TryParse(idAutomation, out int id)) if (int.TryParse(idAutomation, out int id))
{ {
AnimeModel.Note = id+1; if (my_manager.UtilisateurActuel.notesOeuvres.ContainsKey(AnimeModel.Nom))
my_manager.UtilisateurActuel.notesOeuvres.Remove(AnimeModel.Nom);
my_manager.UtilisateurActuel.notesOeuvres.Add(AnimeModel.Nom, id+1);
my_manager.sauvegarder(); my_manager.sauvegarder();
SetNote(); SetNote();
} }
} }
private async void NbEpCheck(object sender, EventArgs e)
{
if (my_manager.UtilisateurActuel.Email == null)
{
await DisplayAlert("Erreur", "Vous n'êtes pas connecté.", "OK");
return;
}
int nb = Convert.ToInt32(nombreEP.Text);
if (my_manager.UtilisateurActuel.episodesVus.ContainsKey(AnimeModel.Nom))
my_manager.UtilisateurActuel.episodesVus.Remove(AnimeModel.Nom);
my_manager.UtilisateurActuel.episodesVus.Add(AnimeModel.Nom, nb);
}
} }

@ -26,16 +26,21 @@
<Label Text="{Binding AnimeModel.Genre}" BackgroundColor="{StaticResource Primary}" TextColor="White" Margin="0,0,0,30"/> <Label Text="{Binding AnimeModel.Genre}" BackgroundColor="{StaticResource Primary}" TextColor="White" Margin="0,0,0,30"/>
<Grid x:Name="stars" ColumnDefinitions="80,80,80,80,80"> <Grid x:Name="stars" ColumnDefinitions="80,80,80,80,80"/>
</Grid>
<Button Text="Ajouter à la liste" <HorizontalStackLayout>
<Button Text="Ajouter à la liste"
TextColor="#FFFFFF" TextColor="#FFFFFF"
HorizontalOptions="Start" HorizontalOptions="Start"
Margin="20" Margin="20"
BackgroundColor="{StaticResource Primary}" BackgroundColor="{StaticResource Primary}"
Clicked="AjouterListe"/> Clicked="AjouterListe"/>
<Entry x:Name="nombreEP" Placeholder="Nombre d'épisodes vues" Margin="10,10,10,10" HeightRequest="20" WidthRequest="180" Style="{StaticResource Champs}"/>
<Label Text="{Binding AnimeModel.NbEpisodes, StringFormat='/ {0}'}" FontSize="Medium" VerticalOptions="Center"/>
<ImageButton Source="ok.png" Margin="20,0,0,0" HeightRequest="20" Clicked="NbEpCheck"/>
</HorizontalStackLayout>
<Label Text="{Binding AnimeModel.Type}" FontSize="Large" TextColor="White"/> <Label Text="{Binding AnimeModel.Type}" FontSize="Large" TextColor="White"/>
<Label Text="{Binding AnimeModel.Description}"/> <Label Text="{Binding AnimeModel.Description}"/>

@ -66,5 +66,4 @@ public partial class homePage : ContentPage
indice++; indice++;
} }
} }
} }

Loading…
Cancel
Save