浏览代码

add delete from ente option in fading_app_bar menu

Neeraj Gupta 3 年之前
父节点
当前提交
b43f824215
共有 1 个文件被更改,包括 23 次插入13 次删除
  1. 23 13
      lib/ui/fading_app_bar.dart

+ 23 - 13
lib/ui/fading_app_bar.dart

@@ -91,7 +91,7 @@ class FadingAppBarState extends State<FadingAppBar> {
 
   AppBar _buildAppBar() {
     final List<Widget> actions = [];
-    final isTrashedFile =  widget.file is TrashFile;
+    final isTrashedFile = widget.file is TrashFile;
     final shouldShowActions = widget.shouldShowActions && !isTrashedFile;
     // only show fav option for files owned by the user
     if (widget.file.ownerID == null || widget.file.ownerID == widget.userID) {
@@ -221,7 +221,7 @@ class FadingAppBarState extends State<FadingAppBar> {
 
   void _showDeleteSheet(File file) {
     final List<Widget> actions = [];
-    if (file.uploadedFileID == null) {
+    if (file.uploadedFileID == null || file.localID == null) {
       actions.add(CupertinoActionSheetAction(
         child: Text("everywhere"),
         isDestructiveAction: true,
@@ -231,17 +231,27 @@ class FadingAppBarState extends State<FadingAppBar> {
         },
       ));
     } else {
-      if (file.localID != null) {
-        actions.add(CupertinoActionSheetAction(
-          child: Text("device"),
-          isDestructiveAction: true,
-          onPressed: () async {
-            await deleteFilesOnDeviceOnly(context, [file]);
-            showToast("file deleted from device");
-            Navigator.of(context, rootNavigator: true).pop();
-          },
-        ));
-      }
+      // uploaded file which is present locally too
+      actions.add(CupertinoActionSheetAction(
+        child: Text("device"),
+        isDestructiveAction: true,
+        onPressed: () async {
+          await deleteFilesOnDeviceOnly(context, [file]);
+          showToast("file deleted from device");
+          Navigator.of(context, rootNavigator: true).pop();
+        },
+      ));
+
+      actions.add(CupertinoActionSheetAction(
+        child: Text("ente"),
+        isDestructiveAction: true,
+        onPressed: () async {
+          await deleteFilesFromRemoteOnly(context, [file]);
+          showToast("moved to trash");
+          Navigator.of(context, rootNavigator: true).pop();
+        },
+      ));
+
       actions.add(CupertinoActionSheetAction(
         child: Text("everywhere"),
         isDestructiveAction: true,