diff --git a/lib/ente_theme_data.dart b/lib/ente_theme_data.dart index b4925120e..dff7624ad 100644 --- a/lib/ente_theme_data.dart +++ b/lib/ente_theme_data.dart @@ -110,6 +110,13 @@ extension CustomColorScheme on ColorScheme { Color get dotsIndicatorInactiveColor => brightness == Brightness.light ? Colors.black.withOpacity(0.12) : Colors.white.withOpacity(0.12); + + Color get toastTextColor => + brightness == Brightness.light ? Colors.white : Colors.black; + + Color get toastBackgroundColor => brightness == Brightness.light + ? Color.fromRGBO(24, 24, 24, 0.95) + : Color.fromRGBO(255, 255, 255, 0.95); } OutlinedButtonThemeData buildOutlinedButtonThemeData( diff --git a/lib/services/user_service.dart b/lib/services/user_service.dart index 6ea3f540d..781561ac6 100644 --- a/lib/services/user_service.dart +++ b/lib/services/user_service.dart @@ -210,7 +210,7 @@ class UserService { ); await dialog.hide(); if (response != null && response.statusCode == 200) { - showShortToast("Email verification successful!"); + showShortToast(context, "Email verification successful!"); Widget page; final String twoFASessionID = response.data["twoFactorSessionID"]; if (twoFASessionID != null && twoFASessionID.isNotEmpty) { @@ -275,7 +275,7 @@ class UserService { ); await dialog.hide(); if (response != null && response.statusCode == 200) { - showToast("Email changed to " + email); + showToast(context, "Email changed to " + email); _config.setEmail(email); Navigator.of(context).popUntil((route) => route.isFirst); Bus.instance.fire(UserDetailsChangedEvent()); @@ -384,7 +384,7 @@ class UserService { ); await dialog.hide(); if (response != null && response.statusCode == 200) { - showToast("Authentication successful!"); + showToast(context, "Authentication successful!"); await _saveConfiguration(response); Navigator.of(context).pushAndRemoveUntil( MaterialPageRoute( @@ -399,7 +399,7 @@ class UserService { await dialog.hide(); _logger.severe(e); if (e.response != null && e.response.statusCode == 404) { - showToast("Session expired"); + showToast(context, "Session expired"); Navigator.of(context).pushAndRemoveUntil( MaterialPageRoute( builder: (BuildContext context) { @@ -446,7 +446,7 @@ class UserService { } on DioError catch (e) { _logger.severe(e); if (e.response != null && e.response.statusCode == 404) { - showToast("Session expired"); + showToast(context, "Session expired"); Navigator.of(context).pushAndRemoveUntil( MaterialPageRoute( builder: (BuildContext context) { @@ -498,7 +498,7 @@ class UserService { }, ); if (response != null && response.statusCode == 200) { - showShortToast("Two-factor authentication successfully reset"); + showShortToast(context, "Two-factor authentication successfully reset"); await _saveConfiguration(response); Navigator.of(context).pushAndRemoveUntil( MaterialPageRoute( @@ -512,7 +512,7 @@ class UserService { } on DioError catch (e) { _logger.severe(e); if (e.response != null && e.response.statusCode == 404) { - showToast("Session expired"); + showToast(context, "Session expired"); Navigator.of(context).pushAndRemoveUntil( MaterialPageRoute( builder: (BuildContext context) { @@ -622,7 +622,7 @@ class UserService { ); Bus.instance.fire(TwoFactorStatusChangeEvent(false)); await dialog.hide(); - showToast("Two-factor authentication has been disabled"); + showToast(context, "Two-factor authentication has been disabled"); } catch (e, s) { await dialog.hide(); _logger.severe(e, s); diff --git a/lib/ui/collections_gallery_widget.dart b/lib/ui/collections_gallery_widget.dart index af4cd3223..e3d462e92 100644 --- a/lib/ui/collections_gallery_widget.dart +++ b/lib/ui/collections_gallery_widget.dart @@ -486,7 +486,7 @@ class _CollectionsGalleryWidgetState extends State ), ), onTap: () async { - await showToast( + await showToast(context, "long press to select photos and click + to create an album", toastLength: Toast.LENGTH_LONG); Bus.instance diff --git a/lib/ui/create_collection_page.dart b/lib/ui/create_collection_page.dart index 4d77c2845..94b78807f 100644 --- a/lib/ui/create_collection_page.dart +++ b/lib/ui/create_collection_page.dart @@ -181,9 +181,11 @@ class _CreateCollectionPageState extends State { ), onTap: () async { if (await _runCollectionAction(item.collection.id)) { - showShortToast(widget.actionType == CollectionActionType.addFiles - ? "Added successfully to " + item.collection.name - : "Moved successfully to " + item.collection.name); + showShortToast( + context, + widget.actionType == CollectionActionType.addFiles + ? "Added successfully to " + item.collection.name + : "Moved successfully to " + item.collection.name); _navigateToCollection(item.collection); } }, @@ -240,9 +242,11 @@ class _CreateCollectionPageState extends State { if (collection != null) { if (await _runCollectionAction(collection.id)) { if (widget.actionType == CollectionActionType.restoreFiles) { - showShortToast('Restored files to album ' + _albumName); + showShortToast( + context, 'Restored files to album ' + _albumName); } else { - showShortToast("Album '" + _albumName + "' created."); + showShortToast( + context, "Album '" + _albumName + "' created."); } _navigateToCollection(collection); } diff --git a/lib/ui/deduplicate_page.dart b/lib/ui/deduplicate_page.dart index 8c4d7159b..fa5658158 100644 --- a/lib/ui/deduplicate_page.dart +++ b/lib/ui/deduplicate_page.dart @@ -64,7 +64,7 @@ class _DeduplicatePageState extends State { _duplicates = DeduplicationService.instance.clubDuplicatesByTime(widget.duplicates); _selectAllFilesButFirst(); - showToast("Long-press on an item to view in full-screen"); + showToast(context, "Long-press on an item to view in full-screen"); } void _selectAllFilesButFirst() { diff --git a/lib/ui/fading_app_bar.dart b/lib/ui/fading_app_bar.dart index 387090234..179605a86 100644 --- a/lib/ui/fading_app_bar.dart +++ b/lib/ui/fading_app_bar.dart @@ -219,7 +219,7 @@ class FadingAppBarState extends State { } catch (e, s) { _logger.severe(e, s); hasError = true; - showToast("Sorry, could not add this to favorites!"); + showToast(context, "Sorry, could not add this to favorites!"); } finally { if (shouldBlockUser) { await dialog.hide(); @@ -231,7 +231,7 @@ class FadingAppBarState extends State { } catch (e, s) { _logger.severe(e, s); hasError = true; - showToast("Sorry, could not remove this from favorites!"); + showToast(context, "Sorry, could not remove this from favorites!"); } } return hasError ? oldValue : isLiked; @@ -294,7 +294,7 @@ class FadingAppBarState extends State { isDestructiveAction: true, onPressed: () async { await deleteFilesOnDeviceOnly(context, [file]); - showToast("File deleted from device"); + showToast(context, "File deleted from device"); Navigator.of(context, rootNavigator: true).pop(); // TODO: Fix behavior when inside a device folder }, @@ -305,7 +305,7 @@ class FadingAppBarState extends State { isDestructiveAction: true, onPressed: () async { await deleteFilesFromRemoteOnly(context, [file]); - showShortToast("Moved to trash"); + showShortToast(context, "Moved to trash"); Navigator.of(context, rootNavigator: true).pop(); // TODO: Fix behavior when inside a collection }, @@ -364,9 +364,9 @@ class FadingAppBarState extends State { Bus.instance.fire(LocalPhotosUpdatedEvent([file])); await dialog.hide(); if (file.fileType == FileType.livePhoto) { - showToast("Photo and video saved to gallery"); + showToast(context, "Photo and video saved to gallery"); } else { - showToast("File saved to gallery"); + showToast(context, "File saved to gallery"); } } } diff --git a/lib/ui/file_info_dialog.dart b/lib/ui/file_info_dialog.dart index 65d656510..51b6ce1e2 100644 --- a/lib/ui/file_info_dialog.dart +++ b/lib/ui/file_info_dialog.dart @@ -275,7 +275,7 @@ class _FileInfoWidgetState extends State { ], ), onPressed: () { - showShortToast("This image has no exif data"); + showShortToast(context, "This image has no exif data"); }, ), ); diff --git a/lib/ui/gallery_overlay_widget.dart b/lib/ui/gallery_overlay_widget.dart index 2b2fdeb10..d37f1cab2 100644 --- a/lib/ui/gallery_overlay_widget.dart +++ b/lib/ui/gallery_overlay_widget.dart @@ -448,7 +448,7 @@ class _OverlayWidgetState extends State { await deleteFilesOnDeviceOnly( context, widget.selectedFiles.files.toList()); _clearSelectedFiles(); - showToast("Files deleted from device"); + showToast(context, "Files deleted from device"); }, )); actions.add(CupertinoActionSheetAction( @@ -459,7 +459,7 @@ class _OverlayWidgetState extends State { await deleteFilesFromRemoteOnly( context, widget.selectedFiles.files.toList()); _clearSelectedFiles(); - showShortToast("Moved to trash"); + showShortToast(context, "Moved to trash"); }, )); actions.add(CupertinoActionSheetAction( diff --git a/lib/ui/image_editor_page.dart b/lib/ui/image_editor_page.dart index 0f9df57c1..fcc1ae2f0 100644 --- a/lib/ui/image_editor_page.dart +++ b/lib/ui/image_editor_page.dart @@ -300,7 +300,7 @@ class _ImageEditorPageState extends State { if (img == null) { _logger.severe("null rawImageData"); - showToast("Something went wrong"); + showToast(context, "Something went wrong"); return; } @@ -329,7 +329,7 @@ class _ImageEditorPageState extends State { if (result == null) { _logger.severe("null result"); - showToast("Something went wrong"); + showToast(context, "Something went wrong"); return; } try { @@ -358,7 +358,7 @@ class _ImageEditorPageState extends State { await LocalSyncService.instance.trackEditedFile(newFile); Bus.instance.fire(LocalPhotosUpdatedEvent([newFile])); SyncService.instance.sync(); - showToast("Edits saved"); + showToast(context, "Edits saved"); _logger.info("Original file " + widget.originalFile.toString()); _logger.info("Saved edits to file " + newFile.toString()); final existingFiles = widget.detailPageConfig.files; @@ -377,7 +377,7 @@ class _ImageEditorPageState extends State { ), ); } catch (e, s) { - showToast("Oops, could not save edits"); + showToast(context, "Oops, could not save edits"); _logger.severe(e, s); } await dialog.hide(); diff --git a/lib/ui/manage_links_widget.dart b/lib/ui/manage_links_widget.dart index c0b589bd8..bda42e26c 100644 --- a/lib/ui/manage_links_widget.dart +++ b/lib/ui/manage_links_widget.dart @@ -414,7 +414,7 @@ class _ManageSharedLinkWidgetState extends State { try { await CollectionsService.instance.updateShareUrl(widget.collection, prop); await dialog.hide(); - showToast("Album updated"); + showToast(context, "Album updated"); } catch (e) { await dialog.hide(); await showGenericErrorDialog(context); diff --git a/lib/ui/password_entry_page.dart b/lib/ui/password_entry_page.dart index 0e7895082..36a61a86e 100644 --- a/lib/ui/password_entry_page.dart +++ b/lib/ui/password_entry_page.dart @@ -429,7 +429,7 @@ class _PasswordEntryPageState extends State { .updatePassword(_passwordController1.text); await UserService.instance.updateKeyAttributes(keyAttributes); await dialog.hide(); - showShortToast("Password changed successfully"); + showShortToast(context, "Password changed successfully"); Navigator.of(context).pop(); if (widget.mode == PasswordEntryMode.reset) { Bus.instance.fire(SubscriptionPurchasedEvent()); diff --git a/lib/ui/payment/stripe_subscription_page.dart b/lib/ui/payment/stripe_subscription_page.dart index fc827ba68..93ec932a4 100644 --- a/lib/ui/payment/stripe_subscription_page.dart +++ b/lib/ui/payment/stripe_subscription_page.dart @@ -94,7 +94,7 @@ class _StripeSubscriptionPageState extends State { try { await _fetchSub(); } catch (e) { - showToast("Failed to refresh subscription"); + showToast(context, "Failed to refresh subscription"); } await _dialog.hide(); @@ -383,7 +383,8 @@ class _StripeSubscriptionPageState extends State { : await _billingService.cancelStripeSubscription(); await _fetchSub(); } catch (e) { - showToast(isRenewCancelled ? 'failed to renew' : 'failed to cancel'); + showToast( + context, isRenewCancelled ? 'failed to renew' : 'failed to cancel'); } await _dialog.hide(); } diff --git a/lib/ui/payment/subscription_page.dart b/lib/ui/payment/subscription_page.dart index c3eb63777..5e3ab7d88 100644 --- a/lib/ui/payment/subscription_page.dart +++ b/lib/ui/payment/subscription_page.dart @@ -86,7 +86,7 @@ class _SubscriptionPageState extends State { text = "your plan was successfully downgraded"; } } - showToast(text); + showToast(context, text); _currentSubscription = newSubscription; _hasActiveSubscription = _currentSubscription.isValid(); setState(() {}); diff --git a/lib/ui/recovery_key_page.dart b/lib/ui/recovery_key_page.dart index f7c4814fc..7cf3b27b1 100644 --- a/lib/ui/recovery_key_page.dart +++ b/lib/ui/recovery_key_page.dart @@ -117,7 +117,7 @@ class _RecoveryKeyPageState extends State { onTap: () async { await Clipboard.setData( ClipboardData(text: recoveryKey)); - showToast("Recovery key copied to clipboard"); + showToast(context, "Recovery key copied to clipboard"); setState(() { _hasTriedToSave = true; }); diff --git a/lib/ui/recovery_page.dart b/lib/ui/recovery_page.dart index 39658adb2..9582d9877 100644 --- a/lib/ui/recovery_page.dart +++ b/lib/ui/recovery_page.dart @@ -40,7 +40,7 @@ class _RecoveryPageState extends State { try { await Configuration.instance.recover(_recoveryKey.text.trim()); await dialog.hide(); - showToast("Recovery successful!"); + showToast(context, "Recovery successful!"); Navigator.of(context).pushReplacement( MaterialPageRoute( builder: (BuildContext context) { diff --git a/lib/ui/sessions_page.dart b/lib/ui/sessions_page.dart index 018d4f5be..a7214cd04 100644 --- a/lib/ui/sessions_page.dart +++ b/lib/ui/sessions_page.dart @@ -128,7 +128,7 @@ class _SessionsPageState extends State { _sessions = await UserService.instance .getActiveSessions() .onError((error, stackTrace) { - showToast("Failed to fetch active sessions"); + showToast(context, "Failed to fetch active sessions"); throw error; }); _sessions.sessions.sort((first, second) { diff --git a/lib/ui/set_wallpaper_dialog.dart b/lib/ui/set_wallpaper_dialog.dart index 08214d7e3..0671b7ae3 100644 --- a/lib/ui/set_wallpaper_dialog.dart +++ b/lib/ui/set_wallpaper_dialog.dart @@ -75,11 +75,11 @@ class _SetWallpaperDialogState extends State { await WallpaperManagerFlutter().setwallpaperfromFile( await getFile(widget.file), _lockscreenValue); await dialog.hide(); - showToast("Wallpaper set successfully"); + showToast(context, "Wallpaper set successfully"); } catch (e, s) { await dialog.hide(); Logger("SetWallpaperDialog").severe(e, s); - showToast("Something went wrong"); + showToast(context, "Something went wrong"); return; } }, diff --git a/lib/ui/settings/account_section_widget.dart b/lib/ui/settings/account_section_widget.dart index 28167c5bb..b92cadf58 100644 --- a/lib/ui/settings/account_section_widget.dart +++ b/lib/ui/settings/account_section_widget.dart @@ -62,7 +62,7 @@ class AccountSectionWidgetState extends State { AppLock.of(context) .setEnabled(Configuration.instance.shouldShowLockScreen()); if (!result) { - showToast(reason); + showToast(context, reason); return; } @@ -91,7 +91,7 @@ class AccountSectionWidgetState extends State { AppLock.of(context) .setEnabled(Configuration.instance.shouldShowLockScreen()); if (!result) { - showToast(reason); + showToast(context, reason); return; } showDialog( @@ -116,7 +116,7 @@ class AccountSectionWidgetState extends State { AppLock.of(context) .setEnabled(Configuration.instance.shouldShowLockScreen()); if (!result) { - showToast(reason); + showToast(context, reason); return; } Navigator.of(context).push( diff --git a/lib/ui/settings/backup_section_widget.dart b/lib/ui/settings/backup_section_widget.dart index 5b6045637..0fd4c9c0b 100644 --- a/lib/ui/settings/backup_section_widget.dart +++ b/lib/ui/settings/backup_section_widget.dart @@ -194,7 +194,7 @@ class BackupSectionWidgetState extends State { ), onPressed: () { if (Platform.isIOS) { - showToast( + showToast(context, "Also empty \"Recently Deleted\" from \"Settings\" -> \"Storage\" to claim the freed space"); } Navigator.of(context, rootNavigator: true).pop('dialog'); @@ -251,7 +251,8 @@ class BackupSectionWidgetState extends State { ), ), onPressed: () { - showToast("Also empty your \"Trash\" to claim the freed up space"); + showToast(context, + "Also empty your \"Trash\" to claim the freed up space"); Navigator.of(context, rootNavigator: true).pop('dialog'); }, ), diff --git a/lib/ui/settings/info_section_widget.dart b/lib/ui/settings/info_section_widget.dart index 42a22af4f..9a4b51e7a 100644 --- a/lib/ui/settings/info_section_widget.dart +++ b/lib/ui/settings/info_section_widget.dart @@ -99,7 +99,7 @@ class InfoSectionWidget extends StatelessWidget { barrierColor: Colors.black.withOpacity(0.85), ); } else { - showToast("You are on the latest version"); + showToast(context, "You are on the latest version"); } }, child: SettingsTextItem( diff --git a/lib/ui/settings/security_section_widget.dart b/lib/ui/settings/security_section_widget.dart index d750c7661..a879cf584 100644 --- a/lib/ui/settings/security_section_widget.dart +++ b/lib/ui/settings/security_section_widget.dart @@ -89,7 +89,7 @@ class _SecuritySectionWidgetState extends State { AppLock.of(context).setEnabled( Configuration.instance.shouldShowLockScreen()); if (!result) { - showToast(reason); + showToast(context, reason); return; } if (value) { @@ -248,7 +248,7 @@ class _SecuritySectionWidgetState extends State { AppLock.of(context) .setEnabled(Configuration.instance.shouldShowLockScreen()); if (!result) { - showToast(kAuthToViewSessions); + showToast(context, kAuthToViewSessions); return; } Navigator.of(context).push( diff --git a/lib/ui/share_collection_widget.dart b/lib/ui/share_collection_widget.dart index 8f795078a..618477853 100644 --- a/lib/ui/share_collection_widget.dart +++ b/lib/ui/share_collection_widget.dart @@ -254,7 +254,7 @@ class _SharingDialogState extends State { GestureDetector( onTap: () async { await Clipboard.setData(ClipboardData(text: url)); - showToast("Link copied to clipboard"); + showToast(context, "Link copied to clipboard"); }, child: Container( padding: EdgeInsets.all(16), @@ -406,7 +406,7 @@ class _SharingDialogState extends State { await CollectionsService.instance .share(widget.collection.id, email, publicKey); await dialog.hide(); - showShortToast("Shared successfully!"); + showShortToast(context, "Shared successfully!"); setState(() { _sharees.add(User(email: email)); _showEntryField = false; @@ -502,7 +502,7 @@ class EmailItemWidget extends StatelessWidget { await CollectionsService.instance.unshare(collection.id, email); collection.sharees.removeWhere((user) => user.email == email); await dialog.hide(); - showToast("Stopped sharing with " + email + "."); + showToast(context, "Stopped sharing with " + email + "."); Navigator.of(context).pop(); } catch (e, s) { Logger("EmailItemWidget").severe(e, s); diff --git a/lib/ui/shared_collections_gallery.dart b/lib/ui/shared_collections_gallery.dart index 3e6d4aa98..e64db1356 100644 --- a/lib/ui/shared_collections_gallery.dart +++ b/lib/ui/shared_collections_gallery.dart @@ -239,7 +239,7 @@ class _SharedCollectionGalleryState extends State Color(0xFF1DB954), ], onTap: () async { - await showToast("Select an album on ente to share", + await showToast(context, "Select an album on ente to share", toastLength: Toast.LENGTH_LONG); Bus.instance.fire( TabChangedEvent(1, TabChangedEventSource.collections_page)); diff --git a/lib/ui/two_factor_setup_page.dart b/lib/ui/two_factor_setup_page.dart index 2662511bc..8c99c69f4 100644 --- a/lib/ui/two_factor_setup_page.dart +++ b/lib/ui/two_factor_setup_page.dart @@ -129,7 +129,7 @@ class _TwoFactorSetupPageState extends State return GestureDetector( onTap: () async { await Clipboard.setData(ClipboardData(text: widget.secretCode)); - showToast("Code copied to clipboard"); + showToast(context, "Code copied to clipboard"); }, child: Column( mainAxisAlignment: MainAxisAlignment.center, diff --git a/lib/ui/video_widget.dart b/lib/ui/video_widget.dart index 2bbda1586..ac8b6d7f1 100644 --- a/lib/ui/video_widget.dart +++ b/lib/ui/video_widget.dart @@ -75,7 +75,7 @@ class _VideoWidgetState extends State { setState(() { _progress = count / total; if (_progress == 1) { - showShortToast("decrypting video..."); + showShortToast(context, "Decrypting video..."); } }); } diff --git a/lib/ui/zoomable_live_image.dart b/lib/ui/zoomable_live_image.dart index 4ca1f1ff0..61c8311b4 100644 --- a/lib/ui/zoomable_live_image.dart +++ b/lib/ui/zoomable_live_image.dart @@ -115,7 +115,7 @@ class _ZoomableLiveImageState extends State } _isLoadingVideoPlayer = true; if (_file.isRemoteFile() && !(await isFileCached(_file, liveVideo: true))) { - showToast("Downloading...", toastLength: Toast.LENGTH_LONG); + showToast(context, "Downloading...", toastLength: Toast.LENGTH_LONG); } var videoFile = await getFile(widget.file, liveVideo: true) @@ -138,7 +138,7 @@ class _ZoomableLiveImageState extends State if (videoFile != null && videoFile.existsSync()) { _setVideoPlayerController(file: videoFile); } else { - showShortToast("download failed"); + showShortToast(context, "download failed"); } _isLoadingVideoPlayer = false; } @@ -159,7 +159,7 @@ class _ZoomableLiveImageState extends State var _preferences = await SharedPreferences.getInstance(); int promptTillNow = _preferences.getInt(kLivePhotoToastCounterKey) ?? 0; if (promptTillNow < kMaxLivePhotoToastCount) { - showToast("Press and hold to play video"); + showToast(context, "Press and hold to play video"); _preferences.setInt(kLivePhotoToastCounterKey, promptTillNow + 1); } } diff --git a/lib/utils/delete_file_util.dart b/lib/utils/delete_file_util.dart index c0f971819..2d6ab33c8 100644 --- a/lib/utils/delete_file_util.dart +++ b/lib/utils/delete_file_util.dart @@ -119,9 +119,9 @@ Future deleteFilesFromEverywhere( Bus.instance.fire(LocalPhotosUpdatedEvent(deletedFiles, type: EventType.deletedFromEverywhere)); if (hasLocalOnlyFiles && Platform.isAndroid) { - showShortToast("Files deleted"); + showShortToast(context, "Files deleted"); } else { - showShortToast("Moved to trash"); + showShortToast(context, "Moved to trash"); } } await dialog.hide(); @@ -134,7 +134,7 @@ Future deleteFilesFromRemoteOnly( BuildContext context, List files) async { files.removeWhere((element) => element.uploadedFileID == null); if (files.isEmpty) { - showToast("Selected files are not on ente"); + showToast(context, "Selected files are not on ente"); return; } final dialog = createProgressDialog(context, "Deleting..."); @@ -239,7 +239,7 @@ Future deleteFromTrash(BuildContext context, List files) async { await dialog.show(); try { await TrashSyncService.instance.deleteFromTrash(files); - showShortToast("Successfully deleted"); + showShortToast(context, "Successfully deleted"); await dialog.hide(); Bus.instance .fire(FilesUpdatedEvent(files, type: EventType.deletedFromEverywhere)); @@ -263,7 +263,7 @@ Future emptyTrash(BuildContext context) async { await dialog.show(); try { await TrashSyncService.instance.emptyTrash(); - showShortToast("Trash emptied"); + showShortToast(context, "Trash emptied"); await dialog.hide(); return true; } catch (e, s) { @@ -307,7 +307,7 @@ Future deleteLocalFiles( Bus.instance.fire(LocalPhotosUpdatedEvent(deletedFiles)); return true; } else { - showToast("Could not free up space"); + showToast(context, "Could not free up space"); return false; } } diff --git a/lib/utils/magic_util.dart b/lib/utils/magic_util.dart index b348e5ac6..4b3faeadd 100644 --- a/lib/utils/magic_util.dart +++ b/lib/utils/magic_util.dart @@ -22,9 +22,11 @@ Future changeVisibility( await dialog.show(); try { await FileMagicService.instance.changeVisibility(files, newVisibility); - showShortToast(newVisibility == kVisibilityArchive - ? "Successfully hidden" - : "Successfully unhidden"); + showShortToast( + context, + newVisibility == kVisibilityArchive + ? "Successfully hidden" + : "Successfully unhidden"); await dialog.hide(); } catch (e, s) { @@ -44,9 +46,11 @@ Future changeCollectionVisibility( await CollectionsService.instance.updateMagicMetadata(collection, update); // Force reload home gallery to pull in the now unarchived files Bus.instance.fire(ForceReloadHomeGalleryEvent()); - showShortToast(newVisibility == kVisibilityArchive - ? "Successfully hidden" - : "Successfully unhidden"); + showShortToast( + context, + newVisibility == kVisibilityArchive + ? "Successfully hidden" + : "Successfully unhidden"); await dialog.hide(); } catch (e, s) { @@ -63,7 +67,7 @@ Future editTime( context, files, kPubMagicKeyEditedTime, editedTime); return true; } catch (e, s) { - showToast('something went wrong'); + showToast(context, 'something went wrong'); return false; } } @@ -92,7 +96,7 @@ Future editFilename( context, List.of([file]), kPubMagicKeyEditedName, result); return true; } catch (e, s) { - showToast('something went wrong'); + showToast(context, 'something went wrong'); return false; } } @@ -107,7 +111,7 @@ Future _updatePublicMetadata( try { Map update = {key: value}; await FileMagicService.instance.updatePublicMagicMetadata(files, update); - showShortToast('done'); + showShortToast(context, '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 605559dfc..bb48c1715 100644 --- a/lib/utils/toast_util.dart +++ b/lib/utils/toast_util.dart @@ -3,9 +3,13 @@ import 'dart:io'; import 'package:flutter/material.dart'; import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:fluttertoast/fluttertoast.dart'; +import 'package:photos/ente_theme_data.dart'; -Future showToast(String message, - {toastLength = Toast.LENGTH_LONG}) async { +Future showToast( + BuildContext context, + String message, { + toastLength = Toast.LENGTH_LONG, +}) async { if (Platform.isAndroid) { await Fluttertoast.cancel(); return Fluttertoast.showToast( @@ -13,14 +17,14 @@ Future showToast(String message, toastLength: toastLength, gravity: ToastGravity.BOTTOM, timeInSecForIosWeb: 1, - backgroundColor: Color.fromRGBO(127, 127, 127, 0.8), - textColor: Colors.white, + backgroundColor: Theme.of(context).colorScheme.toastBackgroundColor, + textColor: Theme.of(context).colorScheme.toastTextColor, fontSize: 16.0); } else { EasyLoading.instance - ..backgroundColor = Color.fromRGBO(127, 127, 127, 0.8) - ..indicatorColor = Color.fromRGBO(127, 127, 127, 0.8) - ..textColor = Colors.white + ..backgroundColor = Theme.of(context).colorScheme.toastBackgroundColor + ..indicatorColor = Theme.of(context).colorScheme.toastBackgroundColor + ..textColor = Theme.of(context).colorScheme.toastTextColor ..userInteractions = true ..loadingStyle = EasyLoadingStyle.custom; return EasyLoading.showToast( @@ -31,6 +35,6 @@ Future showToast(String message, } } -Future showShortToast(String message) { - return showToast(message, toastLength: Toast.LENGTH_SHORT); +Future showShortToast(context, String message) { + return showToast(context, message, toastLength: Toast.LENGTH_SHORT); }