From 0dc098554c76f178f0944be007b141240deb1bad Mon Sep 17 00:00:00 2001 From: Valentin CZERYBA Date: Wed, 11 Dec 2024 22:20:32 +0100 Subject: [PATCH] tags and organizers work --- covas_mobile/lib/pages/EditEvent.dart | 25 ++++++++++++++----------- covas_mobile/lib/pages/ItemMenu.dart | 4 +++- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/covas_mobile/lib/pages/EditEvent.dart b/covas_mobile/lib/pages/EditEvent.dart index af5a8f0..001b4b4 100644 --- a/covas_mobile/lib/pages/EditEvent.dart +++ b/covas_mobile/lib/pages/EditEvent.dart @@ -21,18 +21,27 @@ void main() { class MyApp extends StatelessWidget { Map events = {}; String id = ""; + List organizers = []; + List tags = []; @override Widget build(BuildContext context) { return MaterialApp( debugShowCheckedModeBanner: false, - home: EditEvent(id: id), + home: EditEvent(id: id, organizers: organizers, tags: tags), ); } } class EditEvent extends StatefulWidget { - const EditEvent({Key? key, required this.id}) : super(key: key); + const EditEvent( + {Key? key, + required this.id, + required this.tags, + required this.organizers}) + : super(key: key); final String id; + final List tags; + final List organizers; @override _EditEventState createState() => _EditEventState(); @@ -152,8 +161,6 @@ class _EditEventState extends State String formerMap = ""; String formerImage = ""; String formerDesc = ""; - List formerTags = []; - List formerOrga = []; if (accessToken.isNotEmpty) { var urlGet = Uri.parse("${globals.api}/events/${widget.id}"); @@ -235,12 +242,6 @@ class _EditEventState extends State inputGeo.text = formerMap; imgUrl = formerImage; inputDesc.text = formerDesc; - for (int i = 0; i < events["tags"].length; i++) { - _stringTagController.addTag(events["tags"][i]); - } - for (int i = 0; i < events["organizers"].length; i++) { - _stringOrgaController.addTag(events["organizers"][i]); - } }); } @@ -430,8 +431,10 @@ class _EditEventState extends State @override void initState() { - _getEventInfos(); + initialTags = List.from(widget.tags as List); + initialOrga = List.from(widget.organizers as List); super.initState(); + _getEventInfos(); } final _formKey = GlobalKey(); diff --git a/covas_mobile/lib/pages/ItemMenu.dart b/covas_mobile/lib/pages/ItemMenu.dart index d5c7ed8..22e5978 100644 --- a/covas_mobile/lib/pages/ItemMenu.dart +++ b/covas_mobile/lib/pages/ItemMenu.dart @@ -404,7 +404,9 @@ class _ItemMenuState extends State with ShowErrorDialog { onPressed: () { Navigator.push( context, - MaterialPageRoute(builder: (_) => EditEvent(id: id)), + MaterialPageRoute( + builder: (_) => + EditEvent(id: id, tags: tags, organizers: organizers)), ); }, backgroundColor: Colors.blue,