sorted participants list alphabetically #87
| @@ -3,26 +3,28 @@ import 'package:flutter/material.dart'; | ||||
| import '../../../../../api/marianumcloud/talk/getParticipants/getParticipantsResponse.dart'; | ||||
| import '../../../../../widget/userAvatar.dart'; | ||||
|  | ||||
| class ParticipantsListView extends StatefulWidget { | ||||
| class ParticipantsListView extends StatelessWidget { | ||||
|   final GetParticipantsResponse participantsResponse; | ||||
|   const ParticipantsListView(this.participantsResponse, {super.key}); | ||||
|  | ||||
|   @override | ||||
|   State<ParticipantsListView> createState() => _ParticipantsListViewState(); | ||||
| } | ||||
|   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(); | ||||
|  | ||||
| class _ParticipantsListViewState extends State<ParticipantsListView> { | ||||
|   @override | ||||
|   Widget build(BuildContext context) => Scaffold( | ||||
|     lastname(participant) => participant.title.toString().split(' ').last; | ||||
|     participants.sort((a, b) => lastname(a).compareTo(lastname(b))); | ||||
|  | ||||
|     return Scaffold( | ||||
|       appBar: AppBar( | ||||
|         title: const Text('Teilnehmende'), | ||||
|       ), | ||||
| 
					
					Pupsi marked this conversation as resolved
					
						
						
							Outdated
						
					
				 | ||||
|       body: ListView( | ||||
|         children: widget.participantsResponse.data.map((participant) => ListTile( | ||||
|             leading: UserAvatar(id: participant.actorId), | ||||
|             title: Text(participant.displayName), | ||||
|             subtitle: participant.statusMessage != null ? Text(participant.statusMessage!) : null, | ||||
|           )).toList(), | ||||
|         children: participants, | ||||
|       ), | ||||
|     ); | ||||
|   } | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	
ggf. kann das sort aus der Build methode rausgezogen werden und das Widget zu einem Stateless werden