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,}$");

@ -1,69 +1,71 @@
<?xml version="1.0" encoding="utf-8" ?> <?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui" <ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Stim.LoginPage" x:Class="Stim.LoginPage"
Title="LoginPage"> Title="LoginPage">
<Grid BackgroundColor="{StaticResource Tertiary}"> <Grid BackgroundColor="{StaticResource Tertiary}">
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/> <ColumnDefinition Width="*"/>
<ColumnDefinition Width="5*"/> <ColumnDefinition Width="5*"/>
<ColumnDefinition Width="*"/> <ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="auto"/> <RowDefinition Height="auto"/>
<RowDefinition Height="*"/> <RowDefinition Height="*"/>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<VerticalStackLayout BackgroundColor="Black" Grid.Column="0"/> <VerticalStackLayout BackgroundColor="Black" Grid.Column="0"/>
<VerticalStackLayout BackgroundColor="Black" Grid.Column="2"/> <VerticalStackLayout BackgroundColor="Black" Grid.Column="2"/>
<VerticalStackLayout BackgroundColor="Black" Grid.Column="0" Grid.Row="1"/> <VerticalStackLayout BackgroundColor="Black" Grid.Column="0" Grid.Row="1"/>
<VerticalStackLayout BackgroundColor="Black" Grid.Column="2" Grid.Row="1"/> <VerticalStackLayout BackgroundColor="Black" Grid.Column="2" Grid.Row="1"/>
<Grid Grid.Column="1"> <Grid Grid.Column="1">
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="500"/> <RowDefinition Height="500"/>
<RowDefinition Height="auto"/>
<RowDefinition Height="auto"/> <RowDefinition Height="auto"/>
</Grid.RowDefinitions> <RowDefinition Height="auto"/>
<Image Source="no_cover.png" HeightRequest="490" Margin="0,10,0,0"/> </Grid.RowDefinitions>
<Grid Grid.Row="1"> <Image Source="no_cover.png" HeightRequest="490" Margin="0,10,0,0"/>
<Grid.RowDefinitions> <Grid Grid.Row="1">
<RowDefinition Height="auto"/> <Grid.RowDefinitions>
<RowDefinition Height="auto"/> <RowDefinition Height="auto"/>
<RowDefinition Height="auto"/> <RowDefinition Height="auto"/>
</Grid.RowDefinitions> <RowDefinition Height="auto"/>
<Entry Placeholder="Username" PlaceholderColor="{StaticResource Primary}" </Grid.RowDefinitions>
IsPassword="False" <Entry Text="Bel"
x:Name="Username" Placeholder="Username" PlaceholderColor="{StaticResource Primary}"
HeightRequest="50" IsPassword="False"
ClearButtonVisibility="WhileEditing"/> x:Name="Username"
<Entry Placeholder="Mot de passe" HeightRequest="50"
PlaceholderColor="{StaticResource Primary}" ClearButtonVisibility="WhileEditing"/>
IsPassword="True" x:Name="Pswd" <Entry Text="BelBel1*"
HeightRequest="50" Placeholder="Mot de passe"
Grid.Row="1" PlaceholderColor="{StaticResource Primary}"
ClearButtonVisibility="WhileEditing"/> IsPassword="True" x:Name="Pswd"
HeightRequest="50"
<Grid Grid.Row="2" Grid.Row="1"
Margin="10,0,0,10"> ClearButtonVisibility="WhileEditing"/>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="3*"/> <Grid Grid.Row="2"
<ColumnDefinition Width="*"/> Margin="10,0,0,10">
</Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<Button Text="Se connecter" <ColumnDefinition Width="3*"/>
Clicked="Se_connecter" <ColumnDefinition Width="*"/>
HeightRequest="50" </Grid.ColumnDefinitions>
BackgroundColor="{StaticResource Gray500}"/> <Button Text="Se connecter"
<Button Text="Créer un compte" Clicked="Se_connecter"
Clicked="Creer_un_compte" HeightRequest="50"
HeightRequest="50" BackgroundColor="{StaticResource Gray500}"/>
BackgroundColor="{StaticResource Gray500}" <Button Text="Créer un compte"
Grid.Column="1"/> Clicked="Creer_un_compte"
</Grid> HeightRequest="50"
</Grid> BackgroundColor="{StaticResource Gray500}"
<HorizontalStackLayout x:Name="Error" Grid.Row="2" HorizontalOptions="Center"> Grid.Column="1"/>
</HorizontalStackLayout> </Grid>
</Grid> </Grid>
</Grid> <HorizontalStackLayout x:Name="Error" Grid.Row="2" HorizontalOptions="Center">
</HorizontalStackLayout>
</Grid>
</Grid>
</ContentPage> </ContentPage>

@ -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) Label.IsVisible = false;
{ }
//if (Button == 0) else Label.IsVisible = true;
//{
// //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();
} }
} }
Loading…
Cancel
Save