60 lines
2.0 KiB
Plaintext
60 lines
2.0 KiB
Plaintext
void _showParticipantsDialog(BuildContext context) {
|
|
showDialog(
|
|
context: context,
|
|
builder: (context) => AlertDialog(
|
|
title: const Text('Participants'),
|
|
content: SizedBox(
|
|
width: double.maxFinite,
|
|
child: FutureBuilder<List<User>>(
|
|
future: UserRepository().getUsersByIds([
|
|
...widget.trip.participants,
|
|
widget.trip.createdBy,
|
|
]),
|
|
builder: (context, snapshot) {
|
|
if (snapshot.connectionState == ConnectionState.waiting) {
|
|
return const Center(child: CircularProgressIndicator());
|
|
}
|
|
|
|
if (snapshot.hasError) {
|
|
return const Center(child: Text('Erreur de chargement'));
|
|
}
|
|
|
|
final users = snapshot.data ?? [];
|
|
if (users.isEmpty) {
|
|
return const Center(child: Text('Aucun participant trouvé'));
|
|
}
|
|
|
|
return ListView.builder(
|
|
shrinkWrap: true,
|
|
itemCount: users.length,
|
|
itemBuilder: (context, index) {
|
|
final user = users[index];
|
|
final isCreator = user.id == widget.trip.createdBy;
|
|
|
|
return ListTile(
|
|
leading: CircleAvatar(
|
|
backgroundImage: user.photoUrl != null
|
|
? NetworkImage(user.photoUrl!)
|
|
: null,
|
|
child: user.photoUrl == null
|
|
? Text(user.initials)
|
|
: null,
|
|
),
|
|
title: Text(user.fullName),
|
|
subtitle: isCreator ? const Text('Organisateur') : null,
|
|
);
|
|
},
|
|
);
|
|
},
|
|
),
|
|
),
|
|
actions: [
|
|
TextButton(
|
|
onPressed: () => Navigator.pop(context),
|
|
child: const Text('Fermer'),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|