diff --git a/assets/images/new-design/pay_online_button_arabic_disabled.png b/assets/images/new-design/pay_online_button_arabic_disabled.png new file mode 100644 index 00000000..0cb6dbf7 Binary files /dev/null and b/assets/images/new-design/pay_online_button_arabic_disabled.png differ diff --git a/assets/images/new-design/pay_online_button_disabled.png b/assets/images/new-design/pay_online_button_disabled.png new file mode 100644 index 00000000..b4d0c5a9 Binary files /dev/null and b/assets/images/new-design/pay_online_button_disabled.png differ diff --git a/lib/config/config.dart b/lib/config/config.dart index a68b6f6a..eeb9e6d3 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -31,6 +31,9 @@ const GET_PATIENT_SHARE = "Services/Doctors.svc/REST/GetCheckinScreenAppointment //URL to get patient appointment history const GET_PATIENT_APPOINTMENT_HISTORY = "Services/Doctors.svc/REST/PateintHasAppoimentHistory"; +//URL to confirm appointment +const CONFIRM_APPOINTMENT = "Services/MobileNotifications.svc/REST/ConfirmAppointment"; + const GET_PHARMCY_ITEMS = "/Lists.svc/REST/GetPharmcyItems_Region"; const GET_PHARMACY_LIST = "/Patients.svc/REST/GetPharmcyList"; diff --git a/lib/config/localized_values.dart b/lib/config/localized_values.dart index 594c8cdb..b513cc35 100644 --- a/lib/config/localized_values.dart +++ b/lib/config/localized_values.dart @@ -11,6 +11,7 @@ const Map> localizedValues = { 'services': {'en': 'SERVICES', 'ar': 'الخدمات'}, 'mySchedule': {'en': 'My Schedule', 'ar': 'جدولي'}, 'logout': {'en': 'Logout', 'ar': 'تسجيل خروج'}, + 'bookAppo': {'en': 'Book Appointment', 'ar': 'حجز موعد'}, 'searchBy': {'en': 'Search By:', 'ar': 'البحث عن طريق:'}, 'clinic': {'en': 'Clinic', 'ar': 'العيادة'}, @@ -43,7 +44,20 @@ const Map> localizedValues = { 'appoActions': {'en': 'Appointment Actions', 'ar': 'إجراءات الموعد'}, 'date': {'en': 'Date', 'ar': 'التاريخ'}, 'time': {'en': 'Time', 'ar': 'الوقت'}, + 'pendingPayment': {'en': 'Pending for payment', 'ar': 'في انتظار الدفع'}, + 'payNow': {'en': 'Pay Now', 'ar': 'ادفع الآن'}, + 'viewQR': {'en': 'View QR Code', 'ar': 'عرض رمز الاستجابة السريعة'}, + 'instruction': {'en': 'Instructions', 'ar': 'تعليمات'}, + 'livecare': {'en': 'LiveCare', 'ar': 'لايف كير'}, + 'upcoming-noAction': {'en': 'No Action Required', 'ar': 'لا يوجد إجراء مطلوب'}, + 'upcoming-confirm': {'en': 'Please confirm the appointment to avoid cancellation', 'ar': 'يرجى تأكيد الموعد لتفادي الإلغاء'}, + 'upcoming-payment-pending': {'en': 'Online Payment will be Activated before 24 Hours of Appointment Time', 'ar': 'سيتم تفعيل خدمة الدفع الالكتروني قبل 24 ساعة من موعد الحجز'}, + 'upcoming-payment-now': {'en': 'Pay Online now to avoid long waiting queue', 'ar': 'ادفع الآن لتفادي الانتظار'}, + 'upcoming-QR': {'en': 'Use the QR Code to Check-In in hospital', 'ar': 'استخدم الرمز لتسجيل الحضور في المستشفى'}, + 'upcoming-virtual': {'en': 'This is a virtual appointment, Please adhere to the instructions for a seamless experience.', 'ar': 'هذا موعد اتصال مرئي عن بعد ، يرجى اتباع تعليمات الخدمة.'}, + 'upcoming-livecare': {'en': 'This is a LiveCare appointment', 'ar': 'هذا موعد لايف كير'}, + 'upcoming-details': {'en': 'More Details', 'ar': 'المزيد'}, 'login': {'en': 'Login', 'ar': 'تسجيل الدخول'}, 'loginregister': {'en': 'Login / Register', 'ar': 'دخولتسجيل'}, diff --git a/lib/models/Appointments/AppoimentAllHistoryResultList.dart b/lib/models/Appointments/AppoimentAllHistoryResultList.dart index b4f62d1d..4fa19576 100644 --- a/lib/models/Appointments/AppoimentAllHistoryResultList.dart +++ b/lib/models/Appointments/AppoimentAllHistoryResultList.dart @@ -3,7 +3,7 @@ class AppoitmentAllHistoryResultList { int projectID; int appointmentNo; String appointmentDate; - Null appointmentDateN; + dynamic appointmentDateN; int appointmentType; String bookDate; int patientType; @@ -20,18 +20,18 @@ class AppoitmentAllHistoryResultList { int companyID; int bookedBy; String bookedOn; - Null confirmedBy; - Null confirmedOn; - Null arrivalChangedBy; - Null arrivedOn; - Null editedBy; - Null editedOn; - Null doctorName; - Null doctorNameN; + dynamic confirmedBy; + dynamic confirmedOn; + dynamic arrivalChangedBy; + dynamic arrivedOn; + dynamic editedBy; + dynamic editedOn; + dynamic doctorName; + dynamic doctorNameN; String statusDesc; - Null statusDescN; + dynamic statusDescN; bool vitalStatus; - Null vitalSignAppointmentNo; + dynamic vitalSignAppointmentNo; int episodeID; int actualDoctorRate; String clinicName; @@ -53,8 +53,8 @@ class AppoitmentAllHistoryResultList { bool isMedicalReportRequested; bool isOnlineCheckedIN; String latitude; - Null listHISGetContactLensPerscription; - Null listHISGetGlassPerscription; + dynamic listHISGetContactLensPerscription; + dynamic listHISGetGlassPerscription; String longitude; int nextAction; int noOfPatientsRate; diff --git a/lib/models/Appointments/DoctorListResponse.dart b/lib/models/Appointments/DoctorListResponse.dart index 0d7f7bb5..301ad79a 100644 --- a/lib/models/Appointments/DoctorListResponse.dart +++ b/lib/models/Appointments/DoctorListResponse.dart @@ -28,7 +28,7 @@ class DoctorList { String nationalityName; Null nearestFreeSlot; int noOfPatientsRate; - Null originalClinicID; + int originalClinicID; int personRate; int projectDistanceInKiloMeters; String qR; diff --git a/lib/pages/MyAppointments/AppointmentDetails.dart b/lib/pages/MyAppointments/AppointmentDetails.dart index ffb5f6be..4ba8738b 100644 --- a/lib/pages/MyAppointments/AppointmentDetails.dart +++ b/lib/pages/MyAppointments/AppointmentDetails.dart @@ -1,17 +1,26 @@ +import 'package:diplomaticquarterapp/models/Appointments/AppoimentAllHistoryResultList.dart'; +import 'package:diplomaticquarterapp/models/Appointments/DoctorListResponse.dart'; +import 'package:diplomaticquarterapp/pages/BookAppointment/BookConfirm.dart'; import 'package:diplomaticquarterapp/pages/BookAppointment/components/DocAvailableAppointments.dart'; -import 'package:flutter/material.dart'; +import 'package:diplomaticquarterapp/uitl/app_toast.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; +import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; +import 'package:flutter/material.dart'; import 'package:rating_bar/rating_bar.dart'; -import 'Components/AppointmentActions.dart'; +import 'Components/AppointmentActions.dart'; class AppointmentDetails extends StatefulWidget { + AppoitmentAllHistoryResultList appo; + + AppointmentDetails({@required this.appo}); + @override _AppointmentDetailsState createState() => _AppointmentDetailsState(); } -class _AppointmentDetailsState extends State with SingleTickerProviderStateMixin { - +class _AppointmentDetailsState extends State + with SingleTickerProviderStateMixin { TabController _tabController; bool showFooterButton = false; @@ -23,10 +32,32 @@ class _AppointmentDetailsState extends State with SingleTick @override Widget build(BuildContext context) { - return Scaffold( - appBar: AppBar( - title: Text("Eyad Ismail Abu-Jayab"), - ), + return AppScaffold( + appBarTitle: widget.appo.doctorNameObj, + isShowAppBar: true, + bottomSheet: showFooterButton + ? Container( + width: MediaQuery.of(context).size.width, + height: 50.0, + margin: EdgeInsets.fromLTRB(20.0, 10.0, 20.0, 10.0), + child: ButtonTheme( + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(10.0), + ), + minWidth: MediaQuery.of(context).size.width * 0.7, + height: 45.0, + child: RaisedButton( + color: new Color(0xFF60686b), + textColor: Colors.white, + disabledTextColor: Colors.white, + disabledColor: new Color(0xFFbcc2c4), + onPressed: goToBookConfirm, + child: Text(TranslationBase.of(context).bookNow, + style: TextStyle(fontSize: 18.0)), + ), + ), + ) + : null, body: Container( color: new Color(0xFFf6f6f6), child: SingleChildScrollView( @@ -43,17 +74,17 @@ class _AppointmentDetailsState extends State with SingleTick alignment: Alignment.center, child: ClipRRect( borderRadius: BorderRadius.circular(100.0), - child: Image.network( - "https://hmgwebservices.com/Images/MobileImages/OALAY/2477.png", - fit: BoxFit.fill, - height: 120.0, - width: 120.0), + child: Image.network(widget.appo.doctorImageURL, + fit: BoxFit.fill, height: 120.0, width: 120.0), ), ), Container( margin: EdgeInsets.only(top: 10.0), alignment: Alignment.center, - child: Text("Dr. EYAD ISMAIL ABU-JAYAD", + child: Text( + widget.appo.doctorTitle + + " " + + widget.appo.doctorNameObj, style: TextStyle( fontSize: 20.0, color: Colors.grey[900], @@ -62,7 +93,7 @@ class _AppointmentDetailsState extends State with SingleTick Container( margin: EdgeInsets.only(top: 10.0), alignment: Alignment.center, - child: Text("INTERNAL MEDICINE CLINIC", + child: Text(widget.appo.clinicName, style: TextStyle( fontSize: 12.0, color: Colors.grey[900], @@ -72,7 +103,7 @@ class _AppointmentDetailsState extends State with SingleTick margin: EdgeInsets.only(top: 5.0), alignment: Alignment.center, child: RatingBar.readOnly( - initialRating: 4.0, + initialRating: widget.appo.actualDoctorRate.toDouble(), size: 35.0, filledColor: Colors.yellow[700], emptyColor: Colors.grey[500], @@ -85,7 +116,10 @@ class _AppointmentDetailsState extends State with SingleTick Container( margin: EdgeInsets.only(top: 5.0), alignment: Alignment.center, - child: Text("(2322 Reviews)", + child: Text( + "(" + + widget.appo.noOfPatientsRate.toString() + + " Reviews)", style: TextStyle( fontSize: 14.0, color: Colors.blue[800], @@ -126,7 +160,10 @@ class _AppointmentDetailsState extends State with SingleTick height: MediaQuery.of(context).size.height * 0.8, child: TabBarView( physics: NeverScrollableScrollPhysics(), - children: [AppointmentActions(), DocAvailableAppointments()], + children: [ + AppointmentActions(), + DocAvailableAppointments(doctor: getDoctorObject()) + ], controller: _tabController, ), ), @@ -136,4 +173,36 @@ class _AppointmentDetailsState extends State with SingleTick ), ); } + + void goToBookConfirm() { + if (DocAvailableAppointments.areSlotsAvailable) + navigateToBookConfirm(context); + else + AppToast.showErrorToast(message: "Please select Time Slot to continue"); + } + + Future navigateToBookConfirm(context) async { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => BookConfirm( + doctor: getDoctorObject(), + selectedDate: DocAvailableAppointments.selectedDate, + selectedTime: DocAvailableAppointments.selectedTime))); + } + + DoctorList getDoctorObject() { + DoctorList docObj = new DoctorList(); + docObj.doctorID = widget.appo.doctorID; + docObj.clinicID = widget.appo.clinicID; + docObj.projectID = widget.appo.projectID; + docObj.doctorTitle = widget.appo.doctorTitle; + docObj.name = widget.appo.doctorNameObj; + docObj.clinicName = widget.appo.clinicName; + docObj.speciality = widget.appo.doctorSpeciality; + docObj.actualDoctorRate = widget.appo.actualDoctorRate; + docObj.projectName = widget.appo.projectName; + docObj.originalClinicID = widget.appo.originalClinicID; + return docObj; + } } diff --git a/lib/pages/MyAppointments/Components/AppointmentActions.dart b/lib/pages/MyAppointments/Components/AppointmentActions.dart index 16f50800..6391096c 100644 --- a/lib/pages/MyAppointments/Components/AppointmentActions.dart +++ b/lib/pages/MyAppointments/Components/AppointmentActions.dart @@ -4,7 +4,6 @@ import 'package:diplomaticquarterapp/models/Appointments/appoDetailsButtons.dart import 'package:diplomaticquarterapp/pages/MyAppointments/models/AppointmentModel.dart'; import 'package:diplomaticquarterapp/pages/MyAppointments/models/AppointmentType.dart'; import 'package:diplomaticquarterapp/pages/MyAppointments/models/BookedButtons.dart'; -import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:flutter/material.dart'; class AppointmentActions extends StatefulWidget { @@ -178,8 +177,8 @@ class _AppointmentActionsState extends State { } Future> _getBookedCheckInAppoActionsList() async { -// BookedButtons.getContext(context); print("_getBookedCheckInAppoActionsList"); + print(BookedButtons.buttons); List buttonsList = []; for (var i = 0; i < BookedButtons.buttons.length; i++) { buttonsList.add(AppoDetailsButton( diff --git a/lib/pages/MyAppointments/models/BookedButtons.dart b/lib/pages/MyAppointments/models/BookedButtons.dart index f10d0a09..56102f37 100644 --- a/lib/pages/MyAppointments/models/BookedButtons.dart +++ b/lib/pages/MyAppointments/models/BookedButtons.dart @@ -1,12 +1,12 @@ +import 'package:diplomaticquarterapp/config/config.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; class BookedButtons { - static var context; static var buttons = [ { - "title": TranslationBase.of(context).confirm, - "subtitle": TranslationBase.of(context).appointment, + "title": TranslationBase.of(AppGlobal.context).confirm, + "subtitle": TranslationBase.of(AppGlobal.context).appointment, "icon": "assets/images/new-design/confirm_icon.png", "caller": "confirmAppointment" }, @@ -53,8 +53,4 @@ class BookedButtons { "caller": "goToTodoList(31)" } ]; - - static setContext(context) { - BookedButtons.context = context; - } } diff --git a/lib/pages/ToDoList/ToDo.dart b/lib/pages/ToDoList/ToDo.dart index 4982035f..ddac2a55 100644 --- a/lib/pages/ToDoList/ToDo.dart +++ b/lib/pages/ToDoList/ToDo.dart @@ -1,22 +1,33 @@ +import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; import 'package:diplomaticquarterapp/models/Appointments/AppoimentAllHistoryResultList.dart'; -import 'package:diplomaticquarterapp/pages/ToDoList/widgets/upcomingCard.dart'; +import 'package:diplomaticquarterapp/pages/MyAppointments/AppointmentDetails.dart'; import 'package:diplomaticquarterapp/services/appointment_services/GetDoctorsList.dart'; +import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart'; import 'package:diplomaticquarterapp/uitl/app_toast.dart'; +import 'package:diplomaticquarterapp/uitl/date_uitl.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; +import 'package:diplomaticquarterapp/widgets/progress_indicator/app_circular_progress_Indeicator.dart'; import 'package:flutter/material.dart'; +import 'package:rating_bar/rating_bar.dart'; class ToDo extends StatefulWidget { DoctorsListService service; List appoList = []; + var languageID; @override _ToDoState createState() => _ToDoState(); } class _ToDoState extends State { + AppSharedPreferences sharedPref = AppSharedPreferences(); + + bool isLoading = false; + @override void initState() { + print("initState"); widget.service = new DoctorsListService(); getPatientAppointmentHistory(); super.initState(); @@ -26,29 +37,383 @@ class _ToDoState extends State { Widget build(BuildContext context) { return AppScaffold( appBarTitle: TranslationBase.of(context).todoList, - body: SingleChildScrollView( - child: Container( - child: ListView.builder( - scrollDirection: Axis.vertical, - shrinkWrap: true, - physics: ScrollPhysics(), - padding: EdgeInsets.all(0.0), - itemCount: widget.appoList.length, - itemBuilder: (context, index) { - return TodoListCard( - appo: widget.appoList[index], - ); - }, - ), - ), - ), + body: isLoading == false + ? SingleChildScrollView( + child: Container( + child: ListView.builder( + scrollDirection: Axis.vertical, + shrinkWrap: true, + physics: ScrollPhysics(), + padding: EdgeInsets.all(0.0), + itemCount: widget.appoList.length, + itemBuilder: (context, index) { + return Container( + margin: EdgeInsets.all(10.0), + child: Card( + margin: EdgeInsets.fromLTRB(8.0, 0.0, 8.0, 8.0), + color: Colors.white, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(10), + ), + child: Container( + width: MediaQuery.of(context).size.width, + padding: EdgeInsets.all(10.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.max, + children: [ + Row( + children: [ + Image.asset( + "assets/images/new-design/time_icon.png", + width: 20.0, + height: 20.0), + Container( + margin: EdgeInsets.only( + left: 10.0, right: 30.0), + child: Text( + getDate(widget + .appoList[index].appointmentDate), + style: TextStyle(fontSize: 12.0)), + ), + Image.asset( + "assets/images/new-design/hospital_address_icon.png", + width: 20.0, + height: 20.0), + Container( + margin: EdgeInsets.only( + left: 10.0, right: 10.0), + child: Text( + widget.appoList[index].projectName, + style: TextStyle(fontSize: 12.0)), + ), + ], + ), + Container( + margin: EdgeInsets.only(top: 5.0), + child: Divider( + color: Colors.grey[500], + ), + ), + Flex( + direction: Axis.horizontal, + children: [ + Expanded( + flex: 1, + child: Container( + height: + MediaQuery.of(context).size.height * + 0.1, + margin: EdgeInsets.only(top: 5.0), + child: ClipRRect( + borderRadius: + BorderRadius.circular(100.0), + child: Image.network( + widget + .appoList[index].doctorImageURL, + fit: BoxFit.fill), + ), + ), + ), + Expanded( + flex: 3, + child: Container( + margin: EdgeInsets.only( + top: 20.0, left: 20.0, right: 20.0), + child: Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Text( + widget.appoList[index] + .doctorTitle + + " " + + widget.appoList[index] + .doctorNameObj, + style: TextStyle( + fontSize: 14.0, + color: Colors.black, + fontWeight: FontWeight.bold, + letterSpacing: 1.0)), + Container( + margin: EdgeInsets.only( + top: 3.0, bottom: 3.0), + child: Text( + getDoctorSpeciality(widget + .appoList[index] + .doctorSpeciality) + .trim(), + style: TextStyle( + fontSize: 12.0, + color: Colors.grey[600], + letterSpacing: 1.0)), + ), + Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + mainAxisSize: MainAxisSize.max, + children: [ + RatingBar.readOnly( + initialRating: widget.appoList[index].actualDoctorRate.toDouble(), + size: 20.0, + filledColor: Colors.yellow[700], + emptyColor: Colors.grey[500], + isHalfAllowed: true, + halfFilledIcon: Icons.star_half, + filledIcon: Icons.star, + emptyIcon: Icons.star, + ), + ], + ), + ], + ), + ), + ), + Expanded( + flex: 1, + child: InkWell( + onTap: () => performNextAction( + widget.appoList[index]), + child: Container( + margin: EdgeInsets.only(top: 20.0), + child: Column( + children: [ + Image.asset( + getNextActionImage(widget + .appoList[index] + .nextAction), + width: 50.0, + height: 50.0), + Container( + margin: EdgeInsets.only(top: 5.0), + child: Text( + getNextActionText(widget + .appoList[index] + .nextAction), + textAlign: TextAlign.center, + style: TextStyle( + fontSize: 12.0)), + ) + ], + ), + ), + ), + ) + ], + ), + Divider( + color: Colors.grey[500], + ), + Flex( + direction: Axis.horizontal, + children: [ + Expanded( + flex: 2, + child: Container( + child: Text( + getNextActionDescription(widget + .appoList[index].nextAction), + style: TextStyle( + fontSize: 12.0, + color: Colors.grey[700])), + ), + ), + Expanded( + flex: 1, + child: GestureDetector( + onTap: () { + navigateToAppointmentDetails( + context, widget.appoList[index]); + }, + child: Container( + child: Text( + TranslationBase.of(context) + .upcomingDetails, + textAlign: TextAlign.end, + style: TextStyle( + fontSize: 12.0, + color: Colors.red[600], + decoration: + TextDecoration.underline)), + ), + ), + ) + ], + ) + ], + ), + ), + ), + ); + }, + ), + ), + ) + : AppCircularProgressIndicator(), ); } + String getNextActionImage(nextAction) { + switch (nextAction) { + case 0: + return "No Action"; + break; + case 10: + return "assets/images/new-design/confirm_button.png"; + break; + + case 15: + return widget.languageID == 'ar' + ? "assets/images/new-design/pay_online_button_arabic_disabled.png" + : "assets/images/new-design/pay_online_button_disabled.png"; + break; + + case 20: + return widget.languageID == 'ar' + ? "assets/images/new-design/pay_online_button_arabic.png" + : "assets/images/new-design/pay_online_button.png"; + break; + + case 30: + return "assets/images/new-design/qr_code_button.png"; + break; + + case 40: + return "assets/images/new-design/video_call_instruction.png"; + break; + + case 50: + return "assets/images/new-design/liveCare_logo_icon.png"; + break; + + default: + return ""; + } + } + + performNextAction(AppoitmentAllHistoryResultList appo) { + switch (appo.nextAction) { + case 10: + confirmAppointment(appo); + break; + } + } + + String getNextActionText(nextAction) { + switch (nextAction) { + case 0: + return "No Action"; + break; + case 10: + return TranslationBase.of(context).confirm; + break; + + case 15: + return TranslationBase.of(context).pendingPayment; + break; + + case 20: + return TranslationBase.of(context).payNow; + break; + + case 30: + return TranslationBase.of(context).viewQR; + break; + + case 40: + return TranslationBase.of(context).instruction; + break; + + case 50: + return TranslationBase.of(context).livecare; + break; + + default: + return ""; + } + } + + String getNextActionDescription(nextAction) { + switch (nextAction) { + case 0: + return "No Action"; + break; + case 10: + return TranslationBase.of(context).upcomingConfirm; + break; + + case 15: + return TranslationBase.of(context).upcomingPaymentPending; + break; + + case 20: + return TranslationBase.of(context).upcomingPaymentNow; + break; + + case 30: + return TranslationBase.of(context).upcomingQR; + break; + + case 40: + return TranslationBase.of(context).upcomingVirtual; + break; + + case 50: + return TranslationBase.of(context).upcomingLivecare; + break; + + default: + return ""; + } + } + + getLanguageID() async { + var languageID = await sharedPref.getString(APP_LANGUAGE); + setState(() { + widget.languageID = languageID; + }); + } + + String getDate(String date) { + DateTime dateObj = DateUtil.convertStringToDate(date); + return DateUtil.getWeekDay(dateObj.weekday) + + ", " + + dateObj.day.toString() + + " " + + DateUtil.getMonth(dateObj.month) + + " " + + dateObj.year.toString() + + " " + + dateObj.hour.toString() + + ":" + + getMinute(dateObj); + } + + String getMinute(DateTime dateObj) { + if (dateObj.minute == 0) { + return dateObj.minute.toString() + "0"; + } else { + return dateObj.minute.toString(); + } + } + + String getDoctorSpeciality(List docSpecial) { + String docSpeciality = ""; + docSpecial.forEach((v) { + docSpeciality = docSpeciality + v + "\n"; + }); + return docSpeciality; + } + + Future navigateToAppointmentDetails(context, appo) async { + Navigator.push( + context, MaterialPageRoute(builder: (context) => AppointmentDetails(appo: appo))); + } + getPatientAppointmentHistory() { + loading(true); widget.service.getPatientAppointmentHistory(true).then((res) { print(res['AppoimentAllHistoryResultList']); - if (res['MessageStatus'] == 1) { setState(() { if (res['AppoimentAllHistoryResultList'].length != 0) { @@ -59,12 +424,39 @@ class _ToDoState extends State { }); } else {} }); - print(widget.appoList.length); + loading(false); } else { AppToast.showErrorToast(message: res['ErrorEndUserMessage']); + loading(false); } }).catchError((err) { print(err); + loading(false); + }); + } + + confirmAppointment(AppoitmentAllHistoryResultList appo) { + loading(true); + widget.service + .confirmAppointment(appo.appointmentNo, appo.clinicID, appo.projectID) + .then((res) { + if (res['MessageStatus'] == 1) { + AppToast.showSuccessToast(message: res['ErrorEndUserMessage']); + loading(false); + getPatientAppointmentHistory(); + } else { + AppToast.showErrorToast(message: res['ErrorEndUserMessage']); + loading(false); + } + }).catchError((err) { + print(err); + loading(false); + }); + } + + loading(bool flag) { + setState(() { + isLoading = flag; }); } } diff --git a/lib/pages/ToDoList/widgets/upcomingCard.dart b/lib/pages/ToDoList/widgets/upcomingCard.dart index 324f9c3e..1b4a4cc3 100644 --- a/lib/pages/ToDoList/widgets/upcomingCard.dart +++ b/lib/pages/ToDoList/widgets/upcomingCard.dart @@ -1,22 +1,30 @@ +import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; import 'package:diplomaticquarterapp/models/Appointments/AppoimentAllHistoryResultList.dart'; import 'package:diplomaticquarterapp/pages/MyAppointments/AppointmentDetails.dart'; +import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart'; +import 'package:diplomaticquarterapp/uitl/date_uitl.dart'; +import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:flutter/material.dart'; import 'package:rating_bar/rating_bar.dart'; class TodoListCard extends StatefulWidget { - AppoitmentAllHistoryResultList appo; + var languageID; + final VoidCallback onListUpdated; + - TodoListCard({@required this.appo}); + TodoListCard({@required this.appo, this.onListUpdated}); @override _TodoListCardState createState() => _TodoListCardState(); } class _TodoListCardState extends State { + AppSharedPreferences sharedPref = AppSharedPreferences(); @override void initState() { +// widget.onListUpdated(); super.initState(); } @@ -25,7 +33,7 @@ class _TodoListCardState extends State { return Container( margin: EdgeInsets.all(10.0), child: Card( - margin: EdgeInsets.fromLTRB(8.0, 16.0, 8.0, 8.0), + margin: EdgeInsets.fromLTRB(8.0, 0.0, 8.0, 8.0), color: Colors.white, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(10), @@ -43,7 +51,7 @@ class _TodoListCardState extends State { width: 20.0, height: 20.0), Container( margin: EdgeInsets.only(left: 10.0, right: 30.0), - child: Text("Monday, 31 August 2020 09:30", + child: Text(getDate(widget.appo.appointmentDate), style: TextStyle(fontSize: 12.0)), ), Image.asset( @@ -73,8 +81,7 @@ class _TodoListCardState extends State { margin: EdgeInsets.only(top: 5.0), child: ClipRRect( borderRadius: BorderRadius.circular(100.0), - child: Image.network( - widget.appo.doctorImageURL, + child: Image.network(widget.appo.doctorImageURL, fit: BoxFit.fill), ), ), @@ -87,7 +94,10 @@ class _TodoListCardState extends State { child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text(widget.appo.doctorTitle + " " + widget.appo.doctorNameObj, + Text( + widget.appo.doctorTitle + + " " + + widget.appo.doctorNameObj, style: TextStyle( fontSize: 14.0, color: Colors.black, @@ -95,7 +105,7 @@ class _TodoListCardState extends State { letterSpacing: 1.0)), Container( margin: EdgeInsets.only(top: 3.0, bottom: 3.0), - child: Text("General Practioner", + child: Text(getDoctorSpeciality(widget.appo.doctorSpeciality).trim(), style: TextStyle( fontSize: 12.0, color: Colors.grey[600], @@ -124,17 +134,17 @@ class _TodoListCardState extends State { Expanded( flex: 1, child: Container( -// height: MediaQuery.of(context).size.height * 0.12, margin: EdgeInsets.only(top: 20.0), child: Column( children: [ Image.asset( - "assets/images/new-design/confirm_button.png", + getNextActionImage(widget.appo.nextAction), width: 50.0, height: 50.0), Container( margin: EdgeInsets.only(top: 5.0), - child: Text("Confirm", + child: Text( + getNextActionText(widget.appo.nextAction), textAlign: TextAlign.center, style: TextStyle(fontSize: 12.0)), ) @@ -154,7 +164,7 @@ class _TodoListCardState extends State { flex: 2, child: Container( child: Text( - "Please confirm the appointment to avoid cancellation", + getNextActionDescription(widget.appo.nextAction), style: TextStyle( fontSize: 12.0, color: Colors.grey[700])), ), @@ -166,7 +176,7 @@ class _TodoListCardState extends State { navigateToAppointmentDetails(context); }, child: Container( - child: Text("More Details", + child: Text(TranslationBase.of(context).upcomingDetails, textAlign: TextAlign.end, style: TextStyle( fontSize: 12.0, @@ -184,9 +194,153 @@ class _TodoListCardState extends State { ); } + String getNextActionImage(nextAction) { + switch (nextAction) { + case 0: + return "No Action"; + break; + case 10: + return "assets/images/new-design/confirm_button.png"; + break; + + case 15: + return widget.languageID == 'ar' + ? "assets/images/new-design/pay_online_button_arabic_disabled.png" + : "assets/images/new-design/pay_online_button_disabled.png"; + break; + + case 20: + return widget.languageID == 'ar' + ? "assets/images/new-design/pay_online_button_arabic.png" + : "assets/images/new-design/pay_online_button.png"; + break; + + case 30: + return "assets/images/new-design/qr_code_button.png"; + break; + + case 40: + return "assets/images/new-design/video_call_instruction.png"; + break; + + case 50: + return "assets/images/new-design/liveCare_logo_icon.png"; + break; + + default: + return ""; + } + } + + String getNextActionText(nextAction) { + switch (nextAction) { + case 0: + return "No Action"; + break; + case 10: + return TranslationBase.of(context).confirm; + break; + + case 15: + return TranslationBase.of(context).pendingPayment; + break; + + case 20: + return TranslationBase.of(context).payNow; + break; + + case 30: + return TranslationBase.of(context).viewQR; + break; + + case 40: + return TranslationBase.of(context).instruction; + break; + + case 50: + return TranslationBase.of(context).livecare; + break; + + default: + return ""; + } + } + + String getNextActionDescription(nextAction) { + switch (nextAction) { + case 0: + return "No Action"; + break; + case 10: + return TranslationBase.of(context).upcomingConfirm; + break; + + case 15: + return TranslationBase.of(context).upcomingPaymentPending; + break; + + case 20: + return TranslationBase.of(context).upcomingPaymentNow; + break; + + case 30: + return TranslationBase.of(context).upcomingQR; + break; + + case 40: + return TranslationBase.of(context).upcomingVirtual; + break; + + case 50: + return TranslationBase.of(context).upcomingLivecare; + break; + + default: + return ""; + } + } + + getLanguageID() async { + var languageID = await sharedPref.getString(APP_LANGUAGE); + setState(() { + widget.languageID = languageID; + }); + } + + String getDate(String date) { + DateTime dateObj = DateUtil.convertStringToDate(date); + return DateUtil.getWeekDay(dateObj.weekday) + + ", " + + dateObj.day.toString() + + " " + + DateUtil.getMonth(dateObj.month) + + " " + + dateObj.year.toString() + + " " + + dateObj.hour.toString() + + ":" + + getMinute(dateObj); + } + + String getMinute(DateTime dateObj) { + if(dateObj.minute == 0) { + return dateObj.minute.toString() + "0"; + } else { + return dateObj.minute.toString(); + } + } + + + String getDoctorSpeciality(List docSpecial) { + String docSpeciality = ""; + docSpecial.forEach((v) { + docSpeciality = docSpeciality + v + "\n"; + }); + return docSpeciality; + } + Future navigateToAppointmentDetails(context) async { Navigator.push( context, MaterialPageRoute(builder: (context) => AppointmentDetails())); } - } diff --git a/lib/services/appointment_services/GetDoctorsList.dart b/lib/services/appointment_services/GetDoctorsList.dart index 387d06d5..6511c189 100644 --- a/lib/services/appointment_services/GetDoctorsList.dart +++ b/lib/services/appointment_services/GetDoctorsList.dart @@ -1,7 +1,6 @@ import 'package:diplomaticquarterapp/config/config.dart'; import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; import 'package:diplomaticquarterapp/core/service/base_service.dart'; -import 'package:diplomaticquarterapp/models/Appointments/InsertAppointmentRequest.dart'; import 'package:diplomaticquarterapp/models/Request.dart'; import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart'; @@ -270,4 +269,40 @@ class DoctorsListService extends BaseService { return Future.value(localRes); } + Future confirmAppointment(int appoNo, int clinicID, int projectID) async { + Map request; + var languageID = await sharedPref.getString(APP_LANGUAGE); + Request req = appGlobal.getPublicRequest(); + + request = { + "AppointmentNumber": appoNo, + "ClinicID": clinicID, + "ProjectID": projectID, + "ConfirmationBy": 102, + "VersionID": req.VersionID, + "Channel": req.Channel, + "LanguageID": languageID == 'ar' ? 1 : 2, + "IPAdress": req.IPAdress, + "generalid": req.generalid, + "PatientOutSA": 0, + "SessionID": "YckwoXhUmWBsnHKEKig", + "isDentalAllowedBackend": false, + "DeviceTypeID": 1, + "PatientID": 1231755, + "TokenID": "@dm!n", + "PatientTypeID": 1, + "PatientType": 1 + }; + + dynamic localRes; + + await baseAppClient.post(CONFIRM_APPOINTMENT, + onSuccess: (response, statusCode) async { + localRes = response; + }, onFailure: (String error, int statusCode) { + throw error; + }, body: request); + return Future.value(localRes); + } + } diff --git a/lib/uitl/translations_delegate_base.dart b/lib/uitl/translations_delegate_base.dart index 314dd9ba..ce4f96e5 100644 --- a/lib/uitl/translations_delegate_base.dart +++ b/lib/uitl/translations_delegate_base.dart @@ -155,10 +155,46 @@ class TranslationBase { String get gregorianDate => localizedValues['gregorian-date'][locale.languageCode]; + String get searchMedicine => localizedValues['searchMedicine'][locale.languageCode]; + String get searchMedicineHere => localizedValues['searchMedicineHere'][locale.languageCode]; + + String get pendingPayment => + localizedValues['pendingPayment'][locale.languageCode]; + + String get payNow => localizedValues['payNow'][locale.languageCode]; + + String get viewQR => localizedValues['viewQR'][locale.languageCode]; + + String get instruction => localizedValues['instruction'][locale.languageCode]; + + String get livecare => localizedValues['livecare'][locale.languageCode]; + + String get upcomingNoAction => + localizedValues['upcoming-noAction'][locale.languageCode]; + + String get upcomingConfirm => + localizedValues['upcoming-confirm'][locale.languageCode]; + + String get upcomingPaymentPending => + localizedValues['upcoming-payment-pending'][locale.languageCode]; + + String get upcomingPaymentNow => + localizedValues['upcoming-payment-now'][locale.languageCode]; + + String get upcomingQR => localizedValues['upcoming-QR'][locale.languageCode]; + + String get upcomingVirtual => + localizedValues['upcoming-virtual'][locale.languageCode]; + + String get upcomingLivecare => + localizedValues['upcoming-livecare'][locale.languageCode]; + + String get upcomingDetails => + localizedValues['upcoming-details'][locale.languageCode]; } class TranslationBaseDelegate extends LocalizationsDelegate { diff --git a/lib/widgets/bottom_navigation/bottom_nav_bar.dart b/lib/widgets/bottom_navigation/bottom_nav_bar.dart index 5966ec46..dd186c56 100644 --- a/lib/widgets/bottom_navigation/bottom_nav_bar.dart +++ b/lib/widgets/bottom_navigation/bottom_nav_bar.dart @@ -97,7 +97,7 @@ class _BottomNavBarState extends State { changeIndex: _changeIndex, index: _index, currentIndex: 3, - name: TranslationBase.of(context).services, + name: TranslationBase.of(context).todoList, ) ], ), diff --git a/lib/widgets/mobile-no/mobile_no.dart b/lib/widgets/mobile-no/mobile_no.dart index 2c17a669..d916f570 100644 --- a/lib/widgets/mobile-no/mobile_no.dart +++ b/lib/widgets/mobile-no/mobile_no.dart @@ -1,4 +1,3 @@ -import 'package:diplomaticquarterapp/config/size_config.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart';