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,
onPressed: () async {
await deleteFilesFromRemoteOnly(context, [file]);
showToast("moved to trash");
showShortToast("moved to trash");
Navigator.of(context, rootNavigator: true).pop();
},
));

View file

@ -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(

View file

@ -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...");
}
});
}

View file

@ -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;
}

View file

@ -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);
}

View file

@ -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());

View file

@ -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);
}