Skip to content

armgit / ente

Public Imported from GitHub
0

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

[mob][photos] placeholder for link 1st draft

Aman Raj Singh Mourya8f1119525b70
diff --git a/mobile/lib/ui/TEMP/captureImage.dart b/mobile/lib/ui/TEMP/captureImage.dart
new file mode 100644
index 0000000000..65aec5a6ad
--- /dev/null
+++ b/mobile/lib/ui/TEMP/captureImage.dart
@@ -0,0 +1,65 @@
+// import "dart:typed_data";
+// import 'dart:ui' as ui;
+
+// import 'package:flutter/material.dart';
+// import 'package:flutter/rendering.dart';
+
+// class Captures {
+// static Future<Uint8List> capture(GlobalKey key) async {
+// final double pixelRatio =
+// MediaQuery.of(key.currentContext!).devicePixelRatio;
+// final RenderRepaintBoundary boundary =
+// key.currentContext!.findRenderObject()! as RenderRepaintBoundary;
+// final ui.Image image = await boundary.toImage(pixelRatio: pixelRatio);
+// final ByteData? byteData =
+// await image.toByteData(format: ui.ImageByteFormat.png);
+// final Uint8List pngBytes = byteData!.buffer.asUint8List();
+// print("PNG BYTES ====== ${pngBytes}");
+// return pngBytes;
+// }
+// }
+import "dart:io";
+import 'dart:typed_data';
+import 'dart:ui' as ui;
+import 'package:flutter/material.dart';
+import 'package:flutter/rendering.dart';
+import "package:path_provider/path_provider.dart";
+
+class Captures {
+ Future<Uint8List?> capture(GlobalKey key) async {
+ try {
+ final double pixelRatio =
+ MediaQuery.of(key.currentContext!).devicePixelRatio;
+ final RenderRepaintBoundary boundary =
+ key.currentContext!.findRenderObject()! as RenderRepaintBoundary;
+ final ui.Image image = await boundary.toImage(pixelRatio: pixelRatio);
+ final ByteData? byteData =
+ await image.toByteData(format: ui.ImageByteFormat.png);
+ final Uint8List pngBytes = byteData!.buffer.asUint8List();
+ print("PNG BYTES ====== ${pngBytes}");
+
+ return pngBytes;
+ } catch (e) {
+ print(e);
+ }
+ return null;
+ }
+
+ Future<String> saveImage(GlobalKey key) async {
+ String path = "";
+ try {
+ final Uint8List? bytes = await capture(key);
+ final Directory root = await getTemporaryDirectory();
+ final String directoryPath = '${root.path}/enteTempFiles';
+ // Create the directory if it doesn't exist
+ final DateTime timeStamp = DateTime.now();
+ await Directory(directoryPath).create(recursive: true);
+ final String filePath = '$directoryPath/$timeStamp.jpg';
+ final file = await File(filePath).writeAsBytes(bytes!);
+ path = file.path;
+ } catch (e) {
+ debugPrint(e.toString());
+ }
+ return path;
+ }
+}
diff --git a/mobile/lib/ui/TEMP/show_images_prevew.dart b/mobile/lib/ui/TEMP/show_images_prevew.dart
new file mode 100644
index 0000000000..90bdc78c2e
--- /dev/null
+++ b/mobile/lib/ui/TEMP/show_images_prevew.dart
@@ -0,0 +1,790 @@
+import "dart:ui";
+
+import "package:figma_squircle/figma_squircle.dart";
+import "package:flutter/material.dart";
+import "package:photos/models/file/file.dart";
+import "package:photos/ui/TEMP/captureImage.dart";
+import "package:photos/ui/TEMP/widget_to_image.dart";
+import "package:photos/ui/viewer/file/thumbnail_widget.dart";
+
+class ShowImagePreviewFromTap extends StatefulWidget {
+ const ShowImagePreviewFromTap({
+ required this.tempEnteFile,
+ super.key,
+ });
+ final List<EnteFile> tempEnteFile;
+ @override
+ State<ShowImagePreviewFromTap> createState() =>
+ _ShowImagePreviewFromTapState();
+}
+
+class _ShowImagePreviewFromTapState extends State<ShowImagePreviewFromTap> {
+ // late String tempImagePath;
+ // final ValueNotifier<Uint8List?> bytesNotifier =
+ // ValueNotifier<Uint8List?>(null);
+
+ late GlobalKey _widgetImageKey;
+ final ValueNotifier<String?> tempImagePath = ValueNotifier<String?>(null);
+ @override
+ void initState() {
+ super.initState();
+ WidgetsBinding.instance.addPostFrameCallback((_) async {
+ //delay of 1 second before capturing the image
+ await Future.delayed(const Duration(milliseconds: 100));
+
+ tempImagePath.value = await Captures().saveImage(_widgetImageKey);
+
+ Navigator.of(context).pop(tempImagePath.value);
+ });
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ final int length = widget.tempEnteFile.length;
+ Widget placeholderWidget = const SizedBox(
+ height: 250,
+ width: 250,
+ );
+
+ if (length == 1) {
+ placeholderWidget = BackDrop(
+ backDropImage: widget.tempEnteFile[0],
+ children: [
+ Padding(
+ padding: const EdgeInsets.all(18.0),
+ child: ClipSmoothRect(
+ radius: SmoothBorderRadius(
+ cornerRadius: 7.5,
+ cornerSmoothing: 1,
+ ),
+ child: ThumbnailWidget(
+ widget.tempEnteFile[0],
+ shouldShowArchiveStatus: false,
+ shouldShowSyncStatus: false,
+ ),
+ ),
+ ),
+ ],
+ );
+ } else if (length == 2) {
+ placeholderWidget = BackDrop(
+ backDropImage: widget.tempEnteFile[0],
+ children: [
+ Positioned(
+ top: 65,
+ left: 90,
+ child: CustomImage(
+ height: 100,
+ width: 100,
+ collages: widget.tempEnteFile[0],
+ zIndex: 0.2,
+ ),
+ ),
+ Positioned(
+ top: 20,
+ left: 0,
+ child: CustomImage(
+ height: 100,
+ width: 100,
+ collages: widget.tempEnteFile[1],
+ zIndex: -0.2,
+ ),
+ ),
+ ],
+ );
+ } else if (length == 3) {
+ placeholderWidget = BackDrop(
+ backDropImage: widget.tempEnteFile[0],
+ children: [
+ Positioned(
+ top: 30,
+ left: 0,
+ child: CustomImage(
+ height: 80,
+ width: 80,
+ collages: widget.tempEnteFile[1],
+ zIndex: -0.4,
+ ),
+ ),
+ Positioned(
+ top: 80,
+ left: 110,
+ child: CustomImage(
+ height: 80,
+ width: 80,
+ collages: widget.tempEnteFile[2],
+ zIndex: 0.4,
+ ),
+ ),
+ Positioned(
+ top: 40,
+ left: 40,
+ child: CustomImage(
+ height: 100,
+ width: 100,
+ collages: widget.tempEnteFile[0],
+ zIndex: 0.0,
+ ),
+ ),
+ ],
+ );
+ } else if (length > 3) {
+ placeholderWidget = BackDrop(
+ backDropImage: widget.tempEnteFile[0],
+ children: [
+ Positioned(
+ top: 10,
+ left: 10,
+ child: CustomImage(
+ height: 80,
+ width: 80,
+ collages: widget.tempEnteFile[1],
+ zIndex: 0,
+ ),
+ ),
+ Positioned(
+ top: 95,
+ left: 30,
+ child: CustomImage(
+ height: 80,
+ width: 80,
+ collages: widget.tempEnteFile[2],
+ zIndex: 0,
+ ),
+ ),
+ Positioned(
+ top: 35,
+ left: 60,
+ child: CustomImage(
+ height: 100,
+ width: 100,
+ collages: widget.tempEnteFile[0],
+ zIndex: 0.0,
+ ),
+ ),
+ Positioned(
+ top: 15,
+ left: 140,
+ child: Container(
+ padding: const EdgeInsets.all(8),
+ decoration: BoxDecoration(
+ color: Colors.white,
+ borderRadius: BorderRadius.circular(12),
+ ),
+ child: Text(
+ "+" "$length",
+ style: const TextStyle(
+ fontWeight: FontWeight.w600,
+ color: Colors.black,
+ ),
+ ),
+ ),
+ ),
+ ],
+ );
+ }
+ return Offstage(
+ offstage: false,
+ child: Center(
+ child: Column(
+ children: [
+ WidgetToImage(
+ builder: (key) {
+ _widgetImageKey = key;
+ return placeholderWidget;
+ },
+ ),
+ ],
+ ),
+ ),
+ );
+ }
+}
+
+class BackDrop extends StatelessWidget {
+ const BackDrop({
+ super.key,
+ required this.backDropImage,
+ required this.children,
+ });
+ final List<Widget> children;
+ final EnteFile backDropImage;
+ @override
+ Widget build(BuildContext context) {
+ return Container(
+ padding: const EdgeInsets.all(4.0),
+ height: 200,
+ width: 200,
+ child: Stack(
+ children: [
+ ClipSmoothRect(
+ radius: SmoothBorderRadius(
+ cornerRadius: 7.5,
+ cornerSmoothing: 1,
+ ),
+ child: ThumbnailWidget(
+ backDropImage,
+ shouldShowArchiveStatus: false,
+ shouldShowSyncStatus: false,
+ ),
+ ),
+ BackdropFilter(
+ filter: ImageFilter.blur(sigmaX: 5, sigmaY: 5),
+ child: Container(
+ color: Colors.transparent,
+ ),
+ ),
+ ...children,
+ ],
+ ),
+ );
+ }
+}
+
+class CustomImage extends StatelessWidget {
+ const CustomImage({
+ required this.width,
+ required this.height,
+ super.key,
+ required this.collages,
+ required this.zIndex,
+ });
+ final EnteFile collages;
+ final double zIndex;
+ final double height;
+ final double width;
+ @override
+ Widget build(BuildContext context) {
+ return Container(
+ transform: Matrix4.rotationZ(zIndex),
+ height: height,
+ width: width,
+ child: ClipSmoothRect(
+ radius: SmoothBorderRadius(
+ cornerRadius: 7.5,
+ cornerSmoothing: 1,
+ ),
+ clipBehavior: Clip.antiAliasWithSaveLayer,
+ child: ThumbnailWidget(
+ collages,
+ shouldShowArchiveStatus: false,
+ shouldShowSyncStatus: false,
+ ),
+ ),
+ );
+ }
+}
+
+// import "dart:ui";
+
+// import "package:figma_squircle/figma_squircle.dart";
+// import "package:flutter/material.dart";
+// import "package:photos/models/file/file.dart";
+// import "package:photos/ui/TEMP/captureImage.dart";
+// import "package:photos/ui/TEMP/widget_to_image.dart";
+// import "package:photos/ui/viewer/file/thumbnail_widget.dart";
+
+// class ShowImagePrev {
+// late GlobalKey _widgetImageKey;
+// final ValueNotifier<String?> tempImagePath = ValueNotifier<String?>(null);
+// Future<String?> imageToWidgetFunction(List<EnteFile> tempEnteFile) async {
+// showImagePreviewFromTap(tempEnteFile);
+// await Future.delayed(const Duration(milliseconds: 100));
+// tempImagePath.value = await Captures().saveImage(_widgetImageKey);
+
+// print("VALUE IS ==================${tempImagePath.value}");
+// if (tempImagePath.value != null) {
+// return tempImagePath.value;
+// }
+// return null;
+// }
+
+// Widget showImagePreviewFromTap(List<EnteFile> tempEnteFile) {
+// final int length = tempEnteFile.length;
+// Widget placeholderWidget = const SizedBox(
+// height: 250,
+// width: 250,
+// );
+
+// if (length == 1) {
+// placeholderWidget = BackDrop(
+// backDropImage: tempEnteFile[0],
+// children: [
+// Padding(
+// padding: const EdgeInsets.all(18.0),
+// child: ClipSmoothRect(
+// radius: SmoothBorderRadius(
+// cornerRadius: 7.5,
+// cornerSmoothing: 1,
+// ),
+// child: ThumbnailWidget(
+// tempEnteFile[0],
+// shouldShowArchiveStatus: false,
+// shouldShowSyncStatus: false,
+// ),
+// ),
+// ),
+// ],
+// );
+// } else if (length == 2) {
+// placeholderWidget = BackDrop(
+// backDropImage: tempEnteFile[0],
+// children: [
+// Positioned(
+// top: 65,
+// left: 90,
+// child: CustomImage(
+// height: 100,
+// width: 100,
+// collages: tempEnteFile[0],
+// zIndex: 0.2,
+// ),
+// ),
+// Positioned(
+// top: 20,
+// left: 0,
+// child: CustomImage(
+// height: 100,
+// width: 100,
+// collages: tempEnteFile[1],
+// zIndex: -0.2,
+// ),
+// ),
+// ],
+// );
+// } else if (length == 3) {
+// placeholderWidget = BackDrop(
+// backDropImage: tempEnteFile[0],
+// children: [
+// Positioned(
+// top: 30,
+// left: 0,
+// child: CustomImage(
+// height: 80,
+// width: 80,
+// collages: tempEnteFile[1],
+// zIndex: -0.4,
+// ),
+// ),
+// Positioned(
+// top: 80,
+// left: 110,
+// child: CustomImage(
+// height: 80,
+// width: 80,
+// collages: tempEnteFile[2],
+// zIndex: 0.4,
+// ),
+// ),
+// Positioned(
+// top: 40,
+// left: 40,
+// child: CustomImage(
+// height: 100,
+// width: 100,
+// collages: tempEnteFile[0],
+// zIndex: 0.0,
+// ),
+// ),
+// ],
+// );
+// } else if (length > 3) {
+// placeholderWidget = BackDrop(
+// backDropImage: tempEnteFile[0],
+// children: [
+// Positioned(
+// top: 10,
+// left: 10,
+// child: CustomImage(
+// height: 80,
+// width: 80,
+// collages: tempEnteFile[1],
+// zIndex: 0,
+// ),
+// ),
+// Positioned(
+// top: 95,
+// left: 30,
+// child: CustomImage(
+// height: 80,
+// width: 80,
+// collages: tempEnteFile[2],
+// zIndex: 0,
+// ),
+// ),
+// Positioned(
+// top: 35,
+// left: 60,
+// child: CustomImage(
+// height: 100,
+// width: 100,
+// collages: tempEnteFile[0],
+// zIndex: 0.0,
+// ),
+// ),
+// Positioned(
+// top: 15,
+// left: 140,
+// child: Container(
+// padding: const EdgeInsets.all(8),
+// decoration: BoxDecoration(
+// color: Colors.white,
+// borderRadius: BorderRadius.circular(12),
+// ),
+// child: Text(
+// "+ $length",
+// style: const TextStyle(
+// fontWeight: FontWeight.w600,
+// color: Colors.black,
+// ),
+// ),
+// ),
+// ),
+// ],
+// );
+// }
+
+// return Center(
+// child: WidgetToImage(
+// builder: (key) {
+// _widgetImageKey = key;
+// return placeholderWidget;
+// },
+// ),
+// );
+// }
+// }
+
+// class BackDrop extends StatelessWidget {
+// const BackDrop({
+// super.key,
+// required this.backDropImage,
+// required this.children,
+// });
+// final List<Widget> children;
+// final EnteFile backDropImage;
+
+// @override
+// Widget build(BuildContext context) {
+// return Container(
+// padding: const EdgeInsets.all(4.0),
+// height: 200,
+// width: 200,
+// child: Stack(
+// children: [
+// ClipSmoothRect(
+// radius: SmoothBorderRadius(
+// cornerRadius: 7.5,
+// cornerSmoothing: 1,
+// ),
+// child: ThumbnailWidget(
+// backDropImage,
+// shouldShowArchiveStatus: false,
+// shouldShowSyncStatus: false,
+// ),
+// ),
+// BackdropFilter(
+// filter: ImageFilter.blur(sigmaX: 5, sigmaY: 5),
+// child: Container(
+// color: Colors.transparent,
+// ),
+// ),
+// ...children,
+// ],
+// ),
+// );
+// }
+// }
+
+// class CustomImage extends StatelessWidget {
+// const CustomImage({
+// required this.width,
+// required this.height,
+// super.key,
+// required this.collages,
+// required this.zIndex,
+// });
+// final EnteFile collages;
+// final double zIndex;
+// final double height;
+// final double width;
+// @override
+// Widget build(BuildContext context) {
+// return Container(
+// transform: Matrix4.rotationZ(zIndex),
+// height: height,
+// width: width,
+// child: ClipSmoothRect(
+// radius: SmoothBorderRadius(
+// cornerRadius: 7.5,
+// cornerSmoothing: 1,
+// ),
+// clipBehavior: Clip.antiAliasWithSaveLayer,
+// child: ThumbnailWidget(
+// collages,
+// shouldShowArchiveStatus: false,
+// shouldShowSyncStatus: false,
+// ),
+// ),
+// );
+// }
+// }
+// import "dart:ui";
+
+// import "package:figma_squircle/figma_squircle.dart";
+// import "package:flutter/material.dart";
+// import "package:photos/models/file/file.dart";
+// import "package:photos/ui/TEMP/captureImage.dart";
+// import "package:photos/ui/TEMP/widget_to_image.dart";
+// import "package:photos/ui/viewer/file/thumbnail_widget.dart";
+
+// class ShowImagePrev {
+// late GlobalKey _widgetImageKey;
+// final ValueNotifier<String?> tempImagePath = ValueNotifier<String?>(null);
+
+// ShowImagePrev() {
+// _widgetImageKey = GlobalKey();
+// }
+
+// Future<String?> imageToWidgetFunction(List<EnteFile> tempEnteFile) async {
+// showImagePreviewFromTap(tempEnteFile);
+// // Build the widget to ensure the GlobalKey is assigned correctly
+// WidgetsBinding.instance.addPostFrameCallback((_) async {
+// await Future.delayed(const Duration(milliseconds: 100));
+// tempImagePath.value = await Captures().saveImage(_widgetImageKey);
+// print("VALUE IS ==================${tempImagePath.value}");
+// });
+
+// return tempImagePath.value;
+// }
+
+// Widget showImagePreviewFromTap(List<EnteFile> tempEnteFile) {
+// final int length = tempEnteFile.length;
+// Widget placeholderWidget = const SizedBox(
+// height: 250,
+// width: 250,
+// );
+
+// if (length == 1) {
+// placeholderWidget = BackDrop(
+// backDropImage: tempEnteFile[0],
+// children: [
+// Padding(
+// padding: const EdgeInsets.all(18.0),
+// child: ClipSmoothRect(
+// radius: SmoothBorderRadius(
+// cornerRadius: 7.5,
+// cornerSmoothing: 1,
+// ),
+// child: ThumbnailWidget(
+// tempEnteFile[0],
+// shouldShowArchiveStatus: false,
+// shouldShowSyncStatus: false,
+// ),
+// ),
+// ),
+// ],
+// );
+// } else if (length == 2) {
+// placeholderWidget = BackDrop(
+// backDropImage: tempEnteFile[0],
+// children: [
+// Positioned(
+// top: 65,
+// left: 90,
+// child: CustomImage(
+// height: 100,
+// width: 100,
+// collages: tempEnteFile[0],
+// zIndex: 0.2,
+// ),
+// ),
+// Positioned(
+// top: 20,
+// left: 0,
+// child: CustomImage(
+// height: 100,
+// width: 100,
+// collages: tempEnteFile[1],
+// zIndex: -0.2,
+// ),
+// ),
+// ],
+// );
+// } else if (length == 3) {
+// placeholderWidget = BackDrop(
+// backDropImage: tempEnteFile[0],
+// children: [
+// Positioned(
+// top: 30,
+// left: 0,
+// child: CustomImage(
+// height: 80,
+// width: 80,
+// collages: tempEnteFile[1],
+// zIndex: -0.4,
+// ),
+// ),
+// Positioned(
+// top: 80,
+// left: 110,
+// child: CustomImage(
+// height: 80,
+// width: 80,
+// collages: tempEnteFile[2],
+// zIndex: 0.4,
+// ),
+// ),
+// Positioned(
+// top: 40,
+// left: 40,
+// child: CustomImage(
+// height: 100,
+// width: 100,
+// collages: tempEnteFile[0],
+// zIndex: 0.0,
+// ),
+// ),
+// ],
+// );
+// } else if (length > 3) {
+// placeholderWidget = BackDrop(
+// backDropImage: tempEnteFile[0],
+// children: [
+// Positioned(
+// top: 10,
+// left: 10,
+// child: CustomImage(
+// height: 80,
+// width: 80,
+// collages: tempEnteFile[1],
+// zIndex: 0,
+// ),
+// ),
+// Positioned(
+// top: 95,
+// left: 30,
+// child: CustomImage(
+// height: 80,
+// width: 80,
+// collages: tempEnteFile[2],
+// zIndex: 0,
+// ),
+// ),
+// Positioned(
+// top: 35,
+// left: 60,
+// child: CustomImage(
+// height: 100,
+// width: 100,
+// collages: tempEnteFile[0],
+// zIndex: 0.0,
+// ),
+// ),
+// Positioned(
+// top: 15,
+// left: 140,
+// child: Container(
+// padding: const EdgeInsets.all(8),
+// decoration: BoxDecoration(
+// color: Colors.white,
+// borderRadius: BorderRadius.circular(12),
+// ),
+// child: Text(
+// "+ $length",
+// style: const TextStyle(
+// fontWeight: FontWeight.w600,
+// color: Colors.black,
+// ),
+// ),
+// ),
+// ),
+// ],
+// );
+// }
+
+// return Center(
+// child: WidgetToImage(
+// builder: (key) {
+// _widgetImageKey = key;
+// return placeholderWidget;
+// },
+// ),
+// );
+// }
+// }
+
+// class BackDrop extends StatelessWidget {
+// const BackDrop({
+// super.key,
+// required this.backDropImage,
+// required this.children,
+// });
+// final List<Widget> children;
+// final EnteFile backDropImage;
+
+// @override
+// Widget build(BuildContext context) {
+// return Container(
+// padding: const EdgeInsets.all(4.0),
+// height: 200,
+// width: 200,
+// child: Stack(
+// children: [
+// ClipSmoothRect(
+// radius: SmoothBorderRadius(
+// cornerRadius: 7.5,
+// cornerSmoothing: 1,
+// ),
+// child: ThumbnailWidget(
+// backDropImage,
+// shouldShowArchiveStatus: false,
+// shouldShowSyncStatus: false,
+// ),
+// ),
+// BackdropFilter(
+// filter: ImageFilter.blur(sigmaX: 5, sigmaY: 5),
+// child: Container(
+// color: Colors.transparent,
+// ),
+// ),
+// ...children,
+// ],
+// ),
+// );
+// }
+// }
+
+// class CustomImage extends StatelessWidget {
+// const CustomImage({
+// required this.width,
+// required this.height,
+// super.key,
+// required this.collages,
+// required this.zIndex,
+// });
+// final EnteFile collages;
+// final double zIndex;
+// final double height;
+// final double width;
+// @override
+// Widget build(BuildContext context) {
+// return Container(
+// transform: Matrix4.rotationZ(zIndex),
+// height: height,
+// width: width,
+// child: ClipSmoothRect(
+// radius: SmoothBorderRadius(
+// cornerRadius: 7.5,
+// cornerSmoothing: 1,
+// ),
+// clipBehavior: Clip.antiAliasWithSaveLayer,
+// child: ThumbnailWidget(
+// collages,
+// shouldShowArchiveStatus: false,
+// shouldShowSyncStatus: false,
+// ),
+// ),
+// );
+// }
+// }
diff --git a/mobile/lib/ui/TEMP/widget_to_image.dart b/mobile/lib/ui/TEMP/widget_to_image.dart
new file mode 100644
index 0000000000..b00818b0da
--- /dev/null
+++ b/mobile/lib/ui/TEMP/widget_to_image.dart
@@ -0,0 +1,19 @@
+import "package:flutter/material.dart";
+
+class WidgetToImage extends StatefulWidget {
+ const WidgetToImage({super.key, required this.builder});
+ final Function(GlobalKey key) builder;
+ @override
+ State<WidgetToImage> createState() => _WidgetToImageState();
+}
+
+class _WidgetToImageState extends State<WidgetToImage> {
+ final globalKey = GlobalKey();
+ @override
+ Widget build(BuildContext context) {
+ return RepaintBoundary(
+ key: globalKey,
+ child: widget.builder(globalKey),
+ );
+ }
+}
diff --git a/mobile/lib/ui/actions/collection/collection_sharing_actions.dart b/mobile/lib/ui/actions/collection/collection_sharing_actions.dart
index 3328722dbe..0d571c2d87 100644
--- a/mobile/lib/ui/actions/collection/collection_sharing_actions.dart
+++ b/mobile/lib/ui/actions/collection/collection_sharing_actions.dart
@@ -110,6 +110,7 @@ class CollectionActions {
BuildContext context,
List<EnteFile> files,
) async {
+ print("CREATED LINK");
final dialog = createProgressDialog(
context,
S.of(context).creatingLink,
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 e805927a64..3fbc42ff7e 100644
--- a/mobile/lib/ui/viewer/actions/file_selection_actions_widget.dart
+++ b/mobile/lib/ui/viewer/actions/file_selection_actions_widget.dart
@@ -19,6 +19,7 @@ import 'package:photos/services/collections_service.dart';
import 'package:photos/services/hidden_service.dart';
import "package:photos/theme/colors.dart";
import "package:photos/theme/ente_theme.dart";
+import "package:photos/ui/TEMP/show_images_prevew.dart";
import 'package:photos/ui/actions/collection/collection_file_actions.dart';
import 'package:photos/ui/actions/collection/collection_sharing_actions.dart';
import 'package:photos/ui/collections/collection_action_sheet.dart';
@@ -561,6 +562,25 @@ class _FileSelectionActionsWidgetState
}
}
+ ValueNotifier<String?> generatedPathNotifier = ValueNotifier<String?>(null);
+//Future function to go to next page
+ Future<String?> _nextPageForTesting(List<EnteFile> tempfile) async {
+ final String? tempImagePath = await Navigator.of(context).push(
+ MaterialPageRoute(
+ builder: (context) => ShowImagePreviewFromTap(
+ tempEnteFile: tempfile,
+ ),
+ ),
+ );
+
+ if (tempImagePath != null) {
+ print("Temp image path: $tempImagePath");
+
+ return tempImagePath;
+ }
+ return tempImagePath;
+ }
+
Future<void> _onCreatedSharedLinkClicked() async {
if (split.ownedByCurrentUser.isEmpty) {
showShortToast(
@@ -571,16 +591,26 @@ class _FileSelectionActionsWidgetState
}
_cachedCollectionForSharedLink ??= await collectionActions
.createSharedCollectionLink(context, split.ownedByCurrentUser);
+
+ final List<EnteFile> tempEnteFile = split.ownedByCurrentUser;
+
final actionResult = await showActionSheet(
context: context,
buttons: [
ButtonWidget(
- labelText: S.of(context).copyLink,
+ labelText: S.of(context).shareLink,
buttonType: ButtonType.neutral,
buttonSize: ButtonSize.large,
shouldStickToDarkTheme: true,
buttonAction: ButtonAction.first,
isInAlert: true,
+ // onTap: () async {
+ // // Add a return statement at the end of the function
+ // generatedPathNotifier.value =
+ // await _nextPageForTesting(tempEnteFile);
+ // await shareText(generatedPathNotifier.value!);
+ // return Future<void>.value();
+ // },
),
ButtonWidget(
labelText: S.of(context).manageLink,
@@ -605,6 +635,7 @@ class _FileSelectionActionsWidgetState
);
if (actionResult?.action != null) {
if (actionResult!.action == ButtonAction.first) {
+ //generatedPathNotifier.value = await _nextPageForTesting(tempEnteFile);
await _copyLink();
}
if (actionResult.action == ButtonAction.second) {
@@ -621,6 +652,7 @@ class _FileSelectionActionsWidgetState
}
Future<void> _copyLink() async {
+ print("INSIDE COPY LINK");
if (_cachedCollectionForSharedLink != null) {
final String collectionKey = Base58Encode(
CollectionsService.instance
@@ -628,6 +660,8 @@ class _FileSelectionActionsWidgetState
);
final String url =
"${_cachedCollectionForSharedLink!.publicURLs?.first?.url}#$collectionKey";
+ await shareText(url);
+ //await shareImageAndUrl(context, 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 ff9f691bd6..b94ac33235 100644
--- a/mobile/lib/utils/share_util.dart
+++ b/mobile/lib/utils/share_util.dart
@@ -218,3 +218,11 @@ void shareSelected(
shareButtonKey: shareButtonKey,
);
}
+
+Future<void> shareImageAndUrl(
+ BuildContext context,
+ String imagePath,
+ String url,
+) async {
+ await Share.shareFiles([imagePath], text: url);
+}