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

148 lines
6.7 KiB
Dart

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/theme/colors.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:flutter/material.dart';
import 'package:flutter_rating_bar/flutter_rating_bar.dart';
import 'package:provider/provider.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,
// ),
RatingBar(
initialRating: previousModel!
.productDetailService[0].reviews![index].rating!.toDouble(),
direction: Axis.horizontal,
allowHalfRating: true,
itemCount: 5,
itemSize: 20,
ignoreGestures: true,
ratingWidget: RatingWidget(
full: Icon(Icons.star, color: CustomColors.accentColor,),
half: Icon(Icons.star_half, color: CustomColors.accentColor,),
empty: Icon(Icons.star, color: CustomColors.accentColor,),
),
tapOnlyMode: true,
unratedColor: Colors.grey[500],
itemPadding: EdgeInsets.symmetric(horizontal: 4.0),
onRatingUpdate: (rating) {
print(rating);
},
)
): RatingBar(
initialRating: previousModel!
.productDetailService[0].reviews![index].rating!.toDouble(),
direction: Axis.horizontal,
allowHalfRating: true,
itemCount: 5,
itemSize: 20,
ignoreGestures: true,
ratingWidget: RatingWidget(
full: Icon(Icons.star, color: CustomColors.accentColor,),
half: Icon(Icons.star_half, color: CustomColors.accentColor,),
empty: Icon(Icons.star, color: CustomColors.accentColor,),
),
tapOnlyMode: true,
unratedColor: Colors.grey[500],
itemPadding: EdgeInsets.symmetric(horizontal: 4.0),
onRatingUpdate: (rating) {
print(rating);
},
))])
,
),
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'),
);
}
}