diff --git a/covas_mobile/lib/pages/ListItemMenu.dart b/covas_mobile/lib/pages/ListItemMenu.dart index 04761d1..047c501 100644 --- a/covas_mobile/lib/pages/ListItemMenu.dart +++ b/covas_mobile/lib/pages/ListItemMenu.dart @@ -46,6 +46,7 @@ class _MyHomePageState extends State { String query = ''; List> suggestions = []; TextEditingController inputGeo = TextEditingController(); + TextEditingController Datepicker = TextEditingController(); // Fetching events from API static Future> getPosts() async { @@ -118,6 +119,8 @@ class _MyHomePageState extends State { super.initState(); // Initialize data fetch when the page loads _getCurrentLocation(); + + Datepicker.text = DateFormat("dd-MM-yyyy").format(new DateTime.now()); } // Get the device's current location @@ -296,6 +299,31 @@ class _MyHomePageState extends State { } } + onTapFunctionDatePicker({required BuildContext context}) async { + DateTime dateEvent = DateTime.now(); + + DateTime? pickedDate = await showDatePicker( + context: context, + firstDate: dateEvent, + initialDate: dateEvent, + lastDate: DateTime(2104)); + if (pickedDate == null) return; + Datepicker.text = DateFormat("dd-MM-yyyy").format(pickedDate); + } + + Padding _BuildDateField() { + return Padding( + padding: const EdgeInsets.all(8.0), + //padding: EdgeInsets.symmetric(horizontal: 15), + child: TextFormField( + controller: Datepicker, + readOnly: true, + decoration: InputDecoration( + border: OutlineInputBorder(), hintText: 'Recherche par date'), + onTap: () => onTapFunctionDatePicker(context: context)), + ); + } + Padding _buildGeographicalZoneSearchField() { return Padding( padding: const EdgeInsets.all(8.0), @@ -388,6 +416,7 @@ class _MyHomePageState extends State { body: Column( children: [ _buildGeographicalZoneSearchField(), + _BuildDateField(), Expanded( child: FutureBuilder>( future: postsFuture,