feat: Add map navigation, enhance FCM deep linking, localize Google Places API, and refine activity display.
This commit is contained in:
@@ -20,7 +20,7 @@ class CalendarPage extends StatefulWidget {
|
||||
class _CalendarPageState extends State<CalendarPage> {
|
||||
late DateTime _focusedDay;
|
||||
DateTime? _selectedDay;
|
||||
CalendarFormat _calendarFormat = CalendarFormat.week;
|
||||
final CalendarFormat _calendarFormat = CalendarFormat.week;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -387,20 +387,25 @@ class _CalendarPageState extends State<CalendarPage> {
|
||||
// Simple mapping based on category name
|
||||
// You might want to use the enum if possible, but category is String in Activity model
|
||||
if (category.toLowerCase().contains('musée') ||
|
||||
category.toLowerCase().contains('museum'))
|
||||
category.toLowerCase().contains('museum')) {
|
||||
return Colors.blue;
|
||||
}
|
||||
if (category.toLowerCase().contains('restaurant') ||
|
||||
category.toLowerCase().contains('food'))
|
||||
category.toLowerCase().contains('food')) {
|
||||
return Colors.orange;
|
||||
}
|
||||
if (category.toLowerCase().contains('nature') ||
|
||||
category.toLowerCase().contains('park'))
|
||||
category.toLowerCase().contains('park')) {
|
||||
return Colors.green;
|
||||
}
|
||||
if (category.toLowerCase().contains('photo') ||
|
||||
category.toLowerCase().contains('attraction'))
|
||||
category.toLowerCase().contains('attraction')) {
|
||||
return Colors.purple;
|
||||
}
|
||||
if (category.toLowerCase().contains('détente') ||
|
||||
category.toLowerCase().contains('relax'))
|
||||
category.toLowerCase().contains('relax')) {
|
||||
return Colors.pink;
|
||||
}
|
||||
return Colors.teal;
|
||||
}
|
||||
|
||||
@@ -409,8 +414,9 @@ class _CalendarPageState extends State<CalendarPage> {
|
||||
if (category.toLowerCase().contains('restaurant')) return Icons.restaurant;
|
||||
if (category.toLowerCase().contains('nature')) return Icons.nature;
|
||||
if (category.toLowerCase().contains('photo')) return Icons.camera_alt;
|
||||
if (category.toLowerCase().contains('détente'))
|
||||
if (category.toLowerCase().contains('détente')) {
|
||||
return Icons.icecream; // Gelato icon :)
|
||||
}
|
||||
return Icons.place;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:travel_mate/blocs/trip/trip_bloc.dart';
|
||||
import 'package:travel_mate/blocs/trip/trip_event.dart';
|
||||
@@ -9,11 +9,14 @@ import 'package:travel_mate/components/home/create_trip_content.dart';
|
||||
import 'package:travel_mate/models/trip.dart';
|
||||
import 'package:travel_mate/components/map/map_content.dart';
|
||||
import 'package:travel_mate/services/error_service.dart';
|
||||
import 'package:travel_mate/services/logger_service.dart';
|
||||
|
||||
import 'package:travel_mate/repositories/group_repository.dart';
|
||||
import 'package:travel_mate/repositories/user_repository.dart';
|
||||
import 'package:travel_mate/repositories/account_repository.dart';
|
||||
import 'package:travel_mate/models/group_member.dart';
|
||||
import 'package:travel_mate/components/activities/activities_page.dart';
|
||||
import 'package:travel_mate/components/activities/activity_detail_dialog.dart';
|
||||
import 'package:travel_mate/components/home/calendar/calendar_page.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
@@ -22,7 +25,7 @@ import 'package:travel_mate/blocs/activity/activity_state.dart';
|
||||
import 'package:travel_mate/blocs/balance/balance_bloc.dart';
|
||||
import 'package:travel_mate/blocs/balance/balance_event.dart';
|
||||
import 'package:travel_mate/blocs/balance/balance_state.dart';
|
||||
import 'package:travel_mate/models/settlement.dart';
|
||||
|
||||
import 'package:travel_mate/blocs/user/user_bloc.dart';
|
||||
import 'package:travel_mate/blocs/user/user_state.dart' as user_state;
|
||||
import 'package:travel_mate/components/account/group_expenses_page.dart';
|
||||
@@ -238,30 +241,38 @@ class _ShowTripDetailsContentState extends State<ShowTripDetailsContent> {
|
||||
|
||||
// Méthode pour ouvrir Waze
|
||||
Future<void> _openWaze() async {
|
||||
final location = Uri.encodeComponent(widget.trip.location);
|
||||
|
||||
try {
|
||||
// Essayer d'abord l'URL scheme pour l'app mobile
|
||||
final appUrl = 'waze://?q=$location';
|
||||
final appUri = Uri.parse(appUrl);
|
||||
if (await canLaunchUrl(appUri)) {
|
||||
await launchUrl(appUri);
|
||||
return;
|
||||
String wazeUrl;
|
||||
|
||||
// Utiliser les coordonnées si disponibles (plus précis)
|
||||
if (widget.trip.latitude != null && widget.trip.longitude != null) {
|
||||
final lat = widget.trip.latitude;
|
||||
final lng = widget.trip.longitude;
|
||||
// Format: https://www.waze.com/ul?ll=lat%2Clng&navigate=yes
|
||||
wazeUrl = 'https://www.waze.com/ul?ll=$lat%2C$lng&navigate=yes';
|
||||
LoggerService.info('Opening Waze with coordinates: $lat, $lng');
|
||||
} else {
|
||||
// Fallback sur l'adresse/nom
|
||||
final location = Uri.encodeComponent(widget.trip.location);
|
||||
wazeUrl = 'https://www.waze.com/ul?q=$location&navigate=yes';
|
||||
LoggerService.info(
|
||||
'Opening Waze with location query: ${widget.trip.location}',
|
||||
);
|
||||
}
|
||||
|
||||
// Fallback vers l'URL web
|
||||
final webUrl = 'https://waze.com/ul?q=$location';
|
||||
final webUri = Uri.parse(webUrl);
|
||||
if (await canLaunchUrl(webUri)) {
|
||||
await launchUrl(webUri, mode: LaunchMode.externalApplication);
|
||||
return;
|
||||
}
|
||||
final uri = Uri.parse(wazeUrl);
|
||||
|
||||
_errorService.showError(
|
||||
message:
|
||||
'Impossible d\'ouvrir Waze. Vérifiez que l\'application est installée.',
|
||||
);
|
||||
if (await canLaunchUrl(uri)) {
|
||||
await launchUrl(uri, mode: LaunchMode.externalApplication);
|
||||
} else {
|
||||
LoggerService.warning('Could not launch Waze URL: $wazeUrl');
|
||||
_errorService.showError(
|
||||
message:
|
||||
'Impossible d\'ouvrir Waze. Vérifiez que l\'application est installée.',
|
||||
);
|
||||
}
|
||||
} catch (e) {
|
||||
LoggerService.error('Error opening Waze', error: e);
|
||||
_errorService.showError(message: 'Erreur lors de l\'ouverture de Waze');
|
||||
}
|
||||
}
|
||||
@@ -1035,14 +1046,7 @@ class _ShowTripDetailsContentState extends State<ShowTripDetailsContent> {
|
||||
if (activity.date == null) return const SizedBox.shrink();
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(bottom: 12),
|
||||
child: _buildActivityCard(
|
||||
title: activity.name,
|
||||
date: DateFormat(
|
||||
'd MMM, HH:mm',
|
||||
'fr_FR',
|
||||
).format(activity.date!),
|
||||
icon: _getCategoryIcon(activity.category),
|
||||
),
|
||||
child: _buildActivityCard(activity: activity),
|
||||
);
|
||||
}),
|
||||
],
|
||||
@@ -1060,70 +1064,79 @@ class _ShowTripDetailsContentState extends State<ShowTripDetailsContent> {
|
||||
return Icons.place;
|
||||
}
|
||||
|
||||
Widget _buildActivityCard({
|
||||
required String title,
|
||||
required String date,
|
||||
required IconData icon,
|
||||
}) {
|
||||
Widget _buildActivityCard({required Activity activity}) {
|
||||
final theme = Theme.of(context);
|
||||
final isDarkMode = theme.brightness == Brightness.dark;
|
||||
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color: theme.cardColor,
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
border: Border.all(
|
||||
color: isDarkMode
|
||||
? Colors.white.withValues(alpha: 0.1)
|
||||
: Colors.black.withValues(alpha: 0.05),
|
||||
width: 1,
|
||||
final date = activity.date != null
|
||||
? DateFormat('d MMM, HH:mm', 'fr_FR').format(activity.date!)
|
||||
: 'Date inconnue';
|
||||
final icon = _getCategoryIcon(activity.category);
|
||||
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) => ActivityDetailDialog(activity: activity),
|
||||
);
|
||||
},
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color: theme.cardColor,
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
border: Border.all(
|
||||
color: isDarkMode
|
||||
? Colors.white.withValues(alpha: 0.1)
|
||||
: Colors.black.withValues(alpha: 0.05),
|
||||
width: 1,
|
||||
),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.black.withValues(alpha: 0.05),
|
||||
blurRadius: 10,
|
||||
offset: const Offset(0, 2),
|
||||
),
|
||||
],
|
||||
),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.black.withValues(alpha: 0.05),
|
||||
blurRadius: 10,
|
||||
offset: const Offset(0, 2),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Container(
|
||||
padding: const EdgeInsets.all(12),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.teal.withValues(alpha: 0.1),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
child: Row(
|
||||
children: [
|
||||
Container(
|
||||
padding: const EdgeInsets.all(12),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.teal.withValues(alpha: 0.1),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: Icon(icon, color: Colors.teal, size: 24),
|
||||
),
|
||||
child: Icon(icon, color: Colors.teal, size: 24),
|
||||
),
|
||||
const SizedBox(width: 16),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
title,
|
||||
style: theme.textTheme.bodyLarge?.copyWith(
|
||||
fontWeight: FontWeight.bold,
|
||||
color: theme.colorScheme.onSurface,
|
||||
const SizedBox(width: 16),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
activity.name,
|
||||
style: theme.textTheme.bodyLarge?.copyWith(
|
||||
fontWeight: FontWeight.bold,
|
||||
color: theme.colorScheme.onSurface,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
date,
|
||||
style: theme.textTheme.bodyMedium?.copyWith(
|
||||
color: theme.colorScheme.onSurface.withValues(alpha: 0.6),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
date,
|
||||
style: theme.textTheme.bodyMedium?.copyWith(
|
||||
color: theme.colorScheme.onSurface.withValues(alpha: 0.6),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
Icon(
|
||||
Icons.chevron_right,
|
||||
color: theme.colorScheme.onSurface.withValues(alpha: 0.4),
|
||||
),
|
||||
],
|
||||
Icon(
|
||||
Icons.chevron_right,
|
||||
color: theme.colorScheme.onSurface.withValues(alpha: 0.4),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -1214,13 +1227,7 @@ class _ShowTripDetailsContentState extends State<ShowTripDetailsContent> {
|
||||
'${debtsToReceive.first.fromUserName} vous doit ${debtsToReceive.first.amount.toStringAsFixed(2)}€';
|
||||
} else {
|
||||
balanceText =
|
||||
debtsToReceive
|
||||
.map(
|
||||
(s) =>
|
||||
'${s.fromUserName} (${s.amount.toStringAsFixed(2)}€)',
|
||||
)
|
||||
.join(' et ') +
|
||||
' vous doivent de l\'argent';
|
||||
'${debtsToReceive.map((s) => '${s.fromUserName} (${s.amount.toStringAsFixed(2)}€)').join(' et ')} vous doivent de l\'argent';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user