Add launch configuration, update API keys, and refactor UI components for better structure and performance
This commit is contained in:
31
.vscode/launch.json
vendored
Normal file
31
.vscode/launch.json
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
{
|
||||
// Use IntelliSense to learn about possible attributes.
|
||||
// Hover to view descriptions of existing attributes.
|
||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Flutter",
|
||||
"type": "dart",
|
||||
"request": "launch",
|
||||
"program": "lib/main.dart"
|
||||
},
|
||||
{
|
||||
"name": "travel_mate",
|
||||
"request": "launch",
|
||||
"type": "dart"
|
||||
},
|
||||
{
|
||||
"name": "travel_mate (profile mode)",
|
||||
"request": "launch",
|
||||
"type": "dart",
|
||||
"flutterMode": "profile"
|
||||
},
|
||||
{
|
||||
"name": "travel_mate (release mode)",
|
||||
"request": "launch",
|
||||
"type": "dart",
|
||||
"flutterMode": "release"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -35,7 +35,7 @@
|
||||
android:value="2" />
|
||||
<meta-data
|
||||
android:name="com.google.android.geo.API_KEY"
|
||||
android:value="AIzaSyAAQd5UqtPc0fsbHnuezm22r9b5dgzv21Y"/>
|
||||
android:value="AIzaSyCAtz1_d5K0ANwxAA_T84iq7Ac_gsUs_oM"/>
|
||||
</application>
|
||||
<!-- Required to query activities that can process text, see:
|
||||
https://developer.android.com/training/package-visibility and
|
||||
|
||||
@@ -8,7 +8,7 @@ import GoogleMaps
|
||||
_ application: UIApplication,
|
||||
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
|
||||
) -> Bool {
|
||||
GMSServices.provideAPIKey("AIzaSyDoflpihvRWaQx18SKMu8_fgirF0muW4yU")
|
||||
GMSServices.provideAPIKey("AIzaSyBsgaG8PuDTFodn4xjGSjVDOxzw3gJB35A")
|
||||
GeneratedPluginRegistrant.register(with: self)
|
||||
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
|
||||
}
|
||||
|
||||
@@ -5,9 +5,23 @@ class CountContent extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: const Text('Count Page')),
|
||||
body: const Center(child: Text('This is the Count Page')),
|
||||
return const Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Icon(Icons.account_balance_wallet, size: 64, color: Colors.green),
|
||||
SizedBox(height: 16),
|
||||
Text(
|
||||
'Comptes et Budget',
|
||||
style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold),
|
||||
),
|
||||
SizedBox(height: 8),
|
||||
Text(
|
||||
'Gérez vos dépenses de voyage',
|
||||
style: TextStyle(fontSize: 16, color: Colors.grey),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,9 +5,23 @@ class GroupContent extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: const Text('Chat Group Page')),
|
||||
body: const Center(child: Text('This is the Chat Group Page')),
|
||||
return const Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Icon(Icons.group, size: 64, color: Colors.blue),
|
||||
SizedBox(height: 16),
|
||||
Text(
|
||||
'Chat de Groupe',
|
||||
style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold),
|
||||
),
|
||||
SizedBox(height: 8),
|
||||
Text(
|
||||
'Communiquez avec vos compagnons de voyage',
|
||||
style: TextStyle(fontSize: 16, color: Colors.grey),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
),
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:google_maps_flutter/google_maps_flutter.dart';
|
||||
import 'package:location/location.dart';
|
||||
|
||||
class MapContent extends StatefulWidget {
|
||||
const MapContent({super.key});
|
||||
@@ -12,130 +9,13 @@ class MapContent extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _MapContentState extends State<MapContent> {
|
||||
Location locationController = Location();
|
||||
|
||||
final Completer<GoogleMapController> _mapController =
|
||||
Completer<GoogleMapController>();
|
||||
|
||||
LatLng? currentPosition;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
//getLocationUpdate();
|
||||
currentPosition = LatLng(48.8566, 2.3522); // Position par défaut (Paris)
|
||||
}
|
||||
final LatLng _initialPosition = LatLng(48.8566, 2.3522); // Paris
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
body: SafeArea(
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(8.0),
|
||||
child: Column(
|
||||
children: [
|
||||
TextField(
|
||||
decoration: InputDecoration(
|
||||
hintText: 'Rechercher un lieu...',
|
||||
prefixIcon: Icon(Icons.search),
|
||||
border: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(8.0),
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(height: 8.0),
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
height: 50,
|
||||
child: ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: Theme.of(context).colorScheme.primary,
|
||||
foregroundColor: Colors.white,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(8.0),
|
||||
),
|
||||
),
|
||||
onPressed: () {
|
||||
// TODO : Logique de recherche à implémenter
|
||||
},
|
||||
child: Text('Chercher'),
|
||||
),
|
||||
),
|
||||
SizedBox(height: 8.0),
|
||||
Expanded(
|
||||
child: currentPosition == null
|
||||
? const Center(
|
||||
child: CircularProgressIndicator(),
|
||||
)
|
||||
: GoogleMap(
|
||||
onMapCreated: (GoogleMapController controller) =>
|
||||
_mapController.complete(controller),
|
||||
initialCameraPosition: CameraPosition(
|
||||
target: currentPosition!,
|
||||
zoom: 14.4746,
|
||||
),
|
||||
myLocationEnabled: true,
|
||||
myLocationButtonEnabled: true,
|
||||
mapType: MapType.normal,
|
||||
zoomControlsEnabled: true,
|
||||
markers: {
|
||||
Marker(
|
||||
markerId: MarkerId('currentLocation'),
|
||||
position: currentPosition!,
|
||||
icon: BitmapDescriptor.defaultMarkerWithHue(
|
||||
BitmapDescriptor.hueAzure,
|
||||
),
|
||||
),
|
||||
},
|
||||
),
|
||||
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
return GoogleMap(initialCameraPosition: CameraPosition(
|
||||
target: _initialPosition,
|
||||
zoom: 12,
|
||||
));
|
||||
}
|
||||
|
||||
Future<void> _cameraToPosition(LatLng pos) async {
|
||||
final GoogleMapController controller = await _mapController.future;
|
||||
CameraPosition newCameraPosition = CameraPosition(target: pos, zoom: 13);
|
||||
await controller.animateCamera(
|
||||
CameraUpdate.newCameraPosition(newCameraPosition),
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> getLocationUpdate() async {
|
||||
bool serviceEnabled;
|
||||
PermissionStatus permissionGranted;
|
||||
|
||||
serviceEnabled = await locationController.serviceEnabled();
|
||||
if (serviceEnabled) {
|
||||
serviceEnabled = await locationController.requestService();
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
permissionGranted = await locationController.hasPermission();
|
||||
if (permissionGranted == PermissionStatus.denied) {
|
||||
permissionGranted = await locationController.requestPermission();
|
||||
if (permissionGranted != PermissionStatus.granted) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
locationController.onLocationChanged.listen((LocationData currentLocation) {
|
||||
if (currentLocation.latitude != null &&
|
||||
currentLocation.longitude != null) {
|
||||
setState(() {
|
||||
currentPosition = LatLng(
|
||||
currentLocation.latitude!,
|
||||
currentLocation.longitude!,
|
||||
);
|
||||
_cameraToPosition(currentPosition!);
|
||||
print(currentPosition);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,18 +8,18 @@ class SettingsContent extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ListView(
|
||||
padding: EdgeInsets.all(16),
|
||||
padding: const EdgeInsets.all(16),
|
||||
children: [
|
||||
Text(
|
||||
const Text(
|
||||
'Paramètres',
|
||||
style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold),
|
||||
),
|
||||
SizedBox(height: 20),
|
||||
const SizedBox(height: 20),
|
||||
|
||||
// Section Profil intégrée
|
||||
ProfileContent(),
|
||||
const ProfileContent(),
|
||||
|
||||
SizedBox(height: 20),
|
||||
const SizedBox(height: 20),
|
||||
|
||||
// Autres paramètres
|
||||
Text(
|
||||
@@ -30,39 +30,39 @@ class SettingsContent extends StatelessWidget {
|
||||
color: Colors.grey[600],
|
||||
),
|
||||
),
|
||||
SizedBox(height: 8),
|
||||
const SizedBox(height: 8),
|
||||
|
||||
ListTile(
|
||||
leading: Icon(Icons.palette),
|
||||
title: Text('Thème'),
|
||||
subtitle: Text('Clair, sombre ou système'),
|
||||
trailing: Icon(Icons.arrow_forward_ios),
|
||||
leading: const Icon(Icons.palette),
|
||||
title: const Text('Thème'),
|
||||
subtitle: const Text('Clair, sombre ou système'),
|
||||
trailing: const Icon(Icons.arrow_forward_ios),
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(builder: (context) => SettingsThemeContent()),
|
||||
MaterialPageRoute(builder: (context) => const SettingsThemeContent()),
|
||||
);
|
||||
},
|
||||
),
|
||||
|
||||
ListTile(
|
||||
leading: Icon(Icons.notifications),
|
||||
title: Text('Notifications'),
|
||||
trailing: Icon(Icons.arrow_forward_ios),
|
||||
leading: const Icon(Icons.notifications),
|
||||
title: const Text('Notifications'),
|
||||
trailing: const Icon(Icons.arrow_forward_ios),
|
||||
onTap: () {},
|
||||
),
|
||||
|
||||
ListTile(
|
||||
leading: Icon(Icons.language),
|
||||
title: Text('Langue'),
|
||||
trailing: Icon(Icons.arrow_forward_ios),
|
||||
leading: const Icon(Icons.language),
|
||||
title: const Text('Langue'),
|
||||
trailing: const Icon(Icons.arrow_forward_ios),
|
||||
onTap: () {},
|
||||
),
|
||||
|
||||
ListTile(
|
||||
leading: Icon(Icons.privacy_tip),
|
||||
title: Text('Confidentialité'),
|
||||
trailing: Icon(Icons.arrow_forward_ios),
|
||||
leading: const Icon(Icons.privacy_tip),
|
||||
title: const Text('Confidentialité'),
|
||||
trailing: const Icon(Icons.arrow_forward_ios),
|
||||
onTap: () {},
|
||||
),
|
||||
],
|
||||
|
||||
@@ -9,68 +9,93 @@ class SettingsThemeContent extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text('Thème'),
|
||||
title: const Text('Thème'),
|
||||
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
|
||||
),
|
||||
body: Consumer<ThemeProvider>(
|
||||
builder: (context, themeProvider, child) {
|
||||
return ListView(
|
||||
padding: EdgeInsets.all(16),
|
||||
padding: const EdgeInsets.all(16),
|
||||
children: [
|
||||
Text(
|
||||
'Choisir le thème',
|
||||
style: Theme.of(context).textTheme.headlineSmall,
|
||||
),
|
||||
SizedBox(height: 20),
|
||||
const SizedBox(height: 20),
|
||||
|
||||
// Option Système
|
||||
RadioListTile<ThemeMode>(
|
||||
title: Text('Système'),
|
||||
subtitle: Text('Suit les paramètres de votre appareil'),
|
||||
value: ThemeMode.system,
|
||||
groupValue: themeProvider.themeMode,
|
||||
onChanged: (ThemeMode? value) {
|
||||
if (value != null) {
|
||||
themeProvider.setThemeMode(value);
|
||||
}
|
||||
},
|
||||
secondary: Icon(Icons.brightness_auto),
|
||||
Card(
|
||||
child: ListTile(
|
||||
leading: Icon(
|
||||
themeProvider.themeMode == ThemeMode.system
|
||||
? Icons.radio_button_checked
|
||||
: Icons.radio_button_unchecked,
|
||||
color: themeProvider.themeMode == ThemeMode.system
|
||||
? Theme.of(context).colorScheme.primary
|
||||
: null,
|
||||
),
|
||||
title: const Text('Système'),
|
||||
subtitle: const Text('Suit les paramètres de votre appareil'),
|
||||
trailing: const Icon(Icons.brightness_auto),
|
||||
selected: themeProvider.themeMode == ThemeMode.system,
|
||||
onTap: () {
|
||||
themeProvider.setThemeMode(ThemeMode.system);
|
||||
},
|
||||
),
|
||||
),
|
||||
|
||||
const SizedBox(height: 8),
|
||||
|
||||
// Option Clair
|
||||
RadioListTile<ThemeMode>(
|
||||
title: Text('Clair'),
|
||||
subtitle: Text('Thème clair en permanence'),
|
||||
value: ThemeMode.light,
|
||||
groupValue: themeProvider.themeMode,
|
||||
onChanged: (ThemeMode? value) {
|
||||
if (value != null) {
|
||||
themeProvider.setThemeMode(value);
|
||||
}
|
||||
},
|
||||
secondary: Icon(Icons.light_mode),
|
||||
Card(
|
||||
child: ListTile(
|
||||
leading: Icon(
|
||||
themeProvider.themeMode == ThemeMode.light
|
||||
? Icons.radio_button_checked
|
||||
: Icons.radio_button_unchecked,
|
||||
color: themeProvider.themeMode == ThemeMode.light
|
||||
? Theme.of(context).colorScheme.primary
|
||||
: null,
|
||||
),
|
||||
title: const Text('Clair'),
|
||||
subtitle: const Text('Thème clair en permanence'),
|
||||
trailing: const Icon(Icons.light_mode),
|
||||
selected: themeProvider.themeMode == ThemeMode.light,
|
||||
onTap: () {
|
||||
themeProvider.setThemeMode(ThemeMode.light);
|
||||
},
|
||||
),
|
||||
),
|
||||
|
||||
const SizedBox(height: 8),
|
||||
|
||||
// Option Sombre
|
||||
RadioListTile<ThemeMode>(
|
||||
title: Text('Sombre'),
|
||||
subtitle: Text('Thème sombre en permanence'),
|
||||
value: ThemeMode.dark,
|
||||
groupValue: themeProvider.themeMode,
|
||||
onChanged: (ThemeMode? value) {
|
||||
if (value != null) {
|
||||
themeProvider.setThemeMode(value);
|
||||
}
|
||||
},
|
||||
secondary: Icon(Icons.dark_mode),
|
||||
Card(
|
||||
child: ListTile(
|
||||
leading: Icon(
|
||||
themeProvider.themeMode == ThemeMode.dark
|
||||
? Icons.radio_button_checked
|
||||
: Icons.radio_button_unchecked,
|
||||
color: themeProvider.themeMode == ThemeMode.dark
|
||||
? Theme.of(context).colorScheme.primary
|
||||
: null,
|
||||
),
|
||||
title: const Text('Sombre'),
|
||||
subtitle: const Text('Thème sombre en permanence'),
|
||||
trailing: const Icon(Icons.dark_mode),
|
||||
selected: themeProvider.themeMode == ThemeMode.dark,
|
||||
onTap: () {
|
||||
themeProvider.setThemeMode(ThemeMode.dark);
|
||||
},
|
||||
),
|
||||
),
|
||||
|
||||
SizedBox(height: 30),
|
||||
const SizedBox(height: 30),
|
||||
|
||||
// Aperçu du thème actuel
|
||||
Card(
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(16),
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
@@ -78,7 +103,7 @@ class SettingsThemeContent extends StatelessWidget {
|
||||
'Aperçu',
|
||||
style: Theme.of(context).textTheme.titleMedium,
|
||||
),
|
||||
SizedBox(height: 10),
|
||||
const SizedBox(height: 10),
|
||||
Row(
|
||||
children: [
|
||||
Icon(
|
||||
@@ -87,7 +112,7 @@ class SettingsThemeContent extends StatelessWidget {
|
||||
: Icons.light_mode,
|
||||
color: Theme.of(context).colorScheme.primary,
|
||||
),
|
||||
SizedBox(width: 10),
|
||||
const SizedBox(width: 10),
|
||||
Text(
|
||||
themeProvider.isDarkMode
|
||||
? 'Mode sombre actif'
|
||||
|
||||
@@ -14,29 +14,63 @@ class HomePage extends StatefulWidget {
|
||||
|
||||
class _HomePageState extends State<HomePage> {
|
||||
int _currentIndex = 0;
|
||||
|
||||
// Cache pour les pages créées
|
||||
final Map<int, Widget> _pageCache = {};
|
||||
|
||||
final List<String> titles = [
|
||||
'Mes voyages', // 0
|
||||
'Paramètres', // 1
|
||||
'Carte', // 2
|
||||
'Chat de groupe', // 3
|
||||
'Comptes', // 4
|
||||
];
|
||||
|
||||
Widget _buildPage(int index) {
|
||||
// Vérifier si la page est déjà en cache
|
||||
if (_pageCache.containsKey(index)) {
|
||||
return _pageCache[index]!;
|
||||
}
|
||||
|
||||
// Créer la page seulement quand elle est demandée
|
||||
Widget page;
|
||||
switch (index) {
|
||||
case 0:
|
||||
page = const HomeContent();
|
||||
break;
|
||||
case 1:
|
||||
page = const SettingsContent();
|
||||
break;
|
||||
case 2:
|
||||
page = const MapContent();
|
||||
break;
|
||||
case 3:
|
||||
page = const GroupContent();
|
||||
break;
|
||||
case 4:
|
||||
page = const CountContent();
|
||||
break;
|
||||
default:
|
||||
page = const HomeContent();
|
||||
}
|
||||
|
||||
// Mettre en cache la page créée
|
||||
_pageCache[index] = page;
|
||||
return page;
|
||||
}
|
||||
|
||||
void _onNavigationTap(int index) {
|
||||
setState(() {
|
||||
_currentIndex = index;
|
||||
});
|
||||
Navigator.pop(context); // Fermer le drawer
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// Définir les pages directement dans le build pour éviter les erreurs
|
||||
final List<Widget> pages = [
|
||||
HomeContent(), // 0
|
||||
SettingsContent(), // 1
|
||||
MapContent(), // 2
|
||||
GroupContent(), // 3
|
||||
CountContent(), // 4
|
||||
];
|
||||
|
||||
final List<String> titles = [
|
||||
'Mes voyages', // 0
|
||||
'Paramètres', // 1
|
||||
'Carte', // 2
|
||||
'Chat de groupe', // 3
|
||||
'Comptes', // 4
|
||||
];
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(titles[_currentIndex]), // Debug
|
||||
title: Text(titles[_currentIndex]),
|
||||
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
|
||||
foregroundColor: Colors.white,
|
||||
),
|
||||
@@ -48,70 +82,40 @@ class _HomePageState extends State<HomePage> {
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context).colorScheme.inversePrimary,
|
||||
),
|
||||
child: Text(
|
||||
child: const Text(
|
||||
"Travel Mate",
|
||||
style: TextStyle(color: Colors.white, fontSize: 24),
|
||||
),
|
||||
),
|
||||
ListTile(
|
||||
leading: Icon(Icons.home),
|
||||
title: Text("Mes voyages"),
|
||||
selected: _currentIndex == 0,
|
||||
onTap: () {
|
||||
setState(() {
|
||||
_currentIndex = 0;
|
||||
});
|
||||
Navigator.pop(context);
|
||||
},
|
||||
_buildDrawerItem(
|
||||
icon: Icons.home,
|
||||
title: "Mes voyages",
|
||||
index: 0,
|
||||
),
|
||||
ListTile(
|
||||
leading: Icon(Icons.settings),
|
||||
title: Text("Paramètres"),
|
||||
selected: _currentIndex == 1,
|
||||
onTap: () {
|
||||
setState(() {
|
||||
_currentIndex = 1;
|
||||
});
|
||||
Navigator.pop(context);
|
||||
},
|
||||
_buildDrawerItem(
|
||||
icon: Icons.settings,
|
||||
title: "Paramètres",
|
||||
index: 1,
|
||||
),
|
||||
ListTile(
|
||||
leading: Icon(Icons.map),
|
||||
title: Text("Carte"),
|
||||
selected: _currentIndex == 2,
|
||||
onTap: () {
|
||||
setState(() {
|
||||
_currentIndex = 2;
|
||||
});
|
||||
Navigator.pop(context);
|
||||
},
|
||||
_buildDrawerItem(
|
||||
icon: Icons.map,
|
||||
title: "Carte",
|
||||
index: 2,
|
||||
),
|
||||
ListTile(
|
||||
leading: Icon(Icons.group),
|
||||
title: Text("Chat de groupe"),
|
||||
selected: _currentIndex == 3,
|
||||
onTap: () {
|
||||
setState(() {
|
||||
_currentIndex = 3;
|
||||
});
|
||||
Navigator.pop(context);
|
||||
},
|
||||
_buildDrawerItem(
|
||||
icon: Icons.group,
|
||||
title: "Chat de groupe",
|
||||
index: 3,
|
||||
),
|
||||
ListTile(
|
||||
leading: Icon(Icons.account_balance_wallet),
|
||||
title: Text("Comptes"),
|
||||
selected: _currentIndex == 4,
|
||||
onTap: () {
|
||||
setState(() {
|
||||
_currentIndex = 4;
|
||||
});
|
||||
Navigator.pop(context);
|
||||
},
|
||||
_buildDrawerItem(
|
||||
icon: Icons.account_balance_wallet,
|
||||
title: "Comptes",
|
||||
index: 4,
|
||||
),
|
||||
Divider(),
|
||||
const Divider(),
|
||||
ListTile(
|
||||
leading: Icon(Icons.logout, color: Colors.red),
|
||||
title: Text("Déconnexion", style: TextStyle(color: Colors.red)),
|
||||
leading: const Icon(Icons.logout, color: Colors.red),
|
||||
title: const Text("Déconnexion", style: TextStyle(color: Colors.red)),
|
||||
onTap: () {
|
||||
Navigator.pop(context);
|
||||
Navigator.pushNamedAndRemoveUntil(
|
||||
@@ -124,7 +128,38 @@ class _HomePageState extends State<HomePage> {
|
||||
],
|
||||
),
|
||||
),
|
||||
body: pages[_currentIndex],
|
||||
body: IndexedStack(
|
||||
index: _currentIndex,
|
||||
children: [
|
||||
// Créer les pages seulement si elles sont sélectionnées
|
||||
for (int i = 0; i < titles.length; i++)
|
||||
if (_currentIndex == i || _pageCache.containsKey(i))
|
||||
_buildPage(i)
|
||||
else
|
||||
Container(), // Placeholder vide
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildDrawerItem({
|
||||
required IconData icon,
|
||||
required String title,
|
||||
required int index,
|
||||
}) {
|
||||
return ListTile(
|
||||
leading: Icon(icon),
|
||||
title: Text(title),
|
||||
selected: _currentIndex == index,
|
||||
selectedTileColor: Theme.of(context).colorScheme.primary.withValues(alpha: 0.1),
|
||||
onTap: () => _onNavigationTap(index),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
// Nettoyer le cache si nécessaire
|
||||
_pageCache.clear();
|
||||
super.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,31 +62,39 @@ class _LoginPageState extends State<LoginPage> {
|
||||
_passwordController.text,
|
||||
);
|
||||
|
||||
if (user != null) {
|
||||
// Naviguer vers la page d'accueil
|
||||
Provider.of<UserProvider>(context, listen: false).setCurrentUser(user);
|
||||
Navigator.pushReplacementNamed(context, '/home');
|
||||
} else {
|
||||
// Échec de la connexion
|
||||
_showErrorMessage('Email ou mot de passe incorrect');
|
||||
if (mounted) {
|
||||
if (user != null) {
|
||||
// Naviguer vers la page d'accueil
|
||||
Provider.of<UserProvider>(context, listen: false).setCurrentUser(user);
|
||||
Navigator.pushReplacementNamed(context, '/home');
|
||||
} else {
|
||||
// Échec de la connexion
|
||||
_showErrorMessage('Email ou mot de passe incorrect');
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
_showErrorMessage('Erreur lors de la connexion: ${e.toString()}');
|
||||
if (mounted) {
|
||||
_showErrorMessage('Erreur lors de la connexion: ${e.toString()}');
|
||||
}
|
||||
} finally {
|
||||
setState(() {
|
||||
_isLoading = false;
|
||||
});
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_isLoading = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void _showErrorMessage(String message) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(message),
|
||||
backgroundColor: Colors.red,
|
||||
duration: Duration(seconds: 3),
|
||||
),
|
||||
);
|
||||
if (mounted) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(message),
|
||||
backgroundColor: Colors.red,
|
||||
duration: const Duration(seconds: 3),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
@@ -8,7 +8,7 @@ class ThemeProvider extends ChangeNotifier {
|
||||
|
||||
bool get isDarkMode {
|
||||
if (_themeMode == ThemeMode.system) {
|
||||
return WidgetsBinding.instance.window.platformBrightness ==
|
||||
return WidgetsBinding.instance.platformDispatcher.platformBrightness ==
|
||||
Brightness.dark;
|
||||
}
|
||||
return _themeMode == ThemeMode.dark;
|
||||
|
||||
@@ -16,7 +16,7 @@ class TripService {
|
||||
final List<dynamic> jsonList = json.decode(tripsJson);
|
||||
return jsonList.map((json) => Trip.fromMap(json)).toList();
|
||||
} catch (e) {
|
||||
print('Erreur lors du chargement des voyages: $e');
|
||||
//print('Erreur lors du chargement des voyages: $e');
|
||||
return [];
|
||||
}
|
||||
}
|
||||
@@ -28,7 +28,7 @@ class TripService {
|
||||
final jsonList = trips.map((trip) => trip.toMap()).toList();
|
||||
await prefs.setString(_tripsKey, json.encode(jsonList));
|
||||
} catch (e) {
|
||||
print('Erreur lors de la sauvegarde des voyages: $e');
|
||||
//print('Erreur lors de la sauvegarde des voyages: $e');
|
||||
throw Exception('Erreur de sauvegarde');
|
||||
}
|
||||
}
|
||||
@@ -49,7 +49,7 @@ class TripService {
|
||||
await saveTrips(trips);
|
||||
return true;
|
||||
} catch (e) {
|
||||
print('Erreur lors de l\'ajout du voyage: $e');
|
||||
//print('Erreur lors de l\'ajout du voyage: $e');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -65,7 +65,7 @@ class TripService {
|
||||
)
|
||||
.toList();
|
||||
} catch (e) {
|
||||
print('Erreur lors de la récupération des voyages: $e');
|
||||
//print('Erreur lors de la récupération des voyages: $e');
|
||||
return [];
|
||||
}
|
||||
}
|
||||
@@ -83,7 +83,7 @@ class TripService {
|
||||
}
|
||||
return false;
|
||||
} catch (e) {
|
||||
print('Erreur lors de la mise à jour du voyage: $e');
|
||||
//print('Erreur lors de la mise à jour du voyage: $e');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -101,7 +101,7 @@ class TripService {
|
||||
}
|
||||
return false;
|
||||
} catch (e) {
|
||||
print('Erreur lors de la suppression du voyage: $e');
|
||||
//print('Erreur lors de la suppression du voyage: $e');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ class UserService {
|
||||
|
||||
return jsonList.map((json) => User.fromMap(json)).toList();
|
||||
} catch (e) {
|
||||
print('Erreur lors du chargement des utilisateurs: $e');
|
||||
//print('Erreur lors du chargement des utilisateurs: $e');
|
||||
return [];
|
||||
}
|
||||
}
|
||||
@@ -38,7 +38,7 @@ class UserService {
|
||||
final jsonList = users.map((user) => user.toMap()).toList();
|
||||
await file.writeAsString(json.encode(jsonList));
|
||||
} catch (e) {
|
||||
print('Erreur lors de la sauvegarde des utilisateurs: $e');
|
||||
//print('Erreur lors de la sauvegarde des utilisateurs: $e');
|
||||
throw Exception('Erreur de sauvegarde');
|
||||
}
|
||||
}
|
||||
@@ -62,7 +62,7 @@ class UserService {
|
||||
await saveUsers(users);
|
||||
return true;
|
||||
} catch (e) {
|
||||
print('Erreur lors de l\'ajout de l\'utilisateur: $e');
|
||||
//print('Erreur lors de l\'ajout de l\'utilisateur: $e');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -89,7 +89,7 @@ class UserService {
|
||||
|
||||
return null; // Mot de passe incorrect
|
||||
} catch (e) {
|
||||
print('Erreur lors de l\'authentification: $e');
|
||||
//print('Erreur lors de l\'authentification: $e');
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -102,7 +102,7 @@ class UserService {
|
||||
(user) => user.email.toLowerCase() == email.toLowerCase(),
|
||||
);
|
||||
} catch (e) {
|
||||
print('Erreur lors de la vérification de l\'email: $e');
|
||||
//print('Erreur lors de la vérification de l\'email: $e');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -113,7 +113,7 @@ class UserService {
|
||||
final users = await loadUsers();
|
||||
return users.firstWhere((user) => user.id == id);
|
||||
} catch (e) {
|
||||
print('Utilisateur avec l\'ID $id non trouvé');
|
||||
//print('Utilisateur avec l\'ID $id non trouvé');
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -126,7 +126,7 @@ class UserService {
|
||||
(user) => user.email.toLowerCase() == email.toLowerCase(),
|
||||
);
|
||||
} catch (e) {
|
||||
print('Utilisateur avec l\'email $email non trouvé');
|
||||
//print('Utilisateur avec l\'email $email non trouvé');
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -144,7 +144,7 @@ class UserService {
|
||||
}
|
||||
return false; // Utilisateur non trouvé
|
||||
} catch (e) {
|
||||
print('Erreur lors de la mise à jour de l\'utilisateur: $e');
|
||||
//print('Erreur lors de la mise à jour de l\'utilisateur: $e');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -162,7 +162,7 @@ class UserService {
|
||||
}
|
||||
return false; // Utilisateur non trouvé
|
||||
} catch (e) {
|
||||
print('Erreur lors de la suppression de l\'utilisateur: $e');
|
||||
//print('Erreur lors de la suppression de l\'utilisateur: $e');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -195,7 +195,7 @@ class UserService {
|
||||
|
||||
return true;
|
||||
} catch (e) {
|
||||
print('Erreur lors du changement de mot de passe: $e');
|
||||
//print('Erreur lors du changement de mot de passe: $e');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -219,7 +219,7 @@ class UserService {
|
||||
|
||||
return true;
|
||||
} catch (e) {
|
||||
print('Erreur lors de la réinitialisation du mot de passe: $e');
|
||||
//print('Erreur lors de la réinitialisation du mot de passe: $e');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -230,7 +230,7 @@ class UserService {
|
||||
final users = await loadUsers();
|
||||
return users.length;
|
||||
} catch (e) {
|
||||
print('Erreur lors du comptage des utilisateurs: $e');
|
||||
//print('Erreur lors du comptage des utilisateurs: $e');
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -240,7 +240,7 @@ class UserService {
|
||||
try {
|
||||
await saveUsers([]);
|
||||
} catch (e) {
|
||||
print('Erreur lors du vidage de la base de données: $e');
|
||||
//print('Erreur lors du vidage de la base de données: $e');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -266,7 +266,7 @@ class UserService {
|
||||
await addUser(user);
|
||||
}
|
||||
} catch (e) {
|
||||
print('Erreur lors de la création des utilisateurs de test: $e');
|
||||
//print('Erreur lors de la création des utilisateurs de test: $e');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ dependencies:
|
||||
# The following adds the Cupertino Icons font to your application.
|
||||
# Use with the CupertinoIcons class for iOS style icons.
|
||||
cupertino_icons: ^1.0.8
|
||||
google_maps_flutter: ^2.13.1
|
||||
google_maps_flutter: ^2.5.0
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
@@ -66,7 +66,7 @@ flutter:
|
||||
# To add assets to your application, add an assets section, like this:
|
||||
assets:
|
||||
- assets/icons/
|
||||
- assets/images/
|
||||
#- assets/images/
|
||||
|
||||
# An image asset can refer to one or more resolution-specific "variants", see
|
||||
# https://flutter.dev/to/resolution-aware-images
|
||||
|
||||
Reference in New Issue
Block a user