diff --git a/lib/api/marianumcloud/talk/getParticipants/getParticipantsResponse.dart b/lib/api/marianumcloud/talk/getParticipants/getParticipantsResponse.dart index 1be47ce..0a8468c 100644 --- a/lib/api/marianumcloud/talk/getParticipants/getParticipantsResponse.dart +++ b/lib/api/marianumcloud/talk/getParticipants/getParticipantsResponse.dart @@ -55,12 +55,15 @@ class GetParticipantsResponseObject { } enum GetParticipantsResponseObjectParticipantType { - @JsonValue(1) owner, - @JsonValue(2) moderator, - @JsonValue(3) user, - @JsonValue(4) guest, - @JsonValue(5) userFollowingPublicLink, - @JsonValue(6) guestWithModeratorPermissions + @JsonValue(1) owner('Besitzer'), + @JsonValue(2) moderator('Moderator'), + @JsonValue(3) user('Benutzer'), + @JsonValue(4) guest('Gast'), + @JsonValue(5) userFollowingPublicLink('Link Nutzer'), + @JsonValue(6) guestWithModeratorPermissions('Gast Moderator'); + + const GetParticipantsResponseObjectParticipantType(this.prettyName); + final String prettyName; } enum GetParticipantsResponseObjectParticipantsInCallFlags { diff --git a/lib/view/pages/talk/chatDetails/participants/participantsListView.dart b/lib/view/pages/talk/chatDetails/participants/participantsListView.dart index fd6013a..01f49ee 100644 --- a/lib/view/pages/talk/chatDetails/participants/participantsListView.dart +++ b/lib/view/pages/talk/chatDetails/participants/participantsListView.dart @@ -1,3 +1,4 @@ +import 'package:collection/collection.dart'; import 'package:flutter/material.dart'; import '../../../../../api/marianumcloud/talk/getParticipants/getParticipantsResponse.dart'; @@ -9,22 +10,43 @@ class ParticipantsListView extends StatelessWidget { @override Widget build(BuildContext context) { - final participants = participantsResponse.data.map((participant) => ListTile( - leading: UserAvatar(id: participant.actorId), - title: Text(participant.displayName), - subtitle: participant.statusMessage != null ? Text(participant.statusMessage!) : null, - )).toList(); + // final participants = participantsResponse.data.map((participant) => ListTile( + // leading: UserAvatar(id: participant.actorId), + // title: Text(participant.displayName), + // subtitle: participant.statusMessage != null ? Text(participant.statusMessage!) : null, + // )).toList(); - lastname(participant) => participant.title.toString().split(' ').last; - participants.sort((a, b) => lastname(a).compareTo(lastname(b))); + lastname(participant) => participant.displayName.toString().split(' ').last; + + final participants = participantsResponse.data + .sorted((a, b) => lastname(a).compareTo(lastname(b))) + .sorted((a, b) => a.participantType.index.compareTo(b.participantType.index)); + var groupedParticipants = participants.groupListsBy((participant) => participant.participantType); + + // Map> return Scaffold( appBar: AppBar( title: const Text('Teilnehmende'), ), body: ListView( - children: participants, - ), + children: [ + ...groupedParticipants.entries.map((entry) => Column( + children: [ + ListTile( + title: Text(entry.key.prettyName), + titleTextStyle: TextStyle(fontWeight: FontWeight.bold), + ), + ...entry.value.map((participant) => ListTile( + leading: UserAvatar(id: participant.actorId), + title: Text(participant.displayName), + subtitle: participant.statusMessage != null ? Text(participant.statusMessage!) : null, + )), + Divider(), + ], + )) + ], + ) ); } } diff --git a/pubspec.yaml b/pubspec.yaml index fe83157..842dcb8 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -101,6 +101,7 @@ dependencies: time_range_picker: ^2.3.0 url_launcher: ^6.3.1 uuid: ^4.5.1 + collection: ^1.19.0 dev_dependencies: flutter_test: