Skip to content

armgit / ente

Public Imported from GitHub
0

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

Setup sharing bottom sheet

AmanRajSinghMouryad9862c8874e1
diff --git a/mobile/apps/locker/lib/ui/pages/collection_page.dart b/mobile/apps/locker/lib/ui/pages/collection_page.dart
index c3298ea079..251c0ae69a 100644
--- a/mobile/apps/locker/lib/ui/pages/collection_page.dart
+++ b/mobile/apps/locker/lib/ui/pages/collection_page.dart
@@ -6,8 +6,6 @@ import "package:ente_ui/theme/colors.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_utils/navigation_util.dart";
-
import 'package:flutter/material.dart';
import "package:hugeicons/hugeicons.dart";
import 'package:locker/events/collections_updated_event.dart';
@@ -24,9 +22,7 @@ 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/album_participants_page.dart";
-import "package:locker/ui/sharing/manage_links_widget.dart";
-import "package:locker/ui/sharing/share_collection_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";
@@ -175,33 +171,14 @@ class _CollectionPageState extends UploaderPageState<CollectionPage>
);
}
- if (Configuration.instance.getUserID() == collection.owner.id) {
- unawaited(
- routeToPage(
- context,
- (isQuickLink && (collection.hasLink))
- ? ManageSharedLinkWidget(collection: collection)
- : ShareCollectionPage(collection: collection),
- ),
- );
- } else {
- unawaited(
- routeToPage(
- context,
- AlbumParticipantsPage(collection),
- ),
- );
-
- // TODO :Show new bottom sheet UI
- // await showModalBottomSheet(
- // context: context,
- // backgroundColor: Colors.transparent,
- // isScrollControlled: true,
- // builder: (context) => ShareCollectionBottomSheet(
- // collection: collection,
- // ),
- // );
- }
+ await showModalBottomSheet(
+ context: context,
+ backgroundColor: getEnteColorScheme(context).backgroundBase,
+ isScrollControlled: true,
+ builder: (context) => ShareCollectionBottomSheet(
+ collection: collection,
+ ),
+ );
} catch (e, s) {
_logger.severe(e, s);
await showGenericErrorDialog(context: context, error: e);
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.dart
new file mode 100644
index 0000000000..c08f4069e9
--- /dev/null
+++ b/mobile/apps/locker/lib/ui/sharing/advanced_sharing_bottom_sheet.dart
@@ -0,0 +1,428 @@
+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: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/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> {
+ static const double leadingSpace = 12;
+
+ 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);
+
+ 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(
+ "Sharing",
+ style: textTheme.largeBold,
+ ),
+ const SizedBox(height: 8),
+ MenuItemWidget(
+ captionedTextWidget: const CaptionedTextWidget(
+ title: "Sharing enabled",
+ ),
+ menuItemColor: colorScheme.backgroundElevated2,
+ leadingSpace: leadingSpace,
+ trailingWidget: ToggleSwitchWidget(
+ value: () => _shareeCount > 0 || _hasPublicLink,
+ onChanged: () async {
+ // No action - just display current state
+ },
+ ),
+ isGestureDetectorDisabled: true,
+ ),
+ const SizedBox(height: 8),
+ MenuItemWidget(
+ captionedTextWidget: const CaptionedTextWidget(
+ title: "Allow downloads",
+ ),
+ menuItemColor: colorScheme.backgroundElevated2,
+ leadingSpace: leadingSpace,
+ trailingWidget: ToggleSwitchWidget(
+ value: () => _publicUrl?.enableDownload ?? true,
+ onChanged: _publicUrl != null
+ ? () async {
+ await _updatePublicUrlSettings(
+ {
+ 'enableDownload':
+ !_publicUrl!.enableDownload,
+ },
+ );
+ }
+ : () async {},
+ ),
+ isGestureDetectorDisabled: true,
+ ),
+ const SizedBox(height: 24),
+ Text(
+ "Public Link",
+ style: textTheme.h3Bold.copyWith(
+ fontSize: 18.0,
+ ),
+ ),
+ const SizedBox(height: 8),
+ MenuItemWidget(
+ captionedTextWidget: const CaptionedTextWidget(
+ title: "Link enabled",
+ ),
+ menuItemColor: colorScheme.backgroundElevated2,
+ leadingSpace: leadingSpace,
+ 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: const CaptionedTextWidget(
+ title: "Allow downloads",
+ ),
+ menuItemColor: colorScheme.backgroundElevated2,
+ leadingSpace: leadingSpace,
+ trailingWidget: ToggleSwitchWidget(
+ value: () => _publicUrl!.enableDownload,
+ onChanged: () async {
+ await _updatePublicUrlSettings(
+ {'enableDownload': !_publicUrl!.enableDownload},
+ );
+ },
+ ),
+ isGestureDetectorDisabled: true,
+ ),
+ const SizedBox(height: 8),
+
+ MenuItemWidget(
+ captionedTextWidget: const CaptionedTextWidget(
+ title: "Allow uploads",
+ ),
+ menuItemColor: colorScheme.backgroundElevated2,
+ leadingSpace: leadingSpace,
+ trailingWidget: ToggleSwitchWidget(
+ value: () => _publicUrl!.enableCollect,
+ onChanged: () async {
+ await _updatePublicUrlSettings(
+ {'enableCollect': !_publicUrl!.enableCollect},
+ );
+ },
+ ),
+ isGestureDetectorDisabled: true,
+ ),
+ const SizedBox(height: 8),
+
+ // Password lock
+ MenuItemWidget(
+ captionedTextWidget: const CaptionedTextWidget(
+ title: "Password lock",
+ ),
+ menuItemColor: colorScheme.backgroundElevated2,
+ leadingSpace: leadingSpace,
+ trailingWidget: ToggleSwitchWidget(
+ value: () => _publicUrl!.passwordEnabled,
+ onChanged: () async {
+ if (!_publicUrl!.passwordEnabled) {
+ await _showPasswordDialog();
+ } else {
+ await _updatePublicUrlSettings(
+ {'disablePassword': true},
+ );
+ }
+ },
+ ),
+ isGestureDetectorDisabled: true,
+ ),
+
+ const SizedBox(height: 8),
+
+ MenuItemWidget(
+ captionedTextWidget: CaptionedTextWidget(
+ title: "Device limit",
+ subTitle: _publicUrl!.deviceLimit == 0
+ ? "None"
+ : "${_publicUrl!.deviceLimit} devices",
+ ),
+ menuItemColor: colorScheme.backgroundElevated2,
+ leadingSpace: leadingSpace,
+ trailingWidget: Icon(
+ Icons.chevron_right,
+ color: colorScheme.textMuted,
+ size: 24,
+ ),
+ onTap: () async {
+ // TODO: Navigate to device limit picker
+ },
+ ),
+ const SizedBox(height: 8),
+
+ // Link Expiry
+ MenuItemWidget(
+ captionedTextWidget: CaptionedTextWidget(
+ title: "Link Expiry",
+ subTitle: _publicUrl!.hasExpiry
+ ? (_publicUrl!.isExpired ? "Expired" : "Active")
+ : "Never",
+ ),
+ menuItemColor: colorScheme.backgroundElevated2,
+ leadingSpace: leadingSpace,
+ trailingWidget: Icon(
+ Icons.chevron_right,
+ color: colorScheme.textMuted,
+ size: 24,
+ ),
+ onTap: () async {
+ // TODO: Navigate to link expiry picker
+ },
+ ),
+ ],
+ const SizedBox(height: 24),
+ ],
+ ),
+ ),
+ ),
+ ],
+ ),
+ ),
+ ),
+ );
+ }
+
+ Future<void> _createPublicLink() async {
+ final success = await CollectionActions.enableUrl(
+ context,
+ widget.collection,
+ );
+ if (success && mounted) {
+ setState(() {});
+ }
+ }
+
+ Future<void> _disablePublicLink() async {
+ final confirmed = await showDialog<bool>(
+ context: context,
+ builder: (context) => AlertDialog(
+ title: const Text("Disable public link"),
+ content: const Text(
+ "Are you sure you want to disable the public link? People with this link will no longer be able to access your collection.",
+ ),
+ actions: [
+ TextButton(
+ onPressed: () => Navigator.pop(context, false),
+ child: const Text("Cancel"),
+ ),
+ TextButton(
+ onPressed: () => Navigator.pop(context, true),
+ child: const Text("Disable"),
+ ),
+ ],
+ ),
+ );
+
+ if (confirmed == true) {
+ 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,
+ ) async {
+ try {
+ await CollectionApiClient.instance.updateShareUrl(
+ widget.collection,
+ updates,
+ );
+ if (mounted) {
+ setState(() {});
+ }
+ } catch (e) {
+ if (mounted) {
+ await showGenericErrorDialog(context: context, error: e);
+ }
+ }
+ }
+
+ Future<void> _showPasswordDialog() async {
+ final colorScheme = getEnteColorScheme(context);
+ final textTheme = getEnteTextTheme(context);
+ final passwordController = TextEditingController();
+
+ await showDialog(
+ context: context,
+ builder: (dialogContext) => Dialog(
+ backgroundColor: colorScheme.backgroundElevated,
+ shape: RoundedRectangleBorder(
+ borderRadius: BorderRadius.circular(16),
+ ),
+ child: Padding(
+ padding: const EdgeInsets.all(24),
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Text(
+ "Set password",
+ style: textTheme.h3,
+ ),
+ const SizedBox(height: 16),
+ TextField(
+ controller: passwordController,
+ decoration: InputDecoration(
+ hintText: "Enter password",
+ hintStyle: textTheme.body.copyWith(
+ color: colorScheme.textMuted,
+ ),
+ filled: true,
+ fillColor: colorScheme.backgroundElevated2,
+ border: OutlineInputBorder(
+ borderRadius: BorderRadius.circular(8),
+ borderSide: BorderSide.none,
+ ),
+ ),
+ obscureText: true,
+ autofocus: true,
+ ),
+ const SizedBox(height: 24),
+ Row(
+ mainAxisAlignment: MainAxisAlignment.end,
+ children: [
+ TextButton(
+ onPressed: () => Navigator.pop(dialogContext),
+ child: Text(
+ "Cancel",
+ style: textTheme.body,
+ ),
+ ),
+ const SizedBox(width: 12),
+ ElevatedButton(
+ onPressed: () async {
+ final password = passwordController.text.trim();
+ if (password.isNotEmpty) {
+ Navigator.pop(dialogContext);
+ // TODO: Implement password encryption and update
+ await _updatePublicUrlSettings({
+ 'passwordEnabled': true,
+ });
+ }
+ },
+ child: const Text("Set"),
+ ),
+ ],
+ ),
+ ],
+ ),
+ ),
+ ),
+ );
+ }
+}
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 df0345cc4c..715ecb5f60 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,11 +1,33 @@
import "package:ente_sharing/models/user.dart";
import "package:ente_sharing/user_avator_widget.dart";
+import "package:ente_ui/components/buttons/gradient_button.dart";
+import "package:ente_ui/components/toggle_switch_widget.dart";
+import "package:ente_ui/theme/colors.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/sharing/advanced_sharing_bottom_sheet.dart";
+import "package:locker/ui/sharing/album_share_info_widget.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;
@@ -21,7 +43,7 @@ class ShareCollectionBottomSheet extends StatefulWidget {
class _ShareCollectionBottomSheetState
extends State<ShareCollectionBottomSheet> {
- bool _isExpanded = false;
+ bool _isShareesExpanded = false;
final ScrollController _scrollController = ScrollController();
late CollectionActions _collectionActions;
@@ -41,6 +63,15 @@ class _ShareCollectionBottomSheetState
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);
@@ -48,490 +79,771 @@ class _ShareCollectionBottomSheetState
return Container(
decoration: BoxDecoration(
- color: colorScheme.backgroundElevated,
+ color: colorScheme.backdropBase,
borderRadius: const BorderRadius.only(
- topLeft: Radius.circular(16),
- topRight: Radius.circular(16),
+ topLeft: Radius.circular(20),
+ topRight: Radius.circular(20),
),
),
child: SafeArea(
- child: Padding(
- padding: const EdgeInsets.symmetric(vertical: 16),
- child: Column(
- mainAxisSize: MainAxisSize.min,
- children: [
- // Header: "Shared with X people" and close button
- Padding(
- padding: const EdgeInsets.symmetric(horizontal: 16),
- child: Row(
- children: [
- Icon(
- Icons.people_outline,
- size: 20,
- color: colorScheme.textMuted,
- ),
- const SizedBox(width: 8),
- Expanded(
- child: Text(
- _shareeCount == 0
- ? "Shared with 0 people"
- : "Shared with $_shareeCount ${_shareeCount == 1 ? 'person' : 'people'}",
- style: textTheme.body.copyWith(
- color: colorScheme.textMuted,
- ),
- ),
- ),
- IconButton(
- icon: Icon(
- Icons.close,
- color: colorScheme.textBase,
- ),
- onPressed: () => Navigator.pop(context),
- padding: EdgeInsets.zero,
- constraints: const BoxConstraints(),
- ),
+ 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(),
+ ] else ...[
+ _buildCompactActionsCard(colorScheme, textTheme),
+ ],
+ const SizedBox(height: 24),
+ _buildAdvancedOptionsRow(colorScheme, textTheme),
+ const SizedBox(height: 24),
+ ],
),
-
- const SizedBox(height: 16),
-
- // Sharees section (if any)
- if (_shareeCount > 0) ...[
- _buildShareesSection(colorScheme, textTheme),
- const SizedBox(height: 16),
- ],
-
- _buildAddEmailButton(colorScheme, textTheme),
-
- const SizedBox(height: 12),
-
- // Share as link button (skipped for now)
- _buildShareAsLinkButton(colorScheme, textTheme),
- ],
+ ),
),
),
),
);
}
- Widget _buildShareesSection(
- colorScheme,
- textTheme,
+ Widget _buildHeader(
+ EnteColorScheme colorScheme,
+ EnteTextTheme textTheme,
) {
- return Padding(
- padding: const EdgeInsets.symmetric(horizontal: 16),
+ final shareText = context.l10n.shareWithPeopleSectionTitle(_shareeCount);
+
+ return Row(
+ 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,
+ ),
+ ),
+ GestureDetector(
+ onTap: () => Navigator.pop(context),
+ child: Container(
+ width: 36,
+ height: 36,
+ decoration: BoxDecoration(
+ color: colorScheme.backdropBase,
+ shape: BoxShape.circle,
+ ),
+ alignment: Alignment.center,
+ child: Icon(
+ Icons.close,
+ color: colorScheme.textBase,
+ size: 20,
+ ),
+ ),
+ ),
+ ],
+ );
+ }
+
+ 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: [
- // Avatar circles + expand/collapse button
GestureDetector(
onTap: () {
setState(() {
- _isExpanded = !_isExpanded;
+ _isShareesExpanded = !_isShareesExpanded;
});
},
child: Container(
- padding: const EdgeInsets.symmetric(vertical: 12, horizontal: 16),
decoration: BoxDecoration(
- color: colorScheme.backgroundElevated2,
- borderRadius: BorderRadius.circular(8),
+ borderRadius: BorderRadius.circular(24),
+ ),
+ padding: const EdgeInsets.symmetric(
+ horizontal: 16,
+ vertical: 6,
),
child: Row(
children: [
- // Avatar circles (show first 5)
Expanded(
- child: SizedBox(
- height: 32,
- child: Stack(
- children: [
- for (int i = 0;
- i < (_shareeCount > 5 ? 5 : _shareeCount);
- i++)
- Positioned(
- left: i * 24.0,
- child: UserAvatarWidget(
- _sharees[i],
- currentUserID:
- Configuration.instance.getUserID()!,
- config: Configuration.instance,
- ),
- ),
- ],
- ),
+ child: _buildShareeAvatarsPreview(
+ colorScheme,
+ textTheme,
),
),
- const SizedBox(width: 8),
Icon(
- _isExpanded
- ? Icons.keyboard_arrow_up
- : Icons.keyboard_arrow_down,
+ _isShareesExpanded
+ ? Icons.keyboard_arrow_up_rounded
+ : Icons.keyboard_arrow_down_rounded,
color: colorScheme.textBase,
+ size: 24,
),
],
),
),
),
-
- // Expanded sharees list
- if (_isExpanded) ...[
- const SizedBox(height: 8),
- _buildExpandedShareesList(colorScheme, textTheme),
+ if (_isShareesExpanded) ...[
+ ...List.generate(_sharees.length, (index) {
+ final user = _sharees[index];
+ return _buildShareeItem(
+ user,
+ colorScheme,
+ textTheme,
+ isLast: index == _sharees.length - 1,
+ );
+ }),
],
],
),
);
}
- Widget _buildExpandedShareesList(
- colorScheme,
- textTheme,
+ Widget _buildShareeAvatarsPreview(
+ EnteColorScheme colorScheme,
+ EnteTextTheme textTheme,
) {
- final currentUserID = Configuration.instance.getUserID()!;
- final isOwner = widget.collection.owner.id == currentUserID;
-
- return Container(
- constraints: const BoxConstraints(maxHeight: 300),
- decoration: BoxDecoration(
- color: colorScheme.backgroundElevated2,
- borderRadius: BorderRadius.circular(8),
- ),
- child: ListView.separated(
- controller: _scrollController,
- shrinkWrap: true,
- padding: const EdgeInsets.symmetric(vertical: 8),
- itemCount: _sharees.length,
- separatorBuilder: (context, index) => Divider(
- height: 1,
- color: colorScheme.strokeFaint,
- indent: 56,
+ if (_shareeCount == 0) {
+ return Text(
+ context.l10n.shareWithPeopleSectionTitle(0),
+ style: textTheme.body.copyWith(
+ color: colorScheme.textBase,
),
- itemBuilder: (context, index) {
- final user = _sharees[index];
- return _buildShareeItem(user, colorScheme, textTheme, isOwner);
- },
+ );
+ }
+
+ 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,
- colorScheme,
- textTheme,
- bool isOwner,
- ) {
- return ListTile(
- leading: UserAvatarWidget(
- user,
- currentUserID: Configuration.instance.getUserID()!,
- config: Configuration.instance,
- ),
- title: Text(
- user.email,
- style: textTheme.body,
- overflow: TextOverflow.ellipsis,
- ),
- trailing: Row(
- mainAxisSize: MainAxisSize.min,
- children: [
- // Role icon
- Icon(
- user.isViewer ? Icons.visibility_outlined : Icons.people_outline,
- size: 20,
- color: colorScheme.textMuted,
- ),
- if (isOwner) ...[
- const SizedBox(width: 8),
- // More options button
- IconButton(
- icon: Icon(
- Icons.more_vert,
- size: 20,
- color: colorScheme.textBase,
- ),
- onPressed: () => _showShareeOptions(user),
- padding: EdgeInsets.zero,
- constraints: const BoxConstraints(),
- ),
- ],
- ],
- ),
- );
- }
-
- void _showShareeOptions(User user) {
- final colorScheme = getEnteColorScheme(context);
- final textTheme = getEnteTextTheme(context);
-
- showModalBottomSheet(
- context: context,
- backgroundColor: Colors.transparent,
- builder: (context) => Container(
- decoration: BoxDecoration(
- color: colorScheme.backgroundElevated,
- borderRadius: const BorderRadius.only(
- topLeft: Radius.circular(16),
- topRight: Radius.circular(16),
- ),
+ 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,
),
- child: SafeArea(
- child: Column(
- mainAxisSize: MainAxisSize.min,
- children: [
- // Toggle role option
- ListTile(
- leading: Icon(
+ 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,
),
- title: Text(
- user.isViewer ? "Make Collaborator" : "Make Viewer",
+ const SizedBox(width: 12),
+ Text(
+ user.isViewer ? "Set as collaborator" : "Set as viewer",
style: textTheme.body,
),
- onTap: () {
- Navigator.pop(context);
- _toggleUserRole(user);
- },
- ),
- Divider(height: 1, color: colorScheme.strokeFaint),
- // Remove option
- ListTile(
- leading: Icon(
- Icons.person_remove_outlined,
+ ],
+ ),
+ ),
+ PopupMenuItem<String>(
+ value: "remove",
+ child: Row(
+ children: [
+ Icon(
+ Icons.delete_outline,
color: colorScheme.warning500,
+ size: 20,
),
- title: Text(
- "Remove",
+ const SizedBox(width: 12),
+ Text(
+ "Remove from shared",
style: textTheme.body.copyWith(
color: colorScheme.warning500,
),
),
- onTap: () {
- Navigator.pop(context);
- _removeSharee(user);
- },
- ),
- const SizedBox(height: 16),
- ],
+ ],
+ ),
),
+ ],
+ );
+ } else {
+ trailingIcon = Icon(
+ user.isViewer ? Icons.visibility_outlined : Icons.people_outline,
+ size: 20,
+ 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,
+ ],
),
),
);
}
- Future<void> _toggleUserRole(User user) async {
- final newRole = user.isViewer
- ? CollectionParticipantRole.collaborator
- : CollectionParticipantRole.viewer;
+ Widget _buildCompactActionsCard(
+ EnteColorScheme colorScheme,
+ EnteTextTheme textTheme,
+ ) {
+ final bool canManage = _isOwner;
+ final l10n = context.l10n;
+ final shareLabel = _hasPublicLink ? l10n.sendLink : l10n.shareALink;
- final result = await _collectionActions.addEmailToCollection(
- context,
- widget.collection,
- user.email,
- newRole,
- showProgress: true,
+ 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,
+ ),
+ ],
+ ),
);
+ }
- if (result && mounted) {
- Navigator.pop(context);
- }
+ 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 InkWell(
+ onTap: enabled ? onTap : null,
+ borderRadius: BorderRadius.circular(16),
+ child: Padding(
+ padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 18),
+ child: Row(
+ children: [
+ Expanded(
+ child: Text(
+ title,
+ style: textTheme.body.copyWith(
+ color: effectiveTextColor,
+ fontSize: 16,
+ ),
+ ),
+ ),
+ Icon(
+ icon,
+ size: 20,
+ color: effectiveIconColor,
+ ),
+ ],
+ ),
+ ),
+ );
}
- Future<void> _removeSharee(User user) async {
- final result = await _collectionActions.removeParticipant(
- context,
- widget.collection,
- user,
+ 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",
+ ),
);
+ }
- if (result && mounted) {
- Navigator.pop(context);
+ 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 _buildAddEmailButton(
- colorScheme,
- textTheme,
+ Widget _buildPublicLinkSection(
+ EnteColorScheme colorScheme,
+ EnteTextTheme textTheme,
) {
- return Padding(
- padding: const EdgeInsets.symmetric(horizontal: 16),
- child: InkWell(
- onTap: _showAddEmailDialog,
- child: Container(
- padding: const EdgeInsets.symmetric(vertical: 16, horizontal: 16),
+ final publicUrl = _publicUrl;
+ 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.backgroundElevated2,
+ color: colorScheme.fillFaint,
borderRadius: BorderRadius.circular(8),
),
child: Row(
children: [
- Text(
- "Add Email",
- style: textTheme.body,
+ Expanded(
+ child: Text(
+ publicUrl.url,
+ style: textTheme.bodyMuted,
+ maxLines: 2,
+ overflow: TextOverflow.ellipsis,
+ ),
),
- const Spacer(),
- Icon(
- Icons.open_in_new,
- size: 20,
- color: colorScheme.textBase,
+ 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: publicUrl.enableCollect,
+ onChanged: _isOwner
+ ? () async {
+ await _updatePublicUrlSettings(
+ {'enableCollect': !publicUrl.enableCollect},
+ );
+ }
+ : 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,
),
);
}
- Widget _buildShareAsLinkButton(
- colorScheme,
- textTheme,
+ Widget _buildAdvancedOptionsRow(
+ EnteColorScheme colorScheme,
+ EnteTextTheme textTheme,
) {
- return Padding(
- padding: const EdgeInsets.symmetric(horizontal: 16),
- child: InkWell(
- onTap: () {
- // TODO: Implement share as link functionality
- },
- child: Container(
- padding: const EdgeInsets.symmetric(vertical: 16, horizontal: 16),
- decoration: BoxDecoration(
- color: colorScheme.backgroundElevated2,
- borderRadius: BorderRadius.circular(8),
- ),
- child: Row(
- children: [
- Text(
- "Share as link",
- style: textTheme.body.copyWith(
- color: colorScheme.primary500,
- ),
- ),
- const Spacer(),
- Icon(
- Icons.link,
- size: 20,
- color: colorScheme.primary500,
- ),
- ],
+ 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,
+ color: colorScheme.textBase,
+ size: 24,
+ ),
+ ],
),
),
);
}
- void _showAddEmailDialog() {
+ 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(
+ color: colorScheme.textBase,
+ fontSize: 16,
+ ),
+ ),
+ 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;
- showDialog(
+ final result = await showDialog<bool>(
context: context,
- builder: (context) => StatefulBuilder(
+ builder: (dialogContext) => StatefulBuilder(
builder: (context, setDialogState) => Dialog(
- backgroundColor: colorScheme.backgroundElevated,
- shape: RoundedRectangleBorder(
- borderRadius: BorderRadius.circular(16),
- ),
- child: Padding(
- padding: const EdgeInsets.all(24),
+ child: Container(
+ width: 400,
+ decoration: BoxDecoration(
+ color: colorScheme.backdropBase,
+ 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: [
- Expanded(
- child: Text(
- "Add new email",
- style: textTheme.h3,
- ),
+ Text(
+ context.l10n.addANewEmail,
+ style: textTheme.largeBold,
),
- IconButton(
- icon: Icon(
- Icons.close,
- color: colorScheme.textBase,
+ 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,
+ ),
),
- onPressed: () => Navigator.pop(context),
- padding: EdgeInsets.zero,
- constraints: const BoxConstraints(),
),
],
),
const SizedBox(height: 24),
TextField(
controller: emailController,
+ autofocus: true,
+ keyboardType: TextInputType.emailAddress,
decoration: InputDecoration(
- hintText: "Enter an email address",
+ 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,
),
- contentPadding: const EdgeInsets.symmetric(
- horizontal: 16,
- vertical: 16,
+ focusedBorder: OutlineInputBorder(
+ borderRadius: BorderRadius.circular(8),
+ borderSide: BorderSide(
+ color: colorScheme.strokeFaint,
+ ),
),
),
- keyboardType: TextInputType.emailAddress,
+ style: textTheme.body.copyWith(
+ color: colorScheme.textBase,
+ ),
),
- const SizedBox(height: 16),
- Row(
- children: [
- Checkbox(
- value: allowCollaboration,
- onChanged: (value) {
- setDialogState(() {
- allowCollaboration = value ?? false;
- });
- },
- activeColor: colorScheme.primary500,
+ const SizedBox(height: 20),
+ GestureDetector(
+ onTap: () {
+ setDialogState(() {
+ allowCollaboration = !allowCollaboration;
+ });
+ },
+ child: Container(
+ padding: const EdgeInsets.symmetric(
+ horizontal: 16,
+ vertical: 12,
),
- Text(
- "Allow collaboration",
- style: textTheme.body,
+ 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: 24),
+ const SizedBox(height: 36),
SizedBox(
width: double.infinity,
- child: ElevatedButton(
- onPressed: () {
- final email = emailController.text.trim();
- if (email.isNotEmpty) {
- Navigator.pop(context);
- _addSharee(email, allowCollaboration);
- }
- },
- style: ElevatedButton.styleFrom(
- backgroundColor: colorScheme.primary500,
- foregroundColor: Colors.white,
- padding: const EdgeInsets.symmetric(vertical: 16),
- shape: RoundedRectangleBorder(
- borderRadius: BorderRadius.circular(8),
- ),
- ),
- child: Text(
- "Create",
- style: textTheme.body.copyWith(
- color: Colors.white,
- fontWeight: FontWeight.w600,
- ),
- ),
+ 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),
],
),
),
),
),
);
+
+ if (result == true && mounted) {
+ setState(() {});
+ }
}
Future<void> _addSharee(String email, bool isCollaborator) async {
@@ -548,7 +860,77 @@ class _ShareCollectionBottomSheetState
);
if (result && mounted) {
- Navigator.pop(context);
+ setState(() {});
+ }
+ }
+
+ Future<void> _toggleUserRole(User user) async {
+ final newRole = user.isViewer
+ ? CollectionParticipantRole.collaborator
+ : CollectionParticipantRole.viewer;
+
+ final result = await _collectionActions.addEmailToCollection(
+ context,
+ widget.collection,
+ user.email,
+ newRole,
+ showProgress: true,
+ );
+
+ if (result && mounted) {
+ setState(() {});
+ }
+ }
+
+ Future<void> _removeSharee(User user) async {
+ final result = await _collectionActions.removeParticipant(
+ context,
+ widget.collection,
+ user,
+ );
+
+ if (result && mounted) {
+ 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,
+ ) async {
+ try {
+ await CollectionApiClient.instance.updateShareUrl(
+ widget.collection,
+ updates,
+ );
+ if (mounted) {
+ setState(() {});
+ }
+ } catch (e) {
+ if (mounted) {
+ await showGenericErrorDialog(context: context, error: e);
+ }
}
}
}
diff --git a/mobile/packages/ui/lib/components/menu_item_widget.dart b/mobile/packages/ui/lib/components/menu_item_widget.dart
index 9c87ac195c..bfd2ce9a5b 100644
--- a/mobile/packages/ui/lib/components/menu_item_widget.dart
+++ b/mobile/packages/ui/lib/components/menu_item_widget.dart
@@ -20,6 +20,10 @@ class MenuItemWidget extends StatefulWidget {
// leadIconSize deafult value is 20.
final double leadingIconSize;
+ /// Width of the reserved leading space when no icon/widget is supplied.
+ /// When provided, this space takes precedence over the leading icon/widget.
+ final double? leadingSpace;
+
/// trailing icon can be passed without size as default size set by
/// flutter is what this component expects
final IconData? trailingIcon;
@@ -68,6 +72,7 @@ class MenuItemWidget extends StatefulWidget {
this.leadingIconColor,
this.leadingIconSize = 20.0,
this.leadingIconWidget,
+ this.leadingSpace,
this.trailingIcon,
this.trailingIconColor,
this.trailingWidget,
@@ -164,6 +169,7 @@ class _MenuItemWidgetState extends State<MenuItemWidget> {
final topBorderRadius = widget.isTopBorderRadiusRemoved
? const Radius.circular(0)
: circularRadius;
+ final leadingSection = _buildLeadingSection();
return AnimatedContainer(
duration: const Duration(milliseconds: 20),
width: double.infinity,
@@ -180,17 +186,7 @@ class _MenuItemWidgetState extends State<MenuItemWidget> {
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
- widget.alignCaptionedTextToLeft && widget.leadingIcon == null
- ? const SizedBox.shrink()
- : LeadingWidget(
- leadingIconSize: widget.leadingIconSize,
- leadingIcon: widget.leadingIcon,
- leadingIconColor: widget.leadingIconColor,
- leadingIconWidget: widget.leadingIconWidget,
- ),
- widget.leadingIcon == null
- ? const SizedBox(width: 52)
- : const SizedBox(width: 12),
+ if (leadingSection != null) leadingSection,
widget.captionedTextWidget,
if (widget.expandableController != null)
ExpansionTrailingIcon(
@@ -214,6 +210,28 @@ class _MenuItemWidgetState extends State<MenuItemWidget> {
);
}
+ Widget? _buildLeadingSection() {
+ final hasLeadingIcon =
+ widget.leadingIcon != null || widget.leadingIconWidget != null;
+ final shouldUseLeadingSpace =
+ widget.leadingSpace != null && widget.leadingSpace! > 0;
+
+ if (shouldUseLeadingSpace) {
+ return SizedBox(width: widget.leadingSpace);
+ }
+
+ if (!hasLeadingIcon) {
+ return widget.alignCaptionedTextToLeft ? null : const SizedBox.shrink();
+ }
+
+ return LeadingWidget(
+ leadingIconSize: widget.leadingIconSize,
+ leadingIcon: widget.leadingIcon,
+ leadingIconColor: widget.leadingIconColor,
+ leadingIconWidget: widget.leadingIconWidget,
+ );
+ }
+
Future<void> _onTap() async {
if (executionStateNotifier.value == ExecutionState.inProgress ||
executionStateNotifier.value == ExecutionState.successful) {