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