Pārlūkot izejas kodu

Reduce the duration of the toast

vishnukvmd 3 gadi atpakaļ
vecāks
revīzija
cef7c972e6

+ 1 - 1
lib/ui/fading_app_bar.dart

@@ -298,7 +298,7 @@ class FadingAppBarState extends State<FadingAppBar> {
         isDestructiveAction: true,
         onPressed: () async {
           await deleteFilesFromRemoteOnly(context, [file]);
-          showToast("moved to trash");
+          showShortToast("moved to trash");
           Navigator.of(context, rootNavigator: true).pop();
         },
       ));

+ 1 - 1
lib/ui/gallery_app_bar_widget.dart

@@ -524,7 +524,7 @@ class _GalleryAppBarWidgetState extends State<GalleryAppBarWidget> {
           await deleteFilesFromRemoteOnly(
               context, widget.selectedFiles.files.toList());
           _clearSelectedFiles();
-          showToast("moved to trash");
+          showShortToast("moved to trash");
         },
       ));
       actions.add(CupertinoActionSheetAction(

+ 1 - 1
lib/ui/video_widget.dart

@@ -74,7 +74,7 @@ class _VideoWidgetState extends State<VideoWidget> {
           setState(() {
             _progress = count / total;
             if (_progress == 1) {
-              showToast("decrypting video...", toastLength: Toast.LENGTH_SHORT);
+              showShortToast("decrypting video...");
             }
           });
         }

+ 1 - 2
lib/ui/zoomable_live_image.dart

@@ -19,7 +19,6 @@ class ZoomableLiveImage extends StatefulWidget {
   final String tagPrefix;
   final Decoration backgroundDecoration;
 
-
   ZoomableLiveImage(
     this.file, {
     Key key,
@@ -138,7 +137,7 @@ class _ZoomableLiveImageState extends State<ZoomableLiveImage>
     if (videoFile != null && videoFile.existsSync()) {
       _setVideoPlayerController(file: videoFile);
     } else {
-      showToast("download failed", toastLength: Toast.LENGTH_SHORT);
+      showShortToast("download failed");
     }
     _isLoadingVideoPlayer = false;
   }

+ 1 - 1
lib/utils/delete_file_util.dart

@@ -111,7 +111,7 @@ Future<void> deleteFilesFromEverywhere(
         .fire(LocalPhotosUpdatedEvent(deletedFiles, type: EventType.deleted));
   }
   await dialog.hide();
-  showToast("moved to trash");
+  showShortToast("moved to trash");
   if (uploadedFilesToBeTrashed.isNotEmpty) {
     RemoteSyncService.instance.sync(silently: true);
   }

+ 4 - 6
lib/utils/magic_util.dart

@@ -18,11 +18,9 @@ Future<void> changeVisibility(
   await dialog.show();
   try {
     await FileMagicService.instance.changeVisibility(files, newVisibility);
-    showToast(
-        newVisibility == kVisibilityArchive
-            ? "successfully archived"
-            : "successfully unarchived",
-        toastLength: Toast.LENGTH_SHORT);
+    showShortToast(newVisibility == kVisibilityArchive
+        ? "successfully archived"
+        : "successfully unarchived");
 
     await dialog.hide();
   } catch (e, s) {
@@ -54,7 +52,7 @@ Future<void> _updatePublicMetadata(
   try {
     Map<String, dynamic> update = {key: value};
     await FileMagicService.instance.updatePublicMagicMetadata(files, update);
-    showToast('done', toastLength: Toast.LENGTH_SHORT);
+    showShortToast('done');
     await dialog.hide();
     if (_shouldReloadGallery(key)) {
       Bus.instance.fire(ForceReloadHomeGalleryEvent());

+ 7 - 2
lib/utils/toast_util.dart

@@ -4,7 +4,8 @@ import 'package:flutter/material.dart';
 import 'package:flutter_easyloading/flutter_easyloading.dart';
 import 'package:fluttertoast/fluttertoast.dart';
 
-Future<void> showToast(String message, {toastLength = Toast.LENGTH_LONG}) async {
+Future<void> showToast(String message,
+    {toastLength = Toast.LENGTH_LONG}) async {
   if (Platform.isAndroid) {
     await Fluttertoast.cancel();
     return Fluttertoast.showToast(
@@ -24,8 +25,12 @@ Future<void> showToast(String message, {toastLength = Toast.LENGTH_LONG}) async
       ..loadingStyle = EasyLoadingStyle.custom;
     return EasyLoading.showToast(
       message,
-      duration: Duration(seconds: (toastLength == Toast.LENGTH_LONG ? 5 : 3)),
+      duration: Duration(seconds: (toastLength == Toast.LENGTH_LONG ? 5 : 2)),
       toastPosition: EasyLoadingToastPosition.bottom,
     );
   }
 }
+
+Future<void> showShortToast(String message) {
+  return showToast(message, toastLength: Toast.LENGTH_SHORT);
+}