Skip to content

armgit / ente

Public Imported from GitHub
0

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

Add send link action to file viewer menu

Anand Baburajanfc08bd95ee4c
diff --git a/mobile/apps/photos/lib/ui/viewer/file/file_app_bar.dart b/mobile/apps/photos/lib/ui/viewer/file/file_app_bar.dart
index e37d39228a..d886e142f2 100644
--- a/mobile/apps/photos/lib/ui/viewer/file/file_app_bar.dart
+++ b/mobile/apps/photos/lib/ui/viewer/file/file_app_bar.dart
@@ -1,9 +1,11 @@
import "dart:async";
import 'dart:io';
+import "dart:math" as math;
import "package:ente_icons/ente_icons.dart";
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
+import "package:flutter/services.dart";
import "package:flutter_svg/flutter_svg.dart";
import "package:local_auth/local_auth.dart";
import 'package:logging/logging.dart';
@@ -27,6 +29,7 @@ import "package:photos/services/video_preview_service.dart";
import "package:photos/states/detail_page_state.dart";
import "package:photos/theme/colors.dart";
import "package:photos/theme/ente_theme.dart";
+import "package:photos/ui/actions/collection/collection_sharing_actions.dart";
import "package:photos/ui/actions/file/file_actions.dart";
import 'package:photos/ui/collections/collection_action_sheet.dart';
import "package:photos/ui/common/popup_item.dart";
@@ -39,6 +42,7 @@ import 'package:photos/utils/dialog_util.dart';
import "package:photos/utils/file_download_util.dart";
import 'package:photos/utils/file_util.dart';
import "package:photos/utils/magic_util.dart";
+import "package:photos/utils/share_util.dart";
class FileAppBar extends StatefulWidget {
final EnteFile file;
@@ -322,6 +326,21 @@ class FileAppBarState extends State<FileAppBar> {
iconColor: Theme.of(context).iconTheme.color,
),
);
+ if (isOwnedByUser && !isFileHidden) {
+ items.add(
+ EntePopupMenuItem(
+ AppLocalizations.of(context).sendLink,
+ value: 14,
+ iconWidget: Transform.rotate(
+ angle: math.pi / 2,
+ child: Icon(
+ Icons.navigation_rounded,
+ color: Theme.of(context).iconTheme.color,
+ ),
+ ),
+ ),
+ );
+ }
}
// Edit option for images, live photos, and videos
if (widget.file.fileType == FileType.image ||
@@ -502,6 +521,8 @@ class FileAppBarState extends State<FileAppBar> {
_handleMenuClosed();
if (value == 1) {
await _download(widget.file);
+ } else if (value == 14) {
+ await _sendLink(widget.file);
} else if (value == 2) {
await _toggleFileArchiveStatus(widget.file);
} else if (value == 3) {
@@ -663,6 +684,37 @@ class FileAppBarState extends State<FileAppBar> {
}
}
+ Future<void> _sendLink(EnteFile file) async {
+ if (!file.isUploaded || !file.isOwner) {
+ showShortToast(
+ context,
+ AppLocalizations.of(context).canOnlyCreateLinkForFilesOwnedByYou,
+ );
+ return;
+ }
+ final dialog = createProgressDialog(
+ context,
+ AppLocalizations.of(context).creatingLink,
+ isDismissible: true,
+ );
+ await dialog.show();
+ final Collection? sharedLinkCollection = await CollectionActions(
+ CollectionsService.instance,
+ ).createSharedCollectionLink(context, [file]);
+ if (sharedLinkCollection == null) {
+ await dialog.hide();
+ return;
+ }
+ final String url =
+ CollectionsService.instance.getPublicUrl(sharedLinkCollection);
+ await dialog.hide();
+ unawaited(Clipboard.setData(ClipboardData(text: url)));
+ await shareLinkWithDescription(
+ url,
+ context: context,
+ );
+ }
+
Future<void> _setAs(EnteFile file) async {
final dialog =
createProgressDialog(context, AppLocalizations.of(context).pleaseWait);