diff --git a/lib/screens/prescription/add_prescription_form.dart b/lib/screens/prescription/add_prescription_form.dart index fc4609f3..894d7c33 100644 --- a/lib/screens/prescription/add_prescription_form.dart +++ b/lib/screens/prescription/add_prescription_form.dart @@ -6,7 +6,6 @@ import 'package:doctor_app_flutter/core/model/Prescriptions/post_prescrition_req import 'package:doctor_app_flutter/core/model/Prescriptions/prescription_model.dart'; import 'package:doctor_app_flutter/core/model/search_drug/get_medication_response_model.dart'; import 'package:doctor_app_flutter/core/provider/robot_provider.dart'; - import 'package:doctor_app_flutter/core/viewModel/medicine_view_model.dart'; import 'package:doctor_app_flutter/core/viewModel/prescription_view_model.dart'; import 'package:doctor_app_flutter/core/viewModel/project_view_model.dart'; @@ -15,6 +14,7 @@ import 'package:doctor_app_flutter/models/SOAP/GetAssessmentReqModel.dart'; import 'package:doctor_app_flutter/models/patient/patiant_info_model.dart'; import 'package:doctor_app_flutter/screens/base/base_view.dart'; import 'package:doctor_app_flutter/screens/prescription/drugtodrug.dart'; +import 'package:doctor_app_flutter/screens/prescription/prescription_text_filed.dart'; import 'package:doctor_app_flutter/util/date-utils.dart'; import 'package:doctor_app_flutter/util/dr_app_toast_msg.dart'; import 'package:doctor_app_flutter/util/helpers.dart'; @@ -23,7 +23,6 @@ import 'package:doctor_app_flutter/widgets/medicine/medicine_item_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/TextFields.dart'; import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/buttons/app_buttons_widget.dart'; -import 'package:doctor_app_flutter/widgets/shared/dialogs/dailog-list-select.dart'; import 'package:doctor_app_flutter/widgets/shared/network_base_view.dart'; import 'package:doctor_app_flutter/widgets/shared/speech-text-popup.dart'; import 'package:doctor_app_flutter/widgets/shared/text_fields/app-textfield-custom.dart'; @@ -36,8 +35,7 @@ import 'package:provider/provider.dart'; import 'package:speech_to_text/speech_recognition_error.dart'; import 'package:speech_to_text/speech_to_text.dart' as stt; -addPrescriptionForm(context, PrescriptionViewModel model, - PatiantInformtion patient, prescription) { +addPrescriptionForm(context, PrescriptionViewModel model, PatiantInformtion patient, prescription) { showModalBottomSheet( isScrollControlled: true, context: context, @@ -46,7 +44,7 @@ addPrescriptionForm(context, PrescriptionViewModel model, }); } -postProcedure( +postPrescription( {String duration, String doseTimeIn, String dose, @@ -62,16 +60,15 @@ postProcedure( String icdCode, PatiantInformtion patient, String patientType}) async { - PostPrescriptionReqModel postProcedureReqModel = - new PostPrescriptionReqModel(); - List sss = List(); + PostPrescriptionReqModel postProcedureReqModel = new PostPrescriptionReqModel(); + List prescriptionList = List(); postProcedureReqModel.appointmentNo = patient.appointmentNo; postProcedureReqModel.clinicID = patient.clinicId; postProcedureReqModel.episodeID = patient.episodeNo; postProcedureReqModel.patientMRN = patient.patientMRN; - sss.add(PrescriptionRequestModel( + prescriptionList.add(PrescriptionRequestModel( covered: true, dose: double.parse(dose), itemId: drugId.isEmpty ? 1 : int.parse(drugId), @@ -84,9 +81,7 @@ postProcedure( doseTime: doseTimeIn.isEmpty ? 1 : int.parse(doseTimeIn), duration: duration.isEmpty ? 1 : int.parse(duration), doseStartDate: doseTime.toIso8601String())); - postProcedureReqModel.prescriptionRequestModel = sss; - //postProcedureReqModel.procedures = controlsProcedure; - + postProcedureReqModel.prescriptionRequestModel = prescriptionList; await model.postPrescription(postProcedureReqModel, patient.patientMRN); if (model.state == ViewState.ErrorLocal) { @@ -99,8 +94,9 @@ postProcedure( class PrescriptionFormWidget extends StatefulWidget { final PrescriptionViewModel model; - PatiantInformtion patient; - List prescriptionList; + final PatiantInformtion patient; + final List prescriptionList; + PrescriptionFormWidget(this.model, this.patient, this.prescriptionList); @override @@ -116,10 +112,8 @@ class _PrescriptionFormWidgetState extends State { String strengthError; int selectedType; - TextEditingController durationController = TextEditingController(); + TextEditingController strengthController = TextEditingController(); - TextEditingController routeController = TextEditingController(); - TextEditingController frequencyController = TextEditingController(); TextEditingController indicationController = TextEditingController(); TextEditingController instructionController = TextEditingController(); @@ -128,11 +122,9 @@ class _PrescriptionFormWidgetState extends State { final myController = TextEditingController(); DateTime selectedDate; - dynamic selectedDrug; int strengthChar; GetMedicationResponseModel _selectedMedication; - GlobalKey key = - new GlobalKey>(); + GlobalKey key = new GlobalKey>(); TextEditingController drugIdController = TextEditingController(); TextEditingController doseController = TextEditingController(); @@ -141,15 +133,8 @@ class _PrescriptionFormWidgetState extends State { var event = RobotProvider(); var reconizedWord; - var notesList; - var filteredNotesList; - String textSeartch = "Amoxicillin"; - final GlobalKey formKey = GlobalKey(); final double spaceBetweenTextFileds = 12; - List referToList; - dynamic type; - dynamic strength; dynamic route; dynamic frequency; dynamic duration; @@ -161,41 +146,12 @@ class _PrescriptionFormWidgetState extends State { dynamic x; List indicationList; - String routeInatial = 'By Mouth'; - //PatiantInformtion patient; @override void initState() { super.initState(); selectedType = 1; - referToList = List(); - indicationList = List(); - - dynamic indication1 = {"id": 545, "name": "Gingival Hyperplasia"}; - dynamic indication2 = {"id": 546, "name": "Mild Drowsiness"}; - dynamic indication3 = {"id": 547, "name": "Hypertrichosis"}; - dynamic indication4 = {"id": 548, "name": "Mild Dizziness"}; - dynamic indication5 = {"id": 549, "name": "Enlargement of Facial Features"}; - dynamic indication6 = { - "id": 550, - "name": "Phenytoin Hypersensitivity Syndrome" - }; - dynamic indication7 = {"id": 551, "name": "Asterixis"}; - dynamic indication8 = {"id": 552, "name": "Bullous Dermatitis"}; - dynamic indication9 = {"id": 554, "name": "Purpuric Dermatitis"}; - dynamic indication10 = {"id": 555, "name": "Systemic Lupus Erythematosus"}; - - indicationList.add(indication1); - indicationList.add(indication2); - indicationList.add(indication3); - indicationList.add(indication4); - indicationList.add(indication5); - indicationList.add(indication6); - indicationList.add(indication7); - indicationList.add(indication8); - indicationList.add(indication9); - indicationList.add(indication10); } setSelectedType(int val) { @@ -207,8 +163,7 @@ class _PrescriptionFormWidgetState extends State { onVoiceText() async { new SpeechToText(context: context).showAlertDialog(context); var lang = TranslationBase.of(AppGlobal.CONTEX).locale.languageCode; - bool available = await speech.initialize( - onStatus: statusListener, onError: errorListener); + bool available = await speech.initialize(onStatus: statusListener, onError: errorListener); if (available) { speech.listen( onResult: resultListener, @@ -222,7 +177,6 @@ class _PrescriptionFormWidgetState extends State { void errorListener(SpeechRecognitionError error) { event.setValue({"searchText": 'null'}); - //SpeechToText.closeAlertDialog(context); print(error); } @@ -252,21 +206,15 @@ class _PrescriptionFormWidgetState extends State { } Future initSpeechState() async { - bool hasSpeech = await speech.initialize( - onError: errorListener, onStatus: statusListener); + bool hasSpeech = await speech.initialize(onError: errorListener, onStatus: statusListener); print(hasSpeech); if (!mounted) return; } @override Widget build(BuildContext context) { - ListSelectDialog drugDialog; final screenSize = MediaQuery.of(context).size; ProjectViewModel projectViewModel = Provider.of(context); - - // final routeArgs = ModalRoute.of(context).settings.arguments as Map; - // patient = routeArgs['patient']; - return BaseView( onModelReady: (model) async { x = model.patientAssessmentList.map((element) { @@ -278,22 +226,16 @@ class _PrescriptionFormWidgetState extends State { editedBy: '', doctorID: '', appointmentNo: widget.patient.appointmentNo); - //await model.getMedicationList(); if (model.medicationStrengthList.length == 0) { await model.getMedicationStrength(); } - //await model.getPrescription(mrn: widget.patient.patientMRN); if (model.medicationDurationList.length == 0) { await model.getMedicationDuration(); } - //await model.getMedicationRoute(); - //await model.getMedicationFrequency(); if (model.medicationDoseTimeList.length == 0) { await model.getMedicationDoseTime(); } - //await model.getMedicationIndications(); await model.getPatientAssessment(getAssessmentReqModel); - //await model.getItem(); }, builder: ( BuildContext context, @@ -310,18 +252,14 @@ class _PrescriptionFormWidgetState extends State { initialChildSize: 0.98, maxChildSize: 0.98, minChildSize: 0.9, - builder: - (BuildContext context, ScrollController scrollController) { + builder: (BuildContext context, ScrollController scrollController) { return SingleChildScrollView( child: Container( height: MediaQuery.of(context).size.height * 1.65, color: Color(0xffF8F8F8), child: Padding( - padding: EdgeInsets.symmetric( - horizontal: 12.0, vertical: 10.0), + padding: EdgeInsets.symmetric(horizontal: 12.0, vertical: 10.0), child: Column( - //crossAxisAlignment: CrossAxisAlignment.start, - //mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ Column( children: [ @@ -329,12 +267,10 @@ class _PrescriptionFormWidgetState extends State { height: 15, ), Row( - mainAxisAlignment: - MainAxisAlignment.spaceBetween, + mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ AppText( - TranslationBase.of(context) - .newPrescriptionOrder, + TranslationBase.of(context).newPrescriptionOrder, fontWeight: FontWeight.w700, fontSize: 20, ), @@ -358,17 +294,13 @@ class _PrescriptionFormWidgetState extends State { child: Form( key: formKey, child: Column( - //mainAxisAlignment: MainAxisAlignment.end, children: [ FractionallySizedBox( widthFactor: 0.9, child: Container( decoration: BoxDecoration( - borderRadius: BorderRadius.all( - Radius.circular(6.0)), - border: Border.all( - width: 1.0, - color: HexColor("#CCCCCC"))), + borderRadius: BorderRadius.all(Radius.circular(6.0)), + border: Border.all(width: 1.0, color: HexColor("#CCCCCC"))), padding: EdgeInsets.all(10), child: AppTextFormField( onTap: () { @@ -376,8 +308,7 @@ class _PrescriptionFormWidgetState extends State { visbiltySearch = true; }, borderColor: Colors.white, - hintText: TranslationBase.of(context) - .searchMedicineNameHere, + hintText: TranslationBase.of(context).searchMedicineNameHere, controller: myController, onSaved: (value) {}, onFieldSubmitted: (value) { @@ -403,12 +334,9 @@ class _PrescriptionFormWidgetState extends State { children: [ // TODO change it secondary button and add loading AppButton( - title: TranslationBase.of( - context) - .search, + title: TranslationBase.of(context).search, onPressed: () async { - await searchMedicine( - context, model); + await searchMedicine(context, model); }, ), ], @@ -417,50 +345,25 @@ class _PrescriptionFormWidgetState extends State { ), if (myController.text != '') Container( - height: MediaQuery.of(context) - .size - .height * - 0.5, + height: MediaQuery.of(context).size.height * 0.5, child: ListView.builder( - padding: const EdgeInsets.only( - top: 20), + padding: const EdgeInsets.only(top: 20), scrollDirection: Axis.vertical, // shrinkWrap: true, - itemCount: - model.allMedicationList == - null - ? 0 - : model - .allMedicationList - .length, - itemBuilder: - (BuildContext context, - int index) { + itemCount: model.allMedicationList == null + ? 0 + : model.allMedicationList.length, + itemBuilder: (BuildContext context, int index) { return InkWell( child: MedicineItemWidget( - label: model - .allMedicationList[ - index] - .description - // url: model - // .pharmacyItemsList[ - // index]["ImageSRCUrl"], - ), + label: model.allMedicationList[index].description), onTap: () { - model.getItem( - itemID: model - .allMedicationList[ - index] - .itemId); - visbiltyPrescriptionForm = - true; + model.getItem(itemID: model.allMedicationList[index].itemId); + visbiltyPrescriptionForm = true; visbiltySearch = false; - _selectedMedication = - model.allMedicationList[ - index]; - uom = _selectedMedication - .uom; + _selectedMedication = model.allMedicationList[index]; + uom = _selectedMedication.uom; }, ); }, @@ -479,409 +382,134 @@ class _PrescriptionFormWidgetState extends State { child: Column( children: [ AppText( - _selectedMedication?.description ?? - "", + _selectedMedication?.description ?? "", bold: true, ), Container( child: Row( children: [ AppText( - TranslationBase.of(context) - .orderType, + TranslationBase.of(context).orderType, fontWeight: FontWeight.w600, ), Radio( - activeColor: - Color(0xFFB9382C), + activeColor: Color(0xFFB9382C), value: 1, groupValue: selectedType, onChanged: (value) { setSelectedType(value); }, ), - Text('Regular'), + Text(TranslationBase.of(context).regular), ], ), ), - SizedBox( - height: spaceBetweenTextFileds), + SizedBox(height: spaceBetweenTextFileds), Container( width: double.infinity, child: Row( children: [ Container( - color: Colors.white, - width: MediaQuery.of(context) - .size - .width * - 0.35, + width: MediaQuery.of(context).size.width * 0.35, child: AppTextFieldCustom( height: 40, - validationError: - strengthError, + validationError: strengthError, hintText: 'Strength', isTextFieldHasSuffix: false, enabled: true, - controller: - strengthController, + controller: strengthController, onChanged: (String value) { setState(() { - strengthChar = - value.length; + strengthChar = value.length; }); if (strengthChar >= 5) { - DrAppToastMsg - .showErrorToast( - TranslationBase.of( - context) - .only5DigitsAllowedForStrength, + DrAppToastMsg.showErrorToast( + TranslationBase.of(context).only5DigitsAllowedForStrength, ); } }, - inputType: TextInputType - .numberWithOptions( + inputType: TextInputType.numberWithOptions( decimal: true, ), - // keyboardType: TextInputType - // .numberWithOptions( - // decimal: true, - // ), ), ), SizedBox( width: 5.0, ), - Container( - color: Colors.white, - width: MediaQuery.of(context) - .size - .width * - 0.560, - child: InkWell( - onTap: - model.itemMedicineListUnit != - null - ? () { - Helpers - .hideKeyboard( - context); - ListSelectDialog - dialog = - ListSelectDialog( - list: model - .itemMedicineListUnit, - attributeName: - 'description', - attributeValueId: - 'parameterCode', - okText: TranslationBase.of( - context) - .ok, - okFunction: - (selectedValue) { - setState( - () { - units = - selectedValue; - units['isDefault'] = - true; - }); - }, - ); - showDialog( - barrierDismissible: - false, - context: - context, - builder: - (BuildContext - context) { - return dialog; - }, - ); - } - : null, - child: AppTextFieldCustom( - hintText: 'Select', - isTextFieldHasSuffix: - true, - dropDownText: model - .itemMedicineListUnit - .length == - 1 - ? units = model - .itemMedicineListUnit[0] - ['description'] - : units != null - ? units['description'] - .toString() - : null, - validationError: - model.itemMedicineListUnit - .length != - 1 - ? unitError - : null, - enabled: false), - ), + PrescriptionTextFiled( + width: MediaQuery.of(context).size.width * 0.560, + element: units, + elementError: unitError, + keyName: 'description', + keyId: 'parameterCode', + hintText: 'Select', + elementList: model.itemMedicineListUnit, + okFunction: (selectedValue) { + setState(() { + units = selectedValue; + units['isDefault'] = true; + }); + }, ), ], ), ), - SizedBox( - height: spaceBetweenTextFileds), - Container( - //height: screenSize.height * 0.070, - color: Colors.white, - child: InkWell( - onTap: - model.itemMedicineListRoute != - null - ? () { - Helpers.hideKeyboard( - context); - ListSelectDialog - dialog = - ListSelectDialog( - list: model - .itemMedicineListRoute, - attributeName: - 'description', - attributeValueId: - 'parameterCode', - okText: - TranslationBase.of( - context) - .ok, - okFunction: - (selectedValue) { - setState(() { - route = - selectedValue; - route['isDefault'] = - true; - }); - if (route == - null) { - Helpers.showErrorToast( - 'plase fill'); - } - }, - ); - showDialog( - barrierDismissible: - false, - context: context, - builder: - (BuildContext - context) { - return dialog; - }, - ); - } - : null, - child: AppTextFieldCustom( - // decoration: - // textFieldSelectorDecoration( - // TranslationBase.of( - // context) - // .route, - // model.itemMedicineListRoute - // .length == - // 1 - // ? model.itemMedicineListRoute[ - // 0] - // ['description'] - // : route != null - // ? route[ - // 'description'] - // : null, - // true), - hintText: - TranslationBase.of(context) - .route, - dropDownText: model - .itemMedicineListRoute - .length == - 1 - ? model.itemMedicineListRoute[ - 0]['description'] - : route != null - ? route['description'] - : null, - isTextFieldHasSuffix: true, - //height: 45, - validationError: - model.itemMedicineListRoute - .length != - 1 - ? routeError - : null, - - enabled: false, - ), - ), - ), - SizedBox( - height: spaceBetweenTextFileds), - Container( - //height: screenSize.height * 0.070, - color: Colors.white, - child: InkWell( - onTap: - model.itemMedicineList != null - ? () { - Helpers.hideKeyboard( - context); - ListSelectDialog - dialog = - ListSelectDialog( - list: model - .itemMedicineList, - attributeName: - 'description', - attributeValueId: - 'parameterCode', - okText: - TranslationBase.of( - context) - .ok, - okFunction: - (selectedValue) { - setState(() { - frequency = - selectedValue; - frequency[ - 'isDefault'] = - true; - if (_selectedMedication != null && - duration != - null && - frequency != - null && - strengthController - .text != - null) { - model.getBoxQuantity( - freq: frequency[ - 'parameterCode'], - duration: - duration[ - 'id'], - itemCode: - _selectedMedication - .itemId, - strength: - double.parse( - strengthController.text)); - - return; - } - }); - }, - ); - showDialog( - barrierDismissible: - false, - context: context, - builder: - (BuildContext - context) { - return dialog; - }, - ); - } - : null, - child: AppTextFieldCustom( - isTextFieldHasSuffix: true, - hintText: - TranslationBase.of(context) - .frequency, - dropDownText: model - .itemMedicineList - .length == - 1 - ? model.itemMedicineList[0] - ['description'] - : frequency != null - ? frequency[ - 'description'] - : null, - validationError: model - .itemMedicineList - .length != - 1 - ? frequencyError - : null, - enabled: false, - ), - ), - ), - SizedBox( - height: spaceBetweenTextFileds), - Container( - //height: screenSize.height * 0.070, - color: Colors.white, - child: InkWell( - onTap: - model.medicationDoseTimeList != - null - ? () { - Helpers.hideKeyboard( - context); - ListSelectDialog - dialog = - ListSelectDialog( - list: model - .medicationDoseTimeList, - attributeName: - 'nameEn', - attributeValueId: - 'id', - okText: - TranslationBase.of( - context) - .ok, - okFunction: - (selectedValue) { - setState(() { - doseTime = - selectedValue; - }); - }, - ); - showDialog( - barrierDismissible: - false, - context: context, - builder: - (BuildContext - context) { - return dialog; - }, - ); - } - : null, - child: AppTextFieldCustom( - hintText: - TranslationBase.of(context) - .doseTime, - isTextFieldHasSuffix: true, - dropDownText: doseTime != null - ? doseTime['nameEn'] - : null, - //height: 45, - - enabled: false, - validationError: doseTimeError, - ), - ), + SizedBox(height: spaceBetweenTextFileds), + PrescriptionTextFiled( + elementList: model.itemMedicineListRoute, + element: route, + elementError: routeError, + keyId: 'parameterCode', + keyName: 'description', + okFunction: (selectedValue) { + setState(() { + route = selectedValue; + route['isDefault'] = true; + }); + }, + hintText: TranslationBase.of(context).route, ), - SizedBox( - height: spaceBetweenTextFileds), - if (model - .patientAssessmentList.isNotEmpty) + SizedBox(height: spaceBetweenTextFileds), + PrescriptionTextFiled( + hintText: TranslationBase.of(context).frequency, + elementError: frequencyError, + element: frequencyError, + elementList: model.itemMedicineList, + keyId: 'parameterCode', + keyName: 'description', + okFunction: (selectedValue) { + setState(() { + frequency = selectedValue; + frequency['isDefault'] = true; + if (_selectedMedication != null && + duration != null && + frequency != null && + strengthController.text != null) { + model.getBoxQuantity( + freq: frequency['parameterCode'], + duration: duration['id'], + itemCode: _selectedMedication.itemId, + strength: double.parse(strengthController.text)); + + return; + } + }); + }), + SizedBox(height: spaceBetweenTextFileds), + PrescriptionTextFiled( + hintText: TranslationBase.of(context).doseTime, + elementError: doseTimeError, + element: doseTime, + elementList: model.medicationDoseTimeList, + keyId: 'id', + keyName: 'nameEn', + okFunction: (selectedValue) { + setState(() { + doseTime = selectedValue; + }); + }), + SizedBox(height: spaceBetweenTextFileds), + if (model.patientAssessmentList.isNotEmpty) Container( height: screenSize.height * 0.070, width: double.infinity, @@ -889,326 +517,121 @@ class _PrescriptionFormWidgetState extends State { child: Row( children: [ Container( - width: - MediaQuery.of(context) - .size - .width * - 0.29, - child: InkWell( - onTap: - indicationList != null - ? () { - Helpers.hideKeyboard( - context); - } - : null, - child: TextField( - decoration: - textFieldSelectorDecoration( - model - .patientAssessmentList[ - 0] - .icdCode10ID - .toString(), - indication != - null - ? indication[ - 'name'] - : null, - false), - enabled: true, - readOnly: true, - ), + width: MediaQuery.of(context).size.width * 0.29, + child: TextField( + decoration: textFieldSelectorDecoration( + model.patientAssessmentList[0].icdCode10ID.toString(), + indication != null ? indication['name'] : null, + false), + enabled: true, + readOnly: true, ), ), Container( - width: - MediaQuery.of(context) - .size - .width * - 0.65, + width: MediaQuery.of(context).size.width * 0.65, color: Colors.white, - child: InkWell( - onTap: - indicationList != null - ? () { - Helpers.hideKeyboard( - context); - } - : null, - child: TextField( - maxLines: 5, - decoration: - textFieldSelectorDecoration( - model - .patientAssessmentList[ - 0] - .asciiDesc - .toString(), - indication != - null - ? indication[ - 'name'] - : null, - false), - enabled: true, - readOnly: true, - ), + child: TextField( + maxLines: 5, + decoration: textFieldSelectorDecoration( + model.patientAssessmentList[0].asciiDesc.toString(), + indication != null ? indication['name'] : null, + false), + enabled: true, + readOnly: true, ), ), ], ), ), - SizedBox( - height: spaceBetweenTextFileds), + SizedBox(height: spaceBetweenTextFileds), Container( height: screenSize.height * 0.070, color: Colors.white, child: InkWell( - onTap: () => selectDate( - context, widget.model), + onTap: () => selectDate(context, widget.model), child: TextField( - decoration: - textFieldSelectorDecoration( - TranslationBase.of( - context) - .date, - selectedDate != null - ? "${AppDateUtils.convertStringToDateFormat(selectedDate.toString(), "yyyy-MM-dd")}" - : null, - true, - suffixIcon: Icon( - Icons.calendar_today, - color: Colors.black, - )), + decoration: textFieldSelectorDecoration( + TranslationBase.of(context).date, + selectedDate != null + ? "${AppDateUtils.convertStringToDateFormat(selectedDate.toString(), "yyyy-MM-dd")}" + : null, + true, + suffixIcon: Icon( + Icons.calendar_today, + color: Colors.black, + )), enabled: false, ), ), ), - SizedBox( - height: spaceBetweenTextFileds), - Container( - //height: screenSize.height * 0.070, - color: Colors.white, - child: InkWell( - onTap: - model.medicationDurationList != - null - ? () { - Helpers.hideKeyboard( - context); - ListSelectDialog - dialog = - ListSelectDialog( - list: model - .medicationDurationList, - attributeName: - 'nameEn', - attributeValueId: - 'id', - okText: - TranslationBase.of( - context) - .ok, - okFunction: - (selectedValue) { - setState(() { - duration = - selectedValue; - if (_selectedMedication != null && - duration != - null && - frequency != - null && - strengthController - .text != - null) { - model - .getBoxQuantity( - freq: frequency[ - 'parameterCode'], - duration: - duration[ - 'id'], - itemCode: - _selectedMedication - .itemId, - strength: double.parse( - strengthController - .text), - ); - box = model - .boxQuintity; + SizedBox(height: spaceBetweenTextFileds), + PrescriptionTextFiled( + element: duration, + elementError: durationError, + hintText: TranslationBase.of(context).duration, + elementList: model.medicationDurationList, + keyName: 'nameEn', + keyId: 'id', + okFunction: (selectedValue) { + setState(() { + duration = selectedValue; + if (_selectedMedication != null && + duration != null && + frequency != null && + strengthController.text != null) { + model.getBoxQuantity( + freq: frequency['parameterCode'], + duration: duration['id'], + itemCode: _selectedMedication.itemId, + strength: double.parse(strengthController.text), + ); + box = model.boxQuintity; - return; - } - }); - }, - ); - showDialog( - barrierDismissible: - false, - context: context, - builder: - (BuildContext - context) { - return dialog; - }, - ); - } - : null, - child: AppTextFieldCustom( - validationError: durationError, - isTextFieldHasSuffix: true, - dropDownText: duration != null - ? duration['nameEn'] - : null, - hintText: - TranslationBase.of(context) - .duration, - enabled: false, - ), - ), + return; + } + }); + }, ), - SizedBox( - height: spaceBetweenTextFileds), + SizedBox(height: spaceBetweenTextFileds), Container( - height: screenSize.height * 0.070, color: Colors.white, - child: InkWell( - onTap: model.allMedicationList != - null - ? () { - Helpers.hideKeyboard( - context); - ListSelectDialog dialog = - ListSelectDialog( - list: model - .allMedicationList, - attributeName: 'nameEn', - attributeValueId: 'id', - okText: - TranslationBase.of( - context) - .ok, - okFunction: - (selectedValue) { - setState(() { - duration = - selectedValue; - }); - }, - ); - showDialog( - barrierDismissible: - false, - context: context, - builder: (BuildContext - context) { - return dialog; - }, - ); - } - : null, - child: TextField( - decoration: - textFieldSelectorDecoration( - "UOM", - uom != null - ? uom - : null, - false), - //enabled: false, - readOnly: true, - ), + child: AppTextFieldCustom( + hintText: "UOM", + isTextFieldHasSuffix: false, + dropDownText: uom != null ? uom : null, + enabled: false, ), ), - SizedBox( - height: spaceBetweenTextFileds), + SizedBox(height: spaceBetweenTextFileds), Container( - height: screenSize.height * 0.070, color: Colors.white, - child: InkWell( - onTap: model.allMedicationList != - null - ? () { - Helpers.hideKeyboard( - context); - ListSelectDialog dialog = - ListSelectDialog( - list: model - .allMedicationList, - attributeName: 'nameEn', - attributeValueId: 'id', - okText: - TranslationBase.of( - context) - .ok, - okFunction: - (selectedValue) { - setState(() { - duration = - selectedValue; - }); - }, - ); - showDialog( - barrierDismissible: - false, - context: context, - builder: (BuildContext - context) { - return dialog; - }, - ); - } + child: AppTextFieldCustom( + hintText: TranslationBase.of(context).boxQuantity, + isTextFieldHasSuffix: false, + dropDownText: box != null + ? TranslationBase.of(context).boxQuantity + + ": " + + model.boxQuintity.toString() : null, - child: TextField( - decoration: - textFieldSelectorDecoration( - TranslationBase.of( - context) - .boxQuantity, - box != null - ? TranslationBase.of( - context) - .boxQuantity + - ": " + - model - .boxQuintity - .toString() - : null, - false), - //enabled: false, - readOnly: true, - ), + enabled: false, ), ), - SizedBox( - height: spaceBetweenTextFileds), + SizedBox(height: spaceBetweenTextFileds), Container( decoration: BoxDecoration( - borderRadius: BorderRadius.all( - Radius.circular(6.0)), - border: Border.all( - width: 1.0, - color: - HexColor("#CCCCCC"))), + borderRadius: BorderRadius.all(Radius.circular(6.0)), + border: Border.all(width: 1.0, color: HexColor("#CCCCCC"))), child: Stack( children: [ TextFields( maxLines: 6, minLines: 4, - hintText: TranslationBase.of( - context) - .instruction, - controller: - instructionController, + hintText: TranslationBase.of(context).instruction, + controller: instructionController, //keyboardType: TextInputType.number, ), Positioned( - top: - 0, //MediaQuery.of(context).size.height * 0, + top: 0, right: 15, child: IconButton( icon: Icon( @@ -1217,28 +640,22 @@ class _PrescriptionFormWidgetState extends State { size: 35, ), onPressed: () { - initSpeechState().then( - (value) => - {onVoiceText()}); + initSpeechState().then((value) => {onVoiceText()}); }, ), ), ], ), ), - SizedBox( - height: spaceBetweenTextFileds), + SizedBox(height: spaceBetweenTextFileds), Container( - margin: EdgeInsets.all( - SizeConfig.widthMultiplier * 5), + margin: EdgeInsets.all(SizeConfig.widthMultiplier * 5), child: Wrap( alignment: WrapAlignment.center, children: [ AppButton( color: Color(0xff359846), - title: TranslationBase.of( - context) - .addMedication, + title: TranslationBase.of(context).addMedication, fontWeight: FontWeight.w600, onPressed: () async { if (route != null && @@ -1247,41 +664,25 @@ class _PrescriptionFormWidgetState extends State { frequency != null && units != null && selectedDate != null && - strengthController - .text != - "") { - if (_selectedMedication - .isNarcotic == - true) { - DrAppToastMsg.showErrorToast( - TranslationBase.of( - context) - .narcoticMedicineCanOnlyBePrescribedFromVida); + strengthController.text != "") { + if (_selectedMedication.isNarcotic == true) { + DrAppToastMsg.showErrorToast(TranslationBase.of(context) + .narcoticMedicineCanOnlyBePrescribedFromVida); Navigator.pop(context); return; } - if (double.parse( - strengthController - .text) > - 1000.0) { - DrAppToastMsg - .showErrorToast( - "1000 is the MAX for the strength"); + if (double.parse(strengthController.text) > 1000.0) { + DrAppToastMsg.showErrorToast( + "1000 is the MAX for the strength"); return; } - if (double.parse( - strengthController - .text) < - 0.0) { - DrAppToastMsg - .showErrorToast( - "strength can't be zero"); + if (double.parse(strengthController.text) < 0.0) { + DrAppToastMsg.showErrorToast("strength can't be zero"); return; } - if (formKey.currentState - .validate()) { + if (formKey.currentState.validate()) { Navigator.pop(context); openDrugToDrug(model); { @@ -1370,52 +771,32 @@ class _PrescriptionFormWidgetState extends State { } else { setState(() { if (duration == null) { - durationError = - TranslationBase.of( - context) - .fieldRequired; + durationError = TranslationBase.of(context).fieldRequired; } else { durationError = null; } if (doseTime == null) { - doseTimeError = - TranslationBase.of( - context) - .fieldRequired; + doseTimeError = TranslationBase.of(context).fieldRequired; } else { doseTimeError = null; } if (route == null) { - routeError = - TranslationBase.of( - context) - .fieldRequired; + routeError = TranslationBase.of(context).fieldRequired; } else { routeError = null; } if (frequency == null) { - frequencyError = - TranslationBase.of( - context) - .fieldRequired; + frequencyError = TranslationBase.of(context).fieldRequired; } else { frequencyError = null; } if (units == null) { - unitError = - TranslationBase.of( - context) - .fieldRequired; + unitError = TranslationBase.of(context).fieldRequired; } else { unitError = null; } - if (strengthController - .text == - "") { - strengthError = - TranslationBase.of( - context) - .fieldRequired; + if (strengthController.text == "") { + strengthError = TranslationBase.of(context).fieldRequired; } else { strengthError = null; } @@ -1423,30 +804,6 @@ class _PrescriptionFormWidgetState extends State { } formKey.currentState.save(); - // Navigator.pop(context); - // openDrugToDrug(); - // if (frequency == null || - // strengthController - // .text == - // "" || - // doseTime == null || - // duration == null || - // selectedDate == null) { - // DrAppToastMsg.showErrorToast( - // TranslationBase.of( - // context) - // .pleaseFillAllFields); - // return; - // } - - { - // Navigator.push( - // context, - // MaterialPageRoute( - // builder: (context) => - // NewPrescriptionScreen()), - // ); - } }, ), ], @@ -1489,8 +846,7 @@ class _PrescriptionFormWidgetState extends State { } } - InputDecoration textFieldSelectorDecoration( - String hintText, String selectedText, bool isDropDown, + InputDecoration textFieldSelectorDecoration(String hintText, String selectedText, bool isDropDown, {Icon suffixIcon}) { return InputDecoration( focusedBorder: OutlineInputBorder( @@ -1530,48 +886,6 @@ class _PrescriptionFormWidgetState extends State { ); } - InputDecoration textFieldSelectorDecorationStreangrh( - String hintText, String selectedText, bool isDropDown, - {Icon suffixIcon}) { - return InputDecoration( - focusedBorder: OutlineInputBorder( - borderSide: BorderSide(color: Color(0xFFCCCCCC), width: 2.0), - borderRadius: BorderRadius.circular(8), - ), - enabledBorder: OutlineInputBorder( - borderSide: BorderSide(color: Color(0xFFEFEFEF), width: 2.0), - borderRadius: BorderRadius.circular(8), - ), - disabledBorder: OutlineInputBorder( - borderSide: BorderSide(color: Color(0xFFEFEFEF), width: 2.0), - borderRadius: BorderRadius.circular(8), - ), - suffixIcon: isDropDown - ? suffixIcon != null - ? suffixIcon - : Icon( - Icons.keyboard_arrow_down_sharp, - color: Color(0xff2E303A), - ) - : null, - hintStyle: TextStyle( - fontSize: 13, - color: Color(0xff2E303A), - fontFamily: 'Poppins', - fontWeight: FontWeight.w600, - ), - hintText: selectedText == null || selectedText == "" ? hintText : null, - labelText: - selectedText != null && selectedText != "" ? '\n$selectedText' : null, - labelStyle: TextStyle( - fontSize: 15, - color: Color(0xff2E303A), - fontFamily: 'Poppins', - fontWeight: FontWeight.w600, - ), - ); - } - openDrugToDrug(model) { showModalBottomSheet( context: context, @@ -1583,9 +897,7 @@ class _PrescriptionFormWidgetState extends State { child: Column( // mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - DrugToDrug( - widget.patient, - getPriscriptionforDrug(widget.prescriptionList, model), + DrugToDrug(widget.patient, getPriscriptionforDrug(widget.prescriptionList, model), model.patientAssessmentList), Container( margin: EdgeInsets.all(SizeConfig.widthMultiplier * 3), @@ -1594,37 +906,25 @@ class _PrescriptionFormWidgetState extends State { onPressed: () { Navigator.pop(context); - postProcedure( + postPrescription( icdCode: model.patientAssessmentList.isNotEmpty - ? model.patientAssessmentList[0].icdCode10ID - .isEmpty + ? model.patientAssessmentList[0].icdCode10ID.isEmpty ? "test" - : model.patientAssessmentList[0].icdCode10ID - .toString() + : model.patientAssessmentList[0].icdCode10ID.toString() : "test", - // icdCode: model - // .patientAssessmentList - // .map((value) => value - // .icdCode10ID - // .trim()) - // .toList() - // .join(' '), dose: strengthController.text, doseUnit: model.itemMedicineListUnit.length == 1 - ? model.itemMedicineListUnit[0]['parameterCode'] - .toString() + ? model.itemMedicineListUnit[0]['parameterCode'].toString() : units['parameterCode'].toString(), patient: widget.patient, doseTimeIn: doseTime['id'].toString(), model: widget.model, duration: duration['id'].toString(), frequency: model.itemMedicineList.length == 1 - ? model.itemMedicineList[0]['parameterCode'] - .toString() + ? model.itemMedicineList[0]['parameterCode'].toString() : frequency['parameterCode'].toString(), route: model.itemMedicineListRoute.length == 1 - ? model.itemMedicineListRoute[0]['parameterCode'] - .toString() + ? model.itemMedicineListRoute[0]['parameterCode'].toString() : route['parameterCode'].toString(), drugId: _selectedMedication.itemId.toString(), strength: strengthController.text, @@ -1632,36 +932,6 @@ class _PrescriptionFormWidgetState extends State { instruction: instructionController.text, doseTime: selectedDate, ); - - // postProcedure( - // icdCode: model.patientAssessmentList.isNotEmpty - // ? model.patientAssessmentList[0].icdCode10ID - // .isEmpty - // ? "test" - // : model.patientAssessmentList[0].icdCode10ID - // .toString() - // : "test", - // // icdCode: model - // // .patientAssessmentList - // // .map((value) => value - // // .icdCode10ID - // // .trim()) - // // .toList() - // // .join(' '), - // dose: strengthController.text, - // doseUnit: units['parameterCode'].toString(), - // patient: widget.patient, - // doseTimeIn: doseTime['id'].toString(), - // model: widget.model, - // duration: duration['id'].toString(), - // frequency: frequency['parameterCode'].toString(), - // route: route['parameterCode'].toString(), - // drugId: _selectedMedication.itemId.toString(), - // strength: strengthController.text, - // indication: indicationController.text, - // instruction: instructionController.text, - // doseTime: selectedDate, - // ); }, )) ], @@ -1673,17 +943,7 @@ class _PrescriptionFormWidgetState extends State { }); } - // selectedValue(itemMdeicationList,key){ - // // String selected = ""; - // // units[key]=itemMdeicationList.length==1? itemMdeicationList[0][key]:units[key].toString(); - // // - // // selected = units[key]; - // // - // // return selected; - // // } - - getPriscriptionforDrug( - List prescriptionList, MedicineViewModel model) { + getPriscriptionforDrug(List prescriptionList, MedicineViewModel model) { var prescriptionDetails = []; if (prescriptionList.length > 0) { prescriptionList[0].entityList.forEach((element) { @@ -1728,19 +988,10 @@ class _PrescriptionFormWidgetState extends State { searchMedicine(context, MedicineViewModel model) async { FocusScope.of(context).unfocus(); - // if (myController.text.isEmpty()) { - // Helpers.showErrorToast(TranslationBase.of(context).typeMedicineName); - // //"Type Medicine Name") - // return; - // } if (myController.text.length < 3) { Helpers.showErrorToast(TranslationBase.of(context).moreThan3Letter); return; } - - //GifLoaderDialogUtils.showMyDialog(context); - await model.getMedicationList(drug: myController.text); - //GifLoaderDialogUtils.hideDialog(context); } } diff --git a/lib/screens/prescription/prescription_text_filed.dart b/lib/screens/prescription/prescription_text_filed.dart new file mode 100644 index 00000000..56020ca3 --- /dev/null +++ b/lib/screens/prescription/prescription_text_filed.dart @@ -0,0 +1,76 @@ +import 'package:doctor_app_flutter/core/viewModel/medicine_view_model.dart'; +import 'package:doctor_app_flutter/util/helpers.dart'; +import 'package:doctor_app_flutter/util/translations_delegate_base.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/cupertino.dart'; +import 'package:flutter/material.dart'; + +class PrescriptionTextFiled extends StatefulWidget { + dynamic element; + final String elementError; + final List elementList; + final String keyName; + final String keyId; + final String hintText; + final double width; + final Function(dynamic) okFunction; + + PrescriptionTextFiled( + {Key key, + @required this.element, + @required this.elementError, + this.width, + this.elementList, + this.keyName, + this.keyId, + this.hintText, + this.okFunction}) + : super(key: key); + + @override + _PrescriptionTextFiledState createState() => _PrescriptionTextFiledState(); +} + +class _PrescriptionTextFiledState extends State { + @override + Widget build(BuildContext context) { + return Container( + width: widget.width ?? null, + child: InkWell( + onTap: widget.elementList != null + ? () { + Helpers.hideKeyboard(context); + ListSelectDialog dialog = ListSelectDialog( + list: widget.elementList, + attributeName: '${widget.keyName}', + attributeValueId: '${widget.keyId}', + okText: TranslationBase.of(context).ok, + okFunction: (selectedValue) => + widget.okFunction(selectedValue), + ); + showDialog( + barrierDismissible: false, + context: context, + builder: (BuildContext context) { + return dialog; + }, + ); + } + : null, + child: AppTextFieldCustom( + hintText: widget.hintText, + dropDownText: widget.elementList.length == 1 + ? widget.elementList[0]['${widget.keyName}'] + : widget.element != null + ? widget.element['${widget.keyName}'] + : null, + isTextFieldHasSuffix: true, + validationError: + widget.elementList.length != 1 ? widget.elementError : null, + enabled: false, + ), + ), + ); + } +} diff --git a/lib/screens/prescription/prescriptions_page.dart b/lib/screens/prescription/prescriptions_page.dart index 9bfd9b49..81c8760f 100644 --- a/lib/screens/prescription/prescriptions_page.dart +++ b/lib/screens/prescription/prescriptions_page.dart @@ -1,5 +1,4 @@ import 'package:doctor_app_flutter/core/viewModel/prescription_view_model.dart'; -import 'package:doctor_app_flutter/core/viewModel/project_view_model.dart'; import 'package:doctor_app_flutter/models/patient/patiant_info_model.dart'; import 'package:doctor_app_flutter/screens/base/base_view.dart'; import 'package:doctor_app_flutter/screens/prescription/add_prescription_form.dart'; @@ -16,7 +15,6 @@ import 'package:doctor_app_flutter/widgets/shared/user-guid/in_patient_doctor_ca import 'package:doctor_app_flutter/widgets/transitions/fade_page.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -import 'package:provider/provider.dart'; class PrescriptionsPage extends StatelessWidget { @override @@ -86,9 +84,7 @@ class PrescriptionsPage extends StatelessWidget { fontSize: 13, ), AppText( - TranslationBase - .of(context) - .prescriptions, + TranslationBase.of(context).prescriptions, bold: true, fontSize: 22, ), @@ -96,15 +92,14 @@ class PrescriptionsPage extends StatelessWidget { ), ), if ((patient.patientStatusType != null && - patient.patientStatusType == 43) || + patient.patientStatusType == 43) || (isFromLiveCare && patient.appointmentNo != null)) AddNewOrder( onTap: () { addPrescriptionForm(context, model, patient, model.prescriptionList); }, - label: TranslationBase - .of(context) + label: TranslationBase.of(context) .applyForNewPrescriptionsOrder, ), ...List.generate( @@ -132,7 +127,7 @@ class PrescriptionsPage extends StatelessWidget { .clinicDescription, isPrescriptions: true, appointmentDate: - AppDateUtils.getDateTimeFromServerFormat( + AppDateUtils.getDateTimeFromServerFormat( model.prescriptionsList[index] .appointmentDate, ), @@ -201,7 +196,7 @@ class PrescriptionsPage extends StatelessWidget { clinic: 'basheer', isPrescriptions: true, appointmentDate: - AppDateUtils.getDateTimeFromServerFormat( + AppDateUtils.getDateTimeFromServerFormat( model.inPatientPrescription[index] .prescriptionDatetime, ), diff --git a/lib/util/date-utils.dart b/lib/util/date-utils.dart index fb68ab4e..9ce078ed 100644 --- a/lib/util/date-utils.dart +++ b/lib/util/date-utils.dart @@ -7,7 +7,7 @@ class AppDateUtils { return DateFormat(dateFormat).format(dateTime); } - static DateTime convertISOStringToDateTime(String date){ + static DateTime convertISOStringToDateTime(String date) { DateTime newDate; newDate = DateTime.parse(date); @@ -27,22 +27,20 @@ class AppDateUtils { } static DateTime getDateTimeFromServerFormat(String str) { - DateTime date= DateTime.now(); - if (str!=null) { + DateTime date = DateTime.now(); + if (str != null) { const start = "/Date("; const end = "+0300)"; - if(str.contains("/Date")){ - final startIndex = str.indexOf(start); + if (str.contains("/Date")) { + final startIndex = str.indexOf(start); - final endIndex = str.indexOf(end, startIndex + start.length); - - date = new DateTime.fromMillisecondsSinceEpoch( - int.parse(str.substring(startIndex + start.length, endIndex))); - } else { - date = DateTime.now(); - } + final endIndex = str.indexOf(end, startIndex + start.length); + date = new DateTime.fromMillisecondsSinceEpoch(int.parse(str.substring(startIndex + start.length, endIndex))); + } else { + date = DateTime.now(); + } } else { date = DateTime.parse(str); } @@ -50,8 +48,7 @@ class AppDateUtils { return date; } - static String differenceBetweenDateAndCurrentInYearMonthDay( - DateTime firstDate, BuildContext context) { + static String differenceBetweenDateAndCurrentInYearMonthDay(DateTime firstDate, BuildContext context) { DateTime now = DateTime.now(); // now = now.add(Duration(days: 400, minutes: 0)); var difference = firstDate.difference(now); @@ -71,15 +68,13 @@ class AppDateUtils { return "$days ${TranslationBase.of(context).days}, $months ${TranslationBase.of(context).months}, $years ${TranslationBase.of(context).years}"; } - static String differenceBetweenDateAndCurrent( - DateTime firstDate, BuildContext context) { + static String differenceBetweenDateAndCurrent(DateTime firstDate, BuildContext context) { DateTime now = DateTime.now(); // DateTime now = nows.add(Duration(days: 400, minutes: 25, hours: 0)); var difference = now.difference(firstDate); int minutesInDays = difference.inMinutes; - int hoursInDays = - minutesInDays ~/ 60; // ~/ : truncating division to make the result int + int hoursInDays = minutesInDays ~/ 60; // ~/ : truncating division to make the result int int minutes = minutesInDays % 60; int days = hoursInDays ~/ 24; int hours = hoursInDays % 24; @@ -89,8 +84,7 @@ class AppDateUtils { return "$days ${TranslationBase.of(context).days}, $hours ${TranslationBase.of(context).hr}, $minutes ${TranslationBase.of(context).min}"; } - static String differenceBetweenServerDateAndCurrent( - String str, BuildContext context) { + static String differenceBetweenServerDateAndCurrent(String str, BuildContext context) { const start = "/Date("; const end = "+0300)"; @@ -99,8 +93,7 @@ class AppDateUtils { final endIndex = str.indexOf(end, startIndex + start.length); - var date = new DateTime.fromMillisecondsSinceEpoch( - int.parse(str.substring(startIndex + start.length, endIndex))); + var date = new DateTime.fromMillisecondsSinceEpoch(int.parse(str.substring(startIndex + start.length, endIndex))); return differenceBetweenDateAndCurrent(date, context); } @@ -246,7 +239,10 @@ class AppDateUtils { final startIndex = date.indexOf(start); final endIndex = date.indexOf(end, startIndex + start.length); DateTime newDate = DateTime.fromMillisecondsSinceEpoch( - int.parse(date.substring(startIndex + start.length, endIndex),),); + int.parse( + date.substring(startIndex + start.length, endIndex), + ), + ); return newDate; } else return DateTime.now(); @@ -256,35 +252,30 @@ class AppDateUtils { /// [dateTime] convert DateTime to data formatted Arabic static String getMonthDayYearDateFormattedAr(DateTime dateTime) { if (dateTime != null) - return getMonthArabic(dateTime.month) + - " " + - dateTime.day.toString() + - ", " + - dateTime.year.toString(); + return getMonthArabic(dateTime.month) + " " + dateTime.day.toString() + ", " + dateTime.year.toString(); else return ""; } /// get data formatted like Apr 26,2020 /// [dateTime] convert DateTime to data formatted - static String getMonthDayYearDateFormatted(DateTime dateTime,{bool isArabic = false}) { + static String getMonthDayYearDateFormatted(DateTime dateTime, {bool isArabic = false}) { if (dateTime != null) - return isArabic? getMonthArabic(dateTime.month): getMonth(dateTime.month) + - " " + - dateTime.day.toString() + - ", " + - dateTime.year.toString(); + return isArabic + ? getMonthArabic(dateTime.month) + : getMonth(dateTime.month) + " " + dateTime.day.toString() + ", " + dateTime.year.toString(); else return ""; } /// get data formatted like 26 Apr 2020 /// [dateTime] convert DateTime to data formatted - static String getDayMonthYearDateFormatted(DateTime dateTime,{bool isArabic = false}) { + static String getDayMonthYearDateFormatted(DateTime dateTime, {bool isArabic = false}) { if (dateTime != null) - return dateTime.day.toString()+" "+ "${isArabic? getMonthArabic(dateTime.month): getMonth(dateTime.month) }"+ + return dateTime.day.toString() + + " " + + "${isArabic ? getMonthArabic(dateTime.month) : getMonth(dateTime.month)}" + " " + - dateTime.year.toString(); else return ""; @@ -292,9 +283,9 @@ class AppDateUtils { /// get data formatted like 26/4/2020 /// [dateTime] convert DateTime to data formatted - static String getDayMonthYearDate(DateTime dateTime,{bool isArabic = false}) { + static String getDayMonthYearDate(DateTime dateTime, {bool isArabic = false}) { if (dateTime != null) - return dateTime.day.toString()+"/"+ "${dateTime.month}"+ "/" + dateTime.year.toString(); + return dateTime.day.toString() + "/" + "${dateTime.month}" + "/" + dateTime.year.toString(); else return ""; } @@ -302,15 +293,15 @@ class AppDateUtils { /// get data formatted like 10:45 PM /// [dateTime] convert DateTime to data formatted static String getHour(DateTime dateTime) { - return DateFormat('hh:mm a').format(dateTime); + return DateFormat('hh:mm a').format(dateTime); } - static String getAgeByBirthday(String birthOfDate, BuildContext context, { bool isServerFormat = true}) { + static String getAgeByBirthday(String birthOfDate, BuildContext context, {bool isServerFormat = true}) { // https://leechy.dev/calculate-dates-diff-in-dart DateTime birthDate; - if(birthOfDate.contains("/Date")) { + if (birthOfDate.contains("/Date")) { birthDate = AppDateUtils.getDateTimeFromServerFormat(birthOfDate); - }else{ + } else { birthDate = DateTime.parse(birthOfDate); } final now = DateTime.now(); @@ -328,24 +319,18 @@ class AppDateUtils { return "$years ${TranslationBase.of(context).years} $months ${TranslationBase.of(context).months} $days ${TranslationBase.of(context).days}"; } - static bool isToday(DateTime dateTime){ - + static bool isToday(DateTime dateTime) { DateTime todayDate = DateTime.now().toUtc(); - if(dateTime.day == todayDate.day && dateTime.month == todayDate.month && dateTime.year == todayDate.year) { + if (dateTime.day == todayDate.day && dateTime.month == todayDate.month && dateTime.year == todayDate.year) { return true; } return false; - } static String getDate(DateTime dateTime) { print(dateTime); if (dateTime != null) - return getMonth(dateTime.month) + - " " + - dateTime.day.toString() + - "," + - dateTime.year.toString(); + return getMonth(dateTime.month) + " " + dateTime.day.toString() + "," + dateTime.year.toString(); else return ""; } @@ -353,28 +338,23 @@ class AppDateUtils { static String getDateFormatted(DateTime dateTime) { print(dateTime); if (dateTime != null) - return dateTime.day.toString() + - "/" + - dateTime.month.toString() + - "/" + - dateTime.year.toString(); + return dateTime.day.toString() + "/" + dateTime.month.toString() + "/" + dateTime.year.toString(); else return ""; } - static String getTimeHHMMA(DateTime dateTime){ + static String getTimeHHMMA(DateTime dateTime) { return DateFormat('hh:mm a').format(dateTime); } - static String getTimeHHMMA2 (DateTime dateTime){ + static String getTimeHHMMA2(DateTime dateTime) { return DateFormat('hh:mm').format(dateTime); } - static String getStartTime(String dateTime){ - String time=dateTime; + static String getStartTime(String dateTime) { + String time = dateTime; - if(dateTime.length>7) - time = dateTime.substring(0,5); + if (dateTime.length > 7) time = dateTime.substring(0, 5); return time; } diff --git a/lib/widgets/shared/text_fields/app-textfield-custom.dart b/lib/widgets/shared/text_fields/app-textfield-custom.dart index 7e13f411..fc7df189 100644 --- a/lib/widgets/shared/text_fields/app-textfield-custom.dart +++ b/lib/widgets/shared/text_fields/app-textfield-custom.dart @@ -105,37 +105,36 @@ class _AppTextFieldCustomState extends State { ? widget.height - 22 : null, child: TextField( - textAlign: projectViewModel.isArabic - ? TextAlign.right - : TextAlign.left, - decoration: TextFieldsUtils - .textFieldSelectorDecoration( - widget.hintText, null, true), - style: TextStyle( - fontSize: SizeConfig.textMultiplier * 1.7, - fontFamily: 'Poppins', - color: Color(0xFF575757), - ), - controller: widget.controller, - keyboardType: widget.inputType ?? - (widget.maxLines == 1 - ? TextInputType.text - : TextInputType.multiline), - enabled: widget.enabled, - minLines: widget.minLines, - maxLines: widget.maxLines, - inputFormatters: - widget.inputFormatters != null - ? widget.inputFormatters - : [], - onChanged: (value) { - setState(() {}); - if (widget.onChanged != null) { - widget.onChanged(value); - } - }, - obscureText: widget.isSecure - ), + textAlign: projectViewModel.isArabic + ? TextAlign.right + : TextAlign.left, + decoration: TextFieldsUtils + .textFieldSelectorDecoration( + widget.hintText, null, true), + style: TextStyle( + fontSize: SizeConfig.textMultiplier * 1.7, + fontFamily: 'Poppins', + color: Color(0xFF575757), + ), + controller: widget.controller, + keyboardType: widget.inputType ?? + (widget.maxLines == 1 + ? TextInputType.text + : TextInputType.multiline), + enabled: widget.enabled, + minLines: widget.minLines, + maxLines: widget.maxLines, + inputFormatters: + widget.inputFormatters != null + ? widget.inputFormatters + : [], + onChanged: (value) { + setState(() {}); + if (widget.onChanged != null) { + widget.onChanged(value); + } + }, + obscureText: widget.isSecure), ) : AppText( widget.dropDownText, diff --git a/lib/widgets/shared/text_fields/text_field_error.dart b/lib/widgets/shared/text_fields/text_field_error.dart index ee22a6a4..9c781db0 100644 --- a/lib/widgets/shared/text_fields/text_field_error.dart +++ b/lib/widgets/shared/text_fields/text_field_error.dart @@ -7,12 +7,11 @@ import '../app_texts_widget.dart'; class TextFieldsError extends StatelessWidget { const TextFieldsError({ Key key, - @required this.error, + @required this.error, }) : super(key: key); final String error; - @override Widget build(BuildContext context) { return Container( @@ -27,12 +26,14 @@ class TextFieldsError extends StatelessWidget { SizedBox( width: 12, ), - AppText( - error, - fontFamily: 'Poppins', - fontSize: SizeConfig.textMultiplier * 1.7, - color: Colors.red.shade700, - fontWeight: FontWeight.w700, + Expanded( + child: AppText( + error, + fontFamily: 'Poppins', + fontSize: SizeConfig.textMultiplier * 1.7, + color: Colors.red.shade700, + fontWeight: FontWeight.w700, + ), ), ], ),