diff --git a/Sources/Stim.Model/User.cs b/Sources/Stim.Model/User.cs
index 553e3f8..00e35d7 100644
--- a/Sources/Stim.Model/User.cs
+++ b/Sources/Stim.Model/User.cs
@@ -46,7 +46,7 @@ namespace Model
get => email;
set
{
- Regex rg_email = new Regex("^[\\w-\\.]+@([\\w-]+\\.)+[\\w-]{2,4}$");
+ Regex rg_email = new Regex("^([a-zA-Z0-9_-]+[.])*[a-zA-Z0-9_-]+@([a-zA-Z0-9_-]+[.])+[a-zA-Z0-9_-]{2,4}$");
if (!(string.IsNullOrWhiteSpace(value)) && rg_email.IsMatch(value))
{
email = value;
diff --git a/Sources/Stim/Create.xaml.cs b/Sources/Stim/Create.xaml.cs
index b317763..2ca4b5d 100644
--- a/Sources/Stim/Create.xaml.cs
+++ b/Sources/Stim/Create.xaml.cs
@@ -16,7 +16,7 @@ public partial class Create : ContentPage
{
if (((App)App.Current).Manager.SearchUser(Username.Text) == null)
{
- Regex rg = new Regex("^[\\w-\\.]+@([\\w-]+\\.)+[\\w-]{2,4}$");
+ Regex rg = new Regex("^([a-zA-Z0-9_-]+[.])*[a-zA-Z0-9_-]+@([a-zA-Z0-9_-]+[.])+[a-zA-Z0-9_-]{2,4}$");
if (rg.IsMatch(Email.Text))
{
rg = new Regex("^(?=.*[A-Za-z])(?=.*[0-9@$!%*#?&])[A-Za-z-0-9@$!%*#?&]{8,}$");
diff --git a/Sources/Stim/LoginPage.xaml b/Sources/Stim/LoginPage.xaml
index c3be651..6732ae0 100644
--- a/Sources/Stim/LoginPage.xaml
+++ b/Sources/Stim/LoginPage.xaml
@@ -1,69 +1,71 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Sources/Stim/ProfilPage.xaml b/Sources/Stim/ProfilPage.xaml
index b31c263..ca0e432 100644
--- a/Sources/Stim/ProfilPage.xaml
+++ b/Sources/Stim/ProfilPage.xaml
@@ -31,20 +31,10 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
diff --git a/Sources/Stim/ProfilPage.xaml.cs b/Sources/Stim/ProfilPage.xaml.cs
index e972262..1b26846 100644
--- a/Sources/Stim/ProfilPage.xaml.cs
+++ b/Sources/Stim/ProfilPage.xaml.cs
@@ -1,11 +1,11 @@
using CommunityToolkit.Maui.Views;
using Model;
+using System.Text.RegularExpressions;
namespace Stim;
public partial class ProfilPage : ContentPage
{
- delegate string delegatePopUp();
public ProfilPage()
{
InitializeComponent();
@@ -23,8 +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);
}
- void PopUp(object sender, EventArgs e)
+ public async void PopUpUsername(object sender, EventArgs e)
{
- //handle method here
+ 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 1611420..2349dba 100644
--- a/Sources/Stim/UserInfo.xaml
+++ b/Sources/Stim/UserInfo.xaml
@@ -9,10 +9,10 @@
-
-
+
+
-
diff --git a/Sources/Stim/UserInfo.xaml.cs b/Sources/Stim/UserInfo.xaml.cs
index 49cf6e0..93e01c1 100644
--- a/Sources/Stim/UserInfo.xaml.cs
+++ b/Sources/Stim/UserInfo.xaml.cs
@@ -4,10 +4,24 @@ using CommunityToolkit.Maui.Views;
namespace Stim;
public partial class UserInfo : ContentView
{
- public event EventHandler popUp;
- public void PopUp(object sender, EventArgs e)
+ public bool IsPswd
{
- popUp?.Invoke(sender, e);
+ get => (bool)GetValue(IsPswdProperty);
+ set => SetValue(IsPswdProperty, value);
+ }
+ public static readonly BindableProperty IsPswdProperty =
+ BindableProperty.Create(nameof(Name), typeof(bool), typeof(UserInfo), false);
+ public int LabelHeight
+ {
+ get => (int)GetValue(LabelHeightProperty);
+ set => SetValue(LabelHeightProperty, value);
+ }
+ public static readonly BindableProperty LabelHeightProperty =
+ BindableProperty.Create(nameof(Name), typeof(int), typeof(UserInfo), 32);
+ public event EventHandler PopUp;
+ public void popUp(object sender, EventArgs e)
+ {
+ PopUp?.Invoke(sender, e);
}
public string Name
{
@@ -28,42 +42,10 @@ public partial class UserInfo : ContentView
public UserInfo()
{
InitializeComponent();
- }
-
- private async void Modif(object sender, EventArgs e)
- {
- //if (Button == 0)
- //{
- // //var result = await CurrentPage.ShowPopupAsync(new EntryPopup("Username"));
- // if (string.IsNullOrWhiteSpace((string)result))
- // {
- // ((App)App.Current).Manager.CurrentUser.Username = (string)result;
- // }
- //}
- //else if (Button == 1)
- //{
- // //var result = await CurrentPage.ShowPopupAsync(new EntryPopup("Username"));
- // if (string.IsNullOrWhiteSpace((string)result))
- // {
- // ((App)App.Current).Manager.CurrentUser.Username = (string)result;
- // }
- //}
- //else if (Button == 2)
- //{
- // //var result = await CurrentPage.ShowPopupAsync(new EntryPopup("Username"));
- // if (string.IsNullOrWhiteSpace((string)result))
- // {
- // ((App)App.Current).Manager.CurrentUser.Username = (string)result;
- // }
- //}
- //else if (Button == 3)
- //{
- // //var result = await CurrentPage.ShowPopupAsync(new EntryPopup("Username"));
- // if (string.IsNullOrWhiteSpace((string)result))
- // {
- // ((App)App.Current).Manager.CurrentUser.Username = (string)result;
- // }
- //}
- throw new ArgumentOutOfRangeException();
+ if (IsPswd)
+ {
+ Label.IsVisible = false;
+ }
+ else Label.IsVisible = true;
}
}
\ No newline at end of file