implemented full interactive poll support in Talk, including creation, voting, and closing functionality
This commit is contained in:
@@ -5,6 +5,7 @@ import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:nextcloud/nextcloud.dart';
|
||||
import 'package:persistent_bottom_nav_bar_v2/persistent_bottom_nav_bar_v2.dart';
|
||||
|
||||
import '../../../../api/marianumcloud/talk/room/get_room_response.dart';
|
||||
import '../../../../api/marianumcloud/talk/send_message/send_message.dart';
|
||||
import '../../../../api/marianumcloud/talk/send_message/send_message_params.dart';
|
||||
import '../../../../api/marianumcloud/talk/share_files_to_chat.dart';
|
||||
@@ -20,12 +21,19 @@ import '../../../../widget/file_pick.dart';
|
||||
import '../../../../widget/focus_behaviour.dart';
|
||||
import '../../files/files_upload_dialog.dart';
|
||||
import 'answer_reference.dart';
|
||||
import 'poll_create_sheet.dart';
|
||||
|
||||
class ChatTextfield extends StatefulWidget {
|
||||
final String sendToToken;
|
||||
final String? selfId;
|
||||
final GetRoomResponseObjectConversationType? roomType;
|
||||
|
||||
const ChatTextfield(this.sendToToken, {this.selfId, super.key});
|
||||
const ChatTextfield(
|
||||
this.sendToToken, {
|
||||
this.selfId,
|
||||
this.roomType,
|
||||
super.key,
|
||||
});
|
||||
|
||||
@override
|
||||
State<ChatTextfield> createState() => _ChatTextfieldState();
|
||||
@@ -160,10 +168,31 @@ class _ChatTextfieldState extends State<ChatTextfield> {
|
||||
Navigator.of(sheetCtx).pop();
|
||||
},
|
||||
),
|
||||
if (_pollsAllowed)
|
||||
ListTile(
|
||||
leading: const Icon(Icons.poll_outlined),
|
||||
title: const Text('Umfrage erstellen'),
|
||||
onTap: () {
|
||||
Navigator.of(sheetCtx).pop();
|
||||
showPollCreateSheet(
|
||||
context,
|
||||
token: widget.sendToToken,
|
||||
onCreated: () {
|
||||
if (mounted) context.read<ChatBloc>().refresh();
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
/// Polls can only be created in group/public conversations — the server
|
||||
/// rejects them in one-to-one chats.
|
||||
bool get _pollsAllowed =>
|
||||
widget.roomType == GetRoomResponseObjectConversationType.group ||
|
||||
widget.roomType == GetRoomResponseObjectConversationType.public;
|
||||
|
||||
Future<void> _pickEmoji() async {
|
||||
final emoji = await showEmojiPicker(context);
|
||||
if (emoji == null || !mounted) return;
|
||||
|
||||
Reference in New Issue
Block a user