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;
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

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

@ -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'),
);
);
}
}

@ -127,8 +127,8 @@ class ProductAppBar extends StatelessWidget with PreferredSizeWidget {
TranslationBase.of(context).addToWishlist,
),
onTap: () {
addToWishlistFunction(itemID: itemID, model: model);
},
addToWishlistFunction();
}
),
ListTile(
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/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",

Loading…
Cancel
Save