Compare commits

..

2 Commits

Author SHA1 Message Date
eadf07177b simple textfield 2024-12-20 22:44:05 +01:00
18fdc7d6c4 add tags 2024-12-16 22:26:58 +01:00

View File

@ -14,6 +14,7 @@ import '../variable/globals.dart' as globals;
import 'package:permission_handler/permission_handler.dart';
import "Camera.dart";
import 'package:camera/camera.dart';
import 'package:textfield_tags/textfield_tags.dart';
void main() {
initializeDateFormatting("fr_FR", null).then((_) => runApp(const MyApp()));
@ -50,6 +51,7 @@ class _MyHomePageState extends State<ListItemMenu> {
TextEditingController startDatepicker = TextEditingController();
TextEditingController endDatepicker = TextEditingController();
TextEditingController inputItem = TextEditingController();
TextEditingController inputTags = TextEditingController();
bool showDateFields = false; // State to toggle date fields
bool showArrow = true;
@ -533,6 +535,56 @@ class _MyHomePageState extends State<ListItemMenu> {
);
}
Padding _buildTagsField() {
return Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
children: [
TextField(
controller: inputTags,
decoration: InputDecoration(
labelText: 'Search by tags',
border: OutlineInputBorder(),
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() {
return Padding(
padding: const EdgeInsets.all(8.0),
@ -567,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
});
@ -633,6 +685,7 @@ class _MyHomePageState extends State<ListItemMenu> {
Flexible(child: _buildDateField("start")),
Flexible(child: _buildDateField("end"))
]),
if ((showDateFields) && (showArrow)) _buildTagsField(),
if (showDateFields) _buildGeographicalZoneSearchField(),
if (showArrow)
IconButton(