add loader and cache on images
parent
1e1e230908
commit
47e19c4ab5
@ -1,97 +1,89 @@
|
||||
import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart';
|
||||
import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/product_detail_view_model.dart';
|
||||
import 'package:diplomaticquarterapp/pages/base/base_view.dart';
|
||||
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
|
||||
import 'package:diplomaticquarterapp/widgets/others/network_base_view.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:rating_bar/rating_bar.dart';
|
||||
|
||||
class ReviewsInfo extends StatelessWidget {
|
||||
final PharmacyProduct product;
|
||||
final ProductDetailViewModel previousModel;
|
||||
|
||||
const ReviewsInfo({Key key, this.product}) : super(key: key);
|
||||
const ReviewsInfo({Key key, this.product, this.previousModel}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BaseView<ProductDetailViewModel>(
|
||||
onModelReady: (model) => model.getProductReviewsData(product.id),
|
||||
allowAny: true,
|
||||
builder: (_, model, wi) => NetworkBaseView(
|
||||
baseViewModel:model ,
|
||||
child: model.productDetailService.length != 0 &&
|
||||
model.productDetailService[0].reviews.length != 0
|
||||
? ListView.builder(
|
||||
physics: ScrollPhysics(),
|
||||
itemCount: model.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(
|
||||
children: [
|
||||
Container(
|
||||
child: Text(
|
||||
model.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: model.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(
|
||||
child: Text(
|
||||
model.productDetailService[0].reviews[index]
|
||||
.reviewText,
|
||||
style: TextStyle(fontSize: 20),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 50,
|
||||
),
|
||||
Divider(height: 1, color: Colors.grey),
|
||||
],
|
||||
return previousModel.productDetailService.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(
|
||||
children: [
|
||||
Container(
|
||||
child: Text(
|
||||
previousModel.productDetailService[0].reviews[index]
|
||||
.customerId
|
||||
.toString(),
|
||||
style: TextStyle(
|
||||
fontSize: 17,
|
||||
color: Colors.grey,
|
||||
fontWeight: FontWeight.w600),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
)
|
||||
: Container(
|
||||
padding: EdgeInsets.all(15),
|
||||
alignment: Alignment.center,
|
||||
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(
|
||||
child: Text(
|
||||
TranslationBase.of(context).noReviewsAvailable,
|
||||
previousModel.productDetailService[0].reviews[index]
|
||||
.reviewText,
|
||||
style: TextStyle(fontSize: 20),
|
||||
),
|
||||
// Text('No Reviews Available'),
|
||||
),
|
||||
SizedBox(
|
||||
height: 50,
|
||||
),
|
||||
Divider(height: 1, color: Colors.grey),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
)
|
||||
: Container(
|
||||
padding: EdgeInsets.all(15),
|
||||
alignment: Alignment.center,
|
||||
child: Text(
|
||||
TranslationBase.of(context).noReviewsAvailable,
|
||||
),
|
||||
// Text('No Reviews Available'),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue