mirror of
https://gitlab.com/famedly/fluffychat.git
synced 2024-11-23 20:49:26 +01:00
fix: Sharing on iPad
This commit is contained in:
parent
1eba0e5dbe
commit
67f5a76f16
@ -108,7 +108,7 @@ class ChatController extends State<Chat> {
|
||||
MessageTypes.File,
|
||||
}.contains(selectedEvents.single.messageType);
|
||||
|
||||
void saveSelectedEvent() => selectedEvents.single.saveFile(context);
|
||||
void saveSelectedEvent(context) => selectedEvents.single.saveFile(context);
|
||||
|
||||
List<Event> selectedEvents = [];
|
||||
|
||||
|
@ -46,11 +46,13 @@ class ChatView extends StatelessWidget {
|
||||
onPressed: controller.copyEventsAction,
|
||||
),
|
||||
if (controller.canSaveSelectedEvent)
|
||||
IconButton(
|
||||
icon: Icon(Icons.adaptive.share),
|
||||
tooltip: L10n.of(context)!.share,
|
||||
onPressed: controller.saveSelectedEvent,
|
||||
),
|
||||
// Use builder context to correctly position the share dialog on iPad
|
||||
Builder(
|
||||
builder: (context) => IconButton(
|
||||
icon: Icon(Icons.adaptive.share),
|
||||
tooltip: L10n.of(context)!.share,
|
||||
onPressed: () => controller.saveSelectedEvent(context),
|
||||
)),
|
||||
if (controller.canRedactSelectedEvents)
|
||||
IconButton(
|
||||
icon: const Icon(Icons.delete_outlined),
|
||||
|
@ -18,6 +18,8 @@ class HomeserverPickerView extends StatelessWidget {
|
||||
final benchmarkResults = controller.benchmarkResults;
|
||||
return LoginScaffold(
|
||||
appBar: AppBar(
|
||||
elevation: 0,
|
||||
scrolledUnderElevation: 0,
|
||||
backgroundColor: Colors.transparent,
|
||||
actions: [
|
||||
IconButton(
|
||||
|
@ -25,10 +25,10 @@ class ImageViewerController extends State<ImageViewer> {
|
||||
}
|
||||
|
||||
/// Save this file with a system call.
|
||||
void saveFileAction() => widget.event.saveFile(context);
|
||||
void saveFileAction(BuildContext context) => widget.event.saveFile(context);
|
||||
|
||||
/// Save this file with a system call.
|
||||
void shareFileAction() => widget.event.shareFile(context);
|
||||
void shareFileAction(BuildContext context) => widget.event.shareFile(context);
|
||||
|
||||
static const maxScaleFactor = 1.5;
|
||||
|
||||
|
@ -35,17 +35,19 @@ class ImageViewerView extends StatelessWidget {
|
||||
if (!PlatformInfos.isIOS)
|
||||
IconButton(
|
||||
icon: const Icon(Icons.download_outlined),
|
||||
onPressed: controller.saveFileAction,
|
||||
onPressed: () => controller.saveFileAction(context),
|
||||
color: Colors.white,
|
||||
tooltip: L10n.of(context)!.downloadFile,
|
||||
),
|
||||
if (PlatformInfos.isMobile)
|
||||
IconButton(
|
||||
onPressed: controller.shareFileAction,
|
||||
tooltip: L10n.of(context)!.share,
|
||||
color: Colors.white,
|
||||
icon: Icon(Icons.adaptive.share_outlined),
|
||||
)
|
||||
// Use builder context to correctly position the share dialog on iPad
|
||||
Builder(
|
||||
builder: (context) => IconButton(
|
||||
onPressed: () => controller.shareFileAction(context),
|
||||
tooltip: L10n.of(context)!.share,
|
||||
color: Colors.white,
|
||||
icon: Icon(Icons.adaptive.share_outlined),
|
||||
))
|
||||
],
|
||||
),
|
||||
body: InteractiveViewer(
|
||||
|
@ -26,10 +26,15 @@ extension MatrixFileExtension on MatrixFile {
|
||||
final tmpDirectory = await getTemporaryDirectory();
|
||||
final path = '${tmpDirectory.path}$fileName';
|
||||
await File(path).writeAsBytes(bytes);
|
||||
final box = context.findRenderObject() as RenderBox;
|
||||
|
||||
// Workaround for iPad from
|
||||
// https://github.com/fluttercommunity/plus_plugins/tree/main/packages/share_plus/share_plus#ipad
|
||||
final box = context.findRenderObject() as RenderBox?;
|
||||
|
||||
await Share.shareFiles(
|
||||
[path],
|
||||
sharePositionOrigin: box.localToGlobal(Offset.zero) & box.size,
|
||||
sharePositionOrigin:
|
||||
box == null ? null : box.localToGlobal(Offset.zero) & box.size,
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
@ -1506,7 +1506,7 @@ packages:
|
||||
name: share_plus
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "4.0.9"
|
||||
version: "4.0.10+1"
|
||||
share_plus_linux:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -78,7 +78,7 @@ dependencies:
|
||||
receive_sharing_intent: ^1.4.5
|
||||
record: ^4.3.2
|
||||
scroll_to_index: ^3.0.1
|
||||
share_plus: ^4.0.9
|
||||
share_plus: ^4.0.10+1
|
||||
shared_preferences: ^2.0.13
|
||||
slugify: ^2.0.0
|
||||
swipe_to_action: ^0.2.0
|
||||
|
Loading…
Reference in New Issue
Block a user