Merge branch 'development' of https://gitlab.com/Cloud_Solution/diplomatic-quarter into product_detail_page

 Conflicts:
	lib/pages/pharmacies/screens/product-details/product-name-and-price.dart
merge-update-with-lab-changes
Elham Rababh 4 years ago
commit 145117aa63

@ -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(),
],
),
), ),
), ),
), ),

@ -20,8 +20,6 @@ import 'discount_description.dart';
import 'footor/footer-widget.dart'; import 'footor/footer-widget.dart';
import 'shared/product_details_app_bar.dart'; import 'shared/product_details_app_bar.dart';
String itemID; String itemID;
PharmacyProduct specificationData; PharmacyProduct specificationData;
@ -339,6 +337,4 @@ addToCartFunction({quantity, itemID, BuildContext context,ProductDetailViewModel
notifyMeWhenAvailable({itemId, customerId,ProductDetailViewModel model }) async { notifyMeWhenAvailable({itemId, customerId,ProductDetailViewModel model }) async {
await model.notifyMe(customerId, itemId); await model.notifyMe(customerId, itemId);
} }

@ -95,10 +95,10 @@ 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,352 +0,0 @@
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/core/viewModels/project_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/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/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;
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<RecommendedProducts> {
@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(
color: Colors.white,
height: 210,
margin: EdgeInsets.only(bottom: 75),
padding: EdgeInsets.only(bottom: 5),
// margin: EdgeInsets.symmetric(horizontal: 6, vertical: 4),
child: BaseView<PharmacyModuleViewModel>(
onModelReady: (model) =>
model.getRecommendedProducts(widget.product.id),
builder: (_, model, wi) => Container(
child: 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.customerId != null) {
if (!widget.isInWishList &&
model
.recommendedProductList[
index]
.isinwishlist !=
true) {
GifLoaderDialogUtils
.showMyDialog(context);
await widget.addToWishlistFunction(
itemID: model
.recommendedProductList[
index]
.id,
model: widget
.productDetailViewModel);
// checkWishlist();
GifLoaderDialogUtils
.hideDialog(context);
setState(() {
model
.recommendedProductList[
index]
.isinwishlist = true;
});
} else {
GifLoaderDialogUtils
.showMyDialog(context);
await widget.deleteFromWishlistFunction(
itemID: model
.recommendedProductList[
index]
.id,
model: widget
.productDetailViewModel);
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: <Widget>[
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,
),
],
),
),
),
),
),
],
),
),
);
}
}
Loading…
Cancel
Save