Merge branch 'product_detail_page' into 'development'

Product detail page

See merge request Cloud_Solution/diplomatic-quarter!420
merge-requests/421/merge
Mohammad Aljammal 3 years ago
commit d2be206d6c

@ -1555,6 +1555,7 @@ const Map localizedValues = {
"quantitySize": {"en": "Quantity", "ar": "كميه"},
"addToCart": {"en": "Add to Cart", "ar": "إضف للسلة"},
"addToWishlist": {"en": "Add to Wishlist", "ar": "اضف للمفضلة"},
"removeFromWishlist": {"en": "Remove From Wishlist", "ar": "احذف للمفضلة"},
"noData": {"en": "There is no data", "ar": "لايوجد بيانات"},
"no_data": {"en": "No data", "ar": "لايوجد بيانات"},
"buyNow": {"en": "buy now", "ar": "إشتري الان"},

@ -97,12 +97,12 @@ class ProductDetailViewModel extends BaseViewModel{
}
Future deletWishlistData(itemID) async {
Future deleteWishlistData(itemID) async {
hasError = false;
setState(ViewState.BusyLocal);
GifLoaderDialogUtils.showMyDialog(
locator<NavigationService>().navigatorKey.currentContext);
await _productDetailService.delteItemFromWishlist(itemID);
await _productDetailService.deleteItemFromWishlist(itemID);
GifLoaderDialogUtils.hideDialog(
locator<NavigationService>().navigatorKey.currentContext);
@ -125,4 +125,10 @@ class ProductDetailViewModel extends BaseViewModel{
setState(ViewState.Idle);
}
clearReview(){
productDetailService.clear();
}
}

@ -87,7 +87,7 @@ class _ProductCheckTypeWidgetState extends State<ProductCheckTypeWidget> {
deleteWishListItem(itemID) async {
ProductDetailViewModel x = new ProductDetailViewModel();
GifLoaderDialogUtils.showMyDialog(context);
await x.deletWishlistData(itemID);
await x.deleteWishlistData(itemID);
setState(()
async{
await

@ -31,7 +31,7 @@ class FooterWidget extends StatefulWidget {
}
class _FooterWidgetState extends State<FooterWidget> {
double quantityUI = 70;
double quantityUI = 80;
bool showUI = false;
AuthenticatedUserObject authenticatedUserObject =
locator<AuthenticatedUserObject>();
@ -77,7 +77,7 @@ class _FooterWidgetState extends State<FooterWidget> {
child: Icon(Icons.close, color: Colors.black),
onTap: () {
setState(() {
quantityUI = 70;
quantityUI = 80;
showUI = false;
});
},
@ -172,7 +172,7 @@ class _FooterWidgetState extends State<FooterWidget> {
onPressed: () {
setState(() {
if (showUI) {
quantityUI = 70;
quantityUI = 80;
showUI = false;
} else {
quantityUI = 150;
@ -189,7 +189,7 @@ class _FooterWidgetState extends State<FooterWidget> {
disabled: !widget.isAvailable && widget.quantity > 0 ||
widget.quantity > widget.quantityLimit ||
widget.item.rxMessage != null,
disableColor: Colors.green[400],
disableColor: Color(0xFF4CAF50),
onTap: () async {
if (!authenticatedUserObject.isLogin) {
Navigator.of(context).pushNamed(
@ -199,8 +199,9 @@ class _FooterWidgetState extends State<FooterWidget> {
await widget.addToCartFunction(
widget.quantity, widget.item.id, context);
},
borderColor: Color(0xFF4CAF50),
borderRadius: 5,
color: Colors.green,
color: Color(0xFF4CAF50),
),
),
SizedBox(

@ -32,7 +32,7 @@ class ProductDetailPage extends StatefulWidget {
__ProductDetailPageState createState() => __ProductDetailPageState();
}
class __ProductDetailPageState extends State<ProductDetailPage>{
class __ProductDetailPageState extends State<ProductDetailPage> {
AppSharedPreferences sharedPref = AppSharedPreferences();
bool isTrue = true;
@ -45,7 +45,6 @@ class __ProductDetailPageState extends State<ProductDetailPage>{
bool isInWishList = false;
int quantity = 0;
checkWishlist() async {
GifLoaderDialogUtils.showMyDialog(context);
ProductDetailViewModel model = new ProductDetailViewModel();
@ -96,11 +95,15 @@ class __ProductDetailPageState extends State<ProductDetailPage>{
isShowDecPage: false,
customAppBar: ProductAppBar(
product: widget.product,
quantity: quantity,
model: model,
addToWishlistFunction: (item) {
addToWishlistFunction(itemID:item,model:model);
setState(() {});
addToWishlistFunction: () async {
await addToWishlistFunction(itemID: itemID, model: model);
},
deleteFromWishlistFunction: () async {
await deleteFromWishlistFunction(itemID: itemID, model: model);
},
isInWishList:isInWishList
),
body: SingleChildScrollView(
child: Column(
@ -133,15 +136,19 @@ class __ProductDetailPageState extends State<ProductDetailPage>{
widget.product,
customerId: customerId,
addToWishlistFunction: (item) {
addToWishlistFunction(itemID:item,model:model);
addToWishlistFunction(itemID: item, model: model);
setState(() {});
},
deleteFromWishlistFunction: (item) {
deleteFromWishlistFunction(itemID: item, model: model);
deleteFromWishlistFunction(
itemID: item, model: model);
setState(() {});
},
notifyMeWhenAvailable: (context, itemId) {
notifyMeWhenAvailable(itemId:itemId, customerId: customerId, model: model);
notifyMeWhenAvailable(
itemId: itemId,
customerId: customerId,
model: model);
},
isInWishList: isInWishList,
),
@ -214,12 +221,16 @@ class __ProductDetailPageState extends State<ProductDetailPage>{
children: [
FlatButton(
onPressed: () async {
if(widget.product.approvedTotalReviews>0) {
if (widget.product.approvedTotalReviews >
0) {
GifLoaderDialogUtils.showMyDialog(
context);
await model.getProductReviewsData(
widget.product.id);
GifLoaderDialogUtils.hideDialog(context);
GifLoaderDialogUtils.hideDialog(
context);
} else {
model.clearReview();
}
setState(() {
isDetails = false;
@ -319,21 +330,27 @@ class __ProductDetailPageState extends State<ProductDetailPage>{
addToWishlistFunction({itemID, ProductDetailViewModel model}) async {
isInWishList = true;
await model.addToWishlistData(itemID);
setState(() {});
}
deleteFromWishlistFunction({itemID, ProductDetailViewModel model}) async {
isInWishList = false;
await model.deletWishlistData(itemID);
await model.deleteWishlistData(itemID);
setState(() {});
}
}
addToCartFunction({quantity, itemID, BuildContext context,ProductDetailViewModel model}) async {
addToCartFunction(
{quantity,
itemID,
BuildContext context,
ProductDetailViewModel model}) async {
GifLoaderDialogUtils.showMyDialog(context);
await model.addToCartData(quantity, itemID);
GifLoaderDialogUtils.hideDialog(context);
}
notifyMeWhenAvailable({itemId, customerId,ProductDetailViewModel model }) async {
notifyMeWhenAvailable(
{itemId, customerId, ProductDetailViewModel model}) async {
await model.notifyMe(customerId, itemId);
}
}

@ -22,7 +22,7 @@ class ProductNameAndPrice extends StatefulWidget {
final Function deleteFromWishlistFunction;
AuthenticatedUserObject authenticatedUserObject =
locator<AuthenticatedUserObject>();
locator<AuthenticatedUserObject>();
ProductNameAndPrice(this.context, this.item,
{this.customerId,
@ -64,48 +64,52 @@ class _ProductNameAndPriceState extends State<ProductNameAndPrice> {
: Colors.green,
),
// SizedBox(width: 20),
if(widget.authenticatedUserObject.isLogin)
widget.item.stockAvailability == 'Out of stock' &&
widget.customerId != null
? InkWell(
onTap: () =>
widget.notifyMeWhenAvailable(context, widget.item.id),
child: Row(children: [
Texts(
TranslationBase.of(context).notifyMe,
decoration: TextDecoration.underline,
color: Colors.blue,
),
SizedBox(width: 4),
Icon(
FontAwesomeIcons.bell,
color: Colors.blue,
size: 15.0,
)
]),
)
: IconWithBg(
icon: !widget.isInWishList
? Icons.favorite_border
: Icons.favorite,
color: !widget.isInWishList ? Colors.white : Colors.red,
onPress: () async {
{
if (widget.customerId != null) {
if (!widget.isInWishList) {
await widget
.addToWishlistFunction(widget.item.id);
if (widget.authenticatedUserObject.isLogin)
widget.item.stockAvailability == 'Out of stock' &&
widget.customerId != null
? InkWell(
onTap: () => widget.notifyMeWhenAvailable(
context, widget.item.id),
child: Row(children: [
Texts(
TranslationBase.of(context).notifyMe,
decoration: TextDecoration.underline,
color: Colors.blue,
),
SizedBox(width: 4),
Icon(
FontAwesomeIcons.bell,
color: Colors.blue,
size: 15.0,
)
]),
)
: IconWithBg(
icon: !widget.isInWishList
? Icons.favorite_border
: Icons.favorite,
color: !widget.isInWishList
? Colors.white
: Colors.red[800],
onPress: () async {
{
if (widget.customerId != null) {
if (!widget.isInWishList) {
await widget
.addToWishlistFunction(widget.item.id);
} else {
await widget
.deleteFromWishlistFunction(widget.item.id);
}
} else {
await widget
.deleteFromWishlistFunction(widget.item.id);
return;
}
} else {
return;
setState(() {});
}
setState(() {});
}
},
)
},
)
],
),
),
@ -161,29 +165,32 @@ class _ProductNameAndPriceState extends State<ProductNameAndPrice> {
"(${widget.item.approvedTotalReviews}${TranslationBase.of(context).review})",
fontSize: 12,
),
SizedBox(
width: 70,
),
if (widget.item.rxMessage != null)
Row(
children: [
Text(
projectViewModel.isArabic
? widget.item.rxMessagen.toString()
: widget.item.rxMessage.toString(),
style: TextStyle(color: Colors.red, fontSize: 10),
),
SizedBox(
width: 5,
),
Icon(
FontAwesomeIcons.questionCircle,
color: Colors.red,
size: 15.0,
)
],
)
],
),
),
),
Expanded(
flex: 1,
child: Container(
child: widget.item.rxMessage != null
? Text(
projectViewModel.isArabic
? widget.item.rxMessagen.toString()
: widget.item.rxMessage.toString(),
style: TextStyle(color: Colors.red, fontSize: 10),
)
: Container()),
),
widget.item.rxMessage != null
? Icon(
FontAwesomeIcons.questionCircle,
color: Colors.red,
size: 15.0,
)
: Container(),
],
),
),

@ -8,82 +8,83 @@ class ReviewsInfo extends StatelessWidget {
final PharmacyProduct product;
final ProductDetailViewModel previousModel;
const ReviewsInfo({Key key, this.product, this.previousModel}) : super(key: key);
const ReviewsInfo({Key key, this.product, this.previousModel})
: super(key: key);
@override
Widget build(BuildContext context) {
return previousModel.productDetailService.length != 0 &&
previousModel.productDetailService[0].reviews.length != 0
previousModel.productDetailService[0].reviews.length != 0
? ListView.builder(
physics: ScrollPhysics(),
itemCount: previousModel.productDetailService[0].reviews.length,
scrollDirection: Axis.vertical,
shrinkWrap: true,
itemBuilder: (BuildContext context, int index) {
return Padding(
padding: EdgeInsets.all(8.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
child: Row(
physics: ScrollPhysics(),
itemCount: previousModel.productDetailService[0].reviews.length,
scrollDirection: Axis.vertical,
shrinkWrap: true,
itemBuilder: (BuildContext context, int index) {
return Padding(
padding: EdgeInsets.all(8.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
child: Text(
previousModel.productDetailService[0].reviews[index]
.customerId
.toString(),
style: TextStyle(
fontSize: 17,
color: Colors.grey,
fontWeight: FontWeight.w600),
child: Row(
children: [
Container(
child: Text(
previousModel.productDetailService[0]
.reviews[index].customerId
.toString(),
style: TextStyle(
fontSize: 17,
color: Colors.grey,
fontWeight: FontWeight.w600),
),
),
Container(
margin: EdgeInsets.only(left: 210),
child: RatingBar.readOnly(
initialRating: previousModel
.productDetailService[0].reviews[index].rating
.toDouble(),
size: 15.0,
filledColor: Colors.yellow[700],
emptyColor: Colors.grey[500],
isHalfAllowed: true,
halfFilledIcon: Icons.star_half,
filledIcon: Icons.star,
emptyIcon: Icons.star,
),
),
],
),
),
SizedBox(
height: 10,
),
Container(
margin: EdgeInsets.only(left: 210),
child: RatingBar.readOnly(
initialRating: previousModel.productDetailService[0]
.reviews[index].rating
.toDouble(),
size: 15.0,
filledColor: Colors.yellow[700],
emptyColor: Colors.grey[500],
isHalfAllowed: true,
halfFilledIcon: Icons.star_half,
filledIcon: Icons.star,
emptyIcon: Icons.star,
child: Text(
previousModel
.productDetailService[0].reviews[index].reviewText,
style: TextStyle(fontSize: 20),
),
),
SizedBox(
height: 50,
),
Divider(height: 1, color: Colors.grey),
],
),
),
SizedBox(
height: 10,
),
Container(
child: Text(
previousModel.productDetailService[0].reviews[index]
.reviewText,
style: TextStyle(fontSize: 20),
),
),
SizedBox(
height: 50,
),
Divider(height: 1, color: Colors.grey),
],
),
);
},
)
);
},
)
: Container(
padding: EdgeInsets.all(15),
alignment: Alignment.center,
child: Text(
TranslationBase.of(context).noReviewsAvailable,
),
padding: EdgeInsets.all(15),
alignment: Alignment.center,
child: Text(
TranslationBase.of(context).noReviewsAvailable,
),
// Text('No Reviews Available'),
);
);
}
}

@ -17,12 +17,14 @@ class IconWithBg extends StatelessWidget {
color: Colors.grey[200],
borderRadius: BorderRadius.circular(30),
),
child: IconButton(
icon: Icon(icon),
color: color,
onPressed: () async {
onPress();
},
child: Center(
child: IconButton(
icon: Icon(icon, size: 20,),
color: color,
onPressed: () async {
onPress();
},
),
));
}
}

@ -18,9 +18,18 @@ class ProductAppBar extends StatelessWidget with PreferredSizeWidget {
final ProductDetailViewModel model;
final Function addToWishlistFunction;
final Function deleteFromWishlistFunction;
final int quantity;
final bool isInWishList;
ProductAppBar({Key key, this.product, this.model, this.addToWishlistFunction, this.quantity})
ProductAppBar(
{Key key,
this.product,
this.model,
this.addToWishlistFunction,
this.quantity,
this.deleteFromWishlistFunction,
this.isInWishList})
: super(key: key);
AuthenticatedUserObject authenticatedUserObject =
@ -43,7 +52,7 @@ class ProductAppBar extends StatelessWidget with PreferredSizeWidget {
Row(
children: [
IconWithBg(
icon: Icons.arrow_back_ios,
icon: Icons.arrow_back,
color: Colors.grey,
onPress: () {
Navigator.pop(context);
@ -56,7 +65,7 @@ class ProductAppBar extends StatelessWidget with PreferredSizeWidget {
children: [
IconWithBg(
icon: Icons.shopping_cart,
color: Colors.grey,
color: Colors.grey[800],
onPress: () {
Navigator.push(
context,
@ -84,7 +93,6 @@ class ProductAppBar extends StatelessWidget with PreferredSizeWidget {
);
}
@override
@override
Size get preferredSize => Size(double.maxFinite, 50);
@ -101,37 +109,48 @@ class ProductAppBar extends StatelessWidget with PreferredSizeWidget {
title: Text(
TranslationBase.of(context).addToCart,
),
onTap: () => {
if (quantity > 0)
{
addToCartFunction(
quantity: quantity,
itemID: itemID,
context: context,
model: model)
}
else
{
AppToast.showErrorToast(
message: "you should add quantity")
}
}),
onTap: () async {
if (quantity > 0) {
{
await addToCartFunction(
quantity: quantity,
itemID: itemID,
context: context,
model: model);
Navigator.of(context).pop();
}
} else {
AppToast.showErrorToast(
message: "you should add quantity");
}
}),
ListTile(
leading: Icon(Icons.favorite_border),
title: Text(
TranslationBase.of(context).addToWishlist,
),
onTap: () =>
{addToWishlistFunction(itemID: itemID, model: model)},
),
leading: Icon(
!isInWishList ? Icons.favorite_border : Icons.favorite,
color: !isInWishList ? Colors.white : Colors.red[800],
),
title: Text(
isInWishList
? TranslationBase.of(context).removeFromWishlist
: TranslationBase.of(context).addToWishlist,
),
onTap: () async {
if (isInWishList)
await deleteFromWishlistFunction();
else
await addToWishlistFunction();
Navigator.of(context).pop();
}),
ListTile(
leading: Icon(Icons.compare),
title: Text(
TranslationBase.of(context).compare,
),
onTap: () => {
onTap: () {
Provider.of<CompareList>(context, listen: false)
.addItem(specificationData),
.addItem(specificationData);
Navigator.of(context).pop();
},
),
],

@ -7,6 +7,7 @@ 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/uitl/utils.dart';
class ProductDetailService extends BaseService {
bool isLogin = false;
@ -98,7 +99,7 @@ class ProductDetailService extends BaseService {
}, onFailure: (String error, int statusCode) {
hasError = true;
super.error = error;
AppToast.showErrorToast(message: super.error??'something went wrong please try again');
AppToast.showErrorToast(message: error??Utils.generateContactAdminMessage());
}, body: request);
}
@ -109,7 +110,7 @@ class ProductDetailService extends BaseService {
}, onFailure: (String error, int statusCode) {
hasError = true;
super.error = error;
AppToast.showErrorToast(message: 'something went wrong please try again');
AppToast.showErrorToast(message: error??Utils.generateContactAdminMessage());
});
}
@ -126,12 +127,13 @@ class ProductDetailService extends BaseService {
_wishListProducts.clear();
response['shopping_carts'].forEach((item) {
_wishListProducts.add(Wishlist.fromJson(item));
AppToast.showSuccessToast(message: 'You have added a product to the Wishlist');
});
AppToast.showSuccessToast(message: 'You have added a product to the Wishlist');
}, onFailure: (String error, int statusCode) {
hasError = true;
super.error = error;
AppToast.showErrorToast(message: 'something went wrong please try again');
AppToast.showErrorToast(message: error??Utils.generateContactAdminMessage());
}, body: request);
}
@ -149,7 +151,7 @@ class ProductDetailService extends BaseService {
super.error = error;
});
}
Future delteItemFromWishlist(itemID) async {
Future deleteItemFromWishlist(itemID) async {
var customerId = await sharedPref.getString(PHARMACY_CUSTOMER_ID);
hasError = false;
await baseAppClient.getPharmacy(DELETE_WISHLIST+customerId+"+&product_id="+itemID+"&cart_type=Wishlist",

@ -1398,6 +1398,8 @@ class TranslationBase {
String get addToCart => localizedValues['addToCart'][locale.languageCode];
String get addToWishlist =>
localizedValues['addToWishlist'][locale.languageCode];
String get removeFromWishlist =>
localizedValues['removeFromWishlist'][locale.languageCode];
String get buyNow => localizedValues['buyNow'][locale.languageCode];
String get quantityShortcut =>
localizedValues['quantityShortcut'][locale.languageCode];

Loading…
Cancel
Save