diff --git a/assets/app_icons/config.json b/assets/app_icons/config.json index e2e1afdb..ceb65b05 100644 --- a/assets/app_icons/config.json +++ b/assets/app_icons/config.json @@ -271,6 +271,184 @@ "search": [ "roboticon" ] + }, + { + "uid": "8ce732688587909ad0a9d8323eaca8ad", + "css": "marquee", + "code": 59590, + "src": "fontelico" + }, + { + "uid": "ec8496ef645f3be7b28147ec60cd9ab1", + "css": "crown-minus", + "code": 59589, + "src": "fontelico" + }, + { + "uid": "36ef9feb0754335302784521267a9ad4", + "css": "crown-plus", + "code": 59588, + "src": "fontelico" + }, + { + "uid": "186dec7a13156bbe2550790c158fb85d", + "css": "crown", + "code": 59587, + "src": "fontelico" + }, + { + "uid": "2a46f1d1c9bd036e17a74e46613c1636", + "css": "ie", + "code": 59586, + "src": "fontelico" + }, + { + "uid": "9c2b737b16ae2c8d66b7bfd29ba5ecd8", + "css": "chrome", + "code": 59584, + "src": "fontelico" + }, + { + "uid": "45861dd1e5ce4fde338bcccf01eeb808", + "css": "opera", + "code": 59585, + "src": "fontelico" + }, + { + "uid": "2bd5f98482d86649958312ea2ab5bb40", + "css": "emo-laugh", + "code": 59576, + "src": "fontelico" + }, + { + "uid": "fc92480dedc439d274d4e3e4b425edf4", + "css": "emo-squint", + "code": 59575, + "src": "fontelico" + }, + { + "uid": "4843d0d6050dd508d4c101a334f46db2", + "css": "emo-shoot", + "code": 59574, + "src": "fontelico" + }, + { + "uid": "04688d76a33ce7a7950e40fae79c08ac", + "css": "emo-cry", + "code": 59573, + "src": "fontelico" + }, + { + "uid": "e4b163acaaa08255819f2f78afe8f075", + "css": "cart_menu_icon", + "code": 59412, + "src": "custom_icons", + "selected": true, + "svg": { + "path": "M367.1 624.3H972.6A33.2 33.2 0 0 0 1004.7 601.7L1138.2 164.7A29.6 29.6 0 0 0 1132.9 137.3 34.3 34.3 0 0 0 1106.3 124.9H289.9L266.3 24.5A33 33 0 0 0 233.7 0H33.4A32.4 32.4 0 0 0 0 31.2 32.4 32.4 0 0 0 33.4 62.4H206.9L327.4 569.6A93.8 93.8 0 0 0 267.1 655.5 97.1 97.1 0 0 0 367.2 749.1H972.6A31.3 31.3 0 1 0 972.6 686.7H367.2A31.3 31.3 0 1 1 367.2 624.3ZM1061.9 187.3L947.4 561.9H394L305 187.3ZM1061.9 187.3M315.3 894.6A105.4 105.4 0 1 0 420.7 789.2 105.4 105.4 0 0 0 315.3 894.6ZM420.7 859.4A35.2 35.2 0 1 1 385.6 894.6 35.2 35.2 0 0 1 420.7 859.4ZM420.7 859.4M735.4 894.6A105.4 105.4 0 1 0 840.9 789.2 105.4 105.4 0 0 0 735.4 894.6ZM840.9 859.4A35.2 35.2 0 1 1 805.7 894.6 35.2 35.2 0 0 1 840.9 859.4ZM840.9 859.4", + "width": 1140 + }, + "search": [ + "cart_menu_icon" + ] + }, + { + "uid": "45f50872f02e050e19f0910ca3e0e8e6", + "css": "categories_menu_icon", + "code": 59413, + "src": "custom_icons", + "selected": true, + "svg": { + "path": "M332.7 458.9H126.3A126.3 126.3 0 0 1 0 332.7V126.3A126.3 126.3 0 0 1 126.3 0H332.7A126.3 126.3 0 0 1 459 126.3V332.7A126.3 126.3 0 0 1 332.7 458.9ZM126.3 61.2A65.1 65.1 0 0 0 61.2 126.3V332.7A65.1 65.1 0 0 0 126.3 397.8H332.7A65.1 65.1 0 0 0 397.8 332.7V126.3A65.1 65.1 0 0 0 332.7 61.2ZM873.8 458.9H667.3A126.3 126.3 0 0 1 541 332.6V126.3A126.3 126.3 0 0 1 667.3 0H873.9A126.3 126.3 0 0 1 1000.2 126.3V332.7A126.3 126.3 0 0 1 873.8 458.9ZM667.3 61.2A65.1 65.1 0 0 0 602.2 126.3V332.7A65.1 65.1 0 0 0 667.3 397.8H873.9A65.1 65.1 0 0 0 938.9 332.7V126.3A65.1 65.1 0 0 0 873.9 61.3ZM332.7 999.9H126.3A126.3 126.3 0 0 1 0 873.7V667.3A126.3 126.3 0 0 1 126.3 541H332.7A126.3 126.3 0 0 1 459 667.3V873.9A126.3 126.3 0 0 1 332.7 999.9ZM126.3 602.2A65.1 65.1 0 0 0 61.2 667.3V873.9A65.1 65.1 0 0 0 126.3 938.8H332.7A65.1 65.1 0 0 0 397.8 873.8V667.3A65.1 65.1 0 0 0 332.7 602.3ZM873.8 999.9H667.3A126.3 126.3 0 0 1 541 873.7V667.3A126.3 126.3 0 0 1 667.3 541H873.8A126.3 126.3 0 0 1 1000.1 667.3V873.9A126.3 126.3 0 0 1 873.8 999.9ZM667.3 602.2A65.1 65.1 0 0 0 602.2 667.3V873.9A65.1 65.1 0 0 0 667.3 938.8H873.8A65.1 65.1 0 0 0 938.8 873.8V667.3A65.1 65.1 0 0 0 873.8 602.3Z", + "width": 1000 + }, + "search": [ + "categories_menu_icon" + ] + }, + { + "uid": "de65d94899c08a719eb8f9b723f73fc4", + "css": "hmg_logo_icon", + "code": 59414, + "src": "custom_icons", + "selected": true, + "svg": { + "path": "M146 835.7S180.9 835.5 205.5 835.5L392.2 836.4C414.4 836.4 433 812.7 434 778.5L434 622.5C434 589.3 448.9 563.3 472 561.7L529.2 561.2C552.3 562.7 568.1 588.9 568.1 622L568.1 778.9C569.2 813.1 584.7 835.5 607.1 835.5L858.4 836.1 858.8 643.3C858.8 610.2 842.9 584.4 819.8 583L718.8 582.5C696.5 582.5 678.9 558.9 677.9 524.7L677.5 472.6C678.6 438.4 696.4 414.8 718.7 414.8L820.2 415.1C843.3 413.6 858.3 386.4 858.3 353.3L858.5 112.8A102.4 102.4 0 0 1 780.8 161.4L610.2 161.4C587.9 161.4 569.4 185.7 568.3 219.9V374.6C567.2 408.8 549.8 432.9 527.5 432.9L475.8 432C453.4 432 435.6 408.6 434.5 374.7L434.5 218.4C433.4 184.3 415.6 161.2 393.4 161.2L145.6 161.2 145.6 353.4C145.6 386.6 161.2 413.1 184.3 414.7L285.8 414.3C308.8 415.8 325.1 443.2 325.1 476.2L324.8 520.7C324.8 553.8 309.1 580.4 286 581.9L184.3 581.7C161.2 583.3 145.6 609.5 145.6 642.6ZM999.3 99.1V902.8A102.2 102.2 0 0 1 896 1000H102.8A101.9 101.9 0 0 1 0 902.8L0 97.6A102.3 102.3 0 0 1 103 0L895.4 0.3A104 104 0 0 1 999.3 99.1Z", + "width": 999 + }, + "search": [ + "hmg_logo_icon" + ] + }, + { + "uid": "baf8798b7336aad03b1d61cacc015142", + "css": "user_menu_icon", + "code": 59415, + "src": "custom_icons", + "selected": true, + "svg": { + "path": "M853.6 146.4A500 500 0 0 0 146.4 853.6 500 500 0 0 0 853.6 146.4ZM217 838.5A286.1 286.1 0 0 1 500 586.7 285 285 0 0 1 783 838.5 440.5 440.5 0 0 1 217 838.5ZM500 526.3A151.8 151.8 0 1 1 651.8 374.5 152.1 152.1 0 0 1 500 526.3ZM833.4 788.8A344.4 344.4 0 0 0 617.6 548.7 210.5 210.5 0 1 0 382.1 548.7 344.2 344.2 0 0 0 166.3 788.7 441.4 441.4 0 1 1 833.2 788.7ZM833.4 788.8", + "width": 1000 + }, + "search": [ + "user_menu_icon" + ] + }, + { + "uid": "d3f621623139837ff2fb5fe09cf16994", + "css": "cart_menu_icon-1", + "code": 59416, + "src": "custom_icons", + "selected": true, + "svg": { + "path": "M367.1 624.3H972.6A33.2 33.2 0 0 0 1004.7 601.7L1138.2 164.7A29.6 29.6 0 0 0 1132.9 137.3 34.3 34.3 0 0 0 1106.3 124.9H289.9L266.3 24.5A33 33 0 0 0 233.7 0H33.4A32.4 32.4 0 0 0 0 31.2 32.4 32.4 0 0 0 33.4 62.4H206.9L327.4 569.6A93.8 93.8 0 0 0 267.1 655.5 97.1 97.1 0 0 0 367.2 749.1H972.6A31.3 31.3 0 1 0 972.6 686.7H367.2A31.3 31.3 0 1 1 367.2 624.3ZM1061.9 187.3L947.4 561.9H394L305 187.3ZM1061.9 187.3M315.3 894.6A105.4 105.4 0 1 0 420.7 789.2 105.4 105.4 0 0 0 315.3 894.6ZM420.7 859.4A35.2 35.2 0 1 1 385.6 894.6 35.2 35.2 0 0 1 420.7 859.4ZM420.7 859.4M735.4 894.6A105.4 105.4 0 1 0 840.9 789.2 105.4 105.4 0 0 0 735.4 894.6ZM840.9 859.4A35.2 35.2 0 1 1 805.7 894.6 35.2 35.2 0 0 1 840.9 859.4ZM840.9 859.4", + "width": 1140 + }, + "search": [ + "cart_menu_icon" + ] + }, + { + "uid": "6aac6f399374da0b9c4811b6a7110627", + "css": "categories_menu_icon-1", + "code": 59417, + "src": "custom_icons", + "selected": true, + "svg": { + "path": "M332.7 458.9H126.3A126.3 126.3 0 0 1 0 332.7V126.3A126.3 126.3 0 0 1 126.3 0H332.7A126.3 126.3 0 0 1 459 126.3V332.7A126.3 126.3 0 0 1 332.7 458.9ZM126.3 61.2A65.1 65.1 0 0 0 61.2 126.3V332.7A65.1 65.1 0 0 0 126.3 397.8H332.7A65.1 65.1 0 0 0 397.8 332.7V126.3A65.1 65.1 0 0 0 332.7 61.2ZM873.8 458.9H667.3A126.3 126.3 0 0 1 541 332.6V126.3A126.3 126.3 0 0 1 667.3 0H873.9A126.3 126.3 0 0 1 1000.2 126.3V332.7A126.3 126.3 0 0 1 873.8 458.9ZM667.3 61.2A65.1 65.1 0 0 0 602.2 126.3V332.7A65.1 65.1 0 0 0 667.3 397.8H873.9A65.1 65.1 0 0 0 938.9 332.7V126.3A65.1 65.1 0 0 0 873.9 61.3ZM332.7 999.9H126.3A126.3 126.3 0 0 1 0 873.7V667.3A126.3 126.3 0 0 1 126.3 541H332.7A126.3 126.3 0 0 1 459 667.3V873.9A126.3 126.3 0 0 1 332.7 999.9ZM126.3 602.2A65.1 65.1 0 0 0 61.2 667.3V873.9A65.1 65.1 0 0 0 126.3 938.8H332.7A65.1 65.1 0 0 0 397.8 873.8V667.3A65.1 65.1 0 0 0 332.7 602.3ZM873.8 999.9H667.3A126.3 126.3 0 0 1 541 873.7V667.3A126.3 126.3 0 0 1 667.3 541H873.8A126.3 126.3 0 0 1 1000.1 667.3V873.9A126.3 126.3 0 0 1 873.8 999.9ZM667.3 602.2A65.1 65.1 0 0 0 602.2 667.3V873.9A65.1 65.1 0 0 0 667.3 938.8H873.8A65.1 65.1 0 0 0 938.8 873.8V667.3A65.1 65.1 0 0 0 873.8 602.3Z", + "width": 1000 + }, + "search": [ + "categories_menu_icon" + ] + }, + { + "uid": "0a4cf1ff2671b9ea852d635e27df1e69", + "css": "hmg_logo_icon-1", + "code": 59418, + "src": "custom_icons", + "selected": true, + "svg": { + "path": "M146 835.7S180.9 835.5 205.5 835.5L392.2 836.4C414.4 836.4 433 812.7 434 778.5L434 622.5C434 589.3 448.9 563.3 472 561.7L529.2 561.2C552.3 562.7 568.1 588.9 568.1 622L568.1 778.9C569.2 813.1 584.7 835.5 607.1 835.5L858.4 836.1 858.8 643.3C858.8 610.2 842.9 584.4 819.8 583L718.8 582.5C696.5 582.5 678.9 558.9 677.9 524.7L677.5 472.6C678.6 438.4 696.4 414.8 718.7 414.8L820.2 415.1C843.3 413.6 858.3 386.4 858.3 353.3L858.5 112.8A102.4 102.4 0 0 1 780.8 161.4L610.2 161.4C587.9 161.4 569.4 185.7 568.3 219.9V374.6C567.2 408.8 549.8 432.9 527.5 432.9L475.8 432C453.4 432 435.6 408.6 434.5 374.7L434.5 218.4C433.4 184.3 415.6 161.2 393.4 161.2L145.6 161.2 145.6 353.4C145.6 386.6 161.2 413.1 184.3 414.7L285.8 414.3C308.8 415.8 325.1 443.2 325.1 476.2L324.8 520.7C324.8 553.8 309.1 580.4 286 581.9L184.3 581.7C161.2 583.3 145.6 609.5 145.6 642.6ZM999.3 99.1V902.8A102.2 102.2 0 0 1 896 1000H102.8A101.9 101.9 0 0 1 0 902.8L0 97.6A102.3 102.3 0 0 1 103 0L895.4 0.3A104 104 0 0 1 999.3 99.1Z", + "width": 999 + }, + "search": [ + "hmg_logo_icon" + ] + }, + { + "uid": "d19eb878f1dee49848276b6d0faa6602", + "css": "wishlist_menu_icon", + "code": 59411, + "src": "custom_icons", + "selected": false, + "svg": { + "path": "M877.6 0A394.8 394.8 0 0 0 600.7 112.2 394.8 394.8 0 0 0 323.8 0 332.4 332.4 0 0 0 0 349 515.4 515.4 0 0 0 138.3 679.5 1351.1 1351.1 0 0 0 580.3 995.3 46.9 46.9 0 0 0 621.1 995.3 1351.1 1351.1 0 0 0 1063.1 679.5 515.4 515.4 0 0 0 1201.4 349 332.5 332.5 0 0 0 877.6 0ZM991.8 618.5A1233.8 1233.8 0 0 1 600.7 900.8 1233.7 1233.7 0 0 1 209.5 618.5 418.4 418.4 0 0 1 93.8 349 239.1 239.1 0 0 1 323.8 93.8 297.2 297.2 0 0 1 500.6 150.7 283.5 283.5 0 0 1 562 209.5 46.5 46.5 0 0 0 600.5 230H600.5A46.9 46.9 0 0 0 639.1 209.3 301.2 301.2 0 0 1 877.2 93.8 239.2 239.2 0 0 1 1107.1 349 418.4 418.4 0 0 1 991.8 618.5Z", + "width": 1201 + }, + "search": [ + "wishlist_menu_icon" + ] } ] } \ No newline at end of file diff --git a/assets/app_icons/fonts/DQIcons.ttf b/assets/app_icons/fonts/DQIcons.ttf index bc92c83d..e0a15c88 100644 Binary files a/assets/app_icons/fonts/DQIcons.ttf and b/assets/app_icons/fonts/DQIcons.ttf differ diff --git a/assets/images/pharmacy_module/bg_1.png b/assets/images/pharmacy_module/bg_1.png index 9505e556..0155a7b3 100644 Binary files a/assets/images/pharmacy_module/bg_1.png and b/assets/images/pharmacy_module/bg_1.png differ diff --git a/assets/images/pharmacy_module/bg_2.png b/assets/images/pharmacy_module/bg_2.png index 96cfd3bc..0a1bc5cb 100644 Binary files a/assets/images/pharmacy_module/bg_2.png and b/assets/images/pharmacy_module/bg_2.png differ diff --git a/assets/images/pharmacy_module/bg_3.png b/assets/images/pharmacy_module/bg_3.png index 127c2669..3a28d5f9 100644 Binary files a/assets/images/pharmacy_module/bg_3.png and b/assets/images/pharmacy_module/bg_3.png differ diff --git a/assets/images/pharmacy_module/bg_4.png b/assets/images/pharmacy_module/bg_4.png index 423ab421..234ebe7b 100644 Binary files a/assets/images/pharmacy_module/bg_4.png and b/assets/images/pharmacy_module/bg_4.png differ diff --git a/lib/config/config.dart b/lib/config/config.dart index aca487fe..33f12a0a 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -16,8 +16,8 @@ const BASE_URL = 'https://uat.hmgwebservices.com/'; // const BASE_URL = 'https://hmgwebservices.com/'; // Pharmacy UAT URLs -// const BASE_PHARMACY_URL = 'https://uat.hmgwebservices.com/epharmacy/api/'; -// const PHARMACY_BASE_URL = 'https://uat.hmgwebservices.com/epharmacy/api/'; +const BASE_PHARMACY_URL = 'https://uat.hmgwebservices.com/epharmacy/api/'; +const PHARMACY_BASE_URL = 'https://uat.hmgwebservices.com/epharmacy/api/'; // Pharmacy Production URLs const BASE_PHARMACY_URL = 'https://mdlaboratories.com/exacartapi/api/'; @@ -420,8 +420,8 @@ const TRANSFER_YAHALA_LOYALITY_POINTS = "Services/Patients.svc/REST/TransferYaHa const LAKUM_GET_USER_TERMS_AND_CONDITIONS = "Services/ERP.svc/REST/GetUserTermsAndConditionsForEPharmcy"; const PRESCRIPTION = 'Services/Patients.svc/REST/GetPrescriptionApptList'; const GET_RECOMMENDED_PRODUCT = 'alsoProduct/'; -const GET_MOST_VIEWED_PRODUCTS = "mostview?"; -const GET_NEW_PRODUCTS = "newproducts?"; +const GET_MOST_VIEWED_PRODUCTS = "mostview"; +const GET_NEW_PRODUCTS = "newproducts"; // Home Health Care const HHC_GET_ALL_SERVICES = "Services/Patients.svc/REST/PatientER_HHC_GetAllServices"; diff --git a/lib/config/localized_values.dart b/lib/config/localized_values.dart index 535f69e0..9f161f25 100644 --- a/lib/config/localized_values.dart +++ b/lib/config/localized_values.dart @@ -757,6 +757,9 @@ const Map localizedValues = { "permissions": {"en": "Permission", "ar": "الصلاحيات"}, "camera-permission": {"en": "Camera", "ar": "الكاميرا"}, "location-permission": {"en": "Location", "ar": "تحديد المواقع"}, + + "needPrescription": {"en": "This product requires a prescription", "ar": " هذا المنتج يتطلب وصفة طبية"}, + "outOfStockMsg": {"en": "You have added product which is out of stock now, Please remove that!", "ar": "لقد قمت بإضافة المنتج الذي نفذ من المخزون الآن. يرجى إزالة ذلك"}, "accessibility": {"en": "Accessibility Mode", "ar": "وضع امكانية الوصول"}, "orderStatus": {"en": "Order Status", "ar": "حالة الطلب"}, "CancelOrder": {"en": "Cancel Order", "ar": "الغاء الطلب"}, @@ -1036,6 +1039,7 @@ const Map localizedValues = { "quantitySize": {"en": "Quantity", "ar": "كميه"}, "addToCart": {"en": "Add to Cart", "ar": "إضف للسلة"}, "addToWishlist": {"en": "Add to Wishlist", "ar": "اضف للمفضلة"}, + "removeFromWishlist": {"en": "Remove From Wishlist", "ar": "احذف للمفضلة"}, "noData": {"en": "There is no data", "ar": "لايوجد بيانات"}, "no_data": {"en": "No data", "ar": "لايوجد بيانات"}, "buyNow": {"en": "buy now", "ar": "إشتري الان"}, @@ -1555,4 +1559,6 @@ const Map localizedValues = { "News": {"en": "News", "ar": "أخبار"}, "Latest": {"en": "Latest", "ar": "أحدث"}, "Tour": {"en": "Tour", "ar": "رحلة"}, + "mostViewed": {"en": "Most Viewed", "ar": "الأكثر مشاهدة"}, + "newProducts": {"en": "New Products", "ar": "منتجات جديدة"} }; diff --git a/lib/core/model/pharmacies/PharmacyProduct.dart b/lib/core/model/pharmacies/PharmacyProduct.dart index f69d035b..dbef5737 100644 --- a/lib/core/model/pharmacies/PharmacyProduct.dart +++ b/lib/core/model/pharmacies/PharmacyProduct.dart @@ -108,10 +108,10 @@ class PharmacyProduct { List manufacturerIds; List reviews; List images; - List attributes; + List attributes; List specifications; - List associatedProductIds; - List tags; + List associatedProductIds; + List tags; int vendorId; String seName; @@ -367,7 +367,7 @@ class PharmacyProduct { }); } if (json['attributes'] != null) { - attributes = new List(); + attributes = new List(); json['attributes'].forEach((v) { attributes.add(v); }); diff --git a/lib/core/model/pharmacies/ShoppingCartResponse.dart b/lib/core/model/pharmacies/ShoppingCartResponse.dart index 96b751ae..332f63b6 100644 --- a/lib/core/model/pharmacies/ShoppingCartResponse.dart +++ b/lib/core/model/pharmacies/ShoppingCartResponse.dart @@ -1,7 +1,7 @@ import 'package:diplomaticquarterapp/core/model/pharmacies/ShoppingCart.dart'; import 'package:flutter/material.dart'; -class ShoppingCartResponse with ChangeNotifier { +class ShoppingCartResponse { int itemCount; int quantityCount; double subtotal; @@ -11,17 +11,15 @@ class ShoppingCartResponse with ChangeNotifier { List shoppingCarts; ShoppingCartResponse( - {this.itemCount, - this.quantityCount, - this.subtotal, - this.subtotalWithVat, - this.subtotalVatAmount, - this.subtotalVatRate, + {this.itemCount =0, + this.quantityCount =0, + this.subtotal=0.0, + this.subtotalWithVat = 0.0, + this.subtotalVatAmount = 0.0, + this.subtotalVatRate = 0.0 , this.shoppingCarts}); - void updateShoppingCard() { - notifyListeners(); - } + ShoppingCartResponse.fromJson(Map json) { itemCount = json['item_count']; diff --git a/lib/core/model/pharmacies/payment-checkout-data.dart b/lib/core/model/pharmacies/payment-checkout-data.dart index dd9e0e54..5d91c829 100644 --- a/lib/core/model/pharmacies/payment-checkout-data.dart +++ b/lib/core/model/pharmacies/payment-checkout-data.dart @@ -5,7 +5,7 @@ import 'package:flutter/material.dart'; import 'ShippingOption.dart'; -class PaymentCheckoutData with ChangeNotifier{ +class PaymentCheckoutData { Addresses address; PaymentOption paymentOption; LacumAccountInformation lacumInformation; @@ -15,7 +15,5 @@ class PaymentCheckoutData with ChangeNotifier{ PaymentCheckoutData({this.address, this.paymentOption, this.lacumInformation, this.cartDataVisible = false, this.shippingOption, this.usedLakumPoints = 0}); - void updateData() { - notifyListeners(); - } + } diff --git a/lib/core/service/client/base_app_client.dart b/lib/core/service/client/base_app_client.dart index deee0644..e779d88a 100644 --- a/lib/core/service/client/base_app_client.dart +++ b/lib/core/service/client/base_app_client.dart @@ -29,7 +29,8 @@ AppSharedPreferences sharedPref = new AppSharedPreferences(); /// onFailure: (String error, int statusCode) {}, /// body: Map(); /// -AuthenticatedUserObject authenticatedUserObject = locator(); +AuthenticatedUserObject authenticatedUserObject = + locator(); VitalSignService _vitalSignService = locator(); class BaseAppClient { @@ -113,19 +114,6 @@ class BaseAppClient { } } - // For RC Services - // if(body.containsKey("patientId")) - // body.remove("PatientID"); - // - // if(body.containsKey("patientOutSa")) - // body.remove("PatientOutSA"); - // - // body['PatientID'] = 1018977; - // body['TokenID'] = "@dm!n"; - // body['IdentificationNo'] = "1009199553"; - // body['MobileNo'] = "966545156035"; - // body['PatientMobileNumber'] = "966545156035"; - print("URL : $url"); final jsonBody = json.encode(body); print(jsonBody); @@ -445,13 +433,14 @@ class BaseAppClient { 'Mobilenumber': user != null ? Utils.getPhoneNumberWithoutZero(user['MobileNumber'].toString()) : "", 'Statictoken': 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9', 'Username': user != null ? user['PatientID'].toString() : "", + 'Host': "mdlaboratories.com", }); final int statusCode = response.statusCode; print("statusCode :$statusCode"); if (statusCode < 200 || statusCode >= 400 || json == null) { if (statusCode == 401) { - AppToast.showErrorToast(message: TranslationBase.of(AppGlobal.context).pharmacyRelogin); + onFailure(TranslationBase.of(AppGlobal.context).pharmacyRelogin, statusCode); Navigator.of(AppGlobal.context).pushNamed(HOME); } else { onFailure('Error While Fetching data', statusCode); @@ -706,7 +695,8 @@ class BaseAppClient { final int statusCode = response.statusCode; print("statusCode :$statusCode"); if (statusCode < 200 || statusCode >= 400 || json == null) { - onFailure('Error While Fetching data', statusCode); + var parsed = json.decode(utf8.decode(response.bodyBytes)); + onFailure(parsed['error']['ErrorEndUserMsg'] ??'Error While Fetching data', statusCode); } else { // var parsed = json.decode(response.body.toString()); var parsed = json.decode(utf8.decode(response.bodyBytes)); diff --git a/lib/core/service/parmacyModule/order-preview-service.dart b/lib/core/service/parmacyModule/order-preview-service.dart index 0ada84e7..0364d64f 100644 --- a/lib/core/service/parmacyModule/order-preview-service.dart +++ b/lib/core/service/parmacyModule/order-preview-service.dart @@ -62,6 +62,8 @@ class OrderPreviewService extends BaseService { Future getShoppingCart() async { var customerId = await sharedPref.getString(PHARMACY_CUSTOMER_ID); + if (customerId == null) return null; + Map queryParams = {'shopping_cart_type': '1'}; dynamic localRes; hasError = false; @@ -94,8 +96,8 @@ class OrderPreviewService extends BaseService { Map body = Map(); body["shopping_cart_item"] = choppingCartObject; - await baseAppClient.pharmacyPost("$GET_SHOPPING_CART$productId", isExternal: false, - onSuccess: (response, statusCode) async { + await baseAppClient.pharmacyPost("$GET_SHOPPING_CART$productId", + isExternal: false, onSuccess: (response, statusCode) async { localRes = response; }, onFailure: (String error, int statusCode) { hasError = true; @@ -112,8 +114,8 @@ class OrderPreviewService extends BaseService { Map body = Map(); - await baseAppClient.pharmacyPost("$DELETE_SHOPPING_CART$productId", isExternal: false, - onSuccess: (response, statusCode) async { + await baseAppClient.pharmacyPost("$DELETE_SHOPPING_CART$productId", + isExternal: false, onSuccess: (response, statusCode) async { localRes = response; }, onFailure: (String error, int statusCode) { hasError = true; @@ -225,8 +227,9 @@ class OrderPreviewService extends BaseService { body['order'] = orderBody; try { - await baseAppClient.pharmacyPost(ORDER_SHOPPING_CART, isExternal: false, isAllowAny: true, - onSuccess: (response, statusCode) async { + await baseAppClient.pharmacyPost(ORDER_SHOPPING_CART, + isExternal: false, + isAllowAny: true, onSuccess: (response, statusCode) async { orderList.clear(); response['orders'].forEach((item) { orderList.add(OrderDetailModel.fromJson(item)); @@ -263,24 +266,22 @@ class OrderPreviewService extends BaseService { } } - Future getDriverLocation(dynamic driverId) async{ + Future getDriverLocation(dynamic driverId) async { Map jsonBody = Map(); jsonBody['DriverID'] = driverId; LatLng coordinates; await baseAppClient.post(DRIVER_LOCATION, onSuccess: (response, statusCode) async { - if(statusCode == 200){ - dynamic locationObject = response['PatientER_GetDriverLocationList'][0]; - double lat = locationObject['Latitude']; - double lon = locationObject['Longitude']; - if(lat != null && lon != null){ - coordinates = LatLng(lat,lon); - } - } - }, onFailure: (String error, int statusCode) { - - }, body: jsonBody); + if (statusCode == 200) { + dynamic locationObject = response['PatientER_GetDriverLocationList'][0]; + double lat = locationObject['Latitude']; + double lon = locationObject['Longitude']; + if (lat != null && lon != null) { + coordinates = LatLng(lat, lon); + } + } + }, onFailure: (String error, int statusCode) {}, body: jsonBody); return coordinates; } diff --git a/lib/core/service/parmacyModule/parmacy_module_service.dart b/lib/core/service/parmacyModule/parmacy_module_service.dart index 58ce50f5..6969deac 100644 --- a/lib/core/service/parmacyModule/parmacy_module_service.dart +++ b/lib/core/service/parmacyModule/parmacy_module_service.dart @@ -108,17 +108,18 @@ class PharmacyModuleService extends BaseService { } Future getTopManufacturerList() async { - hasError = false; + if (manufacturerList.isNotEmpty) return; Map queryParams = {'page': '1', 'limit': '8'}; try { await baseAppClient.getPharmacy(GET_PHARMACY_TOP_MANUFACTURER, onSuccess: (dynamic response, int statusCode) { manufacturerList.clear(); response['manufacturer'].forEach((item) { Manufacturer manufacturer = Manufacturer.fromJson(item); - if (manufacturer.image != null) { - manufacturerList.add(Manufacturer.fromJson(item)); - } + // if (manufacturer.image != null) { + manufacturerList.add(Manufacturer.fromJson(item)); + // } }); + hasError = false; }, onFailure: (String error, int statusCode) { hasError = true; super.error = error; @@ -129,6 +130,8 @@ class PharmacyModuleService extends BaseService { } Future getBestSellerProducts() async { + if (bestSellerProducts.isNotEmpty) return; + Map queryParams = { 'fields': 'id,discount_ids,name,namen,localized_names,display_order,short_description,full_description,full_descriptionn,sku,order_minimum_quantity,order_maximum_quantity,price,old_price,images,is_rx,rx_message,rx_messagen,discount_name,discount_namen,approved_rating_sum,approved_total_reviews,allow_back_in_stock_subscriptions,stock_quantity,stock_availability,stock_availabilityn,discount_percentage,reviews', @@ -139,6 +142,7 @@ class PharmacyModuleService extends BaseService { response['products'].forEach((item) { bestSellerProducts.add(PharmacyProduct.fromJson(item)); }); + hasError = false; }, onFailure: (String error, int statusCode) { hasError = true; super.error = error; @@ -150,16 +154,21 @@ class PharmacyModuleService extends BaseService { Future getLastVisitedProducts() async { String lastVisited = ""; - if (await this.sharedPref.getString(PHARMACY_LAST_VISITED_PRODUCTS) != null) { - lastVisited = await this.sharedPref.getString(PHARMACY_LAST_VISITED_PRODUCTS); + if (await this.sharedPref.getString(PHARMACY_LAST_VISITED_PRODUCTS) != + null) { + lastVisited = + await this.sharedPref.getString(PHARMACY_LAST_VISITED_PRODUCTS); + // lastVisited = "2458,4561"; try { await baseAppClient.getPharmacy("$GET_PHARMACY_PRODUCTs_BY_IDS$lastVisited", onSuccess: (dynamic response, int statusCode) { lastVisitedProducts.clear(); response['products'].forEach((item) { lastVisitedProducts.add(PharmacyProduct.fromJson(item)); }); + hasError = false; }, onFailure: (String error, int statusCode) { - hasError = true; + hasError = + true; // sharedPref.setString(PHARMACY_LAST_VISITED_PRODUCTS, ""); super.error = error; }); } catch (error) { diff --git a/lib/core/service/parmacyModule/prescription_service.dart b/lib/core/service/parmacyModule/prescription_service.dart index 37a50c33..9011496c 100644 --- a/lib/core/service/parmacyModule/prescription_service.dart +++ b/lib/core/service/parmacyModule/prescription_service.dart @@ -1,42 +1,23 @@ import 'package:diplomaticquarterapp/config/config.dart'; -import 'package:diplomaticquarterapp/core/model/pharmacies/Prescriptions.dart'; +import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; import 'package:diplomaticquarterapp/core/service/base_service.dart'; import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart'; +import 'package:diplomaticquarterapp/core/model/pharmacies/Prescriptions.dart'; class PrescriptionService extends BaseService { final AppSharedPreferences sharedPref = AppSharedPreferences(); bool isFinished = true; bool hasError = false; String errorMsg = ''; - String url = ""; List _prescriptionsList = List(); List get prescriptionsList => _prescriptionsList; -// Future getPrescription() async { -// hasError = false; -// url = PRESCRIPTION; -// print("Print PRESCRIPTION url" + url); -// await baseAppClient.get(url, -// onSuccess: (dynamic response, int statusCode) { -// _prescriptionsList.clear(); -// response['PatientPrescriptionList'].forEach((item) { -// _prescriptionsList.add(Prescriptions.fromJson(item)); -// }); -// print(_prescriptionsList.length); -// print(response); -// }, onFailure: (String error, int statusCode) { -// hasError = true; -// super.error = error; -// }); -// } Future getPrescription() async { - url = PRESCRIPTION; - print("Print PRESCRIPTION url" + url); hasError = false; Map body = Map(); body['isDentalAllowedBackend'] = false; - await baseAppClient.post(url, + await baseAppClient.post(PRESCRIPTION, onSuccess: (dynamic response, int statusCode) { _prescriptionsList.clear(); response['PatientPrescriptionList'].forEach((prescriptions) { diff --git a/lib/core/service/pharmacy_categorise_service.dart b/lib/core/service/pharmacy_categorise_service.dart index a68a900f..023d0859 100644 --- a/lib/core/service/pharmacy_categorise_service.dart +++ b/lib/core/service/pharmacy_categorise_service.dart @@ -90,8 +90,9 @@ class PharmacyCategoriseService extends BaseService { Future searchProducts({String productName}) async { hasError = false; _searchList.clear(); - String endPoint = - productName != null ? GET_SEARCH_PRODUCTS + "$productName" + '&language_id=1' : GET_SEARCH_PRODUCTS + ""; + String endPoint = productName != null + ? GET_SEARCH_PRODUCTS + "$productName" + '&language_id=1' + : GET_SEARCH_PRODUCTS + ""; await baseAppClient.getPharmacy( endPoint, onSuccess: (dynamic response, int statusCode) { @@ -126,7 +127,8 @@ class PharmacyCategoriseService extends BaseService { Future getCategoriseParent({String id}) async { hasError = false; _parentCategoriseList.clear(); - String endPoint = id != null ? GET_CATEGORISE_PARENT + "$id" : GET_CATEGORISE_PARENT + ""; + String endPoint = + id != null ? GET_CATEGORISE_PARENT + "$id" : GET_CATEGORISE_PARENT + ""; await baseAppClient.getPharmacy( endPoint, onSuccess: (dynamic response, int statusCode) { @@ -144,7 +146,9 @@ class PharmacyCategoriseService extends BaseService { Future getParentProducts({String id}) async { hasError = false; _parentProductsList.clear(); - String endPoint = id != null ? GET_PARENT_PRODUCTS + "$id" + '&page=1&limit=50' : GET_PARENT_PRODUCTS + ""; + String endPoint = id != null + ? GET_PARENT_PRODUCTS + "$id" + '&page=1&limit=50' + : GET_PARENT_PRODUCTS + ""; await baseAppClient.getPharmacy( endPoint, onSuccess: (dynamic response, int statusCode) { @@ -163,7 +167,8 @@ class PharmacyCategoriseService extends BaseService { hasError = false; _subCategoriseList.clear(); - String endPoint = id != null ? GET_SUB_CATEGORISE + "$id" : GET_SUB_CATEGORISE + ""; + String endPoint = + id != null ? GET_SUB_CATEGORISE + "$id" : GET_SUB_CATEGORISE + ""; await baseAppClient.getPharmacy( endPoint, onSuccess: (dynamic response, int statusCode) { @@ -181,7 +186,9 @@ class PharmacyCategoriseService extends BaseService { Future getSubProducts({String id}) async { hasError = false; _subProductsList.clear(); - String endPoint = id != null ? GET_SUB_PRODUCTS + "$id" + '&page=1&limit=50' : GET_SUB_PRODUCTS + ""; + String endPoint = id != null + ? GET_SUB_PRODUCTS + "$id" + '&page=1&limit=50' + : GET_SUB_PRODUCTS + ""; await baseAppClient.getPharmacy( endPoint, onSuccess: (dynamic response, int statusCode) { @@ -199,7 +206,8 @@ class PharmacyCategoriseService extends BaseService { Future getFinalProducts({String id}) async { hasError = false; _finalProducts.clear(); - String endPoint = id != null ? GET_FINAL_PRODUCTS + "$id" : GET_FINAL_PRODUCTS + ""; + String endPoint = + id != null ? GET_FINAL_PRODUCTS + "$id" : GET_FINAL_PRODUCTS + ""; await baseAppClient.getPharmacy( endPoint, onSuccess: (dynamic response, int statusCode) { @@ -236,11 +244,15 @@ class PharmacyCategoriseService extends BaseService { Future getLastVisitedProducts() async { String lastVisited = ""; - if (await this.sharedPref.getString(PHARMACY_LAST_VISITED_PRODUCTS) != null) { - lastVisited = await this.sharedPref.getString(PHARMACY_LAST_VISITED_PRODUCTS); + _finalProducts.clear(); + if (await this.sharedPref.getString(PHARMACY_LAST_VISITED_PRODUCTS) != + null) { + lastVisited = + await this.sharedPref.getString(PHARMACY_LAST_VISITED_PRODUCTS); try { - await baseAppClient.getPharmacy("$GET_PHARMACY_PRODUCTs_BY_IDS$lastVisited", - onSuccess: (dynamic response, int statusCode) { + await baseAppClient + .getPharmacy("$GET_PHARMACY_PRODUCTs_BY_IDS$lastVisited", + onSuccess: (dynamic response, int statusCode) { _finalProducts.clear(); response['products'].forEach((item) { _finalProducts.add(PharmacyProduct.fromJson(item)); @@ -261,7 +273,8 @@ class PharmacyCategoriseService extends BaseService { 'id,discount_ids,name,namen,localized_names,display_order,short_description,full_description,full_descriptionn,sku,order_minimum_quantity,order_maximum_quantity,price,old_price,images,is_rx,rx_message,rx_messagen,discount_name,discount_namen,approved_rating_sum,approved_total_reviews,allow_back_in_stock_subscriptions,stock_quantity,stock_availability,stock_availabilityn,discount_percentage,reviews', }; try { - await baseAppClient.getPharmacy(GET_PHARMACY_BEST_SELLER_PRODUCT, onSuccess: (dynamic response, int statusCode) { + await baseAppClient.getPharmacy(GET_PHARMACY_BEST_SELLER_PRODUCT, + onSuccess: (dynamic response, int statusCode) { _finalProducts.clear(); response['products'].forEach((item) { _finalProducts.add(PharmacyProduct.fromJson(item)); @@ -275,7 +288,8 @@ class PharmacyCategoriseService extends BaseService { } } - Future getFilteredProducts({String categoryId, String brandId, String min, String max}) async { + Future getFilteredProducts( + {String categoryId, String brandId, String min, String max}) async { hasError = false; String endPoint; @@ -299,7 +313,8 @@ class PharmacyCategoriseService extends BaseService { ); } - Future getFilteredSubProducts({String categoryId, String brandId, String min, String max}) async { + Future getFilteredSubProducts( + {String categoryId, String brandId, String min, String max}) async { hasError = false; String endPoint; @@ -324,12 +339,14 @@ class PharmacyCategoriseService extends BaseService { } Future getMostViewedProducts() async { + hasError = false; Map queryParams = { 'fields': - 'id,discount_ids,name,reviews,namen,localized_names,display_order,short_description,full_description,full_descriptionn,sku,order_minimum_quantity,order_maximum_quantity,price,old_price,images,is_rx,rx_message,rx_messagen,discount_name,discount_namen,approved_rating_sum,approved_total_reviews,allow_back_in_stock_subscriptions,stock_quantity,stock_availability,stock_availabilityn,discount_percentage', + 'mostview?fields=id,discount_ids,name,reviews,namen,localized_names,display_order,short_description,full_description,full_descriptionn,sku,order_minimum_quantity,order_maximum_quantity,price,old_price,images,is_rx,rx_message,rx_messagen,discount_name,discount_namen,approved_rating_sum,approved_total_reviews,allow_back_in_stock_subscriptions,stock_quantity,stock_availability,stock_availabilityn,discount_percentage', }; try { - await baseAppClient.getPharmacy(GET_MOST_VIEWED_PRODUCTS, onSuccess: (dynamic response, int statusCode) { + await baseAppClient.getPharmacy(GET_MOST_VIEWED_PRODUCTS, + onSuccess: (dynamic response, int statusCode) { _finalProducts.clear(); response['products'].forEach((item) { _finalProducts.add(PharmacyProduct.fromJson(item)); @@ -341,16 +358,20 @@ class PharmacyCategoriseService extends BaseService { super.error = error; }, queryParams: queryParams); } catch (error) { - throw error; + hasError = true; + super.error = error.toString(); + // throw error; } } Future getNewProducts() async { Map queryParams = { - 'fields': 'Id,name,namen,localized_names,price,images,sku,stock_availability,published', + 'fields': + 'Id,name,namen,localized_names,price,images,sku,stock_availability,published', }; try { - await baseAppClient.getPharmacy(GET_NEW_PRODUCTS, onSuccess: (dynamic response, int statusCode) { + await baseAppClient.getPharmacy(GET_NEW_PRODUCTS, + onSuccess: (dynamic response, int statusCode) { _finalProducts.clear(); response['products'].forEach((item) { _finalProducts.add(PharmacyProduct.fromJson(item)); diff --git a/lib/core/viewModels/base_view_model.dart b/lib/core/viewModels/base_view_model.dart index aab267e9..338fd339 100644 --- a/lib/core/viewModels/base_view_model.dart +++ b/lib/core/viewModels/base_view_model.dart @@ -15,6 +15,7 @@ class BaseViewModel extends ChangeNotifier { ViewState get state => _state; String error = ""; + String languageID = "en"; AuthenticatedUser user; AppSharedPreferences sharedPref = AppSharedPreferences(); @@ -51,6 +52,10 @@ class BaseViewModel extends ChangeNotifier { notifyListeners(); } + Future getSavedLanguage() async { + languageID = await sharedPref.getString(APP_LANGUAGE); + } + @override void dispose() { removeListener(() {}); diff --git a/lib/core/viewModels/pharmacyModule/BestSellerViewModel.dart b/lib/core/viewModels/pharmacyModule/BestSellerViewModel.dart new file mode 100644 index 00000000..b03ee5b9 --- /dev/null +++ b/lib/core/viewModels/pharmacyModule/BestSellerViewModel.dart @@ -0,0 +1,26 @@ +import 'package:diplomaticquarterapp/core/enum/viewstate.dart'; +import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart'; +import 'package:diplomaticquarterapp/core/service/parmacyModule/parmacy_module_service.dart'; +import 'package:diplomaticquarterapp/core/viewModels/base_view_model.dart'; + +import '../../../locator.dart'; + +class BestSellerViewModel extends BaseViewModel { + + PharmacyModuleService _pharmacyService = locator(); + + List get bestSellerProduct => + _pharmacyService.bestSellerProducts; + + getBestSellerProducts() async { + setState(ViewState.BusyLocal); + await _pharmacyService.getBestSellerProducts(); + // if (_pharmacyService.hasError) { + // error = _pharmacyService.error; + // setState(ViewState.Error); + // } else { + setState(ViewState.Idle); + // } + } + +} \ No newline at end of file diff --git a/lib/core/viewModels/pharmacyModule/BrandViewModel.dart b/lib/core/viewModels/pharmacyModule/BrandViewModel.dart new file mode 100644 index 00000000..c1cdc8bc --- /dev/null +++ b/lib/core/viewModels/pharmacyModule/BrandViewModel.dart @@ -0,0 +1,29 @@ +import 'package:diplomaticquarterapp/core/enum/viewstate.dart'; +import 'package:diplomaticquarterapp/core/model/pharmacies/Manufacturer.dart'; +import 'package:diplomaticquarterapp/core/service/parmacyModule/parmacy_module_service.dart'; +import 'package:diplomaticquarterapp/core/viewModels/base_view_model.dart'; + +import '../../../locator.dart'; + +class BrandViewModel extends BaseViewModel { + PharmacyModuleService _pharmacyService = locator(); + + List get manufacturerList => _pharmacyService.manufacturerList; + + Future getTopManufacturerList() async { + setState(ViewState.BusyLocal); + await _pharmacyService.getTopManufacturerList(); + // if (_pharmacyService.hasError) { + // error = _pharmacyService.error; + // setState(ViewState.Error); + // } else { + setState(ViewState.Idle); + // } + } + + @override + void dispose() { + + super.dispose(); + } +} diff --git a/lib/core/viewModels/pharmacyModule/LastVisitedViewModel.dart b/lib/core/viewModels/pharmacyModule/LastVisitedViewModel.dart new file mode 100644 index 00000000..568e56f8 --- /dev/null +++ b/lib/core/viewModels/pharmacyModule/LastVisitedViewModel.dart @@ -0,0 +1,25 @@ +import 'package:diplomaticquarterapp/core/enum/viewstate.dart'; +import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart'; +import 'package:diplomaticquarterapp/core/service/parmacyModule/parmacy_module_service.dart'; +import 'package:diplomaticquarterapp/core/viewModels/base_view_model.dart'; + +import '../../../locator.dart'; + +class LastVisitedViewModel extends BaseViewModel { + + PharmacyModuleService _pharmacyService = locator(); + + List get lastVisitedProducts => + _pharmacyService.lastVisitedProducts; + + getLastVisitedProducts() async { + setState(ViewState.BusyLocal); + await _pharmacyService.getLastVisitedProducts(); + // if (_pharmacyService.hasError) { + // error = _pharmacyService.error; + // setState(ViewState.Error); + // } else { + setState(ViewState.Idle); + // } + } +} \ No newline at end of file diff --git a/lib/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart b/lib/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart index ae218369..f2f87712 100644 --- a/lib/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart +++ b/lib/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart @@ -8,6 +8,8 @@ import 'package:diplomaticquarterapp/core/model/pharmacies/order_detail.dart'; import 'package:diplomaticquarterapp/core/model/pharmacies/payment-checkout-data.dart'; import 'package:diplomaticquarterapp/core/service/parmacyModule/order-preview-service.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/pharmacy_module_view_model.dart'; +import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; +import 'package:diplomaticquarterapp/uitl/navigation_service.dart'; import '../../../locator.dart'; import '../base_view_model.dart'; @@ -16,12 +18,14 @@ class OrderPreviewViewModel extends BaseViewModel { OrderPreviewService _orderService = locator(); List get addresses => _orderService.addresses; + LacumAccountInformation get lacumInformation => _orderService.lacumInformation; + List get orderListModel => _orderService.orderList; PharmacyModuleViewModel pharmacyModuleViewModel = - locator(); + locator(); ShoppingCartResponse cartResponse = ShoppingCartResponse(); PaymentCheckoutData paymentCheckoutData = PaymentCheckoutData(); @@ -38,23 +42,32 @@ class OrderPreviewViewModel extends BaseViewModel { } } + void update() { + notifyListeners(); + } + Future getShoppingCart() async { - setState(ViewState.Busy); + // setState(ViewState.Busy); + // GifLoaderDialogUtils.showMyDialog( + // locator().navigatorKey.currentContext); await _orderService.getShoppingCart().then((res) { - _handleGetShoppingCartResponse(res); + if (res != null) _handleGetShoppingCartResponse(res); }); if (_orderService.hasError) { error = _orderService.error; - setState(ViewState.Error); + // setState(ViewState.Error); } else { if (paymentCheckoutData != null) { paymentCheckoutData.cartDataVisible = true; } + // GifLoaderDialogUtils.hideDialog( + // locator().navigatorKey.currentContext); setState(ViewState.Idle); } } - Future changeProductQuantity(ShoppingCart product) async { + Future changeProductQuantity( + ShoppingCart product) async { setState(ViewState.Busy); var resp = await _orderService.changeProductQuantity(product.id, product); var object = _handleGetShoppingCartResponse(resp); @@ -110,9 +123,9 @@ class OrderPreviewViewModel extends BaseViewModel { res["shopping_carts"].forEach((item) { ShoppingCart shoppingCart = ShoppingCart.fromJson(item); cartResponse.shoppingCarts.add(shoppingCart); - totalAdditionalShippingCharge += shoppingCart.product.additionalShippingCharge; + totalAdditionalShippingCharge += + shoppingCart.product.additionalShippingCharge; }); - cartResponse.updateShoppingCard(); return cartResponse; } @@ -163,7 +176,8 @@ class OrderPreviewViewModel extends BaseViewModel { setState(ViewState.Busy); await _orderService.getLacumGroupInformation(); paymentCheckoutData.lacumInformation = _orderService.lacumGroupInformation; - paymentCheckoutData.usedLakumPoints = paymentCheckoutData.lacumInformation.lakumInquiryInformationObjVersion.pointsBalanceAmount; + paymentCheckoutData.usedLakumPoints = paymentCheckoutData + .lacumInformation.lakumInquiryInformationObjVersion.pointsBalanceAmount; if (_orderService.hasError) { error = _orderService.error; setState(ViewState.Error); @@ -174,9 +188,11 @@ class OrderPreviewViewModel extends BaseViewModel { getShippingOption() async { setState(ViewState.Busy); - await _orderService.getShippingOption(paymentCheckoutData.address).then((res) { - paymentCheckoutData.shippingOption = ShippingOption.fromJson(res); - paymentCheckoutData.updateData(); + await _orderService + .getShippingOption(paymentCheckoutData.address) + .then((res) { + paymentCheckoutData.shippingOption = ShippingOption.fromJson(res); + setState(ViewState.Idle); }); if (_orderService.hasError) { error = _orderService.error; @@ -190,7 +206,8 @@ class OrderPreviewViewModel extends BaseViewModel { setState(ViewState.Busy); await pharmacyModuleViewModel.generatePharmacyToken(); - await _orderService.makeOrder(paymentCheckoutData, cartResponse.shoppingCarts); + await _orderService.makeOrder( + paymentCheckoutData, cartResponse.shoppingCarts); if (_orderService.hasError) { error = _orderService.error; setState(ViewState.ErrorLocal); @@ -198,6 +215,17 @@ class OrderPreviewViewModel extends BaseViewModel { setState(ViewState.Idle); } } + + bool isCartItemsOutOfStock() { + bool outOfStock = false; + for (int i = 0; i < cartResponse.shoppingCarts.length; i++) { + if (cartResponse.shoppingCarts[i].product.stockQuantity == 0) { + outOfStock = true; + break; + } + } + return outOfStock; + } } enum PaymentOption { meda, sadad, visa, mastercard, installments } diff --git a/lib/core/viewModels/pharmacyModule/PrescriptionViewModel.dart b/lib/core/viewModels/pharmacyModule/PrescriptionViewModel.dart new file mode 100644 index 00000000..86a320e6 --- /dev/null +++ b/lib/core/viewModels/pharmacyModule/PrescriptionViewModel.dart @@ -0,0 +1,28 @@ +import 'package:diplomaticquarterapp/core/enum/viewstate.dart'; +import 'package:diplomaticquarterapp/core/model/pharmacies/Prescriptions.dart'; +import 'package:diplomaticquarterapp/core/service/parmacyModule/prescription_service.dart'; +import 'package:diplomaticquarterapp/core/viewModels/base_view_model.dart'; + +import '../../../locator.dart'; + +class PrescriptionViewModel extends BaseViewModel { + + PrescriptionService _prescriptionService = locator(); + + List get prescriptionsList => + _prescriptionService.prescriptionsList; + + getPrescription() async { + await getSavedLanguage(); + if(prescriptionsList.isNotEmpty){ + setState(ViewState.Busy); + await _prescriptionService.getPrescription(); + if (_prescriptionService.hasError) { + error = _prescriptionService.error; + setState(ViewState.Error); + } else { + setState(ViewState.Idle); + } + } + } +} \ No newline at end of file diff --git a/lib/core/viewModels/pharmacyModule/pharmacy_module_view_model.dart b/lib/core/viewModels/pharmacyModule/pharmacy_module_view_model.dart index 5062a010..facccf1e 100644 --- a/lib/core/viewModels/pharmacyModule/pharmacy_module_view_model.dart +++ b/lib/core/viewModels/pharmacyModule/pharmacy_module_view_model.dart @@ -5,47 +5,42 @@ import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyImageObject.d import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart'; import 'package:diplomaticquarterapp/core/model/pharmacies/Prescriptions.dart'; import 'package:diplomaticquarterapp/core/model/pharmacies/recommendedProduct_model.dart'; +import 'package:diplomaticquarterapp/core/service/medical/prescriptions_service.dart'; + //import 'package:diplomaticquarterapp/core/model/prescriptions/perscription_pharmacy.dart'; import 'package:diplomaticquarterapp/core/service/parmacyModule/parmacy_module_service.dart'; import 'package:diplomaticquarterapp/core/service/parmacyModule/prescription_service.dart'; import 'package:diplomaticquarterapp/core/viewModels/base_view_model.dart'; import 'package:diplomaticquarterapp/services/pharmacy_services/recommendedProduct_service.dart'; +import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; +import 'package:diplomaticquarterapp/uitl/navigation_service.dart'; import '../../../locator.dart'; class PharmacyModuleViewModel extends BaseViewModel { PharmacyModuleService _pharmacyService = locator(); - PrescriptionService _prescriptionService = locator(); - - - RecommendedProductService _recommendedProductService = locator(); + RecommendedProductService _recommendedProductService = + locator(); List get bannerList => _pharmacyService.bannerItems; - List get manufacturerList => _pharmacyService.manufacturerList; - - List get bestSellerProduct => - _pharmacyService.bestSellerProducts; - - List get lastVisitedProducts => - _pharmacyService.lastVisitedProducts; - - List get recommendedProductList => + List get recommendedProductList => _recommendedProductService.recommendedList; -// List> get recommendedProductList => -// _recommendedProductService.recommendedList; - - List get prescriptionsList => - _prescriptionService.prescriptionsList; - - bool hasError = false; -// List get pharmacyPrescriptionsList => PharmacyProduct.pharmacyPrescriptionsList ; + Future generatePharmacyToken() async { + setState(ViewState.Busy); + await _pharmacyService.generatePharmacyToken(); + if (_pharmacyService.hasError) { + error = _pharmacyService.error; + setState(ViewState.ErrorLocal); + } else { + setState(ViewState.Idle); + } + } - Future getPharmacyHomeData() async { - if(authenticatedUserObject.isLogin) - await generatePharmacyToken(); + Future verifyCustomer() async { + // if (authenticatedUserObject.isLogin) await generatePharmacyToken(); var data = await sharedPref.getObject(USER_PROFILE); var customerId = await sharedPref.getString(PHARMACY_CUSTOMER_ID); @@ -53,20 +48,7 @@ class PharmacyModuleViewModel extends BaseViewModel { setState(ViewState.Busy); if (authenticatedUserObject.isLogin && data != null && customerId == null) { await _pharmacyService.makeVerifyCustomer(data); - if (_pharmacyService.hasError) { - error = _pharmacyService.error; - setState(ViewState.Error); - } else { - await getBannerList(); - } - } else { - await getBannerList(); } - } - - Future createUser() async { - setState(ViewState.Busy); - await _pharmacyService.createUser(); if (_pharmacyService.hasError) { error = _pharmacyService.error; setState(ViewState.ErrorLocal); @@ -75,9 +57,9 @@ class PharmacyModuleViewModel extends BaseViewModel { } } - Future generatePharmacyToken() async { + Future createUser() async { setState(ViewState.Busy); - await _pharmacyService.generatePharmacyToken(); + await _pharmacyService.createUser(); if (_pharmacyService.hasError) { error = _pharmacyService.error; setState(ViewState.ErrorLocal); @@ -87,13 +69,17 @@ class PharmacyModuleViewModel extends BaseViewModel { } Future getBannerList() async { - setState(ViewState.Busy); - await _pharmacyService.getBannerListList(); - if (_pharmacyService.hasError) { - error = _pharmacyService.error; - setState(ViewState.Error); - } else { - _getTopManufacturerList(); + if (bannerList.isEmpty) { + GifLoaderDialogUtils.showMyDialog( + locator().navigatorKey.currentContext); + await _pharmacyService.getBannerListList(); + GifLoaderDialogUtils.hideDialog( + locator().navigatorKey.currentContext); + if (_pharmacyService.hasError) { + error = _pharmacyService.error; + setState(ViewState.Error); + } else + setState(ViewState.Idle); } } @@ -107,41 +93,8 @@ class PharmacyModuleViewModel extends BaseViewModel { return images; } - _getTopManufacturerList() async { - await _pharmacyService.getTopManufacturerList(); - if (_pharmacyService.hasError) { - error = _pharmacyService.error; - setState(ViewState.Error); - } else { - setState(ViewState.Idle); - _getBestSellerProducts(); - } - } - - _getBestSellerProducts() async { - await _pharmacyService.getBestSellerProducts(); - if (_pharmacyService.hasError) { - error = _pharmacyService.error; - setState(ViewState.Error); - } else { - _getLastVisitedProducts(); - } - } - - _getLastVisitedProducts() async { - await _pharmacyService.getLastVisitedProducts(); - if (_pharmacyService.hasError) { - error = _pharmacyService.error; - setState(ViewState.Error); - } else { - setState(ViewState.Idle); - } - } - - //////////////////////////////////////////RecommendedProducts - getRecommendedProducts(productId) async { - hasError = false; - setState(ViewState.Busy); + getRecommendedProducts(productId) async { + setState(ViewState.Busy); await _recommendedProductService.getRecommendedProducts(productId); if (_recommendedProductService.hasError) { error = _recommendedProductService.error; @@ -164,31 +117,4 @@ class PharmacyModuleViewModel extends BaseViewModel { return false; } } - - getPrescription() async { - setState(ViewState.Busy); - await _prescriptionService.getPrescription(); - if (_prescriptionService.hasError) { - error = _prescriptionService.error; - setState(ViewState.Error); - } else { - setState(ViewState.Idle); - } - } - - - ///////////////////////or -// getPrescriptions() async { -// setState(ViewState.Busy); -// await _prescriptionsService.getPrescriptions(); -// if (_prescriptionsService.hasError) { -// error = _prescriptionsService.error; -// setState(ViewState.Error); -// } else { -// _filterList(); -// await _getPrescriptionsOrders(); -// setState(ViewState.Idle); -// } -// } - } diff --git a/lib/core/viewModels/pharmacyModule/product_detail_view_model.dart b/lib/core/viewModels/pharmacyModule/product_detail_view_model.dart index 01695b10..828aa8e4 100644 --- a/lib/core/viewModels/pharmacyModule/product_detail_view_model.dart +++ b/lib/core/viewModels/pharmacyModule/product_detail_view_model.dart @@ -4,6 +4,9 @@ import 'package:diplomaticquarterapp/models/pharmacy/Wishlist.dart'; import 'package:diplomaticquarterapp/models/pharmacy/locationModel.dart'; import 'package:diplomaticquarterapp/models/pharmacy/productDetailModel.dart'; import 'package:diplomaticquarterapp/models/pharmacy/specification.dart'; +import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; +import 'package:diplomaticquarterapp/uitl/navigation_service.dart'; + import 'package:diplomaticquarterapp/services/pharmacy_services/product_detail_service.dart'; import '../../../locator.dart'; @@ -35,7 +38,7 @@ class ProductDetailViewModel extends BaseViewModel{ Future getProductLocationData() async { hasError = false; - setState(ViewState.Busy); + setState(ViewState.BusyLocal); await _productDetailService.getProductAvailabiltyDetail(); if (_productDetailService.hasError) { error = _productDetailService.error; @@ -46,7 +49,7 @@ class ProductDetailViewModel extends BaseViewModel{ Future notifyMe(customerId, itemID) async { hasError = false; - setState(ViewState.Busy); + setState(ViewState.BusyLocal); await _productDetailService.notifyMe(customerId, itemID); if (_productDetailService.hasError) { error = _productDetailService.error; @@ -57,7 +60,7 @@ class ProductDetailViewModel extends BaseViewModel{ Future addToCartData(quantity, itemID) async { hasError = false; - setState(ViewState.Busy); + setState(ViewState.BusyLocal); await _productDetailService.addToCart(quantity, itemID); if (_productDetailService.hasError) { error = _productDetailService.error; @@ -68,8 +71,13 @@ class ProductDetailViewModel extends BaseViewModel{ Future addToWishlistData(itemID) async { hasError = false; - setState(ViewState.Busy); + setState(ViewState.BusyLocal); + GifLoaderDialogUtils.showMyDialog( + locator().navigatorKey.currentContext); await _productDetailService.addToWishlist(itemID); + GifLoaderDialogUtils.hideDialog( + locator().navigatorKey.currentContext); + if (_productDetailService.hasError) { error = _productDetailService.error; setState(ViewState.ErrorLocal); @@ -89,10 +97,15 @@ class ProductDetailViewModel extends BaseViewModel{ } - Future deletWishlistData(itemID) async { + Future deleteWishlistData(itemID) async { hasError = false; - setState(ViewState.Busy); - await _productDetailService.delteItemFromWishlist(itemID); + setState(ViewState.BusyLocal); + GifLoaderDialogUtils.showMyDialog( + locator().navigatorKey.currentContext); + await _productDetailService.deleteItemFromWishlist(itemID); + GifLoaderDialogUtils.hideDialog( + locator().navigatorKey.currentContext); + if (_productDetailService.hasError) { error = _productDetailService.error; setState(ViewState.ErrorLocal); @@ -112,4 +125,10 @@ class ProductDetailViewModel extends BaseViewModel{ setState(ViewState.Idle); } + clearReview(){ + + productDetailService.clear(); + + } + } \ No newline at end of file diff --git a/lib/core/viewModels/pharmacyModule/wishlist_view_model.dart b/lib/core/viewModels/pharmacyModule/wishlist_view_model.dart index 788b7f3c..9a619357 100644 --- a/lib/core/viewModels/pharmacyModule/wishlist_view_model.dart +++ b/lib/core/viewModels/pharmacyModule/wishlist_view_model.dart @@ -12,20 +12,9 @@ class WishListViewModel extends BaseViewModel{ bool hasError = false; -// Future getWishlistData() async { -// setState(ViewState.Busy); -// await _wishlistService.getWishlist(); -// if (_wishlistService.hasError) { -// error = _wishlistService.error; -// setState(ViewState.Error); -// } else { -// setState(ViewState.Idle); -// } -// } - - Future getWishlistData() async { + Future getWishlistData({isLocalLoader = false}) async { hasError = false; - setState(ViewState.Busy); + setState(isLocalLoader ? ViewState.BusyLocal:ViewState.Busy); await _wishlistService.getWishlist(); if (_wishlistService.hasError) { error = _wishlistService.error; diff --git a/lib/core/viewModels/product_categories_view_model.dart b/lib/core/viewModels/product_categories_view_model.dart new file mode 100644 index 00000000..fa31accd --- /dev/null +++ b/lib/core/viewModels/product_categories_view_model.dart @@ -0,0 +1,27 @@ +import 'package:diplomaticquarterapp/core/enum/viewstate.dart'; +import 'package:diplomaticquarterapp/core/model/pharmacy/pharmacy_categorise.dart'; +import 'package:diplomaticquarterapp/core/service/pharmacy_categorise_service.dart'; +import 'package:diplomaticquarterapp/core/viewModels/base_view_model.dart'; +import 'package:diplomaticquarterapp/locator.dart'; + +class ProductCategoriesViewModel extends BaseViewModel { + bool hasError = false; + + PharmacyCategoriseService _pharmacyCategoriseService = + locator(); + + List get categorise => + _pharmacyCategoriseService.categoriseList; + + Future getCategorise() async { + hasError = false; + // _insuranceCardService.clearInsuranceCard(); + setState(ViewState.Busy); + await _pharmacyCategoriseService.getCategorise(); + if (_pharmacyCategoriseService.hasError) { + error = _pharmacyCategoriseService.error; + setState(ViewState.ErrorLocal); + } else + setState(ViewState.Idle); + } +} diff --git a/lib/d_q_icons_icons.dart b/lib/d_q_icons_icons.dart index 5d1ff3c6..7376b1ca 100644 --- a/lib/d_q_icons_icons.dart +++ b/lib/d_q_icons_icons.dart @@ -11,7 +11,7 @@ /// fonts: /// - asset: fonts/DQIcons.ttf /// -/// +/// /// import 'package:flutter/widgets.dart'; @@ -19,25 +19,80 @@ class DQIcons { DQIcons._(); static const _kFontFam = 'DQIcons'; - static const _kFontPkg = null; + static const String _kFontPkg = null; - static const IconData blood_pressure = IconData(0xe800, fontFamily: _kFontFam, fontPackage: _kFontPkg); - static const IconData blood = IconData(0xe801, fontFamily: _kFontFam, fontPackage: _kFontPkg); - static const IconData bmi = IconData(0xe802, fontFamily: _kFontFam, fontPackage: _kFontPkg); - static const IconData heart = IconData(0xe803, fontFamily: _kFontFam, fontPackage: _kFontPkg); - static const IconData height = IconData(0xe804, fontFamily: _kFontFam, fontPackage: _kFontPkg); - static const IconData outline = IconData(0xe805, fontFamily: _kFontFam, fontPackage: _kFontPkg); - static const IconData thermometer = IconData(0xe806, fontFamily: _kFontFam, fontPackage: _kFontPkg); - static const IconData weight_scale = IconData(0xe807, fontFamily: _kFontFam, fontPackage: _kFontPkg); - static const IconData parking_icon = IconData(0xe808, fontFamily: _kFontFam, fontPackage: _kFontPkg); - static const IconData blood_type_icon = IconData(0xe809, fontFamily: _kFontFam, fontPackage: _kFontPkg); - static const IconData height_icon = IconData(0xe80a, fontFamily: _kFontFam, fontPackage: _kFontPkg); - static const IconData online_payment_icon = IconData(0xe80b, fontFamily: _kFontFam, fontPackage: _kFontPkg); - static const IconData search_medicine_icon = IconData(0xe80c, fontFamily: _kFontFam, fontPackage: _kFontPkg); - static const IconData vital_sign_icon = IconData(0xe80d, fontFamily: _kFontFam, fontPackage: _kFontPkg); - static const IconData weight_icon = IconData(0xe80e, fontFamily: _kFontFam, fontPackage: _kFontPkg); - static const IconData my_medical_file = IconData(0xe80f, fontFamily: _kFontFam, fontPackage: _kFontPkg); - static const IconData family = IconData(0xe810, fontFamily: _kFontFam, fontPackage: _kFontPkg); - static const IconData calendar__2_ = IconData(0xe811, fontFamily: _kFontFam, fontPackage: _kFontPkg); - static const IconData roboticon = IconData(0xe812, fontFamily: _kFontFam, fontPackage: _kFontPkg); + static const IconData blood_pressure = + IconData(0xe800, fontFamily: _kFontFam, fontPackage: _kFontPkg); + static const IconData blood = + IconData(0xe801, fontFamily: _kFontFam, fontPackage: _kFontPkg); + static const IconData bmi = + IconData(0xe802, fontFamily: _kFontFam, fontPackage: _kFontPkg); + static const IconData heart = + IconData(0xe803, fontFamily: _kFontFam, fontPackage: _kFontPkg); + static const IconData height = + IconData(0xe804, fontFamily: _kFontFam, fontPackage: _kFontPkg); + static const IconData outline = + IconData(0xe805, fontFamily: _kFontFam, fontPackage: _kFontPkg); + static const IconData thermometer = + IconData(0xe806, fontFamily: _kFontFam, fontPackage: _kFontPkg); + static const IconData weight_scale = + IconData(0xe807, fontFamily: _kFontFam, fontPackage: _kFontPkg); + static const IconData parking_icon = + IconData(0xe808, fontFamily: _kFontFam, fontPackage: _kFontPkg); + static const IconData blood_type_icon = + IconData(0xe809, fontFamily: _kFontFam, fontPackage: _kFontPkg); + static const IconData height_icon = + IconData(0xe80a, fontFamily: _kFontFam, fontPackage: _kFontPkg); + static const IconData online_payment_icon = + IconData(0xe80b, fontFamily: _kFontFam, fontPackage: _kFontPkg); + static const IconData search_medicine_icon = + IconData(0xe80c, fontFamily: _kFontFam, fontPackage: _kFontPkg); + static const IconData vital_sign_icon = + IconData(0xe80d, fontFamily: _kFontFam, fontPackage: _kFontPkg); + static const IconData weight_icon = + IconData(0xe80e, fontFamily: _kFontFam, fontPackage: _kFontPkg); + static const IconData my_medical_file = + IconData(0xe80f, fontFamily: _kFontFam, fontPackage: _kFontPkg); + static const IconData family = + IconData(0xe810, fontFamily: _kFontFam, fontPackage: _kFontPkg); + static const IconData calendar__2_ = + IconData(0xe811, fontFamily: _kFontFam, fontPackage: _kFontPkg); + static const IconData roboticon = + IconData(0xe812, fontFamily: _kFontFam, fontPackage: _kFontPkg); + static const IconData cart_menu_icon = + IconData(0xe814, fontFamily: _kFontFam, fontPackage: _kFontPkg); + static const IconData categories_menu_icon = + IconData(0xe815, fontFamily: _kFontFam, fontPackage: _kFontPkg); + static const IconData hmg_logo_icon = + IconData(0xe816, fontFamily: _kFontFam, fontPackage: _kFontPkg); + static const IconData user_menu_icon = + IconData(0xe817, fontFamily: _kFontFam, fontPackage: _kFontPkg); + static const IconData cart_menu_icon_1 = + IconData(0xe818, fontFamily: _kFontFam, fontPackage: _kFontPkg); + static const IconData categories_menu_icon_1 = + IconData(0xe819, fontFamily: _kFontFam, fontPackage: _kFontPkg); + static const IconData hmg_logo_icon_1 = + IconData(0xe81a, fontFamily: _kFontFam, fontPackage: _kFontPkg); + static const IconData emo_cry = + IconData(0xe8b5, fontFamily: _kFontFam, fontPackage: _kFontPkg); + static const IconData emo_shoot = + IconData(0xe8b6, fontFamily: _kFontFam, fontPackage: _kFontPkg); + static const IconData emo_squint = + IconData(0xe8b7, fontFamily: _kFontFam, fontPackage: _kFontPkg); + static const IconData emo_laugh = + IconData(0xe8b8, fontFamily: _kFontFam, fontPackage: _kFontPkg); + static const IconData chrome = + IconData(0xe8c0, fontFamily: _kFontFam, fontPackage: _kFontPkg); + static const IconData opera = + IconData(0xe8c1, fontFamily: _kFontFam, fontPackage: _kFontPkg); + static const IconData ie = + IconData(0xe8c2, fontFamily: _kFontFam, fontPackage: _kFontPkg); + static const IconData crown = + IconData(0xe8c3, fontFamily: _kFontFam, fontPackage: _kFontPkg); + static const IconData crown_plus = + IconData(0xe8c4, fontFamily: _kFontFam, fontPackage: _kFontPkg); + static const IconData crown_minus = + IconData(0xe8c5, fontFamily: _kFontFam, fontPackage: _kFontPkg); + static const IconData marquee = + IconData(0xe8c6, fontFamily: _kFontFam, fontPackage: _kFontPkg); } diff --git a/lib/locator.dart b/lib/locator.dart index ee9ea18d..30d1f788 100644 --- a/lib/locator.dart +++ b/lib/locator.dart @@ -8,6 +8,7 @@ import 'package:diplomaticquarterapp/core/viewModels/ancillary_orders_view_model import 'package:diplomaticquarterapp/core/viewModels/child_vaccines/user_information_view_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/dashboard_view_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/PharmacyAddressesViewModel.dart'; +import 'package:diplomaticquarterapp/core/viewModels/product_categories_view_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/order_model_view_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/weather/weather_view_model.dart'; import 'package:diplomaticquarterapp/services/pharmacy_services/cancelOrder_service.dart'; @@ -121,6 +122,10 @@ import 'core/viewModels/offers_Categorise_view_model.dart'; import 'core/viewModels/packages_offers/PackagesOffersViewModel.dart'; import 'core/viewModels/pharmacies_view_model.dart'; import 'core/viewModels/pharmacyModule/OrderPreviewViewModel.dart'; +import 'core/viewModels/pharmacyModule/BestSellerViewModel.dart'; +import 'core/viewModels/pharmacyModule/BrandViewModel.dart'; +import 'core/viewModels/pharmacyModule/LastVisitedViewModel.dart'; +import 'core/viewModels/pharmacyModule/PrescriptionViewModel.dart'; import 'core/viewModels/pharmacyModule/brand_view_model.dart'; import 'core/viewModels/pharmacyModule/lacum-registration-viewModel.dart'; import 'core/viewModels/pharmacyModule/lacum-trasnfer-viewModel.dart'; @@ -284,24 +289,29 @@ void setupLocator() { locator.registerFactory(() => ProductDetailViewModel()); locator.registerFactory(() => WeatherViewModel()); - locator.registerFactory(() => OrderPreviewViewModel()); + // locator.registerFactory(() => OrderPreviewViewModel()); locator.registerFactory(() => LacumViewModel()); locator.registerFactory(() => LacumTranferViewModel()); locator.registerFactory(() => LacumRegistrationViewModel()); locator.registerFactory(() => EdOnlineViewModel()); + locator.registerFactory(() => ProductCategoriesViewModel()); //pharmacy locator.registerFactory(() => PharmacyCategoriseViewModel()); locator.registerFactory(() => OffersCategoriseViewModel()); locator.registerFactory(() => BariatricsViewModel()); + locator.registerFactory(() => PrescriptionViewModel()); + locator.registerFactory(() => BrandViewModel()); + locator.registerFactory(() => BestSellerViewModel()); + locator.registerFactory(() => LastVisitedViewModel()); + // Offer And Packages //---------------------- locator.registerLazySingleton(() => OffersAndPackagesServices()); // offerPackagesServices Service locator.registerFactory(() => OfferCategoriesViewModel()); // Categories View Model locator.registerFactory(() => PackagesViewModel()); // Products View Model - //pharmacy // locator.registerFactory(() => PharmacyCategoriseViewModel()); // locator.registerFactory(() => OffersCategoriseViewModel()); diff --git a/lib/main.dart b/lib/main.dart index 49d37919..bcad3f5f 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -8,6 +8,7 @@ import 'package:diplomaticquarterapp/theme/theme_notifier.dart'; import 'package:diplomaticquarterapp/theme/theme_value.dart'; import 'package:diplomaticquarterapp/uitl/LocalNotification.dart'; import 'package:diplomaticquarterapp/uitl/PlatformBridge.dart'; +import 'package:diplomaticquarterapp/uitl/navigation_service.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:firebase_core/firebase_core.dart'; import 'package:flutter/material.dart'; @@ -16,6 +17,7 @@ import 'package:flutter_localizations/flutter_localizations.dart'; import 'package:provider/provider.dart'; import 'config/size_config.dart'; +import 'core/viewModels/pharmacyModule/OrderPreviewViewModel.dart'; import 'core/viewModels/project_view_model.dart'; import 'locator.dart'; import 'pages/pharmacies/compare-list.dart'; @@ -81,11 +83,17 @@ class _MyApp extends State { value: RobotProvider().intStream(), initialData: RobotProvider().setValue({}), ), - ChangeNotifierProvider(create: (context) => CompareList()), + ChangeNotifierProvider( + create: (context) => CompareList()), + ChangeNotifierProvider( + create: (context) => OrderPreviewViewModel()), ], child: Consumer( builder: (context, projectProvider, child) => MaterialApp( - navigatorObservers: [GAnalytics.shared.navObserver()], + navigatorObservers: [ + GAnalytics.shared.navObserver() + ], + navigatorKey: locator().navigatorKey, showSemanticsDebugger: false, title: 'Diplomatic Quarter App', locale: projectProvider.appLocal, diff --git a/lib/pages/ErService/AmbulanceRequestIndexPages/PickupLocation.dart b/lib/pages/ErService/AmbulanceRequestIndexPages/PickupLocation.dart index cecf8c5d..d05fae2f 100644 --- a/lib/pages/ErService/AmbulanceRequestIndexPages/PickupLocation.dart +++ b/lib/pages/ErService/AmbulanceRequestIndexPages/PickupLocation.dart @@ -51,6 +51,9 @@ class _PickupLocationState extends State { void initState() { super.initState(); _getCurrentLocation(); + setState(() { + + }); } _getCurrentLocation() async { @@ -61,6 +64,7 @@ class _PickupLocationState extends State { _longitude = 0; _latitude = 0; }); + } @override @@ -89,8 +93,8 @@ class _PickupLocationState extends State { context, FadePage( page: PickupLocationFromMap( - latitude: _latitude, - longitude: _longitude, + latitude: _latitude??0, + longitude: _longitude??0, onPick: (value) { setState(() { _result = value; diff --git a/lib/pages/final_products_page.dart b/lib/pages/final_products_page.dart index baf38221..7e8385f0 100644 --- a/lib/pages/final_products_page.dart +++ b/lib/pages/final_products_page.dart @@ -1,21 +1,29 @@ import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; +import 'package:diplomaticquarterapp/core/service/AuthenticatedUserObject.dart'; +import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/product_detail_view_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacy_categorise_view_model.dart'; -import 'package:diplomaticquarterapp/pages/pharmacies/product_detail.dart'; +import 'package:diplomaticquarterapp/locator.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/screens/cart-order-page.dart'; +import 'package:diplomaticquarterapp/uitl/app_toast.dart'; +import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/product-detail.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:diplomaticquarterapp/widgets/others/StarRating.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_pharmacy_widget.dart'; import 'package:diplomaticquarterapp/widgets/others/network_base_view.dart'; import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; import 'package:flutter/material.dart'; - +import 'package:flutter/src/widgets/image.dart' as flutterImage; import 'base/base_view.dart'; - dynamic languageID; + class FinalProductsPage extends StatefulWidget { final String id; final int productType; // 1 : default, 2 : manufacturer , 3 : recently viewed + AuthenticatedUserObject authenticatedUserObject = + locator(); FinalProductsPage({this.id, this.productType = 1}); @@ -27,6 +35,7 @@ class _FinalProductsPageState extends State { String id; _FinalProductsPageState({this.id}); String categoriseName = "Personal Care"; + String appBarTitle = ""; bool styleOne = true; bool styleTwo = false; Icon styleIcon = Icon( @@ -43,29 +52,35 @@ class _FinalProductsPageState extends State { getLanguageID(); super.initState(); } + @override Widget build(BuildContext context) { return BaseView( onModelReady: (model) { if (widget.productType == 1) { model.getFinalProducts(i: id); + appBarTitle = TranslationBase.of(context).products; } else if (widget.productType == 2) { model.getManufacturerProducts(id); } else if (widget.productType == 3) { model.getLastVisitedProducts(); - } else if (widget.productType == 4){ + appBarTitle = TranslationBase.of(context).recentlyViewed; + } else if (widget.productType == 4) { model.getMostViewedProducts(); - } else if (widget.productType == 5){ + appBarTitle = TranslationBase.of(context).mostViewed; + } else if (widget.productType == 5) { model.getNewProducts(); + appBarTitle = TranslationBase.of(context).newProducts; } else { model.getBestSellerProducts(); + appBarTitle = TranslationBase.of(context).bestSellers; } }, allowAny: true, builder: (BuildContext context, PharmacyCategoriseViewModel model, Widget child) => PharmacyAppScaffold( - appBarTitle: TranslationBase.of(context).products, + appBarTitle: appBarTitle, isBottomBar: false, isShowAppBar: true, backgroundColor: Colors.white, @@ -84,7 +99,8 @@ class _FinalProductsPageState extends State { Padding( padding: EdgeInsets.all(8.0), child: Texts( - TranslationBase.of(context).products, + "$appBarTitle " + + TranslationBase.of(context).products, fontWeight: FontWeight.w600, ), ), @@ -136,468 +152,541 @@ class _FinalProductsPageState extends State { ), styleOne == true ? Expanded( - child:model.finalProducts.length > 0 - ? Container( - height: MediaQuery.of(context).size.height * 3.90, - child: GridView.builder( - gridDelegate: - SliverGridDelegateWithFixedCrossAxisCount( - crossAxisCount: 2, - crossAxisSpacing: 0.5, - mainAxisSpacing: 2.0, - childAspectRatio: 1.0, - ), - itemCount: model.finalProducts.length, - itemBuilder: (BuildContext context, int index) { - return NetworkBaseView( - baseViewModel: model, - child: InkWell( - child: Card( - color: model.finalProducts[index] - .discountName != - null - ? Color(0xffFFFF00) - : Colors.white, - elevation: 0, - shape: Border( - right: BorderSide( - color: Colors.grey.shade300, - width: 1, - ), - left: BorderSide( - color: Colors.grey.shade300, - width: 1, - ), - bottom: BorderSide( - color: Colors.grey.shade300, - width: 1, - ), - top: BorderSide( - color: Colors.grey.shade300, - width: 1, - ), - ), - margin: EdgeInsets.symmetric( - horizontal: 8, - vertical: 4, - ), - child: Container( - decoration: BoxDecoration( - borderRadius: BorderRadius.only( - topLeft: Radius.circular(110.0), - ), - color: Colors.white, - ), - padding: EdgeInsets.symmetric( - horizontal: 0), - width: MediaQuery.of(context) - .size - .width / - 3, - child: Column( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Stack( - children: [ - Container( - margin: - EdgeInsets.fromLTRB( - 0, 16, 0, 0), - alignment: - Alignment.center, - child: Image.network( - model - .finalProducts[ - index] - .images - .isNotEmpty - ? model - .finalProducts[ - index] - .images[0] - .thumb - : 'https://upload.wikimedia.org/wikipedia/commons/thumb/6/6c/No_image_3x4.svg/1200px-No_image_3x4.svg.png', - fit: BoxFit.cover, - height: 80, - ), - ), - Container( - width: model.finalProducts[index].rxMessage != null - ? MediaQuery.of( - context) - .size - .width / - 2.8 - : 0, - padding: - EdgeInsets.all(4), - decoration: BoxDecoration( - color: - Color(0xffb23838), - borderRadius: - BorderRadius.only( - topLeft: Radius - .circular( - 6)), - ), - child:model.finalProducts[index].rxMessage != null - ? Texts( languageID == 'ar' ? model.finalProducts[index].rxMessagen - : model.finalProducts[index].rxMessage, - color: Colors.white, - regular: true, - fontSize: 10, - fontWeight: - FontWeight.w600, - ): Texts(""), - ), - ], + child: model.finalProducts.length > 0 + ? Container( + height: MediaQuery.of(context).size.height * + 3.90, + child: GridView.builder( + gridDelegate: + SliverGridDelegateWithFixedCrossAxisCount( + crossAxisCount: 2, + crossAxisSpacing: 0.5, + mainAxisSpacing: 2.0, + childAspectRatio: 1.0, + ), + itemCount: model.finalProducts.length, + itemBuilder: + (BuildContext context, int index) { + return NetworkBaseView( + baseViewModel: model, + child: InkWell( + child: Card( + color: + model.finalProducts[index] + .discountName != + null + ? Color(0xffFFFF00) + : Colors.white, + elevation: 0, + shape: Border( + right: BorderSide( + color: Colors.grey.shade300, + width: 1, + ), + left: BorderSide( + color: Colors.grey.shade300, + width: 1, + ), + bottom: BorderSide( + color: Colors.grey.shade300, + width: 1, + ), + top: BorderSide( + color: Colors.grey.shade300, + width: 1, + ), ), - Container( - margin: EdgeInsets.symmetric( - horizontal: 6, - vertical: 0, + margin: EdgeInsets.symmetric( + horizontal: 8, + vertical: 4, + ), + child: Container( + decoration: BoxDecoration( + borderRadius: + BorderRadius.only( + topLeft: Radius.circular( + 110.0), + ), + color: Colors.white, ), + padding: EdgeInsets.symmetric( + horizontal: 0), + width: MediaQuery.of(context) + .size + .width / + 3, child: Column( crossAxisAlignment: CrossAxisAlignment .start, children: [ - if (model - .finalProducts[ - index] - .discountName != - null) - Container( - width: - double.infinity, - height: 13.0, - decoration: - BoxDecoration( - color: Color( - 0xff5AB145), + Stack( + children: [ + Container( + margin: EdgeInsets + .fromLTRB(0, 16, + 0, 0), + alignment: Alignment + .center, + child: + Image.network( + model + .finalProducts[ + index] + .images + .isNotEmpty + ? model + .finalProducts[ + index] + .images[0] + .thumb + : 'https://upload.wikimedia.org/wikipedia/commons/thumb/6/6c/No_image_3x4.svg/1200px-No_image_3x4.svg.png', + fit: BoxFit.cover, + height: 80, + ), ), - child: Center( - child: Texts( + Container( + width: model + .finalProducts[ + index] + .rxMessage != + null + ? MediaQuery.of( + context) + .size + .width / + 2.8 + : 0, + padding: + EdgeInsets.all( + 4), + decoration: + BoxDecoration( + color: Color( + 0xffb23838), + borderRadius: BorderRadius.only( + topLeft: Radius + .circular( + 6)), + ), + child: model + .finalProducts[ + index] + .rxMessage != + null + ? Texts( + languageID == + 'ar' + ? model + .finalProducts[ + index] + .rxMessagen + : model + .finalProducts[index] + .rxMessage, + color: Colors + .white, + regular: + true, + fontSize: + 10, + fontWeight: + FontWeight + .w600, + ) + : Texts(""), + ), + ], + ), + Container( + margin: EdgeInsets + .symmetric( + horizontal: 6, + vertical: 0, + ), + child: Column( + crossAxisAlignment: + CrossAxisAlignment + .start, + children: [ + if (model + .finalProducts[ + index] + .discountName != + null) + Container( + width: double + .infinity, + height: 13.0, + decoration: + BoxDecoration( + color: Color( + 0xff5AB145), + ), + child: Center( + child: Texts( + model + .finalProducts[ + index] + .discountName, + regular: + true, + color: Colors + .white, + fontSize: + 10.4, + ), + ), + ), + Texts( model .finalProducts[ index] - .discountName, + .name, regular: true, - color: - Colors.white, - fontSize: 10.4, + fontSize: 12, + fontWeight: + FontWeight + .w400, ), - ), - ), - Texts( - model - .finalProducts[ - index] - .name, - regular: true, - fontSize: 12, - fontWeight: - FontWeight.w400, - ), - Padding( - padding: - const EdgeInsets - .only( - top: 4, - bottom: 4), - child: Texts( - "SAR ${model.finalProducts[index].price}", - bold: true, - fontSize: 14, + Padding( + padding: + const EdgeInsets + .only( + top: 4, + bottom: + 4), + child: Texts( + "SAR ${model.finalProducts[index].price}", + bold: true, + fontSize: 14, + ), + ), + Row( + children: [ + StarRating( + totalAverage: model.finalProducts[index].approvedRatingSum > + 0 + ? (model.finalProducts[index].approvedRatingSum.toDouble() / model.finalProducts[index].approvedRatingSum.toDouble()) + .toDouble() + : 0, + forceStars: + true), + Texts( + "(${model.finalProducts[index].approvedTotalReviews})", + regular: true, + fontSize: 10, + fontWeight: + FontWeight + .w400, + ) + ], + ), + ], ), ), - Row( - children: [ - StarRating( - totalAverage: model - .finalProducts[ - index] - .approvedRatingSum > - 0 - ? (model.finalProducts[index].approvedRatingSum - .toDouble() / - model - .finalProducts[index] - .approvedRatingSum - .toDouble()) - .toDouble() - : 0, - forceStars: true), - Texts( - "(${model.finalProducts[index].approvedTotalReviews})", - regular: true, - fontSize: 10, - fontWeight: - FontWeight.w400, - ) - ], - ), ], ), ), - ], - ), + ), + onTap: () => { + Navigator.push( + context, + FadePage( + page: ProductDetailPage( + model.finalProducts[ + index]), + )), + }, + )); + }, + ), + ) + : Container( + child: Column( + mainAxisAlignment: + MainAxisAlignment.center, + crossAxisAlignment: + CrossAxisAlignment.center, + children: [ + Align( + alignment: Alignment.center, + child: Image.asset( + 'assets/images/pharmacy/empty_box.png', + width: 100, + height: 100, ), ), - onTap: () => { - Navigator.push( - context, - FadePage( - page: ProductDetailPage( - model.finalProducts[index]), - )), - }, - )); - }, - ), - ) - : Container( - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Align( - alignment: Alignment.center, - child: Image.asset( - 'assets/images/pharmacy/empty_box.png', - width: 100, - height: 100, - ), - ), - Text( - TranslationBase.of(context).noResult, - style: TextStyle( - fontSize: 20.0, + Text( + TranslationBase.of(context).noResult, + style: TextStyle( + fontSize: 20.0, // fontWeight: FontWeight.bold, + ), + ), + ], ), ), - ], - ), - ),) + ) : Expanded( child: model.finalProducts.length > 0 - ? Container( - height: MediaQuery.of(context).size.height * 5.0, - child: ListView.builder( - itemCount: model.finalProducts.length, - itemBuilder: - (BuildContext context, int index) { - return InkWell( - child: Card( - child: Row( - children: [ - Stack( - children: [ - Column( - children: [ - Container( - decoration: - BoxDecoration(), - child: Padding( - padding: - EdgeInsets.only( - left: 9.0, - top: 8.0, - right: 10.0, - ), + ? Container( + height: MediaQuery.of(context).size.height * + 5.0, + child: ListView.builder( + itemCount: model.finalProducts.length, + itemBuilder: + (BuildContext context, int index) { + return InkWell( + child: Card( + child: Row( + children: [ + Stack( + children: [ + Column( + children: [ + Container( + decoration: + BoxDecoration(), + child: Padding( + padding: + EdgeInsets + .only( + left: 9.0, + top: 8.0, + right: 10.0, + ), + ), + ), + Container( + margin: EdgeInsets + .fromLTRB( + 0, 0, 0, 0), + alignment: Alignment + .center, + child: + Image.network( + model + .finalProducts[ + index] + .images + .isNotEmpty + ? model + .finalProducts[ + index] + .images[0] + .thumb + : 'https://upload.wikimedia.org/wikipedia/commons/thumb/6/6c/No_image_3x4.svg/1200px-No_image_3x4.svg.png', + fit: BoxFit + .contain, + height: 80, + ), + ), + ], ), - ), - Container( - margin: - EdgeInsets.fromLTRB( - 0, 0, 0, 0), - alignment: - Alignment.center, - child: Image.network( - model - .finalProducts[ - index] - .images - .isNotEmpty - ? model - .finalProducts[ - index] - .images[0] - .thumb - : 'https://upload.wikimedia.org/wikipedia/commons/thumb/6/6c/No_image_3x4.svg/1200px-No_image_3x4.svg.png', - fit: BoxFit.contain, - height: 80, + Column( + children: [ + Container( + width: model + .finalProducts[ + index] + .rxMessage != + null + ? MediaQuery.of( + context) + .size + .width / + 5.3 + : 0, + padding: + EdgeInsets.all( + 4), + decoration: + BoxDecoration( + color: Color( + 0xffb23838), + borderRadius: BorderRadius.only( + topLeft: Radius + .circular( + 6)), + ), + child: Texts( + model + .finalProducts[ + index] + .rxMessage != + null + ? model + .finalProducts[ + index] + .rxMessage + : "", + color: + Colors.white, + regular: true, + fontSize: 10, + fontWeight: + FontWeight + .w600, + ), + ), + ], ), + ], + ), + Container( + height: 100.0, + margin: + EdgeInsets.symmetric( + horizontal: 6, + vertical: 0, ), - ], - ), - Column( - children: [ - Container( - width: model - .finalProducts[ - index] - .rxMessage != - null - ? MediaQuery.of( + child: Column( + mainAxisAlignment: + MainAxisAlignment + .spaceAround, + crossAxisAlignment: + CrossAxisAlignment + .start, + children: [ + SizedBox( + height: 4.0, + ), + Container( + width: MediaQuery.of( context) .size - .width / - 3.5 - : 0, - padding: - EdgeInsets.all(4), - decoration: BoxDecoration( - color: - Color(0xffb23838), - borderRadius: - BorderRadius.only( - topLeft: Radius - .circular( - 6)), - ), - child: Texts( - model - .finalProducts[ - index] - .rxMessage != - null - ? model + .width * + 0.65, + child: Texts( + model .finalProducts[ index] - .rxMessage - : "", - color: Colors.white, - regular: true, - fontSize: 10, - fontWeight: - FontWeight.w600, - ), - ), - ], - ), - ], - ), - Container( - height: 100.0, - margin: EdgeInsets.symmetric( - horizontal: 6, - vertical: 0, - ), - child: Column( - mainAxisAlignment: - MainAxisAlignment - .spaceAround, - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - SizedBox( - height: 4.0, - ), - Container( - width: - MediaQuery.of(context) - .size - .width * - 0.65, - child: Texts( - model.finalProducts[index] - .name, - regular: true, - fontSize: 13.2, - fontWeight: - FontWeight.w500, - maxLines: 5, + .name, + regular: true, + fontSize: 13.2, + fontWeight: + FontWeight.w500, + maxLines: 5, + ), + ), + SizedBox( + height: 8.0, + ), + Padding( + padding: + const EdgeInsets + .only( + top: 4, + bottom: 4), + child: Texts( + "SAR ${model.finalProducts[index].price}", + bold: true, + fontSize: 14, + ), + ), + Row( + children: [ + StarRating( + totalAverage: model + .finalProducts[ + index] + .approvedRatingSum > + 0 + ? (model.finalProducts[index].approvedRatingSum.toDouble() / + model.finalProducts[index].approvedRatingSum + .toDouble()) + .toDouble() + : 0, + forceStars: + true), + Texts( + "(${model.finalProducts[index].approvedTotalReviews})", + regular: true, + fontSize: 10, + fontWeight: + FontWeight + .w400, + ) + ], + ), + ], ), ), - SizedBox( - height: 8.0, - ), - Padding( - padding: - const EdgeInsets.only( - top: 4, bottom: 4), - child: Texts( - "SAR ${model.finalProducts[index].price}", - bold: true, - fontSize: 14, + + widget.authenticatedUserObject.isLogin + ? Container( + child: IconButton( + icon: Icon(Icons.shopping_cart, + size: 18, + color: Colors.blue,), + onPressed: () async { + GifLoaderDialogUtils.showMyDialog(context); + if(model.finalProducts[index].rxMessage == null){ + await addToCartFunction(1, model.finalProducts[index].id); +// GifLoaderDialogUtils.hideDialog(context); + Navigator.push( + context, + FadePage(page: CartOrderPage()), + ); + } + else{ + AppToast.showErrorToast(message: TranslationBase.of(context).needPrescription); + } + GifLoaderDialogUtils.hideDialog(context); + } + ), - ), - Row( - children: [ - StarRating( - totalAverage: model - .finalProducts[ - index] - .approvedRatingSum > - 0 - ? (model - .finalProducts[ - index] - .approvedRatingSum - .toDouble() / - model - .finalProducts[ - index] - .approvedRatingSum - .toDouble()) - .toDouble() - : 0, - forceStars: true), - Texts( - "(${model.finalProducts[index].approvedTotalReviews})", - regular: true, - fontSize: 10, - fontWeight: - FontWeight.w400, - ) - ], - ), + ):Container(), ], ), ), - ], + onTap: () => { + Navigator.push( + context, + FadePage( + page: ProductDetailPage( + model.finalProducts[ + index]), + )), + }, + ); + }), + ) + : Container( + child: Column( + mainAxisAlignment: + MainAxisAlignment.center, + crossAxisAlignment: + CrossAxisAlignment.center, + children: [ + Align( + alignment: Alignment.center, + child: Image.asset( + 'assets/images/pharmacy/empty_box.png', + width: 100, + height: 100, + ), ), - ), - onTap: () => { - Navigator.push( - context, - FadePage( - page: ProductDetailPage( - model.finalProducts[index]), - )), - }, - ); - }), - ) - : Container( - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Align( - alignment: Alignment.center, - child: Image.asset( - 'assets/images/pharmacy/empty_box.png', - width: 100, - height: 100, - ), - ), - Text( - TranslationBase.of(context).noResult, - style: TextStyle( - fontSize: 20.0, + Text( + TranslationBase.of(context).noResult, + style: TextStyle( + fontSize: 20.0, // fontWeight: FontWeight.bold, + ), + ), + ], ), ), - ], - ), - ), ) ], ), ), )); } + + addToCartFunction(quantity, itemID) async { + ProductDetailViewModel x = new ProductDetailViewModel(); + await x.addToCartData(quantity, itemID); + } } diff --git a/lib/pages/landing/home_page.dart b/lib/pages/landing/home_page.dart new file mode 100644 index 00000000..4e19386b --- /dev/null +++ b/lib/pages/landing/home_page.dart @@ -0,0 +1,888 @@ +import 'package:diplomaticquarterapp/config/size_config.dart'; +import 'package:diplomaticquarterapp/core/viewModels/dashboard_view_model.dart'; +import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/pharmacy_module_view_model.dart'; +import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; +import 'package:diplomaticquarterapp/locator.dart'; +import 'package:diplomaticquarterapp/pages/AlHabibMedicalService/ComprehensiveMedicalCheckup/cmc_page.dart'; +import 'package:diplomaticquarterapp/pages/AlHabibMedicalService/E-Referral/e_referral_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'; +import 'package:diplomaticquarterapp/pages/ErService/ErOptions.dart'; +import 'package:diplomaticquarterapp/pages/base/base_view.dart'; +import 'package:diplomaticquarterapp/pages/livecare/livecare_home.dart'; +import 'package:diplomaticquarterapp/pages/packages_offers/OfferAndPackagesPage.dart'; +import 'package:diplomaticquarterapp/pages/paymentService/payment_service.dart'; +import 'package:diplomaticquarterapp/uitl/date_uitl.dart'; +import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; +import 'package:diplomaticquarterapp/uitl/translations_delegate_base.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:flutter_svg/flutter_svg.dart'; +import 'package:hexcolor/hexcolor.dart'; +import 'package:provider/provider.dart'; + +import 'landing_page_pharmcy.dart'; + +class HomePage extends StatefulWidget { + final Function goToMyProfile; + + HomePage({Key key, this.goToMyProfile}); + + @override + _HomePageState createState() => _HomePageState(); +} + +class _HomePageState extends State { + PharmacyModuleViewModel pharmacyModuleViewModel = locator(); + + @override + Widget build(BuildContext context) { + ProjectViewModel projectViewModel = Provider.of(context); + return BaseView( + onModelReady: (model) => () async {}, + builder: (_, model, wi) => AppScaffold( + isShowDecPage: false, + isHelp: true, + body: Container( + width: double.infinity, + child: SingleChildScrollView( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Stack( + children: [ + Column( + children: [ + Container( + width: double.infinity, + height: 210, + decoration: BoxDecoration( + image: DecorationImage(image: ExactAssetImage('assets/images/dashboard_top_bg.png'), fit: BoxFit.cover), + ), + child: Stack( + children: [ + Positioned( + top: 15, + left: 5, + right: 5, + child: Container( + width: MediaQuery.of(context).size.width * 0.8, + child: Row( + children: [ + Expanded( + child: Container( + height: 125, + padding: EdgeInsets.all(5), + margin: EdgeInsets.all(5), + decoration: BoxDecoration( + image: DecorationImage( + image: AssetImage("assets/images/new-design/covid_bg_transparent.png"), + fit: BoxFit.fill, + ), + color: Colors.white.withOpacity(0.3), + borderRadius: BorderRadius.all(Radius.circular(5))), + child: (model.user != null && model.user.outSA == 1) + ? Container( + width: double.infinity, + height: double.infinity, + color: Colors.grey.shade500.withOpacity(0.3), + child: Icon( + Icons.lock_outline, + size: 40, + ), + ) + : Container( + child: Column( + children: [ + Texts( + TranslationBase.of(context).covidTest, + color: Colors.white, + fontWeight: FontWeight.w700, + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: [ + Container( + margin: EdgeInsets.only( + top: 15.0, + ), + child: SvgPicture.asset('assets/images/new-design/covid-19-car.svg', width: 45.0, height: 45.0), + ), + Container( + margin: EdgeInsets.only(top: 5.0), + child: Column( + children: [ + Texts( + TranslationBase.of(context).driveThru, + fontWeight: FontWeight.w700, + color: Colors.white, + ), + ButtonTheme( + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(5.0), + ), + minWidth: MediaQuery.of(context).size.width * 0.15, + height: 25.0, + child: RaisedButton( + color: Colors.red[800], + textColor: Colors.white, + disabledTextColor: Colors.white, + disabledColor: new Color(0xFFbcc2c4), + onPressed: (model.user != null && model.user.outSA == 1) + ? () {} + : () { + navigateToCovidDriveThru(); + }, + child: Center( + child: Center( + child: Center( + child: Center( + child: Texts( + TranslationBase.of(context).bookNow, + fontWeight: FontWeight.w700, + color: Colors.white, + ), + ), + ), + ), + ), + ), + ), + ], + ), + ), + ], + ), + ], + ), + )), + ), + Expanded( + child: InkWell( + onTap: () => Navigator.push(context, FadePage(page: LiveCareHome())), + child: Container( + height: 125, + padding: EdgeInsets.all(15), + margin: EdgeInsets.all(5), + decoration: BoxDecoration(color: Colors.white.withOpacity(0.3), borderRadius: BorderRadius.all(Radius.circular(5))), + child: SvgPicture.asset( + projectViewModel.isArabic ? 'assets/images/new-design/livecare_arabic_logo.svg' : 'assets/images/new-design/liveCare_white_logo.svg', + ), + ), + ), + ), + ], + ), + ), + ) + ], + ), + ), + Container(width: double.infinity, height: projectViewModel.isArabic ? 110 : 80) + ], + ), + Positioned( + top: 155, + left: MediaQuery.of(context).size.width * (MediaQuery.of(context).orientation == Orientation.landscape ? 0.02 : 0.03), + right: MediaQuery.of(context).size.width * (MediaQuery.of(context).orientation == Orientation.landscape ? 0.02 : 0.03), + child: (!model.isLogin) + ? Container( + width: double.infinity, + height: 125, + decoration: BoxDecoration( + color: HexColor('#A59E9E'), + shape: BoxShape.rectangle, + border: Border.all(color: Colors.transparent, width: 0.5), + borderRadius: BorderRadius.all(Radius.circular(9)), + image: DecorationImage(image: ExactAssetImage('assets/images/bg_graphic.png'), fit: BoxFit.cover)), + child: Container( + margin: EdgeInsets.all(5), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SizedBox( + height: 2, + ), + Texts( + TranslationBase.of(context).myMedicalFile, + color: Colors.black87, + fontWeight: FontWeight.w700, + fontSize: 23, + ), + Texts( + TranslationBase.of(context).myMedicalFileSubTitle, + color: Colors.black, + fontSize: 16, + ), + Align( + alignment: projectViewModel.isArabic ? Alignment.bottomLeft : Alignment.bottomRight, + child: InkWell( + onTap: () { + widget.goToMyProfile(); + }, + child: Container( + margin: EdgeInsets.only(left: 15, right: 15), + width: 90, + height: 30, + decoration: BoxDecoration( + color: HexColor('#D81A2E'), + shape: BoxShape.rectangle, + border: Border.all(color: Colors.transparent, width: 0.5), + borderRadius: BorderRadius.all(Radius.circular(0)), + ), + child: Center( + child: Texts( + TranslationBase.of(context).viewMore, + color: Colors.white, + fontWeight: FontWeight.w700, + fontSize: 12, + ), + ), + ), + ), + ) + ], + ), + ), + ) + : Container( + width: double.infinity, + height: projectViewModel.isArabic ? 160 : 130, + decoration: BoxDecoration( + color: HexColor('#A59E9E'), + shape: BoxShape.rectangle, + border: Border.all(color: Colors.transparent, width: 0.5), + borderRadius: BorderRadius.all(Radius.circular(9)), + image: DecorationImage(image: ExactAssetImage('assets/images/bg_graphic.png'), fit: BoxFit.cover), + ), + child: Container( + margin: EdgeInsets.all(5), + child: Column( + children: [ + Row( + children: [ + if (projectViewModel.user != null && model.isLogin) + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SizedBox( + height: 8, + ), + model.user.cRSVerificationStatus == 2 + ? Row( + children: [ + Texts( + model.user.firstName + " " + model.user.lastName, + color: Colors.grey[100], + bold: true, + fontSize: 15, + ), + Container( + margin: EdgeInsets.fromLTRB(8.0, 0.0, 8.0, 0.0), + child: SvgPicture.asset("assets/images/new-design/verification_check.svg"), + ), + ], + ) + : model.user.cRSVerificationStatus == 3 + ? Row( + children: [ + Texts( + model.user.firstName + " " + model.user.lastName, + color: Colors.grey[100], + bold: true, + fontSize: 15, + ), + Container( + margin: EdgeInsets.fromLTRB(8.0, 0.0, 8.0, 0.0), + child: SvgPicture.asset("assets/images/new-design/pending.svg"), + ), + ], + ) + : Row( + children: [ + Texts( + model.user.firstName + " " + model.user.lastName, + color: Colors.grey[100], + bold: true, + fontSize: 15, + ), + ], + ), + Texts( + '${model.user.patientID}', + color: Colors.white, + fontSize: 14, + ), + SizedBox( + height: 5, + ), + Texts( + '${DateUtil.getMonthDayYearDateFormatted(model.user.dateofBirthDataTime)} ,${model.user.gender == 1 ? TranslationBase.of(context).male : TranslationBase.of(context).female} ${model.user.age.toString() + "y"}', + color: Colors.grey[100], + fontWeight: FontWeight.normal, + fontSize: 14, + ), + ], + ), + ), + InkWell( + onTap: () { + widget.goToMyProfile(); + }, + child: Container( + margin: EdgeInsets.all(2), + width: 90, + height: 30, + decoration: BoxDecoration( + color: HexColor('#D81A2E'), + shape: BoxShape.rectangle, + border: Border.all(color: Colors.transparent, width: 0.5), + borderRadius: BorderRadius.all( + Radius.circular(5), + ), + ), + child: Center( + child: Texts( + TranslationBase.of(context).myMedicalFile, + color: Colors.white, + fontSize: 12, + textAlign: TextAlign.center, + ), + ), + ), + ) + ], + ), + Row( + children: [ + Expanded( + child: Row( + children: [ + Image.asset( + 'assets/images/height_icon.png', + width: 35, + height: 40, + ), + Texts( + "${model.heightCm} ${TranslationBase.of(context).cm}", + color: Colors.white, + fontSize: 17, + ) + ], + ), + ), + SizedBox( + width: 3, + ), + Expanded( + child: Row( + children: [ + Image.asset( + 'assets/images/weight_icon.png', + width: 25, + height: 40, + ), + Texts('${model.weightKg} ${TranslationBase.of(context).kg}', color: Colors.white, fontSize: 17) + ], + ), + ), + SizedBox( + width: 3, + ), + Expanded( + child: Row( + children: [ + Image.asset( + 'assets/images/blood_icon.png', + width: 35, + height: 40, + ), + Texts('${model.booldType}', color: Colors.white, fontSize: 17) + ], + ), + ), + ], + ) + ], + ), + ), + ), + ), + ], + ), + Padding( + padding: const EdgeInsets.only(bottom: 15, right: 15, left: 15), + child: InkWell( + onTap: () { + Navigator.of(context).push(MaterialPageRoute(builder: (context) => PackagesHomePage())); + }, + child: Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(10), + color: Color(0xffB8382C), + ), + child: Padding( + padding: const EdgeInsets.all(8), + child: Row( + children: [ + Texts( + TranslationBase.of(context).offerAndPackages, + color: Colors.white, + fontSize: 20, + fontWeight: FontWeight.normal, + ), + Spacer(), + Image.asset("assets/images/offer_icon.png"), + ], + ), + ), + ), + ), + ), + if (projectViewModel.havePrivilege(64) || projectViewModel.havePrivilege(65) || projectViewModel.havePrivilege(67)) + Container( + margin: EdgeInsets.only(left: 15, right: 15), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + if (projectViewModel.havePrivilege(64)) + DashboardItem( + onTap: (model.user != null && model.user.outSA == 1) + ? () {} + : () { + Navigator.push( + context, + FadePage( + page: HomeHealthCarePage(), + ), + ); + }, + child: Center( + child: Padding( + padding: (model.user != null && model.user.outSA == 1) ? const EdgeInsets.all(0.0) : const EdgeInsets.all(15.0), + child: (model.user != null && model.user.outSA == 1) + ? Container( + width: double.infinity, + height: double.infinity, + color: Colors.grey.shade500.withOpacity(0.3), + child: Icon( + Icons.lock_outline, + size: 40, + ), + ) + : Column( + children: [ + Image.asset( + 'assets/images/home_health_care_icon.png', + width: 50, + height: 50, + ), + SizedBox( + height: 10, + ), + Texts( + TranslationBase.of(context).homeHealthCare, + textAlign: TextAlign.center, + color: Colors.white, + fontWeight: FontWeight.w700, + fontSize: SizeConfig.textMultiplier * 1.55, + ) + ], + )), + ), + height: MediaQuery.of(context).size.width * 0.4, + imageName: 'home_healthcare_service_bg.png', + opacity: 0.5, + ), + if (projectViewModel.havePrivilege(65)) + DashboardItem( + onTap: () => (model.user != null && model.user.outSA == 1) ? () {} : getPharmacyToken(model), + child: Center( + child: Padding( + padding: (model.user != null && model.user.outSA == 1) ? const EdgeInsets.all(0.0) : const EdgeInsets.all(15.0), + child: (model.user != null && model.user.outSA == 1) + ? Container( + width: double.infinity, + height: double.infinity, + color: Colors.grey.shade500.withOpacity(0.3), + child: Icon( + Icons.lock_outline, + size: 40, + ), + ) + : Column( + children: [ + // if (projectViewModel.user != null && model.isLogin && model.user.outSA == 1) + // Image.asset( + // 'assets/images/lock_icon.png', + // width: 50, + // height: 50, + // ), + Image.asset( + 'assets/images/pharmacy_logo.png', + width: 40, + height: 40, + ), + SizedBox( + height: 20, + ), + Texts( + TranslationBase.of(context).onlinePharmacy, + textAlign: TextAlign.center, + color: Colors.white, + fontWeight: FontWeight.w700, + fontSize: SizeConfig.textMultiplier * 1.55, + ) + ], + ), + ), + ), + height: MediaQuery.of(context).size.width * 0.4, + imageName: 'al-habib_onlne_pharmacy_bg.png', + ), + if (projectViewModel.havePrivilege(67)) + DashboardItem( + onTap: (model.user != null && model.user.outSA == 1) + ? () {} + : () { + Navigator.push( + context, + FadePage( + page: CMCPage(), + ), + ); + }, + child: Center( + child: Padding( + padding: (model.user != null && model.user.outSA == 1) ? const EdgeInsets.all(0.0) : const EdgeInsets.all(15.0), + child: (model.user != null && model.user.outSA == 1) + ? Container( + width: double.infinity, + height: double.infinity, + color: Colors.grey.shade500.withOpacity(0.3), + child: Icon( + Icons.lock_outline, + size: 40, + ), + ) + : Column( + children: [ + Image.asset( + 'assets/images/comprehensive_medical_checkup_logo.png', + width: 50, + height: 50, + ), + SizedBox( + height: 10, + ), + Texts( + TranslationBase.of(context).cmcHeading, + textAlign: TextAlign.center, + color: Colors.white, + fontWeight: FontWeight.w700, + fontSize: SizeConfig.textMultiplier * 1.55, + ) + ], + )), + ), + height: MediaQuery.of(context).size.width * 0.4, + color: HexColor("#747C80"), + imageName: 'emergency_service_image.png', + ), + ], + ), + ), + SizedBox( + height: 8, + ), + Container( + margin: EdgeInsets.only(left: 15, right: 15), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + InkWell( + onTap: () => Navigator.push(context, FadePage(page: PaymentService())), + child: Container( + width: MediaQuery.of(context).size.width * 0.29, + child: Center( + child: Padding( + padding: const EdgeInsets.all(15.0), + child: Column( + children: [ + Image.asset( + 'assets/images/al-habib_online_payment_service_icon.png', + height: 55, + ), + SizedBox( + height: 5, + ), + Texts( + TranslationBase.of(context).onlinePaymentService, + textAlign: TextAlign.center, + color: Colors.black87, + bold: false, + fontSize: SizeConfig.textMultiplier * 1.7, + ) + ], + ), + ), + ), + height: MediaQuery.of(context).size.width * 0.4, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(6.0), + color: Colors.white, + ), + ), + ), + InkWell( + onTap: () { + Navigator.push(context, FadePage(page: EReferralPage())); + }, + child: Container( + child: Center( + child: Padding( + padding: const EdgeInsets.all(15.0), + child: Column( + children: [ + Image.asset( + 'assets/images/ereferral_service_icon.png', + width: 50, + height: 55, + ), + SizedBox( + height: 10, + ), + Texts( + TranslationBase.of(context).ereferral, + textAlign: TextAlign.center, + color: Colors.black87, + bold: false, + fontSize: SizeConfig.textMultiplier * 1.7, + ) + ], + ), + ), + ), + width: MediaQuery.of(context).size.width * 0.29, + height: MediaQuery.of(context).size.width * 0.4, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(6.0), + color: Colors.white, + )), + ), + if (projectViewModel.havePrivilege(60)) + Container( + width: MediaQuery.of(context).size.width * 0.29, + child: InkWell( + onTap: () => Navigator.push( + context, + FadePage( + page: ErOptions( + isAppbar: true, + ))), + child: Center( + child: Padding( + padding: const EdgeInsets.all(15.0), + child: Column( + children: [ + Image.asset( + 'assets/images/Dr_Schedule_report.png', + width: 50, + height: 50, + ), + SizedBox( + height: 10, + ), + Texts( + TranslationBase.of(context).emergencyServices, + textAlign: TextAlign.center, + color: Colors.black87, + bold: false, + fontSize: SizeConfig.textMultiplier * 1.7, + ) + ], + ), + ), + ), + ), + height: MediaQuery.of(context).size.width * 0.4, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(6.0), + color: Colors.white, + ), + ), + ], + ), + ), + // ), + SizedBox( + height: 5, + ), + Container( + margin: EdgeInsets.only(left: 15, right: 15), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + DashboardItem( + child: Container( + width: double.infinity, + padding: EdgeInsets.all(10), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Texts( + TranslationBase.of(context).hMGService, + color: Colors.white, + fontWeight: FontWeight.normal, + ), + Texts( + TranslationBase.of(context).viewAllHabibMedicalService, + color: Colors.white, + fontWeight: FontWeight.normal, + fontSize: 10, + ), + Expanded( + child: Container(), + ), + Texts( + TranslationBase.of(context).viewMore, + color: Colors.white, + //fontWeight: FontWeight.normal, + ) + ], + ), + ), + height: 100, + imageName: 'contact_us_bg.png', + opacity: 0.5, + color: Colors.grey[700], + width: MediaQuery.of(context).size.width * 0.45, + onTap: () => Navigator.push(context, FadePage(page: AllHabibMedicalService())), + ), + DashboardItem( + onTap: () { + // Navigator.push( + // context, FadePage(page: FeedbackHomePage())); + Navigator.push(context, FadePage(page: ContactUsPage())); + }, + child: Container( + width: double.infinity, + padding: EdgeInsets.all(10), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Texts( + TranslationBase.of(context).reachUs, + color: Colors.white, + fontWeight: FontWeight.normal, + ), + Texts( + TranslationBase.of(context).viewAllWaysReachUs, + color: Colors.white, + fontWeight: FontWeight.normal, + fontSize: 10, + ), + Expanded( + child: Container(), + ), + Texts( + TranslationBase.of(context).viewMore, + color: Colors.white, + fontWeight: FontWeight.normal, + ) + ], + ), + ), + height: 100, + imageName: 'contact_us_bg.png', + opacity: 0.5, + color: Colors.grey[700], + width: MediaQuery.of(context).size.width * 0.45, + ), + ], + ), + ), + SizedBox( + height: 120, + ) + ], + ), + ), + ), + ), + ); + } + + getPharmacyToken(DashboardViewModel model) async { + if (!model.isLogin) { + Navigator.push(context, FadePage(page: LandingPagePharmacy())); + } else { + GifLoaderDialogUtils.showMyDialog(context); + await pharmacyModuleViewModel.generatePharmacyToken().then((value) async { + + await pharmacyModuleViewModel.verifyCustomer().then((value) { + GifLoaderDialogUtils.hideDialog(context); + Navigator.push(context, FadePage(page: LandingPagePharmacy())); + }); + }); + } + } + + navigateToCovidDriveThru() { + Navigator.push(context, FadePage(page: CovidDrivethruLocation())); + } +} + +class DashboardItem extends StatelessWidget { + const DashboardItem({this.hasBorder = false, this.imageName, @required this.child, this.onTap, Key key, this.width, this.height, this.color, this.opacity = 0.4, this.hasColorFilter = true}) + : super(key: key); + final bool hasBorder; + final String imageName; + final Widget child; + final Function onTap; + final double width; + final double height; + final Color color; + final double opacity; + final bool hasColorFilter; + + @override + Widget build(BuildContext context) { + return InkWell( + onTap: onTap, + child: Container( + width: width != null ? width : MediaQuery.of(context).size.width * 0.29, + height: height != null + ? height + : MediaQuery.of(context).orientation == Orientation.portrait + ? MediaQuery.of(context).size.height * 0.17 + : MediaQuery.of(context).size.height * 0.35, + decoration: BoxDecoration( + color: !hasBorder + ? color != null + ? color + : HexColor('#050705').withOpacity(opacity) + : Colors.white, + borderRadius: BorderRadius.circular(6.0), + border: hasBorder ? Border.all(width: 1.0, color: const Color(0xffcccccc)) : Border.all(width: 0.0, color: Colors.transparent), + image: imageName != null + ? DecorationImage( + image: ExactAssetImage('assets/images/$imageName'), + fit: BoxFit.cover, + colorFilter: hasColorFilter ? new ColorFilter.mode(Colors.black.withOpacity(0.2), BlendMode.dstIn) : null, + ) + : null, + ), + child: Center( + child: child, + ), + ), + ); + } +} diff --git a/lib/pages/landing/landing_page_pharmcy.dart b/lib/pages/landing/landing_page_pharmcy.dart index 5da853fb..6ae272e2 100644 --- a/lib/pages/landing/landing_page_pharmcy.dart +++ b/lib/pages/landing/landing_page_pharmcy.dart @@ -2,9 +2,10 @@ import 'package:barcode_scan_fix/barcode_scan.dart'; import 'package:diplomaticquarterapp/config/config.dart'; import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart'; import 'package:diplomaticquarterapp/core/service/client/base_app_client.dart'; +import 'package:diplomaticquarterapp/core/service/parmacyModule/parmacy_module_service.dart'; import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; -import 'package:diplomaticquarterapp/pages/pharmacies/product_detail.dart'; -import 'package:diplomaticquarterapp/pages/pharmacies/screens/cart-order-page.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/product-detail.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/screens/cart-page/cart-order-page.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/screens/pharmacy_module_page.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/wishlist.dart'; import 'package:diplomaticquarterapp/pages/pharmacy/profile/profile.dart'; @@ -18,6 +19,8 @@ import 'package:diplomaticquarterapp/widgets/pharmacy/bottom_nav_pharmacy_bar.da import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; import 'package:flutter/material.dart'; +import '../../locator.dart'; + class LandingPagePharmacy extends StatefulWidget { @override _LandingPagePharmacyState createState() => _LandingPagePharmacyState(); @@ -37,127 +40,102 @@ class _LandingPagePharmacyState extends State { void initState() { super.initState(); + locator().manufacturerList = []; + locator().bestSellerProducts = []; + locator().lastVisitedProducts = []; + pageController = PageController(keepPage: true); } @override Widget build(BuildContext context) { - return Scaffold( - appBar: currentTab != 4 && currentTab != 3 - ? AppBar( - backgroundColor: Color(0xff5AB145), - elevation: 0, - title: Container( - height: MediaQuery.of(context).size.height * 0.056, - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(5.0), - color: Colors.white, - ), - child: InkWell( - child: Padding( - padding: EdgeInsets.all(5.0), - child: Row( - //crossAxisAlignment: CrossAxisAlignment.center, - mainAxisAlignment: MainAxisAlignment.start, - children: [ - Icon(Icons.search, size: 25.0), - SizedBox( - width: 15.0, - ), - Texts( - TranslationBase.of(context).searchProductHere, - fontSize: 13, - ) - ], + return WillPopScope( + onWillPop: () async { + return false; + }, + child: Scaffold( + appBar: currentTab != 4 && currentTab != 3 + ? AppBar( + backgroundColor: Color(0xff5AB145), + elevation: 0, + title: Container( + height: MediaQuery.of(context).size.height * 0.056, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(5.0), + color: Colors.white, + ), + child: InkWell( + child: Padding( + padding: EdgeInsets.all(5.0), + child: Row( + //crossAxisAlignment: CrossAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Icon(Icons.search, size: 25.0), + SizedBox( + width: 15.0, + ), + Texts( + TranslationBase.of(context).searchProductHere, + fontSize: 13, + ) + ], + ), ), + onTap: () { + Navigator.push( + context, + FadePage(page: SearchProductsPage()), + ); + }, ), - onTap: () { - Navigator.push( - context, - FadePage(page: SearchProductsPage()), + ), + leading: Builder( + builder: (BuildContext context) { + return InkWell( + onTap: () { + setState(() { + currentTab = 0; + pageController.jumpToPage(0); + }); + }, + child: Container( + height: 2.0, + width: 10.0, + child: Image.asset( + 'assets/images/pharmacy_logo.png', + ), + ), ); }, ), - ), - leading: Builder( - builder: (BuildContext context) { - return InkWell( - onTap: () { - setState(() { - currentTab = 0; - pageController.jumpToPage(0); - }); - }, - child: Container( - height: 2.0, - width: 10.0, - child: Image.asset( - 'assets/images/pharmacy_logo.png', + actions: [ + IconButton( + // iconSize: 70, + icon: Image.asset( + 'assets/images/new-design/qr-code.png', ), - ), - ); - }, - ), - actions: [ - IconButton( - // iconSize: 70, - icon: Image.asset( - 'assets/images/new-design/qr-code.png', - ), - onPressed: _scanQrAndGetProduct //do something, - ) - ], - centerTitle: true, - ) - : null, - // : AppBar( - // backgroundColor: Color(0xff5AB145), - // elevation: 0, - // textTheme: TextTheme( - // headline6: TextStyle( - // color: Colors.white, fontWeight: FontWeight.bold), - // ), - // title: Text(getText(currentTab).toUpperCase()), - // leading: Builder( - // builder: (BuildContext context) { - // return IconButton( - // icon: Icon(Icons.arrow_back), - // color: Colors.white, - // onPressed: () => Scaffold.of(context).openDrawer(), - // ); - // }, - // ), - // actions: [ - // // IconButton( - // // iconSize: 70, - // // icon: SvgPicture.asset('assets/images/svg/robort_svg.svg', - // // height: 100, width: 100, fit: BoxFit.cover), - // // onPressed: () { - // // triggerRobot(); - // // } //do something, - // // ) - // ], - // centerTitle: true, - // ), - extendBody: false, - body: PageView( - physics: NeverScrollableScrollPhysics(), - controller: pageController, - children: [ - PharmacyPage(), - PharmacyCategorisePage(), -// OffersCategorisePage(), - WishlistPage(false), - PharmacyProfilePage(), -// Container( -// child: Text('text'), -// ), - CartOrderPage(), - ], // Please do not remove the BookingOptions from this array - ), - bottomNavigationBar: BottomNavPharmacyBar( - changeIndex: _changeCurrentTab, - index: currentTab, + onPressed: _scanQrAndGetProduct //do something, + ) + ], + centerTitle: true, + ) + : null, + extendBody: false, + body: PageView( + physics: NeverScrollableScrollPhysics(), + controller: pageController, + children: [ + PharmacyPage(), + PharmacyCategorisePage(), + PharmacyProfilePage(), + CartOrderPage(changeTab: _changeCurrentTab), + ], + ), + bottomNavigationBar: BottomNavPharmacyBar( + changeIndex: _changeCurrentTab, + index: currentTab, + ), ), ); } @@ -172,7 +150,7 @@ class _LandingPagePharmacyState extends State { .getPharmacy("$GET_PHARMACY_PRODUCTs_BY_SKU$barcode", onSuccess: (dynamic response, int statusCode) { print(response); - product = PharmacyProduct.fromJson(response["products"][0]); + var product = PharmacyProduct.fromJson(response["products"][0]); GifLoaderDialogUtils.hideDialog(context); Navigator.push(context, FadePage(page: ProductDetailPage(product))); }, onFailure: (String error, int statusCode) { diff --git a/lib/pages/login/login.dart b/lib/pages/login/login.dart index 9c245e01..2bb0e1d0 100644 --- a/lib/pages/login/login.dart +++ b/lib/pages/login/login.dart @@ -64,7 +64,10 @@ class _Login extends State { if (BASE_URL.contains("uat.")) { nationalIDorFile.text = "2001273"; mobileNumberController.text = mobileNo = "0555416043"; - } + }/* else { + nationalIDorFile.text = "3376044"; + mobileNumberController.text = mobileNo = "0555416575"; + }*/ } getDeviceToken() async { diff --git a/lib/pages/packages_offers/OfferAndPackageDetailPage.dart b/lib/pages/packages_offers/OfferAndPackageDetailPage.dart index 8aeb4edf..f2ff8f6c 100644 --- a/lib/pages/packages_offers/OfferAndPackageDetailPage.dart +++ b/lib/pages/packages_offers/OfferAndPackageDetailPage.dart @@ -25,8 +25,6 @@ class OfferAndPackagesDetailState extends State{ @override Widget build(BuildContext context) { - getLanguageID(); - return BaseView( onModelReady: (model){ viewModel = model; diff --git a/lib/pages/parent_categorise_page.dart b/lib/pages/parent_categorise_page.dart index dcae9d90..1ac20946 100644 --- a/lib/pages/parent_categorise_page.dart +++ b/lib/pages/parent_categorise_page.dart @@ -1,8 +1,15 @@ +import 'package:diplomaticquarterapp/config/size_config.dart'; +import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart'; import 'package:diplomaticquarterapp/core/model/pharmacy/categorise_parent_model.dart'; +import 'package:diplomaticquarterapp/core/service/AuthenticatedUserObject.dart'; +import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/product_detail_view_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacy_categorise_view_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; -import 'package:diplomaticquarterapp/pages/pharmacies/product_detail.dart'; +import 'package:diplomaticquarterapp/locator.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/screens/cart-order-page.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/product-detail.dart'; import 'package:diplomaticquarterapp/pages/sub_categorise_page.dart'; +import 'package:diplomaticquarterapp/uitl/app_toast.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; import 'package:diplomaticquarterapp/widgets/buttons/button.dart'; @@ -14,25 +21,34 @@ import 'package:diplomaticquarterapp/widgets/others/network_base_view.dart'; import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:provider/provider.dart'; - +import 'package:diplomaticquarterapp/pages/sub_categories_modalsheet.dart'; import 'base/base_view.dart'; + class ParentCategorisePage extends StatefulWidget { String id; String titleName; + AuthenticatedUserObject authenticatedUserObject = + locator(); + ParentCategorisePage({this.id, this.titleName}); @override - _ParentCategorisePageState createState() => _ParentCategorisePageState(id: id, titleName: titleName); + _ParentCategorisePageState createState() => + _ParentCategorisePageState(id: id, titleName: titleName); } class _ParentCategorisePageState extends State { String id; String titleName; + final dynamic productID; - _ParentCategorisePageState({this.id, this.titleName}); + + + _ParentCategorisePageState({this.id, this.titleName, this.productID,}); Map values = {'huusam': false, 'ali': false, 'noor': false}; bool checkedBrands = false; @@ -56,7 +72,10 @@ class _ParentCategorisePageState extends State { ProjectViewModel projectViewModel = Provider.of(context); return BaseView( onModelReady: (model) => model.getCategoriseParent(i: id), - builder: (BuildContext context, PharmacyCategoriseViewModel model, Widget child) => PharmacyAppScaffold( + allowAny: true, + builder: (BuildContext context, PharmacyCategoriseViewModel model, + Widget child) => + PharmacyAppScaffold( appBarTitle: titleName, isBottomBar: false, isShowAppBar: true, @@ -107,62 +126,72 @@ class _ParentCategorisePageState extends State { child: InkWell( child: Container( child: Texts( - TranslationBase.of(context).viewCategorise, + TranslationBase.of(context) + .viewCategorise, // 'View All Categories', fontWeight: FontWeight.w300, ), ), onTap: () { - showModalBottomSheet( - isScrollControlled: true, - context: context, - builder: (BuildContext context) { - return Container( - // height: MediaQuery.of(context) - // .size - // .height * - // 0.89, - color: Colors.white, - child: Center( - child: ListView.builder( - scrollDirection: Axis.vertical, - itemCount: model.categoriseParent.length, - itemBuilder: (BuildContext context, int index) { - return Container( - child: Padding( - padding: EdgeInsets.all(4.0), - child: InkWell( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Texts(projectViewModel.isArabic - ? model.categoriseParent[index].namen - : model.categoriseParent[index].name), - Divider( - thickness: 0.6, - color: Colors.black12, - ) - ], - ), - onTap: () { - Navigator.push( - context, - FadePage( - page: SubCategorisePage( - title: model.categoriseParent[index].name, - id: model.categoriseParent[index].id, - parentId: id, - )), - ); - }, - ), - ), - ); - }), - ), - ); - }, + Navigator.push( + context, + FadePage( + page: SubCategoriseModalsheet( +// id: model.categorise[0].id, +// titleName: model.categorise[0].name, + ) + ), ); +// showModalBottomSheet( +// isScrollControlled: true, +// context: context, +// builder: (BuildContext context) { +// return Container( +// // height: MediaQuery.of(context) +// // .size +// // .height * +// // 0.89, +// color: Colors.white, +// child: Center( +// child: ListView.builder( +// scrollDirection: Axis.vertical, +// itemCount: model.categoriseParent.length, +// itemBuilder: (BuildContext context, int index) { +// return Container( +// child: Padding( +// padding: EdgeInsets.all(4.0), +// child: InkWell( +// child: Column( +// crossAxisAlignment: CrossAxisAlignment.start, +// children: [ +// Texts(projectViewModel.isArabic +// ? model.categoriseParent[index].namen +// : model.categoriseParent[index].name), +// Divider( +// thickness: 0.6, +// color: Colors.black12, +// ) +// ], +// ), +// onTap: () { +// Navigator.push( +// context, +// FadePage( +// page: SubCategorisePage( +// title: model.categoriseParent[index].name, +// id: model.categoriseParent[index].id, +// parentId: id, +// )), +// ); +// }, +// ), +// ), +// ); +// }), +// ), +// ); +// }, +// ); }, ), ), @@ -184,22 +213,28 @@ class _ParentCategorisePageState extends State { child: Center( child: ListView.builder( scrollDirection: Axis.horizontal, - itemCount: model.categoriseParent.length > 8 ? 8 : model.categoriseParent.length, + itemCount: model.categoriseParent.length > 8 + ? 8 + : model.categoriseParent.length, itemBuilder: (BuildContext context, int index) { return Padding( - padding: EdgeInsets.symmetric(horizontal: 8.0), + padding: + EdgeInsets.symmetric(horizontal: 8.0), child: InkWell( child: Column( - crossAxisAlignment: CrossAxisAlignment.center, + crossAxisAlignment: + CrossAxisAlignment.center, children: [ Padding( - padding: EdgeInsets.symmetric(horizontal: 13.0), + padding: EdgeInsets.symmetric( + horizontal: 13.0), child: Container( height: 60.0, width: 65.0, decoration: BoxDecoration( shape: BoxShape.circle, - color: Colors.orange.shade200.withOpacity(0.45), + color: Colors.orange.shade200 + .withOpacity(0.45), ), child: Center( child: Icon( @@ -210,7 +245,10 @@ class _ParentCategorisePageState extends State { ), ), Container( - width: MediaQuery.of(context).size.width * 0.197, + width: MediaQuery.of(context) + .size + .width * + 0.197, // height: MediaQuery.of(context) // .size // .height * @@ -218,8 +256,12 @@ class _ParentCategorisePageState extends State { child: Center( child: Texts( projectViewModel.isArabic - ? model.categoriseParent[index].namen - : model.categoriseParent[index].name, + ? model + .categoriseParent[index] + .namen + : model + .categoriseParent[index] + .name, fontSize: 13.4, fontWeight: FontWeight.w600, maxLines: 3, @@ -233,8 +275,10 @@ class _ParentCategorisePageState extends State { context, FadePage( page: SubCategorisePage( - title: model.categoriseParent[index].name, - id: model.categoriseParent[index].id, + title: model + .categoriseParent[index].name, + id: model + .categoriseParent[index].id, parentId: id, )), ); @@ -280,16 +324,21 @@ class _ParentCategorisePageState extends State { initialChildSize: 0.95, maxChildSize: 0.95, minChildSize: 0.9, - builder: (BuildContext context, ScrollController scrollController) { + builder: (BuildContext context, + ScrollController scrollController) { return SingleChildScrollView( controller: scrollController, child: Container( color: Colors.white, - height: MediaQuery.of(context).size.height * 1.95, + height: MediaQuery.of(context) + .size + .height * + 1.95, child: Column( children: [ Padding( - padding: EdgeInsets.all(8.0), + padding: + EdgeInsets.all(8.0), child: Row( children: [ Icon( @@ -299,21 +348,29 @@ class _ParentCategorisePageState extends State { width: 10.0, ), Texts( - 'Refine', - fontWeight: FontWeight.w600, + + TranslationBase.of(context).refine, +// 'Refine', + + fontWeight: + FontWeight.w600, + ), SizedBox( width: 250.0, ), InkWell( child: Texts( - 'Close', +// 'Close', + TranslationBase.of(context).closeIt, color: Colors.red, - fontWeight: FontWeight.w600, + fontWeight: + FontWeight.w600, fontSize: 15.0, ), onTap: () { - Navigator.pop(context); + Navigator.pop( + context); }, ), ], @@ -326,27 +383,39 @@ class _ParentCategorisePageState extends State { Column( children: [ ExpansionTile( - title: Texts('Categorise'), + + title: Texts( TranslationBase.of( + context) + .categorise), children: [ ProcedureListWidget( model: model, - masterList: model.categoriseParent, - removeHistory: (item) { + masterList: model + .categoriseParent, + removeHistory: + (item) { setState(() { - entityList.remove(item); + entityList + .remove( + item); }); }, - addHistory: (history) { + addHistory: + (history) { setState(() { - entityList.add(history); + entityList.add( + history); }); }, - addSelectedHistories: () { + addSelectedHistories: + () { //TODO build your fun herr // widget.addSelectedHistories(); }, - isEntityListSelected: (master) => - isEntityListSelected(master), + isEntityListSelected: + (master) => + isEntityListSelected( + master), ) ], ), @@ -355,27 +424,39 @@ class _ParentCategorisePageState extends State { color: Colors.black12, ), ExpansionTile( - title: Texts('Brands'), + title: Texts( TranslationBase.of( + context) + .brands), children: [ ProcedureListWidget( model: model, - masterList: model.brandsList, - removeHistory: (item) { + masterList: model + .brandsList, + removeHistory: + (item) { setState(() { - entityListBrands.remove(item); + entityListBrands + .remove( + item); }); }, - addHistory: (history) { + addHistory: + (history) { setState(() { - entityListBrands.add(history); + entityListBrands + .add( + history); }); }, - addSelectedHistories: () { + addSelectedHistories: + () { //TODO build your fun herr // widget.addSelectedHistories(); }, - isEntityListSelected: (master) => - isEntityListSelectedBrands(master), + isEntityListSelected: + (master) => + isEntityListSelectedBrands( + master), ) ], ), @@ -384,43 +465,68 @@ class _ParentCategorisePageState extends State { color: Colors.black12, ), ExpansionTile( - title: Texts('Price'), + title: Texts( TranslationBase.of( + context) + .price), children: [ Container( - color: Color(0xffEEEEEE), + color: Color( + 0xffEEEEEE), child: Row( - mainAxisAlignment: MainAxisAlignment.spaceAround, + mainAxisAlignment: + MainAxisAlignment + .spaceAround, children: [ Column( - mainAxisAlignment: MainAxisAlignment.start, + mainAxisAlignment: + MainAxisAlignment + .start, children: [ - Texts('Min'), + Texts( + 'Min'), Container( - color: Colors.white, - width: 200, - height: 40, - child: TextFormField( - decoration: InputDecoration( - border: OutlineInputBorder(), + color: Colors + .white, + width: + 200, + height: + 40, + child: + TextFormField( + decoration: + InputDecoration( + border: + OutlineInputBorder(), ), - controller: minField, + controller: + minField, ), ), ], ), Column( - mainAxisAlignment: MainAxisAlignment.start, + mainAxisAlignment: + MainAxisAlignment + .start, children: [ - Texts('Max'), + Texts( + 'Max'), Container( - color: Colors.white, - width: 200, - height: 40, - child: TextFormField( - decoration: InputDecoration( - border: OutlineInputBorder(), + color: Colors + .white, + width: + 200, + height: + 40, + child: + TextFormField( + decoration: + InputDecoration( + border: + OutlineInputBorder(), ), - controller: maxField, + controller: + maxField, ), ), ], @@ -435,18 +541,31 @@ class _ParentCategorisePageState extends State { color: Colors.black12, ), SizedBox( - height: MediaQuery.of(context).size.height * 0.4, + height: MediaQuery.of( + context) + .size + .height * + 0.4, ), Padding( - padding: EdgeInsets.all(8.0), + padding: + EdgeInsets.all(8.0), child: Row( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, + mainAxisAlignment: + MainAxisAlignment + .spaceEvenly, children: [ Container( width: 100, child: Button( - label: 'Reset', + + label: TranslationBase.of( + context) + .reset, backgroundColor: Colors.red, + + + ), ), SizedBox( @@ -455,38 +574,68 @@ class _ParentCategorisePageState extends State { Container( width: 200, child: Button( - onTap: () async { - String categoriesId = ""; - for (CategoriseParentModel category in entityList) { - if (categoriesId == "") { - categoriesId = category.id; + onTap: + () async { + String + categoriesId = + ""; + for (CategoriseParentModel category + in entityList) { + if (categoriesId == + "") { + categoriesId = + category + .id; } else { - categoriesId = "$categoriesId,${category.id}"; + categoriesId = + "$categoriesId,${category.id}"; } } - String brandIds = ""; + String + brandIds = + ""; for (CategoriseParentModel brand in entityListBrands) { - if (brandIds == "") { - brandIds = brand.id; + if (brandIds == + "") { + brandIds = + brand + .id; } else { - brandIds = "$brandIds,${brand.id}"; + brandIds = + "$brandIds,${brand.id}"; } } - GifLoaderDialogUtils.showMyDialog(context); + GifLoaderDialogUtils + .showMyDialog( + context); await model.getFilteredProducts( - min: minField.text.toString(), - max: maxField.text.toString(), - categoryId: categoriesId, - brandId: brandIds); - GifLoaderDialogUtils.hideDialog(context); + min: minField + .text + .toString(), + max: maxField + .text + .toString(), + categoryId: + categoriesId, + brandId: + brandIds); + GifLoaderDialogUtils + .hideDialog( + context); - Navigator.pop(context); + Navigator.pop( + context); }, - label: 'Apply', + + label: TranslationBase.of( + context) + .apply, backgroundColor: Colors.green, + + ), ), ], @@ -553,22 +702,28 @@ class _ParentCategorisePageState extends State { model.parentProducts.isNotEmpty ? styleOne == true ? Container( - height: model.parentProducts.length * MediaQuery.of(context).size.height * 0.15, + height: model.parentProducts.length * + MediaQuery.of(context).size.height * + 0.15, child: GridView.builder( physics: NeverScrollableScrollPhysics(), - gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( + gridDelegate: + SliverGridDelegateWithFixedCrossAxisCount( crossAxisCount: 2, crossAxisSpacing: 0.5, mainAxisSpacing: 2.0, childAspectRatio: 0.9, ), itemCount: model.parentProducts.length, - itemBuilder: (BuildContext context, int index) { + itemBuilder: + (BuildContext context, int index) { return NetworkBaseView( baseViewModel: model, child: InkWell( child: Card( - color: model.parentProducts[index].discountName != null + color: model.parentProducts[index] + .discountName != + null ? Color(0xffFFFF00) : Colors.white, elevation: 0, @@ -596,106 +751,187 @@ class _ParentCategorisePageState extends State { ), child: Container( decoration: BoxDecoration( - borderRadius: BorderRadius.only( - topLeft: Radius.circular(110.0), + borderRadius: + BorderRadius.only( + topLeft: + Radius.circular(110.0), ), color: Colors.white, ), - padding: EdgeInsets.symmetric(horizontal: 0), - width: MediaQuery.of(context).size.width / 3, + padding: EdgeInsets.symmetric( + horizontal: 0), + width: MediaQuery.of(context) + .size + .width / + 3, child: Column( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ Stack( children: [ - if (model.parentProducts[index].discountName != null) + if (model + .parentProducts[ + index] + .discountName != + null) RotatedBox( quarterTurns: 4, child: Container( - decoration: BoxDecoration(), + decoration: + BoxDecoration(), child: Padding( - padding: EdgeInsets.only( + padding: + EdgeInsets + .only( right: 5.0, top: 20.0, bottom: 5.0, ), child: Texts( - 'offer'.toUpperCase(), - color: Colors.red, - fontSize: 13.0, - fontWeight: FontWeight.w900, + 'offer' + .toUpperCase(), + color: Colors + .red, + fontSize: + 13.0, + fontWeight: + FontWeight + .w900, ), ), - transform: new Matrix4.rotationZ(5.837200), + transform: new Matrix4 + .rotationZ( + 5.837200), ), ), Container( - margin: EdgeInsets.fromLTRB(0, 16, 0, 0), - alignment: Alignment.center, + margin: EdgeInsets + .fromLTRB( + 0, 16, 0, 0), + alignment: + Alignment.center, child: Image.network( - model.parentProducts[index].images.isNotEmpty - ? model.parentProducts[index].images[0].thumb + model + .parentProducts[ + index] + .images + .isNotEmpty + ? model + .parentProducts[ + index] + .images[0] + .thumb : 'https://upload.wikimedia.org/wikipedia/commons/thumb/6/6c/No_image_3x4.svg/1200px-No_image_3x4.svg.png', fit: BoxFit.cover, height: 80, ), ), Container( - width: model.parentProducts[index].rxMessage != null - ? MediaQuery.of(context).size.width / 5 + width: model + .parentProducts[ + index] + .rxMessage != + null + ? MediaQuery.of( + context) + .size + .width / + 5 : 0, - padding: EdgeInsets.all(4), - decoration: BoxDecoration( - color: Color(0xffb23838), + padding: + EdgeInsets.all(4), + decoration: + BoxDecoration( + color: Color( + 0xffb23838), borderRadius: - BorderRadius.only(topLeft: Radius.circular(6)), + BorderRadius.only( + topLeft: Radius + .circular( + 6)), ), child: Texts( - model.parentProducts[index].rxMessage != null - ? model.parentProducts[index].rxMessage + model + .parentProducts[ + index] + .rxMessage != + null + ? model + .parentProducts[ + index] + .rxMessage : "", color: Colors.white, regular: true, fontSize: 10, - fontWeight: FontWeight.w400, + fontWeight: + FontWeight.w400, ), ), ], ), Container( - margin: EdgeInsets.symmetric( + margin: + EdgeInsets.symmetric( horizontal: 6, vertical: 0, ), child: Column( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment + .start, children: [ - if (model.parentProducts[index].discountName != null) + if (model + .parentProducts[ + index] + .discountName != + null) Container( - width: double.infinity, + width: double + .infinity, height: 13.0, - decoration: BoxDecoration( - color: Color(0xff5AB145), + decoration: + BoxDecoration( + color: Color( + 0xff5AB145), ), child: Center( child: Texts( - model.parentProducts[index].discountName, + model + .parentProducts[ + index] + .discountName, regular: true, - color: Colors.white, - fontSize: 10.4, + color: Colors + .white, + fontSize: + 10.4, ), ), ), Texts( - projectViewModel.isArabic - ? model.parentProducts[index].namen - : model.parentProducts[index].name, + projectViewModel + .isArabic + ? model + .parentProducts[ + index] + .namen + : model + .parentProducts[ + index] + .name, regular: true, fontSize: 12, - fontWeight: FontWeight.w700, + fontWeight: + FontWeight.w700, ), Padding( - padding: const EdgeInsets.only(top: 4, bottom: 4), + padding: + const EdgeInsets + .only( + top: 4, + bottom: 4), child: Texts( "SAR ${model.parentProducts[index].price}", bold: true, @@ -705,22 +941,25 @@ class _ParentCategorisePageState extends State { Row( children: [ StarRating( - totalAverage: - model.parentProducts[index].approvedRatingSum > 0 - ? (model.parentProducts[index] - .approvedRatingSum - .toDouble() / - model.parentProducts[index] - .approvedRatingSum - .toDouble()) - .toDouble() - : 0, - forceStars: true), + totalAverage: model + .parentProducts[ + index] + .approvedRatingSum > + 0 + ? (model.parentProducts[index].approvedRatingSum.toDouble() / + model.parentProducts[index].approvedRatingSum + .toDouble()) + .toDouble() + : 0, + forceStars: + true), Texts( "(${model.parentProducts[index].approvedTotalReviews})", regular: true, fontSize: 10, - fontWeight: FontWeight.w400, + fontWeight: + FontWeight + .w400, ) ], ), @@ -735,7 +974,9 @@ class _ParentCategorisePageState extends State { Navigator.push( context, FadePage( - page: ProductDetailPage(model.parentProducts[index]), + page: ProductDetailPage( + model.parentProducts[ + index]), )), }, )); @@ -743,11 +984,14 @@ class _ParentCategorisePageState extends State { ), ) : Container( - height: model.parentProducts.length * MediaQuery.of(context).size.height * 0.122, + height: model.parentProducts.length * + MediaQuery.of(context).size.height * + 0.122, child: ListView.builder( physics: NeverScrollableScrollPhysics(), itemCount: model.parentProducts.length, - itemBuilder: (BuildContext context, int index) { + itemBuilder: + (BuildContext context, int index) { return InkWell( child: Card( child: Row( @@ -757,9 +1001,11 @@ class _ParentCategorisePageState extends State { Column( children: [ Container( - decoration: BoxDecoration(), + decoration: + BoxDecoration(), child: Padding( - padding: EdgeInsets.only( + padding: + EdgeInsets.only( left: 9.0, top: 8.0, right: 10.0, @@ -767,11 +1013,22 @@ class _ParentCategorisePageState extends State { ), ), Container( - margin: EdgeInsets.fromLTRB(0, 0, 0, 0), - alignment: Alignment.center, + margin: EdgeInsets + .fromLTRB( + 0, 0, 0, 0), + alignment: + Alignment.center, child: Image.network( - model.parentProducts[index].images.isNotEmpty - ? model.parentProducts[index].images[0].thumb + model + .parentProducts[ + index] + .images + .isNotEmpty + ? model + .parentProducts[ + index] + .images[0] + .thumb : 'https://upload.wikimedia.org/wikipedia/commons/thumb/6/6c/No_image_3x4.svg/1200px-No_image_3x4.svg.png', fit: BoxFit.contain, height: 80, @@ -782,23 +1039,45 @@ class _ParentCategorisePageState extends State { Column( children: [ Container( - width: model.parentProducts[index].rxMessage != null - ? MediaQuery.of(context).size.width / 5 + width: model + .parentProducts[ + index] + .rxMessage != + null + ? MediaQuery.of( + context) + .size + .width / + 5.3 : 0, - padding: EdgeInsets.all(4), - decoration: BoxDecoration( - color: Color(0xffb23838), + padding: + EdgeInsets.all(4), + decoration: + BoxDecoration( + color: Color( + 0xffb23838), borderRadius: - BorderRadius.only(topLeft: Radius.circular(6)), + BorderRadius.only( + topLeft: Radius + .circular( + 6)), ), child: Texts( - model.parentProducts[index].rxMessage != null - ? model.parentProducts[index].rxMessage + model + .parentProducts[ + index] + .rxMessage != + null + ? model + .parentProducts[ + index] + .rxMessage : "", color: Colors.white, regular: true, fontSize: 10, - fontWeight: FontWeight.w400, + fontWeight: + FontWeight.w400, ), ), ], @@ -811,21 +1090,37 @@ class _ParentCategorisePageState extends State { vertical: 0, ), child: Column( - mainAxisAlignment: MainAxisAlignment.spaceAround, - crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: + MainAxisAlignment + .spaceAround, + crossAxisAlignment: + CrossAxisAlignment + .start, children: [ SizedBox( height: 4.0, ), Container( - width: MediaQuery.of(context).size.width * 0.65, + width: MediaQuery.of( + context) + .size + .width * + 0.65, child: Texts( - projectViewModel.isArabic - ? model.parentProducts[index].namen - : model.parentProducts[index].name, + projectViewModel + .isArabic + ? model + .parentProducts[ + index] + .namen + : model + .parentProducts[ + index] + .name, regular: true, fontSize: 13.2, - fontWeight: FontWeight.w500, + fontWeight: + FontWeight.w500, maxLines: 5, ), ), @@ -833,7 +1128,10 @@ class _ParentCategorisePageState extends State { height: 8.0, ), Padding( - padding: const EdgeInsets.only(top: 4, bottom: 4), + padding: + const EdgeInsets + .only( + top: 4, bottom: 4), child: Texts( "SAR ${model.parentProducts[index].price}", bold: true, @@ -843,27 +1141,56 @@ class _ParentCategorisePageState extends State { Row( children: [ StarRating( - totalAverage: - model.parentProducts[index].approvedRatingSum > 0 - ? (model.parentProducts[index].approvedRatingSum - .toDouble() / - model.parentProducts[index] - .approvedRatingSum - .toDouble()) - .toDouble() - : 0, + totalAverage: model + .parentProducts[ + index] + .approvedRatingSum > + 0 + ? (model.parentProducts[index].approvedRatingSum + .toDouble() / + model + .parentProducts[index] + .approvedRatingSum + .toDouble()) + .toDouble() + : 0, forceStars: true), Texts( "(${model.parentProducts[index].approvedTotalReviews})", regular: true, fontSize: 10, - fontWeight: FontWeight.w400, + fontWeight: + FontWeight.w400, ) ], ), ], ), ), + + widget.authenticatedUserObject.isLogin ? + Container( + child: IconButton( + icon: Icon(Icons.shopping_cart, + size: 18, + color: Colors.blue,), + onPressed: () async { + GifLoaderDialogUtils.showMyDialog(context); + if(model.parentProducts[index].rxMessage == null){ + await addToCartFunction(1, model.parentProducts[index].id); + Navigator.push( + context, + FadePage(page: CartOrderPage()), + ); + } + else{ + AppToast.showErrorToast(message: TranslationBase.of(context).needPrescription); + } + GifLoaderDialogUtils.hideDialog(context); + } + + ), + ): Container(), ], ), ), @@ -871,7 +1198,8 @@ class _ParentCategorisePageState extends State { Navigator.push( context, FadePage( - page: ProductDetailPage(model.parentProducts[index]), + page: ProductDetailPage(model + .parentProducts[index]), )), }, ); @@ -910,10 +1238,18 @@ class _ParentCategorisePageState extends State { ), ), )); + + + } + + addToCartFunction(quantity, itemID) async { + ProductDetailViewModel x = new ProductDetailViewModel(); + await x.addToCartData(quantity, itemID); } bool isEntityListSelected(CategoriseParentModel masterKey) { - Iterable history = entityList.where((element) => masterKey.id == element.id); + Iterable history = + entityList.where((element) => masterKey.id == element.id); if (history.length > 0) { return true; } @@ -921,10 +1257,14 @@ class _ParentCategorisePageState extends State { } bool isEntityListSelectedBrands(CategoriseParentModel masterKey) { - Iterable history = entityListBrands.where((element) => masterKey.id == element.id); + Iterable history = + entityListBrands.where((element) => masterKey.id == element.id); if (history.length > 0) { return true; } return false; } + + + } diff --git a/lib/pages/pharmacies/ProductCheckTypeWidget.dart b/lib/pages/pharmacies/ProductCheckTypeWidget.dart index edecff62..aac971a0 100644 --- a/lib/pages/pharmacies/ProductCheckTypeWidget.dart +++ b/lib/pages/pharmacies/ProductCheckTypeWidget.dart @@ -1,113 +1,58 @@ -import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; -import 'package:diplomaticquarterapp/pages/pharmacies/wishlist.dart'; -import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart'; +import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/wishlist_view_model.dart'; +import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/widgets/pharmacy/product_tile.dart'; import 'package:flutter/material.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/product_detail_view_model.dart'; import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; -import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/wishlist_view_model.dart'; -import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; - -AppSharedPreferences sharedPref = AppSharedPreferences(); -var languageID; +import 'package:provider/provider.dart'; class ProductCheckTypeWidget extends StatefulWidget { - final List wishlist; - final bool isTrue; + final WishListViewModel model; - ProductCheckTypeWidget(this.isTrue, this.wishlist); + ProductCheckTypeWidget({this.model}); @override _ProductCheckTypeWidgetState createState() => _ProductCheckTypeWidgetState(); } class _ProductCheckTypeWidgetState extends State { - void initState() { - getLanguageID(); - } @override Widget build(BuildContext context) { - return widget.isTrue - ? ListView.builder( - itemCount: widget.wishlist.length, - itemBuilder: (BuildContext context, int index) { - return Column( - children: [ - Container( - child: widget.isTrue - ? productTile( - productName: languageID == 'ar' - ? widget.wishlist[index].product.namen - : widget.wishlist[index].product.name, - productPrice: widget.wishlist[index].subtotal, - productRate: double.parse( - widget.wishlist[index].subtotalVatRate), - productImage: - widget.wishlist[index].product.images[0].src, - showLine: widget.isTrue, - productID: widget.wishlist[index].product.id, - onDelete: deleteWishListItem, - - ) - : productTile( - productName: languageID == 'ar' - ? widget.wishlist[index].product.namen - : widget.wishlist[index].product.name, - productPrice: widget.wishlist[index].subtotal, - productRate: double.parse( - widget.wishlist[index].subtotalVatRate), - productImage: - widget.wishlist[index].product.images[0].src, - showLine: widget.isTrue, - onDelete: deleteWishListItem, - - ), - ), - Divider(height: 1, color: Colors.grey) - ], - ); - }) - : GridView.count( - crossAxisCount: 2, - children: List.generate( - widget.wishlist.length, - (index) => productTile( - productName: widget.wishlist[index].product.name, - productPrice: widget.wishlist[index].subtotal, - productRate: - double.parse(widget.wishlist[index].subtotalVatRate), - productImage: - widget.wishlist[index].product.images[0].src, - showLine: widget.isTrue, - )), + ProjectViewModel projectViewModel = Provider.of(context); + return ListView.builder( + itemCount: widget.model.wishListList.length, + itemBuilder: (BuildContext context, int index) { + return Column( + children: [ + Container( + child: productTile( + productName: projectViewModel.isArabic + ? widget.model.wishListList[index].product.namen + : widget.model.wishListList[index].product.name, + productPrice: widget.model.wishListList[index].subtotal, + productRate: double.parse(widget.model.wishListList[index].subtotalVatRate), + productImage: widget.model.wishListList[index].product.images[0].src, + productID: widget.model.wishListList[index].product.id, + onDelete: deleteWishListItem, + + ), + ), + Divider(height: 1, color: Colors.grey) + ], ); + }); } deleteWishListItem(itemID) async { ProductDetailViewModel x = new ProductDetailViewModel(); GifLoaderDialogUtils.showMyDialog(context); - await x.deletWishlistData(itemID); - setState(() - async{ - await - //getWishlistData(); - Navigator.push(context, - FadePage(page: WishlistPage(false)), - ); - }); + await x.deleteWishlistData(itemID); + await widget.model.getWishlistData(isLocalLoader: true); GifLoaderDialogUtils.hideDialog(context); - print("Delete"); } - getWishlistData() async { - WishListViewModel x = new WishListViewModel(); - await x.getWishlistData(); - } } -getLanguageID() async { - languageID = await sharedPref.getString(APP_LANGUAGE); -} diff --git a/lib/pages/pharmacies/my_reviews.dart b/lib/pages/pharmacies/my_reviews.dart index 7e7e33a0..08ba3d14 100644 --- a/lib/pages/pharmacies/my_reviews.dart +++ b/lib/pages/pharmacies/my_reviews.dart @@ -44,8 +44,8 @@ class _MyReviewsPageState extends State { ), Padding( padding: const EdgeInsets.all(8.0), - child: Text( - 'There is no data', + child: Text(TranslationBase.of(context).noData, +// 'There is no data', style: TextStyle(fontSize: 30), ), ) @@ -121,7 +121,7 @@ reviewDetails(data, rate, myRate) { : data.product.name, style: TextStyle( color: Colors.black54, - fontSize: languageID == 'ar' ? 7 : 13, + fontSize: languageID == 'ar' ? 12 : 13, fontWeight: FontWeight.bold), ), ), @@ -137,7 +137,7 @@ reviewDetails(data, rate, myRate) { : Alignment.topLeft, child: RichText( text: TextSpan( - text: data.product.price.toString() + + text: data.product.quantity.toString() + " " + data.product.currency, style: TextStyle( @@ -187,7 +187,7 @@ reviewDetails(data, rate, myRate) { padding: languageID == 'ar' ? EdgeInsets.only(right: 10) : EdgeInsets.only(left: 10), - child: Text(data.createdOnUtc.toString())), + child: Text(data.createdOnUtc.toString().substring(0 , 11))), ], ), ), diff --git a/lib/pages/pharmacies/product-brands.dart b/lib/pages/pharmacies/product-brands.dart index 5ae69e84..4ff90706 100644 --- a/lib/pages/pharmacies/product-brands.dart +++ b/lib/pages/pharmacies/product-brands.dart @@ -95,7 +95,7 @@ class _ProductBrandsPageState extends State { height: 10, ), Container( - height: 290, + height: 420, width: double.infinity, color: Colors.white, child: ListView.builder( diff --git a/lib/pages/pharmacies/product_detail.dart b/lib/pages/pharmacies/product_detail.dart index 012ab7b0..e69de29b 100644 --- a/lib/pages/pharmacies/product_detail.dart +++ b/lib/pages/pharmacies/product_detail.dart @@ -1,2199 +0,0 @@ -import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; -import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart'; -import 'package:diplomaticquarterapp/core/model/pharmacies/recommendedProduct_model.dart'; -import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/pharmacy_module_view_model.dart'; -import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/product_detail_view_model.dart'; -import 'package:diplomaticquarterapp/pages/base/base_view.dart'; -import 'package:diplomaticquarterapp/pages/pharmacies/compare-list.dart'; -import 'package:diplomaticquarterapp/uitl/app_toast.dart'; -import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; -import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; -import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; -import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; -import 'package:diplomaticquarterapp/widgets/others/app_scafold_detail_page.dart'; -import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; -import 'package:flutter/material.dart'; -import 'package:font_awesome_flutter/font_awesome_flutter.dart'; -import 'package:provider/provider.dart'; -import 'package:rating_bar/rating_bar.dart'; - -import 'screens/cart-order-page.dart'; -import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart'; - -int price = 0; -dynamic languageID; -bool isOverQuantity = false; -bool isInWishlit = false; -//int isSelected = 1; -bool isSelected= true; -String itemID; -var customerId; -CompareList compareItems = new CompareList(); -PharmacyProduct specificationData; -//Products recommendedData; - -class ProductDetailPage extends StatefulWidget { - final PharmacyProduct product; -// final Products recommendedProducts; - - - ProductDetailPage(this.product ); - - - @override - __ProductDetailPageState createState() => __ProductDetailPageState(); -} - -class __ProductDetailPageState extends State { - AppSharedPreferences sharedPref = AppSharedPreferences(); - - bool isTrue = true; - bool isDetails = true; - bool isReviews = false; - bool isAvailabilty = false; - dynamic wishlistItems; - //var model; - - // String ProductId="4561"; - // String productId = ""; - getLanguageID() async { - languageID = await sharedPref.getString(APP_LANGUAGE); - } - - checkWishlist() async { - GifLoaderDialogUtils.showMyDialog(context); - ProductDetailViewModel x = new ProductDetailViewModel(); - await x.checkWishlistData(); - -// isInWishlit = x.wishListItems.map((e) => e.id.toString()).toList().contains(itemID); - - for (int i = 0; i < x.wishListItems.length; i++) { - if (itemID == x.wishListItems[i].product.id) { - isInWishlit = true; - break; - } else { - isInWishlit = false; - } - } - GifLoaderDialogUtils.hideDialog(context); - setState(() {}); - } - - - void initState() { - getLanguageID(); - price = 1; - specificationData = widget.product; - userInfo(); - super.initState(); - } - - void userInfo() async { - print(specificationData); - customerId = await sharedPref.getString(PHARMACY_CUSTOMER_ID); - if (customerId != null) { - itemID = widget.product.id; - checkWishlist(); -// getSpecificationData(itemID); - } - print("customerId:$customerId"); - - setState(() {}); -// getSpecificationData(itemID); - } - - Widget build(BuildContext context) { - return customerId != null - ? DetailPageScafold( - appBarTitle: TranslationBase.of(context).productDetails, - isShowAppBar: true, - isPharmacy: true, - isShowDecPage: false, - body: SingleChildScrollView( - child: Column( - children: [ - Container( - width: double.infinity, - color: Colors.white, - child: Column( - children: [ - Image.network( - widget.product.images[0].src.trim(), - ), - widget.product.discountDescription != null - ? Container( - width: double.infinity, - height: 50, - color: Colors.yellowAccent, - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Expanded( - flex: 1, - child: Container( - alignment: Alignment.centerRight, - child: languageID == "ar" - ? Text( - widget.product - .discountDescriptionn, - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 17), - ) - : Text( - widget.product - .discountDescription, - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 17), - ), - ), - ), - SizedBox( - width: 10, - ), - Expanded( - flex: 0, - child: Container( - child: Image( - image: AssetImage( - 'assets/images/offer.png'), - ), - ), - ), - ], - ), - ) - : Container(), - ], - ), - ), - SizedBox( - height: 4, - ), - Container( - width: 500, - height: 220, - color: Colors.white, - child: productNameAndPrice(context, widget.product), - ), - SizedBox( - height: 6, - ), - Container( - width: 500, - height: 100, - color: Colors.white, - child: Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Padding( - padding: const EdgeInsets.all(8.0), - child: Container( - child: Text( - TranslationBase.of(context).specification, - style: TextStyle(fontWeight: FontWeight.bold), - ), - ), - ), - Divider(color: Colors.grey), - Padding( - padding: const EdgeInsets.all(8.0), - child: Container( - child: Text( - TranslationBase.of(context).noData, -// "there is no data", - ), - ), - ), - ], - ), - ), - SizedBox( - height: 6, - ), - Container( - width: 500, - margin: EdgeInsets.only(bottom: 6), -// height: 350, - color: Colors.white, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Column( - children: [ - FlatButton( - onPressed: () { - setState(() { - isDetails = true; - isReviews = false; - isAvailabilty = false; - }); - }, - child: Text( - TranslationBase.of(context).details, - style: TextStyle( - fontSize: 16, - fontWeight: FontWeight.bold), - ), - color: Colors.white, - ), - isDetails - ? Container( - width: 100, - height: 5, - color: Colors.green, - ) - : Container() - ], - ), - SizedBox( - width: 20, - ), - Column( - children: [ - FlatButton( - onPressed: () { - setState(() { - isDetails = false; - isReviews = true; - isAvailabilty = false; - }); - }, - child: Text( - TranslationBase.of(context).reviews, - style: TextStyle( - fontSize: 16, - fontWeight: FontWeight.bold), - ), - color: Colors.white, - ), - isReviews - ? Container( - width: 100, - height: 5, - color: Colors.green, - ) - : Container(), - ], - ), - SizedBox( - width: 20, - ), - Column( - children: [ - FlatButton( - onPressed: () { - setState(() { - isDetails = false; - isReviews = false; - isAvailabilty = true; - }); - }, - child: Text( - TranslationBase.of(context).availability, - style: TextStyle( - fontSize: 16, - fontWeight: FontWeight.bold), - ), - color: Colors.white, - ), - isAvailabilty - ? Container( - width: 100, - height: 5, - color: Colors.green, - ) - : Container(), - ], - ), - ], - ), - SizedBox( - height: 10, - ), - isDetails - ? Padding( - padding: const EdgeInsets.all(8.0), - child: Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Container( - child: Text( - TranslationBase.of(context) - .description, - style: TextStyle( - fontSize: 17, - color: Colors.grey, - fontWeight: FontWeight.w600), - ), - ), - SizedBox( - height: 10, - ), - Divider(height: 1, color: Colors.grey), - SizedBox( - height: 15, - ), - Container( - child: Text( - languageID == "ar" - ? widget.product.fullDescriptionn - : widget.product.fullDescription ?? - "", - style: TextStyle( - fontSize: 16, - fontFamily: 'WorkSans-Regular'), - ), - ), - SizedBox( - height: 20, - ), - ]), - ) - -// Container( -// child: Text( -// languageID == 'ar' -// ? widget.product.fullDescriptionn -// : widget.product.fullDescription, -// style: TextStyle( -// fontSize: 16, -// fontFamily: 'WorkSans-Regular'), -// ), -// ), -// SizedBox( -// height: 10, -// ), -// Container( -// child: Text( -// TranslationBase.of(context).howToUse, -// style: TextStyle( -// fontSize: 17, -// color: Colors.grey, -// fontWeight: FontWeight.w600), -// ), -// ), -// SizedBox( -// height: 6, -// ), -// Divider( -// height: 2, -// color: Colors.grey), -// SizedBox( -// height: 10, -// ), -// Container( -// child: Text( -// languageID == 'ar' -// ? widget.product.shortDescriptionn -// : widget.product.shortDescription, -// style: TextStyle( -// fontSize: 16, -// fontFamily: 'WorkSans-Regular'), -// ), -// ), - // ], - // ), - // ) - : isReviews - ? BaseView( - onModelReady: (model) => - model.getProductReviewsData( - widget.product.id), - builder: (_, model, wi) => model - .productDetailService - .length != - 0 && - model.productDetailService[0] - .reviews.length != - 0 - ? ListView.builder( - physics: ScrollPhysics(), - itemCount: model - .productDetailService[0] - .reviews - .length, - scrollDirection: Axis.vertical, - shrinkWrap: true, - itemBuilder: (BuildContext context, - int index) { - return Padding( - padding: EdgeInsets.all(8.0), - child: Column( - mainAxisAlignment: - MainAxisAlignment.start, - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Container( - child: Row( - children: [ - Container( - child: Text( - model - .productDetailService[ - 0] - .reviews[ - index] - .customerId - .toString(), - style: TextStyle( - fontSize: 17, - color: Colors - .grey, - fontWeight: - FontWeight - .w600), - ), - ), - Container( - margin: - EdgeInsets.only( - left: 210), - child: RatingBar - .readOnly( - initialRating: model - .productDetailService[ - 0] - .reviews[ - index] - .rating - .toDouble(), - size: 15.0, - filledColor: - Colors.yellow[ - 700], - emptyColor: Colors - .grey[500], - isHalfAllowed: - true, - halfFilledIcon: - Icons - .star_half, - filledIcon: - Icons.star, - emptyIcon: - Icons.star, - ), - ), - ], - ), - ), - SizedBox( - height: 10, - ), - Container( - child: Text( - model - .productDetailService[ - 0] - .reviews[index] - .reviewText, - style: TextStyle( - fontSize: 20), - ), - ), - SizedBox( - height: 50, - ), - Divider( - height: 1, - color: Colors.grey), - ], - ), - ); - }, - ) - : Container( - padding: EdgeInsets.all(15), - alignment: Alignment.center, - child: Text(TranslationBase.of(context).noReviewsAvailable,), -// Text('No Reviews Available'), - ), - ) - : isAvailabilty - ? BaseView( - onModelReady: (model) => - model.getProductLocationData(), - builder: (_, model, wi) => model - .productLocationService - .length == - 0 - ? Container( - padding: EdgeInsets.all(15), - alignment: Alignment.center, - child: Text(TranslationBase.of(context).noLocationAvailable,), -// Text('No location Available'), - ) - : ListView.builder( - physics: ScrollPhysics(), - scrollDirection: Axis.vertical, - shrinkWrap: true, - itemCount: model - .productLocationService - .length, - itemBuilder: - (BuildContext context, - int index) { - return Padding( - padding: - EdgeInsets.all(8.0), - child: Column( -// crossAxisAlignment: CrossAxisAlignment.start, -// mainAxisAlignment: MainAxisAlignment.start, - children: [ - Row( -// crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: - MainAxisAlignment - .start, - children: [ - Expanded( - flex: 1, - child: Image.network(model - .productLocationService[ - index] - .projectImageUrl), - ), - SizedBox( - width: 10, - ), - Expanded( - flex: 4, - child: Text( - model - .productLocationService[ - index] - .locationDescription + - "\n" + - fixingString(model - .productLocationService[ - 0] - .cityName - .toString()), - style: TextStyle( - fontSize: - 12), - ), - ), - Expanded( - flex: 1, - child: IconButton( - icon: Icon(Icons - .location_on), - color: - Colors.red, - onPressed: - () {}, - ), - ), - Expanded( - flex: 1, - child: IconButton( - icon: Icon(Icons - .phone), - color: - Colors.red, - onPressed: - () {}, - ), - ), - ], - ), - Divider( - height: 1.2, - color: Colors.grey) - ], - ), - ); - }, - ), - ) - : Container(), - ], - ), - ), - Row( - children: [ - customerId != null ? Container( - width: 410, - height: 50, - // margin: EdgeInsets.only(bottom: 5), - color: Colors.white, - child: Texts( - TranslationBase.of(context).recommended, - bold: true, - ), - ) - : Container(), - ], - ), - SingleChildScrollView( - child: Container( - width: 410, - color: Colors.white, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - // mainAxisAlignment: MainAxisAlignment.start, -// mainAxisSize: MainAxisSize.min, - children: [ - Container( - color: Colors.white, - height: 210, - margin: EdgeInsets.only(bottom: 75), - padding: EdgeInsets.only(bottom: 5), - // margin: EdgeInsets.symmetric(horizontal: 6, vertical: 4), - child: BaseView( - - onModelReady: (model) => model.getRecommendedProducts(widget.product.id), - builder: (_, model, wi) => Container( - child: - model.recommendedProductList.length != null - ? Expanded( - child: ListView.builder( - scrollDirection: - Axis.horizontal, - shrinkWrap: true, - physics: ScrollPhysics(), - // physics: NeverScrollableScrollPhysics(), - itemCount: model.recommendedProductList.length, - itemBuilder: (context, index) { - return InkWell( - onTap: () - async { - GifLoaderDialogUtils.showMyDialog(context); - RecommendedProductModel data = model.recommendedProductList[index]; - var json = data.toJson(); - PharmacyProduct product = new PharmacyProduct.fromJson(json); - await Navigator.pushReplacement( - context, - FadePage( - page: ProductDetailPage(product), - )); - GifLoaderDialogUtils.hideDialog(context); - }, - child: Card( - elevation: 2, - shape: RoundedRectangleBorder( - side: BorderSide( - color: Colors.grey[300], - width: 2), - borderRadius: BorderRadius.circular(10)), - margin: EdgeInsets.symmetric( - horizontal: 8, - vertical: 0, - ), - child: Container( - decoration: BoxDecoration( - borderRadius: BorderRadius.all(Radius.circular(15), - ), - ), - padding: EdgeInsets.symmetric(horizontal: 4), - width: MediaQuery.of(context).size.width / 3, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Stack( - children: [ - Container( - child: Align( - alignment: Alignment.topRight, - child: IconButton( - icon: Icon(model.recommendedProductList[index].isinwishlist != true ? Icons.favorite_border : Icons.favorite), - color: model.recommendedProductList[index].isinwishlist != true ? Colors.grey : Colors.red, - onPressed: () async { - - if (customerId != null ) { - if (!isInWishlit && model.recommendedProductList[index].isinwishlist != true) { - GifLoaderDialogUtils.showMyDialog(context); - await addToWishlistFunction(model.recommendedProductList[index].id); -// checkWishlist(); - GifLoaderDialogUtils.hideDialog(context); - setState((){ - model.recommendedProductList[index].isinwishlist= true; - }); - - } else { - GifLoaderDialogUtils.showMyDialog(context); - await deleteFromWishlistFunction(model.recommendedProductList[index].id); - GifLoaderDialogUtils.hideDialog(context); - setState((){ - model.recommendedProductList[index].isinwishlist = false; - }); - } - } else { - return ; - } - setState(() { - // checkWishlist(); - }); - }, - )), - -// child: Align( -// alignment: Alignment.topRight, -// child:itemID.contains(model.recommendedProductList[index]['id']) -// // !isInWishlist -// ? IconButton( -// icon: Icon(Icons.favorite_border), -// color: Colors.grey, -// iconSize: 30, -// onPressed: () { -// setState(() { -// if (customerId != null && isInWishlit ) { -// deleteFromWishlistFunction( -// model.recommendedProductList[index].id); -// } }); -// }, -// ) -// : IconButton( -// icon: Icon(Icons.favorite), -// color: Colors.red, -// iconSize: 30, -// onPressed: () { -// setState(() { -// if (customerId != null && !isInWishlit ) { -// addToWishlistFunction( -// model.recommendedProductList[index].id); -// } }); -// }, -// ) -// ), - ), - - Container( - margin: EdgeInsets.fromLTRB( - 0, - 16, - 10, - 16), - alignment: - Alignment.center, -// padding: EdgeInsets.only(left: 25, bottom: 20), - child: (model.recommendedProductList[index].images != null && - model.recommendedProductList[index].images.length > 0) - ? Image.network( - model.recommendedProductList[index].images[0].src.toString(), -// item.images[0].src, - fit: BoxFit.cover, - height: 60, - ) - : Image.asset( - "assets/images/no_image.png", - fit: BoxFit.cover, - height: 60, - ), - ), - Container( - width: model.recommendedProductList[index].rxMessage != - null - ? MediaQuery.of(context).size.width / - 5 - : 0, - padding: - EdgeInsets.all(4), - decoration: - BoxDecoration( - color: - Color(0xffb23838), - borderRadius: - BorderRadius.only(topLeft: Radius.circular(6)), - ), - child: model.recommendedProductList[index].rxMessage != null - ? Texts( - languageID == "ar" - ? model.recommendedProductList[index].rxMessagen - : model.recommendedProductList[index].rxMessage, - color: Colors.white, - regular: true, - fontSize: 10, - fontWeight: FontWeight.w400, - ):Texts (""), - ), - ]), - Container( - margin: EdgeInsets - .symmetric( - horizontal: - 6, - vertical: 0, - ), - child: Column( - crossAxisAlignment: - CrossAxisAlignment - .start, - children: [ - Text( - languageID == "ar" - ? model.recommendedProductList[index].namen - : model.recommendedProductList[index].name, - style: - TextStyle( - color: - Colors.black, - fontSize: - 13.0, -// fontWeight: FontWeight.bold, - ), - ), - Padding( -// padding: const EdgeInsets.only(top: 15, bottom: 10), - padding: const EdgeInsets.only( - top: - 10, - bottom: - 5), - child: - Texts( - "SAR ${model.recommendedProductList[index].price}", - bold: - true, - fontSize: - 14, - ), - ), - ], - ), - ), - Row( - crossAxisAlignment: - CrossAxisAlignment - .start, - children: < - Widget>[ - Container( - padding: - EdgeInsets.only(right: 10), -// margin: EdgeInsets.only(left: 5), - child: - Align( - alignment: - Alignment.topLeft, - child: - RatingBar.readOnly( - initialRating: model.recommendedProductList[index].approvedRatingSum.toDouble(), -// initialRating: productRate, - size: - 13.0, - filledColor: - Colors.yellow[700], - emptyColor: - Colors.grey[500], - isHalfAllowed: - true, - halfFilledIcon: - Icons.star_half, - filledIcon: - Icons.star, - emptyIcon: - Icons.star, - ), - ), - ), - Texts( - "(${model.recommendedProductList[index].notApprovedTotalReviews.toString()})", -// bold: true, - fontSize: - 12, - ), - ]), - ], - ), - ), - ), - ); - }), - ) - : Container( - // color: Colors.white, - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - // crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Texts(TranslationBase.of(context).nonRecommended, - color: Colors.black,), - ], - ), - ), - )), - ), - ], - ), - ), - ) - ], - ), - ), - bottomSheet: footerWidget( - widget.product.stockAvailability != 'Out of stock', - widget.product.orderMaximumQuantity, - widget.product.orderMinimumQuantity, - widget.product.stockQuantity, - widget.product), - ) - : AppScaffold( - appBarTitle: TranslationBase.of(context).productDetails, - isShowAppBar: true, - isPharmacy: true, - isShowDecPage: false, - body: SingleChildScrollView( - child: Column( - children: [ - Container( - width: double.infinity, - color: Colors.white, - child: Column( - children: [ - Image.network( - widget.product.images[0].src.trim(), - ), - widget.product.discountDescription != null - ? Container( - width: double.infinity, - height: 50, - color: Colors.yellowAccent, - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Expanded( - flex: 1, - child: Container( - alignment: Alignment.centerRight, - child: languageID == 'ar' - ? Text( - widget.product - .discountDescriptionn, - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 17), - ) - : Text( - widget.product - .discountDescription, - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 17), - ), - ), - ), - SizedBox( - width: 10, - ), - Expanded( - flex: 0, - child: Container( - child: Image( - image: AssetImage( - 'assets/images/offer.png'), - ), - ), - ), - ], - ), - ) - : Container(), - ], - ), - ), - SizedBox( - height: 4, - ), - Container( - width: 500, - height: 150, - color: Colors.white, - child: productNameAndPrice(context, widget.product), - ), - SizedBox( - height: 6, - ), - Container( - width: 500, - height: 120, - color: Colors.white, - child: Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Padding( - padding: const EdgeInsets.all(8.0), - child: Container( - child: Text( - TranslationBase.of(context).specification, - style: TextStyle(fontWeight: FontWeight.bold), - ), - ), - ), - Divider(color: Colors.grey) - ], - ), - ), - SizedBox( - height: 6, - ), - Container( - width: 500, - margin: EdgeInsets.only(bottom: 100), -// height: 350, - color: Colors.white, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Column( - children: [ - FlatButton( - onPressed: () { - setState(() { - isDetails = true; - isReviews = false; - isAvailabilty = false; - }); - }, - child: Text( - TranslationBase.of(context).details, - style: TextStyle( - fontSize: 16, - fontWeight: FontWeight.bold), - ), - color: Colors.white, - ), - isDetails - ? Container( - width: 100, - height: 5, - color: Colors.green, - ) - : Container() - ], - ), - SizedBox( - width: 20, - ), - Column( - children: [ - FlatButton( - onPressed: () { - setState(() { - isDetails = false; - isReviews = true; - isAvailabilty = false; - }); - }, - child: Text( - TranslationBase.of(context).reviews, - style: TextStyle( - fontSize: 16, - fontWeight: FontWeight.bold), - ), - color: Colors.white, - ), - isReviews - ? Container( - width: 100, - height: 5, - color: Colors.green, - ) - : Container(), - ], - ), - SizedBox( - width: 20, - ), - Column( - children: [ - FlatButton( - onPressed: () { - setState(() { - isDetails = false; - isReviews = false; - isAvailabilty = true; - }); - }, - child: Text( - TranslationBase.of(context).availability, - style: TextStyle( - fontSize: 16, - fontWeight: FontWeight.bold), - ), - color: Colors.white, - ), - isAvailabilty - ? Container( - width: 100, - height: 5, - color: Colors.green, - ) - : Container(), - ], - ), - ], - ), - SizedBox( - height: 10, - ), - isDetails - ? Padding( - padding: const EdgeInsets.all(8.0), - child: Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Container( - child: Text( - TranslationBase.of(context).description, - style: TextStyle( - fontSize: 17, - color: Colors.grey, - fontWeight: FontWeight.w600), - ), - ), - SizedBox( - height: 6, - ), - Divider(height: 1, color: Colors.grey), - SizedBox( - height: 10, - ), - Container( - child: Text( - languageID == 'ar' - ? widget.product.shortDescriptionn - : widget.product.shortDescription, - style: TextStyle( - fontSize: 16, - fontFamily: 'WorkSans-Regular'), - ), - ), - SizedBox( - height: 10, - ), - Container( - child: Text( - TranslationBase.of(context).howToUse, - style: TextStyle( - fontSize: 17, - color: Colors.grey, - fontWeight: FontWeight.w600), - ), - ), - SizedBox( - height: 6, - ), - Divider(height: 2, color: Colors.grey), - SizedBox( - height: 10, - ), - Container( - child: Text( - languageID == 'ar' - ? widget.product.fullDescriptionn - : widget.product.fullDescription, - style: TextStyle( - fontSize: 16, - fontFamily: 'WorkSans-Regular'), - ), - ), - ], - ), - ) - : isReviews - ? BaseView( - onModelReady: (model) => - model.getProductReviewsData( - widget.product.id), - builder: (_, model, wi) => model - .productDetailService - .length != - 0 && - model.productDetailService[0] - .reviews.length != - 0 - ? ListView.builder( - physics: ScrollPhysics(), - itemCount: model - .productDetailService[0] - .reviews - .length, - scrollDirection: Axis.vertical, - shrinkWrap: true, - itemBuilder: (BuildContext context, - int index) { - return Padding( - padding: EdgeInsets.all(8.0), - child: Column( - mainAxisAlignment: - MainAxisAlignment.start, - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Container( - child: Row( - children: [ - Container( - child: Text( - model - .productDetailService[ - 0] - .reviews[ - index] - .customerId - .toString(), - style: TextStyle( - fontSize: 17, - color: Colors - .grey, - fontWeight: - FontWeight - .w600), - ), - ), - Container( - margin: - EdgeInsets.only( - left: 210), - child: RatingBar - .readOnly( - initialRating: model - .productDetailService[ - 0] - .reviews[ - index] - .rating - .toDouble(), - size: 15.0, - filledColor: - Colors.yellow[ - 700], - emptyColor: Colors - .grey[500], - isHalfAllowed: - true, - halfFilledIcon: - Icons - .star_half, - filledIcon: - Icons.star, - emptyIcon: - Icons.star, - ), - ), - ], - ), - ), - SizedBox( - height: 10, - ), - Container( - child: Text( - model - .productDetailService[ - 0] - .reviews[index] - .reviewText, - style: TextStyle( - fontSize: 20), - ), - ), - SizedBox( - height: 50, - ), - Divider( - height: 1, - color: Colors.grey), - ], - ), - ); - }, - ) - : Container( - padding: EdgeInsets.all(15), - alignment: Alignment.center, - child: Text(TranslationBase.of(context).noReviewsAvailable), -// Text('No Reviews Available'), - ), - ) - : isAvailabilty - ? BaseView( - onModelReady: (model) => - model.getProductLocationData(), - builder: (_, model, wi) => - ListView.builder( - physics: ScrollPhysics(), - scrollDirection: Axis.vertical, - shrinkWrap: true, - itemCount: model - .productLocationService.length, - itemBuilder: (BuildContext context, - int index) { - return Padding( - padding: EdgeInsets.all(8.0), - child: Column( -// crossAxisAlignment: CrossAxisAlignment.start, -// mainAxisAlignment: MainAxisAlignment.start, - children: [ - Row( -// crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: - MainAxisAlignment.start, - children: [ - Expanded( - flex: 1, - child: Image.network(model - .productLocationService[ - index] - .projectImageUrl), - ), - SizedBox( - width: 10, - ), - Expanded( - flex: 4, - child: Text( - model - .productLocationService[ - index] - .locationDescription + - "\n" + - fixingString(model - .productLocationService[ - 0] - .cityName - .toString()), - style: TextStyle( - fontSize: 12), - ), - ), - Expanded( - flex: 1, - child: IconButton( - icon: Icon(Icons - .location_on), - color: Colors.red, - onPressed: () {}, - ), - ), - Expanded( - flex: 1, - child: IconButton( - icon: - Icon(Icons.phone), - color: Colors.red, - onPressed: () {}, - ), - ), - ], - ), - Divider( - height: 1.2, - color: Colors.grey) - ], - ), - ); - }, - ), - ) - : Container(), - ], - ), - ), -// ListView(scrollDirection: Axis.vertical, shrinkWrap: true, children: [Text('ENAD')]), - ], - ), - ), - bottomSheet: footerWidget( - widget.product.stockAvailability != 'Out of stock', - widget.product.orderMaximumQuantity, - widget.product.orderMinimumQuantity, - widget.product.stockQuantity, - widget.product), - ); - } -} - -class footerWidget extends StatefulWidget { - final bool isAvailble; - final int maxQuantity; - final int minQuantity; - final int quantityLimit; - final PharmacyProduct item; - - footerWidget(this.isAvailble, this.maxQuantity, this.minQuantity, - this.quantityLimit, this.item); - - @override - _footerWidgetState createState() => _footerWidgetState(); -} - -class _footerWidgetState extends State { - double quantityUI = 70; - bool showUI = false; - - @override - Widget build(BuildContext context) { - return Container( - width: double.infinity, - height: quantityUI, - color: Colors.white, - child: Column( - children: [ - showUI - ? Container( - width: double.infinity, - height: 90, - color: Colors.white, - child: Container( - child: Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Padding( - padding: const EdgeInsets.all(8.0), - child: Text( - TranslationBase.of(context).quantity, - style: TextStyle( - fontSize: 15, fontWeight: FontWeight.bold), - ), - ), -// ListView( -// scrollDirection: Axis.horizontal, -// children: [ -// itemQuantity(), -// ], -// ), - Container( -// margin: EdgeInsets.symmetric(vertical: 20.0), - height: 50.0, - child: ListView( - scrollDirection: Axis.horizontal, - children: [ - InkWell( - child: Container( - alignment: Alignment.center, - width: 50.0, - color: Colors.white, - child: Text( - '1', - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 20), - ), - ), - onTap: () { - setState(() { - price = 1; - if (price >= widget.quantityLimit) { - isOverQuantity = true; - } else { - isOverQuantity = false; - return price; - } - }); - }, - ), - SizedBox( - width: 5, - ), - InkWell( - child: Container( - alignment: Alignment.center, - width: 50.0, - color: Colors.white, - child: Text( - '2', - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 20), - ), - ), - onTap: () { - setState(() { - price = 2; - if (price >= widget.quantityLimit) { - isOverQuantity = true; - } else { - isOverQuantity = false; - return price; - } - }); - }, - ), - SizedBox( - width: 5, - ), - InkWell( - child: Container( - alignment: Alignment.center, - width: 50.0, - color: Colors.white, - child: Text( - '3', - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 20), - ), - ), - onTap: () { - setState(() { - price = 3; - if (price >= widget.quantityLimit) { - isOverQuantity = true; - } else { - isOverQuantity = false; - return price; - } - }); - }, - ), - SizedBox( - width: 5, - ), - InkWell( - child: Container( - alignment: Alignment.center, - width: 50.0, - color: Colors.white, - child: Text( - '4', - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 20), - ), - ), - onTap: () { - setState(() { - price = 4; - if (price >= widget.quantityLimit) { - isOverQuantity = true; - } else { - isOverQuantity = false; - return price; - } - }); - }, - ), - SizedBox( - width: 5, - ), - InkWell( - child: Container( - alignment: Alignment.center, - width: 50.0, - color: Colors.white, - child: Text( - '5', - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 20), - ), - ), - onTap: () { - setState(() { - price = 5; - if (price >= widget.quantityLimit) { - isOverQuantity = true; - } else { - isOverQuantity = false; - return price; - } - }); - }, - ), - SizedBox( - width: 5, - ), - InkWell( - child: Container( - alignment: Alignment.center, - width: 50.0, - color: Colors.white, - child: Text( - '6', - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 20), - ), - ), - onTap: () { - setState(() { - price = 6; - if (price >= widget.quantityLimit) { - isOverQuantity = true; - } else { - isOverQuantity = false; - return price; - } - }); - }, - ), - SizedBox( - width: 5, - ), - InkWell( - child: Container( - alignment: Alignment.center, - width: 50.0, - color: Colors.white, - child: Text( - '7', - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 20), - ), - ), - onTap: () { - setState(() { - price = 7; - if (price >= widget.quantityLimit) { - isOverQuantity = true; - } else { - isOverQuantity = false; - return price; - } - }); - }, - ), - SizedBox( - width: 5, - ), - InkWell( - child: Container( - alignment: Alignment.center, - width: 50.0, - color: Colors.white, - child: Text( - '8', - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 20), - ), - ), - onTap: () { - setState(() { - price = 8; - if (price >= widget.quantityLimit) { - isOverQuantity = true; - } else { - isOverQuantity = false; - return price; - } - }); - }, - ), - SizedBox( - width: 5, - ), - InkWell( - child: Container( - alignment: Alignment.center, - width: 50.0, - color: Colors.white, - child: Text( - '9', - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 20), - ), - ), - onTap: () { - setState(() { - price = 9; - if (price >= widget.quantityLimit) { - isOverQuantity = true; - } else { - isOverQuantity = false; - return price; - } - }); - }, - ), - SizedBox( - width: 5, - ), - InkWell( - child: Container( - alignment: Alignment.center, - width: 50.0, - color: Colors.white, - child: Text( - '10', - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 20), - ), - ), - onTap: () { - setState(() { - price = 10; - if (price >= widget.quantityLimit) { - isOverQuantity = true; - } else { - isOverQuantity = false; - return price; - } - }); - }, - ), - SizedBox( - width: 5, - ), - Container( - width: 50.0, - child: TextField( - decoration: - InputDecoration(labelText: 'quantity #'), - onChanged: (text) { - print(price); - print(widget.quantityLimit); - if (int.tryParse(text) == null) { - text = ''; - } else { - setState(() { - price = int.parse(text); - if (price >= widget.quantityLimit) { - isOverQuantity = true; - } else { - isOverQuantity = false; - } - }); - } - }, - ), - ), - ], - ), - ) - ], - ), - ), - ) - : Container( - height: 20, - ), - Row( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Container( - width: 70, - height: 50, - child: FlatButton( - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Expanded( - flex: 4, - child: Text( - price.toString(), - style: TextStyle(fontSize: 20), - ), - ), - Expanded( - flex: 5, - child: Text( - TranslationBase.of(context).quantityShortcut, - style: TextStyle(fontSize: 16), - ), - ), - ], - ), - onPressed: () { - setState(() { - if (showUI) { - quantityUI = 70; - showUI = false; - } else { - quantityUI = 150; - showUI = true; - } - }); - }, - ), - ), - !widget.isAvailble && price > 0 || - price > widget.quantityLimit || - widget.item.rxMessage != null - ? Container( - width: 190, - height: 46, - color: Colors.grey, - child: Align( - alignment: Alignment.center, - child: Text( - TranslationBase.of(context).addToCart, - style: TextStyle( - color: Colors.white, - fontWeight: FontWeight.bold, - fontSize: 15), - ), - ), - ) - : InkWell( - onTap: () { - addToCartFunction(price, widget.item.id, context); - }, - child: Container( - alignment: Alignment.center, - width: 190, - height: 46, - color: Colors.green, - child: Text( - TranslationBase.of(context).addToCart, - style: TextStyle( - color: Colors.white, - fontWeight: FontWeight.bold, - fontSize: 15), - ), - ), - ), - SizedBox( - width: 5, - ), - !widget.isAvailble && price > 0 || - price > widget.quantityLimit || - widget.item.rxMessage != null - ? Container( - width: 120, - height: 46, - color: Colors.grey, - child: Align( - alignment: Alignment.center, - child: Text( - TranslationBase.of(context).buyNow, - style: TextStyle( - color: Colors.white, - fontWeight: FontWeight.bold, - fontSize: 15), - ), - ), - ) - : InkWell( - onTap: () { - print('buy now'); - addToCartFunction(price, widget.item.id, context); - Navigator.push( - context, - FadePage(page: CartOrderPage()), - ); - }, - child: Container( - alignment: Alignment.center, - width: 120, - height: 46, - color: Colors.blue, - child: Text( - TranslationBase.of(context).buyNow, - style: TextStyle( - color: Colors.white, - fontWeight: FontWeight.bold, - fontSize: 15), - ), - ), - ), - ], - ), - ], - ), - ); - } -} - -class productNameAndPrice extends StatefulWidget { - BuildContext context; - PharmacyProduct item; - - productNameAndPrice(this.context, this.item); - - @override - _productNameAndPriceState createState() => _productNameAndPriceState(); -} - -class _productNameAndPriceState extends State { - @override - Widget build(BuildContext context) { - return Column( - mainAxisAlignment: MainAxisAlignment.start, - children: [ - Padding( - padding: const EdgeInsets.all(8.0), - child: Row( - children: [ - Text( - widget.item.price.toString() + " " + "SAR", - style: TextStyle(fontWeight: FontWeight.bold, fontSize: 30), - ), - SizedBox( - width: 40, - ), - Text( - languageID == 'ar'? - widget.item.stockAvailabilityn : widget.item.stockAvailability , - style: widget.item.stockAvailability == 'Out of stock' - ? TextStyle(fontWeight: FontWeight.bold, color: Colors.red) - : TextStyle( - fontWeight: FontWeight.bold, color: Colors.green), - ), - SizedBox(width: 20), - widget.item.stockAvailability == 'Out of stock' && - customerId != null - ? InkWell( - onTap: () => - notifyMeWhenAvailable(context, widget.item.id), - child: Row(children: [ - Text( - TranslationBase.of(context).notifyMe, - style: TextStyle( - color: Colors.blue, - decoration: TextDecoration.underline, - ), - ), - SizedBox(width: 4), - Icon( - FontAwesomeIcons.bell, - color: Colors.blue, - size: 15.0, - ) - ]), - ) - : Container( - margin: languageID == 'ar' - ? EdgeInsets.only(right: 25) - : EdgeInsets.only(left: 25), - width: 40, - height: 40, - decoration: BoxDecoration( - color: Colors.grey, - borderRadius: BorderRadius.circular(30), - ), - child: IconButton( - icon: Icon(!isInWishlit - ? Icons.favorite_border - : Icons.favorite), - color: !isInWishlit ? Colors.white : Colors.red, - onPressed: () async { - if (customerId != null) { - if (!isInWishlit) { - GifLoaderDialogUtils.showMyDialog(context); - await addToWishlistFunction(widget.item.id); - GifLoaderDialogUtils.hideDialog(context); - } else { - await deleteFromWishlistFunction(widget.item.id); - } - } else { - return; - } - setState(() {}); - }, - )), - ], - ), - ), - Padding( - padding: const EdgeInsets.all(8.0), - child: Container( - margin: EdgeInsets.only(left: 5), - child: Align( - alignment: - languageID == 'ar' ? Alignment.topRight : Alignment.topLeft, - child: Text( - languageID == 'ar' - ? widget.item.fullDescriptionn - : widget.item.fullDescription, - style: TextStyle(fontWeight: FontWeight.bold, fontSize: 15), - ), - ), - ), - ), - Row( - children: [ - Expanded( - flex: 2, - child: Container( - margin: EdgeInsets.only(right: 150), - child: Align( - alignment: Alignment.bottomLeft, - child: RatingBar.readOnly( - initialRating: 3, - size: 15.0, - filledColor: Colors.yellow[700], - emptyColor: Colors.grey[500], - isHalfAllowed: true, - halfFilledIcon: Icons.star_half, - filledIcon: Icons.star, - emptyIcon: Icons.star, - ), - ), - ), - ), - Expanded( - flex: 1, - child: Container( - child: widget.item.rxMessage != null - ? Text( - languageID == 'ar' - ? widget.item.rxMessagen.toString() - : widget.item.rxMessage.toString(), - style: TextStyle(color: Colors.red, fontSize: 10), - ) - : Container()), - ), - widget.item.rxMessage != null - ? Icon( - FontAwesomeIcons.questionCircle, - color: Colors.red, - size: 15.0, - ) - : Container(), - ], - ), - ], - ); - } -} - -slideDetail() { - return Row( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Padding( - padding: const EdgeInsets.all(8.0), - child: Container( - padding: const EdgeInsets.symmetric(horizontal: 14.0, vertical: 15.0), - decoration: const BoxDecoration( - border: Border( - top: BorderSide(width: 0.5, color: Colors.grey), - left: BorderSide(width: 0.5, color: Colors.grey), - right: BorderSide(width: 0.5, color: Colors.grey), - bottom: BorderSide(width: 0.5, color: Colors.grey), - ), - color: Colors.white, - ), - child: const Text('1', - textAlign: TextAlign.center, - style: TextStyle(color: Color(0xFF000000))), - ), - ) - ], - ); -} - -fixingString(txt) { - String stringTxt; - String newTxt; - stringTxt = txt.toString(); - newTxt = stringTxt.split('.')[1]; - - return newTxt; -} - -//getLanguageID() async { -// languageID = await sharedPref.getString(APP_LANGUAGE); -//} - -getSpecificationData(itemID) async { - ProductDetailViewModel x = new ProductDetailViewModel(); - specificationData = await x.productSpecificationData(itemID); -} - -addToCartFunction(quantity, itemID, BuildContext context) async { - GifLoaderDialogUtils.showMyDialog(context); - ProductDetailViewModel x = new ProductDetailViewModel(); - await x.addToCartData(quantity, itemID).then((value) { - GifLoaderDialogUtils.hideDialog(context); - }); -} - -notifyMeWhenAvailable(context, itemId) async { - ProductDetailViewModel x = new ProductDetailViewModel(); - await x.notifyMe(customerId, itemId); -} - -addToWishlistFunction(itemID) async { - ProductDetailViewModel x = new ProductDetailViewModel(); - isInWishlit = true; - await x.addToWishlistData(itemID); - -} - -deleteFromWishlistFunction(itemID) async { - ProductDetailViewModel x = new ProductDetailViewModel(); - isInWishlit = false; - await x.deletWishlistData(itemID); -} - -checkWishlist() async { - ProductDetailViewModel x = new ProductDetailViewModel(); - await x.checkWishlistData(); - -// isInWishlit = x.wishListItems.map((e) => e.id.toString()).toList().contains(itemID); - - for (int i = 0; i < x.wishListItems.length; i++) { - if (itemID == x.wishListItems[i].product.id) { - isInWishlit = true; - break; - } else { - isInWishlit = false; - } - } -} - -class sttingModalBottomSheet extends StatelessWidget { - @override - Widget build(BuildContext context) { - return Container(); - } -} - -settingModalBottomSheet(context) { - showModalBottomSheet( - context: context, - builder: (BuildContext bc) { - return Container( - child: new Wrap( - children: [ - new ListTile( - leading: Icon(Icons.shopping_cart), - title: Text(TranslationBase.of(context) - .addToCart,), - onTap: () => { - if (price > 0) - {addToCartFunction(price, itemID, context)} - else - { - AppToast.showErrorToast( - message: "you should add quantity") - } - }), - ListTile( - leading: Icon(Icons.favorite_border), - title: Text(TranslationBase.of(context) - .addToWishlist,), - onTap: () => {addToWishlistFunction(itemID)}, - ), - ListTile( - leading: Icon(Icons.compare), - title: Text(TranslationBase.of(context) - .compare,), - onTap: () => { - Provider.of(context, listen: false) - .addItem(specificationData), - }, - ), - ], - ), - ); - }); -} diff --git a/lib/pages/pharmacies/screens/cart-order-page.dart b/lib/pages/pharmacies/screens/cart-order-page.dart index 6c760fcd..f9c928eb 100644 --- a/lib/pages/pharmacies/screens/cart-order-page.dart +++ b/lib/pages/pharmacies/screens/cart-order-page.dart @@ -4,222 +4,265 @@ import 'package:diplomaticquarterapp/core/model/pharmacies/ShoppingCartResponse. import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart'; import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/pages/base/base_view.dart'; -import 'package:diplomaticquarterapp/pages/pharmacies/screens/cart-order-preview.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/screens/pharmacy-terms-conditions-page.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/widgets/ProductOrderItem.dart'; +import 'package:diplomaticquarterapp/uitl/app_toast.dart'; +import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/utils.dart'; import 'package:diplomaticquarterapp/widgets/buttons/GestureIconButton.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; +import 'package:diplomaticquarterapp/widgets/others/network_base_view.dart'; import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; import 'package:flutter/material.dart'; +import 'package:http/http.dart'; import 'package:provider/provider.dart'; -class CartOrderPage extends StatelessWidget { +import 'cart-page/cart-order-preview.dart'; + +class CartOrderPage extends StatefulWidget { + + + const CartOrderPage({ Key key}) + : super(key: key); + + + @override + _CartOrderPageState createState() => _CartOrderPageState(); +} + +class _CartOrderPageState extends State { + bool isLoading = true; + + @override + void initState() { + super.initState(); + getData(); + + } + @override Widget build(BuildContext context) { final mediaQuery = MediaQuery.of(context); + OrderPreviewViewModel model = Provider.of(context); final height = mediaQuery.size.height - 60 - mediaQuery.padding.top; AppScaffold appScaffold; - return BaseView( - onModelReady: (model){ - model.getShoppingCart().then((value){ - appScaffold.appBar.badgeUpdater('${model.cartResponse.quantityCount ?? 0}'); - }); - }, - builder: (_, model, wi) => ChangeNotifierProvider.value( - value: model.cartResponse, - child: appScaffold = AppScaffold( - appBarTitle: TranslationBase.of(context).shoppingCart, - isShowAppBar: true, - isPharmacy: true, - baseViewModel: model, - backgroundColor: Colors.white, - body: !(model.cartResponse.shoppingCarts == null || - model.cartResponse.shoppingCarts.length == 0) - ? Container( - height: height * 0.85, - width: double.infinity, - child: Consumer( - builder: (ctx, cart, _) => Container( - child: SingleChildScrollView( - child: Container( - margin: EdgeInsets.all(10), + return NetworkBaseView( + // baseViewModel: model, + isLoading: isLoading, + isLocalLoader: true, + child: AppScaffold( + appBarTitle: TranslationBase.of(context).shoppingCart, + isShowAppBar: true, + isPharmacy: true, + showHomeAppBarIcon: false, + isShowDecPage: true, + baseViewModel: model, + backgroundColor: Colors.white, + body: !(model.cartResponse.shoppingCarts == null || + model.cartResponse.shoppingCarts.length == 0) + ? Container( + height: height * 0.85, + width: double.infinity, + child: SingleChildScrollView( + child: Container( + margin: EdgeInsets.all(10), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + GestureIconButton( + TranslationBase.of(context).deleteAllItems, + Icon( + Icons.delete_outline_sharp, + color: Colors.grey.shade700, + ), + onTap: () => {model.deleteShoppingCart()}, + ), + const Divider( + color: Color(0xFFD6D6D6), + height: 20, + thickness: 1, + indent: 0, + endIndent: 0, + ), + Container( child: Column( - crossAxisAlignment: CrossAxisAlignment.start, children: [ - GestureIconButton( - TranslationBase.of(context).deleteAllItems, - Icon( - Icons.delete_outline_sharp, - color: Colors.grey.shade700, - ), - onTap: () => {model.deleteShoppingCart()}, - ), - const Divider( - color: Color(0xFFD6D6D6), - height: 20, - thickness: 1, - indent: 0, - endIndent: 0, - ), - Container( - child: Column( - children: [ - ...List.generate( - cart.shoppingCarts != null ? cart.shoppingCarts.length : 0, - (index) => ProductOrderItem( - cart.shoppingCarts[index], () {print(cart.shoppingCarts[index].quantity); - model.changeProductQuantity(cart.shoppingCarts[index]).then((value) { - if (model.state != ViewState.Error) { - appScaffold.appBar.badgeUpdater('${value.quantityCount ?? 0}'); - } - if (model.state == - ViewState.ErrorLocal) {Utils.showErrorToast(model.error);} - }); - }, - () { - model.deleteProduct(cart.shoppingCarts[index]).then((value){ - if (model.state != ViewState.Error) { - appScaffold.appBar.badgeUpdater('${value.quantityCount ?? 0}'); - } - }); - })) - ], - ), - ), - const Divider( - color: Color(0xFFD6D6D6), - height: 20, - thickness: 2, - indent: 0, - endIndent: 0, - ), - Row( - mainAxisAlignment: - MainAxisAlignment.spaceBetween, - children: [ - Texts( - TranslationBase.of(context).subtotal, - fontSize: 14, - color: Colors.black, - fontWeight: FontWeight.w500, - ), - Texts( - "${TranslationBase.of(context).sar} ${(cart.subtotal).toStringAsFixed(2)}", - fontSize: 14, - color: Colors.black, - fontWeight: FontWeight.w500, - ), - ], - ), - const Divider( - color: Color(0xFFD6D6D6), - height: 20, - thickness: 1, - indent: 0, - endIndent: 0, - ), - Row( - mainAxisAlignment: - MainAxisAlignment.spaceBetween, - children: [ - Texts( - "${TranslationBase.of(context).vat}", - fontSize: 14, - color: Colors.black, - fontWeight: FontWeight.w500, - ), - Texts( - "${TranslationBase.of(context).sar} ${(cart.subtotalVatAmount).toStringAsFixed(2)}", - fontSize: 14, - color: Colors.black, - fontWeight: FontWeight.w500, - ), - ], - ), - const Divider( - color: Color(0xFFD6D6D6), - height: 20, - thickness: 1, - indent: 0, - endIndent: 0, - ), - Row( - mainAxisAlignment: - MainAxisAlignment.spaceBetween, - children: [ - Texts( - TranslationBase.of(context).total, - fontSize: 14, - color: Colors.black, - fontWeight: FontWeight.bold, - ), - Texts( - "${TranslationBase.of(context).sar} ${(cart.subtotal).toStringAsFixed(2)}", - fontSize: 14, - color: Colors.black, - fontWeight: FontWeight.bold, - ), - ], - ), - const Divider( - color: Color(0xFFD6D6D6), - height: 20, - thickness: 1, - indent: 0, - endIndent: 0, - ), - Image.asset( - "assets/images/pharmacy_module/payment_image.png", - width: mediaQuery.size.width - 20, - height: 30.0, - fit: BoxFit.scaleDown, - ) + ...List.generate( + model.cartResponse.shoppingCarts != null + ? model.cartResponse.shoppingCarts.length + : 0, + (index) => ProductOrderItem( + model.cartResponse + .shoppingCarts[index], () { + print(model.cartResponse + .shoppingCarts[index].quantity); + model + .changeProductQuantity(model + .cartResponse + .shoppingCarts[index]) + .then((value) { + if (model.state != ViewState.Error) { + appScaffold.appBar.badgeUpdater( + '${value.quantityCount ?? 0}'); + } + if (model.state == + ViewState.ErrorLocal) { + Utils.showErrorToast(model.error); + } + }); + }, () { + model + .deleteProduct(model.cartResponse + .shoppingCarts[index]) + .then((value) { + if (model.state != ViewState.Error) { + appScaffold.appBar.badgeUpdater( + '${value.quantityCount ?? 0}'); + } + }); + })) ], ), ), - ), + const Divider( + color: Color(0xFFD6D6D6), + height: 20, + thickness: 2, + indent: 0, + endIndent: 0, + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Texts( + TranslationBase.of(context).subtotal, + fontSize: 14, + color: Colors.black, + fontWeight: FontWeight.w500, + ), + Texts( + "${TranslationBase.of(context).sar} ${(model.cartResponse.subtotal).toStringAsFixed(2)}", + fontSize: 14, + color: Colors.black, + fontWeight: FontWeight.w500, + ), + ], + ), + const Divider( + color: Color(0xFFD6D6D6), + height: 20, + thickness: 1, + indent: 0, + endIndent: 0, + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Texts( + "${TranslationBase.of(context).vat}", + fontSize: 14, + color: Colors.black, + fontWeight: FontWeight.w500, + ), + Texts( + "${TranslationBase.of(context).sar} ${(model.cartResponse.subtotalVatAmount).toStringAsFixed(2)}", + fontSize: 14, + color: Colors.black, + fontWeight: FontWeight.w500, + ), + ], + ), + const Divider( + color: Color(0xFFD6D6D6), + height: 20, + thickness: 1, + indent: 0, + endIndent: 0, + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Texts( + TranslationBase.of(context).total, + fontSize: 14, + color: Colors.black, + fontWeight: FontWeight.bold, + ), + Texts( + "${TranslationBase.of(context).sar} ${(model.cartResponse.subtotalWithVat).toStringAsFixed(2)}", + fontSize: 14, + color: Colors.black, + fontWeight: FontWeight.bold, + ), + ], + ), + const Divider( + color: Color(0xFFD6D6D6), + height: 20, + thickness: 1, + indent: 0, + endIndent: 0, + ), + Image.asset( + "assets/images/pharmacy_module/payment_image.png", + width: mediaQuery.size.width - 20, + height: 30.0, + fit: BoxFit.scaleDown, + ), + SizedBox( + height: 120, + ) + ], ), ), - ) - : Center( - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Padding( - padding: const EdgeInsets.all(8.0), - child: Image.asset( - 'assets/images/new-design/empty_box.png', - width: 100, - height: 100, - fit: BoxFit.cover, - ), + ), + ) + : Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Padding( + padding: const EdgeInsets.all(8.0), + child: Image.asset( + 'assets/images/new-design/empty_box.png', + width: 100, + height: 100, + fit: BoxFit.cover, ), - Padding( - padding: const EdgeInsets.all(8.0), - child: Text(TranslationBase.of(context).noData, + ), + Padding( + padding: const EdgeInsets.all(8.0), + child: Text( + TranslationBase.of(context).noData, // 'There is no data', - style: TextStyle(fontSize: 30), - ), - ) - ], - ), + style: TextStyle(fontSize: 30), + ), + ) + ], ), - bottomSheet: Container( - height: !(model.cartResponse.shoppingCarts == null || - model.cartResponse.shoppingCarts.length == 0) - ? height * 0.15 - : 0, - color: Colors.white, - child: OrderBottomWidget(model.addresses, height), - ), + ), + bottomSheet: Container( + height: !(model.cartResponse.shoppingCarts == null || + model.cartResponse.shoppingCarts.length == 0) + ? height * 0.15 + : 0, + color: Colors.white, + child: OrderBottomWidget(model.addresses, height), ), ), ); } + + void getData() async { + await Provider.of(context, listen: false) + .getShoppingCart(); + setState(() { + isLoading = false; + }); + } } class OrderBottomWidget extends StatefulWidget { @@ -238,46 +281,41 @@ class _OrderBottomWidgetState extends State { @override Widget build(BuildContext context) { ProjectViewModel projectProvider = Provider.of(context); - - return Container( - margin: EdgeInsets.symmetric(horizontal: 10, vertical: 0), - child: Consumer( - builder: (ctx, cart, _) => !(cart.shoppingCarts == null || - cart.shoppingCarts.length == 0) - ? Column( - crossAxisAlignment: CrossAxisAlignment.start, + OrderPreviewViewModel cart = Provider.of(context); + return !(cart.cartResponse.shoppingCarts == null || + cart.cartResponse.shoppingCarts.length == 0) + ? Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + const Divider( + color: Color(0xFFD6D6D6), + height: 1, + thickness: 1, + indent: 0, + endIndent: 0, + ), + Container( + height: widget.height * 0.070, + color: Color(0xffe6ffe0), + padding: EdgeInsets.symmetric(horizontal: 4), + child: Row( children: [ - const Divider( - color: Color(0xFFD6D6D6), - height: 1, - thickness: 1, - indent: 0, - endIndent: 0, - ), - Container( - height: widget.height * 0.070, - color: Color(0xffe6ffe0), - padding: EdgeInsets.symmetric(horizontal: 4), - child: Row( - children: [ - InkWell( - onTap: () { - setState(() { - isAgree = !isAgree; - }); - }, - child: Container( - width: 25.0, - height: widget.height * 0.070, - decoration: new BoxDecoration( - color: !isAgree - ? Color(0xffeeeeee) - : Colors.green, - shape: BoxShape.circle, - ), - child: !isAgree - ? null - : Padding( + InkWell( + onTap: () { + setState(() { + isAgree = !isAgree; + }); + }, + child: Container( + width: 25.0, + height: widget.height * 0.070, + decoration: new BoxDecoration( + color: !isAgree ? Color(0xffeeeeee) : Colors.green, + shape: BoxShape.circle, + ), + child: !isAgree + ? null + : Padding( padding: const EdgeInsets.all(0.0), child: Icon( Icons.check, @@ -285,108 +323,132 @@ class _OrderBottomWidgetState extends State { size: 25, ), ), - ), - ), - Expanded( - child: Container( - padding: EdgeInsets.symmetric(horizontal: 4), - margin: const EdgeInsets.symmetric(vertical: 4), - child: Texts( - TranslationBase.of(context) - .pharmacyServiceTermsCondition, - fontSize: 13, - color: Colors.grey.shade800, - fontWeight: FontWeight.normal, - ), - ), - ), - InkWell( - onTap: () => { - Navigator.push(context, - FadePage(page: PharmacyTermsConditions())) - }, - child: Container( - child: Icon( - Icons.info, - size: 25, - color: Color(0xff005aff), - ), - ), - ), - ], ), ), - Container( - height: widget.height * 0.065, - margin: EdgeInsets.symmetric(vertical: 2), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, + Expanded( + child: Container( + padding: EdgeInsets.symmetric(horizontal: 4), + margin: const EdgeInsets.symmetric(vertical: 4), + child: Texts( + TranslationBase.of(context) + .pharmacyServiceTermsCondition, + fontSize: 13, + color: Colors.grey.shade800, + fontWeight: FontWeight.normal, + ), + ), + ), + InkWell( + onTap: () => { + Navigator.push( + context, FadePage(page: PharmacyTermsConditions())) + }, + child: Container( + child: Icon( + Icons.info, + size: 25, + color: Color(0xff005aff), + ), + ), + ), + ], + ), + ), + Container( + height: widget.height * 0.065, + margin: EdgeInsets.symmetric(vertical: 2), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.center, children: [ - Expanded( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: MainAxisAlignment.center, + Container( + margin: EdgeInsets.symmetric( + horizontal: 0, vertical: 0), + child: Row( children: [ - Container( - margin: EdgeInsets.symmetric( - horizontal: 0, vertical: 0), - child: Row( - children: [ - Texts( - "${TranslationBase.of(context).sar} ${(cart.subtotal).toStringAsFixed(2)}", - fontSize: - projectProvider.isArabic ? 12 : 14, - fontWeight: FontWeight.bold, - ), - Padding( - padding: const EdgeInsets.symmetric( - horizontal: 4), - child: Texts( - "${TranslationBase.of(context).inclusiveVat}", - fontSize: 8, - color: Colors.grey, - fontWeight: FontWeight.bold, - ), - ), - ], - ), - ), Texts( - "${cart.quantityCount} ${TranslationBase.of(context).items}", - fontSize: 10, - color: Colors.grey, + "${TranslationBase.of(context).sar} ${(cart.cartResponse.subtotalWithVat).toStringAsFixed(2)}", + fontSize: projectProvider.isArabic ? 12 : 14, fontWeight: FontWeight.bold, ), + Padding( + padding: + const EdgeInsets.symmetric(horizontal: 4), + child: Texts( + "${TranslationBase.of(context).inclusiveVat}", + fontSize: 8, + color: Colors.grey, + fontWeight: FontWeight.bold, + ), + ), ], ), ), - RaisedButton( - onPressed: isAgree - ? () => { - Navigator.push( - context, - FadePage( - page: OrderPreviewPage( - widget.addresses))) - } - : null, - child: new Text( - "${TranslationBase.of(context).checkOut}", - style: new TextStyle( - color: isAgree - ? Colors.white - : Colors.grey.shade300, - fontSize: 14), - ), - color: Color(0xff005aff), - disabledColor: Color(0xff005aff), + Texts( + "${cart.cartResponse.quantityCount} ${TranslationBase.of(context).items}", + fontSize: 10, + color: Colors.grey, + fontWeight: FontWeight.bold, ), ], ), ), + RaisedButton( + onPressed: isAgree +// && cart.cartResponse.shoppingCarts[1].product.stockQuantity ==0 + ? () => { + if(cart.isCartItemsOutOfStock()){ + // Toast msg + AppToast.showErrorToast(message: TranslationBase.of(context).outOfStockMsg) + }else { + Navigator.push( + context, + FadePage( + page: + OrderPreviewPage(widget.addresses))) + } + } + : null, + child: new Text( + "${TranslationBase.of(context).checkOut}", + style: new TextStyle( + color: + isAgree ? Colors.white : Colors.grey.shade300, + fontSize: 14), + ), + color: Color(0xff005aff), + disabledColor: Color(0xff005aff), + ) +// RaisedButton( +// onPressed: isAgree +//// && cart.cartResponse.shoppingCarts[1].product.stockQuantity ==0 +// ? () => { +// Navigator.push( +// context, +// FadePage( +// page: +// OrderPreviewPage(widget.addresses))) +// } +// : null, +// child: new Text( +// "${TranslationBase.of(context).checkOut}", +// style: new TextStyle( +// color: +// isAgree ? Colors.white : Colors.grey.shade300, +// fontSize: 14), +// ), +// color: Color(0xff005aff), +// disabledColor: Color(0xff005aff), +// ) ], - ) - : Container(), - )); + ), + ), + ], + ) + : Container(); } } diff --git a/lib/pages/pharmacies/screens/cart-order-preview.dart b/lib/pages/pharmacies/screens/cart-order-preview.dart index dcf2ae64..e69de29b 100644 --- a/lib/pages/pharmacies/screens/cart-order-preview.dart +++ b/lib/pages/pharmacies/screens/cart-order-preview.dart @@ -1,947 +0,0 @@ -import 'package:diplomaticquarterapp/core/enum/viewstate.dart'; -import 'package:diplomaticquarterapp/core/model/pharmacies/Addresses.dart'; -import 'package:diplomaticquarterapp/core/model/pharmacies/order_detail.dart'; -import 'package:diplomaticquarterapp/core/model/pharmacies/payment-checkout-data.dart'; -import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart'; -import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; -import 'package:diplomaticquarterapp/models/Appointments/AppoimentAllHistoryResultList.dart'; -import 'package:diplomaticquarterapp/models/Authentication/authenticated_user.dart'; -import 'package:diplomaticquarterapp/pages/base/base_view.dart'; -import 'package:diplomaticquarterapp/pages/pharmacies/screens/payment-method-select-page.dart'; -import 'package:diplomaticquarterapp/pages/pharmacies/widgets/ProductOrderPreviewItem.dart'; -import 'package:diplomaticquarterapp/pages/pharmacy/pharmacyAddresses/PharmacyAddresses.dart'; -import 'package:diplomaticquarterapp/uitl/app_toast.dart'; -import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; -import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; -import 'package:diplomaticquarterapp/widgets/in_app_browser/InAppBrowser.dart'; -import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; -import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; -import 'package:flutter/material.dart'; -import 'package:provider/provider.dart'; - -class OrderPreviewPage extends StatelessWidget { - final List addresses; - - OrderPreviewPage(this.addresses); - - MyInAppBrowser browser; - - @override - Widget build(BuildContext context) { - final mediaQuery = MediaQuery.of(context); - final height = mediaQuery.size.height - 60 - mediaQuery.padding.top; - - return BaseView( - onModelReady: (model) => model.getShoppingCart(), - builder: (_, model, wi) => ChangeNotifierProvider.value( - value: model.paymentCheckoutData, - child: AppScaffold( - appBarTitle: "${TranslationBase.of(context).checkOut}", - isShowAppBar: true, - isPharmacy: true, - isShowDecPage: false, - backgroundColor: Colors.white, - baseViewModel: model, - body: Container( - height: height * 0.90, - child: SingleChildScrollView( - child: Container( - color: Color(0xFFF1F1F1), - child: Column( - children: [ - SelectAddressWidget(model, addresses), - SizedBox( - height: 10, - ), - SelectPaymentOptionWidget(model), - SizedBox( - height: 10, - ), - Consumer( - builder: (ctx, paymentData, _) => - paymentData.lacumInformation != null - ? Container( - child: Column( - children: [ - LakumWidget(model), - SizedBox( - height: 10, - ), - ], - ), - ) - : Container()), - Container( - color: Colors.white, - width: double.infinity, - padding: EdgeInsets.all(8), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Texts( - TranslationBase - .of(context) - .reviewOrder, - fontSize: 14, - fontWeight: FontWeight.bold, - color: Colors.black, - ), - ...List.generate( - model.cartResponse.shoppingCarts != null - ? model.cartResponse.shoppingCarts.length - : 0, - (index) => - ProductOrderPreviewItem( - model.cartResponse - .shoppingCarts[index]), - ), - ], - ), - ), - Container( - width: double.infinity, - padding: EdgeInsets.all(8), - child: model.cartResponse.subtotal != null - ? Column( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Texts( - TranslationBase - .of(context) - .orderSummary, - fontSize: 14, - fontWeight: FontWeight.bold, - color: Colors.black, - ), - SizedBox( - height: 20, - ), - Row( - mainAxisAlignment: - MainAxisAlignment.spaceBetween, - children: [ - Texts( - "${TranslationBase - .of(context) - .subtotal}", - fontSize: 14, - color: Colors.black, - fontWeight: FontWeight.w500, - ), - Texts( - "${TranslationBase - .of(context) - .sar} ${(model.cartResponse.subtotal) - .toStringAsFixed(2)}", - fontSize: 14, - color: Colors.black, - fontWeight: FontWeight.w500, - ), - ], - ), - const Divider( - color: Color(0xFFD6D6D6), - height: 20, - thickness: 1, - indent: 0, - endIndent: 0, - ), - Row( - mainAxisAlignment: - MainAxisAlignment.spaceBetween, - children: [ - Texts( - "${TranslationBase - .of(context) - .shipping}", - fontSize: 14, - color: Colors.black, - fontWeight: FontWeight.w500, - ), - Texts( - "${TranslationBase - .of(context) - .sar} ${(model - .totalAdditionalShippingCharge) - .toStringAsFixed(2)}", - fontSize: 14, - color: Colors.black, - fontWeight: FontWeight.w500, - ), - ], - ), - const Divider( - color: Color(0xFFD6D6D6), - height: 20, - thickness: 1, - indent: 0, - endIndent: 0, - ), - Row( - mainAxisAlignment: - MainAxisAlignment.spaceBetween, - children: [ - Texts( - "${TranslationBase - .of(context) - .vat}", - fontSize: 14, - color: Colors.black, - fontWeight: FontWeight.w500, - ), - Texts( - "${TranslationBase - .of(context) - .sar} ${(model.cartResponse - .subtotalVatAmount).toStringAsFixed( - 2)}", - fontSize: 14, - color: Colors.black, - fontWeight: FontWeight.w500, - ), - ], - ), - const Divider( - color: Color(0xFFD6D6D6), - height: 20, - thickness: 1, - indent: 0, - endIndent: 0, - ), - Row( - mainAxisAlignment: - MainAxisAlignment.spaceBetween, - children: [ - Texts( - TranslationBase - .of(context) - .total, - fontSize: 14, - color: Colors.black, - fontWeight: FontWeight.bold, - ), - Texts( - "${TranslationBase - .of(context) - .sar} ${(model.cartResponse.subtotal) - .toStringAsFixed(2)}", - fontSize: 14, - color: Colors.black, - fontWeight: FontWeight.bold, - ), - ], - ), - SizedBox( - height: 10, - ), - ], - ) - : Container(), - ) - ], - ), - ), - ), - ), - bottomSheet: Container( - height: model.cartResponse.shoppingCarts != null - ? height * 0.10 - : 0, - color: Colors.white, - child: PaymentBottomWidget(model), - ), - ), - )); - } -} - -class SelectAddressWidget extends StatefulWidget { - final OrderPreviewViewModel model; - final List addresses; - - SelectAddressWidget(this.model, this.addresses); - - @override - _SelectAddressWidgetState createState() => _SelectAddressWidgetState(); -} - -class _SelectAddressWidgetState extends State { - Addresses address; - - _navigateToAddressPage() { - Navigator.push(context, FadePage(page: PharmacyAddressesPage())) - .then((result) { - if (result != null) { - address = result; - widget.model.paymentCheckoutData.address = address; - widget.model.getInformationsByAddress(); - } - - /* setState(() { - if (result != null) { - address = result; - widget.model.paymentCheckoutData.address = address; - widget.model.getInformationsByAddress(); - } - })*/ - }); - } - - @override - void initState() { - if (widget.model.paymentCheckoutData.address != null) { - address = widget.model.paymentCheckoutData.address; - } - super.initState(); - } - - @override - Widget build(BuildContext context) { - return Consumer( - builder: (ctx, paymentData, _) => - Container( - color: Colors.white, - child: address == null - ? InkWell( - onTap: () => {_navigateToAddressPage()}, - child: Container( - margin: EdgeInsets.symmetric(vertical: 12, horizontal: 12), - child: Row( - children: [ - Image.asset( - "assets/images/pharmacy_module/ic_shipping_address.png", - width: 30.0, - height: 30.0, - fit: BoxFit.scaleDown, - ), - Expanded( - child: Container( - padding: - EdgeInsets.symmetric(vertical: 0, horizontal: 6), - child: Texts( - TranslationBase - .of(context) - .selectAddress, - fontSize: 14, - fontWeight: FontWeight.bold, - color: Color(0xff0000ff), - ), - ), - ), - Icon( - Icons.arrow_forward, - size: 20, - color: Colors.grey.shade400, - ), - ], - ), - ), - ) - : Container( - child: Container( - margin: EdgeInsets.symmetric(vertical: 12, horizontal: 12), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - children: [ - Image.asset( - "assets/images/pharmacy_module/ic_shipping_mark.png", - width: 30.0, - height: 30.0, - fit: BoxFit.scaleDown, - ), - Expanded( - child: Container( - padding: EdgeInsets.symmetric( - vertical: 0, horizontal: 6), - child: Texts( - TranslationBase - .of(context) - .shippingAddress, - fontSize: 14, - fontWeight: FontWeight.bold, - color: Colors.black, - ), - ), - ), - InkWell( - onTap: () => {_navigateToAddressPage()}, - child: Texts( - TranslationBase - .of(context) - .changeAddress, - fontSize: 12, - fontWeight: FontWeight.normal, - color: Color(0xff0000ff), - ), - ), - ], - ), - Padding( - padding: const EdgeInsets.symmetric(vertical: 8), - child: Texts( - "${address.firstName} ${address.lastName}", - fontSize: 14, - fontWeight: FontWeight.bold, - color: Colors.black, - ), - ), - Padding( - padding: const EdgeInsets.symmetric(vertical: 8), - child: Texts( - "${address.address1} ${address.address2} ${address - .address2},, ${address.city}, ${address - .country} ${address.zipPostalCode}", - fontSize: 12, - fontWeight: FontWeight.normal, - color: Colors.grey.shade500, - ), - ), - Row( - children: [ - Container( - margin: const EdgeInsets.only(right: 8), - child: Icon( - Icons.phone, - size: 20, - color: Colors.black, - ), - ), - Texts( - "${address.phoneNumber}", - fontSize: 14, - fontWeight: FontWeight.bold, - color: Colors.grey, - ), - ], - ), - Container( - margin: EdgeInsets.symmetric(vertical: 8), - child: SizedBox( - height: 2, - width: double.infinity, - child: Container( - color: Color(0xffefefef), - ), - ), - ), - Row( - children: [ - Image.asset( - "assets/images/pharmacy_module/ic_shipping_truck.png", - width: 30.0, - height: 30.0, - fit: BoxFit.scaleDown, - ), - Container( - padding: EdgeInsets.symmetric( - vertical: 0, horizontal: 6), - child: Texts( - "${TranslationBase - .of(context) - .shipBy}", - fontSize: 12, - fontWeight: FontWeight.bold, - color: Colors.black, - ), - ), - Container( - child: Image.asset( - paymentData.shippingOption - .shippingRateComputationMethodSystemName == - "Shipping.FixedOrByWeight" - ? "assets/images/pharmacy_module/payment/hmg_shipping_logo.png" - : "assets/images/pharmacy_module/payment/aramex_shipping_logo.png", - fit: BoxFit.contain, - ), - margin: EdgeInsets.symmetric(horizontal: 8), - ), - ], - ), - ], - ), - ), - ), // ic_shipping_mark.png - ), - ); - } -} - -class SelectPaymentOptionWidget extends StatefulWidget { - final OrderPreviewViewModel model; - - SelectPaymentOptionWidget(this.model); - - @override - _SelectPaymentOptionWidgetState createState() => - _SelectPaymentOptionWidgetState(); -} - -class _SelectPaymentOptionWidgetState extends State { - PaymentOption paymentOption; - - _navigateToPaymentOption() { - Navigator.push(context, FadePage(page: PaymentMethodSelectPage())) - .then((result) => - { - setState(() { - if (result != null) { - paymentOption = result; - widget.model.paymentCheckoutData.paymentOption = - paymentOption; - widget.model.paymentCheckoutData.updateData(); - } - }) - }); - } - - @override - void initState() { - if (widget.model.paymentCheckoutData.paymentOption != null) { - paymentOption = widget.model.paymentCheckoutData.paymentOption; - } - super.initState(); - } - - @override - Widget build(BuildContext context) { - return Container( - color: Colors.white, - child: paymentOption == null - ? InkWell( - onTap: () => {_navigateToPaymentOption()}, - child: Container( - margin: EdgeInsets.symmetric(vertical: 12, horizontal: 12), - child: Row( - children: [ - Image.asset( - "assets/images/pharmacy_module/ic_payment_option.png", - width: 30.0, - height: 30.0, - fit: BoxFit.scaleDown, - ), - Expanded( - child: Container( - padding: - EdgeInsets.symmetric(vertical: 0, horizontal: 6), - child: Texts( - TranslationBase - .of(context) - .selectPaymentOption, - fontSize: 14, - fontWeight: FontWeight.bold, - color: Color(0xff0000ff), - ), - ), - ), - Icon( - Icons.arrow_forward, - size: 20, - color: Colors.grey.shade400, - ), - ], - ), - ), - ) - : Container( - margin: EdgeInsets.symmetric(vertical: 12, horizontal: 12), - child: Row( - children: [ - Image.asset( - "assets/images/pharmacy_module/ic_payment_option.png", - width: 30.0, - height: 30.0, - fit: BoxFit.scaleDown, - ), - Container( - margin: EdgeInsets.symmetric(horizontal: 8), - padding: EdgeInsets.symmetric(horizontal: 4, vertical: 0), - decoration: new BoxDecoration( - color: Colors.grey.shade100, - shape: BoxShape.rectangle, - ), - child: Image.asset( - widget.model.getPaymentOptionImage(paymentOption), - width: 30.0, - height: 30.0, - fit: BoxFit.scaleDown, - ), - ), - Expanded( - child: Container( - padding: EdgeInsets.symmetric(vertical: 0, horizontal: 6), - child: Texts( - widget.model.getPaymentOptionName(paymentOption), - fontSize: 14, - fontWeight: FontWeight.bold, - color: Colors.black, - ), - ), - ), - InkWell( - onTap: () => {_navigateToPaymentOption()}, - child: Texts( - TranslationBase - .of(context) - .changeMethod, - fontSize: 12, - fontWeight: FontWeight.normal, - color: Color(0xff0000ff), - ), - ), - ], - ), - ), - ); - } -} - -class LakumWidget extends StatefulWidget { - final OrderPreviewViewModel model; - - LakumWidget(this.model); - - @override - _LakumWidgetState createState() => _LakumWidgetState(); -} - -class _LakumWidgetState extends State { - TextEditingController _pointsController = new TextEditingController(); - - @override - Widget build(BuildContext context) { - ProjectViewModel projectProvider = Provider.of(context); - - return Container( - color: Colors.white, - padding: EdgeInsets.symmetric(vertical: 12, horizontal: 12), - child: Row( - children: [ - Image.asset( - "assets/images/pharmacy_module/lakum/lakum_checkout.png", - width: 30.0, - fit: BoxFit.scaleDown, - ), - Container( - decoration: BoxDecoration(color: Color(0x99ffffff)), - padding: const EdgeInsets.symmetric(horizontal: 8), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Texts( - "${TranslationBase - .of(context) - .lakumPoints}", - fontSize: 12, - fontWeight: FontWeight.bold, - ), - Texts( - "${widget.model.paymentCheckoutData.lacumInformation - .lakumInquiryInformationObjVersion.pointsBalanceAmount}", - fontSize: 12, - fontWeight: FontWeight.normal, - ), - ], - ), - ), - Expanded( - child: Container( - decoration: BoxDecoration(color: Color(0x99ffffff)), - padding: const EdgeInsets.symmetric(horizontal: 8), - child: Row( - mainAxisAlignment: MainAxisAlignment.end, - children: [ - Texts( - "${TranslationBase - .of(context) - .riyal}", - fontSize: 12, - fontWeight: FontWeight.bold, - ), - Container( - margin: projectProvider.isArabic - ? EdgeInsets.only(right: 4) - : EdgeInsets.only(left: 4), - width: 60, - height: 50, - child: TextField( - decoration: InputDecoration( - border: OutlineInputBorder( - borderSide: - BorderSide(color: Colors.black, width: 0.2), - gapPadding: 0, - borderRadius: projectProvider.isArabic - ? BorderRadius.only( - topRight: Radius.circular(8), - bottomRight: Radius.circular(8)) - : BorderRadius.only( - topLeft: Radius.circular(8), - bottomLeft: Radius.circular(8)), - ), - disabledBorder: OutlineInputBorder( - borderSide: - BorderSide(color: Colors.black, width: 0.4), - gapPadding: 0, - borderRadius: BorderRadius.only( - topLeft: Radius.circular(8), - bottomLeft: Radius.circular(8)), - ), - ), - controller: _pointsController, - keyboardType: TextInputType.number, - style: TextStyle( - fontSize: 14, - color: widget - .model - .paymentCheckoutData - .lacumInformation - .lakumInquiryInformationObjVersion - .pointsBalanceAmount > - 0 - ? Colors.black - : Colors.grey, - ), - enabled: widget - .model - .paymentCheckoutData - .lacumInformation - .lakumInquiryInformationObjVersion - .pointsBalanceAmount == - 0 - ? false - : true, - onChanged: (val) { - var value = int.tryParse(val); - if (value != null && - value <= - widget - .model - .paymentCheckoutData - .lacumInformation - .lakumInquiryInformationObjVersion - .pointsBalanceAmount) { - widget.model.paymentCheckoutData.usedLakumPoints = - value; - } else { - widget.model.paymentCheckoutData.usedLakumPoints = 0; - } - _pointsController.text = - "${widget.model.paymentCheckoutData.usedLakumPoints}"; - }, - ), - ), - Container( - height: 50, - padding: EdgeInsets.symmetric(horizontal: 8, vertical: 12), - decoration: new BoxDecoration( - color: Color(0xff3666E0), - shape: BoxShape.rectangle, - borderRadius: projectProvider.isArabic - ? BorderRadius.only( - topLeft: Radius.circular(6), - bottomLeft: Radius.circular(6)) - : BorderRadius.only( - topRight: Radius.circular(6), - bottomRight: Radius.circular(6)), - border: Border.fromBorderSide(BorderSide( - color: Color(0xff3666E0), - width: 0.8, - )), - ), - child: Texts( - "${TranslationBase - .of(context) - .use}", - fontSize: 12, - color: Colors.white, - fontWeight: FontWeight.bold, - ), - ), - ], - ), - ), - ), - ], - ), - ); - } -} - -class PaymentBottomWidget extends StatelessWidget { - final OrderPreviewViewModel model; - - BuildContext context; - MyInAppBrowser browser; - - PaymentBottomWidget(this.model); - - @override - Widget build(BuildContext context) { - final scaffold = Scaffold.of(context); - this.context = context; - - return Container( - margin: EdgeInsets.symmetric(horizontal: 10, vertical: 0), - child: Consumer( - builder: (ctx, paymentData, _) => - paymentData.cartDataVisible - ? Container( - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - Container( - margin: - EdgeInsets.symmetric(horizontal: 0, vertical: 4), - child: Row( - children: [ - Texts( - "${TranslationBase - .of(context) - .sar} ${(model.cartResponse.subtotal) - .toStringAsFixed(2)}", - fontSize: 14, - fontWeight: FontWeight.bold, - color: Color(0xff929295), - ), - Padding( - padding: - const EdgeInsets.symmetric(horizontal: 4), - child: Texts( - "${TranslationBase - .of(context) - .inclusiveVat}", - fontSize: 8, - color: Color(0xff929295), - fontWeight: FontWeight.w600, - ), - ), - ], - ), - ), - Texts( - "${model.cartResponse.quantityCount} ${TranslationBase - .of(context) - .items}", - fontSize: 10, - color: Colors.grey, - fontWeight: FontWeight.bold, - ), - ], - ), - Container( - child: RaisedButton( - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(8), - side: BorderSide( - color: Color(0xff929295), - width: 1, - ), - ), - onPressed: (paymentData.address != null && - paymentData.paymentOption != null) - ? () async { - await model.makeOrder(); - if (model.state == ViewState.Idle) { - AppToast.showSuccessToast( - message: "Order has been placed successfully!!"); - openPayment(model.orderListModel[0], model.user); - } else { - AppToast.showErrorToast(message: model.error); - } - Navigator.pop(context); - Navigator.pop(context); - } - : null, - child: Padding( - padding: const EdgeInsets.symmetric(vertical: 16), - child: new Text( - "${TranslationBase - .of(context) - .proceedPay}", - style: new TextStyle( - color: (paymentData.address != null && - paymentData.paymentOption != null) - ? Colors.white - : Colors.grey.shade400, - fontWeight: FontWeight.bold, - fontSize: 12), - ), - ), - color: (paymentData.address != null && - paymentData.paymentOption != null) - ? Colors.green - : Color(0xff929295), - disabledColor: (paymentData.address != null && - paymentData.paymentOption != null) - ? Colors.green - : Color(0xff929295), - ), - ), - ], - ), - ) - : Container(), - ), - ); - } - - openPayment(OrderDetailModel order, - AuthenticatedUser authenticatedUser,) { - browser = new MyInAppBrowser( - onExitCallback: onBrowserExit, onLoadStartCallback: onBrowserLoadStart); - - browser.openPharmacyPaymentBrowser( - order, - order.orderTotal, - 'ePharmacy Order', - order.id, - order.billingAddress.email, - order.customValuesXml, - "${authenticatedUser.firstName} ${authenticatedUser - .middleName} ${authenticatedUser.lastName}", - authenticatedUser.patientID, - authenticatedUser, - browser); - } - - onBrowserLoadStart(String url) { - print("onBrowserLoadStart"); - print(url); - - MyInAppBrowser.successURLS.forEach((element) { - if (url.contains(element)) { - if (browser.isOpened()) browser.close(); - MyInAppBrowser.isPaymentDone = true; - return; - } - }); - - MyInAppBrowser.errorURLS.forEach((element) { - if (url.contains(element)) { - if (browser.isOpened()) browser.close(); - MyInAppBrowser.isPaymentDone = false; - return; - } - }); - } - - onBrowserExit(AppoitmentAllHistoryResultList appo, bool isPaymentMade) { - print("onBrowserExit Called!!!!"); - if (isPaymentMade) { - AppToast.showSuccessToast( - message: "شكراً\nPayment status for your order is Paid"); - Navigator.pop(context); - Navigator.pop(context); - } else { - AppToast.showErrorToast( - message: - "Transaction Failed!\Your transaction is field to some reason please try again or contact to the administration"); - } - } -} diff --git a/lib/pages/pharmacies/screens/cart-page/cart-order-page.dart b/lib/pages/pharmacies/screens/cart-page/cart-order-page.dart new file mode 100644 index 00000000..ef4904b2 --- /dev/null +++ b/lib/pages/pharmacies/screens/cart-page/cart-order-page.dart @@ -0,0 +1,420 @@ +import 'package:diplomaticquarterapp/core/enum/viewstate.dart'; +import 'package:diplomaticquarterapp/core/model/pharmacies/Addresses.dart'; +import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart'; +import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/screens/cart-page/cart-order-preview.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/screens/pharmacy-terms-conditions-page.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/widgets/ProductOrderItem.dart'; +import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; +import 'package:diplomaticquarterapp/uitl/utils.dart'; +import 'package:diplomaticquarterapp/widgets/buttons/GestureIconButton.dart'; +import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; +import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; +import 'package:diplomaticquarterapp/widgets/others/network_base_view.dart'; +import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; + +class CartOrderPage extends StatefulWidget { + final Function(int) changeTab; + + const CartOrderPage({Key key, this.changeTab}) : super(key: key); + + @override + _CartOrderPageState createState() => _CartOrderPageState(); +} + +class _CartOrderPageState extends State { + bool isLoading = true; + + @override + void initState() { + super.initState(); + getData(); + } + + @override + Widget build(BuildContext context) { + final mediaQuery = MediaQuery.of(context); + OrderPreviewViewModel model = Provider.of(context); + + final height = mediaQuery.size.height - 60 - mediaQuery.padding.top; + AppScaffold appScaffold; + return NetworkBaseView( + // baseViewModel: model, + isLoading: isLoading, + isLocalLoader: true, + child: AppScaffold( + appBarTitle: TranslationBase.of(context).shoppingCart, + isShowAppBar: true, + isPharmacy: true, + showHomeAppBarIcon: false, + isShowDecPage: true, + baseViewModel: model, + backButtonTab: + widget.changeTab != null ? () => widget.changeTab(0) : null, + backgroundColor: Colors.white, + body: !(model.cartResponse.shoppingCarts == null || + model.cartResponse.shoppingCarts.length == 0) + ? Container( + height: height * 0.85, + width: double.infinity, + child: SingleChildScrollView( + child: Container( + margin: EdgeInsets.all(10), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + GestureIconButton( + TranslationBase.of(context).deleteAllItems, + Icon( + Icons.delete_outline_sharp, + color: Colors.grey.shade700, + ), + onTap: () => {model.deleteShoppingCart()}, + ), + const Divider( + color: Color(0xFFD6D6D6), + height: 20, + thickness: 1, + indent: 0, + endIndent: 0, + ), + Container( + child: Column( + children: [ + ...List.generate( + model.cartResponse.shoppingCarts != null + ? model.cartResponse.shoppingCarts.length + : 0, + (index) => ProductOrderItem( + model.cartResponse + .shoppingCarts[index], () { + print(model.cartResponse + .shoppingCarts[index].quantity); + model + .changeProductQuantity(model + .cartResponse + .shoppingCarts[index]) + .then((value) { + if (model.state != ViewState.Error) { + appScaffold.appBar.badgeUpdater( + '${value.quantityCount ?? 0}'); + } + if (model.state == + ViewState.ErrorLocal) { + Utils.showErrorToast(model.error); + } + }); + }, () { + model + .deleteProduct(model.cartResponse + .shoppingCarts[index]) + .then((value) { + if (model.state != ViewState.Error) { + appScaffold.appBar.badgeUpdater( + '${value.quantityCount ?? 0}'); + } + }); + })) + ], + ), + ), + const Divider( + color: Color(0xFFD6D6D6), + height: 20, + thickness: 2, + indent: 0, + endIndent: 0, + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Texts( + TranslationBase.of(context).subtotal, + fontSize: 14, + color: Colors.black, + fontWeight: FontWeight.w500, + ), + Texts( + "${TranslationBase.of(context).sar} ${(model.cartResponse.subtotal).toStringAsFixed(2)}", + fontSize: 14, + color: Colors.black, + fontWeight: FontWeight.w500, + ), + ], + ), + const Divider( + color: Color(0xFFD6D6D6), + height: 20, + thickness: 1, + indent: 0, + endIndent: 0, + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Texts( + "${TranslationBase.of(context).vat}", + fontSize: 14, + color: Colors.black, + fontWeight: FontWeight.w500, + ), + Texts( + "${TranslationBase.of(context).sar} ${(model.cartResponse.subtotalVatAmount).toStringAsFixed(2)}", + fontSize: 14, + color: Colors.black, + fontWeight: FontWeight.w500, + ), + ], + ), + const Divider( + color: Color(0xFFD6D6D6), + height: 20, + thickness: 1, + indent: 0, + endIndent: 0, + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Texts( + TranslationBase.of(context).total, + fontSize: 14, + color: Colors.black, + fontWeight: FontWeight.bold, + ), + Texts( + "${TranslationBase.of(context).sar} ${(model.cartResponse.subtotal).toStringAsFixed(2)}", + fontSize: 14, + color: Colors.black, + fontWeight: FontWeight.bold, + ), + ], + ), + const Divider( + color: Color(0xFFD6D6D6), + height: 20, + thickness: 1, + indent: 0, + endIndent: 0, + ), + Image.asset( + "assets/images/pharmacy_module/payment_image.png", + width: mediaQuery.size.width - 20, + height: 30.0, + fit: BoxFit.scaleDown, + ), + SizedBox( + height: 120, + ) + ], + ), + ), + ), + ) + : Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Padding( + padding: const EdgeInsets.all(8.0), + child: Image.asset( + 'assets/images/new-design/empty_box.png', + width: 100, + height: 100, + fit: BoxFit.cover, + ), + ), + Padding( + padding: const EdgeInsets.all(8.0), + child: Text( + TranslationBase.of(context).noData, +// 'There is no data', + style: TextStyle(fontSize: 30), + ), + ) + ], + ), + ), + bottomSheet: Container( + height: !(model.cartResponse.shoppingCarts == null || + model.cartResponse.shoppingCarts.length == 0) + ? height * 0.15 + : 0, + color: Colors.white, + child: OrderBottomWidget(model.addresses, height), + ), + ), + ); + } + + void getData() async { + await Provider.of(context, listen: false) + .getShoppingCart(); + setState(() { + isLoading = false; + }); + } +} + +class OrderBottomWidget extends StatefulWidget { + final List addresses; + final double height; + + OrderBottomWidget(this.addresses, this.height); + + @override + _OrderBottomWidgetState createState() => _OrderBottomWidgetState(); +} + +class _OrderBottomWidgetState extends State { + bool isAgree = false; + + @override + Widget build(BuildContext context) { + ProjectViewModel projectProvider = Provider.of(context); + OrderPreviewViewModel cart = Provider.of(context); + return !(cart.cartResponse.shoppingCarts == null || + cart.cartResponse.shoppingCarts.length == 0) + ? Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + const Divider( + color: Color(0xFFD6D6D6), + height: 1, + thickness: 1, + indent: 0, + endIndent: 0, + ), + Container( + height: widget.height * 0.070, + color: Color(0xffe6ffe0), + padding: EdgeInsets.symmetric(horizontal: 4), + child: Row( + children: [ + InkWell( + onTap: () { + setState(() { + isAgree = !isAgree; + }); + }, + child: Container( + width: 25.0, + height: widget.height * 0.070, + decoration: new BoxDecoration( + color: !isAgree ? Color(0xffeeeeee) : Colors.green, + shape: BoxShape.circle, + ), + child: !isAgree + ? null + : Padding( + padding: const EdgeInsets.all(0.0), + child: Icon( + Icons.check, + color: Colors.white, + size: 25, + ), + ), + ), + ), + Expanded( + child: Container( + padding: EdgeInsets.symmetric(horizontal: 4), + margin: const EdgeInsets.symmetric(vertical: 4), + child: Texts( + TranslationBase.of(context) + .pharmacyServiceTermsCondition, + fontSize: 13, + color: Colors.grey.shade800, + fontWeight: FontWeight.normal, + ), + ), + ), + InkWell( + onTap: () => { + Navigator.push( + context, FadePage(page: PharmacyTermsConditions())) + }, + child: Container( + child: Icon( + Icons.info, + size: 25, + color: Color(0xff005aff), + ), + ), + ), + ], + ), + ), + Container( + height: widget.height * 0.065, + margin: EdgeInsets.symmetric(vertical: 2), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Container( + margin: EdgeInsets.symmetric( + horizontal: 0, vertical: 0), + child: Row( + children: [ + Texts( + "${TranslationBase.of(context).sar} ${(cart.cartResponse.subtotal).toStringAsFixed(2)}", + fontSize: projectProvider.isArabic ? 12 : 14, + fontWeight: FontWeight.bold, + ), + Padding( + padding: + const EdgeInsets.symmetric(horizontal: 4), + child: Texts( + "${TranslationBase.of(context).inclusiveVat}", + fontSize: 8, + color: Colors.grey, + fontWeight: FontWeight.bold, + ), + ), + ], + ), + ), + Texts( + "${cart.cartResponse.quantityCount} ${TranslationBase.of(context).items}", + fontSize: 10, + color: Colors.grey, + fontWeight: FontWeight.bold, + ), + ], + ), + ), + RaisedButton( + onPressed: isAgree + ? () => { + Navigator.push( + context, + FadePage( + page: + OrderPreviewPage(widget.addresses))) + } + : null, + child: new Text( + "${TranslationBase.of(context).checkOut}", + style: new TextStyle( + color: + isAgree ? Colors.white : Colors.grey.shade300, + fontSize: 14), + ), + color: Color(0xff005aff), + disabledColor: Color(0xff005aff), + ), + ], + ), + ), + ], + ) + : Container(); + } +} diff --git a/lib/pages/pharmacies/screens/cart-page/cart-order-preview.dart b/lib/pages/pharmacies/screens/cart-page/cart-order-preview.dart new file mode 100644 index 00000000..25c02dd0 --- /dev/null +++ b/lib/pages/pharmacies/screens/cart-page/cart-order-preview.dart @@ -0,0 +1,238 @@ +import 'package:diplomaticquarterapp/core/model/pharmacies/Addresses.dart'; +import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/screens/cart-page/payment_bottom_widget.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/screens/cart-page/select_address_widget.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/screens/cart-page/select_payment_option_widget.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/widgets/ProductOrderPreviewItem.dart'; +import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; +import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; +import 'package:diplomaticquarterapp/widgets/in_app_browser/InAppBrowser.dart'; +import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; + +import 'lakum_widget.dart'; + +class OrderPreviewPage extends StatefulWidget { + final List addresses; + + OrderPreviewPage(this.addresses); + + @override + _OrderPreviewPageState createState() => _OrderPreviewPageState(); +} + +class _OrderPreviewPageState extends State { + MyInAppBrowser browser; + bool isLoading = true; + + @override + void initState() { + super.initState(); + getData(); + } + + void getData() async { + if (isLoading) + await Provider.of(context, listen: false) + .getShoppingCart(); + setState(() { + isLoading = false; + }); + } + + @override + Widget build(BuildContext context) { + final mediaQuery = MediaQuery.of(context); + final height = mediaQuery.size.height - 60 - mediaQuery.padding.top; + OrderPreviewViewModel model = Provider.of(context); + return AppScaffold( + appBarTitle: "${TranslationBase.of(context).checkOut}", + isShowAppBar: true, + isPharmacy: true, + isShowDecPage: false, + isLoading: isLoading, + isLocalLoader: true, + backgroundColor: Colors.white, + // baseViewModel: model, + body: Container( + color: Color(0xFFF1F1F1), + height: height * 0.90, + child: SingleChildScrollView( + child: Container( + color: Color(0xFFF1F1F1), + child: Column( + children: [ + SelectAddressWidget(model, widget.addresses), + SizedBox( + height: 10, + ), + SelectPaymentOptionWidget(model), + SizedBox( + height: 10, + ), + model.paymentCheckoutData.lacumInformation != null + ? Container( + child: Column( + children: [ + LakumWidget(model), + SizedBox( + height: 10, + ), + ], + ), + ) + : Container(), + Container( + color: Colors.white, + width: double.infinity, + padding: EdgeInsets.all(8), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Texts( + TranslationBase.of(context).reviewOrder, + fontSize: 14, + fontWeight: FontWeight.bold, + color: Colors.black, + ), + ...List.generate( + model.cartResponse.shoppingCarts != null + ? model.cartResponse.shoppingCarts.length + : 0, + (index) => ProductOrderPreviewItem( + model.cartResponse.shoppingCarts[index]), + ), + ], + ), + ), + Container( + width: double.infinity, + padding: EdgeInsets.all(8), + child: model.cartResponse.subtotal != null + ? Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Texts( + TranslationBase.of(context).orderSummary, + fontSize: 14, + fontWeight: FontWeight.bold, + color: Colors.black, + ), + SizedBox( + height: 20, + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Texts( + "${TranslationBase.of(context).subtotal}", + fontSize: 14, + color: Colors.black, + fontWeight: FontWeight.w500, + ), + Texts( + "${TranslationBase.of(context).sar} ${(model.cartResponse.subtotal).toStringAsFixed(2)}", + fontSize: 14, + color: Colors.black, + fontWeight: FontWeight.w500, + ), + ], + ), + const Divider( + color: Color(0xFFD6D6D6), + height: 20, + thickness: 1, + indent: 0, + endIndent: 0, + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Texts( + "${TranslationBase.of(context).shipping}", + fontSize: 14, + color: Colors.black, + fontWeight: FontWeight.w500, + ), + Texts( + "${TranslationBase.of(context).sar} ${(model.totalAdditionalShippingCharge).toStringAsFixed(2)}", + fontSize: 14, + color: Colors.black, + fontWeight: FontWeight.w500, + ), + ], + ), + const Divider( + color: Color(0xFFD6D6D6), + height: 20, + thickness: 1, + indent: 0, + endIndent: 0, + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Texts( + "${TranslationBase.of(context).vat}", + fontSize: 14, + color: Colors.black, + fontWeight: FontWeight.w500, + ), + Texts( + "${TranslationBase.of(context).sar} ${(model.cartResponse.subtotalVatAmount).toStringAsFixed(2)}", + fontSize: 14, + color: Colors.black, + fontWeight: FontWeight.w500, + ), + ], + ), + const Divider( + color: Color(0xFFD6D6D6), + height: 20, + thickness: 1, + indent: 0, + endIndent: 0, + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Texts( + TranslationBase.of(context).total, + fontSize: 14, + color: Colors.black, + fontWeight: FontWeight.bold, + ), + Texts( + "${TranslationBase.of(context).sar} ${(model.cartResponse.subtotal).toStringAsFixed(2)}", + fontSize: 14, + color: Colors.black, + fontWeight: FontWeight.bold, + ), + ], + ), + SizedBox( + height: 10, + ), + ], + ) + : Container(), + ), + SizedBox( + height: model.cartResponse.shoppingCarts != null + ? height * 0.10 + : 0, + ) + ], + ), + ), + ), + ), + bottomSheet: Container( + height: model.cartResponse.shoppingCarts != null ? height * 0.10 : 0, + color: Colors.white, + child: PaymentBottomWidget(model), + ), + ); + } +} diff --git a/lib/pages/pharmacies/screens/cart-page/lakum_widget.dart b/lib/pages/pharmacies/screens/cart-page/lakum_widget.dart new file mode 100644 index 00000000..cdd26ddc --- /dev/null +++ b/lib/pages/pharmacies/screens/cart-page/lakum_widget.dart @@ -0,0 +1,187 @@ +import 'package:diplomaticquarterapp/core/enum/viewstate.dart'; +import 'package:diplomaticquarterapp/core/model/pharmacies/Addresses.dart'; +import 'package:diplomaticquarterapp/core/model/pharmacies/order_detail.dart'; +import 'package:diplomaticquarterapp/core/model/pharmacies/payment-checkout-data.dart'; +import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart'; +import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/order_model_view_model.dart'; +import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; +import 'package:diplomaticquarterapp/models/Appointments/AppoimentAllHistoryResultList.dart'; +import 'package:diplomaticquarterapp/models/Authentication/authenticated_user.dart'; +import 'package:diplomaticquarterapp/pages/base/base_view.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/screens/cart-page/payment_bottom_widget.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/screens/payment-method-select-page.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/widgets/ProductOrderPreviewItem.dart'; +import 'package:diplomaticquarterapp/pages/pharmacy/pharmacyAddresses/PharmacyAddresses.dart'; +import 'package:diplomaticquarterapp/uitl/app_toast.dart'; +import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; +import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; +import 'package:diplomaticquarterapp/widgets/in_app_browser/InAppBrowser.dart'; +import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; +import 'package:diplomaticquarterapp/widgets/others/network_base_view.dart'; +import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; + +class LakumWidget extends StatefulWidget { + final OrderPreviewViewModel model; + + LakumWidget(this.model); + + @override + _LakumWidgetState createState() => _LakumWidgetState(); +} + +class _LakumWidgetState extends State { + TextEditingController _pointsController = new TextEditingController(); + + @override + Widget build(BuildContext context) { + ProjectViewModel projectProvider = Provider.of(context); + + return Container( + color: Colors.white, + padding: EdgeInsets.symmetric(vertical: 12, horizontal: 12), + child: Row( + children: [ + Image.asset( + "assets/images/pharmacy_module/lakum/lakum_checkout.png", + width: 30.0, + fit: BoxFit.scaleDown, + ), + Container( + decoration: BoxDecoration(color: Color(0x99ffffff)), + padding: const EdgeInsets.symmetric(horizontal: 8), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Texts( + "${TranslationBase.of(context).lakumPoints}", + fontSize: 12, + fontWeight: FontWeight.bold, + ), + Texts( + "${widget.model.paymentCheckoutData.lacumInformation.lakumInquiryInformationObjVersion.pointsBalanceAmount}", + fontSize: 12, + fontWeight: FontWeight.normal, + ), + ], + ), + ), + Expanded( + child: Container( + decoration: BoxDecoration(color: Color(0x99ffffff)), + padding: const EdgeInsets.symmetric(horizontal: 8), + child: Row( + mainAxisAlignment: MainAxisAlignment.end, + children: [ + Texts( + "${TranslationBase.of(context).riyal}", + fontSize: 12, + fontWeight: FontWeight.bold, + ), + Container( + margin: projectProvider.isArabic + ? EdgeInsets.only(right: 4) + : EdgeInsets.only(left: 4), + width: 60, + height: 50, + child: TextField( + decoration: InputDecoration( + border: OutlineInputBorder( + borderSide: + BorderSide(color: Colors.black, width: 0.2), + gapPadding: 0, + borderRadius: projectProvider.isArabic + ? BorderRadius.only( + topRight: Radius.circular(8), + bottomRight: Radius.circular(8)) + : BorderRadius.only( + topLeft: Radius.circular(8), + bottomLeft: Radius.circular(8)), + ), + disabledBorder: OutlineInputBorder( + borderSide: + BorderSide(color: Colors.black, width: 0.4), + gapPadding: 0, + borderRadius: BorderRadius.only( + topLeft: Radius.circular(8), + bottomLeft: Radius.circular(8)), + ), + ), + controller: _pointsController, + keyboardType: TextInputType.number, + style: TextStyle( + fontSize: 14, + color: widget + .model + .paymentCheckoutData + .lacumInformation + .lakumInquiryInformationObjVersion + .pointsBalanceAmount > + 0 + ? Colors.black + : Colors.grey, + ), + enabled: widget + .model + .paymentCheckoutData + .lacumInformation + .lakumInquiryInformationObjVersion + .pointsBalanceAmount == + 0 + ? false + : true, + onChanged: (val) { + var value = int.tryParse(val); + if (value != null && + value <= + widget + .model + .paymentCheckoutData + .lacumInformation + .lakumInquiryInformationObjVersion + .pointsBalanceAmount) { + widget.model.paymentCheckoutData.usedLakumPoints = + value; + } else { + widget.model.paymentCheckoutData.usedLakumPoints = 0; + } + _pointsController.text = + "${widget.model.paymentCheckoutData.usedLakumPoints}"; + }, + ), + ), + Container( + height: 50, + padding: EdgeInsets.symmetric(horizontal: 8, vertical: 12), + decoration: new BoxDecoration( + color: Color(0xff3666E0), + shape: BoxShape.rectangle, + borderRadius: projectProvider.isArabic + ? BorderRadius.only( + topLeft: Radius.circular(6), + bottomLeft: Radius.circular(6)) + : BorderRadius.only( + topRight: Radius.circular(6), + bottomRight: Radius.circular(6)), + border: Border.fromBorderSide(BorderSide( + color: Color(0xff3666E0), + width: 0.8, + )), + ), + child: Texts( + "${TranslationBase.of(context).use}", + fontSize: 12, + color: Colors.white, + fontWeight: FontWeight.bold, + ), + ), + ], + ), + ), + ), + ], + ), + ); + } +} diff --git a/lib/pages/pharmacies/screens/cart-page/payment_bottom_widget.dart b/lib/pages/pharmacies/screens/cart-page/payment_bottom_widget.dart new file mode 100644 index 00000000..e0063878 --- /dev/null +++ b/lib/pages/pharmacies/screens/cart-page/payment_bottom_widget.dart @@ -0,0 +1,195 @@ +import 'package:diplomaticquarterapp/core/enum/viewstate.dart'; +import 'package:diplomaticquarterapp/core/model/pharmacies/order_detail.dart'; +import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart'; +import 'package:diplomaticquarterapp/models/Appointments/AppoimentAllHistoryResultList.dart'; +import 'package:diplomaticquarterapp/models/Authentication/authenticated_user.dart'; +import 'package:diplomaticquarterapp/uitl/app_toast.dart'; +import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; +import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; +import 'package:diplomaticquarterapp/widgets/in_app_browser/InAppBrowser.dart'; +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; + +class PaymentBottomWidget extends StatelessWidget { + final OrderPreviewViewModel model; + + BuildContext context; + MyInAppBrowser browser; + + PaymentBottomWidget(this.model); + + @override + Widget build(BuildContext context) { + final scaffold = Scaffold.of(context); + this.context = context; + OrderPreviewViewModel orderPreviewViewModel = Provider.of(context); + return Container( + margin: EdgeInsets.symmetric(horizontal: 10, vertical: 0), + child: orderPreviewViewModel.paymentCheckoutData.cartDataVisible + ? Container( + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + Container( + margin: + EdgeInsets.symmetric(horizontal: 0, vertical: 4), + child: Row( + children: [ + Texts( + "${TranslationBase.of(context).sar} ${(model.cartResponse.subtotal).toStringAsFixed(2)}", + fontSize: 14, + fontWeight: FontWeight.bold, + color: Color(0xff929295), + ), + Padding( + padding: + const EdgeInsets.symmetric(horizontal: 4), + child: Texts( + "${TranslationBase.of(context).inclusiveVat}", + fontSize: 8, + color: Color(0xff929295), + fontWeight: FontWeight.w600, + ), + ), + ], + ), + ), + Texts( + "${model.cartResponse.quantityCount} ${TranslationBase.of(context).items}", + fontSize: 10, + color: Colors.grey, + fontWeight: FontWeight.bold, + ), + ], + ), + Container( + child: RaisedButton( + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(8), + side: BorderSide( + color: Color(0xff929295), + width: 1, + ), + ), + onPressed: (orderPreviewViewModel + .paymentCheckoutData.address != + null && + orderPreviewViewModel + .paymentCheckoutData.paymentOption != + null) + ? () async { + await model.makeOrder(); + if (model.state == ViewState.Idle) { + AppToast.showSuccessToast( + message: + "Order has been placed successfully!!"); + openPayment( + model.orderListModel[0], model.user); + } else { + AppToast.showErrorToast(message: model.error); + } + Navigator.pop(context); + Navigator.pop(context); + } + : null, + child: Padding( + padding: const EdgeInsets.symmetric(vertical: 16), + child: new Text( + "${TranslationBase.of(context).proceedPay}", + style: new TextStyle( + color: (orderPreviewViewModel + .paymentCheckoutData.address != + null && + orderPreviewViewModel.paymentCheckoutData + .paymentOption != + null) + ? Colors.white + : Colors.grey.shade400, + fontWeight: FontWeight.bold, + fontSize: 12), + ), + ), + color: + (orderPreviewViewModel.paymentCheckoutData.address != + null && + orderPreviewViewModel + .paymentCheckoutData.paymentOption != + null) + ? Colors.green + : Color(0xff929295), + disabledColor: + (orderPreviewViewModel.paymentCheckoutData.address != + null && + orderPreviewViewModel + .paymentCheckoutData.paymentOption != + null) + ? Colors.green + : Color(0xff929295), + ), + ), + ], + ), + ) + : Container(), + ); + } + + openPayment( + OrderDetailModel order, + AuthenticatedUser authenticatedUser, + ) { + browser = new MyInAppBrowser( + onExitCallback: onBrowserExit, onLoadStartCallback: onBrowserLoadStart); + + browser.openPharmacyPaymentBrowser( + order, + order.orderTotal, + 'ePharmacy Order', + order.id, + order.billingAddress.email, + order.customValuesXml, + "${authenticatedUser.firstName} ${authenticatedUser.middleName} ${authenticatedUser.lastName}", + authenticatedUser.patientID, + authenticatedUser, + browser); + } + + onBrowserLoadStart(String url) { + print("onBrowserLoadStart"); + print(url); + + MyInAppBrowser.successURLS.forEach((element) { + if (url.contains(element)) { + if (browser.isOpened()) browser.close(); + MyInAppBrowser.isPaymentDone = true; + return; + } + }); + + MyInAppBrowser.errorURLS.forEach((element) { + if (url.contains(element)) { + if (browser.isOpened()) browser.close(); + MyInAppBrowser.isPaymentDone = false; + return; + } + }); + } + + onBrowserExit(AppoitmentAllHistoryResultList appo, bool isPaymentMade) { + print("onBrowserExit Called!!!!"); + if (isPaymentMade) { + AppToast.showSuccessToast( + message: "شكراً\nPayment status for your order is Paid"); + Navigator.pop(context); + Navigator.pop(context); + } else { + AppToast.showErrorToast( + message: + "Transaction Failed!\Your transaction is field to some reason please try again or contact to the administration"); + } + } +} diff --git a/lib/pages/pharmacies/screens/cart-page/select_address_widget.dart b/lib/pages/pharmacies/screens/cart-page/select_address_widget.dart new file mode 100644 index 00000000..bf958a36 --- /dev/null +++ b/lib/pages/pharmacies/screens/cart-page/select_address_widget.dart @@ -0,0 +1,226 @@ +import 'package:diplomaticquarterapp/core/enum/viewstate.dart'; +import 'package:diplomaticquarterapp/core/model/pharmacies/Addresses.dart'; +import 'package:diplomaticquarterapp/core/model/pharmacies/order_detail.dart'; +import 'package:diplomaticquarterapp/core/model/pharmacies/payment-checkout-data.dart'; +import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart'; +import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/order_model_view_model.dart'; +import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; +import 'package:diplomaticquarterapp/models/Appointments/AppoimentAllHistoryResultList.dart'; +import 'package:diplomaticquarterapp/models/Authentication/authenticated_user.dart'; +import 'package:diplomaticquarterapp/pages/base/base_view.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/screens/cart-page/payment_bottom_widget.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/screens/payment-method-select-page.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/widgets/ProductOrderPreviewItem.dart'; +import 'package:diplomaticquarterapp/pages/pharmacy/pharmacyAddresses/PharmacyAddresses.dart'; +import 'package:diplomaticquarterapp/uitl/app_toast.dart'; +import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; +import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; +import 'package:diplomaticquarterapp/widgets/in_app_browser/InAppBrowser.dart'; +import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; +import 'package:diplomaticquarterapp/widgets/others/network_base_view.dart'; +import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; + +class SelectAddressWidget extends StatefulWidget { + final OrderPreviewViewModel model; + final List addresses; + + SelectAddressWidget(this.model, this.addresses); + + @override + _SelectAddressWidgetState createState() => _SelectAddressWidgetState(); +} + +class _SelectAddressWidgetState extends State { + Addresses address; + + _navigateToAddressPage() { + Navigator.push(context, FadePage(page: PharmacyAddressesPage())) + .then((result) { + if (result != null) { + address = result; + widget.model.paymentCheckoutData.address = address; + widget.model.getInformationsByAddress(); + } + + /* setState(() { + if (result != null) { + address = result; + widget.model.paymentCheckoutData.address = address; + widget.model.getInformationsByAddress(); + } + })*/ + }); + } + + @override + void initState() { + if (widget.model.paymentCheckoutData.address != null) { + address = widget.model.paymentCheckoutData.address; + } + super.initState(); + } + + @override + Widget build(BuildContext context) { + OrderPreviewViewModel model = Provider.of(context); + return Container( + color: Colors.white, + child: address == null + ? InkWell( + onTap: () => {_navigateToAddressPage()}, + child: Container( + margin: EdgeInsets.symmetric(vertical: 12, horizontal: 12), + child: Row( + children: [ + Image.asset( + "assets/images/pharmacy_module/ic_shipping_address.png", + width: 30.0, + height: 30.0, + fit: BoxFit.scaleDown, + ), + Expanded( + child: Container( + padding: + EdgeInsets.symmetric(vertical: 0, horizontal: 6), + child: Texts( + TranslationBase.of(context).selectAddress, + fontSize: 14, + fontWeight: FontWeight.bold, + color: Color(0xff0000ff), + ), + ), + ), + Icon( + Icons.arrow_forward_ios, + size: 20, + color: Colors.grey.shade400, + ), + ], + ), + ), + ) + : Container( + child: Container( + margin: EdgeInsets.symmetric(vertical: 12, horizontal: 12), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + children: [ + Image.asset( + "assets/images/pharmacy_module/ic_shipping_mark.png", + width: 30.0, + height: 30.0, + fit: BoxFit.scaleDown, + ), + Expanded( + child: Container( + padding: EdgeInsets.symmetric( + vertical: 0, horizontal: 6), + child: Texts( + TranslationBase.of(context).shippingAddress, + fontSize: 14, + fontWeight: FontWeight.bold, + color: Colors.black, + ), + ), + ), + InkWell( + onTap: () => {_navigateToAddressPage()}, + child: Texts( + TranslationBase.of(context).changeAddress, + fontSize: 12, + fontWeight: FontWeight.normal, + color: Color(0xff0000ff), + ), + ), + ], + ), + Padding( + padding: const EdgeInsets.symmetric(vertical: 8), + child: Texts( + "${address.firstName} ${address.lastName}", + fontSize: 14, + fontWeight: FontWeight.bold, + color: Colors.black, + ), + ), + Padding( + padding: const EdgeInsets.symmetric(vertical: 8), + child: Texts( + "${address.address1} ${address.address2} ${address.address2},, ${address.city}, ${address.country} ${address.zipPostalCode}", + fontSize: 12, + fontWeight: FontWeight.normal, + color: Colors.grey.shade500, + ), + ), + Row( + children: [ + Container( + margin: const EdgeInsets.only(right: 8), + child: Icon( + Icons.phone, + size: 20, + color: Colors.black, + ), + ), + Texts( + "${address.phoneNumber}", + fontSize: 14, + fontWeight: FontWeight.bold, + color: Colors.grey, + ), + ], + ), + Container( + margin: EdgeInsets.symmetric(vertical: 8), + child: SizedBox( + height: 2, + width: double.infinity, + child: Container( + color: Color(0xffefefef), + ), + ), + ), + Row( + children: [ + Image.asset( + "assets/images/pharmacy_module/ic_shipping_truck.png", + width: 30.0, + height: 30.0, + fit: BoxFit.scaleDown, + ), + Container( + padding: + EdgeInsets.symmetric(vertical: 0, horizontal: 6), + child: Texts( + "${TranslationBase.of(context).shipBy}", + fontSize: 12, + fontWeight: FontWeight.bold, + color: Colors.black, + ), + ), + Container( + child: Image.asset( + model.paymentCheckoutData.shippingOption == null + ? "" + : model.paymentCheckoutData.shippingOption + .shippingRateComputationMethodSystemName == + "Shipping.FixedOrByWeight" + ? "assets/images/pharmacy_module/payment/hmg_shipping_logo.png" + : "assets/images/pharmacy_module/payment/aramex_shipping_logo.png", + fit: BoxFit.contain, + ), + margin: EdgeInsets.symmetric(horizontal: 8), + ), + ], + ), + ], + ), + ), + ), // ic_shipping_mark.png + ); + } +} diff --git a/lib/pages/pharmacies/screens/cart-page/select_payment_option_widget.dart b/lib/pages/pharmacies/screens/cart-page/select_payment_option_widget.dart new file mode 100644 index 00000000..9234bb38 --- /dev/null +++ b/lib/pages/pharmacies/screens/cart-page/select_payment_option_widget.dart @@ -0,0 +1,146 @@ +import 'package:diplomaticquarterapp/core/enum/viewstate.dart'; +import 'package:diplomaticquarterapp/core/model/pharmacies/Addresses.dart'; +import 'package:diplomaticquarterapp/core/model/pharmacies/order_detail.dart'; +import 'package:diplomaticquarterapp/core/model/pharmacies/payment-checkout-data.dart'; +import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart'; +import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/order_model_view_model.dart'; +import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; +import 'package:diplomaticquarterapp/models/Appointments/AppoimentAllHistoryResultList.dart'; +import 'package:diplomaticquarterapp/models/Authentication/authenticated_user.dart'; +import 'package:diplomaticquarterapp/pages/base/base_view.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/screens/cart-page/payment_bottom_widget.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/screens/payment-method-select-page.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/widgets/ProductOrderPreviewItem.dart'; +import 'package:diplomaticquarterapp/pages/pharmacy/pharmacyAddresses/PharmacyAddresses.dart'; +import 'package:diplomaticquarterapp/uitl/app_toast.dart'; +import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; +import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; +import 'package:diplomaticquarterapp/widgets/in_app_browser/InAppBrowser.dart'; +import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; +import 'package:diplomaticquarterapp/widgets/others/network_base_view.dart'; +import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; + +class SelectPaymentOptionWidget extends StatefulWidget { + final OrderPreviewViewModel model; + + SelectPaymentOptionWidget(this.model); + + @override + _SelectPaymentOptionWidgetState createState() => + _SelectPaymentOptionWidgetState(); +} + +class _SelectPaymentOptionWidgetState extends State { + PaymentOption paymentOption; + + _navigateToPaymentOption() { + Navigator.push(context, FadePage(page: PaymentMethodSelectPage())) + .then((result) => { + setState(() { + if (result != null) { + paymentOption = result; + widget.model.paymentCheckoutData.paymentOption = + paymentOption; + } + }) + }); + } + + @override + void initState() { + if (widget.model.paymentCheckoutData.paymentOption != null) { + paymentOption = widget.model.paymentCheckoutData.paymentOption; + } + super.initState(); + } + + @override + Widget build(BuildContext context) { + return Container( + color: Colors.white, + child: paymentOption == null + ? InkWell( + onTap: () => {_navigateToPaymentOption()}, + child: Container( + margin: EdgeInsets.symmetric(vertical: 12, horizontal: 12), + child: Row( + children: [ + Image.asset( + "assets/images/pharmacy_module/ic_payment_option.png", + width: 30.0, + height: 30.0, + fit: BoxFit.scaleDown, + ), + Expanded( + child: Container( + padding: + EdgeInsets.symmetric(vertical: 0, horizontal: 6), + child: Texts( + TranslationBase.of(context).selectPaymentOption, + fontSize: 14, + fontWeight: FontWeight.bold, + color: Color(0xff0000ff), + ), + ), + ), + Icon( + Icons.arrow_forward_ios, + size: 20, + color: Colors.grey.shade400, + ), + ], + ), + ), + ) + : Container( + margin: EdgeInsets.symmetric(vertical: 12, horizontal: 12), + child: Row( + children: [ + Image.asset( + "assets/images/pharmacy_module/ic_payment_option.png", + width: 30.0, + height: 30.0, + fit: BoxFit.scaleDown, + ), + Container( + margin: EdgeInsets.symmetric(horizontal: 8), + padding: EdgeInsets.symmetric(horizontal: 4, vertical: 0), + decoration: new BoxDecoration( + color: Colors.grey.shade100, + shape: BoxShape.rectangle, + ), + child: Image.asset( + widget.model.getPaymentOptionImage(paymentOption), + width: 30.0, + height: 30.0, + fit: BoxFit.scaleDown, + ), + ), + Expanded( + child: Container( + padding: EdgeInsets.symmetric(vertical: 0, horizontal: 6), + child: Texts( + widget.model.getPaymentOptionName(paymentOption), + fontSize: 14, + fontWeight: FontWeight.bold, + color: Colors.black, + ), + ), + ), + InkWell( + onTap: () => {_navigateToPaymentOption()}, + child: Texts( + TranslationBase.of(context).changeMethod, + fontSize: 12, + fontWeight: FontWeight.normal, + color: Color(0xff0000ff), + ), + ), + ], + ), + ), + ); + } +} diff --git a/lib/pages/pharmacies/screens/pharmacy_module_page.dart b/lib/pages/pharmacies/screens/pharmacy_module_page.dart index e8ca6caa..392dc187 100644 --- a/lib/pages/pharmacies/screens/pharmacy_module_page.dart +++ b/lib/pages/pharmacies/screens/pharmacy_module_page.dart @@ -1,8 +1,8 @@ +import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart'; import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; import 'package:diplomaticquarterapp/config/size_config.dart'; import 'package:diplomaticquarterapp/core/model/pharmacies/recommendedProduct_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/pharmacy_module_view_model.dart'; -import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/product_detail_view_model.dart'; import 'package:diplomaticquarterapp/pages/base/base_view.dart'; import 'package:diplomaticquarterapp/pages/medical/prescriptions/prescriptions_home_page.dart'; import 'package:diplomaticquarterapp/pages/offers_categorise_page.dart'; @@ -17,9 +17,15 @@ import 'package:diplomaticquarterapp/uitl/date_uitl.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/widgets/buttons/borderedButton.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/widgets/home/BannerPager.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/widgets/home/BestSellerWidget.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/widgets/home/GridViewButtons.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/widgets/home/PrescriptionsWidget.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/widgets/home/RecentlyViewedWidget.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/widgets/home/ShopByBrandWidget.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; -import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; import 'package:hexcolor/hexcolor.dart'; import 'package:rating_bar/rating_bar.dart'; @@ -36,40 +42,25 @@ dynamic languageID; List wishlistData; class PharmacyPage extends StatefulWidget { -// final PharmacyProduct product; -// PharmacyPage(this.product); - @override _PharmacyPageState createState() => _PharmacyPageState(); } class _PharmacyPageState extends State { -// dynamic wishlistVar; - - getLanguageID() async { - languageID = await sharedPref.getString(APP_LANGUAGE); - } - -// List recommendedProductList = []; - List wishList = []; - - var model; -// String ProductId="4561"; - //String id ="3608"; - String productId = ""; - String id = ""; - @override - void initState() { - checkWishlist(); - // userInfo(widget.product.id, widget.product); - userInfo(id, product); - getLanguageID(); - } - @override Widget build(BuildContext context) { - return BaseView( - onModelReady: (model) => model.getPharmacyHomeData(), + OrderPreviewViewModel orderPreviewViewModel = Provider.of(context); + return WillPopScope( + onWillPop: ()async{ + return false; + }, + child:BaseView( + onModelReady: (model) async { + await model.getSavedLanguage(); + await model.getBannerList(); + if(model.isLogin) + await orderPreviewViewModel.getShoppingCart(); + }, allowAny: true, builder: (_, model, wi) => AppScaffold( title: "", @@ -81,868 +72,19 @@ class _PharmacyPageState extends State { width: double.infinity, child: SingleChildScrollView( child: Column( - crossAxisAlignment: CrossAxisAlignment.start, + //crossAxisAlignment: CrossAxisAlignment.start, children: [ BannerPager(model), - // GridViewButtons(model), - Container( - margin: EdgeInsets.fromLTRB(10, 10, 10, 10), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Texts( - TranslationBase.of(context).myPrescription, - bold: true, - ), - BorderedButton( - TranslationBase.of(context).viewAll, - hasBorder: true, - borderColor: Colors.green, - textColor: Colors.green, - vPadding: 6, - hPadding: 4, - handler: () { - Navigator.push( - context, FadePage(page: HomePrescriptionsPage())); - }, - ), - ], - ), - ), - Container( - height: model.prescriptionsList.length > 0 - ? MediaQuery.of(context).size.height * 0.28 - : 0, - padding: - EdgeInsets.symmetric(horizontal: 18.0, vertical: 14.0), -// height: MediaQuery.of(context).size.height * 0.28, -// width: 200.0, -// height: MediaQuery.of(context).size.height / 4 + 20, - margin: EdgeInsets.only(left: 10), - child: BaseView( - onModelReady: (model) => model.getPrescription(), - builder: (_, model, wi) => model.prescriptionsList.length != - 0 -// model.getPrescription(); - ? ListView.builder( - scrollDirection: Axis.horizontal, - shrinkWrap: true, - physics: ScrollPhysics(), - // physics: NeverScrollableScrollPhysics(), - itemCount: model.prescriptionsList.length, - itemBuilder: (context, index) { - return Container( -// width: 160.0, - height: - MediaQuery.of(context).size.height * 0.3, - padding: EdgeInsets.only( - bottom: 5.0, left: 5.0, right: 8.0), - margin: EdgeInsets.only(right: 10.0), - decoration: BoxDecoration( - border: Border.all( - color: Colors.grey, - style: BorderStyle.solid, - width: 1.0, - ), - color: Colors.white, - borderRadius: BorderRadius.circular(10.0)), - child: Column( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Row( - children: [ - Column(children: [ - Container( - padding: EdgeInsets.only( - top: 10.0, - left: 10.0, - right: 10.0, - bottom: 15.0, - ), - child: CircleAvatar( - radius: 30, - backgroundColor: - Colors.transparent, - child: Image.network( - model.prescriptionsList[index] - .doctorImageURL, - width: 60, - height: 60, - ), - ), - ), - ]), -// Column( -// // crossAxisAlignment: CrossAxisAlignment.center, -// children: [ -// Container( -// margin: EdgeInsets.only(left: 1), -// padding: EdgeInsets.only( -// top: 10.0, -// left: 10.0, -// right: 3.0, -// bottom: 15.0, -// ), -// child: Image.network( -// model.prescriptionsList[index] -// .doctorImageURL, -// width: 60, -// height: 60, -// ), -// ), -// ]), - Column( -// crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Container( - margin: - EdgeInsets.only(left: 1), - padding: EdgeInsets.only( - left: 15.0, right: 15.0), - decoration: BoxDecoration( - border: Border.all( - color: Colors.green, - style: - BorderStyle.solid, - width: 4.0, - ), - color: Colors.green, - borderRadius: - BorderRadius.circular( - 30.0)), - child: Text( - languageID == "ar" - ? model.prescriptionsList[index].isInOutPatientDescriptionN.toString() - : model.prescriptionsList[index].isInOutPatientDescription.toString(), - style: TextStyle( - color: Colors.white, - fontSize: 15.0, -// fontWeight: FontWeight.bold, - ), - )), - Row(children: [ - Image.asset( - 'assets/images/Icon-awesome-calendar.png', - width: 30, - height: 30, - ), - Text( - DateUtil.convertStringToDate( - model - .prescriptionsList[ - index] - .appointmentDate - .toString()) - .toString() - .substring(0, 10), - style: TextStyle( - color: Colors.black, - fontSize: 15.0, -// fontWeight: FontWeight.bold, - ), - ) - ]), - ], - ), - ], - ), - Row( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Container( - margin: EdgeInsets.only(left: 5), - child: Row(children: [ - Text( - model.prescriptionsList[index] - .doctorTitle - .toString(), - style: TextStyle( - color: Colors.black, - fontSize: 15.0, - fontWeight: FontWeight.bold, - ), - ), - Text( - model.prescriptionsList[index] - .doctorName - .toString(), - style: TextStyle( - color: Colors.black, - fontSize: 15.0, - fontWeight: FontWeight.bold, - ), - ), - ]), - ), - ], - ), - Row( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Container( - margin: EdgeInsets.only(left: 5), - child: Text( - model.prescriptionsList[index] - .clinicDescription - .toString(), - style: TextStyle( - color: Colors.green, - fontSize: 15.0, -// fontWeight: FontWeight.bold, - ), - ), - ), - ], - ), - Row( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Container( - margin: EdgeInsets.only(left: 5), - child: Align( - alignment: Alignment.topLeft, - child: RatingBar.readOnly( - initialRating: model - .prescriptionsList[index] - .actualDoctorRate - .toDouble(), -// initialRating: productRate, - size: 15.0, - filledColor: - Colors.yellow[700], - emptyColor: Colors.grey[500], - isHalfAllowed: true, - halfFilledIcon: - Icons.star_half, - filledIcon: Icons.star, - emptyIcon: Icons.star, - ), - ), - ) - ]), - ]), - ); - }) - : Container(), - ), - ), -// Container( -// margin: EdgeInsets.fromLTRB(10, 10, 10, 10), -// child: Row( -// mainAxisAlignment: MainAxisAlignment.spaceBetween, -// children: [ -// Texts( -// TranslationBase.of(context).recommended, -// bold: true, -// ), -// BorderedButton( -// TranslationBase.of(context).viewAll, -// hasBorder: true, -// borderColor: Colors.green, -// textColor: Colors.green, -// vPadding: 6, -// hPadding: 4, -// handler: () { -// Navigator.push( -// context, -// MaterialPageRoute( -// builder: (context) => -// RecommendedProductPage(productId : "2316"))); -// }, -// ), -// ], -// ), -// ), -// Container( -// height: model.recommendedProductList.length > 0 -// ? MediaQuery.of(context).size.height * 0.32 -// : 0, -// margin: EdgeInsets.symmetric(horizontal: 6, vertical: 4), -//// padding: EdgeInsets.symmetric(horizontal: 5.0, vertical: 22.0), -//// margin: EdgeInsets.only(left: 10), -// child: BaseView( -// onModelReady: (model) => -// model.getRecommendedProducts(productId), -// builder: (_, model, wi) => model -// .recommendedProductList.length != -// null -// ? ListView.builder( -// scrollDirection: Axis.horizontal, -// shrinkWrap: true, -// physics: ScrollPhysics(), -// // physics: NeverScrollableScrollPhysics(), -// itemCount: model.recommendedProductList.length, -// itemBuilder: (context, index) { -// return Card( -// elevation: 2, -// shape: RoundedRectangleBorder( -// side: BorderSide( -// color: Colors.grey[300], width: 2), -// borderRadius: BorderRadius.circular(10)), -// margin: EdgeInsets.symmetric( -// horizontal: 8, -// vertical: 0, -// ), -// child: Container( -// decoration: BoxDecoration( -// borderRadius: BorderRadius.all( -// Radius.circular(15), -// ), -// ), -// padding: EdgeInsets.symmetric(horizontal: 4), -// width: MediaQuery.of(context).size.width / 3, -// child: Column( -// crossAxisAlignment: -// CrossAxisAlignment.start, -// children: [ -// Stack(children: [ -// Container( -// child: Align( -// alignment: Alignment.topRight, -// child: //true -// itemID.contains(model.recommendedProductList[index].id) -// // !isInWishlist -// ? IconButton( -// icon: Icon(Icons -// .favorite_border), -// color: Colors.grey, -// iconSize: 30, -// onPressed: () { -// setState(() { -// addToWishlistFunction( -// itemID); -// }); -// }, -// ) -// : IconButton( -// icon: Icon( -// Icons.favorite), -// color: Colors.red, -// iconSize: 30, -// onPressed: () { -// setState(() { -// deleteFromWishlistFunction( -// itemID); -// }); -// }, -// ) -//// -// ), -// ), -// Container( -// margin: EdgeInsets.fromLTRB( -// 0, 16, 10, 16), -// alignment: Alignment.center, -//// padding: EdgeInsets.only(left: 25, bottom: 20), -// child: (model.recommendedProductList[index].images != null && -// model.recommendedProductList[index].images.length > 0) -// ? Image.network( -// model.recommendedProductList[index].images[0].src.toString(), -//// item.images[0].src, -// fit: BoxFit.cover, -// height: 60, -// ) -// : Image.asset( -// "assets/images/no_image.png", -// fit: BoxFit.cover, -// height: 60, -// ), -// ), -// Container( -// width: model -// .recommendedProductList[ -// index] -// .rxMessage != -// null -// ? MediaQuery.of(context) -// .size -// .width / -// 5 -// : 0, -// padding: EdgeInsets.all(4), -// decoration: BoxDecoration( -// color: Color(0xffb23838), -// borderRadius: BorderRadius.only( -// topLeft: Radius.circular(6)), -// ), -// child: Texts( -// model.recommendedProductList[index] -// .rxMessage != -// null -// ? model -// .recommendedProductList[ -// index] -// .rxMessage -// : "", -// color: Colors.white, -// regular: true, -// fontSize: 10, -// fontWeight: FontWeight.w400, -// ), -// ), -// ]), -// Container( -// margin: EdgeInsets.symmetric( -// horizontal: 6, -// vertical: 0, -// ), -// child: Column( -// crossAxisAlignment: -// CrossAxisAlignment.start, -// children: [ -// Text( -// languageID == "ar" -// ? model.recommendedProductList[index].namen -// : model.recommendedProductList[index].name, -// style: TextStyle( -// color: Colors.black, -// fontSize: 13.0, -//// fontWeight: FontWeight.bold, -// ), -// ), -// Padding( -//// padding: const EdgeInsets.only(top: 15, bottom: 10), -// padding: const EdgeInsets.only( -// top: 10, bottom: 5), -// child: Texts( -// "SAR ${model.recommendedProductList[index].price}", -// bold: true, -// fontSize: 14, -// ), -// ), -// ], -// ), -// ), -// Row( -// crossAxisAlignment: -// CrossAxisAlignment.start, -// children: [ -// Container( -// padding: -// EdgeInsets.only(right: 10), -//// margin: EdgeInsets.only(left: 5), -// child: Align( -// alignment: Alignment.topLeft, -// child: RatingBar.readOnly( -// initialRating: model -// .recommendedProductList[ -// index] -// .approvedRatingSum -// .toDouble(), -//// initialRating: productRate, -// size: 13.0, -// filledColor: -// Colors.yellow[700], -// emptyColor: Colors.grey[500], -// isHalfAllowed: true, -// halfFilledIcon: -// Icons.star_half, -// filledIcon: Icons.star, -// emptyIcon: Icons.star, -// ), -// ), -// ), -// Texts( -// "(${model.recommendedProductList[index].approvedTotalReviews.toString()})", -//// bold: true, -// fontSize: 12, -// ), -// ]), -// ], -// ), -// ), -// ); -// }) -// : Container( -//// child: Text("NO DATA"), -// ), -// ), -// ), - Container( - margin: EdgeInsets.fromLTRB(10, 10, 10, 0), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Texts( - TranslationBase.of(context).shopByBrands, - bold: true, - ), - BorderedButton( - TranslationBase.of(context).viewAll, - hasBorder: true, - vPadding: 6, - hPadding: 4, - borderColor: Colors.green, - textColor: Colors.green, - handler: () => { - Navigator.push( - context, FadePage(page: ProductBrandsPage())), - }, - ), - ], - ), - ), - Container( - height: 60, - child: ListView.builder( - itemBuilder: (ctx, i) => - ManufacturerItem(model.manufacturerList[i]), - scrollDirection: Axis.horizontal, - itemCount: model.manufacturerList.length, - ), - ), - Container( - margin: EdgeInsets.fromLTRB(10, 10, 10, 10), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Texts( - TranslationBase.of(context).recentlyViewed, - bold: true, - ), - BorderedButton( - TranslationBase.of(context).viewAll, - hasBorder: true, - vPadding: 6, - hPadding: 4, - borderColor: Colors.green, - textColor: Colors.green, - handler: () { - Navigator.push( - context, - FadePage( - page: FinalProductsPage( - id: "", - productType: 3, - ), - ), - ); - }, - ), - ], - ), - ), - Container( - height: model.lastVisitedProducts.length > 0 - ? MediaQuery.of(context).size.height / 4 + 20 - : 0, - child: ListView.builder( - itemBuilder: (ctx, i) => - ProductTileItem(model.lastVisitedProducts[i]), - scrollDirection: Axis.horizontal, - itemCount: model.lastVisitedProducts.length, - ), - ), - Container( - margin: EdgeInsets.fromLTRB(10, 10, 10, 10), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Texts( - TranslationBase.of(context).bestSellers, - bold: true, - ), - BorderedButton( - TranslationBase.of(context).viewAll, - hasBorder: true, - borderColor: Colors.green, - textColor: Colors.green, - vPadding: 6, - hPadding: 4, - handler: () => { - Navigator.push( - context, - FadePage( - page: FinalProductsPage( - id: "", - productType: 4, - ), - ), - ), - }, - ), - ], - ), - ), - Container( - height: MediaQuery.of(context).size.height / 4 + 20, - child: ListView.builder( - itemBuilder: (ctx, i) => - ProductTileItem(model.bestSellerProduct[i]), - scrollDirection: Axis.horizontal, - itemCount: model.bestSellerProduct.length, - ), - ), - ], + GridViewButtons(model), + PrescriptionsWidget(), + ShopByBrandWidget(), + RecentlyViewedWidget(), + BestSellerWidget(), + ],), ), ), ), ), ); } - - addToWishlistFunction(itemID) async { - ProductDetailViewModel x = new ProductDetailViewModel(); - isInWishlist = true; - await x.addToWishlistData(itemID); - } - - deleteFromWishlistFunction(itemID) async { - ProductDetailViewModel x = new ProductDetailViewModel(); - isInWishlist = false; - await x.addToWishlistData(itemID); - } - - checkWishlist() async { - ProductDetailViewModel x = new ProductDetailViewModel(); - await x.checkWishlistData(); - for (int i = 0; i < x.wishListItems.length; i++) { - // itemID = x.wishListItems[i].id; - print("-------------wishlist---------------"); - print(itemID); -// print(product.id); - print(x.wishListItems[i].productId); - if (itemID == x.wishListItems[i].productId) { - isInWishlist = true; -// print('in wishlist'); - break; - } else { - isInWishlist = false; -// print('not in wishlist'); - } - } - } - - Future userInfo(id, product) async { - customerId = await sharedPref.getString(PHARMACY_CUSTOMER_ID); - if (customerId != null) { - itemID = id; - product = product; - checkWishlist(); - } - print("customerId:$customerId"); - return customerId; - } -} - -class GridViewButtons extends StatelessWidget { - final PharmacyModuleViewModel model; - - GridViewButtons(this.model); - - @override - Widget build(BuildContext context) { - final gridHeight = (MediaQuery.of(context).size.width * 0.3) * 1.8; - return Container( - child: SizedBox( - height: gridHeight, - child: GridView.count( - childAspectRatio: 2.2, - crossAxisSpacing: 10, - mainAxisSpacing: 10, - controller: new ScrollController(keepScrollOffset: false), - shrinkWrap: true, - padding: const EdgeInsets.all(4.0), - crossAxisCount: 2, - children: [ - DashboardItem( - imageName: 'pharmacy_module/bg_1.png', - hasColorFilter: false, - opacity: 0.8, - child: GridViewCard( - TranslationBase.of(context).offersAndPromotions, - 'assets/images/pharmacy_module/offer_icon.png', () { - Navigator.push(context, FadePage(page: OffersCategorisePage())); - }), - ), - DashboardItem( - imageName: 'pharmacy_module/bg_2.png', - opacity: 0, - hasColorFilter: false, - child: GridViewCard(TranslationBase.of(context).medicationRefill, - 'assets/images/pharmacy_module/medication_icon.png', () { - model.checkUserIsActivated().then((isActivated) { - if (isActivated) { - Navigator.push(context, FadePage(page: LakumMainPage())); - } else { - Navigator.push( - context, FadePage(page: LakumActivationVidaPage())); - } - }); - }), - ), - DashboardItem( - imageName: 'pharmacy_module/bg_3.png', - opacity: 0, - hasColorFilter: false, - child: GridViewCard(TranslationBase.of(context).myPrescriptions, - 'assets/images/pharmacy_module/prescription_icon.png', () { - Navigator.push( - context, FadePage(page: PharmacyAddressesPage())); - }), - ), - DashboardItem( - imageName: 'pharmacy_module/bg_4.png', - opacity: 0, - hasColorFilter: false, - child: GridViewCard( - TranslationBase.of(context).searchAndScanMedication, - 'assets/images/pharmacy_module/search_scan_icon.png', - () {}), - ), - ], - ), - ), - ); - } } -class DashboardItem extends StatelessWidget { - const DashboardItem({this.hasBorder = false, this.imageName, @required this.child, this.onTap, Key key, this.width, this.height, this.color, this.opacity = 0.4, this.hasColorFilter = true}) - : super(key: key); - final bool hasBorder; - final String imageName; - final Widget child; - final Function onTap; - final double width; - final double height; - final Color color; - final double opacity; - final bool hasColorFilter; - - @override - Widget build(BuildContext context) { - return InkWell( - onTap: onTap, - child: Container( - width: width != null ? width : MediaQuery.of(context).size.width * 0.29, - height: height != null - ? height - : MediaQuery.of(context).orientation == Orientation.portrait - ? MediaQuery.of(context).size.height * 0.17 - : MediaQuery.of(context).size.height * 0.35, - decoration: BoxDecoration( - color: !hasBorder - ? color != null - ? color - : HexColor('#050705').withOpacity(opacity) - : Colors.white, - borderRadius: BorderRadius.circular(6.0), - border: hasBorder ? Border.all(width: 1.0, color: const Color(0xffcccccc)) : Border.all(width: 0.0, color: Colors.transparent), - image: imageName != null - ? DecorationImage( - image: ExactAssetImage('assets/images/$imageName'), - fit: BoxFit.cover, - colorFilter: hasColorFilter ? new ColorFilter.mode(Colors.black.withOpacity(0.2), BlendMode.dstIn) : null, - ) - : null, - ), - child: Center( - child: child, - ), - ), - ); - } -} - - -class GridViewCard extends StatelessWidget { - final String text; - final String cardImage; - final Function handler; - - GridViewCard(this.text, this.cardImage, this.handler); - - @override - Widget build(BuildContext context) { - return Padding( - padding: const EdgeInsets.all(4.0), - child: Container( - child: Row( - children: [ - Expanded( - flex: 2, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Expanded( - flex: 2, - child: Padding( - padding: const EdgeInsets.all(6), - child: Texts( - text, - color: Colors.white, - fontSize: SizeConfig.textMultiplier * 1.5, - ), - ), - ), - Row( - children: [ - BorderedButton( - TranslationBase.of(context).viewAll, - handler: handler, - tPadding: 0, - bPadding: 0, - ), - Expanded(child: Container()), - ], - ), - ], - ), - ), - Expanded( - child: Align( - alignment: Alignment.centerRight, - child: Image.asset( - cardImage, - fit: BoxFit.cover, - ), - ), - ), - ], - ), - ), - ); - } - - String getDate(String date) { - DateTime dateObj = DateUtil.convertStringToDate(date); - return DateUtil.getWeekDay(dateObj.weekday) + - ", " + - dateObj.day.toString() + - " " + - DateUtil.getMonth(dateObj.month) + - " " + - dateObj.year.toString(); - } -} - -class test extends StatefulWidget { - @override - _testState createState() => _testState(); -} - -class _testState extends State { - @override - Widget build(BuildContext context) { - return Container(); - } -} -//addWishlistData() async { -// ProductDetailViewModel x = new ProductDetailViewModel(); -// await wishlistData.add(x.checkWishlistData()); -// print("-------------testWishlist---------------"); -// -//} - -// checkWishlist() async { -// ProductDetailViewModel x = new ProductDetailViewModel(); -// wishlistVar = await x.checkWishlistData(); -// print("wishlistVar>>>>>>>>>>>>>>>"); -// print(wishlistVar); -// -// } diff --git a/lib/pages/pharmacies/screens/product-details/availability_info.dart b/lib/pages/pharmacies/screens/product-details/availability_info.dart new file mode 100644 index 00000000..9e717de6 --- /dev/null +++ b/lib/pages/pharmacies/screens/product-details/availability_info.dart @@ -0,0 +1,90 @@ +import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/product_detail_view_model.dart'; +import 'package:diplomaticquarterapp/pages/base/base_view.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/product-detail.dart'; +import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; +import 'package:diplomaticquarterapp/widgets/others/network_base_view.dart'; +import 'package:flutter/material.dart'; + +class AvailabilityInfo extends StatelessWidget { + final ProductDetailViewModel previousModel; + + const AvailabilityInfo({Key key, this.previousModel}) : super(key: key); + @override + Widget build(BuildContext context) { + return previousModel.productLocationService.length == 0 + ? Container( + padding: EdgeInsets.all(15), + alignment: Alignment.center, + child: Text( + TranslationBase.of(context).noLocationAvailable, + ), + ) + : ListView.builder( + physics: ScrollPhysics(), + scrollDirection: Axis.vertical, + shrinkWrap: true, + itemCount: previousModel.productLocationService.length, + itemBuilder: (BuildContext context, int index) { + return Padding( + padding: EdgeInsets.all(8.0), + child: Column( + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Expanded( + flex: 1, + child: Image.network(previousModel + .productLocationService[index].projectImageUrl), + ), + SizedBox( + width: 10, + ), + Expanded( + flex: 4, + child: Text( + previousModel.productLocationService[index] + .locationDescription + + "\n" + + convertCityName( + previousModel.productLocationService[0].cityName + .toString(), + ), + style: TextStyle(fontSize: 12), + ), + ), + Expanded( + flex: 1, + child: IconButton( + icon: Icon(Icons.location_on), + color: Colors.red, + onPressed: () {}, + ), + ), + Expanded( + flex: 1, + child: IconButton( + icon: Icon(Icons.phone), + color: Colors.red, + onPressed: () {}, + ), + ), + ], + ), + Divider(height: 1.2, color: Colors.grey) + ], + ), + ); + }, + ); + } + + convertCityName(txt) { + String stringTxt; + String newTxt; + stringTxt = txt.toString(); + newTxt = stringTxt.split('.')[1]; + + return newTxt; + } +} diff --git a/lib/pages/pharmacies/screens/product-details/details_info.dart b/lib/pages/pharmacies/screens/product-details/details_info.dart new file mode 100644 index 00000000..bc5e7f80 --- /dev/null +++ b/lib/pages/pharmacies/screens/product-details/details_info.dart @@ -0,0 +1,56 @@ +import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart'; +import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; +import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; +import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; + +class DetailsInfo extends StatelessWidget { + + final PharmacyProduct product; + + const DetailsInfo({Key key, this.product}) : super(key: key); + + + @override + Widget build(BuildContext context) { + ProjectViewModel projectViewModel = Provider.of(context); + return Padding( + padding: const EdgeInsets.all(8.0), + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Container( + child: Texts( + TranslationBase.of(context) + .description, + fontSize: 17, + color: Colors.grey, + ), + ), + SizedBox( + height: 10, + ), + Divider(height: 1, color: Colors.grey), + SizedBox( + height: 15, + ), + Container( + child: Texts( + projectViewModel.isArabic + ? product.fullDescriptionn + : product + .fullDescription ?? + "", + fontSize: 16, + ), + ), + SizedBox( + height: 20, + ), + ]), + ); + } +} diff --git a/lib/pages/pharmacies/screens/product-details/discount_description.dart b/lib/pages/pharmacies/screens/product-details/discount_description.dart new file mode 100644 index 00000000..1dde8175 --- /dev/null +++ b/lib/pages/pharmacies/screens/product-details/discount_description.dart @@ -0,0 +1,47 @@ +import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart'; +import 'package:flutter/material.dart'; + +class DiscountDescription extends StatelessWidget { + final PharmacyProduct product; + + const DiscountDescription({Key key, this.product}) : super(key: key); + @override + Widget build(BuildContext context) { + return Container( + width: double.infinity, + height: 50, + color: Colors.yellowAccent, + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Expanded( + flex: 1, + child: Container( + alignment: Alignment.centerRight, + child: Text( + product + .discountDescription, + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 17), + ), + ), + ), + SizedBox( + width: 10, + ), + Expanded( + flex: 0, + child: Container( + child: Image( + image: AssetImage( + 'assets/images/offer.png'), + ), + ), + ), + ], + ), + ); + } +} diff --git a/lib/pages/pharmacies/screens/product-details/footor/footer-widget.dart b/lib/pages/pharmacies/screens/product-details/footor/footer-widget.dart new file mode 100644 index 00000000..3a3eba23 --- /dev/null +++ b/lib/pages/pharmacies/screens/product-details/footor/footer-widget.dart @@ -0,0 +1,258 @@ +import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart'; +import 'package:diplomaticquarterapp/core/service/AuthenticatedUserObject.dart'; +import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/product_detail_view_model.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/footor/quantity_box.dart'; +import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; +import 'package:diplomaticquarterapp/widgets/buttons/secondary_button.dart'; +import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; +import 'package:flutter/material.dart'; +import 'package:hexcolor/hexcolor.dart'; + +import '../../../../../locator.dart'; +import '../../../../../routes.dart'; +import '../../cart-page/cart-order-page.dart'; +import '../product-detail.dart'; + +class FooterWidget extends StatefulWidget { + final bool isAvailable; + final int maxQuantity; + final int minQuantity; + final int quantityLimit; + final PharmacyProduct item; + final Function addToCartFunction; + final ProductDetailViewModel model; + + int quantity; + bool isOverQuantity; + + FooterWidget(this.isAvailable, this.maxQuantity, this.minQuantity, + this.quantityLimit, this.item, + {this.quantity, + this.isOverQuantity = false, + this.addToCartFunction, + this.model}); + + @override + _FooterWidgetState createState() => _FooterWidgetState(); +} + +class _FooterWidgetState extends State { + double quantityUI = 80; + bool showUI = false; + AuthenticatedUserObject authenticatedUserObject = + locator(); + + @override + Widget build(BuildContext context) { + return Container( + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.all( + Radius.circular(0.0), + ), + border: Border.all(color: HexColor('#707070'), width: 0), + ), + width: double.infinity, + height: quantityUI, + child: Column( + children: [ + showUI + ? Container( + width: double.infinity, + height: 100, + color: Colors.white, + child: Container( + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SizedBox( + height: 10, + ), + Row( + children: [ + Padding( + padding: const EdgeInsets.all(8.0), + child: Text( + "Quantity", + style: TextStyle( + fontSize: 15, fontWeight: FontWeight.bold), + ), + ), + InkWell( + child: Icon(Icons.close, color: Colors.black), + onTap: () { + setState(() { + quantityUI = 80; + showUI = false; + }); + }, + ) + ], + mainAxisAlignment: MainAxisAlignment.spaceBetween, + ), + Container( + height: 50.0, + child: ListView( + scrollDirection: Axis.horizontal, + children: [ + SizedBox( + width: 5, + ), + for (int i = 1; i <= 10; i++) + QuantityBox( + label: i, + onTapFunc: onChangeValue, + isSelected: widget.quantity == i), + Container( + width: 100, + decoration: BoxDecoration( + border: Border.all(color: Colors.grey[300]), + color: Colors.white, + ), + child: TextField( + decoration: InputDecoration( + labelText: ' Quantity # '), + onChanged: (text) { + if (int.tryParse(text) == null) { + text = ''; + } else { + setState(() { + widget.quantity = int.parse(text); + if (widget.quantity >= + widget.quantityLimit) { + widget.isOverQuantity = true; + } else { + widget.isOverQuantity = false; + } + }); + } + }, + ), + ), + ], + ), + ) + ], + ), + ), + ) + : Container( + height: 20, + ), + Row( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + width: 70, + height: 50, + child: FlatButton( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Expanded( + flex: 4, + child: Text( + widget.quantity.toString(), + style: TextStyle(fontSize: 20), + ), + ), + Expanded( + flex: 5, + child: Text( + TranslationBase.of(context).quantityShortcut, + style: TextStyle(fontSize: 16), + ), + ), + ], + ), + onPressed: () { + setState(() { + if (showUI) { + quantityUI = 80; + showUI = false; + } else { + quantityUI = 160; + showUI = true; + } + }); + }, + ), + ), + Container( + width: MediaQuery.of(context).size.width * 0.45, + child: SecondaryButton( + label: TranslationBase.of(context).addToCart.toUpperCase(), + disabled: !widget.isAvailable && widget.quantity == 0 || + widget.quantity > widget.quantityLimit || + widget.item.rxMessage != null, + disableColor: Color(0xFF4CAF50), + onTap: () async { + if (!authenticatedUserObject.isLogin) { + Navigator.of(context).pushNamed( + WELCOME_LOGIN, + ); + } else + await widget.addToCartFunction( + quantity: widget.quantity, + itemID: widget.item.id, + model: widget.model); + }, + fontWeight: FontWeight.w600, + borderColor: Color(0xFF4CAF50), + borderRadius: 3, + color: Color(0xFF4CAF50), + ), + ), + SizedBox( + width: 5, + ), + Container( + width: MediaQuery.of(context).size.width * 0.35, + child: SecondaryButton( + label: TranslationBase.of(context).buyNow.toUpperCase(), + disabled: !widget.isAvailable && widget.quantity > 0 || + widget.quantity > widget.quantityLimit || + widget.item.rxMessage != null, + onTap: () async { + await widget.addToCartFunction( + quantity: widget.quantity, + itemID: widget.item.id, + model: widget.model); + Navigator.push( + context, + FadePage(page: CartOrderPage()), + ); + }, + fontWeight: FontWeight.w600, + borderColor: Colors.grey[800], + borderRadius: 3, + disableColor: Colors.grey[700], + color: !widget.isAvailable && widget.quantity > 0 || + widget.quantity > widget.quantityLimit || + widget.item.rxMessage != null + ? Colors.grey + : Colors.grey[800], + ), + ), + ], + ), + ], + ), + ); + } + + onChangeValue(int i) { + setState(() { + widget.quantity = i; + if (widget.quantity >= widget.quantityLimit) { + widget.isOverQuantity = true; + } else { + widget.isOverQuantity = false; + return widget.quantity; + } + }); + } +} diff --git a/lib/pages/pharmacies/screens/product-details/footor/quantity_box.dart b/lib/pages/pharmacies/screens/product-details/footor/quantity_box.dart new file mode 100644 index 00000000..35e69e0c --- /dev/null +++ b/lib/pages/pharmacies/screens/product-details/footor/quantity_box.dart @@ -0,0 +1,42 @@ +import 'package:flutter/material.dart'; + +class QuantityBox extends StatelessWidget { + final int label; + final bool isSelected; + final Function(int) onTapFunc; + + QuantityBox({ + Key key, + this.label, + this.onTapFunc, this.isSelected = false, + }) : super(key: key); + + @override + Widget build(BuildContext context) { + return Row( + children: [ + InkWell( + child: Container( + decoration: BoxDecoration( + border: Border.all(color:isSelected?Colors.green: Colors.grey[300]), + color: Colors.white, + ), + alignment: Alignment.center, + width: 50.0, + + child: Text( + '$label', + style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20), + ), + ), + onTap:(){ + onTapFunc(label); + } + ), + SizedBox( + width: 5, + ) + ], + ); + } +} diff --git a/lib/pages/pharmacies/screens/product-details/product-detail.dart b/lib/pages/pharmacies/screens/product-details/product-detail.dart new file mode 100644 index 00000000..83a76a19 --- /dev/null +++ b/lib/pages/pharmacies/screens/product-details/product-detail.dart @@ -0,0 +1,365 @@ +import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; +import 'package:diplomaticquarterapp/config/size_config.dart'; +import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart'; +import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/product_detail_view_model.dart'; +import 'package:diplomaticquarterapp/pages/base/base_view.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/compare-list.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/product-name-and-price.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/recommended_products.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/reviews_info.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/shared/custom-divider.dart'; +import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart'; +import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; +import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; +import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; +import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; +import 'package:flutter/material.dart'; + +import 'availability_info.dart'; +import 'details_info.dart'; +import 'discount_description.dart'; +import 'footor/footer-widget.dart'; +import 'shared/product_details_app_bar.dart'; + +String itemID; +PharmacyProduct specificationData; + +class ProductDetailPage extends StatefulWidget { + final PharmacyProduct product; + + ProductDetailPage(this.product); + + @override + __ProductDetailPageState createState() => __ProductDetailPageState(); +} + +class __ProductDetailPageState extends State { + AppSharedPreferences sharedPref = AppSharedPreferences(); + + bool isTrue = true; + bool isDetails = true; + bool isReviews = false; + bool isAvailability = false; + String customerId; + bool isSelected = true; + bool isOverQuantity = false; + bool isInWishList = false; + int quantity = 0; + + checkWishlist() async { + GifLoaderDialogUtils.showMyDialog(context); + ProductDetailViewModel model = new ProductDetailViewModel(); + await model.checkWishlistData(); + + for (int i = 0; i < model.wishListItems.length; i++) { + if (itemID == model.wishListItems[i].product.id) { + isInWishList = true; + break; + } else { + isInWishList = false; + } + } + GifLoaderDialogUtils.hideDialog(context); + setState(() {}); + } + + void initState() { + quantity = 1; + specificationData = widget.product; + + userInfo(); + super.initState(); + } + + @override + void dispose() { + super.dispose(); + } + + void userInfo() async { + print(specificationData); + customerId = await sharedPref.getString(PHARMACY_CUSTOMER_ID); + if (customerId != null) { + itemID = widget.product.id; + checkWishlist(); + } + setState(() {}); + } + + Widget build(BuildContext context) { + return BaseView( + allowAny: true, + builder: (_, model, wi) => AppScaffold( + appBarTitle: TranslationBase.of(context).productDetails, + isShowAppBar: true, + isPharmacy: true, + isShowDecPage: false, + customAppBar: ProductAppBar( + product: widget.product, + quantity: quantity, + model: model, + addToWishlistFunction: () async { + await addToWishlistFunction(itemID: itemID, model: model); + }, + deleteFromWishlistFunction: () async { + await deleteFromWishlistFunction(itemID: itemID, model: model); + }, + isInWishList:isInWishList, + addToCartFunction:addToCartFunction , + ), + body: SingleChildScrollView( + child: Column( + children: [ + Container( + width: double.infinity, + color: Colors.white, + child: Column( + children: [ + if (widget.product.images.isNotEmpty) + Container( + height: MediaQuery.of(context).size.height * .40, + child: Image.network( + widget.product.images[0].src.trim(), + fit: BoxFit.contain, + ), + ), + if (widget.product.discountDescription != null) + DiscountDescription(product: widget.product) + ], + ), + ), + SizedBox( + height: 4, + ), + Container( + color: Colors.white, + child: ProductNameAndPrice( + context, + widget.product, + customerId: customerId, + addToWishlistFunction: (item) { + addToWishlistFunction(itemID: item, model: model); + setState(() {}); + }, + deleteFromWishlistFunction: (item) { + deleteFromWishlistFunction( + itemID: item, model: model); + setState(() {}); + }, + notifyMeWhenAvailable: (context, itemId) { + notifyMeWhenAvailable( + itemId: itemId, + customerId: customerId, + model: model); + }, + isInWishList: isInWishList, + ), + ), + SizedBox( + height: 6, + ), + Container( + color: Colors.white, + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + padding: EdgeInsets.symmetric( + vertical: 15, horizontal: 10), + child: Texts( + TranslationBase.of(context).specification, + fontSize: 15, + fontWeight: FontWeight.bold, + ), + width: double.infinity, + ), + // Divider(color: Colors.grey), + ], + ), + ), + SizedBox( + height: 6, + ), + Container( + // width: 500, + margin: EdgeInsets.only(bottom: 6), + color: Colors.white, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + Column( + children: [ + FlatButton( + onPressed: () { + setState(() { + isDetails = true; + isReviews = false; + isAvailability = false; + }); + }, + child: Text( + TranslationBase.of(context).details, + style: TextStyle( + fontSize: 16, + fontWeight: FontWeight.bold), + ), + color: Colors.white, + ), + CustomDivider( + color: isDetails + ? Colors.green + : Colors.transparent, + ) + ], + ), + SizedBox( + width: 20, + ), + Column( + children: [ + FlatButton( + onPressed: () async { + if (widget.product.approvedTotalReviews > + 0) { + GifLoaderDialogUtils.showMyDialog( + context); + await model.getProductReviewsData( + widget.product.id); + GifLoaderDialogUtils.hideDialog( + context); + } else { + model.clearReview(); + } + setState(() { + isDetails = false; + isReviews = true; + isAvailability = false; + }); + }, + child: Text( + TranslationBase.of(context).reviews, + style: TextStyle( + fontSize: 16, + fontWeight: FontWeight.bold), + ), + color: Colors.white, + ), + CustomDivider( + color: isReviews + ? Colors.green + : Colors.transparent, + ), + ], + ), + SizedBox( + width: 20, + ), + Column( + children: [ + FlatButton( + onPressed: () async { + GifLoaderDialogUtils.showMyDialog( + context); + await model.getProductLocationData(); + GifLoaderDialogUtils.hideDialog(context); + + setState(() { + isDetails = false; + isReviews = false; + isAvailability = true; + }); + }, + child: Text( + TranslationBase.of(context).availability, + style: TextStyle( + fontSize: 16, + fontWeight: FontWeight.bold), + ), + color: Colors.white, + ), + CustomDivider( + color: isAvailability + ? Colors.green + : Colors.transparent, + ), + ], + ), + ], + ), + SizedBox( + height: 10, + ), + isDetails + ? DetailsInfo( + product: widget.product, + ) + : isReviews + ? ReviewsInfo( + product: widget.product, + previousModel: model, + ) + : isAvailability + ? AvailabilityInfo( + previousModel: model, + ) + : Container(), + ], + ), + ), + SizedBox( + height: 10, + ), + RecommendedProducts(product: widget.product,productDetailViewModel: model, + addToWishlistFunction: (itemID) async { + await addToWishlistFunction(itemID: itemID, model: model); + }, deleteFromWishlistFunction: (itemID) async { + await deleteFromWishlistFunction(itemID: itemID, model: model); + },) + ], + ), + ), + bottomSheet: FooterWidget( + widget.product.stockAvailability != 'Out of stock', + widget.product.orderMaximumQuantity, + widget.product.orderMinimumQuantity, + widget.product.stockQuantity, + widget.product, + quantity: quantity, + isOverQuantity: isOverQuantity, + addToCartFunction: addToCartFunction, + model: model, + ), + )); + } + + addToWishlistFunction({itemID, ProductDetailViewModel model}) async { + isInWishList = true; + await model.addToWishlistData(itemID); + setState(() {}); + } + + deleteFromWishlistFunction({itemID, ProductDetailViewModel model}) async { + isInWishList = false; + await model.deleteWishlistData(itemID); + setState(() {}); + } + addToCartFunction( + {quantity, + itemID, + ProductDetailViewModel model}) async { + GifLoaderDialogUtils.showMyDialog(context); + await model.addToCartData(quantity, itemID); + GifLoaderDialogUtils.hideDialog(context); + } +} + + + +notifyMeWhenAvailable( + {itemId, customerId, ProductDetailViewModel model}) async { + await model.notifyMe(customerId, itemId); +} diff --git a/lib/pages/pharmacies/screens/product-details/product-name-and-price.dart b/lib/pages/pharmacies/screens/product-details/product-name-and-price.dart new file mode 100644 index 00000000..6d8ea11d --- /dev/null +++ b/lib/pages/pharmacies/screens/product-details/product-name-and-price.dart @@ -0,0 +1,203 @@ +import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart'; +import 'package:diplomaticquarterapp/core/service/AuthenticatedUserObject.dart'; +import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; +import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; +import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; +import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; +import 'package:flutter/material.dart'; +import 'package:font_awesome_flutter/font_awesome_flutter.dart'; +import 'package:provider/provider.dart'; +import 'package:rating_bar/rating_bar.dart'; + +import '../../../../locator.dart'; +import 'shared/icon_with_bg.dart'; + +class ProductNameAndPrice extends StatefulWidget { + BuildContext context; + PharmacyProduct item; + final customerId; + final bool isInWishList; + final Function notifyMeWhenAvailable; + final Function addToWishlistFunction; + final Function deleteFromWishlistFunction; + + AuthenticatedUserObject authenticatedUserObject = + locator(); + + ProductNameAndPrice(this.context, this.item, + {this.customerId, + this.isInWishList, + this.notifyMeWhenAvailable, + this.addToWishlistFunction, + this.deleteFromWishlistFunction}); + + @override + _ProductNameAndPriceState createState() => _ProductNameAndPriceState(); +} + +class _ProductNameAndPriceState extends State { + @override + Widget build(BuildContext context) { + ProjectViewModel projectViewModel = Provider.of(context); + + return Column( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + SizedBox( + height: 10, + ), + FractionallySizedBox( + widthFactor: 0.95, + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Texts(widget.item.price.toString() + " " + "SR", + fontWeight: FontWeight.bold, fontSize: 20), + Texts( + projectViewModel.isArabic + ? widget.item.stockAvailabilityn + : widget.item.stockAvailability, + fontWeight: FontWeight.bold, + fontSize: 15, + color: widget.item.stockAvailability == 'Out of stock' + ? Colors.red + : Colors.green, + ), + // SizedBox(width: 20), + if (widget.authenticatedUserObject.isLogin) + widget.item.stockAvailability == 'Out of stock' && + widget.customerId != null + ? InkWell( + onTap: () => widget.notifyMeWhenAvailable( + context, widget.item.id), + child: Row(children: [ + Texts( + TranslationBase.of(context).notifyMe, + decoration: TextDecoration.underline, + color: Colors.blue, + ), + SizedBox(width: 4), + Icon( + FontAwesomeIcons.bell, + color: Colors.blue, + size: 15.0, + ) + ]), + ) + : IconWithBg( + icon: !widget.isInWishList + ? Icons.favorite_border + : Icons.favorite, + color: !widget.isInWishList + ? Colors.white + : Colors.red[800], + onPress: () async { + { + if (widget.customerId != null) { + if (!widget.isInWishList) { + + await widget + .addToWishlistFunction(widget.item.id); + + } else { + await widget + .deleteFromWishlistFunction(widget.item.id); + } + } else { + return; + } + setState(() {}); + } + }, + ) + ], + ), + ), + Padding( + padding: const EdgeInsets.all(8.0), + child: Container( + margin: EdgeInsets.only(left: 5), + child: Align( + alignment: projectViewModel.isArabic + ? Alignment.topRight + : Alignment.topLeft, + child: Text( + projectViewModel.isArabic + ? widget.item.namen + : widget.item.name, + style: TextStyle(fontWeight: FontWeight.bold, fontSize: 15), + ), + ), + ), + ), + FractionallySizedBox( + widthFactor: 0.95, + child: Row( + children: [ + Container( + child: Align( + alignment: Alignment.bottomLeft, + child: Row( + children: [ + RatingBar.readOnly( + initialRating: double.parse( + widget.item.approvedRatingSum.toString()), + size: 15.0, + filledColor: Colors.yellow[700], + emptyColor: Colors.grey[400], + isHalfAllowed: true, + halfFilledIcon: Icons.star_half, + filledIcon: Icons.star, + emptyIcon: Icons.star, + ), + SizedBox( + width: 10, + ), + Texts( + "${widget.item.approvedRatingSum}", + fontWeight: FontWeight.bold, + fontSize: 12, + ), + SizedBox( + width: 30, + ), + Texts( + "(${widget.item.approvedTotalReviews}${TranslationBase.of(context).review})", + fontSize: 12, + ), + SizedBox( + width: 70, + ), + if (widget.item.rxMessage != null) + Row( + children: [ + Text( + projectViewModel.isArabic + ? widget.item.rxMessagen.toString() + : widget.item.rxMessage.toString(), + style: TextStyle(color: Colors.red, fontSize: 10), + ), + SizedBox( + width: 5, + ), + Icon( + FontAwesomeIcons.questionCircle, + color: Colors.red, + size: 15.0, + ) + ], + ) + ], + ), + ), + ), + ], + ), + ), + SizedBox( + height: 10, + ), + ], + ); + } +} diff --git a/lib/pages/pharmacies/screens/product-details/recommended_products.dart b/lib/pages/pharmacies/screens/product-details/recommended_products.dart new file mode 100644 index 00000000..6e0fbba9 --- /dev/null +++ b/lib/pages/pharmacies/screens/product-details/recommended_products.dart @@ -0,0 +1,346 @@ +import 'package:diplomaticquarterapp/core/enum/viewstate.dart'; +import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart'; +import 'package:diplomaticquarterapp/core/model/pharmacies/recommendedProduct_model.dart'; +import 'package:diplomaticquarterapp/core/service/AuthenticatedUserObject.dart'; +import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/pharmacy_module_view_model.dart'; +import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/product_detail_view_model.dart'; +import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; +import 'package:diplomaticquarterapp/locator.dart'; +import 'package:diplomaticquarterapp/pages/base/base_view.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/product-detail.dart'; +import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; +import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; +import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; +import 'package:diplomaticquarterapp/widgets/others/network_base_view.dart'; +import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; +import 'package:rating_bar/rating_bar.dart'; + +class RecommendedProducts extends StatefulWidget { + final PharmacyProduct product; + final String customerId; + final ProductDetailViewModel productDetailViewModel; + final bool isOverQuantity; + final bool isInWishList; + final Function addToWishlistFunction; + final Function deleteFromWishlistFunction; + + AuthenticatedUserObject authenticatedUserObject = + locator(); + + RecommendedProducts( + {Key key, + this.product, + this.productDetailViewModel, + this.customerId, + this.isOverQuantity = false, + this.isInWishList = false, + this.addToWishlistFunction, + this.deleteFromWishlistFunction}) + : super(key: key); + + @override + _RecommendedProductsState createState() => _RecommendedProductsState(); +} + +class _RecommendedProductsState extends State { + @override + Widget build(BuildContext context) { + ProjectViewModel projectViewModel = Provider.of(context); + return SingleChildScrollView( + child: Container( + width: 410, + color: Colors.white, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + margin: EdgeInsets.only(top: 9), + width: 410, + color: Colors.white, + child: Texts( + TranslationBase.of(context).recommended, + fontWeight: FontWeight.bold, fontSize: 16 + ), + ), + Container( + color: Colors.white, + height: 210, + margin: EdgeInsets.only(bottom: 75), + padding: EdgeInsets.only(bottom: 5), + // margin: EdgeInsets.symmetric(horizontal: 6, vertical: 4), + child: BaseView( + onModelReady: (model) => + model.getRecommendedProducts(widget.product.id), + builder: (_, model, wi) => NetworkBaseView( + isLocalLoader: true, + baseViewModel: model, + child: Container( + child: model.state== ViewState.BusyLocal?Container( + height: 80, + child: Center( + child: CircularProgressIndicator( + backgroundColor: Colors.white, + valueColor: AlwaysStoppedAnimation( + Colors.grey[500], + ), + ), + ), + ):model.recommendedProductList.length != null + ? ListView.builder( + scrollDirection: Axis.horizontal, + shrinkWrap: true, + physics: ScrollPhysics(), + // physics: NeverScrollableScrollPhysics(), + itemCount: model.recommendedProductList.length, + itemBuilder: (context, index) { + return InkWell( + onTap: () async { + GifLoaderDialogUtils.showMyDialog(context); + RecommendedProductModel data = + model.recommendedProductList[index]; + var json = data.toJson(); + PharmacyProduct product = + new PharmacyProduct.fromJson(json); + await Navigator.pushReplacement( + context, + FadePage( + page: ProductDetailPage(product), + ), + ); + GifLoaderDialogUtils.hideDialog(context); + }, + child: Card( + elevation: 2, + shape: RoundedRectangleBorder( + side: BorderSide( + color: Colors.grey[300], width: 2), + borderRadius: BorderRadius.circular(10), + ), + margin: EdgeInsets.symmetric( + horizontal: 8, + vertical: 0, + ), + child: Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.all( + Radius.circular(15), + ), + ), + padding: EdgeInsets.symmetric(horizontal: 4), + width: MediaQuery.of(context).size.width / 3, + child: Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Stack(children: [ + Container( + child: Align( + alignment: Alignment.topRight, + child: IconButton( + icon: Icon(model.recommendedProductList[index].isinwishlist != true + ? Icons.favorite_border : Icons.favorite), + color: model.recommendedProductList[index].isinwishlist != true + ? Colors.grey : Colors.red, + onPressed: () async { + if (widget.authenticatedUserObject.isLogin + ) { + if (!widget.isInWishList && model.recommendedProductList[index].isinwishlist != true) { + GifLoaderDialogUtils.showMyDialog(context); + await widget.addToWishlistFunction(model.recommendedProductList[index].id, + ); + GifLoaderDialogUtils.hideDialog(context); + setState(() { + model.recommendedProductList[index].isinwishlist = true;}); + } else { + GifLoaderDialogUtils.showMyDialog(context); + await widget.deleteFromWishlistFunction(model.recommendedProductList[index].id, + ); + GifLoaderDialogUtils.hideDialog(context); + setState(() { + model.recommendedProductList[index].isinwishlist = false; + }); + } + } else { + return; + } + setState(() { + // checkWishlist(); + }); + }, + ), + ), + ), + Container( + margin: EdgeInsets.fromLTRB( + 0, 16, 10, 16), + alignment: Alignment.center, + child: (model + .recommendedProductList[ + index] + .images != + null && + model + .recommendedProductList[ + index] + .images + .length > + 0) + ? Image.network( + model + .recommendedProductList[ + index] + .images[0] + .src + .toString(), + fit: BoxFit.cover, + height: 60, + ) + : Image.asset( + "assets/images/no_image.png", + fit: BoxFit.cover, + height: 60, + ), + ), + Container( + width: model + .recommendedProductList[ + index] + .rxMessage != + null + ? MediaQuery.of(context) + .size + .width / + 5 + : 0, + padding: EdgeInsets.all(4), + decoration: BoxDecoration( + color: Color(0xffb23838), + borderRadius: BorderRadius.only( + topLeft: Radius.circular(6), + ), + ), + child: model + .recommendedProductList[ + index] + .rxMessage != + null + ? Texts( + projectViewModel.isArabic + ? model + .recommendedProductList[ + index] + .rxMessagen + : model + .recommendedProductList[ + index] + .rxMessage, + color: Colors.white, + regular: true, + fontSize: 10, + fontWeight: FontWeight.w400, + ) + : Texts(""), + ), + ]), + Container( + margin: EdgeInsets.symmetric( + horizontal: 6, + vertical: 0, + ), + child: Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Text( + projectViewModel.isArabic + ? model + .recommendedProductList[ + index] + .namen + : model + .recommendedProductList[ + index] + .name, + style: TextStyle( + color: Colors.black, + fontSize: 13.0, +// fontWeight: FontWeight.bold, + ), + ), + Padding( +// padding: const EdgeInsets.only(top: 15, bottom: 10), + padding: const EdgeInsets.only( + top: 10, bottom: 5), + child: Texts( + "SAR ${model.recommendedProductList[index].price}", + bold: true, + fontSize: 14, + ), + ), + ], + ), + ), + Row( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Container( + padding: + EdgeInsets.only(right: 10), + child: Align( + alignment: Alignment.topLeft, + child: RatingBar.readOnly( + initialRating: model + .recommendedProductList[ + index] + .approvedRatingSum + .toDouble(), + size: 13.0, + filledColor: + Colors.yellow[700], + emptyColor: Colors.grey[500], + isHalfAllowed: true, + halfFilledIcon: + Icons.star_half, + filledIcon: Icons.star, + emptyIcon: Icons.star, + ), + ), + ), + Texts( + "(${model.recommendedProductList[index].notApprovedTotalReviews.toString()})", +// bold: true, + fontSize: 12, + ), + ]), + ], + ), + ), + ), + ); + }) + : Container( + // color: Colors.white, + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + // crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Texts( + TranslationBase.of(context).nonRecommended, + color: Colors.black, + ), + ], + ), + ), + ), + ), + ), + ), + ], + ), + ), + ); + } +} diff --git a/lib/pages/pharmacies/screens/product-details/reviews_info.dart b/lib/pages/pharmacies/screens/product-details/reviews_info.dart new file mode 100644 index 00000000..64336d85 --- /dev/null +++ b/lib/pages/pharmacies/screens/product-details/reviews_info.dart @@ -0,0 +1,90 @@ +import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart'; +import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/product_detail_view_model.dart'; +import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; +import 'package:flutter/material.dart'; +import 'package:rating_bar/rating_bar.dart'; + +class ReviewsInfo extends StatelessWidget { + final PharmacyProduct product; + final ProductDetailViewModel previousModel; + + const ReviewsInfo({Key key, this.product, this.previousModel}) + : super(key: key); + + @override + Widget build(BuildContext context) { + return previousModel.productDetailService.length != 0 && + previousModel.productDetailService[0].reviews.length != 0 + ? ListView.builder( + physics: ScrollPhysics(), + itemCount: previousModel.productDetailService[0].reviews.length, + scrollDirection: Axis.vertical, + shrinkWrap: true, + itemBuilder: (BuildContext context, int index) { + return Padding( + padding: EdgeInsets.all(8.0), + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + child: Row( + children: [ + Container( + child: Text( + previousModel.productDetailService[0] + .reviews[index].customerId + .toString(), + style: TextStyle( + fontSize: 17, + color: Colors.grey, + fontWeight: FontWeight.w600), + ), + ), + Container( + margin: EdgeInsets.only(left: 210), + child: RatingBar.readOnly( + initialRating: previousModel + .productDetailService[0].reviews[index].rating + .toDouble(), + size: 15.0, + filledColor: Colors.yellow[700], + emptyColor: Colors.grey[500], + isHalfAllowed: true, + halfFilledIcon: Icons.star_half, + filledIcon: Icons.star, + emptyIcon: Icons.star, + ), + ), + ], + ), + ), + SizedBox( + height: 10, + ), + Container( + child: Text( + previousModel + .productDetailService[0].reviews[index].reviewText, + style: TextStyle(fontSize: 20), + ), + ), + SizedBox( + height: 50, + ), + Divider(height: 1, color: Colors.grey), + ], + ), + ); + }, + ) + : Container( + padding: EdgeInsets.all(15), + alignment: Alignment.center, + child: Text( + TranslationBase.of(context).noReviewsAvailable, + ), +// Text('No Reviews Available'), + ); + } +} diff --git a/lib/pages/pharmacies/screens/product-details/shared/custom-divider.dart b/lib/pages/pharmacies/screens/product-details/shared/custom-divider.dart new file mode 100644 index 00000000..268e79d0 --- /dev/null +++ b/lib/pages/pharmacies/screens/product-details/shared/custom-divider.dart @@ -0,0 +1,19 @@ +import 'package:flutter/material.dart'; + +class CustomDivider extends StatelessWidget { + const CustomDivider({ + Key key, + this.color, + }) : super(key: key); + + final Color color; + + @override + Widget build(BuildContext context) { + return Container( + width: 120, + height: 2, + color: color, + ); + } +} \ No newline at end of file diff --git a/lib/pages/pharmacies/screens/product-details/shared/icon_with_bg.dart b/lib/pages/pharmacies/screens/product-details/shared/icon_with_bg.dart new file mode 100644 index 00000000..f2406614 --- /dev/null +++ b/lib/pages/pharmacies/screens/product-details/shared/icon_with_bg.dart @@ -0,0 +1,30 @@ +import 'package:flutter/material.dart'; + +class IconWithBg extends StatelessWidget { + final IconData icon; + final Color color; + final Function onPress; + + const IconWithBg({Key key, this.icon, this.color, this.onPress}) + : super(key: key); + + @override + Widget build(BuildContext context) { + return Container( + width: 40, + height: 40, + decoration: BoxDecoration( + color: Colors.grey[200], + borderRadius: BorderRadius.circular(30), + ), + child: Center( + child: IconButton( + icon: Icon(icon, size: 20,), + color: color, + onPressed: () async { + onPress(); + }, + ), + )); + } +} diff --git a/lib/pages/pharmacies/screens/product-details/shared/product_details_app_bar.dart b/lib/pages/pharmacies/screens/product-details/shared/product_details_app_bar.dart new file mode 100644 index 00000000..b9612925 --- /dev/null +++ b/lib/pages/pharmacies/screens/product-details/shared/product_details_app_bar.dart @@ -0,0 +1,183 @@ +import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart'; +import 'package:diplomaticquarterapp/core/service/AuthenticatedUserObject.dart'; +import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart'; +import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/product_detail_view_model.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/product-detail.dart'; +import 'package:diplomaticquarterapp/uitl/app_toast.dart'; +import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; +import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; +import 'package:flutter/material.dart'; +import 'package:font_awesome_flutter/font_awesome_flutter.dart'; +import 'package:provider/provider.dart'; + +import '../../../../../locator.dart'; +import '../../../compare-list.dart'; +import '../../cart-page/cart-order-page.dart'; +import 'icon_with_bg.dart'; + +class ProductAppBar extends StatelessWidget with PreferredSizeWidget { + final PharmacyProduct product; + + final ProductDetailViewModel model; + final Function addToWishlistFunction; + final Function deleteFromWishlistFunction; + final int quantity; + final bool isInWishList; + final Function addToCartFunction; + + + ProductAppBar( + {Key key, + this.product, + this.model, + this.addToWishlistFunction, + this.quantity, + this.deleteFromWishlistFunction, + this.isInWishList, this.addToCartFunction}) + : super(key: key); + + AuthenticatedUserObject authenticatedUserObject = + locator(); + + @override + Widget build(BuildContext context) { + return Container( + color: Colors.white, + child: FractionallySizedBox( + widthFactor: 0.95, + child: Column( + children: [ + SizedBox( + height: 30, + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Row( + children: [ + IconWithBg( + icon: Icons.arrow_back, + color: Colors.grey, + onPress: () { + Navigator.pop(context); + }, + ), + ], + ), + if (authenticatedUserObject.isLogin) + Row( + children: [ + Stack( + children: [ + IconWithBg( + icon: Icons.shopping_cart, + color: Colors.grey[800], + onPress: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => CartOrderPage()), + ); + }), + + if(Provider.of(context, listen: false).cartResponse.quantityCount !=0) + Positioned( + top:0, right: -1.0, + child: Container( + decoration: BoxDecoration( + color: Colors.red[800], + borderRadius: BorderRadius.circular(15), + + ), + padding: EdgeInsets.only(left: 5, right: 4.5), + height: 18, + child: Center(child: Texts(Provider.of(context, listen: false).cartResponse.quantityCount.toString(), style: "caption", medium: true, color: Colors.white,)), + ), + ) + ], + ), + SizedBox( + width: 10, + ), + IconWithBg( + icon: FontAwesomeIcons.ellipsisV, + color: Colors.grey, + onPress: () { + settingModalBottomSheet(context); + }, + ), + ], + ) + ], + ), + ], + ), + ), + ); + } + + @override + Size get preferredSize => Size(double.maxFinite, 50); + + settingModalBottomSheet(context) { + showModalBottomSheet( + context: context, + builder: (BuildContext bc) { + return Container( + child: new Wrap( + children: [ + if (product.stockAvailability != 'Out of stock') + new ListTile( + leading: Icon(Icons.shopping_cart), + title: Text( + TranslationBase.of(context).addToCart, + ), + onTap: () async { + if (quantity > 0) { + { + await addToCartFunction( + quantity: quantity, + itemID: itemID, + model: model); + + Navigator.of(context).pop(); + } + } else { + AppToast.showErrorToast( + message: "you should add quantity"); + } + }), + ListTile( + leading: Icon( + !isInWishList ? Icons.favorite_border : Icons.favorite, + color: !isInWishList ? Colors.white : Colors.red[800], + ), + title: Text( + isInWishList + ? TranslationBase.of(context).removeFromWishlist + : TranslationBase.of(context).addToWishlist, + ), + onTap: () async { + if (isInWishList) + await deleteFromWishlistFunction(); + else + await addToWishlistFunction(); + Navigator.of(context).pop(); + }), + ListTile( + leading: Icon(Icons.compare), + title: Text( + TranslationBase.of(context).compare, + ), + onTap: () { + Provider.of(context, listen: false) + .addItem(specificationData); + Navigator.of(context).pop(); + }, + ), + ], + ), + ); + }); + } +} diff --git a/lib/pages/pharmacies/widgets/ProductOrderItem.dart b/lib/pages/pharmacies/widgets/ProductOrderItem.dart index d7a82cc6..cb7c59fd 100644 --- a/lib/pages/pharmacies/widgets/ProductOrderItem.dart +++ b/lib/pages/pharmacies/widgets/ProductOrderItem.dart @@ -45,6 +45,7 @@ class _ProductOrderItemState extends State { ), title: Container( child: Row( +// widget.item.product.stock_quantity===0 crossAxisAlignment: CrossAxisAlignment.start, mainAxisSize: MainAxisSize.max, children: [ @@ -166,10 +167,22 @@ class _ProductOrderItemState extends State { "$_totalPrice ${projectProvider.isArabic ? widget.item.currencyn : widget.item.currency}", fontSize: 12, fontWeight: FontWeight.bold, - ) + ), + widget.item.product.stockQuantity == 0 ? + Texts( + projectProvider.isArabic + ? widget.item.product.stockAvailabilityn + : widget.item.product.stockAvailability, + fontWeight: FontWeight.normal, + fontSize: 13, + color:Colors.red, + + ): Texts(""), ], ), - ) + ), + + ], ), ) diff --git a/lib/pages/pharmacies/widgets/ProductTileItem.dart b/lib/pages/pharmacies/widgets/ProductTileItem.dart index 5e296716..92ad8d1a 100644 --- a/lib/pages/pharmacies/widgets/ProductTileItem.dart +++ b/lib/pages/pharmacies/widgets/ProductTileItem.dart @@ -1,6 +1,8 @@ import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart'; import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/product-detail.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/screens/phramacy-product-detail-page.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/product_detail.dart'; import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; @@ -12,8 +14,9 @@ import 'package:provider/provider.dart'; class ProductTileItem extends StatelessWidget { final AppSharedPreferences sharedPref = AppSharedPreferences(); final PharmacyProduct item; + final double itemHeight; - ProductTileItem(this.item); + ProductTileItem(this.item, this.itemHeight); void productOnClick(BuildContext ctx) { _saveLastVisitProducts(); @@ -23,6 +26,7 @@ class ProductTileItem extends StatelessWidget { void _saveLastVisitProducts() async { String lastVisited = ""; bool isIdExist = false; + List items = []; if (await this.sharedPref.getString(PHARMACY_LAST_VISITED_PRODUCTS) != null) { lastVisited = @@ -31,8 +35,27 @@ class ProductTileItem extends StatelessWidget { if (id == item.id) { isIdExist = true; } + items.add(id); }); } + + if(items.length >= 15){ + items.removeAt(0); + // lastVisited = lastVisited.replaceFirst(RegExp('$itemToRemove'), ''); + } + + lastVisited = ""; + for(int i = items.length - 1; i >= 0; i--){ + if (lastVisited == "") { + // it means there is no lastVisited yet + lastVisited = "${items[i]}"; + } else { + // there is lastVisited id's and this product id is not found + lastVisited += ",${items[i]}"; + } + } + + if (!isIdExist) { if (lastVisited == "") { // it means there is no lastVisited yet @@ -41,8 +64,8 @@ class ProductTileItem extends StatelessWidget { // there is lastVisited id's and this product id is not found lastVisited += ",${item.id}"; } - sharedPref.setString(PHARMACY_LAST_VISITED_PRODUCTS, lastVisited); } + sharedPref.setString(PHARMACY_LAST_VISITED_PRODUCTS, lastVisited); } @override @@ -51,75 +74,83 @@ class ProductTileItem extends StatelessWidget { return InkWell( onTap: () => productOnClick(context), splashColor: Theme.of(context).primaryColor, - child: Card( - elevation: 2, - shape: Border(right: BorderSide(color: Colors.grey.shade300, width: 1)), - margin: EdgeInsets.symmetric( - horizontal: 8, - vertical: 0, + child: Container( + margin: EdgeInsets.all(7), + decoration: BoxDecoration( + border:Border.all(color: Colors.grey.shade300,width: 0.5), + borderRadius: BorderRadius.circular(8) ), - child: Container( - padding: EdgeInsets.symmetric(horizontal: 4), - width: MediaQuery.of(context).size.width / 3, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Stack( - children: [ - Container( - margin: EdgeInsets.fromLTRB(0, 16, 0, 0), - alignment: Alignment.center, - child: (item.images != null && item.images.length > 0) - ? Image.network( - item.images[0].src, - fit: BoxFit.cover, - height: 80, - ) - : Image.asset( - "assets/images/no_image.png", - fit: BoxFit.cover, - height: 80, - ), + padding: EdgeInsets.symmetric(horizontal: 4), + width: MediaQuery.of(context).size.width / 2.8, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Stack( + children: [ + Container( + margin: EdgeInsets.fromLTRB(0, 16, 0, 0), + alignment: Alignment.center, + child: (item.images != null && item.images.length > 0) + ? Image.network( + item.images[0].src, + fit: BoxFit.cover, + height: itemHeight / 2, + ) + : Image.asset( + "assets/images/no_image.png", + fit: BoxFit.cover, + height: itemHeight / 2, ), - Container( - width: item.rxMessage != null - ? MediaQuery.of(context).size.width / 5 - : 0, - padding: EdgeInsets.all(4), - decoration: BoxDecoration( - color: Color(0xffb23838), - borderRadius: - BorderRadius.only(topLeft: Radius.circular(6)), - ), - child: item.rxMessage != null ? Texts( - projectProvider.isArabic ? item.rxMessagen : item.rxMessage, - color: Colors.white, - regular: true, - fontSize: 10, - fontWeight: FontWeight.w400, - ): Texts(""), + ), + Container( + width: item.rxMessage != null + ? MediaQuery.of(context).size.width / 5 + : 0, + padding: EdgeInsets.all(4), + decoration: BoxDecoration( + color: Color(0xffb23838), + borderRadius: + BorderRadius.only(topLeft: Radius.circular(6)), + ), + child: item.rxMessage != null + ? Texts( + projectProvider.isArabic + ? item.rxMessagen + : item.rxMessage, + color: Colors.white, + regular: true, + fontSize: 10, + fontWeight: FontWeight.w400, ) - ], + : Texts(""), + ) + ], + ), + SizedBox(height: 8,), + Padding( + padding: const EdgeInsets.symmetric(horizontal: 6.0), + child: Texts( + projectProvider.isArabic ? item.namen : item.name, + regular: true, + fontSize: 12, + fontWeight: FontWeight.w400, ), - Container( + ), + Expanded( + child: Container( margin: EdgeInsets.symmetric( horizontal: 6, vertical: 0, ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.end, children: [ - Texts( - projectProvider.isArabic ? item.namen : item.name, - regular: true, - fontSize: 12, - fontWeight: FontWeight.w400, - ), Padding( padding: const EdgeInsets.only(top: 4, bottom: 4), child: Texts( "SAR ${item.price}", - bold: true, + fontWeight: FontWeight.w600, fontSize: 14, ), ), @@ -129,24 +160,19 @@ class ProductTileItem extends StatelessWidget { child: StarRating( totalAverage: item.approvedTotalReviews > 0 ? (item.approvedRatingSum.toDouble() / - item.approvedTotalReviews.toDouble()) - .toDouble() + item.approvedTotalReviews.toDouble()) + .toDouble() : 0, forceStars: true), ), - /*Texts( - "(${item.approvedTotalReviews})", - regular: true, - fontSize: 10, - fontWeight: FontWeight.w400, - ),*/ ], ), ], ), - ) - ], - ), + ), + ), + SizedBox(height: 5,), + ], ), ), ); diff --git a/lib/pages/pharmacies/widgets/BannerPager.dart b/lib/pages/pharmacies/widgets/home/BannerPager.dart similarity index 86% rename from lib/pages/pharmacies/widgets/BannerPager.dart rename to lib/pages/pharmacies/widgets/home/BannerPager.dart index 756d0758..6f1155dd 100644 --- a/lib/pages/pharmacies/widgets/BannerPager.dart +++ b/lib/pages/pharmacies/widgets/home/BannerPager.dart @@ -1,3 +1,4 @@ +import 'package:cached_network_image/cached_network_image.dart'; import 'package:carousel_slider/carousel_slider.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/pharmacy_module_view_model.dart'; import 'package:diplomaticquarterapp/pages/offers_categorise_page.dart'; @@ -43,7 +44,8 @@ class _BannerPagerState extends State { .mapIndexed( (item, index) => InkWell( onTap: () { - Navigator.push(context, FadePage(page: OffersCategorisePage())); + Navigator.push( + context, FadePage(page: OffersCategorisePage())); }, child: Container( margin: EdgeInsets.symmetric(horizontal: 1.0), @@ -55,10 +57,11 @@ class _BannerPagerState extends State { item, fit: BoxFit.cover, ) - : Image.network( - item, - fit: BoxFit.cover, - ), + : CachedNetworkImage( + imageUrl: item, + fit: BoxFit.fitWidth, + errorWidget: (context, url, error) => + SizedBox()), ), ), ), diff --git a/lib/pages/pharmacies/widgets/home/BestSellerWidget.dart b/lib/pages/pharmacies/widgets/home/BestSellerWidget.dart new file mode 100644 index 00000000..2814bc1c --- /dev/null +++ b/lib/pages/pharmacies/widgets/home/BestSellerWidget.dart @@ -0,0 +1,56 @@ +import 'package:diplomaticquarterapp/core/enum/viewstate.dart'; +import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/BestSellerViewModel.dart'; +import 'package:diplomaticquarterapp/pages/base/base_view.dart'; +import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; +import 'package:diplomaticquarterapp/widgets/others/network_base_view.dart'; +import 'package:flutter/material.dart'; + +import '../../../final_products_page.dart'; +import '../ProductTileItem.dart'; +import 'ViewAllHomeWidget.dart'; + +class BestSellerWidget extends StatelessWidget { + @override + Widget build(BuildContext context) { + return BaseView( + onModelReady: (model) => model.getBestSellerProducts(), + allowAny: true, + builder: (_, model, wi) => NetworkBaseView( + isLocalLoader: true, + baseViewModel: model, + child: Container( + child: Column( + children: [ + ViewAllHomeWidget( + TranslationBase.of(context).bestSellers, + FinalProductsPage( + id: "", + productType: 20, + )), + if (model.state != ViewState.BusyLocal) + Container( + height: MediaQuery.of(context).size.height / 3 + 20, + child: ListView.builder( + itemBuilder: (ctx, i) => + ProductTileItem(model.bestSellerProduct[i], MediaQuery.of(context).size.height / 4 + 20), + scrollDirection: Axis.horizontal, + itemCount: model.bestSellerProduct.length, + ), + ) else + Container( + height: 80, + child: Center( + child: CircularProgressIndicator( + backgroundColor: Colors.white, + valueColor: AlwaysStoppedAnimation( + Colors.grey[500], + ), + ), + ), + ), + ], + ), + ), + )); + } +} diff --git a/lib/pages/pharmacies/widgets/home/GridViewButtons.dart b/lib/pages/pharmacies/widgets/home/GridViewButtons.dart new file mode 100644 index 00000000..5d979136 --- /dev/null +++ b/lib/pages/pharmacies/widgets/home/GridViewButtons.dart @@ -0,0 +1,81 @@ +import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/pharmacy_module_view_model.dart'; +import 'package:diplomaticquarterapp/pages/landing/home_page.dart'; +import 'package:diplomaticquarterapp/pages/medical/prescriptions/prescriptions_home_page.dart'; +import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; +import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; +import 'package:flutter/material.dart'; + +import '../../../offers_categorise_page.dart'; +import 'GridViewCard.dart'; + +class GridViewButtons extends StatelessWidget { + final PharmacyModuleViewModel model; + + GridViewButtons(this.model); + + @override + Widget build(BuildContext context) { + final gridHeight = (MediaQuery.of(context).size.width * 0.3) * 1.8; + return Container( + child: SizedBox( + height: gridHeight, + child: GridView.count( + childAspectRatio: 2.2, + crossAxisSpacing: 10, + mainAxisSpacing: 10, + controller: new ScrollController(keepScrollOffset: false), + shrinkWrap: true, + padding: const EdgeInsets.all(4.0), + crossAxisCount: 2, + children: [ + DashboardItem( + imageName: 'pharmacy_module/bg_1.png', + hasColorFilter: false, + opacity: 0.8, + child: GridViewCard( + TranslationBase.of(context).offersAndPromotions, + 'assets/images/pharmacy_module/offer_icon.png', () { + Navigator.push(context, FadePage(page: OffersCategorisePage())); + }), + ), + DashboardItem( + imageName: 'pharmacy_module/bg_2.png', + opacity: 0, + hasColorFilter: false, + child: GridViewCard(TranslationBase.of(context).medicationRefill, + 'assets/images/pharmacy_module/medication_icon.png', () { + // model.checkUserIsActivated().then((isActivated) { + // if (isActivated) { + // Navigator.push(context, FadePage(page: LakumMainPage())); + // } else { + // Navigator.push( + // context, FadePage(page: LakumActivationVidaPage())); + // } + // }); + }), + ), + DashboardItem( + imageName: 'pharmacy_module/bg_3.png', + opacity: 0, + hasColorFilter: false, + child: GridViewCard(TranslationBase.of(context).myPrescriptions, + 'assets/images/pharmacy_module/prescription_icon.png', () { + Navigator.push( + context, FadePage(page: HomePrescriptionsPage())); + }), + ), + DashboardItem( + imageName: 'pharmacy_module/bg_4.png', + opacity: 0, + hasColorFilter: false, + child: GridViewCard( + TranslationBase.of(context).searchAndScanMedication, + 'assets/images/pharmacy_module/search_scan_icon.png', + () {}), + ), + ], + ), + ), + ); + } +} \ No newline at end of file diff --git a/lib/pages/pharmacies/widgets/home/GridViewCard.dart b/lib/pages/pharmacies/widgets/home/GridViewCard.dart new file mode 100644 index 00000000..fd8bdada --- /dev/null +++ b/lib/pages/pharmacies/widgets/home/GridViewCard.dart @@ -0,0 +1,84 @@ +import 'package:diplomaticquarterapp/config/size_config.dart'; +import 'package:diplomaticquarterapp/uitl/date_uitl.dart'; +import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; +import 'package:diplomaticquarterapp/widgets/buttons/borderedButton.dart'; +import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; +import 'package:flutter/material.dart'; + +class GridViewCard extends StatelessWidget { + final String text; + final String cardImage; + final Function handler; + + GridViewCard(this.text, this.cardImage, this.handler); + + @override + Widget build(BuildContext context) { + return Padding( + padding: const EdgeInsets.all(4.0), + child: Container( + child: Row( + children: [ + Expanded( + flex: 2, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Expanded( + flex: 2, + child: Padding( + padding: const EdgeInsets.all(6), + child: Column( + children: [ + Texts( + text, + color: Colors.white, + bold: true, + fontSize: SizeConfig.textMultiplier * 1.5, + ), + ], + ), + ), + ), + Row( + children: [ + BorderedButton( + TranslationBase.of(context).viewAll, + handler: handler, + tPadding: 0, + textColor: Color(0xFF5ab145), + bPadding: 0, + ), + Expanded(child: Container()), + ], + ), + ], + ), + ), + Expanded( + child: Align( + alignment: Alignment.centerRight, + child: Image.asset( + cardImage, + fit: BoxFit.cover, + ), + ), + ), + ], + ), + ), + ); + } + + String getDate(String date) { + DateTime dateObj = DateUtil.convertStringToDate(date); + return DateUtil.getWeekDay(dateObj.weekday) + + ", " + + dateObj.day.toString() + + " " + + DateUtil.getMonth(dateObj.month) + + " " + + dateObj.year.toString(); + } +} \ No newline at end of file diff --git a/lib/pages/pharmacies/widgets/home/PrescriptionsWidget.dart b/lib/pages/pharmacies/widgets/home/PrescriptionsWidget.dart new file mode 100644 index 00000000..28556679 --- /dev/null +++ b/lib/pages/pharmacies/widgets/home/PrescriptionsWidget.dart @@ -0,0 +1,233 @@ +import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/PrescriptionViewModel.dart'; +import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; +import 'package:diplomaticquarterapp/pages/base/base_view.dart'; +import 'package:diplomaticquarterapp/pages/medical/prescriptions/prescriptions_home_page.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/widgets/home/ViewAllHomeWidget.dart'; +import 'package:diplomaticquarterapp/uitl/date_uitl.dart'; +import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; +import 'package:diplomaticquarterapp/widgets/buttons/borderedButton.dart'; +import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; +import 'package:diplomaticquarterapp/widgets/others/network_base_view.dart'; +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; +import 'package:rating_bar/rating_bar.dart'; + +class PrescriptionsWidget extends StatelessWidget { + @override + Widget build(BuildContext context) { + return BaseView( + onModelReady: (model) async { + if (Provider.of(context, listen: false).isLogin) { + model.getPrescription(); + } + }, + allowAny: true, + builder: (_, model, wi) => model.prescriptionsList.length > 0 + ? NetworkBaseView( + isLocalLoader: true, + baseViewModel: model, + child: Container( + height: model.prescriptionsList.length > 0 + ? MediaQuery.of(context).size.height * 0.28 + : 0, + child: Column( + children: [ + ViewAllHomeWidget( + TranslationBase.of(context).myPrescription, + HomePrescriptionsPage()), + Container( + padding: EdgeInsets.symmetric( + horizontal: 18.0, vertical: 14.0), + margin: EdgeInsets.only(left: 10), + child: ListView.builder( + scrollDirection: Axis.horizontal, + shrinkWrap: true, + physics: ScrollPhysics(), + // physics: NeverScrollableScrollPhysics(), + itemCount: model.prescriptionsList.length, + itemBuilder: (context, index) { + return Container( + height: MediaQuery.of(context).size.height * 0.3, + padding: EdgeInsets.only( + bottom: 5.0, left: 5.0, right: 8.0), + margin: EdgeInsets.only(right: 10.0), + decoration: BoxDecoration( + border: Border.all( + color: Colors.grey, + style: BorderStyle.solid, + width: 1.0, + ), + color: Colors.white, + borderRadius: BorderRadius.circular(10.0)), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + children: [ + Column(children: [ + Container( + padding: EdgeInsets.only( + top: 10.0, + left: 10.0, + right: 10.0, + bottom: 15.0, + ), + child: CircleAvatar( + radius: 30, + backgroundColor: + Colors.transparent, + child: Image.network( + model.prescriptionsList[index] + .doctorImageURL, + width: 60, + height: 60, + ), + ), + ), + ]), + Column( + children: [ + Container( + margin: + EdgeInsets.only(left: 1), + padding: EdgeInsets.only( + left: 15.0, right: 15.0), + decoration: BoxDecoration( + border: Border.all( + color: Colors.green, + style: BorderStyle.solid, + width: 4.0, + ), + color: Colors.green, + borderRadius: + BorderRadius.circular( + 30.0)), + child: Text( + model.languageID == "ar" + ? model + .prescriptionsList[ + index] + .isInOutPatientDescriptionN + .toString() + : model + .prescriptionsList[ + index] + .isInOutPatientDescription + .toString(), + style: TextStyle( + color: Colors.white, + fontSize: 15.0, + ), + )), + Row(children: [ + Image.asset( + 'assets/images/Icon-awesome-calendar.png', + width: 30, + height: 30, + ), + Text( + DateUtil.convertStringToDate( + model + .prescriptionsList[ + index] + .appointmentDate + .toString()) + .toString() + .substring(0, 10), + style: TextStyle( + color: Colors.black, + fontSize: 15.0, + ), + ) + ]), + ], + ), + ], + ), + Row( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Container( + margin: EdgeInsets.only(left: 5), + child: Row(children: [ + Text( + model.prescriptionsList[index] + .doctorTitle + .toString(), + style: TextStyle( + color: Colors.black, + fontSize: 15.0, + fontWeight: FontWeight.bold, + ), + ), + Text( + model.prescriptionsList[index] + .doctorName + .toString(), + style: TextStyle( + color: Colors.black, + fontSize: 15.0, + fontWeight: FontWeight.bold, + ), + ), + ]), + ), + ], + ), + Row( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Container( + margin: EdgeInsets.only(left: 5), + child: Text( + model.prescriptionsList[index] + .clinicDescription + .toString(), + style: TextStyle( + color: Colors.green, + fontSize: 15.0, +// fontWeight: FontWeight.bold, + ), + ), + ), + ], + ), + Row( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Container( + margin: EdgeInsets.only(left: 5), + child: Align( + alignment: Alignment.topLeft, + child: RatingBar.readOnly( + initialRating: model + .prescriptionsList[index] + .actualDoctorRate + .toDouble(), +// initialRating: productRate, + size: 15.0, + filledColor: Colors.yellow[700], + emptyColor: Colors.grey[500], + isHalfAllowed: true, + halfFilledIcon: Icons.star_half, + filledIcon: Icons.star, + emptyIcon: Icons.star, + ), + ), + ) + ]), + ]), + ); + }), + ), + ], + ), + ), + ) + : Container(), + ); + } +} diff --git a/lib/pages/pharmacies/widgets/home/RecentlyViewedWidget.dart b/lib/pages/pharmacies/widgets/home/RecentlyViewedWidget.dart new file mode 100644 index 00000000..3e7cf5fe --- /dev/null +++ b/lib/pages/pharmacies/widgets/home/RecentlyViewedWidget.dart @@ -0,0 +1,59 @@ +import 'package:diplomaticquarterapp/core/enum/viewstate.dart'; +import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/LastVisitedViewModel.dart'; +import 'package:diplomaticquarterapp/pages/base/base_view.dart'; +import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; +import 'package:diplomaticquarterapp/widgets/others/network_base_view.dart'; +import 'package:flutter/material.dart'; + +import '../../../final_products_page.dart'; +import '../ProductTileItem.dart'; +import 'ViewAllHomeWidget.dart'; + +class RecentlyViewedWidget extends StatelessWidget { + @override + Widget build(BuildContext context) { + return BaseView( + onModelReady: (model) => model.getLastVisitedProducts(), + allowAny: true, + builder: (_, model, wi) => NetworkBaseView( + isLocalLoader: true, + baseViewModel: model, + child: model.lastVisitedProducts.isNotEmpty ? Container( + child: Column( + children: [ + ViewAllHomeWidget( + TranslationBase.of(context).recentlyViewed, + FinalProductsPage( + id: "", + productType: 3, + )), + if (model.state != ViewState.BusyLocal) + Container( + height: model.lastVisitedProducts.length > 0 + ? MediaQuery.of(context).size.height / 3 + 20 + : 0, + child: ListView.builder( + itemBuilder: (ctx, i) => + ProductTileItem(model.lastVisitedProducts[i], MediaQuery.of(context).size.height / 4 + 20), + scrollDirection: Axis.horizontal, + itemCount: model.lastVisitedProducts.length, + ), + ) + else + Container( + height: 80, + child: Center( + child:CircularProgressIndicator( + backgroundColor: Colors.white, + valueColor: AlwaysStoppedAnimation( + Colors.grey[500], + ), + ), + ), + ), + ], + ), + ) : Container(), + )); + } +} diff --git a/lib/pages/pharmacies/widgets/home/ShopByBrandWidget.dart b/lib/pages/pharmacies/widgets/home/ShopByBrandWidget.dart new file mode 100644 index 00000000..7fcdbfe8 --- /dev/null +++ b/lib/pages/pharmacies/widgets/home/ShopByBrandWidget.dart @@ -0,0 +1,53 @@ +import 'package:diplomaticquarterapp/core/enum/viewstate.dart'; +import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/BrandViewModel.dart'; +import 'package:diplomaticquarterapp/pages/base/base_view.dart'; +import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; +import 'package:diplomaticquarterapp/widgets/others/network_base_view.dart'; +import 'package:flutter/material.dart'; + +import '../../product-brands.dart'; +import '../manufacturerItem.dart'; +import 'ViewAllHomeWidget.dart'; + +class ShopByBrandWidget extends StatelessWidget { + @override + Widget build(BuildContext context) { + return BaseView( + onModelReady: (model) => model.getTopManufacturerList(), + allowAny: true, + builder: (_, model, wi) => NetworkBaseView( + isLocalLoader: true, + baseViewModel: model, + child: Container( + child: Column( + children: [ + ViewAllHomeWidget(TranslationBase.of(context).shopByBrands, + ProductBrandsPage()), + if (model.state != ViewState.BusyLocal) + Container( + height: 150, + child: ListView.builder( + itemBuilder: (ctx, i) => + ManufacturerItem(model.manufacturerList[i]), + scrollDirection: Axis.horizontal, + itemCount: model.manufacturerList.length, + ), + ) + else + Container( + height: 80, + child: Center( + child: CircularProgressIndicator( + backgroundColor: Colors.white, + valueColor: AlwaysStoppedAnimation( + Colors.grey[500], + ), + ), + ), + ), + ], + ), + ), + )); + } +} diff --git a/lib/pages/pharmacies/widgets/home/ViewAllHomeWidget.dart b/lib/pages/pharmacies/widgets/home/ViewAllHomeWidget.dart new file mode 100644 index 00000000..05c57f2e --- /dev/null +++ b/lib/pages/pharmacies/widgets/home/ViewAllHomeWidget.dart @@ -0,0 +1,46 @@ +import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; +import 'package:diplomaticquarterapp/widgets/buttons/borderedButton.dart'; +import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; +import 'package:flutter/material.dart'; + +class ViewAllHomeWidget extends StatelessWidget { + + final String title; + final Widget navigationWidget; + + + ViewAllHomeWidget(this.title, this.navigationWidget); + + @override + Widget build(BuildContext context) { + return Container( + margin: EdgeInsets.fromLTRB(16, 10, 16, 10), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Texts( + title, + bold: true, + fontSize: 16, + ), + BorderedButton( + TranslationBase.of(context).viewAll, + hasBorder: true, + borderColor: Colors.green, + textColor: Colors.green, + fontWeight: FontWeight.bold, + vPadding: 6, + hPadding: 14, + handler: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => + navigationWidget)); + }, + ), + ], + ), + ); + } +} diff --git a/lib/pages/pharmacies/widgets/manufacturerItem.dart b/lib/pages/pharmacies/widgets/manufacturerItem.dart index 574c37c5..c5b6bf23 100644 --- a/lib/pages/pharmacies/widgets/manufacturerItem.dart +++ b/lib/pages/pharmacies/widgets/manufacturerItem.dart @@ -1,4 +1,5 @@ import 'package:diplomaticquarterapp/core/model/pharmacies/Manufacturer.dart'; +import 'package:diplomaticquarterapp/widgets/text/app_texts_widget.dart'; import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; import 'package:flutter/material.dart'; @@ -23,28 +24,33 @@ class ManufacturerItem extends StatelessWidget { ), ); }, - child: Card( - shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)), + child: Container( + width: 100, margin: EdgeInsets.symmetric( - horizontal: 8, + horizontal: 12, vertical: 4, ), - child: Container( - decoration: BoxDecoration( - border: Border( - right: BorderSide(color: Colors.grey.shade300, width: 1), - bottom: BorderSide(color: Colors.grey.shade300, width: 1), - left: BorderSide(color: Colors.grey.shade300, width: 1), - top: BorderSide(color: Colors.grey.shade300, width: 1)), - ), - child: Padding( - padding: EdgeInsets.symmetric(horizontal: 8), - child: Image.network( - item.image.src, - fit: BoxFit.cover, - ), - ), + decoration: BoxDecoration( + borderRadius:BorderRadius.circular(12) , + border: Border( + right: BorderSide(color: Colors.grey.shade300, width: 1), + bottom: BorderSide(color: Colors.grey.shade300, width: 1), + left: BorderSide(color: Colors.grey.shade300, width: 1), + top: BorderSide(color: Colors.grey.shade300, width: 1)), ), + child: item.image == null + ? Container( + padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 10), + alignment: Alignment.topCenter, + child: AppText(item.name, fontWeight: FontWeight.w500,fontSize: 14,), + ) + : Padding( + padding: EdgeInsets.symmetric(horizontal: 8), + child: Image.network( + item.image.src, + fit: BoxFit.cover, + ), + ), ), ); } diff --git a/lib/pages/pharmacies/wishlist.dart b/lib/pages/pharmacies/wishlist.dart index b75f709b..3d1c8114 100644 --- a/lib/pages/pharmacies/wishlist.dart +++ b/lib/pages/pharmacies/wishlist.dart @@ -5,68 +5,61 @@ import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:flutter/material.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; -class WishlistPage extends StatefulWidget { - bool showBar; - WishlistPage(this.showBar); - @override - _WishlistPageState createState() => _WishlistPageState(); -} - -class _WishlistPageState extends State { - bool isTrue = true; +class WishlistPage extends StatelessWidget { + const WishlistPage({Key key}) : super(key: key); + @override Widget build(BuildContext context) { return BaseView( onModelReady: (model) => model.getWishlistData(), builder: (_, model, wi) => AppScaffold( appBarTitle: TranslationBase.of(context).wishlist, - isShowAppBar: widget.showBar, + isShowAppBar: true, isShowDecPage: false, isPharmacy: true, baseViewModel: model, body: model.wishListList.length == 0 ? Container( - child: Center( - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Padding( - padding: const EdgeInsets.all(8.0), - child: Image.asset( - 'assets/images/new-design/empty_box.png', - width: 100, - height: 100, - fit: BoxFit.cover, - ), - ), - Padding( - padding: const EdgeInsets.all(8.0), - child: Text( - 'There is no data', - style: TextStyle(fontSize: 30), - ), - ) - ], + child: Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Padding( + padding: const EdgeInsets.all(8.0), + child: Image.asset( + 'assets/images/new-design/empty_box.png', + width: 100, + height: 100, + fit: BoxFit.cover, ), ), - ) + Padding( + padding: const EdgeInsets.all(8.0), + child: Text( + 'There is no data', + style: TextStyle(fontSize: 30), + ), + ) + ], + ), + ), + ) : Container( - child: Column( - children: [ - Expanded( - flex: 20, - child: Container( - width: double.infinity, - height: - MediaQuery.of(context).size.height * 0.85, //250, - child: - ProductCheckTypeWidget(isTrue, model.wishListList), - ), - ), - ], + child: Column( + children: [ + Expanded( + flex: 20, + child: Container( + width: double.infinity, + height: MediaQuery.of(context).size.height * 0.85, //250, + child: ProductCheckTypeWidget(model: model,), ), ), + ], + ), + ), ), ); } } + diff --git a/lib/pages/pharmacy/order/Order.dart b/lib/pages/pharmacy/order/Order.dart index 9afd2554..6cc0961e 100644 --- a/lib/pages/pharmacy/order/Order.dart +++ b/lib/pages/pharmacy/order/Order.dart @@ -242,9 +242,10 @@ class _OrderPageState extends State color: Colors.blue[700], borderRadius: BorderRadius.circular(30.0)), - child: deliveredOrderList[index] - .orderStatusId == - 30 + child: deliveredOrderList[index].orderStatusId == 30 || + deliveredOrderList[index].orderStatusId == 997 || + deliveredOrderList[index].orderStatusId == 994 +// deliveredOrderList[index].orderStatusId == 30 ? Text( // deliveredOrderList[0].orderStatus.toString().substring(12), TranslationBase.of(context) @@ -507,9 +508,11 @@ class _OrderPageState extends State color: Colors.green, borderRadius: BorderRadius.circular(30.0)), - child: processingOrderList[index] - .orderStatusId == - 20 + child: processingOrderList[index].orderStatusId == 20 || + processingOrderList[index].orderStatusId == 995 || + processingOrderList[index].orderStatusId == 998 || + processingOrderList[index].orderStatusId == 999 +// processingOrderList[index].orderStatusId == 20 ? Text( // deliveredOrderList[0].orderStatus.toString().substring(12), TranslationBase.of(context) diff --git a/lib/pages/pharmacy/order/OrderDetails.dart b/lib/pages/pharmacy/order/OrderDetails.dart index 999356e9..0a0a131d 100644 --- a/lib/pages/pharmacy/order/OrderDetails.dart +++ b/lib/pages/pharmacy/order/OrderDetails.dart @@ -121,17 +121,40 @@ class _OrderDetailsPageState extends State { ), color: getStatusBackgroundColor(), borderRadius: BorderRadius.circular(30.0)), - child: Text( + child: model.orderListModel[0].orderStatusId == 30 || + model.orderListModel[0].orderStatusId == 997 || + model.orderListModel[0].orderStatusId == 994 +// deliveredOrderList[index].orderStatusId == 30 + ? Text( +// deliveredOrderList[0].orderStatus.toString().substring(12), + TranslationBase.of(context).deliveredOrder, + style: TextStyle( + color: Colors.white, + fontSize: 15.0, + fontWeight: FontWeight.bold, + ), + ) + : Text( languageID == "ar" - ? model.orderListModel[0].orderStatusn - : model.orderListModel[0].orderStatus, -// TranslationBase.of(context).delivered, + ? model.orderListModel[0].orderStatusn.toString() + : model.orderListModel[0].orderStatus.toString(), style: TextStyle( color: Colors.white, fontSize: 13.0, fontWeight: FontWeight.bold, ), - ), + ) +// Text( +// languageID == "ar" +// ? model.orderListModel[0].orderStatusn +// : model.orderListModel[0].orderStatus, +//// TranslationBase.of(context).delivered, +// style: TextStyle( +// color: Colors.white, +// fontSize: 13.0, +// fontWeight: FontWeight.bold, +// ), +// ), ), ], ), diff --git a/lib/pages/pharmacy/pharmacyAddresses/AddAddress.dart b/lib/pages/pharmacy/pharmacyAddresses/AddAddress.dart index 54a54322..514ea1a5 100644 --- a/lib/pages/pharmacy/pharmacyAddresses/AddAddress.dart +++ b/lib/pages/pharmacy/pharmacyAddresses/AddAddress.dart @@ -33,8 +33,14 @@ class _AddAddressPageState extends State { } else { _getCurrentLocation(); } + + setState(() { + }); } + + + _getCurrentLocation() async { await Geolocator.getLastKnownPosition().then((value) { _latitude = value.latitude; @@ -42,9 +48,12 @@ class _AddAddressPageState extends State { }).catchError((e) { _longitude = 0; _latitude = 0; + + }); } + @override Widget build(BuildContext context) { final mediaQuery = MediaQuery.of(context); @@ -59,8 +68,8 @@ class _AddAddressPageState extends State { body: Container( height: height * 1, child: PickupLocationFromMap( - latitude: _latitude, - longitude: _longitude, + latitude: _latitude??0, + longitude: _longitude??0, isWithAppBar: false, buttonColor: Color(0xFF5AB145), buttonLabel: TranslationBase.of(context).save, diff --git a/lib/pages/pharmacy/pharmacyAddresses/PharmacyAddresses.dart b/lib/pages/pharmacy/pharmacyAddresses/PharmacyAddresses.dart index 906abd9e..b763e960 100644 --- a/lib/pages/pharmacy/pharmacyAddresses/PharmacyAddresses.dart +++ b/lib/pages/pharmacy/pharmacyAddresses/PharmacyAddresses.dart @@ -78,6 +78,8 @@ class _PharmacyAddressesState extends State { }, ), ), + SizedBox(height: height * 0.10,) + ], ), ), diff --git a/lib/pages/pharmacy/profile/profile.dart b/lib/pages/pharmacy/profile/profile.dart index 918e9668..a82a74eb 100644 --- a/lib/pages/pharmacy/profile/profile.dart +++ b/lib/pages/pharmacy/profile/profile.dart @@ -93,7 +93,7 @@ class _ProfilePageState extends State { }, builder: (_, model, wi) => AppScaffold( appBarTitle: TranslationBase.of(context).myAccount, - isShowAppBar: true, + isShowAppBar: false, isShowDecPage: false, isPharmacy: true, body: user != null @@ -235,9 +235,7 @@ class _ProfilePageState extends State { onTap: () { Navigator.push( context, - MaterialPageRoute( - builder: (context) => - WishlistPage(true))); + FadePage(page: WishlistPage())); }, child: Column( children: [ diff --git a/lib/pages/pharmacy_categorise.dart b/lib/pages/pharmacy_categorise.dart index ff1920dc..b71c28ce 100644 --- a/lib/pages/pharmacy_categorise.dart +++ b/lib/pages/pharmacy_categorise.dart @@ -30,6 +30,7 @@ class _PharmacyCategorisePageState extends State { ProjectViewModel projectViewModel = Provider.of(context); return BaseView( onModelReady: (model) => model.getCategorise(), + allowAny: true, builder: (BuildContext context, PharmacyCategoriseViewModel model, Widget child) => AppScaffold( diff --git a/lib/pages/search_products_page.dart b/lib/pages/search_products_page.dart index 6e8b0c73..0aac68a0 100644 --- a/lib/pages/search_products_page.dart +++ b/lib/pages/search_products_page.dart @@ -1,5 +1,7 @@ import 'package:diplomaticquarterapp/config/size_config.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacy_categorise_view_model.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/product-brands.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/product-detail.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/product_detail.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/utils.dart'; diff --git a/lib/pages/sub_categories_modalsheet.dart b/lib/pages/sub_categories_modalsheet.dart new file mode 100644 index 00000000..d6499c8e --- /dev/null +++ b/lib/pages/sub_categories_modalsheet.dart @@ -0,0 +1,109 @@ + +import 'package:diplomaticquarterapp/core/model/pharmacy/categorise_parent_model.dart'; +import 'package:diplomaticquarterapp/core/model/pharmacy/pharmacy_categorise.dart'; +import 'package:diplomaticquarterapp/core/viewModels/pharmacy_categorise_view_model.dart'; +import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; +import 'package:diplomaticquarterapp/pages/sub_categorise_page.dart'; +import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; +import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; +import 'package:diplomaticquarterapp/widgets/others/app_scaffold_pharmacy_widget.dart'; +import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; +import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; +import 'package:flutter/material.dart'; +import 'base/base_view.dart'; +import 'package:provider/provider.dart'; + + + + +class SubCategoriseModalsheet extends StatefulWidget { + String id; + String titleName; + + SubCategoriseModalsheet({this.id, this.titleName}); + @override + _SubCategoriseModalsheetState createState() => _SubCategoriseModalsheetState(id: id, titleName: titleName); + +} + +class _SubCategoriseModalsheetState extends State { + String id; + String titleName; +// List categoriesList = []; + _SubCategoriseModalsheetState({this.id, this.titleName}); + + @override + Widget build(BuildContext context) { + ProjectViewModel projectViewModel = Provider.of(context); + return BaseView( + onModelReady: (model) => model.getCategoriseParent(i: id), + builder: (_, model, wi) => AppScaffold( + // appBarTitle: titleName, + appBarTitle: TranslationBase.of(context).categorise, + isBottomBar: false, + isShowAppBar: true, + isPharmacy: true, + backgroundColor: Colors.white, + isShowDecPage: false, + baseViewModel: model, + body: Container( + color: Colors.white, + child: Center( + child: ListView.builder( + scrollDirection: Axis.vertical, + itemCount: model.categoriseParent.length, + itemBuilder: (BuildContext context, int index) { + return Container( + child: Padding( + padding: EdgeInsets.all(4.0), + child: InkWell( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Texts(projectViewModel.isArabic + ? model.categoriseParent[index].namen + : model.categoriseParent[index].name), + SizedBox( + height: 10, + ), + Divider( + thickness: 0.6, + color: Colors.black12, + ) + ], + ), + onTap: () { + Navigator.push( + context, + FadePage( + page: SubCategorisePage( + title: model.categoriseParent[index].name, + id: model.categoriseParent[index].id, + parentId: id, + )), + ); + }, + ), + ), + ); + }), + ), + ), + + ), + ); + } +// getCatName() { +// +// if (widget.id == '1' ) +// return Texts("text1"); +// else if (widget.id == '2' ) +// return Texts("text2"); +// else if (widget.id == '3') +// return Texts("text3"); +// else if (widget.id == '4' ) +// return Texts("text4"); +// } + + +} \ No newline at end of file diff --git a/lib/pages/sub_categorise_page.dart b/lib/pages/sub_categorise_page.dart index 45617072..3fb1574f 100644 --- a/lib/pages/sub_categorise_page.dart +++ b/lib/pages/sub_categorise_page.dart @@ -1,6 +1,11 @@ import 'package:diplomaticquarterapp/core/model/pharmacy/categorise_parent_model.dart'; +import 'package:diplomaticquarterapp/core/service/AuthenticatedUserObject.dart'; +import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/product_detail_view_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacy_categorise_view_model.dart'; -import 'package:diplomaticquarterapp/pages/pharmacies/product_detail.dart'; +import 'package:diplomaticquarterapp/locator.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/screens/cart-order-page.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/product-detail.dart'; +import 'package:diplomaticquarterapp/uitl/app_toast.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; import 'package:diplomaticquarterapp/widgets/buttons/button.dart'; @@ -20,10 +25,14 @@ class SubCategorisePage extends StatefulWidget { String title; String parentId; + AuthenticatedUserObject authenticatedUserObject = + locator(); + SubCategorisePage({this.id, this.parentId, this.title}); @override - _SubCategorisePageState createState() => _SubCategorisePageState(id: id, title: title, parentId: parentId); + _SubCategorisePageState createState() => + _SubCategorisePageState(id: id, title: title, parentId: parentId); } class _SubCategorisePageState extends State { @@ -51,7 +60,9 @@ class _SubCategorisePageState extends State { TextEditingController maxField = TextEditingController(); return BaseView( onModelReady: (model) => model.getSubCategorise(i: id), - builder: (BuildContext context, PharmacyCategoriseViewModel model, Widget child) => PharmacyAppScaffold( + builder: (BuildContext context, PharmacyCategoriseViewModel model, + Widget child) => + PharmacyAppScaffold( appBarTitle: title, isBottomBar: false, isShowAppBar: true, @@ -83,7 +94,8 @@ class _SubCategorisePageState extends State { ? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089195_diet-nutrition_2.png' : parentId == '9' ? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089196_household_2.png' - : parentId == '10' + : parentId == + '10' ? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089197_home-care-appliances_2.png' : '', fit: BoxFit.fill, @@ -95,12 +107,14 @@ class _SubCategorisePageState extends State { children: [ InkWell( child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, + mainAxisAlignment: + MainAxisAlignment.spaceBetween, children: [ Padding( padding: EdgeInsets.all(10.0), child: Container( - child: Texts(TranslationBase.of(context).viewCategorise), + child: Texts(TranslationBase.of(context) + .viewCategorise), ), ), Icon(Icons.arrow_forward) @@ -112,21 +126,30 @@ class _SubCategorisePageState extends State { context: context, builder: (BuildContext context) { return Container( - height: MediaQuery.of(context).size.height * 0.89, + height: + MediaQuery.of(context).size.height * + 0.89, color: Colors.white, child: Center( child: ListView.builder( scrollDirection: Axis.vertical, - itemCount: model.subCategorise.length, - itemBuilder: (BuildContext context, int index) { + itemCount: + model.subCategorise.length, + itemBuilder: (BuildContext context, + int index) { return Container( child: Padding( padding: EdgeInsets.all(8.0), child: InkWell( child: Column( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment + .start, children: [ - Texts(model.subCategorise[index].name), + Texts(model + .subCategorise[ + index] + .name), Divider( thickness: 0.6, color: Colors.black12, @@ -137,8 +160,12 @@ class _SubCategorisePageState extends State { Navigator.push( context, FadePage( - page: FinalProductsPage( - id: model.subCategorise[index].id, + page: + FinalProductsPage( + id: model + .subCategorise[ + index] + .id, ), ), ); @@ -171,19 +198,23 @@ class _SubCategorisePageState extends State { itemCount: model.subCategorise.length, itemBuilder: (BuildContext context, int index) { return Padding( - padding: EdgeInsets.symmetric(horizontal: 8.0), + padding: + EdgeInsets.symmetric(horizontal: 8.0), child: InkWell( child: Column( - crossAxisAlignment: CrossAxisAlignment.center, + crossAxisAlignment: + CrossAxisAlignment.center, children: [ Padding( - padding: EdgeInsets.symmetric(horizontal: 13.0), + padding: EdgeInsets.symmetric( + horizontal: 13.0), child: Container( height: 60.0, width: 65.0, decoration: BoxDecoration( shape: BoxShape.circle, - color: Colors.orange.shade200.withOpacity(0.45), + color: Colors.orange.shade200 + .withOpacity(0.45), ), child: Center( child: Icon( @@ -194,8 +225,14 @@ class _SubCategorisePageState extends State { ), ), Container( - width: MediaQuery.of(context).size.width * 0.17, - height: MediaQuery.of(context).size.height * 0.10, + width: MediaQuery.of(context) + .size + .width * + 0.17, + height: MediaQuery.of(context) + .size + .height * + 0.10, child: Center( child: Texts( model.subCategorise[index].name, @@ -256,16 +293,21 @@ class _SubCategorisePageState extends State { initialChildSize: 0.95, maxChildSize: 0.95, minChildSize: 0.9, - builder: (BuildContext context, ScrollController scrollController) { + builder: (BuildContext context, + ScrollController scrollController) { return SingleChildScrollView( controller: scrollController, child: Container( color: Colors.white, - height: MediaQuery.of(context).size.height * 1.95, + height: MediaQuery.of(context) + .size + .height * + 1.95, child: Column( children: [ Padding( - padding: EdgeInsets.all(8.0), + padding: + EdgeInsets.all(8.0), child: Row( children: [ Icon( @@ -275,23 +317,30 @@ class _SubCategorisePageState extends State { width: 10.0, ), Texts( - TranslationBase.of(context).refine, + TranslationBase.of( + context) + .refine, // 'Refine', - fontWeight: FontWeight.w600, + fontWeight: + FontWeight.w600, ), SizedBox( width: 250.0, ), InkWell( child: Texts( - TranslationBase.of(context).closeIt, + TranslationBase.of( + context) + .closeIt, // 'Close', color: Colors.red, - fontWeight: FontWeight.w600, + fontWeight: + FontWeight.w600, fontSize: 15.0, ), onTap: () { - Navigator.pop(context); + Navigator.pop( + context); }, ), ], @@ -304,27 +353,39 @@ class _SubCategorisePageState extends State { Column( children: [ ExpansionTile( - title: Texts(TranslationBase.of(context).categorise), + title: Texts( + TranslationBase.of( + context) + .categorise), children: [ ProcedureListWidget( model: model, - masterList: model.subCategorise, - removeHistory: (item) { + masterList: model + .subCategorise, + removeHistory: + (item) { setState(() { - entityList.remove(item); + entityList + .remove( + item); }); }, - addHistory: (history) { + addHistory: + (history) { setState(() { - entityList.add(history); + entityList.add( + history); }); }, - addSelectedHistories: () { + addSelectedHistories: + () { //TODO build your fun herr // widget.addSelectedHistories(); }, - isEntityListSelected: (master) => - isEntityListSelected(master), + isEntityListSelected: + (master) => + isEntityListSelected( + master), ) ], ), @@ -333,27 +394,40 @@ class _SubCategorisePageState extends State { color: Colors.black12, ), ExpansionTile( - title: Texts(TranslationBase.of(context).brands), + title: Texts( + TranslationBase.of( + context) + .brands), children: [ ProcedureListWidget( model: model, - masterList: model.brandsList, - removeHistory: (item) { + masterList: model + .brandsList, + removeHistory: + (item) { setState(() { - entityListBrands.remove(item); + entityListBrands + .remove( + item); }); }, - addHistory: (history) { + addHistory: + (history) { setState(() { - entityListBrands.add(history); + entityListBrands + .add( + history); }); }, - addSelectedHistories: () { + addSelectedHistories: + () { //TODO build your fun herr // widget.addSelectedHistories(); }, - isEntityListSelected: (master) => - isEntityListSelectedBrands(master), + isEntityListSelected: + (master) => + isEntityListSelectedBrands( + master), ) ], ), @@ -362,43 +436,69 @@ class _SubCategorisePageState extends State { color: Colors.black12, ), ExpansionTile( - title: Texts(TranslationBase.of(context).price), + title: Texts( + TranslationBase.of( + context) + .price), children: [ Container( - color: Color(0xffEEEEEE), + color: Color( + 0xffEEEEEE), child: Row( - mainAxisAlignment: MainAxisAlignment.spaceAround, + mainAxisAlignment: + MainAxisAlignment + .spaceAround, children: [ Column( - mainAxisAlignment: MainAxisAlignment.start, + mainAxisAlignment: + MainAxisAlignment + .start, children: [ - Texts('Min'), + Texts( + 'Min'), Container( - color: Colors.white, - width: 200, - height: 40, - child: TextFormField( - decoration: InputDecoration( - border: OutlineInputBorder(), + color: Colors + .white, + width: + 200, + height: + 40, + child: + TextFormField( + decoration: + InputDecoration( + border: + OutlineInputBorder(), ), - controller: minField, + controller: + minField, ), ), ], ), Column( - mainAxisAlignment: MainAxisAlignment.start, + mainAxisAlignment: + MainAxisAlignment + .start, children: [ - Texts('Max'), + Texts( + 'Max'), Container( - color: Colors.white, - width: 200, - height: 40, - child: TextFormField( - decoration: InputDecoration( - border: OutlineInputBorder(), + color: Colors + .white, + width: + 200, + height: + 40, + child: + TextFormField( + decoration: + InputDecoration( + border: + OutlineInputBorder(), ), - controller: maxField, + controller: + maxField, ), ), ], @@ -413,20 +513,31 @@ class _SubCategorisePageState extends State { color: Colors.black12, ), SizedBox( - height: MediaQuery.of(context).size.height * 0.4, + height: MediaQuery.of( + context) + .size + .height * + 0.4, ), Padding( - padding: EdgeInsets.all(8.0), + padding: + EdgeInsets.all(8.0), child: Row( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, + mainAxisAlignment: + MainAxisAlignment + .spaceEvenly, children: [ Expanded( child: Container( width: 100, child: Button( - label: TranslationBase.of(context).reset, + label: TranslationBase.of( + context) + .reset, // 'Reset', - backgroundColor: Colors.red, + backgroundColor: + Colors + .red, ), ), ), @@ -436,37 +547,66 @@ class _SubCategorisePageState extends State { Container( width: 200, child: Button( - onTap: () async { - String categoriesId = ""; - for (CategoriseParentModel category in entityList) { - if (categoriesId == "") { - categoriesId = category.id; + onTap: + () async { + String + categoriesId = + ""; + for (CategoriseParentModel category + in entityList) { + if (categoriesId == + "") { + categoriesId = + category + .id; } else { - categoriesId = "$categoriesId,${category.id}"; + categoriesId = + "$categoriesId,${category.id}"; } } - String brandIds = ""; + String + brandIds = + ""; for (CategoriseParentModel brand in entityListBrands) { - if (brandIds == "") { - brandIds = brand.id; + if (brandIds == + "") { + brandIds = + brand + .id; } else { - brandIds = "$brandIds,${brand.id}"; + brandIds = + "$brandIds,${brand.id}"; } } - GifLoaderDialogUtils.showMyDialog(context); + GifLoaderDialogUtils + .showMyDialog( + context); await model.getFilteredSubProducts( - min: minField.text.toString(), - max: maxField.text.toString(), - categoryId: categoriesId, - brandId: brandIds); - GifLoaderDialogUtils.hideDialog(context); - Navigator.pop(context); + min: minField + .text + .toString(), + max: maxField + .text + .toString(), + categoryId: + categoriesId, + brandId: + brandIds); + GifLoaderDialogUtils + .hideDialog( + context); + Navigator.pop( + context); }, - label: TranslationBase.of(context).apply, + label: TranslationBase.of( + context) + .apply, // 'Apply', - backgroundColor: Colors.green, + backgroundColor: + Colors + .green, ), ), ], @@ -533,22 +673,28 @@ class _SubCategorisePageState extends State { model.subProducts.isNotEmpty ? styleOne == true ? Container( - height: model.subProducts.length * MediaQuery.of(context).size.height * 0.15, + height: model.subProducts.length * + MediaQuery.of(context).size.height * + 0.15, child: GridView.builder( physics: NeverScrollableScrollPhysics(), - gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( + gridDelegate: + SliverGridDelegateWithFixedCrossAxisCount( crossAxisCount: 2, crossAxisSpacing: 0.5, mainAxisSpacing: 2.0, childAspectRatio: 0.9, ), itemCount: model.subProducts.length, - itemBuilder: (BuildContext context, int index) { + itemBuilder: + (BuildContext context, int index) { return NetworkBaseView( baseViewModel: model, child: InkWell( child: Card( - color: model.subProducts[index].discountName != null + color: model.subProducts[index] + .discountName != + null ? Color(0xffFFFF00) : Colors.white, elevation: 0, @@ -576,67 +722,118 @@ class _SubCategorisePageState extends State { ), child: Container( decoration: BoxDecoration( - borderRadius: BorderRadius.only( - topLeft: Radius.circular(110.0), + borderRadius: + BorderRadius.only( + topLeft: + Radius.circular(110.0), ), color: Colors.white, ), - padding: EdgeInsets.symmetric(horizontal: 0), - width: MediaQuery.of(context).size.width / 3, + padding: EdgeInsets.symmetric( + horizontal: 0), + width: MediaQuery.of(context) + .size + .width / + 3, child: Column( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ Stack( children: [ Container( - margin: EdgeInsets.fromLTRB(0, 16, 0, 0), - alignment: Alignment.center, + margin: EdgeInsets + .fromLTRB( + 0, 16, 0, 0), + alignment: + Alignment.center, child: Image.network( - model.subProducts[index].images.isNotEmpty - ? model.subProducts[index].images[0].thumb + model + .subProducts[ + index] + .images + .isNotEmpty + ? model + .subProducts[ + index] + .images[0] + .thumb : 'https://upload.wikimedia.org/wikipedia/commons/thumb/6/6c/No_image_3x4.svg/1200px-No_image_3x4.svg.png', fit: BoxFit.cover, height: 80, ), ), Container( - width: model.subProducts[index].rxMessage != null - ? MediaQuery.of(context).size.width / 5 + width: model + .subProducts[ + index] + .rxMessage != + null + ? MediaQuery.of( + context) + .size + .width / + 5 : 0, - padding: EdgeInsets.all(4), - decoration: BoxDecoration( - color: Color(0xffb23838), + padding: + EdgeInsets.all(4), + decoration: + BoxDecoration( + color: Color( + 0xffb23838), borderRadius: - BorderRadius.only(topLeft: Radius.circular(6)), + BorderRadius.only( + topLeft: Radius + .circular( + 6)), ), child: Texts( - model.subProducts[index].rxMessage != null - ? model.subProducts[index].rxMessage + model + .subProducts[ + index] + .rxMessage != + null + ? model + .subProducts[ + index] + .rxMessage : "", color: Colors.white, regular: true, fontSize: 10, - fontWeight: FontWeight.w400, + fontWeight: + FontWeight.w400, ), ), ], ), Container( - margin: EdgeInsets.symmetric( + margin: + EdgeInsets.symmetric( horizontal: 6, vertical: 0, ), child: Column( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment + .start, children: [ Texts( - model.subProducts[index].name, + model + .subProducts[ + index] + .name, regular: true, fontSize: 12, - fontWeight: FontWeight.w400, + fontWeight: + FontWeight.w400, ), Padding( - padding: const EdgeInsets.only(top: 4, bottom: 4), + padding: + const EdgeInsets + .only( + top: 4, + bottom: 4), child: Texts( "SAR ${model.subProducts[index].price}", bold: true, @@ -646,21 +843,25 @@ class _SubCategorisePageState extends State { Row( children: [ StarRating( - totalAverage: - model.subProducts[index].approvedRatingSum > 0 - ? (model.subProducts[index].approvedRatingSum - .toDouble() / - model.subProducts[index] - .approvedRatingSum - .toDouble()) - .toDouble() - : 0, - forceStars: true), + totalAverage: model + .subProducts[ + index] + .approvedRatingSum > + 0 + ? (model.subProducts[index].approvedRatingSum.toDouble() / + model.subProducts[index].approvedRatingSum + .toDouble()) + .toDouble() + : 0, + forceStars: + true), Texts( "(${model.subProducts[index].approvedTotalReviews})", regular: true, fontSize: 10, - fontWeight: FontWeight.w400, + fontWeight: + FontWeight + .w400, ) ], ), @@ -675,7 +876,9 @@ class _SubCategorisePageState extends State { Navigator.push( context, FadePage( - page: ProductDetailPage(model.subProducts[index]), + page: ProductDetailPage( + model.subProducts[ + index]), )), }, )); @@ -683,11 +886,14 @@ class _SubCategorisePageState extends State { ), ) : Container( - height: model.subProducts.length * MediaQuery.of(context).size.height * 0.122, + height: model.subProducts.length * + MediaQuery.of(context).size.height * + 0.122, child: ListView.builder( physics: NeverScrollableScrollPhysics(), itemCount: model.subProducts.length, - itemBuilder: (BuildContext context, int index) { + itemBuilder: + (BuildContext context, int index) { return InkWell( child: Card( child: Row( @@ -697,9 +903,11 @@ class _SubCategorisePageState extends State { Column( children: [ Container( - decoration: BoxDecoration(), + decoration: + BoxDecoration(), child: Padding( - padding: EdgeInsets.only( + padding: + EdgeInsets.only( left: 9.0, top: 8.0, right: 10.0, @@ -707,11 +915,22 @@ class _SubCategorisePageState extends State { ), ), Container( - margin: EdgeInsets.fromLTRB(0, 0, 0, 0), - alignment: Alignment.center, + margin: EdgeInsets + .fromLTRB( + 0, 0, 0, 0), + alignment: + Alignment.center, child: Image.network( - model.subProducts[index].images.isNotEmpty - ? model.subProducts[index].images[0].thumb + model + .subProducts[ + index] + .images + .isNotEmpty + ? model + .subProducts[ + index] + .images[0] + .thumb : 'https://upload.wikimedia.org/wikipedia/commons/thumb/6/6c/No_image_3x4.svg/1200px-No_image_3x4.svg.png', fit: BoxFit.contain, height: 80, @@ -722,23 +941,45 @@ class _SubCategorisePageState extends State { Column( children: [ Container( - width: model.subProducts[index].rxMessage != null - ? MediaQuery.of(context).size.width / 5 + width: model + .subProducts[ + index] + .rxMessage != + null + ? MediaQuery.of( + context) + .size + .width / + 5.3 : 0, - padding: EdgeInsets.all(4), - decoration: BoxDecoration( - color: Color(0xffb23838), + padding: + EdgeInsets.all(4), + decoration: + BoxDecoration( + color: Color( + 0xffb23838), borderRadius: - BorderRadius.only(topLeft: Radius.circular(6)), + BorderRadius.only( + topLeft: Radius + .circular( + 6)), ), child: Texts( - model.subProducts[index].rxMessage != null - ? model.subProducts[index].rxMessage + model + .subProducts[ + index] + .rxMessage != + null + ? model + .subProducts[ + index] + .rxMessage : "", color: Colors.white, regular: true, fontSize: 10, - fontWeight: FontWeight.w400, + fontWeight: + FontWeight.w400, ), ), ], @@ -752,19 +993,31 @@ class _SubCategorisePageState extends State { vertical: 0, ), child: Column( - mainAxisAlignment: MainAxisAlignment.spaceAround, - crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: + MainAxisAlignment + .spaceAround, + crossAxisAlignment: + CrossAxisAlignment + .start, children: [ SizedBox( height: 4.0, ), Container( - width: MediaQuery.of(context).size.width * 0.65, + width: MediaQuery.of( + context) + .size + .width * + 0.65, child: Texts( - model.subProducts[index].name, + model + .subProducts[ + index] + .name, regular: true, fontSize: 13.2, - fontWeight: FontWeight.w500, + fontWeight: + FontWeight.w500, maxLines: 5, ), ), @@ -772,7 +1025,11 @@ class _SubCategorisePageState extends State { height: 8.0, ), Padding( - padding: const EdgeInsets.only(top: 4, bottom: 4), + padding: + const EdgeInsets + .only( + top: 4, + bottom: 4), child: Texts( "SAR ${model.subProducts[index].price}", bold: true, @@ -782,26 +1039,55 @@ class _SubCategorisePageState extends State { Row( children: [ StarRating( - totalAverage: - model.subProducts[index].approvedRatingSum > 0 - ? (model.subProducts[index].approvedRatingSum - .toDouble() / - model.subProducts[index].approvedRatingSum - .toDouble()) - .toDouble() - : 0, + totalAverage: model + .subProducts[ + index] + .approvedRatingSum > + 0 + ? (model.subProducts[index].approvedRatingSum + .toDouble() / + model + .subProducts[index] + .approvedRatingSum + .toDouble()) + .toDouble() + : 0, forceStars: true), Texts( "(${model.subProducts[index].approvedTotalReviews})", regular: true, fontSize: 10, - fontWeight: FontWeight.w400, + fontWeight: + FontWeight.w400, ) ], ), ], ), ), + widget.authenticatedUserObject.isLogin? + Container( + child: IconButton( + icon: Icon(Icons.shopping_cart, + size: 18, + color: Colors.blue,), + onPressed: () async { + GifLoaderDialogUtils.showMyDialog(context); + if(model.subProducts[index].rxMessage == null){ + await addToCartFunction(1, model.subProducts[index].id); +// GifLoaderDialogUtils.hideDialog(context); + Navigator.push( + context, + FadePage(page: CartOrderPage()), + );} + else{ + AppToast.showErrorToast(message: TranslationBase.of(context).needPrescription); + } + GifLoaderDialogUtils.hideDialog(context); + } + + ), + ):Container(), ], ), ), @@ -809,7 +1095,8 @@ class _SubCategorisePageState extends State { Navigator.push( context, FadePage( - page: ProductDetailPage(model.subProducts[index]), + page: ProductDetailPage( + model.subProducts[index]), )), }, ); @@ -851,7 +1138,8 @@ class _SubCategorisePageState extends State { } bool isEntityListSelected(CategoriseParentModel masterKey) { - Iterable history = entityList.where((element) => masterKey.id == element.id); + Iterable history = + entityList.where((element) => masterKey.id == element.id); if (history.length > 0) { return true; } @@ -859,10 +1147,15 @@ class _SubCategorisePageState extends State { } bool isEntityListSelectedBrands(CategoriseParentModel masterKey) { - Iterable history = entityListBrands.where((element) => masterKey.id == element.id); + Iterable history = + entityListBrands.where((element) => masterKey.id == element.id); if (history.length > 0) { return true; } return false; } + addToCartFunction(quantity, itemID) async { + ProductDetailViewModel x = new ProductDetailViewModel(); + await x.addToCartData(quantity, itemID); + } } diff --git a/lib/services/pharmacy_services/product_detail_service.dart b/lib/services/pharmacy_services/product_detail_service.dart index 181a4101..31a06fea 100644 --- a/lib/services/pharmacy_services/product_detail_service.dart +++ b/lib/services/pharmacy_services/product_detail_service.dart @@ -5,6 +5,7 @@ import 'package:diplomaticquarterapp/models/pharmacy/Wishlist.dart'; import 'package:diplomaticquarterapp/models/pharmacy/locationModel.dart'; import 'package:diplomaticquarterapp/models/pharmacy/productDetailModel.dart'; import 'package:diplomaticquarterapp/models/pharmacy/specification.dart'; +import 'package:diplomaticquarterapp/uitl/utils.dart'; import 'package:diplomaticquarterapp/uitl/app_toast.dart'; class ProductDetailService extends BaseService { @@ -87,6 +88,9 @@ class ProductDetailService extends BaseService { "language_id": 1 } }; + + + await baseAppClient.pharmacyPost(GET_SHOPPING_CART, isExternal: false, onSuccess: (dynamic response, int statusCode) { _addToCartModel.clear(); @@ -97,7 +101,7 @@ class ProductDetailService extends BaseService { }, onFailure: (String error, int statusCode) { hasError = true; super.error = error; - AppToast.showErrorToast(message: 'something went wrong please try again'); + AppToast.showErrorToast(message: error??Utils.generateContactAdminMessage()); }, body: request); } @@ -108,7 +112,7 @@ class ProductDetailService extends BaseService { }, onFailure: (String error, int statusCode) { hasError = true; super.error = error; - AppToast.showErrorToast(message: 'something went wrong please try again'); + AppToast.showErrorToast(message: error??Utils.generateContactAdminMessage()); }); } @@ -125,12 +129,13 @@ class ProductDetailService extends BaseService { _wishListProducts.clear(); response['shopping_carts'].forEach((item) { _wishListProducts.add(Wishlist.fromJson(item)); - AppToast.showSuccessToast(message: 'You have added a product to the Wishlist'); }); + AppToast.showSuccessToast(message: 'You have added a product to the Wishlist'); + }, onFailure: (String error, int statusCode) { hasError = true; super.error = error; - AppToast.showErrorToast(message: 'something went wrong please try again'); + AppToast.showErrorToast(message: error??Utils.generateContactAdminMessage()); }, body: request); } @@ -148,7 +153,8 @@ class ProductDetailService extends BaseService { super.error = error; }); } - Future delteItemFromWishlist(itemID) async { + + Future deleteItemFromWishlist(itemID) async { var customerId = await sharedPref.getString(PHARMACY_CUSTOMER_ID); hasError = false; await baseAppClient.getPharmacy(DELETE_WISHLIST+customerId+"+&product_id="+itemID+"&cart_type=Wishlist", @@ -157,9 +163,11 @@ class ProductDetailService extends BaseService { response['shopping_carts'].forEach((item) { _wishListProducts.add(Wishlist.fromJson(item)); }); + AppToast.showSuccessToast(message: 'You have removed a product from the Wishlist'); }, onFailure: (String error, int statusCode) { hasError = true; super.error = error; + AppToast.showErrorToast(message: error??Utils.generateContactAdminMessage()); }); } diff --git a/lib/services/pharmacy_services/review_service.dart b/lib/services/pharmacy_services/review_service.dart index b60ad412..329d52af 100644 --- a/lib/services/pharmacy_services/review_service.dart +++ b/lib/services/pharmacy_services/review_service.dart @@ -28,6 +28,8 @@ class ReviewService extends BaseService { _reviewList.clear(); response['reviews'].forEach((item) { _reviewList.add(Review.fromJson(item)); + print (response); + print (item['reviewText']); }); }, onFailure: (String error, int statusCode) { hasError = true; diff --git a/lib/services/pharmacy_services/wishList_service.dart b/lib/services/pharmacy_services/wishList_service.dart index 78f17401..ce55a40b 100644 --- a/lib/services/pharmacy_services/wishList_service.dart +++ b/lib/services/pharmacy_services/wishList_service.dart @@ -51,9 +51,10 @@ class WishListService extends BaseService { // } Future getWishlist() async { - var customerId = await sharedPref.getString(PHARMACY_CUSTOMER_ID); + //TODO we need to check why the customer id comes null + String customerId = await sharedPref.getString(PHARMACY_CUSTOMER_ID)?? "0"; hasError = false; - await baseAppClient.getPharmacy(GET_WISHLIST+customerId+"?shopping_cart_type=2", + await baseAppClient.getPharmacy(GET_WISHLIST+customerId +"?shopping_cart_type=2", onSuccess: (dynamic response, int statusCode) { _wishListProducts.clear(); response['shopping_carts'].forEach((item) { diff --git a/lib/uitl/translations_delegate_base.dart b/lib/uitl/translations_delegate_base.dart index 3566e95b..ff899765 100644 --- a/lib/uitl/translations_delegate_base.dart +++ b/lib/uitl/translations_delegate_base.dart @@ -1760,6 +1760,8 @@ class TranslationBase { String get referralNumber => localizedValues['referralNumber'][locale.languageCode]; + String get needPrescription => localizedValues['needPrescription'][locale.languageCode]; + String get outOfStockMsg => localizedValues['outOfStockMsg'][locale.languageCode]; String get requestID => localizedValues['requestID'][locale.languageCode]; String get OrderStatus => localizedValues['OrderStatus'][locale.languageCode]; @@ -1797,9 +1799,10 @@ class TranslationBase { String get quantitySize => localizedValues['quantitySize'][locale.languageCode]; String get addToCart => localizedValues['addToCart'][locale.languageCode]; - - String get addToWishlist => localizedValues['addToWishlist'][locale.languageCode]; - + String get addToWishlist => + localizedValues['addToWishlist'][locale.languageCode]; + String get removeFromWishlist => + localizedValues['removeFromWishlist'][locale.languageCode]; String get buyNow => localizedValues['buyNow'][locale.languageCode]; String get quantityShortcut => localizedValues['quantityShortcut'][locale.languageCode]; @@ -2472,6 +2475,9 @@ class TranslationBase { String get Latest => localizedValues["Latest"][locale.languageCode]; String get Tour => localizedValues["Tour"][locale.languageCode]; + String get mostViewed => localizedValues["mostViewed"][locale.languageCode]; + String get newProducts => localizedValues["newProducts"][locale.languageCode]; + } class TranslationBaseDelegate extends LocalizationsDelegate { diff --git a/lib/widgets/buttons/GestureIconButton.dart b/lib/widgets/buttons/GestureIconButton.dart index 841d7ea6..0f035b71 100644 --- a/lib/widgets/buttons/GestureIconButton.dart +++ b/lib/widgets/buttons/GestureIconButton.dart @@ -3,12 +3,12 @@ import 'package:flutter/material.dart'; class GestureIconButton extends StatefulWidget { GestureIconButton( - this.label, - this.icon, { - Key key, - this.onTap, - this.backgroundColor, - }) : super(key: key); + this.label, + this.icon, { + Key key, + this.onTap, + this.backgroundColor, + }) : super(key: key); final String label; final Widget icon; @@ -25,45 +25,48 @@ class _GestureIconButtonState extends State { @override Widget build(BuildContext context) { return GestureDetector( - onLongPressStart: (_) => - setState(() => _buttonLongPress = !_buttonLongPress), - onLongPressEnd: (_) => - setState(() => _buttonLongPress = !_buttonLongPress), - child: Wrap( - children: [ - Container( - decoration: BoxDecoration( - border: Border.all( - color: widget.backgroundColor != null - ? widget.backgroundColor - : Colors.grey[200], + onTap: (){ + setState(() { + _buttonLongPress = !_buttonLongPress; + }); + widget.onTap(); + + }, + // onLongPressStart: (_) => + // setState(() => _buttonLongPress = !_buttonLongPress), + // onLongPressEnd: (_) => + // setState(() => _buttonLongPress = !_buttonLongPress), + child: Container( + decoration: BoxDecoration( + border: Border.all( + color: widget.backgroundColor != null + ? widget.backgroundColor + : Colors.grey[200], + ), + color: widget.backgroundColor != null + ? widget.backgroundColor + : Colors.grey.shade200, + borderRadius: BorderRadius.all(Radius.circular(8))), + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Container( + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + Padding( + padding: const EdgeInsets.only(right: 8.0), + child: widget.icon, ), - color: widget.backgroundColor != null - ? widget.backgroundColor - : Colors.grey.shade200, - borderRadius: BorderRadius.all(Radius.circular(8))), - child: Padding( - padding: const EdgeInsets.all(8.0), - child: Container( - child: Expanded( - child: Row( - mainAxisSize: MainAxisSize.min, - children: [ - Padding( - padding: const EdgeInsets.only(right: 8.0), - child: widget.icon, - ), - Texts( - widget.label, - color: _buttonLongPress ? Colors.white : Colors.black, - ), - ], - ), + Texts( + widget.label, + fontWeight: FontWeight.bold, + fontSize: 13.6, + color: _buttonLongPress ? Colors.white : Colors.black, ), - ), + ], ), ), - ], + ), ), ); } diff --git a/lib/widgets/buttons/secondary_button.dart b/lib/widgets/buttons/secondary_button.dart index 3f6b849b..dadabc71 100644 --- a/lib/widgets/buttons/secondary_button.dart +++ b/lib/widgets/buttons/secondary_button.dart @@ -27,7 +27,10 @@ class SecondaryButton extends StatefulWidget { this.small = false, this.disabled = false, this.borderColor, - this.noBorderRadius = false}) + this.noBorderRadius = false, + this.borderRadius, + this.disableColor, + this.fontWeight}) : super(key: key); final String label; @@ -41,6 +44,10 @@ class SecondaryButton extends StatefulWidget { final bool iconOnly; final bool disabled; final bool noBorderRadius; + final double borderRadius; + final Color disableColor; + final FontWeight fontWeight; + @override _SecondaryButtonState createState() => _SecondaryButtonState(); @@ -167,7 +174,8 @@ class _SecondaryButtonState extends State child: ClipRRect( borderRadius: widget.noBorderRadius ? BorderRadius.all(Radius.circular(0.0)) - : BorderRadius.all(Radius.circular(10.0)), + : BorderRadius.all( + Radius.circular(widget.borderRadius ?? 10.0), ), child: Stack( children: [ Positioned( @@ -178,7 +186,7 @@ class _SecondaryButtonState extends State height: 100, decoration: BoxDecoration( color: widget.disabled - ? Colors.grey + ? widget.disableColor ?? Colors.grey : widget.color ?? Theme.of(context).buttonColor), ), ), @@ -241,6 +249,9 @@ class _SecondaryButtonState extends State color: widget.textColor, fontSize: widget.small ? 12.0 : 14.0, fontWeight: FontWeight.w600, + fontFamily: projectViewModel.isArabic + ? 'Cairo' + : 'WorkSans' ), ), ) diff --git a/lib/widgets/others/StarRating.dart b/lib/widgets/others/StarRating.dart index 5620b21a..74bdbfe3 100644 --- a/lib/widgets/others/StarRating.dart +++ b/lib/widgets/others/StarRating.dart @@ -30,7 +30,7 @@ class StarRating extends StatelessWidget { ) ), if (totalCount!=null) - SizedBox(width: 9.0), + SizedBox(width: 5.0), if (totalCount!=null) Texts("("+totalCount.toString()+")", style: "overline", color: Colors.grey[400],) ] diff --git a/lib/widgets/others/app_scaffold_pharmacy_widget.dart b/lib/widgets/others/app_scaffold_pharmacy_widget.dart index 7f49f441..0d44ec26 100644 --- a/lib/widgets/others/app_scaffold_pharmacy_widget.dart +++ b/lib/widgets/others/app_scaffold_pharmacy_widget.dart @@ -61,7 +61,7 @@ class PharmacyAppScaffold extends StatelessWidget { ), title: Text(authenticatedUserObject.isLogin ? appBarTitle.toUpperCase() - : TranslationBase.of(context).serviceInformationTitle), + : appBarTitle.toUpperCase()), leading: Builder( builder: (BuildContext context) { return ArrowBack(); diff --git a/lib/widgets/others/app_scaffold_widget.dart b/lib/widgets/others/app_scaffold_widget.dart index a0f95c1d..8e9691e1 100644 --- a/lib/widgets/others/app_scaffold_widget.dart +++ b/lib/widgets/others/app_scaffold_widget.dart @@ -4,8 +4,11 @@ import 'package:diplomaticquarterapp/config/config.dart'; import 'package:diplomaticquarterapp/core/model/ImagesInfo.dart'; import 'package:diplomaticquarterapp/core/service/AuthenticatedUserObject.dart'; import 'package:diplomaticquarterapp/core/viewModels/base_view_model.dart'; +import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart'; import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/pages/landing/landing_page.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/screens/cart-page/cart-order-page.dart'; +import 'package:diplomaticquarterapp/routes.dart'; import 'package:diplomaticquarterapp/services/robo_search/event_provider.dart'; import 'package:diplomaticquarterapp/theme/colors.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; @@ -51,6 +54,8 @@ class AppScaffold extends StatelessWidget { final List appBarIcons; final List imagesInfo; final bool isHelp; + final bool isLocalLoader; + final Function backButtonTab; final String icon; final bool showDropDown; final int dropdownIndexValue; @@ -61,6 +66,7 @@ class AppScaffold extends StatelessWidget { AuthenticatedUserObject authenticatedUserObject = locator(); AppBarWidget appBar; + final Widget customAppBar; AppScaffold({ @required this.body, @@ -95,6 +101,10 @@ class AppScaffold extends StatelessWidget { this.dropdownIndexValue, this.dropDownIndexChange, this.onTap, + appBar, + this.customAppBar, + this.isLocalLoader = false, + this.backButtonTab }); AppScaffold setOnAppBarCartClick(VoidCallback onClick) { @@ -123,7 +133,12 @@ class AppScaffold extends StatelessWidget { onTap: onTap, ) : (isShowAppBar - ? appBar = AppBarWidget( + ? + customAppBar != null + ? customAppBar + : + + appBar = AppBarWidget( appBarTitle: appBarTitle, appBarIcons: appBarIcons, showHomeAppBarIcon: showHomeAppBarIcon, @@ -132,6 +147,7 @@ class AppScaffold extends StatelessWidget { isOfferPackages: isOfferPackages, showOfferPackagesCart: showOfferPackagesCart, isShowDecPage: isShowDecPage, + backButtonTab: backButtonTab, ) : null)), bottomSheet: bottomSheet, @@ -163,7 +179,18 @@ class AppScaffold extends StatelessWidget { } buildBodyWidget(context) { - return Stack(children: [body, isHelp == true ? RobotIcon() : Container()]); + return Stack(children: [ + Center( + child: isLoading + ? CircularProgressIndicator( + backgroundColor: Colors.white, + valueColor: AlwaysStoppedAnimation( + Colors.grey[500], + ), + ) + : body), + isHelp == true ? RobotIcon() : Container() + ]); } } @@ -263,6 +290,7 @@ class AppBarWidget extends StatefulWidget with PreferredSizeWidget { final bool showOfferPackagesCart; final bool isShowDecPage; + final Function backButtonTab; Function(String) badgeUpdater; AppBarWidget( @@ -273,6 +301,7 @@ class AppBarWidget extends StatefulWidget with PreferredSizeWidget { this.showPharmacyCart = true, this.isOfferPackages = false, this.showOfferPackagesCart = false, + this.backButtonTab, this.isShowDecPage = true}); @override @@ -285,8 +314,6 @@ class AppBarWidget extends StatefulWidget with PreferredSizeWidget { String _badgeText = "0"; class AppBarWidgetState extends State { - String badgeText = "0"; - @override Widget build(BuildContext context) { widget.badgeUpdater = badgeUpdateBlock; @@ -301,6 +328,8 @@ class AppBarWidgetState extends State { Widget buildAppBar(BuildContext context) { ProjectViewModel projectViewModel = Provider.of(context); + OrderPreviewViewModel orderPreviewViewModel = Provider.of(context); + return AppBar( elevation: 0, backgroundColor: widget.isPharmacy ? Colors.green : Theme.of(context).appBarTheme.color, @@ -311,7 +340,9 @@ class AppBarWidgetState extends State { style: TextStyle(fontWeight: FontWeight.bold, color: Theme.of(context).textTheme.headline1.color, fontFamily: projectViewModel.isArabic ? 'Cairo' : 'WorkSans')), leading: Builder( builder: (BuildContext context) { - return ArrowBack(); + return ArrowBack( + onTap: widget.backButtonTab, + ); }, ), centerTitle: true, @@ -329,8 +360,11 @@ class AppBarWidgetState extends State { icon: Badge( position: BadgePosition.topStart(top: -15, start: -10), badgeContent: Text( - _badgeText, - style: TextStyle(fontSize: 9, color: Colors.white, fontWeight: FontWeight.normal), + orderPreviewViewModel.cartResponse.quantityCount.toString() /*_badgeText*/, + style: TextStyle( + fontSize: 9, + color: Colors.white, + fontWeight: FontWeight.normal), ), child: Icon(Icons.shopping_cart)), color: Colors.white, diff --git a/lib/widgets/others/app_scafold_detail_page.dart b/lib/widgets/others/app_scafold_detail_page.dart index ba729965..e69de29b 100644 --- a/lib/widgets/others/app_scafold_detail_page.dart +++ b/lib/widgets/others/app_scafold_detail_page.dart @@ -1,229 +0,0 @@ -import 'package:diplomaticquarterapp/config/config.dart'; -import 'package:diplomaticquarterapp/config/size_config.dart'; -import 'package:diplomaticquarterapp/core/service/AuthenticatedUserObject.dart'; -import 'package:diplomaticquarterapp/core/viewModels/base_view_model.dart'; -import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; -import 'package:diplomaticquarterapp/pages/insurance/insurance_update_screen.dart'; -import 'package:diplomaticquarterapp/pages/pharmacies/product_detail.dart'; -import 'package:diplomaticquarterapp/pages/pharmacies/screens/cart-order-page.dart'; -import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; -import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; -import 'package:diplomaticquarterapp/widgets/progress_indicator/app_loader_widget.dart'; -import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; -import 'package:flutter/material.dart'; -import 'package:font_awesome_flutter/font_awesome_flutter.dart'; -import 'package:provider/provider.dart'; - -import '../../locator.dart'; -import '../progress_indicator/app_loader_widget.dart'; -import 'network_base_view.dart'; -import 'not_auh_page.dart'; - -class DetailPageScafold extends StatefulWidget { - final String appBarTitle; - final Widget body; - final Widget bottomSheet; - final bool isLoading; - final bool isShowAppBar; - final bool hasAppBarParam; - final BaseViewModel baseViewModel; - final bool isBottomBar; - final Widget floatingActionButton; - final bool isPharmacy; - final String title; - final String description; - final String image; - final bool isShowDecPage; - final List infoList; - final Color backgroundColor; - final double preferredSize; - final List appBarIcons; - final PreferredSizeWidget appBarWidget; - - DetailPageScafold( - {@required this.body, - this.appBarTitle = '', - this.isLoading = false, - this.isShowAppBar = false, - this.hasAppBarParam, - this.bottomSheet, - this.baseViewModel, - this.floatingActionButton, - this.isPharmacy = false, - this.title, - this.description, - this.isShowDecPage = true, - this.isBottomBar, - this.backgroundColor, - this.preferredSize = 0.0, - this.appBarIcons, - this.appBarWidget, - this.image, - this.infoList}); - - @override - _DetailPageScafoldState createState() => _DetailPageScafoldState(); -} - -class _DetailPageScafoldState extends State { - AuthenticatedUserObject authenticatedUserObject = - locator(); - - @override - Widget build(BuildContext context) { - AppGlobal.context = context; - PreferredSizeWidget appBar; - - if (this.widget.appBarWidget == null) { - PreferredSizeWidget appBarWidget = AppBarWidget( - widget.appBarTitle, - widget.appBarIcons, - widget.isShowAppBar, - isPharmacy: widget.isPharmacy, - isShowDecPage: widget.isShowDecPage, - image: widget.image, - ); - appBar = widget.preferredSize == 0 - ? appBarWidget - : PreferredSize( - child: appBarWidget, - preferredSize: Size.fromHeight(widget.preferredSize)); - } else { - appBar = this.widget.appBarWidget; - } - - return Scaffold( - backgroundColor: - widget.backgroundColor ?? Theme.of(context).scaffoldBackgroundColor, - appBar: appBar, - body: (!Provider.of(context, listen: false).isLogin && - widget.isShowDecPage) - ? NotAutPage( - title: widget.appBarTitle, - description: widget.description, - infoList: widget.infoList, - ) - : widget.baseViewModel != null - ? NetworkBaseView( - child: buildBodyWidget(), - baseViewModel: widget.baseViewModel, - ) - : buildBodyWidget(), - bottomSheet: widget.bottomSheet, - //floatingActionButton: floatingActionButton ?? floatingActionButton, - // bottomNavigationBar: - // this.isBottomBar == true ? BottomBarSearch() : SizedBox() - // floatingActionButton: FloatingSearchButton(), - ); - } - - buildAppLoaderWidget(bool isLoading) { - return isLoading ? AppLoaderWidget() : Container(); - } - - buildBodyWidget() { - // return body; //Stack(children: [body, buildAppLoaderWidget(isLoading)]); - return Stack(children: [ - widget.body, /*FloatingSearchButton()*/ - ]); - } -} - -class AppBarWidget extends StatelessWidget with PreferredSizeWidget { - final AuthenticatedUserObject authenticatedUserObject = - locator(); - - final String appBarTitle; - final List appBarIcons; - final bool isShowAppBar; - final bool isPharmacy; - final bool isShowDecPage; - final String image; - - AppBarWidget(this.appBarTitle, this.appBarIcons, this.isShowAppBar, - {this.isPharmacy = true, this.isShowDecPage = true, this.image}); - - @override - Widget build(BuildContext context) { - return buildAppBar(context); - } - - Widget buildAppBar(BuildContext context) { - return isShowAppBar - ? AppBar( - elevation: 0, - backgroundColor: Colors.white, -// isPharmacy ? Colors.green : Theme.of(context).appBarTheme.color, - textTheme: TextTheme( - headline6: - TextStyle(color: Colors.white, fontWeight: FontWeight.bold), - ), - title: Texts( - authenticatedUserObject.isLogin || !isShowDecPage - ? appBarTitle.toUpperCase() - : TranslationBase.of(context).serviceInformationTitle, - color: Colors.white, - bold: true, - ), - leading: Builder( - builder: (BuildContext context) { - return GestureDetector( - behavior: HitTestBehavior.opaque, - onTap: () => Navigator.pop(context), - child: Icon(Icons.arrow_back_ios, color: Colors.grey), - ); - }, - ), - centerTitle: true, - actions: [ - isPharmacy - ? IconButton( - icon: Icon(Icons.shopping_cart), - color: Colors.grey, - onPressed: () { - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => CartOrderPage()), - ); -// Navigator.of(context) -// .popUntil(ModalRoute.withName('/')); - }) - : Container(), - image != null - ? InkWell( - onTap: () => Navigator.push( - context, - FadePage( - page: InsuranceUpdate(), - ), - ), - child: Padding( - padding: const EdgeInsets.all(8.0), - child: Image.asset( - image, - height: SizeConfig.heightMultiplier * 5, - width: SizeConfig.heightMultiplier * 5, - color: Colors.grey, - ), - ), - ) - : IconButton( - icon: Icon(FontAwesomeIcons.ellipsisV), - color: Colors.grey, - onPressed: () { - settingModalBottomSheet(context); - }, - ), - if (appBarIcons != null) ...appBarIcons - ], - ) - : Container( - height: 0, - width: 0, - ); - } - - @override - Size get preferredSize => Size(double.maxFinite, 60); -} diff --git a/lib/widgets/others/network_base_view.dart b/lib/widgets/others/network_base_view.dart index 13c4ff16..402a550b 100644 --- a/lib/widgets/others/network_base_view.dart +++ b/lib/widgets/others/network_base_view.dart @@ -8,8 +8,10 @@ import 'package:flutter/material.dart'; class NetworkBaseView extends StatefulWidget { final BaseViewModel baseViewModel; final Widget child; + final bool isLocalLoader; + final bool isLoading; - NetworkBaseView({Key key, this.baseViewModel, this.child}); + NetworkBaseView({Key key, this.baseViewModel, this.child, this.isLocalLoader = false, this.isLoading}); @override _NetworkBaseViewState createState() => _NetworkBaseViewState(); @@ -29,7 +31,14 @@ class _NetworkBaseViewState extends State{ @override Widget build(BuildContext context) { return Container( - child: buildBaseViewWidget(), + child: (widget.baseViewModel!=null ) ?buildBaseViewWidget():Center( + child:widget.isLoading? CircularProgressIndicator( + backgroundColor: Colors.white, + valueColor: AlwaysStoppedAnimation( + Colors.grey[500], + ), + ):widget.child, + ) , ); } @@ -41,7 +50,19 @@ class _NetworkBaseViewState extends State{ return widget.child; break; case ViewState.Busy: - return Container( + if(widget.isLocalLoader) + return Container( + height: 100, + child: Center( + child:CircularProgressIndicator( + backgroundColor: Colors.white, + valueColor: AlwaysStoppedAnimation( + Colors.grey[500], + ), + ), + ), + ); + else return Container( height: MediaQuery.of(context).size.height, child: Stack( diff --git a/lib/widgets/pharmacy/bottom_nav_pharmacy_bar.dart b/lib/widgets/pharmacy/bottom_nav_pharmacy_bar.dart index bccd288e..d1490d74 100644 --- a/lib/widgets/pharmacy/bottom_nav_pharmacy_bar.dart +++ b/lib/widgets/pharmacy/bottom_nav_pharmacy_bar.dart @@ -1,4 +1,5 @@ - +import 'package:diplomaticquarterapp/d_q_icons_icons.dart'; +import 'package:diplomaticquarterapp/pages/landing/home_page.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:eva_icons_flutter/eva_icons_flutter.dart'; import 'package:flutter/material.dart'; @@ -17,8 +18,6 @@ class BottomNavPharmacyBar extends StatefulWidget { } class _BottomNavPharmacyBarState extends State { - int _index = 0; - _changeIndex(int index) { widget.changeIndex(index); } @@ -43,63 +42,36 @@ class _BottomNavPharmacyBarState extends State { currentIndex: 0, title: TranslationBase.of(context).Alhabibapp, ), - - Container( - height: 65.0, - child: Center( - child: VerticalDivider( - color: Colors.grey, - thickness: 0.5, - width: 0.3, - indent: 25.5, - ), - ), - ), - BottomNavPharmacyItem( - icon: EvaIcons.list, - activeIcon: EvaIcons.list, + icon: DQIcons.categories_menu_icon, + activeIcon: DQIcons.categories_menu_icon, changeIndex: _changeIndex, index: widget.index, currentIndex: 1, title: TranslationBase.of(context).categorise, ), -// Expanded( -// child: SizedBox( -// height: 50, -// child: Column( -// mainAxisSize: MainAxisSize.min, -// mainAxisAlignment: MainAxisAlignment.center, -// children: [ -// SizedBox(height: 22), -// ], -// ), -// ), -// ), - - // Added Calendar Icon to access book appointment flow BottomNavPharmacyItem( - icon: EvaIcons.heart, - activeIcon: EvaIcons.heart, + icon: EvaIcons.home, + activeIcon: EvaIcons.home, changeIndex: _changeIndex, index: widget.index, - currentIndex: 2, - title: TranslationBase.of(context).wishList), - + currentIndex: 0, + isHome: true, + title: TranslationBase.of(context).home), BottomNavPharmacyItem( - icon: EvaIcons.person, - activeIcon: EvaIcons.person, + icon: DQIcons.user_menu_icon, + activeIcon: DQIcons.user_menu_icon, changeIndex: _changeIndex, index: widget.index, - currentIndex: 3, + currentIndex: 2, title: TranslationBase.of(context).myAccount, ), BottomNavPharmacyItem( - icon: EvaIcons.shoppingCart, - activeIcon: EvaIcons.shoppingCart, + icon: DQIcons.cart_menu_icon, + activeIcon: DQIcons.cart_menu_icon, changeIndex: _changeIndex, index: widget.index, - currentIndex: 4, + currentIndex: 3, title: TranslationBase.of(context).cart) ], ), diff --git a/lib/widgets/pharmacy/bottom_nav_pharmacy_home_item.dart b/lib/widgets/pharmacy/bottom_nav_pharmacy_home_item.dart index 77ce71be..f26c4917 100644 --- a/lib/widgets/pharmacy/bottom_nav_pharmacy_home_item.dart +++ b/lib/widgets/pharmacy/bottom_nav_pharmacy_home_item.dart @@ -59,16 +59,16 @@ class BottomNavHomeItem extends StatelessWidget { Container( child: Image.asset( 'assets/images/habib-logo.png', - height: 35.0, ), + height: 22.0, ), SizedBox( - height: 11, + height: 9, ), Texts( title, - textAlign: TextAlign.center, - color: currentIndex == index ? secondaryColor : Colors.grey, + textAlign: TextAlign.start, + color: currentIndex == index ? Colors.grey : Colors.grey, fontSize: 11, ), // Added TextAlign Property diff --git a/lib/widgets/pharmacy/bottom_nav_pharmacy_item.dart b/lib/widgets/pharmacy/bottom_nav_pharmacy_item.dart index 47ff1b23..ff0cac32 100644 --- a/lib/widgets/pharmacy/bottom_nav_pharmacy_item.dart +++ b/lib/widgets/pharmacy/bottom_nav_pharmacy_item.dart @@ -1,6 +1,15 @@ import 'package:diplomaticquarterapp/Constants.dart'; +import 'package:diplomaticquarterapp/core/model/pharmacies/ShoppingCartResponse.dart'; +import 'package:diplomaticquarterapp/core/service/parmacyModule/order-preview-service.dart'; +import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart'; +import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; +import 'package:diplomaticquarterapp/pages/login/welcome.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; +import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; + +import '../../locator.dart'; class BottomNavPharmacyItem extends StatelessWidget { final String title; @@ -10,6 +19,7 @@ class BottomNavPharmacyItem extends StatelessWidget { final int index; final int currentIndex; final Function onTap; + final bool isHome; final IconData activeIcon; BottomNavPharmacyItem( @@ -19,54 +29,103 @@ class BottomNavPharmacyItem extends StatelessWidget { this.currentIndex, this.activeIcon, this.title, - this.onTap}); + this.onTap, + this.isHome = false}); @override Widget build(BuildContext context) { + OrderPreviewViewModel orderPreviewViewModel = Provider.of(context); + ProjectViewModel projectViewModel = Provider.of(context); + return Expanded( child: SizedBox( // height: 72.0, - child: Material( - type: MaterialType.transparency, - child: InkWell( - highlightColor: Colors.transparent, - splashColor: Colors.transparent, - onTap: () => changeIndex(currentIndex), - child: Column( - mainAxisSize: MainAxisSize.min, - mainAxisAlignment: MainAxisAlignment.center, - children: [ - SizedBox( - height: 15, - ), - currentIndex == index - ? Divider( - color: Color(0xff5AB145), - thickness: 3.5, - ) - : Divider( - thickness: 0, - ), - Container( - child: Icon(currentIndex == index ? activeIcon : icon, - color: - currentIndex == index ? secondaryColor : Colors.grey, - size: 22.0), - ), - SizedBox( - height: 11, - ), + child: Stack( + clipBehavior: Clip.none, + children: [ + Material( + type: MaterialType.transparency, + child: InkWell( + highlightColor: Colors.transparent, + splashColor: Colors.transparent, + onTap: () { + if (!Provider.of(context, listen: false) + .isLogin && + (currentIndex == 2 || currentIndex == 3)) + Navigator.push( + context, + FadePage(page: WelcomeLogin()), + ); + else + changeIndex(currentIndex); + }, + child: Column( + mainAxisSize: MainAxisSize.min, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + SizedBox( + height: 15, + ), + currentIndex == index + ? Divider( + color: Color(0xff5AB145), + thickness: 3.5, + ) + : Divider( + thickness: 0, + ), + Container( + child: Icon(currentIndex == index ? activeIcon : icon, + color: isHome + ? Color(0xff5AB145) + : currentIndex == index + ? Colors.grey + : Colors.grey, + size: 22.0), + ), + SizedBox( + height: 11, + ), - // Added TextAlign Property - Texts( - title, - textAlign: TextAlign.center, - color: currentIndex == index ? secondaryColor : Colors.grey, - fontSize: 11, + // Added TextAlign Property + Texts( + title, + textAlign: TextAlign.center, + color: currentIndex == index ? Colors.grey : Colors.grey, + fontWeight: currentIndex == index + ? FontWeight.bold + : FontWeight.w400, + fontSize: currentIndex == index ? 13 : 11, + ), + ], ), - ], + ), ), - ), + if (currentIndex == 3 && + Provider.of(context, listen: false) + .cartResponse + .quantityCount != + 0) + Positioned( + top: 11.5, + right: -4.5, + child: Container( + decoration: BoxDecoration( + color: Colors.red, + borderRadius: BorderRadius.circular(15), + ), + padding: EdgeInsets.only(left: 7, right: 6.5), + height: 18, + child: Center( + child: Texts( + orderPreviewViewModel.cartResponse.quantityCount.toString(), + style: "caption", + medium: true, + color: Colors.white, + )), + ), + ) + ], ), ), ); diff --git a/lib/widgets/pharmacy/my_account_items.dart b/lib/widgets/pharmacy/my_account_items.dart new file mode 100644 index 00000000..bb514e57 --- /dev/null +++ b/lib/widgets/pharmacy/my_account_items.dart @@ -0,0 +1,50 @@ +import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter_svg/flutter_svg.dart'; + +class AccountItem extends StatelessWidget { + final String title; + final String itemIcon; + final bool isTerms; + + const AccountItem({this.title, this.itemIcon, this.isTerms = false}); + + @override + Widget build(BuildContext context) { + return Row( + children: [ + isTerms == false + ? Container( + height: 35.0, + width: 35.0, + child: SvgPicture.asset( + '$itemIcon', + width: 35, + height: 35, + ), + ) + : Container( + height: 35.0, + width: 35.0, + child: Image.asset( + '$itemIcon', + width: 35, + height: 35, + ), + ), + Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + SizedBox( + width: 20, + ), + Texts( + title, + fontSize: 15.0, + ), + ], + ) + ], + ); + } +} diff --git a/lib/widgets/pharmacy/my_account_services.dart b/lib/widgets/pharmacy/my_account_services.dart new file mode 100644 index 00000000..e3b9948d --- /dev/null +++ b/lib/widgets/pharmacy/my_account_services.dart @@ -0,0 +1,52 @@ +import 'package:diplomaticquarterapp/uitl/app_toast.dart'; +import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; +import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_svg/flutter_svg.dart'; + +class AccountServices extends StatelessWidget { + final String title; + final String serviceImage; + final Function onTap; + + const AccountServices({this.title, this.onTap, this.serviceImage}); + + @override + Widget build(BuildContext context) { + return Expanded( + child: InkWell( + onTap: onTap, + // () { + // if (customerId == null) { + // AppToast.showErrorToast( + // message: "Customer not found"); + // return; + // } + // Navigator.push( + // context, + // FadePage( + // page: OrderPage( + // customerID: customerId))); + // }, + child: Column( + children: [ +// Image(image: AssetImage('assets/images/pharmacy/orders_icon.svg')), + SvgPicture.asset( + '$serviceImage', + width: 55, + height: 55, + ), + SizedBox( + height: 7, + ), + Texts( + title, + fontSize: 15.0, + fontWeight: FontWeight.bold, + ), + ], + ), + ), + ); + } +} diff --git a/lib/widgets/pharmacy/product_tile.dart b/lib/widgets/pharmacy/product_tile.dart index 595c8620..405a417c 100644 --- a/lib/widgets/pharmacy/product_tile.dart +++ b/lib/widgets/pharmacy/product_tile.dart @@ -1,6 +1,6 @@ import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/product_detail_view_model.dart'; -import 'package:diplomaticquarterapp/pages/pharmacies/screens/cart-order-page.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/screens/cart-page/cart-order-page.dart'; import 'package:diplomaticquarterapp/pages/pharmacy/order/ProductReview.dart'; import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';