Skip to content

armgit / ente

Public Imported from GitHub
0

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

Brighten Rewind cards with mesh gradient

laurenspriema919c4998edd
diff --git a/mobile/apps/photos/lib/ui/wrapped/cards/story_card.dart b/mobile/apps/photos/lib/ui/wrapped/cards/story_card.dart
index d5f9d52a8c..50c70d361d 100644
--- a/mobile/apps/photos/lib/ui/wrapped/cards/story_card.dart
+++ b/mobile/apps/photos/lib/ui/wrapped/cards/story_card.dart
@@ -47,16 +47,20 @@ class _StoryCard extends StatelessWidget {
required this.colorScheme,
required this.textTheme,
required this.isActive,
+ required this.gradientVariantIndex,
});
final WrappedCard card;
final EnteColorScheme colorScheme;
final EnteTextTheme textTheme;
final bool isActive;
+ final int gradientVariantIndex;
@override
Widget build(BuildContext context) {
- final bool isBadge = card.type == WrappedCardType.badge;
+ final bool isBadge = card.type == WrappedCardType.badge ||
+ card.type == WrappedCardType.badgeDebug;
+ final bool showMeshGradient = _shouldApplyMeshGradient(card);
return AnimatedOpacity(
duration: const Duration(milliseconds: 200),
opacity: isActive ? 1.0 : 0.6,
@@ -82,6 +86,10 @@ class _StoryCard extends StatelessWidget {
card: card,
colorScheme: colorScheme,
),
+ if (showMeshGradient)
+ _MeshGradientOverlay(
+ variantIndex: gradientVariantIndex,
+ ),
Positioned.fill(
child: DecoratedBox(
decoration: BoxDecoration(
@@ -117,6 +125,117 @@ class _StoryCard extends StatelessWidget {
}
}
+bool _shouldApplyMeshGradient(WrappedCard card) {
+ switch (card.type) {
+ case WrappedCardType.badge:
+ case WrappedCardType.badgeDebug:
+ case WrappedCardType.yearInColor:
+ case WrappedCardType.monochrome:
+ return false;
+ default:
+ return true;
+ }
+}
+
+class _MeshGradientOverlay extends StatelessWidget {
+ const _MeshGradientOverlay({
+ required this.variantIndex,
+ });
+
+ final int variantIndex;
+
+ static const List<Color> _palette = <Color>[
+ Color(0xFF43D681),
+ Color(0xFFF0FF03),
+ Color(0xFF0E9297),
+ Color(0xFFA0FFBF),
+ ];
+
+ static final List<MeshGradientPoint> _points = <MeshGradientPoint>[
+ MeshGradientPoint(
+ position: const Offset(-0.3, 0.2),
+ color: _palette[0],
+ ),
+ MeshGradientPoint(
+ position: const Offset(0.2, -0.2),
+ color: _palette[1],
+ ),
+ MeshGradientPoint(
+ position: const Offset(0.9, 0.5),
+ color: _palette[2],
+ ),
+ MeshGradientPoint(
+ position: const Offset(0.4, 1.2),
+ color: _palette[3],
+ ),
+ ];
+
+ static const List<_MeshGradientVariant> _variants = <_MeshGradientVariant>[
+ _MeshGradientVariant(horizontalFactor: -1, verticalFactor: -1),
+ _MeshGradientVariant(horizontalFactor: 1, verticalFactor: -1),
+ _MeshGradientVariant(horizontalFactor: 1, verticalFactor: 1),
+ _MeshGradientVariant(horizontalFactor: -1, verticalFactor: 1),
+ ];
+
+ static final MeshGradientOptions _options = MeshGradientOptions(
+ blend: 3.4,
+ noiseIntensity: 0.08,
+ );
+
+ static const double _kCanvasScale = 3.0;
+ static const double _kTranslationSafetyFactor = 0.94;
+
+ @override
+ Widget build(BuildContext context) {
+ final _MeshGradientVariant variant =
+ _variants[variantIndex % _variants.length];
+ const double maxTranslation =
+ ((_kCanvasScale - 1.0) / (2 * _kCanvasScale)) *
+ _kTranslationSafetyFactor;
+ final Offset translation = Offset(
+ variant.horizontalFactor * maxTranslation,
+ variant.verticalFactor * maxTranslation,
+ );
+ return IgnorePointer(
+ child: LayoutBuilder(
+ builder: (BuildContext context, BoxConstraints constraints) {
+ final double width = constraints.maxWidth;
+ final double height = constraints.maxHeight;
+ final double canvasWidth = width * _kCanvasScale;
+ final double canvasHeight = height * _kCanvasScale;
+ return OverflowBox(
+ alignment: Alignment.center,
+ minWidth: canvasWidth,
+ minHeight: canvasHeight,
+ maxWidth: canvasWidth,
+ maxHeight: canvasHeight,
+ child: FractionalTranslation(
+ translation: translation,
+ child: Opacity(
+ opacity: 0.62,
+ child: MeshGradient(
+ points: _points,
+ options: _options,
+ ),
+ ),
+ ),
+ );
+ },
+ ),
+ );
+ }
+}
+
+class _MeshGradientVariant {
+ const _MeshGradientVariant({
+ required this.horizontalFactor,
+ required this.verticalFactor,
+ });
+
+ final double horizontalFactor;
+ final double verticalFactor;
+}
+
class _StoryCardBackground extends StatelessWidget {
const _StoryCardBackground({
required this.card,
diff --git a/mobile/apps/photos/lib/ui/wrapped/wrapped_viewer_page.dart b/mobile/apps/photos/lib/ui/wrapped/wrapped_viewer_page.dart
index 50923e3f21..416b0366ef 100644
--- a/mobile/apps/photos/lib/ui/wrapped/wrapped_viewer_page.dart
+++ b/mobile/apps/photos/lib/ui/wrapped/wrapped_viewer_page.dart
@@ -10,6 +10,7 @@ import "package:flutter/services.dart";
import "package:intl/intl.dart";
import "package:just_audio/just_audio.dart";
import "package:logging/logging.dart";
+import "package:mesh_gradient/mesh_gradient.dart";
import "package:photos/db/files_db.dart";
import "package:photos/ente_theme_data.dart";
import "package:photos/models/file/file.dart";
@@ -580,6 +581,7 @@ class _WrappedViewerPageState extends State<WrappedViewerPage>
colorScheme: enteColorScheme,
textTheme: textTheme,
isActive: index == _currentIndex,
+ gradientVariantIndex: index,
);
},
),
diff --git a/mobile/apps/photos/pubspec.lock b/mobile/apps/photos/pubspec.lock
index 19c23b9d02..a01218801f 100644
--- a/mobile/apps/photos/pubspec.lock
+++ b/mobile/apps/photos/pubspec.lock
@@ -1668,6 +1668,14 @@ packages:
url: "https://github.com/media-kit/media-kit"
source: git
version: "1.3.0"
+ mesh_gradient:
+ dependency: "direct main"
+ description:
+ name: mesh_gradient
+ sha256: "3dc7a7195d90f164e69aa805f4dea876eee54aed6b271ee22ae792d7b9c1fedb"
+ url: "https://pub.dev"
+ source: hosted
+ version: "1.3.8"
meta:
dependency: transitive
description:
diff --git a/mobile/apps/photos/pubspec.yaml b/mobile/apps/photos/pubspec.yaml
index 4141570c9c..e09f7253d3 100644
--- a/mobile/apps/photos/pubspec.yaml
+++ b/mobile/apps/photos/pubspec.yaml
@@ -137,6 +137,7 @@ dependencies:
media_kit_libs_ios_video:
media_kit_libs_video:
media_kit_video:
+ mesh_gradient: ^1.3.8
ml_linalg: ^13.11.31
mobile_ocr:
git: