From a4065a377a1e29058fae33f112e96975258743a7 Mon Sep 17 00:00:00 2001 From: letuaillon Date: Sun, 7 May 2023 13:20:55 +0200 Subject: [PATCH] add splash login and register to navigation --- App.xaml.cs | 29 +++++++++++++++-------------- AppShell.xaml | 34 +++++++++++++++++++++++----------- Pages/ForgotPassword.xaml | 3 ++- Pages/ForgotPassword.xaml.cs | 4 ++++ Pages/LoginPage.xaml | 14 +++++++++++--- Pages/LoginPage.xaml.cs | 25 ++++++++++++++----------- Pages/RegisterPage.xaml | 16 ++++++++-------- Pages/RegisterPage.xaml.cs | 8 ++++++++ Pages/Splash.xaml | 2 +- Pages/Splash.xaml.cs | 5 +++-- Pages/SplashScreen.xaml | 12 ------------ Pages/SplashScreen.xaml.cs | 9 --------- 12 files changed, 89 insertions(+), 72 deletions(-) delete mode 100644 Pages/SplashScreen.xaml delete mode 100644 Pages/SplashScreen.xaml.cs diff --git a/App.xaml.cs b/App.xaml.cs index 5fb511b..3fa94c2 100644 --- a/App.xaml.cs +++ b/App.xaml.cs @@ -3,20 +3,21 @@ using ShoopNCook.Pages; using ShoopNCook.Models; using ShoopNCook.Models.API; -public partial class App : Application -{ - public App() - { - InitializeComponent(); - - Account account = getUserAccount(); - - MainPage = new AppShell(); - } - +public partial class App : Application +{ + public App() + { + InitializeComponent(); + + Account account = getUserAccount(); + + var appShell = new AppShell(); + MainPage = appShell; + appShell.GoToAsync("//Splash"); + } + 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"); - } - -} + } +} \ No newline at end of file diff --git a/AppShell.xaml b/AppShell.xaml index 6e0a9ee..0c7d017 100644 --- a/AppShell.xaml +++ b/AppShell.xaml @@ -11,13 +11,25 @@ Shell.TabBarTitleColor="{StaticResource Selected}" Shell.TabBarUnselectedColor="{StaticResource TextColorSecondary}"> + + + + + - + - + + x:Name="ForgotPassword" + Title="Login" + ContentTemplate="{DataTemplate pages:ForgotPassword}" + Route="ForgotPassword"/> - \ No newline at end of file diff --git a/Pages/ForgotPassword.xaml b/Pages/ForgotPassword.xaml index f6227f4..6acca64 100644 --- a/Pages/ForgotPassword.xaml +++ b/Pages/ForgotPassword.xaml @@ -21,7 +21,8 @@ HeightRequest="50" WidthRequest="50" - Source="arrow_back.svg"/> + Source="arrow_back.svg" + Clicked="OnBackButtonClicked"/> + TextColor="{StaticResource TextColorPrimary}" + Text="Create Account"> + + + + diff --git a/Pages/LoginPage.xaml.cs b/Pages/LoginPage.xaml.cs index 43c154f..3e6250e 100644 --- a/Pages/LoginPage.xaml.cs +++ b/Pages/LoginPage.xaml.cs @@ -8,17 +8,20 @@ public partial class LoginPage : ContentPage } private async void OnLoginButtonClicked(object sender, EventArgs e) { - await Navigation.PushAsync(new HomePage()); - // Vérification des informations de connexion ici - /* bool loginSuccessful = true; // Remplacez cette ligne par votre propre logique de vérification + // Vérifiez les informations d'identification de l'utilisateur ici + bool isValidUser = true; - if (loginSuccessful) - { - await Navigation.PushAsync(new 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 - Navigation.RemovePage(Navigation.NavigationStack[0]); // Supprime la page Login - }*/ + if (isValidUser) + { + await Shell.Current.GoToAsync("//HomePage"); + } + } + private async void ForgotPasswordTapped(object sender, EventArgs e) + { + await Shell.Current.Navigation.PushAsync(new ForgotPassword()); + } + private async void RegisterLabbelTapped(object sender, EventArgs e) + { + await Shell.Current.GoToAsync("//RegisterPage"); } } \ No newline at end of file diff --git a/Pages/RegisterPage.xaml b/Pages/RegisterPage.xaml index 2164b30..92f4313 100644 --- a/Pages/RegisterPage.xaml +++ b/Pages/RegisterPage.xaml @@ -84,11 +84,6 @@ - + Text="SIGN UP" + Clicked="RegisterTapped"/> + TextColor="{StaticResource TextColorPrimary}" + Text="Log In"> + + + + diff --git a/Pages/RegisterPage.xaml.cs b/Pages/RegisterPage.xaml.cs index 8544462..ee764f0 100644 --- a/Pages/RegisterPage.xaml.cs +++ b/Pages/RegisterPage.xaml.cs @@ -6,4 +6,12 @@ public partial class RegisterPage : ContentPage { 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"); + } } \ No newline at end of file diff --git a/Pages/Splash.xaml b/Pages/Splash.xaml index c1ebc97..94d7fa5 100644 --- a/Pages/Splash.xaml +++ b/Pages/Splash.xaml @@ -33,6 +33,6 @@ TextColor="{StaticResource ButtonText}" Text="Let's Get Started âž" Margin="25" - Clicked="OnSyncButtonClicked"/> + Clicked="OnGetStartedButtonClicked"/> \ No newline at end of file diff --git a/Pages/Splash.xaml.cs b/Pages/Splash.xaml.cs index a81b80d..e965fd1 100644 --- a/Pages/Splash.xaml.cs +++ b/Pages/Splash.xaml.cs @@ -8,8 +8,9 @@ public partial class Splash : ContentPage 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"); } + } diff --git a/Pages/SplashScreen.xaml b/Pages/SplashScreen.xaml deleted file mode 100644 index 7907bdd..0000000 --- a/Pages/SplashScreen.xaml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - \ No newline at end of file diff --git a/Pages/SplashScreen.xaml.cs b/Pages/SplashScreen.xaml.cs deleted file mode 100644 index 98ac91f..0000000 --- a/Pages/SplashScreen.xaml.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace ShoopNCook.Pages; - -public partial class SplashScreen : ContentPage -{ - public SplashScreen() - { - InitializeComponent(); - } -} \ No newline at end of file