From b4b09db5efc9a7068e7093b2cc80a9fc80a01b4e Mon Sep 17 00:00:00 2001 From: Valentin CZERYBA Date: Tue, 30 Jul 2024 23:19:37 +0200 Subject: [PATCH] =?UTF-8?q?texte=20par=20d=C3=A9faut?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lib/pages/DisplayPictureScreen.dart | 6 +- covas_mobile/lib/pages/UpdateEventImage.dart | 68 +++++++------------ 2 files changed, 28 insertions(+), 46 deletions(-) diff --git a/covas_mobile/lib/pages/DisplayPictureScreen.dart b/covas_mobile/lib/pages/DisplayPictureScreen.dart index aef62c5..9546380 100644 --- a/covas_mobile/lib/pages/DisplayPictureScreen.dart +++ b/covas_mobile/lib/pages/DisplayPictureScreen.dart @@ -7,6 +7,7 @@ import 'package:flutter_gemini/flutter_gemini.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:http/http.dart' as http; import "ItemMenu.dart"; +import 'UpdateEventImage.dart'; import 'dart:convert'; @@ -85,7 +86,10 @@ class DisplayPictureScreenState extends State var events = jsonDecode(utf8.decode(responseGet.bodyBytes)); print("reponse http : ${events.length}"); if (events.length == 0) { - showDescImageAddDialog(context, jsonData); + Navigator.push( + context, + MaterialPageRoute( + builder: (_) => UpdateeventImage(events: jsonData))); } else { Navigator.push( context, diff --git a/covas_mobile/lib/pages/UpdateEventImage.dart b/covas_mobile/lib/pages/UpdateEventImage.dart index c9ecbdd..ca699c5 100644 --- a/covas_mobile/lib/pages/UpdateEventImage.dart +++ b/covas_mobile/lib/pages/UpdateEventImage.dart @@ -17,28 +17,34 @@ void main() { } class MyApp extends StatelessWidget { + Map events = {}; @override Widget build(BuildContext context) { return MaterialApp( debugShowCheckedModeBanner: false, - home: UpdateeventImage(), + home: UpdateeventImage(events: events), ); } } class UpdateeventImage extends StatefulWidget { + const UpdateeventImage({Key? key, required this.events}) : super(key: key); + final Map events; + @override _UpdateeventImageState createState() => _UpdateeventImageState(); } class _UpdateeventImageState extends State with ShowErrorDialog { - TextEditingController inputPseudo = TextEditingController(); - TextEditingController inputPassword = TextEditingController(); + TextEditingController inputName = TextEditingController(); + TextEditingController inputPlace = TextEditingController(); + TextEditingController inputDate = TextEditingController(); + Future _login(BuildContext context) async { var url = Uri.parse("${globals.api}/token"); - var pseudo = inputPseudo.text; - var password = inputPassword.text; + var pseudo = inputName.text; + var password = inputPlace.text; print("get login"); print(pseudo.isNotEmpty); print(password.isNotEmpty); @@ -131,25 +137,8 @@ class _UpdateeventImageState extends State } void start() async { - SharedPreferences prefs = await SharedPreferences.getInstance(); - var access_token = prefs.getString("access_token") ?? ""; - print("Get access token"); - - if (access_token.isNotEmpty) { - print("Appel HTTP"); - var urlToken = Uri.parse("${globals.api}/token"); - - var responseToken = await http.get(urlToken, - headers: {HttpHeaders.cookieHeader: 'access_token: ${access_token}'}); - print(responseToken.statusCode); - if (responseToken.statusCode == 200) { - print("route to item list"); - Navigator.push( - context, MaterialPageRoute(builder: (_) => ListItemMenu())); - } else { - prefs.remove("access_token"); - } - } + inputName.text = widget.events["name"]; + inputPlace.text = widget.events["place"]; } @override @@ -186,11 +175,11 @@ class _UpdateeventImageState extends State //padding: const EdgeInsets.only(left:15.0,right: 15.0,top:0,bottom: 0), padding: EdgeInsets.symmetric(horizontal: 15), child: TextField( - controller: inputPseudo, + controller: inputName, decoration: InputDecoration( border: OutlineInputBorder(), - labelText: 'Pseudo', - hintText: 'Enter pseudo existent'), + labelText: 'Nom', + hintText: 'Modifier le nom de l\'évènement'), ), ), Padding( @@ -198,22 +187,15 @@ class _UpdateeventImageState extends State left: 15.0, right: 15.0, top: 15, bottom: 0), //padding: EdgeInsets.symmetric(horizontal: 15), child: TextField( - controller: inputPassword, - obscureText: true, + controller: inputPlace, decoration: InputDecoration( border: OutlineInputBorder(), - labelText: 'Password', - hintText: 'Enter secure password'), + labelText: 'Lieu', + hintText: 'Entrer le lieu'), ), ), - TextButton( - onPressed: () { - //TODO FORGOT PASSWORD SCREEN GOES HERE - }, - child: Text( - 'Forgot Password', - style: TextStyle(color: Colors.blue, fontSize: 15), - ), + SizedBox( + height: 30, ), Container( height: 50, @@ -225,15 +207,11 @@ class _UpdateeventImageState extends State _login(context); }, child: Text( - 'Login', + 'Ajouter', style: TextStyle(color: Colors.white, fontSize: 25), ), ), - ), - SizedBox( - height: 130, - ), - Text('New User? Create Account') + ) ], ), ),