Création du popup de la Page Admin pour la création et ajout de Jeu
continuous-integration/drone/push Build is failing Details

pull/42/head
Rémi LAVERGNE 2 years ago
parent 9ef640aad6
commit b55386a49c

@ -13,26 +13,36 @@ namespace GameAtlas.Models
[DataMember]
public string Nom { get; private set; }
[DataMember]
public string Sortie { get; private set; }
[DataMember]
public List<string> 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<string> 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<string> plateformes, string developpeur, string editeur, int note, int nbTelechargement, List<string> 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;
}
}
}

@ -0,0 +1,170 @@

namespace GameAtlas.Models
{
public class Popup
{
public static Manager PopUpManager => (App.Current as App).MyManager;
public static async Task<string> CreatePopupAsync()
{
var tcs = new TaskCompletionSource<string>();
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<string> plateformesList = plateformesText.Split(' ').ToList();
// Séparer les genres par des espaces et les ajouter à une liste
List<string> 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;
}
}
}

@ -14,12 +14,6 @@ namespace GameAtlas.Stub
List<Utilisateur> ListUsers = new List<Utilisateur>();
List<Jeu> ListJeu = new List<Jeu>();
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);
}

@ -65,86 +65,37 @@
/>
<ScrollView Orientation="Horizontal" Grid.Row="4" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" HorizontalScrollBarVisibility="Never">
<Grid RowDefinitions="auto" ColumnDefinitions="*,*,auto" Padding="18" ColumnSpacing="18">
<!-- #1 -->
<ImageButton Source="cover_zelda.png" Grid.Column="0" CornerRadius="20" HeightRequest="160" WidthRequest="290"/>
<HorizontalStackLayout Grid.Column="0" Margin="25,95,0,0" Spacing="5">
<Image Style="{StaticResource Stars}"/>
<Image Style="{StaticResource Stars}"/>
<Image Style="{StaticResource Stars}"/>
<Image Style="{StaticResource Stars}"/>
<Image Style="{StaticResource Stars}"/>
</HorizontalStackLayout>
<Label Text="The Legend of Zelda: Tears of the Kingdom"
TextColor="White"
FontFamily="PTSansCaption-Bold"
FontSize="12"
Grid.Column="0"
Padding="25,110,0,0"/>
<Image Source="download.png"
HorizontalOptions="Start"
HeightRequest="20"
WidthRequest="20"
Grid.Column="0"
Margin="23,120,0,0"/>
<Label Text="250k de téléchargements"
TextColor="White"
FontFamily="PTSansCaption-Bold"
FontSize="8"
Grid.Column="0"
Padding="44,135,0,0"/>
<!-- #2 -->
<ImageButton Source="cover_hogwarts.png" Grid.Column="1" CornerRadius="20" HeightRequest="160" WidthRequest="290"/>
<HorizontalStackLayout Grid.Column="1" Margin="25,95,0,0" Spacing="5">
<Image Style="{StaticResource Stars}"/>
<Image Style="{StaticResource Stars}"/>
<Image Style="{StaticResource Stars}"/>
<Image Style="{StaticResource Stars}"/>
</HorizontalStackLayout>
<Label Text="Hogwarts Legacy : L'Héritage de Poudlard"
TextColor="White"
FontFamily="PTSansCaption-Bold"
FontSize="12"
Grid.Column="1"
Padding="25,110,0,0"/>
<Image Source="download.png"
HorizontalOptions="Start"
HeightRequest="20"
WidthRequest="20"
Grid.Column="1"
Margin="23,120,0,0"/>
<Label Text="160k de téléchargements"
TextColor="White"
FontFamily="PTSansCaption-Bold"
FontSize="8"
Grid.Column="1"
Padding="44,135,0,0"/>
<!-- #3 -->
<ImageButton Source="cover_residentevil4.png" Grid.Column="2" CornerRadius="20" HeightRequest="160" WidthRequest="290"/>
<HorizontalStackLayout Grid.Column="2" Margin="25,95,0,0" Spacing="5">
<Image Style="{StaticResource Stars}"/>
<Image Style="{StaticResource Stars}"/>
<Image Style="{StaticResource Stars}"/>
</HorizontalStackLayout>
<Label Text="Resident Evil 4"
TextColor="White"
FontFamily="PTSansCaption-Bold"
FontSize="12"
Grid.Column="2"
Padding="25,110,0,0"/>
<Image Source="download.png"
HorizontalOptions="Start"
HeightRequest="20"
WidthRequest="20"
Grid.Column="2"
Margin="23,120,0,0"/>
<Label Text="50k de téléchargements"
TextColor="White"
FontFamily="PTSansCaption-Bold"
FontSize="8"
Grid.Column="2"
Padding="44,135,0,0"/>
</Grid>
<HorizontalStackLayout BindableLayout.ItemsSource="{Binding ListJeux}">
<BindableLayout.ItemTemplate>
<DataTemplate>
<Grid>
<ImageButton Source="{Binding Image}" CornerRadius="20" HeightRequest="160" WidthRequest="290"/>
<HorizontalStackLayout Margin="25,95,0,0" Spacing="5">
<Image Style="{StaticResource Stars}"/>
<Image Style="{StaticResource Stars}"/>
<Image Style="{StaticResource Stars}"/>
<Image Style="{StaticResource Stars}"/>
<Image Style="{StaticResource Stars}"/>
</HorizontalStackLayout>
<Label Text="{Binding Nom}"
TextColor="White"
FontFamily="PTSansCaption-Bold"
FontSize="12"
Padding="25,110,0,0"/>
<Image Source="download.png"
HorizontalOptions="Start"
HeightRequest="20"
WidthRequest="20"
Margin="23,120,0,0"/>
<Label Text="{Binding NbTelechargement}"
TextColor="White"
FontFamily="PTSansCaption-Bold"
FontSize="8"
Padding="44,135,0,0"/>
</Grid>
</DataTemplate>
</BindableLayout.ItemTemplate>
</HorizontalStackLayout>
</ScrollView>
<Label

