Début système de commentaire et de déconnexion #65

Merged
remi.lavergne merged 1 commits from remi into master 2 years ago

@ -11,5 +11,7 @@ public partial class AppShell : Shell
Routing.RegisterRoute(nameof(PageJeu), typeof(PageJeu));
Routing.RegisterRoute(nameof(PageAdmin), typeof(PageAdmin));
Routing.RegisterRoute(nameof(PageAcceuil), typeof(PageAcceuil));
}
}

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
@ -33,7 +34,7 @@ namespace GameAtlas.Models
[DataMember]
public string Image { get; private set; }
[DataMember]
public List<(string, int, string)> ListeAvis { get; private set; }
public ObservableCollection<(string,double,string)> ListeAvis { get; private set; }
[DataMember]
public int NbFavoris { get; private set; }
[DataMember]
@ -52,11 +53,16 @@ namespace GameAtlas.Models
//Revendeurs = revendeurs;
Genres = genres;
Image = image;
ListeAvis = new List<(string, int, string)>();
ListeAvis = new ObservableCollection<(string, double, string)>();
NbFavoris = 0;
NbPossedes = 0;
}
public void AjouterAvis(string pseudo, double note, string commentaire)
{
this.ListeAvis.Add((pseudo, note, commentaire));
}
public override bool Equals(object obj)
{
if (obj == null || GetType() != obj.GetType())

@ -16,7 +16,6 @@ namespace GameAtlas.Models
public List<Utilisateur> Utilisateurs { get; private set; }
private ObservableCollection<Jeu> topRatedGames;
public ObservableCollection<Jeu> TopRatedGames
{
get
@ -44,9 +43,6 @@ namespace GameAtlas.Models
OnPropertyChanged();
}
}
private ObservableCollection<Jeu> listJeux;
public ObservableCollection<Jeu> ListJeux

Binary file not shown.

After

Width:  |  Height:  |  Size: 443 B

