fixed an issue in recommended page

merge-update-with-lab-changes
Fatimah Alshammari 5 years ago
parent bb622f248c
commit 265d13b970

@ -34,7 +34,7 @@ class PharmacyModuleViewModel extends BaseViewModel {
_pharmacyService.lastVisitedProducts; _pharmacyService.lastVisitedProducts;
List<Products> get recommendedProductList => List<PharmacyProduct> get recommendedProductList =>
_recommendedProductService.recommendedList; _recommendedProductService.recommendedList;
List<Prescriptions> get prescriptionsList => List<Prescriptions> get prescriptionsList =>

@ -30,6 +30,7 @@ PharmacyProduct specificationData;
class ProductDetailPage extends StatefulWidget { class ProductDetailPage extends StatefulWidget {
final PharmacyProduct product; final PharmacyProduct product;
ProductDetailPage(this.product); ProductDetailPage(this.product);
@override @override
@ -661,221 +662,230 @@ class __ProductDetailPageState extends State<ProductDetailPage> {
.length, .length,
itemBuilder: itemBuilder:
(context, index) { (context, index) {
return Card( return InkWell(
elevation: 2, onTap: () {
shape: RoundedRectangleBorder( Navigator.push(
side: BorderSide( context,
color: Colors FadePage(
.grey[ page: ProductDetailPage(model.recommendedProductList[index]),
300], ));
width: 2), },
borderRadius: child: Card(
BorderRadius elevation: 2,
.circular( shape: RoundedRectangleBorder(
10)), side: BorderSide(
margin: EdgeInsets color: Colors
.symmetric( .grey[
horizontal: 8, 300],
vertical: 0, width: 2),
), borderRadius:
child: Container( BorderRadius
decoration: .circular(
BoxDecoration( 10)),
borderRadius: margin: EdgeInsets
BorderRadius
.all(
Radius.circular(
15),
),
),
padding: EdgeInsets
.symmetric( .symmetric(
horizontal: horizontal: 8,
4), vertical: 0,
width: MediaQuery.of( ),
context) child: Container(
.size decoration:
.width / BoxDecoration(
3, borderRadius:
child: Column( BorderRadius
crossAxisAlignment: .all(
CrossAxisAlignment Radius.circular(
.start, 15),
children: [ ),
Stack( ),
children: [ padding: EdgeInsets
Container( .symmetric(
child: Align( horizontal:
alignment: Alignment.topRight, 4),
child: //true width: MediaQuery.of(
itemID.contains(model.recommendedProductList[index].id) context)
// !isInWishlist .size
? IconButton( .width /
icon: Icon(Icons.favorite_border), 3,
color: Colors.grey, child: Column(
iconSize: 30, crossAxisAlignment:
onPressed: () { CrossAxisAlignment
setState(() { .start,
addToWishlistFunction(itemID); children: [
}); Stack(
}, children: [
) Container(
: IconButton( child: Align(
icon: Icon(Icons.favorite), alignment: Alignment.topRight,
color: Colors.red, child: //true
iconSize: 30, itemID.contains(model.recommendedProductList[index].id)
onPressed: () { // !isInWishlist
setState(() { ? IconButton(
deleteFromWishlistFunction(itemID); icon: Icon(Icons.favorite_border),
}); color: Colors.grey,
}, iconSize: 30,
) onPressed: () {
setState(() {
addToWishlistFunction(itemID);
});
},
)
: IconButton(
icon: Icon(Icons.favorite),
color: Colors.red,
iconSize: 30,
onPressed: () {
setState(() {
deleteFromWishlistFunction(itemID);
});
},
)
// //
),
),
Container(
margin: EdgeInsets.fromLTRB(
0,
16,
10,
16),
alignment:
Alignment.center,
// padding: EdgeInsets.only(left: 25, bottom: 20),
child: (model.recommendedProductList[index].images != null &&
model.recommendedProductList[index].images.length > 0)
? Image.network(
model.recommendedProductList[index].images[0].src.toString(),
// item.images[0].src,
fit: BoxFit.cover,
height: 60,
)
: Image.asset(
"assets/images/no_image.png",
fit: BoxFit.cover,
height: 60,
), ),
),
Container(
width: model.recommendedProductList[index].rxMessage !=
null
? MediaQuery.of(context).size.width /
5
: 0,
padding:
EdgeInsets.all(4),
decoration:
BoxDecoration(
color:
Color(0xffb23838),
borderRadius:
BorderRadius.only(topLeft: Radius.circular(6)),
), ),
child: Container(
Texts( margin: EdgeInsets.fromLTRB(
model.recommendedProductList[index].rxMessage != null 0,
? model.recommendedProductList[index].rxMessage 16,
: "",
color:
Colors.white,
regular:
true,
fontSize:
10, 10,
fontWeight: 16),
FontWeight.w400, alignment:
Alignment.center,
// padding: EdgeInsets.only(left: 25, bottom: 20),
child: (model.recommendedProductList[index].images != null &&
model.recommendedProductList[index].images.length > 0)
? Image.network(
model.recommendedProductList[index].images[0].src.toString(),
// item.images[0].src,
fit: BoxFit.cover,
height: 60,
)
: Image.asset(
"assets/images/no_image.png",
fit: BoxFit.cover,
height: 60,
),
), ),
), Container(
]), width: model.recommendedProductList[index].rxMessage !=
Container( null
margin: EdgeInsets ? MediaQuery.of(context).size.width /
.symmetric( 5
horizontal: : 0,
6, padding:
vertical: 0, EdgeInsets.all(4),
), decoration:
child: Column( BoxDecoration(
crossAxisAlignment: color:
CrossAxisAlignment Color(0xffb23838),
.start, borderRadius:
children: [ BorderRadius.only(topLeft: Radius.circular(6)),
Text( ),
languageID == child:
"ar" Texts(
? model.recommendedProductList[index].namen model.recommendedProductList[index].rxMessage != null
: model.recommendedProductList[index].name, ? model.recommendedProductList[index].rxMessage
style: : "",
TextStyle( color:
color: Colors.white,
Colors.black, regular:
fontSize: true,
13.0, fontSize:
10,
fontWeight:
FontWeight.w400,
),
),
]),
Container(
margin: EdgeInsets
.symmetric(
horizontal:
6,
vertical: 0,
),
child: Column(
crossAxisAlignment:
CrossAxisAlignment
.start,
children: [
Text(
languageID ==
"ar"
? model.recommendedProductList[index].namen
: model.recommendedProductList[index].name,
style:
TextStyle(
color:
Colors.black,
fontSize:
13.0,
// fontWeight: FontWeight.bold, // fontWeight: FontWeight.bold,
),
), ),
), Padding(
Padding(
// padding: const EdgeInsets.only(top: 15, bottom: 10), // padding: const EdgeInsets.only(top: 15, bottom: 10),
padding: const EdgeInsets.only( padding: const EdgeInsets.only(
top: top:
10, 10,
bottom: bottom:
5), 5),
child: child:
Texts( Texts(
"SAR ${model.recommendedProductList[index].price}", "SAR ${model.recommendedProductList[index].price}",
bold: bold:
true, true,
fontSize: fontSize:
14, 14,
),
), ),
), ],
], ),
), ),
), Row(
Row( crossAxisAlignment:
crossAxisAlignment: CrossAxisAlignment
CrossAxisAlignment .start,
.start, children: <
children: < Widget>[
Widget>[ Container(
Container( padding:
padding: EdgeInsets.only(right: 10),
EdgeInsets.only(right: 10),
// margin: EdgeInsets.only(left: 5), // margin: EdgeInsets.only(left: 5),
child:
Align(
alignment:
Alignment.topLeft,
child: child:
RatingBar.readOnly( Align(
initialRating: alignment:
model.recommendedProductList[index].approvedRatingSum.toDouble(), Alignment.topLeft,
child:
RatingBar.readOnly(
initialRating:
model.recommendedProductList[index].approvedRatingSum.toDouble(),
// initialRating: productRate, // initialRating: productRate,
size: size:
13.0, 13.0,
filledColor: filledColor:
Colors.yellow[700], Colors.yellow[700],
emptyColor: emptyColor:
Colors.grey[500], Colors.grey[500],
isHalfAllowed: isHalfAllowed:
true, true,
halfFilledIcon: halfFilledIcon:
Icons.star_half, Icons.star_half,
filledIcon: filledIcon:
Icons.star, Icons.star,
emptyIcon: emptyIcon:
Icons.star, Icons.star,
),
), ),
), ),
), Texts(
Texts( "(${model.recommendedProductList[index].approvedTotalReviews.toString()})",
"(${model.recommendedProductList[index].approvedTotalReviews.toString()})",
// bold: true, // bold: true,
fontSize: fontSize:
12, 12,
), ),
]), ]),
], ],
),
), ),
), ),
); );

@ -1,5 +1,6 @@
import 'package:diplomaticquarterapp/config/config.dart'; import 'package:diplomaticquarterapp/config/config.dart';
import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; import 'package:diplomaticquarterapp/config/shared_pref_kay.dart';
import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart';
import 'package:diplomaticquarterapp/core/model/pharmacies/recommendedProduct_model.dart'; import 'package:diplomaticquarterapp/core/model/pharmacies/recommendedProduct_model.dart';
import 'package:diplomaticquarterapp/core/service/base_service.dart'; import 'package:diplomaticquarterapp/core/service/base_service.dart';
import 'package:diplomaticquarterapp/models/Authentication/authenticated_user.dart'; import 'package:diplomaticquarterapp/models/Authentication/authenticated_user.dart';
@ -15,8 +16,8 @@ class RecommendedProductService extends BaseService{
AuthenticatedUser authUser = new AuthenticatedUser(); AuthenticatedUser authUser = new AuthenticatedUser();
AuthProvider authProvider = new AuthProvider(); AuthProvider authProvider = new AuthProvider();
List<Products> _recommendedProductList = List(); List<PharmacyProduct> _recommendedProductList = List();
List<Products> get recommendedList => _recommendedProductList; List<PharmacyProduct> get recommendedList => _recommendedProductList;
String url =""; String url ="";
Future getRecommendedProducts(productId) async { Future getRecommendedProducts(productId) async {
@ -26,7 +27,7 @@ class RecommendedProductService extends BaseService{
onSuccess: (dynamic response, int statusCode) { onSuccess: (dynamic response, int statusCode) {
_recommendedProductList.clear(); _recommendedProductList.clear();
response['products'].forEach((item) { response['products'].forEach((item) {
_recommendedProductList.add(Products.fromJson(item)); _recommendedProductList.add(PharmacyProduct.fromJson(item));
print("----------------------------------"); print("----------------------------------");
print("Test data"); print("Test data");
print(_recommendedProductList[0]); print(_recommendedProductList[0]);

Loading…
Cancel
Save