From c1fa40e49275ff71520ba9b46c7bbe0936f01af3 Mon Sep 17 00:00:00 2001 From: Reimar Date: Mon, 26 Aug 2024 20:53:47 +0200 Subject: [PATCH] Fix formatting --- Mobile/lib/base/sidemenu.dart | 101 ++++++++++++++++------------------ Mobile/lib/login.dart | 61 ++++++++++---------- 2 files changed, 76 insertions(+), 86 deletions(-) diff --git a/Mobile/lib/base/sidemenu.dart b/Mobile/lib/base/sidemenu.dart index 824d210..b53a7f5 100644 --- a/Mobile/lib/base/sidemenu.dart +++ b/Mobile/lib/base/sidemenu.dart @@ -4,10 +4,9 @@ import 'package:shared_preferences/shared_preferences.dart'; import 'package:google_fonts/google_fonts.dart'; import 'variables.dart'; - class SideMenu extends StatefulWidget { final Widget body; - final int selectedIndex ; + final int selectedIndex; const SideMenu({super.key, required this.body, required this.selectedIndex}); @@ -29,17 +28,15 @@ class _SideMenuState extends State { prefs.remove('token'); prefs.remove('id'); + setState(() { loggedIn = false; user = null; - }); - + }); if (mounted) { - ScaffoldMessenger.of(context).showSnackBar( - const SnackBar(content: Text('Successfully logged out'))); - Navigator.pushReplacementNamed(context, '/login'); - + ScaffoldMessenger.of(context).showSnackBar(const SnackBar(content: Text('Successfully logged out'))); + Navigator.pushReplacementNamed(context, '/login'); } } @@ -47,13 +44,11 @@ class _SideMenuState extends State { void didChangeDependencies() { super.didChangeDependencies(); - api - .isLoggedIn(context).then((value) { - setState(() { - loggedIn = value; // Update the second variable here - }); -}); - + api.isLoggedIn(context).then((value) { + setState(() { + loggedIn = value; // Update the second variable here + }); + }); } @override @@ -79,20 +74,17 @@ Widget build(BuildContext context) { children: [ DrawerHeader( child: Column( - children: [ - const Image( - image: AssetImage('assets/logo.png'), - height: 100, - ), - Text( - 'SkanTravels', - style: GoogleFonts.jacquesFrancois( - fontSize: 20, - color: Color(0xFF1862E7), + children: [ + const Image(image: AssetImage('assets/logo.png'), height: 100), + Text( + 'SkanTravels', + style: GoogleFonts.jacquesFrancois( + fontSize: 20, + color: const Color(0xFF1862E7), + ), ), - ), - ], - ) + ], + ), ), ListTile( title: const Text('Home'), @@ -124,32 +116,33 @@ Widget build(BuildContext context) { indent: 40, ), ...(loggedIn - ? [ - ListTile( - title: const Text('Log out'), - leading: const Icon(Icons.logout), - selected: false, - onTap: _logout, - ) - ] - : [ - ListTile( - title: const Text('Register'), - leading: const Icon(Icons.add_box_outlined), - selected: _selectedIndex == 3, - onTap: () { - Navigator.pushReplacementNamed(context, '/register'); - }, - ), - ListTile( - title: const Text('Login'), - leading: const Icon(Icons.login), - selected: _selectedIndex == 4, - onTap: () { - Navigator.pushReplacementNamed(context, '/login'); - }, - ) - ]) + ? [ + ListTile( + title: const Text('Log out'), + leading: const Icon(Icons.logout), + selected: false, + onTap: _logout, + ), + ] + : [ + ListTile( + title: const Text('Register'), + leading: const Icon(Icons.add_box_outlined), + selected: _selectedIndex == 3, + onTap: () { + Navigator.pushReplacementNamed(context, '/register'); + }, + ), + ListTile( + title: const Text('Login'), + leading: const Icon(Icons.login), + selected: _selectedIndex == 4, + onTap: () { + Navigator.pushReplacementNamed(context, '/login'); + }, + ), + ] + ), ], ), ), diff --git a/Mobile/lib/login.dart b/Mobile/lib/login.dart index a2fee40..31fa313 100644 --- a/Mobile/lib/login.dart +++ b/Mobile/lib/login.dart @@ -34,9 +34,9 @@ class _LoginPageState extends State { prefs.setString('token', jsonUser.token); prefs.setString('id', jsonUser.id); - setState(() - {loggedIn == true;}); - + setState(() { + loggedIn == true; + }); if (mounted) { ScaffoldMessenger.of(context).showSnackBar(const SnackBar(content: Text('Successfully logged in'))); @@ -50,14 +50,11 @@ class _LoginPageState extends State { selectedIndex: 4, body: Scaffold( body: SingleChildScrollView( - child: Center( - child: Container( - constraints: const BoxConstraints(minWidth: 100, maxWidth: 400), - child: Column(children: [ - const Image( - image: AssetImage('assets/logo.png'), - height: 200, - ), + child: Center( + child: Container( + constraints: const BoxConstraints(minWidth: 100, maxWidth: 400), + child: Column(children: [ + const Image(image: AssetImage('assets/logo.png'), height: 200), Text( 'SkanTravels', style: GoogleFonts.jacquesFrancois( @@ -65,29 +62,29 @@ class _LoginPageState extends State { color: const Color(0xFF1862E7), ), ), - const SizedBox(height: 40), - const Text('Email'), - TextField(controller: emailInput), - const SizedBox(height: 30), - const Text('Password'), - TextField( - controller: passwordInput, - obscureText: true, - enableSuggestions: false, - autocorrect: false, - ), - const SizedBox(height: 30), - ElevatedButton(onPressed: _login, child: const Text('Login')), - const SizedBox(height: 10), - const Text('or'), - TextButton( - child: const Text('Register account'), - onPressed: () => Navigator.pushReplacementNamed(context, '/register') - ), - ]), + const SizedBox(height: 40), + const Text('Email'), + TextField(controller: emailInput), + const SizedBox(height: 30), + const Text('Password'), + TextField( + controller: passwordInput, + obscureText: true, + enableSuggestions: false, + autocorrect: false, + ), + const SizedBox(height: 30), + ElevatedButton(onPressed: _login, child: const Text('Login')), + const SizedBox(height: 10), + const Text('or'), + TextButton( + child: const Text('Register account'), + onPressed: () => Navigator.pushReplacementNamed(context, '/register') + ), + ]), + ), ), ), - ), ), ); }