add a display is no reviews
This commit is contained in:
@@ -1,15 +1,17 @@
|
|||||||
import 'package:custom_rating_bar/custom_rating_bar.dart';
|
import 'package:custom_rating_bar/custom_rating_bar.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:mzansi_innovation_hub/main.dart';
|
import 'package:mzansi_innovation_hub/main.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_components/mih_objects/business.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/business_review.dart';
|
import 'package:mzansi_innovation_hub/mih_components/mih_objects/business_review.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_pop_up_messages/mih_loading_circle.dart';
|
import 'package:mzansi_innovation_hub/mih_components/mih_pop_up_messages/mih_loading_circle.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_packages/mzansi_profile/business_profile/components/mih_review_business_window.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_services/mih_mzansi_directory_services.dart';
|
import 'package:mzansi_innovation_hub/mih_services/mih_mzansi_directory_services.dart';
|
||||||
|
|
||||||
class MihBusinessReviews extends StatefulWidget {
|
class MihBusinessReviews extends StatefulWidget {
|
||||||
final String businessId;
|
final Business business;
|
||||||
const MihBusinessReviews({
|
const MihBusinessReviews({
|
||||||
super.key,
|
super.key,
|
||||||
required this.businessId,
|
required this.business,
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -27,11 +29,27 @@ class _MihBusinessReviewsState extends State<MihBusinessReviews> {
|
|||||||
// );
|
// );
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
void onReviewTap(BusinessReview? businessReview, double width) {
|
||||||
|
// showDialog(context: context, builder: (context)=> )
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (context) {
|
||||||
|
return MihReviewBusinessWindow(
|
||||||
|
business: widget.business,
|
||||||
|
businessReview: businessReview,
|
||||||
|
screenWidth: width,
|
||||||
|
readOnly: true,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
double screenWidth = MediaQuery.of(context).size.width;
|
||||||
return FutureBuilder(
|
return FutureBuilder(
|
||||||
future: MihMzansiDirectoryServices().getAllReviewsofBusiness(
|
future: MihMzansiDirectoryServices().getAllReviewsofBusiness(
|
||||||
widget.businessId,
|
widget.business.business_id,
|
||||||
),
|
),
|
||||||
builder: (context, asyncSnapshot) {
|
builder: (context, asyncSnapshot) {
|
||||||
if (asyncSnapshot.connectionState == ConnectionState.waiting) {
|
if (asyncSnapshot.connectionState == ConnectionState.waiting) {
|
||||||
@@ -39,47 +57,86 @@ class _MihBusinessReviewsState extends State<MihBusinessReviews> {
|
|||||||
} else if (asyncSnapshot.connectionState == ConnectionState.done &&
|
} else if (asyncSnapshot.connectionState == ConnectionState.done &&
|
||||||
asyncSnapshot.hasData) {
|
asyncSnapshot.hasData) {
|
||||||
List<BusinessReview> reviews = asyncSnapshot.data!;
|
List<BusinessReview> reviews = asyncSnapshot.data!;
|
||||||
|
if (reviews.isEmpty) {
|
||||||
|
return Column(
|
||||||
|
children: [
|
||||||
|
const SizedBox(height: 50),
|
||||||
|
Icon(
|
||||||
|
Icons.star_rate_rounded,
|
||||||
|
size: 150,
|
||||||
|
color:
|
||||||
|
MzansiInnovationHub.of(context)!.theme.secondaryColor(),
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
"No reviews yet, be the first the review\n${widget.business.Name}",
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 18,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
int descriptionDisplayCOunt = 75;
|
||||||
return ListView.separated(
|
return ListView.separated(
|
||||||
itemCount: reviews.length,
|
itemCount: reviews.length,
|
||||||
separatorBuilder: (context, index) => Divider(),
|
separatorBuilder: (context, index) => Divider(),
|
||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
return ListTile(
|
return ListTile(
|
||||||
|
onTap: () {
|
||||||
|
onReviewTap(reviews[index], screenWidth);
|
||||||
|
},
|
||||||
title: RatingBar.readOnly(
|
title: RatingBar.readOnly(
|
||||||
size: 25,
|
size: 25,
|
||||||
alignment: Alignment.centerLeft,
|
alignment: Alignment.centerLeft,
|
||||||
filledIcon: Icons.star,
|
filledIcon: Icons.star,
|
||||||
emptyIcon: Icons.star_border,
|
emptyIcon: Icons.star_border,
|
||||||
halfFilledIcon: Icons.star_half,
|
halfFilledIcon: Icons.star_half,
|
||||||
filledColor:
|
filledColor: const Color(0xffe9e8a1),
|
||||||
MzansiInnovationHub.of(context)!.theme.secondaryColor(),
|
// MzansiInnovationHub.of(context)!.theme.primaryColor(),
|
||||||
emptyColor:
|
emptyColor: MzansiInnovationHub.of(context)!
|
||||||
MzansiInnovationHub.of(context)!.theme.secondaryColor(),
|
.theme
|
||||||
halfFilledColor:
|
.secondaryColor(),
|
||||||
MzansiInnovationHub.of(context)!.theme.secondaryColor(),
|
halfFilledColor: const Color(0xffe9e8a1),
|
||||||
|
// MzansiInnovationHub.of(context)!.theme.primaryColor(),
|
||||||
|
// filledColor:
|
||||||
|
// MzansiInnovationHub.of(context)!.theme.secondaryColor(),
|
||||||
|
// emptyColor:
|
||||||
|
// MzansiInnovationHub.of(context)!.theme.secondaryColor(),
|
||||||
|
// halfFilledColor:
|
||||||
|
// MzansiInnovationHub.of(context)!.theme.secondaryColor(),
|
||||||
isHalfAllowed: true,
|
isHalfAllowed: true,
|
||||||
initialRating: double.parse(reviews[index].rating_score),
|
initialRating: double.parse(reviews[index].rating_score),
|
||||||
maxRating: 5,
|
maxRating: 5,
|
||||||
),
|
),
|
||||||
subtitle: Column(
|
subtitle: Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
children: [
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
Row(
|
mainAxisSize: MainAxisSize.max,
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
reviews[index].rating_title,
|
reviews[index].rating_title,
|
||||||
|
softWrap: true,
|
||||||
|
textAlign: TextAlign.left,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 20,
|
fontSize: 20,
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
Text(
|
||||||
|
"${reviews[index].rating_description.substring(0, reviews[index].rating_description.length >= descriptionDisplayCOunt ? descriptionDisplayCOunt : reviews[index].rating_description.length - 1)}${reviews[index].rating_description.length >= descriptionDisplayCOunt ? "..." : ""}",
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 18,
|
||||||
|
fontWeight: FontWeight.normal,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
Row(
|
Row(
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
reviews[index].rating_description,
|
reviews[index].date_time.split("T")[0],
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 18,
|
fontSize: 15,
|
||||||
fontWeight: FontWeight.normal,
|
fontWeight: FontWeight.normal,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -90,6 +147,7 @@ class _MihBusinessReviewsState extends State<MihBusinessReviews> {
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
return Center(child: Text('Error'));
|
return Center(child: Text('Error'));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user