From f2cd07089895d2e2ec2e78e62ce9c5bd7e2f0d2e Mon Sep 17 00:00:00 2001 From: Valentin CZERYBA Date: Sun, 20 Oct 2024 11:32:33 +0200 Subject: [PATCH] add tags in item --- covas_mobile/lib/pages/ItemMenu.dart | 59 +++++++++++++++++++++++++--- 1 file changed, 54 insertions(+), 5 deletions(-) diff --git a/covas_mobile/lib/pages/ItemMenu.dart b/covas_mobile/lib/pages/ItemMenu.dart index 901e488..c7ba670 100644 --- a/covas_mobile/lib/pages/ItemMenu.dart +++ b/covas_mobile/lib/pages/ItemMenu.dart @@ -16,8 +16,6 @@ import '../classes/events.dart'; import 'ListItemMenu.dart'; -import 'package:textfield_tags/textfield_tags.dart'; - void main() { initializeDateFormatting("fr_FR", null).then((_) => (const MyApp())); } @@ -73,6 +71,7 @@ class _ItemMenuState extends State with ShowErrorDialog { String organizers = ""; String place = ""; String imgUrl = ""; + List tags = []; Events? events; @override @@ -91,6 +90,7 @@ class _ItemMenuState extends State with ShowErrorDialog { String formerMap = ""; String formerImage = ""; String formerDesc = ""; + List formerTags = []; if (accessToken.isNotEmpty) { var urlGet = Uri.parse("${globals.api}/events/${widget.title}"); @@ -105,6 +105,7 @@ class _ItemMenuState extends State with ShowErrorDialog { formerMap = "${events["place"]} - ${events["zip_code"]} ${events["city"]} - ${events["country"]}"; formerDesc = events["description"]; + formerTags = List.from(events['tags'] as List); final startDate = DateTime.parse(events["start_date"]); final date = DateFormat.yMd().format(startDate); final time = DateFormat.Hm().format(startDate); @@ -118,13 +119,13 @@ class _ItemMenuState extends State with ShowErrorDialog { } formerDate = "${date} ${time} à ${dateE} ${timeE}"; - if (events["organizers"].length > 1) { + if (events["organizers"].length > 0) { formerOrga = "${events['organizers'][0]}"; for (var i = 1; i < events["organizers"].length; i++) { formerOrga = "${formerOrga}, ${events['organizers'][i]}"; } } else { - formerOrga = "${events['organizers'][0]}"; + formerOrga = ""; } } else { var text = ""; @@ -183,6 +184,7 @@ class _ItemMenuState extends State with ShowErrorDialog { place = formerMap; imgUrl = formerImage; eventDescription = formerDesc; + tags = formerTags; }); } @@ -274,7 +276,54 @@ class _ItemMenuState extends State with ShowErrorDialog { style: TextStyle(fontSize: 15.0), maxLines: 3, 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()), + ), + ], + ) ], ))); }