Chargement depuis fichier, view de login a adapter

pull/9/head
Clement LESME 2 years ago
parent 93dace397a
commit 3a7551e491

@ -5,11 +5,11 @@ namespace CanYouBuildIt;
public partial class App : Application
{
public Manager manager { get; private set; } = new Manager(new Stub());
public Manager manager { get; private set; } = new Manager(new DataContractPersistance.DataContractPers());
public App()
{
manager.chargeDonne();
manager.Persi = new DataContractPersistance.DataContractPers();
//manager.Persi = new DataContractPersistance.DataContractPers();
manager.sauvegardeDonnee();
Debug.WriteLine(manager.listUtil[0]);
InitializeComponent();

@ -32,10 +32,10 @@
<ItemGroup>
<!-- App Icon -->
<MauiIcon Include="Resources\AppIcon\iconcybi.png"/>
<MauiIcon Include="Resources\AppIcon\iconcybi.png" />
<!-- Splash Screen -->
<MauiSplashScreen Include="Resources\Splash\splash.svg" Color="#512BD4" BaseSize="128,128" />
<MauiSplashScreen Include="Resources\Splash\splash.svg" />
<!-- Images -->
<MauiImage Include="Resources\Images\*" />
@ -58,6 +58,9 @@
<MauiXaml Update="Views\Favoris.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
<MauiXaml Update="Views\Login.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
</ItemGroup>

@ -49,7 +49,6 @@ namespace CanYouBuildIt.DataContractPersistance
{
Directory.CreateDirectory(FilePath);
File.Create(Path.Combine(FilePath, FileName));
}
DataToPersist data = new DataToPersist();
data.lu = lu;

@ -72,7 +72,7 @@
</Grid.ColumnDefinitions>
<Button BackgroundColor="DimGrey"
Clicked="AddUtilisater"
Clicked="NavLogin"
Grid.Row="0" Grid.Column="2"
HorizontalOptions="Center"
Text="Configurateur"
@ -92,11 +92,13 @@
x:Name="utilView">
<ListView.ItemTemplate>
<DataTemplate>
<Label Text="{Binding username}"
<Label Text="{Binding listUtil.username}"
TextColor="Black"/>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
<Label Text="{Binding listUtil[0].username}"/>
<Button BackgroundColor="DimGrey"
Clicked="ToQuit"

@ -27,7 +27,11 @@ public partial class Acceuil : ContentPage
{
await Navigation.PushAsync(new Credits());
}
private async void NavLogin(object sender, EventArgs e)
{
await Navigation.PushAsync(new Login());
}
private void ToQuit(object sender, EventArgs e)
{
App.Current.Quit();

@ -0,0 +1,100 @@
<?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.Login"
Title="Login">
<AbsoluteLayout>
<Image Source="fond.jpg"/>
<VerticalStackLayout
BackgroundColor="#320639"
AbsoluteLayout.LayoutBounds="0.5,0.5,500,700"
AbsoluteLayout.LayoutFlags="PositionProportional">
<Image Source="logo.png"
MaximumWidthRequest="90"
Margin="25,60,25,0"/>
<Label Text="Connexion"
Margin="25,60,25,0"
MaximumWidthRequest="160"
TextColor="White"
FontAttributes="Bold"
FontSize="30"
WidthRequest="500"/>
<Entry
Margin="25,60,25,0"
x:Name="Nom"
Placeholder="Nom"
PlaceholderColor="#BF730A"
HeightRequest="20"
BackgroundColor="#BDA7C1" />
<Entry
Margin="25,60,25,0"
x:Name="Mdp"
IsPassword="True"
Placeholder="Mot de Passe"
PlaceholderColor="#BF730A"
HeightRequest="20"
BackgroundColor="#BDA7C1"/>
<Entry
BackgroundColor="#BDA7C1"
Margin="25,60,25,0"
x:Name="Adresse"
Placeholder="Mail"
PlaceholderColor="#BF730A"
HeightRequest="20"/>
<HorizontalStackLayout>
<Button
BackgroundColor="#882297"
Margin="220,60,0,0"
x:Name="BtnValider"
Text="LOGIN"
FontAttributes="Bold"
TextColor="White"
HorizontalOptions="Center" />
<Button Margin="90,60,0,0"
x:Name="btn_insc"
Text="inscription"
FontAttributes="Bold"
TextColor="White"
HorizontalOptions="Center" />
</HorizontalStackLayout>
<HorizontalStackLayout>
<Label Text="ERREUR ! les cases Nom et Mot de Passe doivent etre remplie."
IsVisible="false"
x:Name="error"
BackgroundColor="Red"
FontAttributes="Bold"
Padding="30"
Margin="0,30,0,0"
HorizontalOptions="Center"
WidthRequest="500"/>
<Label Text="ERREUR ! mauvais mdp et nom."
IsVisible="false"
x:Name="wrong"
BackgroundColor="Red"
FontAttributes="Bold"
Padding="30"
Margin="0,30,0,0"
HorizontalOptions="Center"
WidthRequest="500"/>
<Label Text="mot de passe et nom VALIDE."
IsVisible="false"
x:Name="valide"
BackgroundColor="Green"
FontAttributes="Bold"
Padding="30"
Margin="0,30,0,0"
HorizontalOptions="Center"
WidthRequest="500"/>
</HorizontalStackLayout>
</VerticalStackLayout>
</AbsoluteLayout>
</ContentPage>

@ -0,0 +1,48 @@
namespace CanYouBuildIt.Views;
public partial class Login : ContentPage
{
public Manager MyManager => (App.Current as App).MyManager;
public PageConnexion()
{
InitializeComponent();
}
private async void BoutonValider(object sender, EventArgs e)
{
//recupérer les valeurs d'entrées
string email = Adresse.Text;
string MdpUlti = Mdp.Text;
string Name = Nom.Text;
int idname = MyManager.rechercheNom(Name);
int idmail = MyManager.rechercheAdresse(email);
int idmdp = MyManager.rechercheMdp(MdpUlti);
if (Name == null || MdpUlti == null)
{
error.IsVisible = true;
await Task.Delay(3000);
error.IsVisible = false;
return;
}
else if (idname == -1 && idmail == -1 && idmdp == -1)
{
wrong.IsVisible = true;
await Task.Delay(1000);
wrong.IsVisible = false;
return;
}
else if (idname != -1 && idmail != -1 && idmdp != -1)
{
valide.IsVisible = true;
await Task.Delay(1000);
valide.IsVisible = false;
await Navigation.PushAsync(new Accueil(idname));
}
}
private void btninsc(object sender, EventArgs e)
{
Navigation.PushAsync(new PageInscription());
}
}
Loading…
Cancel
Save