Système de Connexion et Ajout de Jeu #49

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

@ -35,6 +35,11 @@
<ShellContent
Title="Profil"
Icon="account"
ContentTemplate="{DataTemplate views:PageProfil}"
Route="PageProfil" />
<ShellContent
Title="Connexion"
Icon="account"
ContentTemplate="{DataTemplate views:PageConnexion}"
Route="PageConnexion" />
</TabBar>

@ -12,8 +12,20 @@ namespace GameAtlas.Models
public List<Jeu> ListJeux { get; private set; }
public List<Admin> Admins { get; private set; }
public List<Utilisateur> Utilisateurs { get; private set; }
public IPersistanceManager Persistance { get; set; }
public Utilisateur ConnectedUser
{
get => connectedUser;
set
{
connectedUser = value;
//OnPropertyChanged();
}
}
private Utilisateur connectedUser;
public Manager(IPersistanceManager persistance)
{

@ -1,172 +0,0 @@

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,
plateformesText,
developpeur,
editeur,
note,
nbTelechargement,
//genresList,
genresText,
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;
}
}
}

@ -17,6 +17,14 @@ public partial class PageAdmin : ContentPage
private async void OnButtonClicked(object sender, EventArgs e)
{
string result = await Popup.CreatePopupAsync();
string nom = await DisplayPromptAsync("Informations sur le Jeu", "Quel est le Titre ?", placeholder: "GTA VI");
string sortie = await DisplayPromptAsync("Informations sur le Jeu", "Date de Sortie", placeholder: "JJ/MM/AAAA");
string plateformes = await DisplayPromptAsync("Informations sur le Jeu", "Plateforme(s), un espace pour séparer", placeholder: "Ex: XOne PC PS5");
string developpeur = await DisplayPromptAsync("Informations sur le Jeu", "Développeur", placeholder: "Rockstar Games");
string editeur = await DisplayPromptAsync("Informations sur le Jeu", "Editeur", placeholder: "Take-Two Interactive");
string note = await DisplayPromptAsync("Informations sur le Jeu", "Note de 0 à 5", maxLength: 1, keyboard:Keyboard.Numeric, placeholder: "5");
string nbtelechargement = await DisplayPromptAsync("Informations sur le Jeu", "Nombre de Téléchargements (en milliers, ex: 630k)", keyboard: Keyboard.Numeric, placeholder: "630");
string genre = await DisplayPromptAsync("Informations sur le Jeu", "Genre(s), un espace pour séparer", placeholder: "Action Aventure");
string image = await DisplayPromptAsync("Informations sur le Jeu", "Image de couverture (préférez URL finissant par .png)", placeholder: "Take-Two Interactive");
}
}

@ -45,15 +45,21 @@
Text="Mot de Passe oublié"
TextColor="#7392FF"
FontSize="13"
FontFamily="PTSansNRegular"
/>
FontFamily="PTSansNRegular">
<Label.GestureRecognizers>
<TapGestureRecognizer Tapped="OnMotDePasseOublie_Tapped" />
</Label.GestureRecognizers>
</Label>
<Label
Text="S'inscrire >"
TextColor="#7392FF"
FontSize="13"
FontFamily="PTSansNBold"
/>
FontFamily="PTSansNBold">
<Label.GestureRecognizers>
<TapGestureRecognizer Tapped="OnInscrire_Tapped" />
</Label.GestureRecognizers>
</Label>
</HorizontalStackLayout>

@ -1,8 +1,14 @@
namespace GameAtlas.Views;
using GameAtlas.Models;
using System.Diagnostics;
using System.Text.RegularExpressions;
public partial class PageConnexion : ContentPage
{
public int compteur { get; set; } = 0;
public Manager ConnexionManager => (App.Current as App).MyManager;
public PageConnexion()
{
InitializeComponent();
@ -21,7 +27,49 @@ public partial class PageConnexion : ContentPage
return;
}
Verification(username, password);
await Navigation.PushAsync(new PageAcceuil());
}
private async void OnInscrire_Tapped(object sender, EventArgs e)
{
await Navigation.PushAsync(new PageInscription());
}
private async void OnMotDePasseOublie_Tapped(object sender, EventArgs e)
{
await DisplayAlert("Oh non !", "Le mot de passe va te revenir à force", "Concentration");
await DisplayAlert("Oh non !", "Encore un petit effort !", "Concentration");
bool reponse = await DisplayAlert("Alors ?", "Tu l'as retrouvé ce mot de passe ?", "Oui", "Non");
if (!reponse)
{
await DisplayAlert("...", "Désolé on peut rien pour toi. La prochaine fois utilise un papier comme tout le monde.", "RIP");
}
else
{
await DisplayAlert("...", "C'est bien, la prochaine fois tu le notera.", "Ok");
}
}
public bool Verification(string username, string password)
{
foreach (Utilisateur user in ConnexionManager.Utilisateurs)
{
if (user.Pseudo == username)
{
Debug.WriteLine($"Pseudo \"{user.Pseudo}\" vérifié et valide");
if (user.Mdp == password)
{
Debug.WriteLine("Mot de Passe verifié et valide");
ConnexionManager.ConnectedUser = user;
return true;
}
}
}
Debug.WriteLine("La connection a echouée (pseudo ou mot de passe invalide)");
ConnexionManager.ConnectedUser = null;
return false;
}
}

@ -33,7 +33,10 @@ public partial class PageJeu : ContentPage
string action = await DisplayActionSheet("Choix de la liste:", "Annuler", null, "Mes Favoris", "Jeux Possédés", "Ma Wishlist");
Debug.WriteLine("Popup Action: " + action);
//if (action == "")
if (action == "Mes Favoris")
{
JeuManager.ConnectedUser.ListeFavoris.Add(JeuModel);
}
}

@ -32,7 +32,7 @@
</Grid>
<VerticalStackLayout Grid.Column="1" VerticalOptions="Center" Spacing="3">
<Label Text="Pseudonyme" FontSize="20" FontFamily="AladinRegular" TextColor="{StaticResource Black}"/>
<Label Text="{Binding ConnectedUser.Pseudo}" FontSize="20" FontFamily="AladinRegular" TextColor="{StaticResource Black}"/>
<Label Text="Compte créé le 13/01/2023" FontSize="12" FontFamily="RobotoRegular" TextColor="{StaticResource Black}"/>
</VerticalStackLayout>
@ -66,7 +66,7 @@
<Label Text="Liste de profil" FontFamily="PTSansCBold" FontSize="24" TextColor="{StaticResource Black}" HorizontalOptions="Center"/>
<Grid>
<CollectionView ItemsSource="{Binding ListeFavoris}" Margin="0,10,0,0" VerticalScrollBarVisibility="Never">
<CollectionView ItemsSource="{Binding ConnectedUser.ListeFavoris}" Margin="0,10,0,0" VerticalScrollBarVisibility="Never">
<CollectionView.ItemTemplate>
<DataTemplate>
<Border HeightRequest="97.5" StrokeShape="RoundRectangle 5" VerticalOptions="Start" HorizontalOptions="Center">

Loading…
Cancel
Save