diff --git a/lib/config/config.dart b/lib/config/config.dart index 1035e221..ebca956b 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -83,8 +83,11 @@ const GET_BABYINFORMATION_REQUEST = const GET_BABY_BY_USER_ID = 'Services/Community.svc/REST/GetBabyByUserID'; ///userInformation -const GET_USERINFORMATION_REQUEST = - 'Services/Community.svc/REST/GetUserInformation_New'; +const GET_USERINFORMATION_REQUEST = 'Services/Community.svc/REST/GetUserInformation_New'; + +///Update email +const UPDATE_PATENT_EMAIL = 'Services/Patients.svc/REST/UpdatePateintEmail'; +const UPDATE_PATENT_INFO = 'Services/Community.svc/REST/UpdateUserInfo_New'; ///addNewChild const GET_NEWCHILD_REQUEST = 'Services/Community.svc/REST/CreateNewBaby'; @@ -92,8 +95,8 @@ const GET_NEWCHILD_REQUEST = 'Services/Community.svc/REST/CreateNewBaby'; ///newUserId const GET_NEW_USER_REQUEST = 'Services/Community.svc/REST/CreateNewUser_New'; -///delteChild -const DELETE_CHILD_REQUEST = 'Services/Community.svc/REST/DeleteBaby'; +///delete Child +const DELETE_CHILD_REQUEST = '/Services/Community.svc/REST/DeleteBaby'; ///addNewTABLE const GET_TABLE_REQUEST = 'Services/Community.svc/REST/CreateVaccinationTable'; @@ -371,6 +374,16 @@ const PUSH_NOTIFICATION_GET_ALL_NOTIFICATIONS = 'Services/MobileNotifications.svc/REST/PushNotification_GetAllNotifications'; const PUSH_NOTIFICATION_SET_MESSAGES_FROM_POOL_AS_READ = 'Services/MobileNotifications.svc/REST/PushNotification_SetMessagesFromPoolAsRead'; +const GET_PATIENT_ALL_PRES_ORD= 'Services/Patients.svc/REST/PatientER_GetPatientAllPresOrders'; +const PATIENT_ER_INSERT_PRES_ORDER= 'Services/Patients.svc/REST/PatientER_InsertPresOrder'; + + +// External API +const ADD_ADDRESS_INFO= "https://mdlaboratories.com/exacartapi/api/addcustomeraddress"; +const GET_CUSTOMER_ADDRESSES= "https://mdlaboratories.com/exacartapi/api/Customers/"; +const GET_CUSTOMER_INFO = "https://mdlaboratories.com/exacartapi/api/VerifyCustomer"; + + const TIMER_MIN = 10; const GOOGLE_API_KEY = "AIzaSyCmevVlr2Bh-c8W1VUzo8gt8JRY7n5PANw"; diff --git a/lib/config/localized_values.dart b/lib/config/localized_values.dart index ab0ac7bb..a5b22d8c 100644 --- a/lib/config/localized_values.dart +++ b/lib/config/localized_values.dart @@ -720,6 +720,9 @@ const Map localizedValues = { "drag-point": { "en": "Drag point to change your age", "ar": "اسحب لتغيير عمرك" + },"HHCNotAuthMsg": { + "en": "This service provides a set of home health care services, continuous and comprehensive follow-up in their places of residence for those who cannot access health facilities, such as (laboratory analyzes - radiology - vaccinations - physical therapy), etc.", + "ar": "من خلال هذه الخدمة يمكنك طلب مجموعة من الفحوصات التي تساعدك وتساعد طبيبك في فهم حالتك الصحية الحالية ومن ثم تحديد المخاطر المحتملة" }, "email": {"en": "Email", "ar": "البريد الالكتروني"}, "Book": {"en": "Book", "ar": "احجز"}, @@ -1112,10 +1115,14 @@ const Map localizedValues = { "en": "Delete", "ar": "حذف" }, - "deleted-child": { + "deleted-child-mes": { "en": "The request was successful. The children have removed from the vaccination schedule subscription service.", "ar": "تم حذف الطفل بنجاح" }, + "deleted-child":{ + "en":"Delete child", + "ar":"إالغاء الطفل" + }, "visit": { "en": "Visit", "ar": "زيارة" @@ -1128,6 +1135,26 @@ const Map localizedValues = { "en": "Due date", "ar": "تاريخ الاستحقاق" }, + "valid-email": { + "en": "Please enter valid email", + "ar": "الرجاء إدخال عنوان بريد صحيح" + }, + "confirm-send": { + "en": "Send the child's schedule to the email?", + "ar": "ارسال جدول التطعيمات الى بريدك الالكتروني؟" + }, + "email-success": { + "en": " The request was successful. You will receive the Schedule in moments.", + "ar": "تم ارسال جدول التطعيمات " + }, + "add-instructions": { + "en": "Add the child's information below to recieve the schedule of vaccinations.", + "ar": "أضف معلومات الطفل لاستلام جدول التطعيمات" + }, + "added-child": { + "en": "The request was successful. You have added a child to the vaccination schedule subscription service.", + "ar": "تمت الاضافة بنجاح." + }, "appUpdate": { "en": "UPDATE THE APP", "ar": "تحديث التطبيق" diff --git a/lib/core/service/AlHabibMedicalService/cmc_service.dart b/lib/core/service/AlHabibMedicalService/cmc_service.dart index dffa6683..9e99f3ad 100644 --- a/lib/core/service/AlHabibMedicalService/cmc_service.dart +++ b/lib/core/service/AlHabibMedicalService/cmc_service.dart @@ -1,4 +1,5 @@ import 'package:diplomaticquarterapp/config/config.dart'; +import 'package:diplomaticquarterapp/core/enum/OrderService.dart'; import 'package:diplomaticquarterapp/core/model/AlHabibMedicalService/ComprehensiveMedicalCheckup/cmc_get_items_request_model.dart'; import 'package:diplomaticquarterapp/core/model/AlHabibMedicalService/ComprehensiveMedicalCheckup/cmc_get_items_response_model.dart'; import 'package:diplomaticquarterapp/core/model/AlHabibMedicalService/ComprehensiveMedicalCheckup/cmc_insert_pres_order_request_model.dart'; @@ -47,8 +48,9 @@ class CMCService extends BaseService { await baseAppClient.post(GET_PATIENT_ALL_PRES_ORDERS, onSuccess: (dynamic response, int statusCode) { cmcAllPresOrdersList.clear(); + cmcAllOrderDetail.clear(); response['PatientER_GetPatientAllPresOrdersList'].forEach((data) { - if (data['ServiceID'] == 3) + if (data['ServiceID'] == OrderService.Comprehensive_Medical_Checkup.getIdOrderService()) cmcAllPresOrdersList .add(GetHHCAllPresOrdersResponseModel.fromJson(data)); }); @@ -104,7 +106,7 @@ class CMCService extends BaseService { Future insertPresPresOrder({CMCInsertPresOrderRequestModel order}) async { hasError = false; - await baseAppClient.post(PATIENT_ER_UPDATE_PRES_ORDER, + await baseAppClient.post(PATIENT_ER_INSERT_PRES_ORDER, onSuccess: (dynamic response, int statusCode) { isOrderUpdated = true; }, onFailure: (String error, int statusCode) { diff --git a/lib/core/service/AlHabibMedicalService/customer_addresses_service.dart b/lib/core/service/AlHabibMedicalService/customer_addresses_service.dart new file mode 100644 index 00000000..cb457735 --- /dev/null +++ b/lib/core/service/AlHabibMedicalService/customer_addresses_service.dart @@ -0,0 +1,211 @@ +import 'package:diplomaticquarterapp/config/config.dart'; +import 'package:diplomaticquarterapp/core/enum/OrderService.dart'; +import 'package:diplomaticquarterapp/core/model/AlHabibMedicalService/HomeHealthCare/HHC_get_all_services_request_modle.dart'; +import 'package:diplomaticquarterapp/core/model/AlHabibMedicalService/HomeHealthCare/HHC_get_all_services_response_model.dart'; +import 'package:diplomaticquarterapp/core/model/AlHabibMedicalService/HomeHealthCare/get_hHC_all_pres_orders_request_model.dart'; +import 'package:diplomaticquarterapp/core/model/AlHabibMedicalService/HomeHealthCare/get_hhc_all_pres_orders_response_model.dart'; +import 'package:diplomaticquarterapp/core/model/AlHabibMedicalService/HomeHealthCare/get_order_detail_by_order_iD_request_model.dart'; +import 'package:diplomaticquarterapp/core/model/AlHabibMedicalService/HomeHealthCare/get_order_detail_by_order_iD_response_model.dart'; +import 'package:diplomaticquarterapp/core/model/AlHabibMedicalService/HomeHealthCare/patient_er_insert_pres_order_request_model.dart'; +import 'package:diplomaticquarterapp/core/model/AlHabibMedicalService/HomeHealthCare/update_pres_oreder_request_model.dart'; +import 'package:diplomaticquarterapp/core/viewModels/AlHabibMedicalService/add_new_address_Request_Model.dart'; +import 'package:intl/intl.dart'; + +import '../base_service.dart'; + +class CustomerAddressesService extends BaseService { + + List addressesList = List(); + CustomerInfo customerInfo; + + Future addAddressInfo({ AddNewAddressRequestModel + addNewAddressRequestModel }) async { + + addNewAddressRequestModel.customer.email = customerInfo.email; + addNewAddressRequestModel.customer.id = customerInfo.customerId; + addNewAddressRequestModel.customer.roleIds = [3]; + addNewAddressRequestModel.customer.addresses[0].email = customerInfo.email; + addNewAddressRequestModel.customer.addresses[0].phoneNumber = customerInfo.mobileNumber; + addNewAddressRequestModel.customer.addresses[0].firstName = user.firstName; + addNewAddressRequestModel.customer.addresses[0].lastName = user.lastName; + addNewAddressRequestModel.customer.addresses[0].countryId = 69; + + var f = DateFormat('E, d MMM yyyy HH:mm:ss'); + var date = f.format(DateTime.now().toUtc()) + " GMT"; + addNewAddressRequestModel.customer.addresses[0].createdOnUtc = date; + hasError = false; + await baseAppClient.post(ADD_ADDRESS_INFO, + onSuccess: (dynamic response, int statusCode) { + addressesList.clear(); + response["customers"][0]["addresses"].forEach((data) { + addressesList + .add(AddressInfo.fromJson(data)); + }); + }, onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, body: addNewAddressRequestModel.toJson(), isExternal: true, isAllowAny: true); + } + + Future getCustomerAddresses() async { + Map queryParams = { + 'fields':'addresses' + }; + hasError = false; + await baseAppClient.get("$GET_CUSTOMER_ADDRESSES${customerInfo.customerId}", + onSuccess: (dynamic response, int statusCode) { + addressesList.clear(); + response["customers"][0]["addresses"].forEach((data) { + addressesList + .add(AddressInfo.fromJson(data)); + }); + }, onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, queryParams: queryParams, isExternal: true); + } + + + Future getCustomerInfo() async { + Map queryParams = { + 'FileNumber':'${user.patientID}' + }; + + hasError = false; + await baseAppClient.get(GET_CUSTOMER_INFO, + onSuccess: (dynamic response, int statusCode) { + customerInfo= CustomerInfo.fromJson(response); + }, onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, queryParams: queryParams, isExternal: true); + } +} + + +class CustomerInfo { + bool isRegistered; + String userName; + Null password; + String email; + Null errorMessage; + String mobileNumber; + int customerId; + + CustomerInfo( + {this.isRegistered, + this.userName, + this.password, + this.email, + this.errorMessage, + this.mobileNumber, + this.customerId}); + + CustomerInfo.fromJson(Map json) { + isRegistered = json['IsRegistered']; + userName = json['UserName']; + password = json['Password']; + email = json['Email']; + errorMessage = json['ErrorMessage']; + mobileNumber = json['MobileNumber']; + customerId = json['CustomerId']; + } + + Map toJson() { + final Map data = new Map(); + data['IsRegistered'] = this.isRegistered; + data['UserName'] = this.userName; + data['Password'] = this.password; + data['Email'] = this.email; + data['ErrorMessage'] = this.errorMessage; + data['MobileNumber'] = this.mobileNumber; + data['CustomerId'] = this.customerId; + return data; + } +} + + +class AddressInfo { + String id; + String firstName; + String lastName; + String email; + Null company; + int countryId; + String country; + Null stateProvinceId; + String city; + String address1; + String address2; + String zipPostalCode; + String phoneNumber; + Null faxNumber; + String customerAttributes; + String createdOnUtc; + Null province; + String latLong; + + AddressInfo( + {this.id, + this.firstName, + this.lastName, + this.email, + this.company, + this.countryId, + this.country, + this.stateProvinceId, + this.city, + this.address1, + this.address2, + this.zipPostalCode, + this.phoneNumber, + this.faxNumber, + this.customerAttributes, + this.createdOnUtc, + this.province, + this.latLong}); + + AddressInfo.fromJson(Map json) { + id = json['id']; + firstName = json['first_name']; + lastName = json['last_name']; + email = json['email']; + company = json['company']; + countryId = json['country_id']; + country = json['country']; + stateProvinceId = json['state_province_id']; + city = json['city']; + address1 = json['address1']; + address2 = json['address2']; + zipPostalCode = json['zip_postal_code']; + phoneNumber = json['phone_number']; + faxNumber = json['fax_number']; + customerAttributes = json['customer_attributes']; + createdOnUtc = json['created_on_utc']; + province = json['province']; + latLong = json['lat_long']; + } + + Map toJson() { + final Map data = new Map(); + data['id'] = this.id; + data['first_name'] = this.firstName; + data['last_name'] = this.lastName; + data['email'] = this.email; + data['company'] = this.company; + data['country_id'] = this.countryId; + data['country'] = this.country; + data['state_province_id'] = this.stateProvinceId; + data['city'] = this.city; + data['address1'] = this.address1; + data['address2'] = this.address2; + data['zip_postal_code'] = this.zipPostalCode; + data['phone_number'] = this.phoneNumber; + data['fax_number'] = this.faxNumber; + data['customer_attributes'] = this.customerAttributes; + data['created_on_utc'] = this.createdOnUtc; + data['province'] = this.province; + data['lat_long'] = this.latLong; + return data; + } +} diff --git a/lib/core/service/AlHabibMedicalService/home_health_care_service.dart b/lib/core/service/AlHabibMedicalService/home_health_care_service.dart index e636321b..2ec1e310 100644 --- a/lib/core/service/AlHabibMedicalService/home_health_care_service.dart +++ b/lib/core/service/AlHabibMedicalService/home_health_care_service.dart @@ -1,4 +1,5 @@ import 'package:diplomaticquarterapp/config/config.dart'; +import 'package:diplomaticquarterapp/core/enum/OrderService.dart'; import 'package:diplomaticquarterapp/core/model/AlHabibMedicalService/HomeHealthCare/HHC_get_all_services_request_modle.dart'; import 'package:diplomaticquarterapp/core/model/AlHabibMedicalService/HomeHealthCare/HHC_get_all_services_response_model.dart'; import 'package:diplomaticquarterapp/core/model/AlHabibMedicalService/HomeHealthCare/get_hHC_all_pres_orders_request_model.dart'; @@ -7,6 +8,8 @@ import 'package:diplomaticquarterapp/core/model/AlHabibMedicalService/HomeHealth import 'package:diplomaticquarterapp/core/model/AlHabibMedicalService/HomeHealthCare/get_order_detail_by_order_iD_response_model.dart'; import 'package:diplomaticquarterapp/core/model/AlHabibMedicalService/HomeHealthCare/patient_er_insert_pres_order_request_model.dart'; import 'package:diplomaticquarterapp/core/model/AlHabibMedicalService/HomeHealthCare/update_pres_oreder_request_model.dart'; +import 'package:diplomaticquarterapp/core/service/AlHabibMedicalService/customer_addresses_service.dart'; +import 'package:diplomaticquarterapp/core/viewModels/AlHabibMedicalService/add_new_address_Request_Model.dart'; import '../base_service.dart'; @@ -15,9 +18,10 @@ class HomeHealthCareService extends BaseService { List hhcAllPresOrdersList = List(); List hhcAllOrderDetail = List(); + List addressesList = List(); bool isOrderUpdated; - + CustomerInfo customerInfo; Future getHHCAllServices( HHCGetAllServicesRequestModel hHCGetAllServicesRequestModel) async { hasError = false; @@ -37,11 +41,11 @@ class HomeHealthCareService extends BaseService { GetHHCAllPresOrdersRequestModel getHHCAllPresOrdersRequestModel = GetHHCAllPresOrdersRequestModel(); hasError = false; - await baseAppClient.post(GET_PATIENT_ALL_PRES_ORDERS, + await baseAppClient.post(GET_PATIENT_ALL_PRES_ORD, onSuccess: (dynamic response, int statusCode) { hhcAllPresOrdersList.clear(); response['PatientER_GetPatientAllPresOrdersList'].forEach((data) { - if (data['ServiceID'] == 2) + if (data['ServiceID'] == OrderService.HOME_HEALTH_CARE.getIdOrderService()) hhcAllPresOrdersList .add(GetHHCAllPresOrdersResponseModel.fromJson(data)); }); @@ -91,3 +95,5 @@ class HomeHealthCareService extends BaseService { }, body: order.toJson()); } } + + diff --git a/lib/core/service/childvaccines/add_new_child_service.dart b/lib/core/service/childvaccines/add_new_child_service.dart index 5e4a4d86..98e87100 100644 --- a/lib/core/service/childvaccines/add_new_child_service.dart +++ b/lib/core/service/childvaccines/add_new_child_service.dart @@ -14,19 +14,12 @@ class CreteNewBabyService extends BaseService { Future getCreateNewBabyOrders({CreateNewBaby newChild,int userID}) async { hasError = false; - await getUser(); Map body = Map.from(newChild.toJson()); body['CreatedBy'] = 102; body['EditedBy'] = 102; body['UserID'] = userID; body['AlertBy'] = 2; - body['EmailAddress'] = user.emailAddress; body['IsLogin'] = true; - body['LogInTokenID'] = await sharedPref.getString(TOKEN); - body['MobileNumber'] = user.mobileNumber; - body['NationalID'] = user.nationalityID; - body['ZipCode'] = user.zipCode; - body['isDentalAllowedBackend'] = false; await baseAppClient.post(GET_NEWCHILD_REQUEST, diff --git a/lib/core/service/childvaccines/delete_baby_service.dart b/lib/core/service/childvaccines/delete_baby_service.dart index 115d13c5..49cbd29e 100644 --- a/lib/core/service/childvaccines/delete_baby_service.dart +++ b/lib/core/service/childvaccines/delete_baby_service.dart @@ -1,4 +1,5 @@ import 'package:diplomaticquarterapp/config/config.dart'; +import 'package:diplomaticquarterapp/core/model/childvaccines/List_BabyInformationModel.dart'; import 'package:diplomaticquarterapp/core/model/childvaccines/add_newchild_model.dart'; import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; import 'package:diplomaticquarterapp/core/model/childvaccines/create_new_user_model.dart'; @@ -17,22 +18,13 @@ class DeleteBabyService extends BaseService{ List deleteBabyModelList= List(); - Future getDeleteBabyOrder({DeleteBaby deleteChild,int babyID}) async { + Future getDeleteBabyOrder({List_BabyInformationModel babyInfo}) async { hasError = false; await getUser(); - Map body = Map.from(deleteChild.toJson()); - // body['CreatedBy'] = 102; + Map body = Map(); body['EditedBy'] = 102; - //body['BabyID'] = babyID; - //body['BabyID'] = createNewBabyModelList ; - // body['AlertBy'] = 2; - // body['EmailAddress'] = user.emailAddress; body['IsLogin'] = true; - body['LogInTokenID'] = await sharedPref.getString(TOKEN); - body['MobileNumber'] = user.mobileNumber; - body['NationalID'] = user.nationalityID; - body['ZipCode'] = user.zipCode; - + body['BabyID'] = babyInfo.babyID; body['isDentalAllowedBackend'] = false; await baseAppClient.post(DELETE_CHILD_REQUEST, @@ -45,31 +37,6 @@ class DeleteBabyService extends BaseService{ }, body: body); } - // Future getCreateNewBabyOrders({CreateNewBaby newChild,int userID}) async { - // hasError = false; - // await getUser(); - // Map body = Map.from(newChild.toJson()); - // body['CreatedBy'] = 102; - // body['EditedBy'] = 102; - // body['UserID'] = userID; - // body['AlertBy'] = 2; - // body['EmailAddress'] = user.emailAddress; - // body['IsLogin'] = true; - // body['LogInTokenID'] = await sharedPref.getString(TOKEN); - // body['MobileNumber'] = user.mobileNumber; - // body['NationalID'] = user.nationalityID; - // body['ZipCode'] = user.zipCode; - // - // body['isDentalAllowedBackend'] = false; - // - // await baseAppClient.post(GET_NEWCHILD_REQUEST, - // onSuccess: (dynamic response, int statusCode) { - // var asd =""; - // }, - // onFailure: (String error, int statusCode) { - // hasError = true; - // super.error = error; - // }, body: body); - // } + } \ No newline at end of file diff --git a/lib/core/service/childvaccines/get_vaccinations_item_services.dart b/lib/core/service/childvaccines/get_vaccinations_item_services.dart deleted file mode 100644 index 5ff936af..00000000 --- a/lib/core/service/childvaccines/get_vaccinations_item_services.dart +++ /dev/null @@ -1,27 +0,0 @@ -import 'package:diplomaticquarterapp/config/config.dart'; -import 'package:diplomaticquarterapp/core/model/childvaccines/get_vacainations_itemsmodel.dart'; - -import '../base_service.dart'; - -class GetVccinationsItemsService extends BaseService { - List getVaccinationsItemModelList = List(); - Map body = Map(); - - - - Future getaccinationsitemOrders() async { - hasError = false; - await baseAppClient.post(GET_TABLE_REQUEST, - onSuccess: (dynamic response, int statusCode) { - getVaccinationsItemModelList.clear(); - response['List_CreateVaccinationTableModel'].forEach((vital) { - getVaccinationsItemModelList.add( - GET_VACCINATIONS_ITEMSMODEL.fromJson(vital)); - }); - }, onFailure: (String error, int statusCode) { - hasError = true; - super.error = error; - }, body: body); - } - -} \ No newline at end of file diff --git a/lib/core/service/childvaccines/user_information_service.dart b/lib/core/service/childvaccines/user_information_service.dart index 0628920c..55ddc259 100644 --- a/lib/core/service/childvaccines/user_information_service.dart +++ b/lib/core/service/childvaccines/user_information_service.dart @@ -4,11 +4,11 @@ import 'package:diplomaticquarterapp/core/model/childvaccines/user_information_m import '../base_service.dart'; class UserInformationService extends BaseService { - List userInformationModelList = List(); - Map body = Map(); + List_UserInformationModel userInformationModel = List_UserInformationModel(); Future getUserInformationOrders() async { hasError = false; + Map body = Map(); await getUser(); body['CreatedBy'] = 102; body['EditedBy'] = 102; @@ -22,14 +22,44 @@ class UserInformationService extends BaseService { await baseAppClient.post(GET_USERINFORMATION_REQUEST, onSuccess: (dynamic response, int statusCode) { - userInformationModelList.clear(); - response['List_UserInformationModel_New'].forEach((vital) { - userInformationModelList.add(List_UserInformationModel.fromJson(vital)); + userInformationModel = List_UserInformationModel.fromJson(vital); }); }, onFailure: (String error, int statusCode) { hasError = true; super.error = error; }, body: body); } + + Future updateEmail(String email) async { + hasError = false; + Map body = Map(); + body['IsInternalRequest'] = true; + body['EmailAddress'] = email; + body['IsLogin'] = true; + body['isDentalAllowedBackend'] = false; + await baseAppClient.post(UPDATE_PATENT_EMAIL, + onSuccess: (dynamic response, int statusCode) { + var asd = ""; + }, onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, body: body); + } + + Future updateUserInfo(String email) async { + hasError = false; + Map body = Map(); + body['IsInternalRequest'] = true; + body['EmailAddress'] = email; + body['IsLogin'] = true; + body['isDentalAllowedBackend'] = false; + await baseAppClient.post(UPDATE_PATENT_INFO, + onSuccess: (dynamic response, int statusCode) { + var asd = ""; + }, onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, body: body); + } } diff --git a/lib/core/service/childvaccines/vaccination_table_service.dart b/lib/core/service/childvaccines/vaccination_table_service.dart index 7f987b76..da3c8518 100644 --- a/lib/core/service/childvaccines/vaccination_table_service.dart +++ b/lib/core/service/childvaccines/vaccination_table_service.dart @@ -1,7 +1,9 @@ import 'package:diplomaticquarterapp/config/config.dart'; +import 'package:diplomaticquarterapp/core/model/childvaccines/List_BabyInformationModel.dart'; import 'package:diplomaticquarterapp/core/model/childvaccines/add_newchild_model.dart'; import 'package:diplomaticquarterapp/core/model/childvaccines/create_vaccination_table.dart'; import 'package:diplomaticquarterapp/core/model/childvaccines/user_information_model.dart'; +import 'package:diplomaticquarterapp/uitl/date_uitl.dart'; import '../base_service.dart'; class VaccinationTableService extends BaseService { @@ -10,19 +12,16 @@ class VaccinationTableService extends BaseService { - Future getCreateVaccinationTableOrders() async { + Future getCreateVaccinationTableOrders({List_BabyInformationModel babyInfo, List_UserInformationModel informationModel, bool isSendEmail=false}) async { hasError = false; await getUser(); - body['BabyName']="fffffffffff eeeeeeeeeeeeee"; - body['DOB'] = "/Date(1585774800000+0300)/"; - body['EmailAddress'] = user.emailAddress; + body['BabyName']=babyInfo.babyName; + body['DOB'] = DateUtil.convertDateToString(babyInfo.dOB); + body['EmailAddress'] = informationModel.emailAddress; body['isDentalAllowedBackend'] = false; - body['SendEmail'] = false; + body['SendEmail'] = isSendEmail; body['IsLogin'] =true; - - - await baseAppClient.post(GET_TABLE_REQUEST, onSuccess: (dynamic response, int statusCode) { createVaccinationTableModelList.clear(); diff --git a/lib/core/service/client/base_app_client.dart b/lib/core/service/client/base_app_client.dart index 2201da3e..c96d6ec7 100644 --- a/lib/core/service/client/base_app_client.dart +++ b/lib/core/service/client/base_app_client.dart @@ -33,74 +33,82 @@ class BaseAppClient { {Map body, Function(dynamic response, int statusCode) onSuccess, Function(String error, int statusCode) onFailure, - bool isAllowAny = false}) async { - String url = BASE_URL + endPoint; + bool isAllowAny = false, + bool isExternal = false}) async { + String url; + if (isExternal) { + url = endPoint; + } else { + url = BASE_URL + endPoint; + } try { //Map profile = await sharedPref.getObj(DOCTOR_PROFILE); - String token = await sharedPref.getString(TOKEN); - var languageID = - await sharedPref.getString(APP_LANGUAGE); - var user = await sharedPref.getObject(USER_PROFILE); - 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'] = body.containsKey('LanguageID') - ? body['LanguageID'] != null - ? body['LanguageID'] - : languageID == 'ar' - ? 1 - : 2 - : languageID == 'en' - ? 2 - : 1; - - 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; - } + if (!isExternal) { + String token = await sharedPref.getString(TOKEN); + var languageID = await sharedPref.getString(APP_LANGUAGE); + var user = await sharedPref.getObject(USER_PROFILE); + 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'] = body.containsKey('LanguageID') + ? body['LanguageID'] != null + ? body['LanguageID'] + : languageID == 'ar' + ? 1 + : 2 + : languageID == 'en' + ? 2 + : 1; + + 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; //getSessionId(token); + 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; //getSessionId(token); + } } } @@ -124,8 +132,9 @@ class BaseAppClient { if (parsed['Response_Message'] != null) { onSuccess(parsed, statusCode); } else { - if(parsed['ErrorType'] == 4) { - navigateToAppUpdate(AppGlobal.context, parsed['ErrorEndUserMessage']); + if (parsed['ErrorType'] == 4) { + navigateToAppUpdate( + AppGlobal.context, parsed['ErrorEndUserMessage']); } if (isAllowAny) { onSuccess(parsed, statusCode); @@ -178,8 +187,14 @@ class BaseAppClient { get(String endPoint, {Function(dynamic response, int statusCode) onSuccess, Function(String error, int statusCode) onFailure, - Map queryParams}) async { - String url = BASE_URL + endPoint; + Map queryParams, + bool isExternal = false}) async { + String url; + if (isExternal) { + url = endPoint; + } else { + url = BASE_URL + endPoint; + } if (queryParams != null) { String queryString = Uri(queryParameters: queryParams).query; url += '?' + queryString; @@ -188,10 +203,13 @@ class BaseAppClient { print("URL : $url"); if (await Utils.checkConnection()) { - final response = await http.get(url.trim(), headers: { - 'Content-Type': 'application/json', - 'Accept': 'application/json' - },); + final response = await http.get( + url.trim(), + headers: { + 'Content-Type': 'application/json', + 'Accept': 'application/json' + }, + ); final int statusCode = response.statusCode; print("statusCode :$statusCode"); @@ -209,9 +227,10 @@ class BaseAppClient { logout() async { await sharedPref.remove(LOGIN_TOKEN_ID); await authenticatedUserObject.getUser(); - Provider.of(AppGlobal.context, listen: false).isLogin = false; - _vitalSignService.weightKg =""; - _vitalSignService.heightCm=""; + Provider.of(AppGlobal.context, listen: false).isLogin = + false; + _vitalSignService.weightKg = ""; + _vitalSignService.heightCm = ""; Navigator.of(AppGlobal.context).pushReplacementNamed(HOME); } diff --git a/lib/core/viewModels/AlHabibMedicalService/add_new_address_Request_Model.dart b/lib/core/viewModels/AlHabibMedicalService/add_new_address_Request_Model.dart new file mode 100644 index 00000000..5bde5a5f --- /dev/null +++ b/lib/core/viewModels/AlHabibMedicalService/add_new_address_Request_Model.dart @@ -0,0 +1,136 @@ +class AddNewAddressRequestModel { + Customer customer; + + AddNewAddressRequestModel({this.customer}); + + AddNewAddressRequestModel.fromJson(Map json) { + customer = json['customer'] != null + ? new Customer.fromJson(json['customer']) + : null; + } + + Map toJson() { + final Map data = new Map(); + if (this.customer != null) { + data['customer'] = this.customer.toJson(); + } + return data; + } +} + +class Customer { + List addresses; + int id; + String email; + List roleIds; + + Customer({this.addresses, this.id, this.email, this.roleIds}); + + Customer.fromJson(Map json) { + if (json['addresses'] != null) { + addresses = new List(); + json['addresses'].forEach((v) { + addresses.add(new Addresses.fromJson(v)); + }); + } + id = json['id']; + email = json['email']; + roleIds = json['role_ids'].cast(); + } + + Map toJson() { + final Map data = new Map(); + if (this.addresses != null) { + data['addresses'] = this.addresses.map((v) => v.toJson()).toList(); + } + data['id'] = this.id; + data['email'] = this.email; + data['role_ids'] = this.roleIds; + return data; + } +} + +class Addresses { + int id; + String firstName; + String lastName; + String email; + Null company; + int countryId; + String country; + Null stateProvinceId; + String city; + String address1; + String address2; + String zipPostalCode; + String phoneNumber; + Null faxNumber; + String customerAttributes; + String createdOnUtc; + Null province; + String latLong; + + Addresses( + {this.id, + this.firstName, + this.lastName, + this.email, + this.company, + this.countryId, + this.country, + this.stateProvinceId, + this.city, + this.address1, + this.address2, + this.zipPostalCode, + this.phoneNumber, + this.faxNumber, + this.customerAttributes, + this.createdOnUtc, + this.province, + this.latLong}); + + Addresses.fromJson(Map json) { + id = json['id']; + firstName = json['first_name']; + lastName = json['last_name']; + email = json['email']; + company = json['company']; + countryId = json['country_id']; + country = json['country']; + stateProvinceId = json['state_province_id']; + city = json['city']; + address1 = json['address1']; + address2 = json['address2']; + zipPostalCode = json['zip_postal_code']; + phoneNumber = json['phone_number']; + faxNumber = json['fax_number']; + customerAttributes = json['customer_attributes']; + createdOnUtc = json['created_on_utc']; + province = json['province']; + latLong = json['lat_long']; + } + + Map toJson() { + final Map data = new Map(); + data['id'] = this.id; + data['first_name'] = this.firstName; + data['last_name'] = this.lastName; + data['email'] = this.email; + data['company'] = this.company; + data['country_id'] = this.countryId; + data['country'] = this.country; + data['state_province_id'] = this.stateProvinceId; + data['city'] = this.city; + data['address1'] = this.address1; + data['address2'] = this.address2; + data['zip_postal_code'] = this.zipPostalCode; + data['phone_number'] = this.phoneNumber; + data['fax_number'] = this.faxNumber; + data['customer_attributes'] = this.customerAttributes; + data['created_on_utc'] = this.createdOnUtc; + data['province'] = this.province; + data['lat_long'] = this.latLong; + return data; + } +} diff --git a/lib/core/viewModels/AlHabibMedicalService/cmc_view_model.dart b/lib/core/viewModels/AlHabibMedicalService/cmc_view_model.dart index bf3404a9..0774e5a7 100644 --- a/lib/core/viewModels/AlHabibMedicalService/cmc_view_model.dart +++ b/lib/core/viewModels/AlHabibMedicalService/cmc_view_model.dart @@ -9,14 +9,19 @@ import 'package:diplomaticquarterapp/core/model/AlHabibMedicalService/HomeHealth import 'package:diplomaticquarterapp/core/model/AlHabibMedicalService/HomeHealthCare/get_order_detail_by_order_iD_response_model.dart'; import 'package:diplomaticquarterapp/core/model/AlHabibMedicalService/HomeHealthCare/update_pres_oreder_request_model.dart'; import 'package:diplomaticquarterapp/core/service/AlHabibMedicalService/cmc_service.dart'; +import 'package:diplomaticquarterapp/core/service/AlHabibMedicalService/customer_addresses_service.dart'; import 'package:diplomaticquarterapp/core/viewModels/base_view_model.dart'; import '../../../locator.dart'; +import 'add_new_address_Request_Model.dart'; class CMCViewModel extends BaseViewModel { CMCService _cMCService = locator(); - + CustomerAddressesService _customerAddressesService = + locator(); + List get addressesList => + _customerAddressesService.addressesList; List get cmcAllServicesList => _cMCService.cmcAllServicesList; @@ -94,7 +99,6 @@ class CMCViewModel extends BaseViewModel { await _cMCService .getOrderDetailByOrderID(getOrderDetailByOrderIDRequestModel); } - //TODO check it in uat Future insertPresPresOrder({CMCInsertPresOrderRequestModel order}) async { setState(ViewState.Busy); order.createdBy = user.patientID; @@ -107,4 +111,44 @@ class CMCViewModel extends BaseViewModel { getCmcAllPresOrders(); } } + + Future getCustomerAddresses() async { + setState(ViewState.Busy); + await _customerAddressesService.getCustomerAddresses( + ); + if (_customerAddressesService.hasError) { + error = _customerAddressesService.error; + setState(ViewState.ErrorLocal); + } else { + setState(ViewState.Idle); + } + } + + Future getCustomerInfo() async { + setState(ViewState.Busy); + await _customerAddressesService.getCustomerInfo( + ); + if (_customerAddressesService.hasError) { + error = _customerAddressesService.error; + setState(ViewState.ErrorLocal); + } else { + await getCustomerAddresses(); + } + } + + Future addAddressInfo( + {AddNewAddressRequestModel addNewAddressRequestModel}) async { + + + setState(ViewState.Busy); + await _customerAddressesService.addAddressInfo( + addNewAddressRequestModel: addNewAddressRequestModel + ); + if (_customerAddressesService.hasError) { + error = _customerAddressesService.error; + setState(ViewState.ErrorLocal); + } else { + setState(ViewState.Idle); + } + } } \ No newline at end of file diff --git a/lib/core/viewModels/AlHabibMedicalService/home_health_care_view_model.dart b/lib/core/viewModels/AlHabibMedicalService/home_health_care_view_model.dart index 031d0a0c..20a19b23 100644 --- a/lib/core/viewModels/AlHabibMedicalService/home_health_care_view_model.dart +++ b/lib/core/viewModels/AlHabibMedicalService/home_health_care_view_model.dart @@ -8,18 +8,28 @@ import 'package:diplomaticquarterapp/core/model/AlHabibMedicalService/HomeHealth import 'package:diplomaticquarterapp/core/model/AlHabibMedicalService/HomeHealthCare/get_order_detail_by_order_iD_response_model.dart'; import 'package:diplomaticquarterapp/core/model/AlHabibMedicalService/HomeHealthCare/patient_er_insert_pres_order_request_model.dart'; import 'package:diplomaticquarterapp/core/model/AlHabibMedicalService/HomeHealthCare/update_pres_oreder_request_model.dart'; +import 'package:diplomaticquarterapp/core/service/AlHabibMedicalService/customer_addresses_service.dart'; import 'package:diplomaticquarterapp/core/service/AlHabibMedicalService/home_health_care_service.dart'; import 'package:diplomaticquarterapp/core/viewModels/base_view_model.dart'; +import 'package:intl/intl.dart'; import '../../../locator.dart'; +import 'add_new_address_Request_Model.dart'; class HomeHealthCareViewModel extends BaseViewModel { HomeHealthCareService _homeHealthCareService = locator(); + CustomerAddressesService _customerAddressesService = + locator(); + List get hhcAllServicesList => _homeHealthCareService.hhcAllServicesList; + + List get addressesList => + _customerAddressesService.addressesList; + List get hhcAllPresOrders => _homeHealthCareService.hhcAllPresOrdersList; @@ -93,5 +103,44 @@ class HomeHealthCareViewModel extends BaseViewModel { } + Future getCustomerAddresses() async { + setState(ViewState.Busy); + await _customerAddressesService.getCustomerAddresses( + ); + if (_customerAddressesService.hasError) { + error = _customerAddressesService.error; + setState(ViewState.ErrorLocal); + } else { + setState(ViewState.Idle); + } + } + + Future getCustomerInfo() async { + setState(ViewState.Busy); + await _customerAddressesService.getCustomerInfo( + ); + if (_customerAddressesService.hasError) { + error = _customerAddressesService.error; + setState(ViewState.ErrorLocal); + } else { + await getCustomerAddresses(); + } + } + + Future addAddressInfo( + {AddNewAddressRequestModel addNewAddressRequestModel}) async { + + setState(ViewState.Busy); + await _customerAddressesService.addAddressInfo( + addNewAddressRequestModel: addNewAddressRequestModel + ); + if (_customerAddressesService.hasError) { + error = _customerAddressesService.error; + setState(ViewState.ErrorLocal); + } else { + setState(ViewState.Idle); + } + } + } \ No newline at end of file diff --git a/lib/core/viewModels/child_vaccines/add_new_child_view_model.dart b/lib/core/viewModels/child_vaccines/add_new_child_view_model.dart index eebaca02..2559c074 100644 --- a/lib/core/viewModels/child_vaccines/add_new_child_view_model.dart +++ b/lib/core/viewModels/child_vaccines/add_new_child_view_model.dart @@ -13,7 +13,6 @@ class AddNewChildViewModel extends BaseViewModel { CreteNewBabyService _creteNewBabyService = locator(); ChildVaccinesService _childVaccinesService = locator(); - // DeleteBabyService _deleteBabyService = locator(); bool isAdded = false; ///create new baby createNewBabyOrders({ CreateNewBaby newChild}) async { @@ -25,13 +24,7 @@ class AddNewChildViewModel extends BaseViewModel { } else { isAdded = true; setState(ViewState.Idle); - await _childVaccinesService.getAllBabyInformationOrders(); - if (_childVaccinesService.hasError) { - error = _childVaccinesService.error; - setState(ViewState.Error); - } else{ - } } } diff --git a/lib/core/viewModels/child_vaccines/child_vaccines_view_model.dart b/lib/core/viewModels/child_vaccines/child_vaccines_view_model.dart index 7c4af285..a713b6ec 100644 --- a/lib/core/viewModels/child_vaccines/child_vaccines_view_model.dart +++ b/lib/core/viewModels/child_vaccines/child_vaccines_view_model.dart @@ -16,14 +16,11 @@ class ChildVaccinesViewModel extends BaseViewModel{ List get babyInformationModelList=> _childVaccinesService.babyInformationModelList; - -//=========== CreteNewBabyService _creteNewBabyService = locator(); DeleteBabyService _deleteBabyService = locator(); bool isAdded = false; bool isDeleted = false; - //============ getNewUserOrders() async { @@ -48,25 +45,15 @@ class ChildVaccinesViewModel extends BaseViewModel{ ///delete baby - deleteBabyOrders({ DeleteBaby newChild}) async { + deleteBabyOrders({ List_BabyInformationModel babyInfo}) async { setState(ViewState.Busy); - //await _creteNewBabyService.getCreateNewBabyOrders(newChild: newChild, userID: _childVaccinesService.userID); - await _deleteBabyService.getDeleteBabyOrder(deleteChild: newChild,babyID: newChild.babyID); - //getDeleteBabyOrder(deleteChild: newChild,); - // getDeleteBabyOrder - if (_creteNewBabyService.hasError) { - error = _creteNewBabyService.error; + await _deleteBabyService.getDeleteBabyOrder(babyInfo: babyInfo); + if (_deleteBabyService.hasError) { + error = _deleteBabyService.error; setState(ViewState.Error); } else { isDeleted = true; - setState(ViewState.Idle); - await _childVaccinesService.getAllBabyInformationOrders(); - if (_childVaccinesService.hasError) { - error = _childVaccinesService.error; - setState(ViewState.Error); - } else{ - - } + getBabyInformatioRequestOrders(); } } diff --git a/lib/core/viewModels/child_vaccines/user_information_view_model.dart b/lib/core/viewModels/child_vaccines/user_information_view_model.dart index 43269f42..e183ee42 100644 --- a/lib/core/viewModels/child_vaccines/user_information_view_model.dart +++ b/lib/core/viewModels/child_vaccines/user_information_view_model.dart @@ -8,8 +8,7 @@ class UserInformationViewModel extends BaseViewModel { UserInformationService _userInformationService = locator(); - List get userInformationModelList => - _userInformationService.userInformationModelList; + List_UserInformationModel get userInformationModelList => _userInformationService.userInformationModel; getUserInformationRequestOrders() async { setState(ViewState.Busy); @@ -20,4 +19,15 @@ class UserInformationViewModel extends BaseViewModel { } else setState(ViewState.Idle); } + + updateEmail(String email)async{ + setState(ViewState.Busy); + await _userInformationService.updateEmail(email); + await _userInformationService.updateUserInfo(email); + if (_userInformationService.hasError) { + error = _userInformationService.error; + setState(ViewState.Error); + } else + await getUserInformationRequestOrders(); + } } diff --git a/lib/core/viewModels/child_vaccines/vaccination_table_view_model.dart b/lib/core/viewModels/child_vaccines/vaccination_table_view_model.dart index 3b72dd50..25559b81 100644 --- a/lib/core/viewModels/child_vaccines/vaccination_table_view_model.dart +++ b/lib/core/viewModels/child_vaccines/vaccination_table_view_model.dart @@ -1,30 +1,27 @@ import 'package:diplomaticquarterapp/core/enum/viewstate.dart'; -import 'package:diplomaticquarterapp/core/model/childvaccines/add_newchild_model.dart'; +import 'package:diplomaticquarterapp/core/model/childvaccines/List_BabyInformationModel.dart'; import 'package:diplomaticquarterapp/core/model/childvaccines/create_vaccination_table.dart'; -import 'package:diplomaticquarterapp/core/service/childvaccines/add_new_child_service.dart'; +import 'package:diplomaticquarterapp/core/model/childvaccines/user_information_model.dart'; import 'package:diplomaticquarterapp/core/service/childvaccines/vaccination_table_service.dart'; import '../../../locator.dart'; import '../base_view_model.dart'; +class VaccinationTableViewModel extends BaseViewModel { + VaccinationTableService _creteVaccinationTableService = + locator(); -class VaccinationTableViewModel extends BaseViewModel{ + List get creteVaccinationTableModelList => + _creteVaccinationTableService.createVaccinationTableModelList; - VaccinationTableService _creteVaccinationTableService = locator(); - - // String get creteVaccinationTableContent => _creteVaccinationTableService.userAgreementContent; - //String get userAgreementContent => _creteNewBabyService.v//_reportsService.userAgreementContent; - List get creteVaccinationTableModelList=> _creteVaccinationTableService.createVaccinationTableModelList;//.createNewBabyModelList; - getCreateVaccinationTable() async { + getCreateVaccinationTable({List_BabyInformationModel babyInfo, List_UserInformationModel informationModel, bool isSendEmail =false}) async { setState(ViewState.Busy); - await _creteVaccinationTableService.getCreateVaccinationTableOrders();//getCreateNewBabyOrders(); - - if ( _creteVaccinationTableService.hasError) { - error = _creteVaccinationTableService.error; + await _creteVaccinationTableService.getCreateVaccinationTableOrders(babyInfo: babyInfo,informationModel: informationModel,isSendEmail: isSendEmail); + if (_creteVaccinationTableService.hasError) { + error = _creteVaccinationTableService.error; setState(ViewState.Error); } else setState(ViewState.Idle); } - } diff --git a/lib/locator.dart b/lib/locator.dart index 6b7bb076..d02d647f 100644 --- a/lib/locator.dart +++ b/lib/locator.dart @@ -8,6 +8,7 @@ import 'package:diplomaticquarterapp/uitl/navigation_service.dart'; import 'package:get_it/get_it.dart'; import 'core/service/AlHabibMedicalService/cmc_service.dart'; +import 'core/service/AlHabibMedicalService/customer_addresses_service.dart'; import 'core/service/AlHabibMedicalService/e_referral_service.dart'; import 'core/service/AlHabibMedicalService/home_health_care_service.dart'; import 'core/service/AuthenticatedUserObject.dart'; @@ -135,13 +136,11 @@ void setupLocator() { locator.registerLazySingleton(() => UserInformationService()); locator.registerLazySingleton(() => CreteNewBabyService()); locator.registerLazySingleton(() => DeleteBabyService()); - locator.registerLazySingleton(() => VaccinationTableService()); locator.registerLazySingleton(() => NotificationService()); - - locator.registerLazySingleton(() => PharmacyModuleService()); locator.registerLazySingleton(() => OrderPreviewService()); + locator.registerLazySingleton(() => CustomerAddressesService()); /// View Model diff --git a/lib/main.dart b/lib/main.dart index f1ed0a62..218fbf07 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -63,7 +63,7 @@ class MyApp extends StatelessWidget { const Locale('ar', ''), // Arabic const Locale('en', ''), // English ], - //theme: themeNotifier.getTheme(), + // theme: themeNotifier.getTheme(), theme:ThemeData( fontFamily:projectProvider.isArabic ? 'Cairo' : 'WorkSans', primarySwatch: Colors.blue, @@ -76,6 +76,11 @@ class MyApp extends StatelessWidget { }, ), hintColor: Colors.grey[400], + textTheme: TextTheme( + headline1: TextStyle( + color: Color(0xffB8382C), + ), + ), disabledColor: Colors.grey[300], errorColor: Color.fromRGBO(235, 80, 60, 1.0), scaffoldBackgroundColor: Color(0xffE9E9E9), // Colors.grey[100], diff --git a/lib/pages/AlHabibMedicalService/ComprehensiveMedicalCheckup/NewCMC/cmc_location_page.dart b/lib/pages/AlHabibMedicalService/ComprehensiveMedicalCheckup/NewCMC/cmc_location_page.dart new file mode 100644 index 00000000..ee32bcb6 --- /dev/null +++ b/lib/pages/AlHabibMedicalService/ComprehensiveMedicalCheckup/NewCMC/cmc_location_page.dart @@ -0,0 +1,147 @@ +import 'package:diplomaticquarterapp/config/config.dart'; +import 'package:diplomaticquarterapp/core/enum/viewstate.dart'; +import 'package:diplomaticquarterapp/core/viewModels/AlHabibMedicalService/add_new_address_Request_Model.dart'; +import 'package:diplomaticquarterapp/core/viewModels/AlHabibMedicalService/cmc_view_model.dart'; +import 'package:diplomaticquarterapp/core/viewModels/AlHabibMedicalService/home_health_care_view_model.dart'; +import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; +import 'package:diplomaticquarterapp/pages/base/base_view.dart'; +import 'package:diplomaticquarterapp/uitl/app_toast.dart'; +import 'package:diplomaticquarterapp/uitl/utils.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 'package:google_maps_flutter/google_maps_flutter.dart'; +import 'package:google_maps_place_picker/google_maps_place_picker.dart'; +import 'package:provider/provider.dart'; + +class CMCLocationPage extends StatefulWidget { + final Function(PickResult) onPick; + final double latitude; + final double longitude; + final dynamic model; + + const CMCLocationPage({Key key, this.onPick, this.latitude, this.longitude, this.model}) + : super(key: key); + + @override + _CMCLocationPageState createState() => + _CMCLocationPageState(); +} + +class _CMCLocationPageState + extends State { + double latitude = 0; + double longitude = 0; + + @override + void initState() { + + latitude = widget.latitude; + longitude = widget.longitude; + super.initState(); + } + + + @override + Widget build(BuildContext context) { + ProjectViewModel projectViewModel = Provider.of(context); + return BaseView( + onModelReady: (model) {}, + builder: (_, model, widget) => AppScaffold( + isShowDecPage: false, + isShowAppBar: true, + baseViewModel: model, + body: PlacePicker( + apiKey: GOOGLE_API_KEY, + enableMyLocationButton: true, + automaticallyImplyAppBarLeading: false, + autocompleteOnTrailingWhitespace: true, + selectInitialPosition: true, + autocompleteLanguage: projectViewModel.currentLanguage, + enableMapTypeButton: true, + searchForInitialValue: false, + onPlacePicked: (PickResult result) { + print(result.adrAddress); + + }, + selectedPlaceWidgetBuilder: + (_, selectedPlace, state, isSearchBarFocused) { + print("state: $state, isSearchBarFocused: $isSearchBarFocused"); + return isSearchBarFocused + ? Container() + : FloatingCard( + bottomPosition: 0.0, + leftPosition: 0.0, + rightPosition: 0.0, + width: 500, + borderRadius: BorderRadius.circular(12.0), + child: state == SearchingState.Searching + ? Center(child: CircularProgressIndicator()) + : Container( + margin: EdgeInsets.all(12), + child: Column( + children: [ + SecondaryButton( + color: Colors.grey[800], + textColor: Colors.white, + onTap: () async { + print(selectedPlace); + AddNewAddressRequestModel + addNewAddressRequestModel = + new AddNewAddressRequestModel( + customer: Customer(addresses: [ + Addresses( + address1: + selectedPlace.formattedAddress, + address2: selectedPlace + .formattedAddress, + customerAttributes: "", + city: "", + createdOnUtc: "", + id: 0, + latLong: "$latitude,$longitude", + email: "") + ]), + ); + + selectedPlace.addressComponents.forEach((e) { + if (e.types.contains("country")) { + addNewAddressRequestModel.customer + .addresses[0].country = e.longName; + } + if (e.types.contains("postal_code")) { + addNewAddressRequestModel.customer + .addresses[0].zipPostalCode = + e.longName; + } + if (e.types.contains("locality")) { + addNewAddressRequestModel.customer + .addresses[0].city = + e.longName; + } + }); + + await model.addAddressInfo( + addNewAddressRequestModel: addNewAddressRequestModel); + if (model.state == ViewState.ErrorLocal) { + Utils.showErrorToast(model.error); + } else { + AppToast.showSuccessToast( + message: "Address Added Successfully"); + } + Navigator.of(context).pop(); + }, + label: " Add New Address ", + ), + ], + ), + ), + ); + }, + initialPosition: LatLng(latitude, longitude), + useCurrentLocation: false, + ), + )); + } +} diff --git a/lib/pages/AlHabibMedicalService/ComprehensiveMedicalCheckup/NewCMC/new_cmc_page.dart b/lib/pages/AlHabibMedicalService/ComprehensiveMedicalCheckup/NewCMC/new_cmc_page.dart index 532396cc..cedd4018 100644 --- a/lib/pages/AlHabibMedicalService/ComprehensiveMedicalCheckup/NewCMC/new_cmc_page.dart +++ b/lib/pages/AlHabibMedicalService/ComprehensiveMedicalCheckup/NewCMC/new_cmc_page.dart @@ -134,7 +134,7 @@ class _NewCMCPageState extends State children: [ widget.model.cmcAllOrderDetail.length != 0 ? FractionallySizedBox( - heightFactor: 0.8, + heightFactor: 0.9, widthFactor: 0.9, child: Container( width: double.infinity, diff --git a/lib/pages/AlHabibMedicalService/ComprehensiveMedicalCheckup/NewCMC/new_cmc_step_one_page.dart b/lib/pages/AlHabibMedicalService/ComprehensiveMedicalCheckup/NewCMC/new_cmc_step_one_page.dart index 02d099b4..7da00dee 100644 --- a/lib/pages/AlHabibMedicalService/ComprehensiveMedicalCheckup/NewCMC/new_cmc_step_one_page.dart +++ b/lib/pages/AlHabibMedicalService/ComprehensiveMedicalCheckup/NewCMC/new_cmc_step_one_page.dart @@ -1,6 +1,8 @@ +import 'package:diplomaticquarterapp/core/enum/viewstate.dart'; import 'package:diplomaticquarterapp/core/model/AlHabibMedicalService/ComprehensiveMedicalCheckup/cmc_get_items_request_model.dart'; import 'package:diplomaticquarterapp/core/model/AlHabibMedicalService/ComprehensiveMedicalCheckup/cmc_insert_pres_order_request_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/AlHabibMedicalService/cmc_view_model.dart'; +import 'package:diplomaticquarterapp/uitl/utils.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'; @@ -199,26 +201,42 @@ class _NewCMCStepOnePageState extends State { child: SecondaryButton( label: "Next", textColor: Theme.of(context).backgroundColor, - onTap: () { - if (widget.cMCInsertPresOrderRequestModel.patientERCMCInsertServicesList.length = null) { + color: Colors.grey[800], + onTap: () async { + if (widget.cMCInsertPresOrderRequestModel + .patientERCMCInsertServicesList.length != + 0 || + widget.cMCInsertPresOrderRequestModel + .patientERCMCInsertServicesList == + null) { int index = widget.model.cmcAllServicesList.length; PatientERCMCInsertServicesList patientERCMCInsertServicesList = new PatientERCMCInsertServicesList( - price: widget.model.cmcAllServicesList[index-1].price, - serviceID: widget.model.cmcAllServicesList[index-1].serviceID.toString(), - selectedServiceName: widget.model.cmcAllServicesList[index-1].description, - selectedServiceNameAR: widget.model.cmcAllServicesList[index-1].description, + price: widget + .model.cmcAllServicesList[index - 1].price, + serviceID: widget + .model.cmcAllServicesList[index - 1].serviceID + .toString(), + selectedServiceName: widget.model + .cmcAllServicesList[index - 1].description, + selectedServiceNameAR: widget.model + .cmcAllServicesList[index - 1].description, recordID: 1, - totalPrice: widget.model.cmcAllServicesList[index-1].totalPrice, + totalPrice: widget + .model.cmcAllServicesList[index - 1].totalPrice, vAT: widget.model.cmcAllServicesList[index-1].vAT); widget.cMCInsertPresOrderRequestModel .patientERCMCInsertServicesList = [ patientERCMCInsertServicesList ]; - - widget.changePageViewIndex(1); + await widget.model.getCustomerInfo(); + if(widget.model.state == ViewState.ErrorLocal){ + Utils.showErrorToast(); + } else { + widget.changePageViewIndex(1); + } } }, ), diff --git a/lib/pages/AlHabibMedicalService/ComprehensiveMedicalCheckup/NewCMC/new_cmc_step_three_page.dart b/lib/pages/AlHabibMedicalService/ComprehensiveMedicalCheckup/NewCMC/new_cmc_step_three_page.dart index e48bb5d5..893fbfa9 100644 --- a/lib/pages/AlHabibMedicalService/ComprehensiveMedicalCheckup/NewCMC/new_cmc_step_three_page.dart +++ b/lib/pages/AlHabibMedicalService/ComprehensiveMedicalCheckup/NewCMC/new_cmc_step_three_page.dart @@ -149,6 +149,7 @@ class _NewCMCStepThreePageState width: MediaQuery.of(context).size.width * 0.9, child: SecondaryButton( label: "Confirm", + color: Colors.grey[800], onTap: () async { await widget.model.insertPresPresOrder(order: widget.cmcInsertPresOrderRequestModel); if (widget.model.state != ViewState.ErrorLocal) { diff --git a/lib/pages/AlHabibMedicalService/ComprehensiveMedicalCheckup/NewCMC/new_cmc_step_tow_page.dart b/lib/pages/AlHabibMedicalService/ComprehensiveMedicalCheckup/NewCMC/new_cmc_step_tow_page.dart index 27cddfe3..c1ec952f 100644 --- a/lib/pages/AlHabibMedicalService/ComprehensiveMedicalCheckup/NewCMC/new_cmc_step_tow_page.dart +++ b/lib/pages/AlHabibMedicalService/ComprehensiveMedicalCheckup/NewCMC/new_cmc_step_tow_page.dart @@ -1,19 +1,22 @@ import 'package:diplomaticquarterapp/config/config.dart'; import 'package:diplomaticquarterapp/core/model/AlHabibMedicalService/ComprehensiveMedicalCheckup/cmc_insert_pres_order_request_model.dart'; -import 'package:diplomaticquarterapp/core/model/AlHabibMedicalService/HomeHealthCare/patient_er_insert_pres_order_request_model.dart'; +import 'package:diplomaticquarterapp/core/service/AlHabibMedicalService/customer_addresses_service.dart'; import 'package:diplomaticquarterapp/core/viewModels/AlHabibMedicalService/cmc_view_model.dart'; -import 'package:diplomaticquarterapp/core/viewModels/AlHabibMedicalService/home_health_care_view_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; +import 'package:diplomaticquarterapp/widgets/dialogs/select_location_dialog.dart'; +import 'package:diplomaticquarterapp/pages/AlHabibMedicalService/HomeHealthCare/NewHomeHealthCare/location_page.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/others/close_back.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -import 'package:google_maps_place_picker/google_maps_place_picker.dart'; import 'package:google_maps_flutter/google_maps_flutter.dart'; +import 'package:google_maps_place_picker/google_maps_place_picker.dart'; import 'package:provider/provider.dart'; +import 'cmc_location_page.dart'; + class NewCMCStepTowPage extends StatefulWidget { final Function(PickResult) onPick; final double latitude; @@ -41,12 +44,13 @@ class _NewCMCStepTowPageState extends State { double latitude = 0; double longitude = 0; + AddressInfo _selectedAddress; + @override void initState() { if (widget.cmcInsertPresOrderRequestModel.latitude == null) { - latitude = widget.latitude; - longitude = widget.longitude; + setLatitudeAndLongitude(); } else { latitude = widget.cmcInsertPresOrderRequestModel.latitude; longitude = widget.cmcInsertPresOrderRequestModel.longitude; @@ -54,60 +58,152 @@ class _NewCMCStepTowPageState super.initState(); } + setLatitudeAndLongitude({bool isSetState = false, String latLong}) { + if (latLong == null) + latLong = widget.model.addressesList[widget.model.addressesList + .length - 1].latLong; + List latLongArr = latLong.split(','); + + latitude = double.parse(latLongArr[0]); + longitude = double.parse(latLongArr[1]); + } @override Widget build(BuildContext context) { ProjectViewModel projectViewModel = Provider.of(context); - return AppScaffold( + return AppScaffold( isShowDecPage: false, - body: PlacePicker( - apiKey: GOOGLE_API_KEY, - enableMyLocationButton: true, - automaticallyImplyAppBarLeading: false, - autocompleteOnTrailingWhitespace: true, - selectInitialPosition: true, - autocompleteLanguage: projectViewModel.currentLanguage, - enableMapTypeButton: true, - onPlacePicked: (PickResult result) { - print(result.adrAddress); - widget.changePageViewIndex(3); - }, - selectedPlaceWidgetBuilder: - (_, selectedPlace, state, isSearchBarFocused) { - print("state: $state, isSearchBarFocused: $isSearchBarFocused"); - return isSearchBarFocused - ? Container() - : FloatingCard( - bottomPosition: 0.0, - leftPosition: 0.0, - rightPosition: 0.0, - width: 500, - borderRadius: BorderRadius.circular(12.0), - child: state == SearchingState.Searching - ? Center(child: CircularProgressIndicator()) - : Container( - margin: EdgeInsets.all(12), - child: SecondaryButton( - color: Colors.grey[800], - textColor: Colors.white, - onTap: () { - setState(() { - widget.cmcInsertPresOrderRequestModel - .latitude = - selectedPlace.geometry.location.lat; - widget.cmcInsertPresOrderRequestModel - .longitude = - selectedPlace.geometry.location.lng; - }); - widget.changePageViewIndex(3); - }, - label: TranslationBase.of(context).next, - ), + body: Stack( + children: [ + PlacePicker( + apiKey: GOOGLE_API_KEY, + enableMyLocationButton: true, + automaticallyImplyAppBarLeading: false, + autocompleteOnTrailingWhitespace: true, + selectInitialPosition: true, + autocompleteLanguage: projectViewModel.currentLanguage, + enableMapTypeButton: true, + searchForInitialValue: false, + + onPlacePicked: (PickResult result) { + print(result.adrAddress); + widget.changePageViewIndex(3); + }, + selectedPlaceWidgetBuilder: + (_, selectedPlace, state, isSearchBarFocused) { + print("state: $state, isSearchBarFocused: $isSearchBarFocused"); + return isSearchBarFocused + ? Container() + : FloatingCard( + bottomPosition: 0.0, + leftPosition: 0.0, + rightPosition: 0.0, + width: 500, + borderRadius: BorderRadius.circular(12.0), + child: state == SearchingState.Searching + ? Center(child: CircularProgressIndicator()) + : Container( + margin: EdgeInsets.all(12), + child: Column( + children: [ + SecondaryButton( + color: Colors.grey[800], + textColor: Colors.white, + onTap: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (BuildContext context) => + CMCLocationPage( + latitude: latitude, + longitude: longitude, + + ), + ), + ); + }, + label: " Add New Address ", + ), + SizedBox(height: 10,), + SecondaryButton( + color: Colors.red + [800], + textColor: Colors.white, + onTap: () { + setState(() { + widget.cmcInsertPresOrderRequestModel + .latitude = + selectedPlace.geometry.location.lat; + widget.cmcInsertPresOrderRequestModel + .longitude = + selectedPlace.geometry.location.lng; + }); + widget.changePageViewIndex(3); + }, + label: TranslationBase.of(context).confirm, ), - ); + ], + ) + ), + ); + }, + initialPosition: LatLng(latitude, longitude), + useCurrentLocation: false, + ), + Container( + child: InkWell( + onTap: () => + confirmSelectLocationDialog(widget.model.addressesList), + child: Container( + padding: EdgeInsets.all(10), + width: double.infinity, + // height: 65, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(10), + color: Colors.white), + child: Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + Expanded(child: Texts(getAddressName(), fontSize: 14,),), + Icon(Icons.arrow_drop_down) + ], + ), + ), + ), + height: 56, width: double.infinity, color: Theme + .of(context) + .scaffoldBackgroundColor, + + ) + ], + ), + ); + + + } + + + void confirmSelectLocationDialog(List addresses) { + showDialog( + context: context, + child: SelectLocationDialog( + addresses: addresses, + selectedAddress: _selectedAddress + , + onValueSelected: (value) { + setLatitudeAndLongitude(latLong: value.latLong); + setState(() { + _selectedAddress = value; + }); }, - initialPosition: LatLng(latitude, longitude), - useCurrentLocation: true, ), ); } + + String getAddressName() { + if (_selectedAddress != null) + return _selectedAddress.address1; + else + return "Select Address" /*TranslationBase.of(context).selectHospital*/; + } } diff --git a/lib/pages/AlHabibMedicalService/ComprehensiveMedicalCheckup/cmc_index_page.dart b/lib/pages/AlHabibMedicalService/ComprehensiveMedicalCheckup/cmc_index_page.dart deleted file mode 100644 index e8e9eccc..00000000 --- a/lib/pages/AlHabibMedicalService/ComprehensiveMedicalCheckup/cmc_index_page.dart +++ /dev/null @@ -1,68 +0,0 @@ -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'; -import 'package:hexcolor/hexcolor.dart'; -import 'cmc_page.dart'; - -class CMCIndexPage extends StatelessWidget { - @override - Widget build(BuildContext context) { - return AppScaffold( - isShowAppBar: true, - appBarTitle: TranslationBase.of(context).serviceInformation, - body: SingleChildScrollView( - padding: EdgeInsets.all(12), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Texts( - "CMC", - fontWeight: FontWeight.normal, - fontSize: 25, - color: Color(0xff60686b), - ), - SizedBox( - height: 12, - ), - Texts( - "This service is designed to help you to set drinking water goals and track the volume of water you are drinking on a daily basis. This service allows for schedule reminders and offers a basic statistical analysis of the amount of what you have consumed over the course of a day, week or month.", - fontWeight: FontWeight.normal, - fontSize: 17, - ), - SizedBox( - height: 22, - ), - Center( - child: Image.asset( - 'assets/images/AlHabibMedicalService/Wifi-AR.png')), - SizedBox( - height: 77, - ), - ], - )), - bottomSheet: Container( - height: MediaQuery.of(context).size.height * 0.10, - width: double.infinity, - child: Column( - children: [ - Container( - width: MediaQuery.of(context).size.width * 0.9, - child: SecondaryButton( - onTap: () => Navigator.push( - context, - FadePage( - page: CMCPage(), - ), - ), - label: "CMC", - textColor: Theme.of(context).backgroundColor), - ), - ], - ), - )); - } -} diff --git a/lib/pages/AlHabibMedicalService/ComprehensiveMedicalCheckup/cmc_page.dart b/lib/pages/AlHabibMedicalService/ComprehensiveMedicalCheckup/cmc_page.dart index 385d0da3..04d8ea36 100644 --- a/lib/pages/AlHabibMedicalService/ComprehensiveMedicalCheckup/cmc_page.dart +++ b/lib/pages/AlHabibMedicalService/ComprehensiveMedicalCheckup/cmc_page.dart @@ -40,7 +40,8 @@ class _CMCPageState extends State }, builder: (_, model, widget) => AppScaffold( isShowAppBar: true, - appBarTitle: TranslationBase.of(context).homeHealthCare, + description: TranslationBase.of(context).HHCNotAuthMsg, + appBarTitle: TranslationBase.of(context).comprehensiveMedicalCheckup, body: Scaffold( extendBodyBehindAppBar: true, appBar: PreferredSize( diff --git a/lib/pages/AlHabibMedicalService/HomeHealthCare/NewHomeHealthCare/location_page.dart b/lib/pages/AlHabibMedicalService/HomeHealthCare/NewHomeHealthCare/location_page.dart new file mode 100644 index 00000000..8592cb34 --- /dev/null +++ b/lib/pages/AlHabibMedicalService/HomeHealthCare/NewHomeHealthCare/location_page.dart @@ -0,0 +1,145 @@ +import 'package:diplomaticquarterapp/config/config.dart'; +import 'package:diplomaticquarterapp/core/enum/viewstate.dart'; +import 'package:diplomaticquarterapp/core/viewModels/AlHabibMedicalService/add_new_address_Request_Model.dart'; +import 'package:diplomaticquarterapp/core/viewModels/AlHabibMedicalService/home_health_care_view_model.dart'; +import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; +import 'package:diplomaticquarterapp/pages/base/base_view.dart'; +import 'package:diplomaticquarterapp/uitl/app_toast.dart'; +import 'package:diplomaticquarterapp/uitl/utils.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 'package:google_maps_flutter/google_maps_flutter.dart'; +import 'package:google_maps_place_picker/google_maps_place_picker.dart'; +import 'package:provider/provider.dart'; + +class LocationPage extends StatefulWidget { + final Function(PickResult) onPick; + final double latitude; + final double longitude; + final dynamic model; + + const LocationPage({Key key, this.onPick, this.latitude, this.longitude, this.model}) + : super(key: key); + + @override + _LocationPageState createState() => + _LocationPageState(); +} + +class _LocationPageState + extends State { + double latitude = 0; + double longitude = 0; + + @override + void initState() { + + latitude = widget.latitude; + longitude = widget.longitude; + super.initState(); + } + + + @override + Widget build(BuildContext context) { + ProjectViewModel projectViewModel = Provider.of(context); + return BaseView( + onModelReady: (model) {}, + builder: (_, model, widget) => AppScaffold( + isShowDecPage: false, + isShowAppBar: true, + baseViewModel: model, + body: PlacePicker( + apiKey: GOOGLE_API_KEY, + enableMyLocationButton: true, + automaticallyImplyAppBarLeading: false, + autocompleteOnTrailingWhitespace: true, + selectInitialPosition: true, + autocompleteLanguage: projectViewModel.currentLanguage, + enableMapTypeButton: true, + searchForInitialValue: false, + onPlacePicked: (PickResult result) { + print(result.adrAddress); + + }, + selectedPlaceWidgetBuilder: + (_, selectedPlace, state, isSearchBarFocused) { + print("state: $state, isSearchBarFocused: $isSearchBarFocused"); + return isSearchBarFocused + ? Container() + : FloatingCard( + bottomPosition: 0.0, + leftPosition: 0.0, + rightPosition: 0.0, + width: 500, + borderRadius: BorderRadius.circular(12.0), + child: state == SearchingState.Searching + ? Center(child: CircularProgressIndicator()) + : Container( + margin: EdgeInsets.all(12), + child: Column( + children: [ + SecondaryButton( + color: Colors.grey[800], + textColor: Colors.white, + onTap: () async { + AddNewAddressRequestModel + addNewAddressRequestModel = + new AddNewAddressRequestModel( + customer: Customer(addresses: [ + Addresses( + address1: + selectedPlace.formattedAddress, + address2: selectedPlace + .formattedAddress, + customerAttributes: "", + city: "", + createdOnUtc: "", + id: 0, + latLong: "$latitude,$longitude", + email: "") + ]), + ); + + selectedPlace.addressComponents.forEach((e) { + if (e.types.contains("country")) { + addNewAddressRequestModel.customer + .addresses[0].country = e.longName; + } + if (e.types.contains("postal_code")) { + addNewAddressRequestModel.customer + .addresses[0].zipPostalCode = + e.longName; + } + if (e.types.contains("locality")) { + addNewAddressRequestModel.customer + .addresses[0].city = + e.longName; + } + }); + + await model.addAddressInfo( + addNewAddressRequestModel: addNewAddressRequestModel); + if (model.state == ViewState.ErrorLocal) { + Utils.showErrorToast(model.error); + } else { + AppToast.showSuccessToast( + message: "Address Added Successfully"); + } + Navigator.of(context).pop(); + }, + label: " Add New Address ", + ), + ], + ), + ), + ); + }, + initialPosition: LatLng(latitude, longitude), + useCurrentLocation: false, + ), + )); + } +} diff --git a/lib/pages/AlHabibMedicalService/HomeHealthCare/NewHomeHealthCare/new_Home_health_care_step_one_page.dart b/lib/pages/AlHabibMedicalService/HomeHealthCare/NewHomeHealthCare/new_Home_health_care_step_one_page.dart index 1dbee1b5..bc5a4a99 100644 --- a/lib/pages/AlHabibMedicalService/HomeHealthCare/NewHomeHealthCare/new_Home_health_care_step_one_page.dart +++ b/lib/pages/AlHabibMedicalService/HomeHealthCare/NewHomeHealthCare/new_Home_health_care_step_one_page.dart @@ -3,6 +3,7 @@ import 'package:diplomaticquarterapp/core/model/AlHabibMedicalService/HomeHealth import 'package:diplomaticquarterapp/core/model/AlHabibMedicalService/HomeHealthCare/patient_er_insert_pres_order_request_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/AlHabibMedicalService/home_health_care_view_model.dart'; import 'package:diplomaticquarterapp/pages/base/base_view.dart'; +import 'package:diplomaticquarterapp/uitl/utils.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'; @@ -138,9 +139,17 @@ class _NewHomeHealthCareStepOnePageState extends State { double latitude = 0; double longitude = 0; + AddressInfo _selectedAddress; @override void initState() { if (widget.patientERInsertPresOrderRequestModel.latitude == null) { - latitude = widget.latitude; - longitude = widget.longitude; + setLatitudeAndLongitude(); } else { latitude = widget.patientERInsertPresOrderRequestModel.latitude; longitude = widget.patientERInsertPresOrderRequestModel.longitude; } + super.initState(); } + setLatitudeAndLongitude({bool isSetState = false, String latLong}) { + if (latLong == null) + latLong = widget.model.addressesList[widget.model.addressesList + .length - 1].latLong; + List latLongArr = latLong.split(','); + + latitude = double.parse(latLongArr[0]); + longitude = double.parse(latLongArr[1]); + } + @override Widget build(BuildContext context) { ProjectViewModel projectViewModel = Provider.of(context); return AppScaffold( isShowDecPage: false, - body: PlacePicker( - apiKey: GOOGLE_API_KEY, - enableMyLocationButton: true, - automaticallyImplyAppBarLeading: false, - autocompleteOnTrailingWhitespace: true, - selectInitialPosition: true, - autocompleteLanguage: projectViewModel.currentLanguage, - enableMapTypeButton: true, - onPlacePicked: (PickResult result) { - print(result.adrAddress); - widget.changePageViewIndex(3); - }, - selectedPlaceWidgetBuilder: - (_, selectedPlace, state, isSearchBarFocused) { - print("state: $state, isSearchBarFocused: $isSearchBarFocused"); - return isSearchBarFocused - ? Container() - : FloatingCard( - bottomPosition: 0.0, - leftPosition: 0.0, - rightPosition: 0.0, - width: 500, - borderRadius: BorderRadius.circular(12.0), - child: state == SearchingState.Searching - ? Center(child: CircularProgressIndicator()) - : Container( - margin: EdgeInsets.all(12), - child: SecondaryButton( - color: Colors.grey[800], - textColor: Colors.white, - onTap: () { - setState(() { - widget.patientERInsertPresOrderRequestModel - .latitude = - selectedPlace.geometry.location.lat; - widget.patientERInsertPresOrderRequestModel - .longitude = - selectedPlace.geometry.location.lng; - }); - widget.changePageViewIndex(3); - }, - label: TranslationBase.of(context).next, - ), - ), - ); + body: Stack( + children: [ + PlacePicker( + apiKey: GOOGLE_API_KEY, + enableMyLocationButton: true, + automaticallyImplyAppBarLeading: false, + autocompleteOnTrailingWhitespace: true, + selectInitialPosition: true, + autocompleteLanguage: projectViewModel.currentLanguage, + enableMapTypeButton: true, + searchForInitialValue: false, + + onPlacePicked: (PickResult result) { + print(result.adrAddress); + widget.changePageViewIndex(3); + }, + selectedPlaceWidgetBuilder: + (_, selectedPlace, state, isSearchBarFocused) { + print("state: $state, isSearchBarFocused: $isSearchBarFocused"); + return isSearchBarFocused + ? Container() + : FloatingCard( + bottomPosition: 0.0, + leftPosition: 0.0, + rightPosition: 0.0, + width: 500, + borderRadius: BorderRadius.circular(12.0), + child: state == SearchingState.Searching + ? Center(child: CircularProgressIndicator()) + : Container( + margin: EdgeInsets.all(12), + child: Column( + children: [ + SecondaryButton( + color: Colors.grey[800], + textColor: Colors.white, + onTap: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (BuildContext context) => + LocationPage( + latitude: latitude, + longitude: longitude, + ), + ), + ); + }, + label: " Add New Address ", + ), + SizedBox(height: 10,), + SecondaryButton( + color: Colors.red[800], + textColor: Colors.white, + onTap: () { + setState(() { + widget.patientERInsertPresOrderRequestModel + .latitude = + selectedPlace.geometry.location.lat; + widget.patientERInsertPresOrderRequestModel + .longitude = + selectedPlace.geometry.location.lng; + }); + widget.changePageViewIndex(3); + }, + label: " Continue ", + ), + ], + ), + ), + ); + }, + initialPosition: LatLng(latitude, longitude), + useCurrentLocation: false, + ), + Container( + child: InkWell( + onTap: () => + confirmSelectLocationDialog(widget.model.addressesList), + child: Container( + padding: EdgeInsets.all(10), + width: double.infinity, + // height: 65, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(10), + color: Colors.white), + child: Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + Expanded(child: Texts(getAddressName(), fontSize: 14,),), + Icon(Icons.arrow_drop_down) + ], + ), + ), + ), + height: 56, width: double.infinity, color: Theme + .of(context) + .scaffoldBackgroundColor, + + ) + ], + ), + ); + } + + + void confirmSelectLocationDialog(List addresses) { + showDialog( + context: context, + child: SelectLocationDialog( + addresses: addresses, + selectedAddress: _selectedAddress + , + onValueSelected: (value) { + setLatitudeAndLongitude(latLong: value.latLong); + setState(() { + _selectedAddress = value; + }); }, - initialPosition: LatLng(latitude, longitude), - useCurrentLocation: true, ), ); } + + String getAddressName() { + if (_selectedAddress != null) + return _selectedAddress.address1; + else + return "Select Address" /*TranslationBase.of(context).selectHospital*/; + } } diff --git a/lib/pages/AlHabibMedicalService/HomeHealthCare/home_health_care_index_page.dart b/lib/pages/AlHabibMedicalService/HomeHealthCare/home_health_care_index_page.dart deleted file mode 100644 index fa0799f9..00000000 --- a/lib/pages/AlHabibMedicalService/HomeHealthCare/home_health_care_index_page.dart +++ /dev/null @@ -1,69 +0,0 @@ -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'; -import 'package:hexcolor/hexcolor.dart'; - -import 'home_health_care_page.dart'; - -class HomeHealthCareIndexPage extends StatelessWidget { - @override - Widget build(BuildContext context) { - return AppScaffold( - isShowAppBar: true, - appBarTitle: TranslationBase.of(context).serviceInformation, - body: SingleChildScrollView( - padding: EdgeInsets.all(12), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Texts( - TranslationBase.of(context).homeHealthCare, - fontWeight: FontWeight.normal, - fontSize: 25, - color: Color(0xff60686b), - ), - SizedBox( - height: 12, - ), - Texts( - TranslationBase.of(context).homeHealthCareText, - fontWeight: FontWeight.normal, - fontSize: 17, - ), - SizedBox( - height: 22, - ), - Center( - child: Image.asset( - 'assets/images/AlHabibMedicalService/Wifi-AR.png')), - SizedBox( - height: 77, - ), - ], - )), - bottomSheet: Container( - height: MediaQuery.of(context).size.height * 0.10, - width: double.infinity, - child: Column( - children: [ - Container( - width: MediaQuery.of(context).size.width * 0.9, - child: SecondaryButton( - onTap: () => Navigator.push( - context, - FadePage( - page: HomeHealthCarePage(), - ), - ), - label: TranslationBase.of(context).loginRegister, - textColor: Theme.of(context).backgroundColor), - ), - ], - ), - )); - } -} diff --git a/lib/pages/AlHabibMedicalService/HomeHealthCare/home_health_care_page.dart b/lib/pages/AlHabibMedicalService/HomeHealthCare/home_health_care_page.dart index 8f4821f6..c249362b 100644 --- a/lib/pages/AlHabibMedicalService/HomeHealthCare/home_health_care_page.dart +++ b/lib/pages/AlHabibMedicalService/HomeHealthCare/home_health_care_page.dart @@ -42,7 +42,9 @@ class _HomeHealthCarePageState extends State }, builder: (_, model, widget) => AppScaffold( isShowAppBar: true, + description: TranslationBase.of(context).HHCNotAuthMsg, appBarTitle: TranslationBase.of(context).homeHealthCare, + // appBarTitle: TranslationBase.of(context).homeHealthCare, body: Scaffold( extendBodyBehindAppBar: true, appBar: PreferredSize( diff --git a/lib/pages/ChildVaccines/ChidDetailsWidget.dart b/lib/pages/ChildVaccines/ChidDetailsWidget.dart index bce5d54e..c06c5422 100644 --- a/lib/pages/ChildVaccines/ChidDetailsWidget.dart +++ b/lib/pages/ChildVaccines/ChidDetailsWidget.dart @@ -1,5 +1,6 @@ import 'package:diplomaticquarterapp/core/model/childvaccines/List_BabyInformationModel.dart'; import 'package:diplomaticquarterapp/core/model/childvaccines/delete_baby_model.dart'; +import 'package:diplomaticquarterapp/core/model/childvaccines/user_information_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/child_vaccines/child_vaccines_view_model.dart'; import 'package:diplomaticquarterapp/pages/ChildVaccines/vaccinationtable_page.dart'; import 'package:diplomaticquarterapp/uitl/app_toast.dart'; @@ -9,99 +10,110 @@ import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_flexible_toast/flutter_flexible_toast.dart'; + +import 'dialogs/delete_child.dart'; class ChildDetailsWidget extends StatelessWidget { final ChildVaccinesViewModel model; final List_BabyInformationModel babyInfo; - DeleteBaby deleteBaby = DeleteBaby(); + final List_UserInformationModel informationModel; + final Function onTapDelete; - ChildDetailsWidget({this.model, this.babyInfo}); + ChildDetailsWidget({this.model, this.babyInfo, this.informationModel, this.onTapDelete}); @override Widget build(BuildContext context) { - return Container( - margin: EdgeInsets.only(left: 5, right: 5, bottom: 10), - decoration: BoxDecoration( - shape: BoxShape.rectangle, - border: Border.all(color: Colors.white, width: 0.5), - borderRadius: BorderRadius.all(Radius.circular(5)), - color: Colors.white, - ), - padding: EdgeInsets.all(12), - width: 200, - //double.infinity, - child: Column( - children: [ - Row(children: [ - Texts(TranslationBase.of(context).childName), - ]), - Row(children: [ - Texts(babyInfo.babyName.trim()), - ]), - Row(children: [ - IconButton( - icon: Image.asset(babyInfo.gender == 1 - ? 'assets/images/new-design/male.png' - : 'assets/images/new-design/female.png'), - tooltip: '', - onPressed: () { - }, + return InkWell( + onTap: (){ + Navigator.push( + context, + FadePage( + page: VaccinationTablePage( + babyInfo: babyInfo, + informationModel: informationModel, ), - Texts(babyInfo.genderDescription), - IconButton( - icon: Icon( - Icons.remove_red_eye, - color: Colors.red, - ), - tooltip: '', - onPressed: () { - Navigator.push( - context, - FadePage( - page: VaccinationTablePage(babyInfo: babyInfo,), - ), - ); - }, - ) - ]), - Row(children: [ - Texts(TranslationBase.of(context).childDob), - ]), - Row( - children: [ + ), + ); + }, + child: Container( + margin: EdgeInsets.only(left: 5, right: 5, bottom: 10), + decoration: BoxDecoration( + shape: BoxShape.rectangle, + border: Border.all(color: Colors.white, width: 0.5), + borderRadius: BorderRadius.all(Radius.circular(5)), + color: Colors.white, + ), + padding: EdgeInsets.all(12), + width: 200, + //double.infinity, + child: Column( + children: [ + Row(children: [ + Texts(TranslationBase.of(context).childName), + ]), + Row(children: [ + Texts(babyInfo.babyName.trim()), + ]), + Row(children: [ IconButton( - icon: new Image.asset( - 'assets/images/new-design/calender-secondary.png'), + icon: Image.asset(babyInfo.gender == 1 + ? 'assets/images/new-design/male.png' + : 'assets/images/new-design/female.png'), tooltip: '', + onPressed: () { + }, ), - Texts( - DateUtil.yearMonthDay(babyInfo.dOB), + Texts(babyInfo.genderDescription), + IconButton( + icon: Icon( + Icons.remove_red_eye, + color: Colors.red, + ), + tooltip: '', + onPressed: () { + Navigator.push( + context, + FadePage( + page: VaccinationTablePage( + babyInfo: babyInfo, + informationModel: informationModel, + ), + ), + ); + }, + ) + ]), + Row(children: [ + Texts(TranslationBase.of(context).childDob), + ]), + Row( + children: [ + IconButton( + icon: new Image.asset( + 'assets/images/new-design/calender-secondary.png'), + tooltip: '', + ), + Texts( + DateUtil.yearMonthDay(babyInfo.dOB), + ), + ], + ), + Row(children: [ + IconButton( + icon: new Image.asset('assets/images/new-design/garbage.png'), + tooltip: '', + onPressed: () async { + onTapDelete(); + }, ), - ], - ), - Row(children: [ - IconButton( - icon: new Image.asset('assets/images/new-design/garbage.png'), - tooltip: '', - onPressed: () async { - await model.deleteBabyOrders(newChild: deleteBaby); - deleteBaby.babyID = babyInfo.babyID; - - await model.deleteBabyOrders(newChild: deleteBaby); - if (model.isDeleted) { - AppToast.showSuccessToast(message: TranslationBase.of(context).deletedChild); - Navigator.pop(context, model.isDeleted); - } else { - //TODO handling error - } - }, + Texts(TranslationBase.of(context).delete), + ]), + SizedBox( + height: 12, ), - Texts(TranslationBase.of(context).delete), - ]), - SizedBox( - height: 12, - ), - ], + ], + ), ), ); } diff --git a/lib/pages/ChildVaccines/add_newchild_page.dart b/lib/pages/ChildVaccines/add_newchild_page.dart index 51b89f98..10dea666 100644 --- a/lib/pages/ChildVaccines/add_newchild_page.dart +++ b/lib/pages/ChildVaccines/add_newchild_page.dart @@ -11,6 +11,7 @@ import 'package:diplomaticquarterapp/pages/ChildVaccines/child_page.dart'; import 'package:diplomaticquarterapp/pages/base/base_view.dart'; import 'package:diplomaticquarterapp/pages/medical/active_medications/DayCheckBoxDialog.dart'; import 'package:diplomaticquarterapp/uitl/app_toast.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'; @@ -21,39 +22,16 @@ import 'package:flutter_datetime_picker/flutter_datetime_picker.dart'; import 'package:diplomaticquarterapp/uitl/date_uitl.dart'; enum Gender { Male, Female, NON } -enum BeneficiaryType { MyAccount, MyFamilyFiles, OtherAccount, NON } class AddNewChildPage extends StatefulWidget { - final int frequency; - final int days; - final String itemDescription; String dateAdd; - List _scheduleList = List(); - List daysOfWeek = [ - DayOfWeek.Monday, - DayOfWeek.Tuesday, - DayOfWeek.Wednesday, - DayOfWeek.Thursday, - DayOfWeek.Friday, - DayOfWeek.Saturday, - DayOfWeek.Sunday - ]; - DateTime startDay; DateTime endDay; - //AddNewChildPage({Key key, this.frequency, this.days, this.itemDescription}) : super(key: key); - AddNewChildPage({Key key, this.frequency, this.days, this.itemDescription}) { + AddNewChildPage() { startDay = DateTime.now(); - endDay = - DateTime.now(); //endDay = DateTime.now().add(Duration(days: days)); - int hour = 24; //(24 / frequency).round(); - int durations = 24 ~/ hour; - for (int count = 0; count < durations; count++) { - _scheduleList.add(DateTime(DateTime.now().year, DateTime.now().month, - DateTime.now().day, (hour * count))); - } + endDay = DateTime.now(); } @override @@ -61,150 +39,140 @@ class AddNewChildPage extends StatefulWidget { } class _AddNewChildPageState extends State { - int tappedIndex; int checkedValue; - @override - void initState() { - super.initState(); - tappedIndex = -1; - } - TextEditingController _firstTextController = TextEditingController(); TextEditingController _secondTextController = TextEditingController(); - TextEditingController _notesTextController = TextEditingController(); - BeneficiaryType beneficiaryType = BeneficiaryType.NON; Gender gender = Gender.Male; CreateNewUser_New newUserChild = CreateNewUser_New(); - //ChildVaccinesViewModel addvancedModel = ChildVaccinesViewModel(); - List_BabyInformationModel addvancedModel = List_BabyInformationModel(); CreateNewBaby newChild = CreateNewBaby(); - List_UserInformationModel informationModel = List_UserInformationModel(); + + String firstName = ""; + String secondName = ""; @override Widget build(BuildContext context) { return BaseView( builder: (_, model, w) => AppScaffold( isShowAppBar: true, - appBarTitle: "Vaccintion", + appBarTitle: TranslationBase.of(context).vaccination, body: SingleChildScrollView( physics: ScrollPhysics(), child: Container( margin: EdgeInsets.all(12), child: Column( - // crossAxisAlignment: CrossAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.start, children: [ SizedBox( - height: 50, - ), - Texts( - "Add the child's information below to recieve the schedule of vaccinations.", - //+model.user.firstName, - textAlign: TextAlign.center, + height: 25, ), + Texts(TranslationBase.of(context).addInstructions), SizedBox( - height: 12, + height: 20, ), NewTextFields( - hintText: "First Name", + hintText: TranslationBase.of(context).firstName, controller: _firstTextController, + onChanged: (value) { + setState(() { + firstName = value; + }); + }, ), SizedBox( height: 12, ), NewTextFields( - hintText: "Second Name", + hintText: TranslationBase.of(context).lastName, controller: _secondTextController, + onChanged: (value) { + secondName = value; + }, ), SizedBox( - height: 12, + height: 20, ), Row( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( - "Gender:", + TranslationBase.of(context).gender + " :", textAlign: TextAlign.end, ), ], ), + SizedBox( + height: 15, + ), Container( - height: MediaQuery.of(context).size.height * 0.12, + height: 60, width: double.infinity, - padding: EdgeInsets.all(12), - - child: Row( crossAxisAlignment: CrossAxisAlignment.stretch, mainAxisAlignment: MainAxisAlignment.center, children: [ - Container( - height: MediaQuery.of(context).size.height * 0.12, - width: 175, - color: Colors.white, - child: SecondaryButton( - textColor: - checkedValue == 1 ? Colors.white : Colors.black, - color: checkedValue == 1 ? Colors.red : Colors.white, - - label: "Male", - // - onTap: () { - - setState(() { - checkedValue = 1; - print("checkedValue=" + checkedValue.toString()); - }); - - // bloodDetails. - }, + Expanded( + child: AnimatedContainer( + duration: Duration(milliseconds: 400), + height: 60, + color: Colors.white, + child: SecondaryButton( + textColor: + checkedValue == 1 ? Colors.white : Colors.black, + color: + checkedValue == 1 ? Colors.red : Colors.white, + label: TranslationBase.of(context).male, + onTap: () { + setState(() { + checkedValue = 1; + }); + }, + ), ), ), - Container( - height: MediaQuery.of(context).size.height * 0.12, - width: 175, - color: Colors.white, - child: SecondaryButton( - textColor: - checkedValue == 2 ? Colors.white : Colors.black, - color: checkedValue == 2 ? Colors.red : Colors.white, - label: "Female", - // - onTap: () { - setState(() { - checkedValue = 2; - print("checkedValue=" + checkedValue.toString()); - }); - // bloodDetails.city=_selectedHospital.toString(); - - // bloodDetails. - }, + Expanded( + child: AnimatedContainer( + duration: Duration(milliseconds: 400), + height: 60, + color: Colors.white, + child: SecondaryButton( + textColor: + checkedValue == 2 ? Colors.white : Colors.black, + color: + checkedValue == 2 ? Colors.red : Colors.white, + label: TranslationBase.of(context).female, + onTap: () { + setState(() { + checkedValue = 2; + }); + }, + ), ), ) ], ), ), - //========== SizedBox( - height: 6, + height: 20, ), Row( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( - "Date Of Birth::", + TranslationBase.of(context).dob + " :", textAlign: TextAlign.end, ), ], ), + SizedBox( + height: 8, + ), InkWell( onTap: () { DatePicker.showDatePicker( context, showTitleActions: true, - // minTime: DateTime( - // DateTime.now().year, DateTime.now().month - 1, 1), minTime: DateTime(1, 1, 1), maxTime: DateTime.now(), onConfirm: (date) { @@ -213,7 +181,6 @@ class _AddNewChildPageState extends State { }); }, currentTime: widget.startDay, - // locale: projectViewModel.localeType ); }, child: Container( @@ -224,99 +191,63 @@ class _AddNewChildPageState extends State { borderRadius: BorderRadius.circular(12), color: Colors.white), child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, + // mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Texts(//getStartDay() - // DateUtil.yearMonthDay(DateTime.now()) - getStartDay()), Icon( Icons.calendar_today, color: Colors.black, - ) + ), + SizedBox( + width: 25, + ), + Expanded(child: Texts(getStartDay())), ], ), ), ), SizedBox( - height: 12, + height: 25, ), Container( - height: MediaQuery.of(context).size.height * 0.12, + height: 60, width: double.infinity, - padding: EdgeInsets.all(15), child: SecondaryButton( textColor: Colors.white, - color: checkedValue == false - ? Colors.white24 - : Color.fromRGBO( - 63, - 72, - 74, - 1, - ), - label: "Add", - // - onTap: () async{ - newChild.babyName = _firstTextController.text + " " + _secondTextController.text; + color: Colors.grey[800], + disabled: (checkedValue == null || + firstName.isEmpty || + secondName.isEmpty), + label: TranslationBase.of(context).add, + onTap: () async { + newChild.babyName = _firstTextController.text + + " " + + _secondTextController.text; newChild.gender = checkedValue.toString(); - newChild.strDOB = getStartDay(); + newChild.strDOB = widget.startDay.toIso8601String(); newChild.tempValue = true; newChild.isLogin = true; await model.createNewBabyOrders(newChild: newChild); - if(model.isAdded){ - AppToast.showSuccessToast(message: "Record Added"); - Navigator.pop(context,model.isAdded); - }else{ - - //TODO handling error + if (model.isAdded) { + AppToast.showSuccessToast( + message: TranslationBase.of(context).addedChild); + Navigator.pop(context, model.isAdded); + } else { + AppToast.showSuccessToast(message: model.error); } - }, ), ), - //========= ], ), ), ), - // bottomSheet: + // bottomSheet: ), ); } String getStartDay() { - return "${DateUtil.getMonth(widget.startDay.month)} ${widget.startDay.day}, ${widget.startDay.year}"; - } - - String getEndDay() { - return "${DateUtil.getMonth(widget.endDay.month)} ${widget.endDay.day}, ${widget.endDay.year}"; - } - - String getDateTime(DateTime dateTime) { - return '${dateTime.hour}:${dateTime.minute}'; - } - - String getDays() { - String days = ""; - widget.daysOfWeek.forEach((element) { - days += "${DateUtil.getDay(element)},"; - }); - return days; - } - - void confirmSelectDayDialog() { - showDialog( - context: context, - child: DayCheckBoxDialog( - title: 'Select Day', - selectedDaysOfWeek: widget.daysOfWeek, - onValueSelected: (value) { - setState(() { - widget.daysOfWeek = value; - }); - }, - ), - ); + return "${widget.startDay.day}-${widget.startDay.month}-${widget.startDay.year}"; } } diff --git a/lib/pages/ChildVaccines/child_page.dart b/lib/pages/ChildVaccines/child_page.dart index 7493a492..45020f79 100644 --- a/lib/pages/ChildVaccines/child_page.dart +++ b/lib/pages/ChildVaccines/child_page.dart @@ -1,5 +1,6 @@ import 'package:diplomaticquarterapp/core/model/childvaccines/List_BabyInformationModel.dart'; import 'package:diplomaticquarterapp/core/model/childvaccines/delete_baby_model.dart'; +import 'package:diplomaticquarterapp/core/model/childvaccines/user_information_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/child_vaccines/child_vaccines_view_model.dart'; import 'package:diplomaticquarterapp/pages/ChildVaccines/add_newchild_page.dart'; import 'package:diplomaticquarterapp/pages/ChildVaccines/vaccinationtable_page.dart'; @@ -13,15 +14,20 @@ import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:diplomaticquarterapp/uitl/date_uitl.dart'; +import 'package:flutter_flexible_toast/flutter_flexible_toast.dart'; import 'ChidDetailsWidget.dart'; import 'dialogs/delete_child.dart'; class ChildPage extends StatefulWidget { + final List_UserInformationModel informationModel; + + const ChildPage({Key key, this.informationModel}) : super(key: key); + @override _ChildPageState createState() => _ChildPageState(); } -//TODO + class _ChildPageState extends State with SingleTickerProviderStateMixin { DeleteBaby deleteBaby = DeleteBaby(); @@ -31,7 +37,7 @@ class _ChildPageState extends State var checkedValue = true; return BaseView( onModelReady: (model) => model.getNewUserOrders(), - builder: (_, model, widget) => AppScaffold( + builder: (_, model, w) => AppScaffold( isShowAppBar: true, appBarTitle: TranslationBase.of(context).vaccination, baseViewModel: model, @@ -54,6 +60,23 @@ class _ChildPageState extends State return ChildDetailsWidget( model: model, babyInfo: model.babyInformationModelList[index], + informationModel: widget.informationModel, + onTapDelete: () { + showDialog( + context: context, + child: DeleteChild(onTap: () async { + await model.deleteBabyOrders(babyInfo: model.babyInformationModelList[index]); + if (model.isDeleted) { + AppToast.showSuccessToast( + message: + TranslationBase.of(context).emailSuccess, + toastLength: Toast.LENGTH_LONG); + } else { + AppToast.showSuccessToast(message: model.error); + } + }), + ); + }, ); }, ), @@ -87,7 +110,8 @@ class _ChildPageState extends State builder: (context) => AddNewChildPage(), ), ).then((value) { - if (value) model.getNewUserOrders(); + if (value!=null) + model.getNewUserOrders(); }); }, ), diff --git a/lib/pages/ChildVaccines/child_vaccines_page.dart b/lib/pages/ChildVaccines/child_vaccines_page.dart index 4dd4c7f5..e3503894 100644 --- a/lib/pages/ChildVaccines/child_vaccines_page.dart +++ b/lib/pages/ChildVaccines/child_vaccines_page.dart @@ -23,6 +23,7 @@ class _ChildVaccinesPageState extends State TextEditingController titleController = TextEditingController(); var checkedValue = false; String addEmail = ""; + final updateEmailFormKey = GlobalKey(); @override Widget build(BuildContext context) { @@ -72,30 +73,31 @@ class _ChildVaccinesPageState extends State indent: 10, endIndent: 10, ), - Padding( - padding: const EdgeInsets.all(10.0), - child: Container( - margin: EdgeInsets.only(left: 10, right: 10, top: 15), - child: TextFields( - fillColor: Colors.red, - hintText: model.user.emailAddress, - controller: titleController, - fontSize: 20, - hintColor: Colors.black, - fontWeight: FontWeight.w600, - onChanged: (text) { - addEmail = text; - model.user.emailAddress == addEmail - ? checkedValue = false - : checkedValue = true; - }, - validator: (value) { - if (value == null) { - return model.user.emailAddress; - } else { - return model.user.emailAddress; - } - }, + Form( + key: updateEmailFormKey, + child: Padding( + padding: const EdgeInsets.all(10.0), + child: Container( + margin: EdgeInsets.only(left: 10, right: 10, top: 15), + child: TextFields( + fillColor: Colors.red, + initialValue: model.userInformationModelList.emailAddress, + fontSize: 20, + hintColor: Colors.black, + fontWeight: FontWeight.w600, + onChanged: (text) { + setState(() { + addEmail = text; + }); + }, + validator: (value) { + if (value.isEmpty) + return TranslationBase.of(context).enterEmail; + else if (!RegExp(r"^[a-zA-Z0-9.a-zA-Z0-9.!#$%&'*+-/=?^_`{|}~]+@[a-zA-Z0-9]+\.[a-zA-Z]+").hasMatch(value)) + return TranslationBase.of(context).validEmail; + return null; + }, + ), ), ), ), @@ -105,23 +107,17 @@ class _ChildVaccinesPageState extends State padding: EdgeInsets.all(15), child: SecondaryButton( textColor: Colors.white, - color: checkedValue == false - ? Colors.white24 - : Color.fromRGBO( - 63, - 72, - 74, - 1, - ), + color: model.userInformationModelList.emailAddress == addEmail ? Colors.white24 : Color.fromRGBO(63, 72, 74, 1,), + disabled: addEmail.isEmpty, label: TranslationBase.of(context).updateEmail, - // - onTap: () { - model.user.emailAddress = addEmail.toString(); - AppToast.showSuccessToast( - message: TranslationBase.of(context).updatedEmail); - // bloodDetails.city=_selectedHospital.toString(); + onTap: () async{ + final form = updateEmailFormKey.currentState; + if (form.validate()) { + form.save(); + await model.updateEmail(addEmail); + AppToast.showSuccessToast(message: TranslationBase.of(context).updatedEmail); + } - // bloodDetails. }, ), ), @@ -138,11 +134,10 @@ class _ChildVaccinesPageState extends State 1, ), label: TranslationBase.of(context).viewListChildren, - // onTap: () => Navigator.push( context, FadePage( - page: ChildPage(), + page: ChildPage(informationModel: model.userInformationModelList,), ), ), ), diff --git a/lib/pages/ChildVaccines/dialogs/SelectGenderDialog.dart b/lib/pages/ChildVaccines/dialogs/ConfirmSendEmailDialog.dart similarity index 70% rename from lib/pages/ChildVaccines/dialogs/SelectGenderDialog.dart rename to lib/pages/ChildVaccines/dialogs/ConfirmSendEmailDialog.dart index 33c11020..2279dd51 100644 --- a/lib/pages/ChildVaccines/dialogs/SelectGenderDialog.dart +++ b/lib/pages/ChildVaccines/dialogs/ConfirmSendEmailDialog.dart @@ -5,16 +5,18 @@ import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -class SelectGenderDialog extends StatefulWidget { - final Email; +class ConfirmSendEmailDialog extends StatefulWidget { + final email; + final Function onTap; + + const ConfirmSendEmailDialog({Key key, this.email, this.onTap}) + : super(key: key); - const SelectGenderDialog({Key key, this.Email}) : super(key: key); @override - _SelectGenderDialogState createState() => _SelectGenderDialogState(); + _ConfirmSendEmailDialogState createState() => _ConfirmSendEmailDialogState(); } -class _SelectGenderDialogState extends State { - +class _ConfirmSendEmailDialogState extends State { @override Widget build(BuildContext context) { return SimpleDialog( @@ -22,22 +24,15 @@ class _SelectGenderDialogState extends State { Container( child: Column( children: [ + Texts(TranslationBase.of(context).confirm), Divider(), Row( children: [ Expanded( flex: 1, - child: InkWell( - onTap: () { - setState(() { - //beneficiaryType = Gender.Male; - }); - }, - child: ListTile( - title: Text("Send the child's schedule to the email\n Tamer.dasdasdas@gmail.com "), - - - ), + child: ListTile( + title: Text(TranslationBase.of(context).confirmSend + + "\n ${widget.email} "), ), ) ], @@ -45,15 +40,7 @@ class _SelectGenderDialogState extends State { SizedBox( height: 5.0, ), - - SizedBox( - height: 5.0, - ), - SizedBox( - height: 5.0, - ), Row( - // mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Expanded( flex: 1, @@ -83,8 +70,7 @@ class _SelectGenderDialogState extends State { flex: 1, child: InkWell( onTap: () { - AppToast.showSuccessToast(message: "Email Sended"); - // widget.onValueSelected(beneficiaryType); + widget.onTap(); Navigator.pop(context); }, child: Padding( @@ -106,7 +92,4 @@ class _SelectGenderDialogState extends State { ], ); } - - - } diff --git a/lib/pages/ChildVaccines/dialogs/delete_child.dart b/lib/pages/ChildVaccines/dialogs/delete_child.dart index 250f40d3..41b02bd5 100644 --- a/lib/pages/ChildVaccines/dialogs/delete_child.dart +++ b/lib/pages/ChildVaccines/dialogs/delete_child.dart @@ -6,6 +6,10 @@ import 'package:flutter/material.dart'; class DeleteChild extends StatefulWidget { + final Function onTap; + + const DeleteChild({Key key, this.onTap}) : super(key: key); + @override _DeleteChildState createState() => _DeleteChildState(); } @@ -18,21 +22,14 @@ class _DeleteChildState extends State { Container( child: Column( children: [ + Texts(TranslationBase.of(context).confirm), Divider(), Row( children: [ Expanded( - flex: 1, - child: InkWell( - onTap: () { - setState(() { - //beneficiaryType = Gender.Male; - }); - }, - child: ListTile( - title: Text("Delete the child "), + child: ListTile( + title: Texts(TranslationBase.of(context).deletedChild), - ), ), ) ], @@ -40,15 +37,7 @@ class _DeleteChildState extends State { SizedBox( height: 5.0, ), - - SizedBox( - height: 5.0, - ), - SizedBox( - height: 5.0, - ), Row( - // mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Expanded( flex: 1, @@ -78,7 +67,7 @@ class _DeleteChildState extends State { flex: 1, child: InkWell( onTap: () { - // widget.onValueSelected(beneficiaryType); + widget.onTap(); Navigator.pop(context); }, child: Padding( diff --git a/lib/pages/ChildVaccines/vaccinationtable_page.dart b/lib/pages/ChildVaccines/vaccinationtable_page.dart index 4654c75a..68734c9a 100644 --- a/lib/pages/ChildVaccines/vaccinationtable_page.dart +++ b/lib/pages/ChildVaccines/vaccinationtable_page.dart @@ -1,7 +1,9 @@ import 'package:diplomaticquarterapp/core/model/childvaccines/List_BabyInformationModel.dart'; +import 'package:diplomaticquarterapp/core/model/childvaccines/user_information_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/child_vaccines/vaccination_table_view_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/medical/reports_monthly_view_model.dart'; import 'package:diplomaticquarterapp/pages/base/base_view.dart'; +import 'package:diplomaticquarterapp/uitl/app_toast.dart'; import 'package:diplomaticquarterapp/uitl/date_uitl.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/widgets/buttons/secondary_button.dart'; @@ -9,19 +11,23 @@ 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_flexible_toast/flutter_flexible_toast.dart'; import 'package:flutter_html/flutter_html.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; -import 'dialogs/SelectGenderDialog.dart'; +import 'dialogs/ConfirmSendEmailDialog.dart'; class VaccinationTablePage extends StatelessWidget { final List_BabyInformationModel babyInfo; + final List_UserInformationModel informationModel; + + const VaccinationTablePage({Key key, this.babyInfo, this.informationModel}) + : super(key: key); - const VaccinationTablePage({Key key, this.babyInfo}) : super(key: key); @override Widget build(BuildContext context) { var checkedValue; return BaseView( - onModelReady: (model) => model.getCreateVaccinationTable(), + onModelReady: (model) => model.getCreateVaccinationTable(babyInfo: babyInfo, informationModel: informationModel), builder: (_, model, w) => AppScaffold( isShowAppBar: true, baseViewModel: model, @@ -37,22 +43,30 @@ class VaccinationTablePage extends StatelessWidget { Expanded( child: Column( children: [ - Texts(TranslationBase.of(context).childName), - Texts(babyInfo.babyName??'',fontWeight: FontWeight.w600,), + Texts(TranslationBase.of(context).childName), + Texts( + babyInfo.babyName ?? '', + fontWeight: FontWeight.w600, + ), ], ), ), Expanded( - child: Column(children: [ - + child: Column( + children: [ Texts(TranslationBase.of(context).childDob), Row( crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center, children: [ - Icon(FontAwesomeIcons.calendarCheck,color: Colors.red,), - SizedBox(width: 15,), - Texts(DateUtil.yearMonthDay(babyInfo.dOB)??''), + Icon( + FontAwesomeIcons.calendarCheck, + color: Colors.red, + ), + SizedBox( + width: 15, + ), + Texts(DateUtil.yearMonthDay(babyInfo.dOB) ?? ''), ], ), ], @@ -60,7 +74,9 @@ class VaccinationTablePage extends StatelessWidget { ), ], ), - SizedBox(height: 15,), + SizedBox( + height: 15, + ), Divider(), Column( children: [ @@ -75,25 +91,19 @@ class VaccinationTablePage extends StatelessWidget { mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: [ - Texts(TranslationBase.of(context).descriptionVaccination), + Texts(TranslationBase.of(context) + .descriptionVaccination), ], ), ), Texts(TranslationBase.of(context).dueDate), ], ), - ], ), ...List.generate( model.creteVaccinationTableModelList.length, (index) => Container( - // decoration: BoxDecoration( - // shape: BoxShape.rectangle, - // border: Border.all(color: Colors.white, width: 0.5), - // borderRadius: BorderRadius.all(Radius.circular(5)), - // // color: Colors.white, - // ), padding: EdgeInsets.all(12), width: double.infinity, child: Column( @@ -111,16 +121,21 @@ class VaccinationTablePage extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.start, children: [ Html( - data: model.creteVaccinationTableModelList[index].vaccinesDescription, + data: model + .creteVaccinationTableModelList[index] + .vaccinesDescription, ), ], ), ), - Texts(model.creteVaccinationTableModelList[index].givenAt), + Texts(model + .creteVaccinationTableModelList[index].givenAt), ], ), Divider( - color: Colors.white,height: 3,thickness: 1.0, + color: Colors.white, + height: 3, + thickness: 1.0, ), ], ), @@ -140,12 +155,24 @@ class VaccinationTablePage extends StatelessWidget { textColor: Colors.white, color: checkedValue == false ? Colors.white24 - : Color.fromRGBO(63, 72, 74, 1,), + : Color.fromRGBO( + 63, + 72, + 74, + 1, + ), label: TranslationBase.of(context).sendEmail, onTap: () { showDialog( context: context, - child: SelectGenderDialog(), + child: ConfirmSendEmailDialog( + email: informationModel.emailAddress, + onTap: () async { + await model.getCreateVaccinationTable(babyInfo: babyInfo, informationModel: informationModel,isSendEmail: true); + AppToast.showSuccessToast(message: TranslationBase.of(context).emailSuccess,toastLength: Toast.LENGTH_LONG); + + }, + ), ); }, ), diff --git a/lib/pages/landing/home_page.dart b/lib/pages/landing/home_page.dart index 79f8f7b1..fb2cc108 100644 --- a/lib/pages/landing/home_page.dart +++ b/lib/pages/landing/home_page.dart @@ -1,8 +1,8 @@ import 'package:diplomaticquarterapp/config/size_config.dart'; import 'package:diplomaticquarterapp/core/viewModels/dashboard_view_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; -import 'package:diplomaticquarterapp/pages/AlHabibMedicalService/ComprehensiveMedicalCheckup/cmc_index_page.dart'; -import 'package:diplomaticquarterapp/pages/AlHabibMedicalService/HomeHealthCare/home_health_care_index_page.dart'; +import 'package:diplomaticquarterapp/pages/AlHabibMedicalService/ComprehensiveMedicalCheckup/cmc_page.dart'; +import 'package:diplomaticquarterapp/pages/AlHabibMedicalService/HomeHealthCare/home_health_care_page.dart'; import 'package:diplomaticquarterapp/pages/AlHabibMedicalService/all_habib_medical_service_page.dart'; import 'package:diplomaticquarterapp/pages/ContactUs/contact_us_page.dart'; import 'package:diplomaticquarterapp/pages/Covid-DriveThru/covid-drivethru-location.dart'; @@ -445,7 +445,7 @@ class _HomePageState extends State { Navigator.push( context, FadePage( - page: HomeHealthCareIndexPage(), + page: HomeHealthCarePage(), ), ); }, @@ -513,7 +513,7 @@ class _HomePageState extends State { Navigator.push( context, FadePage( - page: CMCIndexPage(), + page: CMCPage(), ), ); }, diff --git a/lib/uitl/date_uitl.dart b/lib/uitl/date_uitl.dart index 1068dc74..34c7bf87 100644 --- a/lib/uitl/date_uitl.dart +++ b/lib/uitl/date_uitl.dart @@ -21,7 +21,7 @@ class DateUtil { static String convertDateToString(DateTime date) { const start = "/Date("; - const end = "+0300)"; + const end = "+0300)/"; int milliseconds = date.millisecondsSinceEpoch; return start + "$milliseconds" + end; diff --git a/lib/uitl/translations_delegate_base.dart b/lib/uitl/translations_delegate_base.dart index 4e0edcfd..48743fcd 100644 --- a/lib/uitl/translations_delegate_base.dart +++ b/lib/uitl/translations_delegate_base.dart @@ -1,7 +1,6 @@ import 'dart:async'; import 'package:diplomaticquarterapp/config/localized_values.dart'; -import 'package:diplomaticquarterapp/pages/symptom-checker/select-gender.dart'; import 'package:flutter/foundation.dart' show SynchronousFuture; import 'package:flutter/material.dart'; @@ -697,6 +696,8 @@ String get fileno => localizedValues['fileno'][locale.languageCode]; localizedValues['ServiceInformation'][locale.languageCode]; String get homeHealthCare => localizedValues['HomeHealthCare'][locale.languageCode]; + String get HHCNotAuthMsg => + localizedValues['HHCNotAuthMsg'][locale.languageCode]; String get homeHealthCareText => localizedValues['HomeHealthCareText'][locale.languageCode]; String get loginRegister => @@ -885,10 +886,16 @@ String get fileno => localizedValues['fileno'][locale.languageCode]; String get childName => localizedValues['child-name'][locale.languageCode]; String get childDob => localizedValues['childDob'][locale.languageCode]; String get delete => localizedValues['delete'][locale.languageCode]; - String get deletedChild => localizedValues['deleted-child'][locale.languageCode]; + String get deletedChildMes => localizedValues['deleted-child-mes'][locale.languageCode]; String get visit => localizedValues['visit'][locale.languageCode]; String get descriptionVaccination => localizedValues['description-vaccination'][locale.languageCode]; String get dueDate => localizedValues['due-date'][locale.languageCode]; + String get validEmail => localizedValues['valid-email'][locale.languageCode]; + String get confirmSend => localizedValues['confirm-send'][locale.languageCode]; + String get emailSuccess => localizedValues['email-success'][locale.languageCode]; + String get deletedChild => localizedValues['deleted-child'][locale.languageCode]; + String get addInstructions => localizedValues['add-instructions'][locale.languageCode]; + String get addedChild => localizedValues['added-child'][locale.languageCode]; String get appUpdate => localizedValues['appUpdate'][locale.languageCode]; String get ereferralSaveSuccess => localizedValues['ereferralSaveSuccess'][locale.languageCode]; diff --git a/lib/widgets/dialogs/select_location_dialog.dart b/lib/widgets/dialogs/select_location_dialog.dart new file mode 100644 index 00000000..34e37208 --- /dev/null +++ b/lib/widgets/dialogs/select_location_dialog.dart @@ -0,0 +1,139 @@ +import 'package:diplomaticquarterapp/core/service/AlHabibMedicalService/customer_addresses_service.dart'; +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'; + +// ignore: must_be_immutable +class SelectLocationDialog extends StatefulWidget { + final List addresses; + final Function(AddressInfo) onValueSelected; + AddressInfo selectedAddress; + + SelectLocationDialog( + {Key key, this.addresses, this.onValueSelected, this.selectedAddress}); + + @override + _SelectLocationDialogState createState() => _SelectLocationDialogState(); +} + +class _SelectLocationDialogState extends State { + @override + void initState() { + super.initState(); + widget.selectedAddress = widget.selectedAddress ?? widget.addresses[0]; + } + + @override + Widget build(BuildContext context) { + return SimpleDialog( + title: Texts("sdsdsd"), + children: [ + Column( + children: [ + Container( + height: 150, + child: SingleChildScrollView( + child: Column( + children: [ + Divider(), + ...List.generate( + widget.addresses.length, + (index) => Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SizedBox( + height: 2, + ), + Row( + children: [ + Expanded( + flex: 1, + child: InkWell( + onTap: () { + setState(() { + widget.selectedAddress = widget.addresses[index]; + }); + }, + child: ListTile( + title: Text(widget.addresses[index].address1), + leading: Radio( + value: widget.addresses[index], + groupValue: widget.selectedAddress, + activeColor: Colors.red[800], + onChanged: (value) { + setState(() { + widget.selectedAddress = value; + }); + }, + ), + ), + ), + ) + ], + ), + SizedBox( + height: 5.0, + ), + ], + ), + ), + SizedBox( + height: 5.0, + ), + ], + ), + ), + ), + Row( + // mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Expanded( + flex: 1, + child: InkWell( + onTap: () { + Navigator.pop(context); + }, + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Container( + child: Center( + child: Texts( + TranslationBase.of(context).cancel.toUpperCase(), + color: Colors.red, + ), + ), + ), + ), + ), + ), + Container( + width: 1, + height: 30, + color: Colors.grey[500], + ), + Expanded( + flex: 1, + child: InkWell( + onTap: () { + widget.onValueSelected(widget.selectedAddress); + Navigator.pop(context); + }, + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Center( + child: Texts( + TranslationBase.of(context).ok, + fontWeight: FontWeight.w400, + )), + ), + ), + ), + ], + ) + ], + ) + ], + ); + } +} diff --git a/lib/widgets/input/text_field.dart b/lib/widgets/input/text_field.dart index 6e740fc8..e31ae88a 100644 --- a/lib/widgets/input/text_field.dart +++ b/lib/widgets/input/text_field.dart @@ -47,7 +47,7 @@ class TextFields extends StatefulWidget { this.autoFocus, this.onChanged, - // this.initialValue, + this.initialValue, this.minLines, this.maxLines, this.inputFormatters, @@ -79,7 +79,7 @@ class TextFields extends StatefulWidget { final String hintText; - // final String initialValue; + final String initialValue; final String type; final bool autoFocus; final IconData suffixIcon; @@ -230,7 +230,7 @@ class _TextFieldsState extends State { minLines: widget.minLines ?? 1, maxLines: widget.maxLines ?? 1, maxLengthEnforced: widget.maxLengthEnforced, - // initialValue: widget.initialValue, + initialValue: widget.initialValue, onChanged: widget.onChanged, focusNode: _focusNode, maxLength: widget.maxLength ?? null,