From b55386a49c54c9644937eca83e817e6254e0b3d3 Mon Sep 17 00:00:00 2001 From: relavergne Date: Tue, 23 May 2023 22:44:43 +0200 Subject: [PATCH] =?UTF-8?q?Cr=C3=A9ation=20du=20popup=20de=20la=20Page=20A?= =?UTF-8?q?dmin=20pour=20la=20cr=C3=A9ation=20et=20ajout=20de=20Jeu?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- GameAtlas/GameAtlas/Models/Jeu.cs | 26 ++- GameAtlas/GameAtlas/Models/Popup.cs | 170 ++++++++++++++++++ GameAtlas/GameAtlas/Stub/Stub.cs | 6 - GameAtlas/GameAtlas/Views/PageAccueil.xaml | 111 ++++-------- GameAtlas/GameAtlas/Views/PageAccueil.xaml.cs | 8 +- GameAtlas/GameAtlas/Views/PageAdmin.xaml | 4 +- GameAtlas/GameAtlas/Views/PageAdmin.xaml.cs | 16 +- GameAtlas/GameAtlas/Views/PageJeu.xaml | 4 +- 8 files changed, 240 insertions(+), 105 deletions(-) create mode 100644 GameAtlas/GameAtlas/Models/Popup.cs diff --git a/GameAtlas/GameAtlas/Models/Jeu.cs b/GameAtlas/GameAtlas/Models/Jeu.cs index 886cf1d..642b4b4 100644 --- a/GameAtlas/GameAtlas/Models/Jeu.cs +++ b/GameAtlas/GameAtlas/Models/Jeu.cs @@ -13,26 +13,36 @@ namespace GameAtlas.Models [DataMember] public string Nom { get; private set; } [DataMember] + public string Sortie { get; private set; } + [DataMember] + public List Plateformes { get; private set; } + [DataMember] + public string Developpeur { get; private set; } + [DataMember] + public string Editeur { get; private set; } + [DataMember] public int Note { get; private set; } [DataMember] public int NbTelechargement { get; private set; } + //[DataMember] + //public List<(string,string)> Revendeurs { get; private set; } [DataMember] - public string Plateforme { get; private set; } - [DataMember] - public string Genre { get; private set; } + public List Genres { get; private set; } [DataMember] public string Image { get; private set; } - public Jeu(string nom, int note, int nbTelechargement, string plateforme, string genre, string image) + public Jeu(string nom, string sortie, List plateformes, string developpeur, string editeur, int note, int nbTelechargement, List genres, string image) { Nom = nom; + Sortie = sortie; + Plateformes = plateformes; + Developpeur = developpeur; + Editeur = editeur; Note = note; NbTelechargement = nbTelechargement; - Plateforme = plateforme; - Genre = genre; + //Revendeurs = revendeurs; + Genres = genres; Image = image; } - - } } diff --git a/GameAtlas/GameAtlas/Models/Popup.cs b/GameAtlas/GameAtlas/Models/Popup.cs new file mode 100644 index 0000000..b266c84 --- /dev/null +++ b/GameAtlas/GameAtlas/Models/Popup.cs @@ -0,0 +1,170 @@ + + +namespace GameAtlas.Models +{ + public class Popup + { + public static Manager PopUpManager => (App.Current as App).MyManager; + + public static async Task CreatePopupAsync() + { + var tcs = new TaskCompletionSource(); + + var popupPage = new ContentPage(); + popupPage.BackgroundColor = Color.FromRgba(255, 255, 255, 0); + var popupLayout = new StackLayout + { + Padding = new Thickness(20), + BackgroundColor = Color.FromRgba(255, 255, 255, 255) + }; + + var titleLabel = new Label + { + Text = "Informations sur le Jeu", + FontSize = 18, + FontAttributes = FontAttributes.Bold, + HorizontalOptions = LayoutOptions.Center + }; + + popupLayout.Children.Add(titleLabel); + + var nomLabel = new Label + { + Text = "Nom :" + }; + + var nomEntry = new Entry(); + popupLayout.Children.Add(nomLabel); + popupLayout.Children.Add(nomEntry); + + var sortieLabel = new Label + { + Text = "Date de Sortie :" + }; + + var sortieDatePicker = new DatePicker(); + popupLayout.Children.Add(sortieLabel); + popupLayout.Children.Add(sortieDatePicker); + + var plateformesLabel = new Label + { + Text = "Plateformes :" + }; + + var plateformesEntry = new Entry(); + popupLayout.Children.Add(plateformesLabel); + popupLayout.Children.Add(plateformesEntry); + + + var developpeurLabel = new Label + { + Text = "Développeur :" + }; + + var developpeurEntry = new Entry(); + popupLayout.Children.Add(developpeurLabel); + popupLayout.Children.Add(developpeurEntry); + + var editeurLabel = new Label + { + Text = "Éditeur :" + }; + + var editeurEntry = new Entry(); + popupLayout.Children.Add(editeurLabel); + popupLayout.Children.Add(editeurEntry); + + var noteLabel = new Label + { + Text = "Note :" + }; + + var noteEntry = new Entry(); + popupLayout.Children.Add(noteLabel); + popupLayout.Children.Add(noteEntry); + + var nbTelechargementLabel = new Label + { + Text = "Nombre de téléchargements :" + }; + + var nbTelechargementEntry = new Entry(); + popupLayout.Children.Add(nbTelechargementLabel); + popupLayout.Children.Add(nbTelechargementEntry); + + var genresLabel = new Label + { + Text = "Genres :" + }; + + var genresEntry = new Entry(); + popupLayout.Children.Add(genresLabel); + popupLayout.Children.Add(genresEntry); + + var imageLabel = new Label + { + Text = "Image :" + }; + + var imageEntry = new Entry(); + popupLayout.Children.Add(imageLabel); + popupLayout.Children.Add(imageEntry); + + var saveButton = new Button + { + Text = "Enregistrer", + HorizontalOptions = LayoutOptions.Center, + Margin = new Thickness(0, 20, 0, 0) + }; + + saveButton.Clicked += (sender, args) => + { + // Récupérer les valeurs des champs + string nom = nomEntry.Text; + DateTime sortie = sortieDatePicker.Date; + string sortieString = sortie.ToString("dd/MM/yyyy"); + string plateformesText = plateformesEntry.Text; + string developpeur = developpeurEntry.Text; + string editeur = editeurEntry.Text; + int note = int.Parse(noteEntry.Text); + int nbTelechargement = int.Parse(nbTelechargementEntry.Text); + string genresText = genresEntry.Text; + string image = imageEntry.Text; + + // Séparer les plateformes par des espaces et les ajouter à une liste + List plateformesList = plateformesText.Split(' ').ToList(); + + // Séparer les genres par des espaces et les ajouter à une liste + List genresList = genresText.Split(' ').ToList(); + + Jeu jeu = new Jeu + ( + nom, + sortieString, + plateformesList, + developpeur, + editeur, + note, + nbTelechargement, + genresList, + image + ); + + Popup.PopUpManager.AddJeux(jeu); + Popup.PopUpManager.SauvegardeDonnees(); + + // Fermer la popup et retourner les valeurs + Application.Current.MainPage.Navigation.PopModalAsync(); + tcs.SetResult(""); + }; + + popupLayout.Children.Add(saveButton); + + popupPage.Content = popupLayout; + + await Application.Current.MainPage.Navigation.PushModalAsync(popupPage); + + return await tcs.Task; + } + } +} diff --git a/GameAtlas/GameAtlas/Stub/Stub.cs b/GameAtlas/GameAtlas/Stub/Stub.cs index f8425f3..7c2b7aa 100644 --- a/GameAtlas/GameAtlas/Stub/Stub.cs +++ b/GameAtlas/GameAtlas/Stub/Stub.cs @@ -14,12 +14,6 @@ namespace GameAtlas.Stub List ListUsers = new List(); List ListJeu = new List(); Utilisateur user1 = new Utilisateur("test@gmail.com", "test", "Test1234"); - Jeu TheLastOfUs = new Jeu("The last of Us Part 1", 5, 487, "Ps5", "Aventure", "cover_lastofus1.png"); - Jeu ForzaHorizon = new Jeu("Forza Horizon 5", 4, 420, "Ps4", "Course", "cover_forzahorizon5.png"); - Jeu Test = new Jeu("The Legend of Zelda: Tears of the Kingdom", 5, 250, "Ps4", "Aventure", "cover_zelda.png"); - ListJeu.Add(TheLastOfUs); - ListJeu.Add(ForzaHorizon); - ListJeu.Add(Test); ListUsers.Add(user1); return (ListJeu,ListUsers); } diff --git a/GameAtlas/GameAtlas/Views/PageAccueil.xaml b/GameAtlas/GameAtlas/Views/PageAccueil.xaml index deba581..73cb92f 100644 --- a/GameAtlas/GameAtlas/Views/PageAccueil.xaml +++ b/GameAtlas/GameAtlas/Views/PageAccueil.xaml @@ -65,86 +65,37 @@ /> - - - - - - - - - - - + + + + + + + + + + + + + + + +