Refactor theme management: Replace AppColors with AppPalette
- Removed AppColors class and migrated all references to AppPalette. - Updated VaultAccessScreen, MenuDrawer, NoteCard, SearchAppBar, and other widgets to use AppPalette for color management. - Introduced AppPalette to handle light and dark themes with appropriate color schemes. - Adjusted theme application in AppTheme to utilize AppPalette extensions. - Updated tests to reflect changes in theme structure and color references.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:notas/theme/app_colors.dart';
|
||||
import 'package:notas/theme/app_palette.dart';
|
||||
|
||||
class BiometricChoiceScreen extends StatelessWidget {
|
||||
const BiometricChoiceScreen({
|
||||
@@ -15,9 +15,11 @@ class BiometricChoiceScreen extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final AppPalette palette = Theme.of(context).extension<AppPalette>()!;
|
||||
|
||||
return Scaffold(
|
||||
body: Container(
|
||||
decoration: const BoxDecoration(gradient: AppColors.backdropGradient),
|
||||
decoration: BoxDecoration(gradient: palette.backdropGradient),
|
||||
child: SafeArea(
|
||||
child: Column(
|
||||
children: [
|
||||
@@ -30,12 +32,12 @@ class BiometricChoiceScreen extends StatelessWidget {
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(24),
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.surface,
|
||||
color: palette.cardBackground,
|
||||
borderRadius: BorderRadius.circular(24),
|
||||
border: Border.all(color: AppColors.borderMuted),
|
||||
border: Border.all(color: palette.border),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: AppColors.shadow,
|
||||
color: palette.shadowSoft,
|
||||
blurRadius: 30,
|
||||
offset: const Offset(0, 18),
|
||||
),
|
||||
@@ -55,7 +57,7 @@ class BiometricChoiceScreen extends StatelessWidget {
|
||||
'Proteger con huella',
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
color: AppColors.textPrimary,
|
||||
color: Colors.white,
|
||||
fontSize: 28,
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
@@ -65,7 +67,7 @@ class BiometricChoiceScreen extends StatelessWidget {
|
||||
'¿Quieres que la app te pida huella o cara antes de entrar a tus notas?',
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
color: AppColors.textSecondary,
|
||||
color: palette.textSecondary,
|
||||
height: 1.4,
|
||||
),
|
||||
),
|
||||
@@ -94,10 +96,8 @@ class BiometricChoiceScreen extends StatelessWidget {
|
||||
padding: const EdgeInsets.symmetric(
|
||||
vertical: 14,
|
||||
),
|
||||
side: const BorderSide(
|
||||
color: AppColors.textDisabled,
|
||||
),
|
||||
foregroundColor: AppColors.textPrimary,
|
||||
side: BorderSide(color: palette.border),
|
||||
foregroundColor: palette.textPrimary,
|
||||
),
|
||||
child: const Text('No, entrar sin huella'),
|
||||
),
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:notas/theme/app_colors.dart';
|
||||
import 'package:notas/theme/app_palette.dart';
|
||||
|
||||
class BiometricGateScreen extends StatefulWidget {
|
||||
const BiometricGateScreen({
|
||||
@@ -39,9 +39,11 @@ class _BiometricGateScreenState extends State<BiometricGateScreen> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final AppPalette palette = Theme.of(context).extension<AppPalette>()!;
|
||||
|
||||
return Scaffold(
|
||||
body: Container(
|
||||
decoration: const BoxDecoration(gradient: AppColors.backdropGradient),
|
||||
decoration: BoxDecoration(gradient: palette.backdropGradient),
|
||||
child: SafeArea(
|
||||
child: Column(
|
||||
children: [
|
||||
@@ -54,12 +56,12 @@ class _BiometricGateScreenState extends State<BiometricGateScreen> {
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(24),
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.surface,
|
||||
color: palette.cardBackground,
|
||||
borderRadius: BorderRadius.circular(24),
|
||||
border: Border.all(color: AppColors.borderMuted),
|
||||
border: Border.all(color: palette.border),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: AppColors.shadow,
|
||||
color: palette.shadowSoft,
|
||||
blurRadius: 30,
|
||||
offset: const Offset(0, 18),
|
||||
),
|
||||
@@ -79,7 +81,7 @@ class _BiometricGateScreenState extends State<BiometricGateScreen> {
|
||||
'Desbloqueo biométrico',
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
color: AppColors.textPrimary,
|
||||
color: Colors.white,
|
||||
fontSize: 28,
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
@@ -89,7 +91,7 @@ class _BiometricGateScreenState extends State<BiometricGateScreen> {
|
||||
'Pon tu huella o cara para entrar a tus notas.',
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
color: AppColors.textSecondary,
|
||||
color: palette.textSecondary,
|
||||
height: 1.4,
|
||||
),
|
||||
),
|
||||
|
||||
@@ -15,7 +15,7 @@ import 'package:notas/widgets/note_card.dart';
|
||||
import 'package:notas/widgets/search_app_bar.dart';
|
||||
import 'package:notas/widgets/sync_status.dart';
|
||||
import 'package:notas/widgets/sync_status_indicator.dart';
|
||||
import 'package:notas/theme/app_colors.dart';
|
||||
import 'package:notas/theme/app_palette.dart';
|
||||
|
||||
class HomeScreen extends StatefulWidget {
|
||||
const HomeScreen({
|
||||
@@ -489,9 +489,11 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
),
|
||||
);
|
||||
|
||||
final AppPalette palette = Theme.of(context).extension<AppPalette>()!;
|
||||
|
||||
return Scaffold(
|
||||
body: Container(
|
||||
decoration: const BoxDecoration(gradient: AppColors.backdropGradient),
|
||||
decoration: BoxDecoration(gradient: palette.backdropGradient),
|
||||
child: SafeArea(
|
||||
child: Column(
|
||||
children: [
|
||||
@@ -565,7 +567,7 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
child: GestureDetector(
|
||||
behavior: HitTestBehavior.opaque,
|
||||
onTap: _closeMenu,
|
||||
child: Container(color: AppColors.overlay),
|
||||
child: Container(color: palette.overlay),
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -578,7 +580,7 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
bottom: 0,
|
||||
width: 280,
|
||||
child: Material(
|
||||
color: AppColors.cardBackground,
|
||||
color: palette.cardBackground,
|
||||
elevation: 8,
|
||||
child: MenuDrawer(
|
||||
onMenuItemTapped: _handleMenuItemTapped,
|
||||
@@ -642,11 +644,13 @@ class _DraggableNote extends StatelessWidget {
|
||||
final VoidCallback onDraggableCanceled;
|
||||
final VoidCallback onDragStarted;
|
||||
|
||||
Widget _buildFeedback() {
|
||||
Widget _buildFeedback(BuildContext context) {
|
||||
final AppPalette palette = Theme.of(context).extension<AppPalette>()!;
|
||||
|
||||
return MouseRegion(
|
||||
cursor: SystemMouseCursors.grabbing,
|
||||
child: Material(
|
||||
color: AppColors.transparent,
|
||||
color: palette.transparent,
|
||||
elevation: 8,
|
||||
child: SizedBox(
|
||||
width: cellWidth,
|
||||
@@ -676,7 +680,9 @@ class _DraggableNote extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildChildWhenDragging() {
|
||||
Widget _buildChildWhenDragging(BuildContext context) {
|
||||
final AppPalette palette = Theme.of(context).extension<AppPalette>()!;
|
||||
|
||||
return MouseRegion(
|
||||
cursor: SystemMouseCursors.grabbing,
|
||||
child: Opacity(
|
||||
@@ -684,10 +690,10 @@ class _DraggableNote extends StatelessWidget {
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.cardBackground,
|
||||
color: palette.cardBackground,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
border: Border.all(
|
||||
color: borderColor ?? AppColors.textDisabled,
|
||||
color: borderColor ?? palette.textSecondary,
|
||||
width: 1,
|
||||
),
|
||||
),
|
||||
@@ -697,8 +703,8 @@ class _DraggableNote extends StatelessWidget {
|
||||
children: [
|
||||
Text(
|
||||
note.title,
|
||||
style: const TextStyle(
|
||||
color: AppColors.textPrimary,
|
||||
style: TextStyle(
|
||||
color: palette.textPrimary,
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
@@ -708,10 +714,7 @@ class _DraggableNote extends StatelessWidget {
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
note.body,
|
||||
style: const TextStyle(
|
||||
color: AppColors.textSecondary,
|
||||
fontSize: 14,
|
||||
),
|
||||
style: TextStyle(color: palette.textSecondary, fontSize: 14),
|
||||
maxLines: 20,
|
||||
overflow: TextOverflow.clip,
|
||||
),
|
||||
@@ -724,10 +727,12 @@ class _DraggableNote extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final AppPalette palette = Theme.of(context).extension<AppPalette>()!;
|
||||
|
||||
final Widget content = Container(
|
||||
decoration: BoxDecoration(
|
||||
border: isDragTargetActive
|
||||
? Border.all(color: AppColors.dragTargetBorder, width: 2)
|
||||
? Border.all(color: palette.dragTargetBorder, width: 2)
|
||||
: null,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
@@ -747,8 +752,8 @@ class _DraggableNote extends StatelessWidget {
|
||||
onDragStarted: onDragStarted,
|
||||
onDragEnd: onDragEnd,
|
||||
onDraggableCanceled: (Velocity _v, Offset _o) => onDraggableCanceled(),
|
||||
feedback: _buildFeedback(),
|
||||
childWhenDragging: _buildChildWhenDragging(),
|
||||
feedback: _buildFeedback(context),
|
||||
childWhenDragging: _buildChildWhenDragging(context),
|
||||
child: content,
|
||||
);
|
||||
}
|
||||
@@ -758,8 +763,8 @@ class _DraggableNote extends StatelessWidget {
|
||||
onDragStarted: onDragStarted,
|
||||
onDragEnd: onDragEnd,
|
||||
onDraggableCanceled: (Velocity _v, Offset _o) => onDraggableCanceled(),
|
||||
feedback: _buildFeedback(),
|
||||
childWhenDragging: _buildChildWhenDragging(),
|
||||
feedback: _buildFeedback(context),
|
||||
childWhenDragging: _buildChildWhenDragging(context),
|
||||
child: content,
|
||||
);
|
||||
}
|
||||
@@ -778,15 +783,13 @@ class _EmptyState extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final AppPalette palette = Theme.of(context).extension<AppPalette>()!;
|
||||
|
||||
return Center(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
const Icon(
|
||||
Icons.note_add_outlined,
|
||||
color: AppColors.textMuted,
|
||||
size: 48,
|
||||
),
|
||||
Icon(Icons.note_add_outlined, color: palette.textSecondary, size: 48),
|
||||
const SizedBox(height: 12),
|
||||
Text(
|
||||
searchQuery != null && searchQuery!.isNotEmpty
|
||||
@@ -796,8 +799,8 @@ class _EmptyState extends StatelessWidget {
|
||||
: categoryName != null
|
||||
? 'No hay notas en esta categoría'
|
||||
: 'Aún no hay notas',
|
||||
style: const TextStyle(
|
||||
color: AppColors.textPrimary,
|
||||
style: TextStyle(
|
||||
color: palette.textPrimary,
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
@@ -812,7 +815,7 @@ class _EmptyState extends StatelessWidget {
|
||||
? 'Pulsa el botón + para crear una nota en “$categoryName”.'
|
||||
: 'Pulsa el botón + para crear la primera.',
|
||||
textAlign: TextAlign.center,
|
||||
style: const TextStyle(color: AppColors.textSecondary),
|
||||
style: TextStyle(color: palette.textSecondary),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -934,26 +937,31 @@ class _CategoryDialogState extends State<_CategoryDialog> {
|
||||
Future<void> _deleteCategory() async {
|
||||
final bool? confirm = await showDialog<bool>(
|
||||
context: context,
|
||||
builder: (BuildContext context) => AlertDialog(
|
||||
backgroundColor: AppColors.cardBackground,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
side: BorderSide(color: AppColors.border),
|
||||
),
|
||||
title: const Text('Borrar categoría'),
|
||||
content: const Text('¿Seguro que quieres borrar esta categoría?'),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(context, false),
|
||||
child: const Text('Cancelar'),
|
||||
builder: (BuildContext context) {
|
||||
final AppPalette palette = Theme.of(context).extension<AppPalette>()!;
|
||||
return AlertDialog(
|
||||
backgroundColor: palette.cardBackground,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
side: BorderSide(color: palette.border),
|
||||
),
|
||||
TextButton(
|
||||
style: TextButton.styleFrom(foregroundColor: AppColors.destructive),
|
||||
onPressed: () => Navigator.pop(context, true),
|
||||
child: const Text('Borrar'),
|
||||
),
|
||||
],
|
||||
),
|
||||
title: const Text('Borrar categoría'),
|
||||
content: const Text('¿Seguro que quieres borrar esta categoría?'),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(context, false),
|
||||
child: const Text('Cancelar'),
|
||||
),
|
||||
TextButton(
|
||||
style: TextButton.styleFrom(
|
||||
foregroundColor: palette.destructiveAccent,
|
||||
),
|
||||
onPressed: () => Navigator.pop(context, true),
|
||||
child: const Text('Borrar'),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
if (confirm != true) {
|
||||
@@ -982,11 +990,13 @@ class _CategoryDialogState extends State<_CategoryDialog> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final AppPalette palette = Theme.of(context).extension<AppPalette>()!;
|
||||
|
||||
return AlertDialog(
|
||||
backgroundColor: AppColors.cardBackground,
|
||||
backgroundColor: palette.cardBackground,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
side: BorderSide(color: AppColors.border),
|
||||
side: BorderSide(color: palette.border),
|
||||
),
|
||||
title: Text(
|
||||
widget.category == null ? 'Crear categoría' : 'Editar categoría',
|
||||
@@ -1018,9 +1028,9 @@ class _CategoryDialogState extends State<_CategoryDialog> {
|
||||
const SizedBox(height: 16),
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.fill,
|
||||
color: palette.fill,
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
border: Border.all(color: AppColors.border),
|
||||
border: Border.all(color: palette.border),
|
||||
),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
@@ -1049,7 +1059,7 @@ class _CategoryDialogState extends State<_CategoryDialog> {
|
||||
),
|
||||
],
|
||||
),
|
||||
const Divider(height: 1, color: AppColors.border),
|
||||
Divider(height: 1, color: palette.border),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(12),
|
||||
child: AnimatedSwitcher(
|
||||
@@ -1075,11 +1085,11 @@ class _CategoryDialogState extends State<_CategoryDialog> {
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
border: isSelected
|
||||
? Border.all(
|
||||
color: AppColors.textPrimary,
|
||||
color: palette.textPrimary,
|
||||
width: 2,
|
||||
)
|
||||
: Border.all(
|
||||
color: AppColors.border,
|
||||
color: palette.border,
|
||||
width: 1,
|
||||
),
|
||||
),
|
||||
@@ -1105,21 +1115,21 @@ class _CategoryDialogState extends State<_CategoryDialog> {
|
||||
height: 42,
|
||||
decoration: BoxDecoration(
|
||||
color: isSelected
|
||||
? AppColors.hover
|
||||
: AppColors.transparent,
|
||||
? palette.hover
|
||||
: palette.transparent,
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
border: Border.all(
|
||||
color: isSelected
|
||||
? AppColors.textPrimary
|
||||
: AppColors.border,
|
||||
? palette.textPrimary
|
||||
: palette.border,
|
||||
width: 1,
|
||||
),
|
||||
),
|
||||
child: Icon(
|
||||
icon,
|
||||
color: isSelected
|
||||
? AppColors.textPrimary
|
||||
: AppColors.textSecondary,
|
||||
? palette.textPrimary
|
||||
: palette.textSecondary,
|
||||
),
|
||||
),
|
||||
);
|
||||
@@ -1137,9 +1147,9 @@ class _CategoryDialogState extends State<_CategoryDialog> {
|
||||
if (widget.category != null)
|
||||
TextButton(
|
||||
onPressed: _deleteCategory,
|
||||
child: const Text(
|
||||
child: Text(
|
||||
'Borrar',
|
||||
style: TextStyle(color: AppColors.destructive),
|
||||
style: TextStyle(color: palette.destructiveAccent),
|
||||
),
|
||||
),
|
||||
TextButton(
|
||||
@@ -1176,10 +1186,12 @@ class _PickerTabButton extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final AppPalette palette = Theme.of(context).extension<AppPalette>()!;
|
||||
|
||||
return Material(
|
||||
borderRadius: borderRadius,
|
||||
clipBehavior: Clip.antiAlias,
|
||||
color: selected ? AppColors.hover : AppColors.transparent,
|
||||
color: selected ? palette.hover : palette.transparent,
|
||||
child: InkWell(
|
||||
borderRadius: borderRadius,
|
||||
onTap: onTap,
|
||||
@@ -1189,7 +1201,7 @@ class _PickerTabButton extends StatelessWidget {
|
||||
child: Text(
|
||||
label,
|
||||
style: TextStyle(
|
||||
color: selected ? AppColors.textPrimary : AppColors.textMuted,
|
||||
color: selected ? palette.textPrimary : palette.textSecondary,
|
||||
fontWeight: selected ? FontWeight.w600 : FontWeight.w400,
|
||||
),
|
||||
),
|
||||
|
||||
@@ -7,7 +7,7 @@ import 'package:intl/intl.dart';
|
||||
import 'package:notas/models/category.dart';
|
||||
import 'package:notas/models/note.dart';
|
||||
import 'package:notas/platform/app_platform.dart';
|
||||
import 'package:notas/theme/app_colors.dart';
|
||||
import 'package:notas/theme/app_palette.dart';
|
||||
import 'package:notas/widgets/category_style.dart';
|
||||
|
||||
// NoteEditorScreen: unified UI for creating and editing notes.
|
||||
@@ -42,7 +42,7 @@ class NoteEditorScreen extends StatefulWidget {
|
||||
return showGeneralDialog<dynamic>(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
barrierColor: AppColors.transparent,
|
||||
barrierColor: Colors.transparent,
|
||||
transitionDuration: const Duration(milliseconds: 200),
|
||||
pageBuilder: (context, animation, secondaryAnimation) {
|
||||
return NoteEditorScreen(
|
||||
@@ -120,6 +120,11 @@ class _NoteEditorScreenState extends State<NoteEditorScreen> {
|
||||
|
||||
bool get _isMobileLayout => isAndroid || isIOS;
|
||||
|
||||
AppPalette _paletteOf(BuildContext context) {
|
||||
return Theme.of(context).extension<AppPalette>() ??
|
||||
AppPalette.fromBrightness(Theme.of(context).brightness);
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
@@ -200,36 +205,37 @@ class _NoteEditorScreenState extends State<NoteEditorScreen> {
|
||||
required ValueChanged<bool> onConfirmed,
|
||||
}) {
|
||||
final bool isDeletedNote = _currentNote.isDeleted;
|
||||
final AppPalette palette = _paletteOf(context);
|
||||
|
||||
return AlertDialog(
|
||||
backgroundColor: AppColors.cardBackground,
|
||||
backgroundColor: palette.cardBackground,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
side: BorderSide(color: AppColors.border),
|
||||
side: BorderSide(color: palette.border),
|
||||
),
|
||||
title: Text(
|
||||
isDeletedNote ? 'Eliminar permanentemente' : 'Eliminar nota',
|
||||
style: const TextStyle(color: AppColors.textPrimary),
|
||||
style: TextStyle(color: palette.textPrimary),
|
||||
),
|
||||
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: AppColors.textSecondary),
|
||||
style: TextStyle(color: palette.textSecondary),
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => onConfirmed(false),
|
||||
child: const Text(
|
||||
child: Text(
|
||||
'Cancelar',
|
||||
style: TextStyle(color: AppColors.textSecondary),
|
||||
style: TextStyle(color: palette.textSecondary),
|
||||
),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () => onConfirmed(true),
|
||||
child: Text(
|
||||
isDeletedNote ? 'Eliminar permanentemente' : 'Eliminar',
|
||||
style: const TextStyle(color: AppColors.destructive),
|
||||
style: TextStyle(color: palette.destructiveAccent),
|
||||
),
|
||||
),
|
||||
],
|
||||
@@ -241,7 +247,7 @@ class _NoteEditorScreenState extends State<NoteEditorScreen> {
|
||||
final bool? confirmed = await showDialog<bool>(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
barrierColor: AppColors.transparent,
|
||||
barrierColor: Colors.transparent,
|
||||
builder: (BuildContext dialogContext) {
|
||||
return _buildDeleteConfirmationDialog(
|
||||
onConfirmed: (bool confirmed) =>
|
||||
@@ -258,7 +264,7 @@ class _NoteEditorScreenState extends State<NoteEditorScreen> {
|
||||
final bool? confirmed = await showDialog<bool>(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
barrierColor: AppColors.transparent,
|
||||
barrierColor: Colors.transparent,
|
||||
builder: (BuildContext dialogContext) {
|
||||
return _buildDeleteConfirmationDialog(
|
||||
onConfirmed: (bool confirmed) =>
|
||||
@@ -287,14 +293,11 @@ class _NoteEditorScreenState extends State<NoteEditorScreen> {
|
||||
};
|
||||
|
||||
return Material(
|
||||
color: AppColors.transparent,
|
||||
color: Colors.transparent,
|
||||
child: Stack(
|
||||
children: [
|
||||
const Positioned.fill(
|
||||
child: ModalBarrier(
|
||||
dismissible: false,
|
||||
color: AppColors.overlay,
|
||||
),
|
||||
child: ModalBarrier(dismissible: false, color: Colors.black54),
|
||||
),
|
||||
Center(
|
||||
child: ConstrainedBox(
|
||||
@@ -323,25 +326,30 @@ class _NoteEditorScreenState extends State<NoteEditorScreen> {
|
||||
}
|
||||
|
||||
Color _categoryBackgroundColor(Category? category) {
|
||||
final AppPalette palette = _paletteOf(context);
|
||||
|
||||
if (category?.colorValue == null) {
|
||||
return AppColors.borderMuted;
|
||||
return palette.borderMuted;
|
||||
}
|
||||
|
||||
return Color(category!.colorValue!);
|
||||
}
|
||||
|
||||
Color _categoryForegroundColor(Category? category) {
|
||||
final AppPalette palette = _paletteOf(context);
|
||||
|
||||
if (category == null || category.colorValue == null) {
|
||||
return AppColors.textPrimary;
|
||||
return palette.textPrimary;
|
||||
}
|
||||
|
||||
final Color background = Color(category.colorValue!);
|
||||
return background.computeLuminance() > 0.55
|
||||
? AppColors.textOnSurfaceDark
|
||||
: AppColors.textPrimary;
|
||||
? palette.textOnSurfaceDark
|
||||
: palette.textPrimary;
|
||||
}
|
||||
|
||||
Widget _buildCategorySelectorBox({Category? category}) {
|
||||
final AppPalette palette = _paletteOf(context);
|
||||
final String label = category?.name ?? 'Sin categoría';
|
||||
final IconData icon = CategoryStyle.iconForCodePoint(
|
||||
category?.iconCodePoint,
|
||||
@@ -358,7 +366,7 @@ class _NoteEditorScreenState extends State<NoteEditorScreen> {
|
||||
border: Border.all(
|
||||
color: category?.colorValue != null
|
||||
? backgroundColor.withValues(alpha: 0.85)
|
||||
: AppColors.textDisabled,
|
||||
: palette.textDisabled,
|
||||
),
|
||||
),
|
||||
child: Row(
|
||||
@@ -409,12 +417,13 @@ class _NoteEditorScreenState extends State<NoteEditorScreen> {
|
||||
|
||||
_categoryMenuEntry = OverlayEntry(
|
||||
builder: (BuildContext overlayContext) {
|
||||
final AppPalette palette = _paletteOf(overlayContext);
|
||||
final Size screenSize = MediaQuery.of(overlayContext).size;
|
||||
final double menuWidth = math.min(screenSize.width - 32, 320);
|
||||
final double menuHeight = math.min(screenSize.height - 32, 360);
|
||||
|
||||
return Material(
|
||||
color: AppColors.transparent,
|
||||
color: Colors.transparent,
|
||||
child: Stack(
|
||||
children: [
|
||||
Positioned.fill(
|
||||
@@ -432,7 +441,7 @@ class _NoteEditorScreenState extends State<NoteEditorScreen> {
|
||||
),
|
||||
child: Material(
|
||||
elevation: 10,
|
||||
color: AppColors.surfaceElevated,
|
||||
color: palette.surfaceElevated,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
clipBehavior: Clip.antiAlias,
|
||||
child: ListView(
|
||||
@@ -482,6 +491,7 @@ class _NoteEditorScreenState extends State<NoteEditorScreen> {
|
||||
required bool isSelected,
|
||||
required VoidCallback onTap,
|
||||
}) {
|
||||
final AppPalette palette = _paletteOf(context);
|
||||
final Color backgroundColor = _categoryBackgroundColor(category);
|
||||
final Color foregroundColor = _categoryForegroundColor(category);
|
||||
final IconData icon = CategoryStyle.iconForCodePoint(
|
||||
@@ -492,7 +502,7 @@ class _NoteEditorScreenState extends State<NoteEditorScreen> {
|
||||
onTap: onTap,
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 10),
|
||||
color: isSelected ? AppColors.hover : null,
|
||||
color: isSelected ? palette.hover : null,
|
||||
child: Row(
|
||||
children: [
|
||||
Container(
|
||||
@@ -504,7 +514,7 @@ class _NoteEditorScreenState extends State<NoteEditorScreen> {
|
||||
border: Border.all(
|
||||
color: category?.colorValue != null
|
||||
? backgroundColor.withValues(alpha: 0.85)
|
||||
: AppColors.textDisabled,
|
||||
: palette.textDisabled,
|
||||
),
|
||||
),
|
||||
child: Icon(icon, size: 16, color: foregroundColor),
|
||||
@@ -553,6 +563,7 @@ class _NoteEditorScreenState extends State<NoteEditorScreen> {
|
||||
}
|
||||
|
||||
Widget _buildEditorContent({required bool isMobile}) {
|
||||
final AppPalette palette = _paletteOf(context);
|
||||
final double titleSpacing = isMobile ? 16.0 : 8.0;
|
||||
|
||||
return Column(
|
||||
@@ -560,15 +571,13 @@ class _NoteEditorScreenState extends State<NoteEditorScreen> {
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
|
||||
decoration: BoxDecoration(
|
||||
border: Border(
|
||||
bottom: BorderSide(color: AppColors.border, width: 1),
|
||||
),
|
||||
border: Border(bottom: BorderSide(color: palette.border, width: 1)),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
IconButton(
|
||||
onPressed: _closeWithoutSaving,
|
||||
icon: const Icon(Icons.close, color: AppColors.textSecondary),
|
||||
icon: Icon(Icons.close, color: palette.textSecondary),
|
||||
tooltip: 'Cerrar sin guardar',
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
@@ -579,23 +588,17 @@ class _NoteEditorScreenState extends State<NoteEditorScreen> {
|
||||
children: [
|
||||
Text(
|
||||
'Posicion: ${_currentNote.position}',
|
||||
style: const TextStyle(
|
||||
color: AppColors.textMuted,
|
||||
fontSize: 12,
|
||||
),
|
||||
style: TextStyle(color: palette.textMuted, fontSize: 12),
|
||||
),
|
||||
Text(
|
||||
'Creado: ${_formatDate(_currentNote.createdAt)}',
|
||||
style: const TextStyle(
|
||||
color: AppColors.textMuted,
|
||||
fontSize: 12,
|
||||
),
|
||||
style: TextStyle(color: palette.textMuted, fontSize: 12),
|
||||
),
|
||||
if (_currentNote.updatedAt != _currentNote.createdAt)
|
||||
Text(
|
||||
'Modificado: ${_formatDate(_currentNote.updatedAt)}',
|
||||
style: const TextStyle(
|
||||
color: AppColors.textMuted,
|
||||
style: TextStyle(
|
||||
color: palette.textMuted,
|
||||
fontSize: 12,
|
||||
),
|
||||
),
|
||||
@@ -629,14 +632,14 @@ class _NoteEditorScreenState extends State<NoteEditorScreen> {
|
||||
children: [
|
||||
TextField(
|
||||
controller: _titleController,
|
||||
style: const TextStyle(
|
||||
color: AppColors.textPrimary,
|
||||
style: TextStyle(
|
||||
color: palette.textPrimary,
|
||||
fontSize: 28,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
decoration: const InputDecoration(
|
||||
decoration: InputDecoration(
|
||||
hintText: 'Título',
|
||||
hintStyle: TextStyle(color: AppColors.textHint),
|
||||
hintStyle: TextStyle(color: palette.textHint),
|
||||
border: InputBorder.none,
|
||||
contentPadding: EdgeInsets.zero,
|
||||
),
|
||||
@@ -648,14 +651,14 @@ class _NoteEditorScreenState extends State<NoteEditorScreen> {
|
||||
keyboardType: TextInputType.multiline,
|
||||
maxLines: null,
|
||||
expands: true,
|
||||
style: const TextStyle(
|
||||
color: AppColors.textPrimary,
|
||||
style: TextStyle(
|
||||
color: palette.textPrimary,
|
||||
fontSize: 16,
|
||||
height: 1.6,
|
||||
),
|
||||
decoration: const InputDecoration(
|
||||
decoration: InputDecoration(
|
||||
hintText: 'Escribe tu nota...',
|
||||
hintStyle: TextStyle(color: AppColors.textHint),
|
||||
hintStyle: TextStyle(color: palette.textHint),
|
||||
border: InputBorder.none,
|
||||
contentPadding: EdgeInsets.zero,
|
||||
),
|
||||
@@ -668,7 +671,7 @@ class _NoteEditorScreenState extends State<NoteEditorScreen> {
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
|
||||
decoration: BoxDecoration(
|
||||
border: Border(top: BorderSide(color: AppColors.border, width: 1)),
|
||||
border: Border(top: BorderSide(color: palette.border, width: 1)),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
@@ -676,9 +679,9 @@ class _NoteEditorScreenState extends State<NoteEditorScreen> {
|
||||
if (!_isNewNote)
|
||||
IconButton(
|
||||
onPressed: _deleteNote,
|
||||
icon: const Icon(
|
||||
icon: Icon(
|
||||
Icons.delete_outline,
|
||||
color: AppColors.destructive,
|
||||
color: palette.destructiveAccent,
|
||||
),
|
||||
tooltip: 'Eliminar nota',
|
||||
)
|
||||
@@ -694,12 +697,14 @@ class _NoteEditorScreenState extends State<NoteEditorScreen> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final AppPalette palette = _paletteOf(context);
|
||||
|
||||
if (_isMobileLayout) {
|
||||
return Material(
|
||||
color: AppColors.transparent,
|
||||
color: palette.transparent,
|
||||
child: SafeArea(
|
||||
child: Container(
|
||||
color: AppColors.cardBackground,
|
||||
color: palette.cardBackground,
|
||||
child: _buildEditorContent(isMobile: true),
|
||||
),
|
||||
),
|
||||
@@ -714,10 +719,7 @@ class _NoteEditorScreenState extends State<NoteEditorScreen> {
|
||||
return Stack(
|
||||
children: [
|
||||
Positioned.fill(
|
||||
child: ModalBarrier(
|
||||
dismissible: false,
|
||||
color: AppColors.shadowDim,
|
||||
),
|
||||
child: ModalBarrier(dismissible: false, color: palette.shadowDim),
|
||||
),
|
||||
Positioned.fill(
|
||||
child: Center(
|
||||
@@ -725,10 +727,10 @@ class _NoteEditorScreenState extends State<NoteEditorScreen> {
|
||||
width: maxWidth,
|
||||
height: maxHeight,
|
||||
child: Material(
|
||||
color: AppColors.cardBackground,
|
||||
color: palette.cardBackground,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
side: BorderSide(color: AppColors.textDisabled, width: 1),
|
||||
side: BorderSide(color: palette.textDisabled, width: 1),
|
||||
),
|
||||
clipBehavior: Clip.antiAlias,
|
||||
child: _buildEditorContent(isMobile: false),
|
||||
|
||||
+309
-240
@@ -1,6 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:notas/data/local_vault_service.dart';
|
||||
import 'package:notas/theme/app_colors.dart';
|
||||
import 'package:notas/theme/app_palette.dart';
|
||||
import 'package:notas/widgets/search_app_bar.dart';
|
||||
import 'package:notas/data/api_client.dart';
|
||||
|
||||
@@ -12,6 +12,8 @@ class SettingsScreen extends StatefulWidget {
|
||||
required this.onForceSync,
|
||||
required this.currentSeedColor,
|
||||
required this.onThemeColorSelected,
|
||||
required this.currentThemeMode,
|
||||
required this.onThemeModeSelected,
|
||||
});
|
||||
|
||||
final Future<void> Function() onDeleteAllData;
|
||||
@@ -19,6 +21,8 @@ class SettingsScreen extends StatefulWidget {
|
||||
final Future<void> Function() onForceSync;
|
||||
final Color currentSeedColor;
|
||||
final Future<void> Function(Color color) onThemeColorSelected;
|
||||
final ThemeMode currentThemeMode;
|
||||
final Future<void> Function(ThemeMode mode) onThemeModeSelected;
|
||||
|
||||
@override
|
||||
State<SettingsScreen> createState() => _SettingsScreenState();
|
||||
@@ -36,36 +40,40 @@ class _SettingsScreenState extends State<SettingsScreen> {
|
||||
bool _encryptionKeyLoading = false;
|
||||
bool _encryptionKeyVisible = false;
|
||||
late Color _selectedSeedColor;
|
||||
late ThemeMode _selectedThemeMode;
|
||||
|
||||
static const List<Color> _themeColorOptions = AppColors.themeSeedColors;
|
||||
static const List<Color> _themeColorOptions = AppPalette.themeSeedColors;
|
||||
|
||||
Future<void> _confirmAndDeleteAll() async {
|
||||
final bool? confirmed = await showDialog<bool>(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
backgroundColor: AppColors.cardBackground,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
side: BorderSide(color: AppColors.border),
|
||||
),
|
||||
title: const Text('Borrar todos los datos'),
|
||||
content: const Text(
|
||||
'¿Estás seguro? Esta acción eliminará la base de datos local y la clave de cifrado. Asegúrate de tener una copia de seguridad si es necesario o cuenta sincronizada.',
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(false),
|
||||
child: const Text('Cancelar'),
|
||||
builder: (context) {
|
||||
final AppPalette palette = Theme.of(context).extension<AppPalette>()!;
|
||||
return AlertDialog(
|
||||
backgroundColor: palette.cardBackground,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
side: BorderSide(color: palette.border),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(true),
|
||||
child: const Text(
|
||||
'Borrar',
|
||||
style: TextStyle(color: AppColors.destructive),
|
||||
title: const Text('Borrar todos los datos'),
|
||||
content: const Text(
|
||||
'¿Estás seguro? Esta acción eliminará la base de datos local y la clave de cifrado. Asegúrate de tener una copia de seguridad si es necesario o cuenta sincronizada.',
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(false),
|
||||
child: const Text('Cancelar'),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(true),
|
||||
child: Text(
|
||||
'Borrar',
|
||||
style: TextStyle(color: palette.destructiveAccent),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
if (confirmed != true) return;
|
||||
@@ -100,30 +108,33 @@ class _SettingsScreenState extends State<SettingsScreen> {
|
||||
Future<void> _confirmAndDeleteServerData() async {
|
||||
final bool? confirmed = await showDialog<bool>(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
backgroundColor: AppColors.cardBackground,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
side: BorderSide(color: AppColors.border),
|
||||
),
|
||||
title: const Text('Borrar toda la info del servidor'),
|
||||
content: const Text(
|
||||
'¿Estás seguro? Esta acción eliminará toda la información almacenada en el servidor y no se puede deshacer.',
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(false),
|
||||
child: const Text('Cancelar'),
|
||||
builder: (context) {
|
||||
final AppPalette palette = Theme.of(context).extension<AppPalette>()!;
|
||||
return AlertDialog(
|
||||
backgroundColor: palette.cardBackground,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
side: BorderSide(color: palette.border),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(true),
|
||||
child: const Text(
|
||||
'Borrar',
|
||||
style: TextStyle(color: AppColors.destructive),
|
||||
title: const Text('Borrar toda la info del servidor'),
|
||||
content: const Text(
|
||||
'¿Estás seguro? Esta acción eliminará toda la información almacenada en el servidor y no se puede deshacer.',
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(false),
|
||||
child: const Text('Cancelar'),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(true),
|
||||
child: Text(
|
||||
'Borrar',
|
||||
style: TextStyle(color: palette.destructiveAccent),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
if (confirmed != true) return;
|
||||
@@ -234,6 +245,7 @@ class _SettingsScreenState extends State<SettingsScreen> {
|
||||
void initState() {
|
||||
super.initState();
|
||||
_selectedSeedColor = widget.currentSeedColor;
|
||||
_selectedThemeMode = widget.currentThemeMode;
|
||||
_loadEndpoint();
|
||||
}
|
||||
|
||||
@@ -244,6 +256,26 @@ class _SettingsScreenState extends State<SettingsScreen> {
|
||||
widget.currentSeedColor != _selectedSeedColor) {
|
||||
_selectedSeedColor = widget.currentSeedColor;
|
||||
}
|
||||
if (oldWidget.currentThemeMode != widget.currentThemeMode) {
|
||||
_selectedThemeMode = widget.currentThemeMode;
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _selectThemeMode(ThemeMode mode) async {
|
||||
if (_selectedThemeMode == mode) return;
|
||||
setState(() {
|
||||
_selectedThemeMode = mode;
|
||||
});
|
||||
try {
|
||||
await widget.onThemeModeSelected(mode);
|
||||
} catch (e) {
|
||||
if (!mounted) return;
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text('No se pudo guardar la preferencia de tema: $e'),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _loadEndpoint() async {
|
||||
@@ -307,10 +339,12 @@ class _SettingsScreenState extends State<SettingsScreen> {
|
||||
required bool isLoading,
|
||||
required IconData icon,
|
||||
}) {
|
||||
final AppPalette palette = Theme.of(context).extension<AppPalette>()!;
|
||||
|
||||
return ElevatedButton.icon(
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: AppColors.destructiveAccent,
|
||||
foregroundColor: AppColors.textPrimary,
|
||||
backgroundColor: palette.destructiveAccent,
|
||||
foregroundColor: palette.textPrimary,
|
||||
textStyle: const TextStyle(fontWeight: FontWeight.w600),
|
||||
),
|
||||
onPressed: onPressed,
|
||||
@@ -326,11 +360,12 @@ class _SettingsScreenState extends State<SettingsScreen> {
|
||||
}
|
||||
|
||||
Widget _buildThemeColorButton(Color color) {
|
||||
final AppPalette palette = Theme.of(context).extension<AppPalette>()!;
|
||||
final bool isSelected = _selectedSeedColor.value == color.value;
|
||||
final Color foregroundColor =
|
||||
ThemeData.estimateBrightnessForColor(color) == Brightness.dark
|
||||
? AppColors.textPrimary
|
||||
: AppColors.textOnAccent;
|
||||
? palette.textPrimary
|
||||
: palette.textOnAccent;
|
||||
|
||||
return Semantics(
|
||||
button: true,
|
||||
@@ -349,14 +384,12 @@ class _SettingsScreenState extends State<SettingsScreen> {
|
||||
color: color,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
border: Border.all(
|
||||
color: isSelected
|
||||
? AppColors.textPrimary
|
||||
: AppColors.textDisabled,
|
||||
color: isSelected ? palette.textPrimary : palette.textSecondary,
|
||||
width: isSelected ? 2.5 : 1.2,
|
||||
),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: AppColors.shadowSoft,
|
||||
color: palette.shadowSoft,
|
||||
blurRadius: 8,
|
||||
offset: const Offset(0, 3),
|
||||
),
|
||||
@@ -458,9 +491,11 @@ class _SettingsScreenState extends State<SettingsScreen> {
|
||||
}
|
||||
|
||||
Widget build(BuildContext context) {
|
||||
final AppPalette palette = Theme.of(context).extension<AppPalette>()!;
|
||||
|
||||
return Scaffold(
|
||||
body: Container(
|
||||
decoration: const BoxDecoration(gradient: AppColors.backdropGradient),
|
||||
decoration: BoxDecoration(gradient: palette.backdropGradient),
|
||||
child: SafeArea(
|
||||
child: Column(
|
||||
children: [
|
||||
@@ -472,199 +507,233 @@ class _SettingsScreenState extends State<SettingsScreen> {
|
||||
titleText: 'Configuración',
|
||||
),
|
||||
Expanded(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
const Expanded(child: Text('Borrar datos locales:')),
|
||||
_buildDestructiveButton(
|
||||
label: 'Borrar',
|
||||
onPressed: (_isBusy || _isServerDeleting)
|
||||
? null
|
||||
: _confirmAndDeleteAll,
|
||||
isLoading: _isBusy,
|
||||
icon: Icons.delete_forever,
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Row(
|
||||
children: [
|
||||
const Expanded(
|
||||
child: Text('Borrar info del servidor:'),
|
||||
),
|
||||
_buildDestructiveButton(
|
||||
label: 'Borrar',
|
||||
onPressed:
|
||||
(_isBusy || _isSyncing || _isServerDeleting)
|
||||
? null
|
||||
: _confirmAndDeleteServerData,
|
||||
isLoading: _isServerDeleting,
|
||||
icon: Icons.cloud_off,
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Row(
|
||||
children: [
|
||||
const Expanded(
|
||||
child: Text('Forzar sincronizacion total:'),
|
||||
),
|
||||
ElevatedButton.icon(
|
||||
onPressed:
|
||||
(_isBusy || _isSyncing || _isServerDeleting)
|
||||
? null
|
||||
: _forceSync,
|
||||
icon: _isSyncing
|
||||
? const SizedBox(
|
||||
width: 16,
|
||||
height: 16,
|
||||
child: CircularProgressIndicator(
|
||||
strokeWidth: 2,
|
||||
),
|
||||
)
|
||||
: const Icon(Icons.sync),
|
||||
label: const Text('Sincronizar'),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
const Text('Color del esquema'),
|
||||
const SizedBox(height: 8),
|
||||
Wrap(
|
||||
spacing: 12,
|
||||
runSpacing: 12,
|
||||
children: [
|
||||
for (final Color color in _themeColorOptions)
|
||||
_buildThemeColorButton(color),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
const Text(
|
||||
'API endpoint (ej: https://notas-api.lpncnd.es/api)',
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
_buildResponsiveInputActionsRow(
|
||||
input: _endpointLoading
|
||||
? const SizedBox(
|
||||
height: 48,
|
||||
child: Center(
|
||||
child: CircularProgressIndicator(),
|
||||
),
|
||||
)
|
||||
: TextField(
|
||||
controller: _endpointController,
|
||||
style: const TextStyle(
|
||||
color: AppColors.textPrimary,
|
||||
),
|
||||
keyboardType: TextInputType.url,
|
||||
decoration: InputDecoration(
|
||||
labelText: 'API endpoint',
|
||||
labelStyle: const TextStyle(
|
||||
color: AppColors.textSecondary,
|
||||
),
|
||||
filled: true,
|
||||
fillColor: AppColors.fill,
|
||||
border: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
borderSide: const BorderSide(
|
||||
color: AppColors.border,
|
||||
),
|
||||
),
|
||||
enabledBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
borderSide: const BorderSide(
|
||||
color: AppColors.border,
|
||||
),
|
||||
),
|
||||
focusedBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
borderSide: const BorderSide(
|
||||
color: AppColors.accent,
|
||||
width: 1.2,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
actions: [
|
||||
ElevatedButton(
|
||||
onPressed: _endpointLoading ? null : _saveEndpoint,
|
||||
child: const Text('Guardar'),
|
||||
),
|
||||
OutlinedButton(
|
||||
onPressed: _endpointLoading ? null : _resetEndpoint,
|
||||
child: const Text('Restaurar'),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
const Text('Clave de cifrado local'),
|
||||
const SizedBox(height: 8),
|
||||
_buildResponsiveInputActionsRow(
|
||||
input: TextField(
|
||||
controller: _encryptionKeyController,
|
||||
readOnly: true,
|
||||
obscureText: !_encryptionKeyVisible,
|
||||
enableSuggestions: false,
|
||||
autocorrect: false,
|
||||
style: const TextStyle(color: AppColors.textPrimary),
|
||||
decoration: InputDecoration(
|
||||
labelText: _encryptionKeyVisible
|
||||
? 'Clave de cifrado'
|
||||
: 'Oculta hasta pulsar mostrar',
|
||||
labelStyle: const TextStyle(
|
||||
color: AppColors.textSecondary,
|
||||
child: SingleChildScrollView(
|
||||
physics: const BouncingScrollPhysics(),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
const Expanded(
|
||||
child: Text('Borrar datos locales:'),
|
||||
),
|
||||
filled: true,
|
||||
fillColor: AppColors.fill,
|
||||
border: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
borderSide: const BorderSide(
|
||||
color: AppColors.border,
|
||||
),
|
||||
_buildDestructiveButton(
|
||||
label: 'Borrar',
|
||||
onPressed: (_isBusy || _isServerDeleting)
|
||||
? null
|
||||
: _confirmAndDeleteAll,
|
||||
isLoading: _isBusy,
|
||||
icon: Icons.delete_forever,
|
||||
),
|
||||
enabledBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
borderSide: const BorderSide(
|
||||
color: AppColors.border,
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Row(
|
||||
children: [
|
||||
const Expanded(
|
||||
child: Text('Borrar info del servidor:'),
|
||||
),
|
||||
focusedBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
borderSide: const BorderSide(
|
||||
color: AppColors.accent,
|
||||
width: 1.2,
|
||||
),
|
||||
_buildDestructiveButton(
|
||||
label: 'Borrar',
|
||||
onPressed:
|
||||
(_isBusy || _isSyncing || _isServerDeleting)
|
||||
? null
|
||||
: _confirmAndDeleteServerData,
|
||||
isLoading: _isServerDeleting,
|
||||
icon: Icons.cloud_off,
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Row(
|
||||
children: [
|
||||
const Expanded(
|
||||
child: Text('Forzar sincronizacion total:'),
|
||||
),
|
||||
ElevatedButton.icon(
|
||||
onPressed:
|
||||
(_isBusy || _isSyncing || _isServerDeleting)
|
||||
? null
|
||||
: _forceSync,
|
||||
icon: _isSyncing
|
||||
? const SizedBox(
|
||||
width: 16,
|
||||
height: 16,
|
||||
child: CircularProgressIndicator(
|
||||
strokeWidth: 2,
|
||||
),
|
||||
)
|
||||
: const Icon(Icons.sync),
|
||||
label: const Text('Sincronizar'),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
const Text('Apariencia'),
|
||||
const SizedBox(height: 8),
|
||||
Column(
|
||||
children: [
|
||||
RadioListTile<ThemeMode>(
|
||||
title: const Text('Seguir modo del sistema'),
|
||||
value: ThemeMode.system,
|
||||
groupValue: _selectedThemeMode,
|
||||
onChanged: (ThemeMode? v) =>
|
||||
_selectThemeMode(ThemeMode.system),
|
||||
),
|
||||
RadioListTile<ThemeMode>(
|
||||
title: const Text('Modo claro'),
|
||||
value: ThemeMode.light,
|
||||
groupValue: _selectedThemeMode,
|
||||
onChanged: (ThemeMode? v) =>
|
||||
_selectThemeMode(ThemeMode.light),
|
||||
),
|
||||
RadioListTile<ThemeMode>(
|
||||
title: const Text('Modo oscuro'),
|
||||
value: ThemeMode.dark,
|
||||
groupValue: _selectedThemeMode,
|
||||
onChanged: (ThemeMode? v) =>
|
||||
_selectThemeMode(ThemeMode.dark),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
const Text('Color del esquema'),
|
||||
const SizedBox(height: 8),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 4),
|
||||
child: Wrap(
|
||||
spacing: 12,
|
||||
runSpacing: 12,
|
||||
children: [
|
||||
for (final Color color in _themeColorOptions)
|
||||
_buildThemeColorButton(color),
|
||||
],
|
||||
),
|
||||
),
|
||||
actions: [
|
||||
ElevatedButton(
|
||||
onPressed: _encryptionKeyLoading
|
||||
? null
|
||||
: _loadEncryptionKey,
|
||||
child: _encryptionKeyLoading
|
||||
? const SizedBox(
|
||||
width: 16,
|
||||
height: 16,
|
||||
child: CircularProgressIndicator(
|
||||
strokeWidth: 2,
|
||||
const SizedBox(height: 24),
|
||||
const Text(
|
||||
'API endpoint (ej: https://notas-api.lpncnd.es/api)',
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
_buildResponsiveInputActionsRow(
|
||||
input: _endpointLoading
|
||||
? const SizedBox(
|
||||
height: 48,
|
||||
child: Center(
|
||||
child: CircularProgressIndicator(),
|
||||
),
|
||||
)
|
||||
: TextField(
|
||||
controller: _endpointController,
|
||||
style: TextStyle(color: palette.textPrimary),
|
||||
keyboardType: TextInputType.url,
|
||||
decoration: InputDecoration(
|
||||
labelText: 'API endpoint',
|
||||
labelStyle: TextStyle(
|
||||
color: palette.textSecondary,
|
||||
),
|
||||
)
|
||||
: const Text('Mostrar'),
|
||||
filled: true,
|
||||
fillColor: palette.fill,
|
||||
border: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
borderSide: BorderSide(
|
||||
color: palette.border,
|
||||
),
|
||||
),
|
||||
enabledBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
borderSide: BorderSide(
|
||||
color: palette.border,
|
||||
),
|
||||
),
|
||||
focusedBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
borderSide: BorderSide(
|
||||
color: palette.accent,
|
||||
width: 1.2,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
actions: [
|
||||
ElevatedButton(
|
||||
onPressed: _endpointLoading
|
||||
? null
|
||||
: _saveEndpoint,
|
||||
child: const Text('Guardar'),
|
||||
),
|
||||
OutlinedButton(
|
||||
onPressed: _endpointLoading
|
||||
? null
|
||||
: _resetEndpoint,
|
||||
child: const Text('Restaurar'),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
const Text('Clave de cifrado local'),
|
||||
const SizedBox(height: 8),
|
||||
_buildResponsiveInputActionsRow(
|
||||
input: TextField(
|
||||
controller: _encryptionKeyController,
|
||||
readOnly: true,
|
||||
obscureText: !_encryptionKeyVisible,
|
||||
enableSuggestions: false,
|
||||
autocorrect: false,
|
||||
style: TextStyle(color: palette.textPrimary),
|
||||
decoration: InputDecoration(
|
||||
labelText: _encryptionKeyVisible
|
||||
? 'Clave de cifrado'
|
||||
: 'Oculta hasta pulsar mostrar',
|
||||
labelStyle: TextStyle(
|
||||
color: palette.textSecondary,
|
||||
),
|
||||
filled: true,
|
||||
fillColor: palette.fill,
|
||||
border: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
borderSide: BorderSide(color: palette.border),
|
||||
),
|
||||
enabledBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
borderSide: BorderSide(color: palette.border),
|
||||
),
|
||||
focusedBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
borderSide: BorderSide(
|
||||
color: palette.accent,
|
||||
width: 1.2,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
OutlinedButton(
|
||||
onPressed: _encryptionKeyVisible
|
||||
? _hideEncryptionKey
|
||||
: null,
|
||||
child: const Text('Ocultar'),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
actions: [
|
||||
ElevatedButton(
|
||||
onPressed: _encryptionKeyLoading
|
||||
? null
|
||||
: _loadEncryptionKey,
|
||||
child: _encryptionKeyLoading
|
||||
? const SizedBox(
|
||||
width: 16,
|
||||
height: 16,
|
||||
child: CircularProgressIndicator(
|
||||
strokeWidth: 2,
|
||||
),
|
||||
)
|
||||
: const Text('Mostrar'),
|
||||
),
|
||||
OutlinedButton(
|
||||
onPressed: _encryptionKeyVisible
|
||||
? _hideEncryptionKey
|
||||
: null,
|
||||
child: const Text('Ocultar'),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:notas/data/api_client.dart';
|
||||
import 'package:notas/theme/app_colors.dart';
|
||||
import 'package:notas/theme/app_palette.dart';
|
||||
|
||||
class VaultAccessScreen extends StatefulWidget {
|
||||
const VaultAccessScreen({
|
||||
@@ -75,9 +75,11 @@ class _VaultAccessScreenState extends State<VaultAccessScreen> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final AppPalette palette = Theme.of(context).extension<AppPalette>()!;
|
||||
|
||||
return Scaffold(
|
||||
body: Container(
|
||||
decoration: const BoxDecoration(gradient: AppColors.backdropGradient),
|
||||
decoration: BoxDecoration(gradient: palette.backdropGradient),
|
||||
child: SafeArea(
|
||||
child: Column(
|
||||
children: [
|
||||
@@ -90,12 +92,12 @@ class _VaultAccessScreenState extends State<VaultAccessScreen> {
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(24),
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.surface,
|
||||
color: palette.cardBackground,
|
||||
borderRadius: BorderRadius.circular(24),
|
||||
border: Border.all(color: AppColors.borderMuted),
|
||||
border: Border.all(color: palette.border),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: AppColors.shadow,
|
||||
color: palette.shadowSoft,
|
||||
blurRadius: 30,
|
||||
offset: const Offset(0, 18),
|
||||
),
|
||||
@@ -107,7 +109,7 @@ class _VaultAccessScreenState extends State<VaultAccessScreen> {
|
||||
children: [
|
||||
const Icon(
|
||||
Icons.lock_outline,
|
||||
color: AppColors.accent,
|
||||
color: Colors.white,
|
||||
size: 44,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
@@ -115,7 +117,7 @@ class _VaultAccessScreenState extends State<VaultAccessScreen> {
|
||||
'Mis Notas',
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
color: AppColors.textPrimary,
|
||||
color: Colors.white,
|
||||
fontSize: 30,
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
@@ -125,7 +127,7 @@ class _VaultAccessScreenState extends State<VaultAccessScreen> {
|
||||
'Tus notas se guardan cifradas en este dispositivo. La cuenta y la sincronización vendrán después.',
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
color: AppColors.textSecondary,
|
||||
color: palette.textSecondary,
|
||||
height: 1.4,
|
||||
),
|
||||
),
|
||||
@@ -141,32 +143,30 @@ class _VaultAccessScreenState extends State<VaultAccessScreen> {
|
||||
controller: _endpointController,
|
||||
enabled: !widget.isBusy,
|
||||
keyboardType: TextInputType.url,
|
||||
style: const TextStyle(
|
||||
color: AppColors.textPrimary,
|
||||
),
|
||||
style: const TextStyle(color: Colors.white),
|
||||
decoration: InputDecoration(
|
||||
labelText: 'API endpoint',
|
||||
labelStyle: const TextStyle(
|
||||
color: AppColors.textSecondary,
|
||||
labelStyle: TextStyle(
|
||||
color: palette.textSecondary,
|
||||
),
|
||||
filled: true,
|
||||
fillColor: AppColors.fill,
|
||||
fillColor: palette.fill,
|
||||
border: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
borderSide: const BorderSide(
|
||||
color: AppColors.border,
|
||||
borderSide: BorderSide(
|
||||
color: palette.border,
|
||||
),
|
||||
),
|
||||
enabledBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
borderSide: const BorderSide(
|
||||
color: AppColors.border,
|
||||
borderSide: BorderSide(
|
||||
color: palette.border,
|
||||
),
|
||||
),
|
||||
focusedBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
borderSide: const BorderSide(
|
||||
color: AppColors.accent,
|
||||
borderSide: BorderSide(
|
||||
color: palette.accent,
|
||||
width: 1.2,
|
||||
),
|
||||
),
|
||||
@@ -177,32 +177,26 @@ class _VaultAccessScreenState extends State<VaultAccessScreen> {
|
||||
controller: _emailController,
|
||||
enabled: !widget.isBusy,
|
||||
keyboardType: TextInputType.text,
|
||||
style: const TextStyle(
|
||||
color: AppColors.textPrimary,
|
||||
),
|
||||
style: const TextStyle(color: Colors.white),
|
||||
decoration: InputDecoration(
|
||||
labelText: 'Usuario',
|
||||
labelStyle: const TextStyle(
|
||||
color: AppColors.textSecondary,
|
||||
labelStyle: TextStyle(
|
||||
color: palette.textSecondary,
|
||||
),
|
||||
filled: true,
|
||||
fillColor: AppColors.fill,
|
||||
fillColor: palette.fill,
|
||||
border: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
borderSide: const BorderSide(
|
||||
color: AppColors.border,
|
||||
),
|
||||
borderSide: BorderSide(color: palette.border),
|
||||
),
|
||||
enabledBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
borderSide: const BorderSide(
|
||||
color: AppColors.border,
|
||||
),
|
||||
borderSide: BorderSide(color: palette.border),
|
||||
),
|
||||
focusedBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
borderSide: const BorderSide(
|
||||
color: AppColors.accent,
|
||||
borderSide: BorderSide(
|
||||
color: palette.accent,
|
||||
width: 1.2,
|
||||
),
|
||||
),
|
||||
@@ -213,32 +207,26 @@ class _VaultAccessScreenState extends State<VaultAccessScreen> {
|
||||
controller: _passwordController,
|
||||
enabled: !widget.isBusy,
|
||||
obscureText: true,
|
||||
style: const TextStyle(
|
||||
color: AppColors.textPrimary,
|
||||
),
|
||||
style: const TextStyle(color: Colors.white),
|
||||
decoration: InputDecoration(
|
||||
labelText: 'Contraseña',
|
||||
labelStyle: const TextStyle(
|
||||
color: AppColors.textSecondary,
|
||||
labelStyle: TextStyle(
|
||||
color: palette.textSecondary,
|
||||
),
|
||||
filled: true,
|
||||
fillColor: AppColors.fill,
|
||||
fillColor: palette.fill,
|
||||
border: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
borderSide: const BorderSide(
|
||||
color: AppColors.border,
|
||||
),
|
||||
borderSide: BorderSide(color: palette.border),
|
||||
),
|
||||
enabledBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
borderSide: const BorderSide(
|
||||
color: AppColors.border,
|
||||
),
|
||||
borderSide: BorderSide(color: palette.border),
|
||||
),
|
||||
focusedBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
borderSide: const BorderSide(
|
||||
color: AppColors.accent,
|
||||
borderSide: BorderSide(
|
||||
color: palette.accent,
|
||||
width: 1.2,
|
||||
),
|
||||
),
|
||||
@@ -271,10 +259,8 @@ class _VaultAccessScreenState extends State<VaultAccessScreen> {
|
||||
padding: const EdgeInsets.symmetric(
|
||||
vertical: 14,
|
||||
),
|
||||
side: const BorderSide(
|
||||
color: AppColors.textDisabled,
|
||||
),
|
||||
foregroundColor: AppColors.textPrimary,
|
||||
side: BorderSide(color: palette.border),
|
||||
foregroundColor: palette.textPrimary,
|
||||
),
|
||||
child: const Text('Iniciar sesión'),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user