diff --git a/lib/email.dart b/lib/email.dart index 244194e..dd5fee1 100644 --- a/lib/email.dart +++ b/lib/email.dart @@ -91,6 +91,20 @@ class _EmailListScreenState extends State return false; } + bool moveOfSelected(String destinyFolder) { + //this should be called from a widget + print("move of folder"); + setState(() { + for (int email = 0; email < selectedEmails.length; email++) { + ApiService().moveEmail( + widget.folder, selectedEmails[email].id.toString(), destinyFolder); + } + }); + return false; + } + + // Widget moveOfFolderWidget() + List listOfSelectedThreads() { return selectedEmails; } @@ -153,7 +167,7 @@ class _EmailListScreenState extends State IconButton( icon: Icon(Icons.mark_email_read_outlined), onPressed: () { - //mark email as read + // mark email as read setState(() { widget.emails[index].seen = true; ApiService().markAsSeen(email.id); @@ -163,7 +177,8 @@ class _EmailListScreenState extends State IconButton( icon: Icon(Icons.delete_outline), onPressed: () { - //delete email + // delete email + ApiService().deleteEmail(widget.folder, email.id); }, ), ], @@ -297,8 +312,13 @@ class EmailPageState extends State { return selectionType; } + bool moveSelectedOfFolder(String folder) { + emailListKey.currentState?.moveOfSelected(folder); + return false; + } + List getListOfSelected() { - return emailListKey.currentState!.listOfSelectedThreads() ?? []; + return emailListKey.currentState!.listOfSelectedThreads(); } // return [GetThreadResponse(id: 1, messages: [], subject: "subject", date: DateTime(2025), from_name: "from_name", from_address: "from_address", to: [], seen: false)];