import 'package:doctor_app_flutter/config/size_config.dart'; import 'package:doctor_app_flutter/core/model/PatientRegistration/PatientRegistrationModel.dart'; import 'package:doctor_app_flutter/core/viewModel/PatientRegistrationViewModel.dart'; import 'package:doctor_app_flutter/screens/base/base_view.dart'; import 'package:doctor_app_flutter/util/date-utils.dart'; import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/dialogs/dailog-list-select.dart'; import 'package:doctor_app_flutter/widgets/shared/text_fields/app-textfield-custom.dart'; import 'package:flutter/material.dart'; class RegisterSearchPatientPage extends StatefulWidget { const RegisterSearchPatientPage({Key key}) : super(key: key); @override _RegisterSearchPatientPageState createState() => _RegisterSearchPatientPageState(); } class _RegisterSearchPatientPageState extends State { String countryError; dynamic _selectedCountry; final _phoneController = TextEditingController(); String phoneError; final _idController = TextEditingController(); String idError; DateTime _birthDate; String birthdateError; @override Widget build(BuildContext context) { final screenSize = MediaQuery.of(context).size; return BaseView( builder: (_, model, w) => AppScaffold( baseViewModel: model, isShowAppBar: false, body: Column( children: [ Expanded( child: Container( width: double.infinity, margin: EdgeInsets.all(16.0), child: SingleChildScrollView( child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ AppText( "Please enter mobile number or Identification number", fontFamily: 'Poppins', fontSize: SizeConfig.textMultiplier * 2.2, fontWeight: FontWeight.w800, ), SizedBox( height: 10, ), AppTextFieldCustom( height: screenSize.height * 0.075, hintText: "Country", isTextFieldHasSuffix: true, validationError: countryError, dropDownText: _selectedCountry != null ? _selectedCountry['nameEn'] : null, enabled: false, /*onClick: model.dietTypesList != null && model.dietTypesList.length > 0 ? () { openListDialogField('nameEn', 'id', model.dietTypesList, (selectedValue) { setState(() { _selectedCountry = selectedValue; }); }); } : () async { GifLoaderDialogUtils.showMyDialog(context); await model .getDietTypes(patient.patientId) .then((_) => GifLoaderDialogUtils.hideDialog(context)); if (model.state == ViewState.Idle && model.dietTypesList.length > 0) { openListDialogField('nameEn', 'id', model.dietTypesList, (selectedValue) { setState(() { _selectedCountry = selectedValue; }); }); } else if (model.state == ViewState.ErrorLocal) { DrAppToastMsg.showErrorToast(model.error); } else { DrAppToastMsg.showErrorToast("Empty List"); } },*/ ), SizedBox( height: 10, ), AppTextFieldCustom( height: screenSize.height * 0.075, hintText: "Phone Number", inputType: TextInputType.phone, controller: _phoneController, validationError: phoneError, ), SizedBox( height: 10, ), AppTextFieldCustom( height: screenSize.height * 0.075, hintText: "ID Number", inputType: TextInputType.phone, controller: _idController, validationError: idError, ), SizedBox( height: 12, ), AppText( "Calender", fontSize: SizeConfig.textMultiplier * 1.8, fontWeight: FontWeight.w800, ), SizedBox( height: 10, ), AppTextFieldCustom( height: screenSize.height * 0.075, hintText: "Birthdate", dropDownText: _birthDate != null ? "${AppDateUtils.convertStringToDateFormat(_birthDate.toString(), "yyyy-MM-dd")}" : null, enabled: false, isTextFieldHasSuffix: true, validationError: birthdateError, suffixIcon: IconButton( icon: Icon( Icons.calendar_today, color: Colors.black, ), onPressed: null, ), onClick: () { if (_birthDate == null) { _birthDate = DateTime.now(); } _selectDate(context, _birthDate, (picked) { setState(() { _birthDate = picked; }); }); }, ), ], ), ), ), ), ], ), ), ); } Future _selectDate(BuildContext context, DateTime dateTime, Function(DateTime picked) updateDate) async { final DateTime picked = await showDatePicker( context: context, initialDate: dateTime, firstDate: DateTime.now(), lastDate: DateTime(2040), initialEntryMode: DatePickerEntryMode.calendar, ); if (picked != null && picked != dateTime) { updateDate(picked); } } void openListDialogField(String attributeName, String attributeValueId, List list, Function(dynamic selectedValue) okFunction) { ListSelectDialog dialog = ListSelectDialog( list: list, attributeName: attributeName, attributeValueId: attributeValueId, usingSearch: true, okText: TranslationBase.of(context).ok, okFunction: (selectedValue) { okFunction(selectedValue); }, ); showDialog( barrierDismissible: false, context: context, builder: (BuildContext context) { return dialog; }, ); } }