c90Beretta před 2 měsíci
rodič
revize
49c4260a9e

binární
assets/turquessa_prop.jpg


+ 134 - 89
lib/mvvm/views/home/home_screen.dart

@@ -1,87 +1,93 @@
 import 'package:flutter/material.dart';
+import 'package:provider/provider.dart';
+import 'package:turquessa_mesas_hoster/core/models/producto_model.dart';
+import 'package:turquessa_mesas_hoster/mvvm/viewmodels/pedido_view_model.dart';
+import 'package:turquessa_mesas_hoster/mvvm/viewmodels/producto_view_model.dart';
 import 'package:turquessa_mesas_hoster/utils/widgets/custom_appbar.dart';
 import 'package:turquessa_mesas_hoster/mvvm/views/home/categorias_navbar.dart';
+import 'package:turquessa_mesas_hoster/mvvm/viewmodels/home_view_model.dart';
+import 'package:turquessa_mesas_hoster/utils/widgets/modal_infonegaocio.dart';
 
 const List<Map<String, dynamic>> items = [
   {
-    'titulo': 'Hamburguesa de res',
+    'nombre': 'Hamburguesa de res',
     'descripcion': 'Hamburguesa de res con queso cheddar',
     'precio': '\$ 120.00',
     'imageUrl':
         'https://cdn.pixabay.com/photo/2016/03/05/19/02/hamburger-1238246_960_720.jpg',
   },
   {
-    'titulo': 'Hamburguesa de pollo',
+    'nombre': 'Hamburguesa de pollo',
     'descripcion': 'Hamburguesa de pollo con queso cheddar',
     'precio': '\$ 100.00',
     'imageUrl':
         'https://cdn.pixabay.com/photo/2016/03/05/19/02/hamburger-1238246_960_720.jpg',
   },
   {
-    'titulo': 'Hamburguesa de res',
+    'nombre': 'Hamburguesa de res',
     'descripcion': 'Hamburguesa de res con queso cheddar',
     'precio': '\$ 120.00',
     'imageUrl':
         'https://cdn.pixabay.com/photo/2016/03/05/19/02/hamburger-1238246_960_720.jpg',
   },
   {
-    'titulo': 'Hamburguesa de pollo',
+    'nombre': 'Hamburguesa de pollo',
     'descripcion': 'Hamburguesa de pollo con queso cheddar',
     'precio': '\$ 100.00',
     'imageUrl':
         'https://cdn.pixabay.com/photo/2016/03/05/19/02/hamburger-1238246_960_720.jpg',
   },
   {
-    'titulo': 'Hamburguesa de pollo',
+    'nombre': 'Hamburguesa de pollo',
     'descripcion': 'Hamburguesa de pollo con queso cheddar',
     'precio': '\$ 100.00',
     'imageUrl':
         'https://cdn.pixabay.com/photo/2016/03/05/19/02/hamburger-1238246_960_720.jpg',
   },
   {
-    'titulo': 'Hamburguesa de pollo',
+    'nombre': 'Hamburguesa de pollo',
     'descripcion': 'Hamburguesa de pollo con queso cheddar',
     'precio': '\$ 100.00',
     'imageUrl':
         'https://cdn.pixabay.com/photo/2016/03/05/19/02/hamburger-1238246_960_720.jpg',
   },
   {
-    'titulo': 'Hamburguesa de pollo',
+    'nombre': 'Hamburguesa de pollo',
     'descripcion': 'Hamburguesa de pollo con queso cheddar',
     'precio': '\$ 100.00',
     'imageUrl':
         'https://cdn.pixabay.com/photo/2016/03/05/19/02/hamburger-1238246_960_720.jpg',
   },
   {
-    'titulo': 'Hamburguesa de pollo',
+    'nombre': 'Hamburguesa de pollo',
     'descripcion': 'Hamburguesa de pollo con queso cheddar',
     'precio': '\$ 100.00',
     'imageUrl':
         'https://cdn.pixabay.com/photo/2016/03/05/19/02/hamburger-1238246_960_720.jpg',
   },
   {
-    'titulo': 'Hamburguesa de pollo',
+    'nombre': 'Hamburguesa de pollo',
     'descripcion': 'Hamburguesa de pollo con queso cheddar',
     'precio': '\$ 100.00',
     'imageUrl':
         'https://cdn.pixabay.com/photo/2016/03/05/19/02/hamburger-1238246_960_720.jpg',
   },
   {
-    'titulo': 'Hamburguesa de pollo',
+    'nombre': 'Hamburguesa de pollo',
     'descripcion': 'Hamburguesa de pollo con queso cheddar',
     'precio': '\$ 100.00',
     'imageUrl':
         'https://cdn.pixabay.com/photo/2016/03/05/19/02/hamburger-1238246_960_720.jpg',
   },
   {
-    'titulo': 'Hamburguesa de pollo',
+    'nombre': 'Hamburguesa de pollo',
     'descripcion': 'Hamburguesa de pollo con queso cheddar',
     'precio': '\$ 100.00',
     'imageUrl':
         'https://cdn.pixabay.com/photo/2016/03/05/19/02/hamburger-1238246_960_720.jpg',
   },
   {
-    'titulo': 'Hamburguesa de pollo',
+    'nombre': 'Hamburguesa de pollo',
     'descripcion': 'Hamburguesa de pollo con queso cheddar',
     'precio': '\$ 100.00',
     'imageUrl':
@@ -100,27 +106,33 @@ class _HomeScreenState extends State<HomeScreen> {
   @override
   void initState() {
     super.initState();
-  }
-
-  handleTap() {
-    print('Tapped');
+    final homeViewModel = Provider.of<HomeViewModel>(context, listen: false);
+    final productoViewModel =
+        Provider.of<ProductoViewModel>(context, listen: false);
+    WidgetsBinding.instance.addPostFrameCallback((_) {
+      Provider.of<ProductoViewModel>(context, listen: false)
+          .sincronizarProductosYCategorias();
+      homeViewModel.fetchLocalCategorias();
+      productoViewModel.sincronizarProductos();
+      productoViewModel.sincronizarCategorias();
+      productoViewModel.fetchLocalAll();
+    });
   }
 
   @override
   Widget build(BuildContext context) {
+    final homeViewModel = Provider.of<HomeViewModel>(context);
+    final pedidoViewModel = Provider.of<ProductoViewModel>(context);
     return Scaffold(
         backgroundColor: Colors.white,
         body: CustomScrollView(
           slivers: [
-            SliverToBoxAdapter(
-              child: Container(),
-            ),
             SliverAppBar(
               floating: true,
               expandedHeight: 200, // Ajusta la altura para acomodar la imagen
               flexibleSpace: FlexibleSpaceBar(
                 background: Image.asset(
-                  'assets/Turquessa.png',
+                  'assets/turquessa_prop.jpg',
                   fit: BoxFit.cover,
                 ),
               ),
@@ -146,7 +158,7 @@ class _HomeScreenState extends State<HomeScreen> {
                       ),
                       const SizedBox(width: 20),
                       const Text(
-                        'Turquessa',
+                        'Turquessa-Coffee',
                         style: TextStyle(
                           color: Colors.black,
                           fontSize: 26,
@@ -154,14 +166,19 @@ class _HomeScreenState extends State<HomeScreen> {
                         ),
                       ),
                       const SizedBox(width: 15),
-                      Container(
-                        padding: const EdgeInsets.all(8),
-                        decoration: BoxDecoration(
-                          shape: BoxShape.circle,
-                          border: Border.all(color: Colors.white, width: 2),
+                      GestureDetector(
+                        onTap: () {
+                          mostrarInformacionNegocioBottomSheet(context);
+                        },
+                        child: Container(
+                          padding: const EdgeInsets.all(8),
+                          decoration: BoxDecoration(
+                            shape: BoxShape.circle,
+                            border: Border.all(color: Colors.white, width: 2),
+                          ),
+                          child: const Icon(Icons.info,
+                              color: Colors.white, size: 20),
                         ),
-                        child: const Icon(Icons.info,
-                            color: Colors.white, size: 20),
                       ),
                     ],
                   ),
@@ -172,30 +189,20 @@ class _HomeScreenState extends State<HomeScreen> {
               delegate: CategoriasSliverChild(),
               pinned: true,
             ),
+            const SliverToBoxAdapter(
+              child: Center(
+                child: Text('Coffee', style: TextStyle(fontSize: 30)),
+              ),
+            ),
             SliverList(
                 delegate: SliverChildBuilderDelegate(
               (context, index) {
-                if (index < items.length) {
-                  return Column(
-                    children: [
-                      _buildBurgerItem(
-                          items[index]['titulo'],
-                          items[index]['descripcion'],
-                          items[index]['precio'],
-                          items[index]['imageUrl']),
-                      const Divider(
-                        color: Colors.black,
-                        height: 2,
-                      )
-                    ],
-                  );
-                } else {
-                  return _buildBurgerItem(
-                      items[index]['titulo'],
-                      items[index]['descripcion'],
-                      items[index]['precio'],
-                      items[index]['imageUrl']);
-                }
+                return _buildBurgerItem(
+                  items[index]['nombre'],
+                  items[index]['descripcion'],
+                  items[index]['precio'],
+                  items[index]['imageUrl'],
+                );
               },
               childCount: items.length,
             ))
@@ -225,56 +232,94 @@ class CategoriasSliverChild extends SliverPersistentHeaderDelegate {
 }
 
 Widget _buildBurgerItem(
-    String titulo, String descripcion, String precio, String imageUrl) {
-  return Padding(
-    padding: const EdgeInsets.symmetric(vertical: 20),
-    child: Row(
-      crossAxisAlignment: CrossAxisAlignment.start,
+    String nombre, String descripcion, String precio, String imageUrl) {
+  return GestureDetector(
+    onTap: () {},
+    child: Column(
       children: [
-        const SizedBox(width: 20),
-        ClipRRect(
-          borderRadius: BorderRadius.circular(8),
-          child: Image.network(
-            imageUrl,
-            width: 120,
-            height: 120,
-            fit: BoxFit.cover,
-          ),
-        ),
-        const SizedBox(width: 20),
-        Expanded(
-          child: Column(
-            crossAxisAlignment: CrossAxisAlignment.start,
+        Padding(
+          padding: const EdgeInsets.symmetric(vertical: 16, horizontal: 12),
+          child: Row(
+            crossAxisAlignment: CrossAxisAlignment.center,
             children: [
-              Text(
-                titulo,
-                style: const TextStyle(
-                  color: Colors.black,
-                  fontSize: 22,
-                  fontWeight: FontWeight.bold,
+              // Imagen con borde redondeado
+              ClipRRect(
+                borderRadius: BorderRadius.circular(10),
+                child: Image.network(
+                  imageUrl,
+                  width: 100,
+                  height: 100,
+                  fit: BoxFit.cover,
+                  errorBuilder: (context, error, stackTrace) {
+                    return Container(
+                      width: 100,
+                      height: 100,
+                      color: Colors.grey[300],
+                      child: const Icon(Icons.restaurant,
+                          size: 40, color: Colors.grey),
+                    );
+                  },
                 ),
               ),
-              const SizedBox(height: 10),
-              Text(
-                descripcion,
-                style: const TextStyle(
-                  color: Colors.grey,
-                  fontSize: 16,
+              const SizedBox(width: 16),
+
+              Expanded(
+                child: Column(
+                  crossAxisAlignment: CrossAxisAlignment.start,
+                  children: [
+                    // Título con estilo más negrita
+                    Text(
+                      nombre,
+                      style: const TextStyle(
+                        color: Colors.black,
+                        fontSize: 20,
+                        fontWeight: FontWeight.w800,
+                      ),
+                      maxLines: 1,
+                      overflow: TextOverflow.ellipsis,
+                    ),
+                    const SizedBox(height: 6),
+
+                    // Descripción con color gris más claro
+                    Text(
+                      descripcion,
+                      style: TextStyle(
+                        color: Colors.grey[500],
+                        fontSize: 16,
+                        fontWeight: FontWeight.w400,
+                      ),
+                      maxLines: 2,
+                      overflow: TextOverflow.ellipsis,
+                    ),
+
+                    const SizedBox(height: 12),
+
+                    // Precio con estilo destacado
+                    Text(
+                      precio ?? 'Sin Precio',
+                      style: const TextStyle(
+                        color: Colors.black,
+                        fontSize: 22,
+                        fontWeight: FontWeight.bold,
+                      ),
+                    ),
+                  ],
                 ),
               ),
-              const SizedBox(height: 20),
-              Text(
-                precio,
-                style: const TextStyle(
-                  color: Colors.black,
-                  fontSize: 24,
-                  fontWeight: FontWeight.bold,
-                ),
+
+              Icon(
+                Icons.add_circle_outline,
+                size: 28,
+                color: Colors.grey[700],
               ),
             ],
           ),
         ),
-        const SizedBox(width: 20),
+        Divider(
+          height: 1,
+          thickness: 1,
+          color: Colors.grey[300],
+        ),
       ],
     ),
   );

+ 10 - 0
lib/mvvm/views/home/producto/producto_screen.dart

@@ -0,0 +1,10 @@
+import 'package:flutter/material.dart';
+
+class ProductScreen extends StatelessWidget {
+  const ProductScreen({super.key});
+
+  @override
+  Widget build(BuildContext context) {
+    return Placeholder();
+  }
+}

+ 199 - 0
lib/utils/widgets/modal_infonegaocio.dart

@@ -0,0 +1,199 @@
+import 'package:flutter/material.dart';
+
+void mostrarInformacionNegocioBottomSheet(BuildContext context) {
+  showModalBottomSheet(
+    context: context,
+    isScrollControlled: true,
+    backgroundColor: Colors.transparent,
+    builder: (context) => Container(
+      height: MediaQuery.of(context).size.height * 0.7,
+      decoration: const BoxDecoration(
+        color: Colors.white,
+        borderRadius: BorderRadius.only(
+          topLeft: Radius.circular(25),
+          topRight: Radius.circular(25),
+        ),
+      ),
+      child: SingleChildScrollView(
+        child: Column(
+          crossAxisAlignment: CrossAxisAlignment.start,
+          children: [
+            Container(
+              height: 150,
+              width: double.infinity,
+              decoration: BoxDecoration(
+                borderRadius: const BorderRadius.only(
+                  topLeft: Radius.circular(25),
+                  topRight: Radius.circular(25),
+                ),
+                image: DecorationImage(
+                  image: const AssetImage('assets/turquessa_prop.jpg'),
+                  fit: BoxFit.cover,
+                  colorFilter: ColorFilter.mode(
+                    Colors.black.withOpacity(0.3),
+                    BlendMode.darken,
+                  ),
+                ),
+              ),
+              child: Center(
+                child: Column(
+                  mainAxisAlignment: MainAxisAlignment.center,
+                  children: [
+                    Container(
+                      padding: const EdgeInsets.all(8),
+                      decoration: BoxDecoration(
+                        color: Colors.white,
+                        borderRadius: BorderRadius.circular(10),
+                      ),
+                      child: Image.asset('assets/Turquessa.png', height: 50),
+                    ),
+                    const SizedBox(height: 10),
+                    const Text(
+                      'Turquessa-Coffee',
+                      style: TextStyle(
+                        color: Colors.white,
+                        fontSize: 24,
+                        fontWeight: FontWeight.bold,
+                      ),
+                    ),
+                  ],
+                ),
+              ),
+            ),
+
+            // Sección de información
+            Padding(
+              padding: const EdgeInsets.all(20),
+              child: Column(
+                crossAxisAlignment: CrossAxisAlignment.start,
+                children: [
+                  const Text(
+                    'Acerca de nosotros',
+                    style: TextStyle(
+                      fontSize: 18,
+                      fontWeight: FontWeight.bold,
+                      color: Color(0xFF2FD0E5),
+                    ),
+                  ),
+                  const SizedBox(height: 8),
+                  const Text(
+                    'Turquessa-Coffee es una cafetería de especialidad con los mejores granos seleccionados. Nuestro compromiso es ofrecer una experiencia única en cada taza.',
+                    style: TextStyle(fontSize: 14, color: Colors.black87),
+                  ),
+                  const SizedBox(height: 20),
+
+                  // Información de contacto
+                  _buildInfoItem(Icons.location_on, 'Dirección',
+                      'Av. Principal #123, Zona Centro'),
+                  _buildInfoItem(Icons.access_time, 'Horario',
+                      'Lun-Vie: 7:00 - 20:00\nSáb-Dom: 8:00 - 18:00'),
+                  _buildInfoItem(Icons.phone, 'Teléfono', '(55) 1234-5678'),
+                  _buildInfoItem(Icons.email, 'Email', 'info@turquessa.com'),
+                  _buildInfoItem(
+                      Icons.language, 'Sitio web', 'www.turquessa.com'),
+
+                  const SizedBox(height: 20),
+
+                  // Redes sociales
+                  const Text(
+                    'Síguenos en redes sociales',
+                    style: TextStyle(
+                      fontSize: 18,
+                      fontWeight: FontWeight.bold,
+                      color: Color(0xFF2FD0E5),
+                    ),
+                  ),
+                  const SizedBox(height: 10),
+                  Row(
+                    mainAxisAlignment: MainAxisAlignment.spaceEvenly,
+                    children: [
+                      _buildSocialButton(Icons.facebook, 'Facebook'),
+                      _buildSocialButton(Icons.camera_alt, 'Instagram'),
+                      _buildSocialButton(Icons.chat_bubble, 'Twitter'),
+                    ],
+                  ),
+
+                  const SizedBox(height: 30),
+                  Center(
+                    child: TextButton(
+                      onPressed: () => Navigator.pop(context),
+                      child: Container(
+                        padding: const EdgeInsets.symmetric(
+                            horizontal: 30, vertical: 10),
+                        decoration: BoxDecoration(
+                          color: const Color(0xFF2FD0E5),
+                          borderRadius: BorderRadius.circular(20),
+                        ),
+                        child: const Text('Cerrar',
+                            style: TextStyle(color: Colors.white)),
+                      ),
+                    ),
+                  ),
+                  const SizedBox(height: 20),
+                ],
+              ),
+            ),
+          ],
+        ),
+      ),
+    ),
+  );
+}
+
+// Widgets auxiliares para el Bottom Sheet
+Widget _buildInfoItem(IconData icon, String title, String content) {
+  return Padding(
+    padding: const EdgeInsets.symmetric(vertical: 10),
+    child: Row(
+      crossAxisAlignment: CrossAxisAlignment.start,
+      children: [
+        Container(
+          padding: const EdgeInsets.all(8),
+          decoration: BoxDecoration(
+            color: const Color(0xFFE6F9FB),
+            borderRadius: BorderRadius.circular(8),
+          ),
+          child: Icon(icon, color: const Color(0xFF2FD0E5), size: 22),
+        ),
+        const SizedBox(width: 15),
+        Expanded(
+          child: Column(
+            crossAxisAlignment: CrossAxisAlignment.start,
+            children: [
+              Text(
+                title,
+                style: const TextStyle(
+                  fontSize: 16,
+                  fontWeight: FontWeight.bold,
+                  color: Colors.black87,
+                ),
+              ),
+              const SizedBox(height: 4),
+              Text(
+                content,
+                style: const TextStyle(color: Colors.black54, fontSize: 14),
+              ),
+            ],
+          ),
+        ),
+      ],
+    ),
+  );
+}
+
+Widget _buildSocialButton(IconData icon, String platform) {
+  return Column(
+    children: [
+      Container(
+        padding: const EdgeInsets.all(12),
+        decoration: BoxDecoration(
+          color: const Color(0xFFE6F9FB),
+          borderRadius: BorderRadius.circular(12),
+        ),
+        child: Icon(icon, color: const Color(0xFF2FD0E5), size: 24),
+      ),
+      const SizedBox(height: 5),
+      Text(platform, style: const TextStyle(fontSize: 12)),
+    ],
+  );
+}