Нема описа

favorites_page.dart 2.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. import 'package:flutter/material.dart';
  2. import 'custom_info_card.dart';
  3. class FavoritesPage extends StatelessWidget {
  4. final List<Map<String, dynamic>> favoriteCards;
  5. final VoidCallback? onRefresh;
  6. const FavoritesPage({super.key, required this.favoriteCards, this.onRefresh});
  7. @override
  8. Widget build(BuildContext context) => Scaffold(
  9. appBar: AppBar(
  10. flexibleSpace: Padding(
  11. padding: EdgeInsets.only(top: MediaQuery.of(context).padding.top - 20),
  12. child: Image.asset('assets/header_image.png', fit: BoxFit.cover),
  13. ),
  14. toolbarHeight: MediaQuery.of(context).size.height * 0.19,
  15. title: const Text('Mis Favoritos', style: TextStyle(color: Colors.white)),
  16. ),
  17. body: Container(
  18. decoration: const BoxDecoration(
  19. gradient: LinearGradient(
  20. colors: [Color.fromARGB(255, 254, 100, 91), Colors.orange],
  21. begin: Alignment.topCenter,
  22. end: Alignment.bottomCenter,
  23. ),
  24. ),
  25. child: favoriteCards.isEmpty
  26. ? _buildEmptyState()
  27. : RefreshIndicator(
  28. onRefresh: () async => onRefresh?.call(),
  29. child: ListView.builder(
  30. padding: const EdgeInsets.only(top: 16),
  31. itemCount: favoriteCards.length,
  32. itemBuilder: (_, i) => CustomInfoCard(
  33. imagePath: "assets/icons/${favoriteCards[i]['image']}",
  34. title: favoriteCards[i]['title'],
  35. subtitle: favoriteCards[i]['subtitle'],
  36. texto: favoriteCards[i]['texto'],
  37. categoria: favoriteCards[i]['categoria'],
  38. isFavorite: true,
  39. ),
  40. ),
  41. ),
  42. ),
  43. );
  44. Widget _buildEmptyState() => Center(
  45. child: Column(
  46. mainAxisAlignment: MainAxisAlignment.center,
  47. children: [
  48. const Icon(Icons.favorite_border, size: 64, color: Colors.white54),
  49. const SizedBox(height: 16),
  50. const Text(
  51. 'No tienes favoritos aún',
  52. style: TextStyle(color: Colors.white, fontSize: 18),
  53. ),
  54. const SizedBox(height: 8),
  55. Text(
  56. 'Agrega favoritos desde las otras secciones',
  57. style: TextStyle(color: Colors.white.withOpacity(0.8)),
  58. ),
  59. ],
  60. ),
  61. );
  62. }