tags and organizers work

This commit is contained in:
Valentin CZERYBA 2024-12-11 22:20:32 +01:00
parent b8e6adf2e8
commit 0dc098554c
2 changed files with 17 additions and 12 deletions

View File

@ -21,18 +21,27 @@ void main() {
class MyApp extends StatelessWidget { class MyApp extends StatelessWidget {
Map<String, dynamic> events = {}; Map<String, dynamic> events = {};
String id = ""; String id = "";
List<String> organizers = [];
List<String> tags = [];
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return MaterialApp( return MaterialApp(
debugShowCheckedModeBanner: false, debugShowCheckedModeBanner: false,
home: EditEvent(id: id), home: EditEvent(id: id, organizers: organizers, tags: tags),
); );
} }
} }
class EditEvent extends StatefulWidget { 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 String id;
final List<String> tags;
final List<String> organizers;
@override @override
_EditEventState createState() => _EditEventState(); _EditEventState createState() => _EditEventState();
@ -152,8 +161,6 @@ class _EditEventState extends State<EditEvent>
String formerMap = ""; String formerMap = "";
String formerImage = ""; String formerImage = "";
String formerDesc = ""; String formerDesc = "";
List<String> formerTags = [];
List<String> formerOrga = [];
if (accessToken.isNotEmpty) { if (accessToken.isNotEmpty) {
var urlGet = Uri.parse("${globals.api}/events/${widget.id}"); var urlGet = Uri.parse("${globals.api}/events/${widget.id}");
@ -235,12 +242,6 @@ class _EditEventState extends State<EditEvent>
inputGeo.text = formerMap; inputGeo.text = formerMap;
imgUrl = formerImage; imgUrl = formerImage;
inputDesc.text = formerDesc; 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<EditEvent>
@override @override
void initState() { void initState() {
_getEventInfos(); initialTags = List<String>.from(widget.tags as List);
initialOrga = List<String>.from(widget.organizers as List);
super.initState(); super.initState();
_getEventInfos();
} }
final _formKey = GlobalKey<FormState>(); final _formKey = GlobalKey<FormState>();

View File

@ -404,7 +404,9 @@ class _ItemMenuState extends State<ItemMenu> with ShowErrorDialog {
onPressed: () { onPressed: () {
Navigator.push( Navigator.push(
context, context,
MaterialPageRoute(builder: (_) => EditEvent(id: id)), MaterialPageRoute(
builder: (_) =>
EditEvent(id: id, tags: tags, organizers: organizers)),
); );
}, },
backgroundColor: Colors.blue, backgroundColor: Colors.blue,