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:http/http.dart' as http;
import "ItemMenu.dart";
import 'UpdateEventImage.dart';
import 'dart:convert';
@ -85,7 +86,10 @@ class DisplayPictureScreenState extends State<DisplayPictureScreen>
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,

View File

@ -17,28 +17,34 @@ void main() {
}
class MyApp extends StatelessWidget {
Map<String, dynamic> 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<String, dynamic> events;
@override
_UpdateeventImageState createState() => _UpdateeventImageState();
}
class _UpdateeventImageState extends State<UpdateeventImage>
with ShowErrorDialog {
TextEditingController inputPseudo = TextEditingController();
TextEditingController inputPassword = TextEditingController();
TextEditingController inputName = TextEditingController();
TextEditingController inputPlace = TextEditingController();
TextEditingController inputDate = TextEditingController();
Future<void> _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<UpdateeventImage>
}
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<UpdateeventImage>
//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<UpdateeventImage>
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<UpdateeventImage>
_login(context);
},
child: Text(
'Login',
'Ajouter',
style: TextStyle(color: Colors.white, fontSize: 25),
),
),
),
SizedBox(
height: 130,
),
Text('New User? Create Account')
)
],
),
),