Applied cost from api at cart

merge-requests/458/head
Zohaib Iqbal Kambrani 4 years ago
parent d6d85092ee
commit f3462dfc19

@ -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'
}

@ -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) {

@ -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

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:gravity="center_horizontal"
android:layout_gravity="center_horizontal">
<FrameLayout
android:id="@+id/publisher_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FF9800" />
</LinearLayout>

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:gravity="center_horizontal"
android:layout_gravity="center_horizontal">
<FrameLayout
android:id="@+id/subscriber_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#3F51B5" />
<TextView
android:text="Remote"
android:textColor="#FFFFFF"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</LinearLayout>

@ -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

@ -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/";

@ -224,16 +224,17 @@ class OffersAndPackagesServices extends BaseService {
// --------------------
// Shopping Cart
// --------------------
Future<List<PackagesCartItemsResponseModel>> cartItems({@required BuildContext context, bool showLoading = true}) async{
Future<Map<String,dynamic>> 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<String,dynamic> 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<ResponseModel<PackagesCartItemsResponseModel>> addProductToCart(AddProductToCartRequestModel request, {@required BuildContext context, bool showLoading = true}) async{

@ -421,7 +421,8 @@ class _HomePageState extends State<HomePage> {
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(

@ -36,6 +36,8 @@ class _PackagesCartPageState extends State<PackagesCartPage>
languageID = await sharedPref.getString(APP_LANGUAGE);
}
double subtotal,tax, total;
@override
void initState() {
_agreeTerms = false;
@ -145,6 +147,9 @@ class _PackagesCartPageState extends State<PackagesCartPage>
.catchError((error) {
utils.Utils.showErrorToast(error);
});
if(response.status){
fetchData();
}
return response.status ?? false;
},
));
@ -186,7 +191,7 @@ class _PackagesCartPageState extends State<PackagesCartPage>
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<PackagesCartPage>
}
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,

@ -77,16 +77,16 @@ class PackagesCartItemCardState extends State<PackagesCartItemCard> {
),
),
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

Loading…
Cancel
Save