diff --git a/lib/screens/update_client_record.dart b/lib/screens/update_client_record.dart index 3e843f4..63c9b03 100644 --- a/lib/screens/update_client_record.dart +++ b/lib/screens/update_client_record.dart @@ -247,12 +247,14 @@ class UpdateClientRecord extends StatelessWidget { name: "Start date", onSelected: _onSelectedStartDate, initialDate: _initialStartTime, + icon: const Icon(Icons.date_range), ), const SizedBox(height: 15.0), DatePicker( name: "End date", onSelected: _onSelectedEndDate, initialDate: _initialEndTime, + icon: const Icon(Icons.date_range), ), ]), ), diff --git a/lib/widgets/forms/date_picker.dart b/lib/widgets/forms/date_picker.dart index 9cb3846..b1cf7b7 100644 --- a/lib/widgets/forms/date_picker.dart +++ b/lib/widgets/forms/date_picker.dart @@ -6,15 +6,24 @@ class DatePicker extends StatefulWidget { final String _name; final void Function(DateTime?)? _onSelected; final DateTime? _initialDate; + final Icon _icon; + final DateTime? _firstDate; + final DateTime? _lastDate; const DatePicker({ required String name, void Function(DateTime?)? onSelected, DateTime? initialDate, + required Icon icon, + DateTime? firstDate, + DateTime? lastDate, Key? key, }) : _name = name, _onSelected = onSelected, _initialDate = initialDate, + _icon = icon, + _firstDate = firstDate, + _lastDate = lastDate, super(key: key); @override @@ -32,8 +41,8 @@ class _DatePickerState extends State { DateTime? selected = await showDatePicker( context: context, initialDate: picked ?? widget._initialDate ?? DateTime.now(), - firstDate: DateTime(2020, 01, 01), - lastDate: DateTime(2050, 12, 31), + firstDate: widget._firstDate ?? DateTime(2020, 01, 01), + lastDate: widget._lastDate ?? DateTime(2050, 12, 31), ); setState(() { picked = selected; @@ -49,7 +58,7 @@ class _DatePickerState extends State { : widget._initialDate != null ? hourFormatter.format(widget._initialDate!) : widget._name, - icon: const Icon(Icons.date_range), + icon: widget._icon, enabled: false, ), ); diff --git a/lib/widgets/register/register_second_page.dart b/lib/widgets/register/register_second_page.dart index 831f356..61c88e6 100644 --- a/lib/widgets/register/register_second_page.dart +++ b/lib/widgets/register/register_second_page.dart @@ -2,6 +2,7 @@ import 'package:auto_route/auto_route.dart'; import 'package:cross_file_image/cross_file_image.dart'; import 'package:flutter/material.dart'; import 'package:image_picker/image_picker.dart'; +import 'package:pdg_app/widgets/forms/date_picker.dart'; import 'package:provider/provider.dart'; import '../../provider/register_provider.dart'; @@ -21,6 +22,7 @@ class RegisterSecondPage extends StatelessWidget { List buildInputs(BuildContext context) { final registerProvider = context.watch(); + return [ InkWell( onTap: () async { @@ -59,10 +61,17 @@ class RegisterSecondPage extends StatelessWidget { controller: registerProvider.lastnameController, validator: validateString, ), - const MainTextField( - name: 'Birthdate', - icon: Icon(Icons.cake_outlined), - keyboardType: TextInputType.datetime, + DatePicker( + name: "Birthday", + icon: const Icon(Icons.cake_outlined), + initialDate: registerProvider.birthDay, + firstDate: DateTime(1920, 01, 01), + lastDate: DateTime.now(), + onSelected: (date) { + if (date != null) { + registerProvider.birthday = date; + } + }, ), Row( mainAxisAlignment: MainAxisAlignment.end, diff --git a/pubspec.lock b/pubspec.lock index 7b6317e..3793474 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -7,14 +7,14 @@ packages: name: _fe_analyzer_shared url: "https://pub.dartlang.org" source: hosted - version: "47.0.0" + version: "46.0.0" analyzer: dependency: transitive description: name: analyzer url: "https://pub.dartlang.org" source: hosted - version: "4.7.0" + version: "4.6.0" args: dependency: transitive description: @@ -729,7 +729,7 @@ packages: name: path_provider_windows url: "https://pub.dartlang.org" source: hosted - version: "2.1.3" + version: "2.1.2" petitparser: dependency: transitive description: @@ -1028,7 +1028,7 @@ packages: name: win32 url: "https://pub.dartlang.org" source: hosted - version: "3.0.0" + version: "2.7.0" xdg_directories: dependency: transitive description: