texte par défaut

This commit is contained in:
Valentin CZERYBA 2024-07-30 23:19:37 +02:00
parent ceacbc72ee
commit b4b09db5ef
2 changed files with 28 additions and 46 deletions

View File

@ -7,6 +7,7 @@ import 'package:flutter_gemini/flutter_gemini.dart';
import 'package:shared_preferences/shared_preferences.dart'; import 'package:shared_preferences/shared_preferences.dart';
import 'package:http/http.dart' as http; import 'package:http/http.dart' as http;
import "ItemMenu.dart"; import "ItemMenu.dart";
import 'UpdateEventImage.dart';
import 'dart:convert'; import 'dart:convert';
@ -85,7 +86,10 @@ class DisplayPictureScreenState extends State<DisplayPictureScreen>
var events = jsonDecode(utf8.decode(responseGet.bodyBytes)); var events = jsonDecode(utf8.decode(responseGet.bodyBytes));
print("reponse http : ${events.length}"); print("reponse http : ${events.length}");
if (events.length == 0) { if (events.length == 0) {
showDescImageAddDialog(context, jsonData); Navigator.push(
context,
MaterialPageRoute(
builder: (_) => UpdateeventImage(events: jsonData)));
} else { } else {
Navigator.push( Navigator.push(
context, context,

View File

@ -17,28 +17,34 @@ void main() {
} }
class MyApp extends StatelessWidget { class MyApp extends StatelessWidget {
Map<String, dynamic> events = {};
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return MaterialApp( return MaterialApp(
debugShowCheckedModeBanner: false, debugShowCheckedModeBanner: false,
home: UpdateeventImage(), home: UpdateeventImage(events: events),
); );
} }
} }
class UpdateeventImage extends StatefulWidget { class UpdateeventImage extends StatefulWidget {
const UpdateeventImage({Key? key, required this.events}) : super(key: key);
final Map<String, dynamic> events;
@override @override
_UpdateeventImageState createState() => _UpdateeventImageState(); _UpdateeventImageState createState() => _UpdateeventImageState();
} }
class _UpdateeventImageState extends State<UpdateeventImage> class _UpdateeventImageState extends State<UpdateeventImage>
with ShowErrorDialog { with ShowErrorDialog {
TextEditingController inputPseudo = TextEditingController(); TextEditingController inputName = TextEditingController();
TextEditingController inputPassword = TextEditingController(); TextEditingController inputPlace = TextEditingController();
TextEditingController inputDate = TextEditingController();
Future<void> _login(BuildContext context) async { Future<void> _login(BuildContext context) async {
var url = Uri.parse("${globals.api}/token"); var url = Uri.parse("${globals.api}/token");
var pseudo = inputPseudo.text; var pseudo = inputName.text;
var password = inputPassword.text; var password = inputPlace.text;
print("get login"); print("get login");
print(pseudo.isNotEmpty); print(pseudo.isNotEmpty);
print(password.isNotEmpty); print(password.isNotEmpty);
@ -131,25 +137,8 @@ class _UpdateeventImageState extends State<UpdateeventImage>
} }
void start() async { void start() async {
SharedPreferences prefs = await SharedPreferences.getInstance(); inputName.text = widget.events["name"];
var access_token = prefs.getString("access_token") ?? ""; inputPlace.text = widget.events["place"];
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");
}
}
} }
@override @override
@ -186,11 +175,11 @@ class _UpdateeventImageState extends State<UpdateeventImage>
//padding: const EdgeInsets.only(left:15.0,right: 15.0,top:0,bottom: 0), //padding: const EdgeInsets.only(left:15.0,right: 15.0,top:0,bottom: 0),
padding: EdgeInsets.symmetric(horizontal: 15), padding: EdgeInsets.symmetric(horizontal: 15),
child: TextField( child: TextField(
controller: inputPseudo, controller: inputName,
decoration: InputDecoration( decoration: InputDecoration(
border: OutlineInputBorder(), border: OutlineInputBorder(),
labelText: 'Pseudo', labelText: 'Nom',
hintText: 'Enter pseudo existent'), hintText: 'Modifier le nom de l\'évènement'),
), ),
), ),
Padding( Padding(
@ -198,22 +187,15 @@ class _UpdateeventImageState extends State<UpdateeventImage>
left: 15.0, right: 15.0, top: 15, bottom: 0), left: 15.0, right: 15.0, top: 15, bottom: 0),
//padding: EdgeInsets.symmetric(horizontal: 15), //padding: EdgeInsets.symmetric(horizontal: 15),
child: TextField( child: TextField(
controller: inputPassword, controller: inputPlace,
obscureText: true,
decoration: InputDecoration( decoration: InputDecoration(
border: OutlineInputBorder(), border: OutlineInputBorder(),
labelText: 'Password', labelText: 'Lieu',
hintText: 'Enter secure password'), hintText: 'Entrer le lieu'),
), ),
), ),
TextButton( SizedBox(
onPressed: () { height: 30,
//TODO FORGOT PASSWORD SCREEN GOES HERE
},
child: Text(
'Forgot Password',
style: TextStyle(color: Colors.blue, fontSize: 15),
),
), ),
Container( Container(
height: 50, height: 50,
@ -225,15 +207,11 @@ class _UpdateeventImageState extends State<UpdateeventImage>
_login(context); _login(context);
}, },
child: Text( child: Text(
'Login', 'Ajouter',
style: TextStyle(color: Colors.white, fontSize: 25), style: TextStyle(color: Colors.white, fontSize: 25),
), ),
), ),
), )
SizedBox(
height: 130,
),
Text('New User? Create Account')
], ],
), ),
), ),