|
@@ -11,12 +11,13 @@ import 'package:photos/models/file_type.dart';
|
|
|
import 'package:photos/utils/dialog_util.dart';
|
|
|
import 'package:photos/utils/exif_util.dart';
|
|
|
import 'package:photos/utils/file_util.dart';
|
|
|
+import 'package:photos/utils/toast_util.dart';
|
|
|
import 'package:receive_sharing_intent/receive_sharing_intent.dart';
|
|
|
import 'package:share_plus/share_plus.dart';
|
|
|
|
|
|
final _logger = Logger("ShareUtil");
|
|
|
// share is used to share media/files from ente to other apps
|
|
|
-Future<void> share(BuildContext context, List<File> files) async {
|
|
|
+Future<void> share(BuildContext context, List<File> files, {GlobalKey shareButtonKey}) async {
|
|
|
final dialog = createProgressDialog(context, "preparing...");
|
|
|
await dialog.show();
|
|
|
final List<Future<String>> pathFutures = [];
|
|
@@ -31,14 +32,30 @@ Future<void> share(BuildContext context, List<File> files) async {
|
|
|
}
|
|
|
final paths = await Future.wait(pathFutures);
|
|
|
await dialog.hide();
|
|
|
- final Size size = MediaQuery.of(context).size;
|
|
|
return Share.shareFiles(
|
|
|
paths,
|
|
|
// required for ipad https://github.com/flutter/flutter/issues/47220#issuecomment-608453383
|
|
|
- sharePositionOrigin: Rect.fromLTWH(0, 0, size.width, size.height / 2),
|
|
|
+ sharePositionOrigin: shareButtonRect(context, shareButtonKey),
|
|
|
);
|
|
|
}
|
|
|
|
|
|
+Rect shareButtonRect(BuildContext context, GlobalKey shareButtonKey) {
|
|
|
+ Size size = MediaQuery
|
|
|
+ .of(context)
|
|
|
+ .size;
|
|
|
+ RenderBox renderBox = shareButtonKey?.currentContext?.findRenderObject();
|
|
|
+ if (renderBox == null) {
|
|
|
+ return Rect.fromLTWH(0, 0, size.width, size.height / 2);
|
|
|
+ }
|
|
|
+ size = renderBox.size;
|
|
|
+ Offset position = renderBox.localToGlobal(Offset.zero);
|
|
|
+ showToast('using soln');
|
|
|
+ return Rect.fromCenter(
|
|
|
+ center: position + Offset(size.width / 2, size.height / 2),
|
|
|
+ width: size.width,
|
|
|
+ height: size.height,
|
|
|
+ );
|
|
|
+}
|
|
|
Future<void> shareText(String text) async {
|
|
|
return Share.share(text);
|
|
|
}
|