Add launch configuration, update API keys, and refactor UI components for better structure and performance

This commit is contained in:
Dayron
2025-10-06 14:17:30 +02:00
parent 29141ba8b2
commit 797f77cf69
16 changed files with 371 additions and 351 deletions

View File

@@ -1,6 +1,5 @@
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import '../../providers/user_provider.dart';
class CreateTripContent extends StatefulWidget {
const CreateTripContent({super.key});
@@ -350,11 +349,13 @@ class _CreateTripContentState extends State<CreateTripContent> {
Future<void> _selectEndDate(BuildContext context) async {
if (_startDate == null) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text('Veuillez d\'abord sélectionner la date de début'),
),
);
if (mounted) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text('Veuillez d\'abord sélectionner la date de début'),
),
);
}
return;
}
@@ -364,7 +365,7 @@ class _CreateTripContentState extends State<CreateTripContent> {
firstDate: _startDate!,
lastDate: DateTime.now().add(Duration(days: 365 * 2)),
);
if (picked != null) {
if (picked != null && mounted) {
setState(() {
_endDate = picked;
});
@@ -378,17 +379,21 @@ class _CreateTripContentState extends State<CreateTripContent> {
// Validation email simple
final emailRegex = RegExp(r'^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$');
if (!emailRegex.hasMatch(email)) {
ScaffoldMessenger.of(
context,
).showSnackBar(SnackBar(content: Text('Email invalide')));
if (mounted) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text('Email invalide'))
);
}
return;
}
// Vérifier si l'email existe déjà
if (_participants.contains(email)) {
ScaffoldMessenger.of(
context,
).showSnackBar(SnackBar(content: Text('Ce participant est déjà ajouté')));
if (mounted) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text('Ce participant est déjà ajouté'))
);
}
return;
}
@@ -410,9 +415,11 @@ class _CreateTripContentState extends State<CreateTripContent> {
}
if (_startDate == null || _endDate == null) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text('Veuillez sélectionner les dates')),
);
if (mounted) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text('Veuillez sélectionner les dates')),
);
}
return;
}
@@ -424,25 +431,31 @@ class _CreateTripContentState extends State<CreateTripContent> {
// TODO: Implémenter la sauvegarde du voyage
await Future.delayed(Duration(seconds: 2)); // Simulation
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text('Voyage créé avec succès !'),
backgroundColor: Colors.green,
),
);
if (mounted) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text('Voyage créé avec succès !'),
backgroundColor: Colors.green,
),
);
Navigator.pop(context);
Navigator.pop(context);
}
} catch (e) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text('Erreur lors de la création: $e'),
backgroundColor: Colors.red,
),
);
if (mounted) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text('Erreur lors de la création: $e'),
backgroundColor: Colors.red,
),
);
}
} finally {
setState(() {
_isLoading = false;
});
if (mounted) {
setState(() {
_isLoading = false;
});
}
}
}
}

View File

@@ -68,7 +68,7 @@ class HomeContent extends StatelessWidget {
),
// Espacement en bas pour éviter que le FAB cache le contenu
SizedBox(height: 80),
const SizedBox(height: 80),
],
),
);
@@ -82,7 +82,7 @@ class HomeContent extends StatelessWidget {
},
backgroundColor: Theme.of(context).colorScheme.primary,
foregroundColor: Colors.white,
child: Icon(Icons.add),
child: const Icon(Icons.add),
),
floatingActionButtonLocation: FloatingActionButtonLocation.endFloat,
);
@@ -100,7 +100,7 @@ class HomeContent extends StatelessWidget {
}) {
return Card(
elevation: 4,
margin: EdgeInsets.only(bottom: 16),
margin: const EdgeInsets.only(bottom: 16),
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
child: InkWell(
onTap: () {
@@ -115,7 +115,7 @@ class HomeContent extends StatelessWidget {
Container(
height: 150,
decoration: BoxDecoration(
borderRadius: BorderRadius.vertical(top: Radius.circular(12)),
borderRadius: const BorderRadius.vertical(top: Radius.circular(12)),
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
@@ -131,7 +131,7 @@ class HomeContent extends StatelessWidget {
Container(
width: double.infinity,
decoration: BoxDecoration(
borderRadius: BorderRadius.vertical(
borderRadius: const BorderRadius.vertical(
top: Radius.circular(12),
),
color: color.withValues(alpha: 0.3),
@@ -148,24 +148,24 @@ class HomeContent extends StatelessWidget {
children: [
Text(
title,
style: TextStyle(
style: const TextStyle(
fontSize: 20,
fontWeight: FontWeight.bold,
color: Colors.white,
),
),
SizedBox(height: 4),
const SizedBox(height: 4),
Row(
children: [
Icon(
const Icon(
Icons.location_on,
color: Colors.white,
size: 16,
),
SizedBox(width: 4),
const SizedBox(width: 4),
Text(
location,
style: TextStyle(
style: const TextStyle(
fontSize: 14,
color: Colors.white,
),