π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Use close icons for cancellable sheets
ashilkn1e5e7c9eab34
diff --git a/mobile/apps/photos/lib/ui/components/action_sheet_widget.dart b/mobile/apps/photos/lib/ui/components/action_sheet_widget.dartindex a78939197c..e8ee9d2082 100644--- a/mobile/apps/photos/lib/ui/components/action_sheet_widget.dart+++ b/mobile/apps/photos/lib/ui/components/action_sheet_widget.dart@@ -3,8 +3,8 @@ import "dart:io";import "package:ente_components/ente_components.dart";import 'package:flutter/material.dart';import 'package:modal_bottom_sheet/modal_bottom_sheet.dart';+import "package:photos/generated/l10n.dart";import 'package:photos/models/button_result.dart';-import 'package:photos/theme/colors.dart';import 'package:photos/ui/components/buttons/button_component_adapter.dart';import 'package:photos/ui/components/buttons/button_widget.dart';@@ -23,9 +23,10 @@ Future<ButtonResult?> showActionSheet({String? body,String? bodyHighlight,}) {+ final colors = context.componentColors;return showMaterialModalBottomSheet(backgroundColor: Colors.transparent,- barrierColor: backdropFaintDark,+ barrierColor: colors.specialScrim.withValues(alpha: 0.55),// On iOS setting it to false causes previous page to shift// So we're explicitly setting it to trueuseRootNavigator: Platform.isIOS,@@ -76,6 +77,14 @@ class ActionSheetWidget extends StatelessWidget {hasDefaultContent ||actionSheetType == ActionSheetType.iconOnly;final colors = context.componentColors;+ final cancelButtonIndex = sheetCancelButtonIndex(context, actionButtons);+ final cancelButton = cancelButtonIndex == -1+ ? null+ : actionButtons[cancelButtonIndex];+ final visibleButtons = [+ for (var index = 0; index < actionButtons.length; index++)+ if (index != cancelButtonIndex) actionButtons[index],+ ];return BottomSheetComponent(title: title,@@ -94,10 +103,15 @@ class ActionSheetWidget extends StatelessWidget {): null,actions: [- for (final button in actionButtons)+ for (final button in visibleButtons)ButtonComponentAdapter(button: button),],- showCloseButton: false,+ showCloseButton: cancelButton != null,+ closeTooltip: AppLocalizations.of(context).close,+ closeResult: cancelButton == null ? null : sheetCloseResult(cancelButton),+ onClose: cancelButton == null+ ? null+ : () => sheetCloseAction(context, cancelButton),actionsTopSpacing: hasContent ? Spacing.lg : 0,);}diff --git a/mobile/apps/photos/lib/ui/components/buttons/button_component_adapter.dart b/mobile/apps/photos/lib/ui/components/buttons/button_component_adapter.dartindex df480792b8..d7060c0689 100644--- a/mobile/apps/photos/lib/ui/components/buttons/button_component_adapter.dart+++ b/mobile/apps/photos/lib/ui/components/buttons/button_component_adapter.dart@@ -3,6 +3,7 @@ import "dart:async";import "package:ente_components/ente_components.dart";import "package:flutter/material.dart";import "package:modal_bottom_sheet/modal_bottom_sheet.dart";+import "package:photos/generated/l10n.dart";import "package:photos/models/button_result.dart";import "package:photos/ui/components/buttons/button_widget.dart";import "package:photos/ui/components/models/button_type.dart";@@ -114,3 +115,31 @@ void _popWithResult(BuildContext context, ButtonResult result) {Exception _toException(Object error) {return error is Exception ? error : Exception(error.toString());}++int sheetCancelButtonIndex(BuildContext context, List<ButtonWidget> buttons) {+ final cancelLabels = {AppLocalizations.of(context).cancel, 'Cancel'};+ return buttons.indexWhere(+ (button) =>+ button.isInAlert &&+ !button.isDisabled &&+ cancelLabels.contains(button.labelText),+ );+}++ButtonResult sheetCloseResult(ButtonWidget button) {+ return ButtonResult(button.buttonAction);+}++Future<void> sheetCloseAction(BuildContext context, ButtonWidget button) async {+ try {+ await button.onTap?.call();+ } catch (error) {+ if (button.isInAlert && context.mounted) {+ _popWithResult(+ context,+ ButtonResult(ButtonAction.error, _toException(error)),+ );+ }+ rethrow;+ }+}diff --git a/mobile/apps/photos/lib/ui/components/dialog_widget.dart b/mobile/apps/photos/lib/ui/components/dialog_widget.dartindex 858024742a..44fcf3e55b 100644--- a/mobile/apps/photos/lib/ui/components/dialog_widget.dart+++ b/mobile/apps/photos/lib/ui/components/dialog_widget.dart@@ -6,7 +6,6 @@ import "package:flutter/services.dart";import "package:photos/generated/l10n.dart";import 'package:photos/models/button_result.dart';import 'package:photos/models/typedefs.dart';-import 'package:photos/theme/colors.dart';import "package:photos/ui/components/buttons/button_component_adapter.dart";import 'package:photos/ui/components/buttons/button_widget.dart';@@ -21,7 +20,6 @@ Future<ButtonResult?> showDialogWidget({bool useRootNavigator = false,}) {return showBottomSheetComponent<ButtonResult>(- barrierColor: backdropFaintDark,context: context,isDismissible: isDismissible,enableDrag: isDismissible,@@ -56,6 +54,14 @@ class DialogWidget extends StatelessWidget {final hasTitle = title.isNotEmpty;final hasBody = body?.isNotEmpty == true;final hasContent = hasTitle || hasBody || icon != null;+ final cancelButtonIndex = sheetCancelButtonIndex(context, buttons);+ final cancelButton = cancelButtonIndex == -1+ ? null+ : buttons[cancelButtonIndex];+ final visibleButtons = [+ for (var index = 0; index < buttons.length; index++)+ if (index != cancelButtonIndex) buttons[index],+ ];return BottomSheetComponent(title: hasTitle ? title : null,@@ -64,9 +70,15 @@ class DialogWidget extends StatelessWidget {: Icon(icon, size: 48, color: colors.iconColor),content: hasBody ? _DialogBody(body!) : null,actions: [- for (final button in buttons) ButtonComponentAdapter(button: button),+ for (final button in visibleButtons)+ ButtonComponentAdapter(button: button),],- showCloseButton: false,+ showCloseButton: cancelButton != null,+ closeTooltip: AppLocalizations.of(context).close,+ closeResult: cancelButton == null ? null : sheetCloseResult(cancelButton),+ onClose: cancelButton == null+ ? null+ : () => sheetCloseAction(context, cancelButton),actionsTopSpacing: hasContent ? Spacing.xl : 0,);}@@ -225,12 +237,6 @@ class _TextInputDialogState extends State<TextInputDialog> {alignedMessageAlignment: widget.alignMessage,),actions: [- ButtonComponent(- label: AppLocalizations.of(context).cancel,- variant: ButtonComponentVariant.secondary,- shouldSurfaceExecutionStates: false,- onTap: () => Navigator.of(context).pop(ButtonResult()),- ),ButtonComponent(label: widget.submitButtonLabel,isDisabled: !_hasInput,@@ -241,7 +247,9 @@ class _TextInputDialogState extends State<TextInputDialog> {),],isKeyboardAware: true,- showCloseButton: false,+ showCloseButton: true,+ closeTooltip: AppLocalizations.of(context).close,+ closeResult: ButtonResult(),);}diff --git a/mobile/apps/photos/lib/utils/dialog_util.dart b/mobile/apps/photos/lib/utils/dialog_util.dartindex 09710cc150..461a417b73 100644--- a/mobile/apps/photos/lib/utils/dialog_util.dart+++ b/mobile/apps/photos/lib/utils/dialog_util.dart@@ -8,7 +8,6 @@ import 'package:photos/models/button_result.dart';import 'package:photos/models/typedefs.dart';import "package:photos/module/download/manager.dart";import "package:photos/service_locator.dart";-import 'package:photos/theme/colors.dart';import 'package:photos/ui/common/loading_widget.dart';import 'package:photos/ui/common/progress_dialog.dart';import 'package:photos/ui/components/action_sheet_widget.dart';@@ -369,7 +368,6 @@ Future<dynamic> showTextInputDialog(bool popnavAfterSubmission = true,}) {return showBottomSheetComponent<dynamic>(- barrierColor: backdropFaintDark,context: context,useRootNavigator: useRootNavigator,builder: (_) {diff --git a/mobile/apps/photos/test/ui/components/action_sheet_widget_test.dart b/mobile/apps/photos/test/ui/components/action_sheet_widget_test.dartindex 0d9767dd86..7fff7a26c4 100644--- a/mobile/apps/photos/test/ui/components/action_sheet_widget_test.dart+++ b/mobile/apps/photos/test/ui/components/action_sheet_widget_test.dart@@ -2,6 +2,7 @@ import "package:ente_components/ente_components.dart";import "package:flutter/material.dart";import "package:flutter_test/flutter_test.dart";import "package:photos/ente_theme_data.dart";+import "package:photos/generated/l10n.dart";import "package:photos/models/button_result.dart";import "package:photos/ui/components/action_sheet_widget.dart";import "package:photos/ui/components/buttons/button_widget.dart";@@ -39,18 +40,19 @@ void main() {await _openLauncher(tester);expect(find.byType(BottomSheetComponent), findsOneWidget);- expect(find.byType(ButtonComponent), findsNWidgets(2));+ _expectComponentScrim(tester);+ expect(find.byType(ButtonComponent), findsOneWidget);expect(find.byType(ButtonWidget), findsNothing);final buttonComponents = tester.widgetList<ButtonComponent>(find.byType(ButtonComponent)).toList();expect(buttonComponents[0].variant, ButtonComponentVariant.neutral);expect(buttonComponents[0].size, ButtonComponentSize.large);- expect(buttonComponents[1].variant, ButtonComponentVariant.secondary);expect(find.text("Delete files?"), findsOneWidget);expect(find.text("Files will be moved to trash."), findsOneWidget);expect(find.text("This applies to all albums."), findsOneWidget);- expect(find.byTooltip("Close"), findsNothing);+ expect(find.byTooltip("Close"), findsOneWidget);+ expect(find.text("Cancel"), findsNothing);});testWidgets("returns the tapped button action", (tester) async {@@ -85,6 +87,68 @@ void main() {expect(find.byType(BottomSheetComponent), findsNothing);});+ testWidgets("returns the cancel action from the close button", (+ tester,+ ) async {+ ButtonResult? result;++ await _pumpLauncher(tester, (context) async {+ result = await showActionSheet(+ context: context,+ buttons: const [+ ButtonWidget(+ buttonType: ButtonType.neutral,+ labelText: "Confirm",+ isInAlert: true,+ buttonAction: ButtonAction.first,+ ),+ ButtonWidget(+ buttonType: ButtonType.secondary,+ labelText: "Cancel",+ isInAlert: true,+ buttonAction: ButtonAction.third,+ ),+ ],+ );+ });++ await _openLauncher(tester);+ await tester.tap(find.byTooltip("Close"));+ await tester.pumpAndSettle();++ expect(result?.action, ButtonAction.third);+ expect(result?.exception, isNull);+ expect(find.byType(BottomSheetComponent), findsNothing);+ });++ testWidgets("returns null when dismissed", (tester) async {+ ButtonResult? result;+ var completed = false;++ await _pumpLauncher(tester, (context) async {+ result = await showActionSheet(+ context: context,+ buttons: const [+ ButtonWidget(+ buttonType: ButtonType.secondary,+ labelText: "Cancel",+ isInAlert: true,+ buttonAction: ButtonAction.cancel,+ ),+ ],+ );+ completed = true;+ });++ await _openLauncher(tester);+ await tester.tapAt(const Offset(10, 10));+ await tester.pumpAndSettle();++ expect(completed, isTrue);+ expect(result, isNull);+ expect(find.byType(BottomSheetComponent), findsNothing);+ });+testWidgets("preserves the legacy success confirmation delay", (tester,) async {@@ -185,6 +249,7 @@ void main() {expect(find.text("Done"), findsOneWidget);expect(find.text("Custom body"), findsNothing);expect(find.text("Close"), findsOneWidget);+ expect(find.byTooltip("Close"), findsNothing);});});}@@ -196,6 +261,8 @@ Future<void> _pumpLauncher(await tester.pumpWidget(MaterialApp(theme: darkThemeData,+ localizationsDelegates: AppLocalizations.localizationsDelegates,+ supportedLocales: AppLocalizations.supportedLocales,home: Scaffold(body: Builder(builder: (context) {@@ -214,3 +281,10 @@ Future<void> _openLauncher(WidgetTester tester) async {await tester.tap(find.text("Open sheet"));await tester.pumpAndSettle();}++void _expectComponentScrim(WidgetTester tester) {+ final barrierColors = tester+ .widgetList<ModalBarrier>(find.byType(ModalBarrier))+ .map((barrier) => barrier.color);+ expect(barrierColors, contains(const Color.fromRGBO(0, 0, 0, 0.55)));+}diff --git a/mobile/apps/photos/test/ui/components/buttons/button_widget_test.dart b/mobile/apps/photos/test/ui/components/buttons/button_widget_test.dartindex 5f5c2bc5f2..2d45035ac6 100644--- a/mobile/apps/photos/test/ui/components/buttons/button_widget_test.dart+++ b/mobile/apps/photos/test/ui/components/buttons/button_widget_test.dart@@ -1,6 +1,7 @@import "package:flutter/material.dart";import "package:flutter_test/flutter_test.dart";import "package:photos/ente_theme_data.dart";+import "package:photos/generated/l10n.dart";import "package:photos/models/button_result.dart";import "package:photos/ui/components/buttons/button_widget.dart";import "package:photos/ui/components/models/button_type.dart";@@ -16,6 +17,8 @@ void main() {await tester.pumpWidget(MaterialApp(theme: darkThemeData,+ localizationsDelegates: AppLocalizations.localizationsDelegates,+ supportedLocales: AppLocalizations.supportedLocales,home: Builder(builder: (context) {return Scaffold(@@ -53,6 +56,8 @@ void main() {await tester.pumpWidget(MaterialApp(theme: darkThemeData,+ localizationsDelegates: AppLocalizations.localizationsDelegates,+ supportedLocales: AppLocalizations.supportedLocales,home: Builder(builder: (context) {return Scaffold(diff --git a/mobile/apps/photos/test/ui/components/dialog_widget_test.dart b/mobile/apps/photos/test/ui/components/dialog_widget_test.dartindex e52331981c..cb095a52da 100644--- a/mobile/apps/photos/test/ui/components/dialog_widget_test.dart+++ b/mobile/apps/photos/test/ui/components/dialog_widget_test.dart@@ -44,13 +44,16 @@ void main() {await _openLauncher(tester);expect(find.byType(BottomSheetComponent), findsOneWidget);- expect(find.byType(ButtonComponent), findsNWidgets(2));+ _expectComponentScrim(tester);+ expect(find.byType(ButtonComponent), findsOneWidget);expect(find.byType(ButtonWidget), findsNothing);expect(find.byType(Dialog), findsNothing);expect(find.text("Invite"), findsOneWidget);expect(find.text("Share this invite with a friend."), findsOneWidget);expect(find.byIcon(Icons.info_outline), findsOneWidget);expect(find.byIcon(Icons.share_outlined), findsOneWidget);+ expect(find.byTooltip("Close"), findsOneWidget);+ expect(find.text("Cancel"), findsNothing);final button = tester.widget<ButtonComponent>(find.widgetWithText(ButtonComponent, "Send invite"),);@@ -85,6 +88,41 @@ void main() {expect(find.byType(BottomSheetComponent), findsNothing);});+ testWidgets("returns the cancel action from the close button", (+ tester,+ ) async {+ ButtonResult? result;++ await _pumpLauncher(tester, (context) async {+ result = await showDialogWidget(+ context: context,+ title: "Confirm",+ buttons: const [+ ButtonWidget(+ buttonType: ButtonType.neutral,+ labelText: "Continue",+ isInAlert: true,+ buttonAction: ButtonAction.first,+ ),+ ButtonWidget(+ buttonType: ButtonType.secondary,+ labelText: "Cancel",+ isInAlert: true,+ buttonAction: ButtonAction.second,+ ),+ ],+ );+ });++ await _openLauncher(tester);+ await tester.tap(find.byTooltip("Close"));+ await tester.pumpAndSettle();++ expect(result?.action, ButtonAction.second);+ expect(result?.exception, isNull);+ expect(find.byType(BottomSheetComponent), findsNothing);+ });+testWidgets("returns null when dismissed", (tester) async {ButtonResult? result;var completed = false;@@ -143,6 +181,38 @@ void main() {expect(find.byType(BottomSheetComponent), findsNothing);});+ testWidgets("returns an error result when the close callback throws", (+ tester,+ ) async {+ ButtonResult? result;++ await _pumpLauncher(tester, (context) async {+ result = await showDialogWidget(+ context: context,+ title: "Failure",+ buttons: [+ ButtonWidget(+ buttonType: ButtonType.secondary,+ labelText: "Cancel",+ isInAlert: true,+ buttonAction: ButtonAction.cancel,+ onTap: () async {+ throw StateError("boom");+ },+ ),+ ],+ );+ });++ await _openLauncher(tester);+ await tester.tap(find.byTooltip("Close"));+ await tester.pumpAndSettle();++ expect(result?.action, ButtonAction.error);+ expect(result?.exception, isA<Exception>());+ expect(find.byType(BottomSheetComponent), findsNothing);+ });+testWidgets("returns an error result when a button callback throws", (tester,) async {@@ -195,6 +265,7 @@ void main() {await _openLauncher(tester);expect(find.byType(BottomSheetComponent), findsOneWidget);+ expect(find.byTooltip("Close"), findsNothing);final removeButton = tester.widget<ButtonComponent>(find.widgetWithText(ButtonComponent, "Remove"),);@@ -230,8 +301,9 @@ void main() {await _openLauncher(tester);expect(find.byType(BottomSheetComponent), findsOneWidget);+ _expectComponentScrim(tester);expect(find.byType(TextInputComponent), findsOneWidget);- expect(find.byType(ButtonComponent), findsNWidgets(2));+ expect(find.byType(ButtonComponent), findsOneWidget);expect(find.byType(TextInputWidget), findsNothing);expect(find.byType(Dialog), findsNothing);expect(find.text("Rename file"), findsOneWidget);@@ -240,6 +312,8 @@ void main() {expect(find.text(".JPG"), findsOneWidget);expect(find.byIcon(Icons.edit_outlined), findsOneWidget);expect(find.byIcon(Icons.drive_file_rename_outline), findsOneWidget);+ expect(find.byTooltip("Close"), findsOneWidget);+ expect(find.text("Cancel"), findsNothing);final input = tester.widget<TextField>(find.byType(TextField));expect(input.controller?.text, "IMG_001");@@ -325,7 +399,7 @@ void main() {});await _openLauncher(tester);- await tester.tap(find.text("Cancel"));+ await tester.tap(find.byTooltip("Close"));await tester.pumpAndSettle();expect(result, isA<ButtonResult>());@@ -487,3 +561,10 @@ Future<void> _openLauncher(WidgetTester tester) async {await tester.tap(find.text("Open dialog"));await tester.pumpAndSettle();}++void _expectComponentScrim(WidgetTester tester) {+ final barrierColors = tester+ .widgetList<ModalBarrier>(find.byType(ModalBarrier))+ .map((barrier) => barrier.color);+ expect(barrierColors, contains(const Color.fromRGBO(0, 0, 0, 0.55)));+}diff --git a/mobile/apps/photos/test/utils/delete_file_util_test.dart b/mobile/apps/photos/test/utils/delete_file_util_test.dartindex 78e5afc6ea..37bd20c8f5 100644--- a/mobile/apps/photos/test/utils/delete_file_util_test.dart+++ b/mobile/apps/photos/test/utils/delete_file_util_test.dart@@ -62,13 +62,13 @@ void main() {find.text('They will be deleted from all albums.'),findsOneWidget,);- expect(find.byType(ButtonComponent), findsNWidgets(4));- expect(find.byTooltip('Close'), findsNothing);+ expect(find.byType(ButtonComponent), findsNWidgets(3));+ expect(find.byTooltip('Close'), findsOneWidget);+ expect(find.text('Cancel'), findsNothing);_expectVisibleButtonsInOrder(tester, ['Delete from Ente','Delete from device','Delete from both',- 'Cancel',]);},);@@ -96,11 +96,13 @@ void main() {findsOneWidget,);expect(find.text('They will be deleted from all albums.'), findsNothing);- expect(find.byType(ButtonComponent), findsNWidgets(2));+ expect(find.byType(ButtonComponent), findsOneWidget);expect(find.text('Delete from Ente'), findsNothing);expect(find.text('Delete from device'), findsNothing);expect(find.text('Delete from both'), findsNothing);- _expectVisibleButtonsInOrder(tester, ['Yes, delete', 'Cancel']);+ expect(find.byTooltip('Close'), findsOneWidget);+ expect(find.text('Cancel'), findsNothing);+ _expectVisibleButtonsInOrder(tester, ['Yes, delete']);});testWidgets('matches the legacy local-only delete action sheet', (@@ -124,11 +126,13 @@ void main() {findsOneWidget,);expect(find.text('They will be deleted from all albums.'), findsNothing);- expect(find.byType(ButtonComponent), findsNWidgets(2));+ expect(find.byType(ButtonComponent), findsOneWidget);expect(find.text('Delete from Ente'), findsNothing);expect(find.text('Delete from device'), findsNothing);expect(find.text('Delete from both'), findsNothing);- _expectVisibleButtonsInOrder(tester, ['Yes, delete', 'Cancel']);+ expect(find.byTooltip('Close'), findsOneWidget);+ expect(find.text('Cancel'), findsNothing);+ _expectVisibleButtonsInOrder(tester, ['Yes, delete']);});testWidgets('cancel clears the selection like the legacy action sheet', (@@ -147,7 +151,7 @@ void main() {),);- await tester.tap(find.text('Cancel'));+ await tester.tap(find.byTooltip('Close'));await tester.pumpAndSettle();expect(find.byType(BottomSheetComponent), findsNothing);diff --git a/mobile/packages/ente_components/lib/components/bottom_sheet/bottom_sheet_component.dart b/mobile/packages/ente_components/lib/components/bottom_sheet/bottom_sheet_component.dartindex 7fb476efa0..17acd0f811 100644--- a/mobile/packages/ente_components/lib/components/bottom_sheet/bottom_sheet_component.dart+++ b/mobile/packages/ente_components/lib/components/bottom_sheet/bottom_sheet_component.dart@@ -18,6 +18,7 @@ class _BottomSheetHeaderComponent extends StatelessWidget {this.title,this.illustration,this.onClose,+ this.closeResult,this.showCloseButton = true,this.closeTooltip = 'Close',this.textAlign,@@ -31,6 +32,7 @@ class _BottomSheetHeaderComponent extends StatelessWidget {////// Barrier taps, drag dismissals, and system back dismissals do not call this.final FutureOr<void> Function()? onClose;+ final Object? closeResult;final bool showCloseButton;final String closeTooltip;final TextAlign? textAlign;@@ -43,6 +45,7 @@ class _BottomSheetHeaderComponent extends StatelessWidget {title: title,illustration: illustration,onClose: onClose,+ closeResult: closeResult,showCloseButton: showCloseButton,closeTooltip: closeTooltip,);@@ -53,7 +56,11 @@ class _BottomSheetHeaderComponent extends StatelessWidget {mainAxisAlignment: MainAxisAlignment.end,children: [if (showCloseButton)- _BottomSheetCloseButton(onClose: onClose, tooltip: closeTooltip),+ _BottomSheetCloseButton(+ onClose: onClose,+ closeResult: closeResult,+ tooltip: closeTooltip,+ ),],);}@@ -75,7 +82,11 @@ class _BottomSheetHeaderComponent extends StatelessWidget {),if (showCloseButton) const SizedBox(width: Spacing.md),if (showCloseButton)- _BottomSheetCloseButton(onClose: onClose, tooltip: closeTooltip),+ _BottomSheetCloseButton(+ onClose: onClose,+ closeResult: closeResult,+ tooltip: closeTooltip,+ ),],),);@@ -96,6 +107,7 @@ class BottomSheetComponent extends StatelessWidget {this.content,this.actions = const [],this.onClose,+ this.closeResult,this.showCloseButton = true,this.closeTooltip = 'Close',this.textAlign,@@ -118,6 +130,7 @@ class BottomSheetComponent extends StatelessWidget {////// Barrier taps, drag dismissals, and system back dismissals do not call this.final FutureOr<void> Function()? onClose;+ final Object? closeResult;final bool showCloseButton;final String closeTooltip;final TextAlign? textAlign;@@ -143,6 +156,7 @@ class BottomSheetComponent extends StatelessWidget {title: title,illustration: illustration,onClose: onClose,+ closeResult: closeResult,showCloseButton: showCloseButton,closeTooltip: closeTooltip,textAlign: textAlign,@@ -234,6 +248,7 @@ class _CenteredHeader extends StatelessWidget {required this.title,required this.illustration,required this.onClose,+ required this.closeResult,required this.showCloseButton,required this.closeTooltip,});@@ -241,6 +256,7 @@ class _CenteredHeader extends StatelessWidget {final String? title;final Widget? illustration;final FutureOr<void> Function()? onClose;+ final Object? closeResult;final bool showCloseButton;final String closeTooltip;@@ -255,7 +271,11 @@ class _CenteredHeader extends StatelessWidget {mainAxisAlignment: MainAxisAlignment.end,children: [if (showCloseButton)- _BottomSheetCloseButton(onClose: onClose, tooltip: closeTooltip),+ _BottomSheetCloseButton(+ onClose: onClose,+ closeResult: closeResult,+ tooltip: closeTooltip,+ ),],),if (showCloseButton && (illustration != null || title != null))@@ -277,10 +297,15 @@ class _CenteredHeader extends StatelessWidget {}class _BottomSheetCloseButton extends StatelessWidget {- const _BottomSheetCloseButton({required this.onClose, required this.tooltip});+ const _BottomSheetCloseButton({+ required this.onClose,+ required this.closeResult,+ required this.tooltip,+ });/// Called when the close button is pressed, before the sheet is dismissed.final FutureOr<void> Function()? onClose;+ final Object? closeResult;final String tooltip;@override@@ -305,7 +330,7 @@ class _BottomSheetCloseButton extends StatelessWidget {final route = ModalRoute.of(context);if (route == null || route.isCurrent) {- Navigator.of(context).pop();+ Navigator.of(context).pop(closeResult);}}}diff --git a/mobile/packages/ente_components/test/components/bottom_sheet_component_test.dart b/mobile/packages/ente_components/test/components/bottom_sheet_component_test.dartindex 8352fbc683..2927048f8c 100644--- a/mobile/packages/ente_components/test/components/bottom_sheet_component_test.dart+++ b/mobile/packages/ente_components/test/components/bottom_sheet_component_test.dart@@ -103,6 +103,30 @@ void main() {expect(find.text('Default close'), findsNothing);});+ testWidgets('BottomSheetComponent returns closeResult from close button', (+ tester,+ ) async {+ String? result;++ await _pumpLauncher(tester, (context) async {+ result = await showBottomSheetComponent<String>(+ context: context,+ builder: (_) => const BottomSheetComponent(+ title: 'Close result',+ content: Text('Sheet body'),+ closeResult: 'cancelled',+ ),+ );+ });++ await _openLauncher(tester);+ await tester.tap(find.byTooltip('Close'));+ await tester.pumpAndSettle();++ expect(result, 'cancelled');+ expect(find.text('Close result'), findsNothing);+ });+testWidgets('showBottomSheetComponent blocks system back when not dismissible',(tester) async {