add splash login and register to navigation

pull/39/head
Leo TUAILLON 2 years ago
parent f981b89308
commit a4065a377a

@ -11,12 +11,13 @@ public partial class App : Application
Account account = getUserAccount(); Account account = getUserAccount();
MainPage = new AppShell(); var appShell = new AppShell();
MainPage = appShell;
appShell.GoToAsync("//Splash");
} }
private Account getUserAccount() private Account getUserAccount()
{ {
return new Account(new User(new Uri("https://www.pngkey.com/png/full/115-1150152_default-profile-picture-avatar-png-green.png"), "Stub Account"), "test@example.com"); return new Account(new User(new Uri("https://www.pngkey.com/png/full/115-1150152_default-profile-picture-avatar-png-green.png"), "Stub Account"), "test@example.com");
} }
} }

@ -11,13 +11,25 @@
Shell.TabBarTitleColor="{StaticResource Selected}" Shell.TabBarTitleColor="{StaticResource Selected}"
Shell.TabBarUnselectedColor="{StaticResource TextColorSecondary}"> Shell.TabBarUnselectedColor="{StaticResource TextColorSecondary}">
<ShellContent
x:Name="Splash"
Title="More"
ContentTemplate="{DataTemplate pages:Splash}"
Route="Splash"/>
<ShellContent
x:Name="LoginPage"
Title="Login"
ContentTemplate="{DataTemplate pages:LoginPage}"
Route="LoginPage"/>
<ShellContent
x:Name="RegisterPage"
Title="Register"
ContentTemplate="{DataTemplate pages:RegisterPage}"
Route="RegisterPage"/>
<TabBar> <TabBar>
<ShellContent
x:Name="Splash"
Title="More"
ContentTemplate="{DataTemplate pages:Splash}"
Route="Splash"
IsVisible="False"/>
<ShellContent <ShellContent
x:Name="HomeTab" x:Name="HomeTab"
@ -72,11 +84,11 @@
ContentTemplate="{DataTemplate pages:ProfilePage}" ContentTemplate="{DataTemplate pages:ProfilePage}"
Route="EditProfile"/> Route="EditProfile"/>
</FlyoutItem> </FlyoutItem>
<FlyoutItem Title="LoginPage"> <FlyoutItem>
<ShellContent <ShellContent
Title="LoginPage" x:Name="ForgotPassword"
ContentTemplate="{DataTemplate pages:LoginPage}" Title="Login"
Route="LoginPage"/> ContentTemplate="{DataTemplate pages:ForgotPassword}"
Route="ForgotPassword"/>
</FlyoutItem> </FlyoutItem>
</Shell> </Shell>

@ -21,7 +21,8 @@
HeightRequest="50" HeightRequest="50"
WidthRequest="50" WidthRequest="50"
Source="arrow_back.svg"/> Source="arrow_back.svg"
Clicked="OnBackButtonClicked"/>
</HorizontalStackLayout> </HorizontalStackLayout>
<Label <Label
Margin="-40,10,0,0" Margin="-40,10,0,0"

@ -6,4 +6,8 @@ public partial class ForgotPassword : ContentPage
{ {
InitializeComponent(); InitializeComponent();
} }
private async void OnBackButtonClicked(object sender, EventArgs e)
{
await Navigation.PopAsync();
}
} }

@ -70,7 +70,11 @@
TextColor="{StaticResource TextColorSecondary}" TextColor="{StaticResource TextColorSecondary}"
HorizontalOptions="End" HorizontalOptions="End"
Text="Forgot Password ?" Text="Forgot Password ?"
BackgroundColor="Transparent"/> BackgroundColor="Transparent">
<Label.GestureRecognizers>
<TapGestureRecognizer Tapped="ForgotPasswordTapped" />
</Label.GestureRecognizers>
</Label>
<Border <Border
Margin="0, 30, 0, 0" Margin="0, 30, 0, 0"
@ -137,8 +141,12 @@
New User?</Label> New User?</Label>
<Label <Label
FontAttributes="Bold" FontAttributes="Bold"
TextColor="{StaticResource TextColorPrimary}"> TextColor="{StaticResource TextColorPrimary}"
Create Account</Label> Text="Create Account">
<Label.GestureRecognizers>
<TapGestureRecognizer Tapped="RegisterLabbelTapped" />
</Label.GestureRecognizers>
</Label>
</HorizontalStackLayout> </HorizontalStackLayout>
</VerticalStackLayout> </VerticalStackLayout>

