π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
[mob][photos] Add Rewind home banner animation
laurenspriem957603e31fdf
diff --git a/mobile/apps/photos/assets/ente_rewind_banner.riv b/mobile/apps/photos/assets/ente_rewind_banner.rivnew file mode 100644index 0000000000..c650fcbd4cBinary files /dev/null and b/mobile/apps/photos/assets/ente_rewind_banner.riv differdiff --git a/mobile/apps/photos/lib/ui/home/header_widget.dart b/mobile/apps/photos/lib/ui/home/header_widget.dartindex 6d978403d7..830542cac6 100644--- a/mobile/apps/photos/lib/ui/home/header_widget.dart+++ b/mobile/apps/photos/lib/ui/home/header_widget.dart@@ -4,7 +4,7 @@ import 'package:photos/service_locator.dart';import "package:photos/services/wrapped/wrapped_service.dart";import "package:photos/ui/home/memories/memories_widget.dart";import 'package:photos/ui/home/status_bar_widget.dart';-import "package:photos/ui/wrapped/wrapped_home_banner.dart";+import "package:photos/ui/wrapped/rewind_banner.dart";class HeaderWidget extends StatefulWidget {const HeaderWidget({@@ -54,7 +54,7 @@ class _HeaderWidgetState extends State<HeaderWidget> {const MemoriesWidget(),];if (showWrappedBanner) {- children.add(WrappedHomeBanner(state: _wrappedState));+ children.add(RewindBanner(state: _wrappedState));}return Column(crossAxisAlignment: CrossAxisAlignment.start,diff --git a/mobile/apps/photos/lib/ui/wrapped/rewind_banner.dart b/mobile/apps/photos/lib/ui/wrapped/rewind_banner.dartnew file mode 100644index 0000000000..b3d77cc219--- /dev/null+++ b/mobile/apps/photos/lib/ui/wrapped/rewind_banner.dart@@ -0,0 +1,57 @@+import "package:flutter/material.dart";+import "package:photos/services/wrapped/wrapped_service.dart"+ show WrappedEntryState;+import "package:photos/ui/wrapped/wrapped_rewind_banner_button.dart";++class RewindBanner extends StatelessWidget {+ const RewindBanner({+ required this.state,+ super.key,+ });++ final WrappedEntryState state;++ @override+ Widget build(BuildContext context) {+ final bool hasProgress = state.resumeIndex > 0 &&+ state.resumeIndex < (state.result?.cards.length ?? 0);+ final String semanticsLabel = hasProgress && !state.isComplete+ ? "Resume Ente Rewind 2025"+ : "Open Ente Rewind 2025";++ const double bleed = 12;+ const double bannerHeight = 164;++ return Padding(+ padding: const EdgeInsets.only(top: 12, bottom: 8),+ child: LayoutBuilder(+ builder: (BuildContext context, BoxConstraints constraints) {+ final double baseWidth =+ constraints.hasBoundedWidth && constraints.maxWidth.isFinite+ ? constraints.maxWidth+ : MediaQuery.sizeOf(context).width;+ final double targetWidth = baseWidth + bleed * 2;++ return SizedBox(+ height: bannerHeight,+ child: OverflowBox(+ alignment: Alignment.center,+ minWidth: targetWidth,+ maxWidth: targetWidth,+ minHeight: bannerHeight,+ maxHeight: bannerHeight,+ child: SizedBox(+ width: targetWidth,+ height: bannerHeight,+ child: WrappedRewindBannerButton(+ height: bannerHeight,+ semanticsLabel: semanticsLabel,+ ),+ ),+ ),+ );+ },+ ),+ );+ }+}diff --git a/mobile/apps/photos/lib/ui/wrapped/wrapped_home_banner.dart b/mobile/apps/photos/lib/ui/wrapped/wrapped_home_banner.dartdeleted file mode 100644index b85867b15c..0000000000--- a/mobile/apps/photos/lib/ui/wrapped/wrapped_home_banner.dart+++ /dev/null@@ -1,98 +0,0 @@-import "package:flutter/material.dart";-import "package:photos/service_locator.dart";-import "package:photos/services/wrapped/models.dart";-import "package:photos/services/wrapped/wrapped_service.dart";-import "package:photos/theme/ente_theme.dart";-import "package:photos/ui/notification/toast.dart";-import "package:photos/ui/wrapped/wrapped_viewer_page.dart";--class WrappedHomeBanner extends StatelessWidget {- const WrappedHomeBanner({- required this.state,- super.key,- });-- final WrappedEntryState state;-- @override- Widget build(BuildContext context) {- final enteColorScheme = getEnteColorScheme(context);- final textTheme = getEnteTextTheme(context);- final bool hasProgress = state.resumeIndex > 0 &&- state.resumeIndex < (state.result?.cards.length ?? 0);-- const String title = "Your 2025 Rewind";- final String subtitle = hasProgress && !state.isComplete- ? "Resume where you left off"- : "See your 2025 highlights";-- return Padding(- padding: const EdgeInsets.fromLTRB(12, 12, 12, 8),- child: Material(- color: enteColorScheme.backgroundElevated,- borderRadius: BorderRadius.circular(20),- child: InkWell(- borderRadius: BorderRadius.circular(20),- onTap: () => _handleTap(context),- child: Padding(- padding: const EdgeInsets.symmetric(horizontal: 18, vertical: 20),- child: Row(- children: [- Container(- width: 48,- height: 48,- decoration: BoxDecoration(- color: enteColorScheme.primary400.withValues(alpha: 0.16),- borderRadius: BorderRadius.circular(16),- ),- child: Icon(- Icons.auto_awesome,- color: enteColorScheme.primary500,- ),- ),- const SizedBox(width: 16),- Expanded(- child: Column(- crossAxisAlignment: CrossAxisAlignment.start,- mainAxisSize: MainAxisSize.min,- children: [- Text(- title,- style: textTheme.largeBold,- ),- const SizedBox(height: 4),- Text(- subtitle,- style: textTheme.smallMuted,- ),- ],- ),- ),- Icon(- Icons.chevron_right_rounded,- color: enteColorScheme.textMuted,- ),- ],- ),- ),- ),- ),- );- }-- void _handleTap(BuildContext context) {- final WrappedEntryState currentState = wrappedService.state;- final WrappedResult? result = currentState.result;- if (result == null || result.cards.isEmpty) {- showShortToast(context, "Ente Rewind isn't ready yet");- return;- }- Navigator.of(context).push(- MaterialPageRoute<void>(- builder: (BuildContext context) => WrappedViewerPage(- initialState: currentState,- ),- ),- );- }-}diff --git a/mobile/apps/photos/lib/ui/wrapped/wrapped_rewind_banner_button.dart b/mobile/apps/photos/lib/ui/wrapped/wrapped_rewind_banner_button.dartnew file mode 100644index 0000000000..270839a0ed--- /dev/null+++ b/mobile/apps/photos/lib/ui/wrapped/wrapped_rewind_banner_button.dart@@ -0,0 +1,160 @@+import "package:flutter/material.dart";+import "package:photos/service_locator.dart";+import "package:photos/services/wrapped/models.dart";+import "package:photos/services/wrapped/wrapped_service.dart";+import "package:photos/theme/ente_theme.dart";+import "package:photos/ui/notification/toast.dart";+import "package:photos/ui/wrapped/wrapped_viewer_page.dart";+import "package:rive/rive.dart" show Artboard, Fill, RiveAnimation;++class WrappedRewindBannerButton extends StatefulWidget {+ const WrappedRewindBannerButton({+ super.key,+ this.height,+ this.semanticsLabel,+ });++ final double? height;+ final String? semanticsLabel;++ @override+ State<WrappedRewindBannerButton> createState() =>+ _WrappedRewindBannerButtonState();+}++class _WrappedRewindBannerButtonState extends State<WrappedRewindBannerButton> {+ double? _artboardAspectRatio;++ @override+ Widget build(BuildContext context) {+ final enteColorScheme = getEnteColorScheme(context);+ final textTheme = getEnteTextTheme(context);+ const BorderRadius borderRadius = BorderRadius.all(Radius.circular(24));++ return Semantics(+ button: true,+ label: widget.semanticsLabel,+ child: Material(+ color: Colors.transparent,+ borderRadius: borderRadius,+ child: InkWell(+ borderRadius: borderRadius,+ onTap: () => _handleTap(context),+ child: LayoutBuilder(+ builder: (BuildContext context, BoxConstraints constraints) {+ final double availableWidth =+ constraints.hasBoundedWidth && constraints.maxWidth.isFinite+ ? constraints.maxWidth+ : MediaQuery.sizeOf(context).width;+ double? resolvedHeight = widget.height;+ if (resolvedHeight == null &&+ _artboardAspectRatio != null &&+ _artboardAspectRatio! > 0 &&+ availableWidth.isFinite) {+ resolvedHeight = availableWidth / _artboardAspectRatio!;+ }+ resolvedHeight ??= 128;++ return ClipRRect(+ borderRadius: borderRadius,+ child: SizedBox(+ height: resolvedHeight,+ width: double.infinity,+ child: Stack(+ alignment: Alignment.center,+ children: [+ Positioned.fill(+ child: RiveAnimation.asset(+ "assets/ente_rewind_banner.riv",+ fit: BoxFit.cover,+ stateMachines: const ["State Machine 1"],+ onInit: _onRiveInit,+ ),+ ),+ Container(+ padding: const EdgeInsets.symmetric(+ horizontal: 20,+ vertical: 16,+ ),+ child: Row(+ mainAxisAlignment: MainAxisAlignment.center,+ children: [+ Flexible(+ child: Text(+ "Ente Rewind 2025",+ style: textTheme.largeBold.copyWith(+ color: Colors.white,+ ),+ textAlign: TextAlign.center,+ ),+ ),+ const SizedBox(width: 12),+ Container(+ width: 36,+ height: 36,+ decoration: const BoxDecoration(+ color: Colors.white,+ shape: BoxShape.circle,+ ),+ child: Icon(+ Icons.play_arrow_rounded,+ color: enteColorScheme.textBase,+ size: 24,+ ),+ ),+ ],+ ),+ ),+ ],+ ),+ ),+ );+ },+ ),+ ),+ ),+ );+ }++ void _onRiveInit(Artboard artboard) {+ _sanitizeFillRules(artboard);+ if (!mounted) return;+ final double height = artboard.height;+ final double width = artboard.width;+ if (height <= 0 || width <= 0) {+ return;+ }+ final double aspectRatio = width / height;+ if (aspectRatio == _artboardAspectRatio) {+ return;+ }+ setState(() {+ _artboardAspectRatio = aspectRatio;+ });+ }++ void _sanitizeFillRules(Artboard artboard) {+ artboard.forEachComponent((component) {+ if (component is! Fill) return;+ if (component.fillRule >= PathFillType.values.length) {+ component.fillRule = PathFillType.nonZero.index;+ }+ });+ }++ void _handleTap(BuildContext context) {+ final WrappedEntryState currentState = wrappedService.state;+ final WrappedResult? result = currentState.result;+ if (result == null || result.cards.isEmpty) {+ showShortToast(context, "Ente Rewind isn't ready yet");+ return;+ }+ Navigator.of(context).push(+ MaterialPageRoute<void>(+ builder: (BuildContext context) => WrappedViewerPage(+ initialState: currentState,+ ),+ ),+ );+ }+}