From 7f816e80a2f25fd8fcaecbfce9d7c5a2c5d00102 Mon Sep 17 00:00:00 2001 From: Aman Raj Singh Mourya Date: Thu, 30 May 2024 12:48:07 +0530 Subject: [PATCH] [mob][photos] share placeholder with link when sharing 2nd draft --- .../collection_sharing_actions.dart | 1 - mobile/lib/ui/sharing/show_images_prevew.dart | 32 +++++++++---------- .../file_selection_actions_widget.dart | 26 ++++++++------- mobile/lib/utils/share_util.dart | 1 - 4 files changed, 30 insertions(+), 30 deletions(-) diff --git a/mobile/lib/ui/actions/collection/collection_sharing_actions.dart b/mobile/lib/ui/actions/collection/collection_sharing_actions.dart index 0d571c2d87..3328722dbe 100644 --- a/mobile/lib/ui/actions/collection/collection_sharing_actions.dart +++ b/mobile/lib/ui/actions/collection/collection_sharing_actions.dart @@ -110,7 +110,6 @@ class CollectionActions { BuildContext context, List files, ) async { - print("CREATED LINK"); final dialog = createProgressDialog( context, S.of(context).creatingLink, diff --git a/mobile/lib/ui/sharing/show_images_prevew.dart b/mobile/lib/ui/sharing/show_images_prevew.dart index 7b0632554a..e779df80d1 100644 --- a/mobile/lib/ui/sharing/show_images_prevew.dart +++ b/mobile/lib/ui/sharing/show_images_prevew.dart @@ -7,15 +7,15 @@ import "package:photos/ui/viewer/file/thumbnail_widget.dart"; class ShowImagePreviewFromTap extends StatelessWidget { const ShowImagePreviewFromTap({ - required this.tempEnteFile, + required this.ownedSelectedFiles, super.key, }); - final List tempEnteFile; + final List ownedSelectedFiles; @override Widget build(BuildContext context) { - final int length = tempEnteFile.length; + final int length = ownedSelectedFiles.length; Widget placeholderWidget = const SizedBox( height: 300, // Adjusted height width: 300, // Adjusted width @@ -25,7 +25,7 @@ class ShowImagePreviewFromTap extends StatelessWidget { placeholderWidget = AspectRatio( aspectRatio: 1, child: BackDrop( - backDropImage: tempEnteFile[0], + backDropImage: ownedSelectedFiles[0], children: [ Padding( padding: const EdgeInsets.all(18.0), @@ -54,7 +54,7 @@ class ShowImagePreviewFromTap extends StatelessWidget { cornerSmoothing: 1, ), child: ThumbnailWidget( - tempEnteFile[0], + ownedSelectedFiles[0], shouldShowArchiveStatus: false, shouldShowSyncStatus: false, ), @@ -68,7 +68,7 @@ class ShowImagePreviewFromTap extends StatelessWidget { placeholderWidget = AspectRatio( aspectRatio: 1, child: BackDrop( - backDropImage: tempEnteFile[0], + backDropImage: ownedSelectedFiles[0], children: [ Positioned( right: 20, @@ -76,7 +76,7 @@ class ShowImagePreviewFromTap extends StatelessWidget { child: CustomImage( height: 190, width: 190, - collages: tempEnteFile[1], + collages: ownedSelectedFiles[1], zIndex: 0.2, ), ), @@ -86,7 +86,7 @@ class ShowImagePreviewFromTap extends StatelessWidget { child: CustomImage( height: 190, width: 190, - collages: tempEnteFile[0], + collages: ownedSelectedFiles[0], zIndex: -0.2, ), ), @@ -97,7 +97,7 @@ class ShowImagePreviewFromTap extends StatelessWidget { placeholderWidget = AspectRatio( aspectRatio: 1, child: BackDrop( - backDropImage: tempEnteFile[0], + backDropImage: ownedSelectedFiles[0], children: [ //left image Positioned( @@ -106,7 +106,7 @@ class ShowImagePreviewFromTap extends StatelessWidget { child: CustomImage( height: 160, width: 160, - collages: tempEnteFile[1], + collages: ownedSelectedFiles[1], zIndex: -0.3, ), ), @@ -117,7 +117,7 @@ class ShowImagePreviewFromTap extends StatelessWidget { child: CustomImage( height: 160, width: 160, - collages: tempEnteFile[2], + collages: ownedSelectedFiles[2], zIndex: 0.3, ), ), @@ -128,7 +128,7 @@ class ShowImagePreviewFromTap extends StatelessWidget { child: CustomImage( height: 175, width: 175, - collages: tempEnteFile[0], + collages: ownedSelectedFiles[0], zIndex: 0.0, ), ), @@ -141,7 +141,7 @@ class ShowImagePreviewFromTap extends StatelessWidget { child: AspectRatio( aspectRatio: 1, child: BackDrop( - backDropImage: tempEnteFile[0], + backDropImage: ownedSelectedFiles[0], children: [ Positioned( top: 20, @@ -149,7 +149,7 @@ class ShowImagePreviewFromTap extends StatelessWidget { child: CustomImage( height: 160, width: 160, - collages: tempEnteFile[1], + collages: ownedSelectedFiles[1], zIndex: 0, ), ), @@ -159,7 +159,7 @@ class ShowImagePreviewFromTap extends StatelessWidget { child: CustomImage( height: 160, width: 160, - collages: tempEnteFile[2], + collages: ownedSelectedFiles[2], zIndex: 0, ), ), @@ -169,7 +169,7 @@ class ShowImagePreviewFromTap extends StatelessWidget { child: CustomImage( height: 175, width: 175, - collages: tempEnteFile[0], + collages: ownedSelectedFiles[0], zIndex: 0.0, ), ), diff --git a/mobile/lib/ui/viewer/actions/file_selection_actions_widget.dart b/mobile/lib/ui/viewer/actions/file_selection_actions_widget.dart index a6ad143d28..274ef87cd7 100644 --- a/mobile/lib/ui/viewer/actions/file_selection_actions_widget.dart +++ b/mobile/lib/ui/viewer/actions/file_selection_actions_widget.dart @@ -99,6 +99,7 @@ class _FileSelectionActionsWidgetState @override void dispose() { widget.selectedFiles.removeListener(_selectFileChangeListener); + generatedPathNotifier.dispose(); super.dispose(); } @@ -615,7 +616,7 @@ class _FileSelectionActionsWidgetState final DateTime timeStamp = DateTime.now(); await Directory(directoryPath).create(recursive: true); final String filePath = '$directoryPath/$timeStamp.jpg'; - final file = await File(filePath).writeAsBytes(bytes!); + final file = await File(filePath).writeAsBytes(bytes); path = file.path; } catch (e) { debugPrint(e.toString()); @@ -624,22 +625,24 @@ class _FileSelectionActionsWidgetState } ValueNotifier generatedPathNotifier = ValueNotifier(null); -//Future function to go to next page - Future _nextPageForTesting(List tempfile) async { + + Future _selectedFilePlaceholderPath( + List ownedSelectedFiles, + ) async { final Widget imageWidget = ShowImagePreviewFromTap( - tempEnteFile: tempfile, + ownedSelectedFiles: ownedSelectedFiles, ); await Future.delayed(const Duration(milliseconds: 100)); final double pixelRatio = MediaQuery.of(context).devicePixelRatio; final bytesOfImageToWidget = await screenshotController.captureFromWidget( imageWidget, pixelRatio: pixelRatio, - targetSize: MediaQuery.of(context).size, + targetSize: MediaQuery.sizeOf(context), delay: const Duration(milliseconds: 100), ); - final String tempImagePath = await saveImage(bytesOfImageToWidget); - return tempImagePath; + final String onCreateLinkTapped = await saveImage(bytesOfImageToWidget); + return onCreateLinkTapped; } Future _onCreatedSharedLinkClicked() async { @@ -653,7 +656,7 @@ class _FileSelectionActionsWidgetState _cachedCollectionForSharedLink ??= await collectionActions .createSharedCollectionLink(context, split.ownedByCurrentUser); - final List tempEnteFile = split.ownedByCurrentUser; + final List ownedSelectedFiles = split.ownedByCurrentUser; final actionResult = await showActionSheet( context: context, @@ -689,7 +692,8 @@ class _FileSelectionActionsWidgetState ); if (actionResult?.action != null) { if (actionResult!.action == ButtonAction.first) { - generatedPathNotifier.value = await _nextPageForTesting(tempEnteFile); + generatedPathNotifier.value = + await _selectedFilePlaceholderPath(ownedSelectedFiles); await _copyLink(); } if (actionResult.action == ButtonAction.second) { @@ -801,7 +805,6 @@ class _FileSelectionActionsWidgetState } Future _copyLink() async { - print("INSIDE COPY LINK"); if (_cachedCollectionForSharedLink != null) { final String collectionKey = Base58Encode( CollectionsService.instance @@ -809,8 +812,7 @@ class _FileSelectionActionsWidgetState ); final String url = "${_cachedCollectionForSharedLink!.publicURLs?.first?.url}#$collectionKey"; - //await shareText(url); - await shareImageAndUrl(context, generatedPathNotifier.value!, url); + await shareImageAndUrl(generatedPathNotifier.value!, url); await Clipboard.setData(ClipboardData(text: url)); showShortToast(context, S.of(context).linkCopiedToClipboard); } diff --git a/mobile/lib/utils/share_util.dart b/mobile/lib/utils/share_util.dart index b94ac33235..aeb1e6bdab 100644 --- a/mobile/lib/utils/share_util.dart +++ b/mobile/lib/utils/share_util.dart @@ -220,7 +220,6 @@ void shareSelected( } Future shareImageAndUrl( - BuildContext context, String imagePath, String url, ) async {