Bladeren bron

horario works

c90Beretta 1 maand geleden
bovenliggende
commit
3035913b49

+ 1 - 2
android/gradle.properties

@@ -1,4 +1,3 @@
 org.gradle.jvmargs=-Xmx4G
 android.useAndroidX=true
-android.enableJetifier=true
-org.gradle.java.home=/opt/homebrew/Cellar/openjdk@17/17.0.14/libexec/openjdk.jdk/Contents/Home
+android.enableJetifier=true

+ 1 - 3
android/gradle/wrapper/gradle-wrapper.properties

@@ -1,7 +1,5 @@
-#Wed Feb 26 19:48:01 MST 2025
 distributionBase=GRADLE_USER_HOME
 distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
 zipStoreBase=GRADLE_USER_HOME
 zipStorePath=wrapper/dists
-org.gradle.java.home=/opt/homebrew/Cellar/openjdk@17/17.0.14/libexec/openjdk.jdk/Contents/Home
+distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip

+ 1 - 0
lib/core/models/producto_model.dart

@@ -21,6 +21,7 @@ class Producto extends Basico {
   List<Media>? media;
   int? idWeb;
   String? sincronizado;
+  int? cantidad;
 
   Producto({
     super.id,

+ 23 - 0
lib/mvvm/viewmodels/home_view_model.dart

@@ -16,6 +16,8 @@ class HomeViewModel extends ChangeNotifier {
     required this.productoRepository,
     required this.categoriaRepository,
   });
+  bool _isOpen = false;
+  bool get isopen => _isOpen;
 
   String _busqueda = "";
   String get busqueda => _busqueda;
@@ -104,6 +106,27 @@ class HomeViewModel extends ChangeNotifier {
     }
   }
 
+  void isHorarioServicio() {
+    DateTime now = DateTime.now();
+    int hora = now.hour;
+    int minuto = now.minute;
+    int weekday = now.weekday;
+
+// 1 = Lunes, 7 = Domingo
+    bool isOpen = false;
+
+    if (weekday >= 1 && weekday <= 6) {
+      // Lunes a Sábado: 8:00 a.m. - 10:00 p.m.
+      isOpen = (hora >= 8 && hora < 22) || (hora == 22 && minuto == 0);
+    } else if (weekday == 7) {
+      // Domingo: 4:00 p.m. - 10:00 p.m.
+      isOpen = (hora >= 16 && hora < 22) || (hora == 22 && minuto == 0);
+    }
+
+    _isOpen = isOpen;
+    notifyListeners();
+  }
+
   // void nextPage() {
   //   if (_currentPage < totalPages) {
   //     fetchLocal(page: _currentPage + 1);

+ 5 - 3
lib/mvvm/views/home/home_screen.dart

@@ -10,6 +10,7 @@ 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/mvvm/views/home/producto/producto_screen.dart';
 import 'package:turquessa_mesas_hoster/utils/widgets/widgets.dart';
+import 'package:turquessa_mesas_hoster/utils/widgets/horario_modal.dart';
 
 const List<Map<String, dynamic>> items = [
   {
@@ -112,10 +113,12 @@ class _HomeScreenState extends State<HomeScreen> {
     final homeViewModel = Provider.of<HomeViewModel>(context, listen: false);
     final productoViewModel =
         Provider.of<ProductoViewModel>(context, listen: false);
+    setModalOffService(context);
     WidgetsBinding.instance.addPostFrameCallback((_) {
       Provider.of<ProductoViewModel>(context, listen: false)
           .sincronizarProductosYCategorias();
       homeViewModel.fetchLocalCategorias();
+      homeViewModel.isHorarioServicio();
       productoViewModel.sincronizarProductos();
       productoViewModel.sincronizarCategorias();
       productoViewModel.fetchLocalAll();
@@ -124,9 +127,8 @@ class _HomeScreenState extends State<HomeScreen> {
 
   @override
   Widget build(BuildContext context) {
-    final homeViewModel = Provider.of<HomeViewModel>(context);
-    final pedidoViewModel = Provider.of<ProductoViewModel>(context);
-    final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>();
+    final homeViewModel = Provider.of<HomeViewModel>(context, listen: false);
+
     return Scaffold(
         key: homeViewModel.scaffoldKey,
         drawer: const CustomDrawer(),

+ 64 - 0
lib/utils/widgets/horario_modal.dart

@@ -0,0 +1,64 @@
+import 'package:flutter/material.dart';
+
+void verificarHorarioModal(BuildContext context) {
+  DateTime now = DateTime.now();
+  int hora = now.hour;
+  int minuto = now.minute;
+  int weekday = now.weekday;
+  print(now);
+// 1 = Lunes, 7 = Domingo
+  bool isOpen = false;
+
+  if (weekday >= 1 && weekday <= 6) {
+    // Lunes a Sábado: 8:00 a.m. - 10:00 p.m.
+    isOpen = (hora >= 8 && hora < 22) || (hora == 22 && minuto == 0);
+  } else if (weekday == 7) {
+    // Domingo: 4:00 p.m. - 10:00 p.m.
+    isOpen = (hora >= 16 && hora < 22) || (hora == 22 && minuto == 0);
+  }
+  if (!isOpen) {}
+}
+
+class _DetallesD extends StatelessWidget {
+  const _DetallesD({super.key});
+
+  @override
+  Widget build(BuildContext context) {
+    return Container();
+  }
+}
+
+Widget _buildScheduleRow(String day, String hours, bool isHighlighted) {
+  return Container(
+    padding: const EdgeInsets.symmetric(vertical: 12, horizontal: 16),
+    decoration: BoxDecoration(
+      color: isHighlighted ? Colors.blue[50] : Colors.transparent,
+      borderRadius: BorderRadius.circular(8),
+    ),
+    child: Row(
+      mainAxisAlignment: MainAxisAlignment.spaceBetween,
+      children: [
+        Text(
+          day,
+          style: TextStyle(
+            fontSize: 16,
+            fontWeight: isHighlighted ? FontWeight.bold : FontWeight.normal,
+          ),
+        ),
+        Row(
+          children: [
+            const Icon(Icons.access_time, size: 18),
+            const SizedBox(width: 8),
+            Text(
+              hours,
+              style: TextStyle(
+                fontSize: 16,
+                fontWeight: isHighlighted ? FontWeight.bold : FontWeight.normal,
+              ),
+            ),
+          ],
+        ),
+      ],
+    ),
+  );
+}

+ 31 - 2
lib/utils/widgets/modal_infonegaocio.dart

@@ -1,12 +1,24 @@
 import 'package:animate_do/animate_do.dart';
 import 'package:flutter/material.dart';
+import 'package:provider/provider.dart';
+import 'package:turquessa_mesas_hoster/mvvm/viewmodels/home_view_model.dart';
+import 'package:turquessa_mesas_hoster/utils/themes.dart';
+
+void setModalOffService(BuildContext context) {
+  final homeviewmodel = Provider.of<HomeViewModel>(context, listen: false);
+
+  if (homeviewmodel.isopen) {
+    mostrarInformacionNegocioBottomSheet(context);
+  }
+}
 
 void mostrarInformacionNegocioBottomSheet(BuildContext context) {
+  final homeviewmodel = Provider.of<HomeViewModel>(context, listen: false);
   showModalBottomSheet(
     context: context,
     isScrollControlled: true,
     backgroundColor: Colors.transparent,
-    builder: (context) => BounceInUp(
+    builder: (context) => SlideInUp(
       duration: const Duration(milliseconds: 450),
       child: Container(
         height: MediaQuery.of(context).size.height * 0.7,
@@ -63,7 +75,24 @@ void mostrarInformacionNegocioBottomSheet(BuildContext context) {
                   ),
                 ),
               ),
-
+              Row(
+                mainAxisAlignment: MainAxisAlignment.center,
+                crossAxisAlignment: CrossAxisAlignment.center,
+                children: [
+                  Padding(
+                    padding: const EdgeInsets.all(15),
+                    child: Text(
+                      homeviewmodel.isopen
+                          ? "Turquessa Esta: Abierto"
+                          : "Turquessa Esta: Cerrado",
+                      style: TextStyle(
+                          fontSize: 30,
+                          color: AppTheme.primary,
+                          fontWeight: FontWeight.bold),
+                    ),
+                  ),
+                ],
+              ),
               // Sección de información
               Padding(
                 padding: const EdgeInsets.all(20),