From 941ca2ff0e51869322b5d9c82ce20f3258de966e Mon Sep 17 00:00:00 2001 From: FaizHashmiCS22 Date: Thu, 31 Aug 2023 09:47:33 +0300 Subject: [PATCH] Reformatted Code --- lib/core/api.dart | 12 +- lib/core/base/app_scaffold_widget.dart | 33 +-- lib/core/base/base_app_client.dart | 62 ++---- lib/core/base/base_service.dart | 18 +- lib/core/base/base_view.dart | 100 ++++----- lib/core/base/view_state.dart | 2 +- lib/core/response_model/call_config.dart | 50 ++--- lib/core/response_model/patient_call.dart | 14 +- lib/home/first_column.dart | 32 --- lib/home/home_screen_bkp.dart | 205 ------------------ lib/home/home_screen_components.dart | 12 +- lib/home/priority_calls.dart | 28 ++- lib/home/que_item/que_item.dart | 88 -------- lib/home/que_item/que_item_widget.dart | 67 ------ lib/home/que_item_list.dart | 54 ++--- lib/main.dart | 6 +- lib/utils/call_type.dart | 32 +-- lib/widget/app_loader_widget.dart | 7 +- lib/widget/loader/gif_loader_container.dart | 16 +- .../loader/gif_loader_dialog_utils.dart | 2 - 20 files changed, 211 insertions(+), 629 deletions(-) delete mode 100644 lib/home/first_column.dart delete mode 100644 lib/home/home_screen_bkp.dart delete mode 100644 lib/home/que_item/que_item.dart delete mode 100644 lib/home/que_item/que_item_widget.dart diff --git a/lib/core/api.dart b/lib/core/api.dart index 43a9d99..cc2cf43 100644 --- a/lib/core/api.dart +++ b/lib/core/api.dart @@ -4,6 +4,7 @@ import 'dart:io'; import 'package:flutter/cupertino.dart'; import 'package:queuing_system/core/base/base_app_client.dart'; import 'package:queuing_system/core/config/config.dart'; +import 'package:queuing_system/core/response_model/call_config.dart'; import 'package:queuing_system/core/response_model/patient_call.dart'; import 'package:queuing_system/home/home_screen.dart'; @@ -18,13 +19,14 @@ class MyHttpOverrides extends HttpOverrides { } class API { - static getCallRequestInfoByClinicInfo(String deviceIp, {@required Function(List, List) onSuccess, @required Function(dynamic) onFailure}) async { + static getCallRequestInfoByClinicInfo(String deviceIp, {@required Function(List, List, CallConfig callConfig) onSuccess, @required Function(dynamic) onFailure}) async { final body = {"ipAdress": deviceIp, "apiKey": apiKey}; if (isDevMode) { var callPatients = Tickets.testCallPatients; var isQueuePatients = callPatients.where((element) => (element.callType == 1 && element.isQueue == false) || (element.callType == 2 && element.isQueue == false)).toList(); - onSuccess(callPatients.reversed.toList(), isQueuePatients.reversed.toList()); + CallConfig callConfig = CallConfig(); + onSuccess(callPatients.reversed.toList(), isQueuePatients.reversed.toList(), callConfig); return; } BaseAppClient.post(_getCallRequestInfoByClinicInfo, @@ -32,6 +34,8 @@ class API { onSuccess: (apiResp, status) { if (status == 200) { final response = apiResp["data"]; + + CallConfig callConfig = CallConfig.fromJson(response["callConfig"]); var callPatients = (response["callPatients"] as List).map((j) => Tickets.fromJson(j)).toList(); // final patients = (response["drCallPatients"] as List).map((j) => Tickets.fromJson(j)).toList(); // callPatients.addAll(patients); @@ -44,7 +48,7 @@ class API { // callPatients.addAll(isQueuePatients.toList()); - onSuccess(callPatients.reversed.toList(), isQueuePatients.reversed.toList()); + onSuccess(callPatients.reversed.toList(), isQueuePatients.reversed.toList(), callConfig); } else { onFailure(apiResp); } @@ -60,7 +64,7 @@ class API { List _ticketsUpdated = []; // for (var ticket in tickets) { - final body = {"id": ticket.id, "apiKey": apiKey, "ipAddress": deviceIp}; + final body = {"id": ticket.id, "apiKey": apiKey, "ipAddress": deviceIp, "callType": ticket.callType}; await BaseAppClient.post(_callUpdateNotIsQueueRecordByIDAsync, body: body, onSuccess: (response, status) { diff --git a/lib/core/base/app_scaffold_widget.dart b/lib/core/base/app_scaffold_widget.dart index 3443537..b3733a4 100644 --- a/lib/core/base/app_scaffold_widget.dart +++ b/lib/core/base/app_scaffold_widget.dart @@ -21,8 +21,8 @@ class AppScaffold extends StatelessWidget { final bool isHomeIcon; final bool extendBody; - AppScaffold( - {this.appBarTitle = '', + const AppScaffold( + {Key key, this.appBarTitle = '', this.body, this.isLoading = false, this.isShowAppBar = true, @@ -34,14 +34,15 @@ class AppScaffold extends StatelessWidget { this.subtitle, this.drawer, this.extendBody = false, - this.bottomNavigationBar}); + this.bottomNavigationBar}) : super(key: key); @override Widget build(BuildContext context) { ProjectViewModel projectProvider = Provider.of(context); + return GestureDetector( onTap: () { - FocusScope.of(context).requestFocus(new FocusNode()); + FocusScope.of(context).requestFocus(FocusNode()); }, child: Scaffold( backgroundColor: backgroundColor ?? Theme.of(context).scaffoldBackgroundColor @@ -54,12 +55,6 @@ class AppScaffold extends StatelessWidget { AppBar( elevation: 0, backgroundColor: Colors.white, - //HexColor('#515B5D'), - textTheme: TextTheme( - headline6: TextStyle( - color: Colors.black87, - fontSize: 16.8, - )), title: Column( crossAxisAlignment: CrossAxisAlignment.center, children: [ @@ -67,20 +62,28 @@ class AppScaffold extends StatelessWidget { if (subtitle != null) Text( subtitle, - style: TextStyle(fontSize: 12, color: Colors.red), + style: const TextStyle(fontSize: 12, color: Colors.red), ), ], ), leading: Builder(builder: (BuildContext context) { return IconButton( - icon: Icon(Icons.arrow_back_ios), + icon: const Icon(Icons.arrow_back_ios), color: Colors.black, //Colors.black, onPressed: () => Navigator.pop(context), ); }), centerTitle: true, - actions: [ - ], + actions: const [ + ], toolbarTextStyle: const TextTheme( + titleLarge: TextStyle( + color: Colors.black87, + fontSize: 16.8, + )).bodyMedium, titleTextStyle: const TextTheme( + titleLarge: TextStyle( + color: Colors.black87, + fontSize: 16.8, + )).titleLarge, ) : null, bottomSheet: bottomSheet, @@ -101,7 +104,7 @@ class AppScaffold extends StatelessWidget { "assets/images/undraw_connected_world_wuay.png", height: 250, ), - AppText('No Internet Connection') + const AppText('No Internet Connection') ], ), ), diff --git a/lib/core/base/base_app_client.dart b/lib/core/base/base_app_client.dart index 8406157..bfeb5f7 100644 --- a/lib/core/base/base_app_client.dart +++ b/lib/core/base/base_app_client.dart @@ -1,56 +1,41 @@ - import 'dart:convert'; import 'dart:developer'; -import 'dart:io' show Platform; + +import 'package:http/http.dart' as http; import 'package:queuing_system/core/config/config.dart'; import 'package:queuing_system/utils/Utils.dart'; -import 'package:http/http.dart' as http; class BaseAppClient { - static post(String endPoint, - {Map body, - Function(dynamic response, int statusCode) onSuccess, - Function(String error, int statusCode) onFailure}) async { + static post(String endPoint, {Map body, Function(dynamic response, int statusCode) onSuccess, Function(String error, int statusCode) onFailure}) async { String url; url = BASE_URL + endPoint; try { - - print("URL : $url"); - print("Body : ${json.encode(body)}"); - var asd = json.encode(body); - var asd2; + log("URL : $url"); + log("Body : ${json.encode(body)}"); if (await Utils.checkConnection()) { - - final response = await http.post(Uri.parse(url), - body: json.encode(body), - headers: { - 'Content-Type': 'application/json', - 'Accept': 'application/json', - }); + final response = await http.post(Uri.parse(url), body: json.encode(body), headers: { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }); final int statusCode = response.statusCode; if (statusCode < 200 || statusCode >= 400) { onFailure(Utils.generateContactAdminMsg(), statusCode); } else { log("Response: ${response.body.toString()}"); var parsed = json.decode(response.body.toString()); - onSuccess(parsed, statusCode); + onSuccess(parsed, statusCode); } } else { onFailure('Please Check The Internet Connection', -1); } } catch (e) { - print(e); onFailure(e.toString(), -1); } } - - static get(String endPoint, - {Map body, - Function(dynamic response, int statusCode) onSuccess, - Function(String error, int statusCode) onFailure}) async { + static get(String endPoint, {Map body, Function(dynamic response, int statusCode) onSuccess, Function(String error, int statusCode) onFailure}) async { String url; url = BASE_URL + endPoint; @@ -58,16 +43,10 @@ class BaseAppClient { try { // String token = await sharedPref.getString(TOKEN); - print("URL GET: $url"); - print("Body GET: ${json.encode(body)}"); - var asd = json.encode(body); - var asd2; + log("URL GET: $url"); + log("Body GET: ${json.encode(body)}"); if (await Utils.checkConnection()) { - final response = await http.get(Uri.parse(url), - headers: { - 'Content-Type': 'application/json', - 'Accept': 'application/json' - }); + final response = await http.get(Uri.parse(url), headers: {'Content-Type': 'application/json', 'Accept': 'application/json'}); final int statusCode = response.statusCode; if (statusCode < 200 || statusCode >= 400) { onFailure(Utils.generateContactAdminMsg(), statusCode); @@ -79,26 +58,19 @@ class BaseAppClient { onFailure('Please Check The Internet Connection', -1); } } catch (e) { - print(e); onFailure(e.toString(), -1); } } - String getError(parsed) { //TODO change this fun String error = parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage']; if (parsed["ValidationErrors"] != null) { error = parsed["ValidationErrors"]["StatusMessage"].toString() + "\n"; - if (parsed["ValidationErrors"]["ValidationErrors"] != null && - parsed["ValidationErrors"]["ValidationErrors"].length != 0) { - for (var i = 0; - i < parsed["ValidationErrors"]["ValidationErrors"].length; - i++) { - error = error + - parsed["ValidationErrors"]["ValidationErrors"][i]["Messages"][0] + - "\n"; + if (parsed["ValidationErrors"]["ValidationErrors"] != null && parsed["ValidationErrors"]["ValidationErrors"].length != 0) { + for (var i = 0; i < parsed["ValidationErrors"]["ValidationErrors"].length; i++) { + error = error + parsed["ValidationErrors"]["ValidationErrors"][i]["Messages"][0] + "\n"; } } } diff --git a/lib/core/base/base_service.dart b/lib/core/base/base_service.dart index 573f83e..c80d114 100644 --- a/lib/core/base/base_service.dart +++ b/lib/core/base/base_service.dart @@ -1,9 +1,9 @@ - -class BaseService { - String error; - bool hasError = false; - - - BaseService() { - } -} +// +// class BaseService { +// String error; +// bool hasError = false; +// +// +// BaseService() { +// } +// } diff --git a/lib/core/base/base_view.dart b/lib/core/base/base_view.dart index 4ffde3d..70e7f4c 100644 --- a/lib/core/base/base_view.dart +++ b/lib/core/base/base_view.dart @@ -1,50 +1,50 @@ -import 'package:flutter/material.dart'; -import 'package:provider/provider.dart'; - -import 'base_view_model.dart'; -import 'locater.dart'; - -class BaseView extends StatefulWidget { - final Widget Function(BuildContext context, T model, Widget child) builder; - final Function(T) onModelReady; - - BaseView({ - this.builder, - this.onModelReady, - }); - - @override - _BaseViewState createState() => _BaseViewState(); -} - -class _BaseViewState extends State> { - T model = locator(); - - bool isLogin = false; - - @override - void initState() { - if (widget.onModelReady != null) { - widget.onModelReady(model); - } - - super.initState(); - } - - @override - Widget build(BuildContext context) { - return ChangeNotifierProvider.value( - value: model, - child: Consumer(builder: widget.builder), - ); - } - - @override - void dispose() { - if (model != null) { - model = null; - } - - super.dispose(); - } -} +// import 'package:flutter/material.dart'; +// import 'package:provider/provider.dart'; +// +// import 'base_view_model.dart'; +// import 'locater.dart'; +// +// class BaseView extends StatefulWidget { +// final Widget Function(BuildContext context, T model, Widget child) builder; +// final Function(T) onModelReady; +// +// BaseView({ +// this.builder, +// this.onModelReady, +// }); +// +// @override +// _BaseViewState createState() => _BaseViewState(); +// } +// +// class _BaseViewState extends State> { +// T model = locator(); +// +// bool isLogin = false; +// +// @override +// void initState() { +// if (widget.onModelReady != null) { +// widget.onModelReady(model); +// } +// +// super.initState(); +// } +// +// @override +// Widget build(BuildContext context) { +// return ChangeNotifierProvider.value( +// value: model, +// child: Consumer(builder: widget.builder), +// ); +// } +// +// @override +// void dispose() { +// if (model != null) { +// model = null; +// } +// +// super.dispose(); +// } +// } diff --git a/lib/core/base/view_state.dart b/lib/core/base/view_state.dart index 94d79be..c8fa6a1 100644 --- a/lib/core/base/view_state.dart +++ b/lib/core/base/view_state.dart @@ -1 +1 @@ -enum ViewState { Idle, Busy, Error, BusyLocal, ErrorLocal } +enum ViewState { Idle, Busy, Error, BusyLocal, ErrorLocal } \ No newline at end of file diff --git a/lib/core/response_model/call_config.dart b/lib/core/response_model/call_config.dart index 9bfc3c8..81aae85 100644 --- a/lib/core/response_model/call_config.dart +++ b/lib/core/response_model/call_config.dart @@ -27,30 +27,30 @@ class CallConfig { CallConfig( {this.id, - this.globalClinicPrefixReq, - this.clinicPrefixReq, - this.concurrentCallDelaySec, - this.voiceType, - this.screenLanguage, - this.voiceLanguage, - this.screenMaxDisplayPatients, - this.prioritySMS, - this.priorityWhatsApp, - this.priorityEmail, - this.vitalSignText, - this.vitalSignTextN, - this.doctorText, - this.doctorTextN, - this.procedureText, - this.procedureTextN, - this.vaccinationText, - this.vaccinationTextN, - this.nebulizationText, - this.nebulizationTextN, - this.createdBy, - this.createdOn, - this.editedBy, - this.editedOn}); + this.globalClinicPrefixReq, + this.clinicPrefixReq, + this.concurrentCallDelaySec, + this.voiceType, + this.screenLanguage, + this.voiceLanguage, + this.screenMaxDisplayPatients, + this.prioritySMS, + this.priorityWhatsApp, + this.priorityEmail, + this.vitalSignText, + this.vitalSignTextN, + this.doctorText, + this.doctorTextN, + this.procedureText, + this.procedureTextN, + this.vaccinationText, + this.vaccinationTextN, + this.nebulizationText, + this.nebulizationTextN, + this.createdBy, + this.createdOn, + this.editedBy, + this.editedOn}); CallConfig.fromJson(Map json) { id = json['id']; @@ -58,7 +58,7 @@ class CallConfig { clinicPrefixReq = json['clinicPrefixReq']; concurrentCallDelaySec = json['concurrentCallDelaySec']; voiceType = json['voiceType']; - screenLanguage = json['screenLanguage']; + screenLanguage = json['screenLanguage'] ?? 1; voiceLanguage = json['voiceLanguage']; screenMaxDisplayPatients = json['screenMaxDisplayPatients']; prioritySMS = json['prioritySMS']; diff --git a/lib/core/response_model/patient_call.dart b/lib/core/response_model/patient_call.dart index a72d061..72afad8 100644 --- a/lib/core/response_model/patient_call.dart +++ b/lib/core/response_model/patient_call.dart @@ -92,19 +92,7 @@ class Tickets { } CallType getCallType() { - // { - // [EnumMember] - // VitalSign = 1, - // [EnumMember] - // Doctor = 2, - // [EnumMember] - // Procedure = 3, - // [EnumMember] - // Vaccination = 4, - // [EnumMember] - // Nebulization = 5 - - if (callType == 1) return CallType.nebulization; + if (callType == 1) return CallType.vitalSign; if (callType == 2) return CallType.doctor; if (callType == 3) return CallType.procedure; if (callType == 4) return CallType.vaccination; diff --git a/lib/home/first_column.dart b/lib/home/first_column.dart deleted file mode 100644 index f99e8eb..0000000 --- a/lib/home/first_column.dart +++ /dev/null @@ -1,32 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:queuing_system/core/config/size_config.dart'; -import 'package:queuing_system/home/que_item/que_item.dart'; - -class FirstColumn extends StatelessWidget { - final bool have3Patient; - final bool have2Patient; - - const FirstColumn({Key key, this.have3Patient = false, this.have2Patient = false}) : super(key: key); - - @override - Widget build(BuildContext context) { - return Column( - mainAxisAlignment: MainAxisAlignment.start, - children: [ - const TicketItem(queNo: "OBG-T45", isFirstLine: true, isNurseVisit: true, haveListOfPatient: true,), - SizedBox( - height: SizeConfig.getHeightMultiplier() * 5,), - if(have3Patient ||have2Patient ) - Row( - mainAxisAlignment: MainAxisAlignment.spaceAround, - children: [ - if(have2Patient || have3Patient) - const TicketItem(queNo: "OBG-T45", isSecondLine: true, isNurseVisit: false, haveListOfPatient: true,), - if(have3Patient) - const TicketItem(queNo: "OBG-T45", isSecondLine: true, isNurseVisit: true, haveListOfPatient: true,), - ], - ), - ], - ); - } -} diff --git a/lib/home/home_screen_bkp.dart b/lib/home/home_screen_bkp.dart deleted file mode 100644 index e0ad7bc..0000000 --- a/lib/home/home_screen_bkp.dart +++ /dev/null @@ -1,205 +0,0 @@ -// 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){ -// -// }); -// } -// } diff --git a/lib/home/home_screen_components.dart b/lib/home/home_screen_components.dart index b9ed7b7..a24e35e 100644 --- a/lib/home/home_screen_components.dart +++ b/lib/home/home_screen_components.dart @@ -1,6 +1,6 @@ -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:queuing_system/core/config/size_config.dart'; +import 'package:queuing_system/core/response_model/call_config.dart'; import 'package:queuing_system/core/response_model/patient_call.dart'; import 'package:queuing_system/home/priority_calls.dart'; import 'package:queuing_system/utils/call_type.dart'; @@ -17,16 +17,16 @@ Widget noPatientInQueue() { ); } -Widget priorityTickets(List tickets) { - return PriorityTickets(tickets); +Widget priorityTickets(List tickets, CallConfig callConfig) { + return PriorityTickets(tickets, callConfig); } -Widget priorityTicketsWithSideList(List tickets) { +Widget priorityTicketsWithSideList(List tickets, CallConfig callConfig) { final priorityTickets = tickets.sublist(0, 3); final otherTickets = tickets.sublist(3, tickets.length); return Row( children: [ - Expanded(flex: 7, child: PriorityTickets(priorityTickets)), + Expanded(flex: 7, child: PriorityTickets(priorityTickets, callConfig)), Container(color: Colors.grey.withOpacity(0.1), width: 10, margin: const EdgeInsets.symmetric(horizontal: 10, vertical: 50)), Expanded( flex: 5, @@ -63,7 +63,7 @@ Widget priorityTicketsWithSideList(List tickets) { SizedBox( width: SizeConfig.getWidthMultiplier() * 28, child: AppText( - itm.getCallType().message('en'), + itm.getCallType().message(callConfig), color: itm.getCallType().color(), letterSpacing: -1.5, fontSize: SizeConfig.getWidthMultiplier() * 3, diff --git a/lib/home/priority_calls.dart b/lib/home/priority_calls.dart index b0b2d9e..02db99e 100644 --- a/lib/home/priority_calls.dart +++ b/lib/home/priority_calls.dart @@ -1,14 +1,16 @@ import 'package:blinking_text/blinking_text.dart'; import 'package:flutter/material.dart'; import 'package:queuing_system/core/config/size_config.dart'; +import 'package:queuing_system/core/response_model/call_config.dart'; import 'package:queuing_system/core/response_model/patient_call.dart'; import 'package:queuing_system/utils/call_type.dart'; import 'package:queuing_system/widget/data_display/app_texts_widget.dart'; class PriorityTickets extends StatelessWidget { final List tickets; + final CallConfig callConfig; - const PriorityTickets(this.tickets, {Key key}) : super(key: key); + const PriorityTickets(this.tickets, this.callConfig, {Key key}) : super(key: key); @override Widget build(BuildContext context) { @@ -27,6 +29,7 @@ class PriorityTickets extends StatelessWidget { blink: true, roomNo: firstTicket.roomNo, isClinicAdded: firstTicket.callNoStr != firstTicket.queueNo, + callConfig: callConfig, ), const SizedBox(height: 40), if (tickets.length > 1) ...[ @@ -42,6 +45,7 @@ class PriorityTickets extends StatelessWidget { scale: 0.7, roomNo: ticket.roomNo, isClinicAdded: ticket.callNoStr != ticket.queueNo, + callConfig: callConfig, ), )) .toList(), @@ -59,11 +63,20 @@ class TicketItem extends StatelessWidget { final bool blink; final double scale; final bool isClinicAdded; + final CallConfig callConfig; - const TicketItem({Key key, @required this.isClinicAdded, @required this.ticketNo, @required this.roomNo, @required this.callType, this.scale, this.blink = false}) : super(key: key); + const TicketItem({ + Key key, + @required this.isClinicAdded, + @required this.ticketNo, + @required this.roomNo, + @required this.callType, + @required this.callConfig, + this.scale, + this.blink = false, + }) : super(key: key); String getFormattedTicket(String ticketNo, bool isClinicAdded) { - print("ticket: $ticketNo"); if (isClinicAdded) { var formattedString = ticketNo.split(" "); return formattedString[0] + " " + formattedString[1]; @@ -90,13 +103,6 @@ class TicketItem extends StatelessWidget { // endColor: blink ? AppGlobal.appRedColor : Colors.black, times: 0, duration: const Duration(seconds: 1)), - // AppText( - // ticketNo, - // letterSpacing: -9.32, - // fontSize: SizeConfig.getWidthMultiplier() * 16, - // fontWeight: FontWeight.bold, - // fontHeight: 0.7, - // ), const SizedBox(height: 10), Row( crossAxisAlignment: CrossAxisAlignment.end, @@ -105,7 +111,7 @@ class TicketItem extends StatelessWidget { callType.icon(SizeConfig.getHeightMultiplier() * 3), const SizedBox(width: 10), AppText( - callType.message('en'), + callType.message(callConfig), color: callType.color(), letterSpacing: -1.5, fontSize: SizeConfig.getWidthMultiplier() * 3.8, diff --git a/lib/home/que_item/que_item.dart b/lib/home/que_item/que_item.dart deleted file mode 100644 index 68c0454..0000000 --- a/lib/home/que_item/que_item.dart +++ /dev/null @@ -1,88 +0,0 @@ -import 'package:flutter/cupertino.dart'; -import 'package:flutter_svg/flutter_svg.dart'; -import 'package:queuing_system/core/config/config.dart'; -import 'package:queuing_system/core/config/size_config.dart'; -import 'package:queuing_system/home/que_item/que_item_widget.dart'; -import 'package:queuing_system/widget/data_display/app_texts_widget.dart'; - -class TicketItem extends StatelessWidget { - const TicketItem({ - Key key, - this.isFirstLine = false, - this.isSecondLine = false, - this.isInListLine = false, - this.queNo, - this.isNurseVisit = false, - this.idDoctorVisit = false, this.haveListOfPatient - }) : super(key: key); - final bool isFirstLine; - final bool isSecondLine; - final bool isInListLine; - final bool isNurseVisit; - final bool idDoctorVisit; - final String queNo; - final bool haveListOfPatient; - - @override - Widget build(BuildContext context) { - return haveListOfPatient? - Padding( - padding: const EdgeInsets.all(45.0), - child: Column( - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - QueItemWidget( - isFirstLine: isFirstLine, - isNurseVisit: isNurseVisit, - isSecondLine: isSecondLine, - queNo: queNo, - ), - ], - ), - ) - :Row( - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Padding( - padding: const EdgeInsets.only(right: 20.0, left: 20.0), - child: AppText( - queNo, - fontSize: SizeConfig.getWidthMultiplier() * - (isFirstLine - ? 13 - : isSecondLine - ? 8.5 - : 4.7), - letterSpacing: -3.26, - fontWeight: FontWeight.w600, - fontFamily: 'Poppins', - ), - ), - const SizedBox(width: 30,), - - Row( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SvgPicture.asset( - isNurseVisit - ? "assets/images/nurseicon.svg" - : "assets/images/doctoricon.svg", height:SizeConfig.getHeightMultiplier()*2.5 ,), - const SizedBox(width: 4,), - AppText( - isNurseVisit ? " Please Visit Nurse" : " Please Visit Doctor", - color: AppGlobal.appGreyColor, - fontSize: SizeConfig.getWidthMultiplier() * (isFirstLine - ? 3.3 - : isSecondLine - ? 3.3 - : 3.3), - letterSpacing: -1.6, - fontFamily: 'Poppins-Medium.ttf', - ), - ], - ) - ], - ); - } -} diff --git a/lib/home/que_item/que_item_widget.dart b/lib/home/que_item/que_item_widget.dart deleted file mode 100644 index f327236..0000000 --- a/lib/home/que_item/que_item_widget.dart +++ /dev/null @@ -1,67 +0,0 @@ -import 'package:flutter/cupertino.dart'; -import 'package:flutter_svg/flutter_svg.dart'; -import 'package:queuing_system/core/config/config.dart'; -import 'package:queuing_system/core/config/size_config.dart'; -import 'package:queuing_system/widget/data_display/app_texts_widget.dart'; - -///TODO Roaa we have dublicated code between this and the que item widget we need to make it customize - -class QueItemWidget extends StatelessWidget { - const QueItemWidget({ - Key key, - this.isFirstLine = false, - this.isSecondLine = false, - this.queNo, - this.isNurseVisit = false, - }) : super(key: key); - final bool isFirstLine; - final bool isSecondLine; - final bool isNurseVisit; - final String queNo; - - @override - Widget build(BuildContext context) { - return Column( - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - AppText( - queNo, - fontSize: SizeConfig.getWidthMultiplier() * - (isFirstLine - ? 14 - : isSecondLine - ? 8.5 - : 5.5), - letterSpacing: -13.72, - fontWeight: FontWeight.bold, - // fontFamily: 'Poppins-Bold.ttf', - ), - Row( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: MainAxisAlignment.center, - children: [ - SvgPicture.asset( - isNurseVisit - ? "assets/images/nurseicon.svg" - : "assets/images/doctoricon.svg", height:SizeConfig.getHeightMultiplier()*2.5 ,), - const SizedBox(width: 25,), - AppText( - isNurseVisit ? "Please Visit Nurse" : "Please Visit Doctor", - color: isNurseVisit - ? AppGlobal.appGreenColor - : AppGlobal.appRedColor, - fontSize: SizeConfig.getWidthMultiplier() * (isFirstLine - ? 3.3 - : isSecondLine - ? 3.3 - : 3.3), - letterSpacing: -3.25, - fontWeight: FontWeight.w600, - fontFamily: 'Poppins-Medium.ttf', - ), - ], - ), - ], - ); - } -} diff --git a/lib/home/que_item_list.dart b/lib/home/que_item_list.dart index 5b8d098..07699a1 100644 --- a/lib/home/que_item_list.dart +++ b/lib/home/que_item_list.dart @@ -1,27 +1,27 @@ -import 'package:flutter/material.dart'; -import 'package:queuing_system/core/config/size_config.dart'; -import 'package:queuing_system/home/que_item/que_item.dart'; - -class QueItemList extends StatelessWidget { - const QueItemList({Key key}) : super(key: key); - - @override - Widget build(BuildContext context) { - return SizedBox( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SizedBox(height: SizeConfig.getHeightMultiplier() *2.3,), - const TicketItem(queNo: "OBG-T45", isInListLine: true, isNurseVisit: true, haveListOfPatient: false,), - const TicketItem(queNo: "OBG-T45", isInListLine: true, isNurseVisit: true, haveListOfPatient: false,), - const TicketItem(queNo: "OBG-T45", isInListLine: true, isNurseVisit: false, haveListOfPatient: false,), - const TicketItem(queNo: "OBG-T45", isInListLine: true, isNurseVisit: true, haveListOfPatient: false,), - const TicketItem(queNo: "OBG-T45", isInListLine: true, isNurseVisit: true, haveListOfPatient: false,), - const TicketItem(queNo: "OBG-T45", isInListLine: true, isNurseVisit: false, haveListOfPatient: false,), - const TicketItem(queNo: "OBG-T45", isInListLine: true, isNurseVisit: true, haveListOfPatient: false,), - const TicketItem(queNo: "OBG-T45", isInListLine: true, isNurseVisit: false, haveListOfPatient: false,), - - ],), - ); - } -} +// import 'package:flutter/material.dart'; +// import 'package:queuing_system/core/config/size_config.dart'; +// import 'package:queuing_system/home/que_item/que_item.dart'; +// +// class QueItemList extends StatelessWidget { +// const QueItemList({Key key}) : super(key: key); +// +// @override +// Widget build(BuildContext context) { +// return SizedBox( +// child: Column( +// crossAxisAlignment: CrossAxisAlignment.start, +// children: [ +// SizedBox(height: SizeConfig.getHeightMultiplier() *2.3,), +// const TicketItem(queNo: "OBG-T45", isInListLine: true, isNurseVisit: true, haveListOfPatient: false,), +// const TicketItem(queNo: "OBG-T45", isInListLine: true, isNurseVisit: true, haveListOfPatient: false,), +// const TicketItem(queNo: "OBG-T45", isInListLine: true, isNurseVisit: false, haveListOfPatient: false,), +// const TicketItem(queNo: "OBG-T45", isInListLine: true, isNurseVisit: true, haveListOfPatient: false,), +// const TicketItem(queNo: "OBG-T45", isInListLine: true, isNurseVisit: true, haveListOfPatient: false,), +// const TicketItem(queNo: "OBG-T45", isInListLine: true, isNurseVisit: false, haveListOfPatient: false,), +// const TicketItem(queNo: "OBG-T45", isInListLine: true, isNurseVisit: true, haveListOfPatient: false,), +// const TicketItem(queNo: "OBG-T45", isInListLine: true, isNurseVisit: false, haveListOfPatient: false,), +// +// ],), +// ); +// } +// } diff --git a/lib/main.dart b/lib/main.dart index ab47d96..5caee61 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -44,13 +44,11 @@ class MyApp extends StatelessWidget { showSemanticsDebugger: false, title: 'Doctors App', theme: ThemeData( - primarySwatch: Colors.grey, primaryColor: Colors.grey, fontFamily: 'Poppins', - dividerColor: Colors.grey[350], - backgroundColor: const Color.fromRGBO(255, 255, 255, 1), + dividerColor: Colors.grey[350], colorScheme: ColorScheme.fromSwatch(primarySwatch: Colors.grey).copyWith(background: const Color.fromRGBO(255, 255, 255, 1)), ), - home:MyHomePage() , + home:const MyHomePage() , debugShowCheckedModeBanner: false, )), ); diff --git a/lib/utils/call_type.dart b/lib/utils/call_type.dart index e476ce4..0df1173 100644 --- a/lib/utils/call_type.dart +++ b/lib/utils/call_type.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:queuing_system/core/config/config.dart'; +import 'package:queuing_system/core/response_model/call_config.dart'; enum CallType { vitalSign, doctor, procedure, vaccination, nebulization, none } @@ -21,20 +22,25 @@ extension XCallType on CallType { } } - String message(String lang) { - if (this == CallType.vitalSign) { - return "Please visit VitalSign"; - } else if (this == CallType.doctor) { - return "Please visit Doctor"; - } else if (this == CallType.procedure) { - return "Please visit Procedure"; - } else if (this == CallType.vaccination) { - return "Please visit Vaccination"; - } - if (this == CallType.nebulization) { - return "Please visit Nebulization"; + String message(CallConfig callConfig) { + int language = callConfig.screenLanguage; + switch (this) { + case CallType.vitalSign: + return language == 1 ? callConfig.vitalSignText : callConfig.vitalSignTextN; + case CallType.doctor: + return language == 1 ? callConfig.doctorText : callConfig.doctorTextN; + case CallType.procedure: + return language == 1 ? callConfig.procedureText : callConfig.procedureTextN; + case CallType.vaccination: + return language == 1 ? callConfig.vaccinationText : callConfig.vaccinationTextN; + case CallType.nebulization: + return language == 1 ? callConfig.nebulizationText : callConfig.nebulizationTextN; + case CallType.none: + return language == 1 ? callConfig.vitalSignText : callConfig.vitalSignTextN; + + default: + return language == 1 ? callConfig.vitalSignText : callConfig.vitalSignTextN; } - return "Please wait . . ."; } SvgPicture icon( diff --git a/lib/widget/app_loader_widget.dart b/lib/widget/app_loader_widget.dart index 6f6e27d..61e3125 100644 --- a/lib/widget/app_loader_widget.dart +++ b/lib/widget/app_loader_widget.dart @@ -1,6 +1,5 @@ import 'package:flutter/material.dart'; - -import 'loader/gif_loader_container.dart'; +import 'package:queuing_system/widget/loader/gif_loader_container.dart'; class AppLoaderWidget extends StatefulWidget { AppLoaderWidget({Key key, this.title, this.containerColor}) : super(key: key); @@ -9,13 +8,13 @@ class AppLoaderWidget extends StatefulWidget { final Color containerColor; @override - _AppLoaderWidgetState createState() => new _AppLoaderWidgetState(); + _AppLoaderWidgetState createState() => _AppLoaderWidgetState(); } class _AppLoaderWidgetState extends State { @override Widget build(BuildContext context) { - return Container( + return SizedBox( height: MediaQuery.of(context).size.height, child: Stack( children: [ diff --git a/lib/widget/loader/gif_loader_container.dart b/lib/widget/loader/gif_loader_container.dart index eb9f251..e30b342 100644 --- a/lib/widget/loader/gif_loader_container.dart +++ b/lib/widget/loader/gif_loader_container.dart @@ -30,14 +30,14 @@ class _GifLoaderContainerState extends State @override Widget build(BuildContext context) { return Center( - //progress-loading.gif + //progress-loading.gif child: Container( - // margin: EdgeInsets.only(bottom: 40), - child: GifImage( - controller: controller1, - image: AssetImage( - "assets/images/progress-loading-red.gif"), //NetworkImage("http://img.mp.itc.cn/upload/20161107/5cad975eee9e4b45ae9d3c1238ccf91e.jpg"), - ), - )); + // margin: EdgeInsets.only(bottom: 40), + child: GifImage( + controller: controller1, + image: AssetImage( + "assets/images/progress-loading-red.gif"), //NetworkImage("http://img.mp.itc.cn/upload/20161107/5cad975eee9e4b45ae9d3c1238ccf91e.jpg"), + ), + )); } } diff --git a/lib/widget/loader/gif_loader_dialog_utils.dart b/lib/widget/loader/gif_loader_dialog_utils.dart index 1308a67..95be0df 100644 --- a/lib/widget/loader/gif_loader_dialog_utils.dart +++ b/lib/widget/loader/gif_loader_dialog_utils.dart @@ -1,7 +1,5 @@ import 'package:flutter/material.dart'; - import 'gif_loader_container.dart'; - class GifLoaderDialogUtils { static showMyDialog(BuildContext context) { showDialog(context: context, builder: (ctx) => GifLoaderContainer());