add calender to allow chose date from and to

merge-requests/1/merge
Elham Rababah 5 years ago
parent ed2f0ebcf8
commit d38e2a918b

@ -1,9 +1,10 @@
import 'package:intl/intl.dart';
import '../../models/patient_model.dart';
import 'package:doctor_app_flutter/routes.dart';
import 'package:flutter/material.dart';
import 'package:hexcolor/hexcolor.dart';
class PatientSearch extends StatefulWidget {
@override
_PatientSearchState createState() => _PatientSearchState();
@ -25,6 +26,8 @@ class _PatientSearchState extends State<PatientSearch> {
];
String _selectedType = '1';
String _selectedLocation = '1';
TextEditingController _toDateController = new TextEditingController();
TextEditingController _fromDateController = new TextEditingController();
final _patientSearchForm = GlobalKey<FormState>();
var _patientSearchFormValues = PatientModel(
@ -51,7 +54,11 @@ class _PatientSearchState extends State<PatientSearch> {
void _saveForm() {
_patientSearchForm.currentState.save();
// Navigator.pushNamed(context,routeName)
print(_patientSearchFormValues.From);
print(_patientSearchFormValues.To);
Navigator.of(context).pushNamed(PATIENTS);
}
@ -326,6 +333,7 @@ class _PatientSearchState extends State<PatientSearch> {
height: 10,
),
TextFormField(
keyboardType: TextInputType.number,
decoration: InputDecoration(
hintText: 'Patiant File',
hintStyle: TextStyle(
@ -365,8 +373,10 @@ class _PatientSearchState extends State<PatientSearch> {
height: 10,
),
TextFormField(
keyboardType: TextInputType.number,
controller: _fromDateController,
decoration: InputDecoration(
hintText: 'From',
hintText: '3/11/2020',
hintStyle: TextStyle(
fontSize: isSmallScreen
? 14
@ -389,6 +399,9 @@ class _PatientSearchState extends State<PatientSearch> {
}
return null;
},
onTap: () {
_presentDatePicker('_selectedFromDate');
},
onSaved: (value) {
_patientSearchFormValues.From = value;
},
@ -404,8 +417,10 @@ class _PatientSearchState extends State<PatientSearch> {
height: 10,
),
TextFormField(
keyboardType: TextInputType.number,
controller: _toDateController,
decoration: InputDecoration(
hintText: 'To',
hintText: '3/11/2020',
hintStyle: TextStyle(
fontSize: isSmallScreen
? 14
@ -422,6 +437,9 @@ class _PatientSearchState extends State<PatientSearch> {
)
//BorderRadius.all(Radius.circular(20));
),
onTap: () {
_presentDatePicker('_selectedToDate');
},
validator: (value) {
if (value.isEmpty) {
return 'Please enter some text';
@ -474,7 +492,7 @@ class _PatientSearchState extends State<PatientSearch> {
),
width: double.infinity,
child: DropdownButton(
value: _selectedType,
value: _selectedLocation,
iconSize: 24,
elevation: 16,
selectedItemBuilder: (BuildContext context) {
@ -484,7 +502,7 @@ class _PatientSearchState extends State<PatientSearch> {
},
onChanged: (String newValue) => {
setState(() {
_selectedType = newValue;
_selectedLocation = newValue;
})
},
items: _locations.map((item) {
@ -539,4 +557,27 @@ class _PatientSearchState extends State<PatientSearch> {
}),
));
}
void _presentDatePicker(id) {
showDatePicker(
context: context,
initialDate: DateTime.now(),
firstDate: DateTime(2019),
lastDate: DateTime.now(),
).then((pickedDate) {
if (pickedDate == null) {
return;
}
setState(() {
print(id);
var selectedDate = DateFormat.yMd().format(pickedDate);
if (id == '_selectedFromDate') {
_fromDateController.text = selectedDate;
} else {
_toDateController.text = selectedDate;
}
});
});
}
}

@ -113,13 +113,6 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "4.3.2"
built_mirrors:
dependency: transitive
description:
name: built_mirrors
url: "https://pub.dartlang.org"
source: hosted
version: "0.11.0"
built_value:
dependency: transitive
description:
@ -190,13 +183,6 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.3"
dson:
dependency: "direct main"
description:
name: dson
url: "https://pub.dartlang.org"
source: hosted
version: "0.16.0"
fixnum:
dependency: transitive
description:
@ -277,6 +263,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.4"
intl:
dependency: "direct main"
description:
name: intl
url: "https://pub.dartlang.org"
source: hosted
version: "0.16.1"
io:
dependency: transitive
description:
@ -417,13 +410,6 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "0.0.4+2"
serializable:
dependency: transitive
description:
name: serializable
url: "https://pub.dartlang.org"
source: hosted
version: "0.12.0"
shelf:
dependency: transitive
description:
@ -443,13 +429,6 @@ packages:
description: flutter
source: sdk
version: "0.0.99"
source_gen:
dependency: transitive
description:
name: source_gen
url: "https://pub.dartlang.org"
source: hosted
version: "0.9.5"
source_maps:
dependency: transitive
description:

@ -21,7 +21,7 @@ dependencies:
sdk: flutter
hexcolor: ^1.0.1
flutter_device_type: ^0.2.0
dson: ^0.16.0
intl: ^0.16.1
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^0.1.2

Loading…
Cancel
Save