Преглед на файлове

added delete, and rename options(logic not implemented yet)

juan преди 1 месец
родител
ревизия
5a94b57182
променени са 1 файла, в които са добавени 36 реда и са изтрити 1 реда
  1. 36 1
      lib/folder_drawer.dart

+ 36 - 1
lib/folder_drawer.dart

@@ -1,9 +1,9 @@
 //drawer with the folders for emails a.k.a mailboxes
 
 import 'package:flutter/material.dart';
-import 'package:flutter/services.dart';
 import 'api_service.dart';
 
+// ignore: must_be_immutable
 class FolderDrawer extends StatefulWidget {
   ApiService apiService;
   Function(String) onFolderTap;
@@ -44,6 +44,13 @@ class _FolderDrawerState extends State<FolderDrawer> {
             return ListTile(
               leading: Icon(Icons.mail),
               title: Text(folder),
+              trailing: IconButton(
+                icon: Icon(Icons.more_vert),
+                onPressed: () => {
+                  ///show options
+                  _showOptions(context)
+                },
+              ),
               onTap: () {
                 widget.onFolderTap(folder);
                 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 {