Reduce the duration of the toast

This commit is contained in:
vishnukvmd 2021-10-30 03:48:24 +05:30
parent 0b1438244d
commit cef7c972e6
7 changed files with 16 additions and 14 deletions

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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