diff --git a/lib/lookups/patient_lookup.dart b/lib/lookups/patient_lookup.dart index d13aeb1f..3770b7ea 100644 --- a/lib/lookups/patient_lookup.dart +++ b/lib/lookups/patient_lookup.dart @@ -1,7 +1,8 @@ + const PATIENT_TYPE = const [ {"text": "outPatiant", "val": "1"}, {"text": "Tomorrow Patient", "val": "2"}, - {"text": "Referral", "val": "3"}, + {"text": "Referrd", "val": "3"}, {"text": "Discharge", "val": "4"}, {"text": "InPatiant", "val": "5"}, {"text": "Referral Discharge", "val": "6"}, @@ -12,4 +13,5 @@ const LOCATIONS = const[ {"text": "In Sudia Arabia", "val": "1"}, {"text": "Out Sudia Arabia", "val": "2"}, - ]; \ No newline at end of file + ]; + diff --git a/lib/screens/patients/patient_search_screen.dart b/lib/screens/patients/patient_search_screen.dart index 1dc40c2e..ab393ac0 100644 --- a/lib/screens/patients/patient_search_screen.dart +++ b/lib/screens/patients/patient_search_screen.dart @@ -1,19 +1,12 @@ -import 'package:intl/intl.dart'; - -import '../../models/patient_model.dart'; -import 'package:doctor_app_flutter/routes.dart'; +import '../../routes.dart'; +import '../../widgets/patients/dynamic_elements.dart'; import 'package:flutter/material.dart'; +import 'package:flutter/rendering.dart'; import 'package:hexcolor/hexcolor.dart'; + import '../../lookups/patient_lookup.dart'; +import '../../models/patient_model.dart'; - // const PATIENT_TYPE = [ - // {"text": "outPatiant", "val": "1"}, - // {"text": "Tomorrow Patient", "val": "2"}, - // {"text": "Referral", "val": "3"}, - // {"text": "Discharge", "val": "4"}, - // {"text": "InPatiant", "val": "5"}, - // {"text": "Referral Discharge", "val": "6"}, - // ]; class PatientSearch extends StatefulWidget { @override _PatientSearchState createState() => _PatientSearchState(); @@ -22,8 +15,6 @@ class PatientSearch extends StatefulWidget { class _PatientSearchState extends State { String _selectedType = '1'; String _selectedLocation = '1'; - TextEditingController _toDateController = new TextEditingController(); - TextEditingController _fromDateController = new TextEditingController(); final _patientSearchForm = GlobalKey(); var _patientSearchFormValues = PatientModel( @@ -279,7 +270,6 @@ class _PatientSearchState extends State { height: 10, ), // Container(child: GridView(gridDelegate: null,),) - SizedBox( height: 10, ), @@ -361,118 +351,11 @@ class _PatientSearchState extends State { // _patientSearchFormValues. = value; }, ), - SizedBox( - height: 10, - ), - Text( - 'From', - style: TextStyle(fontSize: 16), - ), - SizedBox( - height: 10, - ), - TextFormField( - keyboardType: TextInputType.number, - controller: _fromDateController, - decoration: InputDecoration( - hintText: '3/11/2020', - hintStyle: TextStyle( - fontSize: isSmallScreen - ? 14 - : constraints.maxWidth * 0.024), - enabledBorder: OutlineInputBorder( - borderRadius: BorderRadius.all(Radius.circular(20)), - borderSide: BorderSide(color: Hexcolor('#CCCCCC')), - ), - focusedBorder: OutlineInputBorder( - borderRadius: - BorderRadius.all(Radius.circular(10.0)), - borderSide: BorderSide( - color: Theme.of(context).primaryColor), - ) - //BorderRadius.all(Radius.circular(20)); - ), - validator: (value) { - if (value.isEmpty) { - return 'Please enter some text'; - } - return null; - }, - onTap: () { - _presentDatePicker('_selectedFromDate'); - }, - onSaved: (value) { - _patientSearchFormValues.From = value; - }, - ), - SizedBox( - height: 10, - ), - Text( - 'TO', - style: TextStyle(fontSize: 16), - ), - SizedBox( - height: 10, - ), - TextFormField( - keyboardType: TextInputType.number, - controller: _toDateController, - decoration: InputDecoration( - hintText: '3/11/2020', - hintStyle: TextStyle( - fontSize: isSmallScreen - ? 14 - : constraints.maxWidth * 0.024), - enabledBorder: OutlineInputBorder( - borderRadius: BorderRadius.all(Radius.circular(20)), - borderSide: BorderSide(color: Hexcolor('#CCCCCC')), - ), - focusedBorder: OutlineInputBorder( - borderRadius: - BorderRadius.all(Radius.circular(10.0)), - borderSide: BorderSide( - color: Theme.of(context).primaryColor), - ) - //BorderRadius.all(Radius.circular(20)); - ), - onTap: () { - _presentDatePicker('_selectedToDate'); - }, - validator: (value) { - if (value.isEmpty) { - return 'Please enter some text'; - } - return null; - }, - onSaved: (value) { - _patientSearchFormValues.To = value; - }, - ), - SizedBox( - height: 10, - ), - Container( - decoration: BoxDecoration( - borderRadius: BorderRadius.all(Radius.circular(10.0)), - border: - Border.all(color: Theme.of(context).primaryColor), - ), - child: Row( - mainAxisAlignment: MainAxisAlignment.start, - children: [ - Checkbox( - value: true, - activeColor: Theme.of(context).primaryColor, - onChanged: (bool newValue) {}), - Text('Only Arrived Patient', - style: TextStyle( - fontSize: isSmallScreen - ? 18 - : constraints.maxWidth * 0.018)), - ], - ), + + (!(_selectedType=='3' ||_selectedType=='5'))? DynamicElements(_patientSearchFormValues): SizedBox( + height: 0, ), + SizedBox( height: 10, ), @@ -556,27 +439,4 @@ class _PatientSearchState extends State { }), )); } - - 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; - } - }); - }); - } } diff --git a/lib/widgets/patients/dynamic_elements.dart b/lib/widgets/patients/dynamic_elements.dart new file mode 100644 index 00000000..0dd8c225 --- /dev/null +++ b/lib/widgets/patients/dynamic_elements.dart @@ -0,0 +1,160 @@ +import 'package:doctor_app_flutter/models/patient_model.dart'; +import 'package:flutter/material.dart'; +import 'package:hexcolor/hexcolor.dart'; +import 'package:intl/intl.dart'; + +class DynamicElements extends StatefulWidget { + PatientModel _patientSearchFormValues; + DynamicElements(this._patientSearchFormValues); + @override + _DynamicElementsState createState() => _DynamicElementsState(); +} + +class _DynamicElementsState extends State { + 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) { + var smallScreenSize = 660; + bool isSmallScreen = constraints.maxWidth <= smallScreenSize; + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SizedBox( + height: 10, + ), + Text( + 'From', + style: TextStyle(fontSize: 16), + ), + SizedBox( + height: 10, + ), + TextFormField( + keyboardType: TextInputType.number, + controller: _fromDateController, + decoration: InputDecoration( + hintText: '3/11/2020', + hintStyle: TextStyle( + fontSize: + isSmallScreen ? 14 : constraints.maxWidth * 0.024), + enabledBorder: OutlineInputBorder( + borderRadius: BorderRadius.all(Radius.circular(20)), + borderSide: BorderSide(color: Hexcolor('#CCCCCC')), + ), + focusedBorder: OutlineInputBorder( + borderRadius: BorderRadius.all(Radius.circular(10.0)), + borderSide: + BorderSide(color: Theme.of(context).primaryColor), + ) + //BorderRadius.all(Radius.circular(20)); + ), + validator: (value) { + if (value.isEmpty) { + return 'Please enter some text'; + } + return null; + }, + onTap: () { + _presentDatePicker('_selectedFromDate'); + }, + onSaved: (value) { + widget._patientSearchFormValues.From = value; + }, + ), + SizedBox( + height: 10, + ), + Text( + 'TO', + style: TextStyle(fontSize: 16), + ), + SizedBox( + height: 10, + ), + TextFormField( + keyboardType: TextInputType.number, + controller: _toDateController, + decoration: InputDecoration( + hintText: '3/11/2020', + hintStyle: TextStyle( + fontSize: + isSmallScreen ? 14 : constraints.maxWidth * 0.024), + enabledBorder: OutlineInputBorder( + borderRadius: BorderRadius.all(Radius.circular(20)), + borderSide: BorderSide(color: Hexcolor('#CCCCCC')), + ), + focusedBorder: OutlineInputBorder( + borderRadius: BorderRadius.all(Radius.circular(10.0)), + borderSide: + BorderSide(color: Theme.of(context).primaryColor), + ) + //BorderRadius.all(Radius.circular(20)); + ), + onTap: () { + _presentDatePicker('_selectedToDate'); + }, + validator: (value) { + if (value.isEmpty) { + return 'Please enter some text'; + } + return null; + }, + onSaved: (value) { + widget._patientSearchFormValues.To = value; + }, + ), + SizedBox( + height: 10, + ), + Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.all(Radius.circular(10.0)), + border: Border.all(color: Theme.of(context).primaryColor), + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Checkbox( + value: true, + activeColor: Theme.of(context).primaryColor, + onChanged: (bool newValue) {}), + Text('Only Arrived Patient', + style: TextStyle( + fontSize: isSmallScreen + ? 18 + : constraints.maxWidth * 0.018)), + ], + ), + ) + ], + ); + }, + ); + } +}