Skip to content

armgit / ente

Public Imported from GitHub
0

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

[mobile][photos] add animation to crafting memories banner

Priyanshu Dangare9003165c3b75
diff --git a/mobile/apps/photos/assets/horts0.png b/mobile/apps/photos/assets/horts0.png
new file mode 100644
index 0000000000..4ceaafa18c
Binary files /dev/null and b/mobile/apps/photos/assets/horts0.png differ
diff --git a/mobile/apps/photos/assets/horts1.png b/mobile/apps/photos/assets/horts1.png
new file mode 100644
index 0000000000..2b2a2cde66
Binary files /dev/null and b/mobile/apps/photos/assets/horts1.png differ
diff --git a/mobile/apps/photos/assets/horts2.png b/mobile/apps/photos/assets/horts2.png
new file mode 100644
index 0000000000..92d4e3f9dd
Binary files /dev/null and b/mobile/apps/photos/assets/horts2.png differ
diff --git a/mobile/apps/photos/assets/horts3.png b/mobile/apps/photos/assets/horts3.png
new file mode 100644
index 0000000000..7b764d2b6a
Binary files /dev/null and b/mobile/apps/photos/assets/horts3.png differ
diff --git a/mobile/apps/photos/assets/horts4.png b/mobile/apps/photos/assets/horts4.png
new file mode 100644
index 0000000000..545b797327
Binary files /dev/null and b/mobile/apps/photos/assets/horts4.png differ
diff --git a/mobile/apps/photos/lib/ui/home/memories/craft_memories.dart b/mobile/apps/photos/lib/ui/home/memories/craft_memories.dart
index 512b247f19..7c2a31e04f 100644
--- a/mobile/apps/photos/lib/ui/home/memories/craft_memories.dart
+++ b/mobile/apps/photos/lib/ui/home/memories/craft_memories.dart
@@ -4,6 +4,7 @@ import "package:flutter/material.dart";
import "package:hugeicons/hugeicons.dart";
import "package:photos/service_locator.dart";
import "package:photos/services/notification_service.dart";
+import "package:photos/ui/home/memories/horts.dart";
import "package:photos/ui/home/memories/memory_cover_widget.dart";
class CraftMemories extends StatelessWidget {
@@ -44,9 +45,7 @@ class CraftMemories extends StatelessWidget {
},
child: Stack(
children: [
- Positioned.fill(
- child: Image.asset("assets/memories.jpg", fit: .cover),
- ),
+ const Positioned.fill(child: Horts()),
Padding(
padding: EdgeInsets.all(width * 0.125),
child: Column(
diff --git a/mobile/apps/photos/lib/ui/home/memories/horts.dart b/mobile/apps/photos/lib/ui/home/memories/horts.dart
new file mode 100644
index 0000000000..755ba8ce02
--- /dev/null
+++ b/mobile/apps/photos/lib/ui/home/memories/horts.dart
@@ -0,0 +1,113 @@
+import "package:flutter/widgets.dart";
+
+class PhaseOffset extends Animatable<double> {
+ const PhaseOffset(this.offset) : assert(offset >= 0 && offset < 1);
+
+ final double offset;
+
+ @override
+ double transform(double t) => (t + offset) % 1.0;
+}
+
+class Horts extends StatefulWidget {
+ const Horts({super.key});
+
+ @override
+ State<StatefulWidget> createState() => _HortsState();
+}
+
+const int _unit = 1200;
+
+class _HortsState extends State<Horts> with SingleTickerProviderStateMixin {
+ late final AnimationController _controller;
+ late final Animation<double> _scaleAnimation;
+
+ @override
+ void initState() {
+ super.initState();
+ _controller = AnimationController(
+ vsync: this,
+ duration: const Duration(milliseconds: 4 * _unit),
+ );
+ _scaleAnimation = _controller.drive(
+ TweenSequence<double>([
+ TweenSequenceItem(tween: Tween(begin: 1.0, end: 1.2), weight: 1),
+ TweenSequenceItem(tween: Tween(begin: 1.2, end: 1.0), weight: 1),
+ TweenSequenceItem(tween: Tween(begin: 1.0, end: 1.2), weight: 1),
+ TweenSequenceItem(tween: Tween(begin: 1.2, end: 1.0), weight: 1),
+ ]),
+ );
+ _controller.repeat();
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ return AnimatedBuilder(
+ animation: _controller,
+ builder: (context, _) {
+ final layers = _createLayers()
+ ..sort((a, b) {
+ final aProgress = (_controller.value + a.offset) % 1.0;
+ final bProgress = (_controller.value + b.offset) % 1.0;
+ return bProgress.compareTo(aProgress);
+ });
+ return Stack(
+ children: [
+ for (final layer in layers) Positioned.fill(child: layer),
+ Positioned.fill(
+ child: ScaleTransition(
+ scale: _scaleAnimation,
+ child: Image.asset("assets/horts0.png", scale: 2),
+ ),
+ ),
+ ],
+ );
+ },
+ );
+ }
+
+ List<_Hort> _createLayers() {
+ const double n = 1 / 8;
+ return [
+ _Hort(_controller, "assets/horts1.png", n * 0),
+ _Hort(_controller, "assets/horts2.png", n * 1),
+ _Hort(_controller, "assets/horts3.png", n * 2),
+ _Hort(_controller, "assets/horts4.png", n * 3),
+ _Hort(_controller, "assets/horts1.png", n * 4),
+ _Hort(_controller, "assets/horts2.png", n * 5),
+ _Hort(_controller, "assets/horts3.png", n * 6),
+ _Hort(_controller, "assets/horts4.png", n * 7),
+ ];
+ }
+}
+
+class _Hort extends StatefulWidget {
+ final AnimationController controller;
+ final String path;
+ final double offset;
+
+ _Hort(this.controller, this.path, this.offset) : super(key: ValueKey(offset));
+
+ @override
+ State<_Hort> createState() => _HortState();
+}
+
+class _HortState extends State<_Hort> with SingleTickerProviderStateMixin {
+ late final Animation<double> _scaleAnimation;
+
+ @override
+ void initState() {
+ super.initState();
+ _scaleAnimation = widget.controller
+ .drive(PhaseOffset(widget.offset))
+ .drive(Tween<double>(begin: 0.0, end: 6.0));
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ return ScaleTransition(
+ scale: _scaleAnimation,
+ child: Image.asset(widget.path),
+ );
+ }
+}