refactor: Improve code formatting and replace print with debugPrint for error logging
This commit is contained in:
+13
-11
@@ -101,7 +101,8 @@ class _NotesAppState extends State<NotesApp>
|
|||||||
}
|
}
|
||||||
|
|
||||||
final AppPalette palette = _activePalette();
|
final AppPalette palette = _activePalette();
|
||||||
final String message = _syncErrorMessage ?? _syncDetailMessage ?? 'Sincronizando...';
|
final String message =
|
||||||
|
_syncErrorMessage ?? _syncDetailMessage ?? 'Sincronizando...';
|
||||||
final double? progress = _syncProgress;
|
final double? progress = _syncProgress;
|
||||||
final IconData icon;
|
final IconData icon;
|
||||||
final Color accentColor;
|
final Color accentColor;
|
||||||
@@ -138,7 +139,9 @@ class _NotesAppState extends State<NotesApp>
|
|||||||
child: Container(
|
child: Container(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 10),
|
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 10),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
border: Border(top: BorderSide(color: accentColor.withValues(alpha: 0.45))),
|
border: Border(
|
||||||
|
top: BorderSide(color: accentColor.withValues(alpha: 0.45)),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
@@ -591,17 +594,15 @@ class _NotesAppState extends State<NotesApp>
|
|||||||
if (available) {
|
if (available) {
|
||||||
bool activated = await _vaultService.enableBiometricProtection();
|
bool activated = await _vaultService.enableBiometricProtection();
|
||||||
while (!activated) {
|
while (!activated) {
|
||||||
// Ask the user to retry or skip
|
// Ask the user to retry or skip - pass currentContext directly in builder
|
||||||
final BuildContext? dialogCtx = _navigatorKey.currentContext;
|
final NavigatorState? navigator = _navigatorKey.currentState;
|
||||||
if (dialogCtx == null) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
final NavigatorState navigator = Navigator.of(dialogCtx);
|
if (navigator == null) break;
|
||||||
|
if (!mounted) return;
|
||||||
|
|
||||||
final bool? retry = await showDialog<bool>(
|
final bool? retry = await showDialog<bool>(
|
||||||
context: dialogCtx,
|
context: context,
|
||||||
builder: (BuildContext context) {
|
builder: (BuildContext dialogContext) {
|
||||||
final AppPalette palette = _activePalette();
|
final AppPalette palette = _activePalette();
|
||||||
return AlertDialog(
|
return AlertDialog(
|
||||||
backgroundColor: palette.cardBackground,
|
backgroundColor: palette.cardBackground,
|
||||||
@@ -1076,7 +1077,8 @@ class _NotesAppState extends State<NotesApp>
|
|||||||
switchOutCurve: Curves.easeInCubic,
|
switchOutCurve: Curves.easeInCubic,
|
||||||
transitionBuilder:
|
transitionBuilder:
|
||||||
(Widget child, Animation<double> animation) {
|
(Widget child, Animation<double> animation) {
|
||||||
final Animation<Offset> slideAnimation = Tween<Offset>(
|
final Animation<Offset> slideAnimation =
|
||||||
|
Tween<Offset>(
|
||||||
begin: const Offset(0.0, 0.35),
|
begin: const Offset(0.0, 0.35),
|
||||||
end: Offset.zero,
|
end: Offset.zero,
|
||||||
).animate(animation);
|
).animate(animation);
|
||||||
|
|||||||
@@ -676,7 +676,7 @@ Future<List<Map<String, Object?>>> _decryptNoteBatch(
|
|||||||
masterKey,
|
masterKey,
|
||||||
);
|
);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print('Failed to decrypt note ${note['id']}: $e');
|
debugPrint('Failed to decrypt note ${note['id']}: $e');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
decryptedTitle = '';
|
decryptedTitle = '';
|
||||||
|
|||||||
@@ -316,7 +316,7 @@ class _HomeScreenState extends State<HomeScreen> {
|
|||||||
),
|
),
|
||||||
boxShadow: [
|
boxShadow: [
|
||||||
BoxShadow(
|
BoxShadow(
|
||||||
color: color.withOpacity(0.18),
|
color: color.withValues(alpha: 0.0),
|
||||||
blurRadius: 10,
|
blurRadius: 10,
|
||||||
offset: const Offset(0, 4),
|
offset: const Offset(0, 4),
|
||||||
),
|
),
|
||||||
@@ -362,7 +362,7 @@ class _HomeScreenState extends State<HomeScreen> {
|
|||||||
height: 50,
|
height: 50,
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: selectedIconCodePoint == icon.codePoint
|
color: selectedIconCodePoint == icon.codePoint
|
||||||
? previewColor.withOpacity(0.14)
|
? previewColor.withValues(alpha: 0.14)
|
||||||
: palette.fill,
|
: palette.fill,
|
||||||
borderRadius: BorderRadius.circular(14),
|
borderRadius: BorderRadius.circular(14),
|
||||||
border: Border.all(
|
border: Border.all(
|
||||||
@@ -613,10 +613,10 @@ class _HomeScreenState extends State<HomeScreen> {
|
|||||||
duration: const Duration(milliseconds: 160),
|
duration: const Duration(milliseconds: 160),
|
||||||
padding: const EdgeInsets.all(2),
|
padding: const EdgeInsets.all(2),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: selected ? color.withOpacity(0.05) : Colors.transparent,
|
color: selected ? color.withValues(alpha: 0.05) : Colors.transparent,
|
||||||
borderRadius: BorderRadius.circular(12),
|
borderRadius: BorderRadius.circular(12),
|
||||||
border: Border.all(
|
border: Border.all(
|
||||||
color: selected ? color.withOpacity(0.42) : Colors.transparent,
|
color: selected ? color.withValues(alpha: 0.42) : Colors.transparent,
|
||||||
width: selected ? 1 : 1,
|
width: selected ? 1 : 1,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -945,7 +945,7 @@ class _HomeScreenState extends State<HomeScreen> {
|
|||||||
style: IconButton.styleFrom(
|
style: IconButton.styleFrom(
|
||||||
backgroundColor: _selectedCategoryId == null
|
backgroundColor: _selectedCategoryId == null
|
||||||
? Colors.transparent
|
? Colors.transparent
|
||||||
: palette.accent.withOpacity(0.08),
|
: palette.accent.withValues(alpha: 0.08),
|
||||||
shape: const CircleBorder(),
|
shape: const CircleBorder(),
|
||||||
),
|
),
|
||||||
icon: Stack(
|
icon: Stack(
|
||||||
@@ -1067,7 +1067,7 @@ class _HomeScreenState extends State<HomeScreen> {
|
|||||||
padding: const EdgeInsets.fromLTRB(10, 10, 10, 14),
|
padding: const EdgeInsets.fromLTRB(10, 10, 10, 14),
|
||||||
buildDefaultDragHandles: false,
|
buildDefaultDragHandles: false,
|
||||||
itemCount: visibleNotes.length,
|
itemCount: visibleNotes.length,
|
||||||
onReorder: _handleReorder,
|
onReorderItem: _handleReorder,
|
||||||
footer: Padding(
|
footer: Padding(
|
||||||
padding: const EdgeInsets.only(top: 4, bottom: 72),
|
padding: const EdgeInsets.only(top: 4, bottom: 72),
|
||||||
child: Center(
|
child: Center(
|
||||||
@@ -1104,8 +1104,7 @@ class _HomeScreenState extends State<HomeScreen> {
|
|||||||
Widget _buildEmptyDetailPane(BuildContext context) {
|
Widget _buildEmptyDetailPane(BuildContext context) {
|
||||||
final AppPalette palette = _paletteOf(context);
|
final AppPalette palette = _paletteOf(context);
|
||||||
|
|
||||||
return Container(
|
return Center(
|
||||||
child: Center(
|
|
||||||
child: Text(
|
child: Text(
|
||||||
'Selecciona una nota o\ncrea una nueva para empezar.',
|
'Selecciona una nota o\ncrea una nueva para empezar.',
|
||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
@@ -1115,7 +1114,6 @@ class _HomeScreenState extends State<HomeScreen> {
|
|||||||
fontWeight: FontWeight.w500,
|
fontWeight: FontWeight.w500,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -98,12 +98,13 @@ class _SettingsScreenState extends State<SettingsScreen> {
|
|||||||
SnackBar(content: Text('Error al borrar los datos: $error')),
|
SnackBar(content: Text('Error al borrar los datos: $error')),
|
||||||
);
|
);
|
||||||
} finally {
|
} finally {
|
||||||
if (!mounted) return;
|
if (mounted) {
|
||||||
setState(() {
|
setState(() {
|
||||||
_isBusy = false;
|
_isBusy = false;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Future<void> _confirmAndDeleteServerData() async {
|
Future<void> _confirmAndDeleteServerData() async {
|
||||||
final bool? confirmed = await showDialog<bool>(
|
final bool? confirmed = await showDialog<bool>(
|
||||||
@@ -168,12 +169,13 @@ class _SettingsScreenState extends State<SettingsScreen> {
|
|||||||
SnackBar(content: Text('Error al borrar la info del servidor: $error')),
|
SnackBar(content: Text('Error al borrar la info del servidor: $error')),
|
||||||
);
|
);
|
||||||
} finally {
|
} finally {
|
||||||
if (!mounted) return;
|
if (mounted) {
|
||||||
setState(() {
|
setState(() {
|
||||||
_isServerDeleting = false;
|
_isServerDeleting = false;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Future<void> _forceSync() async {
|
Future<void> _forceSync() async {
|
||||||
if (_isBusy || _isSyncing) {
|
if (_isBusy || _isSyncing) {
|
||||||
@@ -199,13 +201,13 @@ class _SettingsScreenState extends State<SettingsScreen> {
|
|||||||
SnackBar(content: Text('Error al forzar la sincronización: $error')),
|
SnackBar(content: Text('Error al forzar la sincronización: $error')),
|
||||||
);
|
);
|
||||||
} finally {
|
} finally {
|
||||||
if (!mounted) return;
|
if (mounted) {
|
||||||
|
|
||||||
setState(() {
|
setState(() {
|
||||||
_isSyncing = false;
|
_isSyncing = false;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Future<void> _selectThemeColor(Color color) async {
|
Future<void> _selectThemeColor(Color color) async {
|
||||||
if (_isThemeSaving || _selectedSeedColor == color) {
|
if (_isThemeSaving || _selectedSeedColor == color) {
|
||||||
@@ -576,26 +578,31 @@ class _SettingsScreenState extends State<SettingsScreen> {
|
|||||||
const SizedBox(height: 8),
|
const SizedBox(height: 8),
|
||||||
Column(
|
Column(
|
||||||
children: [
|
children: [
|
||||||
RadioListTile<ThemeMode>(
|
RadioGroup<ThemeMode>(
|
||||||
title: const Text('Seguir modo del sistema'),
|
|
||||||
value: ThemeMode.system,
|
|
||||||
groupValue: _selectedThemeMode,
|
groupValue: _selectedThemeMode,
|
||||||
onChanged: (ThemeMode? v) =>
|
onChanged: (ThemeMode? v) {
|
||||||
_selectThemeMode(ThemeMode.system),
|
if (v != null) {
|
||||||
|
_selectThemeMode(v);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
RadioListTile<ThemeMode>(
|
||||||
|
title: const Text(
|
||||||
|
'Seguir modo del sistema',
|
||||||
|
),
|
||||||
|
value: ThemeMode.system,
|
||||||
),
|
),
|
||||||
RadioListTile<ThemeMode>(
|
RadioListTile<ThemeMode>(
|
||||||
title: const Text('Modo claro'),
|
title: const Text('Modo claro'),
|
||||||
value: ThemeMode.light,
|
value: ThemeMode.light,
|
||||||
groupValue: _selectedThemeMode,
|
|
||||||
onChanged: (ThemeMode? v) =>
|
|
||||||
_selectThemeMode(ThemeMode.light),
|
|
||||||
),
|
),
|
||||||
RadioListTile<ThemeMode>(
|
RadioListTile<ThemeMode>(
|
||||||
title: const Text('Modo oscuro'),
|
title: const Text('Modo oscuro'),
|
||||||
value: ThemeMode.dark,
|
value: ThemeMode.dark,
|
||||||
groupValue: _selectedThemeMode,
|
),
|
||||||
onChanged: (ThemeMode? v) =>
|
],
|
||||||
_selectThemeMode(ThemeMode.dark),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ class NoteCard extends StatelessWidget {
|
|||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
if (categoryIcon != null) ...[
|
if (categoryIcon != null) ...[
|
||||||
Container(
|
SizedBox(
|
||||||
width: 18,
|
width: 18,
|
||||||
height: 18,
|
height: 18,
|
||||||
child: Icon(
|
child: Icon(
|
||||||
|
|||||||
+1
-1
@@ -359,7 +359,7 @@ packages:
|
|||||||
source: hosted
|
source: hosted
|
||||||
version: "6.0.0"
|
version: "6.0.0"
|
||||||
flutter_localizations:
|
flutter_localizations:
|
||||||
dependency: transitive
|
dependency: "direct main"
|
||||||
description: flutter
|
description: flutter
|
||||||
source: sdk
|
source: sdk
|
||||||
version: "0.0.0"
|
version: "0.0.0"
|
||||||
|
|||||||
@@ -50,6 +50,9 @@ dependencies:
|
|||||||
uuid: ^4.0.0
|
uuid: ^4.0.0
|
||||||
flutter_quill: ^11.5.1
|
flutter_quill: ^11.5.1
|
||||||
|
|
||||||
|
flutter_localizations:
|
||||||
|
sdk: flutter
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
|
|||||||
@@ -2,8 +2,6 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:flutter_localizations/flutter_localizations.dart';
|
import 'package:flutter_localizations/flutter_localizations.dart';
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
import 'package:flutter_quill/flutter_quill.dart';
|
import 'package:flutter_quill/flutter_quill.dart';
|
||||||
|
|
||||||
import 'package:notas/models/category.dart';
|
|
||||||
import 'package:notas/models/note.dart';
|
import 'package:notas/models/note.dart';
|
||||||
import 'package:notas/screens/note_editor_screen.dart';
|
import 'package:notas/screens/note_editor_screen.dart';
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user