From 8f37fbf2604e4e1c2e1634cfa0cec9fb017a5e58 Mon Sep 17 00:00:00 2001 From: Sikander Saleem Date: Thu, 28 Jan 2021 09:39:33 +0300 Subject: [PATCH] Qr icon added, notify me api added & improvements --- lib/config/config.dart | 101 +-- .../parmacyModule/parmacy_module_service.dart | 32 +- .../product_detail_view_model.dart | 11 + lib/pages/landing/landing_page_pharmcy.dart | 231 +++--- lib/pages/login/login.dart | 113 ++- lib/pages/pharmacies/product_detail.dart | 764 ++++++------------ .../pharmacies/screens/cart-order-page.dart | 2 +- lib/pages/pharmacies/widgets/BannerPager.dart | 35 +- lib/pages/pharmacy_categorise.dart | 82 +- .../product_detail_service.dart | 20 +- 10 files changed, 564 insertions(+), 827 deletions(-) diff --git a/lib/config/config.dart b/lib/config/config.dart index d276d51a..856ae36a 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -36,40 +36,29 @@ const GET_PRIVILEGE = 'Services/Patients.svc/REST/Service_Privilege'; const WIFI_CREDENTIALS = "Services/Patients.svc/Hmg_SMS_Get_By_ProjectID_And_PatientID"; ///Doctor -const GET_MY_DOCTOR = - 'Services/Doctors.svc/REST/GetPatientDoctorAppointmentResult'; +const GET_MY_DOCTOR = 'Services/Doctors.svc/REST/GetPatientDoctorAppointmentResult'; const GET_DOCTOR_PROFILE = 'Services/Doctors.svc/REST/GetDocProfiles'; -const GET_DOCTOR_RATING_NOTES = - 'Services/Doctors.svc/REST/dr_GetNotesDoctorRating'; -const GET_DOCTOR_RATING_DETAILS = - 'Services/Doctors.svc/REST/dr_GetDoctorRatingDetails'; +const GET_DOCTOR_RATING_NOTES = 'Services/Doctors.svc/REST/dr_GetNotesDoctorRating'; +const GET_DOCTOR_RATING_DETAILS = 'Services/Doctors.svc/REST/dr_GetDoctorRatingDetails'; const GET_DOCTOR_RATING = 'Services/Doctors.svc/REST/dr_GetAvgDoctorRating'; ///Prescriptions const PRESCRIPTIONS = 'Services/Patients.svc/REST/GetPrescriptionApptList'; -const GET_PRESCRIPTIONS_ALL_ORDERS = - 'Services/Patients.svc/REST/PatientER_GetPatientAllPresOrders'; -const GET_PRESCRIPTION_REPORT = - 'Services/Patients.svc/REST/INP_GetPrescriptionReport'; -const SEND_PRESCRIPTION_EMAIL = - 'Services/Notifications.svc/REST/SendPrescriptionEmail'; -const GET_PRESCRIPTION_REPORT_ENH = - 'Services/Patients.svc/REST/GetPrescriptionReport_enh'; +const GET_PRESCRIPTIONS_ALL_ORDERS = 'Services/Patients.svc/REST/PatientER_GetPatientAllPresOrders'; +const GET_PRESCRIPTION_REPORT = 'Services/Patients.svc/REST/INP_GetPrescriptionReport'; +const SEND_PRESCRIPTION_EMAIL = 'Services/Notifications.svc/REST/SendPrescriptionEmail'; +const GET_PRESCRIPTION_REPORT_ENH = 'Services/Patients.svc/REST/GetPrescriptionReport_enh'; ///Lab Order const GET_Patient_LAB_ORDERS = 'Services/Patients.svc/REST/GetPatientLabOrders'; const GET_Patient_LAB_SPECIAL_RESULT = 'Services/Patients.svc/REST/GetPatientLabSpecialResults'; -const SEND_LAB_RESULT_EMAIL = - 'Services/Notifications.svc/REST/SendLabReportEmail'; -const GET_Patient_LAB_RESULT = - 'Services/Patients.svc/REST/GetPatientLabResults'; -const GET_Patient_LAB_ORDERS_RESULT = - 'Services/Patients.svc/REST/GetPatientLabOrdersResults'; +const SEND_LAB_RESULT_EMAIL = 'Services/Notifications.svc/REST/SendLabReportEmail'; +const GET_Patient_LAB_RESULT = 'Services/Patients.svc/REST/GetPatientLabResults'; +const GET_Patient_LAB_ORDERS_RESULT = 'Services/Patients.svc/REST/GetPatientLabOrdersResults'; /// const GET_PATIENT_ORDERS = 'Services/Patients.svc/REST/GetPatientRadOrders'; -const GET_PATIENT_LAB_ORDERS_BY_APPOINTMENT = - 'Services/Patients.svc/REST/GetPatientLabResultsByAppointmentNo'; +const GET_PATIENT_LAB_ORDERS_BY_APPOINTMENT = 'Services/Patients.svc/REST/GetPatientLabResultsByAppointmentNo'; const GET_PATIENT_ORDERS_DETAILS = 'Services/Patients.svc/REST/Rad_UpdatePatientRadOrdersToRead'; const GET_RAD_IMAGE_URL = 'Services/Patients.svc/Rest/GetRadImageURL'; @@ -134,8 +123,7 @@ const GET_BLOOD_REQUEST = 'services/PatientVarification.svc/REST/BloodDonation_G ///Reports const REPORTS = 'Services/Doctors.svc/REST/GetPatientMedicalReportStatusInfo'; const INSERT_REQUEST_FOR_MEDICAL_REPORT = 'Services/Doctors.svc/REST/InsertRequestForMedicalReport'; -const SEND_MEDICAL_REPORT_EMAIL = - 'Services/Notifications.svc/REST/SendMedicalReportEmail'; +const SEND_MEDICAL_REPORT_EMAIL = 'Services/Notifications.svc/REST/SendMedicalReportEmail'; ///Rate const IS_LAST_APPOITMENT_RATED = 'Services/Doctors.svc/REST/IsLastAppoitmentRated'; @@ -254,10 +242,8 @@ const GET_PAtIENTS_INSURANCE = "Services/Patients.svc/REST/Get_PatientInsuranceD const GET_PAtIENTS_INSURANCE_UPDATED = "Services/Patients.svc/REST/PatientER_GetPatientInsuranceCardUpdateHistory"; const INSURANCE_DETAILS = "Services/Patients.svc/REST/Get_InsuranceCheckList"; -const GET_PATIENT_INSURANCE_DETAILS = - "Services/Patients.svc/REST/PatientER_GetPatientInsuranceDetails"; -const UPLOAD_INSURANCE_CARD = - 'Services/Patients.svc/REST/PatientER_PatientInfoForInsuranceCardUpdate'; +const GET_PATIENT_INSURANCE_DETAILS = "Services/Patients.svc/REST/PatientER_GetPatientInsuranceDetails"; +const UPLOAD_INSURANCE_CARD = 'Services/Patients.svc/REST/PatientER_PatientInfoForInsuranceCardUpdate'; const GET_VACCINES = "Services/Patients.svc/REST/GetDoneVaccinesByPatientID"; const GET_VACCINES_EMAIL = "Services/Notifications.svc/REST/SendVaccinesEmail"; @@ -302,10 +288,10 @@ const SEND_AVERAGE_BLOOD_WEIGHT_REPORT = 'Services/Notifications.svc/REST/SendAv const SEND_AVERAGE_BLOOD_PRESSURE_REPORT = 'Services/Notifications.svc/REST/SendAverageBloodPressureReport'; const UPDATE_DIABETIC_RESULT = 'Services/Patients.svc/REST/Patient_UpdateDiabeticResult'; - const GET_WEIGHT_PRESSURE_RESULT_AVERAGE = 'Services/Patients.svc/REST/Patient_GetWeightMeasurementResultAverage'; const GET_WEIGHT_PRESSURE_RESULT = 'Services/Patients.svc/REST/Patient_GetWeightMeasurementResult'; const ADD_WEIGHT_PRESSURE_RESULT = 'Services/Patients.svc/REST/Patient_AddWeightMeasurementResult'; + const UPDATE_WEIGHT_PRESSURE_RESULT = 'Services/Patients.svc/REST/Patient_UpdateWeightMeasurementResult'; const DEACTIVATE_WEIGHT_PRESSURE_RESULT = 'services/Patients.svc/REST/Patient_DeactivateWeightMeasurementStatus'; @@ -342,7 +328,9 @@ const GET_PHARMACY_BANNER = "epharmacy/api/promotionbanners"; const GET_PHARMACY_TOP_MANUFACTURER = "epharmacy/api/topmanufacturer"; const GET_PHARMACY_BEST_SELLER_PRODUCT = "epharmacy/api/bestsellerproducts"; const GET_PHARMACY_PRODUCTs_BY_IDS = "epharmacy/api/productsbyids/"; +const GET_PHARMACY_PRODUCTs_BY_SKU = "epharmacy/api/productbysku/"; const GET_CUSTOMERS_ADDRESSES = "epharmacy/api/Customers/"; +const SUBSCRIBE_PRODUCT = "epharmacy/api/subscribe?"; const GET_ORDER = "orders?"; const GET_ORDER_DETAILS = "orders/"; const ADD_CUSTOMER_ADDRESS = "epharmacy/api/addcustomeraddress"; @@ -354,23 +342,15 @@ const WRITE_REVIEW = "Content-Type" + "text/plain; charset=utf-8"; const GET_SHOPPING_CART = "epharmacy/api/shopping_cart_items/"; const GET_SHIPPING_OPTIONS = "epharmacy/api/get_shipping_option/"; const DELETE_SHOPPING_CART = "epharmacy/api/delete_shopping_cart_items/"; -const DELETE_SHOPPING_CART_ALL = - "epharmacy/api/delete_shopping_cart_item_by_customer/"; +const DELETE_SHOPPING_CART_ALL = "epharmacy/api/delete_shopping_cart_item_by_customer/"; const ORDER_SHOPPING_CART = "epharmacy/api/orders"; -const GET_LACUM_ACCOUNT_INFORMATION = - "Services/Patients.svc/REST/GetLakumAccountInformation"; -const GET_LACUM_GROUP_INFORMATION = - "Services/Patients.svc/REST/GetlakumInQueryInfoGrouping"; -const LACUM_ACCOUNT_ACTIVATE = - "Services/Patients.svc/REST/LakumAccountActivation"; -const LACUM_ACCOUNT_DEACTIVATE = - "Services/Patients.svc/REST/LakumAccountDeactivation"; -const CREATE_LAKUM_ACCOUNT = - "Services/Patients.svc/REST/PHR_CreateLakumAccount"; -const TRANSFER_YAHALA_LOYALITY_POINTS = - "Services/Patients.svc/REST/TransferYaHalaLoyaltyPoints"; -const LAKUM_GET_USER_TERMS_AND_CONDITIONS = - "Services/ERP.svc/REST/GetUserTermsAndConditionsForEPharmcy"; +const GET_LACUM_ACCOUNT_INFORMATION = "Services/Patients.svc/REST/GetLakumAccountInformation"; +const GET_LACUM_GROUP_INFORMATION = "Services/Patients.svc/REST/GetlakumInQueryInfoGrouping"; +const LACUM_ACCOUNT_ACTIVATE = "Services/Patients.svc/REST/LakumAccountActivation"; +const LACUM_ACCOUNT_DEACTIVATE = "Services/Patients.svc/REST/LakumAccountDeactivation"; +const CREATE_LAKUM_ACCOUNT = "Services/Patients.svc/REST/PHR_CreateLakumAccount"; +const TRANSFER_YAHALA_LOYALITY_POINTS = "Services/Patients.svc/REST/TransferYaHalaLoyaltyPoints"; +const LAKUM_GET_USER_TERMS_AND_CONDITIONS = "Services/ERP.svc/REST/GetUserTermsAndConditionsForEPharmcy"; const PRESCRIPTION = 'Services/Patients.svc/REST/GetPrescriptionApptList'; // Home Health Care @@ -380,14 +360,10 @@ const PATIENT_ER_UPDATE_PRES_ORDER = "Services/Patients.svc/REST/PatientER_Updat const GET_ORDER_DETAIL_BY_ID = "Services/Patients.svc/REST/PatientER_HHC_GetTransactionsForOrder"; const GET_CMC_ORDER_DETAIL_BY_ID = "Services/Patients.svc/REST/PatientER_CMC_GetTransactionsForOrder"; const GET_CHECK_UP_ITEMS = "Services/Patients.svc/REST/GetCheckUpItems"; -const PUSH_NOTIFICATION_GET_ALL_NOTIFICATIONS = - 'Services/MobileNotifications.svc/REST/PushNotification_GetAllNotifications'; -const PUSH_NOTIFICATION_SET_MESSAGES_FROM_POOL_AS_READ = - 'Services/MobileNotifications.svc/REST/PushNotification_SetMessagesFromPoolAsRead'; -const GET_PATIENT_ALL_PRES_ORD = - 'Services/Patients.svc/REST/PatientER_GetPatientAllPresOrders'; -const PATIENT_ER_INSERT_PRES_ORDER = - 'Services/Patients.svc/REST/PatientER_InsertPresOrder'; +const PUSH_NOTIFICATION_GET_ALL_NOTIFICATIONS = 'Services/MobileNotifications.svc/REST/PushNotification_GetAllNotifications'; +const PUSH_NOTIFICATION_SET_MESSAGES_FROM_POOL_AS_READ = 'Services/MobileNotifications.svc/REST/PushNotification_SetMessagesFromPoolAsRead'; +const GET_PATIENT_ALL_PRES_ORD = 'Services/Patients.svc/REST/PatientER_GetPatientAllPresOrders'; +const PATIENT_ER_INSERT_PRES_ORDER = 'Services/Patients.svc/REST/PatientER_InsertPresOrder'; const PHARMACY_MAKE_REVIEW = 'epharmacy/api/insertreviews'; const BLOOD_DONATION_REGISTER_BLOOD_TYPE = 'Services/PatientVarification.svc/REST/BloodDonation_RegisterBloodType'; const ADD_USER_AGREEMENT_FOR_BLOOD_DONATION = 'Services/PatientVarification.svc/REST/AddUserAgreementForBloodDonation'; @@ -404,29 +380,22 @@ const GET_SPECIFICATION = "productspecification/"; const GET_BRAND_ITEMS = "products?ManufacturerId="; // External API -const ADD_ADDRESS_INFO = - "https://mdlaboratories.com/exacartapi/api/addcustomeraddress"; -const GET_CUSTOMER_ADDRESSES = - "https://mdlaboratories.com/exacartapi/api/Customers/"; -const GET_CUSTOMER_INFO = - "https://mdlaboratories.com/exacartapi/api/VerifyCustomer"; +const ADD_ADDRESS_INFO = "https://mdlaboratories.com/exacartapi/api/addcustomeraddress"; +const GET_CUSTOMER_ADDRESSES = "https://mdlaboratories.com/exacartapi/api/Customers/"; +const GET_CUSTOMER_INFO = "https://mdlaboratories.com/exacartapi/api/VerifyCustomer"; //Pharmacy -const GET_PHARMACY_CATEGORISE = - 'epharmacy/api/categories?fields=id,name,namen,description,image,localized_names,display_order,parent_category_id,is_leaf&parent_id=0'; +const GET_PHARMACY_CATEGORISE = 'epharmacy/api/categories?fields=id,name,namen,description,image,localized_names,display_order,parent_category_id,is_leaf&parent_id=0'; const GET_OFFERS_CATEGORISE = 'epharmacy/api/discountcategories'; const GET_OFFERS_PRODUCTS = 'epharmacy/api/offerproducts/'; -const GET_CATEGORISE_PARENT = - 'epharmacy/api/categories?fields=id,name,namen,description,image,localized_names,display_order,parent_category_id,is_leaf&parent_id='; +const GET_CATEGORISE_PARENT = 'epharmacy/api/categories?fields=id,name,namen,description,image,localized_names,display_order,parent_category_id,is_leaf&parent_id='; const GET_PARENT_PRODUCTS = 'epharmacy/api/products?categoryid='; -const GET_SUB_CATEGORISE = - 'epharmacy/api/categories?fields=id,name,namen,description,image,localized_names,display_order,parent_category_id,is_leaf&parent_id='; +const GET_SUB_CATEGORISE = 'epharmacy/api/categories?fields=id,name,namen,description,image,localized_names,display_order,parent_category_id,is_leaf&parent_id='; const GET_SUB_PRODUCTS = 'epharmacy/api/products?categoryid='; const GET_FINAL_PRODUCTS = 'epharmacy/api/products?fields=id,reviews,discount_ids,name,namen,localized_names,display_order,short_description,full_description,full_descriptionn,sku,order_minimum_quantity,order_maximum_quantity,price,old_price,images,is_rx,rx_message,rx_messagen,discount_name,discount_namen,approved_rating_sum,approved_total_reviews,allow_back_in_stock_subscriptions,stock_quantity,stock_availability,stock_availabilityn,discount_percentage&CategoryId='; - const TIMER_MIN = 10; const GOOGLE_API_KEY = "AIzaSyCmevVlr2Bh-c8W1VUzo8gt8JRY7n5PANw"; diff --git a/lib/core/service/parmacyModule/parmacy_module_service.dart b/lib/core/service/parmacyModule/parmacy_module_service.dart index 7f0a1050..264af2c2 100644 --- a/lib/core/service/parmacyModule/parmacy_module_service.dart +++ b/lib/core/service/parmacyModule/parmacy_module_service.dart @@ -6,27 +6,23 @@ import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart' import 'package:diplomaticquarterapp/core/service/base_service.dart'; import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart'; - class PharmacyModuleService extends BaseService { final AppSharedPreferences sharedPref = AppSharedPreferences(); bool isFinished = true; bool hasError = false; String errorMsg = ''; - String url =""; + String url = ""; List bannerItems = List(); List manufacturerList = List(); List bestSellerProducts = List(); List lastVisitedProducts = List(); - - Future makeVerifyCustomer(dynamic data) async { Map queryParams = {'FileNumber': data['PatientID'].toString()}; hasError = false; try { - await baseAppClient.get(PHARMACY_VERIFY_CUSTOMER, - onSuccess: (dynamic response, int statusCode) { + await baseAppClient.get(PHARMACY_VERIFY_CUSTOMER, onSuccess: (dynamic response, int statusCode) { if (response['UserName'] != null) { sharedPref.setString(PHARMACY_CUSTOMER_ID, response['CustomerId'].toString()); print(response); @@ -58,8 +54,7 @@ class PharmacyModuleService extends BaseService { }; hasError = false; try { - await baseAppClient.get(PHARMACY_CREATE_CUSTOMER, - onSuccess: (dynamic response, int statusCode) { + await baseAppClient.get(PHARMACY_CREATE_CUSTOMER, onSuccess: (dynamic response, int statusCode) { if (!response['IsRegistered']) {} }, onFailure: (String error, int statusCode) { hasError = true; @@ -73,8 +68,7 @@ class PharmacyModuleService extends BaseService { Future getBannerListList() async { hasError = false; try { - await baseAppClient.get(GET_PHARMACY_BANNER, - onSuccess: (dynamic response, int statusCode) { + await baseAppClient.get(GET_PHARMACY_BANNER, onSuccess: (dynamic response, int statusCode) { bannerItems.clear(); response['images'].forEach((item) { bannerItems.add(PharmacyImageObject.fromJson(item)); @@ -91,12 +85,11 @@ class PharmacyModuleService extends BaseService { Future getTopManufacturerList() async { Map queryParams = {'page': '1', 'limit': '8'}; try { - await baseAppClient.get(GET_PHARMACY_TOP_MANUFACTURER, - onSuccess: (dynamic response, int statusCode) { + await baseAppClient.get(GET_PHARMACY_TOP_MANUFACTURER, onSuccess: (dynamic response, int statusCode) { manufacturerList.clear(); response['manufacturer'].forEach((item) { Manufacturer manufacturer = Manufacturer.fromJson(item); - if(manufacturer.image != null){ + if (manufacturer.image != null) { manufacturerList.add(Manufacturer.fromJson(item)); } }); @@ -115,8 +108,7 @@ class PharmacyModuleService extends BaseService { 'id,discount_ids,name,namen,localized_names,display_order,short_description,full_description,full_descriptionn,sku,order_minimum_quantity,order_maximum_quantity,price,old_price,images,is_rx,rx_message,rx_messagen,discount_name,discount_namen,approved_rating_sum,approved_total_reviews,allow_back_in_stock_subscriptions,stock_quantity,stock_availability,stock_availabilityn,discount_percentage,reviews', }; try { - await baseAppClient.get(GET_PHARMACY_BEST_SELLER_PRODUCT, - onSuccess: (dynamic response, int statusCode) { + await baseAppClient.get(GET_PHARMACY_BEST_SELLER_PRODUCT, onSuccess: (dynamic response, int statusCode) { bestSellerProducts.clear(); response['products'].forEach((item) { bestSellerProducts.add(PharmacyProduct.fromJson(item)); @@ -132,13 +124,10 @@ class PharmacyModuleService extends BaseService { Future getLastVisitedProducts() async { String lastVisited = ""; - if (await this.sharedPref.getString(PHARMACY_LAST_VISITED_PRODUCTS) != - null) { - lastVisited = - await this.sharedPref.getString(PHARMACY_LAST_VISITED_PRODUCTS); + if (await this.sharedPref.getString(PHARMACY_LAST_VISITED_PRODUCTS) != null) { + lastVisited = await this.sharedPref.getString(PHARMACY_LAST_VISITED_PRODUCTS); try { - await baseAppClient.get("$GET_PHARMACY_PRODUCTs_BY_IDS$lastVisited", - onSuccess: (dynamic response, int statusCode) { + await baseAppClient.get("$GET_PHARMACY_PRODUCTs_BY_IDS$lastVisited", onSuccess: (dynamic response, int statusCode) { lastVisitedProducts.clear(); response['products'].forEach((item) { lastVisitedProducts.add(PharmacyProduct.fromJson(item)); @@ -152,5 +141,4 @@ class PharmacyModuleService extends BaseService { } } } - } diff --git a/lib/core/viewModels/pharmacyModule/product_detail_view_model.dart b/lib/core/viewModels/pharmacyModule/product_detail_view_model.dart index 47a3bb11..e3a6255e 100644 --- a/lib/core/viewModels/pharmacyModule/product_detail_view_model.dart +++ b/lib/core/viewModels/pharmacyModule/product_detail_view_model.dart @@ -50,6 +50,17 @@ class ProductDetailViewModel extends BaseViewModel{ setState(ViewState.Idle); } + Future notifyMe(customerId, itemID) async { + hasError = false; + setState(ViewState.Busy); + await _productLocationService.notifyMe(customerId, itemID); + if (_productLocationService.hasError) { + error = _productLocationService.error; + setState(ViewState.ErrorLocal); + } else + setState(ViewState.Idle); + } + Future addToCartData(quantity, itemID) async { hasError = false; setState(ViewState.Busy); diff --git a/lib/pages/landing/landing_page_pharmcy.dart b/lib/pages/landing/landing_page_pharmcy.dart index fda83fc2..a41c263f 100644 --- a/lib/pages/landing/landing_page_pharmcy.dart +++ b/lib/pages/landing/landing_page_pharmcy.dart @@ -1,19 +1,29 @@ +import 'dart:convert'; + +import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; +import 'package:diplomaticquarterapp/config/config.dart'; +import 'package:barcode_scan_fix/barcode_scan.dart'; +import 'package:diplomaticquarterapp/core/service/client/base_app_client.dart'; +import 'package:diplomaticquarterapp/core/viewModels/pharmacy_categorise_view_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/pages/parent_categorise_page.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/product_detail.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/screens/cart-order-page.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/screens/pharmacy_module_page.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/medicine_search_screen.dart'; import 'package:diplomaticquarterapp/pages/pharmacy/profile/profile.dart'; import 'package:diplomaticquarterapp/pages/pharmacy_categorise.dart'; import 'package:diplomaticquarterapp/pages/search_products_page.dart'; +import 'package:diplomaticquarterapp/uitl/app_toast.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; +import 'package:diplomaticquarterapp/uitl/utils.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; -import 'package:diplomaticquarterapp/widgets/drawer/app_drawer_widget.dart'; +import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart'; import 'package:diplomaticquarterapp/widgets/pharmacy/bottom_nav_pharmacy_bar.dart'; +import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; import 'package:flutter/material.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/wishlist.dart'; -import '../offers_categorise_page.dart'; - class LandingPagePharmacy extends StatefulWidget { @override _LandingPagePharmacyState createState() => _LandingPagePharmacyState(); @@ -39,105 +49,107 @@ class _LandingPagePharmacyState extends State { @override Widget build(BuildContext context) { return Scaffold( - appBar: currentTab == 0 || currentTab == 1 - ? AppBar( - backgroundColor: Color(0xff5AB145), - elevation: 0, - title: Container( - height: MediaQuery.of(context).size.height * 0.056, - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(5.0), - color: Colors.white, - ), - child: InkWell( - child: Padding( - padding: EdgeInsets.all(8.0), - child: Row( - //crossAxisAlignment: CrossAxisAlignment.center, - mainAxisAlignment: MainAxisAlignment.start, - children: [ - Icon(Icons.search, size: 25.0), - SizedBox( - width: 15.0, - ), - Texts( - TranslationBase.of(context).searchProductHere, - fontSize: 13, - ) - ], - ), + appBar: + + // currentTab == 0 || currentTab == 1 || currentTab == 2 + // ? + + AppBar( + backgroundColor: Color(0xff5AB145), + elevation: 0, + title: Container( + height: MediaQuery.of(context).size.height * 0.056, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(5.0), + color: Colors.white, + ), + child: InkWell( + child: Padding( + padding: EdgeInsets.all(8.0), + child: Row( + //crossAxisAlignment: CrossAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Icon(Icons.search, size: 25.0), + SizedBox( + width: 15.0, ), - onTap: () { - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => SearchProductsPage()), - ); - }, + Texts( + TranslationBase.of(context).searchProductHere, + fontSize: 13, + ) + ], + ), + ), + onTap: () { + Navigator.push( + context, + MaterialPageRoute(builder: (context) => SearchProductsPage()), + ); + }, + ), + ), + leading: Builder( + builder: (BuildContext context) { + return InkWell( + onTap: () { + setState(() { + currentTab = 0; + pageController.jumpToPage(0); + }); + }, + child: Container( + height: 2.0, + width: 10.0, + child: Image.asset( + 'assets/images/pharmacy_logo.png', ), ), - leading: Builder( - builder: (BuildContext context) { - return InkWell( - onTap: (){ - setState(() { - currentTab = 0; - pageController.jumpToPage(0); - }); - }, - child: Container( - height: 2.0, - width: 10.0, - child: Image.asset( - 'assets/images/pharmacy_logo.png', - ), - ), - ); - }, + ); + }, + ), + actions: [ + IconButton( + // iconSize: 70, + icon: Image.asset( + 'assets/images/new-design/qr-code.png', ), - actions: [ - // IconButton( - // iconSize: 70, - // icon: SvgPicture.asset('assets/images/svg/robort_svg.svg', - // height: 100, width: 100, fit: BoxFit.cover), - // onPressed: () { - // triggerRobot(); - // } //do something, - // ) - ], - centerTitle: true, - ) - : currentTab == 4 - ? null - : AppBar( - backgroundColor: Color(0xff5AB145), - elevation: 0, - textTheme: TextTheme( - headline6: TextStyle( - color: Colors.white, fontWeight: FontWeight.bold), - ), - title: Text(getText(currentTab).toUpperCase()), - leading: Builder( - builder: (BuildContext context) { - return IconButton( - icon: Icon(Icons.arrow_back), - color: Colors.white, - onPressed: () => Scaffold.of(context).openDrawer(), - ); - }, - ), - actions: [ - // IconButton( - // iconSize: 70, - // icon: SvgPicture.asset('assets/images/svg/robort_svg.svg', - // height: 100, width: 100, fit: BoxFit.cover), - // onPressed: () { - // triggerRobot(); - // } //do something, - // ) - ], - centerTitle: true, - ), + onPressed: _scanQrAndGetProduct //do something, + ) + ], + centerTitle: true, + ), + // : currentTab == 4 + // ? null:null, + // : AppBar( + // backgroundColor: Color(0xff5AB145), + // elevation: 0, + // textTheme: TextTheme( + // headline6: TextStyle( + // color: Colors.white, fontWeight: FontWeight.bold), + // ), + // title: Text(getText(currentTab).toUpperCase()), + // leading: Builder( + // builder: (BuildContext context) { + // return IconButton( + // icon: Icon(Icons.arrow_back), + // color: Colors.white, + // onPressed: () => Scaffold.of(context).openDrawer(), + // ); + // }, + // ), + // actions: [ + // // IconButton( + // // iconSize: 70, + // // icon: SvgPicture.asset('assets/images/svg/robort_svg.svg', + // // height: 100, width: 100, fit: BoxFit.cover), + // // onPressed: () { + // // triggerRobot(); + // // } //do something, + // // ) + // ], + // centerTitle: true, + // ), extendBody: false, body: PageView( physics: NeverScrollableScrollPhysics(), @@ -162,6 +174,29 @@ class _LandingPagePharmacyState extends State { ); } + void _scanQrAndGetProduct() async { + try { + String result = await BarcodeScanner.scan(); + try { + String barcode = result; + GifLoaderDialogUtils.showMyDialog(context); + await BaseAppClient().get("$GET_PHARMACY_PRODUCTs_BY_SKU$barcode", + onSuccess: (dynamic response, int statusCode) { + print(response); + var product = PharmacyProduct.fromJson(response["products"][0]); + GifLoaderDialogUtils.hideDialog(context); + Navigator.push(context, FadePage(page: ProductDetailPage(product))); + }, onFailure: (String error, int statusCode) { + GifLoaderDialogUtils.hideDialog(context); + AppToast.showErrorToast(message: "Product not found"); + }); + } catch (apiEx) { + AppToast.showErrorToast( + message: "Something went wrong, please try again"); + } + } catch (barcodeEx) {} + } + getText(currentTab) { switch (currentTab) { case 2: diff --git a/lib/pages/login/login.dart b/lib/pages/login/login.dart index c2a943d2..2c554c1c 100644 --- a/lib/pages/login/login.dart +++ b/lib/pages/login/login.dart @@ -44,11 +44,9 @@ class _Login extends State { final authService = new AuthProvider(); var sharedPref = new AppSharedPreferences(); bool isLoading = false; - AppointmentRateViewModel appointmentRateViewModel = - locator(); + AppointmentRateViewModel appointmentRateViewModel = locator(); - AuthenticatedUserObject authenticatedUserObject = - locator(); + AuthenticatedUserObject authenticatedUserObject = locator(); ProjectViewModel projectViewModel; ToDoCountProviderModel toDoProvider; @@ -101,16 +99,9 @@ class _Login extends State { fontWeight: FontWeight.normal, controller: nationalIDorFile, onChanged: (value) => {validateForm()}, - prefixIcon: Icon( - loginType == 1 - ? Icons.chrome_reader_mode - : Icons.receipt, - color: Color(0xFF40ACC9)), - padding: EdgeInsets.only( - top: 20, bottom: 20, left: 10, right: 10), - hintText: loginType == 1 - ? TranslationBase.of(context).nationalID - : TranslationBase.of(context).fileNo, + prefixIcon: Icon(loginType == 1 ? Icons.chrome_reader_mode : Icons.receipt, color: Color(0xFF40ACC9)), + padding: EdgeInsets.only(top: 20, bottom: 20, left: 10, right: 10), + hintText: loginType == 1 ? TranslationBase.of(context).nationalID : TranslationBase.of(context).fileNo, ))) ], ), @@ -133,9 +124,7 @@ class _Login extends State { child: DefaultButton( TranslationBase.of(context).login, () => {this.startLogin()}, - color: isButtonDisabled == true - ? Colors.grey - : Colors.grey[900], + color: isButtonDisabled == true ? Colors.grey : Colors.grey[900], textColor: Colors.white, )) ], @@ -156,8 +145,7 @@ class _Login extends State { } void validateForm() { - if (util.validateIDBox(nationalIDorFile.text, loginType) == true && - util.isSAUDIIDValid(nationalIDorFile.text, loginType) == true) { + if (util.validateIDBox(nationalIDorFile.text, loginType) == true && util.isSAUDIIDValid(nationalIDorFile.text, loginType) == true) { setState(() { isButtonDisabled = false; }); @@ -242,50 +230,49 @@ class _Login extends State { this.authService.checkActivationCode(request, code).then((result) async { sharedPref.remove(FAMILY_FILE); // Register GeoZones after login - registerGeoZones(); - projectViewModel.setPrivilege(privilegeList: result); - result = CheckActivationCode.fromJson(result); - result.list.isFamily = false; - // this.sharedPref.setString(BLOOD_TYPE, result['PatientBloodType']), - this.sharedPref.setObject(USER_PROFILE, result.list); - this.sharedPref.setObject(MAIN_USER, result.list); - this.sharedPref.setObject(LOGIN_TOKEN_ID, result.logInTokenID); - this.sharedPref.setString(TOKEN, result.authenticationTokenID); - await authenticatedUserObject.getUser(getUser: true); - authenticatedUserObject.isLogin = true; - appointmentRateViewModel.isLogin = true; - projectViewModel.isLogin = true; - projectViewModel.user = authenticatedUserObject.user; - appointmentRateViewModel - .getIsLastAppointmentRatedList() - .then((value) => { - getToDoCount(), - GifLoaderDialogUtils.hideDialog(context), - if (appointmentRateViewModel.isHaveAppointmentNotRate) - { - Navigator.pushAndRemoveUntil( - context, - FadePage( - page: RateAppointmentDoctor(), - ), - (r) => false) - } - else - { - Navigator.pushAndRemoveUntil( - context, - FadePage( - page: LandingPage(), - ), - (r) => false) - } - }) - .catchError((err) { - print(err); - GifLoaderDialogUtils.hideDialog(context); - }); - - }); + registerGeoZones(); + projectViewModel.setPrivilege(privilegeList: result); + result = CheckActivationCode.fromJson(result); + result.list.isFamily = false; + // this.sharedPref.setString(BLOOD_TYPE, result['PatientBloodType']), + this.sharedPref.setObject(USER_PROFILE, result.list); + this.sharedPref.setObject(MAIN_USER, result.list); + this.sharedPref.setObject(LOGIN_TOKEN_ID, result.logInTokenID); + this.sharedPref.setString(TOKEN, result.authenticationTokenID); + await authenticatedUserObject.getUser(getUser: true); + authenticatedUserObject.isLogin = true; + appointmentRateViewModel.isLogin = true; + projectViewModel.isLogin = true; + projectViewModel.user = authenticatedUserObject.user; + appointmentRateViewModel + .getIsLastAppointmentRatedList() + .then((value) => { + getToDoCount(), + GifLoaderDialogUtils.hideDialog(context), + if (appointmentRateViewModel.isHaveAppointmentNotRate) + { + Navigator.pushAndRemoveUntil( + context, + FadePage( + page: RateAppointmentDoctor(), + ), + (r) => false) + } + else + { + Navigator.pushAndRemoveUntil( + context, + FadePage( + page: LandingPage(), + ), + (r) => false) + } + }) + .catchError((err) { + print(err); + GifLoaderDialogUtils.hideDialog(context); + }); + }); } getToDoCount() { diff --git a/lib/pages/pharmacies/product_detail.dart b/lib/pages/pharmacies/product_detail.dart index ebb7fe39..6cd3a7d1 100644 --- a/lib/pages/pharmacies/product_detail.dart +++ b/lib/pages/pharmacies/product_detail.dart @@ -2,6 +2,7 @@ import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/product_detail_view_model.dart'; import 'package:diplomaticquarterapp/pages/base/base_view.dart'; +import 'package:diplomaticquarterapp/pages/login/welcome.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:flutter/material.dart'; @@ -38,7 +39,7 @@ class __ProductDetailPageState extends State { dynamic wishlistItems; void initState() { - price = 0; + price = 1; specificationData = widget.product; setState(() { customerId = userInfo(widget.product.id, widget.product); @@ -79,18 +80,12 @@ class __ProductDetailPageState extends State { alignment: Alignment.centerRight, child: languageID == 'ar' ? Text( - widget.product - .discountDescriptionn, - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 17), + widget.product.discountDescriptionn, + style: TextStyle(fontWeight: FontWeight.bold, fontSize: 17), ) : Text( - widget.product - .discountDescription, - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 17), + widget.product.discountDescription, + style: TextStyle(fontWeight: FontWeight.bold, fontSize: 17), ), ), ), @@ -101,8 +96,7 @@ class __ProductDetailPageState extends State { flex: 0, child: Container( child: Image( - image: AssetImage( - 'assets/images/offer.png'), + image: AssetImage('assets/images/offer.png'), ), ), ), @@ -180,9 +174,7 @@ class __ProductDetailPageState extends State { }, child: Text( TranslationBase.of(context).details, - style: TextStyle( - fontSize: 16, - fontWeight: FontWeight.bold), + style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold), ), color: Colors.white, ), @@ -210,9 +202,7 @@ class __ProductDetailPageState extends State { }, child: Text( TranslationBase.of(context).reviews, - style: TextStyle( - fontSize: 16, - fontWeight: FontWeight.bold), + style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold), ), color: Colors.white, ), @@ -240,9 +230,7 @@ class __ProductDetailPageState extends State { }, child: Text( TranslationBase.of(context).availability, - style: TextStyle( - fontSize: 16, - fontWeight: FontWeight.bold), + style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold), ), color: Colors.white, ), @@ -270,10 +258,7 @@ class __ProductDetailPageState extends State { Container( child: Text( TranslationBase.of(context).description, - style: TextStyle( - fontSize: 17, - color: Colors.grey, - fontWeight: FontWeight.w600), + style: TextStyle(fontSize: 17, color: Colors.grey, fontWeight: FontWeight.w600), ), ), SizedBox( @@ -281,12 +266,8 @@ class __ProductDetailPageState extends State { ), Container( child: Text( - languageID == 'ar' - ? widget.product.shortDescriptionn - : widget.product.shortDescription, - style: TextStyle( - fontSize: 16, - fontFamily: 'WorkSans-Regular'), + languageID == 'ar' ? widget.product.shortDescriptionn : widget.product.shortDescription ?? "", + style: TextStyle(fontSize: 16, fontFamily: 'WorkSans-Regular'), ), ), SizedBox( @@ -295,10 +276,7 @@ class __ProductDetailPageState extends State { Container( child: Text( TranslationBase.of(context).howToUse, - style: TextStyle( - fontSize: 17, - color: Colors.grey, - fontWeight: FontWeight.w600), + style: TextStyle(fontSize: 17, color: Colors.grey, fontWeight: FontWeight.w600), ), ), SizedBox( @@ -306,12 +284,8 @@ class __ProductDetailPageState extends State { ), Container( child: Text( - languageID == 'ar' - ? widget.product.fullDescriptionn - : widget.product.fullDescription, - style: TextStyle( - fontSize: 16, - fontFamily: 'WorkSans-Regular'), + languageID == 'ar' ? widget.product.fullDescriptionn : widget.product.fullDescription, + style: TextStyle(fontSize: 16, fontFamily: 'WorkSans-Regular'), ), ), ], @@ -319,162 +293,98 @@ class __ProductDetailPageState extends State { ) : isReviews ? BaseView( - onModelReady: (model) => - model.getProductReviewsData( - widget.product.id), - builder: (_, model, wi) => model - .productDetailService - .length != - 0 && - model.productDetailService[0] - .reviews.length != - 0 - ? ListView.builder( - physics: ScrollPhysics(), - itemCount: model - .productDetailService[0] - .reviews - .length, - scrollDirection: Axis.vertical, - shrinkWrap: true, - itemBuilder: (BuildContext context, - int index) { - return Padding( - padding: EdgeInsets.all(8.0), - child: Column( - mainAxisAlignment: - MainAxisAlignment.start, - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Container( - child: Row( - children: [ - Container( - child: Text( - model - .productDetailService[ - 0] - .reviews[ - index] - .customerId - .toString(), - style: TextStyle( - fontSize: 17, - color: Colors - .grey, - fontWeight: - FontWeight - .w600), - ), + onModelReady: (model) => model.getProductReviewsData(widget.product.id), + builder: (_, model, wi) => + model.productDetailService.length != 0 && model.productDetailService[0].reviews.length != 0 + ? ListView.builder( + physics: ScrollPhysics(), + itemCount: model.productDetailService[0].reviews.length, + scrollDirection: Axis.vertical, + shrinkWrap: true, + itemBuilder: (BuildContext context, int index) { + return Padding( + padding: EdgeInsets.all(8.0), + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + child: Row( + children: [ + Container( + child: Text( + model.productDetailService[0].reviews[index].customerId.toString(), + style: TextStyle(fontSize: 17, color: Colors.grey, fontWeight: FontWeight.w600), + ), + ), + Container( + margin: EdgeInsets.only(left: 210), + child: RatingBar.readOnly( + initialRating: model.productDetailService[0].reviews[index].rating.toDouble(), + size: 15.0, + filledColor: Colors.yellow[700], + emptyColor: Colors.grey[500], + isHalfAllowed: true, + halfFilledIcon: Icons.star_half, + filledIcon: Icons.star, + emptyIcon: Icons.star, + ), + ), + ], ), - Container( - margin: - EdgeInsets.only( - left: 210), - child: RatingBar - .readOnly( - initialRating: model - .productDetailService[ - 0] - .reviews[ - index] - .rating - .toDouble(), - size: 15.0, - filledColor: - Colors.yellow[ - 700], - emptyColor: Colors - .grey[500], - isHalfAllowed: - true, - halfFilledIcon: - Icons - .star_half, - filledIcon: - Icons.star, - emptyIcon: - Icons.star, - ), + ), + SizedBox( + height: 10, + ), + Container( + child: Text( + model.productDetailService[0].reviews[index].reviewText, + style: TextStyle(fontSize: 20), ), - ], - ), - ), - SizedBox( - height: 10, - ), - Container( - child: Text( - model - .productDetailService[ - 0] - .reviews[index] - .reviewText, - style: TextStyle( - fontSize: 20), - ), - ), - SizedBox( - height: 50, + ), + SizedBox( + height: 50, + ), + Divider(height: 1, color: Colors.grey), + ], ), - Divider( - height: 1, - color: Colors.grey), - ], - ), - ); - }, - ) - : Container( - padding: EdgeInsets.all(15), - alignment: Alignment.center, - child: Text('No Reviews Available'), - ), + ); + }, + ) + : Container( + padding: EdgeInsets.all(15), + alignment: Alignment.center, + child: Text('No Reviews Available'), + ), ) : isAvailabilty ? BaseView( - onModelReady: (model) => - model.getProductLocationData(), - builder: (_, model, wi) => model - .productLocationService - .length == - 0 + onModelReady: (model) => model.getProductLocationData(), + builder: (_, model, wi) => model.productLocationService.length == 0 ? Container( padding: EdgeInsets.all(15), alignment: Alignment.center, - child: Text( - 'No location Available'), + child: Text('No location Available'), ) : ListView.builder( physics: ScrollPhysics(), scrollDirection: Axis.vertical, shrinkWrap: true, - itemCount: model - .productLocationService - .length, - itemBuilder: - (BuildContext context, - int index) { + itemCount: model.productLocationService.length, + itemBuilder: (BuildContext context, int index) { return Padding( - padding: - EdgeInsets.all(8.0), + padding: EdgeInsets.all(8.0), child: Column( // crossAxisAlignment: CrossAxisAlignment.start, // mainAxisAlignment: MainAxisAlignment.start, children: [ Row( // crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: - MainAxisAlignment - .start, + mainAxisAlignment: MainAxisAlignment.start, children: [ Expanded( flex: 1, - child: Image.network(model - .productLocationService[ - index] - .projectImageUrl), + child: Image.network(model.productLocationService[index].projectImageUrl), ), SizedBox( width: 10, @@ -482,48 +392,31 @@ class __ProductDetailPageState extends State { Expanded( flex: 4, child: Text( - model - .productLocationService[ - index] - .locationDescription + + model.productLocationService[index].locationDescription + "\n" + - fixingString(model - .productLocationService[ - 0] - .cityName - .toString()), - style: TextStyle( - fontSize: - 12), + fixingString(model.productLocationService[0].cityName.toString()), + style: TextStyle(fontSize: 12), ), ), Expanded( flex: 1, child: IconButton( - icon: Icon(Icons - .location_on), - color: - Colors.red, - onPressed: - () {}, + icon: Icon(Icons.location_on), + color: Colors.red, + onPressed: () {}, ), ), Expanded( flex: 1, child: IconButton( - icon: Icon(Icons - .phone), - color: - Colors.red, - onPressed: - () {}, + icon: Icon(Icons.phone), + color: Colors.red, + onPressed: () {}, ), ), ], ), - Divider( - height: 1.2, - color: Colors.grey) + Divider(height: 1.2, color: Colors.grey) ], ), ); @@ -538,12 +431,8 @@ class __ProductDetailPageState extends State { ], ), ), - bottomSheet: footerWidget( - widget.product.stockAvailability != 'Out of stock', - widget.product.orderMaximumQuantity, - widget.product.orderMinimumQuantity, - widget.product.stockQuantity, - widget.product), + bottomSheet: footerWidget(widget.product.stockAvailability != 'Out of stock', widget.product.orderMaximumQuantity, + widget.product.orderMinimumQuantity, widget.product.stockQuantity, widget.product), ) : AppScaffold( appBarTitle: 'product detail page', @@ -576,18 +465,12 @@ class __ProductDetailPageState extends State { alignment: Alignment.centerRight, child: languageID == 'ar' ? Text( - widget.product - .discountDescriptionn, - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 17), + widget.product.discountDescriptionn, + style: TextStyle(fontWeight: FontWeight.bold, fontSize: 17), ) : Text( - widget.product - .discountDescription, - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 17), + widget.product.discountDescription, + style: TextStyle(fontWeight: FontWeight.bold, fontSize: 17), ), ), ), @@ -598,8 +481,7 @@ class __ProductDetailPageState extends State { flex: 0, child: Container( child: Image( - image: AssetImage( - 'assets/images/offer.png'), + image: AssetImage('assets/images/offer.png'), ), ), ), @@ -669,9 +551,7 @@ class __ProductDetailPageState extends State { }, child: Text( TranslationBase.of(context).details, - style: TextStyle( - fontSize: 16, - fontWeight: FontWeight.bold), + style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold), ), color: Colors.white, ), @@ -699,9 +579,7 @@ class __ProductDetailPageState extends State { }, child: Text( TranslationBase.of(context).reviews, - style: TextStyle( - fontSize: 16, - fontWeight: FontWeight.bold), + style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold), ), color: Colors.white, ), @@ -729,9 +607,7 @@ class __ProductDetailPageState extends State { }, child: Text( TranslationBase.of(context).availability, - style: TextStyle( - fontSize: 16, - fontWeight: FontWeight.bold), + style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold), ), color: Colors.white, ), @@ -759,10 +635,7 @@ class __ProductDetailPageState extends State { Container( child: Text( TranslationBase.of(context).description, - style: TextStyle( - fontSize: 17, - color: Colors.grey, - fontWeight: FontWeight.w600), + style: TextStyle(fontSize: 17, color: Colors.grey, fontWeight: FontWeight.w600), ), ), SizedBox( @@ -770,12 +643,8 @@ class __ProductDetailPageState extends State { ), Container( child: Text( - languageID == 'ar' - ? widget.product.fullDescriptionn - : widget.product.fullDescription, - style: TextStyle( - fontSize: 16, - fontFamily: 'WorkSans-Regular'), + languageID == 'ar' ? widget.product.fullDescriptionn : widget.product.fullDescription, + style: TextStyle(fontSize: 16, fontFamily: 'WorkSans-Regular'), ), ), ], @@ -783,132 +652,79 @@ class __ProductDetailPageState extends State { ) : isReviews ? BaseView( - onModelReady: (model) => - model.getProductReviewsData( - widget.product.id), - builder: (_, model, wi) => model - .productDetailService - .length != - 0 && - model.productDetailService[0] - .reviews.length != - 0 - ? ListView.builder( - physics: ScrollPhysics(), - itemCount: model - .productDetailService[0] - .reviews - .length, - scrollDirection: Axis.vertical, - shrinkWrap: true, - itemBuilder: (BuildContext context, - int index) { - return Padding( - padding: EdgeInsets.all(8.0), - child: Column( - mainAxisAlignment: - MainAxisAlignment.start, - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Container( - child: Row( - children: [ - Container( - child: Text( - model - .productDetailService[ - 0] - .reviews[ - index] - .customerId - .toString(), - style: TextStyle( - fontSize: 17, - color: Colors - .grey, - fontWeight: - FontWeight - .w600), - ), + onModelReady: (model) => model.getProductReviewsData(widget.product.id), + builder: (_, model, wi) => + model.productDetailService.length != 0 && model.productDetailService[0].reviews.length != 0 + ? ListView.builder( + physics: ScrollPhysics(), + itemCount: model.productDetailService[0].reviews.length, + scrollDirection: Axis.vertical, + shrinkWrap: true, + itemBuilder: (BuildContext context, int index) { + return Padding( + padding: EdgeInsets.all(8.0), + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + child: Row( + children: [ + Container( + child: Text( + model.productDetailService[0].reviews[index].customerId.toString(), + style: TextStyle(fontSize: 17, color: Colors.grey, fontWeight: FontWeight.w600), + ), + ), + Container( + margin: EdgeInsets.only(left: 210), + child: RatingBar.readOnly( + initialRating: model.productDetailService[0].reviews[index].rating.toDouble(), + size: 15.0, + filledColor: Colors.yellow[700], + emptyColor: Colors.grey[500], + isHalfAllowed: true, + halfFilledIcon: Icons.star_half, + filledIcon: Icons.star, + emptyIcon: Icons.star, + ), + ), + ], ), - Container( - margin: - EdgeInsets.only( - left: 210), - child: RatingBar - .readOnly( - initialRating: model - .productDetailService[ - 0] - .reviews[ - index] - .rating - .toDouble(), - size: 15.0, - filledColor: - Colors.yellow[ - 700], - emptyColor: Colors - .grey[500], - isHalfAllowed: - true, - halfFilledIcon: - Icons - .star_half, - filledIcon: - Icons.star, - emptyIcon: - Icons.star, - ), + ), + SizedBox( + height: 10, + ), + Container( + child: Text( + model.productDetailService[0].reviews[index].reviewText, + style: TextStyle(fontSize: 20), ), - ], - ), - ), - SizedBox( - height: 10, - ), - Container( - child: Text( - model - .productDetailService[ - 0] - .reviews[index] - .reviewText, - style: TextStyle( - fontSize: 20), - ), - ), - SizedBox( - height: 50, + ), + SizedBox( + height: 50, + ), + Divider(height: 1, color: Colors.grey), + ], ), - Divider( - height: 1, - color: Colors.grey), - ], - ), - ); - }, - ) - : Container( - padding: EdgeInsets.all(15), - alignment: Alignment.center, - child: Text('No Reviews Available'), - ), + ); + }, + ) + : Container( + padding: EdgeInsets.all(15), + alignment: Alignment.center, + child: Text('No Reviews Available'), + ), ) : isAvailabilty ? BaseView( - onModelReady: (model) => - model.getProductLocationData(), - builder: (_, model, wi) => - ListView.builder( + onModelReady: (model) => model.getProductLocationData(), + builder: (_, model, wi) => ListView.builder( physics: ScrollPhysics(), scrollDirection: Axis.vertical, shrinkWrap: true, - itemCount: model - .productLocationService.length, - itemBuilder: (BuildContext context, - int index) { + itemCount: model.productLocationService.length, + itemBuilder: (BuildContext context, int index) { return Padding( padding: EdgeInsets.all(8.0), child: Column( @@ -917,15 +733,11 @@ class __ProductDetailPageState extends State { children: [ Row( // crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: - MainAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.start, children: [ Expanded( flex: 1, - child: Image.network(model - .productLocationService[ - index] - .projectImageUrl), + child: Image.network(model.productLocationService[index].projectImageUrl), ), SizedBox( width: 10, @@ -933,25 +745,16 @@ class __ProductDetailPageState extends State { Expanded( flex: 4, child: Text( - model - .productLocationService[ - index] - .locationDescription + + model.productLocationService[index].locationDescription + "\n" + - fixingString(model - .productLocationService[ - 0] - .cityName - .toString()), - style: TextStyle( - fontSize: 12), + fixingString(model.productLocationService[0].cityName.toString()), + style: TextStyle(fontSize: 12), ), ), Expanded( flex: 1, child: IconButton( - icon: Icon(Icons - .location_on), + icon: Icon(Icons.location_on), color: Colors.red, onPressed: () {}, ), @@ -959,17 +762,14 @@ class __ProductDetailPageState extends State { Expanded( flex: 1, child: IconButton( - icon: - Icon(Icons.phone), + icon: Icon(Icons.phone), color: Colors.red, onPressed: () {}, ), ), ], ), - Divider( - height: 1.2, - color: Colors.grey) + Divider(height: 1.2, color: Colors.grey) ], ), ); @@ -984,12 +784,8 @@ class __ProductDetailPageState extends State { ], ), ), - bottomSheet: footerWidget( - widget.product.stockAvailability != 'Out of stock', - widget.product.orderMaximumQuantity, - widget.product.orderMinimumQuantity, - widget.product.stockQuantity, - widget.product), + bottomSheet: footerWidget(widget.product.stockAvailability != 'Out of stock', widget.product.orderMaximumQuantity, + widget.product.orderMinimumQuantity, widget.product.stockQuantity, widget.product), ); } } @@ -1000,8 +796,7 @@ class footerWidget extends StatefulWidget { final int minQuantity; final int quantityLimit; final PharmacyProduct item; - footerWidget(this.isAvailble, this.maxQuantity, this.minQuantity, - this.quantityLimit, this.item); + footerWidget(this.isAvailble, this.maxQuantity, this.minQuantity, this.quantityLimit, this.item); @override _footerWidgetState createState() => _footerWidgetState(); } @@ -1031,8 +826,7 @@ class _footerWidgetState extends State { padding: const EdgeInsets.all(8.0), child: Text( TranslationBase.of(context).quantity, - style: TextStyle( - fontSize: 15, fontWeight: FontWeight.bold), + style: TextStyle(fontSize: 15, fontWeight: FontWeight.bold), ), ), // ListView( @@ -1054,9 +848,7 @@ class _footerWidgetState extends State { color: Colors.white, child: Text( '1', - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 20), + style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20), ), ), onTap: () { @@ -1081,9 +873,7 @@ class _footerWidgetState extends State { color: Colors.white, child: Text( '2', - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 20), + style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20), ), ), onTap: () { @@ -1108,9 +898,7 @@ class _footerWidgetState extends State { color: Colors.white, child: Text( '3', - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 20), + style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20), ), ), onTap: () { @@ -1135,9 +923,7 @@ class _footerWidgetState extends State { color: Colors.white, child: Text( '4', - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 20), + style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20), ), ), onTap: () { @@ -1162,9 +948,7 @@ class _footerWidgetState extends State { color: Colors.white, child: Text( '5', - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 20), + style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20), ), ), onTap: () { @@ -1189,9 +973,7 @@ class _footerWidgetState extends State { color: Colors.white, child: Text( '6', - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 20), + style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20), ), ), onTap: () { @@ -1216,9 +998,7 @@ class _footerWidgetState extends State { color: Colors.white, child: Text( '7', - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 20), + style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20), ), ), onTap: () { @@ -1243,9 +1023,7 @@ class _footerWidgetState extends State { color: Colors.white, child: Text( '8', - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 20), + style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20), ), ), onTap: () { @@ -1270,9 +1048,7 @@ class _footerWidgetState extends State { color: Colors.white, child: Text( '9', - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 20), + style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20), ), ), onTap: () { @@ -1297,9 +1073,7 @@ class _footerWidgetState extends State { color: Colors.white, child: Text( '10', - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 20), + style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20), ), ), onTap: () { @@ -1320,8 +1094,7 @@ class _footerWidgetState extends State { Container( width: 50.0, child: TextField( - decoration: - InputDecoration(labelText: 'quantity #'), + decoration: InputDecoration(labelText: 'quantity #'), onChanged: (text) { print(price); print(widget.quantityLimit); @@ -1400,10 +1173,7 @@ class _footerWidgetState extends State { alignment: Alignment.center, child: Text( TranslationBase.of(context).addToCart, - style: TextStyle( - color: Colors.white, - fontWeight: FontWeight.bold, - fontSize: 15), + style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold, fontSize: 15), ), ), ) @@ -1418,10 +1188,7 @@ class _footerWidgetState extends State { color: Colors.green, child: Text( TranslationBase.of(context).addToCart, - style: TextStyle( - color: Colors.white, - fontWeight: FontWeight.bold, - fontSize: 15), + style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold, fontSize: 15), ), ), ), @@ -1437,10 +1204,7 @@ class _footerWidgetState extends State { alignment: Alignment.center, child: Text( TranslationBase.of(context).buyNow, - style: TextStyle( - color: Colors.white, - fontWeight: FontWeight.bold, - fontSize: 15), + style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold, fontSize: 15), ), ), ) @@ -1450,8 +1214,7 @@ class _footerWidgetState extends State { addToCartFunction(price, widget.item.id); Navigator.push( context, - MaterialPageRoute( - builder: (context) => CartOrderPage()), + MaterialPageRoute(builder: (context) => CartOrderPage()), ); }, child: Container( @@ -1461,10 +1224,7 @@ class _footerWidgetState extends State { color: Colors.blue, child: Text( TranslationBase.of(context).buyNow, - style: TextStyle( - color: Colors.white, - fontWeight: FontWeight.bold, - fontSize: 15), + style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold, fontSize: 15), ), ), ), @@ -1505,57 +1265,57 @@ class _productNameAndPriceState extends State { widget.item.stockAvailability, style: widget.item.stockAvailability == 'Out of stock' ? TextStyle(fontWeight: FontWeight.bold, color: Colors.red) - : TextStyle( - fontWeight: FontWeight.bold, color: Colors.green), + : TextStyle(fontWeight: FontWeight.bold, color: Colors.green), ), SizedBox(width: 20), - widget.item.stockAvailability == 'Out of stock' - ? Text( - TranslationBase.of(context).notifyMe, - style: TextStyle( - color: Colors.blue, - decoration: TextDecoration.underline, - ), - ) - : Container(), - widget.item.stockAvailability == 'Out of stock' - ? Icon( - FontAwesomeIcons.bell, - color: Colors.blue, - size: 15.0, + widget.item.stockAvailability == 'Out of stock' && customerId != null + ? InkWell( + onTap: () => notifyMeWhenAvailable(context, widget.item.id), + child: Row(children: [ + Text( + TranslationBase.of(context).notifyMe, + style: TextStyle( + color: Colors.blue, + decoration: TextDecoration.underline, + ), + ), + SizedBox(width: 4), + Icon( + FontAwesomeIcons.bell, + color: Colors.blue, + size: 15.0, + ) + ]), ) - : Container(), - Container( - margin: languageID == 'ar' - ? EdgeInsets.only(right: 25) - : EdgeInsets.only(left: 25), - width: 40, - height: 40, - decoration: BoxDecoration( - color: Colors.grey, - borderRadius: BorderRadius.circular(30), - ), - child: !isInWishlit - ? IconButton( - icon: Icon(Icons.favorite_border), - color: Colors.white, - onPressed: () { - setState(() { - addToWishlistFunction(widget.item.id); - }); + : Container( + margin: languageID == 'ar' ? EdgeInsets.only(right: 25) : EdgeInsets.only(left: 25), + width: 40, + height: 40, + decoration: BoxDecoration( + color: Colors.grey, + borderRadius: BorderRadius.circular(30), + ), + child: !isInWishlit + ? IconButton( + icon: Icon(Icons.favorite_border), + color: Colors.white, + onPressed: () { + setState(() { + addToWishlistFunction(widget.item.id); + }); // MyStatelessWidget(); - }, - ) - : IconButton( - icon: Icon(Icons.favorite), - color: Colors.red, - onPressed: () { - setState(() { - deleteFromWishlistFunction(widget.item.id); - }); + }, + ) + : IconButton( + icon: Icon(Icons.favorite), + color: Colors.red, + onPressed: () { + setState(() { + deleteFromWishlistFunction(widget.item.id); + }); // MyStatelessWidget(); - }, - )), + }, + )), ], ), ), @@ -1564,12 +1324,9 @@ class _productNameAndPriceState extends State { child: Container( margin: EdgeInsets.only(left: 5), child: Align( - alignment: - languageID == 'ar' ? Alignment.topRight : Alignment.topLeft, + alignment: languageID == 'ar' ? Alignment.topRight : Alignment.topLeft, child: Text( - languageID == 'ar' - ? widget.item.fullDescriptionn - : widget.item.fullDescription, + languageID == 'ar' ? widget.item.fullDescriptionn : widget.item.fullDescription, style: TextStyle(fontWeight: FontWeight.bold, fontSize: 15), ), ), @@ -1601,9 +1358,7 @@ class _productNameAndPriceState extends State { child: Container( child: widget.item.rxMessage != null ? Text( - languageID == 'ar' - ? widget.item.rxMessagen.toString() - : widget.item.rxMessage.toString(), + languageID == 'ar' ? widget.item.rxMessagen.toString() : widget.item.rxMessage.toString(), style: TextStyle(color: Colors.red, fontSize: 10), ) : Container()), @@ -1769,9 +1524,7 @@ slideDetail() { ), color: Colors.white, ), - child: const Text('1', - textAlign: TextAlign.center, - style: TextStyle(color: Color(0xFF000000))), + child: const Text('1', textAlign: TextAlign.center, style: TextStyle(color: Color(0xFF000000))), ), ) ], @@ -1801,6 +1554,11 @@ addToCartFunction(quantity, itemID) async { await x.addToCartData(quantity, itemID); } +notifyMeWhenAvailable(context, itemId) async { + ProductDetailViewModel x = new ProductDetailViewModel(); + await x.notifyMe(customerId, itemId); +} + addToWishlistFunction(itemID) async { ProductDetailViewModel x = new ProductDetailViewModel(); isInWishlit = true; @@ -1848,13 +1606,7 @@ settingModalBottomSheet(context) { leading: new Icon(Icons.shopping_cart), title: new Text('Add to cart'), onTap: () => { - if (price > 0) - {addToCartFunction(price, itemID)} - else - { - AppToast.showErrorToast( - message: "you should add quantity") - } + if (price > 0) {addToCartFunction(price, itemID)} else {AppToast.showErrorToast(message: "you should add quantity")} }), new ListTile( leading: new Icon(Icons.favorite_border), @@ -1865,8 +1617,7 @@ settingModalBottomSheet(context) { leading: new Icon(Icons.compare), title: new Text('Compare'), onTap: () => { - Provider.of(context, listen: false) - .addItem(specificationData), + Provider.of(context, listen: false).addItem(specificationData), }, ), ], @@ -1875,13 +1626,14 @@ settingModalBottomSheet(context) { }); } -userInfo(id, product) async { +Future userInfo(id, product) async { customerId = await sharedPref.getString(PHARMACY_CUSTOMER_ID); if (customerId != null) { itemID = id; product = product; checkWishlist(); } + print("customerId:$customerId"); return customerId; // getSpecificationData(itemID); } diff --git a/lib/pages/pharmacies/screens/cart-order-page.dart b/lib/pages/pharmacies/screens/cart-order-page.dart index cca6c1df..6926f9f4 100644 --- a/lib/pages/pharmacies/screens/cart-order-page.dart +++ b/lib/pages/pharmacies/screens/cart-order-page.dart @@ -27,7 +27,7 @@ class CartOrderPage extends StatelessWidget { value: model.cartResponse, child: AppScaffold( appBarTitle: TranslationBase.of(context).shoppingCart, - isShowAppBar: true, + isShowAppBar: false, isPharmacy: true, baseViewModel: model, backgroundColor: Colors.white, diff --git a/lib/pages/pharmacies/widgets/BannerPager.dart b/lib/pages/pharmacies/widgets/BannerPager.dart index 989c7557..b088eefb 100644 --- a/lib/pages/pharmacies/widgets/BannerPager.dart +++ b/lib/pages/pharmacies/widgets/BannerPager.dart @@ -1,5 +1,7 @@ import 'package:carousel_slider/carousel_slider.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/pharmacy_module_view_model.dart'; +import 'package:diplomaticquarterapp/pages/offers_categorise_page.dart'; +import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; import 'package:flutter/material.dart'; import 'package:diplomaticquarterapp/uitl/utils.dart'; @@ -39,20 +41,25 @@ class _BannerPagerState extends State { items: widget._model .getBannerImagesUrl() .mapIndexed( - (item, index) => Container( - margin: EdgeInsets.symmetric(horizontal: 1.0), - child: ClipRRect( - borderRadius: BorderRadius.all(Radius.circular(5.0)), - child: Center( - child: index == 0 - ? Image.asset( - item, - fit: BoxFit.cover, - ) - : Image.network( - item, - fit: BoxFit.cover, - ), + (item, index) => InkWell( + onTap: () { + Navigator.push(context, FadePage(page: OffersCategorisePage())); + }, + child: Container( + margin: EdgeInsets.symmetric(horizontal: 1.0), + child: ClipRRect( + borderRadius: BorderRadius.all(Radius.circular(5.0)), + child: Center( + child: index == 0 + ? Image.asset( + item, + fit: BoxFit.cover, + ) + : Image.network( + item, + fit: BoxFit.cover, + ), + ), ), ), ), diff --git a/lib/pages/pharmacy_categorise.dart b/lib/pages/pharmacy_categorise.dart index 06bba8c3..f0062a1c 100644 --- a/lib/pages/pharmacy_categorise.dart +++ b/lib/pages/pharmacy_categorise.dart @@ -29,9 +29,7 @@ class _PharmacyCategorisePageState extends State { ProjectViewModel projectViewModel = Provider.of(context); return BaseView( onModelReady: (model) => model.getCategorise(), - builder: (BuildContext context, PharmacyCategoriseViewModel model, - Widget child) => - AppScaffold( + builder: (BuildContext context, PharmacyCategoriseViewModel model, Widget child) => AppScaffold( isShowDecPage: false, baseViewModel: model, body: Column( @@ -59,9 +57,7 @@ class _PharmacyCategorisePageState extends State { child: Padding( padding: EdgeInsets.symmetric(horizontal: 10.0), child: Texts( - projectViewModel.isArabic - ? model.categorise[index].namen - : model.categorise[index].name, + projectViewModel.isArabic ? model.categorise[index].namen : model.categorise[index].name, fontWeight: FontWeight.w600, ), ), @@ -70,15 +66,14 @@ class _PharmacyCategorisePageState extends State { Navigator.push( context, MaterialPageRoute( - builder: (context) => - model.categorise[index].id != '12' - ? ParentCategorisePage( - id: model.categorise[index].id, - titleName: model.categorise[index].name, - ) - : FinalProductsPage( - id: model.categorise[index].id, - ), + builder: (context) => model.categorise[index].id != '12' + ? ParentCategorisePage( + id: model.categorise[index].id, + titleName: model.categorise[index].name, + ) + : FinalProductsPage( + id: model.categorise[index].id, + ), ), ), }, @@ -91,10 +86,7 @@ class _PharmacyCategorisePageState extends State { height: 140, child: Column( children: [ - Divider( - height: 2.0, - thickness: 1.0, - color: Colors.black12.withOpacity(0.14)), + Divider(height: 2.0, thickness: 1.0, color: Colors.black12.withOpacity(0.14)), SizedBox( height: 10.0, ), @@ -103,20 +95,21 @@ class _PharmacyCategorisePageState extends State { Expanded( child: Padding( padding: EdgeInsets.all(4.0), - child: Container( - height: 50.0, - width: 55.0, - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(5.0), - color: Colors.green.shade300.withOpacity(0.34), - ), - child: Padding( - padding: EdgeInsets.symmetric(horizontal: 10.0), - child: Texts( - projectViewModel.isArabic - ? 'الاكثر مبيعا' - : 'Best Sellers', - fontWeight: FontWeight.w600, + child: InkWell( + onTap: () {}, + child: Container( + height: 50.0, + width: 55.0, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(5.0), + color: Colors.green.shade300.withOpacity(0.34), + ), + child: Padding( + padding: EdgeInsets.symmetric(horizontal: 10.0), + child: Texts( + projectViewModel.isArabic ? 'الاكثر مبيعا' : 'Best Sellers', + fontWeight: FontWeight.w600, + ), ), ), ), @@ -129,16 +122,13 @@ class _PharmacyCategorisePageState extends State { height: 50.0, width: 55.0, decoration: BoxDecoration( - color: Colors.orangeAccent.shade200 - .withOpacity(0.34), + color: Colors.orangeAccent.shade200.withOpacity(0.34), borderRadius: BorderRadius.circular(5.0), ), child: Padding( padding: EdgeInsets.symmetric(horizontal: 10.0), child: Texts( - projectViewModel.isArabic - ? 'الاكثر مشاهدة' - : 'Most Viewed', + projectViewModel.isArabic ? 'الاكثر مشاهدة' : 'Most Viewed', fontWeight: FontWeight.w600, ), ), @@ -162,9 +152,7 @@ class _PharmacyCategorisePageState extends State { child: Padding( padding: EdgeInsets.symmetric(horizontal: 10.0), child: Texts( - projectViewModel.isArabic - ? 'منتجات جديدة' - : 'New Products', + projectViewModel.isArabic ? 'منتجات جديدة' : 'New Products', fontWeight: FontWeight.w600, ), ), @@ -182,17 +170,13 @@ class _PharmacyCategorisePageState extends State { height: 50.0, width: 55.0, decoration: BoxDecoration( - color: - Colors.purple.shade200.withOpacity(0.34), + color: Colors.purple.shade200.withOpacity(0.34), borderRadius: BorderRadius.circular(5.0), ), child: Padding( - padding: - EdgeInsets.symmetric(horizontal: 10.0), + padding: EdgeInsets.symmetric(horizontal: 10.0), child: Texts( - projectViewModel.isArabic - ? 'شوهد مؤخرا' - : 'Recently Viewed', + projectViewModel.isArabic ? 'شوهد مؤخرا' : 'Recently Viewed', fontWeight: FontWeight.w600, ), ), @@ -220,7 +204,7 @@ class _PharmacyCategorisePageState extends State { /// int patientID = get from qr result String result = await BarcodeScanner.scan(); var data = json.decode(result); - if (data!=null) { + if (data != null) { var qRParkingID = data['QRParkingID']; await model.scanQr(); if (model.state == ViewState.ErrorLocal) { diff --git a/lib/services/pharmacy_services/product_detail_service.dart b/lib/services/pharmacy_services/product_detail_service.dart index 7a2947b0..b974e1b1 100644 --- a/lib/services/pharmacy_services/product_detail_service.dart +++ b/lib/services/pharmacy_services/product_detail_service.dart @@ -102,20 +102,24 @@ class ProductDetailService extends BaseService { }, body: request); } + Future notifyMe(customerId, itemID) async { + hasError = false; + await baseAppClient.get(SUBSCRIBE_PRODUCT + "SinceId=$customerId&ProductId=$itemID", onSuccess: (dynamic response, int statusCode) { + AppToast.showSuccessToast(message: 'You will be notified when product available'); + }, onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + AppToast.showErrorToast(message: 'something went wrong please try again'); + }); + } + Future addToWishlist(itemID) async { var customerId = await sharedPref.getString(PHARMACY_CUSTOMER_ID); hasError = false; Map request; request = { - "shopping_cart_item": - { - "quantity": 1, - "shopping_cart_type": "Wishlist", - "product_id": itemID, - "customer_id": customerId, - "language_id": 1 - } + "shopping_cart_item": {"quantity": 1, "shopping_cart_type": "Wishlist", "product_id": itemID, "customer_id": customerId, "language_id": 1} }; await baseAppClient.post(GET_SHOPPING_CART, onSuccess: (dynamic response, int statusCode) {