enhanced the restore button logic
This commit is contained in:
parent
16e2f5a4f3
commit
e8acfe10d9
@ -197,185 +197,192 @@ class NotesView extends StatelessWidget {
|
|||||||
)
|
)
|
||||||
: null;
|
: null;
|
||||||
|
|
||||||
return AnimatedOpacity(
|
return AnimatedContainer(
|
||||||
duration: const Duration(milliseconds: 200),
|
duration: const Duration(milliseconds: 250),
|
||||||
opacity: note.isActive ? 1.0 : 0.6,
|
padding: MySpacing.xy(12, 12),
|
||||||
child: IgnorePointer(
|
decoration: BoxDecoration(
|
||||||
ignoring: !note.isActive,
|
color: isEditing
|
||||||
ignoringSemantics: false,
|
? Colors.indigo[50]
|
||||||
child: AnimatedContainer(
|
: note.isActive
|
||||||
duration: const Duration(milliseconds: 250),
|
? Colors.white
|
||||||
padding: MySpacing.xy(12, 12),
|
: Colors.grey.shade100,
|
||||||
decoration: BoxDecoration(
|
border: Border.all(
|
||||||
color: isEditing
|
color: note.isActive
|
||||||
? Colors.indigo[50]
|
? (isEditing
|
||||||
: note.isActive
|
? Colors.indigo
|
||||||
? Colors.white
|
: Colors.grey.shade300)
|
||||||
: Colors.grey.shade100,
|
: Colors.grey.shade400,
|
||||||
border: Border.all(
|
width: 1.1,
|
||||||
color: note.isActive
|
),
|
||||||
? (isEditing
|
borderRadius: BorderRadius.circular(5),
|
||||||
? Colors.indigo
|
boxShadow: const [
|
||||||
: Colors.grey.shade300)
|
BoxShadow(
|
||||||
: Colors.grey.shade400,
|
color: Colors.black12,
|
||||||
width: 1.1,
|
blurRadius: 4,
|
||||||
),
|
offset: Offset(0, 2),
|
||||||
borderRadius: BorderRadius.circular(5),
|
|
||||||
boxShadow: const [
|
|
||||||
BoxShadow(
|
|
||||||
color: Colors.black12,
|
|
||||||
blurRadius: 4,
|
|
||||||
offset: Offset(0, 2),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
child: Column(
|
],
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
),
|
||||||
children: [
|
child: Column(
|
||||||
/// Header
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
Row(
|
children: [
|
||||||
|
// Header & Note content (fade them if inactive)
|
||||||
|
AnimatedOpacity(
|
||||||
|
duration: const Duration(milliseconds: 200),
|
||||||
|
opacity: note.isActive ? 1.0 : 0.6,
|
||||||
|
child: IgnorePointer(
|
||||||
|
ignoring: !note.isActive,
|
||||||
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Avatar(
|
Row(
|
||||||
firstName: initials,
|
crossAxisAlignment:
|
||||||
lastName: '',
|
CrossAxisAlignment.start,
|
||||||
size: 40),
|
children: [
|
||||||
MySpacing.width(12),
|
Avatar(
|
||||||
Expanded(
|
firstName: initials,
|
||||||
child: Column(
|
lastName: '',
|
||||||
crossAxisAlignment:
|
size: 40,
|
||||||
CrossAxisAlignment.start,
|
backgroundColor: note.isActive
|
||||||
children: [
|
? null
|
||||||
MyText.titleSmall(
|
: Colors.grey.shade400,
|
||||||
"${note.contactName} (${note.organizationName})",
|
|
||||||
fontWeight: 600,
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
color: Colors.indigo[800],
|
|
||||||
),
|
|
||||||
MyText.bodySmall(
|
|
||||||
"by ${note.createdBy.firstName} • $createdDate, $createdTime",
|
|
||||||
color: Colors.grey[600],
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
|
|
||||||
MySpacing.height(12),
|
|
||||||
|
|
||||||
if (isEditing && quillController != null)
|
|
||||||
CommentEditorCard(
|
|
||||||
controller: quillController,
|
|
||||||
onCancel: () =>
|
|
||||||
controller.editingNoteId.value = null,
|
|
||||||
onSave: (quillCtrl) async {
|
|
||||||
final delta = quillCtrl.document.toDelta();
|
|
||||||
final htmlOutput =
|
|
||||||
_convertDeltaToHtml(delta);
|
|
||||||
final updated =
|
|
||||||
note.copyWith(note: htmlOutput);
|
|
||||||
await controller.updateNote(updated);
|
|
||||||
controller.editingNoteId.value = null;
|
|
||||||
},
|
|
||||||
)
|
|
||||||
else
|
|
||||||
html.Html(
|
|
||||||
data: note.note,
|
|
||||||
style: {
|
|
||||||
"body": html.Style(
|
|
||||||
margin: html.Margins.zero,
|
|
||||||
padding: html.HtmlPaddings.zero,
|
|
||||||
fontSize: html.FontSize.medium,
|
|
||||||
color: Colors.black87,
|
|
||||||
),
|
|
||||||
},
|
|
||||||
),
|
|
||||||
Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.end,
|
|
||||||
children: [
|
|
||||||
if (note.isActive) ...[
|
|
||||||
Row(
|
|
||||||
children: [
|
|
||||||
IconButton(
|
|
||||||
icon: Icon(
|
|
||||||
isEditing
|
|
||||||
? Icons.close
|
|
||||||
: Icons.edit,
|
|
||||||
color: Colors.indigo,
|
|
||||||
size: 20,
|
|
||||||
),
|
|
||||||
padding: EdgeInsets.all(
|
|
||||||
2),
|
|
||||||
constraints: const BoxConstraints(),
|
|
||||||
onPressed: () {
|
|
||||||
controller.editingNoteId.value =
|
|
||||||
isEditing ? null : note.id;
|
|
||||||
},
|
|
||||||
),
|
|
||||||
IconButton(
|
|
||||||
icon: const Icon(
|
|
||||||
Icons.delete_outline,
|
|
||||||
color: Colors.redAccent,
|
|
||||||
size: 20,
|
|
||||||
),
|
|
||||||
padding: EdgeInsets.all(2),
|
|
||||||
constraints: const BoxConstraints(),
|
|
||||||
onPressed: () async {
|
|
||||||
await Get.dialog(
|
|
||||||
ConfirmDialog(
|
|
||||||
title: "Delete Note",
|
|
||||||
message:
|
|
||||||
"Are you sure you want to delete this note?",
|
|
||||||
confirmText: "Delete",
|
|
||||||
confirmColor: Colors.redAccent,
|
|
||||||
icon: Icons.delete_forever,
|
|
||||||
onConfirm: () async {
|
|
||||||
await controller
|
|
||||||
.restoreOrDeleteNote(note,
|
|
||||||
restore: false);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
barrierDismissible: false,
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
],
|
|
||||||
if (!note.isActive)
|
|
||||||
IconButton(
|
|
||||||
icon: const Icon(
|
|
||||||
Icons.restore,
|
|
||||||
color: Colors.green,
|
|
||||||
size: 22,
|
|
||||||
),
|
),
|
||||||
tooltip: "Restore",
|
MySpacing.width(12),
|
||||||
padding: EdgeInsets.zero,
|
Expanded(
|
||||||
onPressed: () async {
|
child: Column(
|
||||||
await Get.dialog(
|
crossAxisAlignment:
|
||||||
ConfirmDialog(
|
CrossAxisAlignment.start,
|
||||||
title: "Restore Note",
|
children: [
|
||||||
message:
|
MyText.titleSmall(
|
||||||
"Are you sure you want to restore this note?",
|
"${note.contactName} (${note.organizationName})",
|
||||||
confirmText: "Restore",
|
fontWeight: 600,
|
||||||
confirmColor: Colors.green,
|
overflow: TextOverflow.ellipsis,
|
||||||
icon: Icons.restore,
|
color: note.isActive
|
||||||
onConfirm: () async {
|
? Colors.indigo[800]
|
||||||
await controller
|
: Colors.grey,
|
||||||
.restoreOrDeleteNote(note,
|
),
|
||||||
restore: true);
|
MyText.bodySmall(
|
||||||
},
|
"by ${note.createdBy.firstName} • $createdDate, $createdTime",
|
||||||
),
|
color: note.isActive
|
||||||
barrierDismissible: false,
|
? Colors.grey[600]
|
||||||
);
|
: Colors.grey,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
MySpacing.height(12),
|
||||||
|
if (isEditing && quillController != null)
|
||||||
|
CommentEditorCard(
|
||||||
|
controller: quillController,
|
||||||
|
onCancel: () =>
|
||||||
|
controller.editingNoteId.value = null,
|
||||||
|
onSave: (quillCtrl) async {
|
||||||
|
final delta =
|
||||||
|
quillCtrl.document.toDelta();
|
||||||
|
final htmlOutput =
|
||||||
|
_convertDeltaToHtml(delta);
|
||||||
|
final updated =
|
||||||
|
note.copyWith(note: htmlOutput);
|
||||||
|
await controller.updateNote(updated);
|
||||||
|
controller.editingNoteId.value = null;
|
||||||
|
},
|
||||||
|
)
|
||||||
|
else
|
||||||
|
html.Html(
|
||||||
|
data: note.note,
|
||||||
|
style: {
|
||||||
|
"body": html.Style(
|
||||||
|
margin: html.Margins.zero,
|
||||||
|
padding: html.HtmlPaddings.zero,
|
||||||
|
fontSize: html.FontSize.medium,
|
||||||
|
color: note.isActive
|
||||||
|
? Colors.black87
|
||||||
|
: Colors.grey,
|
||||||
|
),
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
|
||||||
|
// Action buttons (always fully visible)
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.end,
|
||||||
|
children: [
|
||||||
|
if (note.isActive) ...[
|
||||||
|
IconButton(
|
||||||
|
icon: Icon(
|
||||||
|
isEditing ? Icons.close : Icons.edit,
|
||||||
|
color: Colors.indigo,
|
||||||
|
size: 20,
|
||||||
|
),
|
||||||
|
padding: EdgeInsets.all(2),
|
||||||
|
constraints: const BoxConstraints(),
|
||||||
|
onPressed: () {
|
||||||
|
controller.editingNoteId.value =
|
||||||
|
isEditing ? null : note.id;
|
||||||
|
},
|
||||||
|
),
|
||||||
|
IconButton(
|
||||||
|
icon: const Icon(
|
||||||
|
Icons.delete_outline,
|
||||||
|
color: Colors.redAccent,
|
||||||
|
size: 20,
|
||||||
|
),
|
||||||
|
constraints: const BoxConstraints(),
|
||||||
|
onPressed: () async {
|
||||||
|
await Get.dialog(
|
||||||
|
ConfirmDialog(
|
||||||
|
title: "Delete Note",
|
||||||
|
message:
|
||||||
|
"Are you sure you want to delete this note?",
|
||||||
|
confirmText: "Delete",
|
||||||
|
confirmColor: Colors.redAccent,
|
||||||
|
icon: Icons.delete_forever,
|
||||||
|
onConfirm: () async {
|
||||||
|
await controller.restoreOrDeleteNote(
|
||||||
|
note,
|
||||||
|
restore: false);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
barrierDismissible: false,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
if (!note.isActive)
|
||||||
|
IconButton(
|
||||||
|
icon: const Icon(
|
||||||
|
Icons.restore,
|
||||||
|
color: Colors.green,
|
||||||
|
size: 22,
|
||||||
|
),
|
||||||
|
tooltip: "Restore",
|
||||||
|
onPressed: () async {
|
||||||
|
await Get.dialog(
|
||||||
|
ConfirmDialog(
|
||||||
|
title: "Restore Note",
|
||||||
|
message:
|
||||||
|
"Are you sure you want to restore this note?",
|
||||||
|
confirmText: "Restore",
|
||||||
|
confirmColor: Colors.green,
|
||||||
|
icon: Icons.restore,
|
||||||
|
onConfirm: () async {
|
||||||
|
await controller.restoreOrDeleteNote(
|
||||||
|
note,
|
||||||
|
restore: true);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
barrierDismissible: false,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user