|
|
|
|
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/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/compare-list.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/uitl/app_toast.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/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/transitions/fade_page.dart';
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:font_awesome_flutter/font_awesome_flutter.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 'shared/product_details_app_bar.dart';
|
|
|
|
|
import 'availability_info.dart';
|
|
|
|
|
import 'details_info.dart';
|
|
|
|
|
import 'discount_description.dart';
|
|
|
|
|
import 'footor/footer-widget.dart';
|
|
|
|
|
|
|
|
|
|
int price = 0;
|
|
|
|
|
bool isOverQuantity = false;
|
|
|
|
|
bool isInWishList = false;
|
|
|
|
|
bool isSelected = true;
|
|
|
|
|
String itemID;
|
|
|
|
|
var customerId;
|
|
|
|
|
CompareList compareItems = new CompareList();
|
|
|
|
|
PharmacyProduct specificationData;
|
|
|
|
|
|
|
|
|
|
class ProductDetailPage extends StatefulWidget {
|
|
|
|
|
final PharmacyProduct product;
|
|
|
|
|
|
|
|
|
|
ProductDetailPage(this.product);
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
__ProductDetailPageState createState() => __ProductDetailPageState();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class __ProductDetailPageState extends State<ProductDetailPage>
|
|
|
|
|
with SingleTickerProviderStateMixin {
|
|
|
|
|
TabController _tabController;
|
|
|
|
|
AppSharedPreferences sharedPref = AppSharedPreferences();
|
|
|
|
|
|
|
|
|
|
bool isTrue = true;
|
|
|
|
|
bool isDetails = true;
|
|
|
|
|
bool isReviews = false;
|
|
|
|
|
bool isAvailability = false;
|
|
|
|
|
|
|
|
|
|
checkWishlist() async {
|
|
|
|
|
GifLoaderDialogUtils.showMyDialog(context);
|
|
|
|
|
ProductDetailViewModel x = new ProductDetailViewModel();
|
|
|
|
|
await x.checkWishlistData();
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < x.wishListItems.length; i++) {
|
|
|
|
|
if (itemID == x.wishListItems[i].product.id) {
|
|
|
|
|
isInWishList = true;
|
|
|
|
|
break;
|
|
|
|
|
} else {
|
|
|
|
|
isInWishList = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
GifLoaderDialogUtils.hideDialog(context);
|
|
|
|
|
setState(() {});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void initState() {
|
|
|
|
|
price = 1;
|
|
|
|
|
specificationData = widget.product;
|
|
|
|
|
_tabController = TabController(length: 3, vsync: this);
|
|
|
|
|
|
|
|
|
|
userInfo();
|
|
|
|
|
super.initState();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void dispose() {
|
|
|
|
|
_tabController.dispose();
|
|
|
|
|
super.dispose();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void userInfo() async {
|
|
|
|
|
print(specificationData);
|
|
|
|
|
customerId = await sharedPref.getString(PHARMACY_CUSTOMER_ID);
|
|
|
|
|
if (customerId != null) {
|
|
|
|
|
itemID = widget.product.id;
|
|
|
|
|
checkWishlist();
|
|
|
|
|
}
|
|
|
|
|
setState(() {});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
return BaseView<ProductDetailViewModel>(
|
|
|
|
|
allowAny: true,
|
|
|
|
|
builder: (_, model, wi) => AppScaffold(
|
|
|
|
|
appBarTitle: TranslationBase.of(context).productDetails,
|
|
|
|
|
isShowAppBar: true,
|
|
|
|
|
isPharmacy: true,
|
|
|
|
|
isShowDecPage: false,
|
|
|
|
|
customAppBar: ProductAppBar(
|
|
|
|
|
product: widget.product,
|
|
|
|
|
),
|
|
|
|
|
body: SingleChildScrollView(
|
|
|
|
|
child: Column(
|
|
|
|
|
children: [
|
|
|
|
|
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)
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
SizedBox(
|
|
|
|
|
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,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
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,
|
|
|
|
|
),
|
|
|
|
|
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,
|
|
|
|
|
)
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
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),
|
|
|
|
|
),
|
|
|
|
|
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: 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,
|
|
|
|
|
),
|
|
|
|
|
));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class CustomDivider extends StatelessWidget {
|
|
|
|
|
const CustomDivider({
|
|
|
|
|
Key key,
|
|
|
|
|
this.color,
|
|
|
|
|
}) : super(key: key);
|
|
|
|
|
|
|
|
|
|
final Color color;
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
return Container(
|
|
|
|
|
width: 120,
|
|
|
|
|
height: 2,
|
|
|
|
|
color: color,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
convertCityName(txt) {
|
|
|
|
|
String stringTxt;
|
|
|
|
|
String newTxt;
|
|
|
|
|
stringTxt = txt.toString();
|
|
|
|
|
newTxt = stringTxt.split('.')[1];
|
|
|
|
|
|
|
|
|
|
return newTxt;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
addToCartFunction(quantity, itemID, BuildContext context) async {
|
|
|
|
|
GifLoaderDialogUtils.showMyDialog(context);
|
|
|
|
|
ProductDetailViewModel x = new ProductDetailViewModel();
|
|
|
|
|
await x.addToCartData(quantity, itemID).then((value) {
|
|
|
|
|
GifLoaderDialogUtils.hideDialog(context);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
notifyMeWhenAvailable(context, itemId) async {
|
|
|
|
|
ProductDetailViewModel x = new ProductDetailViewModel();
|
|
|
|
|
await x.notifyMe(customerId, itemId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
addToWishlistFunction(itemID) async {
|
|
|
|
|
ProductDetailViewModel x = new ProductDetailViewModel();
|
|
|
|
|
isInWishList = true;
|
|
|
|
|
await x.addToWishlistData(itemID);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
deleteFromWishlistFunction(itemID) async {
|
|
|
|
|
ProductDetailViewModel x = new ProductDetailViewModel();
|
|
|
|
|
isInWishList = false;
|
|
|
|
|
await x.deletWishlistData(itemID);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//TODO Elham* move to file
|
|
|
|
|
Widget tabWidget(
|
|
|
|
|
Size screenSize,
|
|
|
|
|
bool isActive,
|
|
|
|
|
String title,
|
|
|
|
|
) {
|
|
|
|
|
return Center(
|
|
|
|
|
child: Container(
|
|
|
|
|
height: screenSize.height * 0.070,
|
|
|
|
|
child: Row(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
|
children: [
|
|
|
|
|
AppText(
|
|
|
|
|
title,
|
|
|
|
|
fontSize: SizeConfig.textMultiplier * 1.5,
|
|
|
|
|
// color: Color(0xFF2B353E),
|
|
|
|
|
fontWeight: FontWeight.w700,
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|