π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
[mobile] Remove unused Auth and Photos code (#13209)
neeraj-pilot07c3d7edc54e
diff --git a/mobile/apps/auth/lib/onboarding/view/onboarding_page.dart b/mobile/apps/auth/lib/onboarding/view/onboarding_page.dartindex c0b3fb77bd..7bd19db6a5 100644--- a/mobile/apps/auth/lib/onboarding/view/onboarding_page.dart+++ b/mobile/apps/auth/lib/onboarding/view/onboarding_page.dart@@ -21,11 +21,11 @@ import 'package:ente_auth/ui/settings/developer_settings_widget.dart';import 'package:ente_auth/ui/settings/language_picker.dart';import 'package:ente_auth/utils/debug_build_flags.dart';import 'package:ente_auth/utils/dialog_util.dart';-import 'package:ente_auth/utils/navigation_util.dart';import 'package:ente_auth/utils/platform_util.dart';import 'package:ente_auth/utils/toast_util.dart';import 'package:ente_components/ente_components.dart';import 'package:ente_events/event_bus.dart';+import 'package:ente_pure_utils/ente_pure_utils.dart';import 'package:ente_strings/ente_strings.dart';import 'package:ente_ui/components/alert_bottom_sheet.dart';import 'package:ente_ui/components/buttons/button_widget.dart';diff --git a/mobile/apps/auth/lib/ui/components/actions_bar_widget.dart b/mobile/apps/auth/lib/ui/components/actions_bar_widget.dartdeleted file mode 100644index 9ea37c3310..0000000000--- a/mobile/apps/auth/lib/ui/components/actions_bar_widget.dart+++ /dev/null@@ -1,72 +0,0 @@-import 'package:ente_auth/models/code.dart';-import 'package:ente_auth/theme/ente_theme.dart';-import 'package:ente_strings/ente_strings.dart';-import 'package:flutter/material.dart';--class ActionBarWidget extends StatefulWidget {- final VoidCallback? onCancel;- final Code code;-- const ActionBarWidget({- required this.onCancel,- required this.code,- super.key,- });-- @override- State<ActionBarWidget> createState() => _ActionBarWidgetState();-}--class _ActionBarWidgetState extends State<ActionBarWidget> {- @override- Widget build(BuildContext context) {- final textTheme = getEnteTextTheme(context);- return SizedBox(- child: Padding(- padding: const EdgeInsets.fromLTRB(20, 8, 20, 8),- child: Column(- crossAxisAlignment: CrossAxisAlignment.start,- children: [- if (widget.code.note.isNotEmpty)- SelectableText(widget.code.note, style: textTheme.miniMuted),- Row(- mainAxisAlignment: MainAxisAlignment.spaceBetween,- children: [- Flexible(- flex: 1,- child: Column(- children: [- SelectableText(- widget.code.issuerAccount,- style: textTheme.miniMuted,- ),- ],- ),- ),- Flexible(- flex: 1,- child: Padding(- padding: const EdgeInsets.symmetric(vertical: 12),- child: GestureDetector(- behavior: HitTestBehavior.opaque,- onTap: () {- widget.onCancel?.call();- },- child: Align(- alignment: Alignment.centerRight,- child: Text(- context.strings.cancel,- style: textTheme.mini,- ),- ),- ),- ),- ),- ],- ),- ],- ),- ),- );- }-}diff --git a/mobile/apps/auth/lib/ui/components/bottom_action_bar_widget.dart b/mobile/apps/auth/lib/ui/components/bottom_action_bar_widget.dartdeleted file mode 100644index 8721a5ecd4..0000000000--- a/mobile/apps/auth/lib/ui/components/bottom_action_bar_widget.dart+++ /dev/null@@ -1,85 +0,0 @@-import 'dart:math';--import 'package:ente_auth/models/code.dart';-import 'package:ente_auth/theme/ente_theme.dart';-import 'package:ente_auth/ui/components/actions_bar_widget.dart';-import 'package:ente_auth/ui/components/code_selection_actions_widget.dart';-import 'package:ente_auth/ui/components/components_constants.dart';-import "package:ente_ui/components/divider_widget.dart";-import 'package:flutter/material.dart';--class BottomActionBarWidget extends StatelessWidget {- final Code code;- final VoidCallback? onCancel;- final Color? backgroundColor;- final VoidCallback? onShare;- final VoidCallback? onPin;- final VoidCallback? onShowQR;- final VoidCallback? onEdit;- final VoidCallback? onRestore;- final VoidCallback? onDelete;- final VoidCallback? onTrashed;- final bool showPin;-- const BottomActionBarWidget({- required this.code,- this.onCancel,- this.showPin = true,- this.backgroundColor,- super.key,- this.onShare,- this.onPin,- this.onShowQR,- this.onEdit,- this.onRestore,- this.onDelete,- this.onTrashed,- });-- @override- Widget build(BuildContext context) {- final bottomPadding = MediaQuery.of(context).padding.bottom;- final widthOfScreen = MediaQuery.of(context).size.width;- final colorScheme = getEnteColorScheme(context);- final double leftRightPadding = min(- widthOfScreen > restrictedMaxWidth- ? (widthOfScreen - restrictedMaxWidth) / 2- : 0,- 20,- );- return Container(- decoration: BoxDecoration(- color: backgroundColor ?? colorScheme.backgroundElevated2,- borderRadius: const BorderRadius.only(- topLeft: Radius.circular(8),- topRight: Radius.circular(8),- ),- ),- padding: EdgeInsets.only(- top: 4,- bottom: bottomPadding,- right: leftRightPadding,- left: leftRightPadding,- ),- child: Column(- mainAxisSize: MainAxisSize.min,- children: [- const SizedBox(height: 8),- CodeSelectionActionsWidget(- code: code,- showPin: showPin,- onShare: onShare,- onPin: onPin,- onShowQR: onShowQR,- onEdit: onEdit,- onRestore: onRestore,- onDelete: onDelete,- onTrashed: onTrashed,- ),- const DividerWidget(dividerType: DividerType.bottomBar),- ActionBarWidget(code: code, onCancel: onCancel),- ],- ),- );- }-}diff --git a/mobile/apps/auth/lib/ui/components/code_selection_actions_widget.dart b/mobile/apps/auth/lib/ui/components/code_selection_actions_widget.dartdeleted file mode 100644index 0f133358b6..0000000000--- a/mobile/apps/auth/lib/ui/components/code_selection_actions_widget.dart+++ /dev/null@@ -1,142 +0,0 @@-import "package:ente_auth/models/code.dart";-import "package:ente_auth/ui/components/selection_action_button.dart";-import "package:ente_strings/ente_strings.dart";-import 'package:flutter/material.dart';--class CodeSelectionActionsWidget extends StatefulWidget {- final Code code;- final bool showPin;- final VoidCallback? onShare;- final VoidCallback? onPin;- final VoidCallback? onShowQR;- final VoidCallback? onEdit;- final VoidCallback? onRestore;- final VoidCallback? onDelete;- final VoidCallback? onTrashed;-- const CodeSelectionActionsWidget({- super.key,- required this.code,- this.showPin = true,- this.onShare,- this.onPin,- this.onShowQR,- this.onEdit,- this.onRestore,- this.onDelete,- this.onTrashed,- });-- @override- State<CodeSelectionActionsWidget> createState() =>- _CodeSelectionActionsWidgetState();-}--class _CodeSelectionActionsWidgetState- extends State<CodeSelectionActionsWidget> {- late final scrollController = ScrollController();-- @override- void dispose() {- scrollController.dispose();- super.dispose();- }-- @override- Widget build(BuildContext context) {- final List<SelectionActionButton> items = [];-- if (!widget.code.isTrashed) {- items.add(- SelectionActionButton(- labelText: context.strings.share,- icon: Icons.adaptive.share_outlined,- onTap: widget.onShare,- ),- );- if (widget.showPin) {- items.add(- SelectionActionButton(- labelText: widget.code.isPinned- ? context.strings.unpinText- : context.strings.pinText,- icon: widget.code.isPinned- ? Icons.push_pin- : Icons.push_pin_outlined,- onTap: widget.onPin,- ),- );- }-- items.add(- SelectionActionButton(- labelText: 'QR',- icon: Icons.qr_code_2_outlined,- onTap: widget.onShowQR,- ),- );- }-- if (widget.code.isTrashed) {- items.add(- SelectionActionButton(- labelText: context.strings.restore,- icon: Icons.restore_outlined,- onTap: widget.onRestore,- ),- );- } else {- items.add(- SelectionActionButton(- labelText: context.strings.edit,- icon: Icons.edit,- onTap: widget.onEdit,- ),- );- }-- items.add(- SelectionActionButton(- labelText: widget.code.isTrashed- ? context.strings.delete- : context.strings.trash,- icon: widget.code.isTrashed ? Icons.delete_forever : Icons.delete,- onTap: widget.code.isTrashed ? widget.onDelete : widget.onTrashed,- ),- );-- if (items.isNotEmpty) {- // h4ck: https://github.com/flutter/flutter/issues/57920#issuecomment-893970066- return MediaQuery(- data: MediaQuery.of(context).removePadding(removeBottom: true),- child: SafeArea(- child: Scrollbar(- radius: const Radius.circular(1),- thickness: 2,- controller: scrollController,- thumbVisibility: true,- child: SingleChildScrollView(- controller: scrollController,- physics: const BouncingScrollPhysics(- decelerationRate: ScrollDecelerationRate.fast,- ),- scrollDirection: Axis.horizontal,- child: Container(- padding: const EdgeInsets.only(bottom: 24),- child: Row(- crossAxisAlignment: CrossAxisAlignment.start,- children: [- const SizedBox(width: 4),- ...items,- const SizedBox(width: 4),- ],- ),- ),- ),- ),- ),- );- }- return const SizedBox();- }-}diff --git a/mobile/apps/auth/lib/ui/components/selection_action_button.dart b/mobile/apps/auth/lib/ui/components/selection_action_button.dartdeleted file mode 100644index 00f6d6f916..0000000000--- a/mobile/apps/auth/lib/ui/components/selection_action_button.dart+++ /dev/null@@ -1,193 +0,0 @@-import 'dart:math' as math;--import "package:ente_auth/theme/ente_theme.dart";-import "package:flutter/material.dart";-import "package:flutter_svg/svg.dart";--class SelectionActionButton extends StatelessWidget {- final String labelText;- final IconData? icon;- final String? svgAssetPath;- final VoidCallback? onTap;- final bool shouldShow;-- const SelectionActionButton({- required this.labelText,- required this.onTap,- this.icon,- this.svgAssetPath,- this.shouldShow = true,- super.key,- });-- @override- Widget build(BuildContext context) {- assert(icon != null || svgAssetPath != null);- return AnimatedSize(- duration: const Duration(milliseconds: 350),- curve: Curves.easeInOutCirc,- child: AnimatedSwitcher(- duration: const Duration(milliseconds: 300),- child: shouldShow- ? _Body(- labelText: labelText,- icon: icon,- onTap: onTap,- svgAssetPath: svgAssetPath,- )- : const SizedBox(height: 60),- ),- );- }-}--class _Body extends StatefulWidget {- final String labelText;- final IconData? icon;- final String? svgAssetPath;- final VoidCallback? onTap;- const _Body({- required this.labelText,- required this.onTap,- this.icon,- this.svgAssetPath,- });-- @override- State<_Body> createState() => __BodyState();-}--class __BodyState extends State<_Body> {- static const minWidth = 64.0;- late double widthOfButton;- Color? backgroundColor;-- @override- Widget build(BuildContext context) {- widthOfButton = getWidthOfButton();- final colorScheme = getEnteColorScheme(context);- return GestureDetector(- onTap: widget.onTap,- onTapDown: (details) {- setState(() {- backgroundColor = colorScheme.fillFaintPressed;- });- },- onTapUp: (details) {- setState(() {- backgroundColor = null;- });- },- onTapCancel: () {- setState(() {- backgroundColor = null;- });- },- child: Container(- decoration: BoxDecoration(- borderRadius: BorderRadius.circular(8),- color: backgroundColor,- ),- child: Padding(- padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 8),- child: SizedBox(- width: widthOfButton,- child: Column(- mainAxisAlignment: MainAxisAlignment.center,- mainAxisSize: MainAxisSize.min,- children: [- if (widget.icon == Icons.navigation_rounded)- Transform.rotate(- angle: math.pi / 2,- child: Icon(- widget.icon,- size: 24,- color: getEnteColorScheme(context).primary300,- shadows: const [- BoxShadow(- color: Color.fromARGB(12, 0, 179, 60),- offset: Offset(0, 2.51),- blurRadius: 5.02,- spreadRadius: 0,- ),- BoxShadow(- color: Color.fromARGB(24, 0, 179, 60),- offset: Offset(0, 1.25),- blurRadius: 3.76,- spreadRadius: 0,- ),- BoxShadow(- color: Color.fromARGB(24, 0, 179, 60),- offset: Offset(0, 0.63),- blurRadius: 1.88,- spreadRadius: 0,- ),- ],- ),- )- else- widget.svgAssetPath != null- ? SvgPicture.asset(- widget.svgAssetPath!,- colorFilter: ColorFilter.mode(- getEnteColorScheme(context).textMuted,- BlendMode.srcIn,- ),- width: 24,- height: 24,- )- : Icon(- widget.icon,- size: 24,- color: getEnteColorScheme(context).textMuted,- ),- const SizedBox(height: 4),- Text(- widget.labelText,- textAlign: TextAlign.center,- // Keep this style in sync with getWidthOfWidestWord.- style: getEnteTextTheme(context).miniMuted,- ),- ],- ),- ),- ),- ),- );- }-- double getWidthOfButton() {- final widthOfWidestWord = getWidthOfWidestWord(widget.labelText);- if (widthOfWidestWord > minWidth) return widthOfWidestWord;- return minWidth;- }-- double getWidthOfWidestWord(String labelText) {- final words = labelText.split(RegExp(r'\s+'));- if (words.isEmpty) return 0.0;-- double maxWidth = 0.0;- for (String word in words) {- final width = computeWidthOfWord(- word,- getEnteTextTheme(context).miniMuted,- );- if (width > maxWidth) {- maxWidth = width;- }- }- return maxWidth;- }-- //Todo: this doesn't give the correct width of the word, make it right- double computeWidthOfWord(String text, TextStyle style) {- final textPainter = TextPainter(- text: TextSpan(text: text, style: style),- maxLines: 1,- textDirection: TextDirection.ltr,- textScaler: MediaQuery.textScalerOf(context),- )..layout();- // Add 8 points because TextPainter under-measures this label.- return textPainter.size.width + 8;- }-}diff --git a/mobile/apps/auth/lib/ui/home/home_empty_state.dart b/mobile/apps/auth/lib/ui/home/home_empty_state.dartindex df1c5bcf01..ce4e9cf6c5 100644--- a/mobile/apps/auth/lib/ui/home/home_empty_state.dart+++ b/mobile/apps/auth/lib/ui/home/home_empty_state.dart@@ -1,5 +1,4 @@import 'package:ente_auth/ui/settings/data/import_page.dart';-import 'package:ente_auth/utils/navigation_util.dart' as auth_nav;import 'package:ente_auth/utils/platform_util.dart';import 'package:ente_components/ente_components.dart';import 'package:ente_pure_utils/ente_pure_utils.dart';@@ -134,10 +133,7 @@ class HomeEmptyStateWidget extends StatelessWidget {size: ButtonComponentSize.small,variant: ButtonComponentVariant.link,onTap: () {- auth_nav.routeToPage(- context,- const ImportCodePage(),- );+ routeToPage(context, const ImportCodePage());},),ButtonComponent(diff --git a/mobile/apps/auth/lib/utils/date_time_util.dart b/mobile/apps/auth/lib/utils/date_time_util.dartdeleted file mode 100644index 816fe1ff7e..0000000000--- a/mobile/apps/auth/lib/utils/date_time_util.dart+++ /dev/null@@ -1,231 +0,0 @@-import 'package:flutter/material.dart';-import 'package:intl/intl.dart';--const Set<int> monthWith31Days = {1, 3, 5, 7, 8, 10, 12};-const Set<int> monthWith30Days = {4, 6, 9, 11};-Map<int, String> _months = {- 1: "Jan",- 2: "Feb",- 3: "March",- 4: "April",- 5: "May",- 6: "Jun",- 7: "July",- 8: "Aug",- 9: "Sep",- 10: "Oct",- 11: "Nov",- 12: "Dec",-};--Map<int, String> _fullMonths = {- 1: "January",- 2: "February",- 3: "March",- 4: "April",- 5: "May",- 6: "June",- 7: "July",- 8: "August",- 9: "September",- 10: "October",- 11: "November",- 12: "December",-};--Map<int, String> _days = {- 1: "Mon",- 2: "Tue",- 3: "Wed",- 4: "Thu",- 5: "Fri",- 6: "Sat",- 7: "Sun",-};--final currentYear = int.parse(DateTime.now().year.toString());-const searchStartYear = 1970;--String getMonthAndYear(DateTime dateTime) {- return "${_months[dateTime.month]!} ${dateTime.year}";-}--String getDayAndMonth(DateTime dateTime) {- return "${_days[dateTime.weekday]!}, ${dateTime.day} ${_months[dateTime.month]!}";-}--String getDateAndMonthAndYear(DateTime dateTime) {- return "${dateTime.day} ${_months[dateTime.month]!}, ${dateTime.year}";-}--String getDay(DateTime dateTime) {- return _days[dateTime.weekday]!;-}--String getMonth(DateTime dateTime) {- return _months[dateTime.month]!;-}--String getFullMonth(DateTime dateTime) {- return _fullMonths[dateTime.month]!;-}--String getAbbreviationOfYear(DateTime dateTime) {- return (dateTime.year % 100).toString();-}--String getTime(DateTime dateTime) {- final hours = dateTime.hour > 9- ? dateTime.hour.toString()- : "0${dateTime.hour}";- final minutes = dateTime.minute > 9- ? dateTime.minute.toString()- : "0${dateTime.minute}";- return "$hours:$minutes";-}--String getTimeIn12hrFormat(DateTime dateTime) {- return DateFormat.jm().format(dateTime);-}--String getFormattedTime(DateTime dateTime) {- return "${getDay(dateTime)}, ${getMonth(dateTime)} ${dateTime.day}, ${dateTime.year} - ${getTime(dateTime)}";-}--String getFormattedDate(DateTime dateTime) {- return "${dateTime.day} ${getMonth(dateTime)}'${getAbbreviationOfYear(dateTime)}";-}--String getFullDate(DateTime dateTime) {- return "${getDay(dateTime)}, ${getMonth(dateTime)} ${dateTime.day} ${dateTime.year}";-}--String daysLeft(int futureTime) {- final int daysLeft =- ((futureTime - DateTime.now().microsecondsSinceEpoch) /- Duration.microsecondsPerDay)- .ceil();- return '$daysLeft day${daysLeft <= 1 ? "" : "s"}';-}--String formatDuration(Duration position) {- final ms = position.inMilliseconds;-- int seconds = ms ~/ 1000;- final int hours = seconds ~/ 3600;- seconds = seconds % 3600;- final minutes = seconds ~/ 60;- seconds = seconds % 60;-- final hoursString = hours >= 10- ? '$hours'- : hours == 0- ? '00'- : '0$hours';-- final minutesString = minutes >= 10- ? '$minutes'- : minutes == 0- ? '00'- : '0$minutes';-- final secondsString = seconds >= 10- ? '$seconds'- : seconds == 0- ? '00'- : '0$seconds';-- final formattedTime =- '${hoursString == '00' ? '' : '$hoursString:'}$minutesString:$secondsString';-- return formattedTime;-}--bool isLeapYear(DateTime dateTime) {- final year = dateTime.year;- if (year % 4 == 0) {- if (year % 100 == 0) {- if (year % 400 == 0) {- return true;- } else {- return false;- }- } else {- return true;- }- } else {- return false;- }-}--Widget getDayWidget(- BuildContext context,- int timestamp,- bool smallerTodayFont,-) {- return Container(- padding: const EdgeInsets.fromLTRB(4, 14, 0, 8),- alignment: Alignment.centerLeft,- child: Text(- getDayTitle(timestamp),- style: (getDayTitle(timestamp) == "Today" && !smallerTodayFont)- ? Theme.of(context).textTheme.headlineSmall- : Theme.of(context).textTheme.bodySmall?.copyWith(- fontSize: 16,- fontWeight: FontWeight.w600,- fontFamily: 'Inter-SemiBold',- ),- ),- );-}--String getDayTitle(int timestamp) {- final date = DateTime.fromMicrosecondsSinceEpoch(timestamp);- final now = DateTime.now();- var title = getDayAndMonth(date);- if (date.year == now.year && date.month == now.month) {- if (date.day == now.day) {- title = "Today";- } else if (date.day == now.day - 1) {- title = "Yesterday";- }- }- if (date.year != DateTime.now().year) {- title += " ${date.year}";- }- return title;-}--String secondsToHHMMSS(int value) {- int h, m, s;- h = value ~/ 3600;- m = ((value - h * 3600)) ~/ 60;- s = value - (h * 3600) - (m * 60);- final String hourLeft = h.toString().length < 2 ? "0$h" : h.toString();-- final String minuteLeft = m.toString().length < 2 ? "0$m" : m.toString();-- final String secondsLeft = s.toString().length < 2 ? "0$s" : s.toString();-- final String result = "$hourLeft:$minuteLeft:$secondsLeft";-- return result;-}--bool isValidDate({required int day, required int month, required int year}) {- if (day < 0 || day > 31 || month < 0 || month > 12 || year < 0) {- return false;- }- if (monthWith30Days.contains(month) && day > 30) {- return false;- }- if (month == 2) {- if (day > 29) {- return false;- }- if (day == 29 && year % 4 != 0) {- return false;- }- }- return true;-}diff --git a/mobile/apps/auth/lib/utils/navigation_util.dart b/mobile/apps/auth/lib/utils/navigation_util.dartdeleted file mode 100644index 09752b5c58..0000000000--- a/mobile/apps/auth/lib/utils/navigation_util.dart+++ /dev/null@@ -1,141 +0,0 @@-import 'dart:io';--import 'package:flutter/cupertino.dart' show CupertinoPageTransitionsBuilder;-import 'package:flutter/material.dart';--Future<T?> routeToPage<T extends Object>(- BuildContext context,- Widget page, {- bool forceCustomPageRoute = false,-}) {- if (Platform.isAndroid || forceCustomPageRoute) {- return Navigator.of(context).push(_buildPageRoute(page));- } else {- return Navigator.of(context).push(- SwipeableRouteBuilder(- pageBuilder: (context, animation, secondaryAnimation) {- return page;- },- ),- );- }-}--void replacePage(BuildContext context, Widget page) {- Navigator.of(context).pushReplacement(_buildPageRoute(page));-}--PageRouteBuilder<T> _buildPageRoute<T extends Object>(Widget page) {- return PageRouteBuilder(- pageBuilder:- (- BuildContext context,- Animation<double> animation,- Animation<double> secondaryAnimation,- ) {- return page;- },- transitionsBuilder:- (- BuildContext context,- Animation<double> animation,- Animation<double> secondaryAnimation,- Widget child,- ) {- return Align(- child: FadeTransition(opacity: animation, child: child),- );- },- transitionDuration: const Duration(milliseconds: 200),- opaque: false,- );-}--class SwipeableRouteBuilder<T> extends PageRoute<T> {- final RoutePageBuilder pageBuilder;- // Preserves the iOS back-swipe gesture.- final PageTransitionsBuilder matchingBuilder =- const CupertinoPageTransitionsBuilder();-- SwipeableRouteBuilder({required this.pageBuilder});-- @override- Null get barrierColor => null;-- @override- Null get barrierLabel => null;-- @override- Widget buildPage(- BuildContext context,- Animation<double> animation,- Animation<double> secondaryAnimation,- ) {- return pageBuilder(context, animation, secondaryAnimation);- }-- @override- bool get maintainState => true;-- @override- Duration get transitionDuration => const Duration(milliseconds: 300);-- @override- Widget buildTransitions(- BuildContext context,- Animation<double> animation,- Animation<double> secondaryAnimation,- Widget child,- ) {- return matchingBuilder.buildTransitions<T>(- this,- context,- animation,- secondaryAnimation,- child,- );- }-- @override- bool get opaque => false;-}--class TransparentRoute extends PageRoute<void> {- TransparentRoute({required this.builder, super.settings})- : assert(builder != null),- super(fullscreenDialog: false);-- final WidgetBuilder? builder;-- @override- bool get opaque => false;-- @override- Null get barrierColor => null;-- @override- Null get barrierLabel => null;-- @override- bool get maintainState => true;-- @override- Duration get transitionDuration => const Duration(milliseconds: 200);-- @override- Widget buildPage(- BuildContext context,- Animation<double> animation,- Animation<double> secondaryAnimation,- ) {- final result = builder!(context);- return FadeTransition(- opacity: Tween<double>(begin: 0, end: 1).animate(animation),- child: Semantics(- scopesRoute: true,- explicitChildNodes: true,- child: result,- ),- );- }-}diff --git a/mobile/apps/photos/lib/ui/rituals/all_rituals_screen.dart b/mobile/apps/photos/lib/ui/rituals/all_rituals_screen.dartindex c9f2dbc496..9acf48263b 100644--- a/mobile/apps/photos/lib/ui/rituals/all_rituals_screen.dart+++ b/mobile/apps/photos/lib/ui/rituals/all_rituals_screen.dart@@ -19,10 +19,7 @@ import "package:photos/ui/rituals/ritual_privacy.dart";import "package:photos/ui/rituals/start_new_ritual_card.dart";class AllRitualsScreen extends StatelessWidget {- const AllRitualsScreen({super.key, this.ritual});-- // Legacy param; retained for call sites that pass it.- final Ritual? ritual;+ const AllRitualsScreen({super.key});@overrideWidget build(BuildContext context) {diff --git a/mobile/apps/photos/lib/ui/rituals/ritual_heatmap_card.dart b/mobile/apps/photos/lib/ui/rituals/ritual_heatmap_card.dartdeleted file mode 100644index 9045c34720..0000000000--- a/mobile/apps/photos/lib/ui/rituals/ritual_heatmap_card.dart+++ /dev/null@@ -1,399 +0,0 @@-import "dart:io";-import "dart:math";-import "dart:typed_data";-import "dart:ui" as ui;--import "package:flutter/material.dart";-import "package:flutter/rendering.dart";-import "package:intl/intl.dart";-import "package:logging/logging.dart";-import "package:path_provider/path_provider.dart";-import "package:photos/models/rituals/ritual_models.dart";-import "package:photos/theme/colors.dart";-import "package:photos/theme/ente_theme.dart";-import "package:photos/theme/text_style.dart";-import "package:share_plus/share_plus.dart";--class RitualHeatmapCard extends StatefulWidget {- const RitualHeatmapCard({- required this.ritual,- required this.progress,- this.compact = false,- this.allowHorizontalScroll = true,- this.showShareButton = false,- this.daysToShow = 365,- super.key,- });-- final Ritual ritual;- final RitualProgress? progress;- final bool compact;- final bool allowHorizontalScroll;- final bool showShareButton;- final int daysToShow;-- @override- State<RitualHeatmapCard> createState() => _RitualHeatmapCardState();-}--class _RitualHeatmapCardState extends State<RitualHeatmapCard> {- static final Logger _logger = Logger("RitualHeatmapCard");- final GlobalKey _repaintKey = GlobalKey();- final GlobalKey _shareButtonKey = GlobalKey();-- @override- Widget build(BuildContext context) {- final colorScheme = getEnteColorScheme(context);- final textTheme = getEnteTextTheme(context);-- final progress = widget.progress;- final dayKeys = progress?.completedDayKeys ?? const <int>{};- final now = DateTime.now();- final todayMidnight = DateTime(now.year, now.month, now.day);- final startDay = DateTime(- todayMidnight.year,- todayMidnight.month,- todayMidnight.day - max(0, widget.daysToShow - 1),- );-- final title = widget.ritual.title.isEmpty ? "Ritual" : widget.ritual.title;- final header = "${widget.ritual.icon} $title";-- return Padding(- padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),- child: Container(- clipBehavior: Clip.antiAlias,- decoration: BoxDecoration(- color: Theme.of(context).colorScheme.brightness == Brightness.dark- ? colorScheme.backgroundElevated2- : const Color(0xFFFAFAFA),- borderRadius: BorderRadius.circular(24),- border: Border.all(color: colorScheme.strokeFaint),- ),- padding: const EdgeInsets.fromLTRB(12, 12, 12, 12),- child: Column(- crossAxisAlignment: CrossAxisAlignment.start,- children: [- Row(- children: [- Expanded(- child: Text(- header,- style: textTheme.bodyMuted,- maxLines: 1,- overflow: TextOverflow.ellipsis,- ),- ),- if (widget.showShareButton)- IconButton(- key: _shareButtonKey,- onPressed: progress == null ? null : _shareHeatmap,- tooltip: MaterialLocalizations.of(context).shareButtonLabel,- icon: const Icon(Icons.share_rounded),- ),- ],- ),- const SizedBox(height: 10),- RepaintBoundary(- key: _repaintKey,- child: widget.allowHorizontalScroll- ? SingleChildScrollView(- scrollDirection: Axis.horizontal,- physics: const ClampingScrollPhysics(),- child: _Heatmap(- ritual: widget.ritual,- completedDayKeys: dayKeys,- startDay: startDay,- endDayInclusive: todayMidnight,- compact: widget.compact,- ),- )- : _Heatmap(- ritual: widget.ritual,- completedDayKeys: dayKeys,- startDay: startDay,- endDayInclusive: todayMidnight,- compact: widget.compact,- ),- ),- if (progress != null) ...[- const SizedBox(height: 12),- Row(- children: [- Text(- "Current: ${progress.currentStreak}",- style: textTheme.smallMuted,- ),- const SizedBox(width: 12),- Text(- "Month: ${progress.longestStreakThisMonth}",- style: textTheme.smallMuted,- ),- const SizedBox(width: 12),- Text(- "All-time: ${progress.longestStreakOverall}",- style: textTheme.smallMuted,- ),- ],- ),- ],- ],- ),- ),- );- }-- Future<void> _shareHeatmap() async {- try {- final RenderObject? renderObject = _repaintKey.currentContext- ?.findRenderObject();- if (renderObject is! RenderRepaintBoundary) {- throw StateError("Heatmap boundary not found");- }- final pixelRatio = (MediaQuery.devicePixelRatioOf(context) * 2).clamp(- 2.0,- 3.5,- );- final ui.Image image = await renderObject.toImage(pixelRatio: pixelRatio);- final ByteData? bytes = await image.toByteData(- format: ui.ImageByteFormat.png,- );- final data = bytes?.buffer.asUint8List();- if (data == null || data.isEmpty) {- throw StateError("Failed to render heatmap image");- }-- final dir = await getTemporaryDirectory();- final file = File(- "${dir.path}/ritual_heatmap_${widget.ritual.id}_${DateTime.now().millisecondsSinceEpoch}.png",- );- await file.writeAsBytes(data, flush: true);-- if (!mounted) return;- final shareOrigin = _shareButtonRect(context, _shareButtonKey);- await SharePlus.instance.share(- ShareParams(- files: [XFile(file.path)],- sharePositionOrigin: shareOrigin,- ),- );- } catch (e, s) {- _logger.warning("Failed to share ritual heatmap", e, s);- if (!mounted) return;- ScaffoldMessenger.of(- context,- ).showSnackBar(const SnackBar(content: Text("Failed to share heatmap")));- }- }-}--class _Heatmap extends StatelessWidget {- const _Heatmap({- required this.ritual,- required this.completedDayKeys,- required this.startDay,- required this.endDayInclusive,- required this.compact,- });-- final Ritual ritual;- final Set<int> completedDayKeys;- final DateTime startDay;- final DateTime endDayInclusive;- final bool compact;-- @override- Widget build(BuildContext context) {- final colorScheme = getEnteColorScheme(context);- final textTheme = getEnteTextTheme(context);- final monthFormatter = DateFormat.MMM(- Localizations.localeOf(context).toString(),- );-- final cell = compact ? 10.0 : 12.0;- final spacing = compact ? 2.0 : 3.0;-- final gridStart = _startOfWeekSunday(startDay);- final gridEnd = _endOfWeekSaturday(endDayInclusive);- final weeks = _weekStarts(gridStart, gridEnd);- final monthLabels = _monthLabelsForWeeks(monthFormatter, weeks);-- return Column(- crossAxisAlignment: CrossAxisAlignment.start,- children: [- SizedBox(- height: 18,- child: Row(- crossAxisAlignment: CrossAxisAlignment.start,- children: List.generate(weeks.length, (index) {- final label = monthLabels[index];- return SizedBox(- width: cell + spacing,- child: label == null- ? const SizedBox.shrink()- : Text(- label,- style: textTheme.miniMuted,- maxLines: 1,- overflow: TextOverflow.clip,- ),- );- }, growable: false),- ),- ),- Row(- crossAxisAlignment: CrossAxisAlignment.start,- children: [- if (!compact)- SizedBox(- width: 18,- child: Column(- children: [- _weekdayLabel(textTheme, "M", cell),- SizedBox(height: cell + spacing),- _weekdayLabel(textTheme, "W", cell),- SizedBox(height: cell + spacing),- _weekdayLabel(textTheme, "F", cell),- ],- ),- ),- Row(- children: weeks- .map(- (weekStart) => Padding(- padding: EdgeInsets.only(right: spacing),- child: Column(- children: List.generate(7, (dayOffset) {- final day = DateTime(- weekStart.year,- weekStart.month,- weekStart.day + dayOffset,- );- final bool inRange =- !day.isBefore(startDay) &&- !day.isAfter(endDayInclusive);- final bool scheduled = _isScheduledDay(- ritual.daysOfWeek,- day,- );- final bool completed = completedDayKeys.contains(- DateTime(- day.year,- day.month,- day.day,- ).millisecondsSinceEpoch,- );-- final Color fill = _cellColor(- colorScheme: colorScheme,- inRange: inRange,- scheduled: scheduled,- completed: completed,- );-- return Padding(- padding: EdgeInsets.only(bottom: spacing),- child: Container(- width: cell,- height: cell,- decoration: BoxDecoration(- color: fill,- borderRadius: BorderRadius.circular(3),- ),- ),- );- }),- ),- ),- )- .toList(growable: false),- ),- ],- ),- ],- );- }-- Widget _weekdayLabel(EnteTextTheme textTheme, String label, double cell) {- return SizedBox(- width: 18,- height: cell,- child: Center(child: Text(label, style: textTheme.miniMuted)),- );- }-- Color _cellColor({- required EnteColorScheme colorScheme,- required bool inRange,- required bool scheduled,- required bool completed,- }) {- if (!inRange) {- return Colors.transparent;- }- if (!scheduled) {- return colorScheme.fillFaint.withValues(alpha: 0.35);- }- if (completed) {- return const Color(0xFF1DB954);- }- return colorScheme.fillFaintPressed;- }-}--List<String?> _monthLabelsForWeeks(DateFormat formatter, List<DateTime> weeks) {- final labels = <String?>[];- int? lastLabeledMonth;- for (final weekStart in weeks) {- if (weekStart.day <= 7 && weekStart.month != lastLabeledMonth) {- labels.add(formatter.format(weekStart));- lastLabeledMonth = weekStart.month;- } else {- labels.add(null);- }- }- return labels;-}--bool _isScheduledDay(List<bool> daysOfWeek, DateTime day) {- if (daysOfWeek.length != 7) return false;- final dayIndex = day.weekday % 7; // Sunday -> 0- return daysOfWeek[dayIndex];-}--DateTime _startOfWeekSunday(DateTime day) {- final idx = day.weekday % 7; // Sunday -> 0- return DateTime(day.year, day.month, day.day - idx);-}--DateTime _endOfWeekSaturday(DateTime day) {- final idx = day.weekday % 7; // Sunday -> 0- return DateTime(day.year, day.month, day.day + (6 - idx));-}--List<DateTime> _weekStarts(DateTime start, DateTime endInclusive) {- final weeks = <DateTime>[];- for (- var day = start;- !day.isAfter(endInclusive);- day = day.add(const Duration(days: 7))- ) {- weeks.add(day);- }- return weeks;-}--Rect _shareButtonRect(BuildContext context, GlobalKey key) {- final size = MediaQuery.sizeOf(context);- final RenderObject? renderObject = key.currentContext?.findRenderObject();- if (renderObject is! RenderBox) {- return Rect.fromLTWH(0, 0, size.width, size.height / 2);- }- final buttonSize = renderObject.size;- final position = renderObject.localToGlobal(Offset.zero);- return Rect.fromCenter(- center: position + Offset(buttonSize.width / 2, buttonSize.height / 2),- width: buttonSize.width,- height: buttonSize.height,- );-}diff --git a/mobile/apps/photos/lib/ui/rituals/rituals_section.dart b/mobile/apps/photos/lib/ui/rituals/rituals_section.dartdeleted file mode 100644index cc6431c68c..0000000000--- a/mobile/apps/photos/lib/ui/rituals/rituals_section.dart+++ /dev/null@@ -1,370 +0,0 @@-import "package:ente_pure_utils/ente_pure_utils.dart";-import "package:ente_strings/ente_strings.dart";-import "package:flutter/material.dart";-import "package:hugeicons/hugeicons.dart";-import "package:photos/models/rituals/ritual_models.dart";-import "package:photos/service_locator.dart";-import "package:photos/theme/ente_theme.dart";-import "package:photos/ui/rituals/all_rituals_screen.dart";-import "package:photos/ui/rituals/delete_ritual_confirmation_sheet.dart";-import "package:photos/ui/rituals/ritual_camera_page.dart";-import "package:photos/ui/rituals/ritual_editor_dialog.dart";--class RitualsSection extends StatelessWidget {- const RitualsSection({- required this.rituals,- this.selectedRitualId,- this.onSelectionChanged,- this.showHeader = true,- super.key,- });-- final List<Ritual> rituals;- final String? selectedRitualId;- final ValueChanged<Ritual?>? onSelectionChanged;- final bool showHeader;-- @override- Widget build(BuildContext context) {- final colorScheme = getEnteColorScheme(context);- return Padding(- padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),- child: Column(- crossAxisAlignment: CrossAxisAlignment.start,- children: [- if (showHeader) ...[- Row(- children: [- Text(- context.strings.ritualsTitle,- style: Theme.of(context).textTheme.titleMedium,- ),- const Spacer(),- IconButton(- onPressed: () async {- await showRitualEditor(context, ritual: null);- },- style: IconButton.styleFrom(- backgroundColor: colorScheme.fillFaint,- shape: RoundedRectangleBorder(- borderRadius: BorderRadius.circular(10),- ),- padding: const EdgeInsets.all(8),- minimumSize: const Size(40, 40),- ),- icon: const HugeIcon(- icon: HugeIcons.strokeRoundedPlusSign,- size: 22,- ),- ),- ],- ),- const SizedBox(height: 8),- ] else- const SizedBox(height: 4),- if (rituals.isEmpty)- _CreateRitualCard(- onTap: () async {- await showRitualEditor(context, ritual: null);- },- )- else- Column(- children: rituals- .map(- (ritual) => _RitualCard(- ritual: ritual,- isSelected: ritual.id == selectedRitualId,- onTap: () => onSelectionChanged?.call(ritual),- ),- )- .toList(),- ),- ],- ),- );- }-}--class _CreateRitualCard extends StatelessWidget {- const _CreateRitualCard({this.onTap});-- final VoidCallback? onTap;-- @override- Widget build(BuildContext context) {- final colorScheme = getEnteColorScheme(context);- final textTheme = getEnteTextTheme(context);- return Container(- margin: const EdgeInsets.only(bottom: 12),- decoration: BoxDecoration(- color: colorScheme.backgroundElevated2,- borderRadius: BorderRadius.circular(16),- border: Border.all(color: colorScheme.backgroundElevated2, width: 2),- ),- child: Material(- color: Colors.transparent,- child: InkWell(- onTap: onTap,- borderRadius: BorderRadius.circular(16),- child: Padding(- padding: const EdgeInsets.all(12),- child: Row(- crossAxisAlignment: CrossAxisAlignment.center,- children: [- Container(- width: 40,- height: 40,- decoration: BoxDecoration(- color: colorScheme.fillFaintPressed,- borderRadius: BorderRadius.circular(12),- ),- child: Center(- child: HugeIcon(- icon: HugeIcons.strokeRoundedPlusSign,- color: colorScheme.textBase,- size: 24,- ),- ),- ),- const SizedBox(width: 12),- Expanded(- child: Column(- crossAxisAlignment: CrossAxisAlignment.start,- children: [- Text(- context.strings.ritualCreateYourOwn,- style: textTheme.body,- ),- Text(- context.strings.ritualGetDailyReminders,- style: textTheme.smallMuted,- ),- ],- ),- ),- const SizedBox(width: 12),- Icon(Icons.chevron_right_rounded, color: colorScheme.textMuted),- ],- ),- ),- ),- ),- );- }-}--class _RitualCard extends StatelessWidget {- const _RitualCard({- required this.ritual,- this.isSelected = false,- this.onTap,- });-- final Ritual ritual;- final bool isSelected;- final VoidCallback? onTap;-- @override- Widget build(BuildContext context) {- final colorScheme = getEnteColorScheme(context);- final textTheme = getEnteTextTheme(context);- return Container(- margin: const EdgeInsets.only(bottom: 12),- decoration: BoxDecoration(- color: colorScheme.backgroundElevated2,- borderRadius: BorderRadius.circular(16),- border: Border.all(- color: isSelected- ? colorScheme.primary500- : colorScheme.backgroundElevated2,- width: 2,- ),- ),- child: Material(- color: Colors.transparent,- child: InkWell(- onTap: () {- if (onTap != null) {- onTap!();- } else {- routeToPage(context, AllRitualsScreen(ritual: ritual));- }- },- borderRadius: BorderRadius.circular(16),- child: Padding(- padding: const EdgeInsets.fromLTRB(12, 0, 0, 0),- child: SizedBox(- height: 64,- child: Row(- crossAxisAlignment: CrossAxisAlignment.center,- children: [- Container(- width: 40,- height: 40,- decoration: BoxDecoration(- color: colorScheme.fillFaintPressed,- borderRadius: BorderRadius.circular(12),- ),- child: Center(- child: Text(- ritual.icon,- style: const TextStyle(- fontSize: 18,- height: 1,- decoration: TextDecoration.none,- ),- textHeightBehavior: _tightTextHeightBehavior,- ),- ),- ),- const SizedBox(width: 12),- Expanded(- child: Column(- crossAxisAlignment: CrossAxisAlignment.start,- mainAxisSize: MainAxisSize.min,- mainAxisAlignment: MainAxisAlignment.center,- children: [- Text(- ritual.title.isEmpty- ? context.strings.ritualUntitled- : ritual.title,- style: textTheme.body,- textHeightBehavior: _tightTextHeightBehavior,- ),- ritual.albumName == null || ritual.albumName!.isEmpty- ? Text(- context.strings.ritualAlbumNotSet,- style: textTheme.smallMuted,- textHeightBehavior: _tightTextHeightBehavior,- )- : Text(- ritual.albumName!,- style: textTheme.smallMuted,- textHeightBehavior: _tightTextHeightBehavior,- ),- ],- ),- ),- const SizedBox(width: 8),- IconButton(- icon: HugeIcon(- icon: HugeIcons.strokeRoundedCameraAdd01,- color: colorScheme.textBase,- size: 24,- ),- style: IconButton.styleFrom(- backgroundColor: colorScheme.fillFaint,- shape: RoundedRectangleBorder(- borderRadius: BorderRadius.circular(10),- ),- padding: const EdgeInsets.all(8),- minimumSize: const Size(40, 40),- ),- onPressed: () => openRitualCamera(context, ritual),- tooltip: context.strings.ritualOpenCameraTooltip,- ),- PopupMenuButton<String>(- padding: EdgeInsets.zero,- splashRadius: 20,- icon: Transform.translate(- offset: const Offset(4, 0),- child: const Icon(Icons.more_vert_rounded),- ),- elevation: 0,- color: colorScheme.backgroundElevated,- surfaceTintColor: colorScheme.backgroundElevated,- shape: RoundedRectangleBorder(- borderRadius: BorderRadius.circular(16),- side: BorderSide(- color: colorScheme.strokeFaint,- width: 0.5,- ),- ),- onSelected: (value) async {- switch (value) {- case "edit":- await showRitualEditor(context, ritual: ritual);- break;- case "delete":- final confirmed =- await showDeleteRitualConfirmationSheet(context);- if (!context.mounted || !confirmed) return;- await ritualsService.deleteRitual(ritual.id);- break;- }- },- itemBuilder: (context) => [- PopupMenuItem(- value: "edit",- padding: EdgeInsets.zero,- child: Column(- crossAxisAlignment: CrossAxisAlignment.start,- mainAxisSize: MainAxisSize.min,- children: [- Padding(- padding: const EdgeInsets.fromLTRB(12, 8, 12, 12),- child: Row(- children: [- HugeIcon(- icon: HugeIcons.strokeRoundedPencilEdit01,- color: colorScheme.textBase,- size: 22,- ),- const SizedBox(width: 10),- Text(- context.strings.edit,- style: getEnteTextTheme(context).body,- ),- ],- ),- ),- Divider(- height: 0.5,- thickness: 0.5,- color: colorScheme.strokeFaint,- indent: 0,- endIndent: 0,- ),- ],- ),- ),- PopupMenuItem(- value: "delete",- padding: EdgeInsets.zero,- child: Padding(- padding: const EdgeInsets.fromLTRB(12, 8, 12, 8),- child: Row(- children: [- const HugeIcon(- icon: HugeIcons.strokeRoundedDelete02,- color: Colors.red,- size: 22,- ),- const SizedBox(width: 10),- Text(- context.strings.delete,- style: getEnteTextTheme(- context,- ).body.copyWith(color: Colors.red),- ),- ],- ),- ),- ),- ],- ),- ],- ),- ),- ),- ),- ),- );- }-}--const _tightTextHeightBehavior = TextHeightBehavior(- applyHeightToFirstAscent: false,- applyHeightToLastDescent: false,-);