2020-10-28 07:23:50 +01:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter/services.dart';
|
2021-10-26 18:50:34 +02:00
|
|
|
|
2020-10-28 07:23:50 +01:00
|
|
|
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
2022-05-06 08:58:59 +02:00
|
|
|
import 'package:share_plus/share_plus.dart';
|
2021-10-26 18:50:34 +02:00
|
|
|
|
|
|
|
import 'package:fluffychat/utils/platform_infos.dart';
|
2020-10-28 07:23:50 +01:00
|
|
|
|
|
|
|
abstract class FluffyShare {
|
|
|
|
static Future<void> share(String text, BuildContext context) async {
|
|
|
|
if (PlatformInfos.isMobile) {
|
2022-06-15 13:00:12 +02:00
|
|
|
final box = context.findRenderObject() as RenderBox;
|
|
|
|
return Share.share(
|
|
|
|
text,
|
|
|
|
sharePositionOrigin: box.localToGlobal(Offset.zero) & box.size,
|
|
|
|
);
|
2020-10-28 07:23:50 +01:00
|
|
|
}
|
|
|
|
await Clipboard.setData(
|
|
|
|
ClipboardData(text: text),
|
|
|
|
);
|
2021-05-23 13:11:55 +02:00
|
|
|
ScaffoldMessenger.of(context).showSnackBar(
|
2023-03-02 10:57:52 +01:00
|
|
|
SnackBar(content: Text(L10n.of(context)!.copiedToClipboard)),
|
|
|
|
);
|
2020-10-28 07:23:50 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|