Skip to content

armgit / ente

Public Imported from GitHub
0

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

Sharing collection: wip 1

AmanRajSinghMourya6ef9ff7c8821
diff --git a/mobile/apps/locker/lib/ui/pages/collection_page.dart b/mobile/apps/locker/lib/ui/pages/collection_page.dart
index b16164483f..c6c544e534 100644
--- a/mobile/apps/locker/lib/ui/pages/collection_page.dart
+++ b/mobile/apps/locker/lib/ui/pages/collection_page.dart
@@ -269,6 +269,35 @@ class _CollectionPageState extends UploaderPageState<CollectionPage>
);
}
+ Widget _buildShareButton(EnteColorScheme colorScheme) {
+ if (isFavorite) {
+ return const SizedBox.shrink();
+ }
+ final canShare = collectionViewType == CollectionViewType.ownedCollection ||
+ collectionViewType == CollectionViewType.sharedCollection ||
+ collectionViewType == CollectionViewType.hiddenOwnedCollection ||
+ isQuickLink;
+ if (!canShare) {
+ return const SizedBox.shrink();
+ }
+ return GestureDetector(
+ onTap: _shareCollection,
+ child: Container(
+ height: 48,
+ width: 48,
+ decoration: BoxDecoration(
+ borderRadius: BorderRadius.circular(12),
+ color: colorScheme.backdropBase,
+ ),
+ padding: const EdgeInsets.all(12),
+ child: HugeIcon(
+ icon: HugeIcons.strokeRoundedShare08,
+ color: colorScheme.textBase,
+ ),
+ ),
+ );
+ }
+
Widget _buildMenuButton(EnteColorScheme colorScheme) {
if (isFavorite) {
return SizedBox.fromSize();
@@ -412,6 +441,8 @@ class _CollectionPageState extends UploaderPageState<CollectionPage>
trailingWidgets: widget.isUncategorized
? const []
: [
+ _buildShareButton(colorScheme),
+ const SizedBox(width: 12),
_buildMenuButton(colorScheme),
],
),
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.dart
new file mode 100644
index 0000000000..53e1bcb08f
--- /dev/null
+++ b/mobile/apps/locker/lib/ui/sharing/add_email_bottom_sheet.dart
@@ -0,0 +1,618 @@
+import "package:ente_accounts/services/user_service.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/theme/ente_theme.dart";
+import "package:flutter/material.dart";
+import "package:hugeicons/hugeicons.dart";
+import "package:intl/intl.dart";
+import "package:locker/l10n/l10n.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/components/popup_menu_item_widget.dart";
+import "package:locker/ui/viewer/date/date_time_picker.dart";
+import "package:locker/utils/collection_actions.dart";
+
+class AddEmailBottomSheet extends StatefulWidget {
+ final Collection collection;
+ final VoidCallback onShareAdded;
+
+ const AddEmailBottomSheet({
+ super.key,
+ required this.collection,
+ required this.onShareAdded,
+ });
+
+ @override
+ State<AddEmailBottomSheet> createState() => _AddEmailBottomSheetState();
+}
+
+class _AddEmailBottomSheetState extends State<AddEmailBottomSheet> {
+ bool _shareLater = false;
+ String _email = "";
+ bool _emailIsValid = false;
+ DateTime? _scheduledDate;
+ TimeOfDay? _scheduledTime;
+ CollectionParticipantRole _selectedRole = CollectionParticipantRole.viewer;
+
+ final _textController = TextEditingController();
+ final _textFieldFocusNode = FocusNode();
+ final _scrollController = ScrollController();
+
+ late CollectionActions _collectionActions;
+ late List<User> _suggestedUsers;
+
+ @override
+ void initState() {
+ super.initState();
+ _collectionActions = CollectionActions();
+ _suggestedUsers = _getSuggestedUsers();
+ }
+
+ @override
+ void dispose() {
+ _textController.dispose();
+ _textFieldFocusNode.dispose();
+ _scrollController.dispose();
+ super.dispose();
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ final colorScheme = getEnteColorScheme(context);
+ final textTheme = getEnteTextTheme(context);
+ final bottomInset = MediaQuery.of(context).viewInsets.bottom;
+
+ return Container(
+ decoration: BoxDecoration(
+ color: colorScheme.backgroundElevated2,
+ borderRadius: const BorderRadius.only(
+ topLeft: Radius.circular(24),
+ topRight: Radius.circular(24),
+ ),
+ ),
+ child: Padding(
+ padding: EdgeInsets.only(bottom: bottomInset),
+ child: SafeArea(
+ top: false,
+ child: Padding(
+ padding: const EdgeInsets.all(16),
+ child: SingleChildScrollView(
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ _buildHeader(colorScheme, textTheme),
+ const SizedBox(height: 20),
+ _buildEmailInputField(colorScheme, textTheme),
+ if (_suggestedUsers.isNotEmpty) ...[
+ const SizedBox(height: 20),
+ _buildExistingContactsSection(colorScheme, textTheme),
+ ],
+ const SizedBox(height: 20),
+ _buildShareLaterCheckbox(colorScheme, textTheme),
+ if (_shareLater) ...[
+ const SizedBox(height: 12),
+ _buildScheduleDateTimeRow(colorScheme, textTheme),
+ ],
+ const SizedBox(height: 20),
+ _buildShareButton(),
+ ],
+ ),
+ ),
+ ),
+ ),
+ ),
+ );
+ }
+
+ Widget _buildHeader(colorScheme, textTheme) {
+ return Row(
+ mainAxisAlignment: MainAxisAlignment.spaceBetween,
+ children: [
+ Text(
+ context.l10n.addNewEmail,
+ style: textTheme.largeBold,
+ ),
+ GestureDetector(
+ onTap: () => Navigator.of(context).pop(),
+ child: Container(
+ padding: const EdgeInsets.all(8),
+ decoration: BoxDecoration(
+ color: colorScheme.fillFaint,
+ shape: BoxShape.circle,
+ ),
+ child: Icon(
+ Icons.close,
+ size: 20,
+ color: colorScheme.textBase,
+ ),
+ ),
+ ),
+ ],
+ );
+ }
+
+ Widget _buildEmailInputField(colorScheme, textTheme) {
+ return Container(
+ decoration: BoxDecoration(
+ color: colorScheme.fillFaint,
+ borderRadius: BorderRadius.circular(8),
+ ),
+ child: Row(
+ children: [
+ Expanded(
+ child: TextFormField(
+ controller: _textController,
+ focusNode: _textFieldFocusNode,
+ autofillHints: const [AutofillHints.email],
+ decoration: InputDecoration(
+ fillColor: Colors.transparent,
+ filled: true,
+ hintText: context.l10n.enterNameOrEmailToShareWith,
+ hintStyle: textTheme.small.copyWith(
+ color: colorScheme.textMuted,
+ ),
+ contentPadding: const EdgeInsets.symmetric(
+ horizontal: 16,
+ vertical: 12,
+ ),
+ border: InputBorder.none,
+ ),
+ onChanged: (value) {
+ _email = value.trim();
+ _emailIsValid = _isValidEmail(_email);
+ setState(() {});
+ },
+ autocorrect: false,
+ keyboardType: TextInputType.emailAddress,
+ textInputAction: TextInputAction.done,
+ ),
+ ),
+ _buildRoleDropdown(colorScheme, textTheme),
+ const SizedBox(width: 8),
+ ],
+ ),
+ );
+ }
+
+ Widget _buildRoleDropdown(colorScheme, textTheme) {
+ return PopupMenuButton<CollectionParticipantRole>(
+ onSelected: (role) {
+ setState(() {
+ _selectedRole = role;
+ });
+ },
+ shape: RoundedRectangleBorder(
+ borderRadius: BorderRadius.circular(12),
+ ),
+ padding: EdgeInsets.zero,
+ menuPadding: EdgeInsets.zero,
+ color: Colors.transparent,
+ child: Container(
+ decoration: BoxDecoration(
+ borderRadius: BorderRadius.circular(10),
+ color: colorScheme.backdropBase,
+ ),
+ child: Padding(
+ padding: const EdgeInsets.all(8),
+ child: Row(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ HugeIcon(
+ icon: _selectedRole == CollectionParticipantRole.viewer
+ ? HugeIcons.strokeRoundedView
+ : HugeIcons.strokeRoundedUserGroup,
+ color: colorScheme.textMuted,
+ size: 20,
+ ),
+ const SizedBox(width: 4),
+ HugeIcon(
+ icon: HugeIcons.strokeRoundedArrowDown01,
+ color: colorScheme.textMuted,
+ size: 20,
+ ),
+ ],
+ ),
+ ),
+ ),
+ itemBuilder: (context) => [
+ PopupMenuItem<CollectionParticipantRole>(
+ value: CollectionParticipantRole.viewer,
+ height: 0,
+ padding: EdgeInsets.zero,
+ child: PopupMenuItemWidget(
+ icon: HugeIcon(
+ icon: HugeIcons.strokeRoundedView,
+ color: colorScheme.textBase,
+ size: 20,
+ ),
+ label: context.l10n.viewer,
+ isFirst: true,
+ isLast: false,
+ ),
+ ),
+ PopupMenuItem<CollectionParticipantRole>(
+ value: CollectionParticipantRole.collaborator,
+ height: 0,
+ padding: EdgeInsets.zero,
+ child: PopupMenuItemWidget(
+ icon: HugeIcon(
+ icon: HugeIcons.strokeRoundedUserGroup,
+ color: colorScheme.textBase,
+ size: 20,
+ ),
+ label: context.l10n.collaborator,
+ isFirst: false,
+ isLast: true,
+ ),
+ ),
+ ],
+ );
+ }
+
+ Widget _buildExistingContactsSection(colorScheme, textTheme) {
+ final filteredUsers = _suggestedUsers
+ .where(
+ (user) => user.email
+ .toLowerCase()
+ .contains(_textController.text.trim().toLowerCase()),
+ )
+ .toList();
+
+ if (filteredUsers.isEmpty) {
+ return const SizedBox.shrink();
+ }
+
+ const double maxVisibleHeight = 121.0;
+ final showScrollbar = filteredUsers.length > 2;
+
+ return Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Text(
+ context.l10n.chooseFromAnExistingContact,
+ style: textTheme.small.copyWith(color: colorScheme.textMuted),
+ ),
+ const SizedBox(height: 8),
+ Row(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Expanded(
+ child: Container(
+ constraints: const BoxConstraints(maxHeight: maxVisibleHeight),
+ child: ListView.separated(
+ controller: _scrollController,
+ shrinkWrap: true,
+ padding: EdgeInsets.zero,
+ itemCount: filteredUsers.length,
+ separatorBuilder: (context, index) => DividerWidget(
+ dividerType: DividerType.menu,
+ bgColor: colorScheme.fillFaint,
+ ),
+ itemBuilder: (context, index) {
+ final user = filteredUsers[index];
+ final isFirst = index == 0;
+ final isLast = index == filteredUsers.length - 1;
+ return MenuItemWidget(
+ captionedTextWidget: CaptionedTextWidget(
+ title: user.email,
+ ),
+ leadingIconSize: 24.0,
+ leadingIconWidget: UserAvatarWidget(
+ user,
+ type: AvatarType.mini,
+ config: Configuration.instance,
+ ),
+ menuItemColor: colorScheme.fillFaint,
+ surfaceExecutionStates: false,
+ onTap: () async {
+ _textFieldFocusNode.unfocus();
+ _textController.text = user.email;
+ _email = user.email;
+ _emailIsValid = true;
+ setState(() {});
+ },
+ isTopBorderRadiusRemoved: !isFirst,
+ isBottomBorderRadiusRemoved: !isLast,
+ singleBorderRadius: 20,
+ );
+ },
+ ),
+ ),
+ ),
+ if (showScrollbar) ...[
+ const SizedBox(width: 4),
+ _buildCustomScrollbar(
+ filteredUsers.length,
+ maxVisibleHeight,
+ colorScheme,
+ ),
+ ],
+ ],
+ ),
+ ],
+ );
+ }
+
+ Widget _buildCustomScrollbar(
+ int itemCount,
+ double containerHeight,
+ colorScheme,
+ ) {
+ const visibleItems = 2;
+ final thumbHeightRatio = visibleItems / itemCount;
+ final thumbHeight = containerHeight * thumbHeightRatio;
+
+ return AnimatedBuilder(
+ animation: _scrollController,
+ builder: (context, child) {
+ double thumbPosition = 0;
+ if (_scrollController.hasClients) {
+ final maxExtent = _scrollController.position.hasContentDimensions
+ ? _scrollController.position.maxScrollExtent
+ : 0.0;
+ if (maxExtent > 0) {
+ final scrollFraction = _scrollController.offset / maxExtent;
+ thumbPosition = scrollFraction * (containerHeight - thumbHeight);
+ }
+ }
+
+ return SizedBox(
+ height: containerHeight,
+ width: 5,
+ child: Stack(
+ children: [
+ Container(
+ width: 5,
+ height: containerHeight,
+ decoration: BoxDecoration(
+ color: colorScheme.strokeFaint,
+ borderRadius: BorderRadius.circular(3),
+ ),
+ ),
+ Positioned(
+ top: thumbPosition,
+ child: Container(
+ width: 5,
+ height: thumbHeight,
+ decoration: BoxDecoration(
+ color: colorScheme.strokeMuted,
+ borderRadius: BorderRadius.circular(3),
+ ),
+ ),
+ ),
+ ],
+ ),
+ );
+ },
+ );
+ }
+
+ Widget _buildShareLaterCheckbox(colorScheme, textTheme) {
+ return GestureDetector(
+ onTap: () {
+ setState(() {
+ _shareLater = !_shareLater;
+ if (!_shareLater) {
+ _scheduledDate = null;
+ _scheduledTime = null;
+ }
+ });
+ },
+ child: Row(
+ children: [
+ Container(
+ width: 20,
+ height: 20,
+ decoration: BoxDecoration(
+ color: _shareLater ? colorScheme.primary500 : Colors.transparent,
+ borderRadius: BorderRadius.circular(4),
+ border: Border.all(
+ color: _shareLater
+ ? colorScheme.primary500
+ : colorScheme.strokeMuted,
+ width: 1.5,
+ ),
+ ),
+ child: _shareLater
+ ? const Icon(
+ Icons.check,
+ size: 14,
+ color: Colors.white,
+ )
+ : null,
+ ),
+ const SizedBox(width: 8),
+ Text(
+ context.l10n.shareLater,
+ style: textTheme.body,
+ ),
+ ],
+ ),
+ );
+ }
+
+ 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,
+ ),
+ );
+ }
+
+ Future<void> _onShareTap() async {
+ final success = await _collectionActions.addEmailToCollection(
+ context,
+ widget.collection,
+ _email,
+ _selectedRole,
+ showProgress: true,
+ );
+
+ if (success) {
+ widget.onShareAdded();
+ if (mounted) {
+ Navigator.of(context).pop();
+ }
+ }
+ }
+
+ List<User> _getSuggestedUsers() {
+ final List<User> suggestedUsers = [];
+ final Set<String> existingEmails = {};
+
+ existingEmails.add(Configuration.instance.getEmail() ?? "");
+
+ for (final sharee in widget.collection.sharees) {
+ existingEmails.add(sharee.email);
+ }
+
+ final cachedUserDetails = UserService.instance.getCachedUserDetails();
+ if (cachedUserDetails != null &&
+ (cachedUserDetails.familyData?.members?.isNotEmpty ?? false)) {
+ for (final member in cachedUserDetails.familyData!.members!) {
+ if (!existingEmails.contains(member.email)) {
+ existingEmails.add(member.email);
+ suggestedUsers.add(User(email: member.email));
+ }
+ }
+ }
+
+ suggestedUsers.sort((a, b) => a.email.compareTo(b.email));
+ return suggestedUsers;
+ }
+
+ bool _isValidEmail(String email) {
+ final emailRegex = RegExp(r'^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$');
+ return emailRegex.hasMatch(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/share_collection_bottom_sheet.dart b/mobile/apps/locker/lib/ui/sharing/share_collection_bottom_sheet.dart
index d1cdd84f8c..0a438e45fd 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,33 +1,19 @@
import "package:ente_sharing/models/user.dart";
import "package:ente_sharing/user_avator_widget.dart";
-import "package:ente_ui/components/toggle_switch_widget.dart";
-import "package:ente_ui/theme/colors.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/theme/ente_theme.dart";
-import "package:ente_ui/theme/text_style.dart";
-import "package:ente_ui/utils/dialog_util.dart";
-import "package:ente_ui/utils/toast_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/extensions/user_extension.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/services/configuration.dart";
import "package:locker/ui/components/gradient_button.dart";
-import "package:locker/ui/sharing/advanced_sharing_bottom_sheet.dart";
-import "package:locker/ui/sharing/album_share_info_widget.dart";
+import "package:locker/ui/components/popup_menu_item_widget.dart";
+import "package:locker/ui/sharing/add_email_bottom_sheet.dart";
import "package:locker/utils/collection_actions.dart";
-/// A bottom sheet widget for sharing a collection with others.
-///
-/// This widget provides a clean, modern interface for:
-/// - Viewing and managing sharees (users with access)
-/// - Adding new sharees via email
-/// - Creating and managing public links
-/// - Configuring advanced sharing options
class ShareCollectionBottomSheet extends StatefulWidget {
final Collection collection;
@@ -43,35 +29,21 @@ class ShareCollectionBottomSheet extends StatefulWidget {
class _ShareCollectionBottomSheetState
extends State<ShareCollectionBottomSheet> {
- bool _isShareesExpanded = false;
- final ScrollController _scrollController = ScrollController();
late CollectionActions _collectionActions;
+ List<User> get _sharees => widget.collection.getSharees();
+
+ bool get _isOwner {
+ final currentUserId = Configuration.instance.getUserID();
+ return widget.collection.owner.id == currentUserId;
+ }
+
@override
void initState() {
super.initState();
_collectionActions = CollectionActions();
}
- @override
- void dispose() {
- _scrollController.dispose();
- super.dispose();
- }
-
- List<User> get _sharees => widget.collection.getSharees();
-
- int get _shareeCount => _sharees.length;
-
- bool get _isOwner =>
- widget.collection.owner.id == Configuration.instance.getUserID();
-
- 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);
@@ -79,93 +51,74 @@ class _ShareCollectionBottomSheetState
return Container(
decoration: BoxDecoration(
- color: colorScheme.backdropBase,
+ color: colorScheme.backgroundElevated2,
borderRadius: const BorderRadius.only(
- topLeft: Radius.circular(20),
- topRight: Radius.circular(20),
+ topLeft: Radius.circular(24),
+ topRight: Radius.circular(24),
),
),
child: SafeArea(
- child: ConstrainedBox(
- constraints: BoxConstraints(
- maxHeight: MediaQuery.of(context).size.height * 0.9,
- ),
- child: SingleChildScrollView(
- controller: _scrollController,
- child: Padding(
- padding: const EdgeInsets.symmetric(horizontal: 16),
- child: Column(
- mainAxisSize: MainAxisSize.min,
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- const SizedBox(height: 12),
- _buildHeader(colorScheme, textTheme),
- if (_shareeCount > 0) ...[
- const SizedBox(height: 20),
- _buildShareesCard(colorScheme, textTheme),
- ],
- const SizedBox(height: 12),
- if (_hasPublicLink) ...[
- if (_isOwner) _buildAddEmailButton(),
- if (_isOwner) const SizedBox(height: 24),
- _buildPublicLinkSection(colorScheme, textTheme),
- const SizedBox(height: 12),
- _buildShareLinkButton(),
-
- // Hide Advance Options
- // const SizedBox(height: 24),
- // _buildAdvancedOptionsRow(colorScheme, textTheme),
- // const SizedBox(height: 24),
- ] else ...[
- _buildCompactActionsCard(colorScheme, textTheme),
- ],
- ],
- ),
- ),
+ top: false,
+ child: Padding(
+ padding: const EdgeInsets.all(16),
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ _buildHeader(colorScheme, textTheme),
+ const SizedBox(height: 20),
+ _buildShareesList(colorScheme, textTheme),
+ if (_isOwner) ...[
+ const SizedBox(height: 20),
+ SizedBox(
+ width: double.infinity,
+ child: GradientButton(
+ text: context.l10n.addEmail,
+ onTap: () async {
+ await showModalBottomSheet(
+ context: context,
+ backgroundColor: Colors.transparent,
+ isScrollControlled: true,
+ builder: (context) => AddEmailBottomSheet(
+ collection: widget.collection,
+ onShareAdded: () {
+ if (mounted) {
+ setState(() {});
+ }
+ },
+ ),
+ );
+ },
+ ),
+ ),
+ ],
+ ],
),
),
),
);
}
- Widget _buildHeader(
- EnteColorScheme colorScheme,
- EnteTextTheme textTheme,
- ) {
- final shareText = context.l10n.shareWithPeopleSectionTitle(_shareeCount);
-
+ Widget _buildHeader(colorScheme, textTheme) {
return 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,
- ),
+ Text(
+ context.l10n.sharedWith,
+ style: textTheme.largeBold,
),
GestureDetector(
- onTap: () => Navigator.pop(context),
+ onTap: () => Navigator.of(context).pop(),
child: Container(
- width: 36,
- height: 36,
+ padding: const EdgeInsets.all(8),
decoration: BoxDecoration(
- color: colorScheme.backdropBase,
+ color: colorScheme.fillFaint,
shape: BoxShape.circle,
),
- alignment: Alignment.center,
child: Icon(
Icons.close,
- color: colorScheme.textBase,
size: 20,
+ color: colorScheme.textBase,
),
),
),
@@ -173,714 +126,146 @@ class _ShareCollectionBottomSheetState
);
}
- Widget _buildShareesCard(
- EnteColorScheme colorScheme,
- EnteTextTheme textTheme,
- ) {
- return Container(
- width: double.infinity,
- decoration: BoxDecoration(
- color: colorScheme.backgroundElevated2,
- borderRadius: BorderRadius.circular(24),
- ),
- child: Column(
- mainAxisSize: MainAxisSize.min,
- children: [
- GestureDetector(
- onTap: () {
- setState(() {
- _isShareesExpanded = !_isShareesExpanded;
- });
- },
- child: Container(
- decoration: BoxDecoration(
- borderRadius: BorderRadius.circular(24),
- ),
- padding: const EdgeInsets.symmetric(
- horizontal: 16,
- vertical: 6,
- ),
- child: Row(
- children: [
- Expanded(
- child: _buildShareeAvatarsPreview(
- colorScheme,
- textTheme,
- ),
- ),
- Icon(
- _isShareesExpanded
- ? Icons.keyboard_arrow_up_rounded
- : Icons.keyboard_arrow_down_rounded,
- color: colorScheme.textBase,
- size: 24,
- ),
- ],
- ),
- ),
- ),
- if (_isShareesExpanded) ...[
- ...List.generate(_sharees.length, (index) {
- final user = _sharees[index];
- return _buildShareeItem(
- user,
- colorScheme,
- textTheme,
- isLast: index == _sharees.length - 1,
- );
- }),
- ],
- ],
- ),
- );
- }
-
- Widget _buildShareeAvatarsPreview(
- EnteColorScheme colorScheme,
- EnteTextTheme textTheme,
- ) {
- return SizedBox(
- height: 44,
- child: AlbumSharesIcons(
- sharees: _sharees,
- type: AvatarType.mini,
- limitCountTo: 5,
- removeBorder: false,
- padding: EdgeInsets.zero,
- stackAlignment: Alignment.centerLeft,
- ),
- );
- }
-
- Widget _buildShareeItem(
- User user,
- EnteColorScheme colorScheme,
- EnteTextTheme textTheme, {
- bool isLast = false,
- }) {
- final currentUserId = Configuration.instance.getUserID();
- final isCurrentUser = user.id == currentUserId;
- final isOwnerUser = user.id == widget.collection.owner.id;
-
- Widget trailingIcon;
- if (isOwnerUser) {
- trailingIcon = Icon(
- Icons.admin_panel_settings_outlined,
- size: 20,
- color: colorScheme.textMuted,
- );
- } else if (_isOwner && !isCurrentUser) {
- trailingIcon = PopupMenuButton<String>(
- icon: Icon(
- user.isViewer ? Icons.visibility_outlined : Icons.people_outline,
- size: 20,
- color: colorScheme.textMuted,
- ),
- color: colorScheme.backgroundElevated2,
- shape: RoundedRectangleBorder(
- borderRadius: BorderRadius.circular(12),
- ),
- onSelected: (value) {
- if (value == "toggle_role") {
- _toggleUserRole(user);
- } else if (value == "remove") {
- _removeSharee(user);
- }
- },
- itemBuilder: (context) => [
- PopupMenuItem<String>(
- value: "toggle_role",
- child: Row(
- children: [
- Icon(
- user.isViewer
- ? Icons.people_outline
- : Icons.visibility_outlined,
- color: colorScheme.textBase,
- size: 20,
- ),
- const SizedBox(width: 12),
- Text(
- user.isViewer ? "Set as collaborator" : "Set as viewer",
- style: textTheme.body,
- ),
- ],
- ),
- ),
- PopupMenuItem<String>(
- value: "remove",
- child: Row(
- children: [
- Icon(
- Icons.delete_outline,
- color: colorScheme.warning500,
- size: 20,
- ),
- const SizedBox(width: 12),
- Text(
- "Remove from shared",
- style: textTheme.body.copyWith(
- color: colorScheme.warning500,
- ),
- ),
- ],
- ),
- ),
- ],
- );
- } else {
- trailingIcon = Icon(
- user.isViewer ? Icons.visibility_outlined : Icons.people_outline,
- size: 20,
- color: colorScheme.textMuted,
+ Widget _buildShareesList(colorScheme, textTheme) {
+ if (_sharees.isEmpty) {
+ return Text(
+ context.l10n.noSharedUsers,
+ style: textTheme.small.copyWith(color: colorScheme.textMuted),
);
}
- return Container(
- width: double.infinity,
- decoration: isLast
- ? null
- : BoxDecoration(
- border: Border(
- bottom: BorderSide(
- color: colorScheme.strokeFaint,
- width: 0.5,
- ),
- ),
- ),
- child: Padding(
- padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 6),
- child: Row(
- children: [
- UserAvatarWidget(
- user,
- currentUserID: currentUserId!,
- config: Configuration.instance,
- type: AvatarType.mini,
- ),
- const SizedBox(width: 12),
- Text(
- _displayName(user),
- style: textTheme.body.copyWith(
- color: colorScheme.textBase,
- fontSize: 15,
- ),
- overflow: TextOverflow.ellipsis,
- ),
- const Spacer(),
- trailingIcon,
- ],
- ),
- ),
- );
- }
+ final currentUserId = Configuration.instance.getUserID() ?? -1;
- Widget _buildCompactActionsCard(
- EnteColorScheme colorScheme,
- EnteTextTheme textTheme,
- ) {
- final bool canManage = _isOwner;
- final l10n = context.l10n;
- final shareLabel = _hasPublicLink ? l10n.sendLink : l10n.shareALink;
-
- return Container(
- decoration: BoxDecoration(
- color: colorScheme.backgroundElevated2,
- borderRadius: BorderRadius.circular(20),
- ),
- child: Column(
- mainAxisSize: MainAxisSize.min,
- children: [
- _buildCompactActionRow(
- colorScheme,
- textTheme,
- title: l10n.addANewEmail,
- icon: Icons.open_in_new_rounded,
- enabled: canManage,
- textColor: canManage ? colorScheme.textBase : colorScheme.textMuted,
- iconColor: canManage ? colorScheme.textBase : colorScheme.textMuted,
- onTap: canManage
- ? () async {
- await _showAddEmailDialog();
- }
- : null,
- ),
- Divider(
- height: 1,
- color: colorScheme.strokeFaint,
- ),
- _buildCompactActionRow(
- colorScheme,
- textTheme,
- title: shareLabel,
- icon: Icons.link,
- enabled: canManage || _hasPublicLink,
- textColor: (canManage || _hasPublicLink)
- ? colorScheme.primary700
- : colorScheme.textMuted,
- iconColor: (canManage || _hasPublicLink)
- ? colorScheme.primary700
- : colorScheme.textMuted,
- onTap: (canManage || _hasPublicLink)
- ? () async {
- await _handleShareLinkTap();
- }
- : null,
- ),
- ],
- ),
- );
- }
-
- Widget _buildCompactActionRow(
- EnteColorScheme colorScheme,
- EnteTextTheme textTheme, {
- required String title,
- required IconData icon,
- required bool enabled,
- Color? textColor,
- Color? iconColor,
- VoidCallback? onTap,
- }) {
- final Color effectiveTextColor =
- textColor ?? (enabled ? colorScheme.textBase : colorScheme.textMuted);
- final Color effectiveIconColor =
- iconColor ?? (enabled ? colorScheme.textBase : colorScheme.textMuted);
+ return Column(
+ children: List.generate(_sharees.length, (index) {
+ final user = _sharees[index];
+ final isFirst = index == 0;
+ final isLast = index == _sharees.length - 1;
- return InkWell(
- onTap: enabled ? onTap : null,
- borderRadius: BorderRadius.circular(16),
- child: Padding(
- padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 18),
- child: Row(
+ return Column(
children: [
- Expanded(
- child: Text(
- title,
- style: textTheme.body.copyWith(
- color: effectiveTextColor,
- fontSize: 16,
- ),
+ if (!isFirst)
+ DividerWidget(
+ dividerType: DividerType.menu,
+ bgColor: colorScheme.fillFaint,
),
- ),
- Icon(
- icon,
- size: 20,
- color: effectiveIconColor,
+ MenuItemWidget(
+ captionedTextWidget: CaptionedTextWidget(
+ title: user.email,
+ ),
+ leadingIconSize: 24,
+ leadingIconWidget: UserAvatarWidget(
+ user,
+ currentUserID: currentUserId,
+ config: Configuration.instance,
+ type: AvatarType.mini,
+ ),
+ menuItemColor: colorScheme.fillFaint,
+ trailingWidget:
+ _isOwner ? _buildRolePopupMenu(user, colorScheme) : null,
+ trailingIcon: _isOwner
+ ? null
+ : (user.isViewer
+ ? Icons.visibility_outlined
+ : Icons.people_outline),
+ trailingIconIsMuted: true,
+ surfaceExecutionStates: false,
+ isTopBorderRadiusRemoved: !isFirst,
+ isBottomBorderRadiusRemoved: !isLast,
+ singleBorderRadius: 8,
),
],
- ),
- ),
+ );
+ }),
);
}
- Widget _buildAddEmailButton() {
- return SizedBox(
- width: double.infinity,
- child: GradientButton(
- hugeIcon: const HugeIcon(
- icon: HugeIcons.strokeRoundedFileUpload,
- color: Colors.white,
- ),
- onTap: () async {
- await _showAddEmailDialog();
- },
- text: "Add Email",
+ Widget _buildRolePopupMenu(User user, colorScheme) {
+ return PopupMenuButton<String>(
+ onSelected: (value) {
+ if (value == "viewer") {
+ _setUserRole(user, CollectionParticipantRole.viewer);
+ } else if (value == "collaborator") {
+ _setUserRole(user, CollectionParticipantRole.collaborator);
+ } else if (value == "remove") {
+ _removeSharee(user);
+ }
+ },
+ shape: RoundedRectangleBorder(
+ borderRadius: BorderRadius.circular(12),
),
- );
- }
-
- Future<void> _handleShareLinkTap() async {
- if (_hasPublicLink && _publicUrl != null) {
- await _sharePublicLink(_publicUrl!.url);
- return;
- }
-
- if (!_isOwner) {
- return;
- }
-
- final created = await _createPublicLink();
- if (created && mounted && _publicUrl != null) {
- await _sharePublicLink(_publicUrl!.url);
- }
- }
-
- Widget _buildPublicLinkSection(
- EnteColorScheme colorScheme,
- EnteTextTheme textTheme,
- ) {
- final publicUrl = _publicUrl;
-
- final isCollectEnabled =
- widget.collection.publicURLs.firstOrNull?.enableCollect ?? false;
-
- if (publicUrl == null) {
- return const SizedBox.shrink();
- }
-
- return Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Text(
- "Public Link",
- style: textTheme.largeBold,
- ),
- const SizedBox(height: 12),
- Container(
- width: double.infinity,
- padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
- decoration: BoxDecoration(
- color: colorScheme.fillFaint,
- borderRadius: BorderRadius.circular(8),
- ),
- child: Row(
- children: [
- Expanded(
- child: Text(
- publicUrl.url,
- style: textTheme.bodyMuted,
- maxLines: 2,
- overflow: TextOverflow.ellipsis,
- ),
- ),
- const SizedBox(width: 12),
- IconButton(
- onPressed: () => _copyPublicLink(publicUrl.url),
- icon: Icon(
- Icons.copy,
- color: colorScheme.textBase,
- size: 20,
- ),
- padding: EdgeInsets.zero,
- constraints: const BoxConstraints(),
- ),
- ],
- ),
- ),
- const SizedBox(height: 8),
- _buildToggleRow(
- label: "Allow uploads",
- value: isCollectEnabled,
- onChanged: _isOwner
- ? () async {
- await _updatePublicUrlSettings(
- {'enableCollect': !isCollectEnabled},
- showProgressDialog: true,
- );
- }
- : null,
- colorScheme: colorScheme,
- textTheme: textTheme,
- ),
- ],
- );
- }
-
- Widget _buildShareLinkButton() {
- final publicUrl = _publicUrl;
- if (publicUrl == null) {
- return const SizedBox.shrink();
- }
-
- return SizedBox(
- width: double.infinity,
- child: GradientButton(
- hugeIcon: const HugeIcon(
- icon: HugeIcons.strokeRoundedFileUpload,
- color: Colors.white,
- ),
- onTap: () async {
- await _sharePublicLink(publicUrl.url);
- },
- text: context.l10n.sendLink,
+ padding: EdgeInsets.zero,
+ menuPadding: EdgeInsets.zero,
+ color: Colors.transparent,
+ child: HugeIcon(
+ icon: user.isViewer
+ ? HugeIcons.strokeRoundedView
+ : HugeIcons.strokeRoundedUserGroup,
+ color: colorScheme.textMuted,
+ size: 20,
),
- );
- }
-
- Widget _buildAdvancedOptionsRow(
- EnteColorScheme colorScheme,
- EnteTextTheme textTheme,
- ) {
- return GestureDetector(
- onTap: () {
- showModalBottomSheet(
- context: context,
- isScrollControlled: true,
- backgroundColor: colorScheme.backgroundBase,
- builder: (context) => AdvancedSharingBottomSheet(
- collection: widget.collection,
- ),
- );
- },
- child: Container(
- padding: const EdgeInsets.symmetric(
- horizontal: 16,
- vertical: 20,
- ),
- decoration: BoxDecoration(
- color: colorScheme.backgroundElevated2,
- borderRadius: BorderRadius.circular(24),
- ),
- child: Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: [
- Text(
- "Advanced options",
- style: textTheme.body,
- ),
- Icon(
- Icons.chevron_right,
+ itemBuilder: (context) => [
+ PopupMenuItem<String>(
+ value: "viewer",
+ height: 0,
+ padding: EdgeInsets.zero,
+ child: PopupMenuItemWidget(
+ icon: HugeIcon(
+ icon: HugeIcons.strokeRoundedView,
color: colorScheme.textBase,
- size: 24,
+ size: 20,
),
- ],
+ label: context.l10n.viewer,
+ isFirst: true,
+ isLast: false,
+ ),
),
- ),
- );
- }
-
- Widget _buildToggleRow({
- required String label,
- required bool value,
- required EnteColorScheme colorScheme,
- required EnteTextTheme textTheme,
- Future<void> Function()? onChanged,
- }) {
- return Container(
- padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 16),
- decoration: BoxDecoration(
- color: colorScheme.backgroundElevated2,
- borderRadius: BorderRadius.circular(16),
- ),
- child: Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: [
- Text(
- label,
- style: textTheme.body.copyWith(
+ PopupMenuItem<String>(
+ value: "collaborator",
+ height: 0,
+ padding: EdgeInsets.zero,
+ child: PopupMenuItemWidget(
+ icon: HugeIcon(
+ icon: HugeIcons.strokeRoundedUserGroup,
color: colorScheme.textBase,
- fontSize: 16,
+ size: 20,
),
+ label: context.l10n.collaborator,
+ isFirst: false,
+ isLast: false,
),
- ToggleSwitchWidget(
- value: () => value,
- onChanged: onChanged ?? () async {},
- ),
- ],
- ),
- );
- }
-
- String _displayName(User user) {
- final name = user.displayName;
- if (name != null && name.trim().isNotEmpty) {
- return name;
- }
- return user.email;
- }
-
- Future<void> _showAddEmailDialog() async {
- final colorScheme = getEnteColorScheme(context);
- final textTheme = getEnteTextTheme(context);
- final emailController = TextEditingController();
- bool allowCollaboration = false;
- bool isSubmitting = false;
-
- final result = await showDialog<bool>(
- context: context,
- builder: (dialogContext) => StatefulBuilder(
- builder: (context, setDialogState) => Dialog(
- backgroundColor: colorScheme.backgroundElevated2,
- shape: RoundedRectangleBorder(
- borderRadius: BorderRadius.circular(24),
- ),
- child: Container(
- width: 400,
- decoration: BoxDecoration(
- color: colorScheme.backgroundElevated2,
- borderRadius: BorderRadius.circular(24),
- ),
- padding: const EdgeInsets.symmetric(horizontal: 24),
- child: Column(
- mainAxisSize: MainAxisSize.min,
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- const SizedBox(height: 24),
- Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: [
- Text(
- context.l10n.addANewEmail,
- style: textTheme.largeBold,
- ),
- GestureDetector(
- onTap: () => Navigator.of(dialogContext).pop(false),
- child: Container(
- decoration: BoxDecoration(
- color: colorScheme.backgroundElevated,
- shape: BoxShape.circle,
- ),
- padding: const EdgeInsets.all(6),
- child: Icon(
- Icons.close,
- color: colorScheme.textBase,
- size: 20,
- ),
- ),
- ),
- ],
- ),
- const SizedBox(height: 24),
- TextField(
- controller: emailController,
- autofocus: true,
- keyboardType: TextInputType.emailAddress,
- decoration: InputDecoration(
- hintText: context.l10n.enterEmail,
- hintStyle: textTheme.body.copyWith(
- color: colorScheme.textMuted,
- ),
- filled: true,
- fillColor: colorScheme.fillFaint,
- contentPadding: const EdgeInsets.symmetric(
- horizontal: 16,
- vertical: 16,
- ),
- border: OutlineInputBorder(
- borderRadius: BorderRadius.circular(8),
- borderSide: BorderSide.none,
- ),
- focusedBorder: OutlineInputBorder(
- borderRadius: BorderRadius.circular(8),
- borderSide: BorderSide(
- color: colorScheme.strokeFaint,
- ),
- ),
- ),
- style: textTheme.body.copyWith(
- color: colorScheme.textBase,
- ),
- ),
- const SizedBox(height: 20),
- GestureDetector(
- onTap: () {
- setDialogState(() {
- allowCollaboration = !allowCollaboration;
- });
- },
- child: Container(
- padding: const EdgeInsets.symmetric(
- horizontal: 16,
- vertical: 12,
- ),
- decoration: BoxDecoration(
- color: colorScheme.fillFaint,
- borderRadius: BorderRadius.circular(8),
- ),
- child: Row(
- children: [
- Container(
- width: 20,
- height: 20,
- decoration: BoxDecoration(
- color: allowCollaboration
- ? colorScheme.primary700
- : Colors.transparent,
- borderRadius: BorderRadius.circular(4),
- border: Border.all(
- color: allowCollaboration
- ? colorScheme.primary700
- : colorScheme.strokeBase,
- width: 2,
- ),
- ),
- child: allowCollaboration
- ? const Icon(
- Icons.check,
- size: 14,
- color: Colors.white,
- )
- : null,
- ),
- const SizedBox(width: 12),
- Expanded(
- child: Text(
- "Allow collaboration",
- style: textTheme.body.copyWith(
- color: colorScheme.textBase,
- ),
- ),
- ),
- ],
- ),
- ),
- ),
- const SizedBox(height: 36),
- SizedBox(
- width: double.infinity,
- child: GradientButton(
- onTap: isSubmitting
- ? null
- : () async {
- final email = emailController.text.trim();
- if (email.isNotEmpty) {
- setDialogState(() {
- isSubmitting = true;
- });
- Navigator.pop(dialogContext, true);
- await _addSharee(email, allowCollaboration);
- }
- },
- text: context.l10n.create,
- ),
- ),
- const SizedBox(height: 24),
- ],
+ ),
+ PopupMenuItem<String>(
+ value: "remove",
+ height: 0,
+ padding: EdgeInsets.zero,
+ child: PopupMenuItemWidget(
+ icon: HugeIcon(
+ icon: HugeIcons.strokeRoundedDelete02,
+ color: colorScheme.warning500,
+ size: 20,
),
+ label: context.l10n.removeAccess,
+ isFirst: false,
+ isLast: true,
+ isWarning: true,
),
),
- ),
- );
-
- if (result == true && mounted) {
- setState(() {});
- }
- }
-
- Future<void> _addSharee(String email, bool isCollaborator) async {
- final role = isCollaborator
- ? CollectionParticipantRole.collaborator
- : CollectionParticipantRole.viewer;
-
- final result = await _collectionActions.addEmailToCollection(
- context,
- widget.collection,
- email,
- role,
- showProgress: true,
+ ],
);
-
- if (result && mounted) {
- setState(() {});
- }
}
- Future<void> _toggleUserRole(User user) async {
- final newRole = user.isViewer
- ? CollectionParticipantRole.collaborator
- : CollectionParticipantRole.viewer;
-
+ Future<void> _setUserRole(User user, CollectionParticipantRole role) async {
final result = await _collectionActions.addEmailToCollection(
context,
widget.collection,
user.email,
- newRole,
+ role,
showProgress: true,
);
if (result && mounted) {
- user.role = newRole.toString();
+ user.role = role.toString();
setState(() {});
}
}
@@ -896,53 +281,4 @@ class _ShareCollectionBottomSheetState
setState(() {});
}
}
-
- Future<bool> _createPublicLink() async {
- final success = await CollectionActions.enableUrl(
- context,
- widget.collection,
- );
- if (success && mounted) {
- setState(() {});
- }
- return success;
- }
-
- Future<void> _copyPublicLink(String url) async {
- await Clipboard.setData(ClipboardData(text: url));
- if (mounted) {
- showShortToast(context, "Link copied to clipboard");
- }
- }
-
- Future<void> _sharePublicLink(String url) async {
- await shareText(url, context: context);
- }
-
- Future<void> _updatePublicUrlSettings(
- Map<String, dynamic> updates, {
- bool showProgressDialog = true,
- }) async {
- final dialog = showProgressDialog
- ? createProgressDialog(context, "Please wait...")
- : null;
- await dialog?.show();
- try {
- await CollectionApiClient.instance.updateShareUrl(
- widget.collection,
- updates,
- );
- await dialog?.hide();
- showShortToast(context, "Collection updated");
- if (mounted) {
- setState(() {});
- }
- } catch (e) {
- if (mounted) {
- await dialog?.hide();
- await showGenericErrorDialog(context: context, error: e);
- rethrow;
- }
- }
- }
}