π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
collection sharing for locker
AmanRajSinghMourya20af00bb47d3
diff --git a/mobile/apps/locker/lib/l10n/app_en.arb b/mobile/apps/locker/lib/l10n/app_en.arbindex b758d27deb..7a4036ebe0 100644--- a/mobile/apps/locker/lib/l10n/app_en.arb+++ b/mobile/apps/locker/lib/l10n/app_en.arb@@ -458,6 +458,7 @@"sharedByYou": "Shared by you","sharedWithYou": "Shared with you","manageLink": "Manage link",+ "linkLabel": "Link","linkExpiry": "Link expiry","linkNeverExpires": "Never","linkExpired": "Expired",@@ -915,6 +916,7 @@"sorry": "Sorry","subscribe": "Subscribe","sharedWith": "Shared with",+ "shareCollection": "Share collection","shareLater": "Share later","enterNameOrEmailToShareWith": "Enter name or email to share with","chooseFromAnExistingContact": "Choose from an existing contact",diff --git a/mobile/apps/locker/lib/l10n/app_localizations.dart b/mobile/apps/locker/lib/l10n/app_localizations.dartindex c64783df78..819ade8e2e 100644--- a/mobile/apps/locker/lib/l10n/app_localizations.dart+++ b/mobile/apps/locker/lib/l10n/app_localizations.dart@@ -1590,6 +1590,12 @@ abstract class AppLocalizations {/// **'Manage link'**String get manageLink;+ /// No description provided for @linkLabel.+ ///+ /// In en, this message translates to:+ /// **'Link'**+ String get linkLabel;+/// No description provided for @linkExpiry.////// In en, this message translates to:@@ -2754,6 +2760,12 @@ abstract class AppLocalizations {/// **'Shared with'**String get sharedWith;+ /// No description provided for @shareCollection.+ ///+ /// In en, this message translates to:+ /// **'Share collection'**+ String get shareCollection;+/// No description provided for @shareLater.////// In en, this message translates to:diff --git a/mobile/apps/locker/lib/l10n/app_localizations_en.dart b/mobile/apps/locker/lib/l10n/app_localizations_en.dartindex 521096504d..2325b5fa00 100644--- a/mobile/apps/locker/lib/l10n/app_localizations_en.dart+++ b/mobile/apps/locker/lib/l10n/app_localizations_en.dart@@ -810,6 +810,9 @@ class AppLocalizationsEn extends AppLocalizations {@overrideString get manageLink => 'Manage link';+ @override+ String get linkLabel => 'Link';+@overrideString get linkExpiry => 'Link expiry';@@ -1574,6 +1577,9 @@ class AppLocalizationsEn extends AppLocalizations {@overrideString get sharedWith => 'Shared with';+ @override+ String get shareCollection => 'Share collection';+@overrideString get shareLater => 'Share later';diff --git a/mobile/apps/locker/lib/ui/pages/collection_page.dart b/mobile/apps/locker/lib/ui/pages/collection_page.dartindex d9fd82c9d1..25d923887e 100644--- a/mobile/apps/locker/lib/ui/pages/collection_page.dart+++ b/mobile/apps/locker/lib/ui/pages/collection_page.dart@@ -17,16 +17,15 @@ import 'package:locker/services/collections/models/collection.dart';import "package:locker/services/collections/models/collection_view_type.dart";import "package:locker/services/configuration.dart";import 'package:locker/services/files/sync/models/file.dart';+import "package:locker/ui/components/collection_popup_menu_widget.dart";import "package:locker/ui/components/empty_state_widget.dart";import 'package:locker/ui/components/item_list_view.dart';-import "package:locker/ui/components/popup_menu_item_widget.dart";import 'package:locker/ui/components/search_result_view.dart';import 'package:locker/ui/mixins/search_mixin.dart';import 'package:locker/ui/pages/home_page.dart';import 'package:locker/ui/pages/uploader_page.dart';import "package:locker/ui/sharing/share_collection_bottom_sheet.dart";import "package:locker/ui/viewer/actions/file_selection_overlay_bar.dart";-import 'package:locker/utils/collection_actions.dart';import "package:logging/logging.dart";class CollectionPage extends UploaderPage {@@ -48,9 +47,6 @@ class _CollectionPageState extends UploaderPageState<CollectionPage>final _logger = Logger("CollectionPage");late StreamSubscription<CollectionsUpdatedEvent>_collectionUpdateSubscription;- bool _isCollectionDeleted = false;- bool _isDeletingCollection = false;- bool _ignoreCollectionUpdates = false;late Collection _collection;List<EnteFile> _files = [];@@ -121,9 +117,6 @@ class _CollectionPageState extends UploaderPageState<CollectionPage>_initializeData(widget.collection);_collectionUpdateSubscription =Bus.instance.on<CollectionsUpdatedEvent>().listen((event) async {- if (_ignoreCollectionUpdates || _isCollectionDeleted) {- return;- }_logger.info("CollectionsUpdatedEvent received on CollectionPage (${widget.collection.id}): ${event.source}",);@@ -142,7 +135,7 @@ class _CollectionPageState extends UploaderPageState<CollectionPage>_logger.warning('Collection ${widget.collection.id} no longer exists, navigating back',);- if (!_isCollectionDeleted && mounted) {+ if (mounted) {Navigator.of(context).pop();}}@@ -165,43 +158,6 @@ class _CollectionPageState extends UploaderPageState<CollectionPage>setState(() {});}- Future<void> _deleteCollection() async {- if (_isDeletingCollection) {- return;- }- _isDeletingCollection = true;- _ignoreCollectionUpdates = true;- var didDelete = false;- try {- await CollectionActions.deleteCollection(- context,- _collection,- onSuccess: () {- didDelete = true;- _isCollectionDeleted = true;- if (mounted) {- Navigator.of(context).pop();- }- },- );- } finally {- if (!didDelete) {- _ignoreCollectionUpdates = false;- }- _isDeletingCollection = false;- }- }-- Future<void> _editCollection() async {- await CollectionActions.editCollection(- context,- _collection,- onSuccess: () {- setState(() {});- },- );- }-Future<void> _shareCollection() async {try {if ((collectionViewType != CollectionViewType.ownedCollection &&@@ -217,7 +173,6 @@ class _CollectionPageState extends UploaderPageState<CollectionPage>}await showShareCollectionSheet(context, collection: _collection);- // Refresh state after share sheet closesif (mounted) {setState(() {});}@@ -227,13 +182,6 @@ class _CollectionPageState extends UploaderPageState<CollectionPage>}}- Future<void> _leaveCollection() async {- await CollectionActions.leaveCollection(- context,- _collection,- );- }-@overrideWidget build(BuildContext context) {final colorScheme = getEnteColorScheme(context);@@ -308,19 +256,19 @@ class _CollectionPageState extends UploaderPageState<CollectionPage>if (isFavorite) {return SizedBox.fromSize();}- return PopupMenuButton<String>(- shape: RoundedRectangleBorder(- borderRadius: BorderRadius.circular(16),- side: BorderSide(color: colorScheme.strokeFaint),- ),- color: colorScheme.backdropBase,- surfaceTintColor: Colors.transparent,- padding: EdgeInsets.zero,- menuPadding: EdgeInsets.zero,- elevation: 15,- shadowColor: Colors.black.withValues(alpha: 0.08),- constraints: const BoxConstraints(minWidth: 120),- offset: const Offset(-36, 36),+ final canManageCollection =+ collectionViewType == CollectionViewType.ownedCollection ||+ collectionViewType == CollectionViewType.hiddenOwnedCollection ||+ collectionViewType == CollectionViewType.sharedCollectionViewer ||+ collectionViewType ==+ CollectionViewType.sharedCollectionCollaborator ||+ collectionViewType == CollectionViewType.quickLink;+ if (!canManageCollection) {+ return SizedBox.fromSize();+ }++ return CollectionPopupMenuWidget(+ collection: _collection,child: Container(height: 44,width: 44,@@ -334,101 +282,6 @@ class _CollectionPageState extends UploaderPageState<CollectionPage>color: colorScheme.textBase,),),- onSelected: (value) {- switch (value) {- case 'edit':- _editCollection();- break;- case 'delete':- _deleteCollection();- break;- case 'leave_collection':- _leaveCollection();- break;- }- },- itemBuilder: (BuildContext context) {- final items = <PopupMenuItem<String>>[];- var itemIndex = 0;- var totalItems = 0;-- if (collectionViewType == CollectionViewType.ownedCollection ||- collectionViewType == CollectionViewType.hiddenOwnedCollection ||- collectionViewType == CollectionViewType.quickLink) {- totalItems = 2;- } else if (collectionViewType ==- CollectionViewType.sharedCollectionViewer ||- collectionViewType ==- CollectionViewType.sharedCollectionCollaborator) {- totalItems = 1;- }-- if (collectionViewType == CollectionViewType.ownedCollection ||- collectionViewType == CollectionViewType.hiddenOwnedCollection ||- collectionViewType == CollectionViewType.quickLink) {- items.add(- PopupMenuItem<String>(- value: 'edit',- height: 0,- padding: EdgeInsets.zero,- child: PopupMenuItemWidget(- icon: HugeIcon(- icon: HugeIcons.strokeRoundedPencilEdit02,- color: colorScheme.textBase,- size: 20,- ),- label: context.l10n.edit,- isFirst: itemIndex == 0,- isLast: itemIndex == totalItems - 1,- ),- ),- );- itemIndex++;-- items.add(- PopupMenuItem<String>(- value: 'delete',- padding: EdgeInsets.zero,- height: 0,- child: PopupMenuItemWidget(- icon: HugeIcon(- icon: HugeIcons.strokeRoundedDelete02,- color: colorScheme.warning500,- size: 20,- ),- isWarning: true,- label: context.l10n.delete,- isFirst: itemIndex == 0,- isLast: itemIndex == totalItems - 1,- ),- ),- );- }-- if (collectionViewType == CollectionViewType.sharedCollectionViewer ||- collectionViewType ==- CollectionViewType.sharedCollectionCollaborator) {- items.add(- PopupMenuItem<String>(- value: 'leave_collection',- padding: EdgeInsets.zero,- height: 0,- child: PopupMenuItemWidget(- icon: HugeIcon(- icon: HugeIcons.strokeRoundedDelete02,- color: colorScheme.textBase,- size: 20,- ),- label: context.l10n.leaveCollection,- isFirst: true,- isLast: true,- ),- ),- );- }-- return items;- },);}diff --git a/mobile/apps/locker/lib/ui/sharing/add_email_bottom_sheet.dart b/mobile/apps/locker/lib/ui/sharing/add_email_bottom_sheet.dartindex 591285d6e3..2c33bd6bc1 100644--- a/mobile/apps/locker/lib/ui/sharing/add_email_bottom_sheet.dart+++ b/mobile/apps/locker/lib/ui/sharing/add_email_bottom_sheet.dart@@ -9,13 +9,11 @@ import "package:ente_ui/components/divider_widget.dart";import "package:ente_ui/components/menu_item_widget_v2.dart";import "package:ente_ui/theme/ente_theme.dart";import "package:flutter/material.dart";-import "package:intl/intl.dart";import "package:locker/l10n/l10n.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/gradient_button.dart";-import "package:locker/ui/viewer/date/date_time_picker.dart";import "package:locker/utils/collection_actions.dart";Future<void> showAddEmailSheet(@@ -50,11 +48,8 @@ class AddEmailSheet extends StatefulWidget {}class _AddEmailSheetState extends State<AddEmailSheet> {- final bool _shareLater = false;String _email = "";bool _emailIsValid = false;- DateTime? _scheduledDate;- TimeOfDay? _scheduledTime;final CollectionParticipantRole _selectedRole =CollectionParticipantRole.viewer;@@ -70,7 +65,7 @@ class _AddEmailSheetState extends State<AddEmailSheet> {super.initState();_collectionActions = CollectionActions();_suggestedUsers = _getSuggestedUsers();- }+ }@overridevoid dispose() {@@ -95,11 +90,6 @@ class _AddEmailSheetState extends State<AddEmailSheet> {const SizedBox(height: 20),_buildExistingContactsSection(colorScheme, textTheme),],- // _buildShareLaterCheckbox(colorScheme, textTheme),- if (_shareLater) ...[- const SizedBox(height: 12),- _buildScheduleDateTimeRow(colorScheme, textTheme),- ],const SizedBox(height: 20),_buildShareButton(),],@@ -308,121 +298,12 @@ class _AddEmailSheetState extends State<AddEmailSheet> {);}- Widget _buildScheduleDateTimeRow(colorScheme, textTheme) {- final dateText = _scheduledDate != null- ? DateFormat("dd/MM/yy").format(_scheduledDate!)- : "DD/MM/YY";- final timeText = _scheduledTime != null- ? "${_scheduledTime!.hour.toString().padLeft(2, '0')}:${_scheduledTime!.minute.toString().padLeft(2, '0')}"- : "00:00";-- return Row(- children: [- Expanded(- child: GestureDetector(- onTap: _selectDate,- child: Container(- padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 12),- decoration: BoxDecoration(- color: colorScheme.fillFaint,- borderRadius: BorderRadius.circular(8),- ),- child: Row(- children: [- Icon(- Icons.calendar_today_outlined,- size: 18,- color: colorScheme.textMuted,- ),- const SizedBox(width: 8),- Text(- dateText,- style: textTheme.small.copyWith(- color: _scheduledDate != null- ? colorScheme.textBase- : colorScheme.textMuted,- ),- ),- ],- ),- ),- ),- ),- const SizedBox(width: 12),- Expanded(- child: GestureDetector(- onTap: _selectTime,- child: Container(- padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 12),- decoration: BoxDecoration(- color: colorScheme.fillFaint,- borderRadius: BorderRadius.circular(8),- ),- child: Row(- children: [- Icon(- Icons.access_time_outlined,- size: 18,- color: colorScheme.textMuted,- ),- const SizedBox(width: 8),- Text(- timeText,- style: textTheme.small.copyWith(- color: _scheduledTime != null- ? colorScheme.textBase- : colorScheme.textMuted,- ),- ),- ],- ),- ),- ),- ),- ],- );- }-- Future<void> _selectDate() async {- final initialDate = _scheduledDate ??- DateTime.now().add(- const Duration(days: 1),- );- final pickedDate = await showDatePickerSheet(- context,- initialDate: initialDate,- minDate: DateTime.now(),- );- if (pickedDate != null && mounted) {- setState(() {- _scheduledDate = pickedDate;- });- }- }-- Future<void> _selectTime() async {- final initialTime = _scheduledTime ?? TimeOfDay.now();- final pickedTime = await showTimePicker(- context: context,- initialTime: initialTime,- );- if (pickedTime != null && mounted) {- setState(() {- _scheduledTime = pickedTime;- });- }- }-Widget _buildShareButton() {- final bool canShare =- _emailIsValid && (!_shareLater || _isScheduledDateTimeValid());- final buttonText =- _shareLater ? context.l10n.scheduleShare : context.l10n.share;return SizedBox(width: double.infinity,child: GradientButton(- text: buttonText,- onTap: canShare ? _onShareTap : null,+ text: context.l10n.share,+ onTap: _emailIsValid ? _onShareTap : null,),);}@@ -487,18 +368,4 @@ class _AddEmailSheetState extends State<AddEmailSheet> {bool _isValidEmail(String email) {return EmailValidator.validate(email);}-- bool _isScheduledDateTimeValid() {- if (_scheduledDate == null || _scheduledTime == null) {- return false;- }- final scheduledDateTime = DateTime(- _scheduledDate!.year,- _scheduledDate!.month,- _scheduledDate!.day,- _scheduledTime!.hour,- _scheduledTime!.minute,- );- return scheduledDateTime.isAfter(DateTime.now());- }}diff --git a/mobile/apps/locker/lib/ui/sharing/advanced_sharing_bottom_sheet.dart b/mobile/apps/locker/lib/ui/sharing/advanced_sharing_bottom_sheet.dartdeleted file mode 100644index c4ca574a61..0000000000--- a/mobile/apps/locker/lib/ui/sharing/advanced_sharing_bottom_sheet.dart+++ /dev/null@@ -1,386 +0,0 @@-import "dart:convert";--import "package:ente_crypto_api/ente_crypto_api.dart";-import "package:ente_pure_utils/ente_pure_utils.dart";-import "package:ente_ui/components/alert_bottom_sheet.dart";-import "package:ente_ui/components/captioned_text_widget.dart";-import "package:ente_ui/components/menu_item_widget.dart";-import "package:ente_ui/components/toggle_switch_widget.dart";-import "package:ente_ui/theme/ente_theme.dart";-import "package:ente_ui/utils/dialog_util.dart";-import "package:ente_ui/utils/toast_util.dart";-import "package:ente_utils/email_util.dart";-import "package:flutter/material.dart";-import "package:locker/l10n/l10n.dart";-import "package:locker/services/collections/collections_api_client.dart";-import "package:locker/services/collections/models/collection.dart";-import "package:locker/services/collections/models/public_url.dart";-import "package:locker/ui/components/gradient_button.dart";-import "package:locker/ui/sharing/pickers/device_limit_picker_page.dart";-import "package:locker/ui/sharing/pickers/link_expiry_picker_page.dart";-import "package:locker/utils/collection_actions.dart";--/// A bottom sheet widget for advanced sharing options.-///-/// This widget provides advanced configuration options for:-/// - Sharing settings (enabled/disabled, download permissions)-/// - Public link settings (enable/disable, downloads, uploads, password protection)-/// - Device limits and link expiry settings-class AdvancedSharingBottomSheet extends StatefulWidget {- final Collection collection;-- const AdvancedSharingBottomSheet({- super.key,- required this.collection,- });-- @override- State<AdvancedSharingBottomSheet> createState() =>- _AdvancedSharingBottomSheetState();-}--class _AdvancedSharingBottomSheetState- extends State<AdvancedSharingBottomSheet> {- int get _shareeCount => widget.collection.getSharees().length;-- PublicURL? get _publicUrl => widget.collection.publicURLs.isNotEmpty- ? widget.collection.publicURLs.first- : null;-- bool get _hasPublicLink => _publicUrl != null;-- @override- Widget build(BuildContext context) {- final colorScheme = getEnteColorScheme(context);- final textTheme = getEnteTextTheme(context);- final shareText = context.l10n.shareWithPeopleSectionTitle(_shareeCount);-- final isDownloadEnabled =- widget.collection.publicURLs.firstOrNull?.enableDownload ?? true;- final isCollectEnabled =- widget.collection.publicURLs.firstOrNull?.enableCollect ?? false;- final isPasswordEnabled =- widget.collection.publicURLs.firstOrNull?.passwordEnabled ?? false;-- return Container(- decoration: BoxDecoration(- color: colorScheme.backdropBase,- borderRadius: const BorderRadius.only(- topLeft: Radius.circular(20),- topRight: Radius.circular(20),- ),- ),- child: SafeArea(- child: ConstrainedBox(- constraints: BoxConstraints(- maxHeight: MediaQuery.of(context).size.height * 0.85,- ),- child: Column(- mainAxisSize: MainAxisSize.min,- children: [- Padding(- padding:- const EdgeInsets.symmetric(horizontal: 16, vertical: 8),- child: Row(- mainAxisAlignment: MainAxisAlignment.spaceBetween,- children: [- Icon(- Icons.group_outlined,- size: 20,- color: colorScheme.textMuted,- ),- const SizedBox(width: 8),- Expanded(- child: Text(- shareText,- style: textTheme.body.copyWith(- color: colorScheme.textMuted,- fontSize: 16,- ),- overflow: TextOverflow.ellipsis,- ),- ),- IconButton(- icon: Icon(- Icons.close,- color: colorScheme.textBase,- size: 24,- ),- onPressed: () => Navigator.pop(context),- padding: EdgeInsets.zero,- constraints: const BoxConstraints(),- ),- ],- ),- ),- Flexible(- child: SingleChildScrollView(- padding: const EdgeInsets.symmetric(horizontal: 16),- child: Column(- crossAxisAlignment: CrossAxisAlignment.start,- children: [- Text(- context.l10n.sharingSection,- style: textTheme.largeBold,- ),- const SizedBox(height: 8),- MenuItemWidget(- captionedTextWidget: CaptionedTextWidget(- title: context.l10n.sharingEnabledToggle,- ),- menuItemColor: colorScheme.backgroundElevated2,- trailingWidget: ToggleSwitchWidget(- value: () => _shareeCount > 0 || _hasPublicLink,- onChanged: () async {},- ),- isGestureDetectorDisabled: true,- ),- const SizedBox(height: 8),- MenuItemWidget(- captionedTextWidget: CaptionedTextWidget(- title: context.l10n.allowDownloads,- ),- menuItemColor: colorScheme.backgroundElevated2,- trailingWidget: ToggleSwitchWidget(- value: () => isDownloadEnabled,- onChanged: () async {- await _updatePublicUrlSettings(- {- 'enableDownload': !isDownloadEnabled,- },- );- if (isDownloadEnabled) {- // ignore: unawaited_futures- showAlertBottomSheet(- context,- title: context.l10n.disableDownloadWarningTitle,- message: context.l10n.disableDownloadWarningBody,- assetPath: "assets/warning-grey.png",- buttons: [- GradientButton(- text: context.l10n.contactSupport,- onTap: () async {- await sendLogs(- context,- "[email protected]",- postShare: () {},- );- },- ),- ],- );- }- },- ),- isGestureDetectorDisabled: true,- ),- const SizedBox(height: 24),- Text(- context.l10n.publicLinkSection,- style: textTheme.h3Bold.copyWith(- fontSize: 18.0,- ),- ),- const SizedBox(height: 8),- MenuItemWidget(- captionedTextWidget: CaptionedTextWidget(- title: context.l10n.linkEnabledToggle,- ),- menuItemColor: colorScheme.backgroundElevated2,- trailingWidget: ToggleSwitchWidget(- value: () => _hasPublicLink,- onChanged: () async {- if (_hasPublicLink) {- await _disablePublicLink();- } else {- await _createPublicLink();- }- },- ),- isGestureDetectorDisabled: true,- ),- if (_hasPublicLink && _publicUrl != null) ...[- const SizedBox(height: 8),- MenuItemWidget(- captionedTextWidget: CaptionedTextWidget(- title: context.l10n.allowUploads,- ),- menuItemColor: colorScheme.backgroundElevated2,- trailingWidget: ToggleSwitchWidget(- value: () => isCollectEnabled,- onChanged: () async {- await _updatePublicUrlSettings(- {'enableCollect': !isCollectEnabled},- );- },- ),- isGestureDetectorDisabled: true,- ),- const SizedBox(height: 8),- MenuItemWidget(- captionedTextWidget: CaptionedTextWidget(- title: context.l10n.passwordLock,- ),- menuItemColor: colorScheme.backgroundElevated2,- trailingWidget: ToggleSwitchWidget(- value: () => isPasswordEnabled,- onChanged: () async {- if (!isPasswordEnabled) {- await _showPasswordDialog();- } else {- await _updatePublicUrlSettings(- {'disablePassword': true},- );- }- },- ),- isGestureDetectorDisabled: true,- ),- const SizedBox(height: 8),- MenuItemWidget(- captionedTextWidget: CaptionedTextWidget(- title: context.l10n.linkDeviceLimit,- subTitle: _publicUrl!.deviceLimit == 0- ? context.l10n.noDeviceLimit- : "${_publicUrl!.deviceLimit}",- ),- menuItemColor: colorScheme.backgroundElevated2,- trailingWidget: Icon(- Icons.chevron_right,- color: colorScheme.textMuted,- size: 24,- ),- onTap: () async {- await routeToPage(- context,- DeviceLimitPickerPage(widget.collection),- ).then((value) {- setState(() {});- });- },- ),- const SizedBox(height: 8),- MenuItemWidget(- captionedTextWidget: CaptionedTextWidget(- title: context.l10n.linkExpiry,- subTitle: _publicUrl!.hasExpiry- ? (_publicUrl!.isExpired- ? context.l10n.linkExpired- : context.l10n.linkEnabled)- : context.l10n.never,- ),- menuItemColor: colorScheme.backgroundElevated2,- trailingWidget: Icon(- Icons.chevron_right,- color: colorScheme.textMuted,- size: 24,- ),- onTap: () async {- await routeToPage(- context,- LinkExpiryPickerPage(widget.collection),- ).then((value) {- setState(() {});- });- },- ),- ],- const SizedBox(height: 24),- ],- ),- ),- ),- ],- ),- ),- ),- );- }-- Future<void> _createPublicLink() async {- final success = await CollectionActions.enableUrl(- context,- widget.collection,- );- if (success && mounted) {- setState(() {});- }- }-- Future<void> _disablePublicLink() async {- try {- await CollectionActions.disableUrl(- context,- widget.collection,- );- if (mounted) {- setState(() {});- }- } catch (e) {- if (mounted) {- await showGenericErrorDialog(context: context, error: e);- }- }- }-- Future<void> _updatePublicUrlSettings(- Map<String, dynamic> updates, {- bool showProgressDialog = true,- }) async {- final dialog = showProgressDialog- ? createProgressDialog(context, context.l10n.pleaseWait)- : null;- await dialog?.show();- try {- await CollectionApiClient.instance.updateShareUrl(- widget.collection,- updates,- );- await dialog?.hide();- showShortToast(context, context.l10n.collectionUpdated);- if (mounted) {- setState(() {});- }- } catch (e) {- if (mounted) {- await dialog?.hide();- await showGenericErrorDialog(context: context, error: e);- rethrow;- }- }- }-- Future<void> _showPasswordDialog() async {- await showTextInputDialog(- context,- title: context.l10n.setAPassword,- submitButtonLabel: context.l10n.lockButtonLabel,- hintText: context.l10n.enterPassword,- isPasswordInput: true,- alwaysShowSuccessState: true,- onSubmit: (String password) async {- if (password.trim().isNotEmpty) {- final propToUpdate = await _getEncryptedPassword(password);- await _updatePublicUrlSettings(- propToUpdate,- showProgressDialog: false,- );- }- },- );- }-- Future<Map<String, dynamic>> _getEncryptedPassword(String pass) async {- final kekSalt = CryptoUtil.getSaltToDeriveKey();- final result = await CryptoUtil.deriveInteractiveKey(- utf8.encode(pass),- kekSalt,- );- return {- 'passHash': CryptoUtil.bin2base64(result.key),- 'nonce': CryptoUtil.bin2base64(kekSalt),- 'memLimit': result.memLimit,- 'opsLimit': result.opsLimit,- };- }-}diff --git a/mobile/apps/locker/lib/ui/sharing/manage_album_participant.dart b/mobile/apps/locker/lib/ui/sharing/manage_album_participant.dartindex 11fb21b367..8ee9d0e453 100644--- a/mobile/apps/locker/lib/ui/sharing/manage_album_participant.dart+++ b/mobile/apps/locker/lib/ui/sharing/manage_album_participant.dart@@ -136,7 +136,7 @@ class _ManageIndividualParticipantStateCollectionParticipantRole.viewer,);} catch (e) {- await showGenericErrorDialog(+ await showGenericErrorBottomSheet(context: context,error: e,);diff --git a/mobile/apps/locker/lib/ui/sharing/manage_links_widget.dart b/mobile/apps/locker/lib/ui/sharing/manage_links_widget.dartindex cda8ab2006..2a4c6220bb 100644--- a/mobile/apps/locker/lib/ui/sharing/manage_links_widget.dart+++ b/mobile/apps/locker/lib/ui/sharing/manage_links_widget.dart@@ -1,27 +1,20 @@-import "dart:convert";+import "dart:async";-import "package:ente_crypto_api/ente_crypto_api.dart";import "package:ente_pure_utils/ente_pure_utils.dart";-import "package:ente_ui/components/alert_bottom_sheet.dart";-import "package:ente_ui/components/captioned_text_widget.dart";+import "package:ente_ui/components/captioned_text_widget_v2.dart";import "package:ente_ui/components/divider_widget.dart";-import "package:ente_ui/components/menu_item_widget.dart";-import "package:ente_ui/components/menu_section_description_widget.dart";-import "package:ente_ui/components/toggle_switch_widget.dart";+import "package:ente_ui/components/menu_item_widget_v2.dart";import "package:ente_ui/theme/colors.dart";import "package:ente_ui/theme/ente_theme.dart";-import "package:ente_ui/utils/dialog_util.dart";import "package:ente_ui/utils/toast_util.dart";-import "package:ente_utils/email_util.dart";import "package:ente_utils/share_utils.dart";import "package:flutter/material.dart";import "package:flutter/services.dart";+import "package:hugeicons/hugeicons.dart";import "package:locker/l10n/l10n.dart";-import "package:locker/services/collections/collections_api_client.dart";import "package:locker/services/collections/collections_service.dart";import "package:locker/services/collections/models/collection.dart";import "package:locker/services/collections/models/public_url.dart";-import "package:locker/ui/components/gradient_button.dart";import "package:locker/ui/sharing/pickers/device_limit_picker_page.dart";import "package:locker/ui/sharing/pickers/link_expiry_picker_page.dart";import "package:locker/utils/collection_actions.dart";@@ -45,12 +38,6 @@ class _ManageSharedLinkWidgetState extends State<ManageSharedLinkWidget> {@overrideWidget build(BuildContext context) {- final isCollectEnabled =- widget.collection!.publicURLs.firstOrNull?.enableCollect ?? false;- final isDownloadEnabled =- widget.collection!.publicURLs.firstOrNull?.enableDownload ?? true;- final isPasswordEnabled =- widget.collection!.publicURLs.firstOrNull?.passwordEnabled ?? false;final enteColorScheme = getEnteColorScheme(context);final PublicURL url = widget.collection!.publicURLs.firstOrNull!;final String urlValue =@@ -58,6 +45,7 @@ class _ManageSharedLinkWidgetState extends State<ManageSharedLinkWidget> {return Scaffold(appBar: AppBar(elevation: 0,+ centerTitle: false,title: Text(context.l10n.manageLink),),body: SingleChildScrollView(@@ -68,39 +56,26 @@ class _ManageSharedLinkWidgetState extends State<ManageSharedLinkWidget> {child: Column(crossAxisAlignment: CrossAxisAlignment.start,children: [- MenuItemWidget(- key: ValueKey("Allow collect $isCollectEnabled"),- captionedTextWidget: CaptionedTextWidget(- title: context.l10n.allowAddingFiles,- ),+ MenuItemWidgetV2(alignCaptionedTextToLeft: true,- menuItemColor: getEnteColorScheme(context).fillFaint,- trailingWidget: ToggleSwitchWidget(- value: () => isCollectEnabled,- onChanged: () async {- await _updateUrlSettings(- context,- {'enableCollect': !isCollectEnabled},- );- },- ),- ),- MenuSectionDescriptionWidget(- content: context.l10n.allowAddFilesDescription,- ),- const SizedBox(height: 24),- MenuItemWidget(- alignCaptionedTextToLeft: true,- captionedTextWidget: CaptionedTextWidget(+ captionedTextWidget: CaptionedTextWidgetV2(title: context.l10n.linkExpiry,- subTitle: (url.hasExpiry+ subTitle: url.hasExpiry? (url.isExpired? context.l10n.linkExpired- : context.l10n.linkEnabled)- : context.l10n.linkNeverExpires),+ : getFormattedTime(+ DateTime.fromMicrosecondsSinceEpoch(+ url.validTill,+ ),+ ))+ : context.l10n.never,subTitleColor: url.isExpired ? warning500 : null,),- trailingIcon: Icons.chevron_right,+ trailingWidget: HugeIcon(+ icon: HugeIcons.strokeRoundedArrowRight01,+ color: enteColorScheme.textMuted,+ size: 20,+ ),menuItemColor: enteColorScheme.fillFaint,surfaceExecutionStates: false,onTap: () async {@@ -113,31 +88,21 @@ class _ManageSharedLinkWidgetState extends State<ManageSharedLinkWidget> {});},),- url.hasExpiry- ? MenuSectionDescriptionWidget(- content: url.isExpired- ? context.l10n.expiredLinkInfo- : context.l10n.linkExpiresOn(- getFormattedTime(- DateTime.fromMicrosecondsSinceEpoch(- url.validTill,- ),- ),- ),- )- : const SizedBox.shrink(),const Padding(padding: EdgeInsets.only(top: 24)),- MenuItemWidget(- captionedTextWidget: CaptionedTextWidget(+ MenuItemWidgetV2(+ captionedTextWidget: CaptionedTextWidgetV2(title: context.l10n.linkDeviceLimit,subTitle: url.deviceLimit == 0? context.l10n.noDeviceLimit: "${url.deviceLimit}",),- trailingIcon: Icons.chevron_right,+ trailingWidget: HugeIcon(+ icon: HugeIcons.strokeRoundedArrowRight01,+ color: enteColorScheme.textMuted,+ size: 20,+ ),menuItemColor: enteColorScheme.fillFaint,alignCaptionedTextToLeft: true,- isBottomBorderRadiusRemoved: true,onTap: () async {// ignore: unawaited_futuresrouteToPage(@@ -149,103 +114,12 @@ class _ManageSharedLinkWidgetState extends State<ManageSharedLinkWidget> {},surfaceExecutionStates: false,),- DividerWidget(- dividerType: DividerType.menuNoIcon,- bgColor: getEnteColorScheme(context).fillFaint,- ),- MenuItemWidget(- key: ValueKey("Allow downloads $isDownloadEnabled"),- captionedTextWidget: CaptionedTextWidget(- title: context.l10n.allowDownloads,- ),- alignCaptionedTextToLeft: true,- isBottomBorderRadiusRemoved: true,- isTopBorderRadiusRemoved: true,- menuItemColor: getEnteColorScheme(context).fillFaint,- trailingWidget: ToggleSwitchWidget(- value: () => isDownloadEnabled,- onChanged: () async {- await _updateUrlSettings(- context,- {'enableDownload': !isDownloadEnabled},- );- if (isDownloadEnabled) {- // ignore: unawaited_futures- showAlertBottomSheet(- context,- title: context.l10n.disableDownloadWarningTitle,- message: context.l10n.disableDownloadWarningBody,- assetPath: "assets/warning-grey.png",- buttons: [- GradientButton(- text: context.l10n.contactSupport,- onTap: () async {- await sendLogs(- context,- "[email protected]",- postShare: () {},- );- },- ),- ],- );- }- },- ),- ),- DividerWidget(- dividerType: DividerType.menuNoIcon,- bgColor: getEnteColorScheme(context).fillFaint,- ),- MenuItemWidget(- key: ValueKey("Password lock $isPasswordEnabled"),- captionedTextWidget: CaptionedTextWidget(- title: context.l10n.passwordLock,- ),- alignCaptionedTextToLeft: true,- isTopBorderRadiusRemoved: true,- menuItemColor: getEnteColorScheme(context).fillFaint,- trailingWidget: ToggleSwitchWidget(- value: () => isPasswordEnabled,- onChanged: () async {- if (!isPasswordEnabled) {- // ignore: unawaited_futures- showTextInputDialog(- context,- title: context.l10n.setPasswordTitle,- submitButtonLabel: context.l10n.lockButtonLabel,- hintText: context.l10n.enterPassword,- isPasswordInput: true,- alwaysShowSuccessState: true,- onSubmit: (String password) async {- if (password.trim().isNotEmpty) {- final propToUpdate =- await _getEncryptedPassword(- password,- );- await _updateUrlSettings(- context,- propToUpdate,- showProgressDialog: false,- );- }- },- );- } else {- await _updateUrlSettings(- context,- {'disablePassword': true},- );- }- },- ),- ),const SizedBox(height: 24,),if (url.isExpired)- MenuItemWidget(- captionedTextWidget: CaptionedTextWidget(+ MenuItemWidgetV2(+ captionedTextWidget: CaptionedTextWidgetV2(title: context.l10n.linkExpired,textColor: getEnteColorScheme(context).warning500,),@@ -255,12 +129,16 @@ class _ManageSharedLinkWidgetState extends State<ManageSharedLinkWidget> {isBottomBorderRadiusRemoved: true,),if (!url.isExpired)- MenuItemWidget(- captionedTextWidget: CaptionedTextWidget(+ MenuItemWidgetV2(+ captionedTextWidget: CaptionedTextWidgetV2(title: context.l10n.copyLink,makeTextBold: true,),- leadingIcon: Icons.copy,+ leadingIconWidget: HugeIcon(+ icon: HugeIcons.strokeRoundedCopy01,+ color: enteColorScheme.textBase,+ size: 20,+ ),menuItemColor: getEnteColorScheme(context).fillFaint,showOnlyLoadingState: true,onTap: () async {@@ -278,32 +156,35 @@ class _ManageSharedLinkWidgetState extends State<ManageSharedLinkWidget> {bgColor: getEnteColorScheme(context).fillFaint,),if (!url.isExpired)- MenuItemWidget(+ MenuItemWidgetV2(key: sendLinkButtonKey,- captionedTextWidget: CaptionedTextWidget(+ captionedTextWidget: CaptionedTextWidgetV2(title: context.l10n.sendLink,makeTextBold: true,),- leadingIcon: Icons.adaptive.share,+ leadingIconWidget: HugeIcon(+ icon: HugeIcons.strokeRoundedShare08,+ color: enteColorScheme.textBase,+ size: 20,+ ),menuItemColor: getEnteColorScheme(context).fillFaint,onTap: () async {- // ignore: unawaited_futures- await shareText(- urlValue,- context: context,- );+ unawaited(shareText(urlValue, context: context));},isTopBorderRadiusRemoved: true,),const SizedBox(height: 24),- MenuItemWidget(- captionedTextWidget: CaptionedTextWidget(+ MenuItemWidgetV2(+ captionedTextWidget: CaptionedTextWidgetV2(title: context.l10n.removeLink,textColor: warning500,makeTextBold: true,),- leadingIcon: Icons.remove_circle_outline,- leadingIconColor: warning500,+ leadingIconWidget: const HugeIcon(+ icon: HugeIcons.strokeRoundedDelete02,+ color: warning500,+ size: 20,+ ),menuItemColor: getEnteColorScheme(context).fillFaint,surfaceExecutionStates: false,onTap: () async {@@ -327,42 +208,4 @@ class _ManageSharedLinkWidgetState extends State<ManageSharedLinkWidget> {),);}-- Future<Map<String, dynamic>> _getEncryptedPassword(String pass) async {- final kekSalt = CryptoUtil.getSaltToDeriveKey();- final result = await CryptoUtil.deriveInteractiveKey(- utf8.encode(pass),- kekSalt,- );- return {- 'passHash': CryptoUtil.bin2base64(result.key),- 'nonce': CryptoUtil.bin2base64(kekSalt),- 'memLimit': result.memLimit,- 'opsLimit': result.opsLimit,- };- }-- Future<void> _updateUrlSettings(- BuildContext context,- Map<String, dynamic> prop, {- bool showProgressDialog = true,- }) async {- final dialog = showProgressDialog- ? createProgressDialog(context, context.l10n.pleaseWait)- : null;- await dialog?.show();- try {- await CollectionApiClient.instance- .updateShareUrl(widget.collection!, prop);- await dialog?.hide();- showShortToast(context, context.l10n.collectionUpdated);- if (mounted) {- setState(() {});- }- } catch (e) {- await dialog?.hide();- await showGenericErrorDialog(context: context, error: e);- rethrow;- }- }}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 dff471cedb..f1f2844a15 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@@ -1,6 +1,6 @@-import "package:ente_ui/components/captioned_text_widget.dart";+import "package:ente_ui/components/captioned_text_widget_v2.dart";import "package:ente_ui/components/divider_widget.dart";-import "package:ente_ui/components/menu_item_widget.dart";+import "package:ente_ui/components/menu_item_widget_v2.dart";import "package:ente_ui/components/separators.dart";import "package:ente_ui/components/title_bar_title_widget.dart";import "package:ente_ui/components/title_bar_widget.dart";@@ -85,12 +85,21 @@ class _ItemsWidgetState extends State<ItemsWidget> {items.clear();if (isCustomLimit) {items.add(- _menuItemForPicker(initialDeviceLimit),+ _menuItemForPicker(+ initialDeviceLimit,+ isFirst: true,+ isLast: publicLinkDeviceLimits.isEmpty,+ ),);}- for (int deviceLimit in publicLinkDeviceLimits) {+ for (int index = 0; index < publicLinkDeviceLimits.length; index++) {+ final deviceLimit = publicLinkDeviceLimits[index];items.add(- _menuItemForPicker(deviceLimit),+ _menuItemForPicker(+ deviceLimit,+ isFirst: !isCustomLimit && index == 0,+ isLast: index == publicLinkDeviceLimits.length - 1,+ ),);}items = addSeparators(@@ -106,17 +115,21 @@ class _ItemsWidgetState extends State<ItemsWidget> {);}- Widget _menuItemForPicker(int deviceLimit) {- return MenuItemWidget(+ Widget _menuItemForPicker(+ int deviceLimit, {+ required bool isFirst,+ required bool isLast,+ }) {+ return MenuItemWidgetV2(key: ValueKey(deviceLimit),menuItemColor: getEnteColorScheme(context).fillFaint,- captionedTextWidget: CaptionedTextWidget(+ captionedTextWidget: CaptionedTextWidgetV2(title: deviceLimit == 0 ? context.l10n.noDeviceLimit : "$deviceLimit",),trailingIcon: currentDeviceLimit == deviceLimit ? Icons.check : null,alignCaptionedTextToLeft: true,- isTopBorderRadiusRemoved: true,- isBottomBorderRadiusRemoved: true,+ isTopBorderRadiusRemoved: !isFirst,+ isBottomBorderRadiusRemoved: !isLast,showOnlyLoadingState: true,onTap: () async {await _updateUrlSettings(context, {@@ -138,7 +151,7 @@ class _ItemsWidgetState extends State<ItemsWidget> {await CollectionApiClient.instance.updateShareUrl(widget.collection, prop);} catch (e) {- await showGenericErrorDialog(context: context, error: e);+ await showGenericErrorBottomSheet(context: context, error: e);rethrow;}}diff --git a/mobile/apps/locker/lib/ui/sharing/pickers/link_expiry_picker_page.dart b/mobile/apps/locker/lib/ui/sharing/pickers/link_expiry_picker_page.dartindex 4a85cbbd61..4163c745dc 100644--- a/mobile/apps/locker/lib/ui/sharing/pickers/link_expiry_picker_page.dart+++ b/mobile/apps/locker/lib/ui/sharing/pickers/link_expiry_picker_page.dart@@ -1,6 +1,6 @@-import "package:ente_ui/components/captioned_text_widget.dart";+import "package:ente_ui/components/captioned_text_widget_v2.dart";import "package:ente_ui/components/divider_widget.dart";-import "package:ente_ui/components/menu_item_widget.dart";+import "package:ente_ui/components/menu_item_widget_v2.dart";import "package:ente_ui/components/separators.dart";import "package:ente_ui/components/title_bar_title_widget.dart";import "package:ente_ui/components/title_bar_widget.dart";@@ -82,9 +82,15 @@ class _ItemsWidgetState extends State<ItemsWidget> {@overrideWidget build(BuildContext context) {List<Widget> items = [];- for (Tuple2<String, int> expiryOpiton in _expiryOptions) {+ for (int index = 0; index < _expiryOptions.length; index++) {+ final expiryOpiton = _expiryOptions[index];items.add(- _menuItemForPicker(context, expiryOpiton),+ _menuItemForPicker(+ context,+ expiryOpiton,+ isFirst: index == 0,+ isLast: index == _expiryOptions.length - 1,+ ),);}items = addSeparators(@@ -103,15 +109,19 @@ class _ItemsWidgetState extends State<ItemsWidget> {Widget _menuItemForPicker(BuildContext context,Tuple2<String, int> expiryOpiton,+ {+ required bool isFirst,+ required bool isLast,+ }) {- return MenuItemWidget(+ return MenuItemWidgetV2(menuItemColor: getEnteColorScheme(context).fillFaint,- captionedTextWidget: CaptionedTextWidget(+ captionedTextWidget: CaptionedTextWidgetV2(title: expiryOpiton.item1,),alignCaptionedTextToLeft: true,- isTopBorderRadiusRemoved: true,- isBottomBorderRadiusRemoved: true,+ isTopBorderRadiusRemoved: !isFirst,+ isBottomBorderRadiusRemoved: !isLast,alwaysShowSuccessState: true,surfaceExecutionStates: expiryOpiton.item2 == -1 ? false : true,onTap: () async {@@ -161,7 +171,7 @@ class _ItemsWidgetState extends State<ItemsWidget> {await CollectionApiClient.instance.updateShareUrl(widget.collection, prop);} catch (e) {- await showGenericErrorDialog(context: context, error: e);+ await showGenericErrorBottomSheet(context: context, error: e);rethrow;}}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 13ec779ae0..92c44bf09a 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@@ -1,3 +1,4 @@+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_ui/components/alert_bottom_sheet.dart";@@ -6,15 +7,19 @@ import "package:ente_ui/components/captioned_text_widget_v2.dart";import "package:ente_ui/components/divider_widget.dart";import "package:ente_ui/components/menu_item_widget_v2.dart";import "package:ente_ui/theme/ente_theme.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/l10n/l10n.dart";+import "package:locker/services/collections/collections_service.dart";import "package:locker/services/collections/models/collection.dart";+import "package:locker/services/collections/models/public_url.dart";import "package:locker/services/configuration.dart";import "package:locker/ui/components/gradient_button.dart";import "package:locker/ui/components/popup_menu_item_widget.dart";import "package:locker/ui/sharing/add_email_bottom_sheet.dart";+import "package:locker/ui/sharing/manage_links_widget.dart";import "package:locker/utils/collection_actions.dart";Future<void> showShareCollectionSheet(@@ -23,7 +28,7 @@ Future<void> showShareCollectionSheet(}) {return showBaseBottomSheet<void>(context,- title: context.l10n.sharedWith,+ title: context.l10n.shareCollection,headerSpacing: 20,child: ShareCollectionSheet(collection: collection),);@@ -68,36 +73,36 @@ class _ShareCollectionSheetState extends State<ShareCollectionSheet> {Widget build(BuildContext context) {final colorScheme = getEnteColorScheme(context);final textTheme = getEnteTextTheme(context);+ final shouldShowSharedWithLabel = !_isOwner || _sharees.isNotEmpty;return Column(mainAxisSize: MainAxisSize.min,crossAxisAlignment: CrossAxisAlignment.start,children: [- _buildShareesList(colorScheme, textTheme),if (_isOwner) ...[+ _buildOwnerActions(colorScheme, textTheme),const SizedBox(height: 20),- SizedBox(- width: double.infinity,- child: GradientButton(- text: context.l10n.addEmail,- onTap: () async {- await showAddEmailSheet(- context,- collection: widget.collection,- onShareAdded: () {- if (mounted) {- setState(() {});- }- },- );- },- ),+ ],+ if (shouldShowSharedWithLabel) ...[+ Text(+ context.l10n.sharedWith,+ style: textTheme.small.copyWith(color: colorScheme.textMuted),),+ const SizedBox(height: 8),],+ _buildShareesList(colorScheme, textTheme),],);}+ bool get _hasPublicLink => widget.collection.publicURLs.isNotEmpty;++ bool get _hasActivePublicLink =>+ _hasPublicLink && !(_publicUrl?.isExpired ?? false);++ PublicURL? get _publicUrl =>+ _hasPublicLink ? widget.collection.publicURLs.first : null;+Widget _buildShareesList(colorScheme, textTheme) {final currentUserId = Configuration.instance.getUserID() ?? -1;@@ -112,10 +117,7 @@ class _ShareCollectionSheetState extends State<ShareCollectionSheet> {allUsers.addAll(_sharees);if (allUsers.isEmpty) {- return Text(- context.l10n.noSharedUsers,- style: textTheme.small.copyWith(color: colorScheme.textMuted),- );+ return const SizedBox.shrink();}const double maxVisibleHeight = 244.0;@@ -186,6 +188,56 @@ class _ShareCollectionSheetState extends State<ShareCollectionSheet> {);}+ Widget _buildOwnerActions(colorScheme, textTheme) {+ return Row(+ children: [+ _ShareActionOption(+ icon: HugeIcons.strokeRoundedAdd01,+ label: context.l10n.addEmail,+ onTap: () async {+ await showAddEmailSheet(+ context,+ collection: widget.collection,+ onShareAdded: () {},+ );+ },+ ),+ const SizedBox(width: 16),+ _ShareActionOption(+ icon: HugeIcons.strokeRoundedLink02,+ label: _hasActivePublicLink+ ? context.l10n.manageLink+ : context.l10n.linkLabel,+ onTap: () async {+ if (!_hasActivePublicLink) {+ await _createAndSharePublicLink();+ return;+ }++ await routeToPage(+ context,+ ManageSharedLinkWidget(collection: widget.collection),+ );+ },+ ),+ ],+ );+ }++ Future<void> _createAndSharePublicLink() async {+ final result = await CollectionActions.enableUrl(+ context,+ widget.collection,+ );+ if (result && mounted) {+ setState(() {});+ if (_hasActivePublicLink) {+ final url = CollectionService.instance.getPublicUrl(widget.collection);+ await shareText(url, context: context);+ }+ }+ }+Widget _buildCustomScrollbar(int itemCount,double containerHeight,@@ -421,3 +473,54 @@ class _ShareCollectionSheetState extends State<ShareCollectionSheet> {}}}++class _ShareActionOption extends StatelessWidget {+ final List<List<dynamic>> icon;+ final String label;+ final Future<void> Function() onTap;++ const _ShareActionOption({+ required this.icon,+ required this.label,+ required this.onTap,+ });++ @override+ Widget build(BuildContext context) {+ final colorScheme = getEnteColorScheme(context);+ final textTheme = getEnteTextTheme(context);++ return Expanded(+ child: GestureDetector(+ behavior: HitTestBehavior.opaque,+ onTap: () async {+ await onTap();+ },+ child: Container(+ decoration: BoxDecoration(+ color: colorScheme.fillFaint,+ borderRadius: BorderRadius.circular(16),+ ),+ padding: const EdgeInsets.symmetric(vertical: 16),+ child: Column(+ mainAxisSize: MainAxisSize.min,+ mainAxisAlignment: MainAxisAlignment.center,+ children: [+ HugeIcon(+ icon: icon,+ color: colorScheme.textBase,+ size: 24,+ ),+ const SizedBox(height: 8),+ Text(+ label,+ textAlign: TextAlign.center,+ style: textTheme.small.copyWith(color: colorScheme.textBase),+ ),+ ],+ ),+ ),+ ),+ );+ }+}diff --git a/mobile/apps/locker/lib/ui/sharing/share_collection_page.dart b/mobile/apps/locker/lib/ui/sharing/share_collection_page.dartdeleted file mode 100644index 4a2210382a..0000000000--- a/mobile/apps/locker/lib/ui/sharing/share_collection_page.dart+++ /dev/null@@ -1,406 +0,0 @@-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_ui/components/captioned_text_widget.dart";-import "package:ente_ui/components/divider_widget.dart";-import "package:ente_ui/components/menu_item_widget.dart";-import "package:ente_ui/components/menu_section_description_widget.dart";-import "package:ente_ui/components/menu_section_title.dart";-import "package:ente_ui/theme/colors.dart";-import "package:ente_ui/theme/ente_theme.dart";-import "package:ente_ui/utils/toast_util.dart";-import "package:ente_utils/ente_utils.dart";-import "package:flutter/material.dart";-import "package:flutter/services.dart";-import "package:locker/extensions/collection_extension.dart";-import "package:locker/extensions/user_extension.dart";-import "package:locker/l10n/l10n.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/sharing/add_participant_page.dart";-import "package:locker/ui/sharing/album_participants_page.dart";-import "package:locker/ui/sharing/album_share_info_widget.dart";-import "package:locker/ui/sharing/manage_album_participant.dart";-import "package:locker/ui/sharing/manage_links_widget.dart";-import "package:locker/utils/collection_actions.dart";--class ShareCollectionPage extends StatefulWidget {- final Collection collection;- const ShareCollectionPage({super.key, required this.collection});-- @override- State<ShareCollectionPage> createState() => _ShareCollectionPageState();-}--class _ShareCollectionPageState extends State<ShareCollectionPage> {- late List<User?> _sharees;-- Future<void> _navigateToManageUser() async {- if (_sharees.length == 1) {- await routeToPage(- context,- ManageIndividualParticipant(- collection: widget.collection,- user: _sharees.first!,- ),- );- } else {- await routeToPage(- context,- AlbumParticipantsPage(widget.collection),- );- }- if (mounted) {- setState(() => {});- }- }-- @override- Widget build(BuildContext context) {- final bool hasUrl = widget.collection.hasLink;- final bool hasExpired =- widget.collection.publicURLs.firstOrNull?.isExpired ?? false;- _sharees = widget.collection.sharees;-- final children = <Widget>[];-- children.add(- MenuSectionTitle(- title: context.l10n.shareWithPeopleSectionTitle(_sharees.length),- iconData: Icons.workspaces,- ),- );-- children.add(- EmailItemWidget(- widget.collection,- onTap: _navigateToManageUser,- ),- );-- children.add(- MenuItemWidget(- captionedTextWidget: CaptionedTextWidget(- title: context.l10n.addViewer,- makeTextBold: true,- ),- leadingIcon: Icons.add,- menuItemColor: getEnteColorScheme(context).fillFaint,- isTopBorderRadiusRemoved: _sharees.isNotEmpty,- isBottomBorderRadiusRemoved: true,- onTap: () async {- // ignore: unawaited_futures- routeToPage(- context,- AddParticipantPage(- [widget.collection],- const [ActionTypesToShow.addViewer],- ),- ).then(- (value) => {- if (mounted) {setState(() => {})},- },- );- },- ),- );- children.add(- DividerWidget(- dividerType: DividerType.menu,- bgColor: getEnteColorScheme(context).fillFaint,- ),- );-- children.add(- MenuItemWidget(- captionedTextWidget: CaptionedTextWidget(- title: context.l10n.addCollaborator,- makeTextBold: true,- ),- leadingIcon: Icons.add,- menuItemColor: getEnteColorScheme(context).fillFaint,- isTopBorderRadiusRemoved: true,- onTap: () async {- // ignore: unawaited_futures- routeToPage(- context,- AddParticipantPage(- [widget.collection],- const [ActionTypesToShow.addCollaborator],- ),- ).then(- (value) => {- if (mounted) {setState(() => {})},- },- );- },- ),- );-- if (_sharees.isEmpty && !hasUrl) {- children.add(- MenuSectionDescriptionWidget(- content: context.l10n.sharedCollectionSectionDescription,- ),- );- }-- children.addAll([- const SizedBox(- height: 24,- ),- MenuSectionTitle(- title:- hasUrl ? context.l10n.publicLinkEnabled : context.l10n.shareALink,- iconData: Icons.public,- ),- ]);- if (hasUrl) {- if (hasExpired) {- children.add(- MenuItemWidget(- captionedTextWidget: CaptionedTextWidget(- title: context.l10n.linkHasExpired,- textColor: getEnteColorScheme(context).warning500,- ),- leadingIcon: Icons.error_outline,- leadingIconColor: getEnteColorScheme(context).warning500,- menuItemColor: getEnteColorScheme(context).fillFaint,- isBottomBorderRadiusRemoved: true,- ),- );- } else {- final String url =- CollectionService.instance.getPublicUrl(widget.collection);- children.addAll(- [- MenuItemWidget(- captionedTextWidget: CaptionedTextWidget(- title: context.l10n.copyLink,- makeTextBold: true,- ),- leadingIcon: Icons.copy,- menuItemColor: getEnteColorScheme(context).fillFaint,- showOnlyLoadingState: true,- onTap: () async {- await Clipboard.setData(ClipboardData(text: url));- showShortToast(context, context.l10n.linkCopiedToClipboard);- },- isBottomBorderRadiusRemoved: true,- ),- DividerWidget(- dividerType: DividerType.menu,- bgColor: getEnteColorScheme(context).fillFaint,- ),- MenuItemWidget(- captionedTextWidget: CaptionedTextWidget(- title: context.l10n.sendLink,- makeTextBold: true,- ),- leadingIcon: Icons.adaptive.share,- menuItemColor: getEnteColorScheme(context).fillFaint,- onTap: () async {- // ignore: unawaited_futures- await shareText(- url,- context: context,- );- },- isTopBorderRadiusRemoved: true,- isBottomBorderRadiusRemoved: true,- ),- ],- );- }-- children.addAll(- [- DividerWidget(- dividerType: DividerType.menu,- bgColor: getEnteColorScheme(context).fillFaint,- ),- MenuItemWidget(- captionedTextWidget: CaptionedTextWidget(- title: context.l10n.manageLink,- makeTextBold: true,- ),- leadingIcon: Icons.link,- trailingIcon: Icons.navigate_next,- menuItemColor: getEnteColorScheme(context).fillFaint,- trailingIconIsMuted: true,- onTap: () async {- // ignore: unawaited_futures- routeToPage(- context,- ManageSharedLinkWidget(collection: widget.collection),- ).then(- (value) => {- if (mounted) {setState(() => {})},- },- );- },- isTopBorderRadiusRemoved: true,- ),- const SizedBox(height: 24),- MenuItemWidget(- captionedTextWidget: CaptionedTextWidget(- title: context.l10n.removeLink,- textColor: warning500,- makeTextBold: true,- ),- leadingIcon: Icons.remove_circle_outline,- leadingIconColor: warning500,- menuItemColor: getEnteColorScheme(context).fillFaint,- surfaceExecutionStates: false,- onTap: () async {- final bool result = await CollectionActions.disableUrl(- context,- widget.collection,- );- if (result && mounted) {- Navigator.of(context).pop();- if (widget.collection.isQuickLinkCollection()) {- Navigator.of(context).pop();- }- }- },- ),- ],- );- } else {- children.addAll(- [- MenuItemWidget(- captionedTextWidget: CaptionedTextWidget(- title: context.l10n.createPublicLink,- makeTextBold: true,- ),- leadingIcon: Icons.link,- menuItemColor: getEnteColorScheme(context).fillFaint,- showOnlyLoadingState: true,- onTap: () async {- final bool result =- await CollectionActions.enableUrl(context, widget.collection);- if (result && mounted) {- setState(() => {});- }- },- ),- ],- );- }- return Scaffold(- appBar: AppBar(- title: Text(- widget.collection.displayName ?? context.l10n.collectionLabel,- style:- Theme.of(context).textTheme.headlineSmall?.copyWith(fontSize: 16),- ),- elevation: 0,- centerTitle: false,- ),- body: SingleChildScrollView(- child: ListBody(- children: <Widget>[- Padding(- padding:- const EdgeInsets.symmetric(vertical: 4.0, horizontal: 16),- child: Column(- crossAxisAlignment: CrossAxisAlignment.start,- children: children,- ),- ),- ],- ),- ),- );- }-}--class EmailItemWidget extends StatelessWidget {- final Collection collection;- final Function? onTap;-- const EmailItemWidget(- this.collection, {- this.onTap,- super.key,- });-- @override- Widget build(BuildContext context) {- if (collection.getSharees().isEmpty) {- return const SizedBox.shrink();- } else if (collection.getSharees().length == 1) {- final User? user = collection.getSharees().firstOrNull;- return Column(- mainAxisAlignment: MainAxisAlignment.start,- children: [- MenuItemWidget(- captionedTextWidget: CaptionedTextWidget(- title: user?.displayName ?? user?.email ?? '',- ),- leadingIconWidget: UserAvatarWidget(- collection.getSharees().first,- thumbnailView: false,- config: Configuration.instance,- ),- leadingIconSize: 24,- menuItemColor: getEnteColorScheme(context).fillFaint,- trailingIconIsMuted: true,- trailingIcon: Icons.chevron_right,- onTap: () async {- if (onTap != null) {- onTap!();- }- },- isBottomBorderRadiusRemoved: true,- ),- DividerWidget(- dividerType: DividerType.menu,- bgColor: getEnteColorScheme(context).fillFaint,- ),- ],- );- } else {- return Column(- mainAxisAlignment: MainAxisAlignment.start,- children: [- MenuItemWidget(- captionedTextWidget: Flexible(- child: Padding(- padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 0),- child: SizedBox(- height: 24,- child: AlbumSharesIcons(- sharees: collection.getSharees(),- padding: const EdgeInsets.all(0),- limitCountTo: 10,- type: AvatarType.mini,- removeBorder: false,- ),- ),- ),- ),- alignCaptionedTextToLeft: true,- // leadingIcon: Icons.people_outline,- menuItemColor: getEnteColorScheme(context).fillFaint,- trailingIconIsMuted: true,- trailingIcon: Icons.chevron_right,- onTap: () async {- if (onTap != null) {- onTap!();- }- },- isBottomBorderRadiusRemoved: true,- ),- DividerWidget(- dividerType: DividerType.menu,- bgColor: getEnteColorScheme(context).fillFaint,- ),- ],- );- }- }-}diff --git a/mobile/apps/locker/lib/utils/collection_actions.dart b/mobile/apps/locker/lib/utils/collection_actions.dartindex c9c809819b..4a1d948c83 100644--- a/mobile/apps/locker/lib/utils/collection_actions.dart+++ b/mobile/apps/locker/lib/utils/collection_actions.dart@@ -4,11 +4,10 @@ import "package:ente_accounts/services/user_service.dart";import "package:ente_pure_utils/ente_pure_utils.dart";import "package:ente_sharing/components/invite_dialog.dart";import "package:ente_sharing/models/user.dart";-import "package:ente_ui/components/action_sheet_widget.dart";import "package:ente_ui/components/alert_bottom_sheet.dart";-import 'package:ente_ui/components/buttons/button_widget.dart';-import 'package:ente_ui/components/buttons/models/button_type.dart';+import "package:ente_ui/components/buttons/button_widget.dart";import "package:ente_ui/components/progress_dialog.dart";+import "package:ente_ui/theme/ente_theme.dart";import 'package:ente_ui/utils/dialog_util.dart';import "package:ente_ui/utils/toast_util.dart";import 'package:flutter/material.dart';@@ -440,41 +439,36 @@ class CollectionActions {BuildContext context,Collection collection,) async {- final actionResult = await showActionSheet(- context: context,+ final colorScheme = getEnteColorScheme(context);+ final shouldRemove = await showAlertBottomSheet<bool>(+ context,+ title: context.l10n.removePublicLink,+ message: context.l10n+ .removePublicLinkConfirmation(collection.name ?? "this collection"),+ assetPath: "assets/warning-grey.png",buttons: [- ButtonWidget(- buttonType: ButtonType.critical,- isInAlert: true,- shouldStickToDarkTheme: true,- buttonAction: ButtonAction.first,- shouldSurfaceExecutionStates: true,- labelText: context.l10n.yesRemove,- onTap: () async {- await CollectionApiClient.instance.disableShareUrl(collection);- },- ),- ButtonWidget(- buttonType: ButtonType.secondary,- buttonAction: ButtonAction.cancel,- isInAlert: true,- shouldStickToDarkTheme: true,- labelText: context.l10n.cancel,+ GradientButton(+ text: context.l10n.yesRemove,+ backgroundColor: colorScheme.warning400,+ onTap: () => Navigator.of(context).pop(true),),],- title: context.l10n.removePublicLink,- body: context.l10n- .removePublicLinkConfirmation(collection.name ?? "this collection"),);- if (actionResult?.action != null) {- if (actionResult!.action == ButtonAction.error) {++ if (shouldRemove != true) {+ return false;+ }++ try {+ await CollectionApiClient.instance.disableShareUrl(collection);+ return true;+ } catch (e) {+ if (context.mounted) {await showGenericErrorDialog(context: context,- error: actionResult.exception,+ error: e,);}- return actionResult.action == ButtonAction.first;- } else {return false;}}