From f3462dfc193d5c7f9d4776d5c20faad2dc4a74cc Mon Sep 17 00:00:00 2001 From: Zohaib Iqbal Kambrani <> Date: Tue, 26 Oct 2021 17:05:02 +0300 Subject: [PATCH] Applied cost from api at cart --- android/app/build.gradle | 3 ++ .../cloud/diplomaticquarterapp/Application.kt | 26 +++++++++++++- .../diplomaticquarterapp/opentok/OpenTok.kt | 4 ++- .../app/src/main/res/layout/local_video.xml | 14 ++++++++ .../app/src/main/res/layout/remote_video.xml | 20 +++++++++++ ios/Podfile.lock | 12 +++++++ lib/config/config.dart | 14 ++++++++ .../PackagesOffersServices.dart | 7 ++-- lib/pages/landing/home_page.dart | 3 +- .../OfferAndPackagesCartPage.dart | 26 ++++++++++---- .../offers_packages/PackagesCartItemCard.dart | 34 +++++++++++-------- 11 files changed, 137 insertions(+), 26 deletions(-) create mode 100644 android/app/src/main/res/layout/local_video.xml create mode 100644 android/app/src/main/res/layout/remote_video.xml diff --git a/android/app/build.gradle b/android/app/build.gradle index f13bce1b..25230849 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -112,5 +112,8 @@ dependencies { implementation "com.opentok.android:opentok-android-sdk:2.19.1" + compile 'com.facebook.stetho:stetho:1.5.1' + implementation 'com.facebook.stetho:stetho-urlconnection:1.5.1' + } diff --git a/android/app/src/main/kotlin/com/cloud/diplomaticquarterapp/Application.kt b/android/app/src/main/kotlin/com/cloud/diplomaticquarterapp/Application.kt index 0708653a..a9c5ea88 100644 --- a/android/app/src/main/kotlin/com/cloud/diplomaticquarterapp/Application.kt +++ b/android/app/src/main/kotlin/com/cloud/diplomaticquarterapp/Application.kt @@ -1,16 +1,40 @@ //package com.cloud.diplomaticquarterapp package com.ejada.hmg +import com.facebook.stetho.Stetho import io.flutter.app.FlutterApplication import io.flutter.plugin.common.PluginRegistry import io.flutter.plugin.common.PluginRegistry.PluginRegistrantCallback -import io.flutter.plugins.GeneratedPluginRegistrant import io.flutter.plugins.firebasemessaging.FlutterFirebaseMessagingService class Application : FlutterApplication(), PluginRegistrantCallback { override fun onCreate() { super.onCreate() FlutterFirebaseMessagingService.setPluginRegistrant(this) + +// Stetho.initializeWithDefaults(this); + // Create an InitializerBuilder + // Create an InitializerBuilder + val initializerBuilder = Stetho.newInitializerBuilder(this) + + + // Enable Chrome DevTools + initializerBuilder.enableWebKitInspector( + Stetho.defaultInspectorModulesProvider(this) + ) + + // Enable command line interface + initializerBuilder.enableDumpapp( + Stetho.defaultDumperPluginsProvider(this) + ) + + + // Use the InitializerBuilder to generate an Initializer + val initializer = initializerBuilder.build() + + + // Initialize Stetho with the Initializer + Stetho.initialize(initializer) } override fun registerWith(registry: PluginRegistry) { diff --git a/android/app/src/main/kotlin/com/cloud/diplomaticquarterapp/opentok/OpenTok.kt b/android/app/src/main/kotlin/com/cloud/diplomaticquarterapp/opentok/OpenTok.kt index 0cdc3751..d53d6f9a 100644 --- a/android/app/src/main/kotlin/com/cloud/diplomaticquarterapp/opentok/OpenTok.kt +++ b/android/app/src/main/kotlin/com/cloud/diplomaticquarterapp/opentok/OpenTok.kt @@ -5,8 +5,10 @@ import android.os.Handler import android.os.Looper import android.util.Log import android.view.ViewGroup +import com.facebook.stetho.urlconnection.StethoURLConnectionManager import com.opentok.android.* import io.flutter.embedding.engine.FlutterEngine +import io.flutter.embedding.engine.plugins.util.GeneratedPluginRegister import io.flutter.plugin.common.MethodCall import io.flutter.plugin.common.MethodChannel @@ -21,7 +23,7 @@ enum class OpenTokSDKState { class OpenTok(private var context: Context, private var flutterEngine: FlutterEngine){ private lateinit var remoteVideoPlatformView: RemoteVideoPlatformView private lateinit var localVideoPlatformView: LocalVideoPlatformView - + init { remoteVideoPlatformView = RemoteVideoFactory.getViewInstance(context) flutterEngine diff --git a/android/app/src/main/res/layout/local_video.xml b/android/app/src/main/res/layout/local_video.xml new file mode 100644 index 00000000..f47c48cd --- /dev/null +++ b/android/app/src/main/res/layout/local_video.xml @@ -0,0 +1,14 @@ + + + + + \ No newline at end of file diff --git a/android/app/src/main/res/layout/remote_video.xml b/android/app/src/main/res/layout/remote_video.xml new file mode 100644 index 00000000..cfdbeb0d --- /dev/null +++ b/android/app/src/main/res/layout/remote_video.xml @@ -0,0 +1,20 @@ + + + + + + + \ No newline at end of file diff --git a/ios/Podfile.lock b/ios/Podfile.lock index 549f5592..565b2db9 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -450,6 +450,10 @@ PODS: - TOCropViewController (~> 2.5.4) - image_picker (0.0.1): - Flutter + - in_app_review (0.2.0): + - Flutter + - in_app_update (0.0.1): + - Flutter - just_audio (0.0.1): - Flutter - leveldb-library (1.22) @@ -579,6 +583,8 @@ DEPENDENCIES: - huawei_map (from `.symlinks/plugins/huawei_map/ios`) - image_cropper (from `.symlinks/plugins/image_cropper/ios`) - image_picker (from `.symlinks/plugins/image_picker/ios`) + - in_app_review (from `.symlinks/plugins/in_app_review/ios`) + - in_app_update (from `.symlinks/plugins/in_app_update/ios`) - just_audio (from `.symlinks/plugins/just_audio/ios`) - local_auth (from `.symlinks/plugins/local_auth/ios`) - location (from `.symlinks/plugins/location/ios`) @@ -719,6 +725,10 @@ EXTERNAL SOURCES: :path: ".symlinks/plugins/image_cropper/ios" image_picker: :path: ".symlinks/plugins/image_picker/ios" + in_app_review: + :path: ".symlinks/plugins/in_app_review/ios" + in_app_update: + :path: ".symlinks/plugins/in_app_update/ios" just_audio: :path: ".symlinks/plugins/just_audio/ios" local_auth: @@ -843,6 +853,8 @@ SPEC CHECKSUMS: huawei_map: 34fbad9c274ea78a4151487c9ebe27f1887777e7 image_cropper: c8f9b4157933c7bb965a66d1c5e6c8fd408c6eb4 image_picker: 9c3312491f862b28d21ecd8fdf0ee14e601b3f09 + in_app_review: 4a97249f7a2f539a0f294c2d9196b7fe35e49541 + in_app_update: 16e877e205f4360264cb536e3a6481f0d90299e1 just_audio: baa7252489dbcf47a4c7cc9ca663e9661c99aafa leveldb-library: 55d93ee664b4007aac644a782d11da33fba316f7 Libyuv: 5f79ced0ee66e60a612ca97de1e6ccacd187a437 diff --git a/lib/config/config.dart b/lib/config/config.dart index c1622769..37450066 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -102,6 +102,18 @@ const GET_PICK_UP_REQUEST_BY_PRES_ORDER_ID = 'Services/Patients.svc/REST/Patient const UPDATE_PRESS_ORDER = 'Services/Patients.svc/REST/PatientER_UpdatePresOrder'; const INSERT_ER_INERT_PRES_ORDER = 'Services/Patients.svc/REST/PatientER_InsertPresOrder'; +// HHC RC SERVICES +const HHC_GET_ALL_SERVICES_RC = "rc/api/HHC/getallhhc"; +const ADD_HHC_ORDER_RC = "rc/api/HHC/add"; +const GET_ALL_HHC_ORDERS_RC = 'rc/api/hhc/list'; +const UPDATE_HHC_ORDER_RC = 'rc/api/hhc/update'; + + +// RRT RC SERVICES +const ADD_RRT_ORDER_RC = 'rc/api/rrt/add'; +const GET_ALL_RRT_ORDERS_RC = 'rc/api/rrt/list'; +const UPDATE_RRT_ORDER_RC = 'rc/api/rrt/update'; + /// ER RRT const GET_ALL_RC_TRANSPORTATION = 'rc/api/Transportation/getalltransportation'; const GET_ALL_TRANSPORTATIONS_RC = 'rc/api/Transportation/getalltransportation'; @@ -443,6 +455,8 @@ const ADD_USER_AGREEMENT_FOR_BLOOD_DONATION = 'Services/PatientVarification.svc/ // CMC RC SERVICES const GET_ALL_CMC_SERVICES_RC = 'rc/api/cmc/getallcmc'; const ADD_CMC_ORDER_RC = 'rc/api/cmc/add'; +const GET_ALL_CMC_ORDERS_RC = 'rc/api/cmc/list'; +const UPDATE_CMC_ORDER_RC = 'rc/api/cmc/update'; //Pharmacy wishlist const GET_WISHLIST = "shopping_cart_items/"; diff --git a/lib/core/service/packages_offers/PackagesOffersServices.dart b/lib/core/service/packages_offers/PackagesOffersServices.dart index dbc32029..46e042a4 100644 --- a/lib/core/service/packages_offers/PackagesOffersServices.dart +++ b/lib/core/service/packages_offers/PackagesOffersServices.dart @@ -224,16 +224,17 @@ class OffersAndPackagesServices extends BaseService { // -------------------- // Shopping Cart // -------------------- - Future> cartItems({@required BuildContext context, bool showLoading = true}) async{ + Future> cartItems({@required BuildContext context, bool showLoading = true}) async{ Future errorThrow; cartItemList.clear(); _showLoading(context, showLoading); var url = EXA_CART_API_BASE_URL + PACKAGES_SHOPPING_CART + '/${customer.id}'; + Map jsonResponse; await baseAppClient.simpleGet(url, headers: packagesAuthHeader, onSuccess: (dynamic stringResponse, int statusCode) { _hideLoading(context, showLoading); - var jsonResponse = json.decode(stringResponse); + jsonResponse = json.decode(stringResponse); jsonResponse['shopping_carts'].forEach((json) { cartItemList.add(PackagesCartItemsResponseModel.fromJson(json)); }); @@ -244,7 +245,7 @@ class OffersAndPackagesServices extends BaseService { errorThrow = Future.error({"error":error, "statusCode":statusCode}); }, queryParams: null); - return errorThrow ?? cartItemList; + return errorThrow ?? jsonResponse; } Future> addProductToCart(AddProductToCartRequestModel request, {@required BuildContext context, bool showLoading = true}) async{ diff --git a/lib/pages/landing/home_page.dart b/lib/pages/landing/home_page.dart index 07958a7d..0f010169 100644 --- a/lib/pages/landing/home_page.dart +++ b/lib/pages/landing/home_page.dart @@ -421,7 +421,8 @@ class _HomePageState extends State { padding: const EdgeInsets.only(bottom: 15, right: 15, left: 15), child: InkWell( onTap: () { - Navigator.of(context).push(MaterialPageRoute(builder: (context) => PackagesHomePage())); + final user = projectViewModel.user; + Navigator.of(context).push(MaterialPageRoute(builder: (context) => PackagesHomePage(user))); }, child: Container( decoration: BoxDecoration( diff --git a/lib/pages/packages_offers/OfferAndPackagesCartPage.dart b/lib/pages/packages_offers/OfferAndPackagesCartPage.dart index 727cea23..5ef0a968 100644 --- a/lib/pages/packages_offers/OfferAndPackagesCartPage.dart +++ b/lib/pages/packages_offers/OfferAndPackagesCartPage.dart @@ -36,6 +36,8 @@ class _PackagesCartPageState extends State languageID = await sharedPref.getString(APP_LANGUAGE); } + double subtotal,tax, total; + @override void initState() { _agreeTerms = false; @@ -145,6 +147,9 @@ class _PackagesCartPageState extends State .catchError((error) { utils.Utils.showErrorToast(error); }); + if(response.status){ + fetchData(); + } return response.status ?? false; }, )); @@ -186,7 +191,7 @@ class _PackagesCartPageState extends State height: 0.25, color: Colors.grey[300], ), - _payNow(context, onPayNowClick: onPayNowClick) + _payNow(context, subtotal: subtotal, tax: tax, total: total, onPayNowClick: onPayNowClick) ], ), ) @@ -197,7 +202,12 @@ class _PackagesCartPageState extends State } fetchData() async { - await viewModel.service.cartItems(context: context).catchError((error) {}); + await viewModel.service.cartItems(context: context).then((value){ + subtotal = value['subtotal'] ?? 0.0; + tax = value['tax'] ?? 0.0; + total = value['total'] ?? 0.0; + }).catchError((error) {}); + setState(() {}); } @@ -335,9 +345,13 @@ Widget _termsAndCondition(BuildContext context, ); } -Widget _payNow(BuildContext context, {@required VoidCallback onPayNowClick}) { +Widget _payNow(BuildContext context, {double subtotal, double tax, double total, @required VoidCallback onPayNowClick}) { bool isPayNowAQctive = (_agreeTerms && (_selectedPaymentMethod != null)); + String _subtotal = (subtotal ?? 0.0).toStringAsFixed(2); + String _tax = (tax ?? 0.0).toStringAsFixed(2); + String _total = (total ?? 0).toStringAsFixed(2); + return Padding( padding: const EdgeInsets.all(5), child: Container( @@ -350,13 +364,13 @@ Widget _payNow(BuildContext context, {@required VoidCallback onPayNowClick}) { crossAxisAlignment: CrossAxisAlignment.start, children: [ Texts( - '${TranslationBase.of(context).subtotal}: ${'999.9'} ${TranslationBase.of(context).sar}', + '${TranslationBase.of(context).subtotal}: $_subtotal ${TranslationBase.of(context).sar}', heightFactor: 1.5, fontWeight: FontWeight.bold, color: Colors.grey, fontSize: 8), Texts( - '${TranslationBase.of(context).vat}: ${'14.9'} ${TranslationBase.of(context).sar}', + '${TranslationBase.of(context).vat}: $_tax ${TranslationBase.of(context).sar}', heightFactor: 1.5, fontWeight: FontWeight.bold, color: Colors.grey, @@ -370,7 +384,7 @@ Widget _payNow(BuildContext context, {@required VoidCallback onPayNowClick}) { ), ), Texts( - '${TranslationBase.of(context).total}: 999.99 ${TranslationBase.of(context).sar}', + '${TranslationBase.of(context).total}: $_total ${TranslationBase.of(context).sar}', heightFactor: 1.5, fontWeight: FontWeight.bold, color: Colors.black54, diff --git a/lib/widgets/offers_packages/PackagesCartItemCard.dart b/lib/widgets/offers_packages/PackagesCartItemCard.dart index c59c08cd..ddca9d90 100644 --- a/lib/widgets/offers_packages/PackagesCartItemCard.dart +++ b/lib/widgets/offers_packages/PackagesCartItemCard.dart @@ -77,16 +77,16 @@ class PackagesCartItemCardState extends State { ), ), - Positioned( - bottom: 8, - left: 10, - child: Row( - children: [ - _totalLabel(context: context), - _totalPrice((widget.itemModel.product.price * widget.itemModel.quantity), context: context), - ], - ), - ) + // Positioned( + // bottom: 8, + // left: 10, + // child: Row( + // children: [ + // _totalLabel(context: context), + // _totalPrice((widget.itemModel.product.price * widget.itemModel.quantity), context: context), + // ], + // ), + // ) ], ) ) @@ -136,15 +136,18 @@ Widget _itemName(String name) => Padding( ); -Widget _itemPrice(double price, {@required BuildContext context}) => Padding( +Widget _itemPrice(double price, {@required BuildContext context}) { + final prc = (price ?? 0.0).toStringAsFixed(2); + return Padding( padding: const EdgeInsets.all(0), child: Texts( - '${price} ${TranslationBase.of(context).sar}', + '${prc} ${TranslationBase.of(context).sar}', fontWeight: FontWeight.bold, color: Colors.green, fontSize: 15 ) ); +} // -------------------- @@ -159,16 +162,19 @@ Widget _priceSeperator() => Padding( // -------------------- // Product Price // -------------------- -Widget _itemOldPrice(double oldPrice, {@required BuildContext context}) => Padding( +Widget _itemOldPrice(double oldPrice, {@required BuildContext context}) { + final prc = (oldPrice ?? 0.0).toStringAsFixed(2); + return Padding( padding: const EdgeInsets.all(0), child: Texts( - '${oldPrice} ${TranslationBase.of(context).sar}', + '${prc} ${TranslationBase.of(context).sar}', fontWeight: FontWeight.normal, decoration: TextDecoration.lineThrough, color: Colors.grey, fontSize: 10 ) ); +} // -------------------- // Product Price