simple textfield
This commit is contained in:
parent
18fdc7d6c4
commit
eadf07177b
@ -51,7 +51,7 @@ class _MyHomePageState extends State<ListItemMenu> {
|
||||
TextEditingController startDatepicker = TextEditingController();
|
||||
TextEditingController endDatepicker = TextEditingController();
|
||||
TextEditingController inputItem = TextEditingController();
|
||||
final _stringTagController = StringTagController();
|
||||
TextEditingController inputTags = TextEditingController();
|
||||
|
||||
bool showDateFields = false; // State to toggle date fields
|
||||
bool showArrow = true;
|
||||
@ -535,89 +535,54 @@ class _MyHomePageState extends State<ListItemMenu> {
|
||||
);
|
||||
}
|
||||
|
||||
TextFieldTags<String> _buildTagsField() {
|
||||
return TextFieldTags<String>(
|
||||
textfieldTagsController: _stringTagController,
|
||||
initialTags: [],
|
||||
textSeparators: const [' ', ','],
|
||||
validator: (String tag) {
|
||||
if (_stringTagController.getTags!.contains(tag)) {
|
||||
return 'Tu as deja rentre ce tag';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
inputFieldBuilder: (context, inputFieldValues) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: TextField(
|
||||
controller: inputFieldValues.textEditingController,
|
||||
focusNode: inputFieldValues.focusNode,
|
||||
onChanged: inputFieldValues.onTagChanged,
|
||||
onSubmitted: inputFieldValues.onTagSubmitted,
|
||||
Padding _buildTagsField() {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Column(
|
||||
children: [
|
||||
TextField(
|
||||
controller: inputTags,
|
||||
decoration: InputDecoration(
|
||||
labelText: 'Search by tags',
|
||||
border: OutlineInputBorder(),
|
||||
labelText: 'Tags',
|
||||
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.all(8.0),
|
||||
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,
|
||||
suffixIcon: inputItem.text.isEmpty
|
||||
? null
|
||||
: IconButton(
|
||||
icon: const Icon(Icons.clear),
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
inputItem.clear();
|
||||
itemName = ''; // Reset the geographical zone state
|
||||
suggestionsItem.clear();
|
||||
showDateFields = true;
|
||||
showArrow = true;
|
||||
});
|
||||
fetchPostsByLocation();
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
});
|
||||
onChanged: (value) {
|
||||
if (value.isNotEmpty) {
|
||||
setState(() {
|
||||
itemName = value;
|
||||
searchSuggestionsByItem(value);
|
||||
});
|
||||
} else {
|
||||
setState(() {
|
||||
showDateFields = true;
|
||||
showArrow = true; // Optionally clear suggestions
|
||||
inputItem.clear(); // Clear the text field
|
||||
itemName = ''; // Reset the geographical zone state
|
||||
suggestionsItem.clear();
|
||||
|
||||
/// Clear the filted posts
|
||||
});
|
||||
fetchPostsByLocation();
|
||||
}
|
||||
}),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Padding _buildItemZoneSearchField() {
|
||||
@ -654,11 +619,11 @@ class _MyHomePageState extends State<ListItemMenu> {
|
||||
});
|
||||
} else {
|
||||
setState(() {
|
||||
showDateFields = true;
|
||||
showArrow = true; // Optionally clear suggestions
|
||||
inputItem.clear(); // Clear the text field
|
||||
itemName = ''; // Reset the geographical zone state
|
||||
suggestionsItem.clear();
|
||||
showDateFields = true;
|
||||
showArrow = true; // Optionally clear suggestions
|
||||
|
||||
/// Clear the filted posts
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user