Skip to content

armgit / ente

Public Imported from GitHub
0

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

Empty rituals screen

laurenspriema193e015da7c
diff --git a/mobile/apps/photos/lib/ui/rituals/all_rituals_screen.dart b/mobile/apps/photos/lib/ui/rituals/all_rituals_screen.dart
index 3207c5cdaf..9896c549a0 100644
--- a/mobile/apps/photos/lib/ui/rituals/all_rituals_screen.dart
+++ b/mobile/apps/photos/lib/ui/rituals/all_rituals_screen.dart
@@ -10,6 +10,7 @@ import "package:photos/ui/rituals/ritual_camera_page.dart";
import "package:photos/ui/rituals/ritual_day_thumbnail.dart";
import "package:photos/ui/rituals/ritual_editor_dialog.dart";
import "package:photos/ui/rituals/ritual_page.dart";
+import "package:photos/ui/rituals/start_new_ritual_card.dart";
import "package:photos/utils/navigation_util.dart";
class AllRitualsScreen extends StatelessWidget {
@@ -77,7 +78,8 @@ class AllRitualsScreen extends StatelessWidget {
padding: const EdgeInsets.fromLTRB(16, 8, 16, 48),
children: [
if (rituals.isEmpty)
- _CreateRitualCard(
+ StartNewRitualCard(
+ variant: StartNewRitualCardVariant.wide,
onTap: () async {
await showRitualEditor(context, ritual: null);
},
@@ -101,70 +103,6 @@ class AllRitualsScreen extends StatelessWidget {
}
}
-class _CreateRitualCard extends StatelessWidget {
- const _CreateRitualCard({this.onTap});
-
- final VoidCallback? onTap;
-
- @override
- Widget build(BuildContext context) {
- final colorScheme = getEnteColorScheme(context);
- final textTheme = getEnteTextTheme(context);
- final l10n = context.l10n;
- return Container(
- decoration: BoxDecoration(
- color: Theme.of(context).brightness == Brightness.dark
- ? colorScheme.backgroundElevated2
- : const Color(0xFFFAFAFA),
- borderRadius: BorderRadius.circular(20),
- border: Border.all(
- color: Theme.of(context).brightness == Brightness.dark
- ? colorScheme.strokeFaint
- : Colors.black.withValues(alpha: 0.04),
- ),
- ),
- child: Material(
- color: Colors.transparent,
- child: InkWell(
- onTap: onTap,
- borderRadius: BorderRadius.circular(20),
- child: Padding(
- padding: const EdgeInsets.all(16),
- child: Row(
- children: [
- Container(
- width: 30,
- height: 30,
- decoration: BoxDecoration(
- color: colorScheme.backgroundElevated,
- borderRadius: BorderRadius.circular(8),
- ),
- child: Center(
- child: HugeIcon(
- icon: HugeIcons.strokeRoundedPlusSign,
- size: 18,
- color: colorScheme.textBase,
- ),
- ),
- ),
- const SizedBox(width: 12),
- Expanded(
- child: Text(
- l10n.ritualCreateYourOwn,
- style: textTheme.bodyBold,
- maxLines: 2,
- overflow: TextOverflow.ellipsis,
- ),
- ),
- ],
- ),
- ),
- ),
- ),
- );
- }
-}
-
class _RitualOverviewCard extends StatelessWidget {
const _RitualOverviewCard({required this.ritual, required this.progress});
diff --git a/mobile/apps/photos/lib/ui/rituals/rituals_banner.dart b/mobile/apps/photos/lib/ui/rituals/rituals_banner.dart
index 014b326c35..c297a5edea 100644
--- a/mobile/apps/photos/lib/ui/rituals/rituals_banner.dart
+++ b/mobile/apps/photos/lib/ui/rituals/rituals_banner.dart
@@ -1,10 +1,8 @@
import "dart:async";
import "dart:math" as math;
-import "package:dotted_border/dotted_border.dart";
import "package:ente_icons/ente_icons.dart";
import "package:flutter/material.dart";
-import "package:flutter_svg/flutter_svg.dart";
import "package:hugeicons/hugeicons.dart";
import "package:photos/l10n/l10n.dart";
import "package:photos/models/rituals/ritual_models.dart";
@@ -14,6 +12,7 @@ import "package:photos/ui/rituals/all_rituals_screen.dart";
import "package:photos/ui/rituals/ritual_camera_page.dart";
import "package:photos/ui/rituals/ritual_editor_dialog.dart";
import "package:photos/ui/rituals/ritual_page.dart";
+import "package:photos/ui/rituals/start_new_ritual_card.dart";
import "package:photos/utils/navigation_util.dart";
class RitualsBanner extends StatelessWidget {
@@ -38,14 +37,17 @@ class RitualsBanner extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
_RitualsHeader(
- onTap: () => routeToPage(context, const AllRitualsScreen()),
+ showChevron: rituals.isNotEmpty,
+ onTap: rituals.isNotEmpty
+ ? () => routeToPage(context, const AllRitualsScreen())
+ : null,
),
const SizedBox(height: 2),
if (rituals.isEmpty)
Padding(
padding: const EdgeInsets.symmetric(horizontal: 12),
- child: _StartNewRitualCard(
- variant: _StartNewRitualCardVariant.wide,
+ child: StartNewRitualCard(
+ variant: StartNewRitualCardVariant.wide,
onTap: () async {
await _openNewRitualFromSearchTab(context);
},
@@ -119,8 +121,8 @@ class RitualsBanner extends StatelessWidget {
progress: summary?.ritualProgress[ritual.id],
),
if (rituals.isNotEmpty)
- _StartNewRitualCard(
- variant: _StartNewRitualCardVariant.compact,
+ StartNewRitualCard(
+ variant: StartNewRitualCardVariant.compact,
onTap: () => _openNewRitualFlow(context),
),
];
@@ -128,15 +130,20 @@ class RitualsBanner extends StatelessWidget {
}
class _RitualsHeader extends StatelessWidget {
- const _RitualsHeader({required this.onTap});
+ const _RitualsHeader({
+ required this.showChevron,
+ required this.onTap,
+ });
- final VoidCallback onTap;
+ final bool showChevron;
+ final VoidCallback? onTap;
@override
Widget build(BuildContext context) {
final textTheme = getEnteTextTheme(context);
final colorScheme = getEnteColorScheme(context);
return GestureDetector(
+ behavior: HitTestBehavior.opaque,
onTap: onTap,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
@@ -148,16 +155,17 @@ class _RitualsHeader extends StatelessWidget {
style: textTheme.largeBold,
),
),
- Container(
- color: Colors.transparent,
- child: Padding(
- padding: const EdgeInsets.fromLTRB(24, 12, 12, 12),
- child: Icon(
- Icons.chevron_right_outlined,
- color: colorScheme.blurStrokePressed,
+ if (showChevron)
+ Container(
+ color: Colors.transparent,
+ child: Padding(
+ padding: const EdgeInsets.fromLTRB(24, 12, 12, 12),
+ child: Icon(
+ Icons.chevron_right_outlined,
+ color: colorScheme.blurStrokePressed,
+ ),
),
),
- ),
],
),
);
@@ -426,143 +434,6 @@ class _RitualCameraButton extends StatelessWidget {
}
}
-enum _StartNewRitualCardVariant { compact, wide }
-
-class _StartNewRitualCard extends StatelessWidget {
- const _StartNewRitualCard({
- required this.variant,
- required this.onTap,
- });
-
- final _StartNewRitualCardVariant variant;
- final VoidCallback onTap;
-
- static const _cardRadius = RitualsBanner._cardRadius;
- static const _cardHeight = RitualsBanner._cardHeight;
- static const _compactWidth = 220.0;
- static const _wideDuckyExtraWidth = 40.0;
- static const _wideDuckyHeightReduction = 12.0;
- static const _wideDuckyAspectRatio = 149 / 81;
- static const _wideDuckyRightOverflow = 4.0;
-
- @override
- Widget build(BuildContext context) {
- final colorScheme = getEnteColorScheme(context);
- final textTheme = getEnteTextTheme(context);
- final isDark = Theme.of(context).brightness == Brightness.dark;
- const fillColor = Colors.transparent;
- final dottedBorderColor =
- isDark ? colorScheme.strokeFaint : const Color(0xFFF0F0F0);
- final contentRightPadding =
- variant == _StartNewRitualCardVariant.compact ? 14.0 : 0.0;
- const duckyHeight = _cardHeight - _wideDuckyHeightReduction;
- const duckyWidth = (duckyHeight * _wideDuckyAspectRatio) +
- _wideDuckyExtraWidth +
- _wideDuckyRightOverflow;
-
- final content = Row(
- children: [
- Expanded(
- child: Padding(
- padding: EdgeInsets.fromLTRB(14, 14, contentRightPadding, 14),
- child: Column(
- 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(
- "Start new ritual",
- style: textTheme.body,
- maxLines: 1,
- overflow: TextOverflow.ellipsis,
- textHeightBehavior: _tightTextHeightBehavior,
- ),
- ),
- ],
- ),
- const SizedBox(height: 6),
- Text(
- "Create a ritual, build streaks,\nand share your progress.",
- style: textTheme.miniMuted,
- maxLines: 2,
- overflow: TextOverflow.ellipsis,
- ),
- ],
- ),
- ),
- ),
- if (variant == _StartNewRitualCardVariant.wide)
- SizedBox(
- 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: Transform.translate(
- offset: const Offset(_wideDuckyRightOverflow, 0),
- child: SvgPicture.asset(
- "assets/rituals/ducky_ritual.svg",
- fit: BoxFit.fitHeight,
- alignment: Alignment.bottomRight,
- ),
- ),
- ),
- ),
- ),
- ),
- ],
- );
-
- return SizedBox(
- width:
- variant == _StartNewRitualCardVariant.compact ? _compactWidth : null,
- 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),
- child: Material(
- color: fillColor,
- child: InkWell(
- onTap: onTap,
- child: content,
- ),
- ),
- ),
- ),
- );
- }
-}
-
const _tightTextHeightBehavior = TextHeightBehavior(
applyHeightToFirstAscent: false,
applyHeightToLastDescent: false,
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
new file mode 100644
index 0000000000..6b3b5f100d
--- /dev/null
+++ b/mobile/apps/photos/lib/ui/rituals/start_new_ritual_card.dart
@@ -0,0 +1,148 @@
+import "package:dotted_border/dotted_border.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";
+
+enum StartNewRitualCardVariant { compact, wide }
+
+class StartNewRitualCard extends StatelessWidget {
+ const StartNewRitualCard({
+ super.key,
+ required this.variant,
+ required this.onTap,
+ });
+
+ final StartNewRitualCardVariant variant;
+ final VoidCallback onTap;
+
+ static const _cardRadius = 25.0;
+ static const _cardHeight = 100.0;
+ static const _compactWidth = 220.0;
+ static const _wideDuckyExtraWidth = 40.0;
+ static const _wideDuckyHeightReduction = 12.0;
+ static const _wideDuckyAspectRatio = 149 / 81;
+ static const _wideDuckyRightOverflow = 4.0;
+
+ @override
+ Widget build(BuildContext context) {
+ final colorScheme = getEnteColorScheme(context);
+ final textTheme = getEnteTextTheme(context);
+ final isDark = Theme.of(context).brightness == Brightness.dark;
+ const fillColor = Colors.transparent;
+ final dottedBorderColor =
+ isDark ? colorScheme.strokeFaint : const Color(0xFFF0F0F0);
+ final contentRightPadding =
+ variant == StartNewRitualCardVariant.compact ? 14.0 : 0.0;
+ const duckyHeight = _cardHeight - _wideDuckyHeightReduction;
+ const duckyWidth = (duckyHeight * _wideDuckyAspectRatio) +
+ _wideDuckyExtraWidth +
+ _wideDuckyRightOverflow;
+
+ final content = Row(
+ children: [
+ Expanded(
+ child: Padding(
+ padding: EdgeInsets.fromLTRB(14, 14, contentRightPadding, 14),
+ child: Column(
+ 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(
+ "Start new ritual",
+ style: textTheme.body,
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ textHeightBehavior: _tightTextHeightBehavior,
+ ),
+ ),
+ ],
+ ),
+ const SizedBox(height: 6),
+ Text(
+ "Create a ritual, build streaks,\nand share your progress.",
+ style: textTheme.miniMuted,
+ maxLines: 2,
+ overflow: TextOverflow.ellipsis,
+ ),
+ ],
+ ),
+ ),
+ ),
+ if (variant == StartNewRitualCardVariant.wide)
+ SizedBox(
+ 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: Transform.translate(
+ offset: const Offset(_wideDuckyRightOverflow, 0),
+ child: SvgPicture.asset(
+ "assets/rituals/ducky_ritual.svg",
+ fit: BoxFit.fitHeight,
+ alignment: Alignment.bottomRight,
+ ),
+ ),
+ ),
+ ),
+ ),
+ ),
+ ],
+ );
+
+ return SizedBox(
+ width:
+ variant == StartNewRitualCardVariant.compact ? _compactWidth : null,
+ 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),
+ child: Material(
+ color: fillColor,
+ child: InkWell(
+ onTap: onTap,
+ child: content,
+ ),
+ ),
+ ),
+ ),
+ );
+ }
+}
+
+const _tightTextHeightBehavior = TextHeightBehavior(
+ applyHeightToFirstAscent: false,
+ applyHeightToLastDescent: false,
+);