You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
PatientApp-KKUMC/lib/pages/pharmacies/screens/product-details/reviews_info.dart

122 lines
5.5 KiB
Dart

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