From b1a8b932b912a1631daf346f977dfb05b0454028 Mon Sep 17 00:00:00 2001 From: Valentin CZERYBA Date: Wed, 9 Oct 2024 23:28:24 +0200 Subject: [PATCH] tags work --- covas_mobile/lib/pages/UpdateEventImage.dart | 96 +++++++++++++++++--- 1 file changed, 82 insertions(+), 14 deletions(-) diff --git a/covas_mobile/lib/pages/UpdateEventImage.dart b/covas_mobile/lib/pages/UpdateEventImage.dart index ded3e96..8abc7b0 100644 --- a/covas_mobile/lib/pages/UpdateEventImage.dart +++ b/covas_mobile/lib/pages/UpdateEventImage.dart @@ -396,27 +396,95 @@ class _UpdateeventImageState extends State ), TextFieldTags( textfieldTagsController: _stringTagController, - initialTags: ['python', 'java'], + initialTags: [], textSeparators: const [' ', ','], validator: (String tag) { - if (tag == 'php') { - return 'Php not allowed'; + if (_stringTagController.getTags!.contains(tag)) { + return 'Tu as deja rentre ce tag'; } return null; }, inputFieldBuilder: (context, inputFieldValues) { return Padding( - padding: const EdgeInsets.only( - left: 15.0, right: 15.0, top: 15, bottom: 0), - child: TextField( - controller: inputFieldValues.textEditingController, - decoration: InputDecoration( - border: OutlineInputBorder(), - labelText: 'Tags evenement', - hintText: - 'Cliquez ici pour ajouter ou supprimer des tags'), - focusNode: inputFieldValues.focusNode, - )); + padding: const EdgeInsets.only( + left: 15.0, right: 15.0, top: 15, bottom: 0), + child: TextField( + controller: inputFieldValues.textEditingController, + focusNode: inputFieldValues.focusNode, + onChanged: inputFieldValues.onTagChanged, + onSubmitted: inputFieldValues.onTagSubmitted, + decoration: InputDecoration( + border: OutlineInputBorder(), + labelText: 'Tags evenement', + hintText: inputFieldValues.tags.isNotEmpty + ? '' + : "Enter tag...", + errorText: inputFieldValues.error, + prefixIcon: inputFieldValues.tags.isNotEmpty + ? SingleChildScrollView( + controller: + inputFieldValues.tagScrollController, + scrollDirection: Axis.vertical, + child: Padding( + padding: const EdgeInsets.only( + top: 8, + bottom: 8, + left: 8, + ), + child: Wrap( + runSpacing: 4.0, + spacing: 4.0, + children: inputFieldValues.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"); + }, + ), + const SizedBox(width: 4.0), + InkWell( + child: const Icon( + Icons.cancel, + size: 14.0, + color: Color.fromARGB( + 255, 233, 233, 233), + ), + onTap: () { + inputFieldValues + .onTagRemoved(tag); + }, + ) + ], + ), + ); + }).toList()), + ), + ) + : null, + ), + ), + ); }), Padding( padding: const EdgeInsets.only(