refactor: Improve code readability by formatting and simplifying widget structures
This commit is contained in:
+81
-77
@@ -13,6 +13,7 @@ class NoteCard extends StatelessWidget {
|
||||
this.onTap,
|
||||
this.onDelete,
|
||||
this.onChangeCategory,
|
||||
this.showSelectionBorder = true,
|
||||
});
|
||||
|
||||
final Note note;
|
||||
@@ -21,93 +22,96 @@ class NoteCard extends StatelessWidget {
|
||||
final VoidCallback? onTap;
|
||||
final VoidCallback? onDelete;
|
||||
final ValueChanged<BuildContext>? onChangeCategory;
|
||||
final bool showSelectionBorder;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final AppPalette palette = Theme.of(context).extension<AppPalette>()!;
|
||||
final String bodyText = noteBodyToPlainText(note.body).trim();
|
||||
|
||||
return Material(
|
||||
color: Colors.transparent, // 1. Fondo completamente transparente
|
||||
shape: BorderDirectional(
|
||||
start: BorderSide(
|
||||
color: isSelected ? palette.accent : Colors.transparent,
|
||||
width: isSelected ? 1.6 : 1.0,
|
||||
),
|
||||
),
|
||||
child: InkWell(
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
onTap: onTap,
|
||||
hoverColor: Colors.transparent, // 2. Desactiva el efecto hover (pasar el ratón)
|
||||
splashColor: Colors.transparent, // 3. Desactiva el efecto de onda al hacer clic
|
||||
highlightColor: Colors.transparent, // Desactiva el brillo al mantener pulsado
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 12),
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
note.title.isEmpty ? 'Sin título' : note.title,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(
|
||||
color: palette.textPrimary,
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
return Material(
|
||||
color: Colors.transparent, // 1. Fondo completamente transparente
|
||||
shape: BorderDirectional(
|
||||
start: BorderSide(
|
||||
color: (isSelected && showSelectionBorder)
|
||||
? palette.accent
|
||||
: Colors.transparent,
|
||||
width: isSelected ? 1.6 : 1.0,
|
||||
),
|
||||
),
|
||||
child: InkWell(
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
onTap: onTap,
|
||||
hoverColor:
|
||||
Colors.transparent, // 2. Desactiva el efecto hover (pasar el ratón)
|
||||
splashColor:
|
||||
Colors.transparent, // 3. Desactiva el efecto de onda al hacer clic
|
||||
highlightColor:
|
||||
Colors.transparent, // Desactiva el brillo al mantener pulsado
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 12),
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
note.title.isEmpty ? 'Sin título' : note.title,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(
|
||||
color: palette.textPrimary,
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 6),
|
||||
Text(
|
||||
bodyText.isEmpty ? ' ' : bodyText,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(
|
||||
color: palette.textSecondary,
|
||||
fontSize: 13,
|
||||
height: 1.2,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 6),
|
||||
Text(
|
||||
bodyText.isEmpty ? ' ' : bodyText,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(
|
||||
color: palette.textSecondary,
|
||||
fontSize: 13,
|
||||
height: 1.2,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
PopupMenuButton<String>(
|
||||
tooltip: 'Más opciones',
|
||||
icon: Icon(
|
||||
Icons.more_vert,
|
||||
color: palette.textSecondary,
|
||||
),
|
||||
onOpened: () {},
|
||||
onSelected: (String value) {
|
||||
switch (value) {
|
||||
case 'delete':
|
||||
onDelete?.call();
|
||||
return;
|
||||
case 'category':
|
||||
onChangeCategory?.call(context);
|
||||
return;
|
||||
}
|
||||
},
|
||||
itemBuilder: (BuildContext context) => <PopupMenuEntry<String>>[
|
||||
const PopupMenuItem<String>(
|
||||
value: 'delete',
|
||||
child: Text('Eliminar nota'),
|
||||
),
|
||||
const PopupMenuItem<String>(
|
||||
value: 'category',
|
||||
child: Text('Cambiar categoría'),
|
||||
const SizedBox(width: 8),
|
||||
PopupMenuButton<String>(
|
||||
tooltip: 'Más opciones',
|
||||
icon: Icon(Icons.more_vert, color: palette.textSecondary),
|
||||
onOpened: () {},
|
||||
onSelected: (String value) {
|
||||
switch (value) {
|
||||
case 'delete':
|
||||
onDelete?.call();
|
||||
return;
|
||||
case 'category':
|
||||
onChangeCategory?.call(context);
|
||||
return;
|
||||
}
|
||||
},
|
||||
itemBuilder: (BuildContext context) => <PopupMenuEntry<String>>[
|
||||
const PopupMenuItem<String>(
|
||||
value: 'delete',
|
||||
child: Text('Eliminar nota'),
|
||||
),
|
||||
const PopupMenuItem<String>(
|
||||
value: 'category',
|
||||
child: Text('Cambiar categoría'),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user