@ -10,11 +10,9 @@ public partial class PageAcceuil : ContentPage
public PageAcceuil()
{
InitializeComponent();
BindingContext = AccueilManager;
}
private async void OnProfil_Tapped(object sender, EventArgs e)
@ -24,7 +22,11 @@ public partial class PageAcceuil : ContentPage
private async void OnButtonClicked(object sender, EventArgs e)
{
await Shell.Current.Navigation.PushAsync(new PageJeu());
var selectedjeu = (sender as ImageButton)?.BindingContext as Jeu;
if (selectedjeu != null)
{
await Navigation.PushAsync(new PageJeu(selectedjeu));
}
}
}

@ -26,8 +26,8 @@
<Label Grid.Row="0" Grid.Column="1" Padding="0,20,0,0" HorizontalOptions="Center" Text="Panel Administrateur" TextColor="#B71111" FontFamily="PTSansCaption-Bold" FontSize="24"/>
<Label Grid.Row="1" Grid.Column="1" Padding="-30,20,0,0" HorizontalOptions="Start" Text="Options :" TextColor="Black" FontFamily="PTSansCaption-Bold" FontSize="24"/>
<Button Grid.Row="2" Grid.Column="1" HeightRequest="50" Text="Ajouter un Jeu" TextColor="Black" FontFamily="PTSansCaption-Bold" FontSize="14"/>
<Button Grid.Row="2" Grid.Column="1" HeightRequest="50" Text="Ajouter un Jeu" TextColor="Black" FontFamily="PTSansCaption-Bold" FontSize="14" Clicked="OnButtonClicked"/>
<Button Grid.Row="3" Grid.Column="1" HeightRequest="50" Text="Gérer un jeu" TextColor="Black" FontFamily="PTSansCaption-Bold" FontSize="14"/>

@ -1,14 +1,22 @@
using Microsoft.Maui.Controls;
using GameAtlas.Models;
namespace GameAtlas.Views;
public partial class PageAdmin : ContentPage
{
public PageAdmin()
{
InitializeComponent();
}
public PageAdmin()
{
InitializeComponent();
}
async void Back_Tapped(System.Object sender, Microsoft.Maui.Controls.TappedEventArgs e)
{
await Navigation.PopAsync();
}
private async void OnButtonClicked(object sender, EventArgs e)
{
string result = await Popup.CreatePopupAsync();
}
}

@ -63,7 +63,7 @@
<Label.FormattedText>
<FormattedString>
<Span Text="Développeur: " TextColor="{StaticResource Gray500}" />
<Span Text="Avalanche Software" TextColor="{StaticResource Black}" />
<Span Text="{Binding JeuModel.Developpeur}" TextColor="{StaticResource Black}" />
</FormattedString>
</Label.FormattedText>
</Label>
@ -71,7 +71,7 @@
<Label.FormattedText>
<FormattedString>
<Span Text="Editeur: " TextColor="{StaticResource Gray500}" />
<Span Text="Warner Bros. Games" TextColor="{StaticResource Black}" />
<Span Text="{Binding JeuModel.Developpeur}" TextColor="{StaticResource Black}" />
</FormattedString>
</Label.FormattedText>
</Label>

Loading…
Cancel
Save