feat: Add full-screen receipt viewer, display trip participants in calendar, and restrict trip management options to creator.
This commit is contained in:
@@ -322,7 +322,40 @@ class ExpenseDetailDialog extends StatelessWidget {
|
|||||||
color: Colors.transparent,
|
color: Colors.transparent,
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
// TODO: Show full screen image
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (context) => Dialog(
|
||||||
|
backgroundColor: Colors.transparent,
|
||||||
|
insetPadding: EdgeInsets.zero,
|
||||||
|
child: Stack(
|
||||||
|
alignment: Alignment.center,
|
||||||
|
children: [
|
||||||
|
InteractiveViewer(
|
||||||
|
minScale: 0.5,
|
||||||
|
maxScale: 4.0,
|
||||||
|
child: Image.network(
|
||||||
|
expense.receiptUrl!,
|
||||||
|
fit: BoxFit.contain,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Positioned(
|
||||||
|
top: 40,
|
||||||
|
right: 20,
|
||||||
|
child: IconButton(
|
||||||
|
icon: const Icon(
|
||||||
|
Icons.close,
|
||||||
|
color: Colors.white,
|
||||||
|
size: 30,
|
||||||
|
),
|
||||||
|
onPressed: () => Navigator.of(
|
||||||
|
context,
|
||||||
|
).pop(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ import '../../../models/activity.dart';
|
|||||||
import '../../../blocs/activity/activity_bloc.dart';
|
import '../../../blocs/activity/activity_bloc.dart';
|
||||||
import '../../../blocs/activity/activity_state.dart';
|
import '../../../blocs/activity/activity_state.dart';
|
||||||
import '../../../blocs/activity/activity_event.dart';
|
import '../../../blocs/activity/activity_event.dart';
|
||||||
|
import '../../../repositories/user_repository.dart';
|
||||||
|
import '../../../models/user.dart';
|
||||||
|
|
||||||
class CalendarPage extends StatefulWidget {
|
class CalendarPage extends StatefulWidget {
|
||||||
final Trip trip;
|
final Trip trip;
|
||||||
@@ -93,7 +95,7 @@ class _CalendarPageState extends State<CalendarPage> {
|
|||||||
actions: [
|
actions: [
|
||||||
IconButton(
|
IconButton(
|
||||||
icon: Icon(Icons.people, color: theme.colorScheme.onSurface),
|
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;
|
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'),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter/services.dart';
|
||||||
|
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:travel_mate/blocs/trip/trip_bloc.dart';
|
import 'package:travel_mate/blocs/trip/trip_bloc.dart';
|
||||||
@@ -589,13 +590,25 @@ class _ShowTripDetailsContentState extends State<ShowTripDetailsContent> {
|
|||||||
shape: const RoundedRectangleBorder(
|
shape: const RoundedRectangleBorder(
|
||||||
borderRadius: BorderRadius.vertical(top: Radius.circular(20)),
|
borderRadius: BorderRadius.vertical(top: Radius.circular(20)),
|
||||||
),
|
),
|
||||||
builder: (context) => Container(
|
builder: (context) {
|
||||||
|
return BlocBuilder<UserBloc, user_state.UserState>(
|
||||||
|
builder: (context, state) {
|
||||||
|
final currentUser = state is user_state.UserLoaded
|
||||||
|
? state.user
|
||||||
|
: null;
|
||||||
|
final isCreator = currentUser?.id == widget.trip.createdBy;
|
||||||
|
|
||||||
|
return Container(
|
||||||
padding: const EdgeInsets.all(20),
|
padding: const EdgeInsets.all(20),
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: [
|
children: [
|
||||||
|
if (isCreator) ...[
|
||||||
ListTile(
|
ListTile(
|
||||||
leading: Icon(Icons.edit, color: theme.colorScheme.primary),
|
leading: Icon(
|
||||||
|
Icons.edit,
|
||||||
|
color: theme.colorScheme.primary,
|
||||||
|
),
|
||||||
title: Text(
|
title: Text(
|
||||||
'Modifier le voyage',
|
'Modifier le voyage',
|
||||||
style: theme.textTheme.bodyLarge?.copyWith(
|
style: theme.textTheme.bodyLarge?.copyWith(
|
||||||
@@ -617,22 +630,59 @@ class _ShowTripDetailsContentState extends State<ShowTripDetailsContent> {
|
|||||||
leading: const Icon(Icons.delete, color: Colors.red),
|
leading: const Icon(Icons.delete, color: Colors.red),
|
||||||
title: Text(
|
title: Text(
|
||||||
'Supprimer le voyage',
|
'Supprimer le voyage',
|
||||||
|
style: theme.textTheme.bodyLarge?.copyWith(
|
||||||
|
color: Colors.red,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
onTap: () {
|
||||||
|
Navigator.pop(context);
|
||||||
|
_confirmDeleteTrip();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
const Divider(),
|
||||||
|
],
|
||||||
|
ListTile(
|
||||||
|
leading: Icon(
|
||||||
|
Icons.share,
|
||||||
|
color: theme.colorScheme.onSurface,
|
||||||
|
),
|
||||||
|
title: Text(
|
||||||
|
'Partager le code',
|
||||||
style: theme.textTheme.bodyLarge?.copyWith(
|
style: theme.textTheme.bodyLarge?.copyWith(
|
||||||
color: theme.colorScheme.onSurface,
|
color: theme.colorScheme.onSurface,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
_showDeleteConfirmation();
|
// Implement share functionality
|
||||||
|
if (_group != null) {
|
||||||
|
// Use share_plus package to share the code
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
|
SnackBar(
|
||||||
|
content: Text('ID du groupe : ${_group!.id}'),
|
||||||
|
action: SnackBarAction(
|
||||||
|
label: 'Copier',
|
||||||
|
onPressed: () {
|
||||||
|
Clipboard.setData(
|
||||||
|
ClipboardData(text: _group!.id),
|
||||||
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
void _showDeleteConfirmation() {
|
void _confirmDeleteTrip() {
|
||||||
final theme = Theme.of(context);
|
final theme = Theme.of(context);
|
||||||
|
|
||||||
showDialog(
|
showDialog(
|
||||||
|
|||||||
@@ -150,4 +150,43 @@ class UserRepository {
|
|||||||
throw Exception('Impossible de changer le mot de passe');
|
throw Exception('Impossible de changer le mot de passe');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Récupérer plusieurs utilisateurs par leurs IDs
|
||||||
|
Future<List<User>> getUsersByIds(List<String> uids) async {
|
||||||
|
if (uids.isEmpty) return [];
|
||||||
|
|
||||||
|
try {
|
||||||
|
// Firestore 'in' query supports up to 10 values.
|
||||||
|
// If we have more, we need to split into chunks.
|
||||||
|
List<User> users = [];
|
||||||
|
|
||||||
|
// Remove duplicates
|
||||||
|
final uniqueIds = uids.toSet().toList();
|
||||||
|
|
||||||
|
// Split into chunks of 10
|
||||||
|
for (var i = 0; i < uniqueIds.length; i += 10) {
|
||||||
|
final end = (i + 10 < uniqueIds.length) ? i + 10 : uniqueIds.length;
|
||||||
|
final chunk = uniqueIds.sublist(i, end);
|
||||||
|
|
||||||
|
final querySnapshot = await _firestore
|
||||||
|
.collection('users')
|
||||||
|
.where(FieldPath.documentId, whereIn: chunk)
|
||||||
|
.get();
|
||||||
|
|
||||||
|
for (var doc in querySnapshot.docs) {
|
||||||
|
final data = doc.data();
|
||||||
|
users.add(User.fromMap({...data, 'id': doc.id}));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return users;
|
||||||
|
} catch (e, stackTrace) {
|
||||||
|
_errorService.logError(
|
||||||
|
'UserRepository',
|
||||||
|
'Error retrieving users by IDs: $e',
|
||||||
|
stackTrace,
|
||||||
|
);
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import 'dart:convert';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
import 'package:cloud_firestore/cloud_firestore.dart';
|
import 'package:cloud_firestore/cloud_firestore.dart';
|
||||||
import 'package:firebase_messaging/firebase_messaging.dart';
|
import 'package:firebase_messaging/firebase_messaging.dart';
|
||||||
@@ -49,7 +50,14 @@ class NotificationService {
|
|||||||
onDidReceiveNotificationResponse: (details) {
|
onDidReceiveNotificationResponse: (details) {
|
||||||
// Handle notification tap
|
// Handle notification tap
|
||||||
LoggerService.info('Notification tapped: ${details.payload}');
|
LoggerService.info('Notification tapped: ${details.payload}');
|
||||||
// TODO: Handle local notification tap if needed, usually we rely on FCM callbacks
|
if (details.payload != null) {
|
||||||
|
try {
|
||||||
|
final data = json.decode(details.payload!) as Map<String, dynamic>;
|
||||||
|
_handleNotificationTap(data);
|
||||||
|
} catch (e) {
|
||||||
|
LoggerService.error('Error parsing notification payload', error: e);
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user