enhanced the restore button logic

This commit is contained in:
Vaibhav Surve 2025-10-10 20:01:16 +05:30
parent 16e2f5a4f3
commit e8acfe10d9

View File

@ -197,13 +197,7 @@ class NotesView extends StatelessWidget {
)
: null;
return AnimatedOpacity(
duration: const Duration(milliseconds: 200),
opacity: note.isActive ? 1.0 : 0.6,
child: IgnorePointer(
ignoring: !note.isActive,
ignoringSemantics: false,
child: AnimatedContainer(
return AnimatedContainer(
duration: const Duration(milliseconds: 250),
padding: MySpacing.xy(12, 12),
decoration: BoxDecoration(
@ -232,14 +226,27 @@ class NotesView extends StatelessWidget {
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
/// Header
Row(
// 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,
children: [
Row(
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
Avatar(
firstName: initials,
lastName: '',
size: 40),
size: 40,
backgroundColor: note.isActive
? null
: Colors.grey.shade400,
),
MySpacing.width(12),
Expanded(
child: Column(
@ -250,27 +257,30 @@ class NotesView extends StatelessWidget {
"${note.contactName} (${note.organizationName})",
fontWeight: 600,
overflow: TextOverflow.ellipsis,
color: Colors.indigo[800],
color: note.isActive
? Colors.indigo[800]
: Colors.grey,
),
MyText.bodySmall(
"by ${note.createdBy.firstName}$createdDate, $createdTime",
color: Colors.grey[600],
color: note.isActive
? 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 delta =
quillCtrl.document.toDelta();
final htmlOutput =
_convertDeltaToHtml(delta);
final updated =
@ -287,26 +297,29 @@ class NotesView extends StatelessWidget {
margin: html.Margins.zero,
padding: html.HtmlPaddings.zero,
fontSize: html.FontSize.medium,
color: Colors.black87,
color: note.isActive
? Colors.black87
: Colors.grey,
),
},
),
],
),
),
),
// Action buttons (always fully visible)
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
if (note.isActive) ...[
Row(
children: [
IconButton(
icon: Icon(
isEditing
? Icons.close
: Icons.edit,
isEditing ? Icons.close : Icons.edit,
color: Colors.indigo,
size: 20,
),
padding: EdgeInsets.all(
2),
padding: EdgeInsets.all(2),
constraints: const BoxConstraints(),
onPressed: () {
controller.editingNoteId.value =
@ -319,7 +332,6 @@ class NotesView extends StatelessWidget {
color: Colors.redAccent,
size: 20,
),
padding: EdgeInsets.all(2),
constraints: const BoxConstraints(),
onPressed: () async {
await Get.dialog(
@ -331,8 +343,8 @@ class NotesView extends StatelessWidget {
confirmColor: Colors.redAccent,
icon: Icons.delete_forever,
onConfirm: () async {
await controller
.restoreOrDeleteNote(note,
await controller.restoreOrDeleteNote(
note,
restore: false);
},
),
@ -341,8 +353,6 @@ class NotesView extends StatelessWidget {
},
),
],
),
],
if (!note.isActive)
IconButton(
icon: const Icon(
@ -351,7 +361,6 @@ class NotesView extends StatelessWidget {
size: 22,
),
tooltip: "Restore",
padding: EdgeInsets.zero,
onPressed: () async {
await Get.dialog(
ConfirmDialog(
@ -362,8 +371,8 @@ class NotesView extends StatelessWidget {
confirmColor: Colors.green,
icon: Icons.restore,
onConfirm: () async {
await controller
.restoreOrDeleteNote(note,
await controller.restoreOrDeleteNote(
note,
restore: true);
},
),
@ -375,8 +384,6 @@ class NotesView extends StatelessWidget {
),
],
),
),
),
);
});
},