Compare commits
	
		
			No commits in common. "de8d8982897407d7126c0ba6eba992077830da5d" and "cb67575bfe7a001893c0abc07d5290d8f4b71228" have entirely different histories.
		
	
	
		
			de8d898289
			...
			cb67575bfe
		
	
		
| @ -67,8 +67,10 @@ Future<bool> isLoggedIn(BuildContext context) async { | |||||||
|   final prefs = await SharedPreferences.getInstance(); |   final prefs = await SharedPreferences.getInstance(); | ||||||
| 
 | 
 | ||||||
|   final token = prefs.getString('token'); |   final token = prefs.getString('token'); | ||||||
|   if (token == null) { |   if (token == null){ | ||||||
|     prefs.remove('id'); |     prefs.remove('id'); | ||||||
|  |     loggedIn = false; | ||||||
|  |     user = User as User?; | ||||||
|     return false; |     return false; | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -52,96 +52,101 @@ class _SideMenuState extends State<SideMenu> { | |||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   @override |   @override | ||||||
|   Widget build(BuildContext context) { | Widget build(BuildContext context) { | ||||||
|     return Scaffold( |   return Scaffold( | ||||||
|       appBar: AppBar( |     appBar: AppBar( | ||||||
|         backgroundColor: Theme.of(context).colorScheme.inversePrimary, |       backgroundColor: Theme.of(context).colorScheme.inversePrimary, | ||||||
|         title: Text('SkanTravels', |       title: Row( | ||||||
|           style: GoogleFonts.jacquesFrancois( |         children: [ | ||||||
|             fontSize: 30, |           const SizedBox(width: 55), | ||||||
|             color: Colors.black, |           Text('SkanTravels', | ||||||
|  |                 style: GoogleFonts.jacquesFrancois( | ||||||
|  |                   fontSize: 30, | ||||||
|  |                   color: Colors.black, | ||||||
|  |                 ), | ||||||
|           ), |           ), | ||||||
|         ), |         ], | ||||||
|       ), |       ), | ||||||
|       drawer: Drawer( |     ), | ||||||
|         child: ListView( |     drawer: Drawer( | ||||||
|           padding: EdgeInsets.zero, |       child: ListView( | ||||||
|           children: [ |         padding: EdgeInsets.zero, | ||||||
|             DrawerHeader( |         children: [ | ||||||
|               child: Column( |           DrawerHeader( | ||||||
|                 children: [ |             child: Column( | ||||||
|                   const Image(image: AssetImage('assets/logo.png'), height: 100), |               children: [ | ||||||
|                   Text( |                 const Image(image: AssetImage('assets/logo.png'), height: 100), | ||||||
|                     'SkanTravels', |                 Text( | ||||||
|                     style: GoogleFonts.jacquesFrancois( |                   'SkanTravels', | ||||||
|                       fontSize: 20, |                   style: GoogleFonts.jacquesFrancois( | ||||||
|                       color: const Color(0xFF1862E7), |                     fontSize: 20, | ||||||
|                     ), |                     color: const Color(0xFF1862E7), | ||||||
|                   ), |                   ), | ||||||
|                 ], |                 ), | ||||||
|               ), |               ], | ||||||
|             ), |             ), | ||||||
|             ListTile( |           ), | ||||||
|               title: const Text('Home'), |           ListTile( | ||||||
|               leading: const Icon(Icons.home), |             title: const Text('Home'), | ||||||
|               selected: _selectedIndex == 0, |             leading: const Icon(Icons.home), | ||||||
|               onTap: () { |             selected: _selectedIndex == 0, | ||||||
|                 Navigator.pushReplacementNamed(context, '/home'); |             onTap: () { | ||||||
|               }, |               Navigator.pushReplacementNamed(context, '/home'); | ||||||
|             ), |             }, | ||||||
|             ListTile( |           ), | ||||||
|               title: const Text('Favorites'), |           ListTile( | ||||||
|               leading: const Icon(Icons.star), |             title: const Text('Favorites'), | ||||||
|               selected: _selectedIndex == 1, |             leading: const Icon(Icons.star), | ||||||
|               onTap: () { |             selected: _selectedIndex == 1, | ||||||
|                 Navigator.pushReplacementNamed(context, '/favorites'); |             onTap: () { | ||||||
|               }, |               Navigator.pushReplacementNamed(context, '/favorites'); | ||||||
|             ), |             }, | ||||||
|             ListTile( |           ), | ||||||
|               title: const Text('Profile'), |           ListTile( | ||||||
|               leading: const Icon(Icons.person), |             title: const Text('Profile'), | ||||||
|               selected: _selectedIndex == 2, |             leading: const Icon(Icons.person), | ||||||
|               onTap: () { |             selected: _selectedIndex == 2, | ||||||
|                 Navigator.pushReplacementNamed(context, '/profile'); |             onTap: () { | ||||||
|               }, |               Navigator.pushReplacementNamed(context, '/profile'); | ||||||
|             ), |             }, | ||||||
|             const Divider( |           ), | ||||||
|               color: Colors.grey, |           const Divider( | ||||||
|               thickness: 2, |             color: Colors.grey, | ||||||
|               indent: 40, |             thickness: 2, | ||||||
|             ), |             indent: 40, | ||||||
|             ...(loggedIn |           ), | ||||||
|               ? [ |           ...(loggedIn | ||||||
|                   ListTile( |             ? [ | ||||||
|                     title: const Text('Log out'), |                 ListTile( | ||||||
|                     leading: const Icon(Icons.logout), |                   title: const Text('Log out'), | ||||||
|                     selected: false, |                   leading: const Icon(Icons.logout), | ||||||
|                     onTap: _logout, |                   selected: false, | ||||||
|                   ), |                   onTap: _logout, | ||||||
|                 ] |                 ), | ||||||
|               : [ |               ] | ||||||
|                   ListTile( |             : [ | ||||||
|                     title: const Text('Register'), |                 ListTile( | ||||||
|                     leading: const Icon(Icons.add_box_outlined), |                   title: const Text('Register'), | ||||||
|                     selected: _selectedIndex == 3, |                   leading: const Icon(Icons.add_box_outlined), | ||||||
|                     onTap: () { |                   selected: _selectedIndex == 3, | ||||||
|                       Navigator.pushReplacementNamed(context, '/register'); |                   onTap: () { | ||||||
|                     }, |                     Navigator.pushReplacementNamed(context, '/register'); | ||||||
|                   ), |                   }, | ||||||
|                   ListTile( |                 ), | ||||||
|                     title: const Text('Login'), |                 ListTile( | ||||||
|                     leading: const Icon(Icons.login), |                   title: const Text('Login'), | ||||||
|                     selected: _selectedIndex == 4, |                   leading: const Icon(Icons.login), | ||||||
|                     onTap: () { |                   selected: _selectedIndex == 4, | ||||||
|                       Navigator.pushReplacementNamed(context, '/login'); |                   onTap: () { | ||||||
|                     }, |                     Navigator.pushReplacementNamed(context, '/login'); | ||||||
|                   ), |                   }, | ||||||
|                 ] |                 ), | ||||||
|             ), |               ] | ||||||
|           ], |           ), | ||||||
|         ), |         ], | ||||||
|       ), |       ), | ||||||
|       body: widget.body, |     ), | ||||||
|     ); |     body: widget.body, | ||||||
|   } |   ); | ||||||
|  | } | ||||||
| } | } | ||||||
| @ -14,34 +14,6 @@ class FavoritesPage extends StatefulWidget { | |||||||
| class _FavoritesPage extends State<FavoritesPage> { | class _FavoritesPage extends State<FavoritesPage> { | ||||||
|   List<Favorite> _favorites = []; |   List<Favorite> _favorites = []; | ||||||
| 
 | 
 | ||||||
|   void _confirmDeleteFavorite(Favorite favorite) { |  | ||||||
|     showDialog( |  | ||||||
|       context: context, |  | ||||||
|       builder: (BuildContext context) { |  | ||||||
|         return AlertDialog( |  | ||||||
|           title: const Text('Remove favorite'), |  | ||||||
|           content: Text('Are you sure you want to remove ${favorite.name} from your favorites list?'), |  | ||||||
|           actions: [ |  | ||||||
|             TextButton(onPressed: () => Navigator.pop(context), child: const Text('Cancel')), |  | ||||||
|             TextButton(onPressed: () => _deleteFavorite(favorite), child: const Text('Remove', style: TextStyle(color: Colors.red))), |  | ||||||
|           ], |  | ||||||
|         ); |  | ||||||
|       } |  | ||||||
|     ); |  | ||||||
|   } |  | ||||||
| 
 |  | ||||||
|   void _deleteFavorite(Favorite favorite) async { |  | ||||||
|     Navigator.pop(context); |  | ||||||
| 
 |  | ||||||
|     if (await api.request(context, api.ApiService.app, 'DELETE', '/favorites/${favorite.id}', null) == null) { |  | ||||||
|       return; |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     setState(() { |  | ||||||
|       _favorites = _favorites.where((fav) => fav.id != favorite.id).toList(); |  | ||||||
|     }); |  | ||||||
|   } |  | ||||||
| 
 |  | ||||||
|   @override |   @override | ||||||
|   void didChangeDependencies() { |   void didChangeDependencies() { | ||||||
|     super.didChangeDependencies(); |     super.didChangeDependencies(); | ||||||
| @ -85,10 +57,7 @@ class _FavoritesPage extends State<FavoritesPage> { | |||||||
|             child: Row( |             child: Row( | ||||||
|               crossAxisAlignment: CrossAxisAlignment.start, |               crossAxisAlignment: CrossAxisAlignment.start, | ||||||
|               children: [ |               children: [ | ||||||
|                 const Padding( |                 const Padding(padding: EdgeInsets.only(top: 3), child: Icon(Icons.star, color: Colors.yellow, size: 36)), | ||||||
|                   padding: EdgeInsets.only(top: 3), |  | ||||||
|                   child: Icon(Icons.star, color: Colors.yellow, size: 36) |  | ||||||
|                 ), |  | ||||||
|                 const SizedBox(width: 20), |                 const SizedBox(width: 20), | ||||||
|                 Expanded( |                 Expanded( | ||||||
|                   child: Column( |                   child: Column( | ||||||
| @ -100,7 +69,7 @@ class _FavoritesPage extends State<FavoritesPage> { | |||||||
|                   ), |                   ), | ||||||
|                 ), |                 ), | ||||||
|                 const SizedBox(width: 20), |                 const SizedBox(width: 20), | ||||||
|                 IconButton(icon: const Icon(Icons.delete), color: Colors.grey, onPressed: () => _confirmDeleteFavorite(favorite)), |                 const Padding(padding: EdgeInsets.only(top: 5), child: Icon(Icons.delete, color: Colors.grey)), | ||||||
|               ], |               ], | ||||||
|             ), |             ), | ||||||
|           )).toList(), |           )).toList(), | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user