diff --git a/lib/ente_theme_data.dart b/lib/ente_theme_data.dart index b4925120e47c85535f2534d57b646bb47266f8e7..dff7624ad82f1980b278c626d5879e648551a6bc 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 6ea3f540d3fc698d898e28a56be4ac78b8696849..781561ac67247b9cdc79aa57f5d3dff13c304af8 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 af4cd322368612262352f184fb51eeb07e79f946..e3d462e920fee9f0ff5cb520f4dfc517ecc5f1ec 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 4d77c2845b25fe323ec96f0806e98aeb83e03f9c..94b78807f5a5803c4a439dade7723f53ed7085d8 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 8c4d7159b234661ff660f9980b394fe5345f8fbf..fa5658158af4db09ede4a8f582033c0e3c5c7691 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 387090234787dff82300d24a4e23119e72eef295..179605a86ce5caaa739845a6627c95d005cb0f7a 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 65d6565104f1e19647830d0ad23be34da48eed70..51b6ce1e29bf9b8a62f06339009a86049763afbb 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 2b2fdeb106c02f16f001fe9580960bd377e979da..d37f1cab2a4f529e02f11b6a9463f0fdff75cae8 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 0f9df57c1438dfa2ed7976296666ccf53df5bd8e..fcc1ae2f07ec275e9735e0ea824fb3d5fd4fcf43 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 c0b589bd87bb2d1da5f8843a97fd27513d944aba..bda42e26cc372e2c212af0b9de064ce09b241c0c 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 0e7895082dd4146a442a2aa8fccbf663b08a1ffe..36a61a86e86f982d802881ff119b53f2a6cc2daf 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 fc827ba68e0cad2e40a28a64f94474540c563965..93ec932a4ab558318609034b06cf74a381d91063 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 c3eb6377735ba29216fade551dc0863e1a77ed8e..5e3ab7d8815729df8d6ee4d333fcf72a5e956e09 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 f7c4814fc4cf5aaed8d036eb60eb27e8bb47aadf..7cf3b27b19ac3c266ad610cc461957aa423137d0 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 39658adb2f203e5090fe03a75e1705bbc02a72ec..9582d9877f234be984efab3a2d6aa98d24dba1fb 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 018d4f5befd15e8da85af37da602070410115528..a7214cd0455a6b6938b9245d2c2a851e3b217168 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 08214d7e39acceb5aac7d09b1814cc18415d979a..0671b7ae321fdca300e3a40ffac4cca9c7aa0635 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 28167c5bb75b073926a35e9007e70d2700c1c90a..b92cadf58e1e5b7f1514181b082eb89c40139f5a 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 5b6045637792091c7dc47b17ee5db7097a88e4e5..0fd4c9c0be01ef8e38b24e467b77b11ed889f06d 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 42a22af4f97aab4247531720a3e2d2377dcc3013..9a4b51e7a676aac8a07e6119ba60fd9c23fee9ba 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 d750c7661ad3c22d6b7ba6284a37674be3d66380..a879cf584ad715dcbef9f6e62888c9b0802ed3e7 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 8f795078ad245939080bde2c308d839ffb3ba895..618477853f5ee23cada2cd0e93bd233fbd856871 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 3e6d4aa988548ea2d866d73a2ab65fd153002ced..e64db135684b658d2d83fbee5bf0e2f727b25ba2 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 2662511bc3b57bc5c896444be1a22d2352eadc5d..8c99c69f4ea6cc705a6f458d64dd7fba698f999c 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 2bbda1586098e3bca8207071e956a4769fd02d5c..ac8b6d7f1aaef44209a4c0f242a902bd3226c44c 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 4ca1f1ff0db4f935ae3d82468f185e33f5c3dc4c..61c8311b4432af4028db14c01c0ade67331569f3 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 c0f971819d80e1f6d75665299ce45fc5e33ff0a3..2d6ab33c86b8d277933d0288c0f7ef675de61210 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 b348e5ac6359dcfc0664fc966d3b41ddcdd45500..4b3faeadde1890694a81cd227924b7df36e1f453 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 605559dfc18a0c568ec3d7c46394c025c1da13e9..bb48c1715345af5be9eab31175422eeaf1e00944 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); }