tags work

This commit is contained in:
Valentin CZERYBA 2024-10-09 23:28:24 +02:00
parent 7e6de0aa38
commit b1a8b932b9

View File

@ -396,27 +396,95 @@ class _UpdateeventImageState extends State<UpdateeventImage>
), ),
TextFieldTags<String>( TextFieldTags<String>(
textfieldTagsController: _stringTagController, textfieldTagsController: _stringTagController,
initialTags: ['python', 'java'], initialTags: [],
textSeparators: const [' ', ','], textSeparators: const [' ', ','],
validator: (String tag) { validator: (String tag) {
if (tag == 'php') { if (_stringTagController.getTags!.contains(tag)) {
return 'Php not allowed'; return 'Tu as deja rentre ce tag';
} }
return null; return null;
}, },
inputFieldBuilder: (context, inputFieldValues) { inputFieldBuilder: (context, inputFieldValues) {
return Padding( return Padding(
padding: const EdgeInsets.only( padding: const EdgeInsets.only(
left: 15.0, right: 15.0, top: 15, bottom: 0), left: 15.0, right: 15.0, top: 15, bottom: 0),
child: TextField( child: TextField(
controller: inputFieldValues.textEditingController, controller: inputFieldValues.textEditingController,
decoration: InputDecoration( focusNode: inputFieldValues.focusNode,
border: OutlineInputBorder(), onChanged: inputFieldValues.onTagChanged,
labelText: 'Tags evenement', onSubmitted: inputFieldValues.onTagSubmitted,
hintText: decoration: InputDecoration(
'Cliquez ici pour ajouter ou supprimer des tags'), border: OutlineInputBorder(),
focusNode: inputFieldValues.focusNode, 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(
padding: const EdgeInsets.only( padding: const EdgeInsets.only(