Merge branch 'development_new_design_2.0' of https://gitlab.com/Cloud_Solution/diplomatic-quarter into nov_fixes

merge-update-with-lab-changes
Elham Rababh 4 years ago
commit 41097f119c

@ -1,4 +1,5 @@
import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; import 'package:diplomaticquarterapp/config/shared_pref_kay.dart';
import 'package:diplomaticquarterapp/core/enum/viewstate.dart';
import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart'; import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.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/pages/base/base_view.dart'; import 'package:diplomaticquarterapp/pages/base/base_view.dart';
@ -11,6 +12,7 @@ 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/progress_indicator/app_circular_progress_Indeicator.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'availability_info.dart'; import 'availability_info.dart';
@ -87,8 +89,8 @@ class __ProductDetailPageState extends State<ProductDetailPage> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return BaseView<ProductDetailViewModel>( return BaseView<ProductDetailViewModel>(
allowAny: true, allowAny: true,
onModelReady: (model) { onModelReady: (model) async {
model.getProductReviewsData(widget.product.id); await model.getProductReviewsData(widget.product.id).then((value) {});
}, },
builder: (_, model, wi) => AppScaffold( builder: (_, model, wi) => AppScaffold(
appBarTitle: TranslationBase.of(context).productDetails, appBarTitle: TranslationBase.of(context).productDetails,
@ -108,215 +110,219 @@ class __ProductDetailPageState extends State<ProductDetailPage> {
isInWishList: isInWishList, isInWishList: isInWishList,
addToCartFunction: addToCartFunction, addToCartFunction: addToCartFunction,
), ),
body: SingleChildScrollView( body: model.state == ViewState.Idle
child: Column( ? SingleChildScrollView(
children: [
Container(
width: double.infinity,
color: Colors.white,
child: Column( child: Column(
children: [ children: [
if (widget.product.images.isNotEmpty) Container(
Container( width: double.infinity,
height: MediaQuery.of(context).size.height * .40, color: Colors.white,
child: Image.network( child: Column(
widget.product.images[0].src.trim(), children: [
fit: BoxFit.contain, 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)
],
), ),
if (widget.product.discountDescription != null) DiscountDescription(product: widget.product) ),
], SizedBox(
), height: 4,
), ),
SizedBox(
height: 4,
),
Container(
color: Colors.white,
child: ProductNameAndPrice(
context,
widget.product,
customerId: customerId,
addToWishlistFunction: (item) {
addToWishlistFunction(itemID: item, model: model);
setState(() {});
},
deleteFromWishlistFunction: (item) {
deleteFromWishlistFunction(itemID: item, model: model);
setState(() {});
},
notifyMeWhenAvailable: (context, itemId) {
notifyMeWhenAvailable(itemId: itemId, customerId: customerId, model: model);
},
isInWishList: isInWishList,
isStockAvailable: model.isStockAvailable,
),
),
SizedBox(
height: 6,
),
Container(
color: Colors.white,
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container( Container(
padding: EdgeInsets.symmetric(vertical: 15, horizontal: 10), color: Colors.white,
child: Texts( child: ProductNameAndPrice(
TranslationBase.of(context).specification, context,
fontSize: 15, widget.product,
fontWeight: FontWeight.bold, customerId: customerId,
addToWishlistFunction: (item) {
addToWishlistFunction(itemID: item, model: model);
setState(() {});
},
deleteFromWishlistFunction: (item) {
deleteFromWishlistFunction(itemID: item, model: model);
setState(() {});
},
notifyMeWhenAvailable: (context, itemId) {
notifyMeWhenAvailable(itemId: itemId, customerId: customerId, model: model);
},
isInWishList: isInWishList,
isStockAvailable: model.isStockAvailable,
), ),
width: double.infinity,
), ),
// Divider(color: Colors.grey), SizedBox(
], height: 6,
), ),
), Container(
SizedBox( color: Colors.white,
height: 6, child: Column(
), mainAxisAlignment: MainAxisAlignment.start,
Container( crossAxisAlignment: CrossAxisAlignment.start,
// width: 500, children: [
margin: EdgeInsets.only(bottom: 6), Container(
color: Colors.white, padding: EdgeInsets.symmetric(vertical: 15, horizontal: 10),
child: Column( child: Texts(
crossAxisAlignment: CrossAxisAlignment.start, TranslationBase.of(context).specification,
children: [ fontSize: 15,
Row( fontWeight: FontWeight.bold,
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( width: double.infinity,
color: isDetails ? Colors.green : Colors.transparent, ),
) // Divider(color: Colors.grey),
], ],
), ),
SizedBox( ),
width: 20, SizedBox(
), height: 6,
Column( ),
children: [ Container(
FlatButton( // width: 500,
onPressed: () async { margin: EdgeInsets.only(bottom: 6),
if (widget.product.approvedTotalReviews > 0) { color: Colors.white,
GifLoaderDialogUtils.showMyDialog(context); child: Column(
await model.getProductReviewsData(widget.product.id); crossAxisAlignment: CrossAxisAlignment.start,
GifLoaderDialogUtils.hideDialog(context); children: [
} else { Row(
model.clearReview(); mainAxisAlignment: MainAxisAlignment.spaceEvenly,
} children: [
setState(() { Column(
isDetails = false; children: [
isReviews = true; FlatButton(
isAvailability = false; onPressed: () {
}); setState(() {
}, isDetails = true;
child: Text( isReviews = false;
TranslationBase.of(context).reviews, isAvailability = false;
style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold), });
},
child: Text(
TranslationBase.of(context).details,
style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold),
),
color: Colors.white,
),
CustomDivider(
color: isDetails ? Colors.green : Colors.transparent,
)
],
), ),
color: Colors.white, SizedBox(
), width: 20,
CustomDivider( ),
color: isReviews ? Colors.green : Colors.transparent, Column(
), children: [
], FlatButton(
), onPressed: () async {
SizedBox( if (widget.product.approvedTotalReviews > 0) {
width: 20, GifLoaderDialogUtils.showMyDialog(context);
), await model.getProductReviewsData(widget.product.id);
Column( GifLoaderDialogUtils.hideDialog(context);
children: [ } else {
FlatButton( model.clearReview();
onPressed: () async { }
GifLoaderDialogUtils.showMyDialog(context); setState(() {
await model.getProductLocationData(); isDetails = false;
GifLoaderDialogUtils.hideDialog(context); isReviews = true;
isAvailability = false;
});
},
child: Text(
TranslationBase.of(context).reviews,
style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold),
),
color: Colors.white,
),
CustomDivider(
color: isReviews ? Colors.green : Colors.transparent,
),
],
),
SizedBox(
width: 20,
),
Column(
children: [
FlatButton(
onPressed: () async {
GifLoaderDialogUtils.showMyDialog(context);
await model.getProductLocationData();
GifLoaderDialogUtils.hideDialog(context);
setState(() { setState(() {
isDetails = false; isDetails = false;
isReviews = false; isReviews = false;
isAvailability = true; isAvailability = true;
}); });
}, },
child: Text( child: Text(
TranslationBase.of(context).availability, 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: Colors.white, ],
), ),
CustomDivider( SizedBox(
color: isAvailability ? Colors.green : Colors.transparent, height: 10,
), ),
], isDetails
), ? DetailsInfo(
], product: widget.product,
)
: isReviews
? ReviewsInfo(
product: widget.product,
previousModel: model,
)
: isAvailability
? AvailabilityInfo(
previousModel: model,
)
: Container(),
],
),
), ),
SizedBox( SizedBox(
height: 10, height: 10,
), ),
isDetails RecommendedProducts(
? DetailsInfo( product: widget.product,
product: widget.product, productDetailViewModel: model,
) addToWishlistFunction: (itemID) async {
: isReviews await addToWishlistFunction(itemID: itemID, model: model);
? ReviewsInfo( },
product: widget.product, deleteFromWishlistFunction: (itemID) async {
previousModel: model, await deleteFromWishlistFunction(itemID: itemID, model: model);
) },
: isAvailability )
? AvailabilityInfo(
previousModel: model,
)
: Container(),
], ],
), ),
),
SizedBox(
height: 10,
),
RecommendedProducts(
product: widget.product,
productDetailViewModel: model,
addToWishlistFunction: (itemID) async {
await addToWishlistFunction(itemID: itemID, model: model);
},
deleteFromWishlistFunction: (itemID) async {
await deleteFromWishlistFunction(itemID: itemID, model: model);
},
) )
], : AppCircularProgressIndicator(),
), bottomSheet: model.state == ViewState.Idle
), ? FooterWidget(
bottomSheet: FooterWidget( model.isStockAvailable,
model.isStockAvailable, widget.product.orderMaximumQuantity,
widget.product.orderMaximumQuantity, widget.product.orderMinimumQuantity,
widget.product.orderMinimumQuantity, model.stockQuantity,
model.stockQuantity, widget.product,
widget.product, quantity: quantity,
quantity: quantity, isOverQuantity: isOverQuantity,
isOverQuantity: isOverQuantity, addToCartFunction: addToCartFunction,
addToCartFunction: addToCartFunction, addToShoppingCartFunction: addToShoppingCartFunction,
addToShoppingCartFunction: addToShoppingCartFunction, model: model,
model: model, )
), : SizedBox(),
)); ));
} }

