|
|
|
|
@ -1,4 +1,5 @@
|
|
|
|
|
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/viewModels/pharmacyModule/product_detail_view_model.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/widgets/data_display/text.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 'availability_info.dart';
|
|
|
|
|
@ -87,8 +89,8 @@ class __ProductDetailPageState extends State<ProductDetailPage> {
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
return BaseView<ProductDetailViewModel>(
|
|
|
|
|
allowAny: true,
|
|
|
|
|
onModelReady: (model) {
|
|
|
|
|
model.getProductReviewsData(widget.product.id);
|
|
|
|
|
onModelReady: (model) async {
|
|
|
|
|
await model.getProductReviewsData(widget.product.id).then((value) {});
|
|
|
|
|
},
|
|
|
|
|
builder: (_, model, wi) => AppScaffold(
|
|
|
|
|
appBarTitle: TranslationBase.of(context).productDetails,
|
|
|
|
|
@ -108,215 +110,219 @@ class __ProductDetailPageState extends State<ProductDetailPage> {
|
|
|
|
|
isInWishList: isInWishList,
|
|
|
|
|
addToCartFunction: addToCartFunction,
|
|
|
|
|
),
|
|
|
|
|
body: SingleChildScrollView(
|
|
|
|
|
child: Column(
|
|
|
|
|
children: [
|
|
|
|
|
Container(
|
|
|
|
|
width: double.infinity,
|
|
|
|
|
color: Colors.white,
|
|
|
|
|
body: model.state == ViewState.Idle
|
|
|
|
|
? SingleChildScrollView(
|
|
|
|
|
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,
|
|
|
|
|
),
|
|
|
|
|
Container(
|
|
|
|
|
width: double.infinity,
|
|
|
|
|
color: Colors.white,
|
|
|
|
|
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)
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
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) {
|
|
|
|
|
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: [
|
|
|
|
|
),
|
|
|
|
|
SizedBox(
|
|
|
|
|
height: 4,
|
|
|
|
|
),
|
|
|
|
|
Container(
|
|
|
|
|
padding: EdgeInsets.symmetric(vertical: 15, horizontal: 10),
|
|
|
|
|
child: Texts(
|
|
|
|
|
TranslationBase.of(context).specification,
|
|
|
|
|
fontSize: 15,
|
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
|
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,
|
|
|
|
|
),
|
|
|
|
|
width: double.infinity,
|
|
|
|
|
),
|
|
|
|
|
// Divider(color: Colors.grey),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
SizedBox(
|
|
|
|
|
height: 6,
|
|
|
|
|
),
|
|
|
|
|
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,
|
|
|
|
|
SizedBox(
|
|
|
|
|
height: 6,
|
|
|
|
|
),
|
|
|
|
|
Container(
|
|
|
|
|
color: Colors.white,
|
|
|
|
|
child: Column(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
Container(
|
|
|
|
|
padding: EdgeInsets.symmetric(vertical: 15, horizontal: 10),
|
|
|
|
|
child: Texts(
|
|
|
|
|
TranslationBase.of(context).specification,
|
|
|
|
|
fontSize: 15,
|
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
|
),
|
|
|
|
|
CustomDivider(
|
|
|
|
|
color: isDetails ? Colors.green : Colors.transparent,
|
|
|
|
|
)
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
SizedBox(
|
|
|
|
|
width: 20,
|
|
|
|
|
),
|
|
|
|
|
Column(
|
|
|
|
|
children: [
|
|
|
|
|
FlatButton(
|
|
|
|
|
onPressed: () async {
|
|
|
|
|
if (widget.product.approvedTotalReviews > 0) {
|
|
|
|
|
GifLoaderDialogUtils.showMyDialog(context);
|
|
|
|
|
await model.getProductReviewsData(widget.product.id);
|
|
|
|
|
GifLoaderDialogUtils.hideDialog(context);
|
|
|
|
|
} else {
|
|
|
|
|
model.clearReview();
|
|
|
|
|
}
|
|
|
|
|
setState(() {
|
|
|
|
|
isDetails = false;
|
|
|
|
|
isReviews = true;
|
|
|
|
|
isAvailability = false;
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
child: Text(
|
|
|
|
|
TranslationBase.of(context).reviews,
|
|
|
|
|
style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold),
|
|
|
|
|
width: double.infinity,
|
|
|
|
|
),
|
|
|
|
|
// Divider(color: Colors.grey),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
SizedBox(
|
|
|
|
|
height: 6,
|
|
|
|
|
),
|
|
|
|
|
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 ? Colors.green : Colors.transparent,
|
|
|
|
|
)
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
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);
|
|
|
|
|
SizedBox(
|
|
|
|
|
width: 20,
|
|
|
|
|
),
|
|
|
|
|
Column(
|
|
|
|
|
children: [
|
|
|
|
|
FlatButton(
|
|
|
|
|
onPressed: () async {
|
|
|
|
|
if (widget.product.approvedTotalReviews > 0) {
|
|
|
|
|
GifLoaderDialogUtils.showMyDialog(context);
|
|
|
|
|
await model.getProductReviewsData(widget.product.id);
|
|
|
|
|
GifLoaderDialogUtils.hideDialog(context);
|
|
|
|
|
} else {
|
|
|
|
|
model.clearReview();
|
|
|
|
|
}
|
|
|
|
|
setState(() {
|
|
|
|
|
isDetails = false;
|
|
|
|
|
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(() {
|
|
|
|
|
isDetails = false;
|
|
|
|
|
isReviews = false;
|
|
|
|
|
isAvailability = true;
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
child: Text(
|
|
|
|
|
TranslationBase.of(context).availability,
|
|
|
|
|
style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold),
|
|
|
|
|
setState(() {
|
|
|
|
|
isDetails = false;
|
|
|
|
|
isReviews = false;
|
|
|
|
|
isAvailability = true;
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
child: Text(
|
|
|
|
|
TranslationBase.of(context).availability,
|
|
|
|
|
style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold),
|
|
|
|
|
),
|
|
|
|
|
color: Colors.white,
|
|
|
|
|
),
|
|
|
|
|
CustomDivider(
|
|
|
|
|
color: isAvailability ? Colors.green : Colors.transparent,
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
color: Colors.white,
|
|
|
|
|
),
|
|
|
|
|
CustomDivider(
|
|
|
|
|
color: isAvailability ? Colors.green : Colors.transparent,
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
SizedBox(
|
|
|
|
|
height: 10,
|
|
|
|
|
),
|
|
|
|
|
isDetails
|
|
|
|
|
? DetailsInfo(
|
|
|
|
|
product: widget.product,
|
|
|
|
|
)
|
|
|
|
|
: isReviews
|
|
|
|
|
? ReviewsInfo(
|
|
|
|
|
product: widget.product,
|
|
|
|
|
previousModel: model,
|
|
|
|
|
)
|
|
|
|
|
: isAvailability
|
|
|
|
|
? AvailabilityInfo(
|
|
|
|
|
previousModel: model,
|
|
|
|
|
)
|
|
|
|
|
: Container(),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
SizedBox(
|
|
|
|
|
height: 10,
|
|
|
|
|
),
|
|
|
|
|
isDetails
|
|
|
|
|
? DetailsInfo(
|
|
|
|
|
product: widget.product,
|
|
|
|
|
)
|
|
|
|
|
: isReviews
|
|
|
|
|
? ReviewsInfo(
|
|
|
|
|
product: widget.product,
|
|
|
|
|
previousModel: model,
|
|
|
|
|
)
|
|
|
|
|
: isAvailability
|
|
|
|
|
? AvailabilityInfo(
|
|
|
|
|
previousModel: model,
|
|
|
|
|
)
|
|
|
|
|
: Container(),
|
|
|
|
|
RecommendedProducts(
|
|
|
|
|
product: widget.product,
|
|
|
|
|
productDetailViewModel: model,
|
|
|
|
|
addToWishlistFunction: (itemID) async {
|
|
|
|
|
await addToWishlistFunction(itemID: itemID, model: model);
|
|
|
|
|
},
|
|
|
|
|
deleteFromWishlistFunction: (itemID) async {
|
|
|
|
|
await deleteFromWishlistFunction(itemID: itemID, model: model);
|
|
|
|
|
},
|
|
|
|
|
)
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
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);
|
|
|
|
|
},
|
|
|
|
|
)
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
bottomSheet: FooterWidget(
|
|
|
|
|
model.isStockAvailable,
|
|
|
|
|
widget.product.orderMaximumQuantity,
|
|
|
|
|
widget.product.orderMinimumQuantity,
|
|
|
|
|
model.stockQuantity,
|
|
|
|
|
widget.product,
|
|
|
|
|
quantity: quantity,
|
|
|
|
|
isOverQuantity: isOverQuantity,
|
|
|
|
|
addToCartFunction: addToCartFunction,
|
|
|
|
|
addToShoppingCartFunction: addToShoppingCartFunction,
|
|
|
|
|
model: model,
|
|
|
|
|
),
|
|
|
|
|
: AppCircularProgressIndicator(),
|
|
|
|
|
bottomSheet: model.state == ViewState.Idle
|
|
|
|
|
? FooterWidget(
|
|
|
|
|
model.isStockAvailable,
|
|
|
|
|
widget.product.orderMaximumQuantity,
|
|
|
|
|
widget.product.orderMinimumQuantity,
|
|
|
|
|
model.stockQuantity,
|
|
|
|
|
widget.product,
|
|
|
|
|
quantity: quantity,
|
|
|
|
|
isOverQuantity: isOverQuantity,
|
|
|
|
|
addToCartFunction: addToCartFunction,
|
|
|
|
|
addToShoppingCartFunction: addToShoppingCartFunction,
|
|
|
|
|
model: model,
|
|
|
|
|
)
|
|
|
|
|
: SizedBox(),
|
|
|
|
|
));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|