feat: Implement polls

This commit is contained in:
Christian Kußowski 2025-11-02 13:10:55 +01:00
commit 71fa853f05
No known key found for this signature in database
GPG key ID: E067ECD60F1A0652
12 changed files with 582 additions and 63 deletions

View file

@ -20,7 +20,9 @@ import 'package:fluffychat/config/themes.dart';
import 'package:fluffychat/l10n/l10n.dart';
import 'package:fluffychat/pages/chat/chat_view.dart';
import 'package:fluffychat/pages/chat/event_info_dialog.dart';
import 'package:fluffychat/pages/chat/start_poll_bottom_sheet.dart';
import 'package:fluffychat/pages/chat_details/chat_details.dart';
import 'package:fluffychat/utils/adaptive_bottom_sheet.dart';
import 'package:fluffychat/utils/error_reporter.dart';
import 'package:fluffychat/utils/file_selector.dart';
import 'package:fluffychat/utils/matrix_sdk_extensions/event_extension.dart';
@ -1138,26 +1140,34 @@ class ChatController extends State<ChatPageWithRoom>
FocusScope.of(context).requestFocus(inputFocus);
}
void onAddPopupMenuButtonSelected(String choice) {
room.client.getConfig(); // Preload server file configuration.
void onAddPopupMenuButtonSelected(AddPopupMenuActions choice) {
room.client.getConfig();
if (choice == 'file') {
sendFileAction();
}
if (choice == 'image') {
sendFileAction(type: FileSelectorType.images);
}
if (choice == 'video') {
sendFileAction(type: FileSelectorType.videos);
}
if (choice == 'camera') {
openCameraAction();
}
if (choice == 'camera-video') {
openVideoCameraAction();
}
if (choice == 'location') {
sendLocationAction();
switch (choice) {
case AddPopupMenuActions.image:
sendFileAction(type: FileSelectorType.images);
return;
case AddPopupMenuActions.video:
sendFileAction(type: FileSelectorType.videos);
return;
case AddPopupMenuActions.file:
sendFileAction();
return;
case AddPopupMenuActions.poll:
showAdaptiveBottomSheet(
context: context,
builder: (context) => StartPollBottomSheet(room: room),
);
return;
case AddPopupMenuActions.photoCamera:
openCameraAction();
return;
case AddPopupMenuActions.videoCamera:
openVideoCameraAction();
return;
case AddPopupMenuActions.location:
sendLocationAction();
return;
}
}
@ -1358,3 +1368,13 @@ class ChatController extends State<ChatPageWithRoom>
);
}
}
enum AddPopupMenuActions {
image,
video,
file,
poll,
photoCamera,
videoCamera,
location,
}