|
@@ -10,6 +10,9 @@ import '../../models/models.dart';
|
|
import '../../viewmodels/viewmodels.dart';
|
|
import '../../viewmodels/viewmodels.dart';
|
|
import '../../widgets/widgets_components.dart' as clase;
|
|
import '../../widgets/widgets_components.dart' as clase;
|
|
import 'pedido_form.dart';
|
|
import 'pedido_form.dart';
|
|
|
|
+import 'package:otp/otp.dart';
|
|
|
|
+import 'package:timezone/data/latest.dart' as timezone;
|
|
|
|
+import 'package:timezone/timezone.dart' as timezone;
|
|
|
|
|
|
class PedidoScreen extends StatefulWidget {
|
|
class PedidoScreen extends StatefulWidget {
|
|
const PedidoScreen({Key? key}) : super(key: key);
|
|
const PedidoScreen({Key? key}) : super(key: key);
|
|
@@ -23,6 +26,7 @@ class _PedidoScreenState extends State<PedidoScreen> {
|
|
DateTime? fechaInicio;
|
|
DateTime? fechaInicio;
|
|
DateTime? fechaFin;
|
|
DateTime? fechaFin;
|
|
ScrollController horizontalScrollController = ScrollController();
|
|
ScrollController horizontalScrollController = ScrollController();
|
|
|
|
+ TextEditingController codeController = new TextEditingController();
|
|
|
|
|
|
@override
|
|
@override
|
|
void initState() {
|
|
void initState() {
|
|
@@ -143,44 +147,84 @@ class _PedidoScreenState extends State<PedidoScreen> {
|
|
'¿Estás seguro de que deseas cancelar este pedido?',
|
|
'¿Estás seguro de que deseas cancelar este pedido?',
|
|
style: TextStyle(fontSize: 18)),
|
|
style: TextStyle(fontSize: 18)),
|
|
actions: [
|
|
actions: [
|
|
- Row(
|
|
|
|
- mainAxisAlignment:
|
|
|
|
- MainAxisAlignment.spaceBetween,
|
|
|
|
|
|
+ Column(
|
|
children: [
|
|
children: [
|
|
- TextButton(
|
|
|
|
- onPressed: () =>
|
|
|
|
- Navigator.of(context).pop(false),
|
|
|
|
- child: const Text('No',
|
|
|
|
- style: TextStyle(fontSize: 18)),
|
|
|
|
- style: ButtonStyle(
|
|
|
|
- padding: MaterialStatePropertyAll(
|
|
|
|
- EdgeInsets.fromLTRB(
|
|
|
|
- 20, 10, 20, 10)),
|
|
|
|
- backgroundColor:
|
|
|
|
- MaterialStatePropertyAll(
|
|
|
|
- Colors.red),
|
|
|
|
- foregroundColor:
|
|
|
|
- MaterialStatePropertyAll(
|
|
|
|
- AppTheme.secondary)),
|
|
|
|
- ),
|
|
|
|
- TextButton(
|
|
|
|
- onPressed: () =>
|
|
|
|
- Navigator.of(context).pop(true),
|
|
|
|
- child: const Text('Sí',
|
|
|
|
- style: TextStyle(fontSize: 18)),
|
|
|
|
- style: ButtonStyle(
|
|
|
|
- padding: MaterialStatePropertyAll(
|
|
|
|
- EdgeInsets.fromLTRB(
|
|
|
|
- 20, 10, 20, 10)),
|
|
|
|
- backgroundColor:
|
|
|
|
- MaterialStatePropertyAll(
|
|
|
|
- AppTheme.tertiary),
|
|
|
|
- foregroundColor:
|
|
|
|
- MaterialStatePropertyAll(
|
|
|
|
- AppTheme.quaternary)),
|
|
|
|
|
|
+ Container(
|
|
|
|
+ padding: EdgeInsets.all(8.0),
|
|
|
|
+ child: TextField(
|
|
|
|
+ controller: codeController,
|
|
|
|
+ decoration: InputDecoration(
|
|
|
|
+ label: Text("Para cancelar debe capturar el código")
|
|
|
|
+ ),
|
|
|
|
+ ),
|
|
),
|
|
),
|
|
|
|
+ Row(
|
|
|
|
+ mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
+ children: [
|
|
|
|
+ TextButton(
|
|
|
|
+ onPressed: () =>
|
|
|
|
+ Navigator.of(context).pop(false),
|
|
|
|
+ child: const Text('No',
|
|
|
|
+ style: TextStyle(fontSize: 18)),
|
|
|
|
+ style: ButtonStyle(
|
|
|
|
+ padding: MaterialStatePropertyAll(
|
|
|
|
+ EdgeInsets.fromLTRB(
|
|
|
|
+ 20, 10, 20, 10)),
|
|
|
|
+ backgroundColor:
|
|
|
|
+ MaterialStatePropertyAll(
|
|
|
|
+ Colors.red),
|
|
|
|
+ foregroundColor:
|
|
|
|
+ MaterialStatePropertyAll(
|
|
|
|
+ AppTheme.secondary)),
|
|
|
|
+ ),
|
|
|
|
+ TextButton(
|
|
|
|
+ onPressed: () {
|
|
|
|
+ final now = DateTime.now().toUtc();
|
|
|
|
+ timezone.initializeTimeZones();
|
|
|
|
+
|
|
|
|
+ final pacificTimeZone = timezone.getLocation('America/Los_Angeles');
|
|
|
|
+ final date = timezone.TZDateTime.from(now, pacificTimeZone);
|
|
|
|
+ final codigoTotp = OTP.generateTOTPCodeString('TYSNE4CMT5LVLGWS', date.millisecondsSinceEpoch, algorithm: Algorithm.SHA1, isGoogle: true);
|
|
|
|
+
|
|
|
|
+ String codigo = codeController.text;
|
|
|
|
+ print("totp: $codigoTotp codigo:$codigo");
|
|
|
|
+ List<String> codigosEstaticos = [
|
|
|
|
+ '172449',
|
|
|
|
+ '827329',
|
|
|
|
+ // Agregar más token fijos
|
|
|
|
+ ];
|
|
|
|
+ bool esCodigoEstatico = codigosEstaticos.contains(codigo);
|
|
|
|
+ print("¿Es código estático? ${esCodigoEstatico} ${!esCodigoEstatico && codigo != codigoTotp}");
|
|
|
|
+ if(!esCodigoEstatico && codigo != codigoTotp) {
|
|
|
|
+ ScaffoldMessenger.of(context).showSnackBar(
|
|
|
|
+ SnackBar(
|
|
|
|
+ content: Text('El código no es correcto'),
|
|
|
|
+ duration: Duration(seconds: 2),
|
|
|
|
+ )
|
|
|
|
+ );
|
|
|
|
+ return;
|
|
|
|
+ } else {
|
|
|
|
+ codeController.text = '';
|
|
|
|
+ Navigator.of(context).pop(true);
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ child: const Text('Sí',
|
|
|
|
+ style: TextStyle(fontSize: 18)),
|
|
|
|
+ style: ButtonStyle(
|
|
|
|
+ padding: MaterialStatePropertyAll(
|
|
|
|
+ EdgeInsets.fromLTRB(
|
|
|
|
+ 20, 10, 20, 10)),
|
|
|
|
+ backgroundColor:
|
|
|
|
+ MaterialStatePropertyAll(
|
|
|
|
+ AppTheme.tertiary),
|
|
|
|
+ foregroundColor:
|
|
|
|
+ MaterialStatePropertyAll(
|
|
|
|
+ AppTheme.quaternary)),
|
|
|
|
+ ),
|
|
|
|
+ ],
|
|
|
|
+ )
|
|
],
|
|
],
|
|
- )
|
|
|
|
|
|
+ ),
|
|
],
|
|
],
|
|
);
|
|
);
|
|
},
|
|
},
|