fix bugs pharmacy wishlist

merge-update-with-lab-changes
mosazaid 5 years ago
parent 0d2d4c64c2
commit a41980b252

@ -13,15 +13,16 @@ class PrescriptionViewModel extends BaseViewModel {
_prescriptionService.prescriptionsList; _prescriptionService.prescriptionsList;
getPrescription() async { getPrescription() async {
setState(ViewState.Busy);
await getSavedLanguage(); await getSavedLanguage();
await _prescriptionService.getPrescription(); if(prescriptionsList.isNotEmpty){
if (_prescriptionService.hasError) { setState(ViewState.Busy);
error = _prescriptionService.error; await _prescriptionService.getPrescription();
setState(ViewState.Error); if (_prescriptionService.hasError) {
} else { error = _prescriptionService.error;
setState(ViewState.Idle); setState(ViewState.Error);
} else {
setState(ViewState.Idle);
}
} }
} }
} }

@ -5,6 +5,8 @@ import 'package:diplomaticquarterapp/models/pharmacy/locationModel.dart';
import 'package:diplomaticquarterapp/models/pharmacy/productDetailModel.dart'; import 'package:diplomaticquarterapp/models/pharmacy/productDetailModel.dart';
import 'package:diplomaticquarterapp/services/pharmacy_services/product_detail_service.dart'; import 'package:diplomaticquarterapp/services/pharmacy_services/product_detail_service.dart';
import 'package:diplomaticquarterapp/models/pharmacy/specification.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 '../../../locator.dart'; import '../../../locator.dart';
@ -69,8 +71,13 @@ class ProductDetailViewModel extends BaseViewModel{
Future addToWishlistData(itemID) async { Future addToWishlistData(itemID) async {
hasError = false; hasError = false;
setState(ViewState.Busy); setState(ViewState.BusyLocal);
GifLoaderDialogUtils.showMyDialog(
locator<NavigationService>().navigatorKey.currentContext);
await _productDetailService.addToWishlist(itemID); await _productDetailService.addToWishlist(itemID);
GifLoaderDialogUtils.hideDialog(
locator<NavigationService>().navigatorKey.currentContext);
if (_productDetailService.hasError) { if (_productDetailService.hasError) {
error = _productDetailService.error; error = _productDetailService.error;
setState(ViewState.ErrorLocal); setState(ViewState.ErrorLocal);
@ -92,8 +99,13 @@ class ProductDetailViewModel extends BaseViewModel{
Future deletWishlistData(itemID) async { Future deletWishlistData(itemID) async {
hasError = false; hasError = false;
setState(ViewState.Busy); setState(ViewState.BusyLocal);
GifLoaderDialogUtils.showMyDialog(
locator<NavigationService>().navigatorKey.currentContext);
await _productDetailService.delteItemFromWishlist(itemID); await _productDetailService.delteItemFromWishlist(itemID);
GifLoaderDialogUtils.hideDialog(
locator<NavigationService>().navigatorKey.currentContext);
if (_productDetailService.hasError) { if (_productDetailService.hasError) {
error = _productDetailService.error; error = _productDetailService.error;
setState(ViewState.ErrorLocal); setState(ViewState.ErrorLocal);

@ -49,88 +49,93 @@ class _LandingPagePharmacyState extends State<LandingPagePharmacy> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return WillPopScope(
appBar: currentTab != 4 && currentTab != 3 onWillPop: ()async{
? AppBar( return false;
backgroundColor: Color(0xff5AB145), },
elevation: 0, child: Scaffold(
title: Container( appBar: currentTab != 4 && currentTab != 3
height: MediaQuery.of(context).size.height * 0.056, ? AppBar(
decoration: BoxDecoration( backgroundColor: Color(0xff5AB145),
borderRadius: BorderRadius.circular(5.0), elevation: 0,
color: Colors.white, title: Container(
), height: MediaQuery.of(context).size.height * 0.056,
child: InkWell( decoration: BoxDecoration(
child: Padding( borderRadius: BorderRadius.circular(5.0),
padding: EdgeInsets.all(5.0), color: Colors.white,
child: Row( ),
//crossAxisAlignment: CrossAxisAlignment.center, child: InkWell(
mainAxisAlignment: MainAxisAlignment.start, child: Padding(
children: [ padding: EdgeInsets.all(5.0),
Icon(Icons.search, size: 25.0), child: Row(
SizedBox( //crossAxisAlignment: CrossAxisAlignment.center,
width: 15.0, mainAxisAlignment: MainAxisAlignment.start,
), children: [
Texts( Icon(Icons.search, size: 25.0),
TranslationBase.of(context).searchProductHere, SizedBox(
fontSize: 13, width: 15.0,
) ),
], Texts(
TranslationBase.of(context).searchProductHere,
fontSize: 13,
)
],
),
), ),
onTap: () {
Navigator.push(
context,
FadePage(page: SearchProductsPage()),
);
},
), ),
onTap: () { ),
Navigator.push( leading: Builder(
context, builder: (BuildContext context) {
FadePage(page: SearchProductsPage()), 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: [
leading: Builder( IconButton(
builder: (BuildContext context) { // iconSize: 70,
return InkWell( icon: Image.asset(
onTap: () { 'assets/images/new-design/qr-code.png',
setState(() {
currentTab = 0;
pageController.jumpToPage(0);
});
},
child: Container(
height: 2.0,
width: 10.0,
child: Image.asset(
'assets/images/pharmacy_logo.png',
), ),
), onPressed: _scanQrAndGetProduct //do something,
); )
}, ],
), centerTitle: true,
actions: [ )
IconButton( : null,
// iconSize: 70, extendBody: false,
icon: Image.asset( body: PageView(
'assets/images/new-design/qr-code.png', physics: NeverScrollableScrollPhysics(),
), controller: pageController,
onPressed: _scanQrAndGetProduct //do something, children: [
) PharmacyPage(),
], PharmacyCategorisePage(),
centerTitle: true, PharmacyProfilePage(),
) CartOrderPage(),
: null, ],
extendBody: false, ),
body: PageView( bottomNavigationBar: BottomNavPharmacyBar(
physics: NeverScrollableScrollPhysics(), changeIndex: _changeCurrentTab,
controller: pageController, index: currentTab,
children: [ ),
PharmacyPage(),
PharmacyCategorisePage(),
PharmacyProfilePage(),
CartOrderPage(),
],
),
bottomNavigationBar: BottomNavPharmacyBar(
changeIndex: _changeCurrentTab,
index: currentTab,
), ),
); );
} }

@ -46,31 +46,36 @@ class _PharmacyPageState extends State<PharmacyPage> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return BaseView<PharmacyModuleViewModel>( return WillPopScope(
onModelReady: (model) async { onWillPop: ()async{
await model.getSavedLanguage(); return false;
await model.getBannerList();
}, },
allowAny: true, child: BaseView<PharmacyModuleViewModel>(
builder: (_, model, wi) => AppScaffold( onModelReady: (model) async {
title: "", await model.getSavedLanguage();
isShowAppBar: false, await model.getBannerList();
isShowDecPage: false, },
baseViewModel: model, allowAny: true,
backgroundColor: Colors.white, builder: (_, model, wi) => AppScaffold(
body: Container( title: "",
width: double.infinity, isShowAppBar: false,
child: SingleChildScrollView( isShowDecPage: false,
child: Column( baseViewModel: model,
//crossAxisAlignment: CrossAxisAlignment.start, backgroundColor: Colors.white,
children: <Widget>[ body: Container(
BannerPager(model), width: double.infinity,
GridViewButtons(model), child: SingleChildScrollView(
PrescriptionsWidget(), child: Column(
ShopByBrandWidget(), //crossAxisAlignment: CrossAxisAlignment.start,
RecentlyViewedWidget(), children: <Widget>[
BestSellerWidget(), BannerPager(model),
], GridViewButtons(model),
PrescriptionsWidget(),
ShopByBrandWidget(),
RecentlyViewedWidget(),
BestSellerWidget(),
],
),
), ),
), ),
), ),

@ -1,5 +1,6 @@
import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart'; import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart';
import 'package:diplomaticquarterapp/core/service/AuthenticatedUserObject.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/product-detail.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/product-detail.dart';
import 'package:diplomaticquarterapp/uitl/app_toast.dart'; import 'package:diplomaticquarterapp/uitl/app_toast.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
@ -15,8 +16,9 @@ import 'CustomIcon.dart';
class ProductAppBar extends StatelessWidget with PreferredSizeWidget { class ProductAppBar extends StatelessWidget with PreferredSizeWidget {
final PharmacyProduct product; final PharmacyProduct product;
final ProductDetailViewModel model;
ProductAppBar({Key key, this.product}) : super(key: key); ProductAppBar({Key key, this.product, this.model}) : super(key: key);
AuthenticatedUserObject authenticatedUserObject = AuthenticatedUserObject authenticatedUserObject =
locator<AuthenticatedUserObject>(); locator<AuthenticatedUserObject>();
@ -112,7 +114,7 @@ class ProductAppBar extends StatelessWidget with PreferredSizeWidget {
title: Text( title: Text(
TranslationBase.of(context).addToWishlist, TranslationBase.of(context).addToWishlist,
), ),
onTap: () => {addToWishlistFunction(itemID)}, onTap: () => {model.addToWishlistData(itemID)},
), ),
ListTile( ListTile(
leading: Icon(Icons.compare), leading: Icon(Icons.compare),

@ -1,28 +1,19 @@
import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; import 'package:diplomaticquarterapp/config/shared_pref_kay.dart';
import 'package:diplomaticquarterapp/config/size_config.dart'; import 'package:diplomaticquarterapp/config/size_config.dart';
import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart'; import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.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/pharmacyModule/product_detail_view_model.dart';
import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart';
import 'package:diplomaticquarterapp/pages/base/base_view.dart'; import 'package:diplomaticquarterapp/pages/base/base_view.dart';
import 'package:diplomaticquarterapp/pages/pharmacies/compare-list.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/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/reviews_info.dart';
import 'package:diplomaticquarterapp/uitl/app_toast.dart';
import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart';
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
import 'package:diplomaticquarterapp/widgets/others/app_scafold_detail_page.dart';
import 'package:diplomaticquarterapp/widgets/text/app_texts_widget.dart'; import 'package:diplomaticquarterapp/widgets/text/app_texts_widget.dart';
import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import 'package:rating_bar/rating_bar.dart';
import 'package:diplomaticquarterapp/core/model/pharmacies/recommendedProduct_model.dart';
import '../cart-order-page.dart';
import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart'; import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart';
import 'ProductAppBar.dart'; import 'ProductAppBar.dart';
@ -105,300 +96,307 @@ class __ProductDetailPageState extends State<ProductDetailPage>
ProjectViewModel projectViewModel = Provider.of(context); ProjectViewModel projectViewModel = Provider.of(context);
final screenSize = MediaQuery.of(context).size; final screenSize = MediaQuery.of(context).size;
return AppScaffold( return BaseView<ProductDetailViewModel>(
appBarTitle: TranslationBase.of(context).productDetails, builder: (_, model, wi) => AppScaffold(
isShowAppBar: true, appBarTitle: TranslationBase.of(context).productDetails,
isPharmacy: true, isShowAppBar: true,
isShowDecPage: false, isPharmacy: true,
customAppBar: ProductAppBar(product: widget.product,), baseViewModel: model,
body: SingleChildScrollView( isShowDecPage: false,
child: Column( customAppBar: ProductAppBar(product: widget.product,),
children: [ body: SingleChildScrollView(
Container( child: Column(
width: double.infinity, children: [
color: Colors.white, Container(
child: Column( width: double.infinity,
children: [ color: Colors.white,
if (widget.product.images.isNotEmpty) 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) {
model.addToWishlistData(itemID);
setState(() {
});
},
deleteFromWishlistFunction: (item) {
model.deletWishlistData(itemID);
setState(() {
});
},
notifyMeWhenAvailable: (context, itemId) {
notifyMeWhenAvailable(context, itemId);
},
isInWishList: isInWishList,
),
),
SizedBox(
height: 6,
),
Container(
color: Colors.white,
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container( Container(
height: MediaQuery.of(context).size.height * .40, padding: EdgeInsets.symmetric(
child: Image.network( vertical: 15, horizontal: 10),
widget.product.images[0].src.trim(), child: Texts(
fit: BoxFit.contain, TranslationBase.of(context).specification,
fontSize: 15,
fontWeight: FontWeight.bold,
), ),
width: double.infinity,
), ),
if (widget.product.discountDescription != null) // Divider(color: Colors.grey),
DiscountDescription(product: widget.product) ],
], ),
), ),
), SizedBox(
SizedBox( height: 6,
height: 4,
),
Container(
color: Colors.white,
child: ProductNameAndPrice(
context,
widget.product,
customerId: customerId,
addToWishlistFunction: (item) {
addToWishlistFunction(item);
setState(() {});
},
deleteFromWishlistFunction: (item) {
deleteFromWishlistFunction(item);
setState(() {});
},
notifyMeWhenAvailable: (context, itemId) {
notifyMeWhenAvailable(context, itemId);
},
isInWishList: isInWishList,
), ),
), // Container(
SizedBox( // height: 500,
height: 6, // color: Colors.white,
), // child: Scaffold(
Container( // backgroundColor: Colors.white,
color: Colors.white, // extendBodyBehindAppBar: false,
child: Column( // appBar: PreferredSize(
mainAxisAlignment: MainAxisAlignment.start, // preferredSize: Size.fromHeight(
crossAxisAlignment: CrossAxisAlignment.start, // MediaQuery.of(context).size.height * 0.070),
children: [ // child: Container(
Container( // height: MediaQuery.of(context).size.height * 0.070,
padding: EdgeInsets.symmetric( // decoration: BoxDecoration(
vertical: 15, horizontal: 10), // border: Border(
child: Texts( // bottom: BorderSide(
TranslationBase.of(context).specification, // color: Theme.of(context).dividerColor,
fontSize: 15, // width: 0.5), //width: 0.7
fontWeight: FontWeight.bold, // ),
), // color: Colors.white),
width: double.infinity, // child: Center(
), // child: TabBar(
// Divider(color: Colors.grey), // isScrollable: false,
], // controller: _tabController,
// // indicatorColor: Colors.transparent,
// indicatorWeight: 1.0,
// indicatorSize: TabBarIndicatorSize.tab,
// indicatorColor:Colors.green,
// labelColor: Theme.of(context).primaryColor,
// labelPadding: EdgeInsets.only(
// top: 0, left: 0, right: 0, bottom: 0),
// unselectedLabelColor: Colors.grey[800],
// tabs: [
// tabWidget(screenSize, _activeTab == 0,
// TranslationBase.of(context).details,
// ),
// tabWidget(screenSize, _activeTab == 1,
// TranslationBase.of(context).review,
// ),
// tabWidget(screenSize, _activeTab == 2,
// TranslationBase.of(context).availability),
// ],
// ),
// ),
// ),
// ),
// body: Column(
// children: [
// Expanded(
// child: TabBarView(
// physics: BouncingScrollPhysics(),
// controller: _tabController,
// children: [
// DetailsInfo(
// product: widget.product,
// ),
// ReviewsInfo(
// product: widget.product,
// ),
// AvailabilityInfo()
// ],
// ),
// ),
//
// ],
// ),
// ),
// ),
SizedBox(
height: 6,
), ),
),
SizedBox( //TODO Elham* Remove this
height: 6, Container(
), // width: 500,
// Container( margin: EdgeInsets.only(bottom: 6),
// height: 500, color: Colors.white,
// color: Colors.white, child: Column(
// child: Scaffold( crossAxisAlignment: CrossAxisAlignment.start,
// backgroundColor: Colors.white, children: [
// extendBodyBehindAppBar: false, Row(
// appBar: PreferredSize( mainAxisAlignment: MainAxisAlignment.spaceEvenly,
// preferredSize: Size.fromHeight( children: [
// MediaQuery.of(context).size.height * 0.070), Column(
// child: Container( children: [
// height: MediaQuery.of(context).size.height * 0.070, FlatButton(
// decoration: BoxDecoration( onPressed: () {
// border: Border( setState(() {
// bottom: BorderSide( isDetails = true;
// color: Theme.of(context).dividerColor, isReviews = false;
// width: 0.5), //width: 0.7 isAvailability = false;
// ), });
// color: Colors.white), },
// child: Center( child: Text(
// child: TabBar( TranslationBase.of(context).details,
// isScrollable: false, style: TextStyle(
// controller: _tabController, fontSize: 16,
// // indicatorColor: Colors.transparent, fontWeight: FontWeight.bold),
// indicatorWeight: 1.0, ),
// indicatorSize: TabBarIndicatorSize.tab, color: Colors.white,
// indicatorColor:Colors.green,
// labelColor: Theme.of(context).primaryColor,
// labelPadding: EdgeInsets.only(
// top: 0, left: 0, right: 0, bottom: 0),
// unselectedLabelColor: Colors.grey[800],
// tabs: [
// tabWidget(screenSize, _activeTab == 0,
// TranslationBase.of(context).details,
// ),
// tabWidget(screenSize, _activeTab == 1,
// TranslationBase.of(context).review,
// ),
// tabWidget(screenSize, _activeTab == 2,
// TranslationBase.of(context).availability),
// ],
// ),
// ),
// ),
// ),
// body: Column(
// children: [
// Expanded(
// child: TabBarView(
// physics: BouncingScrollPhysics(),
// controller: _tabController,
// children: [
// DetailsInfo(
// product: widget.product,
// ),
// ReviewsInfo(
// product: widget.product,
// ),
// AvailabilityInfo()
// ],
// ),
// ),
//
// ],
// ),
// ),
// ),
SizedBox(
height: 6,
),
//TODO Elham* Remove this
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
CustomDivider( ? Colors.green
color: isDetails : Colors.transparent,
? Colors.green )
: Colors.transparent, ],
) ),
], SizedBox(
), width: 20,
SizedBox( ),
width: 20, Column(
), children: [
Column( FlatButton(
children: [ onPressed: () {
FlatButton( setState(() {
onPressed: () { isDetails = false;
setState(() { isReviews = true;
isDetails = false; isAvailability = false;
isReviews = true; });
isAvailability = false; },
}); child: Text(
}, TranslationBase.of(context).reviews,
child: Text( style: TextStyle(
TranslationBase.of(context).reviews, fontSize: 16,
style: TextStyle( fontWeight: FontWeight.bold),
fontSize: 16, ),
fontWeight: FontWeight.bold), color: Colors.white,
), ),
color: Colors.white, CustomDivider(
), color: isReviews
CustomDivider( ? Colors.green
color: isReviews : Colors.transparent,
? Colors.green
: Colors.transparent,
),
],
),
SizedBox(
width: 20,
),
Column(
children: [
FlatButton(
onPressed: () {
setState(() {
isDetails = false;
isReviews = false;
isAvailability = true;
});
},
child: Text(
TranslationBase.of(context).availability,
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold),
), ),
color: Colors.white, ],
), ),
CustomDivider( SizedBox(
color: isAvailability width: 20,
? Colors.green ),
: Colors.transparent, Column(
), children: [
], FlatButton(
), onPressed: () {
], setState(() {
), isDetails = false;
SizedBox( isReviews = false;
height: 10, isAvailability = true;
), });
isDetails },
? DetailsInfo( child: Text(
product: widget.product, TranslationBase.of(context).availability,
) style: TextStyle(
: isReviews fontSize: 16,
? ReviewsInfo( fontWeight: FontWeight.bold),
product: widget.product, ),
) color: Colors.white,
: isAvailability ),
? AvailabilityInfo() CustomDivider(
: Container(), color: isAvailability
], ? Colors.green
: Colors.transparent,
),
],
),
],
),
SizedBox(
height: 10,
),
isDetails
? DetailsInfo(
product: widget.product,
)
: isReviews
? ReviewsInfo(
product: widget.product,
)
: isAvailability
? AvailabilityInfo()
: Container(),
],
),
), ),
),
///TODO Elham* check if we need recommanded
///TODO Elham* check if we need recommanded // Row(
// Row( // children: [
// children: [ // customerId != null
// customerId != null // ? Container(
// ? Container( // width: 410,
// width: 410, // height: 50,
// height: 50, // color: Colors.white,
// color: Colors.white, // child: Texts(
// child: Texts( // TranslationBase.of(context).recommended,
// TranslationBase.of(context).recommended, // bold: true,
// bold: true, // ),
// ), // )
// ) // : Container(),
// : Container(), // ],
// ], // ),
// ), // RecommendedProducts(product: widget.product)
// RecommendedProducts(product: widget.product)
SizedBox(
SizedBox( height: 80,
height: 80, )
) ],
], ),
),
bottomSheet: FooterWidget(
widget.product.stockAvailability != 'Out of stock',
widget.product.orderMaximumQuantity,
widget.product.orderMinimumQuantity,
widget.product.stockQuantity,
widget.product,
price: price,
isOverQuantity: isOverQuantity,
addToCartFunction: addToCartFunction,
), ),
), ),
bottomSheet: FooterWidget( );
widget.product.stockAvailability != 'Out of stock',
widget.product.orderMaximumQuantity,
widget.product.orderMinimumQuantity,
widget.product.stockQuantity,
widget.product,
price: price,
isOverQuantity: isOverQuantity,
addToCartFunction: addToCartFunction,
),
);
} }
} }
@ -443,13 +441,8 @@ notifyMeWhenAvailable(context, itemId) async {
await x.notifyMe(customerId, itemId); await x.notifyMe(customerId, itemId);
} }
addToWishlistFunction(itemID) async {
ProductDetailViewModel x = new ProductDetailViewModel();
isInWishList = true;
await x.addToWishlistData(itemID);
}
deleteFromWishlistFunction(itemID) async { deleteFromWishlistFunction(itemID) async {
ProductDetailViewModel x = new ProductDetailViewModel(); ProductDetailViewModel x = new ProductDetailViewModel();
isInWishList = false; isInWishList = false;
await x.deletWishlistData(itemID); await x.deletWishlistData(itemID);

@ -93,10 +93,8 @@ class _ProductNameAndPriceState extends State<ProductNameAndPrice> {
{ {
if (widget.customerId != null) { if (widget.customerId != null) {
if (!widget.isInWishList) { if (!widget.isInWishList) {
GifLoaderDialogUtils.showMyDialog(context);
await widget await widget
.addToWishlistFunction(widget.item.id); .addToWishlistFunction(widget.item.id);
GifLoaderDialogUtils.hideDialog(context);
} else { } else {
await widget await widget
.deleteFromWishlistFunction(widget.item.id); .deleteFromWishlistFunction(widget.item.id);

@ -1,6 +1,7 @@
import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart'; import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart';
import 'package:diplomaticquarterapp/core/model/pharmacies/recommendedProduct_model.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/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/core/viewModels/project_view_model.dart';
import 'package:diplomaticquarterapp/pages/base/base_view.dart'; import 'package:diplomaticquarterapp/pages/base/base_view.dart';
import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/product-detail.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/product-detail.dart';
@ -14,8 +15,9 @@ import 'package:rating_bar/rating_bar.dart';
class RecommendedProducts extends StatefulWidget { class RecommendedProducts extends StatefulWidget {
final PharmacyProduct product; final PharmacyProduct product;
final ProductDetailViewModel productDetailModel;
const RecommendedProducts({Key key, this.product}) : super(key: key); const RecommendedProducts({Key key, this.product, this.productDetailModel}) : super(key: key);
@override @override
_RecommendedProductsState createState() => _RecommendedProductsState(); _RecommendedProductsState createState() => _RecommendedProductsState();
@ -146,7 +148,7 @@ class _RecommendedProductsState extends State<RecommendedProducts> {
true) { true) {
GifLoaderDialogUtils.showMyDialog( GifLoaderDialogUtils.showMyDialog(
context); context);
await addToWishlistFunction(model await widget.productDetailModel.addToWishlistData(model
.recommendedProductList[index] .recommendedProductList[index]
.id); .id);
// checkWishlist(); // checkWishlist();

@ -3,6 +3,7 @@ import 'package:diplomaticquarterapp/config/size_config.dart';
import 'package:diplomaticquarterapp/config/size_config.dart'; import 'package:diplomaticquarterapp/config/size_config.dart';
import 'package:diplomaticquarterapp/core/service/AuthenticatedUserObject.dart'; import 'package:diplomaticquarterapp/core/service/AuthenticatedUserObject.dart';
import 'package:diplomaticquarterapp/core/viewModels/base_view_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/base_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/core/viewModels/project_view_model.dart';
import 'package:diplomaticquarterapp/pages/insurance/insurance_update_screen.dart'; import 'package:diplomaticquarterapp/pages/insurance/insurance_update_screen.dart';
import 'package:diplomaticquarterapp/pages/landing/landing_page.dart'; import 'package:diplomaticquarterapp/pages/landing/landing_page.dart';
@ -261,7 +262,7 @@ class AppBarWidget extends StatelessWidget with PreferredSizeWidget {
title: Text( title: Text(
TranslationBase.of(context).addToWishlist, TranslationBase.of(context).addToWishlist,
), ),
onTap: () => {addToWishlistFunction(itemID)}, onTap: () => {locator<ProductDetailViewModel>().addToWishlistData(itemID)},
), ),
ListTile( ListTile(
leading: Icon(Icons.compare), leading: Icon(Icons.compare),

Loading…
Cancel
Save