Skip to content

armgit / ente

Public Imported from GitHub
0

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

Update search rituals section design

ashilknd13573db95e2
diff --git a/mobile/apps/photos/assets/rituals/2.0x/search_start_ritual_illustration.png b/mobile/apps/photos/assets/rituals/2.0x/search_start_ritual_illustration.png
new file mode 100644
index 0000000000..5676250457
Binary files /dev/null and b/mobile/apps/photos/assets/rituals/2.0x/search_start_ritual_illustration.png differ
diff --git a/mobile/apps/photos/assets/rituals/3.0x/search_start_ritual_illustration.png b/mobile/apps/photos/assets/rituals/3.0x/search_start_ritual_illustration.png
new file mode 100644
index 0000000000..4668847c1c
Binary files /dev/null and b/mobile/apps/photos/assets/rituals/3.0x/search_start_ritual_illustration.png differ
diff --git a/mobile/apps/photos/assets/rituals/search_start_ritual_illustration.png b/mobile/apps/photos/assets/rituals/search_start_ritual_illustration.png
new file mode 100644
index 0000000000..6be85d55f9
Binary files /dev/null and b/mobile/apps/photos/assets/rituals/search_start_ritual_illustration.png differ
diff --git a/mobile/apps/photos/changes/search-rituals-design.md b/mobile/apps/photos/changes/search-rituals-design.md
new file mode 100644
index 0000000000..47ebafee82
--- /dev/null
+++ b/mobile/apps/photos/changes/search-rituals-design.md
@@ -0,0 +1 @@
+- Updated the rituals section in Photos search to match the refreshed design.
diff --git a/mobile/apps/photos/lib/ui/rituals/rituals_banner.dart b/mobile/apps/photos/lib/ui/rituals/rituals_banner.dart
index 5b828bdcf4..b8d261895b 100644
--- a/mobile/apps/photos/lib/ui/rituals/rituals_banner.dart
+++ b/mobile/apps/photos/lib/ui/rituals/rituals_banner.dart
@@ -23,7 +23,7 @@ class RitualsBanner extends StatelessWidget {
const RitualsBanner({super.key});
static const _cardRadius = 25.0;
- static const _cardHeight = 94.0;
+ static const _minCardHeight = 94.0;
static const _cardWidth = 167.5;
@override
@@ -46,7 +46,7 @@ class RitualsBanner extends StatelessWidget {
? () => routeToPage(context, const AllRitualsScreen())
: null,
),
- const SizedBox(height: 2),
+ const SizedBox(height: 4),
if (rituals.isEmpty)
Padding(
padding: EdgeInsets.zero,
@@ -58,20 +58,26 @@ class RitualsBanner extends StatelessWidget {
),
)
else
- SearchTabHorizontalScrollView(
- height: _cardHeight,
- child: Row(
- children: [
- for (final (index, item) in _buildRowItems(
- context,
- rituals,
- summary,
- ).indexed) ...[
- if (index != 0) const SizedBox(width: 10),
- item,
- ],
- ],
- ),
+ Builder(
+ builder: (context) {
+ final cardHeight = _cardHeightFor(context);
+ return SearchTabHorizontalScrollView(
+ height: cardHeight,
+ child: Row(
+ children: [
+ for (final (index, item) in _buildRowItems(
+ context,
+ rituals,
+ summary,
+ cardHeight,
+ ).indexed) ...[
+ if (index != 0) const SizedBox(width: 10),
+ item,
+ ],
+ ],
+ ),
+ );
+ },
),
],
);
@@ -111,20 +117,47 @@ class RitualsBanner extends StatelessWidget {
BuildContext context,
List<Ritual> rituals,
RitualsSummary? summary,
+ double cardHeight,
) {
return [
for (final ritual in rituals)
_RitualSummaryCard(
ritual: ritual,
progress: summary?.ritualProgress[ritual.id],
+ height: cardHeight,
),
if (rituals.isNotEmpty)
StartNewRitualCard(
variant: StartNewRitualCardVariant.compact,
onTap: () => _openNewRitualFlow(context),
+ compactHeight: cardHeight,
),
];
}
+
+ static double _cardHeightFor(BuildContext context) {
+ return math.max(
+ _summaryCardHeightFor(context),
+ StartNewRitualCard.compactHeightFor(context),
+ );
+ }
+
+ static double _summaryCardHeightFor(BuildContext context) {
+ const verticalPadding = 32.0;
+ const rowGap = 4.0;
+ final titleRowHeight = math.max(
+ 28.0,
+ _singleLineTextHeight(context, _ritualSummaryTitleStyle(Colors.black)),
+ );
+ final actionRowHeight = math.max(
+ 28.0,
+ _singleLineTextHeight(context, _streakTextStyle),
+ );
+ return math.max(
+ _minCardHeight,
+ verticalPadding + titleRowHeight + rowGap + actionRowHeight,
+ );
+ }
}
class _RitualsHeader extends StatelessWidget {
@@ -166,28 +199,27 @@ class _RitualsHeader extends StatelessWidget {
}
class _RitualSummaryCard extends StatelessWidget {
- const _RitualSummaryCard({required this.ritual, required this.progress});
+ const _RitualSummaryCard({
+ required this.ritual,
+ required this.progress,
+ required this.height,
+ });
final Ritual ritual;
final RitualProgress? progress;
+ final double height;
static const _cardRadius = RitualsBanner._cardRadius;
- static const _cardHeight = RitualsBanner._cardHeight;
static const _cardWidth = RitualsBanner._cardWidth;
@override
Widget build(BuildContext context) {
final colorScheme = getEnteColorScheme(context);
- final textTheme = getEnteTextTheme(context);
- final isDark = Theme.of(context).brightness == Brightness.dark;
- final backgroundColor = Theme.of(context).brightness == Brightness.dark
- ? colorScheme.backgroundElevated2
- : const Color(0xFFFAFAFA);
final streak = progress?.currentStreak ?? 0;
return SizedBox(
width: _cardWidth,
- height: _cardHeight,
+ height: height,
child: Material(
color: Colors.transparent,
borderRadius: BorderRadius.circular(_cardRadius),
@@ -200,7 +232,7 @@ class _RitualSummaryCard extends StatelessWidget {
},
child: Container(
decoration: BoxDecoration(
- color: backgroundColor,
+ color: colorScheme.fill,
borderRadius: BorderRadius.circular(_cardRadius),
),
padding: const EdgeInsets.all(16),
@@ -211,7 +243,7 @@ class _RitualSummaryCard extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.center,
children: [
_RitualIcon(ritual: ritual),
- const SizedBox(width: 10),
+ const SizedBox(width: 4),
Expanded(
child: Text(
ritual.title.isEmpty
@@ -219,16 +251,16 @@ class _RitualSummaryCard extends StatelessWidget {
: ritual.title,
maxLines: 1,
overflow: TextOverflow.ellipsis,
- style: textTheme.miniBold,
+ style: _ritualSummaryTitleStyle(colorScheme.textBase),
textHeightBehavior: _tightTextHeightBehavior,
),
),
],
),
- const Spacer(),
+ const SizedBox(height: 4),
Row(
children: [
- _StreakIndicator(streak: streak, isDark: isDark),
+ _StreakIndicator(streak: streak),
const Spacer(),
_RitualCameraButton(
onTap: () => openRitualCamera(context, ritual),
@@ -252,19 +284,14 @@ class _RitualIcon extends StatelessWidget {
@override
Widget build(BuildContext context) {
- final colorScheme = getEnteColorScheme(context);
final textTheme = getEnteTextTheme(context);
- return Container(
+ return SizedBox(
width: 28,
height: 28,
- decoration: BoxDecoration(
- color: colorScheme.backgroundElevated,
- borderRadius: BorderRadius.circular(10),
- ),
child: Center(
child: RitualEmojiIcon(
ritual.icon,
- style: textTheme.bodyBold.copyWith(height: 1),
+ style: textTheme.body.copyWith(fontSize: 18, height: 1),
textHeightBehavior: _tightTextHeightBehavior,
),
),
@@ -273,17 +300,16 @@ class _RitualIcon extends StatelessWidget {
}
class _StreakIndicator extends StatelessWidget {
- const _StreakIndicator({required this.streak, required this.isDark});
+ const _StreakIndicator({required this.streak});
final int streak;
- final bool isDark;
@override
Widget build(BuildContext context) {
return Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
- _StreakNumber(streak: streak, isDark: isDark),
+ _StreakNumber(streak: streak),
const SizedBox(width: 4),
const _LightningIcon(),
],
@@ -292,67 +318,32 @@ class _StreakIndicator extends StatelessWidget {
}
class _StreakNumber extends StatelessWidget {
- const _StreakNumber({required this.streak, required this.isDark});
+ const _StreakNumber({required this.streak});
final int streak;
- final bool isDark;
@override
Widget build(BuildContext context) {
final colorScheme = getEnteColorScheme(context);
final text = streak.toString();
- const style = TextStyle(
- fontFamily: "Nunito",
- fontSize: 24,
- fontWeight: FontWeight.w900,
- letterSpacing: -0.96,
- height: 1,
- );
- if (isDark) {
- return Text(
- text,
- style: style.copyWith(color: colorScheme.textBase),
- textHeightBehavior: _tightTextHeightBehavior,
- );
- }
-
- final gradient = _linearGradientFromCssAngle(
- degrees: 178,
- colors: const [Color(0xFF545454), Color(0xFF000000)],
- stops: const [0.1192, 0.8251],
- );
-
- return Stack(
- alignment: Alignment.centerLeft,
- children: [
- ExcludeSemantics(
- child: Text(
- text,
- style: style.copyWith(
- color: Colors.transparent,
- shadows: [
- Shadow(
- offset: const Offset(0, 5),
- blurRadius: 3.3,
- color: Colors.black.withValues(alpha: 0.07),
- ),
- ],
- ),
- textHeightBehavior: _tightTextHeightBehavior,
- ),
- ),
- _GradientText(
- text,
- gradient: gradient,
- style: style,
- textHeightBehavior: _tightTextHeightBehavior,
- ),
- ],
+ return Text(
+ text,
+ style: _streakTextStyle.copyWith(color: colorScheme.textBase),
+ textHeightBehavior: _tightTextHeightBehavior,
);
}
}
+const _streakTextStyle = TextStyle(
+ fontFamily: TextStyles.outfitFontFamily,
+ package: TextStyles.fontPackage,
+ fontSize: 24,
+ fontWeight: FontWeight.w900,
+ letterSpacing: -0.96,
+ height: 1,
+);
+
class _LightningIcon extends StatelessWidget {
const _LightningIcon();
@@ -380,24 +371,18 @@ class _RitualCameraButton extends StatelessWidget {
@override
Widget build(BuildContext context) {
final colorScheme = getEnteColorScheme(context);
- final isDark = Theme.of(context).brightness == Brightness.dark;
- final borderColor = isDark
- ? colorScheme.strokeFaint
- : Colors.black.withValues(alpha: 0.04);
+ final borderRadius = BorderRadius.circular(12);
return Tooltip(
message: tooltip,
child: Material(
- color: colorScheme.backgroundElevated,
- shape: RoundedRectangleBorder(
- borderRadius: BorderRadius.circular(12),
- side: BorderSide(color: borderColor),
- ),
+ color: Colors.transparent,
+ borderRadius: borderRadius,
child: InkWell(
onTap: onTap,
- borderRadius: BorderRadius.circular(12),
+ borderRadius: borderRadius,
child: SizedBox(
- width: 32,
- height: 32,
+ width: 28,
+ height: 28,
child: Center(
child: HugeIcon(
icon: HugeIcons.strokeRoundedCamera01,
@@ -417,45 +402,19 @@ const _tightTextHeightBehavior = TextHeightBehavior(
applyHeightToLastDescent: false,
);
-class _GradientText extends StatelessWidget {
- const _GradientText(
- this.text, {
- required this.gradient,
- required this.style,
- this.textHeightBehavior,
- });
-
- final String text;
- final Gradient gradient;
- final TextStyle style;
- final TextHeightBehavior? textHeightBehavior;
-
- @override
- Widget build(BuildContext context) {
- return ShaderMask(
- blendMode: BlendMode.srcIn,
- shaderCallback: (bounds) => gradient.createShader(bounds),
- child: Text(
- text,
- style: style.copyWith(color: Colors.white),
- textHeightBehavior: textHeightBehavior,
- ),
- );
- }
+TextStyle _ritualSummaryTitleStyle(Color color) {
+ return TextStyles.body.copyWith(
+ color: color,
+ fontFamily: TextStyles.outfitFontFamily,
+ );
}
-LinearGradient _linearGradientFromCssAngle({
- required double degrees,
- required List<Color> colors,
- List<double>? stops,
-}) {
- final radians = degrees * math.pi / 180;
- final dx = math.sin(radians);
- final dy = -math.cos(radians);
- return LinearGradient(
- begin: Alignment(-dx, -dy),
- end: Alignment(dx, dy),
- colors: colors,
- stops: stops,
- );
+double _singleLineTextHeight(BuildContext context, TextStyle style) {
+ final textPainter = TextPainter(
+ text: TextSpan(text: "Ag", style: style),
+ textDirection: Directionality.of(context),
+ textScaler: MediaQuery.textScalerOf(context),
+ textHeightBehavior: _tightTextHeightBehavior,
+ )..layout();
+ return textPainter.height;
}
diff --git a/mobile/apps/photos/lib/ui/rituals/start_new_ritual_card.dart b/mobile/apps/photos/lib/ui/rituals/start_new_ritual_card.dart
index ac0c2e5468..1a3c75ec18 100644
--- a/mobile/apps/photos/lib/ui/rituals/start_new_ritual_card.dart
+++ b/mobile/apps/photos/lib/ui/rituals/start_new_ritual_card.dart
@@ -1,10 +1,8 @@
import "dart:math" as math;
-import "package:dotted_border/dotted_border.dart";
-import "package:ente_components/ente_components.dart";
+import "package:ente_components/theme/text_styles.dart";
import "package:ente_icons/ente_icons.dart";
import "package:flutter/material.dart";
-import "package:flutter_svg/flutter_svg.dart";
import "package:photos/theme/ente_theme.dart";
import "package:photos/utils/pending_translation.dart";
@@ -15,236 +13,144 @@ class StartNewRitualCard extends StatelessWidget {
super.key,
required this.variant,
required this.onTap,
- });
+ double? compactHeight,
+ }) : _compactHeightOverride = compactHeight,
+ assert(
+ variant == StartNewRitualCardVariant.compact || compactHeight == null,
+ );
final StartNewRitualCardVariant variant;
final VoidCallback onTap;
+ final double? _compactHeightOverride;
static const _cardRadius = 25.0;
- static const _cardHeight = 100.0;
+ static const _cardHeight = 94.0;
static const _compactHeight = 94.0;
static const _compactWidth = 167.5;
- static const _wideDuckyHeightReduction = 12.0;
- static const _wideDuckyAspectRatio = 149 / 81;
- static const _wideDuckyRightOverflow = 4.0;
+ static const _wideHorizontalPadding = 20.0;
+ static const _wideBottomPadding = 14.0;
+ static const _wideIllustrationWidth = 123.0;
+ static const _wideIllustrationHeight = 116.0;
+ static const _wideIllustrationRight = 10.0;
+ static const _wideIllustrationTop = -27.0;
+
+ static double compactHeightFor(BuildContext context) {
+ final titleHeight = _measuredTextHeight(
+ context,
+ text: pendingTranslation("Start new ritual"),
+ style: _compactTitleStyle(Colors.black),
+ maxWidth: _compactWidth - 24,
+ );
+ return math.max(_compactHeight, 16 + 24 + 4 + titleHeight + 16);
+ }
@override
Widget build(BuildContext context) {
- final textTheme = getEnteTextTheme(context);
-
if (variant == StartNewRitualCardVariant.compact) {
- return _CompactStartNewRitualCard(onTap: onTap);
+ return _CompactStartNewRitualCard(
+ onTap: onTap,
+ height: _compactHeightOverride,
+ );
}
- final componentColors = context.componentColors;
- const fillColor = Colors.transparent;
- final dottedBorderColor = componentColors.textLightest;
- const duckyHeight = _cardHeight - _wideDuckyHeightReduction;
- const duckyNaturalWidth = duckyHeight * _wideDuckyAspectRatio;
- const duckyChildWidth = duckyNaturalWidth + _wideDuckyRightOverflow;
+ final colorScheme = getEnteColorScheme(context);
+ final borderRadius = BorderRadius.circular(_cardRadius);
+ final titleText = pendingTranslation("Start new ritual");
+ final subtitleText = pendingTranslation(
+ "Create a ritual, build streaks, and share your progress.",
+ );
+
+ return LayoutBuilder(
+ builder: (context, constraints) {
+ final layout = _WideRitualCardLayout.forWidth(
+ context,
+ constraints.maxWidth,
+ titleText: titleText,
+ subtitleText: subtitleText,
+ titleStyle: _wideTitleStyle(colorScheme.textBase),
+ subtitleStyle: TextStyles.tiny.copyWith(color: colorScheme.textMuted),
+ );
- return SizedBox(
- height: _cardHeight,
- child: DottedBorder(
- borderType: BorderType.RRect,
- radius: const Radius.circular(_cardRadius),
- dashPattern: const [3.75, 3.75],
- strokeWidth: 1.5,
- borderPadding: const EdgeInsets.all(0.75),
- color: dottedBorderColor,
- child: ClipRRect(
- borderRadius: BorderRadius.circular(_cardRadius),
+ return SizedBox(
+ height: layout.cardHeight,
child: Material(
- color: fillColor,
+ color: colorScheme.fill,
+ borderRadius: borderRadius,
child: InkWell(
onTap: onTap,
- child: LayoutBuilder(
- builder: (context, constraints) {
- var duckyWidth = 0.0;
- final textScaler = MediaQuery.textScalerOf(context);
- final textDirection = Directionality.of(context);
- const leftPadding = 14.0;
- const iconWidth = 24.0;
- const iconSpacing = 10.0;
-
- bool fits(double candidateDuckyWidth) {
- final leftWidth = math.max(
- 0.0,
- constraints.maxWidth - candidateDuckyWidth,
- );
- final titleMaxWidth =
- leftWidth - leftPadding - iconWidth - iconSpacing;
- const titleWidthEpsilon = 8.0;
- final adjustedTitleMaxWidth =
- titleMaxWidth - titleWidthEpsilon;
- final subtitleMaxWidth = leftWidth - leftPadding;
- if (adjustedTitleMaxWidth <= 0 || subtitleMaxWidth <= 0) {
- return false;
- }
-
- final titlePainter = TextPainter(
- text: TextSpan(
- text: pendingTranslation("Start new ritual"),
- style: textTheme.body,
- ),
- maxLines: 1,
- ellipsis: "…",
- textDirection: textDirection,
- textScaler: textScaler,
- textHeightBehavior: _tightTextHeightBehavior,
- )..layout(maxWidth: adjustedTitleMaxWidth);
- if (titlePainter.didExceedMaxLines) return false;
-
- final subtitlePainter = TextPainter(
- text: TextSpan(
- text: pendingTranslation(
- "Create a ritual, build streaks, and share your progress.",
- ),
- style: textTheme.miniMuted,
- ),
- maxLines: 3,
- ellipsis: "…",
- textDirection: textDirection,
- textScaler: textScaler,
- )..layout(maxWidth: subtitleMaxWidth);
- return !subtitlePainter.didExceedMaxLines;
- }
-
- final upperBound = math.min(
- duckyChildWidth,
- constraints.maxWidth,
- );
- if (fits(upperBound)) {
- duckyWidth = upperBound;
- } else if (fits(0.0)) {
- var low = 0.0;
- var high = upperBound;
- for (var i = 0; i < 10; i++) {
- final mid = (low + high) / 2;
- if (fits(mid)) {
- low = mid;
- } else {
- high = mid;
- }
- }
- duckyWidth = low;
- }
-
- return Row(
- children: [
- Expanded(
- child: Padding(
- padding: const EdgeInsets.fromLTRB(14, 11, 0, 11),
- child: Column(
- mainAxisAlignment: MainAxisAlignment.center,
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Row(
- crossAxisAlignment: CrossAxisAlignment.center,
- children: [
- Container(
- width: 24,
- height: 24,
- decoration: BoxDecoration(
- color: const Color(0xFFFFF2E1),
- borderRadius: BorderRadius.circular(8),
- ),
- child: const Center(
- child: Icon(
- EnteIcons.lightningFilled,
- size: 17,
- color: Color(0xFFFFBC03),
- ),
- ),
- ),
- const SizedBox(width: 10),
- Expanded(
- child: Text(
- pendingTranslation("Start new ritual"),
- style: textTheme.body,
- maxLines: 1,
- overflow: TextOverflow.ellipsis,
- textHeightBehavior:
- _tightTextHeightBehavior,
- ),
- ),
- ],
- ),
- const SizedBox(height: 3),
- Text(
- pendingTranslation(
- "Create a ritual, build streaks, and share your progress.",
- ),
- style: textTheme.miniMuted,
- maxLines: 3,
- overflow: TextOverflow.ellipsis,
+ borderRadius: borderRadius,
+ child: Stack(
+ clipBehavior: Clip.none,
+ children: [
+ Positioned(
+ left: _wideHorizontalPadding,
+ top: _wideHorizontalPadding,
+ width: layout.textWidth,
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Row(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ const Padding(
+ padding: EdgeInsets.only(top: 4),
+ child: Icon(
+ EnteIcons.lightningFilled,
+ size: 13,
+ color: Color(0xFFFFBC03),
),
- ],
- ),
- ),
- ),
- if (duckyWidth > 0)
- SizedBox(
- width: duckyWidth,
- height: double.infinity,
- child: ClipRRect(
- borderRadius: const BorderRadius.only(
- topRight: Radius.circular(_cardRadius),
- bottomRight: Radius.circular(_cardRadius),
),
- child: Align(
- alignment: Alignment.bottomRight,
- child: SizedBox(
- width: duckyWidth,
- height: duckyHeight,
- child: FittedBox(
- fit: BoxFit.scaleDown,
- alignment: Alignment.bottomRight,
- child: SizedBox(
- width: duckyChildWidth,
- height: duckyHeight,
- child: Transform.translate(
- offset: const Offset(
- _wideDuckyRightOverflow,
- 0,
- ),
- child: SvgPicture.asset(
- "assets/rituals/ducky_ritual.svg",
- fit: BoxFit.fitHeight,
- alignment: Alignment.bottomRight,
- ),
- ),
- ),
- ),
+ const SizedBox(width: 8),
+ Expanded(
+ child: Text(
+ titleText,
+ style: _wideTitleStyle(colorScheme.textBase),
+ textHeightBehavior: _tightTextHeightBehavior,
),
),
+ ],
+ ),
+ const SizedBox(height: 6),
+ Text(
+ subtitleText,
+ style: TextStyles.tiny.copyWith(
+ color: colorScheme.textMuted,
),
+ textHeightBehavior: _tightTextHeightBehavior,
),
- ],
- );
- },
+ ],
+ ),
+ ),
+ Positioned(
+ right: _wideIllustrationRight,
+ top: layout.illustrationTop,
+ width: layout.illustrationWidth,
+ height: layout.illustrationHeight,
+ child: const _WideRitualIllustration(),
+ ),
+ ],
),
),
),
- ),
- ),
+ );
+ },
);
}
}
class _CompactStartNewRitualCard extends StatelessWidget {
- const _CompactStartNewRitualCard({required this.onTap});
+ const _CompactStartNewRitualCard({required this.onTap, required this.height});
final VoidCallback onTap;
+ final double? height;
@override
Widget build(BuildContext context) {
final colorScheme = getEnteColorScheme(context);
- final textTheme = getEnteTextTheme(context);
final borderRadius = BorderRadius.circular(StartNewRitualCard._cardRadius);
return SizedBox(
width: StartNewRitualCard._compactWidth,
- height: StartNewRitualCard._compactHeight,
+ height: height ?? StartNewRitualCard._compactHeight,
child: Material(
color: colorScheme.fill,
borderRadius: borderRadius,
@@ -254,20 +160,20 @@ class _CompactStartNewRitualCard extends StatelessWidget {
child: Stack(
children: [
const Positioned(
- left: 22,
- top: 19,
+ left: 50.5,
+ top: 38,
child: Icon(
Icons.auto_awesome,
- size: 13,
+ size: 8,
color: Color(0xFFFFBC03),
),
),
const Positioned(
- right: 28,
- top: 19,
+ left: 103.25,
+ top: 16.93,
child: Icon(
Icons.auto_awesome,
- size: 10,
+ size: 13,
color: Color(0xFFFFD25A),
),
),
@@ -293,12 +199,9 @@ class _CompactStartNewRitualCard extends StatelessWidget {
padding: const EdgeInsets.symmetric(horizontal: 12),
child: Text(
pendingTranslation("Start new ritual"),
- style: textTheme.bodyBold.copyWith(
- color: colorScheme.textBase,
- ),
- maxLines: 1,
- overflow: TextOverflow.ellipsis,
+ style: _compactTitleStyle(colorScheme.textBase),
textAlign: TextAlign.center,
+ textHeightBehavior: _tightTextHeightBehavior,
),
),
],
@@ -312,6 +215,137 @@ class _CompactStartNewRitualCard extends StatelessWidget {
}
}
+TextStyle _wideTitleStyle(Color color) {
+ return const TextStyle(
+ fontFamily: TextStyles.outfitFontFamily,
+ package: TextStyles.fontPackage,
+ fontSize: 16.72,
+ fontWeight: FontWeight.w500,
+ height: 21 / 16.72,
+ letterSpacing: 0,
+ ).copyWith(color: color);
+}
+
+TextStyle _compactTitleStyle(Color color) {
+ return TextStyles.body.copyWith(
+ color: color,
+ fontFamily: TextStyles.outfitFontFamily,
+ );
+}
+
+class _WideRitualCardLayout {
+ const _WideRitualCardLayout({
+ required this.cardHeight,
+ required this.textWidth,
+ required this.illustrationWidth,
+ required this.illustrationHeight,
+ required this.illustrationTop,
+ });
+
+ static const _textIllustrationGap = 12.0;
+ static const _minIllustrationScale = 0.86;
+ static const _narrowWidth = 320.0;
+
+ final double cardHeight;
+ final double textWidth;
+ final double illustrationWidth;
+ final double illustrationHeight;
+ final double illustrationTop;
+
+ factory _WideRitualCardLayout.forWidth(
+ BuildContext context,
+ double width, {
+ required String titleText,
+ required String subtitleText,
+ required TextStyle titleStyle,
+ required TextStyle subtitleStyle,
+ }) {
+ final widthScale = width < _narrowWidth ? width / _narrowWidth : 1.0;
+ final illustrationScale = widthScale
+ .clamp(_minIllustrationScale, 1.0)
+ .toDouble();
+ final illustrationWidth =
+ StartNewRitualCard._wideIllustrationWidth * illustrationScale;
+ final illustrationHeight =
+ StartNewRitualCard._wideIllustrationHeight * illustrationScale;
+ final textWidth = math.max(
+ 0.0,
+ width -
+ StartNewRitualCard._wideHorizontalPadding -
+ _textIllustrationGap -
+ StartNewRitualCard._wideIllustrationRight -
+ illustrationWidth,
+ );
+ const titleIconWidth = 13.0;
+ const titleIconGap = 8.0;
+ final titleTextWidth = math.max(
+ 0.0,
+ textWidth - titleIconWidth - titleIconGap,
+ );
+ final titleHeight = _measuredTextHeight(
+ context,
+ text: titleText,
+ style: titleStyle,
+ maxWidth: titleTextWidth,
+ );
+ final subtitleHeight = _measuredTextHeight(
+ context,
+ text: subtitleText,
+ style: subtitleStyle,
+ maxWidth: textWidth,
+ );
+ final textHeight = titleHeight + 6 + subtitleHeight;
+ final cardHeight = math.max(
+ StartNewRitualCard._cardHeight,
+ StartNewRitualCard._wideHorizontalPadding +
+ textHeight +
+ StartNewRitualCard._wideBottomPadding,
+ );
+
+ return _WideRitualCardLayout(
+ cardHeight: cardHeight,
+ textWidth: textWidth,
+ illustrationWidth: illustrationWidth,
+ illustrationHeight: illustrationHeight,
+ illustrationTop:
+ StartNewRitualCard._wideIllustrationTop * illustrationScale,
+ );
+ }
+}
+
+class _WideRitualIllustration extends StatelessWidget {
+ const _WideRitualIllustration();
+
+ @override
+ Widget build(BuildContext context) {
+ return Image.asset(
+ "assets/rituals/search_start_ritual_illustration.png",
+ fit: BoxFit.contain,
+ );
+ }
+}
+
+double _measuredTextHeight(
+ BuildContext context, {
+ required String text,
+ required TextStyle style,
+ required double maxWidth,
+ int? maxLines,
+}) {
+ if (maxWidth <= 0) {
+ return 0;
+ }
+ final textPainter = TextPainter(
+ text: TextSpan(text: text, style: style),
+ maxLines: maxLines,
+ ellipsis: maxLines == null ? null : "…",
+ textDirection: Directionality.of(context),
+ textScaler: MediaQuery.textScalerOf(context),
+ textHeightBehavior: _tightTextHeightBehavior,
+ )..layout(maxWidth: maxWidth);
+ return textPainter.height;
+}
+
const _tightTextHeightBehavior = TextHeightBehavior(
applyHeightToFirstAscent: false,
applyHeightToLastDescent: false,