diff --git a/android/app/build.gradle b/android/app/build.gradle index b2e72ac..c0b77eb 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -24,7 +24,7 @@ android { applicationId = "com.example.store_sqlite" // You can update the following values to match your application needs. // For more information, see: https://flutter.dev/to/review-gradle-config. - minSdk = flutter.minSdkVersion + minSdk = 26 targetSdk = flutter.targetSdkVersion versionCode = flutter.versionCode versionName = flutter.versionName diff --git a/assets/img/logo_pizza.jfif b/assets/img/logo_pizza.jfif new file mode 100644 index 0000000..1795448 Binary files /dev/null and b/assets/img/logo_pizza.jfif differ diff --git a/lib/controller/Comunidad_controller.dart b/lib/controller/Comunidad_controller.dart new file mode 100644 index 0000000..a57f6da --- /dev/null +++ b/lib/controller/Comunidad_controller.dart @@ -0,0 +1,28 @@ +import 'package:store_sqlite/database/database.dart'; +import 'package:store_sqlite/models/comunidad_model.dart'; + +class ComunidadController { + final TiendaDataBase _dataBase = TiendaDataBase(); + + Future insertarComunidad(String table, Map row) async { + final db = await _dataBase.database; + return await db.insert(table, row); + } + + Future?> mostrarTodasLasComunidades() async { + var con = await _dataBase.database; + var result = await con.query('comunidad'); + return result.map((comunidad)=>ComunidadModel.fromMap(comunidad)).toList(); + } + + Future actualizarComunidad(String table, Map row) async { + var con = await _dataBase.database; + return await con + .update(table, row, where: 'id_comunidad = ?', whereArgs: [row['id_comunidad']]); + } + Future eliminarComunidad(String table, int id_comunidad) async { + var con = await _dataBase.database; + return await con.delete(table, where: 'id_comunidad = ?', whereArgs: [id_comunidad]); + } + +} \ No newline at end of file diff --git a/lib/controller/carrito_controller.dart b/lib/controller/carrito_controller.dart new file mode 100644 index 0000000..ece397e --- /dev/null +++ b/lib/controller/carrito_controller.dart @@ -0,0 +1,40 @@ +import 'package:store_sqlite/database/database.dart'; +import 'package:store_sqlite/models/carrito_model.dart'; + +class CarritoController { + final TiendaDataBase _dataBase = TiendaDataBase(); + + Future insertCarrito(String table, Map row) async { + final db = await _dataBase.database; + return await db.insert(table, row); + } + + Future?> mostrarCarritos() async { + var con = await _dataBase.database; + var result = await con.query('id_carrito'); + return result.map((carrito) => CarritoModel.fromMap(carrito)).toList(); + } + Future>?> mostrarTodosLosCarritos() async { + var con = await _dataBase.database; + var result = await con.rawQuery(''' + SELECT *,sum(cantidad) as cantidad, sum(subtotal) as subtotal + FROM carrito c + inner join producto p on c.id_producto = p.id_producto + group by p.id_producto + '''); // Aquí se pasa el parámetro + print(result); + return result; + } + + Future actualizarCarrito(String table, Map row) async { + var con = await _dataBase.database; + return await con.update(table, row, + where: 'id_carrito = ?', whereArgs: [row['id_carrito']]); + } + + Future eliminarCarrito(String table, int id_carrito) async { + var con = await _dataBase.database; + return await con + .delete(table, where: 'id_carrito = ?', whereArgs: [id_carrito]); + } +} diff --git a/lib/controller/categoria_controller.dart b/lib/controller/categoria_controller.dart new file mode 100644 index 0000000..d5d1785 --- /dev/null +++ b/lib/controller/categoria_controller.dart @@ -0,0 +1,30 @@ +import 'package:sqflite/sqflite.dart'; +import 'package:store_sqlite/database/database.dart'; +import 'package:store_sqlite/models/categoria_model.dart'; + +class CategoriaController { + final TiendaDataBase _dataBase = TiendaDataBase(); + + Future insertCategoria(String table, Map row) async { + final db = await _dataBase.database; + return await db.insert(table, row); + } + + Future?> mostrarTodasLasCategorias() async { + var con = await _dataBase.database; + var result = await con.query('categoria'); + return result.map((categoria)=>CategoriaModel.fromMap(categoria)).toList(); + } + + Future actualizarCategoria(String table, Map row) async { + var con = await _dataBase.database; + return await con + .update(table, row, where: 'id_categoria = ?', whereArgs: [row['id_categoria']]); + } + Future eliminarCategoria(String table, int id_categoria) async { + var con = await _dataBase.database; + return await con.delete(table, where: 'id_categoria = ?', whereArgs: [id_categoria]); + } + + // Métodos adicionales como update, delete, etc. +} diff --git a/lib/controller/direccion_controller.dart b/lib/controller/direccion_controller.dart new file mode 100644 index 0000000..76b8662 --- /dev/null +++ b/lib/controller/direccion_controller.dart @@ -0,0 +1,28 @@ +import 'package:store_sqlite/database/database.dart'; +import 'package:store_sqlite/models/direccion_model.dart'; + +class DireccionController { + final TiendaDataBase _dataBase = TiendaDataBase(); + + Future insertDireccion(String table, Map row) async { + final db = await _dataBase.database; + return await db.insert(table, row); + } + + Future?> mostrarTodasLasDirecciones() async { + var con = await _dataBase.database; + var result = await con.query('categoria'); + return result.map((direccion)=>DireccionModel.fromMap(direccion)).toList(); + } + + Future actualizarDireccion(String table, Map row) async { + var con = await _dataBase.database; + return await con + .update(table, row, where: 'id_direccion = ?', whereArgs: [row['id_direccion']]); + } + Future eliminarDireccion(String table, int id_direccion) async { + var con = await _dataBase.database; + return await con.delete(table, where: 'id_direccion = ?', whereArgs: [id_direccion]); + } + +} \ No newline at end of file diff --git a/lib/controller/listaPedido_controller.dart b/lib/controller/listaPedido_controller.dart new file mode 100644 index 0000000..e48b6a0 --- /dev/null +++ b/lib/controller/listaPedido_controller.dart @@ -0,0 +1,28 @@ +import 'package:store_sqlite/database/database.dart'; +import 'package:store_sqlite/models/lista_pedido_model.dart'; + +class ListapedidoController { + final TiendaDataBase _dataBase = TiendaDataBase(); + + Future insertarListaPedido(String table, Map row) async { + final db = await _dataBase.database; + return await db.insert(table, row); + } + + Future?> mostrarTodosLosListaPedidos() async { + var con = await _dataBase.database; + var result = await con.query('lista_pedido'); + return result.map((lista_pedido)=>ListaPedidoModel.fromMap(lista_pedido)).toList(); + } + + Future actualizarListaPedido(String table, Map row) async { + var con = await _dataBase.database; + return await con + .update(table, row, where: 'id_lista_pedido = ?', whereArgs: [row['id_lista_pedido']]); + } + Future eliminarListaPedido(String table, int id_lista_pedido) async { + var con = await _dataBase.database; + return await con.delete(table, where: 'id_lista_pedido = ?', whereArgs: [id_lista_pedido]); + } + +} \ No newline at end of file diff --git a/lib/controller/municipio_controller.dart b/lib/controller/municipio_controller.dart new file mode 100644 index 0000000..7df0f30 --- /dev/null +++ b/lib/controller/municipio_controller.dart @@ -0,0 +1,29 @@ +import 'package:store_sqlite/database/database.dart'; +import 'package:store_sqlite/models/municipio_model.dart'; + +class MunicipioController { + final TiendaDataBase _dataBase = TiendaDataBase(); + + Future insertarMunicipio(String table, Map row) async { + final db = await _dataBase.database; + return await db.insert(table, row); + } + + Future?> mostrarTodosLosMunicipios() async { + var con = await _dataBase.database; + var result = await con.query('municipio'); + return result.map((municipio)=>MunicipioModel.fromMap(municipio)).toList(); + } + + Future actualizarMunicipio(String table, Map row) async { + var con = await _dataBase.database; + return await con + .update(table, row, where: 'id_municipio = ?', whereArgs: [row['id_municipio']]); + } + Future eliminarMunicipio(String table, int id_municipio) async { + var con = await _dataBase.database; + return await con.delete(table, where: 'id_municipio = ?', whereArgs: [id_municipio]); + } + + +} \ No newline at end of file diff --git a/lib/controller/pedido_controller.dart b/lib/controller/pedido_controller.dart new file mode 100644 index 0000000..7e464ce --- /dev/null +++ b/lib/controller/pedido_controller.dart @@ -0,0 +1,120 @@ +import 'package:store_sqlite/database/database.dart'; +import 'package:store_sqlite/models/pedido_model.dart'; + +class PedidoController { + final TiendaDataBase _dataBase = TiendaDataBase(); + + Future insertarPedido(String table, Map row) async { + final db = await _dataBase.database; + return await db.insert(table, row); + } + + Future?> mostrarTodosLosPedidos(int opc) async { + var con = await _dataBase.database; + + // Definimos el tipo de result para mayor claridad. + List> result; + + switch (opc) { + case 0: + result = + await con.query('pedido', where: 'id_status = ?', whereArgs: [2]); + break; + case 1: + result = await con.query('pedido'); + break; + case 2: + result = + await con.query('pedido', where: 'id_status = ?', whereArgs: [1]); + break; + default: + return []; // Si opc no coincide con ninguno, retornamos una lista vacía. + } + + // Verificamos si result está vacío o nulo antes de mapear. + if (result.isNotEmpty) { + return result.map((pedido) => PedidoModel.fromMap(pedido)).toList(); + } else { + return []; + } + } + + Future actualizarPedido(String table, Map row) async { + var con = await _dataBase.database; + return await con.update(table, row, + where: 'id_pedido = ?', whereArgs: [row['id_pedido']]); + } + + Future eliminarPedido(String table, int id_pedido) async { + var con = await _dataBase.database; + return await con + .delete(table, where: 'id_pedido = ?', whereArgs: [id_pedido]); + } + + Future>?> mostrarPedidosConListaPedido( + int? id_pedido) async { + var con = await _dataBase.database; + var result = await con.rawQuery(''' + SELECT * + FROM lista_pedido + inner join producto on lista_pedido.id_producto=producto.id_producto + where id_pedido=? + ''', [id_pedido]); // Aquí se pasa el parámetro + print(id_pedido); + print(result); + return result; + } + + Future>?> mostrarTodosLosPedidosSinId() async { + var con = await _dataBase.database; + var result = await con.rawQuery(''' + SELECT * + FROM pedido p + inner join direccion d on p.id_direccion=d.id_direccion + '''); // Aquí se pasa el parámetro + + print(result); + return result; + } + + Future>?> mostrarPedidoDatosCliente( + int? id_pedido) async { + var con = await _dataBase.database; + var result = await con.rawQuery(''' +Select * from direccion d +inner join pedido p on d.id_direccion=p.id_direccion +inner join comunidad c on d.id_comunidad=c.id_comunidad +inner join municipio m on c.id_municipio=m.id_municipio +where p.id_pedido=? +group by p.id_pedido +limit 1 + ''', [id_pedido]); // Aquí se pasa el parámetro + print(id_pedido); + print(result); + return result; + +// SELECT +// pedido.id_pedido, +// pedido.fecha_entrega, +// pedido.id_status, +// direccion.calle, +// direccion.colonia, +// direccion.no_exterior, +// direccion.no_interior, +// direccion.num_telefono, +// FROM +// lista_pedido +// INNER JOIN +// producto ON lista_pedido.id_producto = producto.id_producto +// INNER JOIN +// pedido ON lista_pedido.id_pedido = pedido.id_pedido +// INNER JOIN +// direccion ON pedido.id_direccion = direccion.id_direccion +// INNER JOIN +// categoria ON producto.id_categoria = categoria.id_categoria +// WHERE +// lista_pedido.id_pedido = ? +// GROUP BY +// pedido.id_pedido; + } +} diff --git a/lib/controller/producto_controller.dart b/lib/controller/producto_controller.dart new file mode 100644 index 0000000..b350539 --- /dev/null +++ b/lib/controller/producto_controller.dart @@ -0,0 +1,42 @@ +import 'package:store_sqlite/database/database.dart'; +import 'package:store_sqlite/models/producto_model.dart'; + +class ProductoController { + final TiendaDataBase _dataBase = TiendaDataBase(); + + Future insertProducto(String table, Map row) async { + final db = await _dataBase.database; + return await db.insert(table, row); + } + + Future?> mostrarTodosLosProductos() async { + var con = await _dataBase.database; + var result = await con.query('producto'); + return result.map((producto) => ProductoModel.fromMap(producto)).toList(); + } + + Future>?> mostrarProductosConCategoria() async { + var con = await _dataBase.database; + var result = await con.rawQuery( + ''' + SELECT * + FROM producto p + inner join categoria c on p.id_categoria=c.id_categoria + ''', + ); + return result; + } + + + Future actualizarProducto(String table, Map row) async { + var con = await _dataBase.database; + return await con.update(table, row, + where: 'id_producto = ?', whereArgs: [row['id_producto']]); + } + + Future eliminarProducto(String table, int id_producto) async { + var con = await _dataBase.database; + return await con + .delete(table, where: 'id_producto = ?', whereArgs: [id_producto]); + } +} diff --git a/lib/controller/status_controller.dart b/lib/controller/status_controller.dart new file mode 100644 index 0000000..41b126c --- /dev/null +++ b/lib/controller/status_controller.dart @@ -0,0 +1,28 @@ +import 'package:store_sqlite/database/database.dart'; +import 'package:store_sqlite/models/status_model.dart'; + +class StatusController { + final TiendaDataBase _dataBase = TiendaDataBase(); + + Future insertarNuevoStatus(String table, Map row) async { + final db = await _dataBase.database; + return await db.insert(table, row); + } + + Future?> mostrarTodosLosStatus() async { + var con = await _dataBase.database; + var result = await con.query('status'); + return result.map((status)=>StatusModel.fromMap(status)).toList(); + } + + Future actualizarStatus(String table, Map row) async { + var con = await _dataBase.database; + return await con + .update(table, row, where: 'id_status = ?', whereArgs: [row['id_status']]); + } + Future eliminarStatus(String table, int id_status) async { + var con = await _dataBase.database; + return await con.delete(table, where: 'id_status = ?', whereArgs: [id_status]); + } + +} \ No newline at end of file diff --git a/lib/database/database.dart b/lib/database/database.dart new file mode 100644 index 0000000..db2db85 --- /dev/null +++ b/lib/database/database.dart @@ -0,0 +1,255 @@ +import 'dart:io'; +import 'package:path_provider/path_provider.dart'; +import 'package:sqflite/sqflite.dart'; +import 'package:path/path.dart'; +import 'package:store_sqlite/models/carrito_model.dart'; +import 'package:store_sqlite/models/categoria_model.dart'; +import 'package:store_sqlite/models/producto_model.dart'; + +class TiendaDataBase { + static final NAMEDB = 'PizzeriaDB'; + static final VERSIONDB = 1; + + static Database? _database; + + Future get database async { + if (_database != null) return _database!; + return _database = await initDatabase(); + } + + Future initDatabase() async { + Directory folder = await getApplicationDocumentsDirectory(); + String path = join(folder.path, NAMEDB); + return openDatabase( + path, + version: VERSIONDB, + onCreate: (db, version) { + String query1 = ''' + CREATE TABLE categoria( + id_categoria INTEGER PRIMARY KEY, + categoria VARCHAR(100) + ); + '''; + + db.execute(query1); + + String query2 = ''' + CREATE TABLE producto( + id_producto INTEGER PRIMARY KEY, + producto VARCHAR(100), + precio REAL, + descripcion VARCHAR(300), + id_categoria INT, + img_producto VARCHAR(150), + CONSTRAINT Producto_categoria_fk FOREIGN KEY(id_categoria) REFERENCES categoria(id_categoria) + );'''; + db.execute(query2); + + String query3 = ''' + CREATE TABLE carrito( + id_carrito INTEGER PRIMARY KEY, + id_producto INT, + cantidad INT, + subtotal NUMERIC, + CONSTRAINT carrito_producto_fk FOREIGN KEY(id_producto) REFERENCES producto(id_producto) + );'''; + db.execute(query3); + + String query4 = ''' + CREATE TABLE status( + id_status INTEGER PRIMARY KEY, + status VARCHAR(50) + );'''; + + db.execute(query4); + String query5 = ''' + CREATE TABLE municipio( + id_municipio INTEGER PRIMARY KEY, + municipio varchar(150) + );'''; + + db.execute(query5); + String query6 = ''' + CREATE TABLE comunidad( + id_comunidad INTEGER PRIMARY KEY, + id_municipio INT, + comunidad VARCHAR(150), + CONSTRAINT comunidad_municipio_fk FOREIGN KEY(id_municipio) REFERENCES municipio(id_municipio) + );'''; + db.execute(query6); + + String query7 = ''' + CREATE TABLE direccion( + id_direccion INTEGER PRIMARY KEY, + id_comunidad INT, + calle VARCHAR(150) not null, + colonia VARCHAR(150), + no_exterior INT not null, + no_interior INT, + num_telefono VARCHAR(18), + nombre_cliente VARCHAR(100) not null, + CONSTRAINT direccion_comunidad_fk FOREIGN KEY(id_comunidad) REFERENCES comunidad(id_comunidad) + );'''; + db.execute(query7); + + String query8 = ''' + CREATE TABLE pedido( + id_pedido INTEGER PRIMARY KEY, + id_status INT, + id_direccion INT, + fecha_entrega TEXT, + CONSTRAINT pedido_status_fk FOREIGN KEY(id_status) REFERENCES status(id_status), + CONSTRAINT pedido_direccion_fk FOREIGN KEY(id_direccion) REFERENCES direccion(id_direccion) + );'''; + db.execute(query8); + + String query9 = ''' + CREATE TABLE lista_pedido( + id_lista_pedido INTEGER PRIMARY KEY, + id_producto INT, + id_pedido int, + cantidad INT, + precio Real, + subtotal NUMERIC, + Constraint listaPpedido_pedido_fk Foreign key(id_pedido) references pedido(id_pedido), + CONSTRAINT listaPedido_producto_fk FOREIGN KEY(id_producto) REFERENCES producto(id_producto) + );'''; + db.execute(query9); + + String query10 = ''' + INSERT INTO categoria + (categoria) + VALUES + ('Pizza'), + ('Refreco'), + ('Agua') + ; +'''; + db.execute(query10); + + String query11 = ''' + INSERT INTO producto + (producto, precio, descripcion, id_categoria) +VALUES + ('Pizza Grande de Peperoni', 200.50, 'Pizza Grande de 10 Rebanadas, con mucho peperoni y queso, orilla normal', 1), + ('Refresco 2L Pepsi Sabor cola', 29.00, 'Pepsi 2L sabor Cola', 2), + ('Agua de Jamaica 1L Marca La mamá de Pichis', 25.00, 'Agua de jamaica 100% natural', 3); + +'''; + db.execute(query11); + + String query12 = ''' + Insert into status(status)values('completado'),('pendiente'),('cancelado') + '''; + db.execute(query12); + + String query13 = ''' + insert into municipio(municipio)values('Cortazar'),('Celaya'),('Salamanca'),('Villagran') + '''; + db.execute(query13); + String query14 = ''' + insert into comunidad(comunidad,id_municipio)values('Tierra Fria',1) + '''; + db.execute(query14); + String query15 = ''' + insert into direccion(id_comunidad,calle,colonia,no_exterior,no_interior,num_telefono,nombre_cliente) + values (1,'Alameda','Alameda',104,104,'4111549487','Miguel Vera Franco') + '''; + db.execute(query15); + + String query17 = ''' + insert into pedido(id_status,id_direccion,fecha_entrega)values(1,1,'2024-10-18'),(2,1,'2024-11-19'),(3,1,'2024-11-20') + '''; + db.execute(query17); + + String query16 = ''' + INSERT INTO lista_pedido(id_pedido, id_producto, cantidad, subtotal, precio) + VALUES + (1, 1, 2, 211, 105), + (1, 3, 3, 333, 111), + (2, 3, 3, 333, 111), + (3, 3, 3, 333, 111) + '''; + db.execute(query16); + // int? id_lista_pedido, id_producto, cantidad; + // double? subtotal; + print('se creo la base de datos'); + }, + ); + } // initdatabase + + Future CREATE_PEDIDO( + Map pedido, Map direccion) async { + // Obtener conexión a la base de datos + var con = await database; + + // Inserta en la tabla direccion y obtiene el id generado + int id_direccion = await con.insert('direccion', direccion); + + // Asigna id_direccion al mapa pedido + pedido['id_direccion'] = id_direccion; + + // Inserta el pedido con el id_direccion agregado y obtiene el id del pedido + int id_pedido = await con.insert('pedido', pedido); + + // Recupera los productos del carrito + List carritoProducts = await SELECT_CARRITO(); + + // Imprimir los productos del carrito para verificar + print('Productos en el carrito:'); + for (var producto in carritoProducts) { + print('ID Producto: ${producto.id_producto}, ' + 'Cantidad: ${producto.cantidad}, ' + 'Subtotal: ${producto.subtotal}'); + } + + // Inserta cada producto del carrito en la tabla lista_pedido + for (var producto in carritoProducts) { + // Asegurarse de que cantidad y subtotal no sean nulos + int cantidad = + producto.cantidad ?? 0; // Proporciona 0 si cantidad es nulo + double subtotal = (producto.subtotal ?? 0.0) + .toDouble(); // Asegúrate de que subtotal sea un double + + // Verificar que la cantidad no sea cero antes de calcular el precio unitario + double precio = cantidad > 0 ? subtotal / cantidad : 0.0; + + Map listaPedido = { + 'id_producto': producto.id_producto, + 'id_pedido': id_pedido, + 'cantidad': cantidad, + 'precio': precio, + 'subtotal': subtotal, + }; + + await con.insert('lista_pedido', listaPedido); + } + + // Limpia el carrito después de crear el pedido, si es necesario + await con.delete('carrito'); + + return id_pedido; + } + + Future> SELECT_CARRITO() async { + var con = await database; + var result = await con.query('carrito'); + + // Mapea cada resultado al modelo CarritoModel, asegurando que no sea nulo + return result.map((carrito) => CarritoModel.fromMap(carrito)).toList() ?? + []; + } +} + + + + // Future UPDATE(String table, Map row) async { + // var con = await database; + // return await con + // .update(table, row, where: 'idMovie = ?', whereArgs: [row['idMovie']]); + // } + + // Future DELETE(String table, int idMovie) async { + // var con = await database; + // return await con.delete(table, where: 'idMovie = ?', whereArgs: [idMovie]); + // } \ No newline at end of file diff --git a/lib/main.dart b/lib/main.dart index 1aee164..beb9f39 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,8 +1,8 @@ import 'package:flutter/material.dart'; import 'package:store_sqlite/routes/rutes.dart'; -import 'package:store_sqlite/screens/login/login_ScreenH.dart'; -import 'package:store_sqlite/screens/login/login_screenV.dart'; -import 'package:store_sqlite/screens/loginResponsiveScreen.dart'; +import 'package:store_sqlite/screens/MenuAppResponsiveScreen.dart'; +import 'package:store_sqlite/screens/menuApp/MenuApp_screenH.dart'; +import 'package:store_sqlite/screens/menuApp/MenuApp_screenV.dart'; void main() => runApp(const MyApp()); @@ -13,9 +13,11 @@ class MyApp extends StatelessWidget { Widget build(BuildContext context) { return MaterialApp( title: 'Material App', - home: const loginResponsiveScreen( - pantallaVerticalMobile: LoginScreenVertical(), - pantallaHorizontalMobile: LoginScreenHorizontal()), + debugShowCheckedModeBanner: false, + theme: ThemeData.dark(), + home: const Menuappresponsivescreen( + pantallaVerticalMobile: MenuappScreenv(), + pantallaHorizontalMobile: MenuappScreenH()), routes: AppRoutes.routes, ); } diff --git a/lib/models/carrito_model.dart b/lib/models/carrito_model.dart new file mode 100644 index 0000000..4cc43c4 --- /dev/null +++ b/lib/models/carrito_model.dart @@ -0,0 +1,25 @@ +class CarritoModel { + int? id_carrito; + int? id_producto; + int? cantidad; + double? subtotal; + + CarritoModel({ + this.id_carrito, + this.id_producto, + this.cantidad, + this.subtotal, + }); + + factory CarritoModel.fromMap(Map carrito) { + return CarritoModel( + id_carrito: carrito['id_carrito'], + id_producto: carrito['id_producto'], + cantidad: carrito['cantidad'], + subtotal: (carrito['subtotal'] is int) + ? (carrito['subtotal'] as int).toDouble() // Convertir int a double + : carrito['subtotal'] + as double, // Si ya es double, lo devuelve directamente + ); + } +} diff --git a/lib/models/categoria_model.dart b/lib/models/categoria_model.dart new file mode 100644 index 0000000..6ed5f25 --- /dev/null +++ b/lib/models/categoria_model.dart @@ -0,0 +1,14 @@ +class CategoriaModel { + int? id_categoria; + String? categoria; + + CategoriaModel({this.id_categoria, this.categoria}); + + factory CategoriaModel.fromMap(Map categoria){ + return CategoriaModel( + //idGenre: movie['idGenre'], + id_categoria: categoria['id_categoria'], + categoria: categoria['categoria'] + ); + } +} diff --git a/lib/models/comunidad_model.dart b/lib/models/comunidad_model.dart new file mode 100644 index 0000000..4834ec7 --- /dev/null +++ b/lib/models/comunidad_model.dart @@ -0,0 +1,12 @@ +class ComunidadModel { + int? id_comunidad, id_municipio; + String? comunidad; + ComunidadModel({this.id_comunidad, this.id_municipio, this.comunidad}); + + factory ComunidadModel.fromMap(Map comunidad) { + return ComunidadModel( + id_comunidad: comunidad['id_comunidad'], + id_municipio: comunidad['id_municipio'], + comunidad: comunidad['comunidad']); + } +} diff --git a/lib/models/direccion_model.dart b/lib/models/direccion_model.dart new file mode 100644 index 0000000..97593d5 --- /dev/null +++ b/lib/models/direccion_model.dart @@ -0,0 +1,28 @@ +class DireccionModel { + int? id_direccion; + int? id_comunidad, no_exterior, no_interior; + String? calle; + String? colonia, num_telefono, nombre_cliente; + + DireccionModel( + {this.id_direccion, + this.id_comunidad, + this.calle, + this.colonia, + this.no_exterior, + this.no_interior, + this.num_telefono, + this.nombre_cliente}); + + factory DireccionModel.fromMap(Map direccion) { + return DireccionModel( + id_direccion: direccion['id_direccion'], + id_comunidad: direccion['id_comunidad'], + calle: direccion['calle'], + colonia: direccion['colonia'], + no_exterior: direccion['no_exterior'], + no_interior: direccion['no_interior'], + num_telefono: direccion['num_telefono'], + nombre_cliente: direccion['nombre_cliente']); + } +} diff --git a/lib/models/lista_pedido_model.dart b/lib/models/lista_pedido_model.dart new file mode 100644 index 0000000..972e296 --- /dev/null +++ b/lib/models/lista_pedido_model.dart @@ -0,0 +1,14 @@ +class ListaPedidoModel { + int? id_lista_pedido, id_producto, cantidad; + double? subtotal; + + ListaPedidoModel( + {this.id_lista_pedido, this.id_producto, this.cantidad, this.subtotal}); + factory ListaPedidoModel.fromMap(Map lista_pedido) { + return ListaPedidoModel( + id_lista_pedido: lista_pedido['id_lista_pedido'], + id_producto: lista_pedido['id_producto'], + cantidad: lista_pedido['cantidad'], + subtotal: lista_pedido['subtotal']); + } +} diff --git a/lib/models/municipio_model.dart b/lib/models/municipio_model.dart new file mode 100644 index 0000000..5470cec --- /dev/null +++ b/lib/models/municipio_model.dart @@ -0,0 +1,11 @@ +class MunicipioModel { + int? id_municipio; + String? municipio; + + MunicipioModel({this.id_municipio, this.municipio}); + factory MunicipioModel.fromMap(Map municipio) { + return MunicipioModel( + id_municipio: municipio['id_municipio'], + municipio: municipio['municipio']); + } +} diff --git a/lib/models/pedido_model.dart b/lib/models/pedido_model.dart new file mode 100644 index 0000000..0ec2be2 --- /dev/null +++ b/lib/models/pedido_model.dart @@ -0,0 +1,15 @@ +class PedidoModel { + int? id_pedido, id_status, id_direccion; + String? fecha_entrega; + + PedidoModel( + {this.id_pedido, this.id_status, this.id_direccion, this.fecha_entrega}); + + factory PedidoModel.fromMap(Map pedido) { + return PedidoModel( + id_pedido: pedido['id_pedido'], + id_status: pedido['id_status'], + id_direccion: pedido['id_direccion'], + fecha_entrega: pedido['fecha_entrega']); + } +} diff --git a/lib/models/producto_model.dart b/lib/models/producto_model.dart new file mode 100644 index 0000000..4c691fd --- /dev/null +++ b/lib/models/producto_model.dart @@ -0,0 +1,26 @@ +class ProductoModel { + int? id_producto; + String? producto; + double? precio; + String? descripcion; + int? id_categoria; + String? img_producto; + + ProductoModel( + {this.id_producto, + this.producto, + this.precio, + this.descripcion, + this.id_categoria, + this.img_producto}); + factory ProductoModel.fromMap(Map producto) { + return ProductoModel( + id_producto: producto['id_producto'], + producto: producto['producto'], + precio: (producto['precio'] as num) + .toDouble(), // Conversión segura a double + descripcion: producto['descripcion'], + id_categoria: producto['id_categoria'], + img_producto: producto['img_producto']); + } +} diff --git a/lib/models/status_model.dart b/lib/models/status_model.dart new file mode 100644 index 0000000..670d64e --- /dev/null +++ b/lib/models/status_model.dart @@ -0,0 +1,10 @@ +class StatusModel { + int? id_status; + String? status; + StatusModel({this.id_status, this.status}); + + factory StatusModel.fromMap(Map status) { + return StatusModel( + id_status: status['id_status'], status: status['status']); + } +} diff --git a/lib/models/toast_notification.dart b/lib/models/toast_notification.dart new file mode 100644 index 0000000..b646f21 --- /dev/null +++ b/lib/models/toast_notification.dart @@ -0,0 +1,80 @@ +import 'package:flutter/material.dart'; +import 'package:toastification/toastification.dart'; + +class ToastNotification { + void showToast( + BuildContext context, String title, String message, String type) { + // Define las propiedades de acuerdo al tipo de toast + ToastificationType toastType; + Color primaryColor; + Icon icon; + + switch (type) { + case 'success': + toastType = ToastificationType.success; + primaryColor = Colors.green; + icon = const Icon(Icons.check); + break; + case 'warning': + toastType = ToastificationType.warning; + primaryColor = Colors.orange; + icon = const Icon(Icons.warning); + break; + case 'error': + default: + toastType = ToastificationType.error; + primaryColor = Colors.red; + icon = const Icon(Icons.error); + break; + } + + // Llama al método toastification.show con los parámetros configurados + toastification.show( + context: context, // optional if you use ToastificationWrapper + type: toastType, + style: ToastificationStyle.flat, + autoCloseDuration: const Duration(seconds: 5), + title: Text(title), + description: Text(message), + alignment: Alignment.topRight, + direction: TextDirection.ltr, + animationDuration: const Duration(milliseconds: 300), + animationBuilder: (context, animation, alignment, child) { + return FadeTransition( + opacity: animation, + child: child, + ); + }, + icon: icon, + showIcon: true, + primaryColor: primaryColor, + backgroundColor: Colors.white, + foregroundColor: Colors.black, + padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 16), + margin: const EdgeInsets.symmetric(horizontal: 12, vertical: 8), + borderRadius: BorderRadius.circular(12), + boxShadow: const [ + BoxShadow( + color: Color(0x07000000), + blurRadius: 16, + offset: Offset(0, 16), + spreadRadius: 0, + ) + ], + showProgressBar: true, + closeButtonShowType: CloseButtonShowType.onHover, + closeOnClick: false, + pauseOnHover: true, + dragToClose: true, + applyBlurEffect: true, + callbacks: ToastificationCallbacks( + onTap: (toastItem) => print('Toast ${toastItem.id} tapped'), + onCloseButtonTap: (toastItem) => + print('Toast ${toastItem.id} close button tapped'), + onAutoCompleteCompleted: (toastItem) => + print('Toast ${toastItem.id} auto complete completed'), + onDismissed: (toastItem) => print('Toast ${toastItem.id} dismissed'), + ), + ); + } +} diff --git a/lib/routes/rutes.dart b/lib/routes/rutes.dart index bfecdb0..249440a 100644 --- a/lib/routes/rutes.dart +++ b/lib/routes/rutes.dart @@ -1,4 +1,7 @@ import 'package:flutter/material.dart'; +import 'package:store_sqlite/screens/Productos.dart'; +import 'package:store_sqlite/screens/carrito_screens.dart'; +import 'package:store_sqlite/screens/informacionPedido.dart'; import 'package:store_sqlite/screens/login/login_ScreenH.dart'; import 'package:store_sqlite/screens/login/login_screenV.dart'; import 'package:store_sqlite/screens/loginResponsiveScreen.dart'; @@ -6,11 +9,16 @@ import 'package:store_sqlite/screens/loginResponsiveScreen.dart'; class AppRoutes { static const menuScreen = '/MenuScreen'; static const loginScreen = '/loginScreen'; - + static const informacionPedido = '/informacionPedido'; + static const productos = '/productos'; + static const carrito = '/carrito'; static final routes = { //recibe una cadena , y un witget loginScreen: (context) => const loginResponsiveScreen( pantallaVerticalMobile: LoginScreenVertical(), - pantallaHorizontalMobile: LoginScreenHorizontal()) + pantallaHorizontalMobile: LoginScreenHorizontal()), + informacionPedido: (context) => Informacionpedido(), + productos: (context) => Productos(), + carrito: (contexto) => CarritoScreens(), }; } diff --git a/lib/screens/MenuAppResponsiveScreen.dart b/lib/screens/MenuAppResponsiveScreen.dart new file mode 100644 index 0000000..c7141cc --- /dev/null +++ b/lib/screens/MenuAppResponsiveScreen.dart @@ -0,0 +1,23 @@ +import 'package:flutter/material.dart'; + +class Menuappresponsivescreen extends StatelessWidget { + const Menuappresponsivescreen( + {super.key, + required this.pantallaVerticalMobile, + required this.pantallaHorizontalMobile}); + + final Widget pantallaVerticalMobile; + final Widget pantallaHorizontalMobile; + @override + Widget build(BuildContext context) { + return LayoutBuilder( + builder: (BuildContext context, BoxConstraints constraints) { + if (constraints.maxWidth < 600) { + return pantallaVerticalMobile; + } else { + return pantallaHorizontalMobile; + } + }, + ); + } +} diff --git a/lib/screens/Productos.dart b/lib/screens/Productos.dart new file mode 100644 index 0000000..de39816 --- /dev/null +++ b/lib/screens/Productos.dart @@ -0,0 +1,59 @@ +import 'package:flutter/material.dart'; +import 'package:store_sqlite/controller/producto_controller.dart'; +import 'package:store_sqlite/models/producto_model.dart'; +import 'package:store_sqlite/screens/Productos/cardWidget.dart'; + +class Productos extends StatefulWidget { + const Productos({super.key}); + + @override + State createState() => _ProductosState(); +} + +class _ProductosState extends State { + late ProductoController productoController = ProductoController(); + void initState() { + super.initState(); + } + + @override + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + actions: [ + IconButton( + onPressed: () { + Navigator.pushNamed(context, '/carrito'); + }, + icon: Icon(Icons.shop)) + ], + ), + body: FutureBuilder>?>( + future: productoController.mostrarProductosConCategoria(), + builder: + (context, AsyncSnapshot>?> snapshot) { + if (snapshot.connectionState == ConnectionState.waiting) { + return const Center(child: CircularProgressIndicator()); + } else if (snapshot.hasError) { + return const Center(child: Text('Something went wrong :(')); + } else if (!snapshot.hasData || snapshot.data!.isEmpty) { + return const Center(child: Text('No products found.')); + } + + return GridView.builder( + gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount( + crossAxisCount: 2, + childAspectRatio: .4, + crossAxisSpacing: .1, + mainAxisSpacing: 0), + itemCount: snapshot.data!.length, + itemBuilder: (BuildContext context, int index) { + return Cardwidget(snapshot.data![index]); + }, + ); + }, + ), + ); + } +} diff --git a/lib/screens/Productos/cardWidget.dart b/lib/screens/Productos/cardWidget.dart new file mode 100644 index 0000000..f804907 --- /dev/null +++ b/lib/screens/Productos/cardWidget.dart @@ -0,0 +1,91 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_product_card/flutter_product_card.dart'; +import 'package:counter_button/counter_button.dart'; +import 'package:store_sqlite/controller/carrito_controller.dart'; + +class Cardwidget extends StatefulWidget { + final Map producto; + Cardwidget(this.producto, {super.key}); + + @override + State createState() => _CardwidgetState(); +} + +class _CardwidgetState extends State { + CarritoController carritoController = CarritoController(); + int _counterValue = 0; + + @override + Widget build(BuildContext context) { + double precio = widget.producto['precio']; + + double subtotal = 0; + return Column( + children: [ + ProductCard( + imageUrl: + 'https://encrypted-tbn3.gstatic.com/shopping?q=tbn:ANd9GcQndSK7hvssofrM2uzv75NxVjrkAwH3RwyqWcBesUsmq1ipmkuljRr6x_SRbCKaBXvjTR9CKfAaEFtmUFw-69o52wgVMgk2hp8KDYr4FvKtQ8ZfKewgOW4gDQ&usqp=CAE4', + categoryName: '${widget.producto['id_producto']}', + productName: '${widget.producto['producto']}', + price: precio, + currency: '\$', + onTap: () { + // Handle card tap event + }, + cardColor: Colors.white, + textColor: Colors.black, + borderRadius: 6.0, + ), + // Usa SizedBox para controlar el espacio entre el ProductCard y el CounterButton + SizedBox(height: 1), // Ajusta este valor para el espaciado deseado + CounterButton( + loading: false, + onChange: (int val) { + setState(() { + _counterValue = val; + }); + }, + count: _counterValue, + countColor: Colors.purple, + buttonColor: Colors.purpleAccent, + progressColor: Colors.purpleAccent, + ), + // Otro SizedBox para el espacio entre CounterButton e IconButton + SizedBox(height: 1), // Ajusta este valor también + IconButton( + onPressed: () { + print(_counterValue); + subtotal = precio * _counterValue; + if (subtotal > 0 && _counterValue > 0) { + // Validaciones + setState( + () { + carritoController.insertCarrito('carrito', { + 'id_producto': widget.producto['id_producto'], + 'cantidad': _counterValue, + 'subtotal': subtotal, + }); + _counterValue = 0; + + // Feedback al usuario + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + content: Text( + 'Producto ${widget.producto['id_producto']} cantidad=${_counterValue} subtotal= ${subtotal}agregado al carrito')), + ); + }, + ); + } else { + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + content: Text( + 'Error: producto no válido ${widget.producto['id_producto']} o cantidad incorrecta $_counterValue')), + ); + } + }, + icon: const Icon(Icons.add_shopping_cart_rounded), + ), + ], + ); + } +} diff --git a/lib/screens/calendarScreen.dart b/lib/screens/calendarScreen.dart new file mode 100644 index 0000000..0497dfb --- /dev/null +++ b/lib/screens/calendarScreen.dart @@ -0,0 +1,147 @@ +import 'package:flutter/material.dart'; +import 'package:store_sqlite/controller/pedido_controller.dart'; +import 'package:table_calendar/table_calendar.dart'; +import 'package:intl/intl.dart'; + +class TableBasicsExample extends StatefulWidget { + @override + _TableBasicsExampleState createState() => _TableBasicsExampleState(); +} + +class _TableBasicsExampleState extends State { + CalendarFormat _calendarFormat = CalendarFormat.month; + DateTime _focusedDay = DateTime.now(); + DateTime? _selectedDay; + DateTime? _selectedDate; + Map mySelectedEvents = {}; + PedidoController pedidoController = PedidoController(); + + @override + void initState() { + super.initState(); + main(); // Cargar eventos al inicio + } + + Future>?> recuperandoDatos() async { + List>? datos = + await pedidoController.mostrarTodosLosPedidosSinId(); + print('Imprimiendo los datos de la base de datos:'); + return datos; + } + + Future extraerDatos() async { + var datos = await recuperandoDatos(); + + if (datos != null && datos.isNotEmpty) { + for (var dato in datos) { + String fecha = dato['fecha_entrega']; + String eventTitle = dato['colonia']; + String eventDescp = dato['calle']; + + // Revisa si la fecha se almacena en el formato correcto + print('Fecha: $fecha, Título: $eventTitle, Descripción: $eventDescp'); + + mySelectedEvents[fecha] ??= []; + mySelectedEvents[fecha]!.add({ + 'eventTitle': eventTitle, + 'eventDescp': eventDescp, + }); + } + + print('Eventos cargados: $mySelectedEvents'); + } else { + print('No se obtuvieron datos o la lista está vacía.'); + } + } + + Future main() async { + await extraerDatos(); + setState(() {}); + } + + List _listOfDayEvents(DateTime dateTime) { + String formattedDate = DateFormat('yyyy-MM-dd').format(dateTime); + print( + 'Eventos para la fecha $formattedDate: ${mySelectedEvents[formattedDate]}'); + return mySelectedEvents[formattedDate] ?? []; + } + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar(title: Text('Eventos')), + body: Column(children: [ + TableCalendar( + firstDay: DateTime.utc(2020, 1, 1), + lastDay: DateTime.utc(2030, 12, 31), + focusedDay: _focusedDay, + calendarFormat: _calendarFormat, + selectedDayPredicate: (day) { + return isSameDay(_selectedDay, day); + }, + onDaySelected: (selectedDay, focusedDay) { + if (!isSameDay(_selectedDay, selectedDay)) { + setState(() { + _selectedDay = selectedDay; + _focusedDay = focusedDay; + _selectedDate = selectedDay; + }); + + showModalBottomSheet( + context: context, + isScrollControlled: true, + builder: (context) => SafeArea( + child: Container( + height: MediaQuery.of(context).size.height * .9, + width: MediaQuery.of(context).size.width, + padding: EdgeInsets.all(16.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text('Fecha seleccionada: ${selectedDay.toLocal()}'), + SizedBox(height: 10), + ..._listOfDayEvents(selectedDay).map((event) { + return ListTile( + title: Text(event['eventTitle']), + subtitle: Text(event['eventDescp']), + ); + }).toList(), + SizedBox(height: 10), + ElevatedButton( + onPressed: () => Navigator.pop(context), + child: Text('Cerrar'), + ), + ], + ), + ), + ), + ); + } + }, + onFormatChanged: (format) { + if (_calendarFormat != format) { + setState(() { + _calendarFormat = format; + }); + } + }, + onPageChanged: (focusedDay) { + _focusedDay = focusedDay; + }, + eventLoader: _listOfDayEvents, + ), + if (_selectedDate != null) + ..._listOfDayEvents(_selectedDate!).map((myEvents) => ListTile( + leading: const Icon( + Icons.done, + color: Colors.teal, + ), + title: Padding( + padding: const EdgeInsets.only(bottom: 8.0), + child: Text('Event Title: ${myEvents['eventTitle']}'), + ), + subtitle: Text('Description: ${myEvents['eventDescp']}'), + )) + ])); + } +} diff --git a/lib/screens/calendar_widget/modalCalendarWidget.dart b/lib/screens/calendar_widget/modalCalendarWidget.dart new file mode 100644 index 0000000..0b49fd6 --- /dev/null +++ b/lib/screens/calendar_widget/modalCalendarWidget.dart @@ -0,0 +1,39 @@ +import 'package:flutter/material.dart'; +import 'package:wolt_modal_sheet/wolt_modal_sheet.dart'; + + + +class Modalcalendarwidget extends StatelessWidget { + const Modalcalendarwidget({super.key}); + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: const Text('Wolt Modal Bottom Sheet Sample'), + ), + floatingActionButton: FloatingActionButton.extended( + onPressed: () { + WoltModalSheet.show( + context: context, + pageListBuilder: (bottomSheetContext) => [ + SliverWoltModalSheetPage( + mainContentSliversBuilder: (context) => [ + SliverList.builder( + itemBuilder: (context, index) { + return ListTile( + title: Text('Index is $index'), + onTap: Navigator.of(bottomSheetContext).pop, + ); + }, + ), + ], + ) + ], + ); + }, + label: const Text('Trigger Wolt Sheet'), + ), + ); + } + } diff --git a/lib/screens/carrito_screens.dart b/lib/screens/carrito_screens.dart new file mode 100644 index 0000000..d95249f --- /dev/null +++ b/lib/screens/carrito_screens.dart @@ -0,0 +1,344 @@ +import 'package:counter_button/counter_button.dart'; +import 'package:flutter/material.dart'; +import 'package:store_sqlite/controller/carrito_controller.dart'; +import 'package:store_sqlite/controller/direccion_controller.dart'; +import 'package:store_sqlite/controller/listaPedido_controller.dart'; +import 'package:store_sqlite/database/database.dart'; +import 'package:store_sqlite/models/lista_pedido_model.dart'; +import 'package:store_sqlite/models/toast_notification.dart'; +import 'package:store_sqlite/screens/carrito_widgets/dropDown_Municipio_Widget.dart'; + +class CarritoScreens extends StatefulWidget { + const CarritoScreens({super.key}); + + @override + State createState() => _CarritoScreensState(); +} + +class _CarritoScreensState extends State { + CarritoController carritoController = CarritoController(); + List _counterValues = []; + final conNombreCliente = TextEditingController(); + final conTelefono = TextEditingController(); + final conColonia = TextEditingController(); + final conCalle = TextEditingController(); + final conNoExterior = TextEditingController(); + final conNoInterior = TextEditingController(); + final conFechaEntrega = TextEditingController(); + final toast = ToastNotification(); + + late TiendaDataBase db; + + @override + void initState() { + super.initState(); + db = TiendaDataBase(); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: const Text('Carrito'), + ), + floatingActionButton: FloatingActionButton( + child: const Icon(Icons.check), + onPressed: () { + // Mostrar modal para ingresar datos + showModalBottomSheet( + context: context, + isScrollControlled: true, + builder: (context) => SafeArea( + child: Container( + height: MediaQuery.of(context).size.height * .9, + width: MediaQuery.of(context).size.width, + padding: const EdgeInsets.all(16.0), + child: ListView( + shrinkWrap: true, + children: [ + const Padding( + padding: EdgeInsets.all(30.0), + child: Text('Datos Del Pedido'), + ), + TextFormField( + keyboardType: TextInputType.name, + controller: conNombreCliente, + decoration: const InputDecoration( + label: Text('Nombre Del Cliente'), + prefixIcon: Icon(Icons.person), + ), + ), + TextFormField( + keyboardType: TextInputType.number, + controller: conTelefono, + decoration: const InputDecoration( + label: Text('Número De Teléfono'), + prefixIcon: Icon(Icons.phone), + ), + ), + TextFormField( + keyboardType: TextInputType.name, + controller: conColonia, + decoration: const InputDecoration( + label: Text('Colonia'), + prefixIcon: Icon(Icons.add_location_alt_outlined), + ), + ), + TextFormField( + keyboardType: TextInputType.name, + controller: conCalle, + decoration: const InputDecoration( + label: Text('Calle'), + prefixIcon: Icon(Icons.streetview), + ), + ), + TextFormField( + keyboardType: TextInputType.number, + controller: conNoExterior, + decoration: const InputDecoration( + label: Text('Número Exterior'), + prefixIcon: Icon(Icons.numbers), + ), + ), + TextFormField( + keyboardType: TextInputType.number, + controller: conNoInterior, + decoration: const InputDecoration( + label: Text('Número Interior'), + prefixIcon: Icon(Icons.numbers), + ), + ), + const Row( + children: [ + Text('Comunidad'), + DropdownMunicipioWidget(), + ], + ), + TextFormField( + keyboardType: TextInputType + .none, // Desactiva el teclado para mostrar solo el calendario + controller: conFechaEntrega, + decoration: const InputDecoration( + label: Text('Fecha entrega'), + prefixIcon: Icon(Icons.calendar_month), + ), + onTap: () async { + FocusScope.of(context).requestFocus( + FocusNode()); // Evita que el teclado se muestre + DateTime? pickedDate = await showDatePicker( + context: context, + initialDate: DateTime.now(), + firstDate: DateTime(2000), // Fecha mínima permitida + lastDate: DateTime(2101), // Fecha máxima permitida + ); + + if (pickedDate != null) { + // Formatea la fecha seleccionada y la asigna al controlador + String formattedDate = + "${pickedDate.year}-${pickedDate.month}-${pickedDate.day}"; + conFechaEntrega.text = formattedDate; + } + }, + ), + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Padding( + padding: const EdgeInsets.all(15.0), + child: ElevatedButton( + onPressed: () => Navigator.pop(context), + child: const Text('Cerrar'), + ), + ), + Padding( + padding: const EdgeInsets.all(15.0), + child: ElevatedButton( + onPressed: () async { + String nombreCliente = conNombreCliente.text; + String telefono = conTelefono.text; + String colonia = conColonia.text; + String calle = conCalle.text; + String noExterior = conNoExterior.text; + String noInterior = conNoInterior.text; + String fecha = conFechaEntrega.text; + +// Verifica que todos los campos estén completos + if (nombreCliente.isNotEmpty && + telefono.isNotEmpty && + colonia.isNotEmpty && + calle.isNotEmpty) { + // Crear el mapa para la tabla direccion + Map direccion = { + 'id_comunidad': + 1, // Puedes ajustar este valor + 'calle': calle, + 'colonia': colonia, + 'no_exterior': int.parse( + noExterior), // Convierte a entero si es necesario + 'no_interior': noInterior.isNotEmpty + ? int.parse(noInterior) + : null, + 'num_telefono': telefono, + 'nombre_cliente': nombreCliente, + }; + + // Crear el mapa para la tabla pedido + Map pedido = { + 'id_status': + 2, // Estado inicial, ajusta si es necesario + 'id_direccion': + null, // Este se asignará luego de insertar en 'direccion' + 'fecha_entrega': fecha + .toString(), // O asigna la fecha específica + }; + + // Llama a la función para crear el pedido y la dirección + int res = + await db.CREATE_PEDIDO(pedido, direccion); + print('RES CREATE: ${res}'); + if (res > 0) + setState(() { + Navigator.pop(context); + toast.showToast(context, 'Pedido', + 'Se registro con exito!', 'success'); + }); + } else { + // Mostrar un mensaje Toast para llenar todos los campos + print("Por favor llena todos los campos."); + toast.showToast( + context, + 'Campos incompletos', + 'Por favor llenar todos los campos', + 'error'); + } + }, + child: Row( + children: const [ + Icon( + Icons.done_outline_outlined, + color: Colors.greenAccent, + ), + SizedBox(width: 8), + Text( + 'Completado', + style: TextStyle( + color: Colors.greenAccent, + fontSize: 16, + ), + ), + ], + ), + ), + ) + ], + ), + ], + ), + ), + ), + ); + }, + ), + body: FutureBuilder>?>( + future: carritoController.mostrarTodosLosCarritos(), + builder: (context, snapshot) { + if (snapshot.connectionState == ConnectionState.waiting) { + return const Center( + child: CircularProgressIndicator(), + ); + } else if (snapshot.hasError) { + return Center( + child: Text(snapshot.error.toString()), + ); + } else if (snapshot.hasData && snapshot.data!.isNotEmpty) { + if (_counterValues.isEmpty) { + _counterValues = List.filled(snapshot.data!.length, 0); + } + List> carritos = snapshot.data!; + return ListView.builder( + itemCount: carritos.length, + itemBuilder: (context, index) { + var carrito = carritos[index]; + return Padding( + padding: const EdgeInsets.all(8.0), + child: InkWell( + onTap: () {}, + child: Container( + padding: const EdgeInsets.all(20), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(10), + color: const Color.fromARGB(40, 75, 39, 39), + border: const Border( + left: BorderSide( + width: 4, + ), + ), + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + '${carrito['producto']}\n cantidad=${carrito['cantidad']}\n subtotal=${carrito['subtotal']}', + textAlign: TextAlign.left, + style: const TextStyle( + fontSize: 16, + ), + ), + CounterButton( + loading: false, + onChange: (int val) { + setState(() { + _counterValues[index] = val; + }); + }, + count: _counterValues[index], + countColor: Colors.purple, + buttonColor: Colors.purpleAccent, + progressColor: Colors.purpleAccent, + ), + ], + ), + ), + ], + ), + ), + ), + ); + }, + ); + } else { + return const Center( + child: Text('No hay pedidos disponibles'), + ); + } + }, + ), + ); + } + + void ingresarDireccion(String nombreCliente, String NumeroTel, String Colonia, + String Calle, String NumExterior) { + print('se ingresaron los datos'); + + try {} catch (e) {} + DireccionController direccionController = DireccionController(); + + direccionController.insertDireccion('direccion', { + 'Id_comunidad': 1, + 'calle': '${Calle}', + 'no_exterior': '${NumExterior}', + 'colonia': '$Colonia', + 'no_interior': '', + 'telefono': '${NumeroTel}', + 'cliente_nombre': '$nombreCliente' + }); + print('pasando los valores a las tablas'); + ListapedidoController listapedidoController = ListapedidoController(); + listapedidoController.insertarListaPedido('lista_pedido', + {'id_pedido': '', 'id_producto': '', 'cantidad': '', 'subtotal': ''}); + } +} diff --git a/lib/screens/carrito_widgets/dropDown_Municipio_Widget.dart b/lib/screens/carrito_widgets/dropDown_Municipio_Widget.dart new file mode 100644 index 0000000..4e8d99e --- /dev/null +++ b/lib/screens/carrito_widgets/dropDown_Municipio_Widget.dart @@ -0,0 +1,85 @@ +import 'package:flutter/material.dart'; +import 'package:dropdown_button2/dropdown_button2.dart'; +import 'package:store_sqlite/controller/municipio_controller.dart'; +import 'package:store_sqlite/models/municipio_model.dart'; + +class DropdownMunicipioWidget extends StatefulWidget { + const DropdownMunicipioWidget({super.key}); + + @override + State createState() => + _DropdownMunicipioWidgetState(); +} + +class _DropdownMunicipioWidgetState extends State { + late MunicipioController municipioController = MunicipioController(); + List municipios = []; + ValueNotifier selectedMunicipioNotifier = ValueNotifier(null); + + @override + void initState() { + super.initState(); + obtenerMunicipios(); + } + + void obtenerMunicipios() async { + List? fetchedMunicipios = await municipioController.mostrarTodosLosMunicipios(); + if (fetchedMunicipios != null) { + setState(() { + municipios = fetchedMunicipios; + }); + } else { + print('No se encontraron municipios.'); + } + } + + @override + Widget build(BuildContext context) { + return Container( + width: 200, // Ajusta el ancho del Container + child: ValueListenableBuilder( + valueListenable: selectedMunicipioNotifier, + builder: (context, selectedMunicipio, child) { + return DropdownButtonHideUnderline( + child: DropdownButton2( + isExpanded: true, + hint: Text( + 'Seleccione un municipio', + style: TextStyle( + fontSize: 14, + color: Theme.of(context).hintColor, + ), + ), + items: municipios + .map((municipio) => DropdownMenuItem( + value: municipio, + child: Text( + '${municipio.municipio}', + style: const TextStyle( + fontSize: 14, + ), + ), + )) + .toList(), + value: selectedMunicipio, + onChanged: (MunicipioModel? value) { + selectedMunicipioNotifier.value = value; + if (value != null) { + print('ID: ${value.id_municipio}, Municipio: ${value.municipio}'); + } + }, + buttonStyleData: const ButtonStyleData( + padding: EdgeInsets.symmetric(horizontal: 16), + height: 40, + width: 160, // Ajusta el ancho del DropdownButton2 + ), + menuItemStyleData: const MenuItemStyleData( + height: 40, + ), + ), + ); + }, + ), + ); + } +} diff --git a/lib/screens/informacionPedido.dart b/lib/screens/informacionPedido.dart new file mode 100644 index 0000000..8ace204 --- /dev/null +++ b/lib/screens/informacionPedido.dart @@ -0,0 +1,47 @@ +import 'package:flutter/material.dart'; +import 'package:store_sqlite/controller/pedido_controller.dart'; +import 'package:store_sqlite/screens/infromacionPedido/InformacionPedidoWidget.dart'; +import 'package:store_sqlite/screens/infromacionPedido/dropDownButtonListWidget.dart'; +import 'package:store_sqlite/screens/infromacionPedido/floatingButtonWidget.dart'; +import 'package:store_sqlite/screens/infromacionPedido/informacionClienteWidget.dart'; +import 'package:animated_floating_buttons/animated_floating_buttons.dart'; + +class Informacionpedido extends StatefulWidget { + const Informacionpedido({super.key}); + + @override + State createState() => _InformacionpedidoState(); +} + +class _InformacionpedidoState extends State { + PedidoController informacionPedido = PedidoController(); + + late int? id = 0; + late int? id_status = 0; + @override + void initState() { + super.initState(); + } + + @override + Widget build(BuildContext context) { + final arguments = (ModalRoute.of(context)?.settings.arguments ?? + {}) as Map; + // print(arguments['id_pedido']); + id = arguments['id_pedido']; + id_status = arguments['id_status']; + + return Scaffold( + appBar: AppBar( + title: Text('Datos pedido $id'), + // actions: [Dropdownbuttonlistwidget(id_status)], + ), + body: Column( + children: [ + InformacionClientewidget(id), + Informacionpedidowidget(id), + ], + ), + floatingActionButton: Floatingbuttonwidget(id)); + } +} diff --git a/lib/screens/infromacionPedido/InformacionPedidoWidget.dart b/lib/screens/infromacionPedido/InformacionPedidoWidget.dart new file mode 100644 index 0000000..2fa6d75 --- /dev/null +++ b/lib/screens/infromacionPedido/InformacionPedidoWidget.dart @@ -0,0 +1,64 @@ +import 'package:flutter/material.dart'; +import 'package:store_sqlite/controller/pedido_controller.dart'; + +class Informacionpedidowidget extends StatefulWidget { + final int? id; + const Informacionpedidowidget(this.id, {super.key}); // Constructor modificado + + @override + State createState() => + _InformacionpedidowidgetState(); +} + +class _InformacionpedidowidgetState extends State { + PedidoController informacionPedido = PedidoController(); + @override + Widget build(BuildContext context) { + final arguments = (ModalRoute.of(context)?.settings.arguments ?? + {}) as Map; + // print(arguments['id_pedido']); + + return Container( + width: MediaQuery.sizeOf(context).width, + height: MediaQuery.sizeOf(context).height * .58, + decoration: BoxDecoration(), + child: FutureBuilder>?>( + future: informacionPedido + .mostrarPedidosConListaPedido(widget.id), // Usar el id aquí + builder: (context, snapshot) { + if (snapshot.connectionState == ConnectionState.waiting) { + return Center(child: CircularProgressIndicator()); + } else if (snapshot.hasError) { + return Center(child: Text('Error: ${snapshot.error}')); + } else if (!snapshot.hasData || snapshot.data!.isEmpty) { + return Center(child: Text('No se encontraron pedidos')); + } else { + List> pedidos = snapshot.data!; + return ListView.builder( + itemCount: pedidos.length, + itemBuilder: (context, index) { + var pedido = pedidos[index]; + return Container( + child: ListTile( + title: Text('Artículo: ${pedido['producto']}'), + subtitle: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text('Cantidad: ${pedido['cantidad']}'), + SizedBox(height: 4.0), // Espacio entre textos + Text('Precio: \$${pedido['precio']}', + style: TextStyle(fontWeight: FontWeight.bold)), + SizedBox(height: 4.0), // Espacio entre textos + Text('Subtotal: ${pedido['']}'), + ], + ), + ), + ); + }, + ); + } + }, + ), + ); + } +} diff --git a/lib/screens/infromacionPedido/dropDownButtonListWidget.dart b/lib/screens/infromacionPedido/dropDownButtonListWidget.dart new file mode 100644 index 0000000..25707d0 --- /dev/null +++ b/lib/screens/infromacionPedido/dropDownButtonListWidget.dart @@ -0,0 +1,86 @@ +import 'package:flutter/material.dart'; +import 'package:dropdown_button2/dropdown_button2.dart'; +import 'package:store_sqlite/controller/status_controller.dart'; +import 'package:store_sqlite/models/lista_pedido_model.dart'; +import 'package:store_sqlite/models/status_model.dart'; + +class Dropdownbuttonlistwidget extends StatefulWidget { + const Dropdownbuttonlistwidget( {super.key}); + +// Constructor modificado + + @override + State createState() => + _DropdownbuttonlistwidgetState(); +} + +class _DropdownbuttonlistwidgetState extends State { + late StatusController statusController = StatusController(); + final List items = [ + 'Item1', + 'Item2', + 'Item3', + 'Item4', + ]; + + ValueNotifier selectedValueNotifier = ValueNotifier(null); + + @override + void initState() { + super.initState(); + print('+++++++++++++++++++++++++++++++++++++++++'); + Lista(); + } + + void Lista() async { + List? list = await statusController.mostrarTodosLosStatus(); + print(list); // Esto imprimirá la lista cuando esté disponible. + } + + @override + Widget build(BuildContext context) { + return Container( + width: 200, // Ajusta el ancho del Container + child: ValueListenableBuilder( + valueListenable: selectedValueNotifier, + builder: (context, selectedValue, child) { + return DropdownButtonHideUnderline( + child: DropdownButton2( + isExpanded: true, + hint: Text( + '', + style: TextStyle( + fontSize: 14, + color: Theme.of(context).hintColor, + ), + ), + items: items + .map((String item) => DropdownMenuItem( + value: item, + child: Text( + item, + style: const TextStyle( + fontSize: 14, + ), + ), + )) + .toList(), + value: selectedValue, + onChanged: (String? value) { + selectedValueNotifier.value = value; + }, + buttonStyleData: const ButtonStyleData( + padding: EdgeInsets.symmetric(horizontal: 16), + height: 40, + width: 160, // Ajusta el ancho del DropdownButton2 + ), + menuItemStyleData: const MenuItemStyleData( + height: 40, + ), + ), + ); + }, + ), + ); + } +} diff --git a/lib/screens/infromacionPedido/floatingButtonWidget.dart b/lib/screens/infromacionPedido/floatingButtonWidget.dart new file mode 100644 index 0000000..799f6eb --- /dev/null +++ b/lib/screens/infromacionPedido/floatingButtonWidget.dart @@ -0,0 +1,52 @@ +import 'package:flutter/material.dart'; +import 'package:animated_floating_buttons/animated_floating_buttons.dart'; + +class Floatingbuttonwidget extends StatefulWidget { + final int? id; + const Floatingbuttonwidget(this.id, {super.key}); + + @override + State createState() => _FloatingbuttonwidgetState(); +} + +class _FloatingbuttonwidgetState extends State { + final GlobalKey key = + GlobalKey(); + Widget float1() { + return Container( + child: FloatingActionButton( + onPressed: () { + Navigator.pushNamed(context, '/productos'); + }, + heroTag: "new", + tooltip: 'First button', + child: Icon(Icons.add), + ), + ); + } + + Widget float2() { + return Container( + child: FloatingActionButton( + onPressed: () { + print(widget.id); + }, + heroTag: "edit", + tooltip: 'Second button', + child: Icon(Icons.edit), + ), + ); + } + + @override + Widget build(BuildContext context) { + return AnimatedFloatingActionButton( + //Fab list + fabButtons: [float1(), float2()], + key: key, + colorStartAnimation: Colors.blue, + colorEndAnimation: Colors.red, + animatedIconData: AnimatedIcons.menu_close //To principal button + ); + } +} diff --git a/lib/screens/infromacionPedido/informacionClienteWidget.dart b/lib/screens/infromacionPedido/informacionClienteWidget.dart new file mode 100644 index 0000000..5463fe5 --- /dev/null +++ b/lib/screens/infromacionPedido/informacionClienteWidget.dart @@ -0,0 +1,82 @@ +import 'package:flutter/material.dart'; +import 'package:store_sqlite/controller/pedido_controller.dart'; + +class InformacionClientewidget extends StatefulWidget { + final int? id; + const InformacionClientewidget(this.id, + {super.key}); + + @override + State createState() => + _InformacionpedidowidgetState(); +} + +class _InformacionpedidowidgetState extends State { + PedidoController informacionPedido = PedidoController(); + @override + Widget build(BuildContext context) { + final arguments = (ModalRoute.of(context)?.settings.arguments ?? + {}) as Map; + // print(arguments['id_pedido']); + + return Container( + width: MediaQuery.sizeOf(context).width, + height: MediaQuery.sizeOf(context).height * .29, + decoration: BoxDecoration(color: const Color.fromARGB(255, 57, 56, 51)), + child: FutureBuilder>?>( + future: informacionPedido + .mostrarPedidoDatosCliente(widget.id), // Usar el id aquí + builder: (context, snapshot) { + if (snapshot.connectionState == ConnectionState.waiting) { + return Center(child: CircularProgressIndicator()); + } else if (snapshot.hasError) { + return Center(child: Text('Error: ${snapshot.error}')); + } else if (!snapshot.hasData || snapshot.data!.isEmpty) { + return Center(child: Text('No se encontraron pedidos')); + } else { + List> pedidos = snapshot.data!; + return ListView.builder( + itemCount: pedidos.length, + itemBuilder: (context, index) { + var pedido = pedidos[index]; + return Container( + child: ListTile( + title: Text('Datos De Entrega:', + style: TextStyle(fontWeight: FontWeight.bold)), + subtitle: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text('Cliente: ${pedido['nombre_cliente']}'), + IconButton( + onPressed: () { + print(' ${pedido['num_telefono']}'); + }, + icon: Text( + 'Num Tel: ${pedido['num_telefono']}', + style: TextStyle(fontWeight: FontWeight.bold), + )), + + Text( + 'Municipio:${pedido['municipio']}', + ), + SizedBox(height: 4.0), // Espacio entre textos + Text('Comunidad: ${pedido['comunidad']}'), + SizedBox(height: 4.0), + Text('Colonia: ${pedido['colonia']}'), + SizedBox(height: 4.0), + Text('Calle: ${pedido['calle']}'), + SizedBox(height: 4.0), + Text('No.Ext: ${pedido['no_exterior']}'), + SizedBox(height: 4.0), + ], + ), + ), + ); + }, + ); + } + }, + ), + ); + } +} diff --git a/lib/screens/menuApp/MenuApp_screenH.dart b/lib/screens/menuApp/MenuApp_screenH.dart new file mode 100644 index 0000000..37ad4b0 --- /dev/null +++ b/lib/screens/menuApp/MenuApp_screenH.dart @@ -0,0 +1,20 @@ +import 'package:flutter/material.dart'; + +class MenuappScreenH extends StatefulWidget { + const MenuappScreenH({super.key}); + + @override + State createState() => _MenuappScreenvState(); +} + +class _MenuappScreenvState extends State { + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: Text('Menu App'), + ), + body: Text('menu app'), + ); + } +} diff --git a/lib/screens/menuApp/MenuApp_screenV.dart b/lib/screens/menuApp/MenuApp_screenV.dart new file mode 100644 index 0000000..d5a4f9a --- /dev/null +++ b/lib/screens/menuApp/MenuApp_screenV.dart @@ -0,0 +1,143 @@ +import 'package:animated_botton_navigation/animated_botton_navigation.dart'; +import 'package:flutter/material.dart'; +import 'package:store_sqlite/controller/producto_controller.dart'; +import 'package:store_sqlite/database/database.dart'; +import 'package:store_sqlite/models/producto_model.dart'; +import 'package:flutter_product_card/flutter_product_card.dart'; +import 'package:store_sqlite/screens/calendarScreen.dart'; +import 'package:store_sqlite/screens/menuApp/widgetMenuApp/PedidosListaWidget.dart'; +import 'package:store_sqlite/screens/menuApp/widgetMenuApp/drawer.dart'; + +class MenuappScreenv extends StatefulWidget { + const MenuappScreenv({super.key}); + + @override + State createState() => _MenuappScreenvState(); +} + +class _MenuappScreenvState extends State { + int _currentIndex = 0; + + final List _pages = [ + Center( + child: Pedidoslistawidget( + opc: 0, + )), + Center( + child: Pedidoslistawidget( + opc: 1, + )), + Center(child: TableBasicsExample()), + Center( + child: Pedidoslistawidget( + opc: 2, + )), + ]; + + @override + Widget build(BuildContext context) { + return Scaffold( + drawer: SafeArea( + child: Container( + child: ListTileTheme( + textColor: Colors.white, + iconColor: Colors.white, + child: Column( + mainAxisSize: MainAxisSize.max, + children: [ + Container( + width: 128.0, + height: 128.0, + margin: const EdgeInsets.only( + top: 24.0, + bottom: 64.0, + ), + clipBehavior: Clip.antiAlias, + decoration: BoxDecoration( + color: Colors.black26, + shape: BoxShape.circle, + ), + child: Image.asset( + 'assets/img/logo_pizza.jfif', + ), + ), + ListTile( + onTap: () {}, + leading: Icon(Icons.food_bank), + title: Text('Productos'), + ), + ListTile( + onTap: () {}, + leading: Icon(Icons.category), + title: Text('Categorias'), + ), + ListTile( + onTap: () {}, + leading: Icon(Icons.location_city), + title: Text('Municipios'), + ), + ListTile( + onTap: () {}, + leading: Icon(Icons.gps_fixed), + title: Text('Comunidades'), + ), + Spacer(), + DefaultTextStyle( + style: TextStyle( + fontSize: 12, + color: Colors.white54, + ), + child: Container( + margin: const EdgeInsets.symmetric( + vertical: 16.0, + ), + child: Text('Terms of Service | Privacy Policy'), + ), + ), + ], + ), + ), + ), + ), + appBar: AppBar( + title: Text('Glorys Pizza Admin App'), + actions: [ + IconButton( + onPressed: () { + Navigator.pushNamed(context, '/carrito'); + }, + icon: Icon(Icons.shopping_cart), + ), + ], + backgroundColor: const Color.fromARGB(131, 33, 31, 31), + ), + floatingActionButton: FloatingActionButton( + onPressed: () { + Navigator.pushNamed(context, '/productos'); + }, + child: Icon( + Icons.add, + ), + tooltip: 'Nuevo', + ), + body: _pages[_currentIndex], + bottomNavigationBar: AnimatedBottomNavigation( + height: 70, + indicatorSpaceBotton: 25, + selectedColor: Colors.black, + icons: [ + Icons.pending_outlined, + Icons.schedule, + Icons.calendar_month, + Icons.task_alt + ], + currentIndex: _currentIndex, + onTapChange: (index) { + setState(() { + _currentIndex = index; + }); + }, + ), + ); + } +} diff --git a/lib/screens/menuApp/widgetMenuApp/PedidosListaWidget.dart b/lib/screens/menuApp/widgetMenuApp/PedidosListaWidget.dart new file mode 100644 index 0000000..e36d558 --- /dev/null +++ b/lib/screens/menuApp/widgetMenuApp/PedidosListaWidget.dart @@ -0,0 +1,137 @@ +import 'package:flutter/material.dart'; +import 'package:store_sqlite/controller/pedido_controller.dart'; +import 'package:store_sqlite/models/pedido_model.dart'; + +class Pedidoslistawidget extends StatefulWidget { + final int opc; + + const Pedidoslistawidget({super.key, required this.opc}); + + @override + State createState() => _PedidoslistawidgetState(); +} + +class _PedidoslistawidgetState extends State { + late PedidoController pedidoController; + + @override + void initState() { + pedidoController = PedidoController(); + // print('////////////////////////////////////////////'); + // pedidoController.mostrarPedidosConListaPedido(1); + // print('////////////////////////////////////////////'); + super.initState(); + } + + Color getColorByStatus(int? idStatus) { + switch (idStatus) { + case 1: + return Colors.green; // Si el idStatus es 1, el color será verde. + case 3: + return Colors.red; // Si el idStatus es 2, el color será rojo. + case 2: + return Colors.white; // Si el idStatus es 3, el color será blanco. + default: + return Colors + .grey; // Color por defecto si no es ninguno de los anteriores. + } + } + + Icon getIconStatus(int? idStatus) { + switch (idStatus) { + case 1: + return const Icon( + Icons.done, + color: Colors.green, + ); + case 3: + return const Icon( + Icons.cancel, + color: Colors.red, + ); + case 2: + return const Icon( + Icons.hourglass_empty, + color: Colors.grey, + ); + } + return const Icon(Icons.error); + } + + @override + Widget build(BuildContext context) { + var LargoContenedorList = MediaQuery.of(context).size.width * .1; + return Scaffold( + body: FutureBuilder( + future: pedidoController.mostrarTodosLosPedidos(widget.opc), + builder: (context, AsyncSnapshot?> snapshot) { + if (snapshot.hasData) { + return ListView.builder( + itemCount: snapshot.data!.length, + itemBuilder: (context, index) { + return Padding( + padding: const EdgeInsets.all(8.0), + child: InkWell( + onTap: () { + Navigator.pushNamed(context, '/informacionPedido', + arguments: { + 'id_pedido': snapshot.data![index].id_pedido, + 'id_status': snapshot.data![index].id_status + }); + }, + child: Container( + width: LargoContenedorList, + padding: const EdgeInsets.all(20), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(10), + color: const Color.fromARGB(40, 75, 39, 39), + border: Border( + left: BorderSide( + color: getColorByStatus( + snapshot.data![index].id_status), + width: 4, + ), + ), + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + // Texto del pedido y fecha de entrega + Expanded( + child: Text( + 'No_pedido: ${snapshot.data![index].id_pedido}\nFecha entrega: ${snapshot.data![index].fecha_entrega}', + textAlign: TextAlign.left, + style: const TextStyle( + fontSize: 16, + // color: Colors.black, + ), + ), + ), + // Ícono que representa el estado del pedido + getIconStatus(snapshot.data![index].id_status), + ], + ), + ), + ), + ); + }, + + //${snapshot.data![index].fecha_entrega}', + //); + ); + } else { + if (snapshot.hasError) { + return Center( + child: Text(snapshot.error.toString()), + ); + } else { + return const Center( + child: CircularProgressIndicator(), + ); + } + } + }, + ), + ); + } +} diff --git a/lib/screens/menuApp/widgetMenuApp/drawer.dart b/lib/screens/menuApp/widgetMenuApp/drawer.dart new file mode 100644 index 0000000..020708a --- /dev/null +++ b/lib/screens/menuApp/widgetMenuApp/drawer.dart @@ -0,0 +1,67 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_advanced_drawer/flutter_advanced_drawer.dart'; + +class DrawerMain extends StatelessWidget { + DrawerMain({super.key}); + + final _advancedDrawerController = AdvancedDrawerController(); + + @override + Widget build(BuildContext context) { + return AdvancedDrawer( + backdrop: Container( + width: double.infinity, + height: double.infinity, + decoration: BoxDecoration( + gradient: LinearGradient( + begin: Alignment.topLeft, + end: Alignment.bottomRight, + colors: [Colors.blueGrey, Colors.blueGrey.withOpacity(0.2)], + ), + ), + ), + controller: _advancedDrawerController, + animationCurve: Curves.easeInOut, + animationDuration: const Duration(milliseconds: 300), + animateChildDecoration: true, + rtlOpening: false, + // openScale: 1.0, + disabledGestures: false, + childDecoration: const BoxDecoration( + // NOTICE: Uncomment if you want to add shadow behind the page. + // Keep in mind that it may cause animation jerks. + // boxShadow: [ + // BoxShadow( + // color: Colors.black12, + // blurRadius: 0.0, + // ), + // ], + borderRadius: const BorderRadius.all(Radius.circular(16)), + ), + drawer: Container(), + child: Scaffold( + appBar: AppBar( + title: const Text('Advanced Drawer Example'), + leading: IconButton( + onPressed: _handleMenuButtonPressed, + icon: ValueListenableBuilder( + valueListenable: _advancedDrawerController, + builder: (_, value, __) { + return AnimatedSwitcher( + duration: Duration(milliseconds: 250), + child: Icon( + value.visible ? Icons.clear : Icons.menu, + key: ValueKey(value.visible), + ), + ); + }, + ), + ), + ), + body: Container(), + ), + ); + } + + void _handleMenuButtonPressed() {} +} diff --git a/macos/Flutter/GeneratedPluginRegistrant.swift b/macos/Flutter/GeneratedPluginRegistrant.swift index cccf817..4b6159c 100644 --- a/macos/Flutter/GeneratedPluginRegistrant.swift +++ b/macos/Flutter/GeneratedPluginRegistrant.swift @@ -5,6 +5,14 @@ import FlutterMacOS import Foundation +import firebase_auth +import firebase_core +import path_provider_foundation +import sqflite_darwin func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { + FLTFirebaseAuthPlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseAuthPlugin")) + FLTFirebaseCorePlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseCorePlugin")) + PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin")) + SqflitePlugin.register(with: registry.registrar(forPlugin: "SqflitePlugin")) } diff --git a/pubspec.lock b/pubspec.lock index af2ac16..586d285 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -1,6 +1,30 @@ # Generated by pub # See https://dart.dev/tools/pub/glossary#lockfile packages: + _flutterfire_internals: + dependency: transitive + description: + name: _flutterfire_internals + sha256: "5534e701a2c505fed1f0799e652dd6ae23bd4d2c4cf797220e5ced5764a7c1c2" + url: "https://pub.dev" + source: hosted + version: "1.3.44" + animated_botton_navigation: + dependency: "direct main" + description: + name: animated_botton_navigation + sha256: "4c8eb1c5d296c3f1e2144d9965a96ac71b02ee24b8577a3927aede6a86d9ba65" + url: "https://pub.dev" + source: hosted + version: "0.0.7" + animated_floating_buttons: + dependency: "direct main" + description: + name: animated_floating_buttons + sha256: cd89653ab917fb0d7ab04d5b5d6807c75de3f002de99b10f63fcf3c5c7133d60 + url: "https://pub.dev" + source: hosted + version: "0.0.2" async: dependency: transitive description: @@ -41,6 +65,22 @@ packages: url: "https://pub.dev" source: hosted version: "1.18.0" + counter_button: + dependency: "direct main" + description: + name: counter_button + sha256: "36992a764f513c9780195ec4613676d5d3dbe1685ccdb702bd1de7eb2cfe72d9" + url: "https://pub.dev" + source: hosted + version: "1.0.1" + crypto: + dependency: transitive + description: + name: crypto + sha256: "1e445881f28f22d6140f181e07737b22f1e099a5e1ff94b0af2f9e4a463f4855" + url: "https://pub.dev" + source: hosted + version: "3.0.6" cupertino_icons: dependency: "direct main" description: @@ -49,6 +89,22 @@ packages: url: "https://pub.dev" source: hosted version: "1.0.8" + dropdown_button2: + dependency: "direct main" + description: + name: dropdown_button2 + sha256: b0fe8d49a030315e9eef6c7ac84ca964250155a6224d491c1365061bc974a9e1 + url: "https://pub.dev" + source: hosted + version: "2.3.9" + equatable: + dependency: transitive + description: + name: equatable + sha256: c2b87cb7756efdf69892005af546c56c0b5037f54d2a88269b4f347a505e3ca2 + url: "https://pub.dev" + source: hosted + version: "2.0.5" fake_async: dependency: transitive description: @@ -57,11 +113,83 @@ packages: url: "https://pub.dev" source: hosted version: "1.3.1" + ffi: + dependency: transitive + description: + name: ffi + sha256: "16ed7b077ef01ad6170a3d0c57caa4a112a38d7a2ed5602e0aca9ca6f3d98da6" + url: "https://pub.dev" + source: hosted + version: "2.1.3" + firebase_auth: + dependency: "direct main" + description: + name: firebase_auth + sha256: d453acec0d958ba0e25d41a9901b32cb77d1535766903dea7a61b2788c304596 + url: "https://pub.dev" + source: hosted + version: "5.3.1" + firebase_auth_platform_interface: + dependency: transitive + description: + name: firebase_auth_platform_interface + sha256: "78966c2ef774f5bf2a8381a307222867e9ece3509110500f7a138c115926aa65" + url: "https://pub.dev" + source: hosted + version: "7.4.7" + firebase_auth_web: + dependency: transitive + description: + name: firebase_auth_web + sha256: "77ad3b252badedd3f08dfa21a4c7fe244be96c6da3a4067f253b13ea5d32424c" + url: "https://pub.dev" + source: hosted + version: "5.13.2" + firebase_core: + dependency: transitive + description: + name: firebase_core + sha256: "51dfe2fbf3a984787a2e7b8592f2f05c986bfedd6fdacea3f9e0a7beb334de96" + url: "https://pub.dev" + source: hosted + version: "3.6.0" + firebase_core_platform_interface: + dependency: transitive + description: + name: firebase_core_platform_interface + sha256: e30da58198a6d4b49d5bce4e852f985c32cb10db329ebef9473db2b9f09ce810 + url: "https://pub.dev" + source: hosted + version: "5.3.0" + firebase_core_web: + dependency: transitive + description: + name: firebase_core_web + sha256: f967a7138f5d2ffb1ce15950e2a382924239eaa521150a8f144af34e68b3b3e5 + url: "https://pub.dev" + source: hosted + version: "2.18.1" + fixnum: + dependency: transitive + description: + name: fixnum + sha256: b6dc7065e46c974bc7c5f143080a6764ec7a4be6da1285ececdc37be96de53be + url: "https://pub.dev" + source: hosted + version: "1.1.1" flutter: dependency: "direct main" description: flutter source: sdk version: "0.0.0" + flutter_advanced_drawer: + dependency: "direct main" + description: + name: flutter_advanced_drawer + sha256: "4d475bf48b30fcafe5ba9822ca302ea0aa9240317882fffd8450ba96a7e33105" + url: "https://pub.dev" + source: hosted + version: "1.3.6" flutter_lints: dependency: "direct dev" description: @@ -70,11 +198,48 @@ packages: url: "https://pub.dev" source: hosted version: "4.0.0" + flutter_product_card: + dependency: "direct main" + description: + name: flutter_product_card + sha256: "7dbad88b0138de2e3d4a671c81c049a34d1f9d56bd582190ab81c6ec9f23fe17" + url: "https://pub.dev" + source: hosted + version: "0.0.7" flutter_test: dependency: "direct dev" description: flutter source: sdk version: "0.0.0" + flutter_web_plugins: + dependency: transitive + description: flutter + source: sdk + version: "0.0.0" + http_parser: + dependency: transitive + description: + name: http_parser + sha256: "2aa08ce0341cc9b354a498388e30986515406668dbcc4f7c950c3e715496693b" + url: "https://pub.dev" + source: hosted + version: "4.0.2" + iconsax_flutter: + dependency: transitive + description: + name: iconsax_flutter + sha256: "95b65699da8ea98f87c5d232f06b0debaaf1ec1332b697e4d90969ec9a93037d" + url: "https://pub.dev" + source: hosted + version: "1.0.0" + intl: + dependency: transitive + description: + name: intl + sha256: d6f56758b7d3014a48af9701c085700aac781a92a87a62b1333b46d8879661cf + url: "https://pub.dev" + source: hosted + version: "0.19.0" leak_tracker: dependency: transitive description: @@ -139,6 +304,86 @@ packages: url: "https://pub.dev" source: hosted version: "1.9.0" + path_provider: + dependency: "direct main" + description: + name: path_provider + sha256: fec0d61223fba3154d87759e3cc27fe2c8dc498f6386c6d6fc80d1afdd1bf378 + url: "https://pub.dev" + source: hosted + version: "2.1.4" + path_provider_android: + dependency: transitive + description: + name: path_provider_android + sha256: c464428172cb986b758c6d1724c603097febb8fb855aa265aeecc9280c294d4a + url: "https://pub.dev" + source: hosted + version: "2.2.12" + path_provider_foundation: + dependency: transitive + description: + name: path_provider_foundation + sha256: f234384a3fdd67f989b4d54a5d73ca2a6c422fa55ae694381ae0f4375cd1ea16 + url: "https://pub.dev" + source: hosted + version: "2.4.0" + path_provider_linux: + dependency: transitive + description: + name: path_provider_linux + sha256: f7a1fe3a634fe7734c8d3f2766ad746ae2a2884abe22e241a8b301bf5cac3279 + url: "https://pub.dev" + source: hosted + version: "2.2.1" + path_provider_platform_interface: + dependency: transitive + description: + name: path_provider_platform_interface + sha256: "88f5779f72ba699763fa3a3b06aa4bf6de76c8e5de842cf6f29e2e06476c2334" + url: "https://pub.dev" + source: hosted + version: "2.1.2" + path_provider_windows: + dependency: transitive + description: + name: path_provider_windows + sha256: bd6f00dbd873bfb70d0761682da2b3a2c2fccc2b9e84c495821639601d81afe7 + url: "https://pub.dev" + source: hosted + version: "2.3.0" + pausable_timer: + dependency: transitive + description: + name: pausable_timer + sha256: "6ef1a95441ec3439de6fb63f39a011b67e693198e7dae14e20675c3c00e86074" + url: "https://pub.dev" + source: hosted + version: "3.1.0+3" + platform: + dependency: transitive + description: + name: platform + sha256: "9b71283fc13df574056616011fb138fd3b793ea47cc509c189a6c3fa5f8a1a65" + url: "https://pub.dev" + source: hosted + version: "3.1.5" + plugin_platform_interface: + dependency: transitive + description: + name: plugin_platform_interface + sha256: "4820fbfdb9478b1ebae27888254d445073732dae3d6ea81f0b7e06d5dedc3f02" + url: "https://pub.dev" + source: hosted + version: "2.1.8" + simple_gesture_detector: + dependency: transitive + description: + name: simple_gesture_detector + sha256: ba2cd5af24ff20a0b8d609cec3f40e5b0744d2a71804a2616ae086b9c19d19a3 + url: "https://pub.dev" + source: hosted + version: "0.2.1" sky_engine: dependency: transitive description: flutter @@ -152,6 +397,54 @@ packages: url: "https://pub.dev" source: hosted version: "1.10.0" + sprintf: + dependency: transitive + description: + name: sprintf + sha256: "1fc9ffe69d4df602376b52949af107d8f5703b77cda567c4d7d86a0693120f23" + url: "https://pub.dev" + source: hosted + version: "7.0.0" + sqflite: + dependency: "direct main" + description: + name: sqflite + sha256: "79a297dc3cc137e758c6a4baf83342b039e5a6d2436fcdf3f96a00adaaf2ad62" + url: "https://pub.dev" + source: hosted + version: "2.4.0" + sqflite_android: + dependency: transitive + description: + name: sqflite_android + sha256: "78f489aab276260cdd26676d2169446c7ecd3484bbd5fead4ca14f3ed4dd9ee3" + url: "https://pub.dev" + source: hosted + version: "2.4.0" + sqflite_common: + dependency: transitive + description: + name: sqflite_common + sha256: "4468b24876d673418a7b7147e5a08a715b4998a7ae69227acafaab762e0e5490" + url: "https://pub.dev" + source: hosted + version: "2.5.4+5" + sqflite_darwin: + dependency: transitive + description: + name: sqflite_darwin + sha256: "769733dddf94622d5541c73e4ddc6aa7b252d865285914b6fcd54a63c4b4f027" + url: "https://pub.dev" + source: hosted + version: "2.4.1-1" + sqflite_platform_interface: + dependency: transitive + description: + name: sqflite_platform_interface + sha256: "8dd4515c7bdcae0a785b0062859336de775e8c65db81ae33dd5445f35be61920" + url: "https://pub.dev" + source: hosted + version: "2.4.0" stack_trace: dependency: transitive description: @@ -176,6 +469,22 @@ packages: url: "https://pub.dev" source: hosted version: "1.2.0" + synchronized: + dependency: transitive + description: + name: synchronized + sha256: "69fe30f3a8b04a0be0c15ae6490fc859a78ef4c43ae2dd5e8a623d45bfcf9225" + url: "https://pub.dev" + source: hosted + version: "3.3.0+3" + table_calendar: + dependency: "direct main" + description: + name: table_calendar + sha256: "4ca32b2fc919452c9974abd4c6ea611a63e33b9e4f0b8c38dba3ac1f4a6549d1" + url: "https://pub.dev" + source: hosted + version: "3.1.2" term_glyph: dependency: transitive description: @@ -192,6 +501,30 @@ packages: url: "https://pub.dev" source: hosted version: "0.7.2" + toastification: + dependency: "direct main" + description: + name: toastification + sha256: "4d97fbfa463dfe83691044cba9f37cb185a79bb9205cfecb655fa1f6be126a13" + url: "https://pub.dev" + source: hosted + version: "2.3.0" + typed_data: + dependency: transitive + description: + name: typed_data + sha256: f9049c039ebfeb4cf7a7104a675823cd72dba8297f264b6637062516699fa006 + url: "https://pub.dev" + source: hosted + version: "1.4.0" + uuid: + dependency: transitive + description: + name: uuid + sha256: a5be9ef6618a7ac1e964353ef476418026db906c4facdedaa299b7a2e71690ff + url: "https://pub.dev" + source: hosted + version: "4.5.1" vector_math: dependency: transitive description: @@ -204,10 +537,34 @@ packages: dependency: transitive description: name: vm_service - sha256: f652077d0bdf60abe4c1f6377448e8655008eef28f128bc023f7b5e8dfeb48fc + sha256: "5c5f338a667b4c644744b661f309fb8080bb94b18a7e91ef1dbd343bed00ed6d" + url: "https://pub.dev" + source: hosted + version: "14.2.5" + web: + dependency: transitive + description: + name: web + sha256: cd3543bd5798f6ad290ea73d210f423502e71900302dde696f8bff84bf89a1cb + url: "https://pub.dev" + source: hosted + version: "1.1.0" + wolt_modal_sheet: + dependency: "direct main" + description: + name: wolt_modal_sheet + sha256: "2695dadd87e25604f0d9d64fae3696f4e053dcb7983a71e4494bb94b5bf3b67b" + url: "https://pub.dev" + source: hosted + version: "0.9.3" + xdg_directories: + dependency: transitive + description: + name: xdg_directories + sha256: "7a3f37b05d989967cdddcbb571f1ea834867ae2faa29725fd085180e0883aa15" url: "https://pub.dev" source: hosted - version: "14.2.4" + version: "1.1.0" sdks: dart: ">=3.5.0 <4.0.0" - flutter: ">=3.18.0-18.0.pre.54" + flutter: ">=3.24.0" diff --git a/pubspec.yaml b/pubspec.yaml index f29cbd6..529369e 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -2,7 +2,7 @@ name: store_sqlite description: "A new Flutter project." # The following line prevents the package from being accidentally published to # pub.dev using `flutter pub publish`. This is preferred for private packages. -publish_to: 'none' # Remove this line if you wish to publish to pub.dev +publish_to: "none" # Remove this line if you wish to publish to pub.dev # The following defines the version and build number for your application. # A version number is three numbers separated by dots, like 1.2.43 @@ -28,63 +28,60 @@ environment: # the latest version available on pub.dev. To see which dependencies have newer # versions available, run `flutter pub outdated`. dependencies: + animated_botton_navigation: ^0.0.7 + animated_floating_buttons: ^0.0.2 + counter_button: ^1.0.1 + cupertino_icons: ^1.0.8 + dropdown_button2: ^2.3.9 + firebase_auth: ^5.3.1 flutter: sdk: flutter - - - # The following adds the Cupertino Icons font to your application. - # Use with the CupertinoIcons class for iOS style icons. - cupertino_icons: ^1.0.8 + flutter_advanced_drawer: ^1.3.6 + flutter_product_card: ^0.0.7 + path_provider: ^2.1.4 + sqflite: ^2.3.3+1 + table_calendar: ^3.1.2 + wolt_modal_sheet: ^0.9.3 + toastification: ^2.3.0 dev_dependencies: + flutter_lints: ^4.0.0 flutter_test: sdk: flutter - # The "flutter_lints" package below contains a set of recommended lints to - # encourage good coding practices. The lint set provided by the package is - # activated in the `analysis_options.yaml` file located at the root of your - # package. See that file for information about deactivating specific lint - # rules and activating additional ones. - flutter_lints: ^4.0.0 - # For information on the generic Dart part of this file, see the # following page: https://dart.dev/tools/pub/pubspec - # The following section is specific to Flutter packages. flutter: - # The following line ensures that the Material Icons font is # included with your application, so that you can use the icons in # the material Icons class. uses-material-design: true # To add assets to your application, add an assets section, like this: - # assets: - # - images/a_dot_burr.jpeg - # - images/a_dot_ham.jpeg - - # An image asset can refer to one or more resolution-specific "variants", see - # https://flutter.dev/to/resolution-aware-images - - # For details regarding adding assets from package dependencies, see - # https://flutter.dev/to/asset-from-package - - # To add custom fonts to your application, add a fonts section here, - # in this "flutter" section. Each entry in this list should have a - # "family" key with the font family name, and a "fonts" key with a - # list giving the asset and other descriptors for the font. For - # example: - # fonts: - # - family: Schyler - # fonts: - # - asset: fonts/Schyler-Regular.ttf - # - asset: fonts/Schyler-Italic.ttf - # style: italic - # - family: Trajan Pro - # fonts: - # - asset: fonts/TrajanPro.ttf - # - asset: fonts/TrajanPro_Bold.ttf - # weight: 700 - # - # For details regarding fonts from package dependencies, - # see https://flutter.dev/to/font-from-package + assets: + - assets/img/ + # - images/a_dot_ham.jpeg + # An image asset can refer to one or more resolution-specific "variants", see + # https://flutter.dev/to/resolution-aware-images + # For details regarding adding assets from package dependencies, see + # https://flutter.dev/to/asset-from-package + # To add custom fonts to your application, add a fonts section here, + # in this "flutter" section. Each entry in this list should have a + # "family" key with the font family name, and a "fonts" key with a + # list giving the asset and other descriptors for the font. For + # example: + # fonts: + # - family: Schyler + # fonts: + # - asset: fonts/Schyler-Regular.ttf + # - asset: fonts/Schyler-Italic.ttf + # style: italic + # - family: Trajan Pro + # fonts: + # - asset: fonts/TrajanPro.ttf + # - asset: fonts/TrajanPro_Bold.ttf + # weight: 700 + # + # For details regarding fonts from package dependencies, + # see https://flutter.dev/to/font-from-package diff --git a/windows/flutter/generated_plugin_registrant.cc b/windows/flutter/generated_plugin_registrant.cc index 8b6d468..d141b74 100644 --- a/windows/flutter/generated_plugin_registrant.cc +++ b/windows/flutter/generated_plugin_registrant.cc @@ -6,6 +6,12 @@ #include "generated_plugin_registrant.h" +#include +#include void RegisterPlugins(flutter::PluginRegistry* registry) { + FirebaseAuthPluginCApiRegisterWithRegistrar( + registry->GetRegistrarForPlugin("FirebaseAuthPluginCApi")); + FirebaseCorePluginCApiRegisterWithRegistrar( + registry->GetRegistrarForPlugin("FirebaseCorePluginCApi")); } diff --git a/windows/flutter/generated_plugins.cmake b/windows/flutter/generated_plugins.cmake index b93c4c3..29944d5 100644 --- a/windows/flutter/generated_plugins.cmake +++ b/windows/flutter/generated_plugins.cmake @@ -3,6 +3,8 @@ # list(APPEND FLUTTER_PLUGIN_LIST + firebase_auth + firebase_core ) list(APPEND FLUTTER_FFI_PLUGIN_LIST