je sais plus

master
Clement LESME 2 years ago
parent 45c91336f2
commit a2a2cc8473

@ -62,6 +62,9 @@
<MauiXaml Update="Views\Login.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
<MauiXaml Update="Views\SignIn.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
</ItemGroup>

@ -79,5 +79,12 @@
<d2p1:password>0000</d2p1:password>
<d2p1:username>Kevin</d2p1:username>
</d2p1:Utilisateur>
<d2p1:Utilisateur>
<d2p1:Builds xmlns:d4p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays" i:nil="true" />
<d2p1:listBuild i:nil="true" />
<d2p1:listFav xmlns:d4p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays" i:nil="true" />
<d2p1:password>0123</d2p1:password>
<d2p1:username>tt</d2p1:username>
</d2p1:Utilisateur>
</lu>
</DataToPersist>

@ -47,9 +47,10 @@ namespace CanYouBuildIt.Model
Persi.sauvegardeDonnee(data);
}
public void ajouterUtilisateur(Utilisateur utilisateur)
public int ajouterUtilisateur(Utilisateur utilisateur)
{
listUtil.Add(utilisateur);
return listUtil.Count-1 ;
}
public void ajouterComposant(Composant composant)

@ -14,6 +14,8 @@ public partial class Acceuil : ContentPage
{
InitializeComponent();
BindingContext = manager;
if (connecte)
Log.Text = "{Binding ListUtil[user].username}";
}
public Acceuil(int iduser)
@ -47,6 +49,7 @@ public partial class Acceuil : ContentPage
{
await Navigation.PushAsync(new Credits());
}
private async void NavLogin(object sender, EventArgs e)
{
await Navigation.PushAsync(new Login());

@ -15,28 +15,30 @@
Margin="25,60,25,0"/>
<Label Text="Connexion"
FontAttributes="Bold"
FontSize="30"
Margin="25,60,25,0"
MaximumWidthRequest="160"
TextColor="White"
FontAttributes="Bold"
FontSize="30"
WidthRequest="500"/>
<Entry BackgroundColor="#EEEEFF"
HeightRequest="20"
Margin="25,60,25,0"
x:Name="Nom"
Placeholder="Nom"
PlaceholderColor="Black"
HeightRequest="20"/>
TextColor="Black"
x:Name="Nom"/>
<Entry BackgroundColor="#EEEEFF"
Margin="25,60,25,0"
x:Name="Mdp"
HeightRequest="20"
IsPassword="True"
Margin="25,60,25,0"
Placeholder="Mot de Passe"
PlaceholderColor="Black"
HeightRequest="20"/>
TextColor="Black"
x:Name="Mdp"/>
<HorizontalStackLayout>
<Button BackgroundColor="DimGrey"
@ -50,11 +52,11 @@
<Button BackgroundColor="DimGrey"
Margin="90,60,0,0"
x:Name="btn_insc"
x:Name="btInsc"
Text="Inscription"
FontAttributes="Bold"
TextColor="White"
Clicked="BackHome"
Clicked="NavSignIn"
HorizontalOptions="Center" />
</HorizontalStackLayout>

@ -40,4 +40,9 @@ public partial class Login : ContentPage
{
await Navigation.PopAsync();
}
private async void NavSignIn(object sender, EventArgs e)
{
await Navigation.PushAsync(new SignIn());
}
}

