π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
[mob][locker] Update collection link settings (#13608)
aman-pilot96d7d8561ce3
diff --git a/mobile/apps/locker/changes/link-settings.md b/mobile/apps/locker/changes/link-settings.mdnew file mode 100644index 0000000000..7eabd73c66--- /dev/null+++ b/mobile/apps/locker/changes/link-settings.md@@ -0,0 +1 @@+- Updated Link settings with sharing actions first and grouped access controls, and opened settings after creating a collection link.diff --git a/mobile/apps/locker/lib/ui/sharing/manage_links_widget.dart b/mobile/apps/locker/lib/ui/sharing/manage_links_widget.dartindex 1c5e19440a..ea73386412 100644--- a/mobile/apps/locker/lib/ui/sharing/manage_links_widget.dart+++ b/mobile/apps/locker/lib/ui/sharing/manage_links_widget.dart@@ -33,80 +33,107 @@ class ManageSharedLinkWidget extends StatefulWidget {class _ManageSharedLinkWidgetState extends State<ManageSharedLinkWidget> {final GlobalKey sendLinkButtonKey = GlobalKey();- @override- void initState() {- super.initState();- }-@overrideWidget build(BuildContext context) {final colors = context.componentColors;final PublicURL url = widget.collection!.publicURLs.firstOrNull!;- final String urlValue = CollectionService.instance.getPublicUrl(- widget.collection!,+ Widget linkIcon(List<List<dynamic>> icon, {Color? color}) => HugeIcon(+ icon: icon,+ color: color ?? colors.textLight,+ size: IconSizes.small,+ strokeWidth: 1.6,+ );+ final chevron = Icon(+ Icons.chevron_right_rounded,+ color: colors.textLight,+ size: IconSizes.medium,);return Scaffold(backgroundColor: colors.backgroundBase,body: AppBarComponent(- title: context.strings.manageLink,+ title: context.strings.linkSettings,+ physics: const BouncingScrollPhysics(),slivers: [- SliverPadding(- padding: const EdgeInsets.fromLTRB(- Spacing.lg,- Spacing.md,- Spacing.lg,- Spacing.md,- ),- sliver: SliverToBoxAdapter(- child: Column(+ SliverSafeArea(+ top: false,+ sliver: SliverPadding(+ padding: const EdgeInsets.fromLTRB(+ Spacing.lg,+ 0,+ Spacing.lg,+ Spacing.xl,+ ),+ sliver: SliverList.list(children: [- MenuGroupComponent(+ _LinkSettingsGroup(items: [- MenuComponent(- title: context.strings.linkExpiry,- subtitle: url.hasExpiry- ? (url.isExpired- ? context.strings.linkExpired- : getFormattedTime(- DateTime.fromMicrosecondsSinceEpoch(- url.validTill,- ),- ))- : context.strings.never,- subtitleColor: url.isExpired ? colors.warning : null,- trailing: HugeIcon(- icon: HugeIcons.strokeRoundedArrowRight01,- color: colors.textLight,- size: 20,+ if (url.isExpired)+ MenuComponent(+ title: context.strings.linkHasExpired,+ titleColor: colors.warning,+ isDisabled: true,+ iconColor: colors.warning,+ leading: const Icon(Icons.error_outline_rounded),),- onTap: () async {- unawaited(- routeToPage(+ if (!url.isExpired) ...[+ MenuComponent(+ title: context.strings.copyLink,+ leading: linkIcon(HugeIcons.strokeRoundedCopy01),+ showOnlyLoadingState: true,+ onTap: () async {+ await Clipboard.setData(+ ClipboardData(+ text: CollectionService.instance.getPublicUrl(+ widget.collection!,+ ),+ ),+ );+ if (!context.mounted) {+ return;+ }+ showShortToast(context,- LinkExpiryPickerPage(widget.collection!),- ).then((value) {- if (mounted) {- setState(() {});- }- }),- );- },- ),+ context.strings.linkCopiedToClipboard,+ );+ },+ ),+ MenuComponent(+ key: sendLinkButtonKey,+ title: context.strings.sendLink,+ leading: linkIcon(HugeIcons.strokeRoundedSent),+ onTap: () async {+ await shareText(+ CollectionService.instance.getPublicUrl(+ widget.collection!,+ ),+ context: context,+ key: sendLinkButtonKey,+ );+ },+ ),+ ],],),- const SizedBox(height: Spacing.xxl),- MenuGroupComponent(+ if (!url.isExpired)+ Padding(+ padding: const EdgeInsets.only(top: Spacing.sm),+ child: Text(+ context.strings.publicCollectionLinkAccessDescription,+ style: TextStyles.mini.copyWith(+ color: colors.textLight,+ ),+ ),+ ),+ const SizedBox(height: Spacing.lg),+ _LinkSettingsGroup(items: [MenuComponent(title: context.strings.linkDeviceLimit,+ leading: linkIcon(HugeIcons.strokeRoundedLaptop),subtitle: url.deviceLimit == 0- ? context.strings.noDeviceLimit+ ? context.strings.noLimit: "${url.deviceLimit}",- trailing: HugeIcon(- icon: HugeIcons.strokeRoundedArrowRight01,- color: colors.textLight,- size: 20,- ),+ trailing: chevron,onTap: () async {unawaited(routeToPage(@@ -122,7 +149,8 @@ class _ManageSharedLinkWidgetState extends State<ManageSharedLinkWidget> {),MenuComponent(key: ValueKey("Password lock ${url.passwordEnabled}"),- title: context.strings.passwordLock,+ title: context.strings.password,+ leading: linkIcon(HugeIcons.strokeRoundedSquareLock01),trailing: ToggleSwitchComponent.async(value: () => url.passwordEnabled,onChanged: () async {@@ -157,69 +185,59 @@ class _ManageSharedLinkWidgetState extends State<ManageSharedLinkWidget> {},),),- ],- ),- const SizedBox(height: Spacing.xxl),- MenuGroupComponent(- items: [- if (url.isExpired)- MenuComponent(- title: context.strings.linkExpired,- titleColor: colors.warning,- iconColor: colors.warning,- leading: const Icon(Icons.error_outline),- ),- if (!url.isExpired)- MenuComponent(- title: context.strings.copyLink,- titleBold: true,- leading: HugeIcon(- icon: HugeIcons.strokeRoundedCopy01,- color: colors.textBase,- size: 20,- ),- showOnlyLoadingState: true,- onTap: () async {- await Clipboard.setData(- ClipboardData(text: urlValue),- );- if (!context.mounted) {- return;- }- showShortToast(+ MenuComponent(+ title: context.strings.linkExpiry,+ leading: linkIcon(HugeIcons.strokeRoundedCalendar03),+ subtitle: url.hasExpiry+ ? (url.isExpired+ ? context.strings.linkExpired+ : context.strings.linkEnabled)+ : context.strings.linkNeverExpires,+ trailing: chevron,+ onTap: () async {+ unawaited(+ routeToPage(context,- context.strings.linkCopiedToClipboard,- );- },- ),- if (!url.isExpired)- MenuComponent(- key: sendLinkButtonKey,- title: context.strings.sendLink,- titleBold: true,- leading: HugeIcon(- icon: HugeIcons.strokeRoundedShare08,- color: colors.textBase,- size: 20,- ),- onTap: () async {- unawaited(shareText(urlValue, context: context));- },- ),+ LinkExpiryPickerPage(widget.collection!),+ ).then((value) {+ if (mounted) {+ setState(() {});+ }+ }),+ );+ },+ ),],),- const SizedBox(height: Spacing.xxl),- MenuGroupComponent(+ if (url.hasExpiry)+ Padding(+ padding: const EdgeInsets.only(top: Spacing.sm),+ child: Text(+ url.isExpired+ ? context.strings.expiredLinkInfo+ : context.strings.linkExpiresOn(+ expiryTime: getFormattedTime(+ DateTime.fromMicrosecondsSinceEpoch(+ url.validTill,+ ),+ context: context,+ ),+ ),+ style: TextStyles.body.copyWith(+ color: colors.textLight,+ ),+ ),+ ),+ const SizedBox(height: Spacing.lg),+ _LinkSettingsGroup(items: [MenuComponent(title: context.strings.removeLink,- titleBold: true,titleColor: colors.warning,iconColor: colors.warning,- leading: HugeIcon(- icon: HugeIcons.strokeRoundedDelete02,+ leading: linkIcon(+ HugeIcons.strokeRoundedMinusSignCircle,color: colors.warning,- size: 20,),onTap: () async {final bool result =@@ -238,6 +256,7 @@ class _ManageSharedLinkWidgetState extends State<ManageSharedLinkWidget> {),],),+ const SizedBox(height: Spacing.sm),],),),@@ -291,3 +310,32 @@ class _ManageSharedLinkWidgetState extends State<ManageSharedLinkWidget> {}}}++class _LinkSettingsGroup extends StatelessWidget {+ const _LinkSettingsGroup({required this.items});++ final List<Widget> items;++ @override+ Widget build(BuildContext context) {+ return MenuGroupComponent(+ items: items.length > 1+ ? [+ Padding(+ padding: const EdgeInsets.symmetric(vertical: Spacing.sm),+ child: Column(+ mainAxisSize: MainAxisSize.min,+ children: [+ for (var index = 0; index < items.length; index++) ...[+ items[index],+ if (index < items.length - 1)+ const SizedBox(height: Spacing.xs),+ ],+ ],+ ),+ ),+ ]+ : items,+ );+ }+}diff --git a/mobile/apps/locker/lib/ui/sharing/pickers/device_limit_picker_page.dart b/mobile/apps/locker/lib/ui/sharing/pickers/device_limit_picker_page.dartindex 2cb234e3c2..38671802ac 100644--- a/mobile/apps/locker/lib/ui/sharing/pickers/device_limit_picker_page.dart+++ b/mobile/apps/locker/lib/ui/sharing/pickers/device_limit_picker_page.dart@@ -69,7 +69,7 @@ class _ItemsWidgetState extends State<ItemsWidget> {Widget _menuItemForPicker(int deviceLimit) {return MenuComponent(key: ValueKey(deviceLimit),- title: deviceLimit == 0 ? context.strings.noDeviceLimit : "$deviceLimit",+ title: deviceLimit == 0 ? context.strings.noLimit : "$deviceLimit",trailing: currentDeviceLimit == deviceLimit? Icon(Icons.check, color: context.componentColors.primary): null,diff --git a/mobile/apps/locker/lib/ui/sharing/share_collection_bottom_sheet.dart b/mobile/apps/locker/lib/ui/sharing/share_collection_bottom_sheet.dartindex 07e61636ef..a7e1bceaef 100644--- a/mobile/apps/locker/lib/ui/sharing/share_collection_bottom_sheet.dart+++ b/mobile/apps/locker/lib/ui/sharing/share_collection_bottom_sheet.dart@@ -3,11 +3,9 @@ import "package:ente_pure_utils/ente_pure_utils.dart";import "package:ente_sharing/models/user.dart";import "package:ente_sharing/user_avator_widget.dart";import "package:ente_strings/ente_strings.dart";-import "package:ente_utils/share_utils.dart";import "package:flutter/material.dart";import "package:hugeicons/hugeicons.dart";import "package:locker/extensions/user_extension.dart";-import "package:locker/services/collections/collections_service.dart";import "package:locker/services/collections/models/collection.dart";import "package:locker/services/configuration.dart";import "package:locker/ui/components/custom_list_scrollbar.dart";@@ -190,12 +188,15 @@ class _ShareCollectionSheetState extends State<ShareCollectionSheet> {_ShareActionOption(icon: HugeIcons.strokeRoundedLink02,label: _hasPublicLink- ? context.strings.manageLink+ ? context.strings.linkSettings: context.strings.linkLabel,onTap: () async {if (!_hasPublicLink) {- await _createAndSharePublicLink();- return;+ final result = await CollectionActions.enableUrl(+ context,+ widget.collection,+ );+ if (!result || !mounted) return;}await routeToPage(@@ -212,20 +213,6 @@ class _ShareCollectionSheetState extends State<ShareCollectionSheet> {);}- Future<void> _createAndSharePublicLink() async {- final result = await CollectionActions.enableUrl(- context,- widget.collection,- );- if (result && mounted) {- setState(() {});- if (_hasPublicLink) {- final url = CollectionService.instance.getPublicUrl(widget.collection);- await shareText(url, context: context);- }- }- }-Widget _buildRoleIcon(CollectionParticipantRole role) {final colors = context.componentColors;final icon = switch (role) {diff --git a/mobile/packages/strings/lib/l10n/arb/strings_en.arb b/mobile/packages/strings/lib/l10n/arb/strings_en.arbindex ac13021f75..34af554e10 100644--- a/mobile/packages/strings/lib/l10n/arb/strings_en.arb+++ b/mobile/packages/strings/lib/l10n/arb/strings_en.arb@@ -3231,6 +3231,7 @@}},"publicLink": "Public link",+ "publicCollectionLinkAccessDescription": "Anyone with the link can open the collection without an Ente account.","publicLinkAccessDescription": "Anyone with the link can open the album without an Ente account.","publicLinkCollectDescription": "Anyone with this link can add photos to your album.","publicLinkEnabled": "Public link enabled",