From e42999994bf1900ee862fff2fa8e0ff1848017c2 Mon Sep 17 00:00:00 2001 From: sherlock Date: Wed, 11 Oct 2023 13:51:32 +0700 Subject: [PATCH] TW-731: support copy/paste in windows, linux platform --- lib/pages/chat/input_bar.dart | 5 +++-- lib/utils/platform_infos.dart | 7 +++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/pages/chat/input_bar.dart b/lib/pages/chat/input_bar.dart index 1143a471d3..166877a8c1 100644 --- a/lib/pages/chat/input_bar.dart +++ b/lib/pages/chat/input_bar.dart @@ -320,9 +320,10 @@ class InputBar extends StatelessWidget with PasteImageMixin { }, child: CallbackShortcuts( bindings: { - const SingleActivator( + SingleActivator( flutter.LogicalKeyboardKey.keyV, - meta: true, + meta: PlatformInfos.isMacKeyboardPlatform, + control: !PlatformInfos.isMacKeyboardPlatform, ): () async { if (await Clipboard.instance.isReadableImageFormat()) { await pasteImage(context, room!); diff --git a/lib/utils/platform_infos.dart b/lib/utils/platform_infos.dart index 0ec701355e..8c8cd1a97c 100644 --- a/lib/utils/platform_infos.dart +++ b/lib/utils/platform_infos.dart @@ -5,6 +5,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_gen/gen_l10n/l10n.dart'; import 'package:go_router/go_router.dart'; import 'package:package_info_plus/package_info_plus.dart'; +import 'package:universal_html/html.dart' as html; import '../config/app_config.dart'; abstract class PlatformInfos { @@ -28,6 +29,12 @@ abstract class PlatformInfos { static bool get platformCanRecord => (isMobile || isMacOS); + static bool get isMacKeyboardPlatform => + isMacOS && + (kIsWeb && + html.window.navigator.platform != null && + html.window.navigator.platform!.contains('mac')); + static String get clientName => '${AppConfig.applicationName} ${isWeb ? 'web' : Platform.operatingSystem}${kReleaseMode ? '' : 'Debug'}';