π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
[mob][photos] Add ML consent sheet for in-context prompts
r4khulb34329dac4c4
diff --git a/mobile/apps/photos/changes/ml-consent-screen.md b/mobile/apps/photos/changes/ml-consent-screen.mdindex ffeb40536f..2887491db4 100644--- a/mobile/apps/photos/changes/ml-consent-screen.md+++ b/mobile/apps/photos/changes/ml-consent-screen.md@@ -1 +1 @@-- Refreshed the machine learning consent screen. Enabling it now takes you to Search.+- Refreshed the machine learning consent screen and added a consent sheet for the home banner, Search and People widgets.diff --git a/mobile/apps/photos/lib/services/app_navigation_service.dart b/mobile/apps/photos/lib/services/app_navigation_service.dartindex 2e9c9ce2d7..dc250ab251 100644--- a/mobile/apps/photos/lib/services/app_navigation_service.dart+++ b/mobile/apps/photos/lib/services/app_navigation_service.dart@@ -30,7 +30,7 @@ class AppNavigationService {final scheduledPush = _lastScheduledPush.catchError((Object _, StackTrace _) {}).then((_) async {- final navigator = await _waitForNavigator();+ final navigator = await waitForNavigator();if (navigator == null) {_logger.warning("Skipping navigation because app navigator is unavailable",@@ -91,7 +91,7 @@ class AppNavigationService {}// The inner navigator may be unavailable while AppLock rebuilds after resume.- Future<NavigatorState?> _waitForNavigator() async {+ Future<NavigatorState?> waitForNavigator() async {final binding = WidgetsBinding.instance;for (var attempt = 0; attempt < 120; attempt++) {final currentNavigator = navigator;diff --git a/mobile/apps/photos/lib/services/home_widget_service.dart b/mobile/apps/photos/lib/services/home_widget_service.dartindex 29c26945a5..10ccc12cba 100644--- a/mobile/apps/photos/lib/services/home_widget_service.dart+++ b/mobile/apps/photos/lib/services/home_widget_service.dart@@ -15,7 +15,7 @@ import 'package:photos/services/app_navigation_service.dart';import 'package:photos/services/memory_home_widget_service.dart';import 'package:photos/services/people_home_widget_service.dart';import 'package:photos/services/smart_memories_service.dart';-import 'package:photos/ui/settings/ml/machine_learning_settings_page.dart';+import 'package:photos/ui/settings/ml/ml_consent_sheet.dart';import 'package:photos/ui/settings/widgets/albums_widget_settings.dart';import 'package:photos/ui/settings/widgets/memories_widget_settings.dart';import 'package:photos/ui/settings/widgets/people_widget_settings.dart';@@ -268,15 +268,17 @@ class HomeWidgetService {if (isConfigureRoute) {_logger.info("Navigating to People widget customization screen");if (!hasGrantedMLConsent) {- await AppNavigationService.instance.pushPage(- const MachineLearningSettingsPage(),- forceCustomPageRoute: true,- );- } else {- await AppNavigationService.instance.pushPage(- const PeopleWidgetSettings(),- );+ final navigator = await AppNavigationService.instance+ .waitForNavigator();+ if (navigator == null ||+ !navigator.mounted ||+ !await showMLConsentSheet(navigator.context)) {+ break;+ }}+ await AppNavigationService.instance.pushPage(+ const PeopleWidgetSettings(),+ );} else {final personId = uri.queryParameters[MAIN_KEY_PARAM] ?? "";await PeopleHomeWidgetService.instance.onLaunchFromWidget(diff --git a/mobile/apps/photos/lib/ui/home/status_bar_widget.dart b/mobile/apps/photos/lib/ui/home/status_bar_widget.dartindex 442fae1732..20655526d8 100644--- a/mobile/apps/photos/lib/ui/home/status_bar_widget.dart+++ b/mobile/apps/photos/lib/ui/home/status_bar_widget.dart@@ -14,6 +14,8 @@ import 'package:photos/ente_theme_data.dart';import 'package:photos/events/christmas_banner_event.dart';import 'package:photos/events/notification_event.dart';import 'package:photos/events/sync_status_update_event.dart';+import 'package:photos/events/tab_changed_event.dart';+import 'package:photos/models/home_tab.dart';import "package:photos/service_locator.dart";import "package:photos/services/sync/large_backup_session_tracker.dart";import 'package:photos/services/sync/sync_service.dart';@@ -26,7 +28,7 @@ import 'package:photos/ui/home/header_error_widget.dart';import "package:photos/ui/home/large_backup_screen.dart";import "package:photos/ui/settings/backup/backup_settings_screen.dart";import "package:photos/ui/settings/backup/backup_status_screen.dart";-import "package:photos/ui/settings/ml/machine_learning_settings_page.dart";+import "package:photos/ui/settings/ml/ml_consent_sheet.dart";const double kContainerHeight = 36;@@ -200,11 +202,11 @@ class _MachineLearningBanner extends StatelessWidget {state: BannerComponentState.success,trailingWidget: const Icon(Icons.arrow_forward),onTap: () async {- await routeToPage(- context,- const MachineLearningSettingsPage(),- forceCustomPageRoute: true,- );+ if (await showMLConsentSheet(context)) {+ Bus.instance.fire(+ TabChangedEvent(searchTabIndex, TabChangedEventSource.mlConsent),+ );+ }},),);diff --git a/mobile/apps/photos/lib/ui/settings/ml/machine_learning_settings_page.dart b/mobile/apps/photos/lib/ui/settings/ml/machine_learning_settings_page.dartindex 0fc755e923..544d1d59a3 100644--- a/mobile/apps/photos/lib/ui/settings/ml/machine_learning_settings_page.dart+++ b/mobile/apps/photos/lib/ui/settings/ml/machine_learning_settings_page.dart@@ -18,15 +18,13 @@ import "package:photos/services/machine_learning/ml_model_assets.dart";import "package:photos/services/machine_learning/ml_model_download_service.dart";import "package:photos/services/machine_learning/ml_run_control.dart";import "package:photos/services/machine_learning/ml_service.dart";-import "package:photos/services/machine_learning/semantic_search/semantic_search_service.dart";import "package:photos/services/remote_assets_service.dart";import "package:photos/services/wake_lock_service.dart";-import "package:photos/ui/common/web_page.dart";+import "package:photos/ui/settings/ml/ml_consent_sheet.dart";import "package:photos/ui/settings/ml/ml_user_dev_screen.dart";import "package:photos/utils/email_util.dart";import "package:photos/utils/ml_util.dart";import "package:photos/utils/network_util.dart";-import "package:styled_text/styled_text.dart";class MachineLearningSettingsPage extends StatefulWidget {const MachineLearningSettingsPage({super.key});@@ -43,7 +41,6 @@ class _MachineLearningSettingsPageStateint _titleTapCount = 0;Timer? _advancedOptionsTimer;bool _hasAcknowledgedMLConsent = false;- bool _hasHandledDisabledExit = false;bool _mlDecryptionRecordsReady = false;@override@@ -147,7 +144,7 @@ class _MachineLearningSettingsPageStateWidget _buildDisabledMLScreen(BuildContext context) {return PopScope(- onPopInvokedWithResult: (_, _) => unawaited(_handleDisabledScreenExit()),+ onPopInvokedWithResult: (_, _) => unawaited(markMLConsentPromptSeen()),child: SettingsPageScaffold(title: context.strings.machineLearning,bottomNavigationBar: SafeArea(@@ -156,15 +153,12 @@ class _MachineLearningSettingsPageStatechild: ButtonComponent(label: context.strings.mlConsent,isDisabled: !_hasAcknowledgedMLConsent,- onTap: () async {- if (!_hasAcknowledgedMLConsent) return;- await toggleMlConsent(openSearchTab: true);- },+ onTap: _enableAndOpenSearch,),),),children: [- const _MLConsentDescription(),+ const MLConsentDescription(),const SizedBox(height: 20),Center(child: Image.asset(@@ -174,7 +168,14 @@ class _MachineLearningSettingsPageState),),const SizedBox(height: 20),- _buildDisabledConsentAckRow(context),+ MLConsentAcknowledgement(+ selected: _hasAcknowledgedMLConsent,+ onChanged: () {+ setState(() {+ _hasAcknowledgedMLConsent = !_hasAcknowledgedMLConsent;+ });+ },+ ),],),);@@ -204,85 +205,35 @@ class _MachineLearningSettingsPageState.ignore();}- Future<void> _handleDisabledScreenExit() async {- if (_hasHandledDisabledExit || hasGrantedMLConsent) {- return;- }- _hasHandledDisabledExit = true;- await localSettings.setHasSeenMLEnablingBanner();- Bus.instance.fire(NotificationEvent());+ Future<void> _enableAndOpenSearch() async {+ await enableMLConsent();+ if (!mounted) return;+ Navigator.of(+ context,+ ).popUntil((route) => route.isFirst && !route.willHandlePopInternally);+ Bus.instance.fire(+ TabChangedEvent(searchTabIndex, TabChangedEventSource.mlConsent),+ );}- Future<void> toggleMlConsent({bool openSearchTab = false}) async {- final oldMlConsent = hasGrantedMLConsent;- final oldMlEnabled = oldMlConsent && localSettings.isMLLocalIndexingEnabled;- final mlConsent = !oldMlConsent;- await setMLConsent(mlConsent);- final newMlEnabled = mlConsent && localSettings.isMLLocalIndexingEnabled;- // Queue a memories cache refresh so People/Clip memories appear or- // disappear on the next scheduled recompute. We intentionally only queue- // here β the actual recompute will be picked up by the next updateCache- // invocation (runAllML after indexing, or the startup self-schedule).+ Future<void> _disableMl() async {+ final wasMlEnabled = localSettings.isMLLocalIndexingEnabled;+ await setMLConsent(false);+ // Queue a memories cache refresh so People/Clip memories disappear on the+ // next scheduled recompute. We intentionally only queue here β the actual+ // recompute will be picked up by the next updateCache invocation.memoriesCacheService.queueUpdateCache();Bus.instance.fire(NotificationEvent());- if (!mlConsent) {- MLService.instance.stopActiveRun(MlStopReason.manual);- unawaited(MLIndexingIsolate.instance.cleanupLocalIndexingModels());- if (oldMlEnabled && !newMlEnabled) {- await memoriesCacheService.purgeMlOnlyMemoriesFromCache();- }- } else {- await MLService.instance.init();- await SemanticSearchService.instance.init();- unawaited(MLService.instance.runAllML(force: true));- if (openSearchTab && mounted) {- Navigator.of(- context,- ).popUntil((route) => route.isFirst && !route.willHandlePopInternally);- Bus.instance.fire(- TabChangedEvent(searchTabIndex, TabChangedEventSource.mlConsent),- );- return;- }+ MLService.instance.stopActiveRun(MlStopReason.manual);+ unawaited(MLIndexingIsolate.instance.cleanupLocalIndexingModels());+ if (wasMlEnabled) {+ await memoriesCacheService.purgeMlOnlyMemoriesFromCache();}if (mounted) {setState(() {});}}- Widget _buildDisabledConsentAckRow(BuildContext context) {- final colors = context.componentColors;-- return GestureDetector(- behavior: HitTestBehavior.opaque,- onTap: () {- setState(() {- _hasAcknowledgedMLConsent = !_hasAcknowledgedMLConsent;- });- },- child: Row(- crossAxisAlignment: CrossAxisAlignment.start,- children: [- CheckboxComponent(- selected: _hasAcknowledgedMLConsent,- onChanged: (_) {- setState(() {- _hasAcknowledgedMLConsent = !_hasAcknowledgedMLConsent;- });- },- ),- const SizedBox(width: 10),- Expanded(- child: Text(- context.strings.mlConsentConfirmation,- style: TextStyles.body.copyWith(color: colors.textLight),- ),- ),- ],- ),- );- }-Widget _getMlSettings(BuildContext context) {final hasEnabled = hasGrantedMLConsent;if (!hasEnabled) {@@ -298,9 +249,7 @@ class _MachineLearningSettingsPageState),trailing: ToggleSwitchComponent.async(value: () => hasEnabled,- onChanged: () async {- await toggleMlConsent();- },+ onChanged: _disableMl,),),const SizedBox(height: 8),@@ -349,53 +298,6 @@ class _MachineLearningSettingsPageState}}-class _MLConsentDescription extends StatelessWidget {- const _MLConsentDescription();-- @override- Widget build(BuildContext context) {- final textStyle = TextStyles.body.copyWith(- color: context.componentColors.textLight,- );-- return Column(- crossAxisAlignment: CrossAxisAlignment.start,- children: [- for (final paragraph in context.strings.mlConsentDescription.split(- "\n\n",- )) ...[Text(paragraph, style: textStyle), const SizedBox(height: 8)],- StyledText(- text: context.strings.mlConsentPrivacyDetails,- style: textStyle,- tags: {- 'policy': StyledTextActionTag(- (String? text, Map<String?, String?> attrs) =>- _openMLPrivacyPolicy(context),- style: textStyle.copyWith(- decoration: TextDecoration.underline,- decorationColor: textStyle.color,- ),- ),- },- ),- ],- );- }-- Future<void> _openMLPrivacyPolicy(BuildContext context) async {- await Navigator.of(context).push(- MaterialPageRoute(- builder: (BuildContext context) {- return WebPage(- context.strings.privacyPolicyTitle,- "https://ente.com/privacy",- );- },- ),- );- }-}-class ModelLoadingState extends StatefulWidget {const ModelLoadingState({super.key});diff --git a/mobile/apps/photos/lib/ui/settings/ml/ml_consent_sheet.dart b/mobile/apps/photos/lib/ui/settings/ml/ml_consent_sheet.dartnew file mode 100644index 0000000000..93d0731632--- /dev/null+++ b/mobile/apps/photos/lib/ui/settings/ml/ml_consent_sheet.dart@@ -0,0 +1,197 @@+import "dart:async";++import "package:ente_components/ente_components.dart";+import "package:ente_strings/ente_strings.dart";+import "package:flutter/material.dart";+import "package:photos/core/event_bus.dart";+import "package:photos/events/notification_event.dart";+import "package:photos/service_locator.dart";+import "package:photos/services/machine_learning/ml_service.dart";+import "package:photos/services/machine_learning/semantic_search/semantic_search_service.dart";+import "package:photos/ui/common/web_page.dart";+import "package:styled_text/styled_text.dart";++Future<bool> showMLConsentSheet(BuildContext context) async {+ Future<void>? enabling;+ await showBottomSheetComponent<void>(+ context: context,+ builder: (_) =>+ _MLConsentSheet(onEnable: () => enabling = enableMLConsent()),+ );+ await enabling?.catchError((Object _) {});+ if (hasGrantedMLConsent) {+ return true;+ }+ await markMLConsentPromptSeen();+ return false;+}++Future<void> enableMLConsent() async {+ await setMLConsent(true);+ memoriesCacheService.queueUpdateCache();+ Bus.instance.fire(NotificationEvent());+ await MLService.instance.init();+ await SemanticSearchService.instance.init();+ unawaited(MLService.instance.runAllML(force: true));+}++Future<void> markMLConsentPromptSeen() async {+ if (hasGrantedMLConsent) {+ return;+ }+ await localSettings.setHasSeenMLEnablingBanner();+ Bus.instance.fire(NotificationEvent());+}++class _MLConsentSheet extends StatefulWidget {+ const _MLConsentSheet({required this.onEnable});++ final Future<void> Function() onEnable;++ @override+ State<_MLConsentSheet> createState() => _MLConsentSheetState();+}++class _MLConsentSheetState extends State<_MLConsentSheet> {+ bool _hasAcknowledged = false;+ bool _isEnabling = false;++ Future<void> _enable() async {+ setState(() => _isEnabling = true);+ try {+ await widget.onEnable();+ } finally {+ if (mounted) {+ setState(() => _isEnabling = false);+ }+ }+ if (mounted && (ModalRoute.of(context)?.isCurrent ?? false)) {+ Navigator.of(context).pop();+ }+ }++ @override+ Widget build(BuildContext context) {+ return BottomSheetComponent(+ title: context.strings.machineLearning,+ closeTooltip: context.strings.close,+ content: Flexible(+ fit: FlexFit.loose,+ child: IgnorePointer(+ ignoring: _isEnabling,+ child: SingleChildScrollView(+ child: Column(+ crossAxisAlignment: CrossAxisAlignment.start,+ children: [+ Center(+ child: Image.asset(+ "assets/ducky_ml.png",+ height: 150,+ fit: BoxFit.contain,+ ),+ ),+ const SizedBox(height: 20),+ const MLConsentDescription(),+ const SizedBox(height: 16),+ MLConsentAcknowledgement(+ selected: _hasAcknowledged,+ onChanged: () {+ setState(() => _hasAcknowledged = !_hasAcknowledged);+ },+ ),+ ],+ ),+ ),+ ),+ ),+ actions: [+ ButtonComponent(+ label: context.strings.mlConsent,+ isDisabled: !_hasAcknowledged,+ onTap: _enable,+ ),+ ],+ );+ }+}++class MLConsentDescription extends StatelessWidget {+ const MLConsentDescription({super.key});++ @override+ Widget build(BuildContext context) {+ final textStyle = TextStyles.body.copyWith(+ color: context.componentColors.textLight,+ );++ return Column(+ crossAxisAlignment: CrossAxisAlignment.start,+ children: [+ for (final paragraph in context.strings.mlConsentDescription.split(+ "\n\n",+ )) ...[Text(paragraph, style: textStyle), const SizedBox(height: 8)],+ StyledText(+ text: context.strings.mlConsentPrivacyDetails,+ style: textStyle,+ tags: {+ 'policy': StyledTextActionTag(+ (String? text, Map<String?, String?> attrs) =>+ _openPrivacyPolicy(context),+ style: textStyle.copyWith(+ decoration: TextDecoration.underline,+ decorationColor: textStyle.color,+ ),+ ),+ },+ ),+ ],+ );+ }++ Future<void> _openPrivacyPolicy(BuildContext context) async {+ await Navigator.of(context).push(+ MaterialPageRoute(+ builder: (BuildContext context) {+ return WebPage(+ context.strings.privacyPolicyTitle,+ "https://ente.com/privacy",+ );+ },+ ),+ );+ }+}++class MLConsentAcknowledgement extends StatelessWidget {+ const MLConsentAcknowledgement({+ super.key,+ required this.selected,+ required this.onChanged,+ });++ final bool selected;+ final VoidCallback onChanged;++ @override+ Widget build(BuildContext context) {+ return GestureDetector(+ behavior: HitTestBehavior.opaque,+ onTap: onChanged,+ child: Row(+ crossAxisAlignment: CrossAxisAlignment.start,+ children: [+ CheckboxComponent(selected: selected, onChanged: (_) => onChanged()),+ const SizedBox(width: 10),+ Expanded(+ child: Text(+ context.strings.mlConsentConfirmation,+ style: TextStyles.body.copyWith(+ color: context.componentColors.textLight,+ ),+ ),+ ),+ ],+ ),+ );+ }+}diff --git a/mobile/apps/photos/lib/ui/settings/widget_settings_screen.dart b/mobile/apps/photos/lib/ui/settings/widget_settings_screen.dartindex 7992ce66f6..e6b0e7eec2 100644--- a/mobile/apps/photos/lib/ui/settings/widget_settings_screen.dart+++ b/mobile/apps/photos/lib/ui/settings/widget_settings_screen.dart@@ -1,9 +1,11 @@+import "dart:async";+import "package:ente_components/ente_components.dart";import "package:ente_pure_utils/ente_pure_utils.dart";import "package:ente_strings/ente_strings.dart";import "package:flutter/material.dart";import "package:photos/service_locator.dart";-import "package:photos/ui/settings/ml/machine_learning_settings_page.dart";+import "package:photos/ui/settings/ml/ml_consent_sheet.dart";import "package:photos/ui/settings/widgets/albums_widget_settings.dart";import "package:photos/ui/settings/widgets/memories_widget_settings.dart";import "package:photos/ui/settings/widgets/people_widget_settings.dart";@@ -11,17 +13,12 @@ import "package:photos/ui/settings/widgets/people_widget_settings.dart";class WidgetSettingsScreen extends StatelessWidget {const WidgetSettingsScreen({super.key});- void onPeopleTapped(BuildContext context) {- final bool isMLEnabled = !hasGrantedMLConsent;- if (isMLEnabled) {- routeToPage(- context,- const MachineLearningSettingsPage(),- forceCustomPageRoute: true,- );- return;+ Future<void> onPeopleTapped(BuildContext context) async {+ if (!hasGrantedMLConsent) {+ final enabled = await showMLConsentSheet(context);+ if (!enabled || !context.mounted) return;}- routeToPage(context, const PeopleWidgetSettings());+ unawaited(routeToPage(context, const PeopleWidgetSettings()));}void onAlbumsTapped(BuildContext context) {@@ -43,7 +40,7 @@ class WidgetSettingsScreen extends StatelessWidget {title: l10n.people,svgIconPath: "assets/icons/people-widget-icon.svg",showOnlyLoadingState: true,- onTap: () => onPeopleTapped(context),+ onTap: () => unawaited(onPeopleTapped(context)),),const SizedBox(height: 8),SettingsItem(diff --git a/mobile/apps/photos/lib/ui/viewer/search_tab/people_section.dart b/mobile/apps/photos/lib/ui/viewer/search_tab/people_section.dartindex 3d18fa3b83..35160290c0 100644--- a/mobile/apps/photos/lib/ui/viewer/search_tab/people_section.dart+++ b/mobile/apps/photos/lib/ui/viewer/search_tab/people_section.dart@@ -13,10 +13,12 @@ import "package:photos/models/search/search_constants.dart";import "package:photos/models/search/search_result.dart";import "package:photos/models/search/search_types.dart";import "package:photos/models/selected_people.dart";-import "package:photos/service_locator.dart" show isLocalGalleryMode;+import "package:photos/service_locator.dart"+ show hasGrantedMLConsent, isLocalGalleryMode;import "package:photos/theme/ente_theme.dart";import "package:photos/ui/components/collection_share_badge.dart";import "package:photos/ui/settings/ml/machine_learning_settings_page.dart";+import "package:photos/ui/settings/ml/ml_consent_sheet.dart";import "package:photos/ui/viewer/actions/select_all_status_icon.dart";import "package:photos/ui/viewer/file/no_thumbnail_widget.dart";import "package:photos/ui/viewer/file/thumbnail_widget.dart";@@ -109,7 +111,11 @@ class _PeopleSectionState extends State<PeopleSection> {: GestureDetector(behavior: HitTestBehavior.opaque,onTap: () {- routeToPage(context, const MachineLearningSettingsPage());+ if (hasGrantedMLConsent) {+ routeToPage(context, const MachineLearningSettingsPage());+ } else {+ unawaited(showMLConsentSheet(context));+ }},child: Padding(padding: const EdgeInsets.only(diff --git a/mobile/apps/photos/test/ui/settings/ml/ml_consent_sheet_test.dart b/mobile/apps/photos/test/ui/settings/ml/ml_consent_sheet_test.dartnew file mode 100644index 0000000000..3dc7293901--- /dev/null+++ b/mobile/apps/photos/test/ui/settings/ml/ml_consent_sheet_test.dart@@ -0,0 +1,131 @@+import "package:dio/dio.dart";+import "package:ente_components/ente_components.dart";+import "package:ente_strings/ente_strings.dart";+import "package:flutter/material.dart";+import "package:flutter_test/flutter_test.dart";+import "package:package_info_plus/package_info_plus.dart";+import "package:photos/app_mode.dart";+import "package:photos/ente_theme_data.dart";+import "package:photos/service_locator.dart";+import "package:photos/services/app_navigation_service.dart";+import "package:photos/services/home_widget_service.dart";+import "package:photos/ui/settings/ml/ml_consent_sheet.dart";+import "package:photos/ui/settings/widgets/people_widget_settings.dart";+import "package:shared_preferences/shared_preferences.dart";++const _enableLabel = "Enable machine learning";+const _acknowledgement = "I understand, and wish to enable machine learning";++void main() {+ TestWidgetsFlutterBinding.ensureInitialized();++ setUpAll(() async {+ SharedPreferences.setMockInitialValues({});+ final preferences = await SharedPreferences.getInstance();+ ServiceLocator.instance.init(+ preferences,+ Dio(),+ Dio(),+ Dio(),+ PackageInfo(+ appName: "Photos",+ packageName: "photos",+ version: "1.0.0",+ buildNumber: "1",+ ),+ );+ await localSettings.setAppMode(AppMode.localGallery);+ });++ testWidgets("enable stays disabled until the acknowledgement is ticked", (+ tester,+ ) async {+ await _openSheet(tester);++ expect(_enableButton(tester).isDisabled, isTrue);++ await tester.tap(find.text(_acknowledgement));+ await tester.pumpAndSettle();+ expect(_enableButton(tester).isDisabled, isFalse);++ await tester.tap(find.text(_acknowledgement));+ await tester.pumpAndSettle();+ expect(_enableButton(tester).isDisabled, isTrue);+ });++ testWidgets("closing returns false and records the prompt as seen", (+ tester,+ ) async {+ final result = await _openSheet(tester);++ await tester.tap(find.byTooltip("Close"));+ await tester.pumpAndSettle();++ expect(await result, isFalse);+ expect(localSettings.hasSeenMLEnablingBanner, isTrue);+ expect(hasGrantedMLConsent, isFalse);+ expect(find.text(_enableLabel), findsNothing);+ });++ testWidgets(+ "people widget configure link asks for consent on the app navigator",+ (tester) async {+ await tester.binding.setSurfaceSize(const Size(402, 874));+ addTearDown(() => tester.binding.setSurfaceSize(null));+ await tester.pumpWidget(+ MaterialApp(+ navigatorKey: AppNavigationService.instance.navigatorKey,+ theme: lightThemeData,+ localizationsDelegates: StringsLocalizations.localizationsDelegates,+ supportedLocales: StringsLocalizations.supportedLocales,+ home: const Scaffold(body: SizedBox()),+ ),+ );++ final launch = HomeWidgetService.instance.onLaunchFromWidget(+ Uri.parse("peoplewidget://configure"),+ );+ await tester.pumpAndSettle();+ expect(find.text(_acknowledgement), findsOneWidget);++ await tester.tap(find.byTooltip("Close"));+ await tester.pumpAndSettle();+ await launch;++ expect(find.text(_acknowledgement), findsNothing);+ expect(find.byType(PeopleWidgetSettings), findsNothing);+ },+ );+}++ButtonComponent _enableButton(WidgetTester tester) {+ return tester.widget<ButtonComponent>(+ find.widgetWithText(ButtonComponent, _enableLabel),+ );+}++Future<Future<bool>> _openSheet(WidgetTester tester) async {+ await tester.binding.setSurfaceSize(const Size(402, 874));+ addTearDown(() => tester.binding.setSurfaceSize(null));+ late Future<bool> result;+ await tester.pumpWidget(+ MaterialApp(+ theme: lightThemeData,+ localizationsDelegates: StringsLocalizations.localizationsDelegates,+ supportedLocales: StringsLocalizations.supportedLocales,+ home: Scaffold(+ body: Builder(+ builder: (context) {+ return TextButton(+ onPressed: () => result = showMLConsentSheet(context),+ child: const Text("Open"),+ );+ },+ ),+ ),+ ),+ );+ await tester.tap(find.text("Open"));+ await tester.pumpAndSettle();+ return result;+}