@ -24,7 +24,7 @@ class ProductNameAndPrice extends StatefulWidget {
AuthenticatedUserObject authenticatedUserObject = locator<AuthenticatedUserObject>(); AuthenticatedUserObject authenticatedUserObject = locator<AuthenticatedUserObject>();
ProductNameAndPrice(this.context, this.item, ProductNameAndPrice(this.context, this.item,
{this.customerId, this.isInWishList, this.notifyMeWhenAvailable, this.addToWishlistFunction, this.deleteFromWishlistFunction, @required this.isStockAvailable}); {this.customerId, this.isInWishList, this.notifyMeWhenAvailable, this.addToWishlistFunction, this.deleteFromWishlistFunction, this.isStockAvailable = false});
@override @override
_ProductNameAndPriceState createState() => _ProductNameAndPriceState(); _ProductNameAndPriceState createState() => _ProductNameAndPriceState();

@ -2,15 +2,11 @@ import 'package:diplomaticquarterapp/config/config.dart';
import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; import 'package:diplomaticquarterapp/config/shared_pref_kay.dart';
import 'package:diplomaticquarterapp/core/service/base_service.dart'; import 'package:diplomaticquarterapp/core/service/base_service.dart';
import 'package:diplomaticquarterapp/models/pharmacy/Wishlist.dart'; import 'package:diplomaticquarterapp/models/pharmacy/Wishlist.dart';
import 'package:diplomaticquarterapp/models/pharmacy/addToCartModel.dart';
import 'package:diplomaticquarterapp/models/pharmacy/locationModel.dart'; import 'package:diplomaticquarterapp/models/pharmacy/locationModel.dart';
import 'package:diplomaticquarterapp/models/pharmacy/productDetailModel.dart'; import 'package:diplomaticquarterapp/models/pharmacy/productDetailModel.dart';
import 'package:diplomaticquarterapp/config/shared_pref_kay.dart';
import 'package:diplomaticquarterapp/uitl/app_toast.dart';
import 'package:diplomaticquarterapp/models/pharmacy/specification.dart'; import 'package:diplomaticquarterapp/models/pharmacy/specification.dart';
import 'package:diplomaticquarterapp/uitl/utils.dart';
import 'package:diplomaticquarterapp/core/model/pharmacies/ShoppingCart.dart';
import 'package:diplomaticquarterapp/uitl/app_toast.dart'; import 'package:diplomaticquarterapp/uitl/app_toast.dart';
import 'package:diplomaticquarterapp/uitl/utils.dart';
class ProductDetailService extends BaseService { class ProductDetailService extends BaseService {
bool isLogin = false; bool isLogin = false;
@ -57,7 +53,9 @@ class ProductDetailService extends BaseService {
}); });
_stockQuantity = response['products'][0]['stock_quantity']; _stockQuantity = response['products'][0]['stock_quantity'];
_stockAvailability = response['products'][0]['stock_availability']; _stockAvailability = response['products'][0]['stock_availability'];
_isStockAvailable = response['products'][0]['IsStockAvailable'];
// _isStockAvailable = response['products'][0]['IsStockAvailable'];
_isStockAvailable = _stockAvailability == "In stock" ? true : false;
}, onFailure: (String error, int statusCode) { }, onFailure: (String error, int statusCode) {
hasError = true; hasError = true;
super.error = error; super.error = error;

Loading…
Cancel
Save