|
@@ -1,4 +1,5 @@
|
|
|
import 'package:flutter/material.dart';
|
|
|
+import 'package:provider/provider.dart';
|
|
|
import '../../core/services/session_storage.dart';
|
|
|
import '../../core/models/models.dart';
|
|
|
import '../../core/services/services.dart';
|
|
@@ -93,4 +94,34 @@ class LoginViewModel extends ChangeNotifier {
|
|
|
_obscureText = !_obscureText;
|
|
|
notifyListeners();
|
|
|
}
|
|
|
+
|
|
|
+ Future<void> showExitConfirmationDialog(context) async {
|
|
|
+ final bool? confirm = await showDialog(
|
|
|
+ context: context,
|
|
|
+ builder: (ctx) {
|
|
|
+ return AlertDialog(
|
|
|
+ title: const Text('¿Cerrar sesión?'),
|
|
|
+ content: const Text('¿Estás seguro de que quieres cerrar la sesión?'),
|
|
|
+ actions: [
|
|
|
+ TextButton(
|
|
|
+ onPressed: () => Navigator.of(ctx).pop(false),
|
|
|
+ child:
|
|
|
+ const Text('Cancelar', style: TextStyle(color: Colors.red)),
|
|
|
+ ),
|
|
|
+ TextButton(
|
|
|
+ onPressed: () async {
|
|
|
+ Provider.of<LoginViewModel>(context, listen: false).logOut();
|
|
|
+ Navigator.of(ctx).pop(true);
|
|
|
+ },
|
|
|
+ child: const Text('Aceptar'),
|
|
|
+ ),
|
|
|
+ ],
|
|
|
+ );
|
|
|
+ },
|
|
|
+ );
|
|
|
+
|
|
|
+ if (confirm == true) {
|
|
|
+ Navigator.of(context).pushNamedAndRemoveUntil('login', (route) => false);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|