feat: Add full-screen receipt viewer, display trip participants in calendar, and restrict trip management options to creator.
This commit is contained in:
@@ -7,6 +7,8 @@ import '../../../models/activity.dart';
|
||||
import '../../../blocs/activity/activity_bloc.dart';
|
||||
import '../../../blocs/activity/activity_state.dart';
|
||||
import '../../../blocs/activity/activity_event.dart';
|
||||
import '../../../repositories/user_repository.dart';
|
||||
import '../../../models/user.dart';
|
||||
|
||||
class CalendarPage extends StatefulWidget {
|
||||
final Trip trip;
|
||||
@@ -93,7 +95,7 @@ class _CalendarPageState extends State<CalendarPage> {
|
||||
actions: [
|
||||
IconButton(
|
||||
icon: Icon(Icons.people, color: theme.colorScheme.onSurface),
|
||||
onPressed: () {}, // TODO: Show participants
|
||||
onPressed: () => _showParticipantsDialog(context),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -419,4 +421,67 @@ class _CalendarPageState extends State<CalendarPage> {
|
||||
}
|
||||
return Icons.place;
|
||||
}
|
||||
|
||||
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.profilePictureUrl != null
|
||||
? NetworkImage(user.profilePictureUrl!)
|
||||
: null,
|
||||
child: user.profilePictureUrl == null
|
||||
? Text(
|
||||
'${user.prenom.isNotEmpty ? user.prenom[0] : ''}${user.nom.isNotEmpty ? user.nom[0] : ''}'
|
||||
.toUpperCase(),
|
||||
)
|
||||
: null,
|
||||
),
|
||||
title: Text(user.fullName),
|
||||
subtitle: isCreator ? const Text('Organisateur') : null,
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(context),
|
||||
child: const Text('Fermer'),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
59
lib/components/home/calendar/calendar_page.dart_snippet
Normal file
59
lib/components/home/calendar/calendar_page.dart_snippet
Normal file
@@ -0,0 +1,59 @@
|
||||
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'),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user