2 Commits

Author SHA1 Message Date
5354575430 add showmodal 2025-09-13 01:02:42 +02:00
6c2324cb91 fix set settings 2025-09-07 20:51:27 +02:00
2 changed files with 54 additions and 11 deletions

View File

@@ -48,17 +48,18 @@ class _EditProfileState extends State<EditSettings>
final AuthService _authService = AuthService(); final AuthService _authService = AuthService();
TextEditingController inputUserName = TextEditingController(); TextEditingController inputUserName = TextEditingController();
int? kilometer; int? kilometer = 50;
Future<void> getParameter() async { Future<void> getParameter() async {
SharedPreferences prefs = await SharedPreferences.getInstance(); SharedPreferences prefs = await SharedPreferences.getInstance();
setState(() { setState(() {
var kilometer = prefs.getDouble("kilometer")?.toInt() ?? null; kilometer = prefs.getDouble("kilometer")?.toInt() ?? 50;
}); });
} }
Future<void> setParameter() async { Future<void> setParameter() async {
SharedPreferences prefs = await SharedPreferences.getInstance(); SharedPreferences prefs = await SharedPreferences.getInstance();
print("kilometer : ${kilometer}");
if (kilometer != null) { if (kilometer != null) {
prefs.setDouble("kilometer", kilometer?.toDouble() ?? 50); prefs.setDouble("kilometer", kilometer?.toDouble() ?? 50);
showAlertDialog( showAlertDialog(
@@ -115,8 +116,7 @@ class _EditProfileState extends State<EditSettings>
AppLocalizations.of(context)?.define_kilometer ?? AppLocalizations.of(context)?.define_kilometer ??
'Define kilometer', 'Define kilometer',
), ),
value: value: kilometer,
kilometer, // Set the initial selected value here, or leave as `null` if unselected.
items: [ items: [
DropdownMenuItem( DropdownMenuItem(
value: 5, value: 5,
@@ -155,7 +155,7 @@ class _EditProfileState extends State<EditSettings>
color: Colors.blue, color: Colors.blue,
borderRadius: BorderRadius.circular(20)), borderRadius: BorderRadius.circular(20)),
child: TextButton( child: TextButton(
onPressed: () {}, onPressed: setParameter,
child: Text( child: Text(
AppLocalizations.of(context)?.update ?? "Update", AppLocalizations.of(context)?.update ?? "Update",
style: TextStyle(color: Colors.white, fontSize: 25), style: TextStyle(color: Colors.white, fontSize: 25),

View File

@@ -853,12 +853,55 @@ class _MyHomePageState extends State<ListItemMenu> {
), ),
], ],
), ),
floatingActionButton: FloatingActionButton( floatingActionButton: Column(mainAxisSize: MainAxisSize.min, children: [
onPressed: popCamera, const SizedBox(height: 12), // espace entre les deux boutons
backgroundColor: Colors.blue, FloatingActionButton(
tooltip: loc?.search ?? 'Recherche', heroTag: "btn2",
child: const Icon(Icons.photo_camera, color: Colors.white), onPressed: () {
), // Action du deuxième bouton : ouvrir ton modal
showDialog(
context: context,
builder: (context) {
final controller = TextEditingController();
return AlertDialog(
title: Text("Nouveau message"),
content: TextField(
controller: controller,
decoration:
InputDecoration(hintText: "Écris ton message..."),
),
actions: [
TextButton(
onPressed: () => Navigator.pop(context),
child: Text("Annuler"),
),
ElevatedButton(
onPressed: () {
final msg = controller.text.trim();
if (msg.isNotEmpty) {
print("Message saisi: $msg");
// ➝ ici tu peux envoyer à ton chatbot
}
Navigator.pop(context);
},
child: Text("Envoyer"),
)
],
);
},
);
},
backgroundColor: Colors.green,
tooltip: 'Chatbot',
child: const Icon(Icons.chat, color: Colors.white),
),
FloatingActionButton(
onPressed: popCamera,
backgroundColor: Colors.blue,
tooltip: loc?.search ?? 'Recherche',
child: const Icon(Icons.photo_camera, color: Colors.white),
)
]),
); );
} }