From cef7c972e64b7dd84b673b51c809a75840f4a3ce Mon Sep 17 00:00:00 2001 From: vishnukvmd Date: Sat, 30 Oct 2021 03:48:24 +0530 Subject: [PATCH] Reduce the duration of the toast --- lib/ui/fading_app_bar.dart | 2 +- lib/ui/gallery_app_bar_widget.dart | 2 +- lib/ui/video_widget.dart | 2 +- lib/ui/zoomable_live_image.dart | 3 +-- lib/utils/delete_file_util.dart | 2 +- lib/utils/magic_util.dart | 10 ++++------ lib/utils/toast_util.dart | 9 +++++++-- 7 files changed, 16 insertions(+), 14 deletions(-) diff --git a/lib/ui/fading_app_bar.dart b/lib/ui/fading_app_bar.dart index 35e0ac610..c8c3b31da 100644 --- a/lib/ui/fading_app_bar.dart +++ b/lib/ui/fading_app_bar.dart @@ -298,7 +298,7 @@ class FadingAppBarState extends State { isDestructiveAction: true, onPressed: () async { await deleteFilesFromRemoteOnly(context, [file]); - showToast("moved to trash"); + showShortToast("moved to trash"); Navigator.of(context, rootNavigator: true).pop(); }, )); diff --git a/lib/ui/gallery_app_bar_widget.dart b/lib/ui/gallery_app_bar_widget.dart index 9a2d3ab81..f3eb61b63 100644 --- a/lib/ui/gallery_app_bar_widget.dart +++ b/lib/ui/gallery_app_bar_widget.dart @@ -524,7 +524,7 @@ class _GalleryAppBarWidgetState extends State { await deleteFilesFromRemoteOnly( context, widget.selectedFiles.files.toList()); _clearSelectedFiles(); - showToast("moved to trash"); + showShortToast("moved to trash"); }, )); actions.add(CupertinoActionSheetAction( diff --git a/lib/ui/video_widget.dart b/lib/ui/video_widget.dart index 07e77615a..8120b0513 100644 --- a/lib/ui/video_widget.dart +++ b/lib/ui/video_widget.dart @@ -74,7 +74,7 @@ class _VideoWidgetState extends State { setState(() { _progress = count / total; if (_progress == 1) { - showToast("decrypting video...", toastLength: Toast.LENGTH_SHORT); + showShortToast("decrypting video..."); } }); } diff --git a/lib/ui/zoomable_live_image.dart b/lib/ui/zoomable_live_image.dart index 386d481a1..443ff00ac 100644 --- a/lib/ui/zoomable_live_image.dart +++ b/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 if (videoFile != null && videoFile.existsSync()) { _setVideoPlayerController(file: videoFile); } else { - showToast("download failed", toastLength: Toast.LENGTH_SHORT); + showShortToast("download failed"); } _isLoadingVideoPlayer = false; } diff --git a/lib/utils/delete_file_util.dart b/lib/utils/delete_file_util.dart index 324f65dca..c8cf7af96 100644 --- a/lib/utils/delete_file_util.dart +++ b/lib/utils/delete_file_util.dart @@ -111,7 +111,7 @@ Future 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); } diff --git a/lib/utils/magic_util.dart b/lib/utils/magic_util.dart index 52d12e84f..9e8ee68aa 100644 --- a/lib/utils/magic_util.dart +++ b/lib/utils/magic_util.dart @@ -18,11 +18,9 @@ Future 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 _updatePublicMetadata( try { Map 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()); diff --git a/lib/utils/toast_util.dart b/lib/utils/toast_util.dart index 42e775061..554c492c7 100644 --- a/lib/utils/toast_util.dart +++ b/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 showToast(String message, {toastLength = Toast.LENGTH_LONG}) async { +Future showToast(String message, + {toastLength = Toast.LENGTH_LONG}) async { if (Platform.isAndroid) { await Fluttertoast.cancel(); return Fluttertoast.showToast( @@ -24,8 +25,12 @@ Future 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 showShortToast(String message) { + return showToast(message, toastLength: Toast.LENGTH_SHORT); +}