import '../../config/size_config.dart'; import '../../util/text_validator.dart'; import '../../widgets/shared/app_buttons_widget.dart'; import '../../widgets/shared/app_scaffold_widget.dart'; import '../../widgets/shared/app_text_form_field.dart'; import '../../widgets/shared/app_texts_widget.dart'; import '../../widgets/shared/rounded_container_widget.dart'; import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; import '../../lookups/patient_lookup.dart'; import '../../models/patient_model.dart'; import '../../widgets/patients/dynamic_elements.dart'; // OWNER : Ibrahim albitar // DATE : 19-04-2020 // DESCRIPTION : Patient Search Screen. class PatientSearchScreen extends StatefulWidget { @override _PatientSearchScreenState createState() => _PatientSearchScreenState(); } class _PatientSearchScreenState extends State { String _selectedType = '1'; String _selectedLocation = '1'; final GlobalKey _formKey = GlobalKey(); bool _autoValidate = false; var _patientSearchFormValues = PatientModel( ProjectID: 12, ClinicID: 17, DoctorID: 98129, FirstName: "0", MiddleName: "0", LastName: "0", PatientMobileNumber: "0", PatientIdentificationID: "0", PatientID: 0, From: "0", To: "0", LanguageID: 2, stamp: "2020-03-02T13:56:39.170Z", IPAdress: "11.11.11.11", VersionID: 1.2, Channel: 9, TokenID: "2Fi7HoIHB0eDyekVa6tCJg==", SessionID: "5G0yXn0Jnq", IsLoginForDoctorApp: true, PatientOutSA: false); void _validateInputs() { if (_formKey.currentState.validate()) { // If all data are correct then save data to out variables _formKey.currentState.save(); } else { // If all data are not valid then start auto validation. setState(() { _autoValidate = true; }); } } @override Widget build(BuildContext context) { return AppScaffold( appBarTitle: "SEARCH FOR PATIENT", body: ListView( children: [ RoundedContainer( child: Column( children: [ Icon( Icons.search, size: SizeConfig.imageSizeMultiplier * 15, ), Container( padding: EdgeInsets.all(15), width: SizeConfig.screenWidth * 1, child: Form( key: _formKey, autovalidate: _autoValidate, child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ SizedBox( height: 5, ), RoundedContainer( margin: 0, showBorder: true, raduis: 30, borderColor: Color(0xff707070), width: double.infinity, child: Padding( padding: EdgeInsets.only( top: SizeConfig.widthMultiplier * 0.9, bottom: SizeConfig.widthMultiplier * 0.9, right: SizeConfig.widthMultiplier * 3, left: SizeConfig.widthMultiplier * 3), child: Row( mainAxisSize: MainAxisSize.max, children: [ Expanded( // add Expanded to have your dropdown button fill remaining space child: DropdownButton( isExpanded: true, value: _selectedType, iconSize: 40, elevation: 16, selectedItemBuilder: (BuildContext context) { return PATIENT_TYPE.map((item) { return Row( mainAxisSize: MainAxisSize.max, children: [ AppText( item['text'], fontSize: SizeConfig.textMultiplier * 2.1, ), ], ); }).toList(); }, onChanged: (String newValue) => { setState(() { _selectedType = newValue; }) }, items: PATIENT_TYPE.map((item) { return DropdownMenuItem( child: Text( '${item['text']}', textAlign: TextAlign.end, ), value: item['val'], ); }).toList(), ), ), ], ), ), ), SizedBox( height: 10, ), AppTextFormField( hintText: 'First Name', onSaved: (value) { _patientSearchFormValues.FirstName = value; }, validator: (value) { return TextValidator().validateName(value); }, ), SizedBox( height: 10, ), AppTextFormField( hintText: 'Middle Name', onSaved: (value) { _patientSearchFormValues.MiddleName = value; }, validator: (value) { return TextValidator().validateName(value); }, ), SizedBox( height: 10, ), AppTextFormField( hintText: 'Last Name', onSaved: (value) { _patientSearchFormValues.LastName = value; }, validator: (value) { return TextValidator().validateName(value); }, ), SizedBox( height: 10, ), AppTextFormField( textInputType: TextInputType.number, hintText: 'Phone Number', validator: (value) { return TextValidator().validateMobile(value); }, onSaved: (value) { _patientSearchFormValues.PatientMobileNumber = value; }, ), SizedBox( height: 10, ), AppTextFormField( textInputType: TextInputType.number, hintText: 'Patiant ID', validator: (value) { return TextValidator().validateIdNumber(value); }, onSaved: (value) { _patientSearchFormValues.PatientID = 89000; }), SizedBox( height: 10, ), AppTextFormField( textInputType: TextInputType.number, hintText: 'Patiant File', validator: (value) { return TextValidator().validateIdNumber(value); }, onSaved: (value) { //_patientSearchFormValues. = value; }, ), (!(_selectedType == '3' || _selectedType == '5')) ? DynamicElements(_patientSearchFormValues) : SizedBox( height: 0, ), SizedBox( height: 10, ), RoundedContainer( margin: 0, showBorder: true, raduis: 30, borderColor: Color(0xff707070), width: double.infinity, child: Padding( padding: EdgeInsets.only( top: SizeConfig.widthMultiplier * 0.9, bottom: SizeConfig.widthMultiplier * 0.9, right: SizeConfig.widthMultiplier * 3, left: SizeConfig.widthMultiplier * 3), child: Row( mainAxisSize: MainAxisSize.max, children: [ Expanded( // add Expanded to have your dropdown button fill remaining space child: DropdownButton( isExpanded: true, value: _selectedLocation, iconSize: 40, elevation: 16, selectedItemBuilder: (BuildContext context) { return LOCATIONS.map((item) { return Row( mainAxisSize: MainAxisSize.max, children: [ AppText( item['text'], fontSize: SizeConfig.textMultiplier * 2.1, ), ], ); }).toList(); }, onChanged: (String newValue) => { setState(() { _selectedLocation = newValue; }) }, items: LOCATIONS.map((item) { return DropdownMenuItem( child: Text( '${item['text']}', textAlign: TextAlign.end, ), value: item['val'], ); }).toList(), ), ), ], ), ), ), Container( child: Row( mainAxisAlignment: MainAxisAlignment.start, children: [ Checkbox( value: true, activeColor: Color(0xffFFDDD9), onChanged: (bool newValue) {}), AppText('Only Arrived Patient', fontSize: SizeConfig.textMultiplier * 2), ])), SizedBox( height: 10, ), ], ), ), ) ], ), ), Container( margin: EdgeInsets.all(SizeConfig.widthMultiplier * 5), child: Wrap( alignment: WrapAlignment.center, children: [ AppButton( title: "Search", color: Color(0xff58434F), onPressed: () { _validateInputs(); }, ), ], ), ) ], )); } }