@ -0,0 +1,122 @@
<?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="CanYouBuildIt.Views.SignIn"
Title="SignIn"
BackgroundColor="#26B4BE">
<AbsoluteLayout>
<VerticalStackLayout
AbsoluteLayout.LayoutBounds="0.5,0.5,500,700"
AbsoluteLayout.LayoutFlags="PositionProportional"
BackgroundColor="#408097">
<Image Source="logologin.png"
Margin="25,60,25,0"/>
<Label Text="Inscription"
FontAttributes="Bold"
FontSize="30"
Margin="25,60,25,0"
MaximumWidthRequest="160"
TextColor="White"
WidthRequest="500"/>
<Entry BackgroundColor="#EEEEFF"
HeightRequest="20"
Margin="25,60,25,0"
Placeholder="Nom"
PlaceholderColor="Black"
TextColor="Black"
x:Name="Nom"/>
<Entry BackgroundColor="#EEEEFF"
HeightRequest="20"
IsPassword="True"
Margin="25,60,25,0"
Placeholder="Mot de Passe"
PlaceholderColor="Black"
TextColor="Black"
x:Name="Mdp"/>
<Entry BackgroundColor="#EEEEFF"
HeightRequest="20"
IsPassword="True"
Margin="25,60,25,0"
Placeholder="Confirmer Mot de Passe"
PlaceholderColor="Black"
TextColor="Black"
x:Name="cMdp"/>
<VerticalStackLayout>
<Button BackgroundColor="DimGrey"
Clicked="BtValider"
FontAttributes="Bold"
HorizontalOptions="Center"
Text="Valider"
TextColor="White"
x:Name="btnValider" />
<Button BackgroundColor="DimGrey"
Margin="0,60"
x:Name="annul"
Text="Annuler"
FontAttributes="Bold"
TextColor="White"
Clicked="BackLogin"
HorizontalOptions="Center" />
<Label Text="WARNING ! Les champs doivent être remplis."
IsVisible="false"
x:Name="vide"
BackgroundColor="Red"
FontAttributes="Bold"
Padding="30"
Margin="0,30,0,0"
HorizontalOptions="Center"
WidthRequest="500"/>
<!-- the cat : fcgvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv-->
<Label Text="Le mot de passe doit être composé d'au moins 4 caractères."
IsVisible="false"
x:Name="wrong"
BackgroundColor="Red"
FontAttributes="Bold"
Padding="30"
Margin="0,30,0,0"
HorizontalOptions="Center"
WidthRequest="500"/>
<Label Text="Les 2 mots de passe doivent être les mêmes."
BackgroundColor="Red"
FontAttributes="Bold"
HorizontalOptions="Center"
IsVisible="false"
Margin="0,30,0,0"
Padding="30"
WidthRequest="500"
x:Name="nequal"/>
<Label Text="Ce nom n'est pas disponible."
BackgroundColor="Red"
FontAttributes="Bold"
HorizontalOptions="Center"
IsVisible="false"
Margin="0,30,0,0"
Padding="30"
WidthRequest="500"
x:Name="userNameUsed"/>
<Label Text="Incription valide."
IsVisible="false"
x:Name="valide"
BackgroundColor="Green"
FontAttributes="Bold"
Padding="30"
Margin="0,30,0,0"
HorizontalOptions="Center"
WidthRequest="500"/>
</VerticalStackLayout>
</VerticalStackLayout>
</AbsoluteLayout>
</ContentPage>

@ -0,0 +1,47 @@
namespace CanYouBuildIt.Views;
using CanYouBuildIt.Model;
public partial class SignIn : ContentPage
{
public Manager manager => (App.Current as App).manager;
public SignIn()
{
InitializeComponent();
}
private async void BtValider(object sender, EventArgs e)
{
vide.IsVisible = false;
wrong.IsVisible = false;
nequal.IsVisible = false;
userNameUsed.IsVisible = false;
//recupérer les valeurs d'entrées
string MdpUtil = Mdp.Text;
string cMdpUtil = cMdp.Text;
string Name = Nom.Text;
if (Name == null || MdpUtil == null || cMdpUtil ==null)
vide.IsVisible = true;
else if (MdpUtil.Length <4)
wrong.IsVisible=true;
else if (MdpUtil != cMdpUtil)
nequal.IsVisible = true;
else if (manager.rechercheUsername(Name) != -1)
userNameUsed.IsVisible = true;
else
{
valide.IsVisible = true;
await Task.Delay(1000);
valide.IsVisible = false;
int id = manager.ajouterUtilisateur(new Utilisateur(Name,MdpUtil));
manager.sauvegardeDonnee();
await Navigation.PushAsync(new Acceuil(id));
}
}
private async void BackLogin(object sender, EventArgs e)
{
await Navigation.PopAsync();
}
}
Loading…
Cancel
Save