@ -61,64 +61,64 @@ public partial class PageAdmin : ContentPage
}
break;
case 2:
sortie = await DisplayPromptAsync("Informations sur le Jeu [2/10]", "Date de Sortie", accept: "Suivant", cancel: "Annuler", placeholder: "JJ/MM/AAAA");
if (string.IsNullOrEmpty(sortie))
resume = await DisplayPromptAsync("Informations sur le Jeu [2/10]", "Résumé du jeu", accept: "Terminer", cancel: "Annuler", placeholder: "Résumé du jeu");
if (string.IsNullOrEmpty(resume))
{
annuler = true;
}
break;
case 3:
plateformes = await DisplayPromptAsync("Informations sur le Jeu [3/10]", "Plateforme(s), un espace pour séparer", accept: "Suivant", cancel: "Annuler", placeholder: "Ex: XOne PC PS5");
if (string.IsNullOrEmpty(plateformes))
sortie = await DisplayPromptAsync("Informations sur le Jeu [3/10]", "Date de Sortie", accept: "Suivant", cancel: "Annuler", placeholder: "JJ/MM/AAAA");
if (string.IsNullOrEmpty(sortie))
{
annuler = true;
}
break;
case 4:
developpeur = await DisplayPromptAsync("Informations sur le Jeu [4/10]", "Développeur", accept: "Suivant", cancel: "Annuler", placeholder: "Rockstar Games");
if (string.IsNullOrEmpty(developpeur))
plateformes = await DisplayPromptAsync("Informations sur le Jeu [4/10]", "Plateforme(s), un espace pour séparer", accept: "Suivant", cancel: "Annuler", placeholder: "Ex: XOne PC PS5");
if (string.IsNullOrEmpty(plateformes))
{
annuler = true;
}
break;
case 5:
editeur = await DisplayPromptAsync("Informations sur le Jeu [5/10]", "Editeur", accept: "Suivant", cancel: "Annuler", placeholder: "Take-Two Interactive");
if (string.IsNullOrEmpty(editeur))
developpeur = await DisplayPromptAsync("Informations sur le Jeu [5/10]", "Développeur", accept: "Suivant", cancel: "Annuler", placeholder: "Rockstar Games");
if (string.IsNullOrEmpty(developpeur))
{
annuler = true;
}
break;
case 6:
note = await DisplayPromptAsync("Informations sur le Jeu [6/10]", "Note de 0 à 5", accept: "Suivant", cancel: "Annuler", maxLength: 1, placeholder: "5");
if (string.IsNullOrEmpty(note))
editeur = await DisplayPromptAsync("Informations sur le Jeu [6/10]", "Editeur", accept: "Suivant", cancel: "Annuler", placeholder: "Take-Two Interactive");
if (string.IsNullOrEmpty(editeur))
{
annuler = true;
}
break;
case 7:
nbTelechargement = await DisplayPromptAsync("Informations sur le Jeu [7/10]", "Nombre de Téléchargements (en milliers, ex: 630k)", accept: "Suivant", cancel: "Annuler", placeholder: "630");
if (string.IsNullOrEmpty(nbTelechargement))
note = await DisplayPromptAsync("Informations sur le Jeu [7/10]", "Note de 0 à 10", accept: "Suivant", cancel: "Annuler", maxLength: 3, placeholder: "4,5");
if (string.IsNullOrEmpty(note))
{
annuler = true;
}
break;
case 8:
genre = await DisplayPromptAsync("Informations sur le Jeu [8/10]", "Genre(s), un espace pour séparer", accept: "Suivant", cancel: "Annuler", placeholder: "Action Aventure");
if (string.IsNullOrEmpty(genre))
nbTelechargement = await DisplayPromptAsync("Informations sur le Jeu [8/10]", "Nombre de Téléchargements (en milliers, ex: 630k)", accept: "Suivant", cancel: "Annuler", placeholder: "630");
if (string.IsNullOrEmpty(nbTelechargement))
{
annuler = true;
}
break;
case 9:
image = await DisplayPromptAsync("Informations sur le Jeu [9/10]", "Image de couverture (préférez URL finissant par .png)", accept: "Terminer", cancel: "Annuler", placeholder: "http://example.com/monimage.png");
if (string.IsNullOrEmpty(image))
genre = await DisplayPromptAsync("Informations sur le Jeu [9/10]", "Genre(s), un espace pour séparer", accept: "Suivant", cancel: "Annuler", placeholder: "Action Aventure");
if (string.IsNullOrEmpty(genre))
{
annuler = true;
}
break;
break;
case 10:
resume = await DisplayPromptAsync("Informations sur le Jeu [10/10]", "Résumé du jeu", accept: "Terminer", cancel: "Annuler", placeholder: "Résumé du jeu");
if (string.IsNullOrEmpty(resume))
image = await DisplayPromptAsync("Informations sur le Jeu [10/10]", "Image de couverture (préférez URL finissant par .png)", accept: "Terminer", cancel: "Annuler", placeholder: "http://example.com/monimage.png");
if (string.IsNullOrEmpty(image))
{
annuler = true;
}
@ -130,7 +130,7 @@ public partial class PageAdmin : ContentPage
if (!annuler)
{
Jeu adminJeu = new Jeu(nom, sortie, plateformes, developpeur, editeur, Convert.ToDouble(note), Convert.ToInt32(nbTelechargement), genre, image);
Jeu adminJeu = new Jeu(nom, resume, sortie, plateformes, developpeur, editeur, Convert.ToDouble(note), Convert.ToInt32(nbTelechargement), genre, image);
AdminManager.AddJeux(adminJeu);
AdminManager.SauvegardeDonnees();
AdminManager.OnPropertyChanged(nameof(AdminManager.ListJeux));

@ -149,17 +149,9 @@
<Label Text="{Binding JeuModel.Resume}" FontFamily="PTSansNRegular" FontSize="10" TextColor="{StaticResource Gray500}" VerticalOptions="Center"/>
<Button Text="+ Ajouter un commentaire" FontFamily="PTSansCBold" FontSize="13" TextColor="{StaticResource Black}" Clicked="OnAddCommentClicked"/>
<VerticalStackLayout Spacing="10" Margin="0,15,0,0">
<Button Text="+ Ajouter un commentaire" FontFamily="PTSansCBold" FontSize="13" TextColor="{StaticResource Black}" Clicked="OnAddCommentTapped"/>
<BindableLayout.ItemsSource>
<x:Array Type="{x:Type x:String}">
<x:String>XONE</x:String>
<x:String>PS5</x:String>
<x:String>PC</x:String>
<x:String>SWITCH</x:String>
</x:Array>
</BindableLayout.ItemsSource>
<BindableLayout.ItemTemplate>
<BindableLayout.ItemTemplate ItemsSource="{Binding JeuModel.ListeAvis}">
<DataTemplate>
<Frame CornerRadius="5" BackgroundColor="{StaticResource Tertiary}" Padding="15">
<Grid ColumnDefinitions="30,*" RowDefinitions="30,auto" ColumnSpacing="10" RowSpacing="10">
@ -178,14 +170,14 @@
</Frame>
<VerticalStackLayout Grid.Column="1" VerticalOptions="Center" Spacing="3">
<Label Text="Pseudonyme" FontSize="14" FontFamily="AladinRegular" TextColor="{StaticResource Black}"/>
<Label Text="{Binding Item1}" FontSize="14" FontFamily="AladinRegular" TextColor="{StaticResource Black}"/>
<HorizontalStackLayout Spacing="3">
<Image Source="starrating" HeightRequest="10" VerticalOptions="Center" Margin="0,-2,0,0"/>
<Label Text="5" FontSize="10" FontFamily="RobotoRegular" TextColor="{StaticResource Gray600}" VerticalOptions="Center"/>
<Label Text="{Binding Item2}" FontSize="10" FontFamily="RobotoRegular" TextColor="{StaticResource Gray600}" VerticalOptions="Center"/>
</HorizontalStackLayout>
</VerticalStackLayout>
<Label Grid.Row="1" Grid.ColumnSpan="2" Text="Hogwarts Legacy est un jeu de rôle d'action et d'aventure solo basé sur l'univers de Harry Potter, dans lequel le joueur incarne un nouveau venu dans le château enchanté tant apprécié des fans des livres et de la franchise cinématographique." FontFamily="PTSansNRegular" FontSize="10" TextColor="{StaticResource Gray500}" VerticalOptions="Center"/>
<Label Grid.Row="1" Grid.ColumnSpan="2" Text="{Binding Item3}" FontFamily="PTSansNRegular" FontSize="10" TextColor="{StaticResource Gray500}" VerticalOptions="Center"/>
</Grid>
</Frame>

@ -96,6 +96,21 @@ public partial class PageJeu : ContentPage
}
}
async void OnAddCommentClicked(object sender, EventArgs args)
{
if (JeuManager.ConnectedUser != null)
{
string commentaire = await DisplayPromptAsync("⭐ Votre Avis", "Ecrivez votre commentaire:\n(250 caractères maximum)", maxLength: 250, accept: "Suivant", cancel: "Annuler");
string note = await DisplayPromptAsync("✒️ La Note", "De 0 à 10", maxLength: 3, accept: "Envoyer", cancel: "Annuler");
JeuModel.AjouterAvis(JeuManager.ConnectedUser.Pseudo, Convert.ToDouble(note), commentaire);
}
else
{
Alert();
}
}
async void Back_Tapped(System.Object sender, Microsoft.Maui.Controls.TappedEventArgs e)
{
await Navigation.PopAsync();

@ -43,6 +43,12 @@
</Label>
</VerticalStackLayout>
<Image Source="logout.png">
<Image.GestureRecognizers>
<TapGestureRecognizer Tapped="OnDisconnect_Tapped"/>
</Image.GestureRecognizers>
</Image>
<Grid Grid.Row="0" Grid.Column="2" RowDefinitions="50" ColumnDefinitions="50" HorizontalOptions="Start">
<Frame IsVisible="{Binding ConnectedUser.EstAdmin}" WidthRequest="50" HeightRequest="50" CornerRadius="25" VerticalOptions="Start" IsClippedToBounds="True" BackgroundColor="{StaticResource Tertiary}">
<Image Source="shieldperson" HeightRequest="40"/>

@ -39,4 +39,10 @@ public partial class PageProfil : ContentPage
{
await Shell.Current.GoToAsync(nameof(PageAdmin));
}
async void OnDisconnect_Tapped(System.Object sender, Microsoft.Maui.Controls.TappedEventArgs e)
{
await Shell.Current.GoToAsync(nameof(PageAcceuil));
ProfilManager.ConnectedUser = null;
}
}
Loading…
Cancel
Save