You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
90 lines
2.8 KiB
Dart
90 lines
2.8 KiB
Dart
import 'package:doctor_app_flutter/config/config.dart';
|
|
import 'package:doctor_app_flutter/models/patient_model.dart';
|
|
import 'package:doctor_app_flutter/widgets/shared/app_text_form_field.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:intl/intl.dart';
|
|
|
|
class DynamicElements extends StatefulWidget {
|
|
final PatientModel _patientSearchFormValues;
|
|
DynamicElements(this._patientSearchFormValues);
|
|
@override
|
|
_DynamicElementsState createState() => _DynamicElementsState();
|
|
}
|
|
|
|
class _DynamicElementsState extends State<DynamicElements> {
|
|
TextEditingController _toDateController = new TextEditingController();
|
|
TextEditingController _fromDateController = new TextEditingController();
|
|
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;
|
|
}
|
|
});
|
|
});
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return LayoutBuilder(
|
|
builder: (ctx, constraints) {
|
|
return Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: <Widget>[
|
|
SizedBox(
|
|
height: 10,
|
|
),
|
|
AppTextFormField(
|
|
textInputType: TextInputType.number,
|
|
hintText: 'From',
|
|
controller: _fromDateController,
|
|
// validator: (value) {
|
|
// return TextValidator().validateDate(_fromDateController.text);
|
|
// },
|
|
inputFormatter: ONLY_DATE,
|
|
onTap: () {
|
|
_presentDatePicker('_selectedFromDate');
|
|
},
|
|
onSaved: (value) {
|
|
widget._patientSearchFormValues.From = _fromDateController.text;
|
|
},
|
|
),
|
|
|
|
SizedBox(
|
|
height: 10,
|
|
),
|
|
AppTextFormField(
|
|
textInputType: TextInputType.number,
|
|
hintText: 'TO',
|
|
controller: _toDateController,
|
|
onTap: () {
|
|
_presentDatePicker('_selectedToDate');
|
|
},
|
|
// validator: (value) {
|
|
// return TextValidator().validateDate(_toDateController.text);
|
|
// },
|
|
inputFormatter: ONLY_DATE,
|
|
onSaved: (value) {
|
|
widget._patientSearchFormValues.To = _toDateController.text;
|
|
},
|
|
),
|
|
],
|
|
);
|
|
},
|
|
);
|
|
}
|
|
}
|