diff --git a/Mobile/lib/api.dart b/Mobile/lib/api.dart index a53c222..23d65ac 100644 --- a/Mobile/lib/api.dart +++ b/Mobile/lib/api.dart @@ -67,10 +67,8 @@ Future isLoggedIn(BuildContext context) async { final prefs = await SharedPreferences.getInstance(); final token = prefs.getString('token'); - if (token == null){ + if (token == null) { prefs.remove('id'); - loggedIn = false; - user = User as User?; return false; } diff --git a/Mobile/lib/base/sidemenu.dart b/Mobile/lib/base/sidemenu.dart index b53a7f5..ed1a718 100644 --- a/Mobile/lib/base/sidemenu.dart +++ b/Mobile/lib/base/sidemenu.dart @@ -52,101 +52,96 @@ class _SideMenuState extends State { } @override -Widget build(BuildContext context) { - return Scaffold( - appBar: AppBar( - backgroundColor: Theme.of(context).colorScheme.inversePrimary, - title: Row( - children: [ - const SizedBox(width: 55), - Text('SkanTravels', - style: GoogleFonts.jacquesFrancois( - fontSize: 30, - color: Colors.black, - ), + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + backgroundColor: Theme.of(context).colorScheme.inversePrimary, + title: Text('SkanTravels', + style: GoogleFonts.jacquesFrancois( + fontSize: 30, + color: Colors.black, ), - ], + ), ), - ), - drawer: Drawer( - child: ListView( - padding: EdgeInsets.zero, - children: [ - DrawerHeader( - child: Column( - children: [ - const Image(image: AssetImage('assets/logo.png'), height: 100), - Text( - 'SkanTravels', - style: GoogleFonts.jacquesFrancois( - fontSize: 20, - color: const Color(0xFF1862E7), + drawer: Drawer( + child: ListView( + padding: EdgeInsets.zero, + children: [ + DrawerHeader( + child: Column( + 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'), - leading: const Icon(Icons.home), - selected: _selectedIndex == 0, - onTap: () { - Navigator.pushReplacementNamed(context, '/home'); - }, - ), - ListTile( - title: const Text('Favorites'), - leading: const Icon(Icons.star), - selected: _selectedIndex == 1, - onTap: () { - Navigator.pushReplacementNamed(context, '/favorites'); - }, - ), - ListTile( - title: const Text('Profile'), - leading: const Icon(Icons.person), - selected: _selectedIndex == 2, - onTap: () { - Navigator.pushReplacementNamed(context, '/profile'); - }, - ), - const Divider( - color: Colors.grey, - thickness: 2, - 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('Home'), + leading: const Icon(Icons.home), + selected: _selectedIndex == 0, + onTap: () { + Navigator.pushReplacementNamed(context, '/home'); + }, + ), + ListTile( + title: const Text('Favorites'), + leading: const Icon(Icons.star), + selected: _selectedIndex == 1, + onTap: () { + Navigator.pushReplacementNamed(context, '/favorites'); + }, + ), + ListTile( + title: const Text('Profile'), + leading: const Icon(Icons.person), + selected: _selectedIndex == 2, + onTap: () { + Navigator.pushReplacementNamed(context, '/profile'); + }, + ), + const Divider( + color: Colors.grey, + thickness: 2, + 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'); + }, + ), + ] + ), + ], + ), ), - ), - body: widget.body, - ); -} + body: widget.body, + ); + } } \ No newline at end of file