Explorar el Código

made util function to edit file's caption in public metadata

ashilkn hace 2 años
padre
commit
2bea592925
Se han modificado 2 ficheros con 16 adiciones y 1 borrados
  1. 1 0
      lib/models/magic_metadata.dart
  2. 15 1
      lib/utils/magic_util.dart

+ 1 - 0
lib/models/magic_metadata.dart

@@ -7,6 +7,7 @@ const magicKeyVisibility = 'visibility';
 
 const pubMagicKeyEditedTime = 'editedTime';
 const pubMagicKeyEditedName = 'editedName';
+const pubMagicKeyCaption = "caption";
 
 class MagicMetadata {
   // 0 -> visible

+ 15 - 1
lib/utils/magic_util.dart

@@ -120,7 +120,21 @@ Future<bool> editFilename(
     );
     return true;
   } catch (e) {
-    showToast(context, 'something went wrong');
+    showToast(context, 'Something went wrong');
+    return false;
+  }
+}
+
+Future<bool> editFileCaption(
+  BuildContext context,
+  File file,
+  String caption,
+) async {
+  try {
+    await _updatePublicMetadata(context, [file], pubMagicKeyCaption, caption);
+    return true;
+  } catch (e) {
+    showToast(context, "Something went wrong");
     return false;
   }
 }