96 lines
3.3 KiB
Dart
96 lines
3.3 KiB
Dart
import 'package:flutter/foundation.dart';
|
|
import 'package:flutter/material.dart';
|
|
|
|
import '../../../../api/marianumcloud/talk/get_reactions/get_reactions.dart';
|
|
import '../../../../api/marianumcloud/talk/get_reactions/get_reactions_response.dart';
|
|
import '../../../../model/account_data.dart';
|
|
import '../../../../widget/centered_leading.dart';
|
|
import '../../../../widget/loading_spinner.dart';
|
|
import '../../../../widget/placeholder_view.dart';
|
|
import '../../../../widget/unimplemented_dialog.dart';
|
|
import '../../../../widget/user_avatar.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) => Scaffold(
|
|
appBar: AppBar(title: const Text('Reaktionen')),
|
|
body: FutureBuilder(
|
|
future: data,
|
|
builder: (context, snapshot) {
|
|
if (snapshot.connectionState == ConnectionState.waiting) {
|
|
return const LoadingSpinner();
|
|
}
|
|
if (snapshot.data!.data.isEmpty) {
|
|
return const PlaceholderView(
|
|
icon: Icons.search_off_outlined,
|
|
text: 'Keine Reaktionen gefunden!',
|
|
);
|
|
}
|
|
return ListView(
|
|
children: [
|
|
...snapshot.data!.data.entries.map<Widget>(
|
|
(entry) => 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: CenteredLeading(Text(entry.key)),
|
|
title: Text('${entry.value.length} mal reagiert'),
|
|
children: entry.value.map((e) {
|
|
var isSelf = AccountData().getUsername() == e.actorId;
|
|
return ListTile(
|
|
leading: UserAvatar(id: e.actorId, isGroup: false),
|
|
title: Text(e.actorDisplayName),
|
|
subtitle: isSelf
|
|
? const Text('Du')
|
|
: e.actorType ==
|
|
GetReactionsResponseObjectActorType.guests
|
|
? const Text('Gast')
|
|
: null,
|
|
trailing: isSelf
|
|
? null
|
|
: Visibility(
|
|
visible: kReleaseMode,
|
|
child: IconButton(
|
|
onPressed: () =>
|
|
UnimplementedDialog.show(context),
|
|
icon: const Icon(Icons.textsms_outlined),
|
|
),
|
|
),
|
|
);
|
|
}).toList(),
|
|
),
|
|
),
|
|
],
|
|
);
|
|
},
|
|
),
|
|
);
|
|
}
|