From 1c06b2cef156bc45c8fb20dd9558499f9607a386 Mon Sep 17 00:00:00 2001 From: BelsethUwU Date: Fri, 9 Jun 2023 12:49:35 +0200 Subject: [PATCH] =?UTF-8?q?Pourquoi,=20pull,=20=C3=A7a=20voulait=20pas=20p?= =?UTF-8?q?ull=20=3F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Sources/Stim/ProfilPage.xaml | 39 +++++++++++++-------------- Sources/Stim/ProfilPage.xaml.cs | 32 +++++++++++++++++++--- Sources/Stim/UserInfo.xaml | 16 +++++++---- Sources/Stim/UserInfo.xaml.cs | 47 ++++++++++++++++++++++----------- 4 files changed, 90 insertions(+), 44 deletions(-) diff --git a/Sources/Stim/ProfilPage.xaml b/Sources/Stim/ProfilPage.xaml index 8ce1573..c59edb0 100644 --- a/Sources/Stim/ProfilPage.xaml +++ b/Sources/Stim/ProfilPage.xaml @@ -1,7 +1,7 @@ @@ -12,31 +12,30 @@ - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - + diff --git a/Sources/Stim/ProfilPage.xaml.cs b/Sources/Stim/ProfilPage.xaml.cs index 20f6dff..849226c 100644 --- a/Sources/Stim/ProfilPage.xaml.cs +++ b/Sources/Stim/ProfilPage.xaml.cs @@ -1,13 +1,14 @@ using CommunityToolkit.Maui.Views; using Model; +using System.Text.RegularExpressions; namespace Stim; public partial class ProfilPage : ContentPage { - public ProfilPage() - { - InitializeComponent(); + public ProfilPage() + { + InitializeComponent(); BindingContext = ((App)App.Current).Manager; } @@ -22,4 +23,29 @@ public partial class ProfilPage : ContentPage if (string.IsNullOrWhiteSpace(newName as string)) await this.ShowPopupAsync(new MessagePopup("Nom d'utilisateur invalide")); else ((App)App.Current).Manager.CurrentUser.Username = (newName as string); } + public async void PopUpUsername(object sender, EventArgs e) + { + 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.Username = (newName as string); + } + public async void PopUpBio(object sender, EventArgs e) + { + var newBio = await this.ShowPopupAsync(new EntryPopup("Biographie")); + ((App)App.Current).Manager.CurrentUser.Biographie = (newBio as string); + } + public async void PopUpPswd(object sender, EventArgs e) + { + Regex rg = new Regex("^(?=.*[A-Za-z])(?=.*[0-9@$!%*#?&])[A-Za-z-0-9@$!%*#?&]{8,}$"); + var newPswd = await this.ShowPopupAsync(new EntryPopup("Password")); + if (string.IsNullOrWhiteSpace(newPswd as string) || rg.IsMatch(newPswd as string)) await this.ShowPopupAsync(new MessagePopup("Nom d'utilisateur invalide")); + else ((App)App.Current).Manager.CurrentUser.Password = (newPswd as string); + } + public async void PopUpEmail(object sender, EventArgs e) + { + Regex rg = new Regex("^([a-zA-Z0-9_-]+[.])*[a-zA-Z0-9_-]+@([a-zA-Z0-9_-]+[.])+[a-zA-Z0-9_-]{2,4}$"); + var newMail = await this.ShowPopupAsync(new EntryPopup("Email")); + if (string.IsNullOrWhiteSpace(newMail as string) || rg.IsMatch(newMail as string)) await this.ShowPopupAsync(new MessagePopup("Email Invalide")); + else ((App)App.Current).Manager.CurrentUser.Email = (newMail as string); + } } \ No newline at end of file diff --git a/Sources/Stim/UserInfo.xaml b/Sources/Stim/UserInfo.xaml index e743a83..92c27e1 100644 --- a/Sources/Stim/UserInfo.xaml +++ b/Sources/Stim/UserInfo.xaml @@ -4,11 +4,17 @@ xmlns:local="clr-namespace:Stim" x:Class="Stim.UserInfo" x:Name="userInfoView"> - - -