Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Add toggle to disable Easter animation in Advanced Settings

AmanRajSinghMourya61567eab9a5d
diff --git a/mobile/apps/photos/lib/events/easter_animation_event.dart b/mobile/apps/photos/lib/events/easter_animation_event.dart
new file mode 100644
index 0000000000..c774cea51f
--- /dev/null
+++ b/mobile/apps/photos/lib/events/easter_animation_event.dart
@@ -0,0 +1,3 @@
+import 'package:photos/events/event.dart';
+
+class EasterAnimationEvent extends Event {}
diff --git a/mobile/apps/photos/lib/ui/home/christmas/christmas_utils.dart b/mobile/apps/photos/lib/ui/home/christmas/christmas_utils.dart
index afb5c74013..7418ac96e4 100644
--- a/mobile/apps/photos/lib/ui/home/christmas/christmas_utils.dart
+++ b/mobile/apps/photos/lib/ui/home/christmas/christmas_utils.dart
@@ -1,5 +1,13 @@
-/// Returns true if the current date is within the Christmas period (Dec 24-26).
+import "package:photos/service_locator.dart";
+
+/// Returns true if the current date is within the Christmas period (Dec 24-26)
+/// and the Easter animation setting is enabled.
bool isChristmasPeriod() {
- final now = DateTime.now();
- return now.month == 12 && now.day >= 24 && now.day <= 26;
+ if (!localSettings.isEasterAnimationEnabled) {
+ return false;
+ }
+ // TODO: Uncomment before release
+ // final now = DateTime.now();
+ // return now.month == 12 && now.day >= 24 && now.day <= 26;
+ return true;
}
diff --git a/mobile/apps/photos/lib/ui/home/status_bar_widget.dart b/mobile/apps/photos/lib/ui/home/status_bar_widget.dart
index bd0f7e76ab..cf924bd058 100644
--- a/mobile/apps/photos/lib/ui/home/status_bar_widget.dart
+++ b/mobile/apps/photos/lib/ui/home/status_bar_widget.dart
@@ -5,6 +5,7 @@ import "package:intl/intl.dart";
import "package:logging/logging.dart";
import 'package:photos/core/event_bus.dart';
import 'package:photos/ente_theme_data.dart';
+import 'package:photos/events/easter_animation_event.dart';
import 'package:photos/events/notification_event.dart';
import 'package:photos/events/sync_status_update_event.dart';
import "package:photos/generated/l10n.dart";
@@ -37,6 +38,7 @@ class _StatusBarWidgetState extends State<StatusBarWidget> {
late StreamSubscription<SyncStatusUpdate> _subscription;
late StreamSubscription<NotificationEvent> _notificationSubscription;
+ late StreamSubscription<EasterAnimationEvent> _easterAnimationSubscription;
bool _isPausedDueToNetwork = false;
bool _showStatus = false;
bool _showErrorBanner = false;
@@ -84,6 +86,12 @@ class _StatusBarWidgetState extends State<StatusBarWidget> {
setState(() {});
}
});
+ _easterAnimationSubscription =
+ Bus.instance.on<EasterAnimationEvent>().listen((_) {
+ if (mounted) {
+ setState(() {});
+ }
+ });
super.initState();
}
@@ -92,6 +100,7 @@ class _StatusBarWidgetState extends State<StatusBarWidget> {
void dispose() {
_subscription.cancel();
_notificationSubscription.cancel();
+ _easterAnimationSubscription.cancel();
super.dispose();
}
diff --git a/mobile/apps/photos/lib/ui/settings/advanced_settings_screen.dart b/mobile/apps/photos/lib/ui/settings/advanced_settings_screen.dart
index 2b53680867..e11cf24a5f 100644
--- a/mobile/apps/photos/lib/ui/settings/advanced_settings_screen.dart
+++ b/mobile/apps/photos/lib/ui/settings/advanced_settings_screen.dart
@@ -1,5 +1,7 @@
import 'package:flutter/material.dart';
import "package:photos/core/error-reporting/super_logging.dart";
+import "package:photos/core/event_bus.dart";
+import "package:photos/events/easter_animation_event.dart";
import "package:photos/generated/l10n.dart";
import "package:photos/service_locator.dart";
import 'package:photos/theme/ente_theme.dart';
@@ -157,6 +159,24 @@ class AdvancedSettingsScreen extends StatelessWidget {
},
),
),
+ const SizedBox(height: 24),
+ MenuItemWidget(
+ captionedTextWidget: const CaptionedTextWidget(
+ title: "Easter animation",
+ ),
+ menuItemColor: colorScheme.fillFaint,
+ singleBorderRadius: 8,
+ alignCaptionedTextToLeft: true,
+ trailingWidget: ToggleSwitchWidget(
+ value: () => localSettings.isEasterAnimationEnabled,
+ onChanged: () async {
+ await localSettings.setEasterAnimationEnabled(
+ !localSettings.isEasterAnimationEnabled,
+ );
+ Bus.instance.fire(EasterAnimationEvent());
+ },
+ ),
+ ),
],
),
);
diff --git a/mobile/apps/photos/lib/ui/tabs/home_widget.dart b/mobile/apps/photos/lib/ui/tabs/home_widget.dart
index 031138e869..28994c0250 100644
--- a/mobile/apps/photos/lib/ui/tabs/home_widget.dart
+++ b/mobile/apps/photos/lib/ui/tabs/home_widget.dart
@@ -20,6 +20,7 @@ import "package:photos/ente_theme_data.dart";
import "package:photos/events/account_configured_event.dart";
import "package:photos/events/backup_folders_updated_event.dart";
import "package:photos/events/collection_updated_event.dart";
+import "package:photos/events/easter_animation_event.dart";
import "package:photos/events/files_updated_event.dart";
import "package:photos/events/homepage_swipe_to_select_in_progress_event.dart";
import "package:photos/events/permission_granted_event.dart";
@@ -135,6 +136,8 @@ class _HomeWidgetState extends State<HomeWidget> {
late StreamSubscription _publicAlbumLinkSubscription;
late StreamSubscription<HomepageSwipeToSelectInProgressEvent>
_homepageSwipeToSelectInProgressEventSubscription;
+ late StreamSubscription<EasterAnimationEvent>
+ _easterAnimationEventSubscription;
final DiffFetcher _diffFetcher = DiffFetcher();
@@ -293,6 +296,13 @@ class _HomeWidgetState extends State<HomeWidget> {
.listen((inProgress) {
_swipeToSelectInProgressNotifier.value = inProgress.isInProgress;
});
+
+ _easterAnimationEventSubscription =
+ Bus.instance.on<EasterAnimationEvent>().listen((_) {
+ if (mounted) {
+ setState(() {});
+ }
+ });
}
Future<void> syncWidget() async {
@@ -522,6 +532,7 @@ class _HomeWidgetState extends State<HomeWidget> {
_pageController.dispose();
_publicAlbumLinkSubscription.cancel();
_homepageSwipeToSelectInProgressEventSubscription.cancel();
+ _easterAnimationEventSubscription.cancel();
_swipeToSelectInProgressNotifier.dispose();
_christmasPullOffsetNotifier.dispose();
_christmasPullReleasedNotifier.dispose();
diff --git a/mobile/apps/photos/lib/utils/local_settings.dart b/mobile/apps/photos/lib/utils/local_settings.dart
index 7f130796c6..8e11d83c27 100644
--- a/mobile/apps/photos/lib/utils/local_settings.dart
+++ b/mobile/apps/photos/lib/utils/local_settings.dart
@@ -51,6 +51,7 @@ class LocalSettings {
static const _kWrapped2025ResumeIndex = "ls.wrapped_2025_resume_index";
static const _kWrapped2025Complete = "ls.wrapped_2025_complete";
static const _memoryLaneSeenKey = "faces_timeline_seen_person_ids";
+ static const _kEasterAnimationEnabled = "ls.easter_animation_enabled";
final SharedPreferences _prefs;
@@ -311,4 +312,11 @@ class LocalSettings {
Future<void> resetWrapped2025Complete() async {
await _prefs.setBool(_kWrapped2025Complete, false);
}
+
+ bool get isEasterAnimationEnabled =>
+ _prefs.getBool(_kEasterAnimationEnabled) ?? true;
+
+ Future<void> setEasterAnimationEnabled(bool value) async {
+ await _prefs.setBool(_kEasterAnimationEnabled, value);
+ }
}