From ca11fe313458be4ad71beff0a83233d849354389 Mon Sep 17 00:00:00 2001 From: Fatimah Alshammari Date: Sun, 7 Nov 2021 09:27:19 +0300 Subject: [PATCH 1/2] fix issues --- lib/config/localized_values.dart | 1 + .../pharmacyModule/order_model_view_model.dart | 11 +++++++---- lib/pages/pharmacy/order/ProductReview.dart | 2 +- lib/uitl/translations_delegate_base.dart | 2 ++ 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/lib/config/localized_values.dart b/lib/config/localized_values.dart index a61f86c4..69e412bb 100644 --- a/lib/config/localized_values.dart +++ b/lib/config/localized_values.dart @@ -1037,6 +1037,7 @@ const Map localizedValues = { "no-data": {"en": "No data found", "ar": "لاتوجد بيانات"}, "insurance-details": {"en": "Insurance Details", "ar": "تفاصيل التأمين"}, "nearest-hospital": {"en": "Nearest Hospital", "ar": "أقرب مستشفى"}, + "submitReview": {"en": "Your review has been Submitted successfully", "ar": "تم إرسال التقييم بنجاح"}, "request-sent": {"en": "Request sent successfully", "ar": "تم إرسال الطلب بنجاح"}, "message-sent": {"en": "Message sent successfully", "ar": "تم إرسال الرسالة بنجاح"}, "sent-on": {"en": "Sent on", "ar": "أرسلت في"}, diff --git a/lib/core/viewModels/pharmacyModule/order_model_view_model.dart b/lib/core/viewModels/pharmacyModule/order_model_view_model.dart index 232e10c4..fe5be016 100644 --- a/lib/core/viewModels/pharmacyModule/order_model_view_model.dart +++ b/lib/core/viewModels/pharmacyModule/order_model_view_model.dart @@ -11,6 +11,7 @@ import 'package:diplomaticquarterapp/services/pharmacy_services/cancelOrder_serv import 'package:diplomaticquarterapp/services/pharmacy_services/orderDetails_service.dart'; import 'package:diplomaticquarterapp/services/pharmacy_services/order_service.dart'; import 'package:diplomaticquarterapp/uitl/app_toast.dart'; +import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import '../../../locator.dart'; import '../base_view_model.dart'; @@ -77,7 +78,8 @@ class OrderModelViewModel extends BaseViewModel { dynamic res; await _cancelOrderService.getCanceledOrder(order).then((value) { res = value['success']['SuccessEndUserMsg']; - AppToast.showSuccessToast(message: "Request Sent Successfully"); + // AppToast.showSuccessToast(message: "Request Sent Successfully"); + AppToast.showSuccessToast(message: TranslationBase.of(context).requestSent); // Navigator.pop(context); }); if (_cancelOrderService.hasError) { @@ -95,7 +97,7 @@ class OrderModelViewModel extends BaseViewModel { return res; } - Future makeReview(PharmacyProduct product, double rating, String reviewText) async { + Future makeReview(PharmacyProduct product, double rating, String reviewText, context) async { setState(ViewState.Busy); await _orderDetailsService.makeReview(product, rating, reviewText); if (_orderDetailsService.hasError) { @@ -104,8 +106,9 @@ class OrderModelViewModel extends BaseViewModel { AppToast.showErrorToast(message: error); } else { setState(ViewState.Idle); - AppToast.showSuccessToast( - message: "Your review has been Submitted successfully"); + AppToast.showSuccessToast(message: TranslationBase.of(context).submitReview); + // AppToast.showSuccessToast( + // message: "Your review has been Submitted successfully"); } } diff --git a/lib/pages/pharmacy/order/ProductReview.dart b/lib/pages/pharmacy/order/ProductReview.dart index 12ab939a..bb680864 100644 --- a/lib/pages/pharmacy/order/ProductReview.dart +++ b/lib/pages/pharmacy/order/ProductReview.dart @@ -201,7 +201,7 @@ class _ProductReviewPageState extends State { ? () { model .makeReview( - widget.product, ratingValue, reviewText) + widget.product, ratingValue, reviewText, context) .then((value) { setState(() { finishReview = true; diff --git a/lib/uitl/translations_delegate_base.dart b/lib/uitl/translations_delegate_base.dart index b15f7adb..12e01337 100644 --- a/lib/uitl/translations_delegate_base.dart +++ b/lib/uitl/translations_delegate_base.dart @@ -1770,6 +1770,8 @@ class TranslationBase { String get requestSent => localizedValues['request-sent'][locale.languageCode]; + String get submitReview => localizedValues['submitReview'][locale.languageCode]; + String get attachInsuraceImage => localizedValues['attach-insurace-image'][locale.languageCode]; String get infoInsurCards => localizedValues['info-insur-cards'][locale.languageCode]; From eb4801c7ee2eea821afef18bf36c64214bb97710 Mon Sep 17 00:00:00 2001 From: Fatimah Alshammari Date: Mon, 8 Nov 2021 11:16:16 +0300 Subject: [PATCH 2/2] fixed rating issues --- lib/pages/final_products_page.dart | 41 ++++++++++++----- lib/pages/offers_categorise_page.dart | 63 ++++++++++++++++++--------- lib/pages/parent_categorise_page.dart | 41 ++++++++++++----- lib/pages/sub_categorise_page.dart | 41 ++++++++++++----- 4 files changed, 135 insertions(+), 51 deletions(-) diff --git a/lib/pages/final_products_page.dart b/lib/pages/final_products_page.dart index 5705f726..ea5ee011 100644 --- a/lib/pages/final_products_page.dart +++ b/lib/pages/final_products_page.dart @@ -15,6 +15,7 @@ import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:diplomaticquarterapp/widgets/others/network_base_view.dart'; import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; import 'package:flutter/material.dart'; +import 'package:rating_bar/rating_bar.dart'; import 'base/base_view.dart'; @@ -274,11 +275,21 @@ class _FinalProductsPageState extends State { ), Row( children: [ - StarRating( - totalAverage: model.finalProducts[index].approvedRatingSum > 0 - ? (model.finalProducts[index].approvedRatingSum.toDouble() / model.finalProducts[index].approvedRatingSum.toDouble()).toDouble() - : 0, - forceStars: true), +// StarRating( +// totalAverage: model.finalProducts[index].approvedRatingSum > 0 +// ? (model.finalProducts[index].approvedRatingSum.toDouble() / model.finalProducts[index].approvedRatingSum.toDouble()).toDouble() +// : 0, +// forceStars: true), + RatingBar.readOnly( + initialRating: model.finalProducts[index].approvedRatingSum.toDouble(), + size: 15.0, + filledColor: Colors.yellow[700], + emptyColor: Colors.grey[500], + isHalfAllowed: true, + halfFilledIcon: Icons.star_half, + filledIcon: Icons.star, + emptyIcon: Icons.star, + ), Texts( "(${model.finalProducts[index].approvedTotalReviews})", regular: true, @@ -424,11 +435,21 @@ class _FinalProductsPageState extends State { ), Row( children: [ - StarRating( - totalAverage: model.finalProducts[index].approvedRatingSum > 0 - ? (model.finalProducts[index].approvedRatingSum.toDouble() / model.finalProducts[index].approvedRatingSum.toDouble()).toDouble() - : 0, - forceStars: true), +// StarRating( +// totalAverage: model.finalProducts[index].approvedRatingSum > 0 +// ? (model.finalProducts[index].approvedRatingSum.toDouble() / model.finalProducts[index].approvedRatingSum.toDouble()).toDouble() +// : 0, +// forceStars: true), + RatingBar.readOnly( + initialRating: model.finalProducts[index].approvedRatingSum.toDouble(), + size: 15.0, + filledColor: Colors.yellow[700], + emptyColor: Colors.grey[500], + isHalfAllowed: true, + halfFilledIcon: Icons.star_half, + filledIcon: Icons.star, + emptyIcon: Icons.star, + ), Texts( "(${model.finalProducts[index].approvedTotalReviews})", regular: true, diff --git a/lib/pages/offers_categorise_page.dart b/lib/pages/offers_categorise_page.dart index 15c3b070..263aef5c 100644 --- a/lib/pages/offers_categorise_page.dart +++ b/lib/pages/offers_categorise_page.dart @@ -7,6 +7,7 @@ import 'package:diplomaticquarterapp/widgets/others/app_scaffold_pharmacy_widget import 'package:diplomaticquarterapp/widgets/others/network_base_view.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; +import 'package:rating_bar/rating_bar.dart'; import 'base/base_view.dart'; @@ -428,14 +429,24 @@ class _OffersCategorisePageState extends State { ), Row( children: [ - StarRating( - totalAverage: model.products[index].approvedRatingSum > - 0 - ? (model.products[index].approvedRatingSum.toDouble() / model.products[index].approvedRatingSum.toDouble()) - .toDouble() - : 0, - forceStars: - true), +// StarRating( +// totalAverage: model.products[index].approvedRatingSum > +// 0 +// ? (model.products[index].approvedRatingSum.toDouble() / model.products[index].approvedRatingSum.toDouble()) +// .toDouble() +// : 0, +// forceStars: +// true), + RatingBar.readOnly( + initialRating: model.products[index].approvedRatingSum.toDouble(), + size: 15.0, + filledColor: Colors.yellow[700], + emptyColor: Colors.grey[500], + isHalfAllowed: true, + halfFilledIcon: Icons.star_half, + filledIcon: Icons.star, + emptyIcon: Icons.star, + ), Texts( "(${model.products[index].approvedTotalReviews})", regular: true, @@ -663,19 +674,29 @@ class _OffersCategorisePageState extends State { ), Row( children: [ - StarRating( - totalAverage: model - .products[ - index] - .approvedRatingSum > - 0 - ? (model.products[index].approvedRatingSum.toDouble() / - model.products[index].approvedRatingSum - .toDouble()) - .toDouble() - : 0, - forceStars: - true), +// StarRating( +// totalAverage: model +// .products[ +// index] +// .approvedRatingSum > +// 0 +// ? (model.products[index].approvedRatingSum.toDouble() / +// model.products[index].approvedRatingSum +// .toDouble()) +// .toDouble() +// : 0, +// forceStars: +// true), + RatingBar.readOnly( + initialRating: model.products[index].approvedRatingSum.toDouble(), + size: 15.0, + filledColor: Colors.yellow[700], + emptyColor: Colors.grey[500], + isHalfAllowed: true, + halfFilledIcon: Icons.star_half, + filledIcon: Icons.star, + emptyIcon: Icons.star, + ), Texts( "(${model.products[index].approvedTotalReviews})", regular: true, diff --git a/lib/pages/parent_categorise_page.dart b/lib/pages/parent_categorise_page.dart index ec37cff5..d8c2279c 100644 --- a/lib/pages/parent_categorise_page.dart +++ b/lib/pages/parent_categorise_page.dart @@ -22,6 +22,7 @@ import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; +import 'package:rating_bar/rating_bar.dart'; import 'base/base_view.dart'; @@ -714,11 +715,21 @@ class _ParentCategorisePageState extends State { ), Row( children: [ - StarRating( - totalAverage: model.parentProducts[index].approvedRatingSum > 0 - ? (model.parentProducts[index].approvedRatingSum.toDouble() / model.parentProducts[index].approvedRatingSum.toDouble()).toDouble() - : 0, - forceStars: true), +// StarRating( +// totalAverage: model.parentProducts[index].approvedRatingSum > 0 +// ? (model.parentProducts[index].approvedRatingSum.toDouble() / model.parentProducts[index].approvedRatingSum.toDouble()).toDouble() +// : 0, +// forceStars: true), + RatingBar.readOnly( + initialRating: model.parentProducts[index].approvedRatingSum.toDouble(), + size: 15.0, + filledColor: Colors.yellow[700], + emptyColor: Colors.grey[500], + isHalfAllowed: true, + halfFilledIcon: Icons.star_half, + filledIcon: Icons.star, + emptyIcon: Icons.star, + ), Texts( "(${model.parentProducts[index].approvedTotalReviews})", regular: true, @@ -838,11 +849,21 @@ class _ParentCategorisePageState extends State { ), Row( children: [ - StarRating( - totalAverage: model.parentProducts[index].approvedRatingSum > 0 - ? (model.parentProducts[index].approvedRatingSum.toDouble() / model.parentProducts[index].approvedRatingSum.toDouble()).toDouble() - : 0, - forceStars: true), +// StarRating( +// totalAverage: model.parentProducts[index].approvedRatingSum > 0 +// ? (model.parentProducts[index].approvedRatingSum.toDouble() / model.parentProducts[index].approvedRatingSum.toDouble()).toDouble() +// : 0, +// forceStars: true), + RatingBar.readOnly( + initialRating: model.parentProducts[index].approvedRatingSum.toDouble(), + size: 15.0, + filledColor: Colors.yellow[700], + emptyColor: Colors.grey[500], + isHalfAllowed: true, + halfFilledIcon: Icons.star_half, + filledIcon: Icons.star, + emptyIcon: Icons.star, + ), Texts( "(${model.parentProducts[index].approvedTotalReviews})", regular: true, diff --git a/lib/pages/sub_categorise_page.dart b/lib/pages/sub_categorise_page.dart index e5a8b097..9d2a1f6b 100644 --- a/lib/pages/sub_categorise_page.dart +++ b/lib/pages/sub_categorise_page.dart @@ -17,6 +17,7 @@ import 'package:diplomaticquarterapp/widgets/others/entity_checkbox_list.dart'; import 'package:diplomaticquarterapp/widgets/others/network_base_view.dart'; import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; import 'package:flutter/material.dart'; +import 'package:rating_bar/rating_bar.dart'; import 'base/base_view.dart'; import 'final_products_page.dart'; @@ -641,11 +642,21 @@ class _SubCategorisePageState extends State { ), Row( children: [ - StarRating( - totalAverage: model.subProducts[index].approvedRatingSum > 0 - ? (model.subProducts[index].approvedRatingSum.toDouble() / model.subProducts[index].approvedRatingSum.toDouble()).toDouble() - : 0, - forceStars: true), +// StarRating( +// totalAverage: model.subProducts[index].approvedRatingSum > 0 +// ? (model.subProducts[index].approvedRatingSum.toDouble() / model.subProducts[index].approvedRatingSum.toDouble()).toDouble() +// : 0, +// forceStars: true), + RatingBar.readOnly( + initialRating: model.subProducts[index].approvedRatingSum.toDouble(), + size: 15.0, + filledColor: Colors.yellow[700], + emptyColor: Colors.grey[500], + isHalfAllowed: true, + halfFilledIcon: Icons.star_half, + filledIcon: Icons.star, + emptyIcon: Icons.star, + ), Texts( "(${model.subProducts[index].approvedTotalReviews})", regular: true, @@ -766,11 +777,21 @@ class _SubCategorisePageState extends State { ), Row( children: [ - StarRating( - totalAverage: model.subProducts[index].approvedRatingSum > 0 - ? (model.subProducts[index].approvedRatingSum.toDouble() / model.subProducts[index].approvedRatingSum.toDouble()).toDouble() - : 0, - forceStars: true), +// StarRating( +// totalAverage: model.subProducts[index].approvedRatingSum > 0 +// ? (model.subProducts[index].approvedRatingSum.toDouble() / model.subProducts[index].approvedRatingSum.toDouble()).toDouble() +// : 0, +// forceStars: true), + RatingBar.readOnly( + initialRating: model.subProducts[index].approvedRatingSum.toDouble(), + size: 15.0, + filledColor: Colors.yellow[700], + emptyColor: Colors.grey[500], + isHalfAllowed: true, + halfFilledIcon: Icons.star_half, + filledIcon: Icons.star, + emptyIcon: Icons.star, + ), Texts( "(${model.subProducts[index].approvedTotalReviews})", regular: true,