display event with image
This commit is contained in:
parent
54247f8c56
commit
59bec53d9e
@ -69,6 +69,7 @@ class _ItemMenuState extends State<ItemMenu> with ShowErrorDialog {
|
|||||||
String eventStartDate = "";
|
String eventStartDate = "";
|
||||||
String organizers = "";
|
String organizers = "";
|
||||||
String place = "";
|
String place = "";
|
||||||
|
String imgUrl = "";
|
||||||
|
|
||||||
Events? events;
|
Events? events;
|
||||||
@override
|
@override
|
||||||
@ -85,6 +86,7 @@ class _ItemMenuState extends State<ItemMenu> with ShowErrorDialog {
|
|||||||
String formerDate = "";
|
String formerDate = "";
|
||||||
String formerOrga = "";
|
String formerOrga = "";
|
||||||
String formerMap = "";
|
String formerMap = "";
|
||||||
|
String formerImage = "";
|
||||||
|
|
||||||
if (accessToken.isNotEmpty) {
|
if (accessToken.isNotEmpty) {
|
||||||
var urlGet = Uri.parse("${globals.api}/events/${widget.title}");
|
var urlGet = Uri.parse("${globals.api}/events/${widget.title}");
|
||||||
@ -102,8 +104,13 @@ class _ItemMenuState extends State<ItemMenu> with ShowErrorDialog {
|
|||||||
final time = DateFormat.Hm().format(startDate);
|
final time = DateFormat.Hm().format(startDate);
|
||||||
|
|
||||||
final endDate = DateTime.parse(events["end_date"]);
|
final endDate = DateTime.parse(events["end_date"]);
|
||||||
|
|
||||||
final dateE = DateFormat.yMd().format(endDate);
|
final dateE = DateFormat.yMd().format(endDate);
|
||||||
final timeE = DateFormat.Hm().format(endDate);
|
final timeE = DateFormat.Hm().format(endDate);
|
||||||
|
if (events["imgUrl"] != null) {
|
||||||
|
formerImage = events["imgUrl"];
|
||||||
|
}
|
||||||
|
|
||||||
formerDate = "${date} ${time} à ${dateE} ${timeE}";
|
formerDate = "${date} ${time} à ${dateE} ${timeE}";
|
||||||
if (events["organizers"].length > 1) {
|
if (events["organizers"].length > 1) {
|
||||||
formerOrga = "${events['organizers'][0]}";
|
formerOrga = "${events['organizers'][0]}";
|
||||||
@ -168,6 +175,7 @@ class _ItemMenuState extends State<ItemMenu> with ShowErrorDialog {
|
|||||||
eventStartDate = formerDate;
|
eventStartDate = formerDate;
|
||||||
organizers = formerOrga;
|
organizers = formerOrga;
|
||||||
place = formerMap;
|
place = formerMap;
|
||||||
|
imgUrl = formerImage;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -201,8 +209,7 @@ class _ItemMenuState extends State<ItemMenu> with ShowErrorDialog {
|
|||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.only(top: 60.0),
|
padding: const EdgeInsets.only(top: 60.0),
|
||||||
child: Center(
|
child: Center(
|
||||||
child: Container(
|
child: Container(height: 250, child: Image.network(imgUrl)),
|
||||||
height: 250, child: Image.asset('images/flutter.png')),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Row(
|
Row(
|
||||||
|
@ -2,6 +2,7 @@ import 'package:flutter/material.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 'package:intl/intl.dart';
|
import 'package:intl/intl.dart';
|
||||||
|
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
||||||
|
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
@ -87,6 +88,13 @@ class _UpdateeventImageState extends State<UpdateeventImage>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
convertNulltoEmptyString(var check) {
|
||||||
|
if (check == null) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
return check;
|
||||||
|
}
|
||||||
|
|
||||||
String formatDate(String date) {
|
String formatDate(String date) {
|
||||||
var splitedDate = date.split("-");
|
var splitedDate = date.split("-");
|
||||||
var day = splitedDate[0];
|
var day = splitedDate[0];
|
||||||
@ -117,9 +125,10 @@ class _UpdateeventImageState extends State<UpdateeventImage>
|
|||||||
List<String> send = ["toto"];
|
List<String> send = ["toto"];
|
||||||
if (accessToken.isNotEmpty) {
|
if (accessToken.isNotEmpty) {
|
||||||
try {
|
try {
|
||||||
|
await dotenv.load();
|
||||||
final params = {
|
final params = {
|
||||||
'expiration': '600',
|
'expiration': '15552000',
|
||||||
'key': '87a91f7e54516808dda2c4feffbd5287',
|
'key': dotenv.env["IMGBB_API_KEY"],
|
||||||
};
|
};
|
||||||
print("Post Img");
|
print("Post Img");
|
||||||
final urlPost = Uri.parse('https://api.imgbb.com/1/upload')
|
final urlPost = Uri.parse('https://api.imgbb.com/1/upload')
|
||||||
@ -221,15 +230,17 @@ class _UpdateeventImageState extends State<UpdateeventImage>
|
|||||||
}
|
}
|
||||||
|
|
||||||
void start() async {
|
void start() async {
|
||||||
inputName.text = widget.events["name"];
|
inputName.text = convertNulltoEmptyString(widget.events["name"]);
|
||||||
inputCity.text = widget.events["city"];
|
inputCity.text = convertNulltoEmptyString(widget.events["city"]);
|
||||||
inputAddress.text = widget.events["address"];
|
inputAddress.text = convertNulltoEmptyString(widget.events["address"]);
|
||||||
inputZipCode.text = widget.events["zip_code"];
|
inputZipCode.text = convertNulltoEmptyString(widget.events["zip_code"]);
|
||||||
inputCountry.text = widget.events["country"];
|
inputCountry.text = convertNulltoEmptyString(widget.events["country"]);
|
||||||
inputDesc.text = widget.events["description"];
|
inputDesc.text = convertNulltoEmptyString(widget.events["description"]);
|
||||||
|
|
||||||
DateTime pickedStartDate = DateTime.parse(widget.events["start_date"]);
|
DateTime pickedStartDate =
|
||||||
DateTime pickedEndDate = DateTime.parse(widget.events["end_date"]);
|
DateTime.parse(convertNulltoEmptyString(widget.events["start_date"]));
|
||||||
|
DateTime pickedEndDate =
|
||||||
|
DateTime.parse(convertNulltoEmptyString(widget.events["end_date"]));
|
||||||
|
|
||||||
startDatepicker.text = DateFormat("dd-MM-yyyy").format(pickedStartDate);
|
startDatepicker.text = DateFormat("dd-MM-yyyy").format(pickedStartDate);
|
||||||
endDatepicker.text = DateFormat("dd-MM-yyyy").format(pickedEndDate);
|
endDatepicker.text = DateFormat("dd-MM-yyyy").format(pickedEndDate);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user