Feat: Pop up chgt info
continuous-integration/drone/push Build is passing Details

Popup_qui_marche_pas
BelsethUwU 2 years ago
parent 3e665acce3
commit 93a4229116

@ -46,7 +46,7 @@ namespace Model
get => email; get => email;
set 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)) if (!(string.IsNullOrWhiteSpace(value)) && rg_email.IsMatch(value))
{ {
email = value; email = value;

@ -16,7 +16,7 @@ public partial class Create : ContentPage
{ {
if (((App)App.Current).Manager.SearchUser(Username.Text) == null) 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)) if (rg.IsMatch(Email.Text))
{ {
rg = new Regex("^(?=.*[A-Za-z])(?=.*[0-9@$!%*#?&])[A-Za-z-0-9@$!%*#?&]{8,}$"); rg = new Regex("^(?=.*[A-Za-z])(?=.*[0-9@$!%*#?&])[A-Za-z-0-9@$!%*#?&]{8,}$");

@ -33,12 +33,14 @@
<RowDefinition Height="auto"/> <RowDefinition Height="auto"/>
<RowDefinition Height="auto"/> <RowDefinition Height="auto"/>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<Entry Placeholder="Username" PlaceholderColor="{StaticResource Primary}" <Entry Text="Bel"
Placeholder="Username" PlaceholderColor="{StaticResource Primary}"
IsPassword="False" IsPassword="False"
x:Name="Username" x:Name="Username"
HeightRequest="50" HeightRequest="50"
ClearButtonVisibility="WhileEditing"/> ClearButtonVisibility="WhileEditing"/>
<Entry Placeholder="Mot de passe" <Entry Text="BelBel1*"
Placeholder="Mot de passe"
PlaceholderColor="{StaticResource Primary}" PlaceholderColor="{StaticResource Primary}"
IsPassword="True" x:Name="Pswd" IsPassword="True" x:Name="Pswd"
HeightRequest="50" HeightRequest="50"

@ -31,20 +31,10 @@
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<VerticalStackLayout Grid.Column="0" Margin="10,0,0,0"> <VerticalStackLayout Grid.Column="0" Margin="10,0,0,0">
<Image Source="{Binding UserImage}" HeightRequest="200" WidthRequest="200" Margin="0,0,10,0"/> <Image Source="{Binding UserImage}" HeightRequest="200" WidthRequest="200" Margin="0,0,10,0"/>
<local:UserInfo Name="{Binding Username}" Button="0" popUp="PopUp"/> <local:UserInfo Name="{Binding Username}" Button="0" PopUp="PopUpUsername"/>
<local:UserInfo Name="{Binding Biographie}" Button="1" PopUp="PopUpBio" LabelHeight="200"/>
<Grid Margin="0,20,0,0"> <local:UserInfo Name="{Binding Password}" Button="2" PopUp="PopUpPswd" IsPswd="False"/>
<Grid.ColumnDefinitions> <local:UserInfo Name="{Binding Email}" Button="3" PopUp="PopUpEmail"/>
<ColumnDefinition Width="10*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Border>
<Label Text="{Binding Biographie}" HeightRequest="200" HorizontalTextAlignment="Start" VerticalTextAlignment="Start"/>
</Border>
<Button ImageSource="pen.png" Grid.Column="1" MaximumHeightRequest="32" MaximumWidthRequest="32" Padding="0,0,0,0" Margin="5,0,0,0" BackgroundColor="{StaticResource Gray500}"></Button>
</Grid>
<local:UserInfo Name="{Binding Password}" Button="2" popUp="PopUp"/>
<local:UserInfo Name="{Binding Email}" Button="3" popUp="PopUp"/>
</VerticalStackLayout> </VerticalStackLayout>
<VerticalStackLayout Grid.Column="1" Margin="100,0,0,0"> <VerticalStackLayout Grid.Column="1" Margin="100,0,0,0">

@ -1,11 +1,11 @@
using CommunityToolkit.Maui.Views; using CommunityToolkit.Maui.Views;
using Model; using Model;
using System.Text.RegularExpressions;
namespace Stim; namespace Stim;
public partial class ProfilPage : ContentPage public partial class ProfilPage : ContentPage
{ {
delegate string delegatePopUp();
public ProfilPage() public ProfilPage()
{ {
InitializeComponent(); 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")); 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); 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);
} }
} }

@ -9,10 +9,10 @@
<ColumnDefinition Width="10*"/> <ColumnDefinition Width="10*"/>
<ColumnDefinition Width="*"/> <ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<Border Margin="0,10,0,0" Padding="0"> <Border Margin="0,10,0,0" Padding="0" MaximumHeightRequest="{Binding LabelHeight, Source={x:Reference userInfoView}}">
<Label Text="{Binding Name, Source={x:Reference PopUp}}" /> <Label x:Name="Label" Text="{Binding Name, Source={x:Reference userInfoView}}" IsVisible="True"/>
</Border> </Border>
<Button Clicked="Modif" ImageSource="pen.png" Grid.Column="1" <Button Clicked="popUp" ImageSource="pen.png" Grid.Column="1"
MaximumHeightRequest="32" MaximumWidthRequest="32" MaximumHeightRequest="32" MaximumWidthRequest="32"
Padding="0,0,0,0" Margin="5,0,0,0" Padding="0,0,0,0" Margin="5,0,0,0"
BackgroundColor="{StaticResource Gray500}"/> BackgroundColor="{StaticResource Gray500}"/>

@ -4,10 +4,24 @@ using CommunityToolkit.Maui.Views;
namespace Stim; namespace Stim;
public partial class UserInfo : ContentView public partial class UserInfo : ContentView
{ {
public event EventHandler popUp; public bool IsPswd
public void PopUp(object sender, EventArgs e)
{ {
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 public string Name
{ {
@ -28,42 +42,10 @@ public partial class UserInfo : ContentView
public UserInfo() public UserInfo()
{ {
InitializeComponent(); InitializeComponent();
} if (IsPswd)
private async void Modif(object sender, EventArgs e)
{ {
//if (Button == 0) Label.IsVisible = false;
//{ }
// //var result = await CurrentPage.ShowPopupAsync(new EntryPopup("Username")); else Label.IsVisible = true;
// 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();
} }
} }
Loading…
Cancel
Save