From 0d1d68273b593cec0a4b61cdc2bc260bf0216ee0 Mon Sep 17 00:00:00 2001 From: haroon amjad Date: Wed, 25 Aug 2021 16:21:21 +0300 Subject: [PATCH] Covid passport CR implemented in Covid test flow --- .../covid-dirvethru-questions.dart | 163 +++++++++--------- lib/pages/login/login.dart | 8 +- .../medical/labs/passport_update_page.dart | 3 + 3 files changed, 90 insertions(+), 84 deletions(-) diff --git a/lib/pages/Covid-DriveThru/covid-dirvethru-questions.dart b/lib/pages/Covid-DriveThru/covid-dirvethru-questions.dart index b6ccff1d..ed048b9f 100644 --- a/lib/pages/Covid-DriveThru/covid-dirvethru-questions.dart +++ b/lib/pages/Covid-DriveThru/covid-dirvethru-questions.dart @@ -1,8 +1,8 @@ -import 'dart:collection'; import 'dart:convert'; import 'package:diplomaticquarterapp/models/CovidDriveThru/CovidPaymentInfoResponse.dart'; import 'package:diplomaticquarterapp/models/CovidDriveThru/CovidTestProceduresResponse.dart'; +import 'package:diplomaticquarterapp/pages/medical/labs/passport_update_page.dart'; import 'package:diplomaticquarterapp/services/covid-drivethru/covid-drivethru.dart'; import 'package:diplomaticquarterapp/uitl/app_toast.dart'; import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; @@ -11,19 +11,20 @@ import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; import 'covid-payment-details.dart'; -class CovidDirveThruQuestions extends StatefulWidget{ + +class CovidDirveThruQuestions extends StatefulWidget { final String projectId; final List proceduresList; + CovidDirveThruQuestions({@required this.projectId, @required this.proceduresList}); @override - CovidDirveThruQuestionsState createState() => CovidDirveThruQuestionsState(); - + CovidDirveThruQuestionsState createState() => CovidDirveThruQuestionsState(); } -class CovidDirveThruQuestionsState extends State{ + +class CovidDirveThruQuestionsState extends State { List qa; @override @@ -33,10 +34,11 @@ class CovidDirveThruQuestionsState extends State{ } TranslationBase localize; + @override Widget build(BuildContext context) { localize = TranslationBase.of(context); - var isArabic = localize.isArabic(); + var isArabic = localize.isArabic(); return AppScaffold( appBarTitle: TranslationBase.of(context).covidTest, isShowAppBar: true, @@ -49,54 +51,50 @@ class CovidDirveThruQuestionsState extends State{ ), Expanded( child: ListView.separated( - padding: EdgeInsets.symmetric(horizontal: 20), - itemCount: qa.length, - itemBuilder: (ctx, idx){ - var obj = qa[idx]; - var qtext = isArabic ? obj["questionAR"] : obj["questionEN"]; - - return Padding( - padding: const EdgeInsets.symmetric(vertical: 10), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text(qtext, style: TextStyle(fontSize: 15, letterSpacing: 1.5)), - Row( - children: [ - Radio( - value: 1, - groupValue: obj["ans"], - onChanged: (newValue){ - setState(() { - obj["ans"] = newValue; - }); - } - ), - Text(localize.yes), - ], - ), + padding: EdgeInsets.symmetric(horizontal: 20), + itemCount: qa.length, + itemBuilder: (ctx, idx) { + var obj = qa[idx]; + var qtext = isArabic ? obj["questionAR"] : obj["questionEN"]; - Row( - children: [ - Radio( - value: 0, - groupValue: obj["ans"], - onChanged: (newValue){ - setState(() { - obj["ans"] = newValue; - }); - } - ), - Text(localize.no), - ], - ) - ], - ), - ); - }, - separatorBuilder: (ctx, idx) => Divider(height: 0.25, color: Colors.grey.withOpacity(0.5)), - ) - ), + return Padding( + padding: const EdgeInsets.symmetric(vertical: 10), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text(qtext, style: TextStyle(fontSize: 15, letterSpacing: 1.5)), + Row( + children: [ + Radio( + value: 1, + groupValue: obj["ans"], + onChanged: (newValue) { + setState(() { + obj["ans"] = newValue; + }); + }), + Text(localize.yes), + ], + ), + Row( + children: [ + Radio( + value: 0, + groupValue: obj["ans"], + onChanged: (newValue) { + setState(() { + obj["ans"] = newValue; + }); + }), + Text(localize.no), + ], + ) + ], + ), + ); + }, + separatorBuilder: (ctx, idx) => Divider(height: 0.25, color: Colors.grey.withOpacity(0.5)), + )), Padding( padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 10), child: FractionallySizedBox( @@ -105,31 +103,43 @@ class CovidDirveThruQuestionsState extends State{ height: 50, color: Theme.of(context).appBarTheme.color, disabledColor: Theme.of(context).appBarTheme.color.withOpacity(0.25), - shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10) ), - child: Text(localize.next, style: TextStyle(color: Colors.white, fontSize: 13, letterSpacing: 1),), - onPressed: next - ), + shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)), + child: Text( + localize.next, + style: TextStyle(color: Colors.white, fontSize: 13, letterSpacing: 1), + ), + onPressed: next), ), ), ], - ) - ); + )); } - next() async{ + next() async { bool all = true; qa.forEach((element) { all = all && (element["ans"] == 1 || element["ans"] == 0); }); - if(all) - getPaymentInfo(context,widget.projectId); + if (all) if (qa[0]["ans"] == 1) { + openPassportUpdatePage(); + } else { + getPaymentInfo(context, widget.projectId); + } else AppToast.showErrorToast(message: localize.pleaseSelectAllQuestionToContinue); } - List getQuestionsFromJson(){ - var questionsJson = - """ + openPassportUpdatePage() { + Navigator.push(context, FadePage(page: PassportUpdatePage())).then((value) { + print(value); + if(value != null && value == true) { + getPaymentInfo(context, widget.projectId); + } + }); + } + + List getQuestionsFromJson() { + var questionsJson = """ [{"id":1,"questionEN":"Is the test intended for travel?","questionAR":"هل تجري التحليل بغرض السفر؟","ans":2},{"id":2,"questionEN":"Coming from outside KSA within last 2 weeks?","questionAR":"هل قدمت من خارج المملكة خلال الأسبوعين الماضيين؟","ans":2},{"id":3,"questionEN":"Do you currently have fever?","questionAR":"هل تعاني حاليا من حرارة؟","ans":2},{"id":4,"questionEN":"Did you have fever in last 2 weeks?","questionAR":"هل عانيت من حرارة في الأسبوعين الماضيين؟","ans":2},{"id":5,"questionEN":"Do you have a sore throat?","questionAR":"هل لديك التهاب في الحلق؟","ans":2},{"id":6,"questionEN":"Do you have a runny nose?","questionAR":"هل لديك سيلان بالأنف؟"},{"id":7,"questionEN":"Do you have a cough?","questionAR":"هل لديك سعال؟","ans":2},{"id":8,"questionEN":"Do you have shortness of breath?","questionAR":"هل تعانين من ضيق في التنفس؟","ans":2},{"id":9,"questionEN":"Do you have nausea?","questionAR":"هل تعانين من غثيان؟","ans":2},{"id":10,"questionEN":"Do you have vomiting?","questionAR":"هل تعاني من القيء؟","ans":2},{"id":11,"questionEN":"Do you have a headache?","questionAR":"هل تعاني من صداع في الرأس؟","ans":2},{"id":12,"questionEN":"Do you have muscle pain?","questionAR":"هل تعانين من آلام عضلية؟","ans":2},{"id":13,"questionEN":"Do you have joint pain?","questionAR":"هل تعانين من آلام المفاصل؟","ans":2},{"id":14,"questionEN":"Do you have diarrhea?","questionAR":"هل لديك اسهال؟","ans":2}]"""; var map = json.decode(questionsJson) as List; return map; @@ -137,29 +147,22 @@ class CovidDirveThruQuestionsState extends State{ getPaymentInfo(BuildContext context, String projectID) { CovidDriveThruService service = new CovidDriveThruService(); - CovidPaymentInfoResponse covidPaymentInfoResponse = - new CovidPaymentInfoResponse(); + CovidPaymentInfoResponse covidPaymentInfoResponse = new CovidPaymentInfoResponse(); GifLoaderDialogUtils.showMyDialog(context); - service.getCovidPaymentInformation(context, int.parse(projectID), widget.proceduresList[0].procedureID) - .then((res) { + service.getCovidPaymentInformation(context, int.parse(projectID), widget.proceduresList[0].procedureID).then((res) { GifLoaderDialogUtils.hideDialog(context); if (res['MessageStatus'] == 1) { - // setState(() { - // covidPaymentInfoResponse = - // CovidPaymentInfoResponse.fromJson(res['COVID19_PatientShare']); - // }); Navigator.push( context, FadePage( page: CovidPaymentDetails( - covidPaymentInfoResponse: covidPaymentInfoResponse, - projectID: int.parse(projectID), - proceduresList: widget.proceduresList, - ))); + covidPaymentInfoResponse: covidPaymentInfoResponse, + projectID: int.parse(projectID), + proceduresList: widget.proceduresList, + ))); } else {} }).catchError((err) { print(err); }); } - -} \ No newline at end of file +} diff --git a/lib/pages/login/login.dart b/lib/pages/login/login.dart index c8c236db..245167e6 100644 --- a/lib/pages/login/login.dart +++ b/lib/pages/login/login.dart @@ -279,10 +279,10 @@ class _Login extends State { // result['CRSVerificationStatus']; projectViewModel.user = authenticatedUserObject.user; - await pharmacyModuleViewModel.generatePharmacyToken().then((value) async { - if (pharmacyModuleViewModel.error.isNotEmpty) - await pharmacyModuleViewModel.createUser(); - }); + // await pharmacyModuleViewModel.generatePharmacyToken().then((value) async { + // if (pharmacyModuleViewModel.error.isNotEmpty) + // await pharmacyModuleViewModel.createUser(); + // }); appointmentRateViewModel .getIsLastAppointmentRatedList() diff --git a/lib/pages/medical/labs/passport_update_page.dart b/lib/pages/medical/labs/passport_update_page.dart index 0931431c..1e81b2e5 100644 --- a/lib/pages/medical/labs/passport_update_page.dart +++ b/lib/pages/medical/labs/passport_update_page.dart @@ -114,6 +114,9 @@ class _PassportUpdatePageState extends State { GifLoaderDialogUtils.hideDialog(context); print(res['Covid19_Certificate_GetPassportList'][0]['PassportNo']); passportNumber.text = res['Covid19_Certificate_GetPassportList'][0]['PassportNo']; + if(res['Covid19_Certificate_GetPassportList'][0]['PassportNo'] != "") { + _isButtonDisabled = false; + } }).catchError((err) { GifLoaderDialogUtils.hideDialog(context); print(err);