diff --git a/lib/config/config.dart b/lib/config/config.dart index be71b6aa..f173e6ab 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -14,6 +14,7 @@ const PACKAGES_PRODUCTS = '/api/products'; const BASE_URL = 'https://uat.hmgwebservices.com/'; //const BASE_URL = 'https://hmgwebservices.com/'; +//const BASE_URL = 'https://.hmgwebservices.com/'; //const BASE_PHARMACY_URL = 'http://swd-pharapp-01:7200/api/'; const BASE_PHARMACY_URL = 'https://uat.hmgwebservices.com/epharmacy/api/'; @@ -91,6 +92,14 @@ const GET_PATIENT_VITAL_SIGN = const GET_NEAREST_HOSPITAL = 'Services/Patients.svc/REST/Patient_GetProjectAvgERWaitingTime'; +///ED Online +const ER_GET_VISUAL_TRIAGE_QUESTIONS = + "services/Doctors.svc/REST/ER_GetVisualTriageQuestions"; +const ER_SAVE_TRIAGE_INFORMATION = + "services/Doctors.svc/REST/ER_SaveTriageInformation"; +const ER_GetPatientPaymentInformationForERClinic = + "services/Doctors.svc/REST/ER_GetPatientPaymentInformationForERClinic"; + ///Er Nearest const GET_AMBULANCE_REQUEST = 'Services/Patients.svc/REST/PatientER_RRT_GetAllTransportationMethod'; @@ -563,6 +572,8 @@ const GET_SEARCH_PRODUCTS = const SCAN_QR_CODE = 'productbysku/'; +const FILTERED_PRODUCTS = 'products?categoryids='; + class AppGlobal { static var context; diff --git a/lib/config/localized_values.dart b/lib/config/localized_values.dart index 3217d084..6cc4ed83 100644 --- a/lib/config/localized_values.dart +++ b/lib/config/localized_values.dart @@ -1962,4 +1962,23 @@ const Map localizedValues = { "appointment-date": {"en": "Appointment Date", "ar": "تقرری کی تاریخ"}, "appointment-no": {"en": "Appointment No", "ar": "تقرری نمبر"}, "insurance-id": {"en": "Insurance ID", "ar": "انشورنس ID"}, + "onlineCheckInAgreement": { + "en": + "The online check-in is for non-life threatening situationCall the red crescent (number) or go to the nearest emergency department if there are:signs of stroke or heart attack history of seizure or syncope there is limb or life threatening injury picture of severe injuries​", + "ar": + "تسجيل الذهاب الى الطوارئ عبر الإنترنت هو فقط للحالات  التي لا تهدد الحياة يجب الاتصل بالهلال الأحمر (رقم) أو الذهاب إلى أقرب قسم طوارئ إذا كان هناك علامات السكتة الدماغية أو النوبة القلبية او هناك نوبة تشنج او حالة فقدان الوعي او وجود إصابة تهدد أحد الأطراف او تهدد الحياة او وجود إصابات خطيرة" + }, + "chiefComplaints": {"en": "Chief Complaints", "ar": "الشكوى الرئيسة"}, + "errorChiefComplaints": { + "en": "Please Chief Complaints", + "ar": "يرجى ادخال الشكوى الرئيسة" + }, + "errorExpectedArrivalTimes": { + "en": "Please Expected arrival time", + "ar": "يرجى ادخال الوقت المتوقع للوصول" + }, + "expectedArrivalTime": { + "en": "Expected arrival time", + "ar": "الوقت المتوقع للوصول" + }, }; diff --git a/lib/core/model/er/ErPatientShareModel.dart b/lib/core/model/er/ErPatientShareModel.dart new file mode 100644 index 00000000..4c6a4165 --- /dev/null +++ b/lib/core/model/er/ErPatientShareModel.dart @@ -0,0 +1,92 @@ +class ErPatientShareModel { + int cashPrice; + int cashPriceTax; + int cashPriceWithTax; + int companyId; + String companyName; + int companyShareWithTax; + dynamic errCode; + int groupID; + dynamic insurancePolicyNo; + String message; + dynamic patientCardID; + double patientShare; + double patientShareWithTax; + double patientTaxAmount; + int policyId; + String policyName; + String procedureName; + dynamic setupID; + int statusCode; + dynamic subPolicyNo; + + ErPatientShareModel( + {this.cashPrice, + this.cashPriceTax, + this.cashPriceWithTax, + this.companyId, + this.companyName, + this.companyShareWithTax, + this.errCode, + this.groupID, + this.insurancePolicyNo, + this.message, + this.patientCardID, + this.patientShare, + this.patientShareWithTax, + this.patientTaxAmount, + this.policyId, + this.policyName, + this.procedureName, + this.setupID, + this.statusCode, + this.subPolicyNo}); + + ErPatientShareModel.fromJson(Map json) { + cashPrice = json['CashPrice']; + cashPriceTax = json['CashPriceTax']; + cashPriceWithTax = json['CashPriceWithTax']; + companyId = json['CompanyId']; + companyName = json['CompanyName']; + companyShareWithTax = json['CompanyShareWithTax']; + errCode = json['ErrCode']; + groupID = json['GroupID']; + insurancePolicyNo = json['InsurancePolicyNo']; + message = json['Message']; + patientCardID = json['PatientCardID']; + patientShare = json['PatientShare']; + patientShareWithTax = json['PatientShareWithTax']; + patientTaxAmount = json['PatientTaxAmount']; + policyId = json['PolicyId']; + policyName = json['PolicyName']; + procedureName = json['ProcedureName']; + setupID = json['SetupID']; + statusCode = json['StatusCode']; + subPolicyNo = json['SubPolicyNo']; + } + + Map toJson() { + final Map data = new Map(); + data['CashPrice'] = this.cashPrice; + data['CashPriceTax'] = this.cashPriceTax; + data['CashPriceWithTax'] = this.cashPriceWithTax; + data['CompanyId'] = this.companyId; + data['CompanyName'] = this.companyName; + data['CompanyShareWithTax'] = this.companyShareWithTax; + data['ErrCode'] = this.errCode; + data['GroupID'] = this.groupID; + data['InsurancePolicyNo'] = this.insurancePolicyNo; + data['Message'] = this.message; + data['PatientCardID'] = this.patientCardID; + data['PatientShare'] = this.patientShare; + data['PatientShareWithTax'] = this.patientShareWithTax; + data['PatientTaxAmount'] = this.patientTaxAmount; + data['PolicyId'] = this.policyId; + data['PolicyName'] = this.policyName; + data['ProcedureName'] = this.procedureName; + data['SetupID'] = this.setupID; + data['StatusCode'] = this.statusCode; + data['SubPolicyNo'] = this.subPolicyNo; + return data; + } +} diff --git a/lib/core/model/er/TriageInformationRequest.dart b/lib/core/model/er/TriageInformationRequest.dart new file mode 100644 index 00000000..a9717d3d --- /dev/null +++ b/lib/core/model/er/TriageInformationRequest.dart @@ -0,0 +1,147 @@ +import 'package:diplomaticquarterapp/core/model/hospitals/hospitals_model.dart'; + +class TriageInformationRequest { + double versionID; + int channel; + int languageID; + String iPAdress; + String sessionID; + int patientID; + String tokenID; + String generalid; + int patientOutSA; + int patientTypeID; + int patientType; + int projectID; + ERTriageInformation eRTriageInformation; + HospitalsModel selectedHospital; + TriageInformationRequest( + {this.versionID, + this.channel, + this.languageID, + this.iPAdress, + this.sessionID, + this.patientID, + this.tokenID, + this.generalid, + this.patientOutSA, + this.patientTypeID, + this.patientType, + this.projectID, + this.eRTriageInformation,this.selectedHospital}); + + TriageInformationRequest.fromJson(Map json) { + versionID = json['VersionID']; + channel = json['Channel']; + languageID = json['LanguageID']; + iPAdress = json['IPAdress']; + sessionID = json['SessionID']; + patientID = json['PatientID']; + tokenID = json['TokenID']; + generalid = json['generalid']; + patientOutSA = json['PatientOutSA']; + patientTypeID = json['PatientTypeID']; + patientType = json['PatientType']; + projectID = json['ProjectID']; + eRTriageInformation = json['ERTriageInformation'] != null + ? new ERTriageInformation.fromJson(json['ERTriageInformation']) + : null; + } + + Map toJson() { + final Map data = new Map(); + data['VersionID'] = this.versionID; + data['Channel'] = this.channel; + data['LanguageID'] = this.languageID; + data['IPAdress'] = this.iPAdress; + data['SessionID'] = this.sessionID; + data['PatientID'] = this.patientID; + data['TokenID'] = this.tokenID; + data['generalid'] = this.generalid; + data['PatientOutSA'] = this.patientOutSA; + data['PatientTypeID'] = this.patientTypeID; + data['PatientType'] = this.patientType; + data['ProjectID'] = this.projectID; + if (this.eRTriageInformation != null) { + data['ERTriageInformation'] = this.eRTriageInformation.toJson(); + } + return data; + } +} + +class ERTriageInformation { + String notes; + String chiefComplaint; + int patientId; + int projectId; + int riskScore; + List checklist; + + ERTriageInformation( + {this.notes, + this.chiefComplaint, + this.patientId, + this.projectId, + this.riskScore, + this.checklist}); + + ERTriageInformation.fromJson(Map json) { + notes = json['Notes']; + chiefComplaint = json['ChiefComplaint']; + patientId = json['PatientId']; + projectId = json['ProjectId']; + riskScore = json['RiskScore']; + if (json['checklist'] != null) { + checklist = new List(); + json['checklist'].forEach((v) { + checklist.add(new Checklist.fromJson(v)); + }); + } + } + + Map toJson() { + final Map data = new Map(); + data['Notes'] = this.notes; + data['ChiefComplaint'] = this.chiefComplaint; + data['PatientId'] = this.patientId; + data['ProjectId'] = this.projectId; + data['RiskScore'] = this.riskScore; + if (this.checklist != null) { + data['checklist'] = this.checklist.map((v) => v.toJson()).toList(); + } + return data; + } +} + +class Checklist { + int isSelected; + int parameterCode; + int parameterGroup; + int parameterType; + int score; + + Checklist( + {this.isSelected, + this.parameterCode, + this.parameterGroup, + this.parameterType, + this.score}); + + Checklist.fromJson(Map json) { + isSelected = json['IsSelected']; + parameterCode = json['ParameterCode']; + parameterGroup = json['ParameterGroup']; + parameterType = json['ParameterType']; + score = json['Score']; + } + + Map toJson() { + final Map data = new Map(); + data['IsSelected'] = this.isSelected; + data['ParameterCode'] = this.parameterCode; + data['ParameterGroup'] = this.parameterGroup; + data['ParameterType'] = this.parameterType; + data['Score'] = this.score; + return data; + } +} diff --git a/lib/core/model/er/TriageQuestionsModel.dart b/lib/core/model/er/TriageQuestionsModel.dart new file mode 100644 index 00000000..8960973e --- /dev/null +++ b/lib/core/model/er/TriageQuestionsModel.dart @@ -0,0 +1,52 @@ +class TriageQuestionsModel { + String adultPoints; + String headerSequence; + int parameterCode; + int parameterGroup; + int parameterType; + String pediaPoints; + String question; + String questionN; + String scoreGroup; + String titles; + + TriageQuestionsModel( + {this.adultPoints, + this.headerSequence, + this.parameterCode, + this.parameterGroup, + this.parameterType, + this.pediaPoints, + this.question, + this.questionN, + this.scoreGroup, + this.titles}); + + TriageQuestionsModel.fromJson(Map json) { + adultPoints = json['AdultPoints']; + headerSequence = json['HeaderSequence']; + parameterCode = json['ParameterCode']; + parameterGroup = json['ParameterGroup']; + parameterType = json['ParameterType']; + pediaPoints = json['PediaPoints']; + question = json['Question']; + questionN = json['QuestionN']; + scoreGroup = json['ScoreGroup']; + titles = json['Titles']; + } + + Map toJson() { + final Map data = new Map(); + data['AdultPoints'] = this.adultPoints; + data['HeaderSequence'] = this.headerSequence; + data['ParameterCode'] = this.parameterCode; + data['ParameterGroup'] = this.parameterGroup; + data['ParameterType'] = this.parameterType; + data['PediaPoints'] = this.pediaPoints; + data['Question'] = this.question; + data['QuestionN'] = this.questionN; + data['ScoreGroup'] = this.scoreGroup; + data['Titles'] = this.titles; + return data; + } +} diff --git a/lib/core/model/hospitals/hospitals_model.dart b/lib/core/model/hospitals/hospitals_model.dart index 264528c7..246de0b1 100644 --- a/lib/core/model/hospitals/hospitals_model.dart +++ b/lib/core/model/hospitals/hospitals_model.dart @@ -1,11 +1,11 @@ class HospitalsModel { String desciption; - Null desciptionN; + dynamic desciptionN; dynamic iD; String legalName; String legalNameN; String name; - Null nameN; + dynamic nameN; String phoneNumber; String setupID; dynamic distanceInKilometers; @@ -13,7 +13,7 @@ class HospitalsModel { String latitude; String longitude; dynamic mainProjectID; - Null projectOutSA; + dynamic projectOutSA; bool usingInDoctorApp; HospitalsModel( diff --git a/lib/core/model/pharmacies/PharmacyProduct.dart b/lib/core/model/pharmacies/PharmacyProduct.dart index c472cb4c..f69d035b 100644 --- a/lib/core/model/pharmacies/PharmacyProduct.dart +++ b/lib/core/model/pharmacies/PharmacyProduct.dart @@ -4,29 +4,29 @@ import 'PharmacyImageObject.dart'; import 'Reviews.dart'; class PharmacyProduct { - String id; + dynamic id; bool visibleIndividually; - String name; - String namen; - String shortDescription; - String shortDescriptionn; - String fullDescription; - String fullDescriptionn; + dynamic name; + dynamic namen; + dynamic shortDescription; + dynamic shortDescriptionn; + dynamic fullDescription; + dynamic fullDescriptionn; bool markasNew; bool showOnHomePage; - String metaKeywords; - String metaDescription; - String metaTitle; + dynamic metaKeywords; + dynamic metaDescription; + dynamic metaTitle; bool allowCustomerReviews; int approvedRatingSum; int notApprovedRatingSum; int approvedTotalReviews; int notApprovedTotalReviews; - String sku; + dynamic sku; bool isRx; bool prescriptionRequired; - String rxMessage; - String rxMessagen; + dynamic rxMessage; + dynamic rxMessagen; String manufacturerPartNumber; String gtin; bool isGiftCard; @@ -115,118 +115,117 @@ class PharmacyProduct { int vendorId; String seName; - PharmacyProduct( {this.id, - this.visibleIndividually, - this.name, - this.namen, - this.shortDescription, - this.shortDescriptionn, - this.fullDescription, - this.fullDescriptionn, - this.markasNew, - this.showOnHomePage, - this.metaKeywords, - this.metaDescription, - this.metaTitle, - this.allowCustomerReviews, - this.approvedRatingSum, - this.notApprovedRatingSum, - this.approvedTotalReviews, - this.notApprovedTotalReviews, - this.sku, - this.isRx, - this.prescriptionRequired, - this.rxMessage, - this.rxMessagen, - this.manufacturerPartNumber, - this.gtin, - this.isGiftCard, - this.requireOtherProducts, - this.automaticallyAddRequiredProducts, - this.isDownload, - this.unlimitedDownloads, - this.maxNumberOfDownloads, - this.downloadExpirationDays, - this.hasSampleDownload, - this.hasUserAgreement, - this.isRecurring, - this.recurringCycleLength, - this.recurringTotalCycles, - this.isRental, - this.rentalPriceLength, - this.isShipEnabled, - this.isFreeShipping, - this.shipSeparately, - this.additionalShippingCharge, - this.isTaxExempt, - this.isTelecommunicationsOrBroadcastingOrElectronicServices, - this.useMultipleWarehouses, - this.manageInventoryMethodId, - this.stockQuantity, - this.stockAvailability, - this.stockAvailabilityn, - this.displayStockAvailability, - this.displayStockQuantity, - this.minStockQuantity, - this.notifyAdminForQuantityBelow, - this.allowBackInStockSubscriptions, - this.orderMinimumQuantity, - this.orderMaximumQuantity, - this.allowedQuantities, - this.allowAddingOnlyExistingAttributeCombinations, - this.disableBuyButton, - this.disableWishlistButton, - this.availableForPreOrder, - this.preOrderAvailabilityStartDateTimeUtc, - this.callForPrice, - this.price, - this.oldPrice, - this.productCost, - this.specialPrice, - this.specialPriceStartDateTimeUtc, - this.specialPriceEndDateTimeUtc, - this.customerEntersPrice, - this.minimumCustomerEnteredPrice, - this.maximumCustomerEnteredPrice, - this.basepriceEnabled, - this.basepriceAmount, - this.basepriceBaseAmount, - this.hasTierPrices, - this.hasDiscountsApplied, - this.discountName, - this.discountNamen, - this.discountDescription, - this.discountDescriptionn, - this.discountPercentage, - this.currency, - this.currencyn, - this.weight, - this.length, - this.width, - this.height, - this.availableStartDateTimeUtc, - this.availableEndDateTimeUtc, - this.displayOrder, - this.published, - this.deleted, - this.createdOnUtc, - this.updatedOnUtc, - this.productType, - this.parentGroupedProductId, - this.roleIds, - this.discountIds, - this.storeIds, - this.manufacturerIds, - this.reviews, - this.images, - this.attributes, - this.specifications, - this.associatedProductIds, - this.tags, - this.vendorId, - this.seName}); + this.visibleIndividually, + this.name, + this.namen, + this.shortDescription, + this.shortDescriptionn, + this.fullDescription, + this.fullDescriptionn, + this.markasNew, + this.showOnHomePage, + this.metaKeywords, + this.metaDescription, + this.metaTitle, + this.allowCustomerReviews, + this.approvedRatingSum, + this.notApprovedRatingSum, + this.approvedTotalReviews, + this.notApprovedTotalReviews, + this.sku, + this.isRx, + this.prescriptionRequired, + this.rxMessage, + this.rxMessagen, + this.manufacturerPartNumber, + this.gtin, + this.isGiftCard, + this.requireOtherProducts, + this.automaticallyAddRequiredProducts, + this.isDownload, + this.unlimitedDownloads, + this.maxNumberOfDownloads, + this.downloadExpirationDays, + this.hasSampleDownload, + this.hasUserAgreement, + this.isRecurring, + this.recurringCycleLength, + this.recurringTotalCycles, + this.isRental, + this.rentalPriceLength, + this.isShipEnabled, + this.isFreeShipping, + this.shipSeparately, + this.additionalShippingCharge, + this.isTaxExempt, + this.isTelecommunicationsOrBroadcastingOrElectronicServices, + this.useMultipleWarehouses, + this.manageInventoryMethodId, + this.stockQuantity, + this.stockAvailability, + this.stockAvailabilityn, + this.displayStockAvailability, + this.displayStockQuantity, + this.minStockQuantity, + this.notifyAdminForQuantityBelow, + this.allowBackInStockSubscriptions, + this.orderMinimumQuantity, + this.orderMaximumQuantity, + this.allowedQuantities, + this.allowAddingOnlyExistingAttributeCombinations, + this.disableBuyButton, + this.disableWishlistButton, + this.availableForPreOrder, + this.preOrderAvailabilityStartDateTimeUtc, + this.callForPrice, + this.price, + this.oldPrice, + this.productCost, + this.specialPrice, + this.specialPriceStartDateTimeUtc, + this.specialPriceEndDateTimeUtc, + this.customerEntersPrice, + this.minimumCustomerEnteredPrice, + this.maximumCustomerEnteredPrice, + this.basepriceEnabled, + this.basepriceAmount, + this.basepriceBaseAmount, + this.hasTierPrices, + this.hasDiscountsApplied, + this.discountName, + this.discountNamen, + this.discountDescription, + this.discountDescriptionn, + this.discountPercentage, + this.currency, + this.currencyn, + this.weight, + this.length, + this.width, + this.height, + this.availableStartDateTimeUtc, + this.availableEndDateTimeUtc, + this.displayOrder, + this.published, + this.deleted, + this.createdOnUtc, + this.updatedOnUtc, + this.productType, + this.parentGroupedProductId, + this.roleIds, + this.discountIds, + this.storeIds, + this.manufacturerIds, + this.reviews, + this.images, + this.attributes, + this.specifications, + this.associatedProductIds, + this.tags, + this.vendorId, + this.seName}); PharmacyProduct.fromJson(Map json) { id = json['id']; @@ -257,7 +256,7 @@ class PharmacyProduct { isGiftCard = json['is_gift_card']; requireOtherProducts = json['require_other_products']; automaticallyAddRequiredProducts = - json['automatically_add_required_products']; + json['automatically_add_required_products']; isDownload = json['is_download']; unlimitedDownloads = json['unlimited_downloads']; maxNumberOfDownloads = json['max_number_of_downloads']; @@ -275,7 +274,7 @@ class PharmacyProduct { additionalShippingCharge = json['additional_shipping_charge']; isTaxExempt = json['is_tax_exempt']; isTelecommunicationsOrBroadcastingOrElectronicServices = - json['is_telecommunications_or_broadcasting_or_electronic_services']; + json['is_telecommunications_or_broadcasting_or_electronic_services']; useMultipleWarehouses = json['use_multiple_warehouses']; manageInventoryMethodId = json['manage_inventory_method_id']; stockQuantity = json['stock_quantity']; @@ -290,12 +289,12 @@ class PharmacyProduct { orderMaximumQuantity = json['order_maximum_quantity']; allowedQuantities = json['allowed_quantities']; allowAddingOnlyExistingAttributeCombinations = - json['allow_adding_only_existing_attribute_combinations']; + json['allow_adding_only_existing_attribute_combinations']; disableBuyButton = json['disable_buy_button']; disableWishlistButton = json['disable_wishlist_button']; availableForPreOrder = json['available_for_pre_order']; preOrderAvailabilityStartDateTimeUtc = - json['pre_order_availability_start_date_time_utc']; + json['pre_order_availability_start_date_time_utc']; callForPrice = json['call_for_price']; price = json['price']; oldPrice = json['old_price']; diff --git a/lib/core/service/client/base_app_client.dart b/lib/core/service/client/base_app_client.dart index abfa7594..eb6e6850 100644 --- a/lib/core/service/client/base_app_client.dart +++ b/lib/core/service/client/base_app_client.dart @@ -31,6 +31,7 @@ AuthenticatedUserObject authenticatedUserObject = VitalSignService _vitalSignService = locator(); class BaseAppClient { + post(String endPoint, {Map body, Function(dynamic response, int statusCode) onSuccess, @@ -132,7 +133,198 @@ class BaseAppClient { if (statusCode < 200 || statusCode >= 400 || json == null) { onFailure('Error While Fetching data', statusCode); } else { - var parsed = json.decode(response.body.toString()); + // var parsed = json.decode(response.body.toString()); + var parsed = json.decode(utf8.decode(response.bodyBytes)); + if (parsed['Response_Message'] != null) { + onSuccess(parsed, statusCode); + } else { + if (parsed['ErrorType'] == 4) { + navigateToAppUpdate( + AppGlobal.context, parsed['ErrorEndUserMessage']); + } + if (isAllowAny) { + onSuccess(parsed, statusCode); + } else if (parsed['IsAuthenticated'] == null) { + if (parsed['isSMSSent'] == true) { + onSuccess(parsed, statusCode); + } else if (parsed['MessageStatus'] == 1) { + onSuccess(parsed, statusCode); + } else if (parsed['Result'] == 'OK') { + onSuccess(parsed, statusCode); + } else { + if (parsed != null) { + onSuccess(parsed, statusCode); + } else { + onFailure( + parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage'], + statusCode); + logout(); + } + } + } else if (parsed['MessageStatus'] == 1 || + parsed['SMSLoginRequired'] == true) { + onSuccess(parsed, statusCode); + } else if (parsed['MessageStatus'] == 2 && + parsed['IsAuthenticated']) { + if (parsed['SameClinicApptList'] != null) { + onSuccess(parsed, statusCode); + } else { + if (parsed['message'] == null && + parsed['ErrorEndUserMessage'] == null) { + if (parsed['ErrorSearchMsg'] == null) { + onFailure("Server Error found with no available message", + statusCode); + } else { + onFailure(parsed['ErrorSearchMsg'], statusCode); + } + } else { + onFailure( + parsed['message'] ?? + parsed['ErrorEndUserMessage'] ?? + parsed['ErrorMessage'], + statusCode); + } + } + } else if (!parsed['IsAuthenticated']) { + await logout(); + + //helpers.showErrorToast('Your session expired Please login agian'); + } else { + if (parsed['SameClinicApptList'] != null) { + onSuccess(parsed, statusCode); + } else { + if (parsed['message'] != null) { + onFailure(parsed['message'] ?? parsed['message'], statusCode); + } else { + onFailure( + parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage'], + statusCode); + } + } + } + } + } + } else { + onFailure('Please Check The Internet Connection', -1); + } + } catch (e) { + print(e); + onFailure(e.toString(), -1); + } + } + + postPharmacy(String endPoint, + {Map body, + Function(dynamic response, int statusCode) onSuccess, + Function(String error, int statusCode) onFailure, + bool isAllowAny = false, + bool isExternal = false}) async { + + var token = await sharedPref.getString(PHARMACY_AUTORZIE_TOKEN); + var user = await sharedPref.getObject(USER_PROFILE); + String url; + if (isExternal) { + url = endPoint; + } else { + url = PHARMACY_BASE_URL + endPoint; + } + try { + //Map profile = await sharedPref.getObj(DOCTOR_PROFILE); + var pharmacyToken = await sharedPref.getString(PHARMACY_AUTORZIE_TOKEN); + var user = await sharedPref.getObject(USER_PROFILE); + Map headers = { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + 'Authorization': token ?? '', + 'Mobilenumber': user != null + ? getPhoneNumberWithoutZero(user['MobileNumber'].toString()) + : "", + 'Statictoken': 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9', + 'Username': user != null ? user['PatientID'].toString() : "", + }; + if (!isExternal) { + String token = await sharedPref.getString(TOKEN); + var languageID = + await sharedPref.getStringWithDefaultValue(APP_LANGUAGE, 'ar'); + if (body.containsKey('SetupID')) { + body['SetupID'] = body.containsKey('SetupID') + ? body['SetupID'] != null + ? body['SetupID'] + : SETUP_ID + : SETUP_ID; + } + + body['VersionID'] = VERSION_ID; + body['Channel'] = CHANNEL; + body['LanguageID'] = languageID == 'ar' ? 1 : 2; + + body['IPAdress'] = IP_ADDRESS; + body['generalid'] = GENERAL_ID; + body['PatientOutSA'] = body.containsKey('PatientOutSA') + ? body['PatientOutSA'] != null + ? body['PatientOutSA'] + : PATIENT_OUT_SA + : PATIENT_OUT_SA; + + if (body.containsKey('isDentalAllowedBackend')) { + body['isDentalAllowedBackend'] = + body.containsKey('isDentalAllowedBackend') + ? body['isDentalAllowedBackend'] != null + ? body['isDentalAllowedBackend'] + : IS_DENTAL_ALLOWED_BACKEND + : IS_DENTAL_ALLOWED_BACKEND; + } + + body['DeviceTypeID'] = DeviceTypeID; + + if (!body.containsKey('IsPublicRequest')) { + body['PatientType'] = body.containsKey('PatientType') + ? body['PatientType'] != null + ? body['PatientType'] + : user['PatientType'] != null + ? user['PatientType'] + : PATIENT_TYPE + : PATIENT_TYPE; + + body['PatientTypeID'] = body.containsKey('PatientTypeID') + ? body['PatientTypeID'] != null + ? body['PatientTypeID'] + : user['PatientType'] != null + ? user['PatientType'] + : PATIENT_TYPE_ID + : PATIENT_TYPE_ID; + if (user != null) { + body['TokenID'] = token; + body['PatientID'] = body['PatientID'] != null + ? body['PatientID'] + : user['PatientID']; + body['PatientOutSA'] = user['OutSA']; + body['SessionID'] = SESSION_ID; //getSe + headers = { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + 'Authorization': pharmacyToken, + 'Mobilenumber': user['MobileNumber'].toString(), + 'Statictoken': 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9', + 'Username': user['PatientID'].toString(), + }; + } + } + } + + print("URL : $url"); + print("Body : ${json.encode(body)}"); + + if (await Utils.checkConnection()) { + final response = await http.post(url.trim(), + body: json.encode(body), headers: headers); + final int statusCode = response.statusCode; + print("statusCode :$statusCode"); + if (statusCode < 200 || statusCode >= 400 || json == null) { + onFailure('Error While Fetching data', statusCode); + } else { + // var parsed = json.decode(response.body.toString()); + var parsed = json.decode(utf8.decode(response.bodyBytes)); if (parsed['Response_Message'] != null) { onSuccess(parsed, statusCode); } else { @@ -248,7 +440,8 @@ class BaseAppClient { if (statusCode < 200 || statusCode >= 400 || json == null) { onFailure('Error While Fetching data', statusCode); } else { - var parsed = json.decode(response.body.toString()); + // var parsed = json.decode(response.body.toString()); + var parsed = json.decode(utf8.decode(response.bodyBytes)); onSuccess(parsed, statusCode); } } else { @@ -280,7 +473,7 @@ class BaseAppClient { if (await Utils.checkConnection()) { final response = await http.get(url.trim(), headers: { - 'Content-Type': 'application/json', + 'Content-Type': 'text/html; charset=utf-8', 'Accept': 'application/json', 'Authorization': token ?? '', 'Mobilenumber': user != null @@ -295,8 +488,9 @@ class BaseAppClient { if (statusCode < 200 || statusCode >= 400 || json == null) { onFailure('Error While Fetching data', statusCode); } else { - var parsed = json.decode(response.body.toString()); - onSuccess(parsed, statusCode); + // var parsed = json.decode(response.body.toString()); + var bodyUtf = json.decode(utf8.decode(response.bodyBytes)); + onSuccess(bodyUtf, statusCode); } } else { onFailure('Please Check The Internet Connection', -1); @@ -481,7 +675,8 @@ class BaseAppClient { if (statusCode < 200 || statusCode >= 400 || json == null) { onFailure('Error While Fetching data', statusCode); } else { - var parsed = json.decode(response.body.toString()); + // var parsed = json.decode(response.body.toString()); + var parsed = json.decode(utf8.decode(response.bodyBytes)); if (parsed['Response_Message'] != null) { onSuccess(parsed, statusCode); } else { diff --git a/lib/core/service/er/EdOnlineServices.dart b/lib/core/service/er/EdOnlineServices.dart new file mode 100644 index 00000000..2df92d8a --- /dev/null +++ b/lib/core/service/er/EdOnlineServices.dart @@ -0,0 +1,96 @@ +import 'package:diplomaticquarterapp/config/config.dart'; +import 'package:diplomaticquarterapp/core/model/er/ErPatientShareModel.dart'; +import 'package:diplomaticquarterapp/core/model/er/TriageQuestionsModel.dart'; +import 'package:diplomaticquarterapp/core/service/base_service.dart'; + +class EdOnlineServices extends BaseService { + List triageQuestionsModelList = List(); + ErPatientShareModel erPatientShareModel; + + Future getQuestions() async { + hasError =false; + triageQuestionsModelList.clear(); + Map body = Map(); + body['ProjectID'] = 15; + await baseAppClient.post(ER_GET_VISUAL_TRIAGE_QUESTIONS, + onSuccess: (dynamic response, int statusCode) { + triageQuestionsModelList.clear(); + response['ER_TriageQuestionsList'].forEach((questions) { + triageQuestionsModelList.add(TriageQuestionsModel.fromJson(questions)); + }); + }, onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, body: body); + } + + + Future getPatientPaymentInformation({var id}) async { + hasError =false; + await baseAppClient.post(ER_GetPatientPaymentInformationForERClinic, + onSuccess: (dynamic response, int statusCode) { + erPatientShareModel = + ErPatientShareModel.fromJson(response['ER_PatientShare']); + }, onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, body: Map.from({"ProjectID":15,"ClinicID":10})); + } + + Future saveQuestionsInformation( + {String notes, + String chiefComplaint, + int projectId, + DateTime selectedTime, + List selectedQuestions}) async { + hasError =false; + Map body = Map(); + List checklist = List(); + + body['ProjectID'] = 15; + body['ProjectId'] = projectId; + int riskScore = 0; + + if (user.age > 14) { + selectedQuestions.forEach((element) { + int score = int.parse(element.adultPoints); + riskScore += score; + checklist.add(Map.from({ + "IsSelected": 1, + "ParameterCode": element.parameterCode, + "ParameterGroup": element.parameterGroup, + "ParameterType": element.parameterType, + "Score": score + })); + }); + } else { + selectedQuestions.forEach((element) { + int score = int.parse(element.pediaPoints); + riskScore += score; + checklist.add(Map.from({ + "IsSelected": 1, + "ParameterCode": element.parameterCode, + "ParameterGroup": element.parameterGroup, + "ParameterType": element.parameterType, + "Score": score + })); + }); + } + + body['ERTriageInformation'] = { + "Notes": notes, + "ChiefComplaint": chiefComplaint, + "PatientId": user.patientID, + "ProjectId": 15, + "RiskScore": riskScore, + "checklist": checklist.map((e) => e).toList() + }; + + await baseAppClient.post(ER_SAVE_TRIAGE_INFORMATION, + onSuccess: (dynamic response, int statusCode) {}, + onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, body: body); + } +} diff --git a/lib/core/service/parmacyModule/order-preview-service.dart b/lib/core/service/parmacyModule/order-preview-service.dart index 18cfa87e..0721bf59 100644 --- a/lib/core/service/parmacyModule/order-preview-service.dart +++ b/lib/core/service/parmacyModule/order-preview-service.dart @@ -3,6 +3,7 @@ import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; import 'package:diplomaticquarterapp/core/model/pharmacies/Addresses.dart'; import 'package:diplomaticquarterapp/core/model/pharmacies/LacumAccountInformation.dart'; import 'package:diplomaticquarterapp/core/model/pharmacies/ShoppingCart.dart'; +import 'package:diplomaticquarterapp/core/model/pharmacies/order_detail.dart'; import 'package:diplomaticquarterapp/core/model/pharmacies/payment-checkout-data.dart'; import 'package:diplomaticquarterapp/core/service/base_service.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart'; @@ -15,6 +16,7 @@ class OrderPreviewService extends BaseService { List addresses = List(); LacumAccountInformation lacumInformation; LacumAccountInformation lacumGroupInformation; + List orderList = List(); Future getAddresses() async { var customerId = await sharedPref.getString(PHARMACY_CUSTOMER_ID); @@ -42,13 +44,14 @@ class OrderPreviewService extends BaseService { dynamic localRes; hasError = false; try { - await baseAppClient.getPharmacy("$GET_SHIPPING_OPTIONS$customerId/${selectedAddress.id}", - onSuccess: (dynamic response, int statusCode) { - localRes = response['shipping_option'][0]; - }, onFailure: (String error, int statusCode) { - hasError = true; - super.error = error; - }, queryParams: queryParams); + await baseAppClient + .getPharmacy("$GET_SHIPPING_OPTIONS$customerId/${selectedAddress.id}", + onSuccess: (dynamic response, int statusCode) { + localRes = response['shipping_option'][0]; + }, onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, queryParams: queryParams); } catch (error) { throw error; } @@ -89,7 +92,7 @@ class OrderPreviewService extends BaseService { Map body = Map(); body["shopping_cart_item"] = choppingCartObject; - await baseAppClient.post("$GET_SHOPPING_CART$productId", + await baseAppClient.postPharmacy("$GET_SHOPPING_CART$productId", onSuccess: (response, statusCode) async { localRes = response; }, onFailure: (String error, int statusCode) { @@ -125,8 +128,9 @@ class OrderPreviewService extends BaseService { super.error = ""; dynamic localRes; - await baseAppClient.getPharmacy("$DELETE_SHOPPING_CART_ALL$customerId/ShoppingCart", - onSuccess: (response, statusCode) async { + await baseAppClient + .getPharmacy("$DELETE_SHOPPING_CART_ALL$customerId/ShoppingCart", + onSuccess: (response, statusCode) async { localRes = response; }, onFailure: (String error, int statusCode) { hasError = true; @@ -167,23 +171,24 @@ class OrderPreviewService extends BaseService { try { await baseAppClient.post(GET_LACUM_GROUP_INFORMATION, onSuccess: (response, statusCode) async { - lacumGroupInformation = LacumAccountInformation.fromJson(response); - }, onFailure: (String error, int statusCode) { - hasError = true; - super.error = error; - }, body: body); + lacumGroupInformation = LacumAccountInformation.fromJson(response); + }, onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, body: body); } catch (error) { throw error; } } - Future makeOrder(PaymentCheckoutData paymentCheckoutData, List shoppingCarts) async { + Future makeOrder(PaymentCheckoutData paymentCheckoutData, + List shoppingCarts) async { paymentCheckoutData.address.isChecked = true; hasError = false; super.error = ""; var languageID = - await sharedPref.getStringWithDefaultValue(APP_LANGUAGE, 'en'); + await sharedPref.getStringWithDefaultValue(APP_LANGUAGE, 'en'); var customerId = await sharedPref.getString(PHARMACY_CUSTOMER_ID); Map orderBody = Map(); @@ -192,10 +197,15 @@ class OrderPreviewService extends BaseService { orderBody['billing_address'] = paymentCheckoutData.address; orderBody['pick_up_in_store'] = false; orderBody['payment_method_system_name'] = "Payments.PayFort"; - orderBody['shipping_method'] = languageID == 'ar' ? paymentCheckoutData.shippingOption.namen : paymentCheckoutData.shippingOption.name ; - orderBody['shipping_rate_computation_method_system_name'] = paymentCheckoutData.shippingOption.shippingRateComputationMethodSystemName; - orderBody['customer_id'] = customerId; - orderBody['custom_values_xml'] = "PaymentOption:${getPaymentOptionName(paymentCheckoutData.paymentOption)}"; + orderBody['shipping_method'] = languageID == 'ar' + ? paymentCheckoutData.shippingOption.namen + : paymentCheckoutData.shippingOption.name; + orderBody['shipping_rate_computation_method_system_name'] = + paymentCheckoutData + .shippingOption.shippingRateComputationMethodSystemName; + orderBody['customer_id'] = int.parse(customerId); + orderBody['custom_values_xml'] = + "PaymentOption:${getPaymentOptionName(paymentCheckoutData.paymentOption)}"; orderBody['shippingOption'] = paymentCheckoutData.shippingOption; orderBody['shipping_address'] = paymentCheckoutData.address; orderBody['lakum_amount'] = paymentCheckoutData.usedLakumPoints; @@ -215,10 +225,15 @@ class OrderPreviewService extends BaseService { try { await baseAppClient.post(ORDER_SHOPPING_CART, onSuccess: (response, statusCode) async { - }, onFailure: (String error, int statusCode) { - hasError = true; - super.error = error; - }, body: body); + orderList.clear(); + response['orders'].forEach((item) { + orderList.add(OrderDetailModel.fromJson(item)); + print(response); + }); + }, onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, body: body); } catch (error) { throw error; } diff --git a/lib/core/service/pharmacy_categorise_service.dart b/lib/core/service/pharmacy_categorise_service.dart index 479fd25f..5ef3c1d1 100644 --- a/lib/core/service/pharmacy_categorise_service.dart +++ b/lib/core/service/pharmacy_categorise_service.dart @@ -27,8 +27,8 @@ class PharmacyCategoriseService extends BaseService { List get parentProductsList => _parentProductsList; //service four - List _subCategoriseList = List(); - List get subCategoriseList => _subCategoriseList; + List _subCategoriseList = List(); + List get subCategoriseList => _subCategoriseList; //service five List _subProductsList = List(); @@ -40,8 +40,8 @@ class PharmacyCategoriseService extends BaseService { //service 7 - List _brandsList = List(); - List get brandsList => _brandsList; + List _brandsList = List(); + List get brandsList => _brandsList; // service 8 @@ -112,14 +112,14 @@ class PharmacyCategoriseService extends BaseService { ); } - Future getBrands() async { + Future getBrands({String id}) async { hasError = false; _brandsList.clear(); await baseAppClient.getPharmacy( - GET_BRANDS_LIST, + GET_BRANDS_LIST + "$id" + "&fields=id,name,image,namen", onSuccess: (dynamic response, int statusCode) { response['manufacturer'].forEach((item) { - _brandsList.add(BrandsModel.fromJson(item)); + _brandsList.add(CategoriseParentModel.fromJson(item)); }); }, onFailure: (String error, int statusCode) { @@ -178,7 +178,7 @@ class PharmacyCategoriseService extends BaseService { endPoint, onSuccess: (dynamic response, int statusCode) { response['categories'].forEach((item) { - _subCategoriseList.add(SubCategoriesModel.fromJson(item)); + _subCategoriseList.add(CategoriseParentModel.fromJson(item)); }); }, onFailure: (String error, int statusCode) { @@ -291,4 +291,29 @@ class PharmacyCategoriseService extends BaseService { throw error; } } + + Future getFilteredProducts( + {String categoryId, String brandId, String min, String max}) async { + hasError = false; + String endPoint; + + _parentProductsList.clear(); + endPoint = FILTERED_PRODUCTS + + "$categoryId" + + "&manufacturerids=$brandId" + + "&price_min=$min" + + "&price_max=$max&page=1&limit=50"; + await baseAppClient.getPharmacy( + endPoint, + onSuccess: (dynamic response, int statusCode) { + response['products'].forEach((item) { + _parentProductsList.add(PharmacyProduct.fromJson(item)); + }); + }, + onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, + ); + } } diff --git a/lib/core/viewModels/er/EdOnlineViewModel.dart b/lib/core/viewModels/er/EdOnlineViewModel.dart new file mode 100644 index 00000000..1970a965 --- /dev/null +++ b/lib/core/viewModels/er/EdOnlineViewModel.dart @@ -0,0 +1,76 @@ +import 'package:diplomaticquarterapp/core/enum/viewstate.dart'; +import 'package:diplomaticquarterapp/core/model/er/ErPatientShareModel.dart'; +import 'package:diplomaticquarterapp/core/model/er/TriageQuestionsModel.dart'; +import 'package:diplomaticquarterapp/core/model/hospitals/hospitals_model.dart'; +import 'package:diplomaticquarterapp/core/service/er/EdOnlineServices.dart'; +import 'package:diplomaticquarterapp/core/service/hospital_service.dart'; +import 'package:diplomaticquarterapp/core/viewModels/base_view_model.dart'; + +import '../../../locator.dart'; + +class EdOnlineViewModel extends BaseViewModel { + HospitalService _hospitalService = locator(); + + EdOnlineServices _edOnlineServices = locator(); + + List get hospitals => _hospitalService.hospitals; + + List get triageQuestionsModelList => + _edOnlineServices.triageQuestionsModelList; + + ErPatientShareModel get erPatientShareModel => _edOnlineServices.erPatientShareModel; + + Future getHospitals() async { + if(_hospitalService.hospitals.isEmpty){ + setState(ViewState.Busy); + await _hospitalService.getHospitals(); + if (_hospitalService.hasError) { + error = _hospitalService.error; + setState(ViewState.Error); + } else + setState(ViewState.Idle); + } + } + + Future getQuestions() async { + if(_edOnlineServices.triageQuestionsModelList.isEmpty){ + setState(ViewState.Busy); + await _edOnlineServices.getQuestions(); + if (_edOnlineServices.hasError) { + error = _edOnlineServices.error; + setState(ViewState.Error); + } else + setState(ViewState.Idle); + } + } + + Future getPatientPaymentInformation({var id}) async { + setState(ViewState.Busy); + await _edOnlineServices.getPatientPaymentInformation(); + if (_edOnlineServices.hasError) { + error = _edOnlineServices.error; + setState(ViewState.Error); + } else + setState(ViewState.Idle); + } + + Future saveQuestionsInformation( + {String notes, + String chiefComplaint, + int projectId, + DateTime selectedTime, + List selectedQuestions}) async { + setState(ViewState.BusyLocal); + await _edOnlineServices.saveQuestionsInformation( + notes: notes, + projectId: projectId, + chiefComplaint: chiefComplaint, + selectedTime: selectedTime, + selectedQuestions: selectedQuestions); + if (_edOnlineServices.hasError) { + error = _edOnlineServices.error; + setState(ViewState.ErrorLocal); + } else + setState(ViewState.Idle); + } +} diff --git a/lib/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart b/lib/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart index 7272969b..1fa34ee2 100644 --- a/lib/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart +++ b/lib/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart @@ -5,8 +5,10 @@ import 'package:diplomaticquarterapp/core/model/pharmacies/LacumAccountInformati import 'package:diplomaticquarterapp/core/model/pharmacies/ShippingOption.dart'; import 'package:diplomaticquarterapp/core/model/pharmacies/ShoppingCart.dart'; import 'package:diplomaticquarterapp/core/model/pharmacies/ShoppingCartResponse.dart'; +import 'package:diplomaticquarterapp/core/model/pharmacies/order_detail.dart'; import 'package:diplomaticquarterapp/core/model/pharmacies/payment-checkout-data.dart'; import 'package:diplomaticquarterapp/core/service/parmacyModule/order-preview-service.dart'; +import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/pharmacy_module_view_model.dart'; import '../../../locator.dart'; import '../base_view_model.dart'; @@ -17,6 +19,11 @@ class OrderPreviewViewModel extends BaseViewModel { List get addresses => _orderService.addresses; LacumAccountInformation get lacumInformation => _orderService.lacumInformation; + List get orderListModel => _orderService.orderList; + + PharmacyModuleViewModel pharmacyModuleViewModel = + locator(); + ShoppingCartResponse cartResponse = ShoppingCartResponse(); PaymentCheckoutData paymentCheckoutData = PaymentCheckoutData(); double totalAdditionalShippingCharge = 0; @@ -32,7 +39,7 @@ class OrderPreviewViewModel extends BaseViewModel { } } - getShoppingCart() async { + Future getShoppingCart() async { setState(ViewState.Busy); await _orderService.getShoppingCart().then((res) { _handleGetShoppingCartResponse(res); @@ -48,20 +55,20 @@ class OrderPreviewViewModel extends BaseViewModel { } } - changeProductQuantity(ShoppingCart product) async { + Future changeProductQuantity(ShoppingCart product) async { setState(ViewState.Busy); await _orderService.changeProductQuantity(product.id, product).then((res) { _handleGetShoppingCartResponse(res); }); if (_orderService.hasError) { error = _orderService.error; - setState(ViewState.Error); + setState(ViewState.ErrorLocal); } else { setState(ViewState.Idle); } } - deleteProduct(ShoppingCart product) async { + Future deleteProduct(ShoppingCart product) async { setState(ViewState.Busy); await _orderService.deleteProduct(product.id).then((res) { _handleGetShoppingCartResponse(res); @@ -74,7 +81,7 @@ class OrderPreviewViewModel extends BaseViewModel { } } - deleteShoppingCart() async { + Future deleteShoppingCart() async { setState(ViewState.Busy); await _orderService.deleteShoppingCart().then((res) { _handleGetShoppingCartResponse(res); @@ -182,6 +189,8 @@ class OrderPreviewViewModel extends BaseViewModel { Future makeOrder() async { setState(ViewState.Busy); + await pharmacyModuleViewModel.generatePharmacyToken(); + await _orderService.makeOrder(paymentCheckoutData, cartResponse.shoppingCarts); if (_orderService.hasError) { error = _orderService.error; diff --git a/lib/core/viewModels/pharmacyModule/order_model_view_model.dart b/lib/core/viewModels/pharmacyModule/order_model_view_model.dart index 62bf00f4..208f8189 100644 --- a/lib/core/viewModels/pharmacyModule/order_model_view_model.dart +++ b/lib/core/viewModels/pharmacyModule/order_model_view_model.dart @@ -110,15 +110,16 @@ class OrderModelViewModel extends BaseViewModel { message: "Your review has been Submitted successfully"); } } + Future makeOrder() async { - setState(ViewState.Busy); + /* setState(ViewState.Busy); await _orderServices.makeOrder(paymentCheckoutData, cartResponse.shoppingCarts); if (_orderServices.hasError) { error = _orderServices.error; setState(ViewState.Error); } else { setState(ViewState.Idle); - } + }*/ } } diff --git a/lib/core/viewModels/pharmacyModule/pharmacy_module_view_model.dart b/lib/core/viewModels/pharmacyModule/pharmacy_module_view_model.dart index f38237e3..dcf09865 100644 --- a/lib/core/viewModels/pharmacyModule/pharmacy_module_view_model.dart +++ b/lib/core/viewModels/pharmacyModule/pharmacy_module_view_model.dart @@ -44,13 +44,14 @@ class PharmacyModuleViewModel extends BaseViewModel { // List get pharmacyPrescriptionsList => PharmacyProduct.pharmacyPrescriptionsList ; Future getPharmacyHomeData() async { - setState(ViewState.Busy); + await generatePharmacyToken(); + var data = await sharedPref.getObject(USER_PROFILE); var customerId = await sharedPref.getString(PHARMACY_CUSTOMER_ID); + setState(ViewState.Busy); if (authenticatedUserObject.isLogin && data != null && customerId == null) { await _pharmacyService.makeVerifyCustomer(data); - // here must call getShoppingCard() if (_pharmacyService.hasError) { error = _pharmacyService.error; setState(ViewState.Error); diff --git a/lib/core/viewModels/pharmacy_categorise_view_model.dart b/lib/core/viewModels/pharmacy_categorise_view_model.dart index c98eedd7..47f64688 100644 --- a/lib/core/viewModels/pharmacy_categorise_view_model.dart +++ b/lib/core/viewModels/pharmacy_categorise_view_model.dart @@ -29,7 +29,7 @@ class PharmacyCategoriseViewModel extends BaseViewModel { List get parentProducts => _pharmacyCategoriseService.parentProductsList; - List get subCategorise => + List get subCategorise => _pharmacyCategoriseService.subCategoriseList; List get subProducts => @@ -37,7 +37,8 @@ class PharmacyCategoriseViewModel extends BaseViewModel { List get finalProducts => _pharmacyCategoriseService.finalProducts; - List get brandsList => _pharmacyCategoriseService.brandsList; + List get brandsList => + _pharmacyCategoriseService.brandsList; List get searchList => _pharmacyCategoriseService.searchList; @@ -55,11 +56,11 @@ class PharmacyCategoriseViewModel extends BaseViewModel { setState(ViewState.Idle); } - Future getBrands() async { + Future getBrands({String id}) async { hasError = false; // _insuranceCardService.clearInsuranceCard(); setState(ViewState.Busy); - await _pharmacyCategoriseService.getBrands(); + await _pharmacyCategoriseService.getBrands(id: id); if (_pharmacyCategoriseService.hasError) { error = _pharmacyCategoriseService.error; setState(ViewState.ErrorLocal); @@ -105,7 +106,7 @@ class PharmacyCategoriseViewModel extends BaseViewModel { setState(ViewState.ErrorLocal); } else await getParentProducts(i: i); - await getBrands(); + await getBrands(id: i); } Future getParentProducts({String i}) async { @@ -156,6 +157,20 @@ class PharmacyCategoriseViewModel extends BaseViewModel { setState(ViewState.Idle); } + Future getFilteredProducts( + {String categoryId, String brandId, String min, String max}) async { + hasError = false; + // _insuranceCardService.clearInsuranceCard(); + setState(ViewState.Busy); + await _pharmacyCategoriseService.getFilteredProducts( + categoryId: categoryId, brandId: brandId, max: max, min: min); + if (_pharmacyCategoriseService.hasError) { + error = _pharmacyCategoriseService.error; + setState(ViewState.ErrorLocal); + } else + setState(ViewState.Idle); + } + Future getManufacturerProducts(String id) async { setState(ViewState.Busy); await _pharmacyCategoriseService.getManufacturerProducts(id); diff --git a/lib/locator.dart b/lib/locator.dart index 9bc077f7..1409cf5b 100644 --- a/lib/locator.dart +++ b/lib/locator.dart @@ -40,6 +40,7 @@ import 'core/service/childvaccines/vaccination_table_service.dart'; import 'core/service/contactus/finadus_service.dart'; import 'core/service/contactus/livechat_service.dart'; import 'core/service/dashboard_service.dart'; +import 'core/service/er/EdOnlineServices.dart'; import 'core/service/er/am_service.dart'; import 'core/service/er/er_service.dart'; import 'core/service/feedback/feedback_service.dart'; @@ -77,6 +78,7 @@ import 'core/service/parmacyModule/parmacy_module_service.dart'; import 'core/service/offers_service.dart'; import 'core/service/pharmacy_categorise_service.dart'; import 'core/viewModels/AlHabibMedicalService/health-calculator/Bariatrics-viewmodel.dart'; +import 'core/viewModels/er/EdOnlineViewModel.dart'; import 'core/viewModels/medical/PrescriptionDeliveryViewModel.dart'; import 'core/viewModels/TermsConditionsViewModel.dart'; import 'core/viewModels/all_habib_medical_services/e_referral_view_model.dart'; @@ -195,6 +197,8 @@ void setupLocator() { locator.registerLazySingleton(() => VaccinationTableService()); locator.registerLazySingleton(() => AncillaryOrdersService()); + locator.registerLazySingleton(() => EdOnlineServices()); + //pharmacy // locator.registerLazySingleton(() => PharmacyCategoriseService()); // locator.registerLazySingleton(() => OffersCategoriseService()); @@ -287,6 +291,7 @@ void setupLocator() { locator.registerFactory(() => LacumViewModel()); locator.registerFactory(() => LacumTranferViewModel()); locator.registerFactory(() => LacumRegistrationViewModel()); + locator.registerFactory(() => EdOnlineViewModel()); //pharmacy locator.registerFactory(() => PharmacyCategoriseViewModel()); diff --git a/lib/pages/ErService/EdOnline/ConfirmExitPageDialog.dart b/lib/pages/ErService/EdOnline/ConfirmExitPageDialog.dart new file mode 100644 index 00000000..1144e587 --- /dev/null +++ b/lib/pages/ErService/EdOnline/ConfirmExitPageDialog.dart @@ -0,0 +1,76 @@ +import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; +import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; + +class ConfirmExitPageDialog extends StatelessWidget { + final GestureTapCallback onTapYes; + final GestureTapCallback onTapNo; + + const ConfirmExitPageDialog({Key key, this.onTapYes, this.onTapNo}) + : super(key: key); + + @override + Widget build(BuildContext context) { + return SimpleDialog( + contentPadding: EdgeInsets.fromLTRB(28.0, 24.0, 28.0, 0.0), + title: Center( + child: Texts( + TranslationBase.of(context).confirm, + color: Colors.black, + ), + ), + children: [ + Column( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Texts( + "Are you sure you want to exit this page ?", + color: Colors.grey, + ), + SizedBox( + height: 5, + ), + Divider(), + SizedBox( + height: 5.0, + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + InkWell( + onTap: () { + onTapNo(); + }, + child: Container( + child: Center( + child: Texts( + TranslationBase.of(context).no, + color: Colors.red, + ), + ), + ), + ), + + InkWell( + onTap: () { + Navigator.pop(context); + onTapYes(); + }, + child: Container( + child: Center( + child: Texts(TranslationBase.of(context).yes), + ), + ), + ), + ], + ), + SizedBox( + height: 20.0, + ), + ], + ) + ], + ); + } +} diff --git a/lib/pages/ErService/EdOnline/DdServicesPage.dart b/lib/pages/ErService/EdOnline/DdServicesPage.dart new file mode 100644 index 00000000..7395b901 --- /dev/null +++ b/lib/pages/ErService/EdOnline/DdServicesPage.dart @@ -0,0 +1,120 @@ +import 'package:diplomaticquarterapp/core/model/er/TriageInformationRequest.dart'; +import 'package:diplomaticquarterapp/core/model/er/TriageQuestionsModel.dart'; +import 'package:diplomaticquarterapp/core/model/hospitals/hospitals_model.dart'; +import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; + +import 'EdOnlineAgreementPage.dart'; +import 'EdOnlineNotesPage.dart'; +import 'EdOnlineQuestionsPage.dart'; +import 'EdOnlineSelectedHospitalPage.dart'; +import 'EdPaymentInformationPage.dart'; +import 'ConfirmExitPageDialog.dart'; + +class DdServicesPage extends StatefulWidget { + @override + _DdServicesPageState createState() => _DdServicesPageState(); +} + +class _DdServicesPageState extends State { + PageController pageController; + + bool isAgree = false; + TriageInformationRequest triageInformationRequest = new TriageInformationRequest(); + + List selectedQuestions = List(); + + @override + void initState() { + super.initState(); + pageController = new PageController(); + + } + + _changePageViewIndex(int tab) { + setState(() { + pageController.jumpToPage(tab); + pageController.animateToPage(tab, + duration: Duration(milliseconds: 800), curve: Curves.easeOutQuart); + }); + } + + @override + Widget build(BuildContext context) { + ProjectViewModel projectViewModel = Provider.of(context); + return Scaffold( + appBar: AppBar( + elevation: 0, + textTheme: TextTheme( + headline6: TextStyle( + color: Theme.of(context).textTheme.headline1.color, + fontWeight: FontWeight.bold), + ), + title: Text( + 'ED Online', + style: TextStyle( + fontWeight: FontWeight.bold, + color: Theme.of(context).textTheme.headline1.color, + fontFamily: projectViewModel.isArabic ? 'Cairo' : 'WorkSans'), + // bold: true, + // color: Colors.white, + ), + leading: Builder( + builder: (BuildContext context) { + return IconButton( + icon: Icon(Icons.arrow_back), + color: Theme.of(context).textTheme.headline1.color, + onPressed: () { + showConfirmMessage(context); + }, + ); + }, + ), + centerTitle: true, + ), + body: PageView( + physics: NeverScrollableScrollPhysics(), + controller: pageController, + onPageChanged: _changePageViewIndex, + children: [ + EdOnlineSelectedHospitalPage( + changePageViewIndex: _changePageViewIndex, + triageInformationRequest: triageInformationRequest, + ), + EdOnlineAgreementPage( + changePageViewIndex: _changePageViewIndex, + isAgree: isAgree, + ), + EdOnlineQuestionsPage( + changePageViewIndex: _changePageViewIndex, + selectedQuestions: selectedQuestions, + ), + EdOnlineNotesPage( + changePageViewIndex: _changePageViewIndex, + selectedQuestions: selectedQuestions, + triageInformationRequest: triageInformationRequest, + ), + EdPaymentInformationPage(selectedHospital: triageInformationRequest.selectedHospital,) + ], + ), + ); + } + + void showConfirmMessage( + BuildContext context, + ) { + showDialog( + context: context, + child: ConfirmExitPageDialog( + onTapYes: () { + Navigator.pop(context); + }, + onTapNo: () { + Navigator.pop(context); + }, + ), + ); + } +} diff --git a/lib/pages/ErService/EdOnline/EdOnlineAgreementPage.dart b/lib/pages/ErService/EdOnline/EdOnlineAgreementPage.dart new file mode 100644 index 00000000..950dc2e0 --- /dev/null +++ b/lib/pages/ErService/EdOnline/EdOnlineAgreementPage.dart @@ -0,0 +1,99 @@ +import 'package:diplomaticquarterapp/core/model/hospitals/hospitals_model.dart'; +import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; +import 'package:diplomaticquarterapp/widgets/buttons/secondary_button.dart'; +import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; +import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; + +class EdOnlineAgreementPage extends StatefulWidget { + final HospitalsModel selectedHospital; + final Function changePageViewIndex; + bool isAgree; + EdOnlineAgreementPage({Key key, this.selectedHospital, this.changePageViewIndex,this.isAgree}) : super(key: key); + + @override + _EdOnlineAgreementPageState createState() => _EdOnlineAgreementPageState(); +} + +class _EdOnlineAgreementPageState extends State { + + + @override + Widget build(BuildContext context) { + return AppScaffold( + body: SingleChildScrollView( + physics: BouncingScrollPhysics(), + child: Column( + children: [ + SizedBox(), + InkWell( + onTap: (){ + setState(() { + widget.isAgree = !widget.isAgree; + }); + }, + child: Row( + children: [ + Checkbox( + value: widget.isAgree, + activeColor: Colors.red[800], + onChanged: (bool newValue) { + setState(() { + widget.isAgree = !widget.isAgree; + }); + }), + Expanded( + child: Padding( + padding: const EdgeInsets.all(20.0), + child: Texts( + TranslationBase.of(context).onlineCheckInAgreement, + fontSize: 15, + ), + ), + ), + ], + ), + ), + SizedBox(), + ], + ), + ), + bottomSheet: Padding( + padding: const EdgeInsets.all(8.0), + child: Container( + height: 56, + child: Row( + children: [ + Expanded( + child: Container( + margin: EdgeInsets.only(left: 5,right: 5), + child: SecondaryButton( + textColor: Colors.white, + color: Theme.of(context).primaryColor, + label: TranslationBase.of(context).back.toUpperCase(), + onTap: () => widget.changePageViewIndex(0), + ), + ), + ), + SizedBox(width: 10,), + Expanded( + child: Container( + margin: EdgeInsets.only(left: 5,right: 5), + child: SecondaryButton( + textColor: Colors.white, + color: Theme.of(context).primaryColor, + label: TranslationBase.of(context).next.toUpperCase(), + disabled: !widget.isAgree, + onTap: () => widget.changePageViewIndex(2), + ), + ), + ), + + ], + ), + ), + ), + ); + } +} diff --git a/lib/pages/ErService/EdOnline/EdOnlineNotesPage.dart b/lib/pages/ErService/EdOnline/EdOnlineNotesPage.dart new file mode 100644 index 00000000..45df4041 --- /dev/null +++ b/lib/pages/ErService/EdOnline/EdOnlineNotesPage.dart @@ -0,0 +1,177 @@ +import 'package:diplomaticquarterapp/core/enum/viewstate.dart'; +import 'package:diplomaticquarterapp/core/model/er/TriageInformationRequest.dart'; +import 'package:diplomaticquarterapp/core/model/er/TriageQuestionsModel.dart'; +import 'package:diplomaticquarterapp/core/model/hospitals/hospitals_model.dart'; +import 'package:diplomaticquarterapp/core/viewModels/er/EdOnlineViewModel.dart'; +import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; +import 'package:diplomaticquarterapp/pages/Blood/new_text_Field.dart'; +import 'package:diplomaticquarterapp/pages/base/base_view.dart'; +import 'package:diplomaticquarterapp/uitl/app_toast.dart'; +import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; +import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; +import 'package:diplomaticquarterapp/widgets/buttons/secondary_button.dart'; +import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; +import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_datetime_picker/flutter_datetime_picker.dart'; +import 'package:provider/provider.dart'; + +class EdOnlineNotesPage extends StatefulWidget { + final List selectedQuestions; + final Function changePageViewIndex; + TriageInformationRequest triageInformationRequest; + EdOnlineNotesPage( + {Key key, this.selectedQuestions, this.changePageViewIndex,this.triageInformationRequest}) + ; + + @override + _EdOnlineNotesPageState createState() => _EdOnlineNotesPageState(); +} + +class _EdOnlineNotesPageState extends State { + TextEditingController _chiefComplaintsTextController = + TextEditingController(); + TextEditingController _noteTextController = TextEditingController(); + DateTime selectedTime; + final _formKey = GlobalKey(); + + @override + Widget build(BuildContext context) { + ProjectViewModel projectViewModel = Provider.of(context); + return BaseView( + builder: (_, model, w) => AppScaffold( + baseViewModel: model, + body: SingleChildScrollView( + physics: BouncingScrollPhysics(), + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Column( + children: [ + Form( + key: _formKey, + child: NewTextFields( + controller: _chiefComplaintsTextController, + maxLines: 15, + minLines: 5, + hintText: TranslationBase.of(context).chiefComplaints, + validator: (value) { + if (value.isEmpty) return TranslationBase.of(context).errorChiefComplaints; + return null; + }, + ), + ), + SizedBox( + height: 8, + ), + InkWell( + onTap: () { + DatePicker.showDateTimePicker( + context, + showTitleActions: true, + minTime: DateTime.now(), + maxTime: DateTime.now().add(Duration(hours: 24)), + onConfirm: (date) { + setState(() { + selectedTime = date; + }); + }, + currentTime: DateTime.now(), + locale: projectViewModel.localeType, + ); + }, + child: Container( + padding: EdgeInsets.all(12), + width: double.infinity, + // height: 65, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(12), + color: Colors.white), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Texts(selectedTime == null ?TranslationBase.of(context).errorExpectedArrivalTime:TranslationBase.of(context).expectedArrivalTime), + Texts(getDate(context)), + ], + ), + ), + ), + SizedBox( + height: 8, + ), + NewTextFields( + controller: _noteTextController, + maxLines: 15, + minLines: 5, + hintText: TranslationBase.of(context).notes, + ), + ], + ), + ), + ), + bottomSheet: Container( + height: 56, + margin: EdgeInsets.only(bottom: 5), + width: double.infinity, + child: Row( + children: [ + Expanded( + child: Container( + margin: EdgeInsets.only(left: 5,right: 5), + child: SecondaryButton( + textColor: Colors.white, + color: Theme.of(context).primaryColor, + label: TranslationBase.of(context).back.toUpperCase(), + onTap: () => widget.changePageViewIndex(2), + ), + ), + ), + SizedBox(width: 10,), + Expanded( + child: Container( + margin: EdgeInsets.only(left: 5,right: 5), + child: SecondaryButton( + textColor: Colors.white, + color: Theme.of(context).primaryColor, + label: TranslationBase.of(context).save.toUpperCase(), + disabled: selectedTime == null, + onTap: () async { + if (_formKey.currentState.validate()) { + GifLoaderDialogUtils.showMyDialog(context); + model.saveQuestionsInformation( + chiefComplaint: + _chiefComplaintsTextController.text.toString(), + notes: _noteTextController.text.toString(), + selectedQuestions: widget.selectedQuestions, + projectId: widget.triageInformationRequest.projectID,selectedTime: selectedTime).then((value) { + GifLoaderDialogUtils.hideDialog(context); + if(model.state == ViewState.ErrorLocal) + AppToast.showErrorToast(message: model.error); + else + { + widget.changePageViewIndex(4); + } + + }).catchError((onError){ + GifLoaderDialogUtils.hideDialog(context); + AppToast.showErrorToast(message: onError.toString()); + }); + } + }), + ), + ), + ], + ), + ), + ), + ); + } + + getDate(BuildContext context) { + String message = ""; + if (selectedTime != null) { + message = "${selectedTime.hour}:${selectedTime.minute}"; + } + return message; + } +} diff --git a/lib/pages/ErService/EdOnline/EdOnlineQuestionsPage.dart b/lib/pages/ErService/EdOnline/EdOnlineQuestionsPage.dart new file mode 100644 index 00000000..e3eb1c4c --- /dev/null +++ b/lib/pages/ErService/EdOnline/EdOnlineQuestionsPage.dart @@ -0,0 +1,127 @@ +import 'package:diplomaticquarterapp/core/model/er/TriageQuestionsModel.dart'; +import 'package:diplomaticquarterapp/core/model/hospitals/hospitals_model.dart'; +import 'package:diplomaticquarterapp/core/viewModels/er/EdOnlineViewModel.dart'; +import 'package:diplomaticquarterapp/pages/base/base_view.dart'; +import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; +import 'package:diplomaticquarterapp/widgets/buttons/secondary_button.dart'; +import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; +import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; + +// ignore: must_be_immutable +class EdOnlineQuestionsPage extends StatefulWidget { + final HospitalsModel selectedHospital; + final Function changePageViewIndex; + List selectedQuestions; + + EdOnlineQuestionsPage({Key key, this.selectedHospital,this.selectedQuestions, this.changePageViewIndex}); + + + @override + _EdOnlineQuestionsPageState createState() => _EdOnlineQuestionsPageState(); +} + +class _EdOnlineQuestionsPageState extends State { + + + @override + Widget build(BuildContext context) { + return BaseView( + onModelReady: (model) => model.getQuestions(), + builder: (_, model, w) => AppScaffold( + baseViewModel: model, + body: SingleChildScrollView( + physics: BouncingScrollPhysics(), + child: Column( + children: [ + ...List.generate( + model.triageQuestionsModelList.length, + (index) => + InkWell( + onTap: (){ + setState(() { + if (widget.selectedQuestions + .contains(model.triageQuestionsModelList[index])) { + widget.selectedQuestions + .remove(model.triageQuestionsModelList[index]); + } else { + widget.selectedQuestions + .add(model.triageQuestionsModelList[index]); + } + }); + }, + child: Row( + children: [ + Checkbox( + value: widget.selectedQuestions.contains(model.triageQuestionsModelList[index]), + activeColor: Colors.red[800], + onChanged: (bool newValue) { + setState(() { + if (widget.selectedQuestions + .contains(model.triageQuestionsModelList[index])) { + widget.selectedQuestions + .remove(model.triageQuestionsModelList[index]); + } else { + widget.selectedQuestions + .add(model.triageQuestionsModelList[index]); + } + }); + }), + Expanded( + child: Padding( + padding: const EdgeInsets.all(20.0), + child: Texts( + model.triageQuestionsModelList[index].question, + fontSize: 15, + ), + ), + ), + ], + ), + ), + + ), + SizedBox(height: 80,) + ], + ), + ), + bottomSheet: Padding( + padding: const EdgeInsets.all(8.0), + child: Container( + height: 56, + child: Row( + children: [ + Expanded( + child: Container( + margin: EdgeInsets.only(left: 5,right: 5), + child: SecondaryButton( + textColor: Colors.white, + color: Theme.of(context).primaryColor, + label: TranslationBase.of(context).back.toUpperCase(), + onTap: () => widget.changePageViewIndex(1), + ), + ), + ), + SizedBox(width: 10,), + Expanded( + child: Container( + margin: EdgeInsets.only(left: 5,right: 5), + child: SecondaryButton( + textColor: Colors.white, + color: Theme.of(context).primaryColor, + label: TranslationBase.of(context).next.toUpperCase(), + disabled: widget.selectedQuestions.isEmpty, + onTap: () => widget.changePageViewIndex(3), + ), + ), + ), + + ], + ), + ), + ), + ), + ); + } +} diff --git a/lib/pages/ErService/EdOnline/EdOnlineSelectedHospitalPage.dart b/lib/pages/ErService/EdOnline/EdOnlineSelectedHospitalPage.dart new file mode 100644 index 00000000..34c41040 --- /dev/null +++ b/lib/pages/ErService/EdOnline/EdOnlineSelectedHospitalPage.dart @@ -0,0 +1,102 @@ +import 'package:diplomaticquarterapp/core/model/er/TriageInformationRequest.dart'; +import 'package:diplomaticquarterapp/core/model/hospitals/hospitals_model.dart'; +import 'package:diplomaticquarterapp/core/viewModels/er/EdOnlineViewModel.dart'; +import 'package:diplomaticquarterapp/pages/base/base_view.dart'; +import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; +import 'package:diplomaticquarterapp/widgets/buttons/secondary_button.dart'; +import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; + +import '../../../Constants.dart'; + + +class EdOnlineSelectedHospitalPage extends StatefulWidget { + final Function changePageViewIndex; + TriageInformationRequest triageInformationRequest; + + EdOnlineSelectedHospitalPage( + {Key key, this.changePageViewIndex,this.triageInformationRequest}) + : super(key: key); + + @override + _EdOnlineSelectedHospitalPageState createState() => + _EdOnlineSelectedHospitalPageState(); +} + +class _EdOnlineSelectedHospitalPageState + extends State { + @override + Widget build(BuildContext context) { + return BaseView( + onModelReady: (model) => model.getHospitals(), + builder: (_, model, w) => AppScaffold( + baseViewModel: model, + body: SingleChildScrollView( + physics: BouncingScrollPhysics(), + child: Column( + children: [ + ...List.generate( + model.hospitals.length, + (index) => Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SizedBox( + height: 2, + ), + Row( + children: [ + Expanded( + flex: 1, + child: InkWell( + onTap: () { + setState(() { + widget.triageInformationRequest.selectedHospital = model.hospitals[index]; + widget.triageInformationRequest.projectID = model.hospitals[index].iD; + }); + }, + child: ListTile( + title: Text(model.hospitals[index].name + + ' ${model.hospitals[index].distanceInKilometers} ' + + TranslationBase.of(context).km), + leading: Radio( + value: model.hospitals[index], + groupValue: widget.triageInformationRequest.selectedHospital, + activeColor: secondaryColor, + onChanged: (value) { + setState(() { + widget.triageInformationRequest.selectedHospital = model.hospitals[index]; + widget.triageInformationRequest.projectID = model.hospitals[index].iD; + }); + }, + ), + ), + ), + ) + ], + ), + SizedBox( + height: 5.0, + ), + ], + ), + ) + ], + ), + ), + bottomSheet: Container( + height: 76, + child: Padding( + padding: const EdgeInsets.all(8.0), + child: SecondaryButton( + // textColor: Colors.white, + color: Theme.of(context).primaryColor, + label: TranslationBase.of(context).next.toUpperCase(), + disabled: widget.triageInformationRequest.selectedHospital==null, + onTap: () => widget.changePageViewIndex(1)), + ), + ), + ), + ); + } +} diff --git a/lib/pages/ErService/EdOnline/EdPaymentInformationPage.dart b/lib/pages/ErService/EdOnline/EdPaymentInformationPage.dart new file mode 100644 index 00000000..c510196b --- /dev/null +++ b/lib/pages/ErService/EdOnline/EdPaymentInformationPage.dart @@ -0,0 +1,112 @@ +import 'package:diplomaticquarterapp/core/model/hospitals/hospitals_model.dart'; +import 'package:diplomaticquarterapp/core/viewModels/er/EdOnlineViewModel.dart'; +import 'package:diplomaticquarterapp/pages/ToDoList/payment_method_select.dart'; +import 'package:diplomaticquarterapp/pages/base/base_view.dart'; +import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; +import 'package:diplomaticquarterapp/widgets/buttons/secondary_button.dart'; +import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; +import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; +import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; + +class EdPaymentInformationPage extends StatefulWidget { + final HospitalsModel selectedHospital; + + const EdPaymentInformationPage({Key key, this.selectedHospital}) : super(key: key); + @override + _EdPaymentInformationPageState createState() => + _EdPaymentInformationPageState(); +} + +class _EdPaymentInformationPageState extends State { + @override + Widget build(BuildContext context) { + return BaseView( + onModelReady: (model) => model.getPatientPaymentInformation(), + builder: (_, model, w) => AppScaffold( + baseViewModel: model, + body: SingleChildScrollView( + physics: BouncingScrollPhysics(), + child: Column( + children: [ + Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(10.0), + color: Colors.white), + margin: EdgeInsets.fromLTRB(0.0, 30.0, 0.0, 5.0), + padding: EdgeInsets.fromLTRB(20.0, 0.0, 20.0, 20.0), + child: Column( + children: [ + Container( + alignment: Alignment.center, + margin: + EdgeInsets.only(left: 0.0, right: 20.0, top: 30.0), + child: Text(TranslationBase.of(context).testFee, + style: TextStyle( + color: Colors.black, + fontSize: 22.0, + fontWeight: FontWeight.bold)), + ), + if(model.erPatientShareModel!=null) + Table( + children: [ + TableRow(children: [ + TableCell( + child: + Texts(TranslationBase.of(context).testFee)), + TableCell( + child: Texts(model + .erPatientShareModel.patientShare + .toStringAsFixed(2))), + ]), + TableRow(children: [ + TableCell( + child: Texts( + TranslationBase.of(context).patientTaxToDo)), + TableCell( + child: Texts(model + .erPatientShareModel.patientTaxAmount + .toStringAsFixed(2))), + ]), + TableRow(children: [ + TableCell( + child: Texts(TranslationBase.of(context) + .patientShareTotalToDo)), + TableCell( + child: Texts(model + .erPatientShareModel.patientShareWithTax + .toStringAsFixed(2))), + ]), + ], + ), + ], + ), + ), + ], + ), + ), + bottomSheet: Container( + height: 76, + child: Padding( + padding: const EdgeInsets.all(8.0), + child: SecondaryButton( + color: Theme.of(context).primaryColor, + label: TranslationBase.of(context).next.toUpperCase(), + onTap: () { + Navigator.push(context, FadePage(page: PaymentMethod())).then( + (value) { + //TODO Haroun call API here + }, + ); + }, + ), + ), + ), + ), + ); + } + + + +} diff --git a/lib/pages/ErService/ErOptions.dart b/lib/pages/ErService/ErOptions.dart index 886d47d2..e0ff3ed4 100644 --- a/lib/pages/ErService/ErOptions.dart +++ b/lib/pages/ErService/ErOptions.dart @@ -1,10 +1,16 @@ import 'package:diplomaticquarterapp/uitl/location_util.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; +import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; import 'package:flutter/material.dart'; import '../../uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/pages/ErService/widgets/card_common.dart'; +import 'AmbulanceReq.dart'; +import 'EdOnline/DdServicesPage.dart'; +import 'EdOnline/EdOnlineSelectedHospitalPage.dart'; +import 'NearestEr.dart'; + class ErOptions extends StatefulWidget { final bool isAppbar; @@ -49,7 +55,12 @@ class _ErOptionsState extends State { image: 'assets/images/new-design/AM.PNG', text: TranslationBase.of(context).ambulancerequest, subText: TranslationBase.of(context).requestA, - type: 0, + onTap: (){ + Navigator.push( + context, + FadePage( + page: AmbulanceReq())); + }, ), ), @@ -58,8 +69,39 @@ class _ErOptionsState extends State { image: 'assets/images/new-design/emergency_icon.png', text: TranslationBase.of(context).nearester, subText: TranslationBase.of(context).locationa, - type: 1), + onTap:(){ + Navigator.push( + context, + FadePage( + page: NearestEr())); + }), + + ) + ], + ), + ), + Container( + margin: EdgeInsets.fromLTRB(0.0, 10.0, 0.0, 10.0), + child: Row( + mainAxisSize: MainAxisSize.max, + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Expanded( + child: CardCommonEr( + image: 'assets/images/new-design/AM.PNG', + text:'ED service', + subText: 'ED service', + onTap: (){ + Navigator.push( + context, + FadePage( + page: DdServicesPage())); + }, + ), + ), + Expanded( + child: Container(), ) ], ), diff --git a/lib/pages/ErService/widgets/card_common.dart b/lib/pages/ErService/widgets/card_common.dart index 35ece966..6b396dc9 100644 --- a/lib/pages/ErService/widgets/card_common.dart +++ b/lib/pages/ErService/widgets/card_common.dart @@ -10,20 +10,18 @@ class CardCommonEr extends StatelessWidget { final image; final text; final subText; - final type; + + final Function onTap; const CardCommonEr( {@required this.image, @required this.text, @required this.subText, - @required this.type}); + @required this.onTap}); @override Widget build(BuildContext context) { return GestureDetector( - onTap: () { - navigateToSearch(context, this.type); - - }, + onTap: () => onTap(), child: Container( margin: EdgeInsets.fromLTRB(9.0, 9.0, 9.0, 9.0), decoration: BoxDecoration(boxShadow: [ @@ -59,25 +57,4 @@ class CardCommonEr extends StatelessWidget { ); } - Future navigateToSearch(context, type) async { -//===Switch case=== - if(type==0) - { - - Navigator.push( - context, - FadePage( - page: AmbulanceReq())); - } - else{ - - Navigator.push( - context, - FadePage( - page: NearestEr())); - - } - - - } } diff --git a/lib/pages/parent_categorise_page.dart b/lib/pages/parent_categorise_page.dart index 46df3df7..a7e43241 100644 --- a/lib/pages/parent_categorise_page.dart +++ b/lib/pages/parent_categorise_page.dart @@ -1,4 +1,5 @@ import 'package:diplomaticquarterapp/config/size_config.dart'; +import 'package:diplomaticquarterapp/core/model/pharmacy/categorise_parent_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacy_categorise_view_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/product_detail.dart'; @@ -7,8 +8,10 @@ import 'package:diplomaticquarterapp/widgets/buttons/button.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:diplomaticquarterapp/widgets/others/StarRating.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_pharmacy_widget.dart'; +import 'package:diplomaticquarterapp/widgets/others/entity_checkbox_list.dart'; import 'package:diplomaticquarterapp/widgets/others/network_base_view.dart'; import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; +import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; @@ -43,8 +46,13 @@ class _ParentCategorisePageState extends State { size: 29.0, ); + List entityList = List(); + List entityListBrands = List(); + @override Widget build(BuildContext context) { + TextEditingController minField = TextEditingController(); + TextEditingController maxField = TextEditingController(); ProjectViewModel projectViewModel = Provider.of(context); return BaseView( onModelReady: (model) => model.getCategoriseParent(i: id), @@ -57,960 +65,759 @@ class _ParentCategorisePageState extends State { backgroundColor: Colors.white, isShowDecPage: false, baseViewModel: model, - body: Container( - child: ListView( - scrollDirection: Axis.vertical, - children: [ - Container( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Container( - child: Image.network( - id == '1' - ? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089188_personal-care_2.png' - : id == '2' - ? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089189_skin-care_2.png' - : id == '3' - ? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089190_health-care_2.png' - : id == '4' - ? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089191_sexual-health_2.png' - : id == '5' - ? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089192_beauty_2.png' - : id == '6' - ? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089193_baby-child_2.png' - : id == '7' - ? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089194_vitamins-supplements_2.png' - : id == '8' - ? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089195_diet-nutrition_2.png' - : id == '9' - ? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089196_household_2.png' - : id == '10' - ? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089197_home-care-appliances_2.png' - : '', - fit: BoxFit.fill, - height: 160.0, - width: double.infinity), - ), - if (model.categoriseParent.length > 8) - Column( - crossAxisAlignment: CrossAxisAlignment.start, + body: SingleChildScrollView( + child: Container( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + child: Image.network( + id == '1' + ? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089188_personal-care_2.png' + : id == '2' + ? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089189_skin-care_2.png' + : id == '3' + ? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089190_health-care_2.png' + : id == '4' + ? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089191_sexual-health_2.png' + : id == '5' + ? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089192_beauty_2.png' + : id == '6' + ? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089193_baby-child_2.png' + : id == '7' + ? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089194_vitamins-supplements_2.png' + : id == '8' + ? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089195_diet-nutrition_2.png' + : id == '9' + ? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089196_household_2.png' + : id == '10' + ? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089197_home-care-appliances_2.png' + : '', + fit: BoxFit.fill, + height: 160.0, + width: double.infinity), + ), + if (model.categoriseParent.length > 8) + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Row( - mainAxisAlignment: - MainAxisAlignment.spaceBetween, - children: [ - Padding( - padding: EdgeInsets.all(10.0), - child: InkWell( - child: Container( - child: Texts( - 'View All Categories', - fontWeight: FontWeight.w300, - ), - ), - onTap: () { - showModalBottomSheet( - isScrollControlled: true, - context: context, - builder: (BuildContext context) { - return Container( - // height: MediaQuery.of(context) - // .size - // .height * - // 0.89, - color: Colors.white, - child: Center( - child: ListView.builder( - scrollDirection: - Axis.vertical, - itemCount: model - .categoriseParent - .length, - itemBuilder: - (BuildContext context, - int index) { - return Container( - child: Padding( - padding: - EdgeInsets.all( - 4.0), - child: InkWell( - child: Column( - crossAxisAlignment: - CrossAxisAlignment - .start, - children: [ - Texts(model - .categoriseParent[ - index] - .name), - Divider( - thickness: - 0.6, - color: Colors - .black12, - ) - ], - ), - onTap: () { - Navigator.push( - context, - FadePage( - page: - SubCategorisePage( - title: model - .categoriseParent[ - index] - .name, - id: model - .categoriseParent[ - index] - .id, - parentId: - id, - )), - ); - }, - ), + Padding( + padding: EdgeInsets.all(10.0), + child: InkWell( + child: Container( + child: Texts( + 'View All Categories', + fontWeight: FontWeight.w300, + ), + ), + onTap: () { + showModalBottomSheet( + isScrollControlled: true, + context: context, + builder: (BuildContext context) { + return Container( + // height: MediaQuery.of(context) + // .size + // .height * + // 0.89, + color: Colors.white, + child: Center( + child: ListView.builder( + scrollDirection: + Axis.vertical, + itemCount: model + .categoriseParent.length, + itemBuilder: + (BuildContext context, + int index) { + return Container( + child: Padding( + padding: + EdgeInsets.all(4.0), + child: InkWell( + child: Column( + crossAxisAlignment: + CrossAxisAlignment + .start, + children: [ + Texts(model + .categoriseParent[ + index] + .name), + Divider( + thickness: 0.6, + color: Colors + .black12, + ) + ], ), - ); - }), - ), - ); - }, + onTap: () { + Navigator.push( + context, + FadePage( + page: + SubCategorisePage( + title: model + .categoriseParent[ + index] + .name, + id: model + .categoriseParent[ + index] + .id, + parentId: id, + )), + ); + }, + ), + ), + ); + }), + ), ); }, - ), - ), - Icon(Icons.arrow_forward) - ], - ), - Divider( - thickness: 1.0, - color: Colors.grey.shade400, + ); + }, + ), ), + Icon(Icons.arrow_forward) ], ), + Divider( + thickness: 1.0, + color: Colors.grey.shade400, + ), + ], + ), //Expanded widget heree if nassery - Padding( - padding: EdgeInsets.only(top: 35.0), - child: Container( - height: MediaQuery.of(context).size.height * 0.2, - child: Center( - child: ListView.builder( - scrollDirection: Axis.horizontal, - itemCount: model.categoriseParent.length > 8 - ? 8 - : model.categoriseParent.length, - itemBuilder: - (BuildContext context, int index) { - return Padding( - padding: EdgeInsets.symmetric( - horizontal: 8.0), - child: InkWell( - child: Column( - crossAxisAlignment: - CrossAxisAlignment.center, - children: [ - Padding( - padding: EdgeInsets.symmetric( - horizontal: 13.0), - child: Container( - height: 60.0, - width: 65.0, - decoration: BoxDecoration( - shape: BoxShape.circle, - color: Colors - .orange.shade200 - .withOpacity(0.45), - ), - child: Center( - child: Icon( - Icons.apps_sharp, - size: 32.0, - ), - ), - ), + Padding( + padding: EdgeInsets.only(top: 35.0), + child: Container( + height: MediaQuery.of(context).size.height * 0.2, + child: Center( + child: ListView.builder( + scrollDirection: Axis.horizontal, + itemCount: model.categoriseParent.length > 8 + ? 8 + : model.categoriseParent.length, + itemBuilder: (BuildContext context, int index) { + return Padding( + padding: + EdgeInsets.symmetric(horizontal: 8.0), + child: InkWell( + child: Column( + crossAxisAlignment: + CrossAxisAlignment.center, + children: [ + Padding( + padding: EdgeInsets.symmetric( + horizontal: 13.0), + child: Container( + height: 60.0, + width: 65.0, + decoration: BoxDecoration( + shape: BoxShape.circle, + color: Colors.orange.shade200 + .withOpacity(0.45), ), - Container( - width: MediaQuery.of(context) - .size - .width * - 0.197, - // height: MediaQuery.of(context) - // .size - // .height * - // 0.08, - child: Center( - child: Texts( - projectViewModel.isArabic - ? model - .categoriseParent[ - index] - .namen - : model - .categoriseParent[ - index] - .name, - fontSize: 13.4, - fontWeight: FontWeight.w600, - maxLines: 3, - ), + child: Center( + child: Icon( + Icons.apps_sharp, + size: 32.0, ), ), - ], + ), ), - onTap: () { - Navigator.push( - context, - FadePage( - page: SubCategorisePage( - title: model - .categoriseParent[index] - .name, - id: model - .categoriseParent[index].id, - parentId: id, - )), - ); - print(id); - }, - ), - ); - }), - ), - ), + Container( + width: MediaQuery.of(context) + .size + .width * + 0.197, + // height: MediaQuery.of(context) + // .size + // .height * + // 0.08, + child: Center( + child: Texts( + projectViewModel.isArabic + ? model + .categoriseParent[index] + .namen + : model + .categoriseParent[index] + .name, + fontSize: 13.4, + fontWeight: FontWeight.w600, + maxLines: 3, + ), + ), + ), + ], + ), + onTap: () { + Navigator.push( + context, + FadePage( + page: SubCategorisePage( + title: model + .categoriseParent[index].name, + id: model + .categoriseParent[index].id, + parentId: id, + )), + ); + print(id); + }, + ), + ); + }), ), + ), + ), - Divider( - thickness: 1.0, - color: Colors.grey.shade400, - ), - Padding( - padding: EdgeInsets.symmetric(horizontal: 8.0), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - InkWell( - child: Row( - children: [ - Icon( - Icons.wrap_text, - ), - SizedBox( - width: 10.0, - ), - Texts( - 'Refine', - fontWeight: FontWeight.w600, - ), - ], + Divider( + thickness: 1.0, + color: Colors.grey.shade400, + ), + Padding( + padding: EdgeInsets.symmetric(horizontal: 8.0), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + InkWell( + child: Row( + children: [ + Icon( + Icons.wrap_text, ), - onTap: () { - showModalBottomSheet( - isScrollControlled: true, - context: context, - builder: (BuildContext context) { - return DraggableScrollableSheet( - initialChildSize: 0.95, - maxChildSize: 0.95, - minChildSize: 0.9, - builder: (BuildContext context, - ScrollController - scrollController) { - return SingleChildScrollView( - controller: scrollController, - child: Container( - height: MediaQuery.of(context) - .size - .height * - 1.95, - child: Column( - children: [ - Padding( - padding: - EdgeInsets.all(8.0), - child: Row( - children: [ - Icon( - Icons.wrap_text, - ), - SizedBox( - width: 10.0, - ), - Texts( - 'Refine', - fontWeight: - FontWeight - .w600, - ), - SizedBox( - width: 250.0, - ), - InkWell( - child: Texts( - 'Close', - color: - Colors.red, - fontWeight: - FontWeight - .w600, - fontSize: 15.0, - ), - onTap: () { - Navigator.pop( - context); - }, - ), - ], + SizedBox( + width: 10.0, + ), + Texts( + 'Refine', + fontWeight: FontWeight.w600, + ), + ], + ), + onTap: () { + showModalBottomSheet( + isScrollControlled: true, + context: context, + builder: (BuildContext context) { + return DraggableScrollableSheet( + initialChildSize: 0.95, + maxChildSize: 0.95, + minChildSize: 0.9, + builder: (BuildContext context, + ScrollController scrollController) { + return SingleChildScrollView( + controller: scrollController, + child: Container( + color: Colors.white, + height: MediaQuery.of(context) + .size + .height * + 1.95, + child: Column( + children: [ + Padding( + padding: + EdgeInsets.all(8.0), + child: Row( + children: [ + Icon( + Icons.wrap_text, + ), + SizedBox( + width: 10.0, + ), + Texts( + 'Refine', + fontWeight: + FontWeight.w600, ), + SizedBox( + width: 250.0, + ), + InkWell( + child: Texts( + 'Close', + color: Colors.red, + fontWeight: + FontWeight.w600, + fontSize: 15.0, + ), + onTap: () { + Navigator.pop( + context); + }, + ), + ], + ), + ), + Divider( + thickness: 1.0, + color: Colors.black12, + ), + Column( + children: [ + ExpansionTile( + title: + Texts('Categorise'), + children: [ + ProcedureListWidget( + model: model, + masterList: model + .categoriseParent, + removeHistory: + (item) { + setState(() { + entityList + .remove( + item); + }); + }, + addHistory: + (history) { + setState(() { + entityList.add( + history); + }); + }, + addSelectedHistories: + () { + //TODO build your fun herr + // widget.addSelectedHistories(); + }, + isEntityListSelected: + (master) => + isEntityListSelected( + master), + ) + ], ), Divider( thickness: 1.0, color: Colors.black12, ), - Column( + ExpansionTile( + title: Texts('Brands'), children: [ - ExpansionTile( - title: Texts( - 'Categorise'), - children: [ - Container( - height: 350, - child: ListView - .builder( - controller: - scrollController, - scrollDirection: - Axis - .vertical, - shrinkWrap: - true, - itemCount: model - .categoriseParent - .length, - itemBuilder: - (BuildContext context, - int index) { - return CheckboxListTile( - tristate: - true, - title: - Texts(model.categoriseParent[index].name), - controlAffinity: - ListTileControlAffinity.leading, - value: - checkedCategorise, - onChanged: - (bool value) { - setState(() { - checkedCategorise = value; - }); - }, - ); - }), - ) - ], - ), - Divider( - thickness: 1.0, - color: - Colors.black12, - ), - ExpansionTile( - title: - Texts('Brands'), - children: [ - Container( - height: 350, - child: ListView - .builder( - scrollDirection: - Axis - .vertical, - shrinkWrap: - true, - itemCount: model - .brandsList - .length, - itemBuilder: - (BuildContext context, - int index) { - return CheckboxListTile( - tristate: - true, - title: - Texts(model.brandsList[index].name), - controlAffinity: - ListTileControlAffinity.leading, - value: - checkedBrands, - onChanged: - (bool value) { - setState(() { - checkedBrands = value; - }); - }, - autofocus: - true, - ); - }), - ) - ], - ), - Divider( - thickness: 1.0, - color: - Colors.black12, - ), - ExpansionTile( - title: - Texts('Price'), - children: [ - Container( - color: Color( - 0xffEEEEEE), - child: Row( + ProcedureListWidget( + model: model, + masterList: model + .brandsList, + removeHistory: + (item) { + setState(() { + entityListBrands + .remove( + item); + }); + }, + addHistory: + (history) { + setState(() { + entityListBrands + .add( + history); + }); + }, + addSelectedHistories: + () { + //TODO build your fun herr + // widget.addSelectedHistories(); + }, + isEntityListSelected: + (master) => + isEntityListSelectedBrands( + master), + ) + ], + ), + Divider( + thickness: 1.0, + color: Colors.black12, + ), + ExpansionTile( + title: Texts('Price'), + children: [ + Container( + color: Color( + 0xffEEEEEE), + child: Row( + mainAxisAlignment: + MainAxisAlignment + .spaceAround, + children: [ + Column( mainAxisAlignment: MainAxisAlignment - .spaceAround, + .start, children: [ - Column( - mainAxisAlignment: - MainAxisAlignment - .start, - children: [ - Texts( - 'Min'), - Container( - color: - Colors.white, - width: - 200, - height: - 40, - child: - TextFormField( - decoration: - InputDecoration( - border: OutlineInputBorder(), - ), - ), + Texts( + 'Min'), + Container( + color: Colors + .white, + width: + 200, + height: + 40, + child: + TextFormField( + decoration: + InputDecoration( + border: + OutlineInputBorder(), ), - ], + controller: + minField, + ), ), - Column( - mainAxisAlignment: - MainAxisAlignment - .start, - children: [ - Texts( - 'Max'), - Container( - color: - Colors.white, - width: - 200, - height: - 40, - child: - TextFormField( - decoration: - InputDecoration( - border: OutlineInputBorder(), - ), - ), + ], + ), + Column( + mainAxisAlignment: + MainAxisAlignment + .start, + children: [ + Texts( + 'Max'), + Container( + color: Colors + .white, + width: + 200, + height: + 40, + child: + TextFormField( + decoration: + InputDecoration( + border: + OutlineInputBorder(), ), - ], + controller: + maxField, + ), ), ], ), - ) - ], - ), - Divider( - thickness: 1.0, - color: - Colors.black12, - ), - SizedBox( - height: MediaQuery.of( - context) - .size - .height * - 0.4, - ), - Padding( - padding: - EdgeInsets.all( - 8.0), - child: Row( - mainAxisAlignment: - MainAxisAlignment - .spaceEvenly, - children: [ - Container( - width: 100, - child: Button( - label: - 'Reset', - backgroundColor: - Colors - .red, - ), - ), - SizedBox( - width: 30, - ), - Container( - width: 200, - child: Button( - label: - 'Apply', - backgroundColor: - Colors - .green, - ), - ), ], ), - ), + ) ], ), - ], - ), - ), - ); - }); - }, - ); - }, - ), - Row( - children: [ - Container( - height: 44.0, - child: VerticalDivider( - color: Colors.black45, - thickness: 1.0, -//width: 0.3, -// indent: 0.0, - ), - ), - Padding( - padding: EdgeInsets.all(8.0), - child: InkWell( - child: styleIcon, - onTap: () { - setState(() { - if (styleOne == true) { - styleOne = false; - styleTwo = true; - styleIcon = Icon( - Icons.auto_awesome_mosaic, - color: Colors.blue, - size: 29.0, - ); - } else { - styleOne = true; - styleTwo = false; - styleIcon = Icon( - Icons.widgets_sharp, - color: Colors.blue, - size: 29.0, - ); - } - }); - }, - ), - ), - ], - ), - ], - ), - ), - Divider( - thickness: 1.0, - color: Colors.grey.shade400, - ), - styleOne == true - ? Container( - height: SizeConfig.screenHeight * 7.8, - child: GridView.builder( - physics: NeverScrollableScrollPhysics(), - gridDelegate: - SliverGridDelegateWithFixedCrossAxisCount( - crossAxisCount: 2, - crossAxisSpacing: 0.5, - mainAxisSpacing: 2.0, - childAspectRatio: 0.9, - ), - itemCount: model.parentProducts.length, - itemBuilder: - (BuildContext context, int index) { - return NetworkBaseView( - baseViewModel: model, - child: InkWell( - child: Card( - color: model.parentProducts[index] - .discountName != - null - ? Color(0xffFFFF00) - : Colors.white, - elevation: 0, - shape: Border( - right: BorderSide( - color: Colors.grey.shade300, - width: 1, - ), - left: BorderSide( - color: Colors.grey.shade300, - width: 1, - ), - bottom: BorderSide( - color: Colors.grey.shade300, - width: 1, - ), - top: BorderSide( - color: Colors.grey.shade300, - width: 1, - ), - ), - margin: EdgeInsets.symmetric( - horizontal: 8, - vertical: 4, - ), - child: Container( - decoration: BoxDecoration( - borderRadius: - BorderRadius.only( - topLeft: - Radius.circular(110.0), - ), - color: Colors.white, - ), - padding: EdgeInsets.symmetric( - horizontal: 0), - width: MediaQuery.of(context) - .size - .width / - 3, - child: Column( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Stack( - children: [ - if (model - .parentProducts[ - index] - .discountName != - null) - RotatedBox( - quarterTurns: 4, - child: Container( - decoration: - BoxDecoration(), - child: Padding( - padding: - EdgeInsets - .only( - right: 5.0, - top: 20.0, - bottom: 5.0, - ), - child: Texts( - 'offer' - .toUpperCase(), - color: Colors - .red, - fontSize: - 13.0, - fontWeight: - FontWeight - .w900, - ), - ), - transform: new Matrix4 - .rotationZ( - 5.837200), - ), - ), - Container( - margin: EdgeInsets - .fromLTRB( - 0, 16, 0, 0), - alignment: - Alignment.center, - child: Image.network( - model - .parentProducts[ - index] - .images - .isNotEmpty - ? model - .parentProducts[ - index] - .images[0] - .thumb - : 'https://upload.wikimedia.org/wikipedia/commons/thumb/6/6c/No_image_3x4.svg/1200px-No_image_3x4.svg.png', - fit: BoxFit.cover, - height: 80, - ), - ), - Container( - width: model - .parentProducts[ - index] - .rxMessage != - null - ? MediaQuery.of( - context) - .size - .width / - 5 - : 0, - padding: - EdgeInsets.all(4), - decoration: - BoxDecoration( - color: Color( - 0xffb23838), - borderRadius: - BorderRadius.only( - topLeft: Radius - .circular( - 6)), - ), - child: Texts( - model - .parentProducts[ - index] - .rxMessage != - null - ? model - .parentProducts[ - index] - .rxMessage - : "", - color: Colors.white, - regular: true, - fontSize: 10, - fontWeight: - FontWeight.w400, - ), - ), - ], - ), - Container( - margin: - EdgeInsets.symmetric( - horizontal: 6, - vertical: 0, + Divider( + thickness: 1.0, + color: Colors.black12, ), - child: Column( - crossAxisAlignment: - CrossAxisAlignment - .start, - children: [ - if (model - .parentProducts[ - index] - .discountName != - null) + SizedBox( + height: MediaQuery.of( + context) + .size + .height * + 0.4, + ), + Padding( + padding: + EdgeInsets.all(8.0), + child: Row( + mainAxisAlignment: + MainAxisAlignment + .spaceEvenly, + children: [ Container( - width: double - .infinity, - height: 13.0, - decoration: - BoxDecoration( - color: Color( - 0xff5AB145), - ), - child: Center( - child: Texts( - model - .parentProducts[ - index] - .discountName, - regular: true, - color: Colors - .white, - fontSize: - 10.4, - ), + width: 100, + child: Button( + label: 'Reset', + backgroundColor: + Colors.red, ), ), - Texts( - model - .parentProducts[ - index] - .name, - regular: true, - fontSize: 12, - fontWeight: - FontWeight.w700, - ), - Padding( - padding: - const EdgeInsets - .only( - top: 4, - bottom: 4), - child: Texts( - "SAR ${model.parentProducts[index].price}", - bold: true, - fontSize: 14, + SizedBox( + width: 30, ), - ), - Row( - children: [ - StarRating( - totalAverage: model - .parentProducts[ - index] - .approvedRatingSum > - 0 - ? (model.parentProducts[index].approvedRatingSum.toDouble() / - model.parentProducts[index].approvedRatingSum - .toDouble()) - .toDouble() - : 0, - forceStars: - true), - Texts( - "(${model.parentProducts[index].approvedTotalReviews})", - regular: true, - fontSize: 10, - fontWeight: - FontWeight - .w400, - ) - ], - ), - ], + Container( + width: 200, + child: Button( + onTap: () { + String + categoriesId = + ""; + for (CategoriseParentModel category + in entityList) { + if (categoriesId == + "") { + categoriesId = + category + .id; + } else { + categoriesId = + "$categoriesId,${category.id}"; + } + } + String + brandIds = + ""; + for (CategoriseParentModel brand + in entityListBrands) { + if (brandIds == + "") { + brandIds = + brand + .id; + } else { + brandIds = + "$brandIds,${brand.id}"; + } + } + + model.getFilteredProducts( + min: minField + .text + .toString(), + max: maxField + .text + .toString(), + categoryId: + categoriesId, + brandId: + brandIds); + }, + label: 'Apply', + backgroundColor: + Colors + .green, + ), + ), + ], + ), ), - ), - ], - ), + ], + ), + ], ), ), - onTap: () => { - Navigator.push( - context, - FadePage( - page: ProductDetailPage( - model.parentProducts[ - index]), - )), - }, - )); + ); + }); + }, + ); + }, + ), + Row( + children: [ + Container( + height: 44.0, + child: VerticalDivider( + color: Colors.black45, + thickness: 1.0, +//width: 0.3, +// indent: 0.0, + ), + ), + Padding( + padding: EdgeInsets.all(8.0), + child: InkWell( + child: styleIcon, + onTap: () { + setState(() { + if (styleOne == true) { + styleOne = false; + styleTwo = true; + styleIcon = Icon( + Icons.auto_awesome_mosaic, + color: Colors.blue, + size: 29.0, + ); + } else { + styleOne = true; + styleTwo = false; + styleIcon = Icon( + Icons.widgets_sharp, + color: Colors.blue, + size: 29.0, + ); + } + }); }, ), - ) - : Container( - height: - MediaQuery.of(context).size.height * 5.0, - child: ListView.builder( - physics: NeverScrollableScrollPhysics(), - itemCount: model.parentProducts.length, - itemBuilder: - (BuildContext context, int index) { - return InkWell( - child: Card( - child: Row( + ), + ], + ), + ], + ), + ), + Divider( + thickness: 1.0, + color: Colors.grey.shade400, + ), + styleOne == true + ? Container( + height: model.parentProducts.length * + MediaQuery.of(context).size.height * + 0.15, + child: GridView.builder( + physics: NeverScrollableScrollPhysics(), + gridDelegate: + SliverGridDelegateWithFixedCrossAxisCount( + crossAxisCount: 2, + crossAxisSpacing: 0.5, + mainAxisSpacing: 2.0, + childAspectRatio: 0.9, + ), + itemCount: model.parentProducts.length, + itemBuilder: (BuildContext context, int index) { + return NetworkBaseView( + baseViewModel: model, + child: InkWell( + child: Card( + color: model.parentProducts[index] + .discountName != + null + ? Color(0xffFFFF00) + : Colors.white, + elevation: 0, + shape: Border( + right: BorderSide( + color: Colors.grey.shade300, + width: 1, + ), + left: BorderSide( + color: Colors.grey.shade300, + width: 1, + ), + bottom: BorderSide( + color: Colors.grey.shade300, + width: 1, + ), + top: BorderSide( + color: Colors.grey.shade300, + width: 1, + ), + ), + margin: EdgeInsets.symmetric( + horizontal: 8, + vertical: 4, + ), + child: Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.only( + topLeft: Radius.circular(110.0), + ), + color: Colors.white, + ), + padding: EdgeInsets.symmetric( + horizontal: 0), + width: MediaQuery.of(context) + .size + .width / + 3, + child: Column( + crossAxisAlignment: + CrossAxisAlignment.start, children: [ Stack( children: [ - Column( - children: [ - Container( + if (model + .parentProducts[ + index] + .discountName != + null) + RotatedBox( + quarterTurns: 4, + child: Container( decoration: BoxDecoration(), child: Padding( padding: EdgeInsets.only( - left: 9.0, - top: 8.0, - right: 10.0, + right: 5.0, + top: 20.0, + bottom: 5.0, ), - ), - ), - Container( - margin: EdgeInsets - .fromLTRB( - 0, 0, 0, 0), - alignment: - Alignment.center, - child: Image.network( - model - .parentProducts[ - index] - .images - .isNotEmpty - ? model - .parentProducts[ - index] - .images[0] - .thumb - : 'https://upload.wikimedia.org/wikipedia/commons/thumb/6/6c/No_image_3x4.svg/1200px-No_image_3x4.svg.png', - fit: BoxFit.contain, - height: 80, - ), - ), - ], - ), - Column( - children: [ - Container( - width: model - .parentProducts[ - index] - .rxMessage != - null - ? MediaQuery.of( - context) - .size - .width / - 5 - : 0, - padding: - EdgeInsets.all(4), - decoration: - BoxDecoration( - color: Color( - 0xffb23838), - borderRadius: - BorderRadius.only( - topLeft: Radius - .circular( - 6)), - ), - child: Expanded( child: Texts( - model - .parentProducts[ - index] - .rxMessage != - null - ? model - .parentProducts[ - index] - .rxMessage - : "", - color: - Colors.white, - regular: true, - fontSize: 10, + 'offer' + .toUpperCase(), + color: Colors.red, + fontSize: 13.0, fontWeight: FontWeight - .w400, + .w900, ), ), + transform: new Matrix4 + .rotationZ( + 5.837200), ), - ], + ), + Container( + margin: + EdgeInsets.fromLTRB( + 0, 16, 0, 0), + alignment: + Alignment.center, + child: Image.network( + model + .parentProducts[ + index] + .images + .isNotEmpty + ? model + .parentProducts[ + index] + .images[0] + .thumb + : 'https://upload.wikimedia.org/wikipedia/commons/thumb/6/6c/No_image_3x4.svg/1200px-No_image_3x4.svg.png', + fit: BoxFit.cover, + height: 80, + ), + ), + Container( + width: model + .parentProducts[ + index] + .rxMessage != + null + ? MediaQuery.of( + context) + .size + .width / + 5 + : 0, + padding: + EdgeInsets.all(4), + decoration: BoxDecoration( + color: + Color(0xffb23838), + borderRadius: + BorderRadius.only( + topLeft: Radius + .circular( + 6)), + ), + child: Texts( + model + .parentProducts[ + index] + .rxMessage != + null + ? model + .parentProducts[ + index] + .rxMessage + : "", + color: Colors.white, + regular: true, + fontSize: 10, + fontWeight: + FontWeight.w400, + ), ), ], ), @@ -1020,36 +827,46 @@ class _ParentCategorisePageState extends State { vertical: 0, ), child: Column( - mainAxisAlignment: - MainAxisAlignment - .spaceAround, crossAxisAlignment: CrossAxisAlignment .start, children: [ - SizedBox( - height: 4.0, - ), - Container( - width: MediaQuery.of( - context) - .size - .width * - 0.65, - child: Texts( - model + if (model .parentProducts[ index] - .name, - regular: true, - fontSize: 13.2, - fontWeight: - FontWeight.w500, - maxLines: 5, + .discountName != + null) + Container( + width: + double.infinity, + height: 13.0, + decoration: + BoxDecoration( + color: Color( + 0xff5AB145), + ), + child: Center( + child: Texts( + model + .parentProducts[ + index] + .discountName, + regular: true, + color: + Colors.white, + fontSize: 10.4, + ), + ), ), - ), - SizedBox( - height: 8.0, + Texts( + model + .parentProducts[ + index] + .name, + regular: true, + fontSize: 12, + fontWeight: + FontWeight.w700, ), Padding( padding: @@ -1095,23 +912,233 @@ class _ParentCategorisePageState extends State { ], ), ), - onTap: () => { - Navigator.push( - context, - FadePage( - page: ProductDetailPage(model - .parentProducts[index]), - )), - }, - ); - }), - ) - ], - ), - ), - ], + ), + onTap: () => { + Navigator.push( + context, + FadePage( + page: ProductDetailPage(model + .parentProducts[index]), + )), + }, + )); + }, + ), + ) + : Container( + height: model.parentProducts.length * + MediaQuery.of(context).size.height * + 0.122, + child: ListView.builder( + physics: NeverScrollableScrollPhysics(), + itemCount: model.parentProducts.length, + itemBuilder: + (BuildContext context, int index) { + return InkWell( + child: Card( + child: Row( + children: [ + Stack( + children: [ + Column( + children: [ + Container( + decoration: + BoxDecoration(), + child: Padding( + padding: + EdgeInsets.only( + left: 9.0, + top: 8.0, + right: 10.0, + ), + ), + ), + Container( + margin: + EdgeInsets.fromLTRB( + 0, 0, 0, 0), + alignment: + Alignment.center, + child: Image.network( + model + .parentProducts[ + index] + .images + .isNotEmpty + ? model + .parentProducts[ + index] + .images[0] + .thumb + : 'https://upload.wikimedia.org/wikipedia/commons/thumb/6/6c/No_image_3x4.svg/1200px-No_image_3x4.svg.png', + fit: BoxFit.contain, + height: 80, + ), + ), + ], + ), + Column( + children: [ + Container( + width: model + .parentProducts[ + index] + .rxMessage != + null + ? MediaQuery.of( + context) + .size + .width / + 5 + : 0, + padding: + EdgeInsets.all(4), + decoration: BoxDecoration( + color: + Color(0xffb23838), + borderRadius: + BorderRadius.only( + topLeft: Radius + .circular( + 6)), + ), + child: Texts( + model + .parentProducts[ + index] + .rxMessage != + null + ? model + .parentProducts[ + index] + .rxMessage + : "", + color: Colors.white, + regular: true, + fontSize: 10, + fontWeight: + FontWeight.w400, + ), + ), + ], + ), + ], + ), + Container( + margin: EdgeInsets.symmetric( + horizontal: 6, + vertical: 0, + ), + child: Column( + mainAxisAlignment: + MainAxisAlignment + .spaceAround, + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + SizedBox( + height: 4.0, + ), + Container( + width: + MediaQuery.of(context) + .size + .width * + 0.65, + child: Texts( + model + .parentProducts[index] + .name, + regular: true, + fontSize: 13.2, + fontWeight: + FontWeight.w500, + maxLines: 5, + ), + ), + SizedBox( + height: 8.0, + ), + Padding( + padding: + const EdgeInsets.only( + top: 4, bottom: 4), + child: Texts( + "SAR ${model.parentProducts[index].price}", + bold: true, + fontSize: 14, + ), + ), + Row( + children: [ + StarRating( + totalAverage: model + .parentProducts[ + index] + .approvedRatingSum > + 0 + ? (model + .parentProducts[ + index] + .approvedRatingSum + .toDouble() / + model + .parentProducts[ + index] + .approvedRatingSum + .toDouble()) + .toDouble() + : 0, + forceStars: true), + Texts( + "(${model.parentProducts[index].approvedTotalReviews})", + regular: true, + fontSize: 10, + fontWeight: + FontWeight.w400, + ) + ], + ), + ], + ), + ), + ], + ), + ), + onTap: () => { + Navigator.push( + context, + FadePage( + page: ProductDetailPage( + model.parentProducts[index]), + )), + }, + ); + }), + ) + ], + ), ), ), )); } + + bool isEntityListSelected(CategoriseParentModel masterKey) { + Iterable history = + entityList.where((element) => masterKey.id == element.id); + if (history.length > 0) { + return true; + } + return false; + } + + bool isEntityListSelectedBrands(CategoriseParentModel masterKey) { + Iterable history = + entityListBrands.where((element) => masterKey.id == element.id); + if (history.length > 0) { + return true; + } + return false; + } } diff --git a/lib/pages/pharmacies/screens/cart-order-page.dart b/lib/pages/pharmacies/screens/cart-order-page.dart index cca6c1df..f672cc66 100644 --- a/lib/pages/pharmacies/screens/cart-order-page.dart +++ b/lib/pages/pharmacies/screens/cart-order-page.dart @@ -1,3 +1,4 @@ +import 'package:diplomaticquarterapp/core/enum/viewstate.dart'; import 'package:diplomaticquarterapp/core/model/pharmacies/Addresses.dart'; import 'package:diplomaticquarterapp/core/model/pharmacies/ShoppingCartResponse.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart'; @@ -7,6 +8,7 @@ import 'package:diplomaticquarterapp/pages/pharmacies/screens/cart-order-preview import 'package:diplomaticquarterapp/pages/pharmacies/screens/pharmacy-terms-conditions-page.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/widgets/ProductOrderItem.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; +import 'package:diplomaticquarterapp/uitl/utils.dart'; import 'package:diplomaticquarterapp/widgets/buttons/GestureIconButton.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; @@ -32,7 +34,7 @@ class CartOrderPage extends StatelessWidget { baseViewModel: model, backgroundColor: Colors.white, body: !(model.cartResponse.shoppingCarts == null || - model.cartResponse.shoppingCarts.length == 0) + model.cartResponse.shoppingCarts.length == 0) ? Container( height: height * 0.85, width: double.infinity, @@ -70,8 +72,16 @@ class CartOrderPage extends StatelessWidget { cart.shoppingCarts[index], () { print(cart.shoppingCarts[index] .quantity); - model.changeProductQuantity( - cart.shoppingCarts[index]); + model + .changeProductQuantity( + cart.shoppingCarts[index]) + .then((value) { + if (model.state == + ViewState.ErrorLocal) { + Utils.showErrorToast( + model.error); + } + }); }, () => model.deleteProduct( cart.shoppingCarts[index]))) @@ -246,64 +256,62 @@ class _OrderBottomWidgetState extends State { height: widget.height * 0.070, color: Color(0xffe6ffe0), padding: EdgeInsets.symmetric(horizontal: 4), - child: Expanded( - child: Row( - children: [ - InkWell( - onTap: () { - setState(() { - isAgree = !isAgree; - }); - }, - child: Container( - width: 25.0, - height: widget.height * 0.070, - decoration: new BoxDecoration( - color: !isAgree - ? Color(0xffeeeeee) - : Colors.green, - shape: BoxShape.circle, + child: Row( + children: [ + InkWell( + onTap: () { + setState(() { + isAgree = !isAgree; + }); + }, + child: Container( + width: 25.0, + height: widget.height * 0.070, + decoration: new BoxDecoration( + color: !isAgree + ? Color(0xffeeeeee) + : Colors.green, + shape: BoxShape.circle, + ), + child: !isAgree + ? null + : Padding( + padding: const EdgeInsets.all(0.0), + child: Icon( + Icons.check, + color: Colors.white, + size: 25, ), - child: !isAgree - ? null - : Padding( - padding: const EdgeInsets.all(0.0), - child: Icon( - Icons.check, - color: Colors.white, - size: 25, - ), - ), ), ), - Expanded( - child: Container( - padding: EdgeInsets.symmetric(horizontal: 4), - margin: const EdgeInsets.symmetric(vertical: 4), - child: Texts( - TranslationBase.of(context) - .pharmacyServiceTermsCondition, - fontSize: 13, - color: Colors.grey.shade800, - fontWeight: FontWeight.normal, - ), + ), + Expanded( + child: Container( + padding: EdgeInsets.symmetric(horizontal: 4), + margin: const EdgeInsets.symmetric(vertical: 4), + child: Texts( + TranslationBase.of(context) + .pharmacyServiceTermsCondition, + fontSize: 13, + color: Colors.grey.shade800, + fontWeight: FontWeight.normal, ), ), - InkWell( - onTap: () => { - Navigator.push(context, - FadePage(page: PharmacyTermsConditions())) - }, - child: Container( - child: Icon( - Icons.info, - size: 25, - color: Color(0xff005aff), - ), + ), + InkWell( + onTap: () => { + Navigator.push(context, + FadePage(page: PharmacyTermsConditions())) + }, + child: Container( + child: Icon( + Icons.info, + size: 25, + color: Color(0xff005aff), ), ), - ], - ), + ), + ], ), ), Container( diff --git a/lib/pages/pharmacies/screens/cart-order-preview.dart b/lib/pages/pharmacies/screens/cart-order-preview.dart index e0c062fa..7a726e7c 100644 --- a/lib/pages/pharmacies/screens/cart-order-preview.dart +++ b/lib/pages/pharmacies/screens/cart-order-preview.dart @@ -1,8 +1,11 @@ import 'package:diplomaticquarterapp/core/enum/viewstate.dart'; import 'package:diplomaticquarterapp/core/model/pharmacies/Addresses.dart'; +import 'package:diplomaticquarterapp/core/model/pharmacies/order_detail.dart'; import 'package:diplomaticquarterapp/core/model/pharmacies/payment-checkout-data.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart'; import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; +import 'package:diplomaticquarterapp/models/Appointments/AppoimentAllHistoryResultList.dart'; +import 'package:diplomaticquarterapp/models/Authentication/authenticated_user.dart'; import 'package:diplomaticquarterapp/pages/base/base_view.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/screens/address-select-page.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/screens/payment-method-select-page.dart'; @@ -12,6 +15,7 @@ import 'package:diplomaticquarterapp/pages/pharmacy/pharmacyAddresses/PharmacyAd import 'package:diplomaticquarterapp/uitl/app_toast.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; +import 'package:diplomaticquarterapp/widgets/in_app_browser/InAppBrowser.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; import 'package:flutter/material.dart'; @@ -30,10 +34,13 @@ class OrderPreviewPage extends StatelessWidget { return BaseView( onModelReady: (model) => model.getShoppingCart(), - builder: (_, model, wi) => ChangeNotifierProvider.value( + builder: (_, model, wi) => + ChangeNotifierProvider.value( value: model.paymentCheckoutData, child: AppScaffold( - appBarTitle: "${TranslationBase.of(context).checkOut}", + appBarTitle: "${TranslationBase + .of(context) + .checkOut}", isShowAppBar: true, isPharmacy: true, isShowDecPage: false, @@ -56,18 +63,18 @@ class OrderPreviewPage extends StatelessWidget { ), Consumer( builder: (ctx, paymentData, _) => - paymentData.lacumInformation != null - ? Container( - child: Column( - children: [ - LakumWidget(model), - SizedBox( - height: 10, - ), - ], - ), - ) - : Container()), + paymentData.lacumInformation != null + ? Container( + child: Column( + children: [ + LakumWidget(model), + SizedBox( + height: 10, + ), + ], + ), + ) + : Container()), Container( color: Colors.white, width: double.infinity, @@ -76,7 +83,9 @@ class OrderPreviewPage extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.start, children: [ Texts( - TranslationBase.of(context).reviewOrder, + TranslationBase + .of(context) + .reviewOrder, fontSize: 14, fontWeight: FontWeight.bold, color: Colors.black, @@ -85,8 +94,10 @@ class OrderPreviewPage extends StatelessWidget { model.cartResponse.shoppingCarts != null ? model.cartResponse.shoppingCarts.length : 0, - (index) => ProductOrderPreviewItem( - model.cartResponse.shoppingCarts[index]), + (index) => + ProductOrderPreviewItem( + model.cartResponse + .shoppingCarts[index]), ), ], ), @@ -96,117 +107,140 @@ class OrderPreviewPage extends StatelessWidget { padding: EdgeInsets.all(8), child: model.cartResponse.subtotal != null ? Column( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Texts( - TranslationBase.of(context) - .orderSummary, - fontSize: 14, - fontWeight: FontWeight.bold, - color: Colors.black, - ), - SizedBox( - height: 20, - ), - Row( - mainAxisAlignment: - MainAxisAlignment.spaceBetween, - children: [ - Texts( - "${TranslationBase.of(context).subtotal}", - fontSize: 14, - color: Colors.black, - fontWeight: FontWeight.w500, - ), - Texts( - "${TranslationBase.of(context).sar} ${(model.cartResponse.subtotal).toStringAsFixed(2)}", - fontSize: 14, - color: Colors.black, - fontWeight: FontWeight.w500, - ), - ], - ), - const Divider( - color: Color(0xFFD6D6D6), - height: 20, - thickness: 1, - indent: 0, - endIndent: 0, - ), - Row( - mainAxisAlignment: - MainAxisAlignment.spaceBetween, - children: [ - Texts( - "${TranslationBase.of(context).shipping}", - fontSize: 14, - color: Colors.black, - fontWeight: FontWeight.w500, - ), - Texts( - "${TranslationBase.of(context).sar} ${(model.totalAdditionalShippingCharge).toStringAsFixed(2)}", - fontSize: 14, - color: Colors.black, - fontWeight: FontWeight.w500, - ), - ], - ), - const Divider( - color: Color(0xFFD6D6D6), - height: 20, - thickness: 1, - indent: 0, - endIndent: 0, - ), - Row( - mainAxisAlignment: - MainAxisAlignment.spaceBetween, - children: [ - Texts( - "${TranslationBase.of(context).vat}", - fontSize: 14, - color: Colors.black, - fontWeight: FontWeight.w500, - ), - Texts( - "${TranslationBase.of(context).sar} ${(model.cartResponse.subtotalVatAmount).toStringAsFixed(2)}", - fontSize: 14, - color: Colors.black, - fontWeight: FontWeight.w500, - ), - ], - ), - const Divider( - color: Color(0xFFD6D6D6), - height: 20, - thickness: 1, - indent: 0, - endIndent: 0, - ), - Row( - mainAxisAlignment: - MainAxisAlignment.spaceBetween, - children: [ - Texts( - TranslationBase.of(context).total, - fontSize: 14, - color: Colors.black, - fontWeight: FontWeight.bold, - ), - Texts( - "${TranslationBase.of(context).sar} ${(model.cartResponse.subtotal).toStringAsFixed(2)}", - fontSize: 14, - color: Colors.black, - fontWeight: FontWeight.bold, - ), - ], - ), - SizedBox( - height: 10, - ), - ], - ) + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Texts( + TranslationBase + .of(context) + .orderSummary, + fontSize: 14, + fontWeight: FontWeight.bold, + color: Colors.black, + ), + SizedBox( + height: 20, + ), + Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + Texts( + "${TranslationBase + .of(context) + .subtotal}", + fontSize: 14, + color: Colors.black, + fontWeight: FontWeight.w500, + ), + Texts( + "${TranslationBase + .of(context) + .sar} ${(model.cartResponse.subtotal) + .toStringAsFixed(2)}", + fontSize: 14, + color: Colors.black, + fontWeight: FontWeight.w500, + ), + ], + ), + const Divider( + color: Color(0xFFD6D6D6), + height: 20, + thickness: 1, + indent: 0, + endIndent: 0, + ), + Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + Texts( + "${TranslationBase + .of(context) + .shipping}", + fontSize: 14, + color: Colors.black, + fontWeight: FontWeight.w500, + ), + Texts( + "${TranslationBase + .of(context) + .sar} ${(model + .totalAdditionalShippingCharge) + .toStringAsFixed(2)}", + fontSize: 14, + color: Colors.black, + fontWeight: FontWeight.w500, + ), + ], + ), + const Divider( + color: Color(0xFFD6D6D6), + height: 20, + thickness: 1, + indent: 0, + endIndent: 0, + ), + Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + Texts( + "${TranslationBase + .of(context) + .vat}", + fontSize: 14, + color: Colors.black, + fontWeight: FontWeight.w500, + ), + Texts( + "${TranslationBase + .of(context) + .sar} ${(model.cartResponse + .subtotalVatAmount).toStringAsFixed( + 2)}", + fontSize: 14, + color: Colors.black, + fontWeight: FontWeight.w500, + ), + ], + ), + const Divider( + color: Color(0xFFD6D6D6), + height: 20, + thickness: 1, + indent: 0, + endIndent: 0, + ), + Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + Texts( + TranslationBase + .of(context) + .total, + fontSize: 14, + color: Colors.black, + fontWeight: FontWeight.bold, + ), + Texts( + "${TranslationBase + .of(context) + .sar} ${(model.cartResponse.subtotal) + .toStringAsFixed(2)}", + fontSize: 14, + color: Colors.black, + fontWeight: FontWeight.bold, + ), + ], + ), + SizedBox( + height: 10, + ), + ], + ) : Container(), ) ], @@ -269,161 +303,172 @@ class _SelectAddressWidgetState extends State { @override Widget build(BuildContext context) { return Consumer( - builder: (ctx, paymentData, _) => Container( - color: Colors.white, - child: address == null - ? InkWell( - onTap: () => {_navigateToAddressPage()}, - child: Container( - margin: EdgeInsets.symmetric(vertical: 12, horizontal: 12), - child: Row( - children: [ - Image.asset( - "assets/images/pharmacy_module/ic_shipping_address.png", - width: 30.0, - height: 30.0, - fit: BoxFit.scaleDown, + builder: (ctx, paymentData, _) => + Container( + color: Colors.white, + child: address == null + ? InkWell( + onTap: () => {_navigateToAddressPage()}, + child: Container( + margin: EdgeInsets.symmetric(vertical: 12, horizontal: 12), + child: Row( + children: [ + Image.asset( + "assets/images/pharmacy_module/ic_shipping_address.png", + width: 30.0, + height: 30.0, + fit: BoxFit.scaleDown, + ), + Expanded( + child: Container( + padding: + EdgeInsets.symmetric(vertical: 0, horizontal: 6), + child: Texts( + TranslationBase + .of(context) + .selectAddress, + fontSize: 14, + fontWeight: FontWeight.bold, + color: Color(0xff0000ff), + ), ), - Expanded( - child: Container( - padding: - EdgeInsets.symmetric(vertical: 0, horizontal: 6), + ), + Icon( + Icons.arrow_forward_ios, + size: 20, + color: Colors.grey.shade400, + ), + ], + ), + ), + ) + : Container( + child: Container( + margin: EdgeInsets.symmetric(vertical: 12, horizontal: 12), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + children: [ + Image.asset( + "assets/images/pharmacy_module/ic_shipping_mark.png", + width: 30.0, + height: 30.0, + fit: BoxFit.scaleDown, + ), + Expanded( + child: Container( + padding: EdgeInsets.symmetric( + vertical: 0, horizontal: 6), + child: Texts( + TranslationBase + .of(context) + .shippingAddress, + fontSize: 14, + fontWeight: FontWeight.bold, + color: Colors.black, + ), + ), + ), + InkWell( + onTap: () => {_navigateToAddressPage()}, child: Texts( - TranslationBase.of(context).selectAddress, - fontSize: 14, - fontWeight: FontWeight.bold, + TranslationBase + .of(context) + .changeAddress, + fontSize: 12, + fontWeight: FontWeight.normal, color: Color(0xff0000ff), ), ), + ], + ), + Padding( + padding: const EdgeInsets.symmetric(vertical: 8), + child: Texts( + "${address.firstName} ${address.lastName}", + fontSize: 14, + fontWeight: FontWeight.bold, + color: Colors.black, ), - Icon( - Icons.arrow_forward_ios, - size: 20, - color: Colors.grey.shade400, + ), + Padding( + padding: const EdgeInsets.symmetric(vertical: 8), + child: Texts( + "${address.address1} ${address.address2} ${address + .address2},, ${address.city}, ${address + .country} ${address.zipPostalCode}", + fontSize: 12, + fontWeight: FontWeight.normal, + color: Colors.grey.shade500, ), - ], - ), - ), - ) - : Container( - child: Container( - margin: EdgeInsets.symmetric(vertical: 12, horizontal: 12), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - children: [ - Image.asset( - "assets/images/pharmacy_module/ic_shipping_mark.png", - width: 30.0, - height: 30.0, - fit: BoxFit.scaleDown, - ), - Expanded( - child: Container( - padding: EdgeInsets.symmetric( - vertical: 0, horizontal: 6), - child: Texts( - TranslationBase.of(context).shippingAddress, - fontSize: 14, - fontWeight: FontWeight.bold, - color: Colors.black, - ), - ), - ), - InkWell( - onTap: () => {_navigateToAddressPage()}, - child: Texts( - TranslationBase.of(context).changeAddress, - fontSize: 12, - fontWeight: FontWeight.normal, - color: Color(0xff0000ff), - ), + ), + Row( + children: [ + Container( + margin: const EdgeInsets.only(right: 8), + child: Icon( + Icons.phone, + size: 20, + color: Colors.black, ), - ], - ), - Padding( - padding: const EdgeInsets.symmetric(vertical: 8), - child: Texts( - "${address.firstName} ${address.lastName}", + ), + Texts( + "${address.phoneNumber}", fontSize: 14, fontWeight: FontWeight.bold, - color: Colors.black, + color: Colors.grey, ), - ), - Padding( - padding: const EdgeInsets.symmetric(vertical: 8), - child: Texts( - "${address.address1} ${address.address2} ${address.address2},, ${address.city}, ${address.country} ${address.zipPostalCode}", - fontSize: 12, - fontWeight: FontWeight.normal, - color: Colors.grey.shade500, + ], + ), + Container( + margin: EdgeInsets.symmetric(vertical: 8), + child: SizedBox( + height: 2, + width: double.infinity, + child: Container( + color: Color(0xffefefef), ), ), - Row( - children: [ - Container( - margin: const EdgeInsets.only(right: 8), - child: Icon( - Icons.phone, - size: 20, - color: Colors.black, - ), - ), - Texts( - "${address.phoneNumber}", - fontSize: 14, + ), + Row( + children: [ + Image.asset( + "assets/images/pharmacy_module/ic_shipping_truck.png", + width: 30.0, + height: 30.0, + fit: BoxFit.scaleDown, + ), + Container( + padding: EdgeInsets.symmetric( + vertical: 0, horizontal: 6), + child: Texts( + "${TranslationBase + .of(context) + .shipBy}", + fontSize: 12, fontWeight: FontWeight.bold, - color: Colors.grey, - ), - ], - ), - Container( - margin: EdgeInsets.symmetric(vertical: 8), - child: SizedBox( - height: 2, - width: double.infinity, - child: Container( - color: Color(0xffefefef), + color: Colors.black, ), ), - ), - Row( - children: [ - Image.asset( - "assets/images/pharmacy_module/ic_shipping_truck.png", - width: 30.0, - height: 30.0, - fit: BoxFit.scaleDown, - ), - Container( - padding: EdgeInsets.symmetric( - vertical: 0, horizontal: 6), - child: Texts( - "${TranslationBase.of(context).shipBy}", - fontSize: 12, - fontWeight: FontWeight.bold, - color: Colors.black, - ), - ), - Container( - child: Image.asset( - paymentData.shippingOption - .shippingRateComputationMethodSystemName == - "Shipping.FixedOrByWeight" - ? "assets/images/pharmacy_module/payment/hmg_shipping_logo.png" - : "assets/images/pharmacy_module/payment/aramex_shipping_logo.png", - fit: BoxFit.contain, - ), - margin: EdgeInsets.symmetric(horizontal: 8), + Container( + child: Image.asset( + paymentData.shippingOption + .shippingRateComputationMethodSystemName == + "Shipping.FixedOrByWeight" + ? "assets/images/pharmacy_module/payment/hmg_shipping_logo.png" + : "assets/images/pharmacy_module/payment/aramex_shipping_logo.png", + fit: BoxFit.contain, ), - ], - ), - ], - ), + margin: EdgeInsets.symmetric(horizontal: 8), + ), + ], + ), + ], ), - ), // ic_shipping_mark.png - ), + ), + ), // ic_shipping_mark.png + ), ); } } @@ -443,16 +488,17 @@ class _SelectPaymentOptionWidgetState extends State { _navigateToPaymentOption() { Navigator.push(context, FadePage(page: PaymentMethodSelectPage())) - .then((result) => { - setState(() { - if (result != null) { - paymentOption = result; - widget.model.paymentCheckoutData.paymentOption = - paymentOption; - widget.model.paymentCheckoutData.updateData(); - } - }) - }); + .then((result) => + { + setState(() { + if (result != null) { + paymentOption = result; + widget.model.paymentCheckoutData.paymentOption = + paymentOption; + widget.model.paymentCheckoutData.updateData(); + } + }) + }); } @override @@ -469,85 +515,89 @@ class _SelectPaymentOptionWidgetState extends State { color: Colors.white, child: paymentOption == null ? InkWell( - onTap: () => {_navigateToPaymentOption()}, - child: Container( - margin: EdgeInsets.symmetric(vertical: 12, horizontal: 12), - child: Row( - children: [ - Image.asset( - "assets/images/pharmacy_module/ic_payment_option.png", - width: 30.0, - height: 30.0, - fit: BoxFit.scaleDown, - ), - Expanded( - child: Container( - padding: - EdgeInsets.symmetric(vertical: 0, horizontal: 6), - child: Texts( - TranslationBase.of(context).selectPaymentOption, - fontSize: 14, - fontWeight: FontWeight.bold, - color: Color(0xff0000ff), - ), - ), - ), - Icon( - Icons.arrow_forward_ios, - size: 20, - color: Colors.grey.shade400, - ), - ], + onTap: () => {_navigateToPaymentOption()}, + child: Container( + margin: EdgeInsets.symmetric(vertical: 12, horizontal: 12), + child: Row( + children: [ + Image.asset( + "assets/images/pharmacy_module/ic_payment_option.png", + width: 30.0, + height: 30.0, + fit: BoxFit.scaleDown, + ), + Expanded( + child: Container( + padding: + EdgeInsets.symmetric(vertical: 0, horizontal: 6), + child: Texts( + TranslationBase + .of(context) + .selectPaymentOption, + fontSize: 14, + fontWeight: FontWeight.bold, + color: Color(0xff0000ff), + ), ), ), - ) + Icon( + Icons.arrow_forward_ios, + size: 20, + color: Colors.grey.shade400, + ), + ], + ), + ), + ) : Container( - margin: EdgeInsets.symmetric(vertical: 12, horizontal: 12), - child: Row( - children: [ - Image.asset( - "assets/images/pharmacy_module/ic_payment_option.png", - width: 30.0, - height: 30.0, - fit: BoxFit.scaleDown, - ), - Container( - margin: EdgeInsets.symmetric(horizontal: 8), - padding: EdgeInsets.symmetric(horizontal: 4, vertical: 0), - decoration: new BoxDecoration( - color: Colors.grey.shade100, - shape: BoxShape.rectangle, - ), - child: Image.asset( - widget.model.getPaymentOptionImage(paymentOption), - width: 30.0, - height: 30.0, - fit: BoxFit.scaleDown, - ), - ), - Expanded( - child: Container( - padding: EdgeInsets.symmetric(vertical: 0, horizontal: 6), - child: Texts( - widget.model.getPaymentOptionName(paymentOption), - fontSize: 14, - fontWeight: FontWeight.bold, - color: Colors.black, - ), - ), - ), - InkWell( - onTap: () => {_navigateToPaymentOption()}, - child: Texts( - TranslationBase.of(context).changeMethod, - fontSize: 12, - fontWeight: FontWeight.normal, - color: Color(0xff0000ff), - ), - ), - ], + margin: EdgeInsets.symmetric(vertical: 12, horizontal: 12), + child: Row( + children: [ + Image.asset( + "assets/images/pharmacy_module/ic_payment_option.png", + width: 30.0, + height: 30.0, + fit: BoxFit.scaleDown, + ), + Container( + margin: EdgeInsets.symmetric(horizontal: 8), + padding: EdgeInsets.symmetric(horizontal: 4, vertical: 0), + decoration: new BoxDecoration( + color: Colors.grey.shade100, + shape: BoxShape.rectangle, + ), + child: Image.asset( + widget.model.getPaymentOptionImage(paymentOption), + width: 30.0, + height: 30.0, + fit: BoxFit.scaleDown, + ), + ), + Expanded( + child: Container( + padding: EdgeInsets.symmetric(vertical: 0, horizontal: 6), + child: Texts( + widget.model.getPaymentOptionName(paymentOption), + fontSize: 14, + fontWeight: FontWeight.bold, + color: Colors.black, + ), + ), + ), + InkWell( + onTap: () => {_navigateToPaymentOption()}, + child: Texts( + TranslationBase + .of(context) + .changeMethod, + fontSize: 12, + fontWeight: FontWeight.normal, + color: Color(0xff0000ff), ), ), + ], + ), + ), ); } } @@ -585,12 +635,15 @@ class _LakumWidgetState extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ Texts( - "${TranslationBase.of(context).lakumPoints}", + "${TranslationBase + .of(context) + .lakumPoints}", fontSize: 12, fontWeight: FontWeight.bold, ), Texts( - "${widget.model.paymentCheckoutData.lacumInformation.lakumInquiryInformationObjVersion.pointsBalanceAmount}", + "${widget.model.paymentCheckoutData.lacumInformation + .lakumInquiryInformationObjVersion.pointsBalanceAmount}", fontSize: 12, fontWeight: FontWeight.normal, ), @@ -605,7 +658,9 @@ class _LakumWidgetState extends State { mainAxisAlignment: MainAxisAlignment.end, children: [ Texts( - "${TranslationBase.of(context).riyal}", + "${TranslationBase + .of(context) + .riyal}", fontSize: 12, fontWeight: FontWeight.bold, ), @@ -619,19 +674,19 @@ class _LakumWidgetState extends State { decoration: InputDecoration( border: OutlineInputBorder( borderSide: - BorderSide(color: Colors.black, width: 0.2), + BorderSide(color: Colors.black, width: 0.2), gapPadding: 0, borderRadius: projectProvider.isArabic ? BorderRadius.only( - topRight: Radius.circular(8), - bottomRight: Radius.circular(8)) + topRight: Radius.circular(8), + bottomRight: Radius.circular(8)) : BorderRadius.only( - topLeft: Radius.circular(8), - bottomLeft: Radius.circular(8)), + topLeft: Radius.circular(8), + bottomLeft: Radius.circular(8)), ), disabledBorder: OutlineInputBorder( borderSide: - BorderSide(color: Colors.black, width: 0.4), + BorderSide(color: Colors.black, width: 0.4), gapPadding: 0, borderRadius: BorderRadius.only( topLeft: Radius.circular(8), @@ -643,22 +698,22 @@ class _LakumWidgetState extends State { style: TextStyle( fontSize: 14, color: widget - .model - .paymentCheckoutData - .lacumInformation - .lakumInquiryInformationObjVersion - .pointsBalanceAmount > - 0 + .model + .paymentCheckoutData + .lacumInformation + .lakumInquiryInformationObjVersion + .pointsBalanceAmount > + 0 ? Colors.black : Colors.grey, ), enabled: widget - .model - .paymentCheckoutData - .lacumInformation - .lakumInquiryInformationObjVersion - .pointsBalanceAmount == - 0 + .model + .paymentCheckoutData + .lacumInformation + .lakumInquiryInformationObjVersion + .pointsBalanceAmount == + 0 ? false : true, onChanged: (val) { @@ -677,7 +732,7 @@ class _LakumWidgetState extends State { widget.model.paymentCheckoutData.usedLakumPoints = 0; } _pointsController.text = - "${widget.model.paymentCheckoutData.usedLakumPoints}"; + "${widget.model.paymentCheckoutData.usedLakumPoints}"; }, ), ), @@ -689,18 +744,20 @@ class _LakumWidgetState extends State { shape: BoxShape.rectangle, borderRadius: projectProvider.isArabic ? BorderRadius.only( - topLeft: Radius.circular(6), - bottomLeft: Radius.circular(6)) + topLeft: Radius.circular(6), + bottomLeft: Radius.circular(6)) : BorderRadius.only( - topRight: Radius.circular(6), - bottomRight: Radius.circular(6)), + topRight: Radius.circular(6), + bottomRight: Radius.circular(6)), border: Border.fromBorderSide(BorderSide( color: Color(0xff3666E0), width: 0.8, )), ), child: Texts( - "${TranslationBase.of(context).use}", + "${TranslationBase + .of(context) + .use}", fontSize: 12, color: Colors.white, fontWeight: FontWeight.bold, @@ -719,106 +776,176 @@ class _LakumWidgetState extends State { class PaymentBottomWidget extends StatelessWidget { final OrderPreviewViewModel model; + BuildContext context; + MyInAppBrowser browser; + PaymentBottomWidget(this.model); @override Widget build(BuildContext context) { final scaffold = Scaffold.of(context); + this.context = context; return Container( margin: EdgeInsets.symmetric(horizontal: 10, vertical: 0), child: Consumer( - builder: (ctx, paymentData, _) => paymentData.cartDataVisible + builder: (ctx, paymentData, _) => + paymentData.cartDataVisible ? Container( - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: MainAxisAlignment.spaceEvenly, + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + Container( + margin: + EdgeInsets.symmetric(horizontal: 0, vertical: 4), + child: Row( children: [ - Container( - margin: - EdgeInsets.symmetric(horizontal: 0, vertical: 4), - child: Row( - children: [ - Texts( - "${TranslationBase.of(context).sar} ${(model.cartResponse.subtotal).toStringAsFixed(2)}", - fontSize: 14, - fontWeight: FontWeight.bold, - color: Color(0xff929295), - ), - Padding( - padding: - const EdgeInsets.symmetric(horizontal: 4), - child: Texts( - "${TranslationBase.of(context).inclusiveVat}", - fontSize: 8, - color: Color(0xff929295), - fontWeight: FontWeight.w600, - ), - ), - ], - ), - ), Texts( - "${model.cartResponse.quantityCount} ${TranslationBase.of(context).items}", - fontSize: 10, - color: Colors.grey, + "${TranslationBase + .of(context) + .sar} ${(model.cartResponse.subtotal) + .toStringAsFixed(2)}", + fontSize: 14, fontWeight: FontWeight.bold, + color: Color(0xff929295), ), - ], - ), - Container( - child: RaisedButton( - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(8), - side: BorderSide( + Padding( + padding: + const EdgeInsets.symmetric(horizontal: 4), + child: Texts( + "${TranslationBase + .of(context) + .inclusiveVat}", + fontSize: 8, color: Color(0xff929295), - width: 1, + fontWeight: FontWeight.w600, ), ), - onPressed: (paymentData.address != null && - paymentData.paymentOption != null) - ? () async { - await model.makeOrder(); - if (model.state != ViewState.Idle) { - AppToast.showSuccessToast(message: "Order has been placed successfully!!"); - } else { - AppToast.showErrorToast(message: model.error); - } - Navigator.pop(context); - Navigator.pop(context); - } - : null, - child: Padding( - padding: const EdgeInsets.symmetric(vertical: 16), - child: new Text( - "${TranslationBase.of(context).proceedPay}", - style: new TextStyle( - color: (paymentData.address != null && - paymentData.paymentOption != null) - ? Colors.white - : Colors.grey.shade400, - fontWeight: FontWeight.bold, - fontSize: 12), - ), - ), - color: (paymentData.address != null && - paymentData.paymentOption != null) - ? Colors.green - : Color(0xff929295), - disabledColor: (paymentData.address != null && - paymentData.paymentOption != null) - ? Colors.green - : Color(0xff929295), - ), + ], ), - ], + ), + Texts( + "${model.cartResponse.quantityCount} ${TranslationBase + .of(context) + .items}", + fontSize: 10, + color: Colors.grey, + fontWeight: FontWeight.bold, + ), + ], + ), + Container( + child: RaisedButton( + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(8), + side: BorderSide( + color: Color(0xff929295), + width: 1, + ), + ), + onPressed: (paymentData.address != null && + paymentData.paymentOption != null) + ? () async { + await model.makeOrder(); + if (model.state == ViewState.Idle) { + AppToast.showSuccessToast( + message: "Order has been placed successfully!!"); + openPayment(model.orderListModel[0], model.user); + } else { + AppToast.showErrorToast(message: model.error); + } + Navigator.pop(context); + Navigator.pop(context); + } + : null, + child: Padding( + padding: const EdgeInsets.symmetric(vertical: 16), + child: new Text( + "${TranslationBase + .of(context) + .proceedPay}", + style: new TextStyle( + color: (paymentData.address != null && + paymentData.paymentOption != null) + ? Colors.white + : Colors.grey.shade400, + fontWeight: FontWeight.bold, + fontSize: 12), + ), + ), + color: (paymentData.address != null && + paymentData.paymentOption != null) + ? Colors.green + : Color(0xff929295), + disabledColor: (paymentData.address != null && + paymentData.paymentOption != null) + ? Colors.green + : Color(0xff929295), ), - ) + ), + ], + ), + ) : Container(), ), ); } + + openPayment(OrderDetailModel order, + AuthenticatedUser authenticatedUser,) { + browser = new MyInAppBrowser( + onExitCallback: onBrowserExit, onLoadStartCallback: onBrowserLoadStart); + + browser.openPharmacyPaymentBrowser( + order, + order.orderTotal, + 'ePharmacy Order', + order.id, + order.billingAddress.email, + order.customValuesXml, + "${authenticatedUser.firstName} ${authenticatedUser + .middleName} ${authenticatedUser.lastName}", + authenticatedUser.patientID, + authenticatedUser, + browser); + } + + onBrowserLoadStart(String url) { + print("onBrowserLoadStart"); + print(url); + + MyInAppBrowser.successURLS.forEach((element) { + if (url.contains(element)) { + if (browser.isOpened()) browser.close(); + MyInAppBrowser.isPaymentDone = true; + return; + } + }); + + MyInAppBrowser.errorURLS.forEach((element) { + if (url.contains(element)) { + if (browser.isOpened()) browser.close(); + MyInAppBrowser.isPaymentDone = false; + return; + } + }); + } + + onBrowserExit(AppoitmentAllHistoryResultList appo, bool isPaymentMade) { + print("onBrowserExit Called!!!!"); + if (isPaymentMade) { + AppToast.showSuccessToast( + message: "شكراً\nPayment status for your order is Paid"); + Navigator.pop(context); + Navigator.pop(context); + } else { + AppToast.showErrorToast( + message: + "Transaction Failed!\Your transaction is field to some reason please try again or contact to the administration"); + } + } } diff --git a/lib/pages/pharmacies/widgets/ProductOrderItem.dart b/lib/pages/pharmacies/widgets/ProductOrderItem.dart index 92e2c39d..d7a82cc6 100644 --- a/lib/pages/pharmacies/widgets/ProductOrderItem.dart +++ b/lib/pages/pharmacies/widgets/ProductOrderItem.dart @@ -72,7 +72,7 @@ class _ProductOrderItemState extends State { child: Texts( projectProvider.isArabic ? widget.item.product.namen - : widget.item.product.name, + : "${widget.item.product.name}", regular: true, textAlign: TextAlign.justify, fontSize: 12, @@ -88,91 +88,90 @@ class _ProductOrderItemState extends State { ), margin: const EdgeInsets.only(bottom: 4), ), - Row( - children: [ - InkWell( - onTap: () => - {_quantityOnChangeClick(Operation.dec)}, - child: Container( - width: 25, - height: 25, - child: Center( - child: Texts( - "-", - color: Colors.grey.shade400, - )), - decoration: BoxDecoration( - border: Border.all( - color: Colors.grey.shade400, - width: 1.0, + Container( + margin: EdgeInsets.symmetric(vertical: 4), + child: Row( + children: [ + InkWell( + onTap: () => + {_quantityOnChangeClick(Operation.dec)}, + child: Container( + width: 25, + height: 25, + child: Icon( + Icons.remove, color: Colors.grey.shade400, size: 20, + ), + decoration: BoxDecoration( + border: Border.all( + color: Colors.grey.shade400, + width: 1.0, + ), ), ), ), - ), - Container( - margin: - const EdgeInsets.symmetric(horizontal: 4), - width: 25, - height: 25, - color: Colors.grey.shade300, - child: Center( - child: TextField( - cursorColor: Colors.black, - keyboardType: TextInputType.number, - controller: _quantityController, - textAlign: TextAlign.center, - onChanged: (text) { - setState(() { - var value = int.tryParse(text); - if (value == null) { - widget.item.quantity = 0; - } else { - widget.item.quantity = int.parse(text); - } - _totalPrice = - "${(widget.item.product.price * widget.item.quantity).toStringAsFixed(2)}"; - }); - }, - )), - ), - InkWell( - onTap: () => - {_quantityOnChangeClick(Operation.inc)}, - child: Container( + Container( + margin: + const EdgeInsets.symmetric(horizontal: 4), width: 25, height: 25, + color: Colors.grey.shade300, child: Center( - child: Texts( - "+", - color: Colors.grey.shade400, + child: TextField( + cursorColor: Colors.black, + keyboardType: TextInputType.number, + controller: _quantityController, + textAlign: TextAlign.center, + onChanged: (text) { + setState(() { + var value = int.tryParse(text); + if (value == null) { + widget.item.quantity = 0; + } else { + widget.item.quantity = int.parse(text); + } + _totalPrice = + "${(widget.item.product.price * widget.item.quantity).toStringAsFixed(2)}"; + }); + }, )), - decoration: BoxDecoration( - border: Border.all( - color: Colors.grey.shade400, - width: 1.0, - ), - ), ), - ), - Expanded( - child: Column( - crossAxisAlignment: CrossAxisAlignment.end, - children: [ - Texts( - TranslationBase.of(context).total, - color: Colors.grey.shade500, - fontWeight: FontWeight.bold, - fontSize: 12, + InkWell( + onTap: () => + {_quantityOnChangeClick(Operation.inc)}, + child: Container( + width: 25, + height: 25, + child: Icon( + Icons.add, color: Colors.grey.shade400, size: 20, + ), + decoration: BoxDecoration( + border: Border.all( + color: Colors.grey.shade400, + width: 1.0, + ), ), - Texts( - "$_totalPrice ${projectProvider.isArabic ? widget.item.currencyn : widget.item.currency}", - fontSize: 12, - fontWeight: FontWeight.bold, - ) - ], + ), ), - ) - ], + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + Texts( + TranslationBase.of(context).total, + color: Colors.grey.shade500, + fontWeight: FontWeight.bold, + fontSize: 12, + ), + Texts( + "$_totalPrice ${projectProvider.isArabic ? widget.item.currencyn : widget.item.currency}", + fontSize: 12, + fontWeight: FontWeight.bold, + ) + ], + ), + ) + ], + ), ) ], ), diff --git a/lib/pages/pharmacy_categorise.dart b/lib/pages/pharmacy_categorise.dart index 033c7087..65886dc5 100644 --- a/lib/pages/pharmacy_categorise.dart +++ b/lib/pages/pharmacy_categorise.dart @@ -104,7 +104,17 @@ class _PharmacyCategorisePageState extends State { child: Padding( padding: EdgeInsets.all(4.0), child: InkWell( - onTap: () {}, + onTap: () { + Navigator.push( + context, + FadePage( + page: FinalProductsPage( + id: "", + productType: 4, + ), + ), + ); + }, child: Container( height: 50.0, width: 55.0, @@ -181,7 +191,15 @@ class _PharmacyCategorisePageState extends State { padding: EdgeInsets.all(4.0), child: InkWell( onTap: () { - // _scanQrAndGetPatient(context, model); + Navigator.push( + context, + FadePage( + page: FinalProductsPage( + id: "", + productType: 3, + ), + ), + ); }, child: Container( height: 50.0, diff --git a/lib/pages/sub_categorise_page.dart b/lib/pages/sub_categorise_page.dart index 7c14e05d..cc374b96 100644 --- a/lib/pages/sub_categorise_page.dart +++ b/lib/pages/sub_categorise_page.dart @@ -1,9 +1,11 @@ +import 'package:diplomaticquarterapp/core/model/pharmacy/categorise_parent_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacy_categorise_view_model.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/product_detail.dart'; import 'package:diplomaticquarterapp/widgets/buttons/button.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:diplomaticquarterapp/widgets/others/StarRating.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_pharmacy_widget.dart'; +import 'package:diplomaticquarterapp/widgets/others/entity_checkbox_list.dart'; import 'package:diplomaticquarterapp/widgets/others/network_base_view.dart'; import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; import 'package:flutter/material.dart'; @@ -40,9 +42,12 @@ class _SubCategorisePageState extends State { color: Colors.blue, size: 29.0, ); - + List entityList = List(); + List entityListBrands = List(); @override Widget build(BuildContext context) { + TextEditingController minField = TextEditingController(); + TextEditingController maxField = TextEditingController(); return BaseView( onModelReady: (model) => model.getSubCategorise(i: id), builder: (BuildContext context, PharmacyCategoriseViewModel model, @@ -56,7 +61,6 @@ class _SubCategorisePageState extends State { baseViewModel: model, body: SingleChildScrollView( child: Container( - height: MediaQuery.of(context).size.height * 5.97, child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -282,6 +286,7 @@ class _SubCategorisePageState extends State { return SingleChildScrollView( controller: scrollController, child: Container( + color: Colors.white, height: MediaQuery.of(context) .size .height * @@ -333,45 +338,34 @@ class _SubCategorisePageState extends State { title: Texts('Categorise'), children: [ - Container( - height: 350, - child: ListView - .builder( - controller: - scrollController, - scrollDirection: - Axis - .vertical, - shrinkWrap: - true, - itemCount: model - .categoriseParent - .length, - itemBuilder: - (BuildContext - context, - int index) { - return CheckboxListTile( - tristate: - true, - title: Texts(model - .categoriseParent[index] - .name), - controlAffinity: - ListTileControlAffinity.leading, - value: - checkedCategorise, - onChanged: - (bool - value) { - setState( - () { - checkedCategorise = - value; - }); - }, - ); - }), + ProcedureListWidget( + model: model, + masterList: model + .subCategorise, + removeHistory: + (item) { + setState(() { + entityList + .remove( + item); + }); + }, + addHistory: + (history) { + setState(() { + entityList.add( + history); + }); + }, + addSelectedHistories: + () { + //TODO build your fun herr + // widget.addSelectedHistories(); + }, + isEntityListSelected: + (master) => + isEntityListSelected( + master), ) ], ), @@ -382,45 +376,35 @@ class _SubCategorisePageState extends State { ExpansionTile( title: Texts('Brands'), children: [ - Container( - height: 350, - child: ListView - .builder( - scrollDirection: - Axis - .vertical, - shrinkWrap: - true, - itemCount: model - .brandsList - .length, - itemBuilder: - (BuildContext - context, - int index) { - return CheckboxListTile( - tristate: - true, - title: Texts(model - .brandsList[index] - .name), - controlAffinity: - ListTileControlAffinity.leading, - value: - checkedBrands, - onChanged: - (bool - value) { - setState( - () { - checkedBrands = - value; - }); - }, - autofocus: - true, - ); - }), + ProcedureListWidget( + model: model, + masterList: model + .brandsList, + removeHistory: + (item) { + setState(() { + entityListBrands + .remove( + item); + }); + }, + addHistory: + (history) { + setState(() { + entityListBrands + .add( + history); + }); + }, + addSelectedHistories: + () { + //TODO build your fun herr + // widget.addSelectedHistories(); + }, + isEntityListSelected: + (master) => + isEntityListSelectedBrands( + master), ) ], ), @@ -460,6 +444,8 @@ class _SubCategorisePageState extends State { border: OutlineInputBorder(), ), + controller: + minField, ), ), ], @@ -485,6 +471,8 @@ class _SubCategorisePageState extends State { border: OutlineInputBorder(), ), + controller: + maxField, ), ), ], @@ -527,6 +515,50 @@ class _SubCategorisePageState extends State { Container( width: 200, child: Button( + onTap: () { + String + categoriesId = + ""; + for (CategoriseParentModel category + in entityList) { + if (categoriesId == + "") { + categoriesId = + category + .id; + } else { + categoriesId = + "$categoriesId,${category.id}"; + } + } + String + brandIds = + ""; + for (CategoriseParentModel brand + in entityListBrands) { + if (brandIds == + "") { + brandIds = + brand + .id; + } else { + brandIds = + "$brandIds,${brand.id}"; + } + } + + model.getFilteredProducts( + min: minField + .text + .toString(), + max: maxField + .text + .toString(), + categoryId: + categoriesId, + brandId: + brandIds); + }, label: 'Apply', backgroundColor: Colors @@ -596,7 +628,9 @@ class _SubCategorisePageState extends State { ), styleOne == true ? Container( - height: MediaQuery.of(context).size.height * 3.85, + height: model.subProducts.length * + MediaQuery.of(context).size.height * + 0.15, child: GridView.builder( physics: NeverScrollableScrollPhysics(), gridDelegate: @@ -604,7 +638,7 @@ class _SubCategorisePageState extends State { crossAxisCount: 2, crossAxisSpacing: 0.5, mainAxisSpacing: 2.0, - childAspectRatio: 1.0, + childAspectRatio: 0.9, ), itemCount: model.subProducts.length, itemBuilder: (BuildContext context, int index) { @@ -798,7 +832,9 @@ class _SubCategorisePageState extends State { ), ) : Container( - height: MediaQuery.of(context).size.height * 5.0, + height: model.subProducts.length * + MediaQuery.of(context).size.height * + 0.122, child: ListView.builder( physics: NeverScrollableScrollPhysics(), itemCount: model.subProducts.length, @@ -991,4 +1027,22 @@ class _SubCategorisePageState extends State { ), )); } + + bool isEntityListSelected(CategoriseParentModel masterKey) { + Iterable history = + entityList.where((element) => masterKey.id == element.id); + if (history.length > 0) { + return true; + } + return false; + } + + bool isEntityListSelectedBrands(CategoriseParentModel masterKey) { + Iterable history = + entityListBrands.where((element) => masterKey.id == element.id); + if (history.length > 0) { + return true; + } + return false; + } } diff --git a/lib/uitl/translations_delegate_base.dart b/lib/uitl/translations_delegate_base.dart index a24be50a..492cf049 100644 --- a/lib/uitl/translations_delegate_base.dart +++ b/lib/uitl/translations_delegate_base.dart @@ -1573,6 +1573,11 @@ class TranslationBase { String get shippingAddresss => localizedValues["shipping-address"][locale.languageCode]; String get covidAlert => localizedValues["covid-alert"][locale.languageCode]; + String get onlineCheckInAgreement => localizedValues["onlineCheckInAgreement"][locale.languageCode]; + String get chiefComplaints => localizedValues["chiefComplaints"][locale.languageCode]; + String get errorChiefComplaints => localizedValues["errorChiefComplaints"][locale.languageCode]; + String get expectedArrivalTime => localizedValues["expectedArrivalTime"][locale.languageCode]; + String get errorExpectedArrivalTime => localizedValues["errorExpectedArrivalTimes"][locale.languageCode]; String get anicllaryOrders => localizedValues["ancillary-orders"][locale.languageCode]; String get mrn => localizedValues["MRN"][locale.languageCode]; diff --git a/lib/widgets/others/entity_checkbox_list.dart b/lib/widgets/others/entity_checkbox_list.dart new file mode 100644 index 00000000..da09a0ac --- /dev/null +++ b/lib/widgets/others/entity_checkbox_list.dart @@ -0,0 +1,170 @@ +import 'package:diplomaticquarterapp/core/model/pharmacy/categorise_parent_model.dart'; +import 'package:diplomaticquarterapp/core/viewModels/pharmacy_categorise_view_model.dart'; +import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; +import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; +import 'package:diplomaticquarterapp/widgets/input/text_field.dart'; +import 'package:diplomaticquarterapp/widgets/others/network_base_view.dart'; +import 'package:diplomaticquarterapp/widgets/text/app_texts_widget.dart'; +import 'package:eva_icons_flutter/eva_icons_flutter.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; + +class ProcedureListWidget extends StatefulWidget { + final PharmacyCategoriseViewModel model; + final Function addSelectedHistories; + final Function(CategoriseParentModel) removeHistory; + final Function(CategoriseParentModel) addHistory; + final Function(CategoriseParentModel) addRemarks; + + final bool Function(CategoriseParentModel) isEntityListSelected; + final List masterList; + + ProcedureListWidget( + {Key key, + this.model, + this.addSelectedHistories, + this.removeHistory, + this.masterList, + this.addHistory, + this.isEntityListSelected, + this.addRemarks}) + : super(key: key); + + @override + _ProcedureListWidgetState createState() => _ProcedureListWidgetState(); +} + +class _ProcedureListWidgetState extends State { + int selectedType = 0; + int typeUrgent; + int typeRegular; + + setSelectedType(int val) { + setState(() { + selectedType = val; + }); + } + + List items = List(); + List remarksList = List(); + List typeList = List(); + + @override + void initState() { + items.addAll(widget.masterList); + super.initState(); + } + + TextEditingController remarksController = TextEditingController(); + @override + Widget build(BuildContext context) { + return Container( + child: Column( + children: [ + NetworkBaseView( + baseViewModel: widget.model, + child: Container( + height: MediaQuery.of(context).size.height * 0.35, + child: Center( + child: Container( + margin: EdgeInsets.only(top: 15), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(12), + color: Colors.white), + child: ListView( + children: [ + // TextFields( + // hintText: + // 'sss', //TranslationBase.of(context).searchProcedures, + // suffixIcon: EvaIcons.search, + // onChanged: (value) { + // filterSearchResults(value); + // }, + // ), + SizedBox( + height: 15, + ), + items.length != 0 + ? Column( + children: items.map((historyInfo) { + return Column( + children: [ + Row( + children: [ + Checkbox( + value: widget.isEntityListSelected( + historyInfo), + activeColor: Colors.red[800], + onChanged: (bool newValue) { + setState(() { + if (widget.isEntityListSelected( + historyInfo)) { + widget + .removeHistory(historyInfo); + } else { + widget.addHistory(historyInfo); + } + }); + }), + Expanded( + child: Padding( + padding: const EdgeInsets.symmetric( + horizontal: 10, vertical: 0), + child: Texts(historyInfo.name, + variant: "bodyText", + bold: true, + color: Colors.black), + ), + ), + ], + ), + Divider( + height: 1, + ), + ], + ); + }).toList(), + ) + : Center( + child: Container( + child: AppText( + "There's no procedures for this category", + color: Color(0xFFB9382C)), + ), + ) + ], + ), + )), + ), + ), + SizedBox( + height: 10, + ), + ], + ), + ); + } + + void filterSearchResults(String query) { + List dummySearchList = List(); + dummySearchList.addAll(widget.masterList); + if (query.isNotEmpty) { + List dummyListData = List(); + dummySearchList.forEach((item) { + if (item.name.toLowerCase().contains(query.toLowerCase())) { + dummyListData.add(item); + } + }); + setState(() { + items.clear(); + items.addAll(dummyListData); + }); + return; + } else { + setState(() { + items.clear(); + items.addAll(widget.masterList); + }); + } + } +}