From 7e82746ce3f02f263610dc0add7470295d471cbf Mon Sep 17 00:00:00 2001 From: Faiz Hashmi Date: Mon, 2 Jan 2023 15:49:13 +0300 Subject: [PATCH] Pushing after callType Testing --- lib/core/api.dart | 46 +-- lib/core/base/base_app_client.dart | 6 +- lib/core/response_model/patient_call.dart | 20 +- lib/home/home_screen.dart | 23 +- lib/home/home_screen_bkp.dart | 410 +++++++++++----------- 5 files changed, 252 insertions(+), 253 deletions(-) diff --git a/lib/core/api.dart b/lib/core/api.dart index 01bb09c..8f747ae 100644 --- a/lib/core/api.dart +++ b/lib/core/api.dart @@ -21,27 +21,27 @@ class API{ }, onFailure: (error, status) => onFailure(error)); } - static Call_UpdateNotIsQueueRecordByIDAsync(String deviceIp, {@required List tickets, @required Function(List) onSuccess, @required Function(dynamic) onFailure}) async{ - if(tickets.isEmpty) { - return; - } - - List _ticketsUpdated = []; - - for (var ticket in tickets) { - final body = { "CallID" : ticket.callNo}; - await BaseAppClient.post(_call_UpdateNotIsQueueRecordByIDAsync, body: body, onSuccess: (response, status){ - if(status == 200){ - ticket.call_updated = true; - _ticketsUpdated.add(ticket); - } - }, onFailure: (error, status) => onFailure(error)); - } - - if(_ticketsUpdated.isNotEmpty) { - onSuccess(_ticketsUpdated); - }else{ - onFailure(false); - } - } + // static Call_UpdateNotIsQueueRecordByIDAsync(String deviceIp, {@required List tickets, @required Function(List) onSuccess, @required Function(dynamic) onFailure}) async{ + // if(tickets.isEmpty) { + // return; + // } + // + // List _ticketsUpdated = []; + // + // for (var ticket in tickets) { + // final body = { "CallID" : ticket.callNo}; + // await BaseAppClient.post(_call_UpdateNotIsQueueRecordByIDAsync, body: body, onSuccess: (response, status){ + // if(status == 200){ + // ticket.call_updated = true; + // _ticketsUpdated.add(ticket); + // } + // }, onFailure: (error, status) => onFailure(error)); + // } + // + // if(_ticketsUpdated.isNotEmpty) { + // onSuccess(_ticketsUpdated); + // }else{ + // onFailure(false); + // } + // } } diff --git a/lib/core/base/base_app_client.dart b/lib/core/base/base_app_client.dart index a4eeabc..c6e5d6c 100644 --- a/lib/core/base/base_app_client.dart +++ b/lib/core/base/base_app_client.dart @@ -32,7 +32,7 @@ class BaseAppClient { if (statusCode < 200 || statusCode >= 400) { onFailure(Utils.generateContactAdminMsg(), statusCode); } else { - print(response.body.toString()); + print("Response: ${response.body.toString()}"); var parsed = json.decode(response.body.toString()); onSuccess(parsed, statusCode); } @@ -57,8 +57,8 @@ class BaseAppClient { try { // String token = await sharedPref.getString(TOKEN); - print("URL : $url"); - print("Body : ${json.encode(body)}"); + print("URL GET: $url"); + print("Body GET: ${json.encode(body)}"); var asd = json.encode(body); var asd2; if (await Utils.checkConnection()) { diff --git a/lib/core/response_model/patient_call.dart b/lib/core/response_model/patient_call.dart index a7332f2..ff913fa 100644 --- a/lib/core/response_model/patient_call.dart +++ b/lib/core/response_model/patient_call.dart @@ -1,6 +1,4 @@ -import 'dart:convert'; - import 'package:queuing_system/utils/call_type.dart'; class Tickets { @@ -15,12 +13,13 @@ class Tickets { this.mobileNo, this.patientGender, this.patientID, - this.queueNo,}); + this.queueNo, + }); Tickets.fromJson(dynamic json) { callNo = json['CallNo']; roomNo = json['RoomNo']; - callType = json['CallType']; + callType = json['callType']; createdON = json['CreatedON']; doctorName = json['DoctorName']; doctorNameN = json['DoctorNameN']; @@ -48,7 +47,7 @@ class Tickets { final map = {}; map['CallNo'] = callNo; map['RoomNo'] = roomNo; - map['CallType'] = callType; + map['callType'] = callType; map['CreatedON'] = createdON; map['DoctorName'] = doctorName; map['DoctorNameN'] = doctorNameN; @@ -65,11 +64,10 @@ class Tickets { return (callNo).toString(); } - CallType getCallType(){ - if(callType == 0) return CallType.RECEPTION; - if(callType == 1) return CallType.NURSE; - if(callType == 2) return CallType.DOCTOR; + CallType getCallType() { + if (callType == 0) return CallType.RECEPTION; + if (callType == 1) return CallType.NURSE; + if (callType == 2) return CallType.DOCTOR; return CallType.NONE; } - -} \ No newline at end of file +} diff --git a/lib/home/home_screen.dart b/lib/home/home_screen.dart index 4c298a8..db9ea26 100644 --- a/lib/home/home_screen.dart +++ b/lib/home/home_screen.dart @@ -1,3 +1,5 @@ +import 'dart:developer'; + import 'package:connectivity/connectivity.dart'; import 'package:flutter/material.dart'; import 'package:queuing_system/core/api.dart'; @@ -12,7 +14,7 @@ import 'package:queuing_system/utils/signalR_utils.dart'; import 'package:queuing_system/utils/utils.dart'; import 'package:queuing_system/widget/data_display/app_texts_widget.dart'; -var DEVICE_IP = "10.20.20.19"; // Testing IP +var DEVICE_IP = "10.10.14.11"; // Testing IP // var DEVICE_IP = "10.70.249.21"; // (Make sure by Haroon before use it) Production IP class MyHomePage extends StatefulWidget { @@ -55,7 +57,6 @@ class _MyHomePageState extends State { @override Widget build(BuildContext context) { - return AppScaffold( appBar: AppHeader(), body: content(), @@ -124,12 +125,12 @@ class _MyHomePageState extends State { currents = currentInClinic; }); - print("\n\n"); - print("--------------------"); - print("Current: $currentInClinic"); - print("Waiting: $waitingCalls"); - print("--------------------"); - print("\n\n"); + log("\n\n"); + log("--------------------"); + log("Current: $currentInClinic"); + log("Waiting: $waitingCalls"); + log("--------------------"); + log("\n\n"); updateTickets(); @@ -150,15 +151,15 @@ class _MyHomePageState extends State { onConnect(){ - print("SignalR: onConnect"); + log("SignalR: onConnect"); } onDisconnect(exception){ - print("SignalR: onDisconnect"); + log("SignalR: onDisconnect"); } onConnecting(){ - print("SignalR: onConnecting"); + log("SignalR: onConnecting"); } listenNetworkConnectivity() async{ diff --git a/lib/home/home_screen_bkp.dart b/lib/home/home_screen_bkp.dart index 34b0dc2..e0ad7bc 100644 --- a/lib/home/home_screen_bkp.dart +++ b/lib/home/home_screen_bkp.dart @@ -1,205 +1,205 @@ -import 'dart:async'; -import 'package:flutter/material.dart'; -import 'package:queuing_system/core/api.dart'; -import 'package:queuing_system/core/base/app_scaffold_widget.dart'; -import 'package:queuing_system/core/base/base_app_client.dart'; -import 'package:queuing_system/core/config/config.dart'; -import 'package:queuing_system/core/config/size_config.dart'; -import 'package:queuing_system/header/app_header.dart'; -import 'package:queuing_system/home/que_item_list.dart'; -import 'package:queuing_system/utils/signalR_utils.dart'; -import 'package:queuing_system/utils/utils.dart'; -import 'package:queuing_system/widget/data_display/app_texts_widget.dart'; -import 'first_column.dart'; - - -var DEVICE_IP = "10.70.249.21"; - -class MyHomePage extends StatefulWidget { - String title = "MyHomePage"; - bool have0Patient = true; - bool have1Patient = false; - bool have2Patient = false; - bool have3Patient = false; - bool haveListOfPatient = false; - - @override - State createState() => _MyHomePageState(); -} - -class _MyHomePageState extends State { - Timer _timer; - int remainingTime = 30; - - @override - void dispose() { - _timer.cancel(); - super.dispose(); - } - - startTimer() { - Timer.periodic(const Duration(seconds: 1), (timer) { - if (remainingTime == 0) { - setState(() { - remainingTime = 30; - }); - } else { - setState(() { - remainingTime--; - if (remainingTime > 25) { - - /// for 0 patinet - widget.have0Patient = true; - widget.have1Patient = false; - widget.have2Patient = false; - widget.have3Patient = false; - widget.haveListOfPatient = false; - } else if (remainingTime > 20) { - /// for 1 patinet - - widget.have0Patient = false; - widget.have1Patient = true; - widget.have2Patient = false; - widget.have3Patient = false; - widget.haveListOfPatient = false; - } else if (remainingTime > 15) { - - /// for 2 patinet - - widget.have0Patient = false; - widget.have1Patient = false; - widget.have2Patient = true; - widget.have3Patient = false; - widget.haveListOfPatient = false; - } else if (remainingTime > 10) { - /// for 3 only patinet - widget.have0Patient = false; - widget.have1Patient = false; - widget.have2Patient = false; - widget.have3Patient = true; - widget.haveListOfPatient = false; - } else { - /// for 3+ only patinet - - widget.have0Patient = false; - widget.have1Patient = false; - widget.have2Patient = false; - widget.have3Patient = true; - widget.haveListOfPatient = true; - } - }); - } - }); - } - - @override - void initState() { - startTimer(); - // Get Ticket Info - // http://10.200.204.11:2222/Services/Nurses.svc/REST/GetCallRequestInfoByClinincInfo - - SignalRHelper signalRHelper = SignalRHelper(); - if (!signalRHelper.getConnectionState()) { - signalRHelper.startSignalRConnection(DEVICE_IP, onUpdateAvailable: onUpdateAvailable); - } - super.initState(); - } - - @override - Widget build(BuildContext context) { - - - return AppScaffold( - appBar: AppHeader(), - body: Column( - children: [ - SizedBox( - height: SizeConfig.getHeightMultiplier() * - (widget.haveListOfPatient - ? 2 - : widget.have1Patient || widget.have0Patient - ? 20 - : 10)), - widget.have0Patient - ? Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Center( - child: AppText("Awaiting Patients Arrival", - fontFamily: 'Poppins-SemiBold.ttf', - fontSize: SizeConfig.getWidthMultiplier() * 9), - ), - ], - ) - : widget.haveListOfPatient - ? Row( - children: [ - FirstColumn( - have3Patient: widget.have3Patient, - have2Patient: widget.have2Patient, - ), - const SizedBox( - width: 40, - ), - if (widget.haveListOfPatient) - Container( - width: 10, - height: SizeConfig.getHeightMultiplier() * 40, - color: AppGlobal.appLightGreyColor, - ), - if (widget.haveListOfPatient) - const SizedBox( - width: 40, - ), - if (widget.haveListOfPatient) const QueItemList() - ], - ) - : FirstColumn( - have3Patient: widget.have3Patient, - have2Patient: widget.have2Patient, - ), - ], - ), - bottomSheet: Container( - color: Colors.transparent, - height: Utils.getHeight(), - width: double.infinity, - child: Row( - children: [ - Padding( - padding: const EdgeInsets.only(top: 30, left: 30), - child: AppText( - "Powered By", - fontSize: SizeConfig.getWidthMultiplier() * 2.6, - fontFamily: 'Poppins-Medium.ttf', - ), - ), - Padding( - padding: const EdgeInsets.only(top: 40, left: 18), - child: Image.asset( - "assets/images/cloud_logo.png", - height: SizeConfig.getHeightMultiplier() * 6, - ), - ), - ], - ), - ), // This trailing comma makes auto-formatting nicer for build methods. - ); - } - - - onUpdateAvailable(data) async{ - API.GetCallRequestInfoByClinincInfo( - DEVICE_IP, - onSuccess: (waitingCalls, currentInClinic){ - print("\n\n"); - print("--------------------"); - print("Current: $currentInClinic"); - print("Waiting: $waitingCalls"); - print("--------------------"); - print("\n\n"); - }, onFailure: (error){ - - }); - } -} +// import 'dart:async'; +// import 'package:flutter/material.dart'; +// import 'package:queuing_system/core/api.dart'; +// import 'package:queuing_system/core/base/app_scaffold_widget.dart'; +// import 'package:queuing_system/core/base/base_app_client.dart'; +// import 'package:queuing_system/core/config/config.dart'; +// import 'package:queuing_system/core/config/size_config.dart'; +// import 'package:queuing_system/header/app_header.dart'; +// import 'package:queuing_system/home/que_item_list.dart'; +// import 'package:queuing_system/utils/signalR_utils.dart'; +// import 'package:queuing_system/utils/utils.dart'; +// import 'package:queuing_system/widget/data_display/app_texts_widget.dart'; +// import 'first_column.dart'; +// +// +// var DEVICE_IP = "10.70.249.21"; +// +// class MyHomePage extends StatefulWidget { +// String title = "MyHomePage"; +// bool have0Patient = true; +// bool have1Patient = false; +// bool have2Patient = false; +// bool have3Patient = false; +// bool haveListOfPatient = false; +// +// @override +// State createState() => _MyHomePageState(); +// } +// +// class _MyHomePageState extends State { +// Timer _timer; +// int remainingTime = 30; +// +// @override +// void dispose() { +// _timer.cancel(); +// super.dispose(); +// } +// +// startTimer() { +// Timer.periodic(const Duration(seconds: 1), (timer) { +// if (remainingTime == 0) { +// setState(() { +// remainingTime = 30; +// }); +// } else { +// setState(() { +// remainingTime--; +// if (remainingTime > 25) { +// +// /// for 0 patinet +// widget.have0Patient = true; +// widget.have1Patient = false; +// widget.have2Patient = false; +// widget.have3Patient = false; +// widget.haveListOfPatient = false; +// } else if (remainingTime > 20) { +// /// for 1 patinet +// +// widget.have0Patient = false; +// widget.have1Patient = true; +// widget.have2Patient = false; +// widget.have3Patient = false; +// widget.haveListOfPatient = false; +// } else if (remainingTime > 15) { +// +// /// for 2 patinet +// +// widget.have0Patient = false; +// widget.have1Patient = false; +// widget.have2Patient = true; +// widget.have3Patient = false; +// widget.haveListOfPatient = false; +// } else if (remainingTime > 10) { +// /// for 3 only patinet +// widget.have0Patient = false; +// widget.have1Patient = false; +// widget.have2Patient = false; +// widget.have3Patient = true; +// widget.haveListOfPatient = false; +// } else { +// /// for 3+ only patinet +// +// widget.have0Patient = false; +// widget.have1Patient = false; +// widget.have2Patient = false; +// widget.have3Patient = true; +// widget.haveListOfPatient = true; +// } +// }); +// } +// }); +// } +// +// @override +// void initState() { +// startTimer(); +// // Get Ticket Info +// // http://10.200.204.11:2222/Services/Nurses.svc/REST/GetCallRequestInfoByClinincInfo +// +// SignalRHelper signalRHelper = SignalRHelper(); +// if (!signalRHelper.getConnectionState()) { +// signalRHelper.startSignalRConnection(DEVICE_IP, onUpdateAvailable: onUpdateAvailable); +// } +// super.initState(); +// } +// +// @override +// Widget build(BuildContext context) { +// +// +// return AppScaffold( +// appBar: AppHeader(), +// body: Column( +// children: [ +// SizedBox( +// height: SizeConfig.getHeightMultiplier() * +// (widget.haveListOfPatient +// ? 2 +// : widget.have1Patient || widget.have0Patient +// ? 20 +// : 10)), +// widget.have0Patient +// ? Column( +// mainAxisAlignment: MainAxisAlignment.center, +// children: [ +// Center( +// child: AppText("Awaiting Patients Arrival", +// fontFamily: 'Poppins-SemiBold.ttf', +// fontSize: SizeConfig.getWidthMultiplier() * 9), +// ), +// ], +// ) +// : widget.haveListOfPatient +// ? Row( +// children: [ +// FirstColumn( +// have3Patient: widget.have3Patient, +// have2Patient: widget.have2Patient, +// ), +// const SizedBox( +// width: 40, +// ), +// if (widget.haveListOfPatient) +// Container( +// width: 10, +// height: SizeConfig.getHeightMultiplier() * 40, +// color: AppGlobal.appLightGreyColor, +// ), +// if (widget.haveListOfPatient) +// const SizedBox( +// width: 40, +// ), +// if (widget.haveListOfPatient) const QueItemList() +// ], +// ) +// : FirstColumn( +// have3Patient: widget.have3Patient, +// have2Patient: widget.have2Patient, +// ), +// ], +// ), +// bottomSheet: Container( +// color: Colors.transparent, +// height: Utils.getHeight(), +// width: double.infinity, +// child: Row( +// children: [ +// Padding( +// padding: const EdgeInsets.only(top: 30, left: 30), +// child: AppText( +// "Powered By", +// fontSize: SizeConfig.getWidthMultiplier() * 2.6, +// fontFamily: 'Poppins-Medium.ttf', +// ), +// ), +// Padding( +// padding: const EdgeInsets.only(top: 40, left: 18), +// child: Image.asset( +// "assets/images/cloud_logo.png", +// height: SizeConfig.getHeightMultiplier() * 6, +// ), +// ), +// ], +// ), +// ), // This trailing comma makes auto-formatting nicer for build methods. +// ); +// } +// +// +// onUpdateAvailable(data) async{ +// API.GetCallRequestInfoByClinincInfo( +// DEVICE_IP, +// onSuccess: (waitingCalls, currentInClinic){ +// print("\n\n"); +// print("--------------------"); +// print("Current: $currentInClinic"); +// print("Waiting: $waitingCalls"); +// print("--------------------"); +// print("\n\n"); +// }, onFailure: (error){ +// +// }); +// } +// }