3 Commits 55de9ea8b9 ... 9b0b72003a

Author SHA1 Message Date
  juan 9b0b72003a dead code and minor warning removal 1 month ago
  juan 777dab2873 delete api call added (not tested) 1 month ago
  juan 5a94b57182 added delete, and rename options(logic not implemented yet) 1 month ago
4 changed files with 90 additions and 32 deletions
  1. 25 1
      lib/api_service.dart
  2. 1 0
      lib/email.dart
  3. 36 1
      lib/folder_drawer.dart
  4. 28 30
      lib/home_page.dart

+ 25 - 1
lib/api_service.dart

@@ -127,6 +127,30 @@ class ApiService {
       print('error making post req: $e');
       print('error making post req: $e');
     }
     }
   }
   }
+
+
+  Future<void> deleteFolder(String folderName) async {
+    var url = Uri.http('127.0.0.1:3001', 'delete_folder');
+
+    Map<String, String> requestBody = {'name': folderName};
+
+    try {
+      var response = await http.post(
+        url,
+        headers: {
+          'Content-Type': 'application/json',
+        },
+        body: jsonEncode(requestBody),
+      );
+      if (response.statusCode == 200) {
+        print('response body: ${response.body}');
+      } else {
+        print('Error: ${response.statusCode}, response body: ${response.body}');
+      }
+    } catch (e) {
+      print('error making post req: $e');
+    }
+  }
 }
 }
 
 
 class EmailView extends StatefulWidget {
 class EmailView extends StatefulWidget {
@@ -156,7 +180,7 @@ class _EmailViewState extends State<EmailView> {
   late Key iframeKey;
   late Key iframeKey;
   late String currentContent;
   late String currentContent;
   late String viewTypeId;
   late String viewTypeId;
-  TextEditingController _jumpController = TextEditingController();
+  // TextEditingController _jumpController = TextEditingController();
 
 
   @override
   @override
   void initState() {
   void initState() {

+ 1 - 0
lib/email.dart

@@ -48,6 +48,7 @@ class EmailListScreen extends StatelessWidget {
   }
   }
 }
 }
 
 
+// ignore: must_be_immutable
 class EmailPage extends StatefulWidget {
 class EmailPage extends StatefulWidget {
   EmailPage({Key? key}) : super(key: key);
   EmailPage({Key? key}) : super(key: key);
   String selectedFolder = "INBOX";
   String selectedFolder = "INBOX";

+ 36 - 1
lib/folder_drawer.dart

@@ -1,9 +1,9 @@
 //drawer with the folders for emails a.k.a mailboxes
 //drawer with the folders for emails a.k.a mailboxes
 
 
 import 'package:flutter/material.dart';
 import 'package:flutter/material.dart';
-import 'package:flutter/services.dart';
 import 'api_service.dart';
 import 'api_service.dart';
 
 
+// ignore: must_be_immutable
 class FolderDrawer extends StatefulWidget {
 class FolderDrawer extends StatefulWidget {
   ApiService apiService;
   ApiService apiService;
   Function(String) onFolderTap;
   Function(String) onFolderTap;
@@ -44,6 +44,13 @@ class _FolderDrawerState extends State<FolderDrawer> {
             return ListTile(
             return ListTile(
               leading: Icon(Icons.mail),
               leading: Icon(Icons.mail),
               title: Text(folder),
               title: Text(folder),
+              trailing: IconButton(
+                icon: Icon(Icons.more_vert),
+                onPressed: () => {
+                  ///show options
+                  _showOptions(context)
+                },
+              ),
               onTap: () {
               onTap: () {
                 widget.onFolderTap(folder);
                 widget.onFolderTap(folder);
                 Navigator.pop(
                 Navigator.pop(
@@ -76,6 +83,34 @@ class _FolderDrawerState extends State<FolderDrawer> {
       ),
       ),
     );
     );
   }
   }
+  void _showOptions(BuildContext context) async {
+  final RenderBox overlay = Overlay.of(context).context.findRenderObject() as RenderBox;
+  
+  await showMenu<String>(
+    context: context,
+    position: RelativeRect.fromLTRB(100, 100, overlay.size.width, overlay.size.height),
+    items: <PopupMenuEntry<String>>[
+      PopupMenuItem<String>(
+        value: 'Rename',
+        child: Text('Rename Folder'),
+      ),
+      PopupMenuItem<String>(
+        value: 'Delete',
+        child: Text('Delete Folder'),
+      ),
+    ],
+  ).then((value) {
+    // Handle the action based on the selected menu item
+    if (value == 'Rename') {
+      // Logic for renaming the folder
+      print('Rename folder');
+    } else if (value == 'Delete') {
+      // Logic for deleting the folder
+      print('Delete folder');
+    }
+  });
+}
+
 }
 }
 
 
 class NewMailbox extends StatelessWidget {
 class NewMailbox extends StatelessWidget {

+ 28 - 30
lib/home_page.dart

@@ -163,34 +163,32 @@ class _HomeScreenState extends State<HomeScreen> {
     );
     );
   }
   }
 
 
-  void _showPopupMenu(BuildContext context, Offset position) async {
-    final RenderBox overlay =
-        Overlay.of(context).context.findRenderObject() as RenderBox;
+//   void _showPopupMenu(BuildContext context, Offset position) async {
+//     final RenderBox overlay =
+//         Overlay.of(context).context.findRenderObject() as RenderBox;
 
 
-    await showMenu<String>(
-      context: context,
-      position: RelativeRect.fromLTRB(
-        position.dx,
-        position.dy,
-        overlay.size.width - position.dx,
-        overlay.size.height - position.dy,
-      ),
-      items: <PopupMenuEntry<String>>[
-        PopupMenuItem<String>(
-          value: 'Open',
-          child: Text('Open'),
-        ),
-        PopupMenuItem<String>(
-          value: 'Reply',
-          child: Text('Reply'),
-        ),
-        PopupMenuItem<String>(
-          value: 'Delete',
-          child: Text('Delete'),
-        ),
-      ],
-    );
-  }
-}
-
-//show popup menu
+//     await showMenu<String>(
+//       context: context,
+//       position: RelativeRect.fromLTRB(
+//         position.dx,
+//         position.dy,
+//         overlay.size.width - position.dx,
+//         overlay.size.height - position.dy,
+//       ),
+//       items: <PopupMenuEntry<String>>[
+//         PopupMenuItem<String>(
+//           value: 'Open',
+//           child: Text('Open'),
+//         ),
+//         PopupMenuItem<String>(
+//           value: 'Reply',
+//           child: Text('Reply'),
+//         ),
+//         PopupMenuItem<String>(
+//           value: 'Delete',
+//           child: Text('Delete'),
+//         ),
+//       ],
+//     );
+//   }
+// }