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