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.
109 lines
4.5 KiB
Dart
109 lines
4.5 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:mc_common_app/classes/consts.dart';
|
|
import 'package:mc_common_app/extensions/string_extensions.dart';
|
|
import 'package:mc_common_app/generated/locale_keys.g.dart';
|
|
import 'package:easy_localization/easy_localization.dart';
|
|
import 'package:mc_common_app/extensions/int_extensions.dart';
|
|
import 'package:mc_common_app/models/provider_branches_models/branch_review_model.dart';
|
|
import 'package:mc_common_app/theme/colors.dart';
|
|
import 'package:mc_common_app/utils/enums.dart';
|
|
import 'package:mc_common_app/view_models/appointments_view_model.dart';
|
|
import 'package:mc_common_app/widgets/extensions/extensions_widget.dart';
|
|
import 'package:provider/provider.dart';
|
|
|
|
class BranchReviewsWidget extends StatelessWidget {
|
|
final double branchRateAvg;
|
|
|
|
const BranchReviewsWidget({super.key, required this.branchRateAvg});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Consumer(builder: (BuildContext context, AppointmentsVM appointmentsVM, Widget? child) {
|
|
return Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
LocaleKeys.review.tr().toText(fontSize: 18, isBold: true, letterSpacing: 0.1),
|
|
if (branchRateAvg != 0.0) ...[
|
|
"$branchRateAvg".toString().toText(fontSize: 18, isBold: true, letterSpacing: 0.1),
|
|
]
|
|
],
|
|
),
|
|
10.height,
|
|
if (appointmentsVM.state == ViewState.busy) ...[
|
|
Center(child: CircularProgressIndicator())
|
|
] else if (appointmentsVM.currentBranchReviews.isEmpty) ...[
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
LocaleKeys.noReviewsBranch.tr().toText(fontSize: 14, color: MyColors.lightTextColor),
|
|
],
|
|
),
|
|
] else ...[
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: List.generate(
|
|
5,
|
|
(index) => MyAssets.icStar.buildSvg(
|
|
color: (index <= branchRateAvg - 1) ? MyColors.lightPrimaryColor : MyColors.lightGreyDDColor,
|
|
height: 50,
|
|
),
|
|
),
|
|
),
|
|
10.height,
|
|
ListView.separated(
|
|
separatorBuilder: (context, index) => Divider(height: 1),
|
|
itemCount: !appointmentsVM.isReadMoreEnabled ? 3 : appointmentsVM.currentBranchReviews.length,
|
|
physics: NeverScrollableScrollPhysics(),
|
|
shrinkWrap: true,
|
|
itemBuilder: (context, index) {
|
|
BranchRatingModel rating = appointmentsVM.currentBranchReviews[index];
|
|
return Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
10.height,
|
|
Row(
|
|
children: [
|
|
("${rating.title} - ${rating.ratNo}.0").toText(fontSize: 14, isBold: true),
|
|
MyAssets.icStar.buildSvg(color: MyColors.darkPrimaryColor, height: 13).paddingOnly(left: 5, bottom: 2),
|
|
],
|
|
),
|
|
3.height,
|
|
Row(
|
|
children: [
|
|
Expanded(
|
|
flex: 9,
|
|
child: "${rating.review}".toText(fontSize: 12, color: MyColors.lightTextColor),
|
|
),
|
|
Expanded(
|
|
flex: 3,
|
|
child: "-${rating.customerName ?? "Unknown"}".toText(fontSize: 2, color: MyColors.lightTextColor),
|
|
),
|
|
],
|
|
),
|
|
10.height,
|
|
],
|
|
);
|
|
},
|
|
),
|
|
if (appointmentsVM.isReadMoreEnabled) ...[
|
|
LocaleKeys.readLess.tr().toText(fontSize: 13, color: MyColors.darkPrimaryColor, isUnderLine: true).onPress(() {
|
|
appointmentsVM.updateIsReadMoreEnabled(false);
|
|
}),
|
|
] else ...[
|
|
LocaleKeys.readMoreReviews.tr().toText(fontSize: 13, color: MyColors.darkPrimaryColor, isUnderLine: true).onPress(() {
|
|
appointmentsVM.updateIsReadMoreEnabled(true);
|
|
}),
|
|
]
|
|
]
|
|
],
|
|
).toWhiteContainer(
|
|
width: double.infinity,
|
|
allPading: 12,
|
|
);
|
|
});
|
|
}
|
|
}
|