|
|
|
|
import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/product_detail_view_model.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
|
import 'package:rating_bar/rating_bar.dart';
|
|
|
|
|
|
|
|
|
|
class ReviewsInfo extends StatelessWidget {
|
|
|
|
|
final PharmacyProduct product;
|
|
|
|
|
final ProductDetailViewModel previousModel;
|
|
|
|
|
|
|
|
|
|
const ReviewsInfo({Key key, this.product, this.previousModel})
|
|
|
|
|
: super(key: key);
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
ProjectViewModel projectViewModel = Provider.of(context);
|
|
|
|
|
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: [
|
|
|
|
|
Expanded(
|
|
|
|
|
child: Container(
|
|
|
|
|
child: Text(previousModel.productDetailService[0].reviews[index].customer.firstName != null
|
|
|
|
|
&& previousModel.productDetailService[0].reviews[index].customer.firstName != null
|
|
|
|
|
? previousModel.productDetailService[0].reviews[index].customer.firstName.toString() + " "
|
|
|
|
|
+ previousModel.productDetailService[0].reviews[index].customer.lastName.toString()
|
|
|
|
|
:"",
|
|
|
|
|
// previousModel.productDetailService[0]
|
|
|
|
|
// .reviews[index].customerId
|
|
|
|
|
// .toString(),
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
fontSize: 14,
|
|
|
|
|
color: Colors.black,
|
|
|
|
|
fontWeight: FontWeight.w600),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
Container(
|
|
|
|
|
// margin: EdgeInsets.only(left: 210),
|
|
|
|
|
child: projectViewModel.isArabic?
|
|
|
|
|
Align(
|
|
|
|
|
alignment: Alignment.topLeft,
|
|
|
|
|
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,
|
|
|
|
|
),
|
|
|
|
|
): Align(
|
|
|
|
|
alignment: Alignment.topRight,
|
|
|
|
|
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,
|
|
|
|
|
),
|
|
|
|
|
Padding(
|
|
|
|
|
padding: const EdgeInsets.all(8.0),
|
|
|
|
|
child: Container(
|
|
|
|
|
child: Text(
|
|
|
|
|
previousModel
|
|
|
|
|
.productDetailService[0].reviews[index].replyText,
|
|
|
|
|
style: TextStyle(fontSize: 20),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
SizedBox(
|
|
|
|
|
height: 50,
|
|
|
|
|
),
|
|
|
|
|
Divider(height: 1, color: Colors.grey),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
)
|
|
|
|
|
: Container(
|
|
|
|
|
padding: EdgeInsets.fromLTRB(15,15,15,20),
|
|
|
|
|
margin: EdgeInsets.only(bottom: 40),
|
|
|
|
|
alignment: Alignment.center,
|
|
|
|
|
child: Text(
|
|
|
|
|
TranslationBase.of(context).noReviewsAvailable,
|
|
|
|
|
),
|
|
|
|
|
// Text('No Reviews Available'),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|