From 3b0aff2efab5b93103e9e47660d2de0a40465a99 Mon Sep 17 00:00:00 2001 From: Sultan Khan Date: Sun, 28 Jun 2020 16:29:03 +0300 Subject: [PATCH] overflow issue and model mapped --- lib/models/livecare/get_pending_res_list.dart | 24 +- lib/providers/livecare_provider.dart | 8 +- lib/screens/live_care/panding_list.dart | 289 ++++++++---------- 3 files changed, 143 insertions(+), 178 deletions(-) diff --git a/lib/models/livecare/get_pending_res_list.dart b/lib/models/livecare/get_pending_res_list.dart index 22839f91..b45c53b9 100644 --- a/lib/models/livecare/get_pending_res_list.dart +++ b/lib/models/livecare/get_pending_res_list.dart @@ -1,24 +1,24 @@ class LiveCarePendingListResponse { - Null acceptedBy; - Null acceptedOn; + dynamic acceptedBy; + dynamic acceptedOn; int age; - Null appointmentNo; + dynamic appointmentNo; String arrivalTime; String arrivalTimeD; int callStatus; String clientRequestID; String clinicName; - Null consoltationEnd; - Null consultationNotes; - Null createdOn; + dynamic consoltationEnd; + dynamic consultationNotes; + dynamic createdOn; String dateOfBirth; String deviceToken; String deviceType; - Null doctorName; + dynamic doctorName; String editOn; String gender; bool isFollowUP; - Null isFromVida; + dynamic isFromVida; int isLoginB; bool isOutKSA; int isRejected; @@ -26,16 +26,16 @@ class LiveCarePendingListResponse { double latitude; double longitude; String mobileNumber; - Null openSession; - Null openTokenID; + dynamic openSession; + dynamic openTokenID; String patientID; String patientName; int patientStatus; String preferredLanguage; int projectID; - int scoring; + double scoring; int serviceID; - Null tokenID; + dynamic tokenID; int vCID; String voipToken; diff --git a/lib/providers/livecare_provider.dart b/lib/providers/livecare_provider.dart index 31c012f8..dcce7e0e 100644 --- a/lib/providers/livecare_provider.dart +++ b/lib/providers/livecare_provider.dart @@ -3,6 +3,7 @@ import 'dart:convert'; import 'package:doctor_app_flutter/client/base_app_client.dart'; import 'package:doctor_app_flutter/config/config.dart'; import 'package:doctor_app_flutter/models/livecare/get_panding_req_list.dart'; +import 'package:doctor_app_flutter/models/livecare/get_pending_res_list.dart'; import 'package:doctor_app_flutter/models/livecare/start_call_req.dart'; import 'package:doctor_app_flutter/util/dr_app_shared_pref.dart'; import 'package:doctor_app_flutter/util/helpers.dart'; @@ -12,7 +13,7 @@ import 'package:doctor_app_flutter/config/shared_pref_kay.dart'; class LiveCareProvider with ChangeNotifier { DrAppSharedPreferances sharedPref = new DrAppSharedPreferances(); - var liveCarePendingList = []; + List liveCarePendingList = []; var inCallResponse = {}; bool isFinished = true; bool hasError = false; @@ -33,7 +34,10 @@ class LiveCareProvider with ChangeNotifier { await BaseAppClient.post(GET_LIVECARE_PENDINGLIST, onSuccess: (response, statusCode) async { isFinished = true; - liveCarePendingList = response["List_PendingPatientList"]; + liveCarePendingList = []; + response['List_PendingPatientList'].forEach((v) { + liveCarePendingList.add(new LiveCarePendingListResponse.fromJson(v)); + }); }, onFailure: (String error, int statusCode) { isFinished = true; throw error; diff --git a/lib/screens/live_care/panding_list.dart b/lib/screens/live_care/panding_list.dart index 202fc774..18b787cd 100644 --- a/lib/screens/live_care/panding_list.dart +++ b/lib/screens/live_care/panding_list.dart @@ -29,14 +29,18 @@ class LiveCarePandingListScreen extends StatefulWidget { } class _LiveCarePandingListState extends State { - var _data = []; + List _data = []; Helpers helpers = new Helpers(); + bool _isInit = true; LiveCareProvider _liveCareProvider; @override void didChangeDependencies() { super.didChangeDependencies(); - _liveCareProvider = Provider.of(context); - if (_data.isEmpty) pendingList(); + if (_isInit) { + _liveCareProvider = Provider.of(context); + pendingList(); + } + _isInit = false; } @override @@ -63,7 +67,8 @@ class _LiveCarePandingListState extends State { ), ) : Column( - children: _data.map((item) { + children: _liveCareProvider.liveCarePendingList + .map((item) { return Container( decoration: myBoxDecoration(), child: InkWell( @@ -75,124 +80,125 @@ class _LiveCarePandingListState extends State { // decoration: myBoxDecoration(), child: Row( children: [ - Column( - children: [ - Container( - decoration: - BoxDecoration( - gradient: - LinearGradient( - begin: - Alignment( - -1, - -1), - end: - Alignment( - 1, - 1), - colors: [ - Colors.grey[ - 100], - Colors.grey[ - 200], - ]), - boxShadow: [ - BoxShadow( - color: Color - .fromRGBO( - 0, - 0, - 0, - 0.08), - offset: - Offset( - 0.0, - 5.0), - blurRadius: - 16.0) - ], - borderRadius: - BorderRadius.all( - Radius.circular( - 50.0)), - ), - width: 80, - height: 80, - child: Icon( - item["Gender"] == - "1" - ? DoctorApp.male - : DoctorApp - .femaleicon, - size: 80, - )), - ], - ), - SizedBox( - width: 20, - ), - Column( - crossAxisAlignment: - CrossAxisAlignment - .start, - children: [ - AppText( - item["PatientName"], - fontSize: 2.0 * - SizeConfig - .textMultiplier, - fontWeight: - FontWeight.bold, - backGroundcolor: - Colors.white, - ), - SizedBox( - height: 8, - ), - AppText( - TranslationBase.of( - context) - .fileNo + - item["PatientID"] - .toString(), - fontSize: 2.0 * - SizeConfig - .textMultiplier, - fontWeight: - FontWeight.bold, - backGroundcolor: - Colors.white, - ), + Expanded( + flex: 4, + child: Row( + children: [ + Column( + children: [ + Container( + decoration: + BoxDecoration( + gradient: LinearGradient( + begin: Alignment( + -1, + -1), + end: Alignment( + 1, 1), + colors: [ + Colors.grey[ + 100], + Colors.grey[ + 200], + ]), + boxShadow: [ + BoxShadow( + color: Color.fromRGBO( + 0, + 0, + 0, + 0.08), + offset: Offset( + 0.0, + 5.0), + blurRadius: + 16.0) + ], + borderRadius: + BorderRadius.all( + Radius.circular( + 50.0)), + ), + width: 80, + height: 80, + child: Icon( + item.gender == + "1" + ? DoctorApp + .male + : DoctorApp + .femaleicon, + size: 80, + )), + ], + ), + SizedBox( + width: 20, + ), + Column( + crossAxisAlignment: + CrossAxisAlignment + .start, + children: [ + AppText( + item.patientName, + fontSize: 2.0 * + SizeConfig + .textMultiplier, + fontWeight: + FontWeight + .bold, + backGroundcolor: + Colors.white, + ), + SizedBox( + height: 8, + ), + AppText( + TranslationBase.of( + context) + .fileNo + + item.patientID + .toString(), + fontSize: 2.0 * + SizeConfig + .textMultiplier, + fontWeight: + FontWeight + .bold, + backGroundcolor: + Colors.white, + ), - // SizedBox( - // height: 8, - // ), - AppText( - TranslationBase.of( - context) - .age + - ' ' + - item["Age"] - .toString(), - fontSize: 2.0 * - SizeConfig - .textMultiplier, - fontWeight: - FontWeight.bold, - backGroundcolor: - Colors.white, - ), - SizedBox( - height: 8, - ), - ], - ), - SizedBox( - width: 80, + // SizedBox( + // height: 8, + // ), + AppText( + TranslationBase.of( + context) + .age + + ' ' + + item.age + .toString(), + fontSize: 2.0 * + SizeConfig + .textMultiplier, + fontWeight: + FontWeight + .bold, + backGroundcolor: + Colors.white, + ), + SizedBox( + height: 8, + ), + ], + ), + ], + ), ), - // Divider(color: Colors.grey Expanded( - flex: 3, + flex: 1, child: IconButton( icon: Icon( Icons.video_call, @@ -230,51 +236,6 @@ class _LiveCarePandingListState extends State { _liveCareProvider.getpendingList().then((result) { this.setState(() { _data = _liveCareProvider.liveCarePendingList; - // _data = [ - // { - // "AcceptedBy": null, - // "AcceptedOn": null, - // "Age": 33, - // "AppointmentNo": null, - // "ArrivalTime": "2020-06-14 09:34", - // "ArrivalTimeD": "/Date(1592116471237+0300)/", - // "CallStatus": 1, - // "ClientRequestID": "2344670985-1231755-1584378710", - // "ClinicName": "ER Clinic", - // "ConsoltationEnd": null, - // "ConsultationNotes": null, - // "CreatedOn": null, - // "DateOfBirth": "1987-01-04", - // "DeviceToken": - // "fbxt2XpseU_DpO8Msqa1V6:APA91bHUxsfKpAewTt0DzGg_mSTN0T7KIQM92VpubUTobgTm0-DGcJMgcc3DmERbEiWbyTup3zGttU3_9RBaRBxZUKj9ju5wnTGSrIelEE-qxOK30YnIaDhbhs8fJixACbyzgr72HU8Y", - // "DeviceType": "iOS", - // "DoctorName": null, - // "EditOn": "/Date(1592116471237+0300)/", - // "Gender": "1", - // "IsFollowUP": false, - // "IsFromVida": null, - // "IsLoginB": 0, - // "IsOutKSA": false, - // "IsRejected": 0, - // "Language": "AR", - // "Latitude": 24.708879, - // "Longitude": 46.665827, - // "MobileNumber": "0537503378", - // "OpenSession": null, - // "OpenTokenID": null, - // "PatientID": "1231755", - // "PatientName": "TAMER FANASHEH", - // "PatientStatus": 1, - // "PreferredLanguage": "Ar", - // "ProjectID": 0, - // "Scoring": 0.00, - // "ServiceID": 1, - // "TokenID": null, - // "VC_ID": 2240, - // "VoipToken": - // "8dcc17e2365d4f3c4afadc6b5d625a88407398ee517f0e9beda7f663007e88b9" - // } - // ]; }); }); return true;