From a5f3731b9ac190f0ea32e1a2e94b32575a970ed3 Mon Sep 17 00:00:00 2001 From: Elham Rababh Date: Mon, 23 Aug 2021 17:26:55 +0300 Subject: [PATCH 1/7] first step from fixing header --- lib/config/config.dart | 4 +- .../profile/patient-profile-app-bar.dart | 507 ++++++++---------- ...ent-profile-header-new-design-app-bar.dart | 155 +++--- 3 files changed, 308 insertions(+), 358 deletions(-) diff --git a/lib/config/config.dart b/lib/config/config.dart index d0ff0df9..d5086b5b 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -5,8 +5,8 @@ const ONLY_NUMBERS = "[0-9]"; const ONLY_LETTERS = "[a-zA-Z &'\"]"; const ONLY_DATE = "[0-9/]"; const BASE_URL_LIVE_CARE = 'https://livecare.hmg.com/'; -// const BASE_URL = 'https://hmgwebservices.com/'; -const BASE_URL = 'https://uat.hmgwebservices.com/'; +const BASE_URL = 'https://hmgwebservices.com/'; +// const BASE_URL = 'https://uat.hmgwebservices.com/'; const PHARMACY_ITEMS_URL = "Services/Lists.svc/REST/GetPharmcyItems_Region_enh"; const PHARMACY_LIST_URL = "Services/Patients.svc/REST/GetPharmcyList"; const PATIENT_PROGRESS_NOTE_URL = "Services/DoctorApplication.svc/REST/GetProgressNoteForInPatient"; diff --git a/lib/widgets/patients/profile/patient-profile-app-bar.dart b/lib/widgets/patients/profile/patient-profile-app-bar.dart index 5901f9b8..f9bab58c 100644 --- a/lib/widgets/patients/profile/patient-profile-app-bar.dart +++ b/lib/widgets/patients/profile/patient-profile-app-bar.dart @@ -12,8 +12,7 @@ import 'package:url_launcher/url_launcher.dart'; import 'large_avatar.dart'; -class PatientProfileAppBar extends StatelessWidget - with PreferredSizeWidget { +class PatientProfileAppBar extends StatelessWidget with PreferredSizeWidget { final PatiantInformtion patient; final double height; final bool isInpatient; @@ -35,8 +34,7 @@ class PatientProfileAppBar extends StatelessWidget final bool isFromLabResult; final VoidCallback onPressed; - PatientProfileAppBar( - this.patient, + PatientProfileAppBar(this.patient, {this.height = 0.0, this.isInpatient = false, this.isDischargedPatient = false, @@ -53,8 +51,8 @@ class PatientProfileAppBar extends StatelessWidget this.episode, this.visitDate, this.isAppointmentHeader = false, - this.isFromLabResult = false, this.onPressed}); - + this.isFromLabResult = false, + this.onPressed}); @override Widget build(BuildContext context) { @@ -74,35 +72,33 @@ class PatientProfileAppBar extends StatelessWidget bottom: 5, ), decoration: BoxDecoration( - color: Colors.white, - border: Border( bottom: BorderSide(color:Color(0xFFEFEFEF))) - - ), + color: Colors.white, + border: Border(bottom: BorderSide(color: Color(0xFFEFEFEF)))), child: Container( padding: EdgeInsets.only(left: 10, right: 10, bottom: 10), - - margin: EdgeInsets.only(top: SizeConfig.isHeightVeryShort?30: 50), + margin: EdgeInsets.only(top: SizeConfig.isHeightVeryShort ? 30 : 50), child: Column( children: [ Container( - padding: EdgeInsets.only(left: SizeConfig.isHeightVeryShort?0: 12.0), + padding: EdgeInsets.only( + left: SizeConfig.isHeightVeryShort ? 0 : 12.0), child: Row(children: [ IconButton( icon: Icon(Icons.arrow_back_ios), color: Color(0xFF2B353E), //Colors.black, onPressed: () { - if(onPressed!=null) - onPressed(); - Navigator.pop(context); + if (onPressed != null) onPressed(); + Navigator.pop(context); }, ), Expanded( child: AppText( patient.firstName != null ? (Helpers.capitalize(patient.firstName) + - " " + - Helpers.capitalize(patient.lastName)) - : Helpers.capitalize(patient.fullName??patient.patientDetails.fullName), + " " + + Helpers.capitalize(patient.lastName)) + : Helpers.capitalize(patient.fullName ?? + patient.patientDetails.fullName), fontSize: SizeConfig.textMultiplier * 1.8, fontWeight: FontWeight.bold, fontFamily: 'Poppins', @@ -111,13 +107,13 @@ class PatientProfileAppBar extends StatelessWidget ), gender == 1 ? Icon( - DoctorApp.male_2, - color: Colors.blue, - ) + DoctorApp.male_2, + color: Colors.blue, + ) : Icon( - DoctorApp.female_1, - color: Colors.pink, - ), + DoctorApp.female_1, + color: Colors.pink, + ), Container( margin: EdgeInsets.symmetric(horizontal: 4), child: InkWell( @@ -134,10 +130,11 @@ class PatientProfileAppBar extends StatelessWidget ), Row(children: [ Padding( - padding: EdgeInsets.only(left: SizeConfig.isHeightVeryShort?0: 12.0), + padding: EdgeInsets.only( + left: SizeConfig.isHeightVeryShort ? 0 : 12.0), child: Container( - width: SizeConfig.getTextMultiplierBasedOnWidth()*20, - height: SizeConfig.getTextMultiplierBasedOnWidth()*20, + width: SizeConfig.getTextMultiplierBasedOnWidth() * 20, + height: SizeConfig.getTextMultiplierBasedOnWidth() * 20, child: Image.asset( gender == 1 ? 'assets/images/male_avatar.png' @@ -155,25 +152,27 @@ class PatientProfileAppBar extends StatelessWidget children: [ patient.patientStatusType != null ? Container( - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - patient.patientStatusType == 43 - ? AppText( - TranslationBase - .of(context) - .arrivedP, - color: Colors.green, - fontWeight: FontWeight.bold, - fontFamily: 'Poppins', - fontSize: SizeConfig.getTextMultiplierBasedOnWidth() *3.5, - ) + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + patient.patientStatusType == 43 + ? AppText( + TranslationBase.of(context).arrivedP, + color: Colors.green, + fontWeight: FontWeight.bold, + fontFamily: 'Poppins', + fontSize: SizeConfig + .getTextMultiplierBasedOnWidth() * + 3.5, + ) : AppText( TranslationBase.of(context).notArrived, color: Colors.red[800], fontWeight: FontWeight.bold, fontFamily: 'Poppins', - fontSize: SizeConfig.getTextMultiplierBasedOnWidth() *3.5, + fontSize: SizeConfig + .getTextMultiplierBasedOnWidth() * + 3.5, ), patient.startTime != null ? AppText( @@ -181,7 +180,9 @@ class PatientProfileAppBar extends StatelessWidget ? patient.startTime : '', fontWeight: FontWeight.w700, - fontSize: SizeConfig.getTextMultiplierBasedOnWidth() *3.5, + fontSize: SizeConfig + .getTextMultiplierBasedOnWidth() * + 3.5, color: Color(0xFF2E303A)) : SizedBox() ], @@ -194,17 +195,21 @@ class PatientProfileAppBar extends StatelessWidget Row( children: [ AppText( - TranslationBase - .of(context) - .fileNumber, - fontSize: SizeConfig.getTextMultiplierBasedOnWidth() *3, + TranslationBase.of(context).fileNumber, + fontSize: + SizeConfig.getTextMultiplierBasedOnWidth() * + 3, color: Color(0xFF575757), fontWeight: FontWeight.w600, ), - SizedBox(width: 1,), + SizedBox( + width: 1, + ), AppText( patient.patientId.toString(), - fontSize: SizeConfig.getTextMultiplierBasedOnWidth() *3.5, + fontSize: + SizeConfig.getTextMultiplierBasedOnWidth() * + 3.5, color: Color(0xFF2E303A), fontWeight: FontWeight.w700, isCopyable: true, @@ -214,188 +219,87 @@ class PatientProfileAppBar extends StatelessWidget Row( children: [ AppText( - patient.nationalityName ?? patient.nationality?? patient.nationalityId ?? '', + patient.nationalityName ?? + patient.nationality ?? + patient.nationalityId ?? + '', fontWeight: FontWeight.bold, - fontSize: SizeConfig.getTextMultiplierBasedOnWidth() *3.5, + fontSize: + SizeConfig.getTextMultiplierBasedOnWidth() * + 3.5, ), patient.nationalityFlagURL != null ? ClipRRect( - borderRadius: BorderRadius.circular(20.0), - child: Image.network( - patient.nationalityFlagURL, - height: 25, - width: 30, - errorBuilder: (BuildContext context, - Object exception, - StackTrace stackTrace) { - return Text('No Image'); - }, - )) + borderRadius: BorderRadius.circular(20.0), + child: Image.network( + patient.nationalityFlagURL, + height: 25, + width: 30, + errorBuilder: (BuildContext context, + Object exception, + StackTrace stackTrace) { + return Text('No Image'); + }, + )) : SizedBox() ], ) ], ), - Container( - child: RichText( - text: new TextSpan( - style: new TextStyle( - fontSize: 1.6 * SizeConfig.textMultiplier, - color: Colors.black, - fontFamily: 'Poppins', - ), - children: [ - new TextSpan( - text: TranslationBase - .of(context) - .age + " : ", - style: TextStyle(fontSize: SizeConfig.getTextMultiplierBasedOnWidth() *3, fontWeight: FontWeight.w600,color: Color(0xFF575757),)), - new TextSpan( - text: - "${AppDateUtils.getAgeByBirthday( - patient.patientDetails != null - ? patient.patientDetails.dateofBirth ?? - "" - : patient.dateofBirth ?? "", context, - isServerFormat: !isFromLiveCare)}", - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: SizeConfig.getTextMultiplierBasedOnWidth() *3.5, - color: Color(0xFF2E303A),)), - ], - ), - ), + + HeaderRow( + label: TranslationBase.of(context).age + " : ", + value: + "${AppDateUtils.getAgeByBirthday(patient.patientDetails != null ? patient.patientDetails.dateofBirth ?? "" : patient.dateofBirth ?? "", context, isServerFormat: !isFromLiveCare)}", ), - if ( patient.appointmentDate != null && patient.appointmentDate.isNotEmpty && !isFromLabResult) - Row( - mainAxisAlignment: MainAxisAlignment.start, - children: [ - AppText( - TranslationBase.of(context).appointmentDate + - " : ", - fontSize: SizeConfig.getTextMultiplierBasedOnWidth() *3, - color: Color(0xFF575757), - fontWeight: FontWeight.w600, - fontFamily: 'Poppins', - ), - SizedBox( - width: 3.5, - ), - AppText( - AppDateUtils - .getDayMonthYearDateFormatted( - AppDateUtils.convertStringToDate( - patient.appointmentDate)) - , - fontWeight: FontWeight.w700, - fontSize: SizeConfig.getTextMultiplierBasedOnWidth() *3.5, - color: Color(0xFF2E303A), - ), - SizedBox( - height: 0.5, - ) - ], + if (patient.appointmentDate != null && + patient.appointmentDate.isNotEmpty && + !isFromLabResult) + HeaderRow( + label: + TranslationBase.of(context).appointmentDate + " : ", + value: AppDateUtils.getDayMonthYearDateFormatted( + AppDateUtils.convertStringToDate( + patient.appointmentDate)), ), - if(isFromLabResult)Container( - child: RichText( - text: new TextSpan( - style: new TextStyle( - fontSize: 1.6 * SizeConfig.textMultiplier, - color: Colors.black, - fontFamily: 'Poppins', - ), - children: [ - new TextSpan( - text: "Result Date: ", - style: TextStyle( fontSize: SizeConfig.getTextMultiplierBasedOnWidth() *3, - color: Color(0xFF575757), - fontWeight: FontWeight.w600, - fontFamily: 'Poppins',)), - new TextSpan( - text: - '${AppDateUtils.getDayMonthYearDateFormatted(appointmentDate, isArabic: projectViewModel.isArabic)}', - style: TextStyle( - fontWeight: FontWeight.w700, fontSize: 12)), - ], - ), + if (isFromLabResult) + HeaderRow( + label: "Result Date: ", + value: + '${AppDateUtils.getDayMonthYearDateFormatted(appointmentDate, isArabic: projectViewModel.isArabic)}', ), - ), + // if(isInpatient) - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - if(patient.admissionDate != null && patient.admissionDate.isNotEmpty) - Container( - child: RichText( - text: new TextSpan( - style: new TextStyle( - fontSize: SizeConfig.getTextMultiplierBasedOnWidth() *3, fontWeight: FontWeight.w600,color: Color(0xFF575757), - fontFamily: 'Poppins', - ), - children: [ - new TextSpan( - text: patient.admissionDate == null - ? "" - : TranslationBase.of(context) - .admissionDate + - " : ", - style: TextStyle(fontSize: 10)), - new TextSpan( - text: patient.admissionDate == null - ? "" - : "${AppDateUtils - .getDayMonthYearDateFormatted( - (AppDateUtils - .getDateTimeFromServerFormat( - patient.admissionDate - .toString())))}", - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: SizeConfig.getTextMultiplierBasedOnWidth() *3.5, - color: Color(0xFF2E303A),)), - ]))), - if (patient.admissionDate != null) - Row( - children: [ - AppText( - "${TranslationBase.of(context).numOfDays}: ", - fontSize: SizeConfig.getTextMultiplierBasedOnWidth() *3, fontWeight: FontWeight.w600,color: Color(0xFF575757) - ), - if(isDischargedPatient && - patient.dischargeDate != null) - AppText( - "${AppDateUtils - .getDateTimeFromServerFormat( - patient.dischargeDate) - .difference(AppDateUtils - .getDateTimeFromServerFormat( - patient.admissionDate)) - .inDays + 1}", - fontWeight: FontWeight.w700, - fontSize: SizeConfig.getTextMultiplierBasedOnWidth() *3.5, - color: Color(0xFF2E303A), - ) - else - AppText( - "${DateTime - .now() - .difference(AppDateUtils - .getDateTimeFromServerFormat( - patient.admissionDate)) - .inDays + 1}", - fontWeight: FontWeight.w700, - fontSize: SizeConfig.getTextMultiplierBasedOnWidth() *3.5, - color: Color(0xFF2E303A),), - ], - ), - ], - ), + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + if (patient.admissionDate != null && + patient.admissionDate.isNotEmpty) + HeaderRow( + label: patient.admissionDate == null + ? "" + : TranslationBase.of(context).admissionDate + + " : ", + value: patient.admissionDate == null + ? "" + : "${AppDateUtils.getDayMonthYearDateFormatted((AppDateUtils.getDateTimeFromServerFormat(patient.admissionDate.toString())))}", + ), + if (patient.admissionDate != null) + HeaderRow( + label: "${TranslationBase.of(context).numOfDays}: ", + value: isDischargedPatient && + patient.dischargeDate != null + ? "${AppDateUtils.getDateTimeFromServerFormat(patient.dischargeDate).difference(AppDateUtils.getDateTimeFromServerFormat(patient.admissionDate)).inDays + 1}" + : "${DateTime.now().difference(AppDateUtils.getDateTimeFromServerFormat(patient.admissionDate)).inDays + 1}", + ) + ], + ), ], ), ), ]), - if(isAppointmentHeader) + if (isAppointmentHeader) Row( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -409,10 +313,9 @@ class PatientProfileAppBar extends StatelessWidget decoration: BoxDecoration( shape: BoxShape.rectangle, border: Border( - bottom: BorderSide( - color: Colors.grey[400], width: 2.5), - left: BorderSide( - color: Colors.grey[400], width: 2.5), + bottom: + BorderSide(color: Colors.grey[400], width: 2.5), + left: BorderSide(color: Colors.grey[400], width: 2.5), )), ), Expanded( @@ -430,101 +333,123 @@ class PatientProfileAppBar extends StatelessWidget height: 25, margin: EdgeInsets.only(top: 10), ), - - Expanded( flex: 5, child: Container( margin: EdgeInsets.all(10), child: Column( - crossAxisAlignment: CrossAxisAlignment - .start, + crossAxisAlignment: CrossAxisAlignment.start, children: [ AppText( - '${TranslationBase - .of(context) - .dr}$doctorName', + '${TranslationBase.of(context).dr}$doctorName', color: Color(0xFF2E303A), fontWeight: FontWeight.w700, - fontSize: SizeConfig.getTextMultiplierBasedOnWidth() *3.5, + fontSize: SizeConfig + .getTextMultiplierBasedOnWidth() * + 3.5, ), - if (orderNo != null && - !isPrescriptions) + if (orderNo != null && !isPrescriptions) Row( children: [ - AppText('Order No: ', - - fontSize: SizeConfig.getTextMultiplierBasedOnWidth() *3, fontWeight: FontWeight.w600,color: Color(0xFF575757),), - AppText(orderNo ?? '', - fontSize: 12) + AppText( + 'Order No: ', + fontSize: SizeConfig + .getTextMultiplierBasedOnWidth() * + 3, + fontWeight: FontWeight.w600, + color: Color(0xFF575757), + ), + AppText(orderNo ?? '', fontSize: 12) ], ), - if (invoiceNO != null && - !isPrescriptions) + if (invoiceNO != null && !isPrescriptions) Row( children: [ - AppText('Invoice: ', - fontSize: SizeConfig.getTextMultiplierBasedOnWidth() *3, fontWeight: FontWeight.w600,color: Color(0xFF575757),), - AppText(invoiceNO ?? "", - fontSize: 12) + AppText( + 'Invoice: ', + fontSize: SizeConfig + .getTextMultiplierBasedOnWidth() * + 3, + fontWeight: FontWeight.w600, + color: Color(0xFF575757), + ), + AppText(invoiceNO ?? "", fontSize: 12) ], ), if (branch != null) Row( children: [ - AppText('Branch: ', - fontSize: SizeConfig.getTextMultiplierBasedOnWidth() *3, fontWeight: FontWeight.w600,color: Color(0xFF575757),), - AppText(branch ?? '', - fontSize: 12) + AppText( + 'Branch: ', + fontSize: SizeConfig + .getTextMultiplierBasedOnWidth() * + 3, + fontWeight: FontWeight.w600, + color: Color(0xFF575757), + ), + AppText(branch ?? '', fontSize: 12) ], ), - if (clinic != null) Row( children: [ - AppText('Clinic: ', - fontSize: SizeConfig.getTextMultiplierBasedOnWidth() *3, fontWeight: FontWeight.w600,color: Color(0xFF575757),), - AppText(clinic ?? '', - fontSize: 12) + AppText( + 'Clinic: ', + fontSize: SizeConfig + .getTextMultiplierBasedOnWidth() * + 3, + fontWeight: FontWeight.w600, + color: Color(0xFF575757), + ), + AppText(clinic ?? '', fontSize: 12) ], ), - if (isMedicalFile && - episode != null) + if (isMedicalFile && episode != null) Row( children: [ - AppText('Episode: ', - fontSize: SizeConfig.getTextMultiplierBasedOnWidth() *3, fontWeight: FontWeight.w600,color: Color(0xFF575757),), - AppText(episode ?? '', - fontSize: 12) + AppText( + 'Episode: ', + fontSize: SizeConfig + .getTextMultiplierBasedOnWidth() * + 3, + fontWeight: FontWeight.w600, + color: Color(0xFF575757), + ), + AppText(episode ?? '', fontSize: 12) ], ), - if (isMedicalFile && - visitDate != null) + if (isMedicalFile && visitDate != null) Row( children: [ - AppText('Visit Date: ', - fontSize: SizeConfig.getTextMultiplierBasedOnWidth() *3, fontWeight: FontWeight.w600,color: Color(0xFF575757),), - AppText(visitDate ?? '', - fontSize: 12) + AppText( + 'Visit Date: ', + fontSize: SizeConfig + .getTextMultiplierBasedOnWidth() * + 3, + fontWeight: FontWeight.w600, + color: Color(0xFF575757), + ), + AppText(visitDate ?? '', fontSize: 12) ], ), if (!isMedicalFile) Row( - children: [ AppText( !isPrescriptions ? 'Result Date:' : 'Prescriptions Date ', - fontSize: SizeConfig.getTextMultiplierBasedOnWidth() *3, fontWeight: FontWeight.w600,color: Color(0xFF575757), + fontSize: SizeConfig + .getTextMultiplierBasedOnWidth() * + 3, + fontWeight: FontWeight.w600, + color: Color(0xFF575757), ), AppText( - '${AppDateUtils - .getDayMonthYearDateFormatted( - appointmentDate, - isArabic: projectViewModel - .isArabic)}', - fontSize: SizeConfig.getTextMultiplierBasedOnWidth() *3.5, + '${AppDateUtils.getDayMonthYearDateFormatted(appointmentDate, isArabic: projectViewModel.isArabic)}', + fontSize: SizeConfig + .getTextMultiplierBasedOnWidth() * + 3.5, ) ], ) @@ -542,9 +467,51 @@ class PatientProfileAppBar extends StatelessWidget ), ); } + @override - Size get preferredSize => - Size(double.maxFinite, height == 0 - ? isInpatient ? (isFromLabResult?200:190) : isAppointmentHeader ? 290 : SizeConfig.isHeightVeryShort?137:SizeConfig.isHeightShort?190: SizeConfig.heightMultiplier * (SizeConfig.isWidthLarge?25:20) + Size get preferredSize => Size( + double.maxFinite, + height == 0 + ? isInpatient + ? (isFromLabResult ? 200 : 190) + : isAppointmentHeader + ? 290 + : SizeConfig.isHeightVeryShort + ? 137 + : SizeConfig.isHeightShort + ? 190 + : SizeConfig.heightMultiplier * + (SizeConfig.isWidthLarge ? 25 : 20) : height); } + +class HeaderRow extends StatelessWidget { + final String label; + final String value; + + const HeaderRow({Key key, this.label, this.value}) : super(key: key); + + @override + Widget build(BuildContext context) { + return Row( + children: [ + AppText( + label, + fontSize: SizeConfig.getTextMultiplierBasedOnWidth() * 3, + color: Color(0xFF575757), + fontWeight: FontWeight.w600, + ), + SizedBox( + width: 1, + ), + AppText( + value, + fontSize: SizeConfig.getTextMultiplierBasedOnWidth() * 3.5, + color: Color(0xFF2E303A), + fontWeight: FontWeight.w700, + isCopyable: true, + ), + ], + ); + } +} diff --git a/lib/widgets/patients/profile/patient-profile-header-new-design-app-bar.dart b/lib/widgets/patients/profile/patient-profile-header-new-design-app-bar.dart index 08cc26c5..7940fd61 100644 --- a/lib/widgets/patients/profile/patient-profile-header-new-design-app-bar.dart +++ b/lib/widgets/patients/profile/patient-profile-header-new-design-app-bar.dart @@ -7,13 +7,15 @@ import 'package:doctor_app_flutter/models/patient/patiant_info_model.dart'; import 'package:doctor_app_flutter/util/date-utils.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/patients/profile/patient-profile-app-bar.dart'; import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; import 'package:flutter/material.dart'; import 'package:hexcolor/hexcolor.dart'; import 'package:intl/intl.dart'; import 'package:url_launcher/url_launcher.dart'; -class PatientProfileHeaderNewDesignAppBar extends StatelessWidget with PreferredSizeWidget { +class PatientProfileHeaderNewDesignAppBar extends StatelessWidget + with PreferredSizeWidget { final PatiantInformtion patient; final String patientType; final String arrivalType; @@ -24,7 +26,8 @@ class PatientProfileHeaderNewDesignAppBar extends StatelessWidget with Preferred final Stream videoCallDurationStream; - PatientProfileHeaderNewDesignAppBar(this.patient, this.patientType, this.arrivalType, + PatientProfileHeaderNewDesignAppBar( + this.patient, this.patientType, this.arrivalType, {this.height = 0.0, this.isInpatient = false, this.isDischargedPatient = false, @@ -69,8 +72,11 @@ class PatientProfileHeaderNewDesignAppBar extends StatelessWidget with Preferred Expanded( child: AppText( patient.firstName != null - ? (Helpers.capitalize(patient.firstName) + " " + Helpers.capitalize(patient.lastName)) - : Helpers.capitalize(patient.fullName ?? patient.patientDetails.fullName), + ? (Helpers.capitalize(patient.firstName) + + " " + + Helpers.capitalize(patient.lastName)) + : Helpers.capitalize(patient.fullName ?? + patient.patientDetails.fullName), fontSize: SizeConfig.textMultiplier * 1.8, fontWeight: FontWeight.bold, fontFamily: 'Poppins', @@ -103,13 +109,17 @@ class PatientProfileHeaderNewDesignAppBar extends StatelessWidget with Preferred ), StreamBuilder( stream: videoCallDurationStream, - builder: (BuildContext context, AsyncSnapshot snapshot) { + builder: + (BuildContext context, AsyncSnapshot snapshot) { if (snapshot.hasData && snapshot.data != null) return InkWell( onTap: () {}, child: Container( - decoration: BoxDecoration(color: Colors.red, borderRadius: BorderRadius.circular(20)), - padding: EdgeInsets.symmetric(vertical: 2, horizontal: 10), + decoration: BoxDecoration( + color: Colors.red, + borderRadius: BorderRadius.circular(20)), + padding: + EdgeInsets.symmetric(vertical: 2, horizontal: 10), child: Text( snapshot.data, style: TextStyle(color: Colors.white), @@ -129,7 +139,9 @@ class PatientProfileHeaderNewDesignAppBar extends StatelessWidget with Preferred width: 60, height: 60, child: Image.asset( - gender == 1 ? 'assets/images/male_avatar.png' : 'assets/images/female_avatar.png', + gender == 1 + ? 'assets/images/male_avatar.png' + : 'assets/images/female_avatar.png', fit: BoxFit.cover, ), ), @@ -141,7 +153,8 @@ class PatientProfileHeaderNewDesignAppBar extends StatelessWidget with Preferred child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - SERVICES_PATIANT2[int.parse(patientType)] == "patientArrivalList" + SERVICES_PATIANT2[int.parse(patientType)] == + "patientArrivalList" ? Container( child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, @@ -163,14 +176,18 @@ class PatientProfileHeaderNewDesignAppBar extends StatelessWidget with Preferred ), arrivalType == '1' || patient.arrivedOn == null ? AppText( - patient.startTime != null ? patient.startTime : '', + patient.startTime != null + ? patient.startTime + : '', fontFamily: 'Poppins', fontWeight: FontWeight.w600, ) : AppText( patient.arrivedOn != null - ? AppDateUtils.convertStringToDateFormat( - patient.arrivedOn, 'MM-dd-yyyy HH:mm') + ? AppDateUtils + .convertStringToDateFormat( + patient.arrivedOn, + 'MM-dd-yyyy HH:mm') : '', fontFamily: 'Poppins', fontWeight: FontWeight.w600, @@ -178,13 +195,16 @@ class PatientProfileHeaderNewDesignAppBar extends StatelessWidget with Preferred ], )) : SizedBox(), - if (SERVICES_PATIANT2[int.parse(patientType)] == "List_MyOutPatient" && !isFromLiveCare) + if (SERVICES_PATIANT2[int.parse(patientType)] == + "List_MyOutPatient" && + !isFromLiveCare) Container( child: Row( mainAxisAlignment: MainAxisAlignment.start, children: [ AppText( - TranslationBase.of(context).appointmentDate + " : ", + TranslationBase.of(context).appointmentDate + + " : ", fontSize: 14, ), patient.startTime != null @@ -209,7 +229,8 @@ class PatientProfileHeaderNewDesignAppBar extends StatelessWidget with Preferred ), Container( child: AppText( - convertDateFormat2(patient.appointmentDate ?? ''), + convertDateFormat2( + patient.appointmentDate ?? ''), fontSize: 1.5 * SizeConfig.textMultiplier, fontWeight: FontWeight.bold, ), @@ -226,23 +247,17 @@ class PatientProfileHeaderNewDesignAppBar extends StatelessWidget with Preferred Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - RichText( - text: TextSpan( - style: TextStyle(fontSize: 1.6 * SizeConfig.textMultiplier, color: Colors.black), - children: [ - new TextSpan( - text: TranslationBase.of(context).fileNumber, - style: TextStyle(fontSize: 12, fontFamily: 'Poppins')), - new TextSpan( - text: patient.patientId.toString(), - style: TextStyle(fontWeight: FontWeight.w700, fontFamily: 'Poppins', fontSize: 14)), - ], - ), + HeaderRow( + label: TranslationBase.of(context).fileNumber, + value: patient.patientId.toString(), ), Row( children: [ AppText( - patient.nationalityName ?? patient.nationality ?? patient.nationalityId ?? '', + patient.nationalityName ?? + patient.nationality ?? + patient.nationalityId ?? + '', fontWeight: FontWeight.bold, fontSize: 12, ), @@ -253,7 +268,9 @@ class PatientProfileHeaderNewDesignAppBar extends StatelessWidget with Preferred patient.nationalityFlagURL, height: 25, width: 30, - errorBuilder: (BuildContext context, Object exception, StackTrace stackTrace) { + errorBuilder: (BuildContext context, + Object exception, + StackTrace stackTrace) { return Text('No Image'); }, )) @@ -262,67 +279,31 @@ class PatientProfileHeaderNewDesignAppBar extends StatelessWidget with Preferred ) ], ), - Container( - child: RichText( - text: new TextSpan( - style: new TextStyle( - fontSize: 1.6 * SizeConfig.textMultiplier, - color: Colors.black, - fontFamily: 'Poppins', - ), - children: [ - new TextSpan(text: TranslationBase.of(context).age + " : ", style: TextStyle(fontSize: 14)), - new TextSpan( - text: - "${AppDateUtils.getAgeByBirthday(patient.patientDetails != null ? patient.patientDetails.dateofBirth ?? "" : patient.dateofBirth ?? "", context, isServerFormat: !isFromLiveCare)}", - style: TextStyle(fontWeight: FontWeight.w700, fontSize: 14)), - ], - ), - ), + HeaderRow( + label: TranslationBase.of(context).age + " : ", + value: + "${AppDateUtils.getAgeByBirthday(patient.patientDetails != null ? patient.patientDetails.dateofBirth ?? "" : patient.dateofBirth ?? "", context, isServerFormat: !isFromLiveCare)}", ), if (isInpatient) Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Container( - child: RichText( - text: new TextSpan( - style: new TextStyle( - fontSize: 2.0 * SizeConfig.textMultiplier, - color: Colors.black, - fontFamily: 'Poppins', - ), - children: [ - new TextSpan( - text: patient.admissionDate == null - ? "" - : TranslationBase.of(context).admissionDate + " : ", - style: TextStyle(fontSize: 14)), - new TextSpan( - text: patient.admissionDate == null - ? "" - : "${AppDateUtils.convertDateFromServerFormat(patient.admissionDate.toString(), 'yyyy-MM-dd')}", - style: TextStyle(fontWeight: FontWeight.w700, fontSize: 15)), - ]))), + HeaderRow( + label: patient.admissionDate == null + ? "" + : TranslationBase.of(context).admissionDate + + " : ", + value: patient.admissionDate == null + ? "" + : "${AppDateUtils.convertDateFromServerFormat(patient.admissionDate.toString(), 'yyyy-MM-dd')}"), if (patient.admissionDate != null) - Row( - children: [ - AppText( - "${TranslationBase.of(context).numOfDays}: ", - fontSize: 15, - ), - if (isDischargedPatient && patient.dischargeDate != null) - AppText( - "${AppDateUtils.getDateTimeFromServerFormat(patient.dischargeDate).difference(AppDateUtils.getDateTimeFromServerFormat(patient.admissionDate)).inDays + 1}", - fontSize: 15, - fontWeight: FontWeight.w700) - else - AppText( - "${DateTime.now().difference(AppDateUtils.getDateTimeFromServerFormat(patient.admissionDate)).inDays + 1}", - fontSize: 15, - fontWeight: FontWeight.w700), - ], - ), + HeaderRow( + label: "${TranslationBase.of(context).numOfDays}: ", + value: isDischargedPatient && + patient.dischargeDate != null + ? "${AppDateUtils.getDateTimeFromServerFormat(patient.dischargeDate).difference(AppDateUtils.getDateTimeFromServerFormat(patient.admissionDate)).inDays + 1}" + : "${DateTime.now().difference(AppDateUtils.getDateTimeFromServerFormat(patient.admissionDate)).inDays + 1}", + ) ], ) ], @@ -344,7 +325,8 @@ class PatientProfileHeaderNewDesignAppBar extends StatelessWidget with Preferred final startIndex = str.indexOf(start); 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))); newDate = date.year.toString() + "/" + date.month.toString().padLeft(2, '0') + @@ -357,7 +339,8 @@ class PatientProfileHeaderNewDesignAppBar extends StatelessWidget with Preferred isToday(date) { DateTime tempDate = new DateFormat("yyyy-MM-dd").parse(date); - return DateFormat("yyyy-MM-dd").format(tempDate) == DateFormat("yyyy-MM-dd").format(DateTime.now()); + return DateFormat("yyyy-MM-dd").format(tempDate) == + DateFormat("yyyy-MM-dd").format(DateTime.now()); } myBoxDecoration() { From c17f9fb91da6c6dd7814fe0b0f5c8c6f5851c55c Mon Sep 17 00:00:00 2001 From: Elham Rababh Date: Tue, 24 Aug 2021 10:58:57 +0300 Subject: [PATCH 2/7] add copy to patient cart --- .../patients/patient_card/PatientCard.dart | 200 +++++++----------- .../profile/patient-profile-app-bar.dart | 118 +++-------- 2 files changed, 101 insertions(+), 217 deletions(-) diff --git a/lib/widgets/patients/patient_card/PatientCard.dart b/lib/widgets/patients/patient_card/PatientCard.dart index b90eecd3..22b35417 100644 --- a/lib/widgets/patients/patient_card/PatientCard.dart +++ b/lib/widgets/patients/patient_card/PatientCard.dart @@ -35,7 +35,6 @@ class PatientCard extends StatelessWidget { @override Widget build(BuildContext context) { - return Container( width: SizeConfig.screenWidth * 0.9, margin: EdgeInsets.all(6), @@ -260,9 +259,9 @@ class PatientCard extends StatelessWidget { patientInfo.fullName) : (Helpers.capitalize( patientInfo.firstName) + - " " + - Helpers.capitalize( - patientInfo.lastName)), + " " + + Helpers.capitalize( + patientInfo.lastName)), fontSize: 16, color: Color(0xff2e303a), fontWeight: FontWeight.w700, @@ -270,7 +269,6 @@ class PatientCard extends StatelessWidget { textOverflow: TextOverflow.ellipsis, ), ), - if (patientInfo.gender == 1) Icon( DoctorApp.male_2, @@ -281,9 +279,10 @@ class PatientCard extends StatelessWidget { DoctorApp.female_1, color: Colors.pink, ), - - if(isFromLiveCare) - ShowTimer(patientInfo: patientInfo,), + if (isFromLiveCare) + ShowTimer( + patientInfo: patientInfo, + ), ]), ), Row( @@ -351,129 +350,45 @@ class PatientCard extends StatelessWidget { child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Container( - child: RichText( - text: new TextSpan( - style: new TextStyle( - fontSize: 2.0 * SizeConfig.textMultiplier, - color: Colors.black), - children: [ - new TextSpan( - text: TranslationBase.of(context) - .fileNumber, - style: TextStyle( - fontSize: 12, - fontFamily: 'Poppins')), - new TextSpan( - text: patientInfo.patientId.toString(), - style: TextStyle( - fontWeight: FontWeight.w700, - fontFamily: 'Poppins', - fontSize: 13)), - ], - ), - ), + CustomRow( + label: TranslationBase.of(context).fileNumber, + value: patientInfo.patientId.toString(), ), + //if (isInpatient) - Container( - child: RichText( - text: new TextSpan( - style: new TextStyle( - fontSize: 2.0 * SizeConfig.textMultiplier, - color: Colors.black, - fontFamily: 'Poppins', - ), - children: [ - new TextSpan( - text: TranslationBase.of(context).age + - " : ", - style: TextStyle(fontSize: 12)), - new TextSpan( - text: - "${AppDateUtils.getAgeByBirthday(patientInfo.dateofBirth, context, isServerFormat: !isFromLiveCare)}", - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 13)), - ], - ), - ), + + CustomRow( + label: TranslationBase.of(context).age + " : ", + value: + "${AppDateUtils.getAgeByBirthday(patientInfo.dateofBirth, context, isServerFormat: !isFromLiveCare)}", ), + if (isInpatient) - Container( - child: RichText( - text: new TextSpan( - style: new TextStyle( - fontSize: - 2.0 * SizeConfig.textMultiplier, - color: Colors.black, - fontFamily: 'Poppins', - ), - children: [ - new TextSpan( - text: patientInfo.admissionDate == null - ? "" - : TranslationBase.of(context) - .admissionDate + - " : ", - style: TextStyle(fontSize: 12)), - new TextSpan( - text: patientInfo.admissionDate == null - ? "" - : "${AppDateUtils.convertDateFromServerFormat(patientInfo.admissionDate.toString(), 'yyyy-MM-dd')}", - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 13)), - ]))), + CustomRow( + label: patientInfo.admissionDate == null + ? "" + : TranslationBase.of(context) + .admissionDate + + " : ", + value: patientInfo.admissionDate == null + ? "" + : "${AppDateUtils.convertDateFromServerFormat(patientInfo.admissionDate.toString(), 'yyyy-MM-dd')}", + ), if (patientInfo.admissionDate != null) - Container( - child: RichText( - text: new TextSpan( - style: new TextStyle( - fontSize: - 2.0 * SizeConfig.textMultiplier, - color: Colors.black, - fontFamily: 'Poppins', - ), - children: [ - new TextSpan( - text: TranslationBase.of(context) - .numOfDays + - " : ", - style: TextStyle(fontSize: 12)), - new TextSpan( - text: - "${DateTime.now().difference(AppDateUtils.getDateTimeFromServerFormat(patientInfo.admissionDate)).inDays + 1}", - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 13)), - ]))), + CustomRow( + label: TranslationBase.of(context).numOfDays + + " : ", + value: + "${DateTime.now().difference(AppDateUtils.getDateTimeFromServerFormat(patientInfo.admissionDate)).inDays + 1}", + ), if (isFromLiveCare) Column( children: [ - Container( - child: RichText( - text: new TextSpan( - style: new TextStyle( - fontSize: 2.0 * SizeConfig.textMultiplier, - color: Colors.black, - fontFamily: 'Poppins', - ), - children: [ - new TextSpan( - text: - TranslationBase.of(context).clinic + - " : ", - style: TextStyle(fontSize: 12)), - new TextSpan( - text: - patientInfo.clinicName, - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 13)), - ], - ), - ), - ), + + CustomRow(label: TranslationBase.of(context) + .clinic + + " : ",value: patientInfo.clinicName,), + ], ), ])) @@ -522,14 +437,47 @@ class PatientCard extends StatelessWidget { height: 25, width: 35, )), - ]) - : SizedBox() + ]) + : SizedBox() ], ), onTap: onTap, )), )); } +} + +class CustomRow extends StatelessWidget { + const CustomRow({ + Key key, + this.label, + this.value, + }) : super(key: key); + final String label; + final String value; -} \ No newline at end of file + @override + Widget build(BuildContext context) { + return Row( + children: [ + AppText( + label, + fontSize: SizeConfig.getTextMultiplierBasedOnWidth() * 2.8, + color: Color(0xFF575757), + fontWeight: FontWeight.w600, + ), + SizedBox( + width: 1, + ), + AppText( + value, + fontSize: SizeConfig.getTextMultiplierBasedOnWidth() * 3, + color: Color(0xFF2E303A), + fontWeight: FontWeight.w700, + isCopyable: true, + ), + ], + ); + } +} diff --git a/lib/widgets/patients/profile/patient-profile-app-bar.dart b/lib/widgets/patients/profile/patient-profile-app-bar.dart index f9bab58c..8b2f7de4 100644 --- a/lib/widgets/patients/profile/patient-profile-app-bar.dart +++ b/lib/widgets/patients/profile/patient-profile-app-bar.dart @@ -103,6 +103,7 @@ class PatientProfileAppBar extends StatelessWidget with PreferredSizeWidget { fontWeight: FontWeight.bold, fontFamily: 'Poppins', color: Color(0xFF2B353E), + isCopyable: true, ), ), gender == 1 @@ -347,112 +348,46 @@ class PatientProfileAppBar extends StatelessWidget with PreferredSizeWidget { fontSize: SizeConfig .getTextMultiplierBasedOnWidth() * 3.5, + isCopyable: true, ), if (orderNo != null && !isPrescriptions) - Row( - children: [ - AppText( - 'Order No: ', - fontSize: SizeConfig - .getTextMultiplierBasedOnWidth() * - 3, - fontWeight: FontWeight.w600, - color: Color(0xFF575757), - ), - AppText(orderNo ?? '', fontSize: 12) - ], + HeaderRow( + label: 'Order No: ', + value: orderNo ?? '', ), if (invoiceNO != null && !isPrescriptions) - Row( - children: [ - AppText( - 'Invoice: ', - fontSize: SizeConfig - .getTextMultiplierBasedOnWidth() * - 3, - fontWeight: FontWeight.w600, - color: Color(0xFF575757), - ), - AppText(invoiceNO ?? "", fontSize: 12) - ], + HeaderRow( + label: 'Invoice: ', + value: invoiceNO ?? "", ), if (branch != null) - Row( - children: [ - AppText( - 'Branch: ', - fontSize: SizeConfig - .getTextMultiplierBasedOnWidth() * - 3, - fontWeight: FontWeight.w600, - color: Color(0xFF575757), - ), - AppText(branch ?? '', fontSize: 12) - ], + HeaderRow( + label: 'Branch: ', + value: branch ?? '', ), if (clinic != null) - Row( - children: [ - AppText( - 'Clinic: ', - fontSize: SizeConfig - .getTextMultiplierBasedOnWidth() * - 3, - fontWeight: FontWeight.w600, - color: Color(0xFF575757), - ), - AppText(clinic ?? '', fontSize: 12) - ], + HeaderRow( + label: 'Clinic: ', + value: clinic ?? '', ), if (isMedicalFile && episode != null) - Row( - children: [ - AppText( - 'Episode: ', - fontSize: SizeConfig - .getTextMultiplierBasedOnWidth() * - 3, - fontWeight: FontWeight.w600, - color: Color(0xFF575757), - ), - AppText(episode ?? '', fontSize: 12) - ], + HeaderRow( + label: 'Episode: ', + value: episode ?? '', ), if (isMedicalFile && visitDate != null) - Row( - children: [ - AppText( - 'Visit Date: ', - fontSize: SizeConfig - .getTextMultiplierBasedOnWidth() * - 3, - fontWeight: FontWeight.w600, - color: Color(0xFF575757), - ), - AppText(visitDate ?? '', fontSize: 12) - ], + HeaderRow( + label: 'Visit Date: ', + value: visitDate ?? '', ), if (!isMedicalFile) - Row( - children: [ - AppText( - !isPrescriptions - ? 'Result Date:' - : 'Prescriptions Date ', - fontSize: SizeConfig - .getTextMultiplierBasedOnWidth() * - 3, - fontWeight: FontWeight.w600, - color: Color(0xFF575757), - ), - AppText( + HeaderRow( + label: !isPrescriptions + ? 'Result Date:' + : 'Prescriptions Date ', + value: '${AppDateUtils.getDayMonthYearDateFormatted(appointmentDate, isArabic: projectViewModel.isArabic)}', - fontSize: SizeConfig - .getTextMultiplierBasedOnWidth() * - 3.5, - ) - ], - ) + ), ]), ), ), @@ -497,6 +432,7 @@ class HeaderRow extends StatelessWidget { children: [ AppText( label, + isCopyable: true, fontSize: SizeConfig.getTextMultiplierBasedOnWidth() * 3, color: Color(0xFF575757), fontWeight: FontWeight.w600, From 943463b1d9cf904a01f6d550b3ff4087e0788ed3 Mon Sep 17 00:00:00 2001 From: Elham Rababh Date: Tue, 24 Aug 2021 14:17:36 +0300 Subject: [PATCH 3/7] add pagination to doctor replay --- lib/config/localized_values.dart | 1 + .../service/home/doctor_reply_service.dart | 4 +- .../viewModel/doctor_replay_view_model.dart | 35 +++++---- .../doctor/replay/request_doctor_reply.dart | 26 ++++--- lib/screens/doctor/doctor_repaly_chat.dart | 2 +- lib/screens/doctor/doctor_reply_screen.dart | 72 ++++++++++++++----- lib/util/translations_delegate_base.dart | 1 + pubspec.lock | 6 +- 8 files changed, 101 insertions(+), 46 deletions(-) diff --git a/lib/config/localized_values.dart b/lib/config/localized_values.dart index 56b3fde8..f3308c58 100644 --- a/lib/config/localized_values.dart +++ b/lib/config/localized_values.dart @@ -709,5 +709,6 @@ const Map> localizedValues = { "Completed": {"en": "Completed", "ar": "مكتمل"}, "Locked": {"en": "Locked", "ar": "مقفل"}, "textCopiedSuccessfully": {"en": "Text copied successfully", "ar": "تم نسخ النص بنجاح"}, + "seeMore": {"en": "See More ...", "ar": "شاهد المزيد..."}, }; diff --git a/lib/core/service/home/doctor_reply_service.dart b/lib/core/service/home/doctor_reply_service.dart index f8008e0e..cdb45f1b 100644 --- a/lib/core/service/home/doctor_reply_service.dart +++ b/lib/core/service/home/doctor_reply_service.dart @@ -13,15 +13,15 @@ class DoctorReplyService extends BaseService { List _listDoctorWorkingHoursTable = []; - RequestDoctorReply _requestDoctorReply = RequestDoctorReply(); List _listMyReferralPatientModel = []; List get listMyReferralPatientModel => _listMyReferralPatientModel; int notRepliedCount = 0; - Future getDoctorReply() async { + Future getDoctorReply(RequestDoctorReply _requestDoctorReply,{bool clearData = false}) async { hasError = false; await baseAppClient.post(GT_MY_PATIENT_QUESTION, onSuccess: (dynamic response, int statusCode) { + if(clearData) _listDoctorWorkingHoursTable.clear(); response['List_GtMyPatientsQuestions'].forEach((v) { _listDoctorWorkingHoursTable diff --git a/lib/core/viewModel/doctor_replay_view_model.dart b/lib/core/viewModel/doctor_replay_view_model.dart index 7ed0acc4..17607d80 100644 --- a/lib/core/viewModel/doctor_replay_view_model.dart +++ b/lib/core/viewModel/doctor_replay_view_model.dart @@ -2,6 +2,7 @@ import 'package:doctor_app_flutter/core/enum/viewstate.dart'; import 'package:doctor_app_flutter/core/service/home/doctor_reply_service.dart'; import 'package:doctor_app_flutter/models/doctor/list_gt_my_patients_question_model.dart'; import 'package:doctor_app_flutter/models/doctor/replay/request_create_doctor_response.dart'; +import 'package:doctor_app_flutter/models/doctor/replay/request_doctor_reply.dart'; import '../../locator.dart'; import 'base_view_model.dart'; @@ -12,13 +13,25 @@ class DoctorReplayViewModel extends BaseViewModel { List get listDoctorWorkingHoursTable => _doctorReplyService.listDoctorWorkingHoursTable; - Future getDoctorReply() async { - setState(ViewState.Busy); + Future getDoctorReply( + {int pageSize = 10, int pageIndex = 1, bool isLocalBusy = true}) async { + if (isLocalBusy) { + setState(ViewState.BusyLocal); + } else { + setState(ViewState.Busy); + } await getDoctorProfile(); - await _doctorReplyService.getDoctorReply(); + RequestDoctorReply _requestDoctorReply = + RequestDoctorReply(pageIndex: pageIndex, pageSize: pageSize); + + await _doctorReplyService.getDoctorReply(_requestDoctorReply, clearData:!isLocalBusy ); if (_doctorReplyService.hasError) { error = _doctorReplyService.error; - setState(ViewState.Error); + if (isLocalBusy) { + setState(ViewState.ErrorLocal); + } else { + setState(ViewState.Error); + } } else setState(ViewState.Idle); } @@ -28,13 +41,12 @@ class DoctorReplayViewModel extends BaseViewModel { await getDoctorProfile(); CreateDoctorResponseModel createDoctorResponseModel = CreateDoctorResponseModel( - transactionNo: model.transactionNo.toString(), - doctorResponse: response, - infoStatus: 6, - createdBy:this.doctorProfile.doctorID, - infoEnteredBy: this.doctorProfile.doctorID, - setupID:"010266" - ); + transactionNo: model.transactionNo.toString(), + doctorResponse: response, + infoStatus: 6, + createdBy: this.doctorProfile.doctorID, + infoEnteredBy: this.doctorProfile.doctorID, + setupID: "010266"); setState(ViewState.BusyLocal); await _doctorReplyService.createDoctorResponse(createDoctorResponseModel); if (_doctorReplyService.hasError) { @@ -43,7 +55,6 @@ class DoctorReplayViewModel extends BaseViewModel { } else { setState(ViewState.Idle); _doctorReplyService.getNotRepliedCount(); - } } } diff --git a/lib/models/doctor/replay/request_doctor_reply.dart b/lib/models/doctor/replay/request_doctor_reply.dart index 707336d6..1c3948cb 100644 --- a/lib/models/doctor/replay/request_doctor_reply.dart +++ b/lib/models/doctor/replay/request_doctor_reply.dart @@ -13,20 +13,24 @@ class RequestDoctorReply { String sessionID; bool isLoginForDoctorApp; bool patientOutSA; + int pageIndex; + int pageSize; RequestDoctorReply( - {this.projectID , - this.doctorID , - this.transactionNo = TRANSACTION_NO , - this.languageID , - this.stamp , + {this.projectID, + this.doctorID, + this.transactionNo = TRANSACTION_NO, + this.languageID, + this.stamp, this.iPAdress, - this.versionID , + this.versionID, this.channel, - this.tokenID , + this.tokenID, this.sessionID, - this.isLoginForDoctorApp , - this.patientOutSA }); + this.isLoginForDoctorApp, + this.patientOutSA, + this.pageIndex, + this.pageSize}); RequestDoctorReply.fromJson(Map json) { projectID = json['ProjectID']; @@ -41,6 +45,8 @@ class RequestDoctorReply { sessionID = json['SessionID']; isLoginForDoctorApp = json['IsLoginForDoctorApp']; patientOutSA = json['PatientOutSA']; + pageIndex = json['PageIndex']; + pageSize = json['PageSize']; } Map toJson() { @@ -57,6 +63,8 @@ class RequestDoctorReply { data['SessionID'] = this.sessionID; data['IsLoginForDoctorApp'] = this.isLoginForDoctorApp; data['PatientOutSA'] = this.patientOutSA; + data['PageIndex'] = this.pageIndex; + data['PageSize'] = this.pageSize; return data; } } diff --git a/lib/screens/doctor/doctor_repaly_chat.dart b/lib/screens/doctor/doctor_repaly_chat.dart index c3b58806..935dbf7c 100644 --- a/lib/screens/doctor/doctor_repaly_chat.dart +++ b/lib/screens/doctor/doctor_repaly_chat.dart @@ -370,7 +370,7 @@ class DoctorReplayChat extends StatelessWidget { Helpers.showErrorToast(previousModel.error); } else { DrAppToastMsg.showSuccesToast("Thank you for your replay "); - await previousModel.getDoctorReply(); + await previousModel.getDoctorReply(isLocalBusy: false); Navigator.pop(context); } GifLoaderDialogUtils.hideDialog(context); diff --git a/lib/screens/doctor/doctor_reply_screen.dart b/lib/screens/doctor/doctor_reply_screen.dart index b318f6a4..988ddef7 100644 --- a/lib/screens/doctor/doctor_reply_screen.dart +++ b/lib/screens/doctor/doctor_reply_screen.dart @@ -1,10 +1,15 @@ +import 'package:doctor_app_flutter/config/size_config.dart'; +import 'package:doctor_app_flutter/core/enum/viewstate.dart'; import 'package:doctor_app_flutter/core/viewModel/doctor_replay_view_model.dart'; import 'package:doctor_app_flutter/screens/base/base_view.dart'; import 'package:doctor_app_flutter/screens/doctor/doctor_repaly_chat.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/doctor/doctor_reply_widget.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/errors/dr_app_embedded_error.dart'; +import 'package:doctor_app_flutter/widgets/shared/loader/gif_loader_dialog_utils.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; @@ -15,21 +20,27 @@ import 'package:flutter/material.dart'; *@return: *@desc: Doctor Reply Screen display data from GtMyPatientsQuestions service */ -class DoctorReplyScreen extends StatelessWidget { - +class DoctorReplyScreen extends StatefulWidget { final Function changeCurrentTab; const DoctorReplyScreen({Key key, this.changeCurrentTab}) : super(key: key); + @override + _DoctorReplyScreenState createState() => _DoctorReplyScreenState(); +} + +class _DoctorReplyScreenState extends State { + int pageIndex = 1; + @override Widget build(BuildContext context) { return BaseView( onModelReady: (model) { - model.getDoctorReply(); + model.getDoctorReply(isLocalBusy: false); }, builder: (_, model, w) => WillPopScope( - onWillPop: ()async{ - changeCurrentTab(); + onWillPop: () async { + widget.changeCurrentTab(); return false; }, child: AppScaffold( @@ -45,22 +56,46 @@ class DoctorReplyScreen extends StatelessWidget { Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: - model.listDoctorWorkingHoursTable.map((reply) { + children: model.listDoctorWorkingHoursTable.map( + (reply) { return InkWell( - onTap: () { - Navigator.push( - context, - MaterialPageRoute( - builder: (BuildContext context) => - DoctorReplayChat( - reply: reply, - previousModel: model, - ), settings: RouteSettings(name: 'DoctorReplayChat'),)); - }, + onTap: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (BuildContext context) => + DoctorReplayChat( + reply: reply, + previousModel: model, + ), + settings: + RouteSettings(name: 'DoctorReplayChat'), + )); + }, child: DoctorReplyWidget(reply: reply), ); - }).toList(), + }).toList() + ..add(InkWell( + onTap: () async { + setState(() { + pageIndex++; + }); + GifLoaderDialogUtils.showMyDialog(context); + await model.getDoctorReply(pageIndex: pageIndex); + if (model.state == ViewState.ErrorLocal) { + GifLoaderDialogUtils.hideDialog(context); + + Helpers.showErrorToast(model.error); + } else + GifLoaderDialogUtils.hideDialog(context); + }, + child: Center( + child: Container( + padding: EdgeInsets.all(20), + child: AppText("${TranslationBase.of(context).seeMore}", fontSize: SizeConfig.getTextMultiplierBasedOnWidth()*4,), + ), + ), + )), ) ], ), @@ -68,6 +103,5 @@ class DoctorReplyScreen extends StatelessWidget { ), ), ); - } } diff --git a/lib/util/translations_delegate_base.dart b/lib/util/translations_delegate_base.dart index e104a01e..afda54eb 100644 --- a/lib/util/translations_delegate_base.dart +++ b/lib/util/translations_delegate_base.dart @@ -1371,6 +1371,7 @@ class TranslationBase { String get summeryReply => localizedValues['summeryReply'][locale.languageCode]; String get severityValidationError => localizedValues['severityValidationError'][locale.languageCode]; String get textCopiedSuccessfully => localizedValues['textCopiedSuccessfully'][locale.languageCode]; + String get seeMore => localizedValues['seeMore'][locale.languageCode]; } class TranslationBaseDelegate extends LocalizationsDelegate { diff --git a/pubspec.lock b/pubspec.lock index 0229e774..e2215d0c 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -664,7 +664,7 @@ packages: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.3.0-nullsafety.4" + version: "1.3.0-nullsafety.3" mime: dependency: transitive description: @@ -956,7 +956,7 @@ packages: name: stack_trace url: "https://pub.dartlang.org" source: hosted - version: "1.10.0-nullsafety.2" + version: "1.10.0-nullsafety.1" sticky_headers: dependency: "direct main" description: @@ -1154,5 +1154,5 @@ packages: source: hosted version: "2.2.1" sdks: - dart: ">=2.10.0 <=2.11.0-213.1.beta" + dart: ">=2.10.0 <2.11.0" flutter: ">=1.22.0 <2.0.0" From 64c98ba12825ff6e845c9fd587dbdc6c482efc24 Mon Sep 17 00:00:00 2001 From: Elham Rababh Date: Tue, 24 Aug 2021 15:48:23 +0300 Subject: [PATCH 4/7] modify pagination to make works on scroll --- lib/screens/doctor/doctor_reply_screen.dart | 97 +++++++++++---------- 1 file changed, 51 insertions(+), 46 deletions(-) diff --git a/lib/screens/doctor/doctor_reply_screen.dart b/lib/screens/doctor/doctor_reply_screen.dart index 988ddef7..9047bb2d 100644 --- a/lib/screens/doctor/doctor_reply_screen.dart +++ b/lib/screens/doctor/doctor_reply_screen.dart @@ -8,6 +8,7 @@ import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; import 'package:doctor_app_flutter/widgets/doctor/doctor_reply_widget.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/dr_app_circular_progress_Indeicator.dart'; import 'package:doctor_app_flutter/widgets/shared/errors/dr_app_embedded_error.dart'; import 'package:doctor_app_flutter/widgets/shared/loader/gif_loader_dialog_utils.dart'; import 'package:flutter/cupertino.dart'; @@ -49,57 +50,61 @@ class _DoctorReplyScreenState extends State { isShowAppBar: false, body: model.listDoctorWorkingHoursTable.isEmpty ? DrAppEmbeddedError(error: TranslationBase.of(context).noItem) - : Container( - padding: EdgeInsetsDirectional.fromSTEB(30, 0, 30, 0), - child: ListView( - children: [ - Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: model.listDoctorWorkingHoursTable.map( - (reply) { - return InkWell( - onTap: () { - Navigator.push( - context, - MaterialPageRoute( - builder: (BuildContext context) => - DoctorReplayChat( - reply: reply, - previousModel: model, + : Column( + children: [ + Expanded( + child: Container( + padding: EdgeInsetsDirectional.fromSTEB(30, 0, 30, 0), + child: NotificationListener( + child: ListView.builder( + scrollDirection: Axis.vertical, + shrinkWrap: true, + + itemBuilder: (BuildContext ctxt, int index) { + return Column( + children: [ + InkWell( + onTap: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (BuildContext context) => + DoctorReplayChat( + reply: + model.listDoctorWorkingHoursTable[ + index], + previousModel: model, + ), + settings: RouteSettings( + name: 'DoctorReplayChat'), + )); + }, + child: DoctorReplyWidget( + reply: model + .listDoctorWorkingHoursTable[index]), ), - settings: - RouteSettings(name: 'DoctorReplayChat'), - )); - }, - child: DoctorReplyWidget(reply: reply), - ); - }).toList() - ..add(InkWell( - onTap: () async { + if(model.state == ViewState.BusyLocal &&index ==model.listDoctorWorkingHoursTable.length-1) + DrAppCircularProgressIndeicator() + + ], + ); + }), + onNotification: (t) { + if (t is ScrollEndNotification && + model.state != ViewState.BusyLocal) { + print("${model.state}"); setState(() { pageIndex++; }); - GifLoaderDialogUtils.showMyDialog(context); - await model.getDoctorReply(pageIndex: pageIndex); - if (model.state == ViewState.ErrorLocal) { - GifLoaderDialogUtils.hideDialog(context); - - Helpers.showErrorToast(model.error); - } else - GifLoaderDialogUtils.hideDialog(context); - }, - child: Center( - child: Container( - padding: EdgeInsets.all(20), - child: AppText("${TranslationBase.of(context).seeMore}", fontSize: SizeConfig.getTextMultiplierBasedOnWidth()*4,), - ), - ), - )), - ) - ], + model.getDoctorReply(pageIndex: pageIndex); + } + return; + }, + ), + ), ), - ), + ], + ), ), ), ); From 66e33b708537ff0fd4ccc4c4c4f683534777543b Mon Sep 17 00:00:00 2001 From: Elham Rababh Date: Wed, 25 Aug 2021 11:26:41 +0300 Subject: [PATCH 5/7] fix error happen while scrolling --- lib/screens/doctor/doctor_reply_screen.dart | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/screens/doctor/doctor_reply_screen.dart b/lib/screens/doctor/doctor_reply_screen.dart index 9047bb2d..fa5ae47d 100644 --- a/lib/screens/doctor/doctor_reply_screen.dart +++ b/lib/screens/doctor/doctor_reply_screen.dart @@ -58,8 +58,8 @@ class _DoctorReplyScreenState extends State { child: NotificationListener( child: ListView.builder( scrollDirection: Axis.vertical, + itemCount: model.listDoctorWorkingHoursTable.length, shrinkWrap: true, - itemBuilder: (BuildContext ctxt, int index) { return Column( children: [ @@ -83,20 +83,20 @@ class _DoctorReplyScreenState extends State { reply: model .listDoctorWorkingHoursTable[index]), ), - if(model.state == ViewState.BusyLocal &&index ==model.listDoctorWorkingHoursTable.length-1) + if(model.state == ViewState.BusyLocal && index == model.listDoctorWorkingHoursTable.length-1) DrAppCircularProgressIndeicator() ], ); }), - onNotification: (t) { + onNotification: (t) { if (t is ScrollEndNotification && model.state != ViewState.BusyLocal) { print("${model.state}"); - setState(() { - pageIndex++; - }); - model.getDoctorReply(pageIndex: pageIndex); + // setState(() { + // pageIndex++; + // }); + model.getDoctorReply(pageIndex: 2); } return; }, From bf12203e816fceccb150164a8b8154ab61d1bbd3 Mon Sep 17 00:00:00 2001 From: Elham Rababh Date: Wed, 25 Aug 2021 11:27:39 +0300 Subject: [PATCH 6/7] fix error happen while scrolling --- lib/screens/doctor/doctor_reply_screen.dart | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/screens/doctor/doctor_reply_screen.dart b/lib/screens/doctor/doctor_reply_screen.dart index fa5ae47d..2d74a2cc 100644 --- a/lib/screens/doctor/doctor_reply_screen.dart +++ b/lib/screens/doctor/doctor_reply_screen.dart @@ -92,10 +92,9 @@ class _DoctorReplyScreenState extends State { onNotification: (t) { if (t is ScrollEndNotification && model.state != ViewState.BusyLocal) { - print("${model.state}"); - // setState(() { - // pageIndex++; - // }); + setState(() { + pageIndex++; + }); model.getDoctorReply(pageIndex: 2); } return; From 076301e91a21b60d46191cd59e51f8ea8c4ca516 Mon Sep 17 00:00:00 2001 From: Elham Rababh Date: Wed, 25 Aug 2021 11:28:20 +0300 Subject: [PATCH 7/7] fix error happen while scrolling --- lib/screens/doctor/doctor_reply_screen.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/screens/doctor/doctor_reply_screen.dart b/lib/screens/doctor/doctor_reply_screen.dart index 2d74a2cc..e56360e7 100644 --- a/lib/screens/doctor/doctor_reply_screen.dart +++ b/lib/screens/doctor/doctor_reply_screen.dart @@ -95,7 +95,7 @@ class _DoctorReplyScreenState extends State { setState(() { pageIndex++; }); - model.getDoctorReply(pageIndex: 2); + model.getDoctorReply(pageIndex: pageIndex); } return; },