diff --git a/lib/UpdatePage.dart b/lib/UpdatePage.dart index ee866c64..5633d901 100644 --- a/lib/UpdatePage.dart +++ b/lib/UpdatePage.dart @@ -10,12 +10,11 @@ import 'package:url_launcher/url_launcher.dart'; import 'widgets/shared/buttons/secondary_button.dart'; class UpdatePage extends StatelessWidget { - final String message; - final String androidLink; - final String iosLink; + final String? message; + final String? androidLink; + final String? iosLink; - const UpdatePage({Key ? key, this.message, this.androidLink, this.iosLink}) - : super(key: key); + const UpdatePage({Key? key, this.message, this.androidLink, this.iosLink}) : super(key: key); @override Widget build(BuildContext context) { @@ -35,7 +34,7 @@ class UpdatePage extends StatelessWidget { Image.asset('assets/images/HMG_logo.png'), SizedBox(height: 8,), AppText( - TranslationBase.of(context).updateTheApp.toUpperCase(),fontSize: 17, + TranslationBase.of(context).updateTheApp!.toUpperCase(),fontSize: 17, fontWeight: FontWeight.w600, ), SizedBox(height: 12,), @@ -55,11 +54,11 @@ class UpdatePage extends StatelessWidget { color: Colors.red[800], onTap: () { if (Platform.isIOS) - launch(iosLink); + launch(iosLink!); else - launch(androidLink); + launch(androidLink!); }, - label: TranslationBase.of(context).updateNow.toUpperCase(), + label: TranslationBase.of(context).updateNow!.toUpperCase(), ), ), ), diff --git a/lib/core/viewModel/patient-referral-viewmodel.dart b/lib/core/viewModel/patient-referral-viewmodel.dart index 51a110ff..01fec57f 100644 --- a/lib/core/viewModel/patient-referral-viewmodel.dart +++ b/lib/core/viewModel/patient-referral-viewmodel.dart @@ -293,15 +293,15 @@ class PatientReferralViewModel extends BaseViewModel { String getReferralStatusNameByCode(int statusCode, BuildContext context) { switch (statusCode) { case 1: - return TranslationBase.of(context).referralStatusHold /*pending*/; + return TranslationBase.of(context).referralStatusHold! /*pending*/; case 2: - return TranslationBase.of(context).referralStatusActive /* accepted*/; + return TranslationBase.of(context).referralStatusActive! /* accepted*/; case 4: - return TranslationBase.of(context).referralStatusCancelled /*rejected*/; + return TranslationBase.of(context).referralStatusCancelled! /*rejected*/; case 46: - return TranslationBase.of(context).referralStatusCompleted /*accepted*/; + return TranslationBase.of(context).referralStatusCompleted! /*accepted*/; case 63: - return TranslationBase.of(context).rejected /*referralStatusNotSeen*/; + return TranslationBase.of(context).rejected! /*referralStatusNotSeen*/; default: return "-"; } diff --git a/lib/landing_page.dart b/lib/landing_page.dart index 169f97a3..84b424ab 100644 --- a/lib/landing_page.dart +++ b/lib/landing_page.dart @@ -8,7 +8,6 @@ import 'package:doctor_app_flutter/widgets/shared/app_drawer_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/bottom_nav_bar.dart'; -import 'package:doctor_app_flutter/widgets/shared/user-guid/app_showcase_widget.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; @@ -21,7 +20,7 @@ class LandingPage extends StatefulWidget { class _LandingPageState extends State { int currentTab = 0; - PageController pageController; + late PageController pageController; _changeCurrentTab(int tab) { setState(() { diff --git a/lib/models/patient/profile/patient_profile_app_bar_model.dart b/lib/models/patient/profile/patient_profile_app_bar_model.dart new file mode 100644 index 00000000..97862aaa --- /dev/null +++ b/lib/models/patient/profile/patient_profile_app_bar_model.dart @@ -0,0 +1,91 @@ +import '../patiant_info_model.dart'; + +class PatientProfileAppBarModel { + double? height; + bool? isInpatient; + bool? isDischargedPatient; + bool? isFromLiveCare; + PatiantInformtion? patient; + String? doctorName; + String? branch; + DateTime? appointmentDate; + String? profileUrl; + String? invoiceNO; + String? orderNo; + bool? isPrescriptions; + bool? isMedicalFile; + String? episode; + String? visitDate; + String? clinic; + bool? isAppointmentHeader; + bool? isFromLabResult; + Stream ?videoCallDurationStream; + + + PatientProfileAppBarModel( + {this.height = 0.0, + this.isInpatient= false, + this.isDischargedPatient= false, + this.isFromLiveCare= false, + this.patient, + this.doctorName, + this.branch, + this.appointmentDate, + this.profileUrl, + this.invoiceNO, + this.orderNo, + this.isPrescriptions= false, + this.isMedicalFile= false, + this.episode, + this.visitDate, + this.clinic, + this.isAppointmentHeader = false, + this.isFromLabResult =false, this.videoCallDurationStream}); + + PatientProfileAppBarModel.fromJson(Map json) { + height = json['height']; + isInpatient = json['isInpatient']; + isDischargedPatient = json['isDischargedPatient']; + isFromLiveCare = json['isFromLiveCare']; + patient = json['patient']; + doctorName = json['doctorName']; + branch = json['branch']; + appointmentDate = json['appointmentDate']; + profileUrl = json['profileUrl']; + invoiceNO = json['invoiceNO']; + orderNo = json['orderNo']; + isPrescriptions = json['isPrescriptions']; + isMedicalFile = json['isMedicalFile']; + episode = json['episode']; + visitDate = json['visitDate']; + clinic = json['clinic']; + isAppointmentHeader = json['isAppointmentHeader']; + isFromLabResult = json['isFromLabResult']; + videoCallDurationStream = json['videoCallDurationStream']; + + } + + Map toJson() { + final Map data = new Map(); + data['height'] = this.height; + data['isInpatient'] = this.isInpatient; + data['isDischargedPatient'] = this.isDischargedPatient; + data['isFromLiveCare'] = this.isFromLiveCare; + data['patient'] = this.patient; + data['doctorName'] = this.doctorName; + data['branch'] = this.branch; + data['appointmentDate'] = this.appointmentDate; + data['profileUrl'] = this.profileUrl; + data['invoiceNO'] = this.invoiceNO; + data['orderNo'] = this.orderNo; + data['isPrescriptions'] = this.isPrescriptions; + data['isMedicalFile'] = this.isMedicalFile; + data['episode'] = this.episode; + data['visitDate'] = this.visitDate; + data['clinic'] = this.clinic; + data['isAppointmentHeader'] = this.isAppointmentHeader; + data['isFromLabResult'] = this.isFromLabResult; + data['videoCallDurationStream'] = this.videoCallDurationStream; + return data; + } +} diff --git a/lib/screens/patients/insurance_approval_screen_patient.dart b/lib/screens/patients/insurance_approval_screen_patient.dart index ecd153eb..8bca412d 100644 --- a/lib/screens/patients/insurance_approval_screen_patient.dart +++ b/lib/screens/patients/insurance_approval_screen_patient.dart @@ -4,6 +4,7 @@ import 'package:doctor_app_flutter/core/viewModel/InsuranceViewModel.dart'; import 'package:doctor_app_flutter/core/viewModel/project_view_model.dart'; import 'package:doctor_app_flutter/locator.dart'; import 'package:doctor_app_flutter/models/patient/patiant_info_model.dart'; +import 'package:doctor_app_flutter/models/patient/profile/patient_profile_app_bar_model.dart'; import 'package:doctor_app_flutter/screens/patients/insurance_approvals_details.dart'; import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; import 'package:doctor_app_flutter/widgets/patients/patient_service_title.dart'; @@ -18,9 +19,9 @@ import 'package:provider/provider.dart'; import '../base/base_view.dart'; class InsuranceApprovalScreenNew extends StatefulWidget { - final int appointmentNo; + final int? appointmentNo; - InsuranceApprovalScreenNew({required this.appointmentNo}); + InsuranceApprovalScreenNew({this.appointmentNo}); @override _InsuranceApprovalScreenNewState createState() => @@ -32,7 +33,7 @@ class _InsuranceApprovalScreenNewState @override Widget build(BuildContext context) { ProjectViewModel projectViewModel = Provider.of(context); - final routeArgs = ModalRoute.of(context).settings.arguments as Map; + final routeArgs = ModalRoute.of(context)!.settings.arguments as Map; PatiantInformtion patient = routeArgs['patient']; patient = routeArgs['patient']; String patientType = routeArgs['patientType']; @@ -42,18 +43,16 @@ class _InsuranceApprovalScreenNewState ? (model) => model.getInsuranceInPatient(mrn: patient.patientId) : patient.appointmentNo != null ? (model) => model.getInsuranceApproval(patient, - appointmentNo: int.parse(patient?.appointmentNo.toString()), - projectId: patient.projectId) + appointmentNo: int.parse(patient.appointmentNo.toString()), projectId: patient.projectId) : (model) => model.getInsuranceApproval(patient), - builder: (BuildContext context, InsuranceViewModel model, Widget child) => - AppScaffold( - appBar: PatientProfileAppBar( - patient, + builder: (BuildContext context, InsuranceViewModel model, Widget? child) => AppScaffold( + patientProfileAppBarModel: PatientProfileAppBarModel( + patient: patient, isInpatient: isInpatient, ), isShowAppBar: true, baseViewModel: model, - appBarTitle: TranslationBase.of(context).approvals, + appBarTitle: TranslationBase.of(context).approvals ?? "", body: patient.admissionNo != null ? SingleChildScrollView( child: Container( @@ -67,8 +66,8 @@ class _InsuranceApprovalScreenNewState crossAxisAlignment: CrossAxisAlignment.start, children: [ ServiceTitle( - title: TranslationBase.of(context).insurance22, - subTitle: TranslationBase.of(context).approvals22, + title: TranslationBase.of(context).insurance22!, + subTitle: TranslationBase.of(context).approvals22!, ), ...List.generate( model.insuranceApprovalInPatient.length, @@ -150,9 +149,9 @@ class _InsuranceApprovalScreenNewState ? Column( children: [ ServiceTitle( - title: TranslationBase.of(context).insurance22, + title: TranslationBase.of(context).insurance22!, subTitle: - TranslationBase.of(context).approvals22, + TranslationBase.of(context).approvals22!, ), ...List.generate( model.insuranceApproval.length, diff --git a/lib/widgets/dashboard/out_patient_stack.dart b/lib/widgets/dashboard/out_patient_stack.dart index 235a3646..1962549b 100644 --- a/lib/widgets/dashboard/out_patient_stack.dart +++ b/lib/widgets/dashboard/out_patient_stack.dart @@ -89,7 +89,7 @@ class GetOutPatientStack extends StatelessWidget { gradient: LinearGradient( begin: Alignment.topLeft, end: Alignment(0.0, 1.0), // 10% of the width, so there are ten blinds. - colors: [Color(0x8FF5F6FA), Colors.red[100]], // red to yellow + colors: [Color(0x8FF5F6FA), Colors.red[50]!], // red to yellow tileMode: TileMode.mirror, // repeats the gradient over the canvas ), borderRadius: BorderRadius.circular(4), diff --git a/lib/widgets/doctor/lab_result_widget.dart b/lib/widgets/doctor/lab_result_widget.dart index 0c0a4767..70723cae 100644 --- a/lib/widgets/doctor/lab_result_widget.dart +++ b/lib/widgets/doctor/lab_result_widget.dart @@ -31,7 +31,7 @@ class _LabResultWidgetState extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ AppText( - TranslationBase.of(context).generalResult, + TranslationBase.of(context).generalResult!, fontSize: 2.5 * SizeConfig.textMultiplier, fontWeight: FontWeight.bold, ), diff --git a/lib/widgets/doctor/my_referral_patient_widget.dart b/lib/widgets/doctor/my_referral_patient_widget.dart index c8ce4eea..ce4db69e 100644 --- a/lib/widgets/doctor/my_referral_patient_widget.dart +++ b/lib/widgets/doctor/my_referral_patient_widget.dart @@ -102,7 +102,7 @@ class _MyReferralPatientWidgetState extends State { Row( children: [ AppText( - TranslationBase.of(context).fileNo, + TranslationBase.of(context).fileNo!, fontSize: 1.7 * SizeConfig.textMultiplier, fontWeight: FontWeight.bold, textAlign: TextAlign.start, @@ -170,7 +170,7 @@ class _MyReferralPatientWidgetState extends State { ), SizedBox( child: AppText( - TranslationBase.of(context).referralDoctor, + TranslationBase.of(context).referralDoctor!, fontSize: 1.9 * SizeConfig.textMultiplier, fontWeight: FontWeight.bold, textAlign: TextAlign.start, @@ -213,7 +213,7 @@ class _MyReferralPatientWidgetState extends State { ), SizedBox( child: AppText( - TranslationBase.of(context).referringClinic, + TranslationBase.of(context).referringClinic!, fontSize: 1.9 * SizeConfig.textMultiplier, fontWeight: FontWeight.bold, textAlign: TextAlign.start, @@ -268,7 +268,7 @@ class _MyReferralPatientWidgetState extends State { ), SizedBox( child: AppText( - TranslationBase.of(context).frequency, + TranslationBase.of(context).frequency!, fontSize: 1.9 * SizeConfig.textMultiplier, fontWeight: FontWeight.bold, textAlign: TextAlign.start, @@ -311,7 +311,7 @@ class _MyReferralPatientWidgetState extends State { ), SizedBox( child: AppText( - TranslationBase.of(context).maxResponseTime, + TranslationBase.of(context).maxResponseTime!, fontSize: 1.9 * SizeConfig.textMultiplier, fontWeight: FontWeight.bold, textAlign: TextAlign.start, @@ -365,8 +365,8 @@ class _MyReferralPatientWidgetState extends State { ), SizedBox( child: AppText( - TranslationBase.of(context) - .clinicDetailsandRemarks, + TranslationBase.of(context)! + .clinicDetailsandRemarks!, fontSize: 1.9 * SizeConfig.textMultiplier, fontWeight: FontWeight.bold, textAlign: TextAlign.start, @@ -414,7 +414,7 @@ class _MyReferralPatientWidgetState extends State { controller: answerController, maxLines: 3, minLines: 2, - hintText: TranslationBase.of(context).answerThePatient, + hintText: TranslationBase.of(context).answerThePatient!, fontWeight: FontWeight.normal, readOnly: _isLoading, validator: (value) { @@ -431,7 +431,7 @@ class _MyReferralPatientWidgetState extends State { width: double.infinity, margin: EdgeInsets.only(left: 10, right: 10), child: AppButton( - title : TranslationBase.of(context).replay, + title : TranslationBase.of(context).replay!, onPressed: () async { final form = _formKey.currentState; if (form!.validate()) { diff --git a/lib/widgets/patients/patient-referral-item-widget.dart b/lib/widgets/patients/patient-referral-item-widget.dart index 0e077895..e3e784d5 100644 --- a/lib/widgets/patients/patient-referral-item-widget.dart +++ b/lib/widgets/patients/patient-referral-item-widget.dart @@ -11,24 +11,24 @@ import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; class PatientReferralItemWidget extends StatelessWidget { - final String referralStatus; - final int referralStatusCode; - final String patientName; - final int patientGender; - final String referredDate; - final String referredTime; - final String patientID; + final String? referralStatus; + final int? referralStatusCode; + final String? patientName; + final int? patientGender; + final String? referredDate; + final String? referredTime; + final String? patientID; final isSameBranch; - final bool isReferral; - final bool isReferralClinic; - final String referralClinic; - final String remark; - final String nationality; - final String nationalityFlag; - final String doctorAvatar; - final String referralDoctorName; - final String clinicDescription; - final Widget infoIcon; + final bool? isReferral; + final bool? isReferralClinic; + final String? referralClinic; + final String? remark; + final String? nationality; + final String? nationalityFlag; + final String? doctorAvatar; + final String? referralDoctorName; + final String? clinicDescription; + final Widget? infoIcon; PatientReferralItemWidget( {this.referralStatus, @@ -67,8 +67,8 @@ class PatientReferralItemWidget extends StatelessWidget { : referralStatusCode == 46 ? AppGlobal.appGreenColor : referralStatusCode == 4 - ? Colors.red[700] - : Colors.red[900], + ? Colors.red[700]! + : Colors.red[900]!, hasBorder: false, widget: Container( // padding: EdgeInsets.only(left: 20, right: 0, bottom: 0), @@ -80,7 +80,7 @@ class PatientReferralItemWidget extends StatelessWidget { mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ AppText( - referralStatus != null ? referralStatus : "", + referralStatus != null ? referralStatus! : "", fontFamily: 'Poppins', fontSize: 10.0, letterSpacing: -0.4, @@ -92,11 +92,11 @@ class PatientReferralItemWidget extends StatelessWidget { : referralStatusCode == 46 ? AppGlobal.appGreenColor : referralStatusCode == 4 - ? Colors.red[700] - : Colors.red[900], + ? Colors.red[700]! + : Colors.red[900]!, ), AppText( - referredDate, + referredDate!, fontFamily: 'Poppins', fontWeight: FontWeight.w600, letterSpacing: -0.48, @@ -110,7 +110,7 @@ class PatientReferralItemWidget extends StatelessWidget { children: [ Expanded( child: AppText( - patientName, + patientName!, fontSize: 16.0, fontWeight: FontWeight.w600, color: Color(0xff2E303A), @@ -132,7 +132,7 @@ class PatientReferralItemWidget extends StatelessWidget { width: 4, ), AppText( - referredTime, + referredTime!, fontFamily: 'Poppins', fontWeight: FontWeight.w600, fontSize: 12.0, @@ -153,8 +153,8 @@ class PatientReferralItemWidget extends StatelessWidget { children: [ CustomRow( label: - TranslationBase.of(context).fileNumber, - value: patientID, + TranslationBase.of(context).fileNumber!, + value: patientID!, ), ], ), @@ -165,15 +165,15 @@ class PatientReferralItemWidget extends StatelessWidget { CustomRow( label: isSameBranch ? TranslationBase.of(context) - .referredFrom - : TranslationBase.of(context).refClinic, - value: !isReferralClinic + .referredFrom! + : TranslationBase.of(context).refClinic!, + value: !isReferralClinic! ? isSameBranch ? TranslationBase.of(context) - .sameBranch + .sameBranch! : TranslationBase.of(context) - .otherBranch - : " " + referralClinic, + .otherBranch! + : " " + referralClinic!, ), ], ), @@ -183,7 +183,7 @@ class PatientReferralItemWidget extends StatelessWidget { Row( children: [ AppText( - nationality != null ? nationality : "", + nationality != null ? nationality! : "", fontWeight: FontWeight.w600, color: Color(0xFF2E303A), fontSize: 10.0, @@ -193,12 +193,10 @@ class PatientReferralItemWidget extends StatelessWidget { ? ClipRRect( borderRadius: BorderRadius.circular(20.0), child: Image.network( - nationalityFlag, + nationalityFlag!, height: 25, width: 30, - errorBuilder: (BuildContext context, - Object exception, - StackTrace stackTrace) { + errorBuilder: (BuildContext context, Object exception, StackTrace? stackTrace) { return Text(''); }, )) @@ -212,7 +210,7 @@ class PatientReferralItemWidget extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.start, children: [ CustomRow( - label: TranslationBase.of(context).remarks + " : ", + label: TranslationBase.of(context).remarks! + " : ", value: remark ?? "", ), ], @@ -223,7 +221,7 @@ class PatientReferralItemWidget extends StatelessWidget { Container( margin: EdgeInsets.only(left: 10, right: 0), child: Image.asset( - isReferral + isReferral! ? 'assets/images/patient/ic_ref_arrow_up.png' : 'assets/images/patient/ic_ref_arrow_left.png', height: 50, @@ -241,12 +239,10 @@ class PatientReferralItemWidget extends StatelessWidget { ? ClipRRect( borderRadius: BorderRadius.circular(20.0), child: Image.network( - doctorAvatar, + doctorAvatar!, height: 25, width: 30, - errorBuilder: (BuildContext context, - Object exception, - StackTrace stackTrace) { + errorBuilder: (BuildContext context, Object exception, StackTrace? stackTrace) { return Text('No Image'); }, )) @@ -278,7 +274,7 @@ class PatientReferralItemWidget extends StatelessWidget { ), if (clinicDescription != null) AppText( - clinicDescription, + clinicDescription??"", fontFamily: 'Poppins', fontWeight: FontWeight.w600, fontSize: 10.0, diff --git a/lib/widgets/patients/patient_card/PatientCard.dart b/lib/widgets/patients/patient_card/PatientCard.dart index 5df10470..30204dbf 100644 --- a/lib/widgets/patients/patient_card/PatientCard.dart +++ b/lib/widgets/patients/patient_card/PatientCard.dart @@ -76,7 +76,7 @@ class PatientCard extends StatelessWidget { : isInpatient ? Colors.white : !isFromSearch - ? Colors.red[800] + ? Colors.red[800]! : Colors.white, widget: Container( decoration: BoxDecoration( @@ -134,8 +134,8 @@ class PatientCard extends StatelessWidget { PatientStatus( label: TranslationBase.of(context) - .notArrived, - color: Colors.red[800], + .notArrived!, + color: Colors.red[800]!, ), SizedBox( width: 8, @@ -169,8 +169,8 @@ class PatientCard extends StatelessWidget { PatientStatus( label: TranslationBase.of( context) - .notArrived, - color: Colors.red[800], + .notArrived!, + color: Colors.red[800]!, ), SizedBox( width: 8, @@ -202,8 +202,8 @@ class PatientCard extends StatelessWidget { this.arrivalType == '1' ? AppText( patientInfo.startTime != null - ? patientInfo.startTime - : patientInfo.startTimes, + ? patientInfo.startTime! + : patientInfo.startTimes!, fontFamily: 'Poppins', fontWeight: FontWeight.w400, ) @@ -212,7 +212,7 @@ class PatientCard extends StatelessWidget { padding: EdgeInsets.only(right: 9), child: AppText( - "${AppDateUtils.getStartTime(patientInfo.startTime)}", + "${AppDateUtils.getStartTime(patientInfo.startTime!)}", fontFamily: 'Poppins', fontWeight: FontWeight.w600, fontSize: 11, @@ -222,11 +222,11 @@ class PatientCard extends StatelessWidget { : (patientInfo.appointmentDate != null && patientInfo - .appointmentDate.isNotEmpty) + .appointmentDate!.isNotEmpty!) ? Container( padding: EdgeInsets.only(right: 9), child: AppText( - " ${AppDateUtils.getStartTime(patientInfo.startTime)}", + " ${AppDateUtils.getStartTime(patientInfo!.startTime!)}", fontFamily: 'Poppins', fontWeight: FontWeight.w600, fontSize: 11, @@ -296,7 +296,7 @@ class PatientCard extends StatelessWidget { ), ]), ), - if (nationalityName.isNotEmpty) + if (nationalityName!.isNotEmpty) Expanded( child: Row( mainAxisAlignment: MainAxisAlignment.end, @@ -381,14 +381,14 @@ class PatientCard extends StatelessWidget { // SizedBox(height: 10,), CustomRow( label: TranslationBase.of(context) - .fileNumber, + .fileNumber!, value: patientInfo.patientId.toString(), ), CustomRow( - label: TranslationBase.of(context).age + + label: TranslationBase.of(context).age! + " : ", value: - "${AppDateUtils.getAgeByBirthday(patientInfo.dateofBirth, context, isServerFormat: !isFromLiveCare)}", + "${AppDateUtils.getAgeByBirthday(patientInfo!.dateofBirth!, context, isServerFormat: !isFromLiveCare)}", ), patientInfo.arrivedOn != null @@ -416,13 +416,13 @@ class PatientCard extends StatelessWidget { CustomRow( label: TranslationBase.of( context) - .arrivedP + + .arrivedP! + " : ", value: AppDateUtils .getDayMonthYearDateFormatted( AppDateUtils .convertStringToDate( - patientInfo.arrivedOn, + patientInfo!.arrivedOn!, ), isMonthShort: true, ), @@ -431,7 +431,7 @@ class PatientCard extends StatelessWidget { ) : (patientInfo.appointmentDate != null && - patientInfo.appointmentDate + patientInfo!.appointmentDate! .isNotEmpty) ? Column( crossAxisAlignment: @@ -442,11 +442,11 @@ class PatientCard extends StatelessWidget { CustomRow( label: TranslationBase.of( context) - .appointmentDate + + .appointmentDate! + " : ", value: "${AppDateUtils.getDayMonthYearDateFormatted(AppDateUtils.convertStringToDate( - patientInfo - .appointmentDate, + patientInfo! + .appointmentDate!, ), isMonthShort: true)}", ), ], @@ -459,7 +459,7 @@ class PatientCard extends StatelessWidget { patientInfo.admissionDate == null ? "" : TranslationBase.of(context) - .admissionDate + + .admissionDate! + " : ", value: patientInfo.admissionDate == null @@ -469,15 +469,15 @@ class PatientCard extends StatelessWidget { if (patientInfo.admissionDate != null) CustomRow( label: TranslationBase.of(context) - .numOfDays + + .numOfDays!+ " : ", value: - "${DateTime.now().difference(AppDateUtils.getDateTimeFromServerFormat(patientInfo.admissionDate)).inDays + 1}", + "${DateTime.now().difference(AppDateUtils.getDateTimeFromServerFormat(patientInfo!.admissionDate!)).inDays + 1}", ), if (patientInfo.admissionDate != null) CustomRow( label: TranslationBase.of(context) - .clinicName + + .clinicName! + " : ", value: "${patientInfo.clinicDescription}", @@ -485,7 +485,7 @@ class PatientCard extends StatelessWidget { if (patientInfo.admissionDate != null) CustomRow( label: TranslationBase.of(context) - .roomNo + + .roomNo! + " : ", value: "${patientInfo.roomId}", ), @@ -494,9 +494,9 @@ class PatientCard extends StatelessWidget { children: [ CustomRow( label: TranslationBase.of(context) - .clinic + + .clinic! + " : ", - value: patientInfo.clinicName, + value: patientInfo!.clinicName!, ), ], ), @@ -580,13 +580,13 @@ class PatientStatus extends StatelessWidget { this.label, this.color, }) : super(key: key); - final String label; - final Color color; + final String? label; + final Color? color; @override Widget build(BuildContext context) { return AppText( - label, + label??"", color: color ?? AppGlobal.appGreenColor, fontWeight: FontWeight.w600, fontFamily: 'Poppins', diff --git a/lib/widgets/patients/patient_card/ShowTimer.dart b/lib/widgets/patients/patient_card/ShowTimer.dart index fba1a52a..165bbbd9 100644 --- a/lib/widgets/patients/patient_card/ShowTimer.dart +++ b/lib/widgets/patients/patient_card/ShowTimer.dart @@ -9,7 +9,7 @@ class ShowTimer extends StatefulWidget { const ShowTimer({ - Key ? key, this.patientInfo, + Key? key, required this.patientInfo, }) : super(key: key); @override @@ -50,7 +50,7 @@ class _ShowTimerState extends State { generateShowTimerString() { DateTime now = DateTime.now(); - DateTime liveCareDate = DateTime.parse(widget.patientInfo.arrivalTime); + DateTime liveCareDate = DateTime.parse(widget.patientInfo!.arrivalTime!); String timer = AppDateUtils.differenceBetweenDateAndCurrent( liveCareDate, context, isShowSecond: true, isShowDays: false); diff --git a/lib/widgets/patients/profile/PatientProfileButton.dart b/lib/widgets/patients/profile/PatientProfileButton.dart index bafd45c9..a9e7b60b 100644 --- a/lib/widgets/patients/profile/PatientProfileButton.dart +++ b/lib/widgets/patients/profile/PatientProfileButton.dart @@ -11,35 +11,35 @@ import 'package:provider/provider.dart'; // ignore: must_be_immutable class PatientProfileButton extends StatelessWidget { - final String nameLine1; - final String nameLine2; + final String? nameLine1; + final String? nameLine2; final String icon; final dynamic route; final PatiantInformtion patient; final String patientType; String arrivalType; final bool isInPatient; - String from; - String to; + String? from; + String? to; final String url = "assets/images/"; final bool isDisable; final bool isLoading; - final Function onTap; + final GestureTapCallback? onTap; final bool isDischargedPatient; final bool isSelectInpatient; final bool isDartIcon; - final IconData dartIcon; - final bool isFromLiveCare; - final Color color; + final IconData? dartIcon; + final bool? isFromLiveCare; + final Color? color; PatientProfileButton({ - Key ? key, - this.patient, - this.patientType, - this.arrivalType, - this.nameLine1, - this.nameLine2, - this.icon, + Key? key, + required this.patient, + required this.patientType, + required this.arrivalType, + this.nameLine1, + this.nameLine2, + required this.icon, this.route, this.isDisable = false, this.onTap, @@ -100,7 +100,7 @@ class PatientProfileButton extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.start, children: [ AppText( - !projectsProvider.isArabic ? this.nameLine1 : nameLine2, + !projectsProvider.isArabic ? this.nameLine1! : nameLine2!??'', color: color ?? AppGlobal.appTextColor, letterSpacing: -0.33, fontWeight: FontWeight.w600, @@ -108,7 +108,7 @@ class PatientProfileButton extends StatelessWidget { fontSize: SizeConfig.textMultiplier * 1.30, ), AppText( - !projectsProvider.isArabic ? this.nameLine2 : nameLine1, + !projectsProvider.isArabic ? this.nameLine2! : nameLine1!??'', color: color ?? Color(0xFF2B353E), fontWeight: FontWeight.w600, textAlign: TextAlign.left, diff --git a/lib/widgets/patients/profile/add-order/addNewOrder.dart b/lib/widgets/patients/profile/add-order/addNewOrder.dart index 1b9441dd..8b643536 100644 --- a/lib/widgets/patients/profile/add-order/addNewOrder.dart +++ b/lib/widgets/patients/profile/add-order/addNewOrder.dart @@ -3,12 +3,12 @@ import 'package:flutter/material.dart'; class AddNewOrder extends StatelessWidget { const AddNewOrder({ - Key ? key, - this.onTap, - this.label, + Key? key, + required this.onTap, + required this.label, }) : super(key: key); - final Function onTap; + final GestureTapCallback onTap; final String label; @override diff --git a/lib/widgets/patients/profile/large_avatar.dart b/lib/widgets/patients/profile/large_avatar.dart index bc50c07b..03ad1362 100644 --- a/lib/widgets/patients/profile/large_avatar.dart +++ b/lib/widgets/patients/profile/large_avatar.dart @@ -5,8 +5,8 @@ import 'package:flutter/material.dart'; class LargeAvatar extends StatelessWidget { LargeAvatar( - {Key ? key, - this.name, + {Key? key, + required this.name, this.url, this.disableProfileView: false, this.radius = 60.0, @@ -15,14 +15,14 @@ class LargeAvatar extends StatelessWidget { : super(key: key); final String name; - final String url; + final String? url; final bool disableProfileView; final double radius; final double width; final double height; Widget _getAvatar() { - if (url != null && url.isNotEmpty && Uri.parse(url).isAbsolute) { + if (url != null && url!.isNotEmpty && Uri.parse(url!).isAbsolute) { return CircleAvatar( radius: SizeConfig.imageSizeMultiplier * 12, @@ -71,8 +71,8 @@ class LargeAvatar extends StatelessWidget { begin: Alignment(-1, -1), end: Alignment(1, 1), colors: [ - Colors.grey[100], - Colors.grey[800], + Colors.grey[100]!, + Colors.grey[800]!, ]), boxShadow: [ BoxShadow( 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 46b8ed7f..323e75b9 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 @@ -24,7 +24,7 @@ class PatientProfileHeaderNewDesignAppBar extends StatelessWidget final bool isDischargedPatient; final bool isFromLiveCare; - final Stream videoCallDurationStream; + final Stream? videoCallDurationStream; PatientProfileHeaderNewDesignAppBar( this.patient, this.patientType, this.arrivalType, @@ -38,9 +38,9 @@ class PatientProfileHeaderNewDesignAppBar extends StatelessWidget Widget build(BuildContext context) { int gender = 1; if (patient.patientDetails != null) { - gender = patient.patientDetails.gender; + gender = patient.patientDetails!.gender!; } else { - gender = patient.gender; + gender = patient!.gender!; } return Container( padding: EdgeInsets.only( @@ -76,7 +76,7 @@ class PatientProfileHeaderNewDesignAppBar extends StatelessWidget " " + Helpers.capitalize(patient.lastName)) : Helpers.capitalize(patient.fullName ?? - patient.patientDetails.fullName), + patient.patientDetails!.fullName!), fontSize: SizeConfig.textMultiplier * 1.8, fontWeight: FontWeight.bold, fontFamily: 'Poppins', @@ -99,7 +99,7 @@ class PatientProfileHeaderNewDesignAppBar extends StatelessWidget eventCategory: "Patient Profile Header", eventAction: "Call Patient", ); - launch("tel://" + patient.mobileNumber); + launch("tel://" + patient!.mobileNumber!); }, child: Icon( Icons.phone, @@ -121,7 +121,7 @@ class PatientProfileHeaderNewDesignAppBar extends StatelessWidget padding: EdgeInsets.symmetric(vertical: 2, horizontal: 10), child: Text( - snapshot.data, + snapshot!.data!, style: TextStyle(color: Colors.white), ), ), @@ -161,15 +161,15 @@ class PatientProfileHeaderNewDesignAppBar extends StatelessWidget children: [ patient.patientStatusType == 43 ? AppText( - TranslationBase.of(context).arrivedP, + TranslationBase.of(context).arrivedP!, color: AppGlobal.appGreenColor, fontWeight: FontWeight.bold, fontFamily: 'Poppins', fontSize: 12, ) : AppText( - TranslationBase.of(context).notArrived, - color: Colors.red[800], + TranslationBase.of(context).notArrived!, + color: Colors.red[800]!, fontWeight: FontWeight.bold, fontFamily: 'Poppins', fontSize: 12, @@ -177,7 +177,7 @@ class PatientProfileHeaderNewDesignAppBar extends StatelessWidget arrivalType == '1' || patient.arrivedOn == null ? AppText( patient.startTime != null - ? patient.startTime + ? patient.startTime! : '', fontFamily: 'Poppins', fontWeight: FontWeight.w600, @@ -186,7 +186,7 @@ class PatientProfileHeaderNewDesignAppBar extends StatelessWidget patient.arrivedOn != null ? AppDateUtils .convertStringToDateFormat( - patient.arrivedOn, + patient!.arrivedOn!, 'MM-dd-yyyy HH:mm') : '', fontFamily: 'Poppins', @@ -203,7 +203,7 @@ class PatientProfileHeaderNewDesignAppBar extends StatelessWidget mainAxisAlignment: MainAxisAlignment.start, children: [ AppText( - TranslationBase.of(context).appointmentDate + + TranslationBase.of(context).appointmentDate!+ " : ", fontSize: 14, ), @@ -273,12 +273,12 @@ class PatientProfileHeaderNewDesignAppBar extends StatelessWidget ? ClipRRect( borderRadius: BorderRadius.circular(20.0), child: Image.network( - patient.nationalityFlagURL, + patient!.nationalityFlagURL!, height: 25, width: 30, - errorBuilder: (BuildContext context, - Object exception, - StackTrace stackTrace) { + errorBuilder: (BuildContext? context, + Object? exception, + StackTrace? stackTrace) { return Text(''); }, )) @@ -289,9 +289,9 @@ class PatientProfileHeaderNewDesignAppBar extends StatelessWidget ], ), HeaderRow( - label: TranslationBase.of(context).age + " : ", + label: TranslationBase.of(context).age! + " : ", value: - "${AppDateUtils.getAgeByBirthday(patient.patientDetails != null ? patient.patientDetails.dateofBirth ?? "" : patient.dateofBirth ?? "", context, isServerFormat: !isFromLiveCare)}", + "${AppDateUtils.getAgeByBirthday(patient.patientDetails != null ? patient.patientDetails!.dateofBirth ?? "" : patient.dateofBirth ?? "", context, isServerFormat: !isFromLiveCare)}", ), if (isInpatient) Column( @@ -300,7 +300,7 @@ class PatientProfileHeaderNewDesignAppBar extends StatelessWidget HeaderRow( label: patient.admissionDate == null ? "" - : TranslationBase.of(context).admissionDate + + : TranslationBase.of(context).admissionDate! + " : ", value: patient.admissionDate == null ? "" @@ -310,8 +310,8 @@ class PatientProfileHeaderNewDesignAppBar extends StatelessWidget 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}", + ? "${AppDateUtils.getDateTimeFromServerFormat(patient!.dischargeDate!).difference(AppDateUtils.getDateTimeFromServerFormat(patient.admissionDate!)).inDays + 1}" + : "${DateTime.now().difference(AppDateUtils.getDateTimeFromServerFormat(patient!.admissionDate!)).inDays + 1}", ) ], ) @@ -343,7 +343,7 @@ class PatientProfileHeaderNewDesignAppBar extends StatelessWidget date.day.toString().padLeft(2, '0'); } - return newDate ?? ''; + return newDate??''; } isToday(date) { diff --git a/lib/widgets/patients/profile/prescription_in_patinets_widget.dart b/lib/widgets/patients/profile/prescription_in_patinets_widget.dart index 171ff4f5..dd6d869e 100644 --- a/lib/widgets/patients/profile/prescription_in_patinets_widget.dart +++ b/lib/widgets/patients/profile/prescription_in_patinets_widget.dart @@ -14,8 +14,7 @@ import 'large_avatar.dart'; class PrescriptionInPatientWidget extends StatelessWidget { final List prescriptionReportForInPatientList; - PrescriptionInPatientWidget( - {Key ? key, this.prescriptionReportForInPatientList}); + PrescriptionInPatientWidget({Key? key, required this.prescriptionReportForInPatientList}); @override Widget build(BuildContext context) { @@ -43,13 +42,13 @@ class PrescriptionInPatientWidget extends StatelessWidget { ), Padding( child: AppText( - TranslationBase.of(context).noPrescription, + TranslationBase.of(context).noPrescription!, fontWeight: FontWeight.bold, ), padding: EdgeInsets.all(10), ), AppText( - TranslationBase.of(context).applyNow, + TranslationBase.of(context).applyNow!, fontWeight: FontWeight.bold, color: HexColor('#B8382C'), ) @@ -78,9 +77,7 @@ class PrescriptionInPatientWidget extends StatelessWidget { Row( children: [ LargeAvatar( - name: - prescriptionReportForInPatientList[index] - .createdByName, + name: prescriptionReportForInPatientList[index].createdByName ?? "", radius: 10, width: 70, ), diff --git a/lib/widgets/patients/profile/prescription_out_patinets_widget.dart b/lib/widgets/patients/profile/prescription_out_patinets_widget.dart index 920065d9..81a6d629 100644 --- a/lib/widgets/patients/profile/prescription_out_patinets_widget.dart +++ b/lib/widgets/patients/profile/prescription_out_patinets_widget.dart @@ -14,7 +14,7 @@ import 'large_avatar.dart'; class PrescriptionOutPatientWidget extends StatelessWidget { final List patientPrescriptionsList; - PrescriptionOutPatientWidget({Key ? key, this.patientPrescriptionsList}); + PrescriptionOutPatientWidget({Key? key, required this.patientPrescriptionsList}); @override Widget build(BuildContext context) { @@ -42,13 +42,13 @@ class PrescriptionOutPatientWidget extends StatelessWidget { ), Padding( child: AppText( - TranslationBase.of(context).noPrescription, + TranslationBase.of(context).noPrescription!, fontWeight: FontWeight.bold, ), padding: EdgeInsets.all(10), ), AppText( - TranslationBase.of(context).applyNow, + TranslationBase.of(context).applyNow!, fontWeight: FontWeight.bold, color: HexColor('#B8382C'), ) @@ -82,10 +82,8 @@ class PrescriptionOutPatientWidget extends StatelessWidget { Row( children: [ LargeAvatar( - url: patientPrescriptionsList[index] - .doctorImageURL, - name: patientPrescriptionsList[index] - .doctorName, + url: patientPrescriptionsList[index].doctorImageURL, + name: patientPrescriptionsList[index].doctorName ?? "", radius: 10, width: 70, ), diff --git a/lib/widgets/patients/profile/profile-welcome-widget.dart b/lib/widgets/patients/profile/profile-welcome-widget.dart index fc859526..52762560 100644 --- a/lib/widgets/patients/profile/profile-welcome-widget.dart +++ b/lib/widgets/patients/profile/profile-welcome-widget.dart @@ -34,7 +34,7 @@ class ProfileWelcomeWidget extends StatelessWidget { child: ClipRRect( borderRadius: BorderRadius.circular(20), child: CachedNetworkImage( - imageUrl: authenticationViewModel.doctorProfile!.doctorImageURL, + imageUrl: authenticationViewModel.doctorProfile!.doctorImageURL ?? "", fit: BoxFit.fill, width: 75, height: 75, diff --git a/lib/widgets/patients/profile/profile_medical_info_widget.dart b/lib/widgets/patients/profile/profile_medical_info_widget.dart index 910e2e3a..23a0a2b5 100644 --- a/lib/widgets/patients/profile/profile_medical_info_widget.dart +++ b/lib/widgets/patients/profile/profile_medical_info_widget.dart @@ -16,7 +16,7 @@ class ProfileMedicalInfoWidget extends StatelessWidget { final bool isInpatient; ProfileMedicalInfoWidget( - {Key ? key, this.patient, this.patientType, this.arrivalType, this.from, this.to, this.isInpatient}); + {Key? key, required this.patient, required this.patientType, required this.arrivalType, required this.from, required this.to, this.isInpatient = false}); @override Widget build(BuildContext context) { diff --git a/lib/widgets/patients/profile/profile_medical_info_widget_search.dart b/lib/widgets/patients/profile/profile_medical_info_widget_search.dart index 9afa90b1..fe2e0803 100644 --- a/lib/widgets/patients/profile/profile_medical_info_widget_search.dart +++ b/lib/widgets/patients/profile/profile_medical_info_widget_search.dart @@ -8,27 +8,35 @@ import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -class ProfileMedicalInfoWidgetSearch extends StatelessWidget { +class ProfileMedicalInfoWidgetSearch extends StatefulWidget { final String? from; final String? to; final PatiantInformtion patient; final String patientType; - final String arrivalType; + final String? arrivalType; final bool isInpatient; - final bool isDischargedPatient; + final bool? isDischargedPatient; ProfileMedicalInfoWidgetSearch( - {Key ? key, - this.patient, - this.patientType, + {Key? key, + required this.patient, + required this.patientType, this.arrivalType, this.from, this.to, - this.isInpatient , + this.isInpatient = false, this.isDischargedPatient}); - TabController _tabController; + + @override + _ProfileMedicalInfoWidgetSearchState createState() => _ProfileMedicalInfoWidgetSearchState(); +} + +class _ProfileMedicalInfoWidgetSearchState extends State + with SingleTickerProviderStateMixin { + late TabController _tabController; + void initState() { - _tabController = TabController(length: 2); + _tabController = TabController(length: 2, vsync: this); } void dispose() { @@ -41,7 +49,7 @@ class ProfileMedicalInfoWidgetSearch extends StatelessWidget { onModelReady: (model) async {}, builder: (_, model, w) => DefaultTabController( length: 2, - initialIndex: isInpatient ? 0 : 1, + initialIndex: widget.isInpatient! ? 0 : 1, child: SizedBox( height: MediaQuery.of(context).size.height * 1.0, width: double.infinity, @@ -55,22 +63,21 @@ class ProfileMedicalInfoWidgetSearch extends StatelessWidget { crossAxisCount: 3, children: [ PatientProfileButton( - key: key, - patient: patient, - patientType: patientType, - arrivalType: arrivalType, - from: from, - to: to, - nameLine1: TranslationBase.of(context).vital, - nameLine2: TranslationBase.of(context).signs, + patient: widget.patient, + patientType: widget.patientType, + arrivalType: widget.arrivalType??"", + from: widget.from, + to: widget.to, + nameLine1: TranslationBase.of(context).vital??'', + nameLine2: TranslationBase.of(context).signs??'', route: VITAL_SIGN_DETAILS, icon: 'assets/images/svgs/profile_screen/vital signs.svg'), // if (selectedPatientType != 7) PatientProfileButton( - key: key, - patient: patient, - patientType: patientType, - arrivalType: arrivalType, + + patient: widget.patient, + patientType: widget.patientType, + arrivalType: widget.arrivalType??"", route: HEALTH_SUMMARY, nameLine1: "Health", //TranslationBase.of(context).medicalReport, @@ -78,128 +85,128 @@ class ProfileMedicalInfoWidgetSearch extends StatelessWidget { "Summary", //TranslationBase.of(context).summaryReport, icon: 'assets/images/svgs/profile_screen/health summary.svg'), PatientProfileButton( - key: key, - patient: patient, - patientType: patientType, - arrivalType: arrivalType, + + patient: widget.patient, + patientType: widget.patientType, + arrivalType: widget.arrivalType??"", route: LAB_RESULT, - nameLine1: TranslationBase.of(context).lab, - nameLine2: TranslationBase.of(context).result, + nameLine1: TranslationBase.of(context).lab??'', + nameLine2: TranslationBase.of(context).result??"", icon: 'assets/images/svgs/profile_screen/lab results.svg'), // if (int.parse(patientType) == 7 || int.parse(patientType) == 6) PatientProfileButton( - key: key, - patient: patient, - patientType: patientType, - arrivalType: arrivalType, - isInPatient: isInpatient, + + patient: widget.patient, + patientType: widget.patientType, + arrivalType: widget.arrivalType??"", + isInPatient: widget.isInpatient, route: RADIOLOGY_PATIENT, - nameLine1: TranslationBase.of(context).radiology, - nameLine2: TranslationBase.of(context).service, + nameLine1: TranslationBase.of(context).radiology??"", + nameLine2: TranslationBase.of(context).service??"", icon: 'assets/images/svgs/profile_screen/health summary.svg'), PatientProfileButton( - key: key, - patient: patient, - patientType: patientType, - arrivalType: arrivalType, + + patient: widget.patient, + patientType: widget.patientType, + arrivalType: widget.arrivalType??"", route: PATIENT_ECG, nameLine1: TranslationBase.of(context).patient, nameLine2: "ECG", icon: 'assets/images/svgs/profile_screen/ECG.svg'), PatientProfileButton( - key: key, - patient: patient, - patientType: patientType, - arrivalType: arrivalType, + + patient: widget.patient, + patientType: widget.patientType, + arrivalType: widget.arrivalType??"", route: ORDER_PRESCRIPTION_NEW, - nameLine1: TranslationBase.of(context).orders, - nameLine2: TranslationBase.of(context).prescription, + nameLine1: TranslationBase.of(context).orders??"", + nameLine2: TranslationBase.of(context).prescription??'', icon: 'assets/images/svgs/profile_screen/order prescription.svg'), // if (int.parse(patientType) == 7 || int.parse(patientType) == 6) PatientProfileButton( - key: key, - patient: patient, - patientType: patientType, - arrivalType: arrivalType, + + patient: widget.patient, + patientType: widget.patientType, + arrivalType: widget.arrivalType??"", route: ORDER_PROCEDURE, nameLine1: TranslationBase.of(context).orders, nameLine2: TranslationBase.of(context).procedures, icon: 'assets/images/svgs/profile_screen/Order Procedures.svg'), //if (int.parse(patientType) == 7 || int.parse(patientType) == 6) PatientProfileButton( - key: key, - patient: patient, - patientType: patientType, - arrivalType: arrivalType, + + patient: widget.patient, + patientType: widget.patientType, + arrivalType: widget.arrivalType??"", route: PATIENT_INSURANCE_APPROVALS_NEW, nameLine1: TranslationBase.of(context).insurance, nameLine2: TranslationBase.of(context).service, icon: 'assets/images/svgs/profile_screen/insurance approval.svg'), // if (int.parse(patientType) == 7 || int.parse(patientType) == 6) PatientProfileButton( - key: key, - patient: patient, - patientType: patientType, - arrivalType: arrivalType, + + patient: widget.patient, + patientType: widget.patientType, + arrivalType: widget.arrivalType??"", route: ADD_SICKLEAVE, nameLine1: TranslationBase.of(context).patientSick, nameLine2: TranslationBase.of(context).leave, icon: 'assets/images/svgs/profile_screen/patient sick leave.svg'), - if (patient.appointmentNo != null && - patient.appointmentNo != 0) + if (widget.patient.appointmentNo != null && + widget.patient.appointmentNo != 0) PatientProfileButton( - key: key, - patient: patient, - patientType: patientType, - arrivalType: arrivalType, + + patient: widget.patient, + patientType: widget.patientType, + arrivalType: widget.arrivalType??"", route: PATIENT_UCAF_REQUEST, isDisable: - patient.patientStatusType != 43 ? true : false, + widget.patient.patientStatusType != 43 ? true : false, nameLine1: TranslationBase.of(context).patient, nameLine2: TranslationBase.of(context).ucaf, icon: 'assets/images/svgs/profile_screen/UCAF.svg'), - if (patient.appointmentNo != null && - patient.appointmentNo != 0) + if (widget.patient.appointmentNo != null && + widget.patient.appointmentNo != 0) PatientProfileButton( - key: key, - patient: patient, - patientType: patientType, - arrivalType: arrivalType, + + patient: widget.patient, + patientType: widget.patientType, + arrivalType: widget.arrivalType??"", route: REFER_PATIENT_TO_DOCTOR, isDisable: - patient.patientStatusType != 43 ? true : false, + widget.patient.patientStatusType != 43 ? true : false, nameLine1: TranslationBase.of(context).referral, nameLine2: TranslationBase.of(context).patient, icon: 'assets/images/svgs/profile_screen/refer patient.svg'), - if (patient.appointmentNo != null && - patient.appointmentNo != 0) + if (widget.patient.appointmentNo != null && + widget.patient.appointmentNo != 0) PatientProfileButton( - key: key, - patient: patient, - patientType: patientType, - arrivalType: arrivalType, + + patient: widget.patient, + patientType: widget.patientType, + arrivalType: widget.arrivalType??"", route: PATIENT_ADMISSION_REQUEST, isDisable: - patient.patientStatusType != 43 ? true : false, + widget.patient.patientStatusType != 43 ? true : false, nameLine1: TranslationBase.of(context).admission, nameLine2: TranslationBase.of(context).request, icon: 'assets/images/svgs/profile_screen/admission req.svg'), - if (isInpatient) + if (widget.isInpatient) PatientProfileButton( - key: key, - patient: patient, - patientType: patientType, - arrivalType: arrivalType, + + patient: widget.patient, + patientType: widget.patientType, + arrivalType: widget.arrivalType??"", route: PROGRESS_NOTE, nameLine1: TranslationBase.of(context).progress, nameLine2: TranslationBase.of(context).note, icon: 'assets/images/svgs/profile_screen/Progress notes.svg'), - if (isInpatient) + if (widget.isInpatient) PatientProfileButton( - key: key, - patient: patient, - patientType: patientType, - arrivalType: arrivalType, + + patient: widget.patient, + patientType: widget.patientType, + arrivalType: widget.arrivalType??"", route: ORDER_NOTE, nameLine1: "Order", //"Text", nameLine2: "Sheet", diff --git a/lib/widgets/patients/vital_sign_details_wideget.dart b/lib/widgets/patients/vital_sign_details_wideget.dart index eeeb1cdc..767f1a63 100644 --- a/lib/widgets/patients/vital_sign_details_wideget.dart +++ b/lib/widgets/patients/vital_sign_details_wideget.dart @@ -12,7 +12,7 @@ class VitalSignDetailsWidget extends StatefulWidget { final String viewKey; VitalSignDetailsWidget( - {Key ? key, this.vitalList, this.title1, this.title2, this.viewKey}); + {Key? key, required this.vitalList, required this.title1, required this.title2, required this.viewKey}); @override _VitalSignDetailsWidgetState createState() => _VitalSignDetailsWidgetState(); @@ -38,7 +38,7 @@ class _VitalSignDetailsWidgetState extends State { children: [ Table( border: TableBorder.symmetric( - inside: BorderSide(width: 2.0,color: Colors.grey[300]), + inside: BorderSide(width: 2.0, color: Colors.grey[300]!), ), children: fullData(), ), @@ -90,7 +90,7 @@ class _VitalSignDetailsWidgetState extends State { color: Colors.white, child: Center( child: AppText( - '${AppDateUtils.getWeekDay(vital.vitalSignDate.weekday)}, ${vital.vitalSignDate.day} ${AppDateUtils.getMonth(vital.vitalSignDate.month)}, ${vital.vitalSignDate.year} ', + '${AppDateUtils.getWeekDay(vital.vitalSignDate!.weekday!)}, ${vital.vitalSignDate!.day} ${AppDateUtils.getMonth(vital.vitalSignDate!.month)}, ${vital.vitalSignDate!.year} ', textAlign: TextAlign.center, ), ), diff --git a/lib/widgets/shared/StarRating.dart b/lib/widgets/shared/StarRating.dart index a65df00b..1caded9b 100644 --- a/lib/widgets/shared/StarRating.dart +++ b/lib/widgets/shared/StarRating.dart @@ -8,30 +8,21 @@ class StarRating extends StatelessWidget { final int totalCount; final bool forceStars; - StarRating( - {Key ? key, - this.totalAverage: 0.0, - this.size: 16.0, - this.totalCount = 5, - this.forceStars = false}) + StarRating({Key? key, this.totalAverage: 0.0, this.size: 16.0, this.totalCount = 5, this.forceStars = false}) : super(key: key); @override Widget build(BuildContext context) { return Row(mainAxisAlignment: MainAxisAlignment.start, children: [ - if (!forceStars && (totalAverage == null || totalAverage == 0)) - AppText("New", style: "caption"), + if (!forceStars && (totalAverage == null || totalAverage == 0)) AppText("New", style: "caption"), if (forceStars || (totalAverage != null && totalAverage > 0)) ...List.generate( 5, (index) => Padding( padding: EdgeInsets.only(right: 1.0), - child: Icon( - (index + 1) <= (totalAverage ?? 0) - ? EvaIcons.star - : EvaIcons.starOutline, + child: Icon((index + 1) <= (totalAverage) ? EvaIcons.star : EvaIcons.starOutline, size: size, - color: (index + 1) <= (totalAverage ?? 0) + color: (index + 1) <= (totalAverage) ? Color.fromRGBO(255, 186, 0, 1.0) : Theme.of(context).hintColor), )), diff --git a/lib/widgets/shared/TextFields.dart b/lib/widgets/shared/TextFields.dart index 07cbc52f..00fc4edb 100644 --- a/lib/widgets/shared/TextFields.dart +++ b/lib/widgets/shared/TextFields.dart @@ -4,8 +4,7 @@ import 'package:flutter/services.dart'; class NumberTextInputFormatter extends TextInputFormatter { @override - TextEditingValue formatEditUpdate( - TextEditingValue oldValue, TextEditingValue newValue) { + TextEditingValue formatEditUpdate(TextEditingValue oldValue, TextEditingValue newValue) { final int newTextLength = newValue.text.length; int selectionIndex = newValue.selection.end; int usedSubstringIndex = 0; @@ -27,8 +26,7 @@ class NumberTextInputFormatter extends TextInputFormatter { if (newValue.selection.end >= 10) selectionIndex++; } // Dump the rest. - if (newTextLength >= usedSubstringIndex) - newText.write(newValue.text.substring(usedSubstringIndex)); + if (newTextLength >= usedSubstringIndex) newText.write(newValue.text.substring(usedSubstringIndex)); return TextEditingValue( text: newText.toString(), selection: TextSelection.collapsed(offset: selectionIndex), @@ -39,87 +37,90 @@ class NumberTextInputFormatter extends TextInputFormatter { final _mobileFormatter = NumberTextInputFormatter(); class TextFields extends StatefulWidget { - TextFields( - {Key ? key, - this.type, - this.hintText, - this.suffixIcon, - this.autoFocus, - this.onChanged, - this.initialValue, - this.minLines, - this.maxLines, - this.inputFormatters, - this.padding, - this.focus = false, - this.maxLengthEnforced = true, - this.suffixIconColor, - this.inputAction = TextInputAction.done, - this.onSubmit, - this.keepPadding = true, - this.textCapitalization = TextCapitalization.none, - this.controller, - this.keyboardType, - this.validator, - this.borderOnlyError = false, - this.onSaved, - this.onSuffixTap, - this.readOnly: false, - this.maxLength, - this.prefixIcon, - this.bare = false, - this.onTap, - this.fontSize = 16.0, - this.fontWeight = FontWeight.w700, - this.autoValidate = false, - this.fillColor, - this.hintColor, - this.hasBorder = true, - this.onTapTextFields, - this.hasLabelText = false, - this.showLabelText = false, this.borderRadius= 8.0, this.borderColor, this.borderWidth = 1, }) - : super(key: key); + TextFields({ + Key? key, + this.type, + this.hintText, + this.suffixIcon, + this.autoFocus, + this.onChanged, + this.initialValue, + this.minLines, + this.maxLines, + this.inputFormatters, + this.padding, + this.focus = false, + this.maxLengthEnforced = true, + this.suffixIconColor, + this.inputAction = TextInputAction.done, + this.onSubmit, + this.keepPadding = true, + this.textCapitalization = TextCapitalization.none, + this.controller, + this.keyboardType, + this.validator, + this.borderOnlyError = false, + this.onSaved, + this.onSuffixTap, + this.readOnly: false, + this.maxLength, + this.prefixIcon, + this.bare = false, + this.onTap, + this.fontSize = 16.0, + this.fontWeight = FontWeight.w700, + this.autoValidate = false, + this.fillColor, + this.hintColor, + this.hasBorder = true, + this.onTapTextFields, + this.hasLabelText = false, + this.showLabelText = false, + this.borderRadius = 8.0, + this.borderColor, + this.borderWidth = 1, + }) : super(key: key); - final String hintText; - final String initialValue; - final String type; - final bool autoFocus; - final IconData suffixIcon; - final Color suffixIconColor; - final Icon prefixIcon; - final VoidCallback onTap; - final Function onTapTextFields; - final TextEditingController controller; - final TextInputType keyboardType; - final FormFieldValidator validator; - final Function onSaved; - final Function onSuffixTap; - final Function onChanged; - final Function onSubmit; - final bool readOnly; - final int maxLength; - final int minLines; - final int maxLines; - final bool maxLengthEnforced; - final bool bare; - final TextInputAction inputAction; - final double fontSize; - final FontWeight fontWeight; - final bool keepPadding; - final TextCapitalization textCapitalization; - final List inputFormatters; - final bool autoValidate; - final EdgeInsets padding; - final bool focus; - final bool borderOnlyError; - final Color hintColor; - final Color fillColor; - final bool hasBorder; - final bool showLabelText; - Color borderColor; - final double borderRadius; - final double borderWidth; - bool hasLabelText; + final String? hintText; + final String? initialValue; + final String? type; + final bool? autoFocus; + final IconData? suffixIcon; + final Color? suffixIconColor; + final Icon? prefixIcon; + final VoidCallback? onTap; + final GestureTapCallback? onTapTextFields; + final TextEditingController? controller; + final TextInputType? keyboardType; + final FormFieldValidator? validator; + final FormFieldSetter? onSaved; + final GestureTapCallback? onSuffixTap; + final Function? onChanged; + final ValueChanged? onSubmit; + final bool? readOnly; + final int? maxLength; + final int? minLines; + final int? maxLines; + final bool? maxLengthEnforced; + final bool? bare; + final TextInputAction? inputAction; + final double? fontSize; + final FontWeight? fontWeight; + final bool? keepPadding; + final TextCapitalization? textCapitalization; + final List? inputFormatters; + final bool? autoValidate; + final EdgeInsets? padding; + final bool? focus; + final bool? borderOnlyError; + final Color? hintColor; + final Color? fillColor; + final bool? hasBorder; + final bool? showLabelText; + Color? borderColor; + final double? borderRadius; + final double? borderWidth; + bool? hasLabelText; @override _TextFieldsState createState() => _TextFieldsState(); @@ -142,7 +143,7 @@ class _TextFieldsState extends State { @override void didUpdateWidget(TextFields oldWidget) { - if (widget.focus) _focusNode.requestFocus(); + if (widget.focus!) _focusNode.requestFocus(); super.didUpdateWidget(oldWidget); } @@ -152,7 +153,7 @@ class _TextFieldsState extends State { super.dispose(); } - Widget _buildSuffixIcon() { + Widget? _buildSuffixIcon() { switch (widget.type) { case "password": { @@ -160,40 +161,35 @@ class _TextFieldsState extends State { padding: const EdgeInsets.only(right: 8.0), child: view ? InkWell( - onTap: () { - this.setState(() { - view = false; - }); - }, - child: Icon(EvaIcons.eye, - size: 24.0, color: Color.fromRGBO(78, 62, 253, 1.0))) + onTap: () { + this.setState(() { + view = false; + }); + }, + child: Icon(EvaIcons.eye, size: 24.0, color: Color?.fromRGBO(78, 62, 253, 1.0))) : InkWell( - onTap: () { - this.setState(() { - view = true; - }); - }, - child: Icon(EvaIcons.eyeOff, - size: 24.0, color: Colors.grey[500]))); + onTap: () { + this.setState(() { + view = true; + }); + }, + child: Icon(EvaIcons.eyeOff, size: 24.0, color: Colors.grey[500]))); } break; default: if (widget.suffixIcon != null) return InkWell( - onTap: widget.onSuffixTap, + onTap: widget.onSuffixTap??null, child: Icon(widget.suffixIcon, - size: 22.0, - color: widget.suffixIconColor != null - ? widget.suffixIconColor - : Colors.grey[500])); + size: 22.0, color: widget.suffixIconColor != null ? widget.suffixIconColor : Colors.grey[500])); else return null; } } - bool _determineReadOnly() { - if (widget.readOnly != null && widget.readOnly) { + bool? _determineReadOnly() { + if (widget.readOnly != null && widget.readOnly!) { _focusNode.unfocus(); return true; } else { @@ -203,44 +199,43 @@ class _TextFieldsState extends State { @override Widget build(BuildContext context) { - - widget.borderColor = widget.borderColor?? Colors.grey; + widget.borderColor = widget.borderColor ?? Colors.grey; return (AnimatedContainer( duration: Duration(milliseconds: 300), - decoration: widget.bare + decoration: widget.bare! ? null : BoxDecoration(boxShadow: [ - // BoxShadow( - // color: Color.fromRGBO(70, 68, 167, focus ? 0.20 : 0), - // offset: Offset(0.0, 13.0), - // blurRadius: focus ? 34.0 : 12.0) - BoxShadow( - color: Color.fromRGBO(110, 68, 80, focus ? 0.20 : 0), - offset: Offset(0.0, 13.0), - blurRadius: focus ? 34.0 : 12.0) - ]), + // BoxShadow( + // color: Color?.fromRGBO(70, 68, 167, focus ? 0.20 : 0), + // offset: Offset(0.0, 13.0), + // blurRadius: focus ? 34.0 : 12.0) + BoxShadow( + color: Color?.fromRGBO(110, 68, 80, focus ? 0.20 : 0), + offset: Offset(0.0, 13.0), + blurRadius: focus ? 34.0 : 12.0) + ]), child: Column( children: [ TextFormField( onTap: widget.onTapTextFields, keyboardAppearance: Theme.of(context).brightness, scrollPhysics: BouncingScrollPhysics(), - // autovalidate: widget.autoValidate, - textCapitalization: widget.textCapitalization, - onFieldSubmitted: widget.inputAction == TextInputAction.next - ? (widget.onSubmit != null - ? widget.onSubmit - : (val) { - _focusNode.nextFocus(); - }) + // autovalidate: widget.autoValidate!, + textCapitalization: widget.textCapitalization!, + onFieldSubmitted: widget.inputAction! == TextInputAction.next + ? (widget.onSubmit! != null + ? widget.onSubmit + : (val) { + _focusNode.nextFocus(); + }) : widget.onSubmit, textInputAction: widget.inputAction, minLines: widget.minLines ?? 1, maxLines: widget.maxLines ?? 1, - maxLengthEnforced: widget.maxLengthEnforced, + maxLengthEnforced: widget.maxLengthEnforced!, initialValue: widget.initialValue, onChanged: (value) { - if (widget.showLabelText) { + if (widget.showLabelText!) { if ((value == null || value == '')) { setState(() { widget.hasLabelText = false; @@ -251,27 +246,29 @@ class _TextFieldsState extends State { }); } } - if (widget.onChanged != null) widget.onChanged(value); + if (widget.onChanged != null) widget.onChanged!(value); }, focusNode: _focusNode, maxLength: widget.maxLength ?? null, controller: widget.controller, keyboardType: widget.keyboardType, - readOnly: _determineReadOnly(), + readOnly: _determineReadOnly()!, obscureText: widget.type == "password" && !view ? true : false, autofocus: widget.autoFocus ?? false, validator: widget.validator, onSaved: widget.onSaved, - style: Theme.of(context).textTheme.bodyText1.copyWith( - fontSize: widget.fontSize, fontWeight: widget.fontWeight), + style: Theme.of(context) + .textTheme + .bodyText1! + .copyWith(fontSize: widget.fontSize, fontWeight: widget.fontWeight), inputFormatters: widget.keyboardType == TextInputType.phone ? [ - // WhitelistingTextInputFormatter.digitsOnly, - _mobileFormatter, - ] + // WhitelistingTextInputFormatter.digitsOnly, + _mobileFormatter, + ] : widget.inputFormatters, decoration: InputDecoration( - labelText: widget.hasLabelText ? widget.hintText : null, + labelText: widget.hasLabelText! ? widget.hintText : null, labelStyle: TextStyle( fontSize: widget.fontSize, fontWeight: widget.fontWeight, @@ -281,68 +278,54 @@ class _TextFieldsState extends State { hintText: widget.hintText, hintStyle: TextStyle( fontSize: widget.fontSize, - fontWeight: widget.fontWeight, color: widget.hintColor ?? Theme.of(context).hintColor, ), contentPadding: widget.padding != null ? widget.padding : EdgeInsets.symmetric( - vertical: - (widget.bare && !widget.keepPadding) ? 0.0 : 10.0, - horizontal: 16.0), + vertical: (widget.bare! && !widget.keepPadding!) ? 0.0 : 10.0, horizontal: 16.0), filled: true, - fillColor: widget.bare - ? Colors.transparent - : Theme.of(context).backgroundColor, + fillColor: widget.bare! ? Colors.transparent : Theme.of(context).backgroundColor, suffixIcon: _buildSuffixIcon(), prefixIcon: widget.prefixIcon, errorStyle: TextStyle( - fontSize: 12.0, - fontWeight: widget.fontWeight, - height: widget.borderOnlyError ? 0.0 : null), + fontSize: 12.0, fontWeight: widget.fontWeight, height: widget.borderOnlyError! ? 0.0 : null), errorBorder: OutlineInputBorder( - borderSide: widget.hasBorder - ? BorderSide( - color: Theme.of(context) - .errorColor - .withOpacity(widget.bare ? 0.0 : 0.5), - width: 1.0) + borderSide: widget.hasBorder! + ? BorderSide(color: Theme.of(context).errorColor.withOpacity(widget.bare! ? 0.0 : 0.5), width: 1.0) : BorderSide(color: Colors.transparent, width: 0), - borderRadius: widget.hasBorder - ? BorderRadius.circular(widget.bare ? 0.0 : widget.borderRadius) + borderRadius: widget.hasBorder! + ? BorderRadius.circular(widget.bare! ? 0.0 : widget.borderRadius!) : BorderRadius.circular(0.0), ), focusedErrorBorder: OutlineInputBorder( - borderSide: widget.hasBorder + borderSide: widget.hasBorder! ? BorderSide( - color: Theme.of(context) - .errorColor - .withOpacity(widget.bare ? 0.0 : 0.5), - width: 1.0) + color: Theme.of(context).errorColor.withOpacity(widget.bare! ? 0.0 : 0.5), width: 1.0) : BorderSide(color: Colors.transparent, width: 0), - borderRadius: BorderRadius.circular(widget.bare ? 0.0 : widget.borderRadius)), + borderRadius: BorderRadius.circular(widget.bare! ? 0.0 : widget.borderRadius!)), focusedBorder: OutlineInputBorder( - borderSide: widget.hasBorder - ? BorderSide(color: widget.borderColor,width: widget.borderWidth) + borderSide: widget.hasBorder! + ? BorderSide(color: widget.borderColor!, width: widget.borderWidth!) : BorderSide(color: Colors.transparent, width: 0), - borderRadius: widget.hasBorder - ? BorderRadius.circular(widget.bare ? 0.0 : widget.borderRadius) + borderRadius: widget.hasBorder! + ? BorderRadius.circular(widget.bare! ? 0.0 : widget.borderRadius!) : BorderRadius.circular(0.0), ), disabledBorder: OutlineInputBorder( - borderSide: widget.hasBorder - ? BorderSide(color: widget.borderColor,width: widget.borderWidth) + borderSide: widget.hasBorder! + ? BorderSide(color: widget.borderColor!, width: widget.borderWidth!) : BorderSide(color: Colors.transparent, width: 0), - borderRadius: widget.hasBorder - ? BorderRadius.circular(widget.bare ? 0.0 : widget.borderRadius) + borderRadius: widget.hasBorder! + ? BorderRadius.circular(widget.bare! ? 0.0 : widget.borderRadius!) : BorderRadius.circular(0.0)), enabledBorder: OutlineInputBorder( - borderSide: widget.hasBorder - ? BorderSide(color: widget.borderColor,width: widget.borderWidth) + borderSide: widget.hasBorder! + ? BorderSide(color: widget.borderColor!, width: widget.borderWidth!) : BorderSide(color: Colors.transparent, width: 0), - borderRadius: widget.hasBorder - ? BorderRadius.circular(widget.bare ? 0.0 : widget.borderRadius) + borderRadius: widget.hasBorder! + ? BorderRadius.circular(widget.bare! ? 0.0 : widget.borderRadius!) : BorderRadius.circular(0.0), ), ), diff --git a/lib/widgets/shared/app_drawer_widget.dart b/lib/widgets/shared/app_drawer_widget.dart index 7f6ced05..82ecf103 100644 --- a/lib/widgets/shared/app_drawer_widget.dart +++ b/lib/widgets/shared/app_drawer_widget.dart @@ -24,7 +24,7 @@ class AppDrawer extends StatefulWidget { class _AppDrawerState extends State { Helpers helpers = new Helpers(); - ProjectViewModel projectsProvider; + late ProjectViewModel projectsProvider; @override Widget build(BuildContext context) { @@ -87,11 +87,11 @@ class _AppDrawerState extends State { Padding( padding: EdgeInsets.only(top: 8.0), child: AppText( - TranslationBase.of(context).dr + + TranslationBase.of(context).dr!+ capitalizeOnlyFirstLater( authenticationViewModel - .doctorProfile!.doctorName - .replaceAll("DR.", "") + .doctorProfile!.doctorName! + .replaceAll!("DR.", "") .toLowerCase()), fontWeight: FontWeight.w700, color: Color(0xFF2E303A), @@ -103,8 +103,8 @@ class _AppDrawerState extends State { Padding( padding: EdgeInsets.only(top: 0), child: AppText( - authenticationViewModel - .doctorProfile?.clinicDescription, + authenticationViewModel! + .doctorProfile?.clinicDescription!!, fontWeight: FontWeight.w500, color: Color(0xFF2E303A), fontSize: 16, @@ -118,7 +118,7 @@ class _AppDrawerState extends State { SizedBox(height: 40), InkWell( child: DrawerItem( - TranslationBase.of(context).applyOrRescheduleLeave, + TranslationBase.of(context).applyOrRescheduleLeave!, icon: DoctorApp.reschedule__1, // subTitle: , @@ -138,7 +138,9 @@ class _AppDrawerState extends State { SizedBox(height: 15), InkWell( child: DrawerItem( - TranslationBase.of(context).myQRCode, + TranslationBase + .of(context) + .myQRCode!, icon: DoctorApp.qr_code_3, // subTitle: , ), @@ -165,8 +167,12 @@ class _AppDrawerState extends State { InkWell( child: DrawerItem( projectsProvider.isArabic - ? TranslationBase.of(context).lanEnglish - : TranslationBase.of(context).lanArabic, + ? TranslationBase + .of(context) + .lanEnglish ?? "" + : TranslationBase + .of(context) + .lanArabic ?? "", // icon: DoctorApp.qr_code, assetLink: projectsProvider.isArabic ? 'assets/images/usa-flag.png' @@ -182,7 +188,9 @@ class _AppDrawerState extends State { SizedBox(height: 10), InkWell( child: DrawerItem( - TranslationBase.of(context).logout, + TranslationBase + .of(context) + .logout!, icon: DoctorApp.logout_1, ), onTap: () async { diff --git a/lib/widgets/shared/app_expandable_notifier.dart b/lib/widgets/shared/app_expandable_notifier.dart deleted file mode 100644 index 76a7f57e..00000000 --- a/lib/widgets/shared/app_expandable_notifier.dart +++ /dev/null @@ -1,58 +0,0 @@ -import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; -import 'package:expandable/expandable.dart'; -import 'package:flutter/material.dart'; - -class AppExpandableNotifier extends StatelessWidget { - final Widget headerWid; - final Widget bodyWid; - - AppExpandableNotifier({this.headerWid, this.bodyWid}); - - @override - Widget build(BuildContext context) { - return ExpandableNotifier( - child: Padding( - padding: const EdgeInsets.all(10), - child: Card( - clipBehavior: Clip.antiAlias, - child: Column( - children: [ - SizedBox( - child: headerWid, - ), - ScrollOnExpand( - scrollOnExpand: true, - scrollOnCollapse: false, - child: ExpandablePanel( - theme: const ExpandableThemeData( - headerAlignment: ExpandablePanelHeaderAlignment.center, - tapBodyToCollapse: true, - ), - header: Padding( - padding: EdgeInsets.all(10), - child: Text( - "${TranslationBase.of(context).graphDetails}", - style: TextStyle(fontWeight: FontWeight.bold), - )), - collapsed: Text(''), - expanded: bodyWid, - builder: (_, collapsed, expanded) { - return Padding( - padding: EdgeInsets.only(left: 10, right: 10, bottom: 10), - child: Expandable( - collapsed: collapsed, - expanded: expanded, - theme: const ExpandableThemeData(crossFadePoint: 0), - ), - ); - }, - ), - ), - ], - ), - ), - ), - initialExpanded: true, - ); - } -} diff --git a/lib/widgets/shared/app_expandable_notifier_new.dart b/lib/widgets/shared/app_expandable_notifier_new.dart deleted file mode 100644 index 848f5265..00000000 --- a/lib/widgets/shared/app_expandable_notifier_new.dart +++ /dev/null @@ -1,127 +0,0 @@ -import 'package:doctor_app_flutter/config/size_config.dart'; -import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; -import 'package:expandable/expandable.dart'; -import 'package:flutter/material.dart'; - - -/// App Expandable Notifier with animation -/// [headerWidget] widget want to show in the header -/// [bodyWidget] widget want to show in the body -/// [title] the widget title -/// [collapsed] The widget shown in the collapsed state -class AppExpandableNotifier extends StatefulWidget { - final Widget headerWidget; - final Widget bodyWidget; - final String title; - final Widget collapsed; - final bool isExpand; - bool expandFlag = false; - var controller = new ExpandableController(); - AppExpandableNotifier( - {this.headerWidget, - this.bodyWidget, - this.title, - this.collapsed, - this.isExpand = false}); - - _AppExpandableNotifier createState() => _AppExpandableNotifier(); -} - -class _AppExpandableNotifier extends State { - - @override - void initState() { - setState(() { - if (widget.isExpand) { - widget.expandFlag = widget.isExpand; - widget.controller.expanded = true; - } - }); - super.initState(); - } - - @override - Widget build(BuildContext context) { - - return ExpandableNotifier( - child: Padding( - padding: const EdgeInsets.only(left: 10, right: 10, top: 4), - child: Card( - color: Colors.grey[200], - clipBehavior: Clip.antiAlias, - child: Column( - children: [ - SizedBox( - child: widget.headerWidget, - ), - ScrollOnExpand( - scrollOnExpand: true, - scrollOnCollapse: false, - child: ExpandablePanel( - hasIcon: false, - theme: const ExpandableThemeData( - headerAlignment: ExpandablePanelHeaderAlignment.center, - tapBodyToCollapse: true, - ), - header: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Expanded( - child: Padding( - padding: EdgeInsets.all(10), - child: Text( - widget.title ?? TranslationBase.of(context).details, - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: SizeConfig.textMultiplier * 2, - ), - ), - ), - ), - IconButton( - icon: new Container( - height: 28.0, - width: 30.0, - decoration: new BoxDecoration( - color: Theme.of(context).primaryColor, - shape: BoxShape.circle, - ), - child: new Center( - child: new Icon( - widget.expandFlag - ? Icons.keyboard_arrow_up - : Icons.keyboard_arrow_down, - color: Colors.white, - size: 30.0, - ), - ), - ), - onPressed: () { - setState(() { - widget.expandFlag = !widget.expandFlag; - widget.controller.expanded = widget.expandFlag; - }); - }), - ]), - collapsed: widget.collapsed ?? Container(), - expanded: widget.bodyWidget, - builder: (_, collapsed, expanded) { - return Padding( - padding: EdgeInsets.only(left: 5, right: 5, bottom: 5), - child: Expandable( - controller: widget.controller, - collapsed: collapsed, - expanded: expanded, - theme: const ExpandableThemeData(crossFadePoint: 0), - ), - ); - }, - ), - ), - ], - ), - ), - ), - ); - } -} diff --git a/lib/widgets/shared/app_loader_widget.dart b/lib/widgets/shared/app_loader_widget.dart index 48ae1774..0940a76e 100644 --- a/lib/widgets/shared/app_loader_widget.dart +++ b/lib/widgets/shared/app_loader_widget.dart @@ -1,13 +1,12 @@ import 'package:flutter/material.dart'; -import 'package:progress_hud_v2/progress_hud.dart'; import 'loader/gif_loader_container.dart'; class AppLoaderWidget extends StatefulWidget { - AppLoaderWidget({Key ? key, this.title, this.containerColor}) : super(key: key); + AppLoaderWidget({Key? key, this.title, this.containerColor}) : super(key: key); - final String title; - final Color containerColor; + final String? title; + final Color? containerColor; @override _AppLoaderWidgetState createState() => new _AppLoaderWidgetState(); diff --git a/lib/widgets/shared/app_scaffold_widget.dart b/lib/widgets/shared/app_scaffold_widget.dart index b930c21a..297ce714 100644 --- a/lib/widgets/shared/app_scaffold_widget.dart +++ b/lib/widgets/shared/app_scaffold_widget.dart @@ -2,6 +2,7 @@ import 'package:doctor_app_flutter/config/config.dart'; import 'package:doctor_app_flutter/core/viewModel/base_view_model.dart'; import 'package:doctor_app_flutter/core/viewModel/project_view_model.dart'; import 'package:doctor_app_flutter/icons_app/doctor_app_icons.dart'; +import 'package:doctor_app_flutter/models/patient/profile/patient_profile_app_bar_model.dart'; import 'package:doctor_app_flutter/routes.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; @@ -12,18 +13,20 @@ import 'network_base_view.dart'; class AppScaffold extends StatelessWidget { final String appBarTitle; - final Widget body; + final Widget? body; final bool isLoading; final bool isShowAppBar; - final BaseViewModel baseViewModel; - final Widget bottomSheet; - final Color backgroundColor; - final Widget appBar; - final Widget drawer; - final Widget bottomNavigationBar; - final String subtitle; + final BaseViewModel? baseViewModel; + final Widget? bottomSheet; + final Color? backgroundColor; + final PreferredSizeWidget? appBar; + final Widget? drawer; + final Widget? bottomNavigationBar; + final String? subtitle; final bool isHomeIcon; final bool extendBody; + final PatientProfileAppBarModel? patientProfileAppBarModel; + AppScaffold( {this.appBarTitle = '', this.body, @@ -33,7 +36,10 @@ class AppScaffold extends StatelessWidget { this.bottomSheet, this.backgroundColor, this.isHomeIcon = true, - this.appBar, this.subtitle, this.drawer, this.extendBody = false, this.bottomNavigationBar}); + + this.subtitle, + this.patientProfileAppBarModel, + this.drawer, this.extendBody = false, this.bottomNavigationBar, this.appBar}); @override Widget build(BuildContext context) { @@ -62,8 +68,11 @@ class AppScaffold extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.center, children: [ Text(appBarTitle.toUpperCase()), - if(subtitle!=null) - Text(subtitle,style: TextStyle(fontSize: 12,color: Colors.red),), + if (subtitle != null) + Text( + subtitle!, + style: TextStyle(fontSize: 12, color: Colors.red), + ), ], ), leading: Builder(builder: (BuildContext context) { @@ -93,8 +102,7 @@ class AppScaffold extends StatelessWidget { baseViewModel: baseViewModel, child: body, ) - : Stack( - children: [body, buildAppLoaderWidget(isLoading)]) + : Stack(children: [body!, buildAppLoaderWidget(isLoading)]) : Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, diff --git a/lib/widgets/shared/app_texts_widget.dart b/lib/widgets/shared/app_texts_widget.dart index f612e9e0..f09120ec 100644 --- a/lib/widgets/shared/app_texts_widget.dart +++ b/lib/widgets/shared/app_texts_widget.dart @@ -7,33 +7,33 @@ import 'package:flutter/services.dart'; import 'package:hexcolor/hexcolor.dart'; class AppText extends StatefulWidget { - final String text; - final String variant; - final Color color; - final FontWeight fontWeight; - final double fontSize; - final double fontHeight; - final String fontFamily; - final int maxLength; - final bool italic; - final double margin; - final double marginTop; - final double marginRight; - final double marginBottom; - final double marginLeft; - final double letterSpacing; - final TextAlign textAlign; - final bool bold; - final bool regular; - final bool medium; - final int maxLines; - final bool readMore; - final String style; - final bool allowExpand; - final bool visibility; - final TextOverflow textOverflow; - final TextDecoration textDecoration; - final bool isCopyable; + final String? text; + final String? variant; + final Color? color; + final FontWeight? fontWeight; + final double? fontSize; + final double? fontHeight; + final String? fontFamily; + final int? maxLength; + final bool? italic; + final double? margin; + final double? marginTop; + final double? marginRight; + final double? marginBottom; + final double? marginLeft; + final double? letterSpacing; + final TextAlign? textAlign; + final bool? bold; + final bool? regular; + final bool? medium; + final int? maxLines; + final bool? readMore; + final String? style; + final bool? allowExpand; + final bool? visibility; + final TextOverflow? textOverflow; + final TextDecoration? textDecoration; + final bool? isCopyable; AppText( this.text, { @@ -77,9 +77,9 @@ class _AppTextState extends State { void didUpdateWidget(covariant AppText oldWidget) { setState(() { if (widget.style == "overline") - text = widget.text.toUpperCase(); + text = widget.text!.toUpperCase(); else { - text = widget.text; + text = widget.text!; } }); super.didUpdateWidget(oldWidget); @@ -87,11 +87,11 @@ class _AppTextState extends State { @override void initState() { - hidden = widget.readMore; + hidden = widget.readMore!; if (widget.style == "overline") - text = widget.text.toUpperCase(); + text = widget.text!.toUpperCase(); else { - text = widget.text; + text = widget.text!; } super.initState(); } @@ -101,12 +101,9 @@ class _AppTextState extends State { return GestureDetector( child: Container( margin: widget.margin != null - ? EdgeInsets.all(widget.margin) + ? EdgeInsets.all(widget.margin!) : EdgeInsets.only( - top: widget.marginTop, - right: widget.marginRight, - bottom: widget.marginBottom, - left: widget.marginLeft), + top: widget.marginTop!, right: widget.marginRight!, bottom: widget.marginBottom!, left: widget.marginLeft!), child: Column( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.start, @@ -114,7 +111,7 @@ class _AppTextState extends State { Stack( children: [ _textWidget(), - if (widget.readMore && text.length > widget.maxLength && hidden) + if (widget.readMore! && text.length > widget.maxLength! && hidden) Positioned( bottom: 0, left: 0, @@ -133,9 +130,7 @@ class _AppTextState extends State { ) ], ), - if (widget.allowExpand && - widget.readMore && - text.length > widget.maxLength) + if (widget.allowExpand! && widget.readMore! && text.length > widget.maxLength!) Padding( padding: EdgeInsets.only(top: 8.0, right: 8.0, bottom: 8.0), child: InkWell( @@ -165,20 +160,14 @@ class _AppTextState extends State { } Widget _textWidget() { - if (widget.isCopyable) { + if (widget.isCopyable!) { return Theme( data: ThemeData( textSelectionColor: Colors.lightBlueAccent, ), child: Container( child: SelectableText( - !hidden - ? text - : (text.substring( - 0, - text.length > widget.maxLength - ? widget.maxLength - : text.length)), + !hidden ? text : (text.substring(0, text.length > widget.maxLength! ? widget.maxLength : text.length)), textAlign: widget.textAlign, // overflow: widget.maxLines != null // ? ((widget.maxLines > 1) @@ -188,12 +177,12 @@ class _AppTextState extends State { maxLines: widget.maxLines ?? null, style: widget.style != null ? _getFontStyle().copyWith( - fontStyle: widget.italic ? FontStyle.italic : null, + fontStyle: widget.italic! ? FontStyle.italic : null, color: widget.color, fontWeight: widget.fontWeight ?? _getFontWeight(), height: widget.fontHeight) : TextStyle( - fontStyle: widget.italic ? FontStyle.italic : null, + fontStyle: widget.italic! ? FontStyle.italic : null, color: widget.color != null ? widget.color : Color(0xff2E303A), fontSize: widget.fontSize ?? _getFontSize(), @@ -212,24 +201,24 @@ class _AppTextState extends State { ? text : (text.substring( 0, - text.length > widget.maxLength + text.length > widget.maxLength! ? widget.maxLength : text.length)), textAlign: widget.textAlign, overflow: widget.maxLines != null - ? ((widget.maxLines > 1) + ? ((widget.maxLines! > 1) ? TextOverflow.fade : TextOverflow.ellipsis) : null, maxLines: widget.maxLines ?? null, style: widget.style != null ? _getFontStyle().copyWith( - fontStyle: widget.italic ? FontStyle.italic : null, + fontStyle: widget.italic! ? FontStyle.italic : null, color: widget.color, fontWeight: widget.fontWeight ?? _getFontWeight(), height: widget.fontHeight) : TextStyle( - fontStyle: widget.italic ? FontStyle.italic : null, + fontStyle: widget.italic! ? FontStyle.italic : null, color: widget.color != null ? widget.color : Colors.black, fontSize: widget.fontSize ?? _getFontSize(), letterSpacing: widget.letterSpacing ?? @@ -245,27 +234,27 @@ class _AppTextState extends State { TextStyle _getFontStyle() { switch (widget.style) { case "headline2": - return Theme.of(context).textTheme.headline2; + return Theme.of(context).textTheme.headline2!; case "headline3": - return Theme.of(context).textTheme.headline3; + return Theme.of(context).textTheme.headline3!; case "headline4": - return Theme.of(context).textTheme.headline4; + return Theme.of(context).textTheme.headline4!; case "headline5": - return Theme.of(context).textTheme.headline5; + return Theme.of(context).textTheme.headline5!; case "headline6": - return Theme.of(context).textTheme.headline6; + return Theme.of(context).textTheme.headline6!; case "bodyText2": - return Theme.of(context).textTheme.bodyText2; + return Theme.of(context).textTheme.bodyText2!; case "bodyText_15": - return Theme.of(context).textTheme.bodyText2.copyWith(fontSize: 15.0); + return Theme.of(context).textTheme.bodyText2!.copyWith(fontSize: 15.0); case "bodyText1": - return Theme.of(context).textTheme.bodyText1; + return Theme.of(context).textTheme.bodyText1!; case "caption": - return Theme.of(context).textTheme.caption; + return Theme.of(context).textTheme.caption!; case "overline": - return Theme.of(context).textTheme.overline; + return Theme.of(context).textTheme.overline!; case "button": - return Theme.of(context).textTheme.button; + return Theme.of(context).textTheme.button!; default: return TextStyle(); } @@ -350,7 +339,7 @@ class _AppTextState extends State { return FontWeight.w500; } } else { - return null; + return FontWeight.normal; } } } diff --git a/lib/widgets/shared/bottom_nav_bar.dart b/lib/widgets/shared/bottom_nav_bar.dart index 182dad4e..0130f1d2 100644 --- a/lib/widgets/shared/bottom_nav_bar.dart +++ b/lib/widgets/shared/bottom_nav_bar.dart @@ -13,7 +13,7 @@ class BottomNavBar extends StatefulWidget { DashboardViewModel dashboardViewModel = DashboardViewModel(); - BottomNavBar({Key ? key, this.changeIndex, this.index}) : super(key: key); + BottomNavBar({Key? key, required this.changeIndex, required this.index}) : super(key: key); @override _BottomNavBarState createState() => _BottomNavBarState(); diff --git a/lib/widgets/shared/bottom_navigation_item.dart b/lib/widgets/shared/bottom_navigation_item.dart index 36037413..31fa112a 100644 --- a/lib/widgets/shared/bottom_navigation_item.dart +++ b/lib/widgets/shared/bottom_navigation_item.dart @@ -20,16 +20,18 @@ class BottomNavigationItem extends StatelessWidget { final String? name; final DashboardViewModel? dashboardViewModel; + String svgPath; + BottomNavigationItem( {this.icon, this.activeIcon, - this.changeIndex, + required this.changeIndex, this.index, - this.currentIndex, + required this.currentIndex, this.name, this.dashboardViewModel, - this.svgPath}); + required this.svgPath}); @override Widget build(BuildContext context) { @@ -89,7 +91,7 @@ class BottomNavigationItem extends StatelessWidget { ], ), if (currentIndex == 3 && - dashboardViewModel.notRepliedCount != 0) + dashboardViewModel?.notRepliedCount != 0) Positioned( right: 18.0, bottom: 40.0, @@ -102,7 +104,7 @@ class BottomNavigationItem extends StatelessWidget { badgeContent: Container( // padding: EdgeInsets.all(2.0), child: AppText( - dashboardViewModel.notRepliedCount.toString(), + dashboardViewModel?.notRepliedCount.toString(), color: Colors.white, fontSize: 12.0), ), diff --git a/lib/widgets/shared/buttons/app_buttons_widget.dart b/lib/widgets/shared/buttons/app_buttons_widget.dart index bb43dc8c..7109b6cb 100644 --- a/lib/widgets/shared/buttons/app_buttons_widget.dart +++ b/lib/widgets/shared/buttons/app_buttons_widget.dart @@ -8,23 +8,23 @@ import 'package:hexcolor/hexcolor.dart'; import '../app_texts_widget.dart'; class AppButton extends StatefulWidget { - final GestureTapCallback onPressed; - final String title; - final IconData iconData; - final Widget icon; - final Color color; - final double fontSize; - final double padding; - final Color fontColor; - final bool loading; - final bool disabled; - final FontWeight fontWeight; - final bool hasBorder; - final Color borderColor; - final double radius; - final double vPadding; - final double hPadding; - final double height; + final GestureTapCallback? onPressed; + final String? title; + final IconData? iconData; + final Widget? icon; + final Color? color; + final double? fontSize; + final double? padding; + final Color? fontColor; + final bool? loading; + final bool? disabled; + final FontWeight? fontWeight; + final bool? hasBorder; + final Color? borderColor; + final double? radius; + final double? vPadding; + final double? hPadding; + final double? height; AppButton({ @required this.onPressed, @@ -56,21 +56,20 @@ class _AppButtonState extends State { // height: MediaQuery.of(context).size.height * 0.075, height: widget.height, child: IgnorePointer( - ignoring: widget.loading || widget.disabled, + ignoring: widget.loading! || widget.disabled!, child: RawMaterialButton( - fillColor: widget.disabled + fillColor: widget.disabled! ? Colors.grey : widget.color != null ? widget.color : HexColor("#D02127"), splashColor: widget.color, child: Padding( - padding: (widget.hPadding > 0 || widget.vPadding > 0) - ? EdgeInsets.symmetric( - vertical: widget.vPadding, horizontal: widget.hPadding) + padding: (widget.hPadding! > 0 || widget.vPadding! > 0) + ? EdgeInsets.symmetric(vertical: widget.vPadding!, horizontal: widget.hPadding!) : EdgeInsets.only( - top: widget.padding, - bottom: widget.padding, + top: widget.padding!, + bottom: widget.padding!, //right: SizeConfig.widthMultiplier * widget.padding, //left: SizeConfig.widthMultiplier * widget.padding ), @@ -89,7 +88,7 @@ class _AppButtonState extends State { SizedBox( width: 5.0, ), - widget.loading + widget.loading! ? Padding( padding: EdgeInsets.all(2.6), child: SizedBox( @@ -98,7 +97,7 @@ class _AppButtonState extends State { child: CircularProgressIndicator( backgroundColor: Colors.white, valueColor: AlwaysStoppedAnimation( - Colors.grey[300], + Colors.grey[300]!, ), ), ), @@ -115,17 +114,17 @@ class _AppButtonState extends State { ], ), ), - onPressed: widget.disabled ? () {} : widget.onPressed, + onPressed: widget.disabled! ? () {} : widget.onPressed, shape: RoundedRectangleBorder( side: BorderSide( - color: widget.hasBorder + color: (widget.hasBorder! ? widget.borderColor - : widget.disabled - ? Colors.grey - : widget.color ?? Color(0xFFB8382C), + : widget.disabled! + ? Colors.grey! + : widget.color) ?? Color(0xFFB8382C), width: 0.8, ), - borderRadius: BorderRadius.all(Radius.circular(widget.radius))), + borderRadius: BorderRadius.all(Radius.circular(widget.radius!))), ), ), ); diff --git a/lib/widgets/shared/buttons/button_bottom_sheet.dart b/lib/widgets/shared/buttons/button_bottom_sheet.dart index 3c5cc32d..6ecae98a 100644 --- a/lib/widgets/shared/buttons/button_bottom_sheet.dart +++ b/lib/widgets/shared/buttons/button_bottom_sheet.dart @@ -3,25 +3,25 @@ import 'package:flutter/material.dart'; import 'app_buttons_widget.dart'; class ButtonBottomSheet extends StatelessWidget { + final GestureTapCallback? onPressed; + final String? title; + final IconData? iconData; + final Widget? icon; + final Color? color; + final double? fontSize; + final double? padding; + final Color? fontColor; + final bool? loading; + final bool? disabled; + final FontWeight? fontWeight; + final bool? hasBorder; + final Color? borderColor; + final double? radius; + final double? vPadding; + final double? hPadding; - final GestureTapCallback onPressed; - final String title; - final IconData iconData; - final Widget icon; - final Color color; - final double fontSize; - final double padding; - final Color fontColor; - final bool loading; - final bool disabled; - final FontWeight fontWeight; - final bool hasBorder; - final Color borderColor; - final double radius; - final double vPadding; - final double hPadding; - - ButtonBottomSheet({@required this.onPressed, + ButtonBottomSheet({ + @required this.onPressed, this.title, this.iconData, this.icon, diff --git a/lib/widgets/shared/buttons/secondary_button.dart b/lib/widgets/shared/buttons/secondary_button.dart index e2dd72bd..2851cdbb 100644 --- a/lib/widgets/shared/buttons/secondary_button.dart +++ b/lib/widgets/shared/buttons/secondary_button.dart @@ -15,7 +15,7 @@ import 'package:provider/provider.dart'; /// [noBorderRadius] remove border radius class SecondaryButton extends StatefulWidget { SecondaryButton( - {Key ? key, + {Key? key, this.label = "", this.icon, this.iconOnly = false, @@ -30,12 +30,12 @@ class SecondaryButton extends StatefulWidget { : super(key: key); final String label; - final Widget icon; - final VoidCallback onTap; + final Widget? icon; + final VoidCallback? onTap; final bool loading; - final Color color; + final Color? color; final Color textColor; - final Color borderColor; + final Color? borderColor; final bool small; final bool iconOnly; final bool disabled; @@ -45,15 +45,14 @@ class SecondaryButton extends StatefulWidget { _SecondaryButtonState createState() => _SecondaryButtonState(); } -class _SecondaryButtonState extends State - with TickerProviderStateMixin { +class _SecondaryButtonState extends State with TickerProviderStateMixin { double _buttonSize = 1.0; - AnimationController _animationController; - Animation _animation; + late AnimationController _animationController; + late Animation _animation; double _rippleSize = 0.0; - AnimationController _rippleController; - Animation _rippleAnimation; + late AnimationController _rippleController; + late Animation _rippleAnimation; @override void initState() { @@ -142,7 +141,7 @@ class _SecondaryButtonState extends State _animationController.forward(); }, onTap: () => { - widget.disabled ? null : widget.onTap(), + widget.disabled ? null : widget.onTap!(), }, // onTap: widget.disabled?null:Feedback.wrapForTap(widget.onTap, context), behavior: HitTestBehavior.opaque, @@ -151,8 +150,7 @@ class _SecondaryButtonState extends State child: Container( decoration: BoxDecoration( border: widget.borderColor != null - ? Border.all( - color: widget.borderColor.withOpacity(0.1), width: 2.0) + ? Border.all(color: widget.borderColor!.withOpacity(0.1), width: 2.0) : null, borderRadius: BorderRadius.all(Radius.circular(100.0)), boxShadow: [ @@ -224,9 +222,8 @@ class _SecondaryButtonState extends State width: 19.0, child: CircularProgressIndicator( backgroundColor: Colors.white, - valueColor: - AlwaysStoppedAnimation( - Colors.grey[300], + valueColor: AlwaysStoppedAnimation( + Colors.grey[300]!, ), ), ), diff --git a/lib/widgets/shared/card_with_bgNew_widget.dart b/lib/widgets/shared/card_with_bgNew_widget.dart index 00b836bc..bd3439e5 100644 --- a/lib/widgets/shared/card_with_bgNew_widget.dart +++ b/lib/widgets/shared/card_with_bgNew_widget.dart @@ -12,7 +12,7 @@ import 'package:hexcolor/hexcolor.dart'; class CardWithBgWidgetNew extends StatelessWidget { final Widget widget; - CardWithBgWidgetNew({@required this.widget}); + CardWithBgWidgetNew({required this.widget}); @override Widget build(BuildContext context) { diff --git a/lib/widgets/shared/card_with_bg_widget.dart b/lib/widgets/shared/card_with_bg_widget.dart index d7513975..6bf57eba 100644 --- a/lib/widgets/shared/card_with_bg_widget.dart +++ b/lib/widgets/shared/card_with_bg_widget.dart @@ -11,8 +11,8 @@ class CardWithBgWidget extends StatelessWidget { final double marginSymmetric; CardWithBgWidget( - {@required this.widget, - this.bgColor, + { required this.widget, + required this.bgColor, this.hasBorder = true, this.padding = 15.0, this.marginLeft = 10.0, diff --git a/lib/widgets/shared/charts/app_line_chart.dart b/lib/widgets/shared/charts/app_line_chart.dart deleted file mode 100644 index abb0cdc5..00000000 --- a/lib/widgets/shared/charts/app_line_chart.dart +++ /dev/null @@ -1,41 +0,0 @@ -import 'package:charts_flutter/flutter.dart' as charts; -import 'package:flutter/material.dart'; - -/* - *@author: Elham Rababah - *@Date:03/6/2020 - *@param: - *@return: - *@desc: AppLineChart - */ -class AppLineChart extends StatelessWidget { - const AppLineChart({ - Key ? key, - @required this.seriesList, - this.chartTitle, - }) : super(key: key); - - final List seriesList; - - final String chartTitle; - - @override - Widget build(BuildContext context) { - return Container( - child: Column( - children: [ - Text( - 'Body Mass Index', - style: TextStyle(fontSize: 24.0, fontWeight: FontWeight.bold), - ), - Expanded( - child: charts.LineChart(seriesList, - defaultRenderer: new charts.LineRendererConfig( - includeArea: false, stacked: true), - animate: true), - ), - ], - ), - ); - } -} diff --git a/lib/widgets/shared/charts/app_time_series_chart.dart b/lib/widgets/shared/charts/app_time_series_chart.dart deleted file mode 100644 index 76fd56f9..00000000 --- a/lib/widgets/shared/charts/app_time_series_chart.dart +++ /dev/null @@ -1,121 +0,0 @@ -import 'package:charts_flutter/flutter.dart' as charts; -import 'package:flutter/material.dart'; - -import '../../../config/size_config.dart'; -import '../../../models/patient/vital_sign/vital_sign_res_model.dart'; -import '../../../widgets/shared/rounded_container_widget.dart'; - -/* - *@author: Elham Rababah - *@Date:03/6/2020 - *@param: - *@return: - *@desc: AppTimeSeriesChart - */ -class AppTimeSeriesChart extends StatelessWidget { - AppTimeSeriesChart( - {Key ? key, - @required this.vitalList, - @required this.viewKey, - this.chartName = ''}); - - final List vitalList; - final String chartName; - final String viewKey; - List seriesList; - - @override - Widget build(BuildContext context) { - seriesList = generateData(); - return RoundedContainer( - height: SizeConfig.realScreenHeight * 0.47, - child: Column( - children: [ - Text( - chartName, - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: SizeConfig.textMultiplier * 3), - ), - Container( - height: SizeConfig.realScreenHeight * 0.37, - child: Center( - child: Container( - child: charts.TimeSeriesChart( - seriesList, - animate: true, - behaviors: [ - new charts.RangeAnnotation( - [ - new charts.RangeAnnotationSegment( - DateTime( - vitalList[vitalList.length - 1] - .vitalSignDate - .year, - vitalList[vitalList.length - 1] - .vitalSignDate - .month + - 3, - vitalList[vitalList.length - 1] - .vitalSignDate - .day), - vitalList[0].vitalSignDate, - charts.RangeAnnotationAxisType.domain), - ], - ), - ], - ), - ), - ), - ), - ], - ), - ); - } - - /* - *@author: Elham Rababah - *@Date:03/6/2020 - *@param: - *@return: - *@desc: generateData - */ - generateData() { - final List data = []; - if (vitalList.length > 0) { - vitalList.forEach( - (element) { - data.add( - TimeSeriesSales( - new DateTime(element.vitalSignDate.year, - element.vitalSignDate.month, element.vitalSignDate.day), - element.toJson()[viewKey].toInt(), - ), - ); - }, - ); - } - return [ - new charts.Series( - id: 'Sales', - domainFn: (TimeSeriesSales sales, _) => sales.time, - measureFn: (TimeSeriesSales sales, _) => sales.sales, - data: data, - ) - ]; - } -} - -/* - *@author: Elham Rababah - *@Date:03/6/2020 - *@param: - *@return: - *@desc: TimeSeriesSales - */ -class TimeSeriesSales { - final DateTime time; - final int sales; - - TimeSeriesSales(this.time, this.sales); -} diff --git a/lib/widgets/shared/dialogs/ShowImageDialog.dart b/lib/widgets/shared/dialogs/ShowImageDialog.dart index bb418d28..b4365248 100644 --- a/lib/widgets/shared/dialogs/ShowImageDialog.dart +++ b/lib/widgets/shared/dialogs/ShowImageDialog.dart @@ -4,7 +4,7 @@ import 'package:flutter/material.dart'; class ShowImageDialog extends StatelessWidget { final String imageUrl; - const ShowImageDialog({Key ? key, this.imageUrl}) : super(key: key); + const ShowImageDialog({Key? key, required this.imageUrl}) : super(key: key); @override Widget build(BuildContext context) { return SimpleDialog( diff --git a/lib/widgets/shared/dialogs/dailog-list-select.dart b/lib/widgets/shared/dialogs/dailog-list-select.dart index 4fabbded..01675194 100644 --- a/lib/widgets/shared/dialogs/dailog-list-select.dart +++ b/lib/widgets/shared/dialogs/dailog-list-select.dart @@ -9,16 +9,16 @@ class ListSelectDialog extends StatefulWidget { final okText; final Function(dynamic) okFunction; dynamic selectedValue; - final Widget searchWidget; + final Widget? searchWidget; final bool usingSearch; - final String hintSearchText; + final String? hintSearchText; ListSelectDialog({ - @required this.list, - @required this.attributeName, - @required this.attributeValueId, + required this.list, + required this.attributeName, + required this.attributeValueId, @required this.okText, - @required this.okFunction, + required this.okFunction, this.searchWidget, this.usingSearch = false, this.hintSearchText, @@ -46,7 +46,7 @@ class _ListSelectDialogState extends State { showAlertDialog(BuildContext context) { // set up the buttons Widget cancelButton = FlatButton( - child: Text(TranslationBase.of(context).cancel), + child: Text(TranslationBase.of(context).cancel ?? ""), onPressed: () { Navigator.of(context).pop(); }); @@ -73,13 +73,13 @@ class _ListSelectDialogState extends State { height: MediaQuery.of(context).size.height * 0.5, child: Column( children: [ - if (widget.searchWidget != null) widget.searchWidget, + if (widget.searchWidget != null) widget.searchWidget!, if (widget.usingSearch) Container( height: MediaQuery.of(context).size.height * 0.070, child: TextField( decoration: Helpers.textFieldSelectorDecoration( - widget.hintSearchText ?? TranslationBase.of(context).search, null, false, + widget.hintSearchText ?? TranslationBase.of(context).search??"", "", false, suffixIcon: Icon( Icons.search, )), diff --git a/lib/widgets/shared/dialogs/master_key_dailog.dart b/lib/widgets/shared/dialogs/master_key_dailog.dart index 7c12b54a..e185d31c 100644 --- a/lib/widgets/shared/dialogs/master_key_dailog.dart +++ b/lib/widgets/shared/dialogs/master_key_dailog.dart @@ -12,15 +12,11 @@ class MasterKeyDailog extends StatefulWidget { final List list; final okText; final Function(MasterKeyModel) okFunction; - MasterKeyModel selectedValue; + MasterKeyModel? selectedValue; final bool isICD; MasterKeyDailog( - {@required this.list, - @required this.okText, - @required this.okFunction, - this.selectedValue, - this.isICD = false}); + {required this.list, required this.okText, required this.okFunction, this.selectedValue, this.isICD = false}); @override _MasterKeyDailogState createState() => _MasterKeyDailogState(); @@ -42,14 +38,14 @@ class _MasterKeyDailogState extends State { showAlertDialog(BuildContext context, ProjectViewModel projectViewModel) { // set up the buttons Widget cancelButton = FlatButton( - child: AppText(TranslationBase.of(context).cancel, color: Colors.grey,fontSize: SizeConfig.getTextMultiplierBasedOnWidth() * (SizeConfig.isWidthLarge?3.5:5),), + child: AppText(TranslationBase.of(context)!.cancel!, color: Colors.grey,fontSize: SizeConfig.getTextMultiplierBasedOnWidth() * (SizeConfig.isWidthLarge?3.5:5),), onPressed: () { Navigator.of(context).pop(); }); Widget continueButton = FlatButton( child: AppText(this.widget.okText, color: Colors.grey,fontSize: SizeConfig.getTextMultiplierBasedOnWidth() * (SizeConfig.isWidthLarge?3.5:5),), onPressed: () { - this.widget.okFunction(widget.selectedValue); + this.widget.okFunction(widget.selectedValue!); Navigator.of(context).pop(); }); // set up the AlertDialog @@ -72,23 +68,15 @@ class _MasterKeyDailogState extends State { children: [ ...widget.list .map((item) => RadioListTile( - title: AppText( - '${projectViewModel.isArabic ? item.nameAr : item.nameEn}' + - (widget.isICD ? '/${item.code}' : ''), - - ), - groupValue: widget.isICD - ? widget.selectedValue.code.toString() - : widget.selectedValue.id.toString(), - value: widget.isICD - ? widget.selectedValue.code.toString() - : item.id.toString(), + title: AppText('${projectViewModel.isArabic ? item.nameAr : item.nameEn}' + + (widget.isICD ? '/${item.code}' : ''),), + groupValue: + widget.isICD ? widget.selectedValue!.code.toString() : widget.selectedValue!.id.toString(), + value: widget.isICD ? widget.selectedValue!.code.toString() : item.id.toString(), activeColor: Colors.blue.shade700, selected: widget.isICD - ? item.code.toString() == - widget.selectedValue.code.toString() - : item.id.toString() == - widget.selectedValue.id.toString(), + ? item.code.toString() == widget.selectedValue!.code.toString() + : item.id.toString() == widget.selectedValue!.id.toString(), onChanged: (val) { setState(() { widget.selectedValue = item; diff --git a/lib/widgets/shared/dialogs/search-drugs-dailog-list.dart b/lib/widgets/shared/dialogs/search-drugs-dailog-list.dart deleted file mode 100644 index 68dce5a4..00000000 --- a/lib/widgets/shared/dialogs/search-drugs-dailog-list.dart +++ /dev/null @@ -1,92 +0,0 @@ -import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; -import 'package:flutter/material.dart'; - -class ListSelectDialog extends StatefulWidget { - final List list; - final String attributeName; - final String attributeValueId; - final okText; - final Function(dynamic) okFunction; - dynamic selectedValue; - - ListSelectDialog( - {@required this.list, - @required this.attributeName, - @required this.attributeValueId, - @required this.okText, - @required this.okFunction}); - - @override - _ListSelectDialogState createState() => _ListSelectDialogState(); -} - -class _ListSelectDialogState extends State { - @override - void initState() { - super.initState(); - widget.selectedValue = widget.selectedValue ?? widget.list[0]; - } - - @override - Widget build(BuildContext context) { - return showAlertDialog(context); - } - - showAlertDialog(BuildContext context) { - // set up the buttons - Widget cancelButton = FlatButton( - child: Text(TranslationBase.of(context).cancel), - onPressed: () { - Navigator.of(context).pop(); - }); - Widget continueButton = FlatButton( - child: Text(this.widget.okText), - onPressed: () { - this.widget.okFunction(widget.selectedValue); - Navigator.of(context).pop(); - }); -// set up the AlertDialog - AlertDialog alert = AlertDialog( - // title: Text(widget.title), - content: createDialogList(), - actions: [ - cancelButton, - continueButton, - ], - ); - return alert; - } - - Widget createDialogList() { - return Container( - height: MediaQuery.of(context).size.height * 0.5, - child: SingleChildScrollView( - child: Column( - children: [ - ...widget.list - .map((item) => RadioListTile( - title: Text("${item[widget.attributeName].toString()}"), - groupValue: widget.selectedValue[widget.attributeValueId] - .toString(), - value: item[widget.attributeValueId].toString(), - activeColor: Colors.blue.shade700, - selected: item[widget.attributeValueId].toString() == - widget.selectedValue[widget.attributeValueId] - .toString(), - onChanged: (val) { - setState(() { - widget.selectedValue = item; - }); - }, - )) - .toList() - ], - ), - ), - ); - } - - static closeAlertDialog(BuildContext context) { - Navigator.of(context).pop(); - } -} diff --git a/lib/widgets/shared/doctor_card.dart b/lib/widgets/shared/doctor_card.dart index 5bd12bb8..cd8ba762 100644 --- a/lib/widgets/shared/doctor_card.dart +++ b/lib/widgets/shared/doctor_card.dart @@ -13,9 +13,9 @@ class DoctorCard extends StatelessWidget { final String branch; final DateTime appointmentDate; final String profileUrl; - final String invoiceNO; - final String orderNo; - final Function onTap; + final String? invoiceNO; + final String? orderNo; + final GestureTapCallback? onTap; final bool isPrescriptions; final String clinic; final bool isShowEye; @@ -23,15 +23,15 @@ class DoctorCard extends StatelessWidget { final bool isNoMargin; DoctorCard( - {this.doctorName, - this.branch, - this.profileUrl, + {required this.doctorName, + required this.branch, + required this.profileUrl, this.invoiceNO, this.onTap, - this.appointmentDate, + required this.appointmentDate, this.orderNo, this.isPrescriptions = false, - this.clinic, + required this.clinic, this.isShowEye = true, this.isShowTime= true, this.isNoMargin =false}); @override @@ -59,7 +59,7 @@ class DoctorCard extends StatelessWidget { children: [ Expanded( child: AppText( - doctorName ?? "", + doctorName, fontSize: 15, bold: true, )), @@ -73,7 +73,7 @@ class DoctorCard extends StatelessWidget { fontWeight: FontWeight.w600, fontSize: 14, ), - if (!isPrescriptions&& isShowTime) + if (!isPrescriptions && isShowTime) AppText( '${AppDateUtils.getHour(appointmentDate)}', fontWeight: FontWeight.w600, @@ -110,7 +110,7 @@ class DoctorCard extends StatelessWidget { Row( children: [ AppText( - TranslationBase.of(context).orderNo + + TranslationBase.of(context).orderNo??"" + " ", color: Colors.grey[500], fontSize: 14, @@ -126,7 +126,7 @@ class DoctorCard extends StatelessWidget { children: [ AppText( TranslationBase.of(context) - .invoiceNo + + .invoiceNo! + " ", fontSize: 14, color: Colors.grey[500], @@ -142,7 +142,7 @@ class DoctorCard extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.start, children: [ AppText( - TranslationBase.of(context).clinic + + TranslationBase.of(context).clinic! + ": ", color: Colors.grey[500], fontSize: 14, @@ -160,7 +160,7 @@ class DoctorCard extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.start, children: [ AppText( - TranslationBase.of(context).branch + + TranslationBase.of(context).branch!+ ": ", fontSize: 14, color: Colors.grey[500], diff --git a/lib/widgets/shared/doctor_card_insurance.dart b/lib/widgets/shared/doctor_card_insurance.dart index abb8efcc..7f88f820 100644 --- a/lib/widgets/shared/doctor_card_insurance.dart +++ b/lib/widgets/shared/doctor_card_insurance.dart @@ -10,22 +10,25 @@ import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; class DoctorCardInsurance extends StatelessWidget { - final String doctorName; - final String approvalNo; - final DateTime appointmentDate; - final String profileUrl; - final String invoiceNO; - final String orderNo; - final Function onTap; - final bool isInsurance; - final String clinic; - final String approvalStatus; - final String patientOut; - final String branch2; + final String? doctorName; + final String? branch; + final DateTime? appointmentDate; + final String? profileUrl; + final String? invoiceNO; + final String? orderNo; + final GestureTapCallback? onTap; + final bool? isPrescriptions; + final String? clinic; + final String? approvalStatus; + final String? patientOut; + final String? branch2; + + final bool? isInsurance; + final String? approvalNo; DoctorCardInsurance( {this.doctorName, - this.approvalNo, + this.branch, this.profileUrl, this.invoiceNO, this.onTap, @@ -35,7 +38,7 @@ class DoctorCardInsurance extends StatelessWidget { this.clinic, this.approvalStatus, this.patientOut, - this.branch2}); + this.branch2, this.isPrescriptions, this.approvalNo}); @override Widget build(BuildContext context) { @@ -129,7 +132,7 @@ class DoctorCardInsurance extends StatelessWidget { children: [ Container( child: LargeAvatar( - name: doctorName, + name: doctorName??"", url: profileUrl, ), width: 55, @@ -142,36 +145,36 @@ class DoctorCardInsurance extends StatelessWidget { child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - if (orderNo != null && !isInsurance) + if (orderNo != null && !isInsurance!) CustomRow( label: 'Invoice:', - value: invoiceNO, + value: invoiceNO??"", ), - if (invoiceNO != null && !isInsurance) + if (invoiceNO != null && !isInsurance!) CustomRow( label: 'Invoice:', - value: invoiceNO, + value: invoiceNO??'', ), - if (isInsurance) + if (isInsurance!) CustomRow( label: - TranslationBase.of(context).clinic + + TranslationBase.of(context).clinic! + ": ", - value: clinic, + value: clinic??'', ), if (branch2 != null) CustomRow( label: - TranslationBase.of(context).branch + + TranslationBase.of(context).branch! + ": ", - value: branch2, + value: branch2??'', ), if (approvalNo != null) CustomRow( label: TranslationBase.of(context) - .approvalNo + + .approvalNo! + ": ", - value: approvalNo, + value: approvalNo!, ), ]), ), diff --git a/lib/widgets/shared/drawer_item_widget.dart b/lib/widgets/shared/drawer_item_widget.dart index 46497e17..75b889f5 100644 --- a/lib/widgets/shared/drawer_item_widget.dart +++ b/lib/widgets/shared/drawer_item_widget.dart @@ -8,12 +8,12 @@ import '../shared/app_texts_widget.dart'; class DrawerItem extends StatefulWidget { final String title; final String subTitle; - final IconData icon; - final Color color; - final String assetLink; + final IconData? icon; + final Color? color; + final String? assetLink; + final double? drawerWidth; - DrawerItem(this.title, - {this.icon, this.color, this.subTitle = '', this.assetLink}); + DrawerItem(this.title, {this.icon, this.color, this.subTitle = '', this.assetLink, this.drawerWidth}); @override _DrawerItemState createState() => _DrawerItemState(); @@ -31,7 +31,7 @@ class _DrawerItemState extends State { Container( height: 20, width: 20, - child: Image.asset(widget.assetLink), + child: Image.asset(widget.assetLink!), ), if (widget.assetLink == null) Icon( diff --git a/lib/widgets/shared/errors/dr_app_embedded_error.dart b/lib/widgets/shared/errors/dr_app_embedded_error.dart index f97c1e93..72fbe92c 100644 --- a/lib/widgets/shared/errors/dr_app_embedded_error.dart +++ b/lib/widgets/shared/errors/dr_app_embedded_error.dart @@ -11,8 +11,8 @@ import '../app_texts_widget.dart'; */ class DrAppEmbeddedError extends StatelessWidget { const DrAppEmbeddedError({ - Key ? key, - @required this.error, + Key? key, + required this.error, }) : super(key: key); final String error; diff --git a/lib/widgets/shared/errors/error_message.dart b/lib/widgets/shared/errors/error_message.dart index 2a58518e..86798937 100644 --- a/lib/widgets/shared/errors/error_message.dart +++ b/lib/widgets/shared/errors/error_message.dart @@ -5,8 +5,8 @@ import '../app_texts_widget.dart'; class ErrorMessage extends StatelessWidget { const ErrorMessage({ - Key ? key, - @required this.error, + Key? key, + required this.error, }) : super(key: key); final String error; diff --git a/lib/widgets/shared/expandable-widget-header-body.dart b/lib/widgets/shared/expandable-widget-header-body.dart index 20d95bcd..9f92432d 100644 --- a/lib/widgets/shared/expandable-widget-header-body.dart +++ b/lib/widgets/shared/expandable-widget-header-body.dart @@ -2,10 +2,10 @@ import 'package:expandable/expandable.dart'; import 'package:flutter/material.dart'; class HeaderBodyExpandableNotifier extends StatefulWidget { - final Widget headerWidget; - final Widget bodyWidget; - final Widget collapsed; - final bool isExpand; + final Widget? headerWidget; + final Widget? bodyWidget; + final Widget? collapsed; + final bool? isExpand; bool expandFlag = false; var controller = new ExpandableController(); @@ -28,7 +28,7 @@ class _HeaderBodyExpandableNotifierState Widget build(BuildContext context) { setState(() { if (widget.isExpand == true) { - widget.expandFlag = widget.isExpand; + widget.expandFlag = widget.isExpand!; widget.controller.expanded = true; } }); @@ -50,7 +50,7 @@ class _HeaderBodyExpandableNotifierState ), // header: widget.headerWidget, collapsed: Container(), - expanded: widget.bodyWidget, + expanded: widget.bodyWidget!, builder: (_, collapsed, expanded) { return Padding( padding: EdgeInsets.only(left: 0, right: 0, bottom: 0), diff --git a/lib/widgets/shared/loader/gif_loader_container.dart b/lib/widgets/shared/loader/gif_loader_container.dart index b2c2224b..d8a67921 100644 --- a/lib/widgets/shared/loader/gif_loader_container.dart +++ b/lib/widgets/shared/loader/gif_loader_container.dart @@ -6,17 +6,15 @@ class GifLoaderContainer extends StatefulWidget { _GifLoaderContainerState createState() => _GifLoaderContainerState(); } -class _GifLoaderContainerState extends State - with TickerProviderStateMixin { - GifController controller1; +class _GifLoaderContainerState extends State with TickerProviderStateMixin { + late GifController controller1; @override void initState() { controller1 = GifController(vsync: this); - WidgetsBinding.instance.addPostFrameCallback((_) { - controller1.repeat( - min: 0, max: 11, period: Duration(milliseconds: 750), reverse: true); + WidgetsBinding.instance!.addPostFrameCallback((_) { + controller1.repeat(min: 0, max: 11, period: Duration(milliseconds: 750), reverse: true); }); super.initState(); } diff --git a/lib/widgets/shared/master_key_checkbox_search_widget.dart b/lib/widgets/shared/master_key_checkbox_search_widget.dart index dbba1da2..e13806aa 100644 --- a/lib/widgets/shared/master_key_checkbox_search_widget.dart +++ b/lib/widgets/shared/master_key_checkbox_search_widget.dart @@ -19,17 +19,17 @@ class MasterKeyCheckboxSearchWidget extends StatefulWidget { final Function(MasterKeyModel) addHistory; final bool Function(MasterKeyModel) isServiceSelected; final List masterList; - final String buttonName; - final String hintSearchText; + final String? buttonName; + final String? hintSearchText; MasterKeyCheckboxSearchWidget( - {Key ? key, - this.model, - this.addSelectedHistories, - this.removeHistory, - this.masterList, - this.addHistory, - this.isServiceSelected, + {Key? key, + required this.model, + required this.addSelectedHistories, + required this.removeHistory, + required this.masterList, + required this.addHistory, + required this.isServiceSelected, this.buttonName, this.hintSearchText}) : super(key: key); @@ -86,10 +86,11 @@ class _MasterKeyCheckboxSearchWidgetState filterSearchResults(value); }, suffixIcon: IconButton( + onPressed: () {}, icon: Icon( - Icons.search, - color: Colors.black, - )), + Icons.search, + color: Colors.black, + )), ), // SizedBox(height: 15,), @@ -113,13 +114,11 @@ class _MasterKeyCheckboxSearchWidgetState child: Row( children: [ Checkbox( - value: widget - .isServiceSelected(historyInfo), + value: widget.isServiceSelected(historyInfo), activeColor: Colors.red[800], - onChanged: (bool newValue) { + onChanged: (bool? newValue) { setState(() { - if (widget.isServiceSelected( - historyInfo)) { + if (widget.isServiceSelected(historyInfo)) { widget.removeHistory(historyInfo); } else { widget.addHistory(historyInfo); @@ -167,8 +166,8 @@ class _MasterKeyCheckboxSearchWidgetState if (query.isNotEmpty) { List dummyListData = []; dummySearchList.forEach((item) { - if (item.nameAr.toLowerCase().contains(query.toLowerCase()) || - item.nameEn.toLowerCase().contains(query.toLowerCase())) { + if (item.nameAr!.toLowerCase().contains(query.toLowerCase()) || + item.nameEn!.toLowerCase().contains(query.toLowerCase())) { dummyListData.add(item); } }); diff --git a/lib/widgets/shared/network_base_view.dart b/lib/widgets/shared/network_base_view.dart index 1e7b00fd..68b6c1cd 100644 --- a/lib/widgets/shared/network_base_view.dart +++ b/lib/widgets/shared/network_base_view.dart @@ -7,10 +7,10 @@ import 'app_loader_widget.dart'; import 'errors/error_message.dart'; class NetworkBaseView extends StatelessWidget { - final BaseViewModel baseViewModel; - final Widget child; + final BaseViewModel? baseViewModel; + final Widget? child; - NetworkBaseView({Key ? key, this.baseViewModel, this.child}); + NetworkBaseView({Key? key, this.baseViewModel, this.child}); @override Widget build(BuildContext context) { @@ -21,7 +21,7 @@ class NetworkBaseView extends StatelessWidget { } buildBaseViewWidget() { - switch (baseViewModel.state) { + switch (baseViewModel!.state) { case ViewState.ErrorLocal: case ViewState.Idle: case ViewState.BusyLocal: @@ -31,7 +31,9 @@ class NetworkBaseView extends StatelessWidget { return AppLoaderWidget(); break; case ViewState.Error: - return ErrorMessage(error: baseViewModel.error ,); + return ErrorMessage( + error: baseViewModel!.error, + ); break; } } diff --git a/lib/widgets/shared/profile_image_widget.dart b/lib/widgets/shared/profile_image_widget.dart index 3db93f9d..70a7356f 100644 --- a/lib/widgets/shared/profile_image_widget.dart +++ b/lib/widgets/shared/profile_image_widget.dart @@ -10,21 +10,15 @@ import 'package:flutter/material.dart'; *@desc: Profile Image Widget class */ class ProfileImageWidget extends StatelessWidget { - String url; - String name; - String des; - double height; - double width; - Color color; - double fontsize; + String? url; + String? name; + String? des; + double? height; + double? width; + Color? color; + double? fontsize; ProfileImageWidget( - {this.url, - this.name, - this.des, - this.height, - this.width, - this.fontsize, - this.color = Colors.black}); + {this.url, this.name, this.des, this.height, this.width, this.fontsize, this.color = Colors.black}); @override Widget build(BuildContext context) { @@ -42,7 +36,7 @@ class ProfileImageWidget extends StatelessWidget { borderRadius:BorderRadius.circular(50), child: Image.network( - url, + url!, fit: BoxFit.fill, width: 700, ), diff --git a/lib/widgets/shared/rounded_container_widget.dart b/lib/widgets/shared/rounded_container_widget.dart index 9c622dd3..3f8804de 100644 --- a/lib/widgets/shared/rounded_container_widget.dart +++ b/lib/widgets/shared/rounded_container_widget.dart @@ -1,24 +1,24 @@ import 'package:flutter/material.dart'; class RoundedContainer extends StatefulWidget { - final double width; - final double height; - final double raduis; - final Color backgroundColor; - final EdgeInsets margin; - final double elevation; - final bool showBorder; - final Color borderColor; - final double shadowWidth; - final double shadowSpreadRadius; - final double shadowDy; - final bool customCornerRaduis; - final double topLeft; - final double bottomRight; - final double topRight; - final double bottomLeft; - final Widget child; - final double borderWidth; + final double? width; + final double? height; + final double? raduis; + final Color? backgroundColor; + final EdgeInsets? margin; + final double? elevation; + final bool? showBorder; + final Color? borderColor; + final double? shadowWidth; + final double? shadowSpreadRadius; + final double? shadowDy; + final bool? customCornerRaduis; + final double? topLeft; + final double? bottomRight; + final double? topRight; + final double? bottomLeft; + final Widget? child; + final double? borderWidth; RoundedContainer( {@required this.child, @@ -54,22 +54,21 @@ class _RoundedContainerState extends State { decoration: widget.showBorder == true ? BoxDecoration( color: Colors.white/*Theme.of(context).primaryColor*/, - border: Border.all( - color: widget.borderColor, width: widget.borderWidth), - borderRadius: widget.customCornerRaduis + border: Border.all(color: widget.borderColor!, width: widget.borderWidth!), + borderRadius: widget.customCornerRaduis! ? BorderRadius.only( - topLeft: Radius.circular(widget.topLeft), - topRight: Radius.circular(widget.topRight), - bottomRight: Radius.circular(widget.bottomRight), - bottomLeft: Radius.circular(widget.bottomLeft)) - : BorderRadius.circular(widget.raduis), + topLeft: Radius.circular(widget.topLeft!), + topRight: Radius.circular(widget.topRight!), + bottomRight: Radius.circular(widget.bottomRight!), + bottomLeft: Radius.circular(widget.bottomLeft!)) + : BorderRadius.circular(widget.raduis!), boxShadow: [ BoxShadow( - color: Colors.grey.withOpacity(widget.shadowWidth), - spreadRadius: widget.shadowSpreadRadius, + color: Colors.grey.withOpacity(widget.shadowWidth!), + spreadRadius: widget.shadowSpreadRadius!, blurRadius: 5, offset: Offset( - 0, widget.shadowDy), // changes position of shadow + 0, widget.shadowDy!), // changes position of shadow ), ], ) @@ -77,13 +76,13 @@ class _RoundedContainerState extends State { child: Card( margin: EdgeInsets.all(0), shape: RoundedRectangleBorder( - borderRadius: widget.customCornerRaduis + borderRadius: widget.customCornerRaduis! ? BorderRadius.only( - topLeft: Radius.circular(widget.topLeft), - topRight: Radius.circular(widget.topRight), - bottomRight: Radius.circular(widget.bottomRight), - bottomLeft: Radius.circular(widget.bottomLeft)) - : BorderRadius.circular(widget.raduis), + topLeft: Radius.circular(widget.topLeft!), + topRight: Radius.circular(widget.topRight!), + bottomRight: Radius.circular(widget.bottomRight!), + bottomLeft: Radius.circular(widget.bottomLeft!)) + : BorderRadius.circular(widget.raduis!), ), color: widget.backgroundColor, child: widget.child, diff --git a/lib/widgets/shared/speech-text-popup.dart b/lib/widgets/shared/speech-text-popup.dart index dad7e2d1..82583ad0 100644 --- a/lib/widgets/shared/speech-text-popup.dart +++ b/lib/widgets/shared/speech-text-popup.dart @@ -15,7 +15,7 @@ class SpeechToText { static var dialog; static stt.SpeechToText speech = stt.SpeechToText(); SpeechToText({ - @required this.context, + required this.context, }); showAlertDialog(BuildContext context) { @@ -44,7 +44,7 @@ typedef Disposer = void Function(); class MyStatefulBuilder extends StatefulWidget { const MyStatefulBuilder({ // @required this.builder, - @required this.dispose, + required this.dispose, }); //final StatefulWidgetBuilder builder; @@ -57,7 +57,7 @@ class MyStatefulBuilder extends StatefulWidget { class _MyStatefulBuilderState extends State { var event = RobotProvider(); var searchText; - static StreamSubscription streamSubscription; + static StreamSubscription? streamSubscription; static var isClosed = false; @override void initState() { @@ -135,7 +135,7 @@ class _MyStatefulBuilderState extends State { child: InkWell( child: Container( decoration: BoxDecoration( - border: Border.all(color: Colors.grey[300])), + border: Border.all(color: Colors.grey[300]!)), padding: EdgeInsets.all(5), child: AppText( 'Try Again', diff --git a/lib/widgets/shared/text_fields/app-textfield-custom.dart b/lib/widgets/shared/text_fields/app-textfield-custom.dart index 30a5234a..9e6e1361 100644 --- a/lib/widgets/shared/text_fields/app-textfield-custom.dart +++ b/lib/widgets/shared/text_fields/app-textfield-custom.dart @@ -26,9 +26,9 @@ class AppTextFieldCustom extends StatefulWidget { final Function(String)? onChanged; final VoidCallback? onFieldSubmitted; - final String validationError; - final bool isPrscription; - final bool isSecure; + final String? validationError; + final bool? isPrscription; + final bool? isSecure; final bool focus; final bool isSearchTextField; @@ -94,10 +94,8 @@ class _AppTextFieldCustomState extends State { return Column( children: [ Container( - height: widget.height != 0 && widget.maxLines == 1 - ? widget.height + 8 - : MediaQuery.of(context).size.height * 0.098, - decoration: widget.hasBorder + height: widget.height != 0 && widget.maxLines == 1 ? widget.height! + 8 : null, + decoration: widget.hasBorder! ? TextFieldsUtils.containerBorderDecoration( Color(0Xffffffff), widget.validationError == null @@ -127,7 +125,7 @@ class _AppTextFieldCustomState extends State { // widget.controller.text != "") || // widget.dropDownText != null) AppText( - widget.hintText, + widget.hintText!, // marginTop: widget.hasHintmargin ? 0 : 30, color: Color(0xFF2E303A), fontSize: widget.isPrscription == false @@ -143,7 +141,7 @@ class _AppTextFieldCustomState extends State { ? Container( height: widget.height != 0 && widget.maxLines == 1 - ? widget.height - 22 + ? widget.height!- 22 : MediaQuery.of(context).size.height * 0.045, child: TextFormField( @@ -154,7 +152,8 @@ class _AppTextFieldCustomState extends State { textAlignVertical: TextAlignVertical.top, decoration: TextFieldsUtils .textFieldSelectorDecoration( - widget.hintText, null, true), + widget.hintText!, + "", true), style: TextStyle( fontSize: 14.0, //SizeConfig.textMultiplier * 1.7, @@ -178,14 +177,14 @@ class _AppTextFieldCustomState extends State { onChanged: (value) { setState(() {}); if (widget.onChanged != null) { - widget.onChanged(value); + widget.onChanged!(value); } }, onFieldSubmitted: (_)=>widget.onFieldSubmitted, - obscureText: widget.isSecure), + obscureText: widget.isSecure!), ) : AppText( - widget.dropDownText, + widget!.dropDownText!, fontFamily: 'Poppins', color: Color(0xFF575757), fontSize: SizeConfig.textMultiplier * 1.7, @@ -194,12 +193,12 @@ class _AppTextFieldCustomState extends State { ), ), ), - widget.isTextFieldHasSuffix + widget.isTextFieldHasSuffix! ? widget.suffixIcon != null ? Container( margin: EdgeInsets.only( bottom: widget.isSearchTextField - ? (widget.controller.text.isEmpty || + ? (widget.controller!.text.isEmpty || widget.controller == null) ? 10 : 25 @@ -219,8 +218,7 @@ class _AppTextFieldCustomState extends State { ), ), ), - if (widget.validationError != null && widget.validationError.isNotEmpty) - TextFieldsError(error: widget.validationError), + if (widget.validationError != null && widget.validationError!.isNotEmpty) TextFieldsError(error: widget!.validationError!), ], ); } diff --git a/lib/widgets/shared/text_fields/app_text_field_custom_serach.dart b/lib/widgets/shared/text_fields/app_text_field_custom_serach.dart index cb73a143..a32588db 100644 --- a/lib/widgets/shared/text_fields/app_text_field_custom_serach.dart +++ b/lib/widgets/shared/text_fields/app_text_field_custom_serach.dart @@ -9,7 +9,7 @@ import 'app-textfield-custom.dart'; class AppTextFieldCustomSearch extends StatelessWidget { const AppTextFieldCustomSearch({ - Key ? key, + Key? key, this.onChangeFun, this.positionedChild, this.marginTop, @@ -26,19 +26,18 @@ class AppTextFieldCustomSearch extends StatelessWidget { final Function(String)? onChangeFun; final Function(String)? onFieldSubmitted; - final Widget positionedChild; - final IconButton suffixIcon; - final double marginTop; - final String validationError; - final String hintText; + final Widget ?positionedChild; + final IconButton? suffixIcon; + final double? marginTop; + final String? validationError; + final String? hintText; - final TextInputType inputType; - final List inputFormatters; + final TextInputType? inputType; + final List? inputFormatters; @override Widget build(BuildContext context) { - ProjectViewModel projectViewModel = Provider.of(context); return Container( - margin: EdgeInsets.only(left: 16, right: 16, bottom: 16, top: marginTop), + margin: EdgeInsets.only(left: 16, right: 16, bottom: 16, top: marginTop!), child: Stack( children: [ AppTextFieldCustom( @@ -60,7 +59,7 @@ class AppTextFieldCustomSearch extends StatelessWidget { onFieldSubmitted: ()=>onFieldSubmitted, validationError: validationError), if (positionedChild != null) - projectViewModel.isArabic?Positioned(left: 35, top: 5, child: positionedChild):Positioned(right: 35, top: 5, child: positionedChild) + Positioned(right: 35, top: 5, child: positionedChild!) ], ), ); diff --git a/lib/widgets/shared/text_fields/app_text_form_field.dart b/lib/widgets/shared/text_fields/app_text_form_field.dart index 7d3a06da..b58f8176 100644 --- a/lib/widgets/shared/text_fields/app_text_form_field.dart +++ b/lib/widgets/shared/text_fields/app_text_form_field.dart @@ -6,22 +6,22 @@ import 'package:hexcolor/hexcolor.dart'; class AppTextFormField extends FormField { AppTextFormField( - {FormFieldSetter onSaved, - String inputFormatter, - FormFieldValidator validator, - ValueChanged onChanged, - GestureTapCallback onTap, + {FormFieldSetter? onSaved, + String? inputFormatter, + FormFieldValidator? validator, + ValueChanged? onChanged, + GestureTapCallback? onTap, bool obscureText = false, - TextEditingController controller, + TextEditingController? controller, bool autovalidate = true, - TextInputType textInputType, - String hintText, - FocusNode focusNode, - TextInputAction textInputAction=TextInputAction.done, - ValueChanged onFieldSubmitted, - IconButton prefix, - String labelText, - IconData suffixIcon, + TextInputType? textInputType, + String? hintText, + FocusNode? focusNode, + TextInputAction textInputAction = TextInputAction.done, + ValueChanged? onFieldSubmitted, + IconButton? prefix, + String? labelText, + IconData? suffixIcon, bool readOnly = false, borderColor}) : super( @@ -83,7 +83,7 @@ class AppTextFormField extends FormField { ), state.hasError ? Text( - state.errorText, + state.errorText ?? "", style: TextStyle(color: Colors.red), ) : Container() diff --git a/lib/widgets/shared/text_fields/auto_complete_text_field.dart b/lib/widgets/shared/text_fields/auto_complete_text_field.dart index 386ec459..d85b3468 100644 --- a/lib/widgets/shared/text_fields/auto_complete_text_field.dart +++ b/lib/widgets/shared/text_fields/auto_complete_text_field.dart @@ -8,9 +8,9 @@ class CustomAutoCompleteTextField extends StatelessWidget { final Widget child; const CustomAutoCompleteTextField({ - Key ? key, - this.isShowError, - this.child, + Key? key, + required this.isShowError, + required this.child, }) : super(key: key); @@ -31,7 +31,7 @@ class CustomAutoCompleteTextField extends StatelessWidget { ), if (isShowError) TextFieldsError( - error: TranslationBase.of(context).emptyMessage, + error: TranslationBase.of(context).emptyMessage ?? "", ) ], ), diff --git a/lib/widgets/shared/text_fields/country_textfield_custom.dart b/lib/widgets/shared/text_fields/country_textfield_custom.dart index 603bcc26..145ece5e 100644 --- a/lib/widgets/shared/text_fields/country_textfield_custom.dart +++ b/lib/widgets/shared/text_fields/country_textfield_custom.dart @@ -7,16 +7,16 @@ import 'package:flutter/material.dart'; class CountryTextField extends StatefulWidget { final dynamic element; - final String elementError; - final List elementList; - final String keyName; - final String keyId; - final String hintText; - final double width; - final Function(dynamic) okFunction; + final String? elementError; + final List? elementList; + final String? keyName; + final String? keyId; + final String? hintText; + final double? width; + final Function(dynamic)? okFunction; CountryTextField( - {Key ? key, + {Key? key, @required this.element, @required this.elementError, this.width, @@ -41,14 +41,14 @@ class _CountryTextfieldState extends State { ? () { Helpers.hideKeyboard(context); ListSelectDialog dialog = ListSelectDialog( - list: widget.elementList, + list: widget.elementList!, attributeName: '${widget.keyName}', - attributeValueId: widget.elementList.length == 1 - ? widget.elementList[0]['${widget.keyId}'] + attributeValueId: widget.elementList!.length == 1 + ? widget.elementList![0]['${widget.keyId}'] : '${widget.keyId}', okText: TranslationBase.of(context).ok, okFunction: (selectedValue) => - widget.okFunction(selectedValue), + widget.okFunction!(selectedValue), ); showDialog( barrierDismissible: false, @@ -61,14 +61,14 @@ class _CountryTextfieldState extends State { : null, child: AppTextFieldCustom( hintText: widget.hintText, - dropDownText: widget.elementList.length == 1 - ? widget.elementList[0]['${widget.keyName}'] + 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, + widget.elementList!.length != 1 ? widget.elementError : null, enabled: false, ), ), diff --git a/lib/widgets/shared/text_fields/html_rich_editor.dart b/lib/widgets/shared/text_fields/html_rich_editor.dart index 71359604..3b9db9c6 100644 --- a/lib/widgets/shared/text_fields/html_rich_editor.dart +++ b/lib/widgets/shared/text_fields/html_rich_editor.dart @@ -12,7 +12,16 @@ import 'package:speech_to_text/speech_to_text.dart' as stt; import '../speech-text-popup.dart'; class HtmlRichEditor extends StatefulWidget { - HtmlRichEditor({ + final String hint; + final String? initialText; + final double height; + final BoxDecoration? decoration; + final bool darkMode; + final bool showBottomToolbar; + final List? toolbar; + final HtmlEditorController controller; + + HtmlRichEditor({ key, this.hint = "Your text here...", this.initialText, @@ -21,22 +30,15 @@ class HtmlRichEditor extends StatefulWidget { this.darkMode = false, this.showBottomToolbar = false, this.toolbar, + required this.controller, }) : super(key: key); - final String hint; - final String initialText; - final double height; - final BoxDecoration decoration; - final bool darkMode; - final bool showBottomToolbar; - final List toolbar; - @override _HtmlRichEditorState createState() => _HtmlRichEditorState(); } class _HtmlRichEditorState extends State { - ProjectViewModel projectViewModel; + late ProjectViewModel projectViewModel; stt.SpeechToText speech = stt.SpeechToText(); var recognizedWord; var event = RobotProvider(); @@ -64,51 +66,42 @@ class _HtmlRichEditorState extends State { return Stack( children: [ HtmlEditor( - hint: widget.hint, - height: widget.height, - initialText: widget.initialText, - showBottomToolbar: widget.showBottomToolbar, - darkMode: widget.darkMode, - decoration: widget.decoration ?? - BoxDecoration( - color: Colors.transparent, - borderRadius: BorderRadius.all( - Radius.circular(30.0), - ), - border: Border.all(color: Colors.grey[200], width: 0.5), - ), - toolbar: widget.toolbar ?? - const [ - // Style(), - Font(buttons: [ - FontButtons.bold, - FontButtons.italic, - FontButtons.underline, - ]), - // ColorBar(buttons: [ColorButtons.color]), - Paragraph(buttons: [ - ParagraphButtons.ul, - ParagraphButtons.ol, - ParagraphButtons.paragraph - ]), - // Insert(buttons: [InsertButtons.link, InsertButtons.picture, InsertButtons.video, InsertButtons.table]), - // Misc(buttons: [MiscButtons.fullscreen, MiscButtons.codeview, MiscButtons.help]) - ], - ), + controller: widget.controller, + htmlToolbarOptions: HtmlToolbarOptions(defaultToolbarButtons: [ + StyleButtons(), + FontSettingButtons(), + FontButtons(), + // ColorButtons(), + ListButtons(), + ParagraphButtons(), + // InsertButtons(), + // OtherButtons(), + ]), + htmlEditorOptions: HtmlEditorOptions( + hint: widget.hint, + initialText: widget.initialText, + darkMode: widget.darkMode, + ), + otherOptions: OtherOptions( + height: widget.height, + decoration: widget.decoration ?? + BoxDecoration( + color: Colors.transparent, + borderRadius: BorderRadius.all( + Radius.circular(30.0), + ), + border: Border.all(color: Colors.grey[200]!, width: 0.5), + ), + )), Positioned( - top: - 50, //MediaQuery.of(context).size.height * 0, - right: projectViewModel.isArabic - ? MediaQuery.of(context).size.width * 0.75 - : 15, + top: 50, //MediaQuery.of(context).size.height * 0, + right: projectViewModel.isArabic ? MediaQuery.of(context).size.width * 0.75 : 15, child: Column( children: [ IconButton( - icon: Icon(DoctorApp.speechtotext, - color: Colors.black, size: 35), + icon: Icon(DoctorApp.speechtotext, color: Colors.black, size: 35), onPressed: () { - initSpeechState() - .then((value) => {onVoiceText()}); + initSpeechState().then((value) => {onVoiceText()}); }, ), ], @@ -121,8 +114,7 @@ class _HtmlRichEditorState 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, @@ -150,15 +142,15 @@ class _HtmlRichEditorState extends State { ].request(); } - void resultListener(result)async { + void resultListener(result) async { recognizedWord = result.recognizedWords; event.setValue({"searchText": recognizedWord}); - String txt = await HtmlEditor.getText(); + String txt = await widget.controller.getText(); if (result.finalResult == true) { setState(() { SpeechToText.closeAlertDialog(context); speech.stop(); - HtmlEditor.setText(txt+recognizedWord); + widget.controller.setText(txt + recognizedWord); }); } else { print(result.finalResult); diff --git a/lib/widgets/shared/text_fields/new_text_Field.dart b/lib/widgets/shared/text_fields/new_text_Field.dart index 3319719a..a01d21a8 100644 --- a/lib/widgets/shared/text_fields/new_text_Field.dart +++ b/lib/widgets/shared/text_fields/new_text_Field.dart @@ -41,77 +41,88 @@ final _mobileFormatter = NumberTextInputFormatter(); class NewTextFields extends StatefulWidget { NewTextFields( - {Key ? key, - this.type, - this.hintText, - this.suffixIcon, - this.autoFocus, - this.onChanged, - this.initialValue, - this.minLines, - this.maxLines, - this.inputFormatters, - this.padding, - this.focus = false, - this.maxLengthEnforced = true, - this.suffixIconColor, - this.inputAction, - this.onSubmit, - this.keepPadding = true, - this.textCapitalization = TextCapitalization.none, - this.controller, - this.keyboardType, - this.validator, - this.borderOnlyError = false, - this.onSaved, - this.onSuffixTap, - this.readOnly: false, - this.maxLength, - this.prefixIcon, - this.bare = false, - this.onTap, - this.fontSize = 15.0, - this.fontWeight = FontWeight.w500, - this.autoValidate = false, - this.hintColor, - this.isEnabled = true}) + {Key? key, + this.type, + this.hintText, + this.suffixIcon, + this.autoFocus, + this.onChanged, + this.initialValue, + this.minLines, + this.maxLines, + this.inputFormatters, + this.padding, + this.focus = false, + this.maxLengthEnforced = true, + this.suffixIconColor, + this.inputAction, + this.onSubmit, + this.keepPadding = true, + this.textCapitalization = TextCapitalization.none, + this.controller, + this.keyboardType, + this.validator, + this.borderOnlyError = false, + this.onSaved, + this.onSuffixTap, + this.readOnly: false, + this.maxLength, + this.prefixIcon, + this.bare = false, + this.onTap, + this.fontSize = 15.0, + this.fontWeight = FontWeight.w500, + this.autoValidate = false, + this.hintColor, + this.isEnabled = true, + this.onTapTextFields, + this.fillColor, + this.hasBorder, + this.showLabelText, + this.borderRadius, + this.borderWidth}) : super(key: key); - - final String hintText; - - // final String initialValue; - final String type; - final bool autoFocus; - final IconData suffixIcon; - final Color suffixIconColor; - final Icon prefixIcon; - final VoidCallback onTap; - final TextEditingController controller; - final TextInputType keyboardType; - final FormFieldValidator validator; - final Function onSaved; - final Function onSuffixTap; - final Function onChanged; - final Function onSubmit; - final bool readOnly; - final int maxLength; - final int minLines; - final int maxLines; - final bool maxLengthEnforced; - final bool bare; - final bool isEnabled; - final TextInputAction inputAction; - final double fontSize; - final FontWeight fontWeight; - final bool keepPadding; - final TextCapitalization textCapitalization; - final List inputFormatters; - final bool autoValidate; - final EdgeInsets padding; - final bool focus; - final bool borderOnlyError; - final Color hintColor; - final String initialValue; + final String? hintText; + final String? initialValue; + final String? type; + final bool? autoFocus; + final bool? isEnabled; + final IconData? suffixIcon; + final Color? suffixIconColor; + final Icon? prefixIcon; + final VoidCallback? onTap; + final GestureTapCallback? onTapTextFields; + final TextEditingController? controller; + final TextInputType? keyboardType; + final FormFieldValidator? validator; + final FormFieldSetter? onSaved; + final GestureTapCallback? onSuffixTap; + final ValueChanged? onChanged; + final ValueChanged? onSubmit; + final bool? readOnly; + final int? maxLength; + final int? minLines; + final int? maxLines; + final bool? maxLengthEnforced; + final bool? bare; + final TextInputAction? inputAction; + final double? fontSize; + final FontWeight? fontWeight; + final bool? keepPadding; + final TextCapitalization? textCapitalization; + final List? inputFormatters; + final bool? autoValidate; + final EdgeInsets? padding; + final bool? focus; + final bool? borderOnlyError; + final Color? hintColor; + final Color? fillColor; + final bool? hasBorder; + final bool? showLabelText; + Color? borderColor; + final double? borderRadius; + final double? borderWidth; + bool? hasLabelText; @override _NewTextFieldsState createState() => _NewTextFieldsState(); } @@ -133,7 +144,7 @@ class _NewTextFieldsState extends State { @override void didUpdateWidget(NewTextFields oldWidget) { - if (widget.focus) _focusNode.requestFocus(); + if (widget.focus!) _focusNode.requestFocus(); super.didUpdateWidget(oldWidget); } @@ -144,7 +155,7 @@ class _NewTextFieldsState extends State { } bool _determineReadOnly() { - if (widget.readOnly != null && widget.readOnly) { + if (widget.readOnly != null && widget.readOnly!) { _focusNode.unfocus(); return true; } else { @@ -172,8 +183,8 @@ class _NewTextFieldsState extends State { initialValue: widget.initialValue, keyboardAppearance: Theme.of(context).brightness, scrollPhysics: BouncingScrollPhysics(), - // autovalidate: widget.autoValidate, - textCapitalization: widget.textCapitalization, + // autovalidate: widget.autoValidate!, + textCapitalization: widget.textCapitalization!, onFieldSubmitted: widget.inputAction == TextInputAction.next ? (widget.onSubmit != null ? widget.onSubmit @@ -184,8 +195,8 @@ class _NewTextFieldsState extends State { textInputAction: widget.inputAction, minLines: widget.minLines ?? 1, maxLines: widget.maxLines ?? 1, - maxLengthEnforced: widget.maxLengthEnforced, - onChanged: widget.onChanged, + // maxLengthEnforced: widget.maxLengthEnforced!, + onChanged: widget.onChanged!, focusNode: _focusNode, maxLength: widget.maxLength ?? null, controller: widget.controller, @@ -195,8 +206,11 @@ class _NewTextFieldsState extends State { autofocus: widget.autoFocus ?? false, validator: widget.validator, onSaved: widget.onSaved, - style: Theme.of(context).textTheme.body2.copyWith( - fontSize: widget.fontSize, fontWeight: widget.fontWeight, color: Color(0xFF575757), fontFamily: 'Poppins'), + style: Theme.of(context).textTheme.bodyText1!.copyWith( + fontSize: widget.fontSize, + fontWeight: widget.fontWeight, + color: Color(0xFF575757), + fontFamily: 'Poppins'), inputFormatters: widget.keyboardType == TextInputType.phone ? [ // WhitelistingTextInputFormatter.digitsOnly, diff --git a/lib/widgets/shared/text_fields/text_field_error.dart b/lib/widgets/shared/text_fields/text_field_error.dart index 95c6ff9a..b327388c 100644 --- a/lib/widgets/shared/text_fields/text_field_error.dart +++ b/lib/widgets/shared/text_fields/text_field_error.dart @@ -6,8 +6,8 @@ import '../app_texts_widget.dart'; class TextFieldsError extends StatelessWidget { const TextFieldsError({ - Key ? key, - @required this.error, + Key? key, + required this.error, }) : super(key: key); final String error; diff --git a/lib/widgets/shared/text_fields/text_fields_utils.dart b/lib/widgets/shared/text_fields/text_fields_utils.dart index 23ae13a8..85d25475 100644 --- a/lib/widgets/shared/text_fields/text_fields_utils.dart +++ b/lib/widgets/shared/text_fields/text_fields_utils.dart @@ -1,9 +1,8 @@ import 'package:flutter/material.dart'; class TextFieldsUtils { - static BoxDecoration containerBorderDecoration( - Color containerColor, Color borderColor, - {double borderWidth = -1, double borderRadius = 10.0}) { + static BoxDecoration containerBorderDecoration(Color containerColor, Color borderColor, + {double borderWidth = -1, double borderRadius = 12}) { return BoxDecoration( color: containerColor, shape: BoxShape.rectangle, @@ -15,9 +14,8 @@ class TextFieldsUtils { ); } - static InputDecoration textFieldSelectorDecoration( - String hintText, String selectedText, bool isDropDown, - {IconData suffixIcon, Color dropDownColor}) { + static InputDecoration textFieldSelectorDecoration(String hintText, String selectedText, bool isDropDown, + {IconData? suffixIcon, Color? dropDownColor}) { return InputDecoration( isDense: true, contentPadding: EdgeInsets.symmetric(horizontal: 0, vertical: 0), diff --git a/lib/widgets/shared/user-guid/CusomRow.dart b/lib/widgets/shared/user-guid/CusomRow.dart index 9ab5d8ae..dbc9ef56 100644 --- a/lib/widgets/shared/user-guid/CusomRow.dart +++ b/lib/widgets/shared/user-guid/CusomRow.dart @@ -5,21 +5,17 @@ import '../app_texts_widget.dart'; class CustomRow extends StatelessWidget { const CustomRow({ - Key ? key, - this.label, - this.value, - this.labelSize, - this.valueSize, - this.width, - this.isCopyable = true, + Key? key, + this.label, + required this.value, this.labelSize, this.valueSize, this.width, this.isCopyable= true, }) : super(key: key); - final String label; + final String? label; final String value; - final double labelSize; - final double valueSize; - final double width; - final bool isCopyable; + final double? labelSize; + final double? valueSize; + final double? width; + final bool? isCopyable; @override Widget build(BuildContext context) { diff --git a/lib/widgets/shared/user-guid/app_anchored_overlay_widget.dart b/lib/widgets/shared/user-guid/app_anchored_overlay_widget.dart deleted file mode 100644 index 8a4891fd..00000000 --- a/lib/widgets/shared/user-guid/app_anchored_overlay_widget.dart +++ /dev/null @@ -1,183 +0,0 @@ -/* - * Copyright © 2020, Simform Solutions - * All rights reserved. - * https://github.com/simformsolutions/flutter_showcaseview - */ - -/* -Customized By: Ibrahim Albitar - -*/ - -import 'package:flutter/material.dart'; - -/// Displays an overlay Widget anchored directly above the center of this -/// [AnchoredOverlay]. -/// -/// The overlay Widget is created by invoking the provided [overlayBuilder]. -/// -/// The [anchor] position is provided to the [overlayBuilder], but the builder -/// does not have to respect it. In other words, the [overlayBuilder] can -/// interpret the meaning of "anchor" however it wants - the overlay will not -/// be forced to be centered about the [anchor]. -/// -/// The overlay built by this [AnchoredOverlay] can be conditionally shown -/// and hidden by settings the [showOverlay] property to true or false. -/// -/// The [overlayBuilder] is invoked every time this Widget is rebuilt. -/// -class AnchoredOverlay extends StatelessWidget { - final bool showOverlay; - final Widget Function(BuildContext, Rect anchorBounds, Offset anchor) - overlayBuilder; - final Widget child; - - AnchoredOverlay({ - key, - this.showOverlay = false, - this.overlayBuilder, - this.child, - }) : super(key: key); - - @override - Widget build(BuildContext context) { - return LayoutBuilder( - builder: (BuildContext context, BoxConstraints constraints) { - return OverlayBuilder( - showOverlay: showOverlay, - overlayBuilder: (BuildContext overlayContext) { - // To calculate the "anchor" point we grab the render box of - // our parent Container and then we find the center of that box. - RenderBox box = context.findRenderObject() as RenderBox; - final topLeft = - box.size.topLeft(box.localToGlobal(const Offset(0.0, 0.0))); - final bottomRight = - box.size.bottomRight(box.localToGlobal(const Offset(0.0, 0.0))); - final Rect anchorBounds = Rect.fromLTRB( - topLeft.dx, - topLeft.dy, - bottomRight.dx, - bottomRight.dy, - ); - final anchorCenter = box.size.center(topLeft); - return overlayBuilder(overlayContext, anchorBounds, anchorCenter); - }, - child: child, - ); - }, - ); - } -} - -// -// Displays an overlay Widget as constructed by the given [overlayBuilder]. -// -// The overlay built by the [overlayBuilder] can be conditionally shown and hidden by settings the [showOverlay] -// property to true or false. -// -// The [overlayBuilder] is invoked every time this Widget is rebuilt. -// -// Implementation note: the reason we rebuild the overlay every time our state changes is because there doesn't seem -// to be any better way to invalidate the overlay itself than to invalidate this Widget. -// Remember, overlay Widgets exist in [OverlayEntry]s which are inaccessible to outside Widgets. -// But if a better approach is found then feel free to use it. -// -class OverlayBuilder extends StatefulWidget { - final bool showOverlay; - final Widget Function(BuildContext) overlayBuilder; - final Widget child; - - OverlayBuilder({ - key, - this.showOverlay = false, - this.overlayBuilder, - this.child, - }) : super(key: key); - - @override - _OverlayBuilderState createState() => _OverlayBuilderState(); -} - -class _OverlayBuilderState extends State { - OverlayEntry _overlayEntry; - - @override - void initState() { - super.initState(); - - if (widget.showOverlay) { - WidgetsBinding.instance.addPostFrameCallback((_) => showOverlay()); - } - } - - @override - void didUpdateWidget(OverlayBuilder oldWidget) { - super.didUpdateWidget(oldWidget); - WidgetsBinding.instance.addPostFrameCallback((_) => syncWidgetAndOverlay()); - } - - @override - void reassemble() { - super.reassemble(); - WidgetsBinding.instance.addPostFrameCallback((_) => syncWidgetAndOverlay()); - } - - @override - void dispose() { - if (isShowingOverlay()) { - hideOverlay(); - } - - super.dispose(); - } - - bool isShowingOverlay() => _overlayEntry != null; - - void showOverlay() { - if (_overlayEntry == null) { - // Create the overlay. - _overlayEntry = OverlayEntry( - builder: widget.overlayBuilder, - ); - addToOverlay(_overlayEntry); - } else { - // Rebuild overlay. - buildOverlay(); - } - } - - void addToOverlay(OverlayEntry overlayEntry) async { - Overlay.of(context).insert(overlayEntry); - final overlay = Overlay.of(context); - if (overlayEntry == null) - WidgetsBinding.instance - .addPostFrameCallback((_) => overlay.insert(overlayEntry)); - } - - void hideOverlay() { - if (_overlayEntry != null) { - _overlayEntry.remove(); - _overlayEntry = null; - } - } - - void syncWidgetAndOverlay() { - if (isShowingOverlay() && !widget.showOverlay) { - hideOverlay(); - } else if (!isShowingOverlay() && widget.showOverlay) { - showOverlay(); - } - } - - void buildOverlay() async { - WidgetsBinding.instance - .addPostFrameCallback((_) => _overlayEntry?.markNeedsBuild()); - } - - @override - Widget build(BuildContext context) { - buildOverlay(); - - return widget.child; - } -} diff --git a/lib/widgets/shared/user-guid/app_get_position.dart b/lib/widgets/shared/user-guid/app_get_position.dart deleted file mode 100644 index c0430994..00000000 --- a/lib/widgets/shared/user-guid/app_get_position.dart +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright © 2020, Simform Solutions - * All rights reserved. - * https://github.com/simformsolutions/flutter_showcaseview - */ - -/* -Customized By: Ibrahim Albitar - -*/ -import 'package:flutter/material.dart'; - -class GetPosition { - final GlobalKey key; - - GetPosition({this.key}); - - Rect getRect() { - RenderBox box = key.currentContext.findRenderObject(); - - final topLeft = box.size.topLeft(box.localToGlobal(const Offset(0.0, 0.0))); - final bottomRight = - box.size.bottomRight(box.localToGlobal(const Offset(0.0, 0.0))); - - Rect rect = Rect.fromLTRB( - topLeft.dx, - topLeft.dy, - bottomRight.dx, - bottomRight.dy, - ); - return rect; - } - - ///Get the bottom position of the widget - double getBottom() { - RenderBox box = key.currentContext.findRenderObject(); - final bottomRight = - box.size.bottomRight(box.localToGlobal(const Offset(0.0, 0.0))); - return bottomRight.dy; - } - - ///Get the top position of the widget - double getTop() { - RenderBox box = key.currentContext.findRenderObject(); - final topLeft = box.size.topLeft(box.localToGlobal(const Offset(0.0, 0.0))); - return topLeft.dy; - } - - ///Get the left position of the widget - double getLeft() { - RenderBox box = key.currentContext.findRenderObject(); - final topLeft = box.size.topLeft(box.localToGlobal(const Offset(0.0, 0.0))); - return topLeft.dx; - } - - ///Get the right position of the widget - double getRight() { - RenderBox box = key.currentContext.findRenderObject(); - final bottomRight = - box.size.bottomRight(box.localToGlobal(const Offset(0.0, 0.0))); - return bottomRight.dx; - } - - double getHeight() { - return getBottom() - getTop(); - } - - double getWidth() { - return getRight() - getLeft(); - } - - double getCenter() { - return (getLeft() + getRight()) / 2; - } -} diff --git a/lib/widgets/shared/user-guid/app_shape_painter.dart b/lib/widgets/shared/user-guid/app_shape_painter.dart deleted file mode 100644 index 925d18d0..00000000 --- a/lib/widgets/shared/user-guid/app_shape_painter.dart +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright © 2020, Simform Solutions - * All rights reserved. - * https://github.com/simformsolutions/flutter_showcaseview - */ - -/* -Customized By: Ibrahim Albitar - -*/ - -import 'package:flutter/material.dart'; - -class ShapePainter extends CustomPainter { - Rect rect; - final ShapeBorder shapeBorder; - final Color color; - final double opacity; - - ShapePainter({ - @required this.rect, - this.color, - this.shapeBorder, - this.opacity, - }); - - @override - void paint(Canvas canvas, Size size) { - final paint = Paint(); - paint.color = color.withOpacity(opacity); - RRect outer = - RRect.fromLTRBR(0, 0, size.width, size.height, Radius.circular(0)); - - double radius = shapeBorder == CircleBorder() ? 50 : 3; - - RRect inner = RRect.fromRectAndRadius(rect, Radius.circular(radius)); - canvas.drawDRRect(outer, inner, paint); - } - - @override - bool shouldRepaint(CustomPainter oldDelegate) => false; -} diff --git a/lib/widgets/shared/user-guid/app_showcase.dart b/lib/widgets/shared/user-guid/app_showcase.dart deleted file mode 100644 index 377172c8..00000000 --- a/lib/widgets/shared/user-guid/app_showcase.dart +++ /dev/null @@ -1,349 +0,0 @@ -/* - * Copyright © 2020, Simform Solutions - * All rights reserved. - * https://github.com/simformsolutions/flutter_showcaseview - */ - -/* -Customized By: Ibrahim Albitar - -*/ - -import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter/scheduler.dart'; - -import 'app_anchored_overlay_widget.dart'; -import 'app_get_position.dart'; -import 'app_shape_painter.dart'; -import 'app_showcase_widget.dart'; -import 'app_tool_tip_widget.dart'; - -class AppShowcase extends StatefulWidget { - final Widget child; - final String title; - final String description; - final ShapeBorder shapeBorder; - final TextStyle titleTextStyle; - final TextStyle descTextStyle; - final GlobalKey key; - final Color overlayColor; - final double overlayOpacity; - final Widget container; - final Color showcaseBackgroundColor; - final Color textColor; - final bool showArrow; - final double height; - final double width; - final Duration animationDuration; - final VoidCallback onToolTipClick; - final VoidCallback onTargetClick; - final VoidCallback onSkipClick; - final bool disposeOnTap; - final bool disableAnimation; - - const AppShowcase( - {@required this.key, - @required this.child, - this.title, - @required this.description, - this.shapeBorder, - this.overlayColor = Colors.black, - this.overlayOpacity = 0.75, - this.titleTextStyle, - this.descTextStyle, - this.showcaseBackgroundColor = Colors.white, - this.textColor = Colors.black, - this.showArrow = true, - this.onTargetClick, - this.onSkipClick, - this.disposeOnTap, - this.animationDuration = const Duration(milliseconds: 2000), - this.disableAnimation = false}) - : height = null, - width = null, - container = null, - this.onToolTipClick = null, - assert(overlayOpacity >= 0.0 && overlayOpacity <= 1.0, - "overlay opacity should be >= 0.0 and <= 1.0."), - assert( - onTargetClick == null - ? true - : (disposeOnTap == null ? false : true), - "disposeOnTap is required if you're using onTargetClick"), - assert( - disposeOnTap == null - ? true - : (onTargetClick == null ? false : true), - "onTargetClick is required if you're using disposeOnTap"), - assert(key != null || - child != null || - title != null || - showArrow != null || - description != null || - shapeBorder != null || - overlayColor != null || - titleTextStyle != null || - descTextStyle != null || - showcaseBackgroundColor != null || - textColor != null || - shapeBorder != null || - animationDuration != null); - - const AppShowcase.withWidget( - {this.key, - @required this.child, - @required this.container, - @required this.height, - @required this.width, - this.title, - this.description, - this.shapeBorder, - this.overlayColor = Colors.black, - this.overlayOpacity = 0.75, - this.titleTextStyle, - this.descTextStyle, - this.showcaseBackgroundColor = Colors.white, - this.textColor = Colors.black, - this.onTargetClick, - this.onSkipClick, - this.disposeOnTap, - this.animationDuration = const Duration(milliseconds: 2000), - this.disableAnimation = false}) - : this.showArrow = false, - this.onToolTipClick = null, - assert(overlayOpacity >= 0.0 && overlayOpacity <= 1.0, - "overlay opacity should be >= 0.0 and <= 1.0."), - assert(key != null || - child != null || - title != null || - description != null || - shapeBorder != null || - overlayColor != null || - titleTextStyle != null || - descTextStyle != null || - showcaseBackgroundColor != null || - textColor != null || - shapeBorder != null || - animationDuration != null); - - @override - _AppShowcaseState createState() => _AppShowcaseState(); -} - -class _AppShowcaseState extends State - with TickerProviderStateMixin { - bool _showShowCase = false; - Animation _slideAnimation; - AnimationController _slideAnimationController; - - GetPosition position; - - @override - void initState() { - super.initState(); - - _slideAnimationController = AnimationController( - duration: widget.animationDuration, - vsync: this, - )..addStatusListener((AnimationStatus status) { - if (status == AnimationStatus.completed) { - _slideAnimationController.reverse(); - } - if (_slideAnimationController.isDismissed) { - if (!widget.disableAnimation) { - _slideAnimationController.forward(); - } - } - }); - - _slideAnimation = CurvedAnimation( - parent: _slideAnimationController, - curve: Curves.easeInOut, - ); - - position = GetPosition(key: widget.key); - } - - @override - void dispose() { - _slideAnimationController.dispose(); - super.dispose(); - } - - @override - void didChangeDependencies() { - super.didChangeDependencies(); - showOverlay(); - } - - /// - /// show overlay if there is any target widget - /// - void showOverlay() { - GlobalKey activeStep = ShowCaseWidget.activeTargetWidget(context); - setState(() { - _showShowCase = activeStep == widget.key; - }); - - if (activeStep == widget.key) { - if (!widget.disableAnimation) { - _slideAnimationController.forward(); - } - } - } - - @override - Widget build(BuildContext context) { - Size size = MediaQuery.of(context).size; - return AnchoredOverlay( - overlayBuilder: (BuildContext context, Rect rectBound, Offset offset) => - buildOverlayOnTarget(offset, rectBound.size, rectBound, size), - showOverlay: true, - child: widget.child, - ); - } - - _nextIfAny() { - ShowCaseWidget.of(context).completed(widget.key); - if (!widget.disableAnimation) { - _slideAnimationController.forward(); - } - } - - _getOnTargetTap() { - if (widget.disposeOnTap == true) { - return widget.onTargetClick == null - ? () { - ShowCaseWidget.of(context).dismiss(); - } - : () { - ShowCaseWidget.of(context).dismiss(); - widget.onTargetClick(); - }; - } else { - return widget.onTargetClick ?? _nextIfAny; - } - } - - _getOnTooltipTap() { - if (widget.disposeOnTap == true) { - return widget.onToolTipClick == null - ? () { - ShowCaseWidget.of(context).dismiss(); - } - : () { - ShowCaseWidget.of(context).dismiss(); - widget.onToolTipClick(); - }; - } else { - return widget.onToolTipClick ?? () {}; - } - } - - buildOverlayOnTarget( - Offset offset, - Size size, - Rect rectBound, - Size screenSize, - ) => - Visibility( - visible: _showShowCase, - maintainAnimation: true, - maintainState: true, - child: Stack( - children: [ - GestureDetector( - onTap: _nextIfAny, - child: Container( - width: MediaQuery.of(context).size.width, - height: MediaQuery.of(context).size.height, - child: CustomPaint( - painter: ShapePainter( - opacity: widget.overlayOpacity, - rect: position.getRect(), - shapeBorder: widget.shapeBorder, - color: widget.overlayColor), - ), - ), - ), - _TargetWidget( - offset: offset, - size: size, - onTap: _getOnTargetTap(), - shapeBorder: widget.shapeBorder, - ), - AppToolTipWidget( - position: position, - offset: offset, - screenSize: screenSize, - title: widget.title, - description: widget.description, - animationOffset: _slideAnimation, - titleTextStyle: widget.titleTextStyle, - descTextStyle: widget.descTextStyle, - container: widget.container, - tooltipColor: widget.showcaseBackgroundColor, - textColor: widget.textColor, - showArrow: widget.showArrow, - contentHeight: widget.height, - contentWidth: widget.width, - onTooltipTap: _getOnTooltipTap(), - ), - GestureDetector( - child: AppText( - "Skip", - color: Colors.white, - fontSize: 20, - marginRight: 15, - marginLeft: 15, - marginTop: 15, - ), - onTap: widget.onSkipClick) - ], - ), - ); -} - -class _TargetWidget extends StatelessWidget { - final Offset offset; - final Size size; - final Animation widthAnimation; - final VoidCallback onTap; - final ShapeBorder shapeBorder; - - _TargetWidget({ - Key ? key, - @required this.offset, - this.size, - this.widthAnimation, - this.onTap, - this.shapeBorder, - }) : super(key: key); - - @override - Widget build(BuildContext context) { - return Positioned( - top: offset.dy, - left: offset.dx, - child: FractionalTranslation( - translation: const Offset(-0.5, -0.5), - child: GestureDetector( - onTap: onTap, - child: Container( - height: size.height + 16, - width: size.width + 16, - decoration: ShapeDecoration( - shape: shapeBorder ?? - RoundedRectangleBorder( - borderRadius: const BorderRadius.all( - Radius.circular(8), - ), - ), - ), - ), - ), - ), - ); - } -} diff --git a/lib/widgets/shared/user-guid/app_showcase_widget.dart b/lib/widgets/shared/user-guid/app_showcase_widget.dart deleted file mode 100644 index 07577b3b..00000000 --- a/lib/widgets/shared/user-guid/app_showcase_widget.dart +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright © 2020, Simform Solutions - * All rights reserved. - * https://github.com/simformsolutions/flutter_showcaseview - */ - -/* -Customized By: Ibrahim Albitar - -*/ - -import 'package:flutter/material.dart'; - -class ShowCaseWidget extends StatefulWidget { - final Builder builder; - final VoidCallback onFinish; - - const ShowCaseWidget({@required this.builder, this.onFinish}); - - static activeTargetWidget(BuildContext context) { - return context - .dependOnInheritedWidgetOfExactType<_InheritedShowCaseView>() - .activeWidgetIds; - } - - static ShowCaseWidgetState of(BuildContext context) { - ShowCaseWidgetState state = - context.findAncestorStateOfType(); - if (state != null) { - return context.findAncestorStateOfType(); - } else { - throw Exception('Please provide ShowCaseView context'); - } - } - - @override - ShowCaseWidgetState createState() => ShowCaseWidgetState(); -} - -class ShowCaseWidgetState extends State { - List ids; - int activeWidgetId; - - void startShowCase(List widgetIds) { - setState(() { - this.ids = widgetIds; - activeWidgetId = 0; - }); - } - - void completed(GlobalKey id) { - if (ids != null && ids[activeWidgetId] == id) { - setState(() { - ++activeWidgetId; - - if (activeWidgetId >= ids.length) { - _cleanupAfterSteps(); - if (widget.onFinish != null) { - widget.onFinish(); - } - } - }); - } - } - - void dismiss() { - setState(() { - _cleanupAfterSteps(); - }); - } - - void _cleanupAfterSteps() { - ids = null; - activeWidgetId = null; - } - - @override - Widget build(BuildContext context) { - return _InheritedShowCaseView( - child: widget.builder, - activeWidgetIds: ids?.elementAt(activeWidgetId), - ); - } -} - -class _InheritedShowCaseView extends InheritedWidget { - final GlobalKey activeWidgetIds; - - _InheritedShowCaseView({ - @required this.activeWidgetIds, - @required child, - }) : super(child: child); - - @override - bool updateShouldNotify(_InheritedShowCaseView oldWidget) => - oldWidget.activeWidgetIds != activeWidgetIds; -} diff --git a/lib/widgets/shared/user-guid/app_tool_tip_widget.dart b/lib/widgets/shared/user-guid/app_tool_tip_widget.dart deleted file mode 100644 index 285caa8e..00000000 --- a/lib/widgets/shared/user-guid/app_tool_tip_widget.dart +++ /dev/null @@ -1,290 +0,0 @@ -/* - * Copyright © 2020, Simform Solutions - * All rights reserved. - * https://github.com/simformsolutions/flutter_showcaseview - */ - -/* -Customized By: Ibrahim Albitar - -*/ - -import 'package:doctor_app_flutter/icons_app/doctor_app_icons.dart'; -import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; -import 'package:flutter/material.dart'; - -import 'app_get_position.dart'; - -class AppToolTipWidget extends StatelessWidget { - final GetPosition position; - final Offset offset; - final Size screenSize; - final String title; - final String description; - final Animation animationOffset; - final TextStyle titleTextStyle; - final TextStyle descTextStyle; - final Widget container; - final Color tooltipColor; - final Color textColor; - final bool showArrow; - final double contentHeight; - final double contentWidth; - static bool isArrowUp; - final VoidCallback onTooltipTap; - - AppToolTipWidget({ - this.position, - this.offset, - this.screenSize, - this.title, - this.description, - this.animationOffset, - this.titleTextStyle, - this.descTextStyle, - this.container, - this.tooltipColor, - this.textColor, - this.showArrow, - this.contentHeight, - this.contentWidth, - this.onTooltipTap, - }); - - bool isCloseToTopOrBottom(Offset position) { - double height = 120; - if (contentHeight != null) { - height = contentHeight; - } - return (screenSize.height - position.dy) <= height; - } - - String findPositionForContent(Offset position) { - if (isCloseToTopOrBottom(position)) { - return 'ABOVE'; - } else { - return 'BELOW'; - } - } - - double _getTooltipWidth() { - double titleLength = title == null ? 0 : (title.length * 10.0); - double descriptionLength = (description.length * 7.0); - if (titleLength > descriptionLength) { - return titleLength + 10; - } else { - return descriptionLength + 10; - } - } - - bool _isLeft() { - double screenWidth = screenSize.width / 3; - return !(screenWidth <= position.getCenter()); - } - - bool _isRight() { - double screenWidth = screenSize.width / 3; - return ((screenWidth * 2) <= position.getCenter()); - } - - double _getLeft() { - if (_isLeft()) { - double leftPadding = position.getCenter() - (_getTooltipWidth() * 0.1); - if (leftPadding + _getTooltipWidth() > screenSize.width) { - leftPadding = (screenSize.width - 20) - _getTooltipWidth(); - } - if (leftPadding < 20) { - leftPadding = 14; - } - return leftPadding; - } else if (!(_isRight())) { - return position.getCenter() - (_getTooltipWidth() * 0.5); - } else { - return null; - } - } - - double _getRight() { - if (_isRight()) { - double rightPadding = position.getCenter() + (_getTooltipWidth() / 2); - if (rightPadding + _getTooltipWidth() > screenSize.width) { - rightPadding = 14; - } - return rightPadding; - } else if (!(_isLeft())) { - return position.getCenter() - (_getTooltipWidth() * 0.5); - } else { - return null; - } - } - - double _getSpace() { - double space = position.getCenter() - (contentWidth / 2); - if (space + contentWidth > screenSize.width) { - space = screenSize.width - contentWidth - 8; - } else if (space < (contentWidth / 2)) { - space = 16; - } - return space; - } - - @override - Widget build(BuildContext context) { - final contentOrientation = findPositionForContent(offset); - final contentOffsetMultiplier = contentOrientation == "BELOW" ? 1.0 : -1.0; - isArrowUp = contentOffsetMultiplier == 1.0 ? true : false; - - final contentY = isArrowUp - ? position.getBottom() + (contentOffsetMultiplier * 3) - : position.getTop() + (contentOffsetMultiplier * 3); - - final contentFractionalOffset = contentOffsetMultiplier.clamp(-1.0, 0.0); - - double paddingTop = isArrowUp ? 22 : 0; - double paddingBottom = isArrowUp ? 0 : 27; - - if (!showArrow) { - paddingTop = 10; - paddingBottom = 10; - } - - if (container == null) { - return Stack( - children: [ - showArrow ? _getArrow(contentOffsetMultiplier) : Container(), - Positioned( - top: contentY, - left: _getLeft(), - right: _getRight(), - child: FractionalTranslation( - translation: Offset(0.0, contentFractionalOffset), - child: SlideTransition( - position: Tween( - begin: Offset(0.0, contentFractionalOffset / 10), - end: Offset(0.0, 0.100), - ).animate(animationOffset), - child: Material( - color: Colors.transparent, - child: Container( - padding: - EdgeInsets.only(top: paddingTop, bottom: paddingBottom), - child: ClipRRect( - borderRadius: BorderRadius.circular(8), - child: GestureDetector( - onTap: onTooltipTap, - child: Container( - width: _getTooltipWidth(), - padding: EdgeInsets.symmetric(vertical: 8), - color: tooltipColor, - child: Column( - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Container( - child: Column( - crossAxisAlignment: title != null - ? CrossAxisAlignment.start - : CrossAxisAlignment.center, - children: [ - title != null - ? Row( - children: [ - Padding( - padding: - const EdgeInsets.all(8.0), - child: Icon( - DoctorApp.search_patient), - ), - AppText( - title, - color: textColor, - margin: 2, - fontWeight: FontWeight.bold, - fontSize: 16, - ), - ], - ) - : Container(), - AppText( - description, - color: textColor, - margin: 8, - ), - ], - ), - ) - ], - ), - ), - ), - ), - ), - ), - ), - ), - ) - ], - ); - } else { - return Stack( - children: [ - Positioned( - left: _getSpace(), - top: contentY - 10, - child: FractionalTranslation( - translation: Offset(0.0, contentFractionalOffset), - child: SlideTransition( - position: Tween( - begin: Offset(0.0, contentFractionalOffset / 5), - end: Offset(0.0, 0.100), - ).animate(animationOffset), - child: Material( - color: Colors.transparent, - child: GestureDetector( - onTap: onTooltipTap, - child: Container( - padding: EdgeInsets.only( - top: paddingTop, - ), - color: Colors.transparent, - child: Center( - child: container, - ), - ), - ), - ), - ), - ), - ), - ], - ); - } - } - - Widget _getArrow(contentOffsetMultiplier) { - final contentFractionalOffset = contentOffsetMultiplier.clamp(-1.0, 0.0); - return Positioned( - top: isArrowUp ? position.getBottom() : position.getTop() - 1, - left: position.getCenter() - 24, - child: FractionalTranslation( - translation: Offset(0.0, contentFractionalOffset), - child: SlideTransition( - position: Tween( - begin: Offset(0.0, contentFractionalOffset / 5), - end: Offset(0.0, 0.150), - ).animate(animationOffset), - child: isArrowUp - ? Icon( - Icons.arrow_drop_up, - color: tooltipColor, - size: 50, - ) - : Icon( - Icons.arrow_drop_down, - color: tooltipColor, - size: 50, - ), - ), - ), - ); - } -} diff --git a/lib/widgets/shared/user-guid/custom_validation_error.dart b/lib/widgets/shared/user-guid/custom_validation_error.dart index abfac6c4..c444bba7 100644 --- a/lib/widgets/shared/user-guid/custom_validation_error.dart +++ b/lib/widgets/shared/user-guid/custom_validation_error.dart @@ -5,7 +5,7 @@ import 'package:flutter/material.dart'; // ignore: must_be_immutable class CustomValidationError extends StatelessWidget { - String error; + String? error; CustomValidationError({ Key ? key, this.error, }) : super(key: key); diff --git a/lib/widgets/shared/user-guid/in_patient_doctor_card.dart b/lib/widgets/shared/user-guid/in_patient_doctor_card.dart index 9197a4a1..e5d4c647 100644 --- a/lib/widgets/shared/user-guid/in_patient_doctor_card.dart +++ b/lib/widgets/shared/user-guid/in_patient_doctor_card.dart @@ -7,15 +7,15 @@ import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; class InPatientDoctorCard extends StatelessWidget { - final String doctorName; - final String branch; - final DateTime appointmentDate; - final String profileUrl; - final String invoiceNO; - final String orderNo; - final Function onTap; - final bool isPrescriptions; - final String clinic; + final String? doctorName; + final String? branch; + final DateTime? appointmentDate; + final String? profileUrl; + final String? invoiceNO; + final String? orderNo; + final VoidCallback? onTap; + final bool? isPrescriptions; + final String? clinic; final createdBy; InPatientDoctorCard( @@ -63,14 +63,14 @@ class InPatientDoctorCard extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.end, children: [ AppText( - '${AppDateUtils.getDayMonthYearDateFormatted(appointmentDate, isArabic: projectViewModel.isArabic)}', + '${AppDateUtils.getDayMonthYearDateFormatted(appointmentDate!, isArabic: projectViewModel.isArabic)}', color: Colors.black, fontWeight: FontWeight.w600, fontSize: 14, ), - if (!isPrescriptions) + if (!isPrescriptions!) AppText( - '${AppDateUtils.getHour(appointmentDate)}', + '${AppDateUtils.getHour(appointmentDate!)}', fontWeight: FontWeight.w600, color: Colors.grey[700], fontSize: 14, diff --git a/lib/widgets/transitions/fade_page.dart b/lib/widgets/transitions/fade_page.dart index 7cd3826c..2330894b 100644 --- a/lib/widgets/transitions/fade_page.dart +++ b/lib/widgets/transitions/fade_page.dart @@ -4,30 +4,25 @@ import 'package:flutter/material.dart'; /// [page] class FadePage extends PageRouteBuilder { final Widget page; - FadePage({this.page}) - : super( - opaque: false, - settings: RouteSettings(name: page.runtimeType.toString()), - fullscreenDialog: true, - barrierDismissible: true, - barrierColor: Colors.black.withOpacity(0.8), - pageBuilder: ( - BuildContext context, - Animation animation, - Animation secondaryAnimation, - ) => - page, - transitionDuration: Duration(milliseconds: 300), - transitionsBuilder: ( - BuildContext context, - Animation animation, - Animation secondaryAnimation, - Widget child, - ) { - return FadeTransition( - opacity: animation, - child: child - ); - } - ); + FadePage({required this.page}) + : super( + opaque: false, + settings: RouteSettings(name: page.runtimeType.toString()),fullscreenDialog: true, + barrierDismissible: true, + barrierColor: Colors.black.withOpacity(0.8), + pageBuilder: ( + BuildContext context, + Animation animation, + Animation secondaryAnimation, + ) => + page, + transitionDuration: Duration(milliseconds: 300), + transitionsBuilder: ( + BuildContext context, + Animation animation, + Animation secondaryAnimation, + Widget child, + ) { + return FadeTransition(opacity: animation, child: child); + }); } \ No newline at end of file diff --git a/lib/widgets/transitions/slide_up_page.dart b/lib/widgets/transitions/slide_up_page.dart index ee0b7473..1893a172 100644 --- a/lib/widgets/transitions/slide_up_page.dart +++ b/lib/widgets/transitions/slide_up_page.dart @@ -9,9 +9,9 @@ class SlideUpPageRoute extends PageRouteBuilder { final Widget widget; final bool fullscreenDialog; final bool opaque; - final String settingRoute; + final String? settingRoute; - SlideUpPageRoute({this.widget, this.fullscreenDialog = false, this.opaque = true, this.settingRoute}) + SlideUpPageRoute({required this.widget, this.fullscreenDialog = false, this.opaque = true, this.settingRoute}) : super( pageBuilder: ( BuildContext context,