@ -8,17 +8,20 @@ public partial class LoginPage : ContentPage
} }
private async void OnLoginButtonClicked(object sender, EventArgs e) private async void OnLoginButtonClicked(object sender, EventArgs e)
{ {
await Navigation.PushAsync(new HomePage()); // Vérifiez les informations d'identification de l'utilisateur ici
// Vérification des informations de connexion ici bool isValidUser = true;
/* bool loginSuccessful = true; // Remplacez cette ligne par votre propre logique de vérification
if (loginSuccessful) if (isValidUser)
{ {
await Navigation.PushAsync(new HomePage()); await Shell.Current.GoToAsync("//HomePage");
}
// Supprimez les pages Splash et Login de la pile de navigation pour éviter qu'elles ne soient accessibles en revenant en arrière }
Navigation.RemovePage(Navigation.NavigationStack[0]); // Supprime la page Splash private async void ForgotPasswordTapped(object sender, EventArgs e)
Navigation.RemovePage(Navigation.NavigationStack[0]); // Supprime la page Login {
}*/ await Shell.Current.Navigation.PushAsync(new ForgotPassword());
}
private async void RegisterLabbelTapped(object sender, EventArgs e)
{
await Shell.Current.GoToAsync("//RegisterPage");
} }
} }

@ -84,11 +84,6 @@
</Grid> </Grid>
</Border> </Border>
<Label
TextColor="{StaticResource TextColorSecondary}"
HorizontalOptions="End">
Forgot Password ?
</Label>
<Border <Border
@ -99,7 +94,8 @@
BackgroundColor="{StaticResource ActionButton}" BackgroundColor="{StaticResource ActionButton}"
FontFamily="PoppinsMedium" FontFamily="PoppinsMedium"
TextColor="White" TextColor="White"
Text="SIGN UP"/> Text="SIGN UP"
Clicked="RegisterTapped"/>
</Border> </Border>
<HorizontalStackLayout <HorizontalStackLayout
@ -155,8 +151,12 @@
Already have an account ?</Label> Already have an account ?</Label>
<Label <Label
FontAttributes="Bold" FontAttributes="Bold"
TextColor="{StaticResource TextColorPrimary}"> TextColor="{StaticResource TextColorPrimary}"
Log In</Label> Text="Log In">
<Label.GestureRecognizers>
<TapGestureRecognizer Tapped="LoginTapped" />
</Label.GestureRecognizers>
</Label>
</HorizontalStackLayout> </HorizontalStackLayout>
</VerticalStackLayout> </VerticalStackLayout>

@ -6,4 +6,12 @@ public partial class RegisterPage : ContentPage
{ {
InitializeComponent(); InitializeComponent();
} }
private async void LoginTapped(object sender, EventArgs e)
{
await Shell.Current.GoToAsync("//LoginPage");
}
private async void RegisterTapped(object sender, EventArgs e)
{
await Shell.Current.GoToAsync("//LoginPage");
}
} }

@ -33,6 +33,6 @@
TextColor="{StaticResource ButtonText}" TextColor="{StaticResource ButtonText}"
Text="Let's Get Started ➝" Text="Let's Get Started ➝"
Margin="25" Margin="25"
Clicked="OnSyncButtonClicked"/> Clicked="OnGetStartedButtonClicked"/>
</Grid> </Grid>
</ContentPage> </ContentPage>

@ -8,8 +8,9 @@ public partial class Splash : ContentPage
NavigationPage.SetHasNavigationBar(this, false); NavigationPage.SetHasNavigationBar(this, false);
} }
private async void OnSyncButtonClicked(object sender, EventArgs e) private async void OnGetStartedButtonClicked(object sender, EventArgs e)
{ {
await Navigation.PushAsync(new LoginPage()); await Shell.Current.GoToAsync("//LoginPage");
} }
} }

@ -1,12 +0,0 @@
<?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="ShoopNCook.Pages.SplashScreen"
Title="SplashScreen">
<VerticalStackLayout>
<Label
Text="Welcome to .NET MAUI!"
VerticalOptions="Center"
HorizontalOptions="Center" />
</VerticalStackLayout>
</ContentPage>

@ -1,9 +0,0 @@
namespace ShoopNCook.Pages;
public partial class SplashScreen : ContentPage
{
public SplashScreen()
{
InitializeComponent();
}
}
Loading…
Cancel
Save