feat: Paste image from clipboard on desktop/web

This commit is contained in:
Alexey 2026-03-20 14:38:41 +03:00
commit aea906f801
11 changed files with 56 additions and 1 deletions

View file

@ -1618,6 +1618,11 @@
"type": "String",
"placeholders": {}
},
"pasteImage": "Image from clipboard",
"@pasteImage": {
"type": "String",
"placeholders": {}
},
"sendImages": "Send {count} image",
"@sendImages": {
"type": "String",

View file

@ -1452,6 +1452,11 @@
"type": "String",
"placeholders": {}
},
"pasteImage": "Изображение из буфера обмена",
"@pasteImage": {
"type": "String",
"placeholders": {}
},
"sendMessages": "Отправить сообщения",
"@sendMessages": {
"type": "String",
@ -2695,4 +2700,4 @@
}
}
}
}
}

View file

@ -14,6 +14,7 @@ import 'package:go_router/go_router.dart';
import 'package:image_picker/image_picker.dart';
import 'package:matrix/matrix.dart';
import 'package:scroll_to_index/scroll_to_index.dart';
import 'package:pasteboard/pasteboard.dart';
import 'package:fluffychat/config/setting_keys.dart';
import 'package:fluffychat/config/themes.dart';
@ -643,6 +644,11 @@ class ChatController extends State<ChatPageWithRoom>
);
}
Future<void> sendImageFromClipBoardAction() async {
final image = await Pasteboard.image;
await sendImageFromClipBoard(image);
}
Future<void> sendImageFromClipBoard(Uint8List? image) async {
if (image == null) return;
await showAdaptiveDialog(
@ -1219,6 +1225,9 @@ class ChatController extends State<ChatPageWithRoom>
case AddPopupMenuActions.location:
sendLocationAction();
return;
case AddPopupMenuActions.pasteImage:
sendImageFromClipBoardAction();
return;
}
}
@ -1421,4 +1430,5 @@ enum AddPopupMenuActions {
photoCamera,
videoCamera,
location,
pasteImage,
}

View file

@ -172,6 +172,21 @@ class ChatInputRow extends StatelessWidget {
contentPadding: const EdgeInsets.all(0),
),
),
if (!PlatformInfos.isMobile)
PopupMenuItem(
value: AddPopupMenuActions.pasteImage,
child: ListTile(
leading: CircleAvatar(
backgroundColor:
theme.colorScheme.onPrimaryContainer,
foregroundColor:
theme.colorScheme.primaryContainer,
child: const Icon(Icons.content_paste),
),
title: Text(L10n.of(context).pasteImage),
contentPadding: const EdgeInsets.all(0),
),
),
PopupMenuItem(
value: AddPopupMenuActions.image,
child: ListTile(