|
@@ -9,6 +9,7 @@ import '../../themes/themes.dart';
|
|
import '../../models/models.dart';
|
|
import '../../models/models.dart';
|
|
import '../../viewmodels/viewmodels.dart';
|
|
import '../../viewmodels/viewmodels.dart';
|
|
import 'package:collection/collection.dart';
|
|
import 'package:collection/collection.dart';
|
|
|
|
+import 'package:flutter/services.dart';
|
|
|
|
|
|
import '../../widgets/widgets.dart';
|
|
import '../../widgets/widgets.dart';
|
|
|
|
|
|
@@ -166,6 +167,9 @@ class _PedidoFormState extends State<PedidoForm> {
|
|
String errorMessage = '';
|
|
String errorMessage = '';
|
|
double faltante = totalPedido;
|
|
double faltante = totalPedido;
|
|
bool totalCompletado = false;
|
|
bool totalCompletado = false;
|
|
|
|
+ bool efectivoCompleto = false;
|
|
|
|
+ bool tarjetaCompleto = false;
|
|
|
|
+ bool transferenciaCompleto = false;
|
|
|
|
|
|
void _calcularCambio(StateSetter setState) {
|
|
void _calcularCambio(StateSetter setState) {
|
|
double totalPagado = (double.tryParse(efectivoController.text) ?? 0) +
|
|
double totalPagado = (double.tryParse(efectivoController.text) ?? 0) +
|
|
@@ -182,6 +186,13 @@ class _PedidoFormState extends State<PedidoForm> {
|
|
faltante = 0;
|
|
faltante = 0;
|
|
totalCompletado = true;
|
|
totalCompletado = true;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ // Si el total ha sido alcanzado o excedido, desactivar otros métodos de pago
|
|
|
|
+ if (totalPagado >= totalPedido) {
|
|
|
|
+ if (!efectivoSeleccionado) efectivoSeleccionado = false;
|
|
|
|
+ if (!tarjetaSeleccionada) tarjetaSeleccionada = false;
|
|
|
|
+ if (!transferenciaSeleccionada) transferenciaSeleccionada = false;
|
|
|
|
+ }
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
@@ -196,303 +207,516 @@ class _PedidoFormState extends State<PedidoForm> {
|
|
_calcularCambio(setState);
|
|
_calcularCambio(setState);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ bool _isPaymentOptionEnabled(bool isSelected) {
|
|
|
|
+ return !totalCompletado || isSelected;
|
|
|
|
+ }
|
|
|
|
+
|
|
bool? shouldSave = await showDialog<bool>(
|
|
bool? shouldSave = await showDialog<bool>(
|
|
context: context,
|
|
context: context,
|
|
builder: (BuildContext context) {
|
|
builder: (BuildContext context) {
|
|
return StatefulBuilder(
|
|
return StatefulBuilder(
|
|
builder: (context, setState) {
|
|
builder: (context, setState) {
|
|
- return AlertDialog(
|
|
|
|
- actionsPadding: EdgeInsets.fromLTRB(50, 10, 50, 30),
|
|
|
|
- title: const Text(
|
|
|
|
- 'Finalizar Pedido',
|
|
|
|
- style: TextStyle(fontSize: 22, fontWeight: FontWeight.w500),
|
|
|
|
- ),
|
|
|
|
- content: Container(
|
|
|
|
- height: 600,
|
|
|
|
- child: Column(
|
|
|
|
- children: [
|
|
|
|
- Expanded(
|
|
|
|
- child: SingleChildScrollView(
|
|
|
|
- child: Column(
|
|
|
|
- children: [
|
|
|
|
- AppTextField(
|
|
|
|
- controller: nombreController,
|
|
|
|
- etiqueta: 'Nombre',
|
|
|
|
- hintText: "Nombre del Cliente",
|
|
|
|
- ),
|
|
|
|
- const SizedBox(height: 10),
|
|
|
|
- AppTextField(
|
|
|
|
- controller: comentarioController,
|
|
|
|
- etiqueta: 'Comentarios (opcional)',
|
|
|
|
- hintText: 'Comentarios',
|
|
|
|
- maxLines: 2,
|
|
|
|
- ),
|
|
|
|
- const SizedBox(height: 10),
|
|
|
|
- Align(
|
|
|
|
- alignment: Alignment.center,
|
|
|
|
- child: Text(
|
|
|
|
- 'Métodos de pago',
|
|
|
|
- style: TextStyle(
|
|
|
|
- fontWeight: FontWeight.bold, fontSize: 20),
|
|
|
|
- ),
|
|
|
|
- ),
|
|
|
|
- const SizedBox(height: 10),
|
|
|
|
- // Efectivo
|
|
|
|
- GestureDetector(
|
|
|
|
- onTap: () {
|
|
|
|
- setState(() {
|
|
|
|
- efectivoSeleccionado = !efectivoSeleccionado;
|
|
|
|
- if (!efectivoSeleccionado) {
|
|
|
|
- efectivoController.clear();
|
|
|
|
- _calcularCambio(setState);
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
- },
|
|
|
|
- child: Row(
|
|
|
|
- mainAxisAlignment:
|
|
|
|
- MainAxisAlignment.spaceBetween,
|
|
|
|
- children: [
|
|
|
|
- Row(
|
|
|
|
|
|
+ return RawKeyboardListener(
|
|
|
|
+ focusNode: FocusNode(),
|
|
|
|
+ onKey: (RawKeyEvent event) {
|
|
|
|
+ if (event.isKeyPressed(LogicalKeyboardKey.enter) &&
|
|
|
|
+ totalCompletado) {
|
|
|
|
+ Navigator.of(context).pop(true);
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ child: AlertDialog(
|
|
|
|
+ actionsPadding: EdgeInsets.fromLTRB(50, 10, 50, 30),
|
|
|
|
+ title: const Text(
|
|
|
|
+ 'Finalizar Pedido',
|
|
|
|
+ style: TextStyle(fontSize: 22, fontWeight: FontWeight.w500),
|
|
|
|
+ ),
|
|
|
|
+ content: Container(
|
|
|
|
+ height: 600,
|
|
|
|
+ child: Column(
|
|
|
|
+ children: [
|
|
|
|
+ Expanded(
|
|
|
|
+ child: SingleChildScrollView(
|
|
|
|
+ child: Column(
|
|
|
|
+ children: [
|
|
|
|
+ AppTextField(
|
|
|
|
+ controller: nombreController,
|
|
|
|
+ etiqueta: 'Nombre',
|
|
|
|
+ hintText: "Nombre del Cliente",
|
|
|
|
+ ),
|
|
|
|
+ const SizedBox(height: 10),
|
|
|
|
+ AppTextField(
|
|
|
|
+ controller: comentarioController,
|
|
|
|
+ etiqueta: 'Comentarios (opcional)',
|
|
|
|
+ hintText: 'Comentarios',
|
|
|
|
+ maxLines: 2,
|
|
|
|
+ ),
|
|
|
|
+ const SizedBox(height: 10),
|
|
|
|
+ Align(
|
|
|
|
+ alignment: Alignment.center,
|
|
|
|
+ child: Text(
|
|
|
|
+ 'Métodos de pago',
|
|
|
|
+ style: TextStyle(
|
|
|
|
+ fontWeight: FontWeight.bold,
|
|
|
|
+ fontSize: 20),
|
|
|
|
+ ),
|
|
|
|
+ ),
|
|
|
|
+ const SizedBox(height: 10),
|
|
|
|
+ // Efectivo
|
|
|
|
+ GestureDetector(
|
|
|
|
+ onTap: () {
|
|
|
|
+ if (_isPaymentOptionEnabled(
|
|
|
|
+ efectivoSeleccionado)) {
|
|
|
|
+ setState(() {
|
|
|
|
+ efectivoSeleccionado =
|
|
|
|
+ !efectivoSeleccionado;
|
|
|
|
+ if (!efectivoSeleccionado) {
|
|
|
|
+ efectivoCompleto = false;
|
|
|
|
+ efectivoController.clear();
|
|
|
|
+ _calcularCambio(setState);
|
|
|
|
+ } else if (efectivoCompleto) {
|
|
|
|
+ efectivoController.text =
|
|
|
|
+ totalPedido.toStringAsFixed(2);
|
|
|
|
+ _calcularCambio(setState);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ child: Row(
|
|
|
|
+ mainAxisAlignment:
|
|
|
|
+ MainAxisAlignment.spaceBetween,
|
|
|
|
+ crossAxisAlignment:
|
|
|
|
+ CrossAxisAlignment.center,
|
|
children: [
|
|
children: [
|
|
- Checkbox(
|
|
|
|
- activeColor: AppTheme.primary,
|
|
|
|
- value: efectivoSeleccionado,
|
|
|
|
- onChanged: (totalCompletado &&
|
|
|
|
- !efectivoSeleccionado)
|
|
|
|
- ? null
|
|
|
|
- : (bool? value) {
|
|
|
|
- setState(() {
|
|
|
|
- efectivoSeleccionado =
|
|
|
|
- value ?? false;
|
|
|
|
- if (!efectivoSeleccionado) {
|
|
|
|
- efectivoController.clear();
|
|
|
|
- _calcularCambio(setState);
|
|
|
|
|
|
+ Row(
|
|
|
|
+ children: [
|
|
|
|
+ Checkbox(
|
|
|
|
+ activeColor: AppTheme.primary,
|
|
|
|
+ value: efectivoSeleccionado,
|
|
|
|
+ onChanged: _isPaymentOptionEnabled(
|
|
|
|
+ efectivoSeleccionado)
|
|
|
|
+ ? (bool? value) {
|
|
|
|
+ setState(() {
|
|
|
|
+ efectivoSeleccionado =
|
|
|
|
+ value ?? false;
|
|
|
|
+ if (!efectivoSeleccionado) {
|
|
|
|
+ efectivoCompleto =
|
|
|
|
+ false;
|
|
|
|
+ efectivoController
|
|
|
|
+ .clear();
|
|
|
|
+ _calcularCambio(
|
|
|
|
+ setState);
|
|
|
|
+ } else if (efectivoCompleto) {
|
|
|
|
+ efectivoController
|
|
|
|
+ .text =
|
|
|
|
+ totalPedido
|
|
|
|
+ .toStringAsFixed(
|
|
|
|
+ 2);
|
|
|
|
+ _calcularCambio(
|
|
|
|
+ setState);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
}
|
|
}
|
|
- });
|
|
|
|
- },
|
|
|
|
- ),
|
|
|
|
- const Text(
|
|
|
|
- "Efectivo",
|
|
|
|
- style: TextStyle(
|
|
|
|
- fontSize: 18,
|
|
|
|
- fontWeight: FontWeight.bold),
|
|
|
|
|
|
+ : null,
|
|
|
|
+ ),
|
|
|
|
+ const Text(
|
|
|
|
+ "Efectivo",
|
|
|
|
+ style: TextStyle(
|
|
|
|
+ fontSize: 18,
|
|
|
|
+ fontWeight: FontWeight.bold),
|
|
|
|
+ ),
|
|
|
|
+ ],
|
|
),
|
|
),
|
|
|
|
+ if (efectivoSeleccionado)
|
|
|
|
+ SizedBox(
|
|
|
|
+ width: 180,
|
|
|
|
+ child: Row(
|
|
|
|
+ crossAxisAlignment:
|
|
|
|
+ CrossAxisAlignment.start,
|
|
|
|
+ children: [
|
|
|
|
+ Column(
|
|
|
|
+ children: [
|
|
|
|
+ const Text('Exacto',
|
|
|
|
+ style: TextStyle(
|
|
|
|
+ fontSize: 18,
|
|
|
|
+ fontWeight:
|
|
|
|
+ FontWeight.bold,
|
|
|
|
+ color: Colors.black)),
|
|
|
|
+ const SizedBox(
|
|
|
|
+ height: 17,
|
|
|
|
+ ),
|
|
|
|
+ Checkbox(
|
|
|
|
+ activeColor:
|
|
|
|
+ AppTheme.primary,
|
|
|
|
+ value: efectivoCompleto,
|
|
|
|
+ onChanged:
|
|
|
|
+ efectivoSeleccionado
|
|
|
|
+ ? (bool? value) {
|
|
|
|
+ setState(() {
|
|
|
|
+ efectivoCompleto =
|
|
|
|
+ value ??
|
|
|
|
+ false;
|
|
|
|
+ if (efectivoCompleto) {
|
|
|
|
+ efectivoController
|
|
|
|
+ .text =
|
|
|
|
+ totalPedido
|
|
|
|
+ .toStringAsFixed(2);
|
|
|
|
+ _calcularCambio(
|
|
|
|
+ setState);
|
|
|
|
+ } else {
|
|
|
|
+ efectivoController
|
|
|
|
+ .clear();
|
|
|
|
+ _calcularCambio(
|
|
|
|
+ setState);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ : null,
|
|
|
|
+ ),
|
|
|
|
+ ],
|
|
|
|
+ ),
|
|
|
|
+ const SizedBox(
|
|
|
|
+ width: 5,
|
|
|
|
+ ),
|
|
|
|
+ Expanded(
|
|
|
|
+ child: AppTextField(
|
|
|
|
+ controller:
|
|
|
|
+ efectivoController,
|
|
|
|
+ etiqueta: 'Cantidad',
|
|
|
|
+ hintText: '0.00',
|
|
|
|
+ keyboardType:
|
|
|
|
+ TextInputType.number,
|
|
|
|
+ onChanged: (value) =>
|
|
|
|
+ _calcularCambio(setState),
|
|
|
|
+ ),
|
|
|
|
+ ),
|
|
|
|
+ ],
|
|
|
|
+ ),
|
|
|
|
+ ),
|
|
],
|
|
],
|
|
),
|
|
),
|
|
- if (efectivoSeleccionado)
|
|
|
|
- SizedBox(
|
|
|
|
- width: 150,
|
|
|
|
- child: AppTextField(
|
|
|
|
- controller: efectivoController,
|
|
|
|
- etiqueta: 'Cantidad',
|
|
|
|
- hintText: '0.00',
|
|
|
|
- keyboardType: TextInputType.number,
|
|
|
|
- onChanged: (value) =>
|
|
|
|
- _calcularCambio(setState),
|
|
|
|
- ),
|
|
|
|
- ),
|
|
|
|
- ],
|
|
|
|
- ),
|
|
|
|
- ),
|
|
|
|
- const SizedBox(height: 10),
|
|
|
|
- // Tarjeta
|
|
|
|
- GestureDetector(
|
|
|
|
- onTap: () {
|
|
|
|
- setState(() {
|
|
|
|
- tarjetaSeleccionada = !tarjetaSeleccionada;
|
|
|
|
- if (!tarjetaSeleccionada) {
|
|
|
|
- tarjetaController.clear();
|
|
|
|
- _calcularCambio(setState);
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
- },
|
|
|
|
- child: Row(
|
|
|
|
- mainAxisAlignment:
|
|
|
|
- MainAxisAlignment.spaceBetween,
|
|
|
|
- children: [
|
|
|
|
- Row(
|
|
|
|
|
|
+ ),
|
|
|
|
+ const SizedBox(height: 10),
|
|
|
|
+ // Tarjeta
|
|
|
|
+ GestureDetector(
|
|
|
|
+ onTap: () {
|
|
|
|
+ if (_isPaymentOptionEnabled(
|
|
|
|
+ tarjetaSeleccionada)) {
|
|
|
|
+ setState(() {
|
|
|
|
+ tarjetaSeleccionada =
|
|
|
|
+ !tarjetaSeleccionada;
|
|
|
|
+ if (!tarjetaSeleccionada) {
|
|
|
|
+ tarjetaController.clear();
|
|
|
|
+ _calcularCambio(setState);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ child: Row(
|
|
|
|
+ mainAxisAlignment:
|
|
|
|
+ MainAxisAlignment.spaceBetween,
|
|
|
|
+ crossAxisAlignment:
|
|
|
|
+ CrossAxisAlignment.center,
|
|
children: [
|
|
children: [
|
|
- Checkbox(
|
|
|
|
- activeColor: AppTheme.primary,
|
|
|
|
- value: tarjetaSeleccionada,
|
|
|
|
- onChanged: (totalCompletado &&
|
|
|
|
- !tarjetaSeleccionada)
|
|
|
|
- ? null
|
|
|
|
- : (bool? value) {
|
|
|
|
- setState(() {
|
|
|
|
- tarjetaSeleccionada =
|
|
|
|
- value ?? false;
|
|
|
|
- if (!tarjetaSeleccionada) {
|
|
|
|
- tarjetaController.clear();
|
|
|
|
- _calcularCambio(setState);
|
|
|
|
|
|
+ Row(
|
|
|
|
+ children: [
|
|
|
|
+ Checkbox(
|
|
|
|
+ activeColor: AppTheme.primary,
|
|
|
|
+ value: tarjetaSeleccionada,
|
|
|
|
+ onChanged: _isPaymentOptionEnabled(
|
|
|
|
+ tarjetaSeleccionada)
|
|
|
|
+ ? (bool? value) {
|
|
|
|
+ setState(() {
|
|
|
|
+ tarjetaSeleccionada =
|
|
|
|
+ value ?? false;
|
|
|
|
+ if (!tarjetaSeleccionada) {
|
|
|
|
+ tarjetaController
|
|
|
|
+ .clear();
|
|
|
|
+ _calcularCambio(
|
|
|
|
+ setState);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
}
|
|
}
|
|
- });
|
|
|
|
- },
|
|
|
|
- ),
|
|
|
|
- const Text(
|
|
|
|
- "Tarjeta",
|
|
|
|
- style: TextStyle(
|
|
|
|
- fontSize: 18,
|
|
|
|
- fontWeight: FontWeight.bold),
|
|
|
|
|
|
+ : null,
|
|
|
|
+ ),
|
|
|
|
+ const Text(
|
|
|
|
+ "Tarjeta",
|
|
|
|
+ style: TextStyle(
|
|
|
|
+ fontSize: 18,
|
|
|
|
+ fontWeight: FontWeight.bold),
|
|
|
|
+ ),
|
|
|
|
+ ],
|
|
),
|
|
),
|
|
|
|
+ if (tarjetaSeleccionada)
|
|
|
|
+ SizedBox(
|
|
|
|
+ width: 180,
|
|
|
|
+ child: Row(
|
|
|
|
+ crossAxisAlignment:
|
|
|
|
+ CrossAxisAlignment.start,
|
|
|
|
+ children: [
|
|
|
|
+ Column(
|
|
|
|
+ children: [
|
|
|
|
+ const Text('Exacto',
|
|
|
|
+ style: TextStyle(
|
|
|
|
+ fontSize: 18,
|
|
|
|
+ fontWeight:
|
|
|
|
+ FontWeight.bold,
|
|
|
|
+ color: Colors.black)),
|
|
|
|
+ const SizedBox(
|
|
|
|
+ height: 17,
|
|
|
|
+ ),
|
|
|
|
+ Checkbox(
|
|
|
|
+ activeColor:
|
|
|
|
+ AppTheme.primary,
|
|
|
|
+ value: tarjetaCompleto,
|
|
|
|
+ onChanged:
|
|
|
|
+ tarjetaSeleccionada
|
|
|
|
+ ? (bool? value) {
|
|
|
|
+ setState(() {
|
|
|
|
+ tarjetaCompleto =
|
|
|
|
+ value ??
|
|
|
|
+ false;
|
|
|
|
+ if (tarjetaCompleto) {
|
|
|
|
+ tarjetaController
|
|
|
|
+ .text =
|
|
|
|
+ totalPedido
|
|
|
|
+ .toStringAsFixed(2);
|
|
|
|
+ _calcularCambio(
|
|
|
|
+ setState);
|
|
|
|
+ } else {
|
|
|
|
+ tarjetaController
|
|
|
|
+ .clear();
|
|
|
|
+ _calcularCambio(
|
|
|
|
+ setState);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ : null,
|
|
|
|
+ ),
|
|
|
|
+ ],
|
|
|
|
+ ),
|
|
|
|
+ const SizedBox(
|
|
|
|
+ width: 5,
|
|
|
|
+ ),
|
|
|
|
+ Expanded(
|
|
|
|
+ child: AppTextField(
|
|
|
|
+ controller: tarjetaController,
|
|
|
|
+ etiqueta: 'Cantidad',
|
|
|
|
+ hintText: '0.00',
|
|
|
|
+ keyboardType:
|
|
|
|
+ TextInputType.number,
|
|
|
|
+ onChanged: (value) {
|
|
|
|
+ _validarCantidad(setState,
|
|
|
|
+ tarjetaController);
|
|
|
|
+ },
|
|
|
|
+ ),
|
|
|
|
+ ),
|
|
|
|
+ ],
|
|
|
|
+ ),
|
|
|
|
+ ),
|
|
],
|
|
],
|
|
),
|
|
),
|
|
- if (tarjetaSeleccionada)
|
|
|
|
- SizedBox(
|
|
|
|
- width: 150,
|
|
|
|
- child: AppTextField(
|
|
|
|
- controller: tarjetaController,
|
|
|
|
- etiqueta: 'Cantidad',
|
|
|
|
- hintText: '0.00',
|
|
|
|
- keyboardType: TextInputType.number,
|
|
|
|
- onChanged: (value) {
|
|
|
|
- _validarCantidad(
|
|
|
|
- setState, tarjetaController);
|
|
|
|
- },
|
|
|
|
- ),
|
|
|
|
- ),
|
|
|
|
- ],
|
|
|
|
- ),
|
|
|
|
- ),
|
|
|
|
- const SizedBox(height: 10),
|
|
|
|
- // Transferencia
|
|
|
|
- GestureDetector(
|
|
|
|
- onTap: () {
|
|
|
|
- setState(() {
|
|
|
|
- transferenciaSeleccionada =
|
|
|
|
- !transferenciaSeleccionada;
|
|
|
|
- if (!transferenciaSeleccionada) {
|
|
|
|
- transferenciaController.clear();
|
|
|
|
- _calcularCambio(setState);
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
- },
|
|
|
|
- child: Row(
|
|
|
|
- mainAxisAlignment:
|
|
|
|
- MainAxisAlignment.spaceBetween,
|
|
|
|
- children: [
|
|
|
|
- Row(
|
|
|
|
|
|
+ ),
|
|
|
|
+ const SizedBox(height: 10),
|
|
|
|
+ // Transferencia
|
|
|
|
+ GestureDetector(
|
|
|
|
+ onTap: () {
|
|
|
|
+ if (_isPaymentOptionEnabled(
|
|
|
|
+ transferenciaSeleccionada)) {
|
|
|
|
+ setState(() {
|
|
|
|
+ transferenciaSeleccionada =
|
|
|
|
+ !transferenciaSeleccionada;
|
|
|
|
+ if (!transferenciaSeleccionada) {
|
|
|
|
+ transferenciaController.clear();
|
|
|
|
+ _calcularCambio(setState);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ child: Row(
|
|
|
|
+ mainAxisAlignment:
|
|
|
|
+ MainAxisAlignment.spaceBetween,
|
|
|
|
+ crossAxisAlignment:
|
|
|
|
+ CrossAxisAlignment.center,
|
|
children: [
|
|
children: [
|
|
- Checkbox(
|
|
|
|
- activeColor: AppTheme.primary,
|
|
|
|
- value: transferenciaSeleccionada,
|
|
|
|
- onChanged: (totalCompletado &&
|
|
|
|
- !transferenciaSeleccionada)
|
|
|
|
- ? null
|
|
|
|
- : (bool? value) {
|
|
|
|
- setState(() {
|
|
|
|
- transferenciaSeleccionada =
|
|
|
|
- value ?? false;
|
|
|
|
- if (!transferenciaSeleccionada) {
|
|
|
|
- transferenciaController
|
|
|
|
- .clear();
|
|
|
|
- _calcularCambio(setState);
|
|
|
|
|
|
+ Row(
|
|
|
|
+ children: [
|
|
|
|
+ Checkbox(
|
|
|
|
+ activeColor: AppTheme.primary,
|
|
|
|
+ value: transferenciaSeleccionada,
|
|
|
|
+ onChanged: _isPaymentOptionEnabled(
|
|
|
|
+ transferenciaSeleccionada)
|
|
|
|
+ ? (bool? value) {
|
|
|
|
+ setState(() {
|
|
|
|
+ transferenciaSeleccionada =
|
|
|
|
+ value ?? false;
|
|
|
|
+ if (!transferenciaSeleccionada) {
|
|
|
|
+ transferenciaController
|
|
|
|
+ .clear();
|
|
|
|
+ _calcularCambio(
|
|
|
|
+ setState);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
}
|
|
}
|
|
- });
|
|
|
|
- },
|
|
|
|
- ),
|
|
|
|
- const Text(
|
|
|
|
- "Transferencia",
|
|
|
|
- style: TextStyle(
|
|
|
|
- fontSize: 18,
|
|
|
|
- fontWeight: FontWeight.bold),
|
|
|
|
|
|
+ : null,
|
|
|
|
+ ),
|
|
|
|
+ const Text(
|
|
|
|
+ "Transferencia",
|
|
|
|
+ style: TextStyle(
|
|
|
|
+ fontSize: 18,
|
|
|
|
+ fontWeight: FontWeight.bold),
|
|
|
|
+ ),
|
|
|
|
+ ],
|
|
),
|
|
),
|
|
|
|
+ if (transferenciaSeleccionada)
|
|
|
|
+ SizedBox(
|
|
|
|
+ width: 180,
|
|
|
|
+ child: Row(
|
|
|
|
+ crossAxisAlignment:
|
|
|
|
+ CrossAxisAlignment.start,
|
|
|
|
+ children: [
|
|
|
|
+ Column(
|
|
|
|
+ children: [
|
|
|
|
+ const Text('Exacto',
|
|
|
|
+ style: TextStyle(
|
|
|
|
+ fontSize: 18,
|
|
|
|
+ fontWeight:
|
|
|
|
+ FontWeight.bold,
|
|
|
|
+ color: Colors.black)),
|
|
|
|
+ const SizedBox(
|
|
|
|
+ height: 17,
|
|
|
|
+ ),
|
|
|
|
+ Checkbox(
|
|
|
|
+ activeColor:
|
|
|
|
+ AppTheme.primary,
|
|
|
|
+ value:
|
|
|
|
+ transferenciaCompleto,
|
|
|
|
+ onChanged:
|
|
|
|
+ transferenciaSeleccionada
|
|
|
|
+ ? (bool? value) {
|
|
|
|
+ setState(() {
|
|
|
|
+ transferenciaCompleto =
|
|
|
|
+ value ??
|
|
|
|
+ false;
|
|
|
|
+ if (transferenciaCompleto) {
|
|
|
|
+ transferenciaController
|
|
|
|
+ .text =
|
|
|
|
+ totalPedido
|
|
|
|
+ .toStringAsFixed(2);
|
|
|
|
+ _calcularCambio(
|
|
|
|
+ setState);
|
|
|
|
+ } else {
|
|
|
|
+ transferenciaController
|
|
|
|
+ .clear();
|
|
|
|
+ _calcularCambio(
|
|
|
|
+ setState);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ : null,
|
|
|
|
+ ),
|
|
|
|
+ ],
|
|
|
|
+ ),
|
|
|
|
+ const SizedBox(
|
|
|
|
+ width: 5,
|
|
|
|
+ ),
|
|
|
|
+ Expanded(
|
|
|
|
+ child: AppTextField(
|
|
|
|
+ controller:
|
|
|
|
+ transferenciaController,
|
|
|
|
+ etiqueta: 'Cantidad',
|
|
|
|
+ hintText: '0.00',
|
|
|
|
+ keyboardType:
|
|
|
|
+ TextInputType.number,
|
|
|
|
+ onChanged: (value) {
|
|
|
|
+ _validarCantidad(setState,
|
|
|
|
+ transferenciaController);
|
|
|
|
+ },
|
|
|
|
+ ),
|
|
|
|
+ ),
|
|
|
|
+ ],
|
|
|
|
+ ),
|
|
|
|
+ ),
|
|
],
|
|
],
|
|
),
|
|
),
|
|
- if (transferenciaSeleccionada)
|
|
|
|
- SizedBox(
|
|
|
|
- width: 150,
|
|
|
|
- child: AppTextField(
|
|
|
|
- controller: transferenciaController,
|
|
|
|
- etiqueta: 'Cantidad',
|
|
|
|
- hintText: '0.00',
|
|
|
|
- keyboardType: TextInputType.number,
|
|
|
|
- onChanged: (value) {
|
|
|
|
- _validarCantidad(setState,
|
|
|
|
- transferenciaController);
|
|
|
|
- },
|
|
|
|
- ),
|
|
|
|
- ),
|
|
|
|
- ],
|
|
|
|
- ),
|
|
|
|
- ),
|
|
|
|
- const SizedBox(height: 10),
|
|
|
|
- // Mostrar el total del pedido y la cantidad faltante
|
|
|
|
- Align(
|
|
|
|
- alignment: Alignment.centerRight,
|
|
|
|
- child: Column(
|
|
|
|
- crossAxisAlignment: CrossAxisAlignment.end,
|
|
|
|
- children: [
|
|
|
|
- Text(
|
|
|
|
- 'Total del pedido: \$${totalPedido.toStringAsFixed(2)}',
|
|
|
|
- style: const TextStyle(
|
|
|
|
- fontWeight: FontWeight.bold,
|
|
|
|
- fontSize: 18),
|
|
|
|
- ),
|
|
|
|
- if (faltante > 0)
|
|
|
|
- Text(
|
|
|
|
- 'Faltante: \$${faltante.toStringAsFixed(2)}',
|
|
|
|
- style: const TextStyle(
|
|
|
|
- color: Colors.red,
|
|
|
|
- fontSize: 18,
|
|
|
|
- fontWeight: FontWeight.bold),
|
|
|
|
- )
|
|
|
|
- else if (cambio > 0)
|
|
|
|
- Text(
|
|
|
|
- 'Cambio: \$${cambio.toStringAsFixed(2)}',
|
|
|
|
|
|
+ ),
|
|
|
|
+ const SizedBox(height: 10),
|
|
|
|
+ // Mostrar el total del pedido y la cantidad faltante
|
|
|
|
+ Align(
|
|
|
|
+ alignment: Alignment.centerRight,
|
|
|
|
+ child: Column(
|
|
|
|
+ crossAxisAlignment:
|
|
|
|
+ CrossAxisAlignment.end,
|
|
|
|
+ children: [
|
|
|
|
+ Text(
|
|
|
|
+ 'Total del pedido: \$${totalPedido.toStringAsFixed(2)}',
|
|
style: const TextStyle(
|
|
style: const TextStyle(
|
|
- color: Colors.green,
|
|
|
|
- fontSize: 18,
|
|
|
|
- fontWeight: FontWeight.bold)),
|
|
|
|
- ]),
|
|
|
|
|
|
+ fontWeight: FontWeight.bold,
|
|
|
|
+ fontSize: 18),
|
|
|
|
+ ),
|
|
|
|
+ if (faltante > 0)
|
|
|
|
+ Text(
|
|
|
|
+ 'Faltante: \$${faltante.toStringAsFixed(2)}',
|
|
|
|
+ style: const TextStyle(
|
|
|
|
+ color: Colors.red,
|
|
|
|
+ fontSize: 18,
|
|
|
|
+ fontWeight: FontWeight.bold),
|
|
|
|
+ )
|
|
|
|
+ else if (cambio > 0)
|
|
|
|
+ Text(
|
|
|
|
+ 'Cambio: \$${cambio.toStringAsFixed(2)}',
|
|
|
|
+ style: const TextStyle(
|
|
|
|
+ color: Colors.green,
|
|
|
|
+ fontSize: 18,
|
|
|
|
+ fontWeight: FontWeight.bold)),
|
|
|
|
+ ]),
|
|
|
|
+ ),
|
|
|
|
+ ],
|
|
),
|
|
),
|
|
- ],
|
|
|
|
- ),
|
|
|
|
- ),
|
|
|
|
- ),
|
|
|
|
- // Aquí mantenemos los botones fijos
|
|
|
|
- Row(
|
|
|
|
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
- children: [
|
|
|
|
- TextButton(
|
|
|
|
- child: const Text('Cancelar',
|
|
|
|
- style: TextStyle(fontSize: 18)),
|
|
|
|
- onPressed: () {
|
|
|
|
- Navigator.of(context).pop(false);
|
|
|
|
- },
|
|
|
|
- style: ButtonStyle(
|
|
|
|
- padding: MaterialStatePropertyAll(
|
|
|
|
- EdgeInsets.fromLTRB(30, 20, 30, 20)),
|
|
|
|
- backgroundColor:
|
|
|
|
- MaterialStatePropertyAll(Colors.red),
|
|
|
|
- foregroundColor:
|
|
|
|
- MaterialStatePropertyAll(AppTheme.secondary)),
|
|
|
|
|
|
+ ),
|
|
),
|
|
),
|
|
- const SizedBox(width: 100),
|
|
|
|
- TextButton(
|
|
|
|
- child: const Text('Guardar',
|
|
|
|
- style: TextStyle(fontSize: 18)),
|
|
|
|
- onPressed: totalCompletado
|
|
|
|
- ? () {
|
|
|
|
- Navigator.of(context).pop(true);
|
|
|
|
- }
|
|
|
|
- : null,
|
|
|
|
- style: ButtonStyle(
|
|
|
|
- padding: MaterialStatePropertyAll(
|
|
|
|
- EdgeInsets.fromLTRB(30, 20, 30, 20)),
|
|
|
|
- backgroundColor: MaterialStatePropertyAll(
|
|
|
|
- totalCompletado
|
|
|
|
- ? AppTheme.tertiary
|
|
|
|
- : Colors.grey),
|
|
|
|
- foregroundColor: MaterialStatePropertyAll(
|
|
|
|
- AppTheme.quaternary)),
|
|
|
|
|
|
+ // Aquí mantenemos los botones fijos
|
|
|
|
+ Row(
|
|
|
|
+ mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
+ children: [
|
|
|
|
+ TextButton(
|
|
|
|
+ child: const Text('Cancelar',
|
|
|
|
+ style: TextStyle(fontSize: 18)),
|
|
|
|
+ onPressed: () {
|
|
|
|
+ Navigator.of(context).pop(false);
|
|
|
|
+ },
|
|
|
|
+ style: ButtonStyle(
|
|
|
|
+ padding: MaterialStatePropertyAll(
|
|
|
|
+ EdgeInsets.fromLTRB(30, 20, 30, 20)),
|
|
|
|
+ backgroundColor:
|
|
|
|
+ MaterialStatePropertyAll(Colors.red),
|
|
|
|
+ foregroundColor: MaterialStatePropertyAll(
|
|
|
|
+ AppTheme.secondary)),
|
|
|
|
+ ),
|
|
|
|
+ const SizedBox(width: 100),
|
|
|
|
+ TextButton(
|
|
|
|
+ child: const Text('Guardar',
|
|
|
|
+ style: TextStyle(fontSize: 18)),
|
|
|
|
+ onPressed: totalCompletado
|
|
|
|
+ ? () {
|
|
|
|
+ Navigator.of(context).pop(true);
|
|
|
|
+ }
|
|
|
|
+ : null,
|
|
|
|
+ style: ButtonStyle(
|
|
|
|
+ padding: MaterialStatePropertyAll(
|
|
|
|
+ EdgeInsets.fromLTRB(30, 20, 30, 20)),
|
|
|
|
+ backgroundColor: MaterialStatePropertyAll(
|
|
|
|
+ totalCompletado
|
|
|
|
+ ? AppTheme.tertiary
|
|
|
|
+ : Colors.grey),
|
|
|
|
+ foregroundColor: MaterialStatePropertyAll(
|
|
|
|
+ AppTheme.quaternary)),
|
|
|
|
+ ),
|
|
|
|
+ ],
|
|
),
|
|
),
|
|
],
|
|
],
|
|
),
|
|
),
|
|
- ],
|
|
|
|
- ),
|
|
|
|
- ),
|
|
|
|
- );
|
|
|
|
|
|
+ ),
|
|
|
|
+ ));
|
|
},
|
|
},
|
|
);
|
|
);
|
|
},
|
|
},
|