Skip to content

armgit / ente

Public Imported from GitHub
0

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

Confirm disabling library sharing

Neeraj Gupta6c3f3717aeee
diff --git a/mobile/apps/photos/lib/ui/sharing/library_sharing/library_sharing_page.dart b/mobile/apps/photos/lib/ui/sharing/library_sharing/library_sharing_page.dart
index 6c262f6ad0..b386448b00 100644
--- a/mobile/apps/photos/lib/ui/sharing/library_sharing/library_sharing_page.dart
+++ b/mobile/apps/photos/lib/ui/sharing/library_sharing/library_sharing_page.dart
@@ -406,6 +406,13 @@ class _LibrarySharingPageState extends State<LibrarySharingPage> {
Future<void> _toggleLibrarySharing() async {
if (_controller.isAutomaticSharingEnabled) {
+ final confirmed = await confirmDisableLibrarySharing(
+ context: context,
+ recipientLabel: _recipient.label,
+ );
+ if (!confirmed || !mounted) {
+ return;
+ }
await _showFailureIfNeeded(
await _controller.disableAutomaticSharing(),
_toggleLibrarySharing,
diff --git a/mobile/apps/photos/lib/ui/sharing/library_sharing/library_sharing_sheets.dart b/mobile/apps/photos/lib/ui/sharing/library_sharing/library_sharing_sheets.dart
index 69cee9b99a..0c4459519a 100644
--- a/mobile/apps/photos/lib/ui/sharing/library_sharing/library_sharing_sheets.dart
+++ b/mobile/apps/photos/lib/ui/sharing/library_sharing/library_sharing_sheets.dart
@@ -70,6 +70,40 @@ Future<CollectionParticipantRole?> showEnableLibrarySharingSheet({
);
}
+Future<bool> confirmDisableLibrarySharing({
+ required BuildContext context,
+ required String recipientLabel,
+}) async {
+ return await showBottomSheetComponent<bool>(
+ context: context,
+ builder: (sheetContext) {
+ final colors = sheetContext.componentColors;
+ return BottomSheetComponent(
+ title: sheetContext.strings.librarySharingDisableTitle,
+ closeTooltip: sheetContext.strings.close,
+ borderSide: BorderSide(color: colors.strokeDark),
+ actionsTopSpacing: Spacing.xxl,
+ content: Text(
+ sheetContext.strings.librarySharingDisableDescription(
+ recipient: recipientLabel,
+ ),
+ style: TextStyles.body.copyWith(color: colors.textLight),
+ ),
+ actions: [
+ ButtonComponent(
+ label: sheetContext.strings.librarySharingDisable,
+ variant: ButtonComponentVariant.critical,
+ density: ButtonComponentDensity.compact,
+ shouldSurfaceExecutionStates: false,
+ onTap: () => Navigator.of(sheetContext).pop(true),
+ ),
+ ],
+ );
+ },
+ ) ??
+ false;
+}
+
Future<bool?> showLibrarySharingRolesSheet({
required BuildContext context,
required LibrarySharingController controller,
diff --git a/mobile/apps/photos/test/ui/sharing/library_sharing_page_test.dart b/mobile/apps/photos/test/ui/sharing/library_sharing_page_test.dart
index 64e191a2a4..6a337686b2 100644
--- a/mobile/apps/photos/test/ui/sharing/library_sharing_page_test.dart
+++ b/mobile/apps/photos/test/ui/sharing/library_sharing_page_test.dart
@@ -75,73 +75,6 @@ void main() {
expect(find.byType(ToggleSwitchComponent), findsNothing);
});
- testWidgets('library sharing banner enables and disables automatic sharing', (
- tester,
- ) async {
- final controller = _LayoutTestLibrarySharingController();
-
- await tester.pumpWidget(
- _app(
- LibrarySharingPage(
- recipient: librarySharingTestRecipient,
- controller: controller,
- ),
- ),
- );
- await tester.pumpAndSettle();
-
- expect(find.text('Library sharing'), findsOneWidget);
- expect(find.text('Share all your albums'), findsOneWidget);
- final toggle = tester.widget<ToggleSwitchComponent>(
- find.byKey(const ValueKey('library-sharing-toggle')),
- );
- expect(toggle.selected, isFalse);
-
- await tester.tap(find.text('Library sharing'));
- await tester.pump();
- await tester.pump(const Duration(milliseconds: 500));
-
- expect(find.text('Enable library sharing?'), findsOneWidget);
- expect(
- find.text(
- 'Your existing albums and any albums you create in the future will be automatically shared with Friend.',
- ),
- findsOneWidget,
- );
- expect(
- find.text(
- 'Hidden albums will not be shared. You can stop sharing any album at any time.',
- ),
- findsOneWidget,
- );
- expect(find.text('Role'), findsOneWidget);
- expect(find.text('Viewer'), findsOneWidget);
-
- await tester.tap(find.text('Enable'));
- await tester.pumpAndSettle();
-
- expect(find.text('Enable library sharing?'), findsNothing);
- expect(
- tester
- .widget<ToggleSwitchComponent>(
- find.byKey(const ValueKey('library-sharing-toggle')),
- )
- .selected,
- isTrue,
- );
-
- await tester.tap(find.text('Library sharing'));
- await tester.pumpAndSettle();
- expect(
- tester
- .widget<ToggleSwitchComponent>(
- find.byKey(const ValueKey('library-sharing-toggle')),
- )
- .selected,
- isFalse,
- );
- });
-
testWidgets('offers to review albums that were previously unshared', (
tester,
) async {
diff --git a/mobile/packages/strings/lib/l10n/arb/strings_en.arb b/mobile/packages/strings/lib/l10n/arb/strings_en.arb
index b5971414f0..781dfc5e70 100644
--- a/mobile/packages/strings/lib/l10n/arb/strings_en.arb
+++ b/mobile/packages/strings/lib/l10n/arb/strings_en.arb
@@ -2179,6 +2179,17 @@
},
"librarySharingAllCurrentAlbumsShared": "All your current albums are shared",
"librarySharingBannerDescription": "Share all your albums",
+ "librarySharingDisable": "Disable",
+ "librarySharingDisableDescription": "Albums you have already shared will stay shared with {recipient}, including any new photos you add to them. New albums will not be shared automatically.\n\nTo stop sharing an album, tap it and select 'Stop sharing'",
+ "@librarySharingDisableDescription": {
+ "placeholders": {
+ "recipient": {
+ "type": "String",
+ "example": "Alex"
+ }
+ }
+ },
+ "librarySharingDisableTitle": "Disable library sharing?",
"librarySharingEnableDescription": "Your existing albums and any albums you create in the future will be automatically shared with {recipient}.",
"@librarySharingEnableDescription": {
"placeholders": {