mirror of
https://github.com/chenasraf/pantry-flutter.git
synced 2026-05-17 17:28:03 +00:00
feat: add undo action for checking items
This commit is contained in:
@@ -707,6 +707,16 @@ class ChecklistsMessages {
|
||||
/// ```
|
||||
String get moveFailed => """Failed to move item.""";
|
||||
|
||||
/// ```dart
|
||||
/// "Item marked as done"
|
||||
/// ```
|
||||
String get itemMarkedDone => """Item marked as done""";
|
||||
|
||||
/// ```dart
|
||||
/// "Undo"
|
||||
/// ```
|
||||
String get undo => """Undo""";
|
||||
|
||||
/// ```dart
|
||||
/// "New list"
|
||||
/// ```
|
||||
@@ -1574,6 +1584,8 @@ Please complete login in your browser.""",
|
||||
"""checklists.removeItem""": """Remove item""",
|
||||
"""checklists.moveItem""": """Move to list""",
|
||||
"""checklists.moveFailed""": """Failed to move item.""",
|
||||
"""checklists.itemMarkedDone""": """Item marked as done""",
|
||||
"""checklists.undo""": """Undo""",
|
||||
"""checklists.createList""": """New list""",
|
||||
"""checklists.listName""": """List name""",
|
||||
"""checklists.listDescription""": """Description (optional)""",
|
||||
|
||||
@@ -129,6 +129,8 @@ checklists:
|
||||
removeItem: Remove item
|
||||
moveItem: Move to list
|
||||
moveFailed: Failed to move item.
|
||||
itemMarkedDone: Item marked as done
|
||||
undo: Undo
|
||||
createList: New list
|
||||
listName: List name
|
||||
listDescription: Description (optional)
|
||||
|
||||
@@ -713,6 +713,16 @@ class ChecklistsMessagesDe extends ChecklistsMessages {
|
||||
/// ```
|
||||
String get moveFailed => """Eintrag konnte nicht verschoben werden.""";
|
||||
|
||||
/// ```dart
|
||||
/// "Eintrag als erledigt markiert"
|
||||
/// ```
|
||||
String get itemMarkedDone => """Eintrag als erledigt markiert""";
|
||||
|
||||
/// ```dart
|
||||
/// "Rückgängig"
|
||||
/// ```
|
||||
String get undo => """Rückgängig""";
|
||||
|
||||
/// ```dart
|
||||
/// "Neue Liste"
|
||||
/// ```
|
||||
@@ -1595,6 +1605,8 @@ Bitte melde dich in deinem Browser an.""",
|
||||
"""checklists.removeItem""": """Eintrag entfernen""",
|
||||
"""checklists.moveItem""": """In Liste verschieben""",
|
||||
"""checklists.moveFailed""": """Eintrag konnte nicht verschoben werden.""",
|
||||
"""checklists.itemMarkedDone""": """Eintrag als erledigt markiert""",
|
||||
"""checklists.undo""": """Rückgängig""",
|
||||
"""checklists.createList""": """Neue Liste""",
|
||||
"""checklists.listName""": """Listenname""",
|
||||
"""checklists.listDescription""": """Beschreibung (optional)""",
|
||||
|
||||
@@ -129,6 +129,8 @@ checklists:
|
||||
removeItem: Eintrag entfernen
|
||||
moveItem: In Liste verschieben
|
||||
moveFailed: Eintrag konnte nicht verschoben werden.
|
||||
itemMarkedDone: Eintrag als erledigt markiert
|
||||
undo: "Rückgängig"
|
||||
createList: Neue Liste
|
||||
listName: Listenname
|
||||
listDescription: Beschreibung (optional)
|
||||
|
||||
@@ -711,6 +711,16 @@ class ChecklistsMessagesEs extends ChecklistsMessages {
|
||||
/// ```
|
||||
String get moveFailed => """No se pudo mover el artículo.""";
|
||||
|
||||
/// ```dart
|
||||
/// "Artículo marcado como hecho"
|
||||
/// ```
|
||||
String get itemMarkedDone => """Artículo marcado como hecho""";
|
||||
|
||||
/// ```dart
|
||||
/// "Deshacer"
|
||||
/// ```
|
||||
String get undo => """Deshacer""";
|
||||
|
||||
/// ```dart
|
||||
/// "Nueva lista"
|
||||
/// ```
|
||||
@@ -1587,6 +1597,8 @@ Por favor, completa el inicio de sesión en tu navegador.""",
|
||||
"""checklists.removeItem""": """Eliminar artículo""",
|
||||
"""checklists.moveItem""": """Mover a lista""",
|
||||
"""checklists.moveFailed""": """No se pudo mover el artículo.""",
|
||||
"""checklists.itemMarkedDone""": """Artículo marcado como hecho""",
|
||||
"""checklists.undo""": """Deshacer""",
|
||||
"""checklists.createList""": """Nueva lista""",
|
||||
"""checklists.listName""": """Nombre de la lista""",
|
||||
"""checklists.listDescription""": """Descripción (opcional)""",
|
||||
|
||||
@@ -129,6 +129,8 @@ checklists:
|
||||
removeItem: "Eliminar artículo"
|
||||
moveItem: Mover a lista
|
||||
moveFailed: "No se pudo mover el artículo."
|
||||
itemMarkedDone: "Artículo marcado como hecho"
|
||||
undo: Deshacer
|
||||
createList: Nueva lista
|
||||
listName: Nombre de la lista
|
||||
listDescription: "Descripción (opcional)"
|
||||
|
||||
@@ -714,6 +714,16 @@ class ChecklistsMessagesFr extends ChecklistsMessages {
|
||||
/// ```
|
||||
String get moveFailed => """Impossible de déplacer l'article.""";
|
||||
|
||||
/// ```dart
|
||||
/// "Article marqué comme fait"
|
||||
/// ```
|
||||
String get itemMarkedDone => """Article marqué comme fait""";
|
||||
|
||||
/// ```dart
|
||||
/// "Annuler"
|
||||
/// ```
|
||||
String get undo => """Annuler""";
|
||||
|
||||
/// ```dart
|
||||
/// "Nouvelle liste"
|
||||
/// ```
|
||||
@@ -1592,6 +1602,8 @@ Veuillez terminer la connexion dans votre navigateur.""",
|
||||
"""checklists.removeItem""": """Supprimer l'article""",
|
||||
"""checklists.moveItem""": """Déplacer vers une liste""",
|
||||
"""checklists.moveFailed""": """Impossible de déplacer l'article.""",
|
||||
"""checklists.itemMarkedDone""": """Article marqué comme fait""",
|
||||
"""checklists.undo""": """Annuler""",
|
||||
"""checklists.createList""": """Nouvelle liste""",
|
||||
"""checklists.listName""": """Nom de la liste""",
|
||||
"""checklists.listDescription""": """Description (facultatif)""",
|
||||
|
||||
@@ -129,6 +129,8 @@ checklists:
|
||||
removeItem: Supprimer l'article
|
||||
moveItem: "Déplacer vers une liste"
|
||||
moveFailed: "Impossible de déplacer l'article."
|
||||
itemMarkedDone: "Article marqué comme fait"
|
||||
undo: Annuler
|
||||
createList: Nouvelle liste
|
||||
listName: Nom de la liste
|
||||
listDescription: Description (facultatif)
|
||||
|
||||
@@ -708,6 +708,16 @@ class ChecklistsMessagesHe extends ChecklistsMessages {
|
||||
/// ```
|
||||
String get moveFailed => """העברת הפריט נכשלה.""";
|
||||
|
||||
/// ```dart
|
||||
/// "הפריט סומן כהושלם"
|
||||
/// ```
|
||||
String get itemMarkedDone => """הפריט סומן כהושלם""";
|
||||
|
||||
/// ```dart
|
||||
/// "בטל"
|
||||
/// ```
|
||||
String get undo => """בטל""";
|
||||
|
||||
/// ```dart
|
||||
/// "רשימה חדשה"
|
||||
/// ```
|
||||
@@ -1573,6 +1583,8 @@ Map<String, String> get messagesHeMap => {
|
||||
"""checklists.removeItem""": """הסר פריט""",
|
||||
"""checklists.moveItem""": """העבר לרשימה""",
|
||||
"""checklists.moveFailed""": """העברת הפריט נכשלה.""",
|
||||
"""checklists.itemMarkedDone""": """הפריט סומן כהושלם""",
|
||||
"""checklists.undo""": """בטל""",
|
||||
"""checklists.createList""": """רשימה חדשה""",
|
||||
"""checklists.listName""": """שם הרשימה""",
|
||||
"""checklists.listDescription""": """תיאור (אופציונלי)""",
|
||||
|
||||
@@ -129,6 +129,8 @@ checklists:
|
||||
removeItem: הסר פריט
|
||||
moveItem: העבר לרשימה
|
||||
moveFailed: העברת הפריט נכשלה.
|
||||
itemMarkedDone: הפריט סומן כהושלם
|
||||
undo: בטל
|
||||
createList: רשימה חדשה
|
||||
listName: שם הרשימה
|
||||
listDescription: תיאור (אופציונלי)
|
||||
|
||||
@@ -525,6 +525,34 @@ class _ReorderablePartition extends StatelessWidget {
|
||||
this.categorySpacing = 'disabled',
|
||||
});
|
||||
|
||||
void _toggleItem(
|
||||
BuildContext context,
|
||||
ChecklistsController controller,
|
||||
ListItem item,
|
||||
) {
|
||||
final wasDone = item.done;
|
||||
controller.toggleItem(item);
|
||||
if (wasDone) return;
|
||||
|
||||
final messenger = ScaffoldMessenger.of(context);
|
||||
messenger.clearSnackBars();
|
||||
messenger.showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(m.checklists.itemMarkedDone),
|
||||
action: SnackBarAction(
|
||||
label: m.checklists.undo,
|
||||
onPressed: () {
|
||||
final current = controller.items.firstWhere(
|
||||
(i) => i.id == item.id,
|
||||
orElse: () => item.copyWith(done: true),
|
||||
);
|
||||
if (current.done) controller.toggleItem(current);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _viewItem(
|
||||
BuildContext context,
|
||||
ChecklistsController controller,
|
||||
@@ -684,7 +712,7 @@ class _ReorderablePartition extends StatelessWidget {
|
||||
? controller.categories[item.categoryId]
|
||||
: null,
|
||||
houseId: controller.houseId,
|
||||
onToggle: controller.toggleItem,
|
||||
onToggle: (item) => _toggleItem(context, controller, item),
|
||||
onView: (item) => _viewItem(context, controller, item),
|
||||
onEdit: (item) => _editItem(context, controller, item),
|
||||
onMove: (item) => _moveItem(context, controller, item),
|
||||
|
||||
Reference in New Issue
Block a user