diff --git a/analysis_options.yaml b/analysis_options.yaml index 0d29021..9b164a1 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -7,6 +7,9 @@ # The following line activates a set of recommended lints for Flutter apps, # packages, and plugins designed to encourage good coding practices. +analyzer: + errors: + unnecessary_brace_in_string_interps: ignore include: package:flutter_lints/flutter.yaml linter: diff --git a/android/app/build.gradle b/android/app/build.gradle index b2e72ac..81c736a 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -7,7 +7,7 @@ plugins { android { namespace = "com.example.store_sqlite" - compileSdk = flutter.compileSdkVersion + compileSdk = 34 ndkVersion = flutter.ndkVersion compileOptions { @@ -24,8 +24,8 @@ 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 - targetSdk = flutter.targetSdkVersion + minSdk = 26 + targetSdk = 34 versionCode = flutter.versionCode versionName = flutter.versionName } diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index b4cf25d..c750ba7 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -1,41 +1,42 @@ - - + + + + + + + + + + + + - - + android:name=".MainActivity" + android:exported="true" + android:launchMode="singleTop" + android:taskAffinity="" + android:theme="@style/LaunchTheme" + android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode" + android:hardwareAccelerated="true" + android:windowSoftInputMode="adjustResize" + android:enableOnBackInvokedCallback="true"> + + + - - + + - diff --git a/android/app/src/main/res/mipmap-hdpi/ic_launcher.png b/android/app/src/main/res/mipmap-hdpi/ic_launcher.png index db77bb4..2b5f318 100644 Binary files a/android/app/src/main/res/mipmap-hdpi/ic_launcher.png and b/android/app/src/main/res/mipmap-hdpi/ic_launcher.png differ diff --git a/android/app/src/main/res/mipmap-mdpi/ic_launcher.png b/android/app/src/main/res/mipmap-mdpi/ic_launcher.png index 17987b7..9dc5525 100644 Binary files a/android/app/src/main/res/mipmap-mdpi/ic_launcher.png and b/android/app/src/main/res/mipmap-mdpi/ic_launcher.png differ diff --git a/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png index 09d4391..77efc03 100644 Binary files a/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png and b/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png index d5f1c8d..e2863e0 100644 Binary files a/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png and b/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png index 4d6372e..482b27e 100644 Binary files a/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png and b/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/assets/img/logo.png b/assets/img/logo.png new file mode 100644 index 0000000..08faa5f Binary files /dev/null and b/assets/img/logo.png differ 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/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index 40367d8..d094d3d 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -427,7 +427,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; - ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = AppIcon; CLANG_ANALYZER_NONNULL = YES; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; @@ -484,7 +484,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; - ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = AppIcon; CLANG_ANALYZER_NONNULL = YES; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png index dc9ada4..97cdfb7 100644 Binary files a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png index 7353c41..2b10f4e 100644 Binary files a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png index 797d452..b865d7f 100644 Binary files a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png index 6ed2d93..e8d5c75 100644 Binary files a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png index 4cd7b00..078f856 100644 Binary files a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png index fe73094..997da47 100644 Binary files a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png index 321773c..55c7fc7 100644 Binary files a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png index 797d452..b865d7f 100644 Binary files a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png index 502f463..ba6d1e9 100644 Binary files a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png index 0ec3034..2bed345 100644 Binary files a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-50x50@1x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-50x50@1x.png new file mode 100644 index 0000000..572a5c4 Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-50x50@1x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-50x50@2x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-50x50@2x.png new file mode 100644 index 0000000..4f25907 Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-50x50@2x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-57x57@1x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-57x57@1x.png new file mode 100644 index 0000000..d236cd9 Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-57x57@1x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-57x57@2x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-57x57@2x.png new file mode 100644 index 0000000..c8d7986 Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-57x57@2x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png index 0ec3034..2bed345 100644 Binary files a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png index e9f5fea..71927c0 100644 Binary files a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-72x72@1x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-72x72@1x.png new file mode 100644 index 0000000..2b5f318 Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-72x72@1x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-72x72@2x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-72x72@2x.png new file mode 100644 index 0000000..e2863e0 Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-72x72@2x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png index 84ac32a..88c9abc 100644 Binary files a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png index 8953cba..230a873 100644 Binary files a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png index 0467bf1..2cbb5a1 100644 Binary files a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png differ diff --git a/lib/config/globalValues.dart b/lib/config/globalValues.dart new file mode 100644 index 0000000..adb26ab --- /dev/null +++ b/lib/config/globalValues.dart @@ -0,0 +1,13 @@ +import 'package:flutter/material.dart'; + +class Globalvalues { + static ValueNotifier banMoviemientoActualizar = ValueNotifier(true); + static ValueNotifier refrescarWidget = ValueNotifier(true); + static ValueNotifier refrescarCarrito_desde_borrar = + ValueNotifier(true); + static ValueNotifier carritoContador = ValueNotifier(0); + static ValueNotifier id_Municipio = ValueNotifier(0); + static ValueNotifier refrescarCalendario = ValueNotifier(true); + static ValueNotifier refrescarCarrito = ValueNotifier(true); + static ValueNotifier refrecarCarritoContador = ValueNotifier(true); +} diff --git a/lib/controller/Comunidad_controller.dart b/lib/controller/Comunidad_controller.dart new file mode 100644 index 0000000..d0c6eff --- /dev/null +++ b/lib/controller/Comunidad_controller.dart @@ -0,0 +1,59 @@ +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]); + } + + Future>?> mostrarComunidadYMunicipio() async { + var con = await _dataBase.database; + var result = await con.rawQuery( + ''' + SELECT * + FROM comunidad c + inner join municipio m on c.id_municipio=m.id_municipio + ''', + ); + return result; + } + + Future?> mostrarComunidadByIdMunicipio( + int idMunicipio) async { + var con = await _dataBase.database; + var result = await con.rawQuery(''' + SELECT * FROM comunidad c + JOIN municipio m ON c.id_municipio = m.id_municipio + WHERE c.id_municipio = ? + ''', [idMunicipio]); + + if (result.isNotEmpty) { + return result.map((map) => ComunidadModel.fromMap(map)).toList(); + } + return null; + } +} diff --git a/lib/controller/carrito_controller.dart b/lib/controller/carrito_controller.dart new file mode 100644 index 0000000..cb77fbb --- /dev/null +++ b/lib/controller/carrito_controller.dart @@ -0,0 +1,50 @@ +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_producto) async { + var con = await _dataBase.database; + return await con + .delete(table, where: 'id_producto = ?', whereArgs: [id_producto]); + + } + + Future>> conteoDeArticulosEnCarrito() async { + var con = await _dataBase.database; + String sql = 'select sum(cantidad) from carrito'; + var result = await con.rawQuery(sql); + print(result); + return result; + } +} 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..b6d5129 --- /dev/null +++ b/lib/controller/municipio_controller.dart @@ -0,0 +1,44 @@ +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]); + } + + Future>?> mostrarmunicipioById( + int id_comunidad) async { + var con = await _dataBase.database; + var result = await con.rawQuery(''' + SELECT m.municipio AS municipio, m.id_municipio AS id_municipio +FROM municipio m +JOIN comunidad c ON m.id_municipio = c.id_municipio +WHERE c.id_comunidad = ? + ''', [id_comunidad]); + return result; + } +} diff --git a/lib/controller/pedido_controller.dart b/lib/controller/pedido_controller.dart new file mode 100644 index 0000000..3abf3a2 --- /dev/null +++ b/lib/controller/pedido_controller.dart @@ -0,0 +1,153 @@ +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>?> mostrarPedidoDatosDelPedidoPorFecha( + String fecha) 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.fecha_entrega=? +group by p.id_pedido +limit 1 + ''', [fecha]); // Aquí se pasa el parámetro + print(fecha); + 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; + } + + Future CHANGE_STATUS(int id_pedido, int id_status) async { + // Obtén la referencia a la base de datos + var con = await _dataBase.database; + + // Realiza la actualización + int count = await con.update( + 'pedido', // Nombre de la tabla + {'id_status': id_status}, // Campo a actualizar con el nuevo valor + where: 'id_pedido = ?', // Condición para encontrar el registro + whereArgs: [id_pedido], // Argumento de la condición + ); + + // Retorna `true` si se actualizó al menos una fila, `false` si no se actualizó nada + return count > 0; + } +} 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..ec5dcff --- /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 double) + .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..d025f2a 100644 --- a/lib/routes/rutes.dart +++ b/lib/routes/rutes.dart @@ -1,16 +1,41 @@ import 'package:flutter/material.dart'; +import 'package:store_sqlite/screens/Cruds/categoria_crud/categoria_crud_screen.dart'; +import 'package:store_sqlite/screens/Productos.dart'; +import 'package:store_sqlite/screens/carrito_screens.dart'; +import 'package:store_sqlite/screens/categoria_screen.dart'; +import 'package:store_sqlite/screens/comunidad_screen.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'; +import 'package:store_sqlite/screens/menuApp/MenuApp_screenV.dart'; +import 'package:store_sqlite/screens/municipios_screen.dart'; +import 'package:store_sqlite/screens/productos_screen.dart'; class AppRoutes { static const menuScreen = '/MenuScreen'; static const loginScreen = '/loginScreen'; - + static const informacionPedido = '/informacionPedido'; + static const productos = '/productos'; + static const carrito = '/carrito'; + static const categoria_screen = '/categoria'; + static const crudCategoria = '/crud_categoria'; + static const municipioScreen = '/municipios'; + static const productosScreen = '/listaProductos'; + static const comunidadScreen = '/comunidades'; 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: (context) => CarritoScreens(), + categoria_screen: (context) => CategoriaScreen(), + crudCategoria: (context) => CategoriaCrudScreen(), + municipioScreen: (context) => MunicipiosScreen(), + productosScreen: (context) => ProductosScreen(), + comunidadScreen: (context) => ComunidadScreen(), + menuScreen: (context) => MenuappScreenv(), }; } diff --git a/lib/screens/Cruds/categoria_crud/categoria_crud_screen.dart b/lib/screens/Cruds/categoria_crud/categoria_crud_screen.dart new file mode 100644 index 0000000..b73363a --- /dev/null +++ b/lib/screens/Cruds/categoria_crud/categoria_crud_screen.dart @@ -0,0 +1,55 @@ +import 'package:flutter/material.dart'; + +class CategoriaCrudScreen extends StatefulWidget { + const CategoriaCrudScreen({super.key}); + + @override + State createState() => _CategoriaCrudScreenState(); +} + +class _CategoriaCrudScreenState extends State { + TextEditingController conCategoria = TextEditingController(); + + @override + Widget build(BuildContext context) { + TextFormField txtCategoria = TextFormField( + keyboardType: TextInputType.name, + controller: conCategoria, + decoration: const InputDecoration( + label: Text('Ingresa una nueva categoria'), + prefixIcon: Icon(Icons.category_outlined), + ), + ); + + ElevatedButton btnGuardar = ElevatedButton( + style: ElevatedButton.styleFrom(backgroundColor: Colors.indigo), + onPressed: () {}, + child: const Text( + 'Guardar', + ), + ); + return Scaffold( + appBar: AppBar( + title: Text('Agregar Nuevas categorias'), + ), + body: ListView( + //solo la tiene list view + shrinkWrap: true, //hace la magia para que se pueda retraer al escribir + //final declaras una constante en la compilacion + children: [ + Padding( + padding: const EdgeInsets.all(40.0), + child: txtCategoria, + ), + Padding( + padding: const EdgeInsets.all(15.0), + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [btnGuardar, btnGuardar], + ), + ) + ], + ), + ); + } +} 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..3dfb2fe --- /dev/null +++ b/lib/screens/Productos.dart @@ -0,0 +1,104 @@ +import 'package:flutter/material.dart'; +import 'package:store_sqlite/config/globalValues.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'; +import 'package:store_sqlite/screens/Productos/cardWidgetToCarrito.dart'; +import 'package:badges/badges.dart' as badges; +import 'package:store_sqlite/screens/menuApp/MenuApp_screenV.dart'; + +class Productos extends StatefulWidget { + const Productos({super.key}); + + @override + State createState() => _ProductosState(); +} + +class _ProductosState extends State { + late ProductoController productoController = ProductoController(); + int _cartBadgeAmount = 4; + int relaConteo = 0; + late bool _showCartBadge = true; + + Future _initializeCartBadge() async { + await NumeroArticulosEnCArrito(); + setState(() { + _cartBadgeAmount = relaConteo; + + Globalvalues.carritoContador.value = + relaConteo; // Actualiza el valor global + }); + } + + Future> NumeroArticulosEnCArrito() async { + var resp = await carritoController.conteoDeArticulosEnCarrito(); + relaConteo = (resp[0]['sum(cantidad)'] ?? 0) as int; + return resp; + } + + @override + void initState() { + super.initState(); + _initializeCartBadge(); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar(actions: [_shoppingCartBadge()]), + 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: 0.5, + crossAxisSpacing: 10, + mainAxisSpacing: 10, + ), + itemCount: snapshot.data!.length, + itemBuilder: (BuildContext context, int index) { + return Cardwidgettocarrito(snapshot.data![index]); + }, + ); + }, + ), + ); + } + + Widget _shoppingCartBadge() { + return ValueListenableBuilder( + valueListenable: Globalvalues.carritoContador, + builder: (BuildContext context, int value, Widget? child) { + return badges.Badge( + position: badges.BadgePosition.topEnd(top: 0, end: 3), + badgeAnimation: badges.BadgeAnimation.slide(), + showBadge: _showCartBadge, + badgeStyle: badges.BadgeStyle( + badgeColor: const Color.fromARGB(255, 172, 6, 6), + ), + badgeContent: Text( + value.toString(), + style: TextStyle(color: Colors.white), + ), + child: IconButton( + icon: Icon(Icons.shopping_cart), + onPressed: () { + Navigator.pushNamed(context, '/carrito'); + }, + ), + ); + }, + ); + } + +} diff --git a/lib/screens/Productos/cardWidget.dart b/lib/screens/Productos/cardWidget.dart new file mode 100644 index 0000000..3c8e429 --- /dev/null +++ b/lib/screens/Productos/cardWidget.dart @@ -0,0 +1,335 @@ +import 'dart:io'; + +import 'package:flutter/material.dart'; +import 'package:flutter_product_card/flutter_product_card.dart'; +import 'package:image_picker/image_picker.dart'; +import 'package:path_provider/path_provider.dart'; +import 'package:store_sqlite/config/globalValues.dart'; +import 'package:store_sqlite/controller/carrito_controller.dart'; +import 'package:store_sqlite/controller/producto_controller.dart'; +import 'package:store_sqlite/models/categoria_model.dart'; +import 'package:store_sqlite/screens/Productos/dropDown_Categoria_widget.dart'; + +class Cardwidget extends StatefulWidget { + final Map producto; + Cardwidget(this.producto, {super.key}); + + @override + State createState() => _CardwidgetState(); +} + +class _CardwidgetState extends State { + ProductoController productoController = ProductoController(); + static ValueNotifier refrescarWidget = ValueNotifier(true); + File? _profilePicFile; + late String? _directoryImage; + void _directUpdateImage(File? file) async { + if (file == null) return; + + setState(() { + _profilePicFile = file; + }); + } + + CarritoController carritoController = CarritoController(); + + int _counterValue = 0; + int newId = 0; + String path = 'assets/img/products'; + + Future _pickImage(int id_Producto) async { + final ImagePicker picker = ImagePicker(); + final id = id_Producto; + final XFile? image = await picker.pickImage(source: ImageSource.gallery); + + if (image != null) { + // Obtener la ruta y el nombre de la imagen + final String imagePath = image.path; + final String imageName = image.name; + + // Imprimir la ruta y el nombre para verificar + print('Path: $imagePath, Name: $imageName, el id= $id_Producto'); + // Guardar la imagen en la carpeta de la aplicación + await saveImageInAppDirectory(File(image.path), imageName, id); + + // Actualizar la imagen directamente (si es necesario) + // _directUpdateImage(File(image.path)); + } + } + + Future saveImageInAppDirectory( + File image, String imageName, int id) async { + final directory = await getApplicationDocumentsDirectory(); + + _directoryImage = '${directory.path}/assets/img/products'; + + final imageDir = Directory(_directoryImage!); + + if (!(await imageDir.exists())) { + await imageDir.create(recursive: true); + } + + final savedImagePath = '$_directoryImage/$imageName'; + final savedImage = await image.copy(savedImagePath); + + print('Imagen guardada en: $savedImagePath'); + print('directoryPath=${_directoryImage}'); + int res = await productoController.actualizarProducto( + 'producto', {'img_producto': '$imageName', 'id_producto': '$id'}); + // Aquí puedes agregar lógica para guardar el path en la base de datos + + print('res de la actualizacion $res'); + if (res > 0) { + Globalvalues.refrescarWidget.value = !Globalvalues.refrescarWidget.value; + } + } + + @override + void initState() { + // TODO: implement initState + + _directoryImage = + '/data/user/0/com.example.store_sqlite/app_flutter/assets/img/products'; + super.initState(); + } + + @override + Widget build(BuildContext context) { + double precio = widget.producto['precio']; + return Column( + children: [ + ProductCard( + onFavoritePressed: () { + int id_producto = widget.producto['id_producto']; + _pickImage( + id_producto); // Llama a la función para seleccionar una imagen + }, + imageUrl: widget.producto['img_producto'] != null + ? '${_directoryImage}/${widget.producto['img_producto']}' + : 'assets/img/logo_pizza.jfif', + categoryName: '${widget.producto['categoria']}', + productName: '${widget.producto['producto']}', + price: precio, + currency: '\$', + onTap: () { + showModalBottomSheet( + context: context, + isScrollControlled: + true, // Permite que el modal ocupe toda la pantalla + // barrierColor: Colors.greenAccent, + backgroundColor: const Color.fromARGB(255, 46, 45, 41), + elevation: 10, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(10.0), + ), + builder: (BuildContext context) { + int id = widget.producto['id_producto']; + return editarProducto(widget: widget); + }, + ); + }, + 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 + ], + ); + } +} + +class editarProducto extends StatefulWidget { + final Cardwidget? widget; + const editarProducto({ + super.key, + this.widget, + }); + + @override + _editarProductoState createState() => _editarProductoState(); +} + +class _editarProductoState extends State { + TextEditingController conNameProduct = TextEditingController(); + TextEditingController conDescripcion = TextEditingController(); + TextEditingController conPrecio = TextEditingController(); + int? id_categoria; + String? categoria; + + @override + void initState() { + super.initState(); + if (widget.widget != null) { + // Inicializa los controladores con los valores actuales del producto + conNameProduct.text = widget.widget?.producto['producto']; + conDescripcion.text = widget.widget?.producto['descripcion']; + conPrecio.text = widget.widget!.producto['precio'].toString(); + id_categoria = widget.widget?.producto['id_categoria']; + categoria = widget.widget?.producto['categoria']; + } else { + conNameProduct.clear(); + conDescripcion.clear(); + conPrecio.clear(); + } + } + + @override + void dispose() { + // Limpia los controladores cuando el widget se destruye + conNameProduct.dispose(); + conDescripcion.dispose(); + conPrecio.dispose(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + TextFormField txtName = TextFormField( + controller: conNameProduct, + decoration: InputDecoration( + label: Text(id_categoria == null + ? 'Nombre del producto' + : 'Agregar Nuevo Producto')), + ); + + TextFormField txtDescripcion = TextFormField( + controller: conDescripcion, + decoration: InputDecoration( + border: OutlineInputBorder(), + labelText: 'Escribe una descripción:', + ), + maxLines: 3, + ); + + TextFormField txtPrecio = TextFormField( + controller: conPrecio, + decoration: InputDecoration(label: Text('Precio:')), + ); + + return DraggableScrollableSheet( + expand: false, + builder: (context, scrollController) { + return Container( + padding: const EdgeInsets.all(16.0), + child: ListView( + shrinkWrap: true, + controller: scrollController, + children: [ + Padding( + padding: const EdgeInsets.only(top: 50), + child: Center(child: Text('EDITAR PRODUCTO')), + ), + Padding( + padding: const EdgeInsets.only(top: 40), + child: txtName, + ), + Padding( + padding: const EdgeInsets.all(12.0), + child: txtDescripcion, + ), + Padding( + padding: const EdgeInsets.all(12.0), + child: txtPrecio, + ), + Padding( + padding: const EdgeInsets.all(8.0), + child: Center(child: Text('Categoria:')), + ), + DropdownCategoriaWidget( + id_categoria, + categoria, + OnChanged: (CategoriaModel? categoria) { + print('trae el valor de vuelta'); + print(categoria?.id_categoria); + if (categoria != null) { + setState(() { + id_categoria = categoria.id_categoria!; + }); + } else { + print('ocurrio un error'); + } + }, + ), + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Padding( + padding: const EdgeInsets.all(8.0), + child: Container( + width: MediaQuery.of(context).size.width * .3, + height: MediaQuery.of(context).size.height * .05, + decoration: BoxDecoration( + color: const Color.fromARGB(255, 221, 21, 10), + borderRadius: BorderRadius.circular(100)), + child: IconButton( + onPressed: () { + Navigator.pop(context); + }, + icon: Icon(Icons.cancel)), + ), + ), + Padding( + padding: const EdgeInsets.all(8.0), + child: Container( + width: MediaQuery.of(context).size.width * .3, + height: MediaQuery.of(context).size.height * .05, + decoration: BoxDecoration( + color: const Color.fromARGB(255, 11, 141, 11), + borderRadius: BorderRadius.circular(100)), + child: IconButton( + onPressed: () { + double precio_Converter = + double.parse(conPrecio.text); + try { + if (widget.widget?.producto['id_producto'] != + null) { + ActualizarProducto(precio_Converter); + } else if (widget + .widget?.producto['id_producto'] == + null) { + insertarProducto(precio_Converter); + } + } catch (e) { + print('el error al editar el producto= $e'); + } + }, + icon: Icon(Icons.done)), + ), + ), + ], + ) + ], + ), + ); + }, + ); + } + + void insertarProducto(double precio_converter) { + ProductoController productoController = ProductoController(); + productoController.insertProducto('producto', { + 'id_categoria': '$id_categoria', + 'producto': conNameProduct.text, + 'descripcion': conDescripcion.text, + 'precio': '${precio_converter}' + }); + print('Producto Agregado'); + Globalvalues.refrescarWidget.value = !Globalvalues.refrescarWidget.value; + Navigator.pop(context); + } + + void ActualizarProducto(double precio_converter) { + ProductoController productoController = ProductoController(); + productoController.actualizarProducto('producto', { + 'id_producto': '${widget.widget!.producto['id_producto']}', + 'id_categoria': '$id_categoria', + 'producto': conNameProduct.text, + 'descripcion': conDescripcion.text, + 'precio': '${precio_converter}' + }); + print('el producto se actualizo'); + Globalvalues.refrescarWidget.value = !Globalvalues.refrescarWidget.value; + Navigator.pop(context); + } +} diff --git a/lib/screens/Productos/cardWidgetToCarrito.dart b/lib/screens/Productos/cardWidgetToCarrito.dart new file mode 100644 index 0000000..304ccbb --- /dev/null +++ b/lib/screens/Productos/cardWidgetToCarrito.dart @@ -0,0 +1,122 @@ +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/config/globalValues.dart'; +import 'package:store_sqlite/controller/carrito_controller.dart'; + +class Cardwidgettocarrito extends StatefulWidget { + final Map producto; + Cardwidgettocarrito(this.producto, {super.key}); + + @override + State createState() => _CardwidgetState(); +} + +class _CardwidgetState extends State { + CarritoController carritoController = CarritoController(); + int _counterValue = 0; + final String _directoryImage = + '/data/user/0/com.example.store_sqlite/app_flutter/assets/img/products'; + @override + void initState() { + super.initState(); + } + + @override + Widget build(BuildContext context) { + String path = 'assets/img/products'; + + double precio = widget.producto['precio']; + + double subtotal = 0; + return Column( + children: [ + ProductCard( + imageUrl: widget.producto['img_producto'] != null + ? '${_directoryImage}/${widget.producto['img_producto']}' + : 'assets/img/logo_pizza.jfif', + 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: () async { + print(_counterValue); + + subtotal = precio * _counterValue; + if (subtotal > 0 && _counterValue > 0) { + // Validaciones + setState( + () { + inSertarACarrito(subtotal); + // Actualiza el contador global para que se refleje el cambio en el badge + _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), + ), + ], + ); + } + + Future inSertarACarrito(double subtotal) async { + try { + int resp = await carritoController.insertCarrito('carrito', { + 'id_producto': widget.producto['id_producto'], + 'cantidad': _counterValue, + 'subtotal': subtotal, + }); + + if (resp > 0) { + // Aquí se obtiene el número de productos en el carrito desde la base de datos + var resp = await carritoController.conteoDeArticulosEnCarrito(); + int cantidadProductos = (resp[0]['sum(cantidad)'] ?? 0) as int; + Globalvalues.carritoContador.value = cantidadProductos; + print('cantidad=$cantidadProductos'); + return cantidadProductos; + } else { + print('no se mando nada'); + } + } catch (e) { + 'fallo al haceer la insercion $e'; + } + return null; + } +} diff --git a/lib/screens/Productos/dropDown_Categoria_widget.dart b/lib/screens/Productos/dropDown_Categoria_widget.dart new file mode 100644 index 0000000..5e64e68 --- /dev/null +++ b/lib/screens/Productos/dropDown_Categoria_widget.dart @@ -0,0 +1,125 @@ +import 'package:flutter/material.dart'; +import 'package:store_sqlite/controller/Comunidad_controller.dart'; +import 'package:store_sqlite/controller/categoria_controller.dart'; +import 'package:store_sqlite/models/categoria_model.dart'; + +class DropdownCategoriaWidget extends StatefulWidget { + final Function(CategoriaModel?) OnChanged; + final int? id_categoria; + final String? categoria; + DropdownCategoriaWidget( + this.id_categoria, + this.categoria, { + super.key, + required this.OnChanged, + }); + + @override + State createState() => + _DropdownCategoriaWidgetState(); +} + +class _DropdownCategoriaWidgetState extends State { + CategoriaController categoriaController = CategoriaController(); + List _categorias = []; + List> _categoria_by_id = []; + + CategoriaModel? _categoriaSeleccionada; + CategoriaModel? _editarCategoria; + int? id_categoria; + String? categoria = 'Selecciona categoria'; + + @override + void initState() { + // TODO: implement initState + id_categoria = widget.id_categoria; + + categoria = widget.categoria; + agregarAlModelo(id_categoria, categoria); + cargarCategorias(); + super.initState(); + } + + void cargarCategorias() async { + try { + List? categorias = + await categoriaController.mostrarTodasLasCategorias(); + setState(() { + _categorias = categorias ?? []; + }); + } catch (e) { + print(e); + } + } + + void agregarAlModelo(int? id_categoria, String? categoria) { + _editarCategoria = + CategoriaModel(id_categoria: id_categoria, categoria: categoria); + } + + @override + Widget build(BuildContext context) { + return Center( + child: Container( + padding: const EdgeInsets.symmetric(vertical: 5, horizontal: 15), + width: 300, + decoration: BoxDecoration( + color: Theme.of(context).primaryColor, + borderRadius: BorderRadius.circular(30), + ), + child: DropdownButton( + // value: id_municipio == null ? _editarMunicipio : _selectedMunicipio, + //en el onchange mapeamos + value: _categoriaSeleccionada, + onChanged: (CategoriaModel? value) { + setState(() { + _categoriaSeleccionada = value; + }); + widget.OnChanged(value); // Pasar el valor seleccionado al callback + categoria = _categoriaSeleccionada?.categoria; + debugPrint( + "Has seleccionado: ${_categoriaSeleccionada?.categoria} con ID: ${_categoriaSeleccionada?.id_categoria}"); + }, + hint: Center( + child: Text( + id_categoria == null ? 'Seleccione Categoria' : '${categoria}', + style: const TextStyle(color: Colors.white), + ), + ), + underline: Container(), + dropdownColor: const Color.fromARGB(255, 202, 188, 145), + icon: const Icon( + Icons.arrow_downward, + color: Color.fromARGB(255, 130, 126, 92), + ), + isExpanded: true, + items: _categorias + .map((categoria) => DropdownMenuItem( + value: categoria, // El objeto MunicipioModel es el valor + child: Container( + alignment: Alignment.centerLeft, + child: Text( + '${categoria.categoria}', + style: const TextStyle(fontSize: 18), + ), + ), + )) + .toList(), + selectedItemBuilder: (BuildContext context) => _categorias + .map((categoria) => Center( + child: Text( + '${categoria.categoria}', + style: const TextStyle( + fontSize: 18, + color: Color.fromARGB(255, 223, 200, 131), + fontStyle: FontStyle.italic, + fontWeight: FontWeight.bold, + ), + ), + )) + .toList(), + ), + ), + ); + } +} diff --git a/lib/screens/calendarScreen.dart b/lib/screens/calendarScreen.dart new file mode 100644 index 0000000..a5c84a2 --- /dev/null +++ b/lib/screens/calendarScreen.dart @@ -0,0 +1,327 @@ +import 'package:flutter/material.dart'; +import 'package:store_sqlite/config/globalValues.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(); + int? _status; + + @override + void initState() { + super.initState(); + // mostrarPedidoDatosCliente(); + main(); // Cargar eventos al inicio + } + + Future> _buildEventMarkers(DateTime date, List events) async { + List markers = []; + + for (var event in events) { + Color color = + await SelectColorPoints(date); // Obtiene el color de cada evento + markers.add( + Container( + margin: const EdgeInsets.symmetric(horizontal: 1.5), + width: 8, + height: 8, + decoration: BoxDecoration( + shape: BoxShape.circle, + color: color, + ), + ), + ); + } + + return markers; + } + + 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) { + print(dato); + String fecha = dato['fecha_entrega']; + String eventTitle = dato['nombre_cliente']; + + String eventDescp = + '${dato['calle']} ,${dato['colonia']} ,${dato['no_exterior']}'; + + // Revisa si la fecha se almacena en el formato correcto + print('Fecha: $fecha, Usuario: $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] ?? []; + } + + Future mostrarPedidoDatosCliente(String Fecha) async { + // String Fecha = '2024-10-18'; + List>? pedidoPorFecha = + await pedidoController.mostrarPedidoDatosDelPedidoPorFecha(Fecha); + for (var pedido in pedidoPorFecha!) { + pedido['municipio']; + pedido['id_municipio']; + // print('${municipio['id_status']} ${municipio['id_pedido']}'); + _status = pedido['id_status']; + } + } + + Future SelectColorPoints(DateTime? selectedDate) async { + String fecha = DateFormat('yyyy-MM-dd').format(selectedDate!); + await mostrarPedidoDatosCliente( + fecha); // Esperamos que la función asíncrona termine + + // Insert into status(status)values('completado'),('En Proceso'),('cancelado') + print('status=${_status}'); + + switch (_status) { + case 1: + return Colors.green; // Si el idStatus es 1, el color será verde. + case 3: + return Colors.red; // Si el idStatus es 3, el color será rojo. + case 2: + return Colors.white; // Si el idStatus es 2, el color será blanco. + default: + return Colors.grey; + } + } + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar(title: Text('Eventos')), + body: ValueListenableBuilder( + valueListenable: Globalvalues.refrescarCalendario, + builder: (BuildContext context, dynamic value, Widget? child) { + return 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; + }); + + // Recopilamos los eventos de la fecha seleccionada + List eventosDelDia = _listOfDayEvents(selectedDay); + + // Mostramos el ModalBottomSheet con los eventos del día + 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: ${DateFormat('yyyy-MM-dd').format(selectedDay)}', + style: TextStyle( + fontSize: 18, fontWeight: FontWeight.bold), + ), + SizedBox(height: 10), + + // Mostramos los eventos del día + ...eventosDelDia.map((event) { + return ListTile( + onTap: () { + // Navigator.pushNamed( + // context, '/informacionPedido', + // arguments: { + // 'id_pedido': + // snapshot.data![index].id_pedido, + // 'id_status': + // snapshot.data![index].id_status + // }); + }, + title: Text('Cliente: ${event['eventTitle']}'), + subtitle: + Text('Direccion: ${event['eventDescp']}'), + ); + }).toList(), + + // Botón para cerrar el modal + SizedBox(height: 10), + ElevatedButton( + onPressed: () => Navigator.pop(context), + child: Text('Cerrar'), + ), + + // Otros detalles adicionales que quieras mostrar + SizedBox(height: 10), + Text( + 'Detalles adicionales sobre los eventos del día ${DateFormat('yyyy-MM-dd').format(selectedDay)}'), + ], + ), + ), + ), + ); + } + }, + onFormatChanged: (format) { + if (_calendarFormat != format) { + setState(() { + _calendarFormat = format; + }); + } + }, + onPageChanged: (focusedDay) { + _focusedDay = focusedDay; + }, + eventLoader: _listOfDayEvents, + + // Aquí está el `calendarBuilders` con los puntos de colores + calendarBuilders: CalendarBuilders( + markerBuilder: (context, date, events) { + if (events.isNotEmpty) { + return FutureBuilder>( + future: _buildEventMarkers(date, events), + builder: (context, snapshot) { + if (snapshot.connectionState == + ConnectionState.waiting) { + return Container( + margin: const EdgeInsets.symmetric(horizontal: 1.5), + width: 8, + height: 8, + decoration: BoxDecoration( + shape: BoxShape.circle, + color: Colors.grey, + ), + ); + } else if (snapshot.hasError) { + return Container( + margin: const EdgeInsets.symmetric(horizontal: 1.5), + width: 8, + height: 8, + decoration: BoxDecoration( + shape: BoxShape.circle, + color: Colors.red, + ), + ); + } else { + return Row( + mainAxisAlignment: MainAxisAlignment.center, + children: snapshot.data!, + ); + } + }, + ); + } + return SizedBox(); // Si no hay eventos, no muestra nada + }, + ), + ), + if (_selectedDate != null) + ..._listOfDayEvents(_selectedDate!).map((myEvents) => + FutureBuilder( + future: SelectColorPoints(_selectedDate), + builder: (context, snapshot) { + if (snapshot.connectionState == ConnectionState.waiting) { + // Mientras esperamos que el futuro se complete, mostramos un indicador de carga o color predeterminado + return ListTile( + leading: const Icon( + Icons.done, + color: + Colors.grey, // Muestra un color predeterminado + ), + title: Padding( + padding: const EdgeInsets.only(bottom: 8.0), + child: Text( + 'Event Title: ${myEvents['eventTitle']}'), + ), + subtitle: + Text('Description: ${myEvents['eventDescp']}'), + ); + } else if (snapshot.hasError) { + // Si hay algún error, muestra un icono o color diferente + return ListTile( + leading: const Icon( + Icons.error, + color: Colors.red, // Muestra un color de error + ), + title: Padding( + padding: const EdgeInsets.only(bottom: 8.0), + child: Text( + 'Event Title: ${myEvents['eventTitle']}'), + ), + subtitle: + Text('Description: ${myEvents['eventDescp']}'), + ); + } else { + // Una vez que el futuro se complete, usamos el color devuelto + return ListTile( + leading: Icon( + Icons.done, + color: snapshot + .data, // Usamos el color retornado por SelectColorPoints + ), + title: Padding( + padding: const EdgeInsets.only(bottom: 8.0), + child: Text( + 'Event Title: ${myEvents['eventTitle']}'), + ), + subtitle: + Text('Description: ${myEvents['eventDescp']}'), + ); + } + }, + )) + ]); + }, + ), + ); + } + + // ignore: non_constant_identifier_names +} 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..fa7d844 --- /dev/null +++ b/lib/screens/carrito_screens.dart @@ -0,0 +1,455 @@ + +import 'package:counter_button/counter_button.dart'; +import 'package:flutter/material.dart'; +import 'package:store_sqlite/config/globalValues.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/comunidad_model.dart'; +import 'package:store_sqlite/models/lista_pedido_model.dart'; +import 'package:store_sqlite/models/municipio_model.dart'; +import 'package:store_sqlite/models/toast_notification.dart'; +import 'package:store_sqlite/screens/carrito_widgets/dropDown_Municipio_Widget.dart'; +import 'package:store_sqlite/screens/carrito_widgets/dropdown_Comunidad_Car_widget.dart'; +import 'package:store_sqlite/screens/carrito_widgets/dropdown_Municipio_Car_widget.dart'; +import 'package:store_sqlite/screens/comunidad/dropdown_Comunidad_widget.dart'; + +class CarritoScreens extends StatefulWidget { + const CarritoScreens({super.key}); + + @override + State createState() => _CarritoScreensState(); +} + +class _CarritoScreensState extends State { + // static ValueNotifier refrescarCarrito = ValueNotifier(true); + CarritoController carritoController = CarritoController(); + List _counterValues = []; + int? id_municipio; + int? id_comunidad; + 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(); + // id_municipio = 1; + } + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: const Text('Carrito'), + ), + floatingActionButton: ValueListenableBuilder( + valueListenable: Globalvalues.id_Municipio, + builder: (context, value, child) { + return FloatingActionButton( + child: const Icon(Icons.check), + onPressed: () { + // Mostrar modal para ingresar datos + showModalBottomSheet( + context: context, + isScrollControlled: true, + builder: (context) { + return StatefulBuilder( + builder: (BuildContext context, StateSetter setState) { + return 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), + ), + ), + Text('Municipio'), + DropdownMunicipioCarWidget( + id_municipio, + onChanged: (MunicipioModel? municipio) { + if (municipio != null) { + print( + "Municipio seleccionado: ${municipio.municipio}, ID: ${municipio.id_municipio}"); + setState(() { + id_municipio = municipio.id_municipio; + Globalvalues.id_Municipio.value = + id_municipio!; + print( + 'Globalvalues.id_Municipio.value=${Globalvalues.id_Municipio.value}'); + }); + } else { + print("No se seleccionó ningún municipio."); + } + }, + ), + Text('Comunidad'), + DropdownComunidadCarWidget( + id_municipio: Globalvalues.id_Municipio + .value, // Asegúrate de que este ID tenga un valor válido + onChanged: (ComunidadModel? comunidad) { + if (comunidad != null) { + print( + "Comunidad seleccionada: ${comunidad.comunidad}, ID: ${comunidad.id_comunidad}"); + setState(() { + id_comunidad = comunidad + .id_comunidad; // Actualiza el ID de la comunidad seleccionada + }); + } else { + print("No se seleccionó ninguna comunidad."); + } + }, + ), + 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': id_comunidad, + // 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(() { + Globalvalues.refrescarCarrito.value = + !Globalvalues + .refrescarCarrito.value; + + 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: ValueListenableBuilder( + valueListenable: Globalvalues.refrescarCarrito, + builder: (BuildContext context, dynamic value, Widget? child) { + return 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: Row( + mainAxisAlignment: MainAxisAlignment + .spaceBetween, // Espacia elementos + children: [ + Expanded( + // Asegura que el texto ocupe el espacio restante + child: Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Text( + '${carrito['producto']}', + style: const TextStyle( + fontSize: 18, + fontWeight: FontWeight + .bold, // Resalta el nombre del producto + ), + ), + const SizedBox( + height: + 4), // Espacio entre el nombre del producto y la información + Text( + 'Cantidad: ${carrito['cantidad']}', + style: const TextStyle( + fontSize: 16, + color: Colors + .grey, // Color gris para menor jerarquía + ), + ), + const SizedBox( + height: 2), // Espacio adicional + Text( + 'Subtotal: \$${carrito['subtotal'].toStringAsFixed(2)}', // Formato de precio + style: const TextStyle( + fontSize: 16, + color: Colors + .green, // Verde para el subtotal + fontWeight: FontWeight + .w600, // Fuente más fuerte + ), + ), + ], + ), + ), + IconButton( + onPressed: () async { + int res = await carritoController + .eliminarCarrito('carrito', + carrito['id_producto']); + if (res > 0) { + setState(() { + Globalvalues + .refrescarCarrito.value = + !Globalvalues + .refrescarCarrito.value; + // Navigator.pop(context); + toast.showToast( + context, + 'Borrado', + 'Se borró con exito!', + 'success'); + }); + } + }, + + icon: const Icon(Icons.delete, + color: Colors + .red), // Ícono de eliminar en rojo + ), + ], + ), + ), + ], + ), + ), + ), + ); + }, + ); + } 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/carrito_widgets/dropdown_Comunidad_Car_widget.dart b/lib/screens/carrito_widgets/dropdown_Comunidad_Car_widget.dart new file mode 100644 index 0000000..a2f6f21 --- /dev/null +++ b/lib/screens/carrito_widgets/dropdown_Comunidad_Car_widget.dart @@ -0,0 +1,109 @@ +import 'package:flutter/material.dart'; +import 'package:store_sqlite/controller/Comunidad_controller.dart'; +import 'package:store_sqlite/models/comunidad_model.dart'; + +class DropdownComunidadCarWidget extends StatefulWidget { + final Function(ComunidadModel?) onChanged; + final int id_municipio; + + const DropdownComunidadCarWidget({ + required this.id_municipio, + super.key, + required this.onChanged, + }); + + @override + State createState() => + _DropdownComunidadWidgetState(); +} + +class _DropdownComunidadWidgetState extends State { + ComunidadController comunidadController = ComunidadController(); + List _comunidades = []; + ComunidadModel? _selectedComunidad; + + @override + void initState() { + super.initState(); + print('el id_municipio que llego =${widget.id_municipio}'); + _loadComunidadById_municipio(widget.id_municipio); + } + + // Este método detecta cambios en los parámetros del widget + @override + void didUpdateWidget(DropdownComunidadCarWidget oldWidget) { + super.didUpdateWidget(oldWidget); + if (oldWidget.id_municipio != widget.id_municipio) { + _loadComunidadById_municipio(widget.id_municipio); + } + } + + Future _loadComunidadById_municipio(int id_municipio) async { + try { + // Obtener las comunidades basadas en el id_municipio + List? comunidades = + await comunidadController.mostrarComunidadByIdMunicipio(id_municipio); + + setState(() { + // Si no se encuentran comunidades, asigna una lista vacía + _comunidades = comunidades ?? []; + _selectedComunidad = + null; // Reinicia la selección al cargar nuevos datos + }); + } catch (e) { + debugPrint('Error al cargar comunidades: $e'); + setState(() { + _comunidades = []; // Si hay un error, también se reinicia la lista + _selectedComunidad = null; + }); + } + } + + @override + Widget build(BuildContext context) { + return Center( + child: Container( + padding: const EdgeInsets.symmetric(vertical: 5, horizontal: 15), + width: 300, + decoration: BoxDecoration( + color: Theme.of(context).primaryColor, + borderRadius: BorderRadius.circular(30), + ), + child: DropdownButton( + value: _selectedComunidad, + onChanged: (ComunidadModel? value) { + setState(() { + _selectedComunidad = value; + }); + widget.onChanged(value); // Pasar el valor seleccionado al callback + }, + hint: Center( + child: Text( + _selectedComunidad?.comunidad ?? 'Selecciona', + style: const TextStyle(color: Colors.white), + ), + ), + underline: Container(), + dropdownColor: const Color.fromARGB(255, 202, 188, 145), + icon: const Icon( + Icons.arrow_downward, + color: Color.fromARGB(255, 130, 126, 92), + ), + isExpanded: true, + items: _comunidades + .map((comunidad) => DropdownMenuItem( + value: comunidad, + child: Container( + alignment: Alignment.centerLeft, + child: Text( + comunidad.comunidad!, + style: const TextStyle(fontSize: 18), + ), + ), + )) + .toList(), + ), + ), + ); + } +} diff --git a/lib/screens/carrito_widgets/dropdown_Municipio_Car_widget.dart b/lib/screens/carrito_widgets/dropdown_Municipio_Car_widget.dart new file mode 100644 index 0000000..0ed56ea --- /dev/null +++ b/lib/screens/carrito_widgets/dropdown_Municipio_Car_widget.dart @@ -0,0 +1,164 @@ +import 'package:flutter/material.dart'; +import 'package:store_sqlite/controller/municipio_controller.dart'; +import 'package:store_sqlite/models/municipio_model.dart'; + +class DropdownMunicipioCarWidget extends StatefulWidget { + //recibe el modelo de municipio + final Function(MunicipioModel?) onChanged; + final int? id_comunidad; + const DropdownMunicipioCarWidget( + this.id_comunidad, + {super.key, required this.onChanged}); + + @override + State createState() => + _DropdownComunidadWidgetState(); +} + +class _DropdownComunidadWidgetState extends State { + MunicipioController municipioController = MunicipioController(); + + // Lista de municipios obtenidos de la base de datos + List _municipios = []; //para gau + List> _municipioBuId = [{}]; + // Variable para almacenar el municipio seleccionado + MunicipioModel? _selectedMunicipio; + MunicipioModel? _editarMunicipio; + int? id_comunidad; + int? id_municipio; + String? municipioN ='Selecciona'; + @override + void initState() { + super.initState(); + id_comunidad = widget.id_comunidad; + print('el id que llego=${id_comunidad}'); + // Cargar los municipios desde la base de datos al iniciar la pantalla + _loadMunicipioById(id_comunidad); + print(_municipioBuId); + print('++++++++++++++++++'); + _loadMunicipios(); + print(municipioN); + print('7777777777777777777777'); + } + + Future _loadMunicipios() async { + try { + // Obtener los municipios desde el controlador + List? municipios = + await municipioController.mostrarTodosLosMunicipios(); + + setState(() { + _municipios = municipios ?? []; + }); + } catch (e) { + debugPrint('Error al cargar municipios: $e'); + } + } + + Future _loadMunicipioById(int? id_comunidad) async { + try { + // Obtener los municipios desde el controlador + + List>? municipioByid = + await municipioController.mostrarmunicipioById(id_comunidad!); + setState(() { + print('estamos imprimiendo MunicipioByID $id_comunidad'); + print(municipioByid); + + setState(() { + _municipioBuId = municipioByid!; + for (var municipio in _municipioBuId) { + municipioN = municipio['municipio']; + id_municipio = municipio['id_municipio']; + agregarAlModelo(id_municipio, municipio['municipio']); + } + print('el munucipio ggs'); + print(municipioN); + }); + }); + } catch (e) { + debugPrint('Error al cargar municipios: $e'); + } + } + + void agregarAlModelo(int? id_municipio, String? municipio) { + _editarMunicipio = MunicipioModel( + id_municipio: id_municipio, + municipio: municipio, + ); + } + + @override + Widget build(BuildContext context) { + print(id_municipio); + print('------------------------------------'); + + if (id_comunidad == null) { + _selectedMunicipio = _editarMunicipio; + } else { + _editarMunicipio = _selectedMunicipio; + } + return Center( + child: Container( + padding: const EdgeInsets.symmetric(vertical: 5, horizontal: 15), + width: 300, + decoration: BoxDecoration( + color: Theme.of(context).primaryColor, + borderRadius: BorderRadius.circular(30), + ), + child: DropdownButton( + // value: id_municipio == null ? _editarMunicipio : _selectedMunicipio, + //en el onchange mapeamos + value: _selectedMunicipio, + onChanged: (MunicipioModel? value) { + setState(() { + _selectedMunicipio = value; + }); + widget.onChanged(value); // Pasar el valor seleccionado al callback + municipioN = _selectedMunicipio?.municipio; + debugPrint( + "Has seleccionado: ${_selectedMunicipio?.municipio} con ID: ${_selectedMunicipio?.id_municipio}"); + }, + hint: Center( + child: Text( + id_comunidad == null ? '${municipioN}' : '${municipioN}', + style: const TextStyle(color: Colors.white), + ), + ), + underline: Container(), + dropdownColor: const Color.fromARGB(255, 202, 188, 145), + icon: const Icon( + Icons.arrow_downward, + color: Color.fromARGB(255, 130, 126, 92), + ), + isExpanded: true, + items: _municipios + .map((municipio) => DropdownMenuItem( + value: municipio, // El objeto MunicipioModel es el valor + child: Container( + alignment: Alignment.centerLeft, + child: Text( + '${municipio.municipio}', + style: const TextStyle(fontSize: 18), + ), + ), + )) + .toList(), + selectedItemBuilder: (BuildContext context) => _municipios + .map((municipio) => Center( + child: Text( + '${municipio.municipio}', + style: const TextStyle( + fontSize: 18, + color: Color.fromARGB(255, 223, 200, 131), + fontStyle: FontStyle.italic, + fontWeight: FontWeight.bold, + ), + ), + )) + .toList(), + ), + ), + ); + } +} diff --git a/lib/screens/categoria_screen.dart b/lib/screens/categoria_screen.dart new file mode 100644 index 0000000..5c2f85b --- /dev/null +++ b/lib/screens/categoria_screen.dart @@ -0,0 +1,290 @@ +import 'package:flutter/material.dart'; +import 'package:store_sqlite/controller/categoria_controller.dart'; +import 'package:store_sqlite/models/categoria_model.dart'; + +class CategoriaScreen extends StatefulWidget { + const CategoriaScreen({super.key}); + + @override + State createState() => _CategoriaScreenState(); +} + +class _CategoriaScreenState extends State { + TextEditingController conCategoria = TextEditingController(); + CategoriaController categoriaController = CategoriaController(); + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: const Text('Lista de Categorias'), + ), + floatingActionButton: FloatingActionButton( + onPressed: () { + modal(context, null, null); + }, + child: const Icon(Icons.add_circle), + ), + body: Container( + width: MediaQuery.of(context).size.width, + height: MediaQuery.of(context).size.height, + child: FutureBuilder( + future: categoriaController.mostrarTodasLasCategorias(), + 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: () {}, + child: Container( + width: MediaQuery.of(context).size.width, + padding: const EdgeInsets.all(20), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(10), + color: const Color.fromARGB(136, 60, 81, 73), + border: const Border( + left: BorderSide( + color: Color.fromARGB(255, 100, 80, 73), + width: 4, + ), + ), + ), + child: Column( + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + // Texto del pedido y fecha de entrega + Expanded( + child: Text( + 'id: ${snapshot.data![index].id_categoria}\nCategoria: ${snapshot.data![index].categoria}', + textAlign: TextAlign.left, + style: const TextStyle( + fontSize: 16, + ), + ), + ), + // Botón de editar + IconButton( + icon: const Icon(Icons.edit, + color: Colors.blue), + onPressed: () { + modal( + context, + snapshot.data![index].categoria, + snapshot.data![index].id_categoria); + ScaffoldMessenger.of(context) + .hideCurrentSnackBar(); + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + content: Text( + 'Es el boton editar y tenemos el id=${snapshot.data![index].id_categoria}'), + backgroundColor: Colors.red, + ), + ); + }, + ), + // Botón de borrar + // IconButton( + // icon: const Icon(Icons.delete, + // color: Colors.red), + // onPressed: () { + // // Acción para eliminar el elemento + // // Aquí podrías mostrar una confirmación de eliminación antes de proceder. + // }, + // ), + ], + ), + ], + ), + ), + ), + ); + }, + + //${snapshot.data![index].fecha_entrega}', + //); + ); + } else { + if (snapshot.hasError) { + return Center( + child: Text(snapshot.error.toString()), + ); + } else { + return const Center( + child: CircularProgressIndicator(), + ); + } + } + }, + ), + ), + ); + } + + Future modal( + BuildContext context, String? categoria, int? id_categoria) { + if (categoria != null) { + conCategoria.text = categoria; + } else { + conCategoria.clear(); // Limpia el controlador si es una nueva categoría. + } + + return 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: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + Padding( + padding: const EdgeInsets.all(8.0), + child: Text( + ///valida si la categoria viene vacia + id_categoria == null + ? 'NUEVA CATEGORÍA' + : 'EDITAR CATEGORÍA'), + ), + const SizedBox(height: 10), + Padding( + padding: const EdgeInsets.all(20.0), + child: TextFormField( + controller: conCategoria, + decoration: const InputDecoration( + label: Text('Ingresa una categoría'), + prefixIcon: Icon(Icons.category_outlined), + ), + ), + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + ElevatedButton( + onPressed: () => Navigator.pop(context), + child: const Row( + children: [ + Icon(Icons.cancel, + color: Color.fromARGB(255, 107, 4, 4)), + Text( + 'Cancelar', + style: TextStyle( + color: Color.fromARGB(255, 158, 6, 6), + fontSize: 12), + ), + ], + ), + ), + ElevatedButton( + onPressed: () { + ///valida si la categoria no esta vacia + if (conCategoria.text.trim().isNotEmpty) { + + if (id_categoria == null) { + // Si id_categoria es nulo, significa que es una nueva categoría. + _agregarCategoria(); + } else { + // Si id_categoria tiene un valor, significa que estamos editando. + _editarCategoria(id_categoria); + } + } else { + ScaffoldMessenger.of(context).hideCurrentSnackBar(); + ScaffoldMessenger.of(context).showSnackBar( + const SnackBar( + content: Text('El campo no puede estar vacío'), + backgroundColor: Colors.orange, + ), + ); + } + }, + child: Row( + children: [ + Icon( + Icons.done_outline_outlined, + color: Colors.greenAccent, + ), + Text( + id_categoria == null ? 'Agregar' : 'Guardar Cambios', + style: const TextStyle( + color: Colors.greenAccent, + fontSize: 16, + ), + ), + ], + ), + ), + ], + ), + ], + ), + ), + ), + ); + } + + void _agregarCategoria() { + try { + categoriaController.insertCategoria( + 'categoria', + {'categoria': conCategoria.text.trim()}, + ); + conCategoria.clear(); + ScaffoldMessenger.of(context).hideCurrentSnackBar(); + ScaffoldMessenger.of(context).showSnackBar( + const SnackBar( + content: Text('Categoría agregada correctamente'), + backgroundColor: Colors.green, + ), + ); + Navigator.pop(context); + setState(() {}); // Actualizar la lista de categorías. + } catch (e) { + ScaffoldMessenger.of(context).hideCurrentSnackBar(); + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + content: Text('Hubo un error al agregar la categoría: $e'), + backgroundColor: Colors.red, + ), + ); + } + } + + void _editarCategoria( + int id_categoria, + ) { + try { + // categoriaController.insertCategoria( + // 'categoria', + // {'categoria': conCategoria.text.trim()}, + // id_categoria, + // ); + categoriaController.actualizarCategoria('categoria', { + 'id_categoria': id_categoria, + 'categoria': conCategoria.text.trim() + }); + conCategoria.clear(); + ScaffoldMessenger.of(context).hideCurrentSnackBar(); + ScaffoldMessenger.of(context).showSnackBar( + const SnackBar( + content: Text('Categoría actualizada correctamente'), + backgroundColor: Colors.green, + ), + ); + Navigator.pop(context); + setState(() {}); // Actualizar la lista de categorías. + } catch (e) { + ScaffoldMessenger.of(context).hideCurrentSnackBar(); + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + content: Text('Hubo un error al actualizar la categoría: $e'), + backgroundColor: Colors.red, + ), + ); + } + } +} diff --git a/lib/screens/comunidad/dropdown_Comunidad_widget.dart b/lib/screens/comunidad/dropdown_Comunidad_widget.dart new file mode 100644 index 0000000..4cb501e --- /dev/null +++ b/lib/screens/comunidad/dropdown_Comunidad_widget.dart @@ -0,0 +1,164 @@ +import 'package:flutter/material.dart'; +import 'package:store_sqlite/controller/municipio_controller.dart'; +import 'package:store_sqlite/models/municipio_model.dart'; + +class DropdownComunidadWidget extends StatefulWidget { + //recibe el modelo de municipio + final Function(MunicipioModel?) onChanged; + final int? id_comunidad; + const DropdownComunidadWidget( + this.id_comunidad, + {super.key, required this.onChanged}); + + @override + State createState() => + _DropdownComunidadWidgetState(); +} + +class _DropdownComunidadWidgetState extends State { + MunicipioController municipioController = MunicipioController(); + + // Lista de municipios obtenidos de la base de datos + List _municipios = []; //para gau + List> _municipioBuId = [{}]; + // Variable para almacenar el municipio seleccionado + MunicipioModel? _selectedMunicipio; + MunicipioModel? _editarMunicipio; + int? id_comunidad; + int? id_municipio; + String? municipioN ='Selecciona'; + @override + void initState() { + super.initState(); + id_comunidad = widget.id_comunidad; + print('el id que llego=${id_comunidad}'); + // Cargar los municipios desde la base de datos al iniciar la pantalla + _loadMunicipioById(id_comunidad); + print(_municipioBuId); + print('++++++++++++++++++'); + _loadMunicipios(); + print(municipioN); + print('7777777777777777777777'); + } + + Future _loadMunicipios() async { + try { + // Obtener los municipios desde el controlador + List? municipios = + await municipioController.mostrarTodosLosMunicipios(); + + setState(() { + _municipios = municipios ?? []; + }); + } catch (e) { + debugPrint('Error al cargar municipios: $e'); + } + } + + Future _loadMunicipioById(int? id_comunidad) async { + try { + // Obtener los municipios desde el controlador + + List>? municipioByid = + await municipioController.mostrarmunicipioById(id_comunidad!); + setState(() { + print('estamos imprimiendo MunicipioByID $id_comunidad'); + print(municipioByid); + + setState(() { + _municipioBuId = municipioByid!; + for (var municipio in _municipioBuId) { + municipioN = municipio['municipio']; + id_municipio = municipio['id_municipio']; + agregarAlModelo(id_municipio, municipio['municipio']); + } + print('el munucipio ggs'); + print(municipioN); + }); + }); + } catch (e) { + debugPrint('Error al cargar municipios: $e'); + } + } + + void agregarAlModelo(int? id_municipio, String? municipio) { + _editarMunicipio = MunicipioModel( + id_municipio: id_municipio, + municipio: municipio, + ); + } + + @override + Widget build(BuildContext context) { + print(id_municipio); + print('------------------------------------'); + + if (id_comunidad == null) { + _selectedMunicipio = _editarMunicipio; + } else { + _editarMunicipio = _selectedMunicipio; + } + return Center( + child: Container( + padding: const EdgeInsets.symmetric(vertical: 5, horizontal: 15), + width: 300, + decoration: BoxDecoration( + color: Theme.of(context).primaryColor, + borderRadius: BorderRadius.circular(30), + ), + child: DropdownButton( + // value: id_municipio == null ? _editarMunicipio : _selectedMunicipio, + //en el onchange mapeamos + value: _selectedMunicipio, + onChanged: (MunicipioModel? value) { + setState(() { + _selectedMunicipio = value; + }); + widget.onChanged(value); // Pasar el valor seleccionado al callback + municipioN = _selectedMunicipio?.municipio; + debugPrint( + "Has seleccionado: ${_selectedMunicipio?.municipio} con ID: ${_selectedMunicipio?.id_municipio}"); + }, + hint: Center( + child: Text( + id_comunidad == null ? '${municipioN}' : '${municipioN}', + style: const TextStyle(color: Colors.white), + ), + ), + underline: Container(), + dropdownColor: const Color.fromARGB(255, 202, 188, 145), + icon: const Icon( + Icons.arrow_downward, + color: Color.fromARGB(255, 130, 126, 92), + ), + isExpanded: true, + items: _municipios + .map((municipio) => DropdownMenuItem( + value: municipio, // El objeto MunicipioModel es el valor + child: Container( + alignment: Alignment.centerLeft, + child: Text( + '${municipio.municipio}', + style: const TextStyle(fontSize: 18), + ), + ), + )) + .toList(), + selectedItemBuilder: (BuildContext context) => _municipios + .map((municipio) => Center( + child: Text( + '${municipio.municipio}', + style: const TextStyle( + fontSize: 18, + color: Color.fromARGB(255, 223, 200, 131), + fontStyle: FontStyle.italic, + fontWeight: FontWeight.bold, + ), + ), + )) + .toList(), + ), + ), + ); + } +} diff --git a/lib/screens/comunidad_screen.dart b/lib/screens/comunidad_screen.dart new file mode 100644 index 0000000..885e063 --- /dev/null +++ b/lib/screens/comunidad_screen.dart @@ -0,0 +1,318 @@ +import 'package:flutter/material.dart'; +import 'package:store_sqlite/controller/Comunidad_controller.dart'; +import 'package:store_sqlite/controller/carrito_controller.dart'; +import 'package:store_sqlite/controller/categoria_controller.dart'; +import 'package:store_sqlite/controller/municipio_controller.dart'; +import 'package:store_sqlite/models/municipio_model.dart'; +import 'package:store_sqlite/screens/comunidad/dropdown_Comunidad_widget.dart'; + +class ComunidadScreen extends StatefulWidget { + const ComunidadScreen({super.key}); + + @override + State createState() => _ComunidadScreenState(); +} + +class _ComunidadScreenState extends State { + CarritoController carritoController = CarritoController(); + ComunidadController comunidadController = ComunidadController(); + MunicipioController municipioController = MunicipioController(); + TextEditingController conComunidad = TextEditingController(); + + String? _selectedMunicipio; // Guardamos el valor seleccionado aquí + int? id_municipio; + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar(title: Text('Lista De Comunidades'),), + floatingActionButton: FloatingActionButton(onPressed: () { + modal(context, null, null); + }), + body: FutureBuilder>?>( + future: comunidadController.mostrarComunidadYMunicipio(), + 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) { + List> comunidades = snapshot.data!; + return ListView.builder( + itemCount: comunidades.length, + itemBuilder: (context, index) { + var comunidad = comunidades[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: Column( + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + '${comunidad['id_comunidad']}\n comunidad=${comunidad['comunidad']}\n municipio=${comunidad['municipio']}', + textAlign: TextAlign.left, + style: const TextStyle( + fontSize: 16, + ), + ), + ], + ), + ), + IconButton( + onPressed: () { + modal(context, comunidad['comunidad'], + comunidad['id_comunidad']); + ScaffoldMessenger.of(context) + .hideCurrentSnackBar(); + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + content: Text( + 'Es el boton editar y tenemos el id=${comunidad['id_comunidad']}'), + backgroundColor: Colors.red, + ), + ); + }, + icon: Icon(Icons.edit, color: Colors.blue), + ), + // IconButton( + // icon: + // const Icon(Icons.delete, color: Colors.red), + // onPressed: () { + // // Acción para eliminar el elemento + // // Aquí podrías mostrar una confirmación de eliminación antes de proceder. + // }, + // ), + ], + ), + ], + ), + ), + ), + ); + }, + ); + } else { + return const Center( + child: Text('No hay pedidos disponibles'), + ); + } + }, + ), + ); + } + + Future modal( + BuildContext context, String? comunidad, int? id_comunidad) { + //le pasa el valor a la caja de texto + if (comunidad != null) { + conComunidad.text = comunidad; + } else { + conComunidad.clear(); + } + + return 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: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + Padding( + padding: const EdgeInsets.all(8.0), + child: Text(id_comunidad == null + ? 'NUEVA COMUNIDAD' + : 'EDITAR COMUNIDAD'), + ), + const SizedBox(height: 10), + Padding( + padding: const EdgeInsets.all(20.0), + child: TextFormField( + controller: conComunidad, + decoration: const InputDecoration( + label: Text('COMUNIDAD'), + prefixIcon: Icon(Icons.category_outlined), + ), + ), + ), + DropdownComunidadWidget( + //le pasamos el modelo para que pueda leerlo + id_comunidad = id_comunidad, + onChanged: (MunicipioModel? municipio) { + if (municipio != null) { + // si no viene vacio + print( + "Municipio seleccionado: ${municipio.municipio}, ID: ${municipio.id_municipio}"); + setState(() { + id_municipio = municipio.id_municipio; + }); + } else { + print( + "Municipio editar seleccionado : ${municipio?.municipio}, ID: ${municipio?.id_municipio}"); + } + }, + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + ElevatedButton( + onPressed: () => Navigator.pop(context), + child: const Row( + children: [ + Icon(Icons.cancel, + color: Color.fromARGB(255, 107, 4, 4)), + Text( + 'Cancelar', + style: TextStyle( + color: Color.fromARGB(255, 158, 6, 6), + fontSize: 12), + ), + ], + ), + ), + ElevatedButton( + onPressed: () { + ///valida si la categoria no esta vacia + if (conComunidad.text.trim().isNotEmpty) { + if (id_comunidad == null) { + // Si id_categoria es nulo, significa que es una nueva categoría. + // _agregarComunidad(); + print('¿¿¿¿¿¿¿¿¿'); + print('${conComunidad.text}' '${id_municipio}'); + _agregarComunidad(conComunidad.text, id_municipio!); + } else { + // Si id_categoria tiene un valor, significa que estamos editando. + //_editarMucipio(id_municipio); + _editarComunidad( + id_comunidad!, id_municipio, conComunidad.text); + print('tiene comuniad'); + print(id_comunidad); + print('tiene municipio'); + print(id_municipio); + print('nombreCoomunidad'); + print(comunidad); + } + } else { + ScaffoldMessenger.of(context).hideCurrentSnackBar(); + ScaffoldMessenger.of(context).showSnackBar( + const SnackBar( + content: Text('El campo no puede estar vacío'), + backgroundColor: Colors.orange, + ), + ); + } + }, + child: Row( + children: [ + Icon( + Icons.done_outline_outlined, + color: Colors.greenAccent, + ), + Text( + id_comunidad == null ? 'Agregar' : 'Guardar Cambios', + style: const TextStyle( + color: Colors.greenAccent, + fontSize: 16, + ), + ), + ], + ), + ), + ], + ), + ], + ), + ), + ), + ); + } + + void _agregarComunidad(String comunidad, int id_municipio) { + // 'INSERT INTO comunidad (comunidad, id_comunidad) + try { + comunidadController.insertarComunidad( + 'comunidad', + {'comunidad': comunidad, 'id_municipio': id_municipio}, + ); + conComunidad.clear(); + ScaffoldMessenger.of(context).hideCurrentSnackBar(); + ScaffoldMessenger.of(context).showSnackBar( + const SnackBar( + content: Text('Categoría agregada correctamente'), + backgroundColor: Colors.green, + ), + ); + Navigator.pop(context); + setState(() {}); // Actualizar la lista de categorías. + } catch (e) { + ScaffoldMessenger.of(context).hideCurrentSnackBar(); + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + content: Text('Hubo un error al agregar la categoría: $e'), + backgroundColor: Colors.red, + ), + ); + } + } + + void _editarComunidad(id_comunidad, id_municipio, comunidad) { + try { + // SqfliteDatabaseException (DatabaseException(no such column: id_comunidad (code 1 SQLITE_ERROR): + // , while compiling: UPDATE municipio SET id_comunidad = ?, comunidad = ?, id_municipio = ? + // WHERE id_comunidad = ?) sql + // 'UPDATE municipio SET id_comunidad = ?, comunidad = ?, id_municipio = ? WHERE id_comunidad = ?' + // args [4, rrrrr, 4, 4]) + comunidadController.actualizarComunidad( + 'comunidad', + { + 'comunidad': comunidad, + 'id_municipio': id_municipio, + 'id_comunidad': id_comunidad + }, + ); + conComunidad.clear(); + ScaffoldMessenger.of(context).hideCurrentSnackBar(); + ScaffoldMessenger.of(context).showSnackBar( + const SnackBar( + content: Text('Comunidad actualizada correctamente'), + backgroundColor: Colors.green, + ), + ); + Navigator.pop(context); + setState(() {}); // Actualizar la lista de categorías. + } catch (e) { + ScaffoldMessenger.of(context).hideCurrentSnackBar(); + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + content: Text('Hubo un error al actualizar la comunidad: $e'), + backgroundColor: Colors.red, + ), + ); + } + } +} diff --git a/lib/screens/informacionPedido.dart b/lib/screens/informacionPedido.dart new file mode 100644 index 0000000..c8591f4 --- /dev/null +++ b/lib/screens/informacionPedido.dart @@ -0,0 +1,46 @@ +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), + ], + )); + } +} diff --git a/lib/screens/infromacionPedido/InformacionPedidoWidget.dart b/lib/screens/infromacionPedido/InformacionPedidoWidget.dart new file mode 100644 index 0000000..fd49a7a --- /dev/null +++ b/lib/screens/infromacionPedido/InformacionPedidoWidget.dart @@ -0,0 +1,252 @@ +import 'package:art_sweetalert/art_sweetalert.dart'; +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; + + return Container( + width: MediaQuery.of(context).size.width, // Ajuste en MediaQuery + height: MediaQuery.of(context).size.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 Column( + children: [ + Expanded( + child: ListView.builder( + itemCount: pedidos.length, + itemBuilder: (context, index) { + var pedido = pedidos[index]; + return Column( + children: [ + Container( + child: ListTile( + title: Text('Artículo: ${pedido['producto']}'), + subtitle: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text('Cantidad: ${pedido['cantidad']}'), + SizedBox(height: 4.0), + Text( + 'Precio: \$${pedido['precio']}', + style: + TextStyle(fontWeight: FontWeight.bold), + ), + SizedBox(height: 4.0), + Text( + 'Subtotal: ${pedido['subtotal'] ?? 0}'), // Ajuste en Subtotal + ], + ), + ), + ), + ], + ); + }, + ), + ), + arguments['id_status'] == 2 + ? Row( + children: [ + Expanded( + child: Padding( + padding: EdgeInsets.all(10), + child: ElevatedButton( + style: ButtonStyle( + textStyle: MaterialStateProperty.all( + TextStyle(fontSize: 18), + ), + backgroundColor: MaterialStateProperty.all( + Color.fromARGB(255, 255, 0, 0)), + ), + onPressed: () async { + // Acción del primer botón + ArtDialogResponse? response = + await ArtSweetAlert.show( + barrierDismissible: false, + context: context, + artDialogArgs: ArtDialogArgs( + showCancelBtn: true, + title: + "¿Seguro que quieres rechazarlo?", + // confirmButtonText: "Si", + confirmButtonColor: Colors.red, + confirmButtonText: 'Rechazar', + cancelButtonText: 'Cancelar', + onConfirm: () async { + await informacionPedido + .CHANGE_STATUS( + widget.id!, 3) + ? ArtSweetAlert.show( + context: context, + artDialogArgs: + ArtDialogArgs( + type: + ArtSweetAlertType + .success, + title: + "El pedido de rechazo", + confirmButtonColor: + Colors + .green, + onConfirm: () { + setState(() { + return; + }); + Navigator.pushNamed( + context, + '/MenuScreen'); + }), + ) + : ArtSweetAlert.show( + context: context, + artDialogArgs: + ArtDialogArgs( + type: + ArtSweetAlertType + .danger, + title: + "No se pudo rechazar", + confirmButtonColor: + Colors.red, + onConfirm: () { + setState( + () {}); + }), + ); + }, + ), + ) ?? + null; + if (response == null) { + return; + } + + if (response.isTapDenyButton) { + return; + } + }, + child: Text("Rechazar", + style: TextStyle(color: Colors.white)), + ), + ), + ), + Expanded( + child: Padding( + padding: EdgeInsets.all(10), + child: ElevatedButton( + style: ButtonStyle( + textStyle: MaterialStateProperty.all( + TextStyle(fontSize: 18), + ), + backgroundColor: MaterialStateProperty.all( + Color.fromARGB(213, 0, 188, 0)), + ), + onPressed: () async { + // Acción del primer botón + ArtDialogResponse? response = + await ArtSweetAlert.show( + barrierDismissible: false, + context: context, + artDialogArgs: ArtDialogArgs( + showCancelBtn: true, + title: + "¿Seguro que quieres completar el pedido?", + // confirmButtonText: "Si", + confirmButtonColor: Colors.green, + confirmButtonText: + 'Completar pedido', + cancelButtonText: 'Cancelar', + onConfirm: () async { + await informacionPedido + .CHANGE_STATUS( + widget.id!, 1) + ? ArtSweetAlert.show( + context: context, + artDialogArgs: + ArtDialogArgs( + type: + ArtSweetAlertType + .success, + title: + "El pedido se completo", + confirmButtonColor: + Colors + .green, + onConfirm: () { + setState(() { + return; + }); + Navigator.pushNamed( + context, + '/MenuScreen'); + }), + ) + : ArtSweetAlert.show( + context: context, + artDialogArgs: + ArtDialogArgs( + type: + ArtSweetAlertType + .danger, + title: + "No se pudo completar el pedido", + confirmButtonColor: + Colors.red, + onConfirm: () { + setState( + () {}); + }), + ); + }, + ), + ) ?? + null; + if (response == null) { + return; + } + + if (response.isTapDenyButton) { + return; + } + }, + child: Text("Completar", + style: TextStyle(color: Colors.white)), + ), + ), + ), + ], + ) + : Divider(), + ], + ); + } + }, + ), + ); + } +} 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..5f27bd9 --- /dev/null +++ b/lib/screens/menuApp/MenuApp_screenV.dart @@ -0,0 +1,288 @@ +import 'package:animated_botton_navigation/animated_botton_navigation.dart'; +import 'package:flutter/material.dart'; +import 'package:store_sqlite/config/globalValues.dart'; +import 'package:store_sqlite/controller/carrito_controller.dart'; +import 'package:store_sqlite/screens/calendarScreen.dart'; +import 'package:store_sqlite/screens/menuApp/widgetMenuApp/PedidosListaWidget.dart'; +import 'package:permission_handler/permission_handler.dart'; +import 'package:badges/badges.dart' as badges; + +class MenuappScreenv extends StatefulWidget { + const MenuappScreenv({super.key}); + + @override + State createState() => _MenuappScreenvState(); +} + +Future requestPermission() async { + final permission = Permission.location; + + if (await permission.isDenied) { + await permission.request(); + } +} + +Future checkPermissionStatus() async { + final permission = Permission.location; + return await permission.status.isGranted; +} + +Future requestPermissionCamera() async { + final permission = Permission.storage; + + if (await permission.isDenied) { + await permission.request(); + } +} + +Future checkPermissionStatusCamera() async { + final permission = Permission.camera; + + return await permission.status.isGranted; +} + +Future requestPermissionManageStorage() async { + final permission = Permission.manageExternalStorage; + + if (await permission.isDenied) { + // Solicitar el permiso + final result = await permission.request(); + + // Manejar el resultado + if (result.isGranted) { + print('Se le dieron los permisos'); + } else if (result.isDenied) { + print('Permiso denegado, no se puede acceder al almacenamiento'); + } else if (result.isPermanentlyDenied) { + print('Permiso permanentemente denegado, redirigiendo a configuración'); + // Redirigir a la configuración de la app + openAppSettings(); + } + } else { + print('Ya tiene permisos de almacenamiento'); + } +} + +CarritoController carritoController = CarritoController(); +int _cartBadgeAmount = 4; +int relaConteo = 0; +late bool _showCartBadge; + +// Future> NumeroArticulosEnCArrito() async { +// var resp = await carritoController.conteoDeArticulosEnCarrito(); +// print(' este es el parametro de articulos=$resp'); + +// relaConteo = (resp[0]['sum(cantidad)'] ?? 0) as int; +// print('in metodo=$relaConteo'); +// // for (var cantidad in resp) { +// // cantidad['sum(cantidad)']; +// // print('el for'); +// // print(cantidad['sum(cantidad)']); +// // cantidad['sum(cantidad)']; +// // } +// print('cantidad carirto cast'); +// // print(cantidadCarrito); +// return resp; +// } + +// Color color = Colors.red; +Future requestPermissionStorage() async { + final permission = Permission.manageExternalStorage; + + if (await permission.isDenied) { + final result = await permission.request(); + if (result.isGranted) { + // Permission is granted + } else if (result.isDenied) { + // Permission is denied + } else if (result.isPermanentlyDenied) { + // Permission is permanently denied + } + } +} + +class _MenuappScreenvState extends State { + int _cartBadgeAmount = 4; + int relaConteo = 0; + late bool _showCartBadge = true; + + Future _initializeCartBadge() async { + await NumeroArticulosEnCArrito(); + setState(() { + _cartBadgeAmount = relaConteo; + + Globalvalues.carritoContador.value = + relaConteo; // Actualiza el valor global + }); + } + + Future> NumeroArticulosEnCArrito() async { + var resp = await carritoController.conteoDeArticulosEnCarrito(); + relaConteo = (resp[0]['sum(cantidad)'] ?? 0) as int; + return resp; + } + + @override + void initState() { + super.initState(); + _initializeCartBadge(); + } + + 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) { + _showCartBadge = _cartBadgeAmount > 0; + 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: () { + ///perdir permisos + requestPermissionManageStorage(); + // requestPermissionStorage() + Navigator.pushNamed(context, '/listaProductos'); + }, + leading: Icon(Icons.food_bank), + title: Text('Productos'), + ), + ListTile( + onTap: () { + Navigator.pushNamed(context, '/categoria'); + }, + leading: Icon(Icons.category), + title: Text('Categorias'), + ), + ListTile( + onTap: () { + Navigator.pushNamed(context, '/municipios'); + }, + leading: Icon(Icons.location_city), + title: Text('Municipios'), + ), + ListTile( + onTap: () { + Navigator.pushNamed(context, '/comunidades'); + }, + 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'), + backgroundColor: const Color.fromARGB(131, 33, 31, 31), + actions: [ + _shoppingCartBadge(), + ], + ), + 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; + }); + }, + ), + ); + } + + Widget _shoppingCartBadge() { + return ValueListenableBuilder( + valueListenable: Globalvalues.carritoContador, + builder: (BuildContext context, int value, Widget? child) { + return badges.Badge( + position: badges.BadgePosition.topEnd(top: 0, end: 3), + badgeAnimation: badges.BadgeAnimation.slide(), + showBadge: _showCartBadge, + badgeStyle: badges.BadgeStyle( + badgeColor: const Color.fromARGB(255, 172, 6, 6), + ), + badgeContent: Text( + value.toString(), + style: TextStyle(color: Colors.white), + ), + child: IconButton( + icon: Icon(Icons.shopping_cart), + onPressed: () { + Navigator.pushNamed(context, '/carrito'); + }, + ), + ); + }, + ); + } +} diff --git a/lib/screens/menuApp/widgetMenuApp/PedidosListaWidget.dart b/lib/screens/menuApp/widgetMenuApp/PedidosListaWidget.dart new file mode 100644 index 0000000..9908621 --- /dev/null +++ b/lib/screens/menuApp/widgetMenuApp/PedidosListaWidget.dart @@ -0,0 +1,140 @@ +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( + '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/carrito_badget.dart b/lib/screens/menuApp/widgetMenuApp/carrito_badget.dart new file mode 100644 index 0000000..e69de29 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/lib/screens/municipios_screen.dart b/lib/screens/municipios_screen.dart new file mode 100644 index 0000000..ef09b8a --- /dev/null +++ b/lib/screens/municipios_screen.dart @@ -0,0 +1,291 @@ +import 'package:flutter/material.dart'; +import 'package:store_sqlite/controller/municipio_controller.dart'; +import 'package:store_sqlite/models/municipio_model.dart'; + +class MunicipiosScreen extends StatefulWidget { + const MunicipiosScreen({super.key}); + + @override + State createState() => _MunicipiosScreenState(); +} + +class _MunicipiosScreenState extends State { + TextEditingController conMunicipio = TextEditingController(); + MunicipioController municipioController = MunicipioController(); + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: const Text('Lista De Municipios'), + ), + floatingActionButton: FloatingActionButton( + onPressed: () { + modal(context, null, null); + }, + child: const Icon(Icons.add_circle), + ), + body: Container( + width: MediaQuery.of(context).size.width, + height: MediaQuery.of(context).size.height, + child: FutureBuilder( + future: municipioController.mostrarTodosLosMunicipios(), + 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: () {}, + child: Container( + width: MediaQuery.of(context).size.width, + padding: const EdgeInsets.all(20), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(10), + color: const Color.fromARGB(136, 60, 81, 73), + border: const Border( + left: BorderSide( + color: Color.fromARGB(255, 100, 80, 73), + width: 4, + ), + ), + ), + child: Column( + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + // Texto del pedido y fecha de entrega + Expanded( + child: Text( + 'id: ${snapshot.data![index].id_municipio}\n Municipio: ${snapshot.data![index].municipio}', + textAlign: TextAlign.left, + style: const TextStyle( + fontSize: 16, + ), + ), + ), + // Botón de editar + IconButton( + icon: const Icon(Icons.edit, + color: Colors.blue), + onPressed: () { + modal( + context, + snapshot.data![index].municipio, + snapshot.data![index].id_municipio); + ScaffoldMessenger.of(context) + .hideCurrentSnackBar(); + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + content: Text( + 'Es el boton editar y tenemos el id=${snapshot.data![index].id_municipio}'), + backgroundColor: Colors.red, + ), + ); + }, + ), + // Botón de borrar + // IconButton( + // icon: const Icon(Icons.delete, + // color: Colors.red), + // onPressed: () { + // // Acción para eliminar el elemento + // // Aquí podrías mostrar una confirmación de eliminación antes de proceder. + // }, + // ), + ], + ), + ], + ), + ), + ), + ); + }, + + //${snapshot.data![index].fecha_entrega}', + //); + ); + } else { + if (snapshot.hasError) { + return Center( + child: Text(snapshot.error.toString()), + ); + } else { + return const Center( + child: CircularProgressIndicator(), + ); + } + } + }, + ), + ), + ); + } + + Future modal( + BuildContext context, String? municipio, int? id_municipio) { + if (municipio != null) { + conMunicipio.text = municipio; + } else { + conMunicipio.clear(); // Limpia el controlador si es una nueva categoría. + } + + return 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: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + Padding( + padding: const EdgeInsets.all(8.0), + child: Text( + + ///valida si la categoria viene vacia + id_municipio == null + ? 'Nuevo Municipio' + : 'EDITAR Municipio'), + ), + const SizedBox(height: 10), + Padding( + padding: const EdgeInsets.all(20.0), + child: TextFormField( + controller: conMunicipio, + decoration: const InputDecoration( + label: Text('Ingresa una categoría'), + prefixIcon: Icon(Icons.category_outlined), + ), + ), + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + ElevatedButton( + onPressed: () => Navigator.pop(context), + child: const Row( + children: [ + Icon(Icons.cancel, + color: Color.fromARGB(255, 107, 4, 4)), + Text( + 'Cancelar', + style: TextStyle( + color: Color.fromARGB(255, 158, 6, 6), + fontSize: 12), + ), + ], + ), + ), + ElevatedButton( + onPressed: () { + ///valida si la categoria no esta vacia + if (conMunicipio.text.trim().isNotEmpty) { + if (id_municipio == null) { + // Si id_categoria es nulo, significa que es una nueva categoría. + _agregarMunicipio(); + } else { + // Si id_categoria tiene un valor, significa que estamos editando. + _editarMucipio(id_municipio); + } + } else { + ScaffoldMessenger.of(context).hideCurrentSnackBar(); + ScaffoldMessenger.of(context).showSnackBar( + const SnackBar( + content: Text('El campo no puede estar vacío'), + backgroundColor: Colors.orange, + ), + ); + } + }, + child: Row( + children: [ + Icon( + Icons.done_outline_outlined, + color: Colors.greenAccent, + ), + Text( + id_municipio == null ? 'Agregar' : 'Guardar Cambios', + style: const TextStyle( + color: Colors.greenAccent, + fontSize: 16, + ), + ), + ], + ), + ), + ], + ), + ], + ), + ), + ), + ); + } + + void _agregarMunicipio() { + try { + municipioController.insertarMunicipio( + 'municipio', + {'municipio': conMunicipio.text.trim()}, + ); + conMunicipio.clear(); + ScaffoldMessenger.of(context).hideCurrentSnackBar(); + ScaffoldMessenger.of(context).showSnackBar( + const SnackBar( + content: Text('Categoría agregada correctamente'), + backgroundColor: Colors.green, + ), + ); + Navigator.pop(context); + setState(() {}); // Actualizar la lista de categorías. + } catch (e) { + ScaffoldMessenger.of(context).hideCurrentSnackBar(); + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + content: Text('Hubo un error al agregar la categoría: $e'), + backgroundColor: Colors.red, + ), + ); + } + } + + void _editarMucipio( + int id_municipio, + ) { + try { + // categoriaController.insertCategoria( + // 'categoria', + // {'categoria': conCategoria.text.trim()}, + // id_categoria, + // ); + municipioController.actualizarMunicipio('municipio', { + 'id_municipio': id_municipio, + 'municipio': conMunicipio.text.trim() + }); + conMunicipio.clear(); + ScaffoldMessenger.of(context).hideCurrentSnackBar(); + ScaffoldMessenger.of(context).showSnackBar( + const SnackBar( + content: Text('Categoría actualizada correctamente'), + backgroundColor: Colors.green, + ), + ); + Navigator.pop(context); + setState(() {}); // Actualizar la lista de categorías. + } catch (e) { + ScaffoldMessenger.of(context).hideCurrentSnackBar(); + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + content: Text('Hubo un error al actualizar la categoría: $e'), + backgroundColor: Colors.red, + ), + ); + } + } +} diff --git a/lib/screens/productos_screen.dart b/lib/screens/productos_screen.dart new file mode 100644 index 0000000..7d21f7b --- /dev/null +++ b/lib/screens/productos_screen.dart @@ -0,0 +1,91 @@ +import 'package:flutter/material.dart'; +import 'package:store_sqlite/config/globalValues.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 ProductosScreen extends StatefulWidget { + const ProductosScreen({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)) + ], + ), + floatingActionButton: FloatingActionButton( + child: Icon(Icons.add), + onPressed: () { + showModalBottomSheet( + context: context, + isScrollControlled: + true, // Permite que el modal ocupe toda la pantalla + // barrierColor: Colors.greenAccent, + backgroundColor: const Color.fromARGB(255, 46, 45, 41), + elevation: 10, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(10.0), + ), + builder: (BuildContext context) { + return editarProducto( + widget: null, + ); + }, + ); + }), + body: ValueListenableBuilder( + valueListenable: Globalvalues.refrescarWidget, + builder: (BuildContext context, bool value, Widget? child) { + return 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 Container( + width: MediaQuery.of(context).size.width, + height: MediaQuery.of(context).size.height * .9, + child: GridView.builder( + gridDelegate: + const SliverGridDelegateWithFixedCrossAxisCount( + crossAxisCount: 2, + childAspectRatio: 0.7, + crossAxisSpacing: + 10, // usualmente se utilizan valores mayores que 0 + mainAxisSpacing: + 10, // usualmente se utilizan valores mayores que 0 + ), + itemCount: snapshot.data?.length ?? 0, // chequeo nulo + itemBuilder: (BuildContext context, int index) { + return Cardwidget(snapshot.data![index]); + }, + ), + ); + }); + }), + ); + } +} diff --git a/linux/flutter/generated_plugin_registrant.cc b/linux/flutter/generated_plugin_registrant.cc index e71a16d..64a0ece 100644 --- a/linux/flutter/generated_plugin_registrant.cc +++ b/linux/flutter/generated_plugin_registrant.cc @@ -6,6 +6,10 @@ #include "generated_plugin_registrant.h" +#include void fl_register_plugins(FlPluginRegistry* registry) { + g_autoptr(FlPluginRegistrar) file_selector_linux_registrar = + fl_plugin_registry_get_registrar_for_plugin(registry, "FileSelectorPlugin"); + file_selector_plugin_register_with_registrar(file_selector_linux_registrar); } diff --git a/linux/flutter/generated_plugins.cmake b/linux/flutter/generated_plugins.cmake index 2e1de87..2db3c22 100644 --- a/linux/flutter/generated_plugins.cmake +++ b/linux/flutter/generated_plugins.cmake @@ -3,6 +3,7 @@ # list(APPEND FLUTTER_PLUGIN_LIST + file_selector_linux ) list(APPEND FLUTTER_FFI_PLUGIN_LIST diff --git a/macos/Flutter/GeneratedPluginRegistrant.swift b/macos/Flutter/GeneratedPluginRegistrant.swift index cccf817..d8177e2 100644 --- a/macos/Flutter/GeneratedPluginRegistrant.swift +++ b/macos/Flutter/GeneratedPluginRegistrant.swift @@ -5,6 +5,16 @@ import FlutterMacOS import Foundation +import file_selector_macos +import firebase_auth +import firebase_core +import path_provider_foundation +import sqflite_darwin func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { + FileSelectorPlugin.register(with: registry.registrar(forPlugin: "FileSelectorPlugin")) + 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..b0853c9 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -1,6 +1,54 @@ # 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" + archive: + dependency: transitive + description: + name: archive + sha256: cb6a278ef2dbb298455e1a713bda08524a175630ec643a242c399c932a0a1f7d + url: "https://pub.dev" + source: hosted + version: "3.6.1" + args: + dependency: transitive + description: + name: args + sha256: bf9f5caeea8d8fe6721a9c358dd8a5c1947b27f1cfaa18b39c301273594919e6 + url: "https://pub.dev" + source: hosted + version: "2.6.0" + art_sweetalert: + dependency: "direct main" + description: + name: art_sweetalert + sha256: "64dd68fc8648197e2b8201b3d28e2e9ec41c0883a05e18be21386ec6435d2b54" + url: "https://pub.dev" + source: hosted + version: "0.0.5" async: dependency: transitive description: @@ -9,6 +57,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.11.0" + badges: + dependency: "direct main" + description: + name: badges + sha256: a7b6bbd60dce418df0db3058b53f9d083c22cdb5132a052145dc267494df0b84 + url: "https://pub.dev" + source: hosted + version: "3.1.2" boolean_selector: dependency: transitive description: @@ -25,6 +81,22 @@ packages: url: "https://pub.dev" source: hosted version: "1.3.0" + checked_yaml: + dependency: transitive + description: + name: checked_yaml + sha256: feb6bed21949061731a7a75fc5d2aa727cf160b91af9a3e464c5e3a32e28b5ff + url: "https://pub.dev" + source: hosted + version: "2.0.3" + cli_util: + dependency: transitive + description: + name: cli_util + sha256: ff6785f7e9e3c38ac98b2fb035701789de90154024a75b6cb926445e83197d1c + url: "https://pub.dev" + source: hosted + version: "0.4.2" clock: dependency: transitive description: @@ -41,6 +113,30 @@ 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" + cross_file: + dependency: transitive + description: + name: cross_file + sha256: "7caf6a750a0c04effbb52a676dce9a4a592e10ad35c34d6d2d0e4811160d5670" + url: "https://pub.dev" + source: hosted + version: "0.3.4+2" + 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 +145,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,24 +169,277 @@ 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" + file_selector_linux: + dependency: transitive + description: + name: file_selector_linux + sha256: "712ce7fab537ba532c8febdb1a8f167b32441e74acd68c3ccb2e36dcb52c4ab2" + url: "https://pub.dev" + source: hosted + version: "0.9.3" + file_selector_macos: + dependency: transitive + description: + name: file_selector_macos + sha256: "271ab9986df0c135d45c3cdb6bd0faa5db6f4976d3e4b437cf7d0f258d941bfc" + url: "https://pub.dev" + source: hosted + version: "0.9.4+2" + file_selector_platform_interface: + dependency: transitive + description: + name: file_selector_platform_interface + sha256: a3994c26f10378a039faa11de174d7b78eb8f79e4dd0af2a451410c1a5c3f66b + url: "https://pub.dev" + source: hosted + version: "2.6.2" + file_selector_windows: + dependency: transitive + description: + name: file_selector_windows + sha256: "8f5d2f6590d51ecd9179ba39c64f722edc15226cc93dcc8698466ad36a4a85a4" + url: "https://pub.dev" + source: hosted + version: "0.9.3+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_launcher_icons: + dependency: "direct main" + description: + name: flutter_launcher_icons + sha256: "526faf84284b86a4cb36d20a5e45147747b7563d921373d4ee0559c54fcdbcea" + url: "https://pub.dev" + source: hosted + version: "0.13.1" flutter_lints: dependency: "direct dev" description: name: flutter_lints - sha256: "3f41d009ba7172d5ff9be5f6e6e6abb4300e263aab8866d2a0842ed2a70f8f0c" + sha256: "5398f14efa795ffb7a33e9b6a08798b26a180edac4ad7db3f231e40f82ce11e1" + url: "https://pub.dev" + source: hosted + version: "5.0.0" + flutter_plugin_android_lifecycle: + dependency: transitive + description: + name: flutter_plugin_android_lifecycle + sha256: "9b78450b89f059e96c9ebb355fa6b3df1d6b330436e0b885fb49594c41721398" + url: "https://pub.dev" + source: hosted + version: "2.0.23" + flutter_product_card: + dependency: "direct main" + description: + name: flutter_product_card + sha256: "7dbad88b0138de2e3d4a671c81c049a34d1f9d56bd582190ab81c6ec9f23fe17" url: "https://pub.dev" source: hosted - version: "4.0.0" + 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: + dependency: transitive + description: + name: http + sha256: b9c29a161230ee03d3ccf545097fccd9b87a5264228c5d348202e0f0c28f9010 + url: "https://pub.dev" + source: hosted + version: "1.2.2" + 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" + image: + dependency: transitive + description: + name: image + sha256: f31d52537dc417fdcde36088fdf11d191026fd5e4fae742491ebd40e5a8bea7d + url: "https://pub.dev" + source: hosted + version: "4.3.0" + image_picker: + dependency: "direct main" + description: + name: image_picker + sha256: "021834d9c0c3de46bf0fe40341fa07168407f694d9b2bb18d532dc1261867f7a" + url: "https://pub.dev" + source: hosted + version: "1.1.2" + image_picker_android: + dependency: transitive + description: + name: image_picker_android + sha256: "8faba09ba361d4b246dc0a17cb4289b3324c2b9f6db7b3d457ee69106a86bd32" + url: "https://pub.dev" + source: hosted + version: "0.8.12+17" + image_picker_for_web: + dependency: transitive + description: + name: image_picker_for_web + sha256: "717eb042ab08c40767684327be06a5d8dbb341fe791d514e4b92c7bbe1b7bb83" + url: "https://pub.dev" + source: hosted + version: "3.0.6" + image_picker_ios: + dependency: transitive + description: + name: image_picker_ios + sha256: "4f0568120c6fcc0aaa04511cb9f9f4d29fc3d0139884b1d06be88dcec7641d6b" + url: "https://pub.dev" + source: hosted + version: "0.8.12+1" + image_picker_linux: + dependency: transitive + description: + name: image_picker_linux + sha256: "4ed1d9bb36f7cd60aa6e6cd479779cc56a4cb4e4de8f49d487b1aaad831300fa" + url: "https://pub.dev" + source: hosted + version: "0.2.1+1" + image_picker_macos: + dependency: transitive + description: + name: image_picker_macos + sha256: "3f5ad1e8112a9a6111c46d0b57a7be2286a9a07fc6e1976fdf5be2bd31d4ff62" + url: "https://pub.dev" + source: hosted + version: "0.2.1+1" + image_picker_platform_interface: + dependency: transitive + description: + name: image_picker_platform_interface + sha256: "9ec26d410ff46f483c5519c29c02ef0e02e13a543f882b152d4bfd2f06802f80" + url: "https://pub.dev" + source: hosted + version: "2.10.0" + image_picker_windows: + dependency: transitive + description: + name: image_picker_windows + sha256: "6ad07afc4eb1bc25f3a01084d28520496c4a3bb0cb13685435838167c9dcedeb" + url: "https://pub.dev" + source: hosted + version: "0.2.1+1" + images_picker: + dependency: "direct main" + description: + name: images_picker + sha256: cc99347a6fa93228bf92f15ce36e4474256e4af0e6c0e1f0e7e9f047adbccd5b + url: "https://pub.dev" + source: hosted + version: "1.2.11" + intl: + dependency: transitive + description: + name: intl + sha256: d6f56758b7d3014a48af9701c085700aac781a92a87a62b1333b46d8879661cf + url: "https://pub.dev" + source: hosted + version: "0.19.0" + json_annotation: + dependency: transitive + description: + name: json_annotation + sha256: "1ce844379ca14835a50d2f019a3099f419082cfdd231cd86a142af94dd5c6bb1" + url: "https://pub.dev" + source: hosted + version: "4.9.0" leak_tracker: dependency: transitive description: @@ -103,10 +468,10 @@ packages: dependency: transitive description: name: lints - sha256: "976c774dd944a42e83e2467f4cc670daef7eed6295b10b36ae8c85bcbf828235" + sha256: "3315600f3fb3b135be672bf4a178c55f274bebe368325ae18462c89ac1e3b413" url: "https://pub.dev" source: hosted - version: "4.0.0" + version: "5.0.0" matcher: dependency: transitive description: @@ -131,6 +496,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.15.0" + mime: + dependency: transitive + description: + name: mime + sha256: "41a20518f0cb1256669420fdba0cd90d21561e560ac240f26ef8322e45bb7ed6" + url: "https://pub.dev" + source: hosted + version: "2.0.0" path: dependency: transitive description: @@ -139,6 +512,142 @@ packages: url: "https://pub.dev" source: hosted version: "1.9.0" + path_provider: + dependency: "direct main" + description: + name: path_provider + sha256: "50c5dd5b6e1aaf6fb3a78b33f6aa3afca52bf903a8a5298f53101fdaee55bbcd" + url: "https://pub.dev" + source: hosted + version: "2.1.5" + 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" + permission_handler: + dependency: "direct main" + description: + name: permission_handler + sha256: "18bf33f7fefbd812f37e72091a15575e72d5318854877e0e4035a24ac1113ecb" + url: "https://pub.dev" + source: hosted + version: "11.3.1" + permission_handler_android: + dependency: transitive + description: + name: permission_handler_android + sha256: "71bbecfee799e65aff7c744761a57e817e73b738fedf62ab7afd5593da21f9f1" + url: "https://pub.dev" + source: hosted + version: "12.0.13" + permission_handler_apple: + dependency: transitive + description: + name: permission_handler_apple + sha256: e6f6d73b12438ef13e648c4ae56bd106ec60d17e90a59c4545db6781229082a0 + url: "https://pub.dev" + source: hosted + version: "9.4.5" + permission_handler_html: + dependency: transitive + description: + name: permission_handler_html + sha256: af26edbbb1f2674af65a8f4b56e1a6f526156bc273d0e65dd8075fab51c78851 + url: "https://pub.dev" + source: hosted + version: "0.1.3+2" + permission_handler_platform_interface: + dependency: transitive + description: + name: permission_handler_platform_interface + sha256: e9c8eadee926c4532d0305dff94b85bf961f16759c3af791486613152af4b4f9 + url: "https://pub.dev" + source: hosted + version: "4.2.3" + permission_handler_windows: + dependency: transitive + description: + name: permission_handler_windows + sha256: "1a790728016f79a41216d88672dbc5df30e686e811ad4e698bfc51f76ad91f1e" + url: "https://pub.dev" + source: hosted + version: "0.2.1" + petitparser: + dependency: transitive + description: + name: petitparser + sha256: c15605cd28af66339f8eb6fbe0e541bfe2d1b72d5825efc6598f3e0a31b9ad27 + url: "https://pub.dev" + source: hosted + version: "6.0.2" + platform: + dependency: transitive + description: + name: platform + sha256: "5d6b1b0036a5f331ebc77c850ebc8506cbc1e9416c27e59b439f917a902a4984" + url: "https://pub.dev" + source: hosted + version: "3.1.6" + 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 +661,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 +733,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 +765,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 +801,50 @@ 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: "1.1.0" + xml: + dependency: transitive + description: + name: xml + sha256: b015a8ad1c488f66851d762d3090a21c600e479dc75e68328c52774040cf9226 + url: "https://pub.dev" + source: hosted + version: "6.5.0" + yaml: + dependency: transitive + description: + name: yaml + sha256: "75769501ea3489fca56601ff33454fe45507ea3bfb014161abc3b43ae25989d5" url: "https://pub.dev" source: hosted - version: "14.2.4" + version: "3.1.2" 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..503b7be 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,72 @@ 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 + art_sweetalert: ^0.0.5 + badges: ^3.1.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 + image_picker: ^1.1.2 + images_picker: ^1.2.11 + path_provider: ^2.1.4 + permission_handler: ^11.3.1 + sqflite: ^2.3.3+1 + table_calendar: ^3.1.2 + toastification: ^2.3.0 + wolt_modal_sheet: ^0.9.3 + flutter_launcher_icons: ^0.13.1 dev_dependencies: + flutter_lints: ^5.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 +flutter_icons: + android: true # Habilita el cambio de icono para Android + ios: true # Habilita el cambio de icono para iOS + image_path: "assets/img/logo.png" # Ruta de tu icono # 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/ + - assets/products/ + # - 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..5b3a80b 100644 --- a/windows/flutter/generated_plugin_registrant.cc +++ b/windows/flutter/generated_plugin_registrant.cc @@ -6,6 +6,18 @@ #include "generated_plugin_registrant.h" +#include +#include +#include +#include void RegisterPlugins(flutter::PluginRegistry* registry) { + FileSelectorWindowsRegisterWithRegistrar( + registry->GetRegistrarForPlugin("FileSelectorWindows")); + FirebaseAuthPluginCApiRegisterWithRegistrar( + registry->GetRegistrarForPlugin("FirebaseAuthPluginCApi")); + FirebaseCorePluginCApiRegisterWithRegistrar( + registry->GetRegistrarForPlugin("FirebaseCorePluginCApi")); + PermissionHandlerWindowsPluginRegisterWithRegistrar( + registry->GetRegistrarForPlugin("PermissionHandlerWindowsPlugin")); } diff --git a/windows/flutter/generated_plugins.cmake b/windows/flutter/generated_plugins.cmake index b93c4c3..570ff1d 100644 --- a/windows/flutter/generated_plugins.cmake +++ b/windows/flutter/generated_plugins.cmake @@ -3,6 +3,10 @@ # list(APPEND FLUTTER_PLUGIN_LIST + file_selector_windows + firebase_auth + firebase_core + permission_handler_windows ) list(APPEND FLUTTER_FFI_PLUGIN_LIST