From 6eecb4a61478113a030f1d46dbeea2d964ec9e8b Mon Sep 17 00:00:00 2001 From: hussam al-habibeh Date: Thu, 9 Sep 2021 15:44:34 +0300 Subject: [PATCH] adding cashed network image --- .../patients/patient_card/PatientCard.dart | 166 +++++++----------- .../profile/profile-welcome-widget.dart | 30 ++-- 2 files changed, 83 insertions(+), 113 deletions(-) diff --git a/lib/widgets/patients/patient_card/PatientCard.dart b/lib/widgets/patients/patient_card/PatientCard.dart index 22deda0c..4bc5d2cd 100644 --- a/lib/widgets/patients/patient_card/PatientCard.dart +++ b/lib/widgets/patients/patient_card/PatientCard.dart @@ -82,8 +82,7 @@ class PatientCard extends StatelessWidget { ? Row( children: [ AppText( - TranslationBase.of(context) - .arrivedP, + TranslationBase.of(context).arrivedP, color: Colors.green, fontWeight: FontWeight.bold, fontFamily: 'Poppins', @@ -135,27 +134,19 @@ class PatientCard extends StatelessWidget { width: 8, ), AppText( - patientInfo.status == 2 - ? 'Confirmed' - : 'Booked', - color: patientInfo.status == 2 - ? Colors.green - : Colors.grey, + patientInfo.status == 2 ? 'Confirmed' : 'Booked', + color: patientInfo.status == 2 ? Colors.green : Colors.grey, fontWeight: FontWeight.bold, fontFamily: 'Poppins', fontSize: 10, ), ], ) - : !isFromSearch && - !isFromLiveCare && - patientInfo.patientStatusType == - null + : !isFromSearch && !isFromLiveCare && patientInfo.patientStatusType == null ? Row( children: [ AppText( - TranslationBase.of(context) - .notArrived, + TranslationBase.of(context).notArrived, color: Colors.red[800], fontWeight: FontWeight.bold, fontFamily: 'Poppins', @@ -175,13 +166,8 @@ class PatientCard extends StatelessWidget { width: 8, ), AppText( - patientInfo.status == 2 - ? 'Booked' - : 'Confirmed', - color: - patientInfo.status == 2 - ? Colors.grey - : Colors.green, + patientInfo.status == 2 ? 'Booked' : 'Confirmed', + color: patientInfo.status == 2 ? Colors.grey : Colors.green, fontWeight: FontWeight.bold, fontFamily: 'Poppins', fontSize: 12, @@ -191,17 +177,13 @@ class PatientCard extends StatelessWidget { : SizedBox(), this.arrivalType == '1' ? AppText( - patientInfo.startTime != null - ? patientInfo.startTime - : patientInfo.startTimes, + patientInfo.startTime != null ? patientInfo.startTime : patientInfo.startTimes, fontFamily: 'Poppins', fontWeight: FontWeight.w400, ) : patientInfo.arrivedOn != null ? AppText( - AppDateUtils.getDayMonthYearDate( - AppDateUtils - .convertStringToDate( + AppDateUtils.getDayMonthYearDate(AppDateUtils.convertStringToDate( patientInfo.arrivedOn, )) + " " + @@ -210,10 +192,8 @@ class PatientCard extends StatelessWidget { fontWeight: FontWeight.w400, fontSize: 15, ) - : (patientInfo.appointmentDate != - null && - patientInfo - .appointmentDate.isNotEmpty) + : (patientInfo.appointmentDate != null && + patientInfo.appointmentDate.isNotEmpty) ? AppText( "${AppDateUtils.getDayMonthYearDate(AppDateUtils.convertStringToDate( patientInfo.appointmentDate, @@ -252,13 +232,10 @@ class PatientCard extends StatelessWidget { // width: MediaQuery.of(context).size.width*0.51, child: AppText( isFromLiveCare - ? Helpers.capitalize( - patientInfo.fullName) - : (Helpers.capitalize( - patientInfo.firstName) + + ? Helpers.capitalize(patientInfo.fullName) + : (Helpers.capitalize(patientInfo.firstName) + " " + - Helpers.capitalize( - patientInfo.lastName)), + Helpers.capitalize(patientInfo.lastName)), fontSize: 16, color: Color(0xff2e303a), fontWeight: FontWeight.w700, @@ -296,25 +273,19 @@ class PatientCard extends StatelessWidget { fontSize: 14, textOverflow: TextOverflow.ellipsis, ), - patientInfo.nationality != null || - patientInfo.nationalityId != null + patientInfo.nationality != null || patientInfo.nationalityId != null ? ClipRRect( - borderRadius: - BorderRadius.circular(20.0), - child: Image.network( - patientInfo.nationalityFlagURL != null + borderRadius: BorderRadius.circular(20.0), + child: CachedNetworkImage( + imageUrl: patientInfo.nationalityFlagURL != null ? patientInfo.nationalityFlagURL : '', height: 25, width: 30, - errorBuilder: (BuildContext context, - Object exception, - StackTrace stackTrace) { - return AppText( - 'No Image', - fontSize: 10, - ); - }, + errorWidget: (context, url, error) => AppText( + 'No Image', + fontSize: 10, + ), )) : SizedBox() ], @@ -345,54 +316,55 @@ class PatientCard extends StatelessWidget { ), Expanded( child: Row( - children: [ - Expanded(child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [ - CustomRow( - label: TranslationBase.of(context).fileNumber, - value: patientInfo.patientId.toString(), - - ), - CustomRow( - label: TranslationBase.of(context).age + " : ", - value: - "${AppDateUtils.getAgeByBirthday(patientInfo.dateofBirth, context, isServerFormat: !isFromLiveCare)}", - ), - - if (isInpatient) - CustomRow( - label: patientInfo.admissionDate == null - ? "" - : TranslationBase.of(context).admissionDate + " : ", - value: patientInfo.admissionDate == null - ? "" - : "${AppDateUtils.convertDateFromServerFormat(patientInfo.admissionDate.toString(), 'yyyy-MM-dd')}", - ), - if (patientInfo.admissionDate != null) - CustomRow( - label: TranslationBase.of(context).numOfDays + " : ", - value: - "${DateTime.now().difference(AppDateUtils.getDateTimeFromServerFormat(patientInfo.admissionDate)).inDays + 1}", - ), - if (patientInfo.admissionDate != null) - CustomRow( - label: TranslationBase.of(context).roomNo + " : ", - value: "${patientInfo.roomId}", - ), - - if (isFromLiveCare) - Column( - children: [ + children: [ + Expanded( + child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [ CustomRow( - label: TranslationBase.of(context).clinic + " : ", - value: patientInfo.clinicName, + label: TranslationBase.of(context).fileNumber, + value: patientInfo.patientId.toString(), ), - ], - ), - ]), + CustomRow( + label: TranslationBase.of(context).age + " : ", + value: + "${AppDateUtils.getAgeByBirthday(patientInfo.dateofBirth, context, isServerFormat: !isFromLiveCare)}", ), - Icon(Icons.arrow_forward, size: 24,), - ], - )) + if (isInpatient) + CustomRow( + label: patientInfo.admissionDate == null + ? "" + : TranslationBase.of(context).admissionDate + " : ", + value: patientInfo.admissionDate == null + ? "" + : "${AppDateUtils.convertDateFromServerFormat(patientInfo.admissionDate.toString(), 'yyyy-MM-dd')}", + ), + if (patientInfo.admissionDate != null) + CustomRow( + label: TranslationBase.of(context).numOfDays + " : ", + value: + "${DateTime.now().difference(AppDateUtils.getDateTimeFromServerFormat(patientInfo.admissionDate)).inDays + 1}", + ), + if (patientInfo.admissionDate != null) + CustomRow( + label: TranslationBase.of(context).roomNo + " : ", + value: "${patientInfo.roomId}", + ), + if (isFromLiveCare) + Column( + children: [ + CustomRow( + label: TranslationBase.of(context).clinic + " : ", + value: patientInfo.clinicName, + ), + ], + ), + ]), + ), + Icon( + Icons.arrow_forward, + size: 24, + ), + ], + )) ]), isFromLiveCare ? Row( @@ -440,5 +412,3 @@ class PatientCard extends StatelessWidget { )); } } - - diff --git a/lib/widgets/patients/profile/profile-welcome-widget.dart b/lib/widgets/patients/profile/profile-welcome-widget.dart index 53228bc2..0a405d8d 100644 --- a/lib/widgets/patients/profile/profile-welcome-widget.dart +++ b/lib/widgets/patients/profile/profile-welcome-widget.dart @@ -1,13 +1,14 @@ import 'package:doctor_app_flutter/core/viewModel/authentication_view_model.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; +import 'package:cached_network_image/cached_network_image.dart'; class ProfileWelcomeWidget extends StatelessWidget { final Widget clinicWidget; final double height; final bool isClinic; - ProfileWelcomeWidget(this.clinicWidget, - {this.height = 150, this.isClinic = false}); + + ProfileWelcomeWidget(this.clinicWidget, {this.height = 150, this.isClinic = false}); @override Widget build(BuildContext context) { @@ -27,24 +28,23 @@ class ProfileWelcomeWidget extends StatelessWidget { SizedBox( width: 20, ), - if(authenticationViewModel.doctorProfile!=null) - CircleAvatar( - // radius: (52) - child: ClipRRect( - borderRadius: BorderRadius.circular(20), - child: Image.network( - authenticationViewModel.doctorProfile.doctorImageURL, - fit: BoxFit.fill, - width: 75, - height: 75, + if (authenticationViewModel.doctorProfile != null) + CircleAvatar( + // radius: (52) + child: ClipRRect( + borderRadius: BorderRadius.circular(20), + child: CachedNetworkImage( + imageUrl: authenticationViewModel.doctorProfile.doctorImageURL, + fit: BoxFit.fill, + width: 75, + height: 75, + ), ), + backgroundColor: Colors.transparent, ), - backgroundColor: Colors.transparent, - ), SizedBox( height: 20, ), - ], )), );