Pharmacy fixes

merge-requests/481/head
haroon amjad 4 years ago
parent 925e3cb686
commit 8d6278a59b

@ -144,12 +144,12 @@ class OrderPreviewService extends BaseService {
return Future.value(localRes);
}
Future getLacumAccountInformation() async {
Future getLacumAccountInformation(String identificationNo) async {
hasError = false;
super.error = "";
Map<String, dynamic> body = Map();
body['IdentificationNo'] = user.patientIdentificationNo;
body['IdentificationNo'] = identificationNo;
try {
await baseAppClient.post(GET_LACUM_ACCOUNT_INFORMATION,
@ -164,12 +164,12 @@ class OrderPreviewService extends BaseService {
}
}
Future getLacumGroupInformation() async {
Future getLacumGroupInformation(String identificationNo) async {
hasError = false;
super.error = "";
Map<String, dynamic> body = Map();
body['IdentificationNo'] = user.patientIdentificationNo;
body['IdentificationNo'] = identificationNo;
body['AccountNumber'] = "${lacumInformation.yahalaAccountNo}";
try {

@ -161,25 +161,25 @@ class OrderPreviewViewModel extends BaseViewModel {
return _orderService.getPaymentOptionName(paymentOption);
}
getInformationsByAddress() async {
await getLacumAccountInformation();
getInformationsByAddress(String identificationNo) async {
await getShippingOption();
await getLacumAccountInformation(identificationNo);
}
getLacumAccountInformation() async {
getLacumAccountInformation(String identificationNo) async {
setState(ViewState.Busy);
await _orderService.getLacumAccountInformation();
await _orderService.getLacumAccountInformation(identificationNo);
if (_orderService.hasError) {
error = _orderService.error;
setState(ViewState.Error);
} else {
getLacumGroupData();
getLacumGroupData(identificationNo);
}
}
Future getLacumGroupData() async {
Future getLacumGroupData(String identificationNo) async {
setState(ViewState.Busy);
await _orderService.getLacumGroupInformation();
await _orderService.getLacumGroupInformation(identificationNo);
paymentCheckoutData.lacumInformation = _orderService.lacumGroupInformation;
paymentCheckoutData.usedLakumPoints = paymentCheckoutData
.lacumInformation.lakumInquiryInformationObjVersion.pointsBalanceAmount;

@ -40,7 +40,7 @@ class _ClinicPackagesPageState extends State<ClinicPackagesPage> with AfterLayo
if(viewModel.service.customer != null) {
var request = AddProductToCartRequestModel(product_id: product.id, customer_id: viewModel.service.customer.id);
await viewModel.service.addProductToCart(request, context: context).then((response){
appScaffold.appBar.badgeUpdater(viewModel.service.cartItemCount);
// appScaffold.appBar.badgeUpdater(viewModel.service.cartItemCount);
}).catchError((error) {
utils.Utils.showErrorToast(error);
});
@ -50,7 +50,7 @@ class _ClinicPackagesPageState extends State<ClinicPackagesPage> with AfterLayo
@override
void afterFirstLayout(BuildContext context) async{
appScaffold.appBar.badgeUpdater(viewModel.service.cartItemCount);
// appScaffold.appBar.badgeUpdater(viewModel.service.cartItemCount);
}
@override

@ -96,7 +96,7 @@ class _PackagesHomePageState extends State<PackagesHomePage> with AfterLayoutMix
if(viewModel.service.customer != null) {
var request = AddProductToCartRequestModel(product_id: product.id, customer_id: viewModel.service.customer.id);
await viewModel.service.addProductToCart(request, context: context).then((response){
appScaffold.appBar.badgeUpdater(viewModel.service.cartItemCount);
// appScaffold.appBar.badgeUpdater(viewModel.service.cartItemCount);
}).catchError((error) {
utils.Utils.showErrorToast(error.toString());
});

@ -105,8 +105,8 @@ class _CartOrderPageState extends State<CartOrderPage> {
.shoppingCarts[index])
.then((value) {
if (model.state != ViewState.Error) {
appScaffold.appBar.badgeUpdater(
'${value.quantityCount ?? 0}');
// appScaffold.appBar.badgeUpdater(
// '${value.quantityCount ?? 0}');
}
if (model.state ==
ViewState.ErrorLocal) {
@ -119,8 +119,8 @@ class _CartOrderPageState extends State<CartOrderPage> {
.shoppingCarts[index])
.then((value) {
if (model.state != ViewState.Error) {
appScaffold.appBar.badgeUpdater(
'${value.quantityCount ?? 0}');
// appScaffold.appBar.badgeUpdater(
// '${value.quantityCount ?? 0}');
}
});
}))

@ -89,7 +89,7 @@ class PaymentBottomWidget extends StatelessWidget {
message:
"Order has been placed successfully!!");
openPayment(
model.orderListModel[0], model.user);
model.orderListModel[0], model.authenticatedUserObject.user);
} else {
AppToast.showErrorToast(message: model.error);
}

@ -37,14 +37,14 @@ class SelectAddressWidget extends StatefulWidget {
class _SelectAddressWidgetState extends State<SelectAddressWidget> {
AddressInfo address;
_navigateToAddressPage() {
_navigateToAddressPage(String identificationNo) {
Navigator.push(context, FadePage(page: PharmacyAddressesPage()))
.then((result) {
if (result != null) {
address = result;
widget.model.paymentCheckoutData.address =
Addresses.fromJson(address.toJson());
widget.model.getInformationsByAddress();
widget.model.getInformationsByAddress(identificationNo);
widget.changeMainState();
}
});
@ -66,7 +66,7 @@ class _SelectAddressWidgetState extends State<SelectAddressWidget> {
color: Colors.white,
child: address == null
? InkWell(
onTap: () => {_navigateToAddressPage()},
onTap: () => {_navigateToAddressPage(model.user.patientIdentificationNo)},
child: Container(
margin: EdgeInsets.symmetric(vertical: 12, horizontal: 12),
child: Row(
@ -125,7 +125,7 @@ class _SelectAddressWidgetState extends State<SelectAddressWidget> {
),
),
InkWell(
onTap: () => {_navigateToAddressPage()},
onTap: () => {_navigateToAddressPage(model.authenticatedUserObject.user.patientIdentificationNo)},
child: Texts(
TranslationBase.of(context).changeAddress,
fontSize: 12,

@ -55,7 +55,7 @@ class _PharmacyPageState extends State<PharmacyPage> {
//crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
BannerPager(model),
GridViewButtons(model),
// GridViewButtons(model),
PrescriptionsWidget(),
ShopByBrandWidget(),
RecentlyViewedWidget(),

@ -1,12 +1,7 @@
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/core/enum/viewstate.dart';
import 'package:diplomaticquarterapp/pages/pharmacies/screens/cart-order-page.dart';
import 'package:diplomaticquarterapp/pages/pharmacies/compare-list.dart';
import 'package:diplomaticquarterapp/pages/pharmacies/screens/cart-page/cart-order-page.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';
@ -16,7 +11,6 @@ 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/material.dart';
import 'availability_info.dart';
@ -108,8 +102,8 @@ class __ProductDetailPageState extends State<ProductDetailPage> {
deleteFromWishlistFunction: () async {
await deleteFromWishlistFunction(itemID: itemID, model: model);
},
isInWishList:isInWishList,
addToCartFunction:addToCartFunction ,
isInWishList: isInWishList,
addToCartFunction: addToCartFunction,
),
body: SingleChildScrollView(
child: Column(
@ -127,8 +121,7 @@ class __ProductDetailPageState extends State<ProductDetailPage> {
fit: BoxFit.contain,
),
),
if (widget.product.discountDescription != null)
DiscountDescription(product: widget.product)
if (widget.product.discountDescription != null) DiscountDescription(product: widget.product)
],
),
),
@ -146,15 +139,11 @@ class __ProductDetailPageState extends State<ProductDetailPage> {
setState(() {});
},
deleteFromWishlistFunction: (item) {
deleteFromWishlistFunction(
itemID: item, model: model);
deleteFromWishlistFunction(itemID: item, model: model);
setState(() {});
},
notifyMeWhenAvailable: (context, itemId) {
notifyMeWhenAvailable(
itemId: itemId,
customerId: customerId,
model: model);
notifyMeWhenAvailable(itemId: itemId, customerId: customerId, model: model);
},
isInWishList: isInWishList,
),
@ -169,8 +158,7 @@ class __ProductDetailPageState extends State<ProductDetailPage> {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
padding: EdgeInsets.symmetric(
vertical: 15, horizontal: 10),
padding: EdgeInsets.symmetric(vertical: 15, horizontal: 10),
child: Texts(
TranslationBase.of(context).specification,
fontSize: 15,
@ -207,16 +195,12 @@ class __ProductDetailPageState extends State<ProductDetailPage> {
},
child: Text(
TranslationBase.of(context).details,
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold),
style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold),
),
color: Colors.white,
),
CustomDivider(
color: isDetails
? Colors.green
: Colors.transparent,
color: isDetails ? Colors.green : Colors.transparent,
)
],
),
@ -227,14 +211,10 @@ class __ProductDetailPageState extends State<ProductDetailPage> {
children: [
FlatButton(
onPressed: () async {
if (widget.product.approvedTotalReviews >
0) {
GifLoaderDialogUtils.showMyDialog(
context);
await model.getProductReviewsData(
widget.product.id);
GifLoaderDialogUtils.hideDialog(
context);
if (widget.product.approvedTotalReviews > 0) {
GifLoaderDialogUtils.showMyDialog(context);
await model.getProductReviewsData(widget.product.id);
GifLoaderDialogUtils.hideDialog(context);
} else {
model.clearReview();
}
@ -246,16 +226,12 @@ class __ProductDetailPageState extends State<ProductDetailPage> {
},
child: Text(
TranslationBase.of(context).reviews,
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold),
style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold),
),
color: Colors.white,
),
CustomDivider(
color: isReviews
? Colors.green
: Colors.transparent,
color: isReviews ? Colors.green : Colors.transparent,
),
],
),
@ -266,8 +242,7 @@ class __ProductDetailPageState extends State<ProductDetailPage> {
children: [
FlatButton(
onPressed: () async {
GifLoaderDialogUtils.showMyDialog(
context);
GifLoaderDialogUtils.showMyDialog(context);
await model.getProductLocationData();
GifLoaderDialogUtils.hideDialog(context);
@ -279,16 +254,12 @@ class __ProductDetailPageState extends State<ProductDetailPage> {
},
child: Text(
TranslationBase.of(context).availability,
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold),
style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold),
),
color: Colors.white,
),
CustomDivider(
color: isAvailability
? Colors.green
: Colors.transparent,
color: isAvailability ? Colors.green : Colors.transparent,
),
],
),
@ -317,12 +288,16 @@ class __ProductDetailPageState extends State<ProductDetailPage> {
SizedBox(
height: 10,
),
RecommendedProducts(product: widget.product,productDetailViewModel: model,
RecommendedProducts(
product: widget.product,
productDetailViewModel: model,
addToWishlistFunction: (itemID) async {
await addToWishlistFunction(itemID: itemID, model: model);
}, deleteFromWishlistFunction: (itemID) async {
await addToWishlistFunction(itemID: itemID, model: model);
},
deleteFromWishlistFunction: (itemID) async {
await deleteFromWishlistFunction(itemID: itemID, model: model);
},)
},
)
],
),
),
@ -340,9 +315,9 @@ class __ProductDetailPageState extends State<ProductDetailPage> {
),
));
}
addToShoppingCartFunction({quantity,itemID,ProductDetailViewModel model})async{
await model.addToCartData(quantity,itemID);
addToShoppingCartFunction({quantity, itemID, ProductDetailViewModel model}) async {
await model.addToCartData(quantity, itemID);
}
addToWishlistFunction({itemID, ProductDetailViewModel model}) async {
@ -356,20 +331,18 @@ class __ProductDetailPageState extends State<ProductDetailPage> {
await model.deleteWishlistData(itemID);
setState(() {});
}
addToCartFunction(
{quantity,
itemID,
ProductDetailViewModel model,
}) async {
addToCartFunction({
quantity,
itemID,
ProductDetailViewModel model,
}) async {
GifLoaderDialogUtils.showMyDialog(context);
await model.addToCartData(quantity, itemID);
GifLoaderDialogUtils.hideDialog(context);
}
}
notifyMeWhenAvailable(
{itemId, customerId, ProductDetailViewModel model}) async {
notifyMeWhenAvailable({itemId, customerId, ProductDetailViewModel model}) async {
await model.notifyMe(customerId, itemId);
}

@ -36,7 +36,7 @@ class PrescriptionsWidget extends StatelessWidget {
ViewAllHomeWidget(TranslationBase.of(context).myPrescription, HomePrescriptionsPage()),
Container(
margin: EdgeInsets.only(right: 10.0, left: 10.0),
height: MediaQuery.of(context).size.height * 0.28,
height: MediaQuery.of(context).size.height * 0.18,
child: ListView.builder(
scrollDirection: Axis.horizontal,
shrinkWrap: true,

@ -12,13 +12,8 @@ import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/OrderPreview
import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart';
import 'package:diplomaticquarterapp/pages/landing/landing_page.dart';
import 'package:diplomaticquarterapp/pages/landing/landing_page_pharmcy.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/screens/product-details/product-detail.dart';
import 'package:diplomaticquarterapp/pages/pharmacy/profile/profile.dart';
import 'package:diplomaticquarterapp/pages/pharmacy_categorise.dart';
import 'package:diplomaticquarterapp/pages/search_products_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/app_toast.dart';
@ -27,7 +22,6 @@ import 'package:diplomaticquarterapp/uitl/navigation_service.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/uitl/utils_new.dart';
import 'package:diplomaticquarterapp/widgets/data_display/text.dart';
import 'package:diplomaticquarterapp/widgets/others/bottom_bar.dart';
import 'package:diplomaticquarterapp/widgets/pharmacy/bottom_nav_pharmacy_bar.dart';
import 'package:diplomaticquarterapp/widgets/progress_indicator/app_loader_widget.dart';
import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart';
@ -45,8 +39,6 @@ import 'not_auh_page.dart';
VoidCallback _onCartClick;
class AppScaffold extends StatefulWidget {
AppBarWidget appBar;
final String appBarTitle;
final Widget body;
final Widget bottomSheet;
@ -60,11 +52,9 @@ class AppScaffold extends StatefulWidget {
final bool isBottomBar;
final Widget floatingActionButton;
final bool isPharmacy;
final bool isMainPharmacyPages;
final bool isOfferPackages;
final bool showPharmacyCart;
final bool showOfferPackagesCart;
final bool extendBody;
final String title;
final String description;
final bool isShowDecPage;
@ -83,13 +73,12 @@ class AppScaffold extends StatefulWidget {
List<String> dropDownList;
final Function(int) dropDownIndexChange;
Function onTap;
final bool isMainPharmacyPages;
final bool extendBody;
final ValueChanged<int> changeCurrentTab;
AuthenticatedUserObject authenticatedUserObject = locator<AuthenticatedUserObject>();
final Widget customAppBar;
final int currentTab;
final bool isShowPharmacyAppbar;
final Widget customAppBar;
AppScaffold setOnAppBarCartClick(VoidCallback onClick) {
_onCartClick = onClick;
@ -103,17 +92,17 @@ class AppScaffold extends StatefulWidget {
this.isShowAppBar = false,
this.showNewAppBar = false,
this.showNewAppBarTitle = false,
this.isMainPharmacyPages = false,
this.extendBody = false,
this.hasAppBarParam,
this.bottomSheet,
this.bottomNavigationBar,
this.baseViewModel,
this.floatingActionButton,
this.isPharmacy = false,
this.isMainPharmacyPages = false,
this.showPharmacyCart = true,
this.isOfferPackages = false,
this.showOfferPackagesCart = false,
this.extendBody = false,
this.title,
this.description,
this.isShowDecPage = true,
@ -145,9 +134,11 @@ class AppScaffold extends StatefulWidget {
class _AppScaffoldState extends State<AppScaffold> {
AuthenticatedUserObject authenticatedUserObject = locator<AuthenticatedUserObject>();
AppBarWidget appBar;
@override
void initState() {
// TODO: implement initState
super.initState();
}
@ -218,66 +209,87 @@ class _AppScaffoldState extends State<AppScaffold> {
@override
Widget build(BuildContext context) {
PharmacyPagesViewModel pagesViewModel = Provider.of(context);
AppGlobal.context = context;
PharmacyPagesViewModel pagesViewModel = Provider.of(context);
bool isUserNotLogin = (!Provider.of<ProjectViewModel>(context, listen: false).isLogin && isShowDecPage);
bool isUserNotLogin = (!Provider.of<ProjectViewModel>(context, listen: false).isLogin && widget.isShowDecPage);
return Scaffold(
backgroundColor: backgroundColor ?? CustomColors.appBackgroudGrey2Color,
backgroundColor: widget.backgroundColor ?? CustomColors.appBackgroudGrey2Color,
// appBar: widget.isShowPharmacyAppbar
// ? pharmacyAppbar()
// : widget.isShowAppBar
// ? widget.customAppBar != null
// ? widget.customAppBar
appBar: isUserNotLogin
? null
: (widget.isShowPharmacyAppbar
: widget.isShowPharmacyAppbar
? pharmacyAppbar()
: showNewAppBar
: (widget.showNewAppBar
? NewAppBarWidget(
title: appBarTitle,
showTitle: showNewAppBarTitle,
showDropDown: showDropDown,
dropdownIndexValue: dropdownIndexValue,
dropDownList: dropDownList ?? [],
dropDownIndexChange: dropDownIndexChange,
appBarIcons: appBarIcons,
onTap: onTap,
title: widget.appBarTitle,
showTitle: widget.showNewAppBarTitle,
showDropDown: widget.showDropDown,
dropdownIndexValue: widget.dropdownIndexValue,
dropDownList: widget.dropDownList ?? [],
dropDownIndexChange: widget.dropDownIndexChange,
appBarIcons: widget.appBarIcons,
onTap: widget.onTap,
)
: (isShowAppBar
? customAppBar != null
? customAppBar
: (widget.isShowAppBar
? widget.customAppBar != null
? widget.customAppBar
: appBar = AppBarWidget(
appBarTitle: appBarTitle,
appBarIcons: appBarIcons,
showHomeAppBarIcon: showHomeAppBarIcon,
isPharmacy: isPharmacy,
showPharmacyCart: showPharmacyCart,
isOfferPackages: isOfferPackages,
showOfferPackagesCart: showOfferPackagesCart,
isShowDecPage: isShowDecPage,
backButtonTab: backButtonTab,
appBarTitle: widget.appBarTitle,
appBarIcons: widget.appBarIcons,
showHomeAppBarIcon: widget.showHomeAppBarIcon,
isPharmacy: widget.isPharmacy,
showPharmacyCart: widget.showPharmacyCart,
isOfferPackages: widget.isOfferPackages,
showOfferPackagesCart: widget.showOfferPackagesCart,
isShowDecPage: widget.isShowDecPage,
backButtonTab: widget.backButtonTab,
)
: null)),
bottomSheet: bottomSheet,
bottomSheet: widget.bottomSheet,
body: SafeArea(
top: true,
bottom: true,
child: isUserNotLogin
? NotAutPage(
title: title ?? appBarTitle,
description: description,
infoList: infoList,
imagesInfo: imagesInfo,
icon: icon,
title: widget.title ?? widget.appBarTitle,
description: widget.description,
infoList: widget.infoList,
imagesInfo: widget.imagesInfo,
icon: widget.icon,
)
: baseViewModel != null
: widget.baseViewModel != null
? NetworkBaseView(
child: buildBodyWidget(context),
baseViewModel: baseViewModel,
baseViewModel: widget.baseViewModel,
)
: buildBodyWidget(context),
),
bottomNavigationBar: bottomNavigationBar,
floatingActionButton: floatingActionButton,
bottomNavigationBar: widget.isBottomBar
? BottomNavPharmacyBar(
changeIndex: changeCurrentTab,
index: widget.currentTab,
)
: null,
floatingActionButton: widget.floatingActionButton,
);
}
void changeCurrentTab(int value) {
if (widget.isMainPharmacyPages) {
widget.changeCurrentTab(value);
} else {
Navigator.pushAndRemoveUntil(
locator<NavigationService>().navigatorKey.currentContext, MaterialPageRoute(builder: (context) => LandingPagePharmacy(currentTab: value)), (Route<dynamic> r) => false);
}
}
void _scanQrAndGetProduct() async {
try {
String result = await BarcodeScanner.scan();
@ -304,7 +316,7 @@ class _AppScaffoldState extends State<AppScaffold> {
}
buildBodyWidget(context) {
return Stack(children: <Widget>[body, isHelp == true ? RobotIcon() : Container()]);
return Stack(children: <Widget>[widget.body, widget.isHelp == true ? RobotIcon() : Container()]);
}
}

@ -7,14 +7,10 @@ import 'bottom_nav_pharmacy_item.dart';
class BottomNavPharmacyBar extends StatefulWidget {
final ValueChanged<int> changeIndex;
final int index;
BottomNavPharmacyBar({Key key, this.changeIndex, this.index}) : super(key: key);
int index = 0;
BottomNavPharmacyBar({Key key, this.changeIndex, this.index})
: super(key: key);
@override
_BottomNavPharmacyBarState createState() => _BottomNavPharmacyBarState();
}

Loading…
Cancel
Save