π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
[photos] Add Christmas pull-to-reveal animation
AmanRajSinghMouryaec0f0cb41901
diff --git a/mobile/apps/photos/assets/x_mas.riv b/mobile/apps/photos/assets/x_mas.rivnew file mode 100644index 0000000000..ffd0ad200fBinary files /dev/null and b/mobile/apps/photos/assets/x_mas.riv differdiff --git a/mobile/apps/photos/assets/x_mas_banner.riv b/mobile/apps/photos/assets/x_mas_banner.rivnew file mode 100644index 0000000000..432ba9253fBinary files /dev/null and b/mobile/apps/photos/assets/x_mas_banner.riv differdiff --git a/mobile/apps/photos/lib/ui/home/christmas/christmas_lights_banner.dart b/mobile/apps/photos/lib/ui/home/christmas/christmas_lights_banner.dartnew file mode 100644index 0000000000..3971f709a0--- /dev/null+++ b/mobile/apps/photos/lib/ui/home/christmas/christmas_lights_banner.dart@@ -0,0 +1,53 @@+import "package:flutter/material.dart";+import "package:rive/rive.dart" as rive;++class ChristmasLightsBanner extends StatefulWidget {+ const ChristmasLightsBanner({super.key});++ @override+ State<ChristmasLightsBanner> createState() => _ChristmasLightsBannerState();+}++class _ChristmasLightsBannerState extends State<ChristmasLightsBanner> {+ late final rive.FileLoader _riveFileLoader;++ @override+ void initState() {+ super.initState();+ _riveFileLoader = rive.FileLoader.fromAsset(+ "assets/x_mas_banner.riv",+ riveFactory: rive.Factory.flutter,+ );+ }++ @override+ void dispose() {+ _riveFileLoader.dispose();+ super.dispose();+ }++ @override+ Widget build(BuildContext context) {+ return Container(+ color: Colors.redAccent,+ height: 10,+ width: double.infinity,+ child: rive.RiveWidgetBuilder(+ fileLoader: _riveFileLoader,+ stateMachineSelector: const rive.StateMachineNamed("State Machine 1"),+ builder: (BuildContext context, rive.RiveState state) {+ if (state is rive.RiveLoaded) {+ return rive.RiveWidget(+ controller: state.controller,+ fit: rive.Fit.cover,+ );+ }+ if (state is rive.RiveFailed) {+ return const SizedBox.shrink();+ }+ return const SizedBox.shrink();+ },+ ),+ );+ }+}diff --git a/mobile/apps/photos/lib/ui/home/christmas/christmas_pull_animation.dart b/mobile/apps/photos/lib/ui/home/christmas/christmas_pull_animation.dartnew file mode 100644index 0000000000..18989dc14e--- /dev/null+++ b/mobile/apps/photos/lib/ui/home/christmas/christmas_pull_animation.dart@@ -0,0 +1,106 @@+import "package:flutter/material.dart";+import "package:rive/rive.dart" as rive;++/// Overlay widget that appears at the top of the screen when pulling down.+/// This shows the Merry Christmas animation with the duck character.+class ChristmasPullOverlay extends StatefulWidget {+ final double pullOffset;+ final bool isReleased;+ final double triggerThreshold;++ const ChristmasPullOverlay({+ super.key,+ required this.pullOffset,+ this.isReleased = false,+ this.triggerThreshold = 60,+ });++ @override+ State<ChristmasPullOverlay> createState() => _ChristmasPullOverlayState();+}++class _ChristmasPullOverlayState extends State<ChristmasPullOverlay> {+ late final rive.FileLoader _riveFileLoader;+ rive.BooleanInput? _triggerInput;++ @override+ void initState() {+ super.initState();+ _riveFileLoader = rive.FileLoader.fromAsset(+ "assets/x_mas.riv",+ riveFactory: rive.Factory.flutter,+ );+ }++ @override+ void dispose() {+ _riveFileLoader.dispose();+ super.dispose();+ }++ @override+ void didUpdateWidget(ChristmasPullOverlay oldWidget) {+ super.didUpdateWidget(oldWidget);++ // Set trigger to true when pulled past threshold+ if (widget.pullOffset >= widget.triggerThreshold) {+ _triggerInput?.value = true;+ }++ // Set trigger to false when released+ if (widget.isReleased) {+ _triggerInput?.value = false;+ }+ }++ void _onRiveLoaded(rive.RiveLoaded loaded) {+ final controller = loaded.controller;+ _triggerInput = controller.stateMachine.boolean("Trigger");+ }++ @override+ Widget build(BuildContext context) {+ final double pullOffset = widget.pullOffset;+ if (pullOffset <= 0) {+ return const SizedBox.shrink();+ }++ // Multiplier to reveal animation faster with less scrolling+ const double multiplier = 35.0;+ final double animationHeight = pullOffset * multiplier;++ return SizedBox(+ height: pullOffset,+ width: double.infinity,+ child: ClipRect(+ child: OverflowBox(+ maxHeight: animationHeight,+ alignment: Alignment.bottomCenter,+ child: SizedBox(+ height: animationHeight,+ width: double.infinity,+ child: rive.RiveWidgetBuilder(+ fileLoader: _riveFileLoader,+ stateMachineSelector:+ const rive.StateMachineNamed("State Machine 1"),+ onLoaded: _onRiveLoaded,+ builder: (BuildContext context, rive.RiveState state) {+ if (state is rive.RiveLoaded) {+ return rive.RiveWidget(+ controller: state.controller,+ fit: rive.Fit.fitWidth,+ alignment: Alignment.bottomCenter,+ );+ }+ if (state is rive.RiveFailed) {+ return const SizedBox.shrink();+ }+ return const SizedBox.shrink();+ },+ ),+ ),+ ),+ ),+ );+ }+}diff --git a/mobile/apps/photos/lib/ui/home/status_bar_widget.dart b/mobile/apps/photos/lib/ui/home/status_bar_widget.dartindex 5e23c24441..7b24f281e8 100644--- a/mobile/apps/photos/lib/ui/home/status_bar_widget.dart+++ b/mobile/apps/photos/lib/ui/home/status_bar_widget.dart@@ -15,6 +15,7 @@ import 'package:photos/theme/text_style.dart';import 'package:photos/ui/account/verify_recovery_page.dart';import 'package:photos/ui/components/home_header_widget.dart';import 'package:photos/ui/components/notification_widget.dart';+import 'package:photos/ui/home/christmas/christmas_lights_banner.dart';import 'package:photos/ui/home/header_error_widget.dart';import "package:photos/ui/settings/backup/backup_settings_screen.dart";import "package:photos/ui/settings/backup/backup_status_screen.dart";@@ -97,6 +98,7 @@ class _StatusBarWidgetState extends State<StatusBarWidget> {Widget build(BuildContext context) {return Column(children: [+ const ChristmasLightsBanner(),HomeHeaderWidget(centerWidget: _showStatus && !_showErrorBanner? GestureDetector(diff --git a/mobile/apps/photos/lib/ui/tabs/home_widget.dart b/mobile/apps/photos/lib/ui/tabs/home_widget.dartindex 2a0d0f3644..fd711bfda2 100644--- a/mobile/apps/photos/lib/ui/tabs/home_widget.dart+++ b/mobile/apps/photos/lib/ui/tabs/home_widget.dart@@ -59,6 +59,7 @@ import "package:photos/ui/common/web_page.dart";import "package:photos/ui/components/buttons/button_widget.dart";import "package:photos/ui/components/models/button_type.dart";import "package:photos/ui/extents_page_view.dart";+import "package:photos/ui/home/christmas/christmas_pull_animation.dart";import "package:photos/ui/home/grant_permissions_widget.dart";import "package:photos/ui/home/header_widget.dart";import "package:photos/ui/home/home_bottom_nav_bar.dart";@@ -104,6 +105,10 @@ class _HomeWidgetState extends State<HomeWidget> {final PageController _pageController = PageController();int _selectedTabIndex = 0;+ final ValueNotifier<double> _christmasPullOffsetNotifier =+ ValueNotifier<double>(0);+ final ValueNotifier<bool> _christmasPullReleasedNotifier =+ ValueNotifier<bool>(false);// for receiving media files// ignore: unused_field@@ -535,6 +540,8 @@ class _HomeWidgetState extends State<HomeWidget> {_publicAlbumLinkSubscription.cancel();_homepageSwipeToSelectInProgressEventSubscription.cancel();_swipeToSelectInProgressNotifier.dispose();+ _christmasPullOffsetNotifier.dispose();+ _christmasPullReleasedNotifier.dispose();activityService.stateNotifier.removeListener(_activityStateListener);super.dispose();}@@ -747,13 +754,39 @@ class _HomeWidgetState extends State<HomeWidget> {): null,onDrawerChanged: (isOpened) => isSettingsOpen = isOpened,- body: SafeArea(- bottom: false,- child: Builder(- builder: (context) {- return _getBody(context);- },- ),+ body: Stack(+ children: [+ SafeArea(+ bottom: false,+ child: Builder(+ builder: (context) {+ return _getBody(context);+ },+ ),+ ),+ ValueListenableBuilder<double>(+ valueListenable: _christmasPullOffsetNotifier,+ builder: (context, pullOffset, child) {+ if (pullOffset <= 0) {+ return const SizedBox.shrink();+ }+ return ValueListenableBuilder<bool>(+ valueListenable: _christmasPullReleasedNotifier,+ builder: (context, isReleased, child) {+ return Positioned(+ top: 0,+ left: 0,+ right: 0,+ child: ChristmasPullOverlay(+ pullOffset: pullOffset,+ isReleased: isReleased,+ ),+ );+ },+ );+ },+ ),+ ],),///To fix the status bar not adapting it's color when switching@@ -838,12 +871,30 @@ class _HomeWidgetState extends State<HomeWidget> {],);},- child: HomeGalleryWidget(- header: const HeaderWidget(),- footer: const SizedBox(- height: 160,+ child: NotificationListener<ScrollNotification>(+ onNotification: (notification) {+ if (notification is ScrollUpdateNotification) {+ final double overscroll = notification.metrics.pixels;+ if (overscroll < 0) {+ _christmasPullOffsetNotifier.value = -overscroll;+ _christmasPullReleasedNotifier.value = false;+ } else if (_christmasPullOffsetNotifier.value != 0) {+ _christmasPullOffsetNotifier.value = 0;+ }+ } else if (notification is ScrollEndNotification) {+ if (_christmasPullOffsetNotifier.value > 0) {+ _christmasPullReleasedNotifier.value = true;+ }+ }+ return false;+ },+ child: HomeGalleryWidget(+ header: const HeaderWidget(),+ footer: const SizedBox(+ height: 160,+ ),+ selectedFiles: _selectedFiles,),- selectedFiles: _selectedFiles,),);},