feat: Add sticker picker

This commit is contained in:
Sorunome 2021-07-23 14:24:52 +02:00 committed by Christian Pauly
commit 1e98fdd7b0
4 changed files with 180 additions and 1 deletions

View file

@ -28,6 +28,7 @@ import 'package:vrouter/vrouter.dart';
import '../utils/localized_exception_extension.dart';
import 'send_file_dialog.dart';
import 'sticker_picker_dialog.dart';
import '../utils/matrix_sdk_extensions.dart/filtered_timeline_extension.dart';
import '../utils/matrix_sdk_extensions.dart/matrix_file_extension.dart';
@ -308,6 +309,28 @@ class ChatController extends State<Chat> {
);
}
void sendStickerAction() async {
final sticker = await showModalBottomSheet<ImagePackImageContent>(
context: context,
useRootNavigator: false,
builder: (c) => StickerPickerDialog(room: room),
);
if (sticker == null) return;
final eventContent = <String, dynamic>{
'body': sticker.body,
if (sticker.info != null) 'info': sticker.info,
'url': sticker.url.toString(),
};
// send the sticker
await showFutureLoadingDialog(
context: context,
future: () => room.sendEvent(
eventContent,
type: EventTypes.Sticker,
),
);
}
void voiceMessageAction() async {
if (await Permission.microphone.isGranted != true) {
final status = await Permission.microphone.request();
@ -645,12 +668,16 @@ class ChatController extends State<Chat> {
void onAddPopupMenuButtonSelected(String choice) {
if (choice == 'file') {
sendFileAction();
} else if (choice == 'image') {
}
if (choice == 'image') {
sendImageAction();
}
if (choice == 'camera') {
openCameraAction();
}
if (choice == 'sticker') {
sendStickerAction();
}
if (choice == 'voice') {
voiceMessageAction();
}