merge-update-with-lab-changes
Elham Rababh 4 years ago
parent 145117aa63
commit b0b278a7e3

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

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

@ -98,8 +98,8 @@ class __ProductDetailPageState extends State<ProductDetailPage>{
product: widget.product, product: widget.product,
quantity: quantity, quantity: quantity,
model: model, model: model,
addToWishlistFunction: (item) { addToWishlistFunction: () {
addToWishlistFunction(itemID:item,model:model); addToWishlistFunction(itemID:itemID,model:model);
setState(() {}); setState(() {});
}, },
), ),
@ -221,6 +221,8 @@ class __ProductDetailPageState extends State<ProductDetailPage>{
await model.getProductReviewsData( await model.getProductReviewsData(
widget.product.id); widget.product.id);
GifLoaderDialogUtils.hideDialog(context); GifLoaderDialogUtils.hideDialog(context);
} else {
model.clearReview();
} }
setState(() { setState(() {
isDetails = false; isDetails = false;
@ -324,7 +326,7 @@ class __ProductDetailPageState extends State<ProductDetailPage>{
deleteFromWishlistFunction({itemID, ProductDetailViewModel model}) async { deleteFromWishlistFunction({itemID, ProductDetailViewModel model}) async {
isInWishList = false; isInWishList = false;
await model.deletWishlistData(itemID); await model.deleteWishlistData(itemID);
} }
} }

@ -8,82 +8,83 @@ class ReviewsInfo extends StatelessWidget {
final PharmacyProduct product; final PharmacyProduct product;
final ProductDetailViewModel previousModel; 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 @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return previousModel.productDetailService.length != 0 && return previousModel.productDetailService.length != 0 &&
previousModel.productDetailService[0].reviews.length != 0 previousModel.productDetailService[0].reviews.length != 0
? ListView.builder( ? ListView.builder(
physics: ScrollPhysics(), physics: ScrollPhysics(),
itemCount: previousModel.productDetailService[0].reviews.length, itemCount: previousModel.productDetailService[0].reviews.length,
scrollDirection: Axis.vertical, scrollDirection: Axis.vertical,
shrinkWrap: true, shrinkWrap: true,
itemBuilder: (BuildContext context, int index) { itemBuilder: (BuildContext context, int index) {
return Padding( return Padding(
padding: EdgeInsets.all(8.0), padding: EdgeInsets.all(8.0),
child: Column( child: Column(
mainAxisAlignment: MainAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
child: Row(
children: [ children: [
Container( Container(
child: Text( child: Row(
previousModel.productDetailService[0].reviews[index] children: [
.customerId Container(
.toString(), child: Text(
style: TextStyle( previousModel.productDetailService[0]
fontSize: 17, .reviews[index].customerId
color: Colors.grey, .toString(),
fontWeight: FontWeight.w600), 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( Container(
margin: EdgeInsets.only(left: 210), child: Text(
child: RatingBar.readOnly( previousModel
initialRating: previousModel.productDetailService[0] .productDetailService[0].reviews[index].reviewText,
.reviews[index].rating style: TextStyle(fontSize: 20),
.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: 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( : Container(
padding: EdgeInsets.all(15), padding: EdgeInsets.all(15),
alignment: Alignment.center, alignment: Alignment.center,
child: Text( child: Text(
TranslationBase.of(context).noReviewsAvailable, TranslationBase.of(context).noReviewsAvailable,
), ),
// Text('No Reviews Available'), // Text('No Reviews Available'),
); );
} }
} }

@ -127,8 +127,8 @@ class ProductAppBar extends StatelessWidget with PreferredSizeWidget {
TranslationBase.of(context).addToWishlist, TranslationBase.of(context).addToWishlist,
), ),
onTap: () { onTap: () {
addToWishlistFunction(itemID: itemID, model: model); addToWishlistFunction();
}, }
), ),
ListTile( ListTile(
leading: Icon(Icons.compare), leading: Icon(Icons.compare),

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

Loading…
Cancel
Save