itemDescription en coursé

'
This commit is contained in:
Valentin CZERYBA 2024-07-01 23:49:58 +02:00
parent 2c6a1a1686
commit 635b927976

View File

@ -7,13 +7,15 @@ import 'package:covas_mobile/classes/alert.dart';
import 'package:flutter/material.dart';
import 'package:http/http.dart' as http;
import 'package:shared_preferences/shared_preferences.dart';
import 'package:intl/intl.dart';
import 'package:intl/date_symbol_data_local.dart';
import '../variable/globals.dart' as globals;
import '../classes/events.dart';
void main() {
runApp(const MyApp());
initializeDateFormatting("fr_FR", null).then((_) => (const MyApp()));
}
class MyApp extends StatelessWidget {
@ -62,6 +64,7 @@ class ItemMenu extends StatefulWidget {
class _ItemMenuState extends State<ItemMenu> with ShowErrorDialog {
String listUser = "";
String eventName = "";
String eventStartDate = "";
Events? events;
@override
@ -74,7 +77,8 @@ class _ItemMenuState extends State<ItemMenu> with ShowErrorDialog {
Future<void> _getEventInfos() async {
SharedPreferences prefs = await SharedPreferences.getInstance();
var accessToken = prefs.getString("access_token") ?? "";
String former = "";
String formerName = "";
String formerDate = "";
print("${accessToken}");
if (accessToken.isNotEmpty) {
@ -86,8 +90,11 @@ class _ItemMenuState extends State<ItemMenu> with ShowErrorDialog {
if (responseGet.statusCode == 200) {
stderr.writeln('Username : ${responseGet.body}');
var events = jsonDecode(utf8.decode(responseGet.bodyBytes));
print(events["name"]);
former = events["name"];
formerName = events["name"];
final startDate = DateTime.parse(events["start_date"]);
final date = DateFormat.yMd().format(startDate);
final time = DateFormat.Hm().format(startDate);
formerDate = "${date} - ${time}";
} else {
var text = "";
switch (responseGet.statusCode) {
@ -139,8 +146,8 @@ class _ItemMenuState extends State<ItemMenu> with ShowErrorDialog {
// so that the display can reflect the updated values. If we changed
// _counter without calling setState(), then the build method would not be
// called again, and so nothing would appear to happen.
eventName = former;
print(eventName);
eventName = formerName;
eventStartDate = formerDate;
});
}
@ -162,54 +169,25 @@ class _ItemMenuState extends State<ItemMenu> with ShowErrorDialog {
backgroundColor: Colors.blue,
foregroundColor: Colors.white,
),
body: Center(
// Center is a layout widget. It takes a single child and positions it
// in the middle of the parent.
child: Column(
// Column is also a layout widget. It takes a list of children and
// arranges them vertically. By default, it sizes itself to fit its
// children horizontally, and tries to be as tall as its parent.
//
// Invoke "debug painting" (press "p" in the console, choose the
// "Toggle Debug Paint" action from the Flutter Inspector in Android
// Studio, or the "Toggle Debug Paint" command in Visual Studio Code)
// to see the wireframe for each widget.
//
// Column has various properties to control how it sizes itself and
// how it positions its children. Here we use mainAxisAlignment to
// center the children vertically; the main axis here is the vertical
// axis because Columns are vertical (the cross axis would be
// horizontal).
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Form(
key: _formKey,
body: SingleChildScrollView(
child: Column(
children: <Widget>[
// Add TextFormFields and ElevatedButton here.
TextFormField(
// The validator receives the text that the user has entered.
validator: (value) {
if (value == null || value.isEmpty) {
return 'Please enter some text';
}
return null;
},
Padding(
padding: const EdgeInsets.only(top: 60.0),
child: Center(
child: Container(
height: 150,
/*decoration: BoxDecoration(
color: Colors.red,
borderRadius: BorderRadius.circular(50.0)),*/
//child: Image.asset('asset/images/flutter-logo.png')
),
),
),
Row(
children: [Icon(Icons.event), Text("${eventStartDate}")],
)
],
),
),
const Text(
'You have pushed the button this many times:',
),
Text(
'$listUser',
style: Theme.of(context).textTheme.headlineMedium,
),
],
),
),
// This trailing comma makes auto-formatting nicer for build methods.
);
)));
}
}