|
@@ -9,93 +9,8 @@ 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/mvvm/viewmodels/home_view_model.dart';
|
|
import 'package:turquessa_mesas_hoster/utils/widgets/modal_infonegaocio.dart';
|
|
import 'package:turquessa_mesas_hoster/utils/widgets/modal_infonegaocio.dart';
|
|
import 'package:turquessa_mesas_hoster/mvvm/views/home/producto/producto_screen.dart';
|
|
import 'package:turquessa_mesas_hoster/mvvm/views/home/producto/producto_screen.dart';
|
|
-
|
|
|
|
-const List<Map<String, dynamic>> items = [
|
|
|
|
- {
|
|
|
|
- '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',
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- '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',
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- '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',
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- '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',
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- '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',
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- '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',
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- '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',
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- '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',
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- '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',
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- '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',
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- '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',
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- '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',
|
|
|
|
- },
|
|
|
|
-];
|
|
|
|
|
|
+import 'package:turquessa_mesas_hoster/utils/widgets/widgets.dart';
|
|
|
|
+import 'package:turquessa_mesas_hoster/utils/widgets/horario_modal.dart';
|
|
|
|
|
|
class HomeScreen extends StatefulWidget {
|
|
class HomeScreen extends StatefulWidget {
|
|
const HomeScreen({Key? key}) : super(key: key);
|
|
const HomeScreen({Key? key}) : super(key: key);
|
|
@@ -111,10 +26,14 @@ class _HomeScreenState extends State<HomeScreen> {
|
|
final homeViewModel = Provider.of<HomeViewModel>(context, listen: false);
|
|
final homeViewModel = Provider.of<HomeViewModel>(context, listen: false);
|
|
final productoViewModel =
|
|
final productoViewModel =
|
|
Provider.of<ProductoViewModel>(context, listen: false);
|
|
Provider.of<ProductoViewModel>(context, listen: false);
|
|
|
|
+ setModalOffService(context);
|
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
|
Provider.of<ProductoViewModel>(context, listen: false)
|
|
Provider.of<ProductoViewModel>(context, listen: false)
|
|
.sincronizarProductosYCategorias();
|
|
.sincronizarProductosYCategorias();
|
|
|
|
+ homeViewModel.isHorarioServicio();
|
|
homeViewModel.fetchLocalCategorias();
|
|
homeViewModel.fetchLocalCategorias();
|
|
|
|
+ homeViewModel
|
|
|
|
+ .fetchLocalProductosPorCategoria(homeViewModel.selectedCategoria!);
|
|
productoViewModel.sincronizarProductos();
|
|
productoViewModel.sincronizarProductos();
|
|
productoViewModel.sincronizarCategorias();
|
|
productoViewModel.sincronizarCategorias();
|
|
productoViewModel.fetchLocalAll();
|
|
productoViewModel.fetchLocalAll();
|
|
@@ -123,9 +42,11 @@ class _HomeScreenState extends State<HomeScreen> {
|
|
|
|
|
|
@override
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
Widget build(BuildContext context) {
|
|
- final homeViewModel = Provider.of<HomeViewModel>(context);
|
|
|
|
- final pedidoViewModel = Provider.of<ProductoViewModel>(context);
|
|
|
|
|
|
+ final homeViewModel = Provider.of<HomeViewModel>(context, listen: false);
|
|
|
|
+ final productos = homeViewModel.productos ?? [];
|
|
return Scaffold(
|
|
return Scaffold(
|
|
|
|
+ key: homeViewModel.scaffoldKey,
|
|
|
|
+ drawer: const CustomDrawer(),
|
|
bottomNavigationBar: BottomAppBar(
|
|
bottomNavigationBar: BottomAppBar(
|
|
color: Colors.black,
|
|
color: Colors.black,
|
|
child: Row(
|
|
child: Row(
|
|
@@ -133,7 +54,9 @@ class _HomeScreenState extends State<HomeScreen> {
|
|
children: [
|
|
children: [
|
|
IconButton(
|
|
IconButton(
|
|
icon: const Icon(Icons.search, color: Colors.white),
|
|
icon: const Icon(Icons.search, color: Colors.white),
|
|
- onPressed: () {},
|
|
|
|
|
|
+ onPressed: () {
|
|
|
|
+ homeViewModel.openDrawer();
|
|
|
|
+ },
|
|
),
|
|
),
|
|
IconButton(
|
|
IconButton(
|
|
icon: const Icon(Icons.menu, color: Colors.white),
|
|
icon: const Icon(Icons.menu, color: Colors.white),
|
|
@@ -150,7 +73,9 @@ class _HomeScreenState extends State<HomeScreen> {
|
|
),
|
|
),
|
|
IconButton(
|
|
IconButton(
|
|
icon: const Icon(Icons.favorite_border, color: Colors.white),
|
|
icon: const Icon(Icons.favorite_border, color: Colors.white),
|
|
- onPressed: () {},
|
|
|
|
|
|
+ onPressed: () {
|
|
|
|
+ Navigator.of(context).pushNamed('perfil');
|
|
|
|
+ },
|
|
),
|
|
),
|
|
],
|
|
],
|
|
)),
|
|
)),
|
|
@@ -158,6 +83,7 @@ class _HomeScreenState extends State<HomeScreen> {
|
|
body: CustomScrollView(
|
|
body: CustomScrollView(
|
|
slivers: [
|
|
slivers: [
|
|
SliverAppBar(
|
|
SliverAppBar(
|
|
|
|
+ automaticallyImplyLeading: false,
|
|
floating: true,
|
|
floating: true,
|
|
expandedHeight: 200, // Ajusta la altura para acomodar la imagen
|
|
expandedHeight: 200, // Ajusta la altura para acomodar la imagen
|
|
flexibleSpace: FlexibleSpaceBar(
|
|
flexibleSpace: FlexibleSpaceBar(
|
|
@@ -183,7 +109,7 @@ class _HomeScreenState extends State<HomeScreen> {
|
|
borderRadius: BorderRadius.circular(12),
|
|
borderRadius: BorderRadius.circular(12),
|
|
),
|
|
),
|
|
child: Center(
|
|
child: Center(
|
|
- child: Image.asset('assets/Turquessa.png'),
|
|
|
|
|
|
+ child: Image.asset('assets/logo.png'),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
const SizedBox(width: 20),
|
|
const SizedBox(width: 20),
|
|
@@ -232,13 +158,17 @@ class _HomeScreenState extends State<HomeScreen> {
|
|
SliverList(
|
|
SliverList(
|
|
delegate: SliverChildBuilderDelegate(
|
|
delegate: SliverChildBuilderDelegate(
|
|
(context, index) {
|
|
(context, index) {
|
|
- return _buildBurgerItem(
|
|
|
|
- items[index]['nombre'],
|
|
|
|
- items[index]['descripcion'],
|
|
|
|
- items[index]['precio'],
|
|
|
|
- items[index]['imageUrl'],
|
|
|
|
- context,
|
|
|
|
- );
|
|
|
|
|
|
+ productos.isEmpty
|
|
|
|
+ ? _buildBurgerItem(
|
|
|
|
+ productos[index].nombre!,
|
|
|
|
+ productos[index].descripcion!,
|
|
|
|
+ productos[index].precio.toString(),
|
|
|
|
+ productos[index].media![0].ruta! ?? ' ',
|
|
|
|
+ context,
|
|
|
|
+ )
|
|
|
|
+ : const Center(
|
|
|
|
+ child: CircularProgressIndicator(),
|
|
|
|
+ );
|
|
},
|
|
},
|
|
childCount: items.length,
|
|
childCount: items.length,
|
|
))
|
|
))
|
|
@@ -251,8 +181,7 @@ class CategoriasSliverChild extends SliverPersistentHeaderDelegate {
|
|
@override
|
|
@override
|
|
Widget build(
|
|
Widget build(
|
|
BuildContext context, double shrinkOffset, bool overlapsContent) {
|
|
BuildContext context, double shrinkOffset, bool overlapsContent) {
|
|
- return SingleChildScrollView(
|
|
|
|
- scrollDirection: Axis.horizontal, child: CategoriasNavBar());
|
|
|
|
|
|
+ return CategoriasNavBar();
|
|
}
|
|
}
|
|
|
|
|
|
@override
|
|
@override
|