add tags in item

This commit is contained in:
Valentin CZERYBA 2024-10-20 11:32:33 +02:00
parent 045209575e
commit f2cd070898

View File

@ -16,8 +16,6 @@ import '../classes/events.dart';
import 'ListItemMenu.dart'; import 'ListItemMenu.dart';
import 'package:textfield_tags/textfield_tags.dart';
void main() { void main() {
initializeDateFormatting("fr_FR", null).then((_) => (const MyApp())); initializeDateFormatting("fr_FR", null).then((_) => (const MyApp()));
} }
@ -73,6 +71,7 @@ class _ItemMenuState extends State<ItemMenu> with ShowErrorDialog {
String organizers = ""; String organizers = "";
String place = ""; String place = "";
String imgUrl = ""; String imgUrl = "";
List<String> tags = [];
Events? events; Events? events;
@override @override
@ -91,6 +90,7 @@ class _ItemMenuState extends State<ItemMenu> with ShowErrorDialog {
String formerMap = ""; String formerMap = "";
String formerImage = ""; String formerImage = "";
String formerDesc = ""; String formerDesc = "";
List<String> formerTags = [];
if (accessToken.isNotEmpty) { if (accessToken.isNotEmpty) {
var urlGet = Uri.parse("${globals.api}/events/${widget.title}"); var urlGet = Uri.parse("${globals.api}/events/${widget.title}");
@ -105,6 +105,7 @@ class _ItemMenuState extends State<ItemMenu> with ShowErrorDialog {
formerMap = formerMap =
"${events["place"]} - ${events["zip_code"]} ${events["city"]} - ${events["country"]}"; "${events["place"]} - ${events["zip_code"]} ${events["city"]} - ${events["country"]}";
formerDesc = events["description"]; formerDesc = events["description"];
formerTags = List<String>.from(events['tags'] as List);
final startDate = DateTime.parse(events["start_date"]); final startDate = DateTime.parse(events["start_date"]);
final date = DateFormat.yMd().format(startDate); final date = DateFormat.yMd().format(startDate);
final time = DateFormat.Hm().format(startDate); final time = DateFormat.Hm().format(startDate);
@ -118,13 +119,13 @@ class _ItemMenuState extends State<ItemMenu> with ShowErrorDialog {
} }
formerDate = "${date} ${time} à ${dateE} ${timeE}"; formerDate = "${date} ${time} à ${dateE} ${timeE}";
if (events["organizers"].length > 1) { if (events["organizers"].length > 0) {
formerOrga = "${events['organizers'][0]}"; formerOrga = "${events['organizers'][0]}";
for (var i = 1; i < events["organizers"].length; i++) { for (var i = 1; i < events["organizers"].length; i++) {
formerOrga = "${formerOrga}, ${events['organizers'][i]}"; formerOrga = "${formerOrga}, ${events['organizers'][i]}";
} }
} else { } else {
formerOrga = "${events['organizers'][0]}"; formerOrga = "";
} }
} else { } else {
var text = ""; var text = "";
@ -183,6 +184,7 @@ class _ItemMenuState extends State<ItemMenu> with ShowErrorDialog {
place = formerMap; place = formerMap;
imgUrl = formerImage; imgUrl = formerImage;
eventDescription = formerDesc; eventDescription = formerDesc;
tags = formerTags;
}); });
} }
@ -274,7 +276,54 @@ class _ItemMenuState extends State<ItemMenu> with ShowErrorDialog {
style: TextStyle(fontSize: 15.0), style: TextStyle(fontSize: 15.0),
maxLines: 3, maxLines: 3,
overflow: TextOverflow.ellipsis)) overflow: TextOverflow.ellipsis))
]) ]),
Row(children: [
Icon(Icons.category),
Text("Tags : ",
style: TextStyle(fontSize: 15.0, fontWeight: FontWeight.bold))
]),
Row(
children: [
Padding(
padding: const EdgeInsets.only(
top: 8,
bottom: 8,
left: 8,
),
child: Wrap(
runSpacing: 4.0,
spacing: 4.0,
children: tags.map((String tag) {
return Container(
decoration: const BoxDecoration(
borderRadius: BorderRadius.all(
Radius.circular(20.0),
),
color: Colors.blue,
),
margin: const EdgeInsets.symmetric(horizontal: 5.0),
padding: const EdgeInsets.symmetric(
horizontal: 10.0, vertical: 5.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
InkWell(
child: Text(
'$tag',
style: const TextStyle(color: Colors.white),
),
onTap: () {
//print("$tag selected");
},
),
],
),
);
}).toList()),
),
],
)
], ],
))); )));
} }