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;
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;

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

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

@ -31,20 +31,10 @@
</Grid.ColumnDefinitions>
<VerticalStackLayout Grid.Column="0" Margin="10,0,0,0">
<Image Source="{Binding UserImage}" HeightRequest="200" WidthRequest="200" Margin="0,0,10,0"/>
<local:UserInfo Name="{Binding Username}" Button="0" popUp="PopUp"/>
<Grid Margin="0,20,0,0">
<Grid.ColumnDefinitions>
<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"/>
<local:UserInfo Name="{Binding Username}" Button="0" PopUp="PopUpUsername"/>
<local:UserInfo Name="{Binding Biographie}" Button="1" PopUp="PopUpBio" LabelHeight="200"/>
<local:UserInfo Name="{Binding Password}" Button="2" PopUp="PopUpPswd" IsPswd="False"/>
<local:UserInfo Name="{Binding Email}" Button="3" PopUp="PopUpEmail"/>
</VerticalStackLayout>
<VerticalStackLayout Grid.Column="1" Margin="100,0,0,0">

@ -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);
}
}

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

@ -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;
}
}
Loading…
Cancel
Save