From 491231684512368537deac3d89b2d7607e95e577 Mon Sep 17 00:00:00 2001 From: Marcos Date: Tue, 19 May 2026 20:20:03 +0200 Subject: [PATCH] feat: Update biometric screens to remove amber color from fingerprint icon for consistency --- lib/screens/biometric_choice_screen.dart | 1 - lib/screens/biometric_gate_screen.dart | 1 - lib/screens/note_editor_screen.dart | 198 +++++++++++++++++++---- 3 files changed, 164 insertions(+), 36 deletions(-) diff --git a/lib/screens/biometric_choice_screen.dart b/lib/screens/biometric_choice_screen.dart index 3d68760..8354a17 100644 --- a/lib/screens/biometric_choice_screen.dart +++ b/lib/screens/biometric_choice_screen.dart @@ -58,7 +58,6 @@ class BiometricChoiceScreen extends StatelessWidget { children: [ const Icon( Icons.fingerprint, - color: Colors.amber, size: 44, ), const SizedBox(height: 16), diff --git a/lib/screens/biometric_gate_screen.dart b/lib/screens/biometric_gate_screen.dart index 8822008..36ed06a 100644 --- a/lib/screens/biometric_gate_screen.dart +++ b/lib/screens/biometric_gate_screen.dart @@ -82,7 +82,6 @@ class _BiometricGateScreenState extends State { children: [ const Icon( Icons.fingerprint, - color: Colors.amber, size: 44, ), const SizedBox(height: 16), diff --git a/lib/screens/note_editor_screen.dart b/lib/screens/note_editor_screen.dart index 63f3557..4371683 100644 --- a/lib/screens/note_editor_screen.dart +++ b/lib/screens/note_editor_screen.dart @@ -65,7 +65,9 @@ class NoteEditorScreen extends StatefulWidget { if (!completer.isCompleted) { completer.complete(result); } - entry.remove(); + if (entry.mounted) { + entry.remove(); + } }, ); }, @@ -146,45 +148,173 @@ class _NoteEditorScreenState extends State { _complete(updatedNote); } - void _deleteNote() { + Future _showDeleteConfirmation() async { final bool isDeletedNote = _currentNote.isDeleted; - showDialog( - context: context, - builder: (BuildContext context) { - return AlertDialog( - backgroundColor: const Color(0xFF303134), - title: Text( - isDeletedNote ? 'Eliminar permanentemente' : 'Eliminar nota', - style: const TextStyle(color: Colors.white), - ), - content: Text( - isDeletedNote - ? 'Esta nota ya está borrada. Si la eliminas ahora, se borrará permanentemente.' - : '¿Estás seguro de que deseas eliminar esta nota?', - style: const TextStyle(color: Colors.white70), - ), - actions: [ - TextButton( - onPressed: () => Navigator.of(context).pop(), - child: const Text( - 'Cancelar', - style: TextStyle(color: Colors.white70), - ), + + if (_isMobileLayout) { + final bool? confirmed = await showDialog( + context: context, + barrierDismissible: false, + barrierColor: Colors.transparent, + builder: (BuildContext dialogContext) { + return AlertDialog( + backgroundColor: const Color(0xFF303134), + title: Text( + isDeletedNote ? 'Eliminar permanentemente' : 'Eliminar nota', + style: const TextStyle(color: Colors.white), ), - TextButton( - onPressed: () { - Navigator.of(context).pop(); - _complete('delete'); - }, - child: Text( - isDeletedNote ? 'Eliminar permanentemente' : 'Eliminar', - style: const TextStyle(color: Colors.red), - ), + content: Text( + isDeletedNote + ? 'Esta nota ya está borrada. Si la eliminas ahora, se borrará permanentemente.' + : '¿Estás seguro de que deseas eliminar esta nota?', + style: const TextStyle(color: Colors.white70), ), - ], + actions: [ + TextButton( + onPressed: () => Navigator.of(dialogContext).pop(false), + child: const Text( + 'Cancelar', + style: TextStyle(color: Colors.white70), + ), + ), + TextButton( + onPressed: () => Navigator.of(dialogContext).pop(true), + child: Text( + isDeletedNote ? 'Eliminar permanentemente' : 'Eliminar', + style: const TextStyle(color: Colors.red), + ), + ), + ], + ); + }, + ); + + return confirmed ?? false; + } + + final OverlayState? overlayState = Overlay.of(context, rootOverlay: true); + if (overlayState == null) { + final bool? confirmed = await showDialog( + context: context, + barrierDismissible: false, + barrierColor: Colors.transparent, + builder: (BuildContext dialogContext) { + return AlertDialog( + backgroundColor: const Color(0xFF303134), + title: Text( + isDeletedNote ? 'Eliminar permanentemente' : 'Eliminar nota', + style: const TextStyle(color: Colors.white), + ), + content: Text( + isDeletedNote + ? 'Esta nota ya está borrada. Si la eliminas ahora, se borrará permanentemente.' + : '¿Estás seguro de que deseas eliminar esta nota?', + style: const TextStyle(color: Colors.white70), + ), + actions: [ + TextButton( + onPressed: () => Navigator.of(dialogContext).pop(false), + child: const Text( + 'Cancelar', + style: TextStyle(color: Colors.white70), + ), + ), + TextButton( + onPressed: () => Navigator.of(dialogContext).pop(true), + child: Text( + isDeletedNote ? 'Eliminar permanentemente' : 'Eliminar', + style: const TextStyle(color: Colors.red), + ), + ), + ], + ); + }, + ); + + return confirmed ?? false; + } + + final Completer completer = Completer(); + late final OverlayEntry entry; + bool didRemove = false; + + void close(bool confirmed) { + if (!completer.isCompleted) { + completer.complete(confirmed); + } + if (!didRemove && entry.mounted) { + didRemove = true; + entry.remove(); + } + } + + entry = OverlayEntry( + builder: (BuildContext overlayContext) { + return Material( + color: Colors.transparent, + child: Stack( + children: [ + const Positioned.fill( + child: ModalBarrier( + dismissible: false, + color: Color.fromARGB(140, 0, 0, 0), + ), + ), + Center( + child: ConstrainedBox( + constraints: const BoxConstraints(maxWidth: 420), + child: AlertDialog( + backgroundColor: const Color(0xFF303134), + title: Text( + isDeletedNote + ? 'Eliminar permanentemente' + : 'Eliminar nota', + style: const TextStyle(color: Colors.white), + ), + content: Text( + isDeletedNote + ? 'Esta nota ya está borrada. Si la eliminas ahora, se borrará permanentemente.' + : '¿Estás seguro de que deseas eliminar esta nota?', + style: const TextStyle(color: Colors.white70), + ), + actions: [ + TextButton( + onPressed: () => close(false), + child: const Text( + 'Cancelar', + style: TextStyle(color: Colors.white70), + ), + ), + TextButton( + onPressed: () => close(true), + child: Text( + isDeletedNote + ? 'Eliminar permanentemente' + : 'Eliminar', + style: const TextStyle(color: Colors.red), + ), + ), + ], + ), + ), + ), + ], + ), ); }, ); + + overlayState.insert(entry); + return completer.future; + } + + Future _deleteNote() async { + final bool confirmed = await _showDeleteConfirmation(); + if (!mounted || !confirmed) { + return; + } + + _complete('delete'); } String _formatDate(DateTime date) {