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.
96 lines
3.9 KiB
Dart
96 lines
3.9 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/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: [
|
|
"This branch has no reviews.".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) {
|
|
return Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
10.height,
|
|
Row(
|
|
children: [
|
|
("Mohammad Al Shafa - 5.0").toText(fontSize: 14, isBold: true),
|
|
MyAssets.icStar.buildSvg(color: MyColors.darkPrimaryColor, height: 13).paddingOnly(left: 5, bottom: 2),
|
|
],
|
|
),
|
|
3.height,
|
|
"Some Reviews about the Provider from Customer".toText(fontSize: 12, color: MyColors.lightTextColor),
|
|
10.height,
|
|
],
|
|
);
|
|
},
|
|
),
|
|
if (appointmentsVM.isReadMoreEnabled) ...[
|
|
("Read Less").toText(fontSize: 13, color: MyColors.darkPrimaryColor, isUnderLine: true).onPress(() {
|
|
appointmentsVM.updateIsReadMoreEnabled(false);
|
|
}),
|
|
] else ...[
|
|
("Read More Reviews").toText(fontSize: 13, color: MyColors.darkPrimaryColor, isUnderLine: true).onPress(() {
|
|
appointmentsVM.updateIsReadMoreEnabled(true);
|
|
}),
|
|
]
|
|
]
|
|
],
|
|
).toWhiteContainer(
|
|
width: double.infinity,
|
|
allPading: 12,
|
|
);
|
|
});
|
|
}
|
|
}
|