Added reaction overview with list of names who reacted
This commit is contained in:
@ -18,6 +18,7 @@ import '../../../theming/appTheme.dart';
|
||||
import '../../../widget/debug/debugTile.dart';
|
||||
import '../files/fileElement.dart';
|
||||
import 'chatMessage.dart';
|
||||
import 'messageReactions.dart';
|
||||
|
||||
class ChatBubble extends StatefulWidget {
|
||||
final BuildContext context;
|
||||
@ -199,6 +200,20 @@ class _ChatBubbleState extends State<ChatBubble> {
|
||||
),
|
||||
],
|
||||
),
|
||||
const Divider(),
|
||||
Visibility(
|
||||
visible: true,
|
||||
child: ListTile(
|
||||
leading: const Icon(Icons.add_reaction_outlined),
|
||||
title: const Text("Reaktionen"),
|
||||
onTap: () {
|
||||
Navigator.of(context).push(MaterialPageRoute(builder: (context) => MessageReactions(
|
||||
token: widget.chatData.token,
|
||||
messageId: widget.bubbleData.id,
|
||||
)));
|
||||
},
|
||||
),
|
||||
),
|
||||
Visibility(
|
||||
visible: !message.containsFile && widget.bubbleData.messageType == GetRoomResponseObjectMessageType.comment,
|
||||
child: ListTile(
|
||||
|
73
lib/view/pages/talk/messageReactions.dart
Normal file
73
lib/view/pages/talk/messageReactions.dart
Normal file
@ -0,0 +1,73 @@
|
||||
import 'dart:developer';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../api/marianumcloud/talk/getReactions/getReactions.dart';
|
||||
import '../../../api/marianumcloud/talk/getReactions/getReactionsResponse.dart';
|
||||
import '../../../model/accountData.dart';
|
||||
import '../../../widget/centeredLeading.dart';
|
||||
import '../../../widget/loadingSpinner.dart';
|
||||
import '../../../widget/unimplementedDialog.dart';
|
||||
|
||||
class MessageReactions extends StatefulWidget {
|
||||
final String token;
|
||||
final int messageId;
|
||||
const MessageReactions({super.key, required this.token, required this.messageId});
|
||||
|
||||
@override
|
||||
State<MessageReactions> createState() => _MessageReactionsState();
|
||||
}
|
||||
|
||||
class _MessageReactionsState extends State<MessageReactions> {
|
||||
late Future<GetReactionsResponse> data;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
data = GetReactions(chatToken: widget.token, messageId: widget.messageId).run();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text("Reaktionen"),
|
||||
),
|
||||
body: FutureBuilder(
|
||||
future: data,
|
||||
builder: (context, snapshot) {
|
||||
if(snapshot.data == null) return const LoadingSpinner();
|
||||
log(snapshot.data!.toJson().toString());
|
||||
return ListView(
|
||||
children: [
|
||||
...snapshot.data!.data.entries.map<Widget>((entry) {
|
||||
return ExpansionTile(
|
||||
textColor: Theme.of(context).colorScheme.onSurface,
|
||||
collapsedTextColor: Theme.of(context).colorScheme.onSurface,
|
||||
iconColor: Theme.of(context).colorScheme.onSurface,
|
||||
collapsedIconColor: Theme.of(context).colorScheme.onSurface,
|
||||
|
||||
subtitle: const Text("Tippe für mehr"),
|
||||
leading: Text(entry.key),
|
||||
title: Text("${entry.value.length} mal reagiert"),
|
||||
children: entry.value.map((e) {
|
||||
bool isSelf = AccountData().getUsername() == e.actorId;
|
||||
return ListTile(
|
||||
leading: const CenteredLeading(Icon(Icons.person)),
|
||||
title: Text(e.actorDisplayName),
|
||||
subtitle: isSelf ? const Text("Du") : e.actorType == GetReactionsResponseObjectActorType.guests ? const Text("Gast") : null,
|
||||
trailing: isSelf ? null : IconButton(
|
||||
onPressed: () => UnimplementedDialog.show(context),
|
||||
icon: const Icon(Icons.textsms_outlined),
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
);
|
||||
}).toList()
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user