Skip to content

armgit / ente

Public Imported from GitHub
0

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

Update share dialog

AmanRajSinghMouryab2ebc0fa2233
diff --git a/mobile/apps/locker/lib/ui/components/share_link_dialog.dart b/mobile/apps/locker/lib/ui/components/share_link_dialog.dart
index 6ad63b2a64..b0ffcafa87 100644
--- a/mobile/apps/locker/lib/ui/components/share_link_dialog.dart
+++ b/mobile/apps/locker/lib/ui/components/share_link_dialog.dart
@@ -1,9 +1,11 @@
+import "package:ente_ui/components/buttons/gradient_button.dart";
import "package:ente_ui/theme/ente_theme.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:locker/l10n/l10n.dart";
import "package:locker/services/files/sync/models/file.dart";
-import "package:locker/ui/components/button/copy_button.dart";
import "package:locker/ui/components/delete_share_link_dialog.dart";
Future<void> showShareLinkDialog(
@@ -12,81 +14,189 @@ Future<void> showShareLinkDialog(
String linkID,
EnteFile file,
) async {
- final colorScheme = getEnteColorScheme(context);
- final textTheme = getEnteTextTheme(context);
// Capture the root context (with Scaffold) before showing dialog
final rootContext = context;
await showDialog<void>(
context: context,
+ barrierDismissible: false,
builder: (BuildContext dialogContext) {
- return StatefulBuilder(
- builder: (context, setState) {
- return AlertDialog(
- title: Text(
- dialogContext.l10n.share,
- style: textTheme.largeBold,
- ),
- content: Column(
- mainAxisSize: MainAxisSize.min,
- crossAxisAlignment: CrossAxisAlignment.start,
+ return ShareLinkDialog(
+ url: url,
+ file: file,
+ rootContext: rootContext,
+ );
+ },
+ );
+}
+
+class ShareLinkDialog extends StatefulWidget {
+ final String url;
+ final EnteFile file;
+ final BuildContext rootContext;
+
+ const ShareLinkDialog({
+ super.key,
+ required this.url,
+ required this.file,
+ required this.rootContext,
+ });
+
+ @override
+ State<ShareLinkDialog> createState() => _ShareLinkDialogState();
+}
+
+class _ShareLinkDialogState extends State<ShareLinkDialog> {
+ @override
+ Widget build(BuildContext context) {
+ final colorScheme = getEnteColorScheme(context);
+ final textTheme = getEnteTextTheme(context);
+ final l10n = context.l10n;
+
+ return Dialog(
+ backgroundColor: colorScheme.backdropBase,
+ insetPadding: const EdgeInsets.symmetric(horizontal: 24, vertical: 24),
+ shape: RoundedRectangleBorder(
+ borderRadius: BorderRadius.circular(24),
+ ),
+ child: Container(
+ constraints: const BoxConstraints(maxWidth: 400),
+ padding: const EdgeInsets.all(24),
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Row(
+ mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
- dialogContext.l10n.shareThisLink,
- style: textTheme.body,
+ l10n.share,
+ style: textTheme.largeBold,
+ ),
+ GestureDetector(
+ onTap: () => Navigator.of(context).pop(),
+ child: Container(
+ padding: const EdgeInsets.all(8),
+ decoration: BoxDecoration(
+ shape: BoxShape.circle,
+ color: colorScheme.fillFaint,
+ ),
+ child: Icon(
+ Icons.close,
+ size: 20,
+ color: colorScheme.textMuted,
+ ),
+ ),
),
- const SizedBox(height: 20),
- Container(
- padding: const EdgeInsets.all(12),
- decoration: BoxDecoration(
- color: colorScheme.fillFaint,
- borderRadius: BorderRadius.circular(8),
- border: Border.all(color: colorScheme.strokeFaint),
+ ],
+ ),
+ const SizedBox(height: 16),
+ Text(
+ l10n.shareThisLink,
+ style: textTheme.body.copyWith(
+ color: colorScheme.textMuted,
+ ),
+ ),
+ const SizedBox(height: 24),
+ Container(
+ decoration: BoxDecoration(
+ color: colorScheme.primary700,
+ borderRadius: BorderRadius.circular(12),
+ ),
+ child: Stack(
+ children: [
+ Padding(
+ padding: const EdgeInsets.symmetric(
+ horizontal: 22,
+ vertical: 24,
+ ),
+ child: Row(
+ children: [
+ Expanded(
+ child: SelectableText(
+ widget.url,
+ style: textTheme.small.copyWith(
+ color: colorScheme.backgroundBase,
+ fontFamily: 'monospace',
+ ),
+ ),
+ ),
+ ],
+ ),
),
- child: Row(
- children: [
- Expanded(
- child: SelectableText(
- url,
- style: textTheme.small,
+ Positioned(
+ right: 0,
+ top: 0,
+ child: Center(
+ child: IconButton(
+ onPressed: () => _copyToClipboard(),
+ visualDensity: VisualDensity.compact,
+ icon: Icon(
+ Icons.copy_rounded,
+ size: 18,
+ color: colorScheme.primary500,
),
+ tooltip: 'Copy link',
),
- const SizedBox(width: 8),
- CopyButton(url: url),
- ],
+ ),
),
- ),
- ],
+ ],
+ ),
),
- actions: [
- TextButton(
- onPressed: () async {
+ const SizedBox(height: 24),
+ SizedBox(
+ width: double.infinity,
+ child: GradientButton(
+ onTap: () async {
Navigator.of(context).pop();
- await deleteShareLink(rootContext, file.uploadedFileID!);
+ await shareText(
+ widget.url,
+ context: widget.rootContext,
+ );
},
- child: Text(
- dialogContext.l10n.deleteLink,
- style: textTheme.body.copyWith(color: colorScheme.warning500),
- ),
+ text: l10n.shareLink,
),
- TextButton(
+ ),
+ const SizedBox(height: 12),
+ SizedBox(
+ width: double.infinity,
+ height: 56,
+ child: ElevatedButton(
+ style: ElevatedButton.styleFrom(
+ backgroundColor: colorScheme.warning500,
+ shape: RoundedRectangleBorder(
+ borderRadius: BorderRadius.circular(20),
+ ),
+ elevation: 0,
+ ),
onPressed: () async {
- Navigator.of(dialogContext).pop();
- // Use system share sheet to share the URL
- await shareText(
- url,
- context: rootContext,
+ Navigator.of(context).pop();
+ await deleteShareLink(
+ widget.rootContext,
+ widget.file.uploadedFileID!,
);
},
child: Text(
- dialogContext.l10n.shareLink,
- style: textTheme.body.copyWith(color: colorScheme.primary500),
+ l10n.deleteLink,
+ style: textTheme.largeBold.copyWith(
+ color: Colors.white,
+ ),
),
),
- ],
- );
- },
+ ),
+ ],
+ ),
+ ),
+ );
+ }
+
+ Future<void> _copyToClipboard() async {
+ await Clipboard.setData(ClipboardData(text: widget.url));
+ if (mounted) {
+ showShortToast(
+ context,
+ 'Link copied to clipboard',
);
- },
- );
+ }
+ }
}