Compare commits

..

No commits in common. "de8d8982897407d7126c0ba6eba992077830da5d" and "cb67575bfe7a001893c0abc07d5290d8f4b71228" have entirely different histories.

3 changed files with 97 additions and 121 deletions

View File

@ -67,8 +67,10 @@ Future<bool> 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;
}

View File

@ -52,16 +52,21 @@ class _SideMenuState extends State<SideMenu> {
}
@override
Widget build(BuildContext context) {
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
title: Text('SkanTravels',
title: Row(
children: [
const SizedBox(width: 55),
Text('SkanTravels',
style: GoogleFonts.jacquesFrancois(
fontSize: 30,
color: Colors.black,
),
),
],
),
),
drawer: Drawer(
child: ListView(
@ -143,5 +148,5 @@ class _SideMenuState extends State<SideMenu> {
),
body: widget.body,
);
}
}
}

View File

@ -14,34 +14,6 @@ class FavoritesPage extends StatefulWidget {
class _FavoritesPage extends State<FavoritesPage> {
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
void didChangeDependencies() {
super.didChangeDependencies();
@ -85,10 +57,7 @@ class _FavoritesPage extends State<FavoritesPage> {
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Padding(
padding: EdgeInsets.only(top: 3),
child: Icon(Icons.star, color: Colors.yellow, size: 36)
),
const Padding(padding: EdgeInsets.only(top: 3), child: Icon(Icons.star, color: Colors.yellow, size: 36)),
const SizedBox(width: 20),
Expanded(
child: Column(
@ -100,7 +69,7 @@ class _FavoritesPage extends State<FavoritesPage> {
),
),
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(),