From ba275eaed4883831ed1e9953fcfda11a8babeb72 Mon Sep 17 00:00:00 2001 From: hussam al-habibeh Date: Thu, 9 Sep 2021 12:47:08 +0300 Subject: [PATCH] adding cashed network image --- .../patients/patient_card/PatientCard.dart | 213 +++++++----------- pubspec.lock | 85 ++++++- pubspec.yaml | 4 + 3 files changed, 167 insertions(+), 135 deletions(-) diff --git a/lib/widgets/patients/patient_card/PatientCard.dart b/lib/widgets/patients/patient_card/PatientCard.dart index b86256fd..ed6fe74e 100644 --- a/lib/widgets/patients/patient_card/PatientCard.dart +++ b/lib/widgets/patients/patient_card/PatientCard.dart @@ -9,6 +9,7 @@ import 'package:doctor_app_flutter/widgets/shared/card_with_bg_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/user-guid/CusomRow.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:cached_network_image/cached_network_image.dart'; import 'ShowTimer.dart'; @@ -81,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', @@ -102,12 +102,8 @@ 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, @@ -118,8 +114,7 @@ class PatientCard extends StatelessWidget { ? Row( children: [ AppText( - TranslationBase.of(context) - .notArrived, + TranslationBase.of(context).notArrived, color: Colors.red[800], fontWeight: FontWeight.bold, fontFamily: 'Poppins', @@ -139,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', @@ -179,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, @@ -195,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, )) + " " + @@ -214,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, @@ -256,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, @@ -300,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: 7.5, + ), )) : SizedBox() ], @@ -348,58 +315,51 @@ class PatientCard extends StatelessWidget { width: 10, ), Expanded( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - CustomRow( - label: TranslationBase.of(context).fileNumber, - value: patientInfo.patientId.toString(), - ), + child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [ + CustomRow( + label: TranslationBase.of(context).fileNumber, + value: patientInfo.patientId.toString(), + ), - //if (isInpatient) + //if (isInpatient) - CustomRow( - label: TranslationBase.of(context).age + " : ", - value: - "${AppDateUtils.getAgeByBirthday(patientInfo.dateofBirth, context, isServerFormat: !isFromLiveCare)}", - ), + 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 (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, - ), - ], + if (isFromLiveCare) + Column( + children: [ + CustomRow( + label: TranslationBase.of(context).clinic + " : ", + value: patientInfo.clinicName, ), - ])) + ], + ), + ])) ]), isFromLiveCare ? Row( @@ -416,36 +376,29 @@ class PatientCard extends StatelessWidget { ], ) : !isInpatient && !isFromSearch - ? Row( - mainAxisAlignment: MainAxisAlignment.end, - children: [ + ? Row(mainAxisAlignment: MainAxisAlignment.end, children: [ + Container( + padding: EdgeInsets.all(4), + child: Image.asset( + patientInfo.appointmentType == 'Regular' && patientInfo.visitTypeId == 100 + ? 'assets/images/livecare.png' + : patientInfo.appointmentType == 'Walkin' + ? 'assets/images/walkin.png' + : 'assets/images/booked.png', + height: 25, + width: 35, + )), + ]) + : (isInpatient == true) + ? Row(mainAxisAlignment: MainAxisAlignment.end, children: [ Container( padding: EdgeInsets.all(4), child: Image.asset( - patientInfo.appointmentType == - 'Regular' && - patientInfo.visitTypeId == 100 - ? 'assets/images/livecare.png' - : patientInfo.appointmentType == - 'Walkin' - ? 'assets/images/walkin.png' - : 'assets/images/booked.png', + 'assets/images/inpatient.png', height: 25, width: 35, )), ]) - : (isInpatient == true) - ? Row( - mainAxisAlignment: MainAxisAlignment.end, - children: [ - Container( - padding: EdgeInsets.all(4), - child: Image.asset( - 'assets/images/inpatient.png', - height: 25, - width: 35, - )), - ]) : SizedBox() ], ), @@ -454,5 +407,3 @@ class PatientCard extends StatelessWidget { )); } } - - diff --git a/pubspec.lock b/pubspec.lock index e2215d0c..53035a4a 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -141,6 +141,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "7.1.0" + cached_network_image: + dependency: "direct main" + description: + name: cached_network_image + url: "https://pub.dartlang.org" + source: hosted + version: "2.5.1" characters: dependency: transitive description: @@ -433,6 +440,20 @@ packages: description: flutter source: sdk version: "0.0.0" + flutter_blurhash: + dependency: transitive + description: + name: flutter_blurhash + url: "https://pub.dartlang.org" + source: hosted + version: "0.5.0" + flutter_cache_manager: + dependency: transitive + description: + name: flutter_cache_manager + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.2" flutter_device_type: dependency: "direct main" description: @@ -595,6 +616,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "3.1.4" + image: + dependency: transitive + description: + name: image + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.19" imei_plugin: dependency: "direct main" description: @@ -664,7 +692,7 @@ packages: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.3.0-nullsafety.3" + version: "1.3.0-nullsafety.4" mime: dependency: transitive description: @@ -693,6 +721,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.2.0" + octo_image: + dependency: transitive + description: + name: octo_image + url: "https://pub.dartlang.org" + source: hosted + version: "0.3.0" open_iconic_flutter: dependency: transitive description: @@ -728,6 +763,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.1.4" + path_provider: + dependency: transitive + description: + name: path_provider + url: "https://pub.dartlang.org" + source: hosted + version: "1.6.28" path_provider_linux: dependency: transitive description: @@ -735,6 +777,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.0.1+2" + path_provider_macos: + dependency: transitive + description: + name: path_provider_macos + url: "https://pub.dartlang.org" + source: hosted + version: "0.0.4+8" path_provider_platform_interface: dependency: transitive description: @@ -854,6 +903,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.1.5" + rxdart: + dependency: transitive + description: + name: rxdart + url: "https://pub.dartlang.org" + source: hosted + version: "0.25.0" scratch_space: dependency: transitive description: @@ -950,13 +1006,27 @@ packages: relative: true source: path version: "0.0.0" + sqflite: + dependency: transitive + description: + name: sqflite + url: "https://pub.dartlang.org" + source: hosted + version: "1.3.2+4" + sqflite_common: + dependency: transitive + description: + name: sqflite_common + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.3+3" stack_trace: dependency: transitive description: name: stack_trace url: "https://pub.dartlang.org" source: hosted - version: "1.10.0-nullsafety.1" + version: "1.10.0-nullsafety.2" sticky_headers: dependency: "direct main" description: @@ -985,6 +1055,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.1.0-nullsafety.1" + synchronized: + dependency: transitive + description: + name: synchronized + url: "https://pub.dartlang.org" + source: hosted + version: "2.2.0+2" term_glyph: dependency: transitive description: @@ -1154,5 +1231,5 @@ packages: source: hosted version: "2.2.1" sdks: - dart: ">=2.10.0 <2.11.0" - flutter: ">=1.22.0 <2.0.0" + dart: ">=2.10.2 <=2.11.0-213.1.beta" + flutter: ">=1.22.2 <2.0.0" diff --git a/pubspec.yaml b/pubspec.yaml index cf5ced70..66f0df91 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -96,6 +96,10 @@ dependencies: # Html Editor Enhanced html_editor_enhanced: ^1.3.0 + #Network Image + cached_network_image: ^2.5.0 + + # Badges badges: ^1.1.4