Files
TravelMate/lib/components/home/show_trip_details_content.dart
Dayron d0a76b5043 feat: Enhance trip management features and improve UI responsiveness
- Implemented AutomaticKeepAliveClientMixin in HomeContent to maintain state during navigation.
- Modified trip loading logic to trigger after the first frame for better performance.
- Updated trip loading events to use LoadTripsByUserId for consistency.
- Added temporary success messages for trip creation and operations.
- Improved UI elements for better user experience, including updated text styles and spacing.
- Refactored trip model to support Firestore timestamps and improved error handling during parsing.
- Streamlined trip repository methods for better clarity and performance.
- Enhanced trip service methods to ensure correct mapping from Firestore documents.
- Removed unnecessary trip reset logic on logout.
2025-10-20 14:31:41 +02:00

125 lines
4.2 KiB
Dart

import 'package:flutter/material.dart';
import 'package:travel_mate/components/home/create_trip_content.dart';
import 'package:travel_mate/data/models/trip.dart';
class ShowTripDetailsContent extends StatefulWidget {
final Trip trip;
const ShowTripDetailsContent({super.key, required this.trip});
@override
State<ShowTripDetailsContent> createState() => _ShowTripDetailsContentState();
}
class _ShowTripDetailsContentState extends State<ShowTripDetailsContent> {
@override
Widget build(BuildContext context) {
final isDarkMode = Theme.of(context).brightness == Brightness.dark;
final textColor = isDarkMode ? Colors.white : Colors.black;
final secondaryTextColor = isDarkMode ? Colors.white70 : Colors.grey[600];
return Scaffold(
appBar: AppBar(
title: Text(widget.trip.title),
),
body: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
widget.trip.title,
style: TextStyle(
fontSize: 24,
fontWeight: FontWeight.bold,
color: textColor,
),
),
SizedBox(height: 8),
Text(
widget.trip.description,
style: TextStyle(color: textColor),
),
SizedBox(height: 16),
Row(
children: [
Icon(Icons.location_on, size: 16, color: secondaryTextColor),
SizedBox(width: 8),
Text(
widget.trip.location,
style: TextStyle(fontSize: 14, color: secondaryTextColor),
),
],
),
SizedBox(height: 8),
Row(
children: [
Icon(Icons.calendar_today, size: 16, color: secondaryTextColor),
SizedBox(width: 8),
Text(
'${widget.trip.startDate.day}/${widget.trip.startDate.month}/${widget.trip.startDate.year} - ${widget.trip.endDate.day}/${widget.trip.endDate.month}/${widget.trip.endDate.year}',
style: TextStyle(fontSize: 14, color: secondaryTextColor),
),
],
),
SizedBox(height: 8),
Row(
children: [
Icon(Icons.group, size: 16, color: secondaryTextColor),
SizedBox(width: 8),
Text(
'${widget.trip.participants.length} participant${widget.trip.participants.length > 1 ? 's' : ''}',
style: TextStyle(
fontSize: 14,
color: secondaryTextColor,
),
),
],
),
SizedBox(height: 16),
Text(
'Budget: ${widget.trip.budget ?? 'N/A'}',
style: TextStyle(color: textColor),
),
SizedBox(height: 16),
SizedBox(
width: double.infinity,
height: 50,
child: ElevatedButton(
onPressed: () async {
final result = await Navigator.push(
context,
MaterialPageRoute(
builder: (context) => CreateTripContent(
tripToEdit: widget.trip,
),
),
);
if (result == true && mounted) {
Navigator.pop(context, true); // Retour avec flag
}
},
style: ElevatedButton.styleFrom(
backgroundColor: Color.fromARGB(255, 0, 123, 255),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
),
),
child: Text(
'Modifier les informations du voyage',
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
fontSize: 16,
),
),
),
),
],
),
),
);
}
}