diff --git a/Sources/Stim.Model/User.cs b/Sources/Stim.Model/User.cs index 272edc2..3fc12a7 100644 --- a/Sources/Stim.Model/User.cs +++ b/Sources/Stim.Model/User.cs @@ -15,7 +15,7 @@ namespace Model public string? Username { get => username; - private set + set { if (string.IsNullOrWhiteSpace(value)) username = "Default"; else diff --git a/Sources/Stim/App.xaml.cs b/Sources/Stim/App.xaml.cs index 00ab9dd..6d9c550 100644 --- a/Sources/Stim/App.xaml.cs +++ b/Sources/Stim/App.xaml.cs @@ -10,8 +10,7 @@ public partial class App : Application public App() { InitializeComponent(); - //Faut changer le boot sur LoginPage plus tard, j'ai mit create là pour pouvoir use l'appli, ce référer au comment sur create et loginpage. - MainPage = new Create(); + MainPage = new LoginPage(); if (File.Exists(Path.Combine(FileSystem.Current.AppDataDirectory, "games.xml"))) Manager = new Manager(new Persistance(FileSystem.Current.AppDataDirectory)); else Manager = new(new Stub()); } diff --git a/Sources/Stim/Create.xaml.cs b/Sources/Stim/Create.xaml.cs index 1e9e39e..093aa43 100644 --- a/Sources/Stim/Create.xaml.cs +++ b/Sources/Stim/Create.xaml.cs @@ -24,7 +24,7 @@ public partial class Create : ContentPage Application.Current.MainPage = new AppShell(); await Shell.Current.GoToAsync("//MainPage"); } - else Error.Children.Add(new Label { Text = "Mot de passe incorrect", TextColor = Colors.Red, VerticalTextAlignment = TextAlignment.Start }); + else Error.Children.Add(new Label { Text = "Mot de passe invalide, votre mot de passe doit contenir une Majuscule, une minuscule, un chiffre et faire au moins 8 caractères", TextColor = Colors.Red, VerticalTextAlignment = TextAlignment.Start }); } else Error.Children.Add(new Label { Text = "Ce nom d'utilisateur est déjà pris", TextColor = Colors.Red, VerticalTextAlignment = TextAlignment.Start }); } diff --git a/Sources/Stim/DetailledPage.xaml.cs b/Sources/Stim/DetailledPage.xaml.cs index ceae734..86faa64 100644 --- a/Sources/Stim/DetailledPage.xaml.cs +++ b/Sources/Stim/DetailledPage.xaml.cs @@ -12,8 +12,11 @@ public partial class DetailledPage : ContentPage InitializeComponent(); BindingContext = game; CurrGame= game; - avgLabel.Text = game.GetAvgRate().ToString(); - AddStars(starsContainer, game.GetAvgRate()); + if (CurrGame != null) + { + avgLabel.Text = game.GetAvgRate().ToString(); + AddStars(starsContainer, game.GetAvgRate()); + } } private void AddStars(object sender, EventArgs e) diff --git a/Sources/Stim/LoginPage.xaml.cs b/Sources/Stim/LoginPage.xaml.cs index c812304..84557dd 100644 --- a/Sources/Stim/LoginPage.xaml.cs +++ b/Sources/Stim/LoginPage.xaml.cs @@ -1,19 +1,19 @@ -//using Microsoft.UI.Xaml.Navigation; +//using Microsoft.UI.Xaml.Navigation; using Model; using static System.Runtime.InteropServices.JavaScript.JSType; namespace Stim; -public partial class LoginPage : ContentPage -{ - public LoginPage() - { - InitializeComponent(); - } - - private async void Se_connecter(object sender, EventArgs e) - { - if (!string.IsNullOrWhiteSpace(Username.Text) && !string.IsNullOrWhiteSpace(Pswd.Text)) - { +public partial class LoginPage : ContentPage +{ + public LoginPage() + { + InitializeComponent(); + } + + private async void Se_connecter(object sender, EventArgs e) + { + if (!string.IsNullOrWhiteSpace(Username.Text) && !string.IsNullOrWhiteSpace(Pswd.Text)) + { User user = ((App)App.Current).Manager.SearchUser(Username.Text); if (user != null) { @@ -21,19 +21,19 @@ public partial class LoginPage : ContentPage { ((App)App.Current).Manager.CurrentUser = user; Application.Current.MainPage = new AppShell(); - await Shell.Current.GoToAsync("//MainPage"); + await Shell.Current.GoToAsync("//MainPage"); } else Error.Children.Add(new Label { Text = "Mot de passe incorrect", TextColor = Colors.Red, VerticalTextAlignment = TextAlignment.Start }); } - else Error.Children.Add(new Label { Text = "Information incorrecte", TextColor = Colors.Red, VerticalTextAlignment = TextAlignment.Start }); + else Error.Children.Add(new Label { Text = "Information incorrecte", TextColor = Colors.Red, VerticalTextAlignment = TextAlignment.Start }); } - else Error.Children.Add(new Label { Text = "Champs vides", TextColor = Colors.Red, VerticalTextAlignment = TextAlignment.Start }); - - } - - private void Creer_un_compte(object sender, EventArgs e) + else Error.Children.Add(new Label { Text = "Champs vides", TextColor = Colors.Red, VerticalTextAlignment = TextAlignment.Start }); + + } + + private void Creer_un_compte(object sender, EventArgs e) { - Application.Current.MainPage = new Create(); - } + Application.Current.MainPage = new Create(); + } } \ No newline at end of file diff --git a/Sources/Stim/MainPage.xaml.cs b/Sources/Stim/MainPage.xaml.cs index 5263420..29cfc33 100644 --- a/Sources/Stim/MainPage.xaml.cs +++ b/Sources/Stim/MainPage.xaml.cs @@ -27,7 +27,6 @@ public partial class MainPage : ContentPage private void SearchBar_GameChanged(object sender, TextChangedEventArgs e) { - SearchBar searchBar = (SearchBar)sender; string GameText = Game.Text; string Tag1Text = Tag1.Text; string Tag2Text = Tag2.Text; @@ -47,7 +46,5 @@ public partial class MainPage : ContentPage { ((App)App.Current).Manager.ResearchedGame.Add(game); } - - } } diff --git a/Sources/Stim/ProfilPage.xaml.cs b/Sources/Stim/ProfilPage.xaml.cs index f7fcf8b..20f6dff 100644 --- a/Sources/Stim/ProfilPage.xaml.cs +++ b/Sources/Stim/ProfilPage.xaml.cs @@ -20,6 +20,6 @@ public partial class ProfilPage : ContentPage { var newName = await this.ShowPopupAsync(new EntryPopup("Username")); if (string.IsNullOrWhiteSpace(newName as string)) await this.ShowPopupAsync(new MessagePopup("Nom d'utilisateur invalide")); - else ((App)App.Current).Manager.CurrentUser.ChangeUsername(newName as string); + else ((App)App.Current).Manager.CurrentUser.Username = (newName as string); } } \ No newline at end of file