forked from yaso_meth/mih-project
add new review tool to business profile view
This commit is contained in:
@@ -4,6 +4,7 @@ import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_tools.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_packages/mzansi_profile/business_profile/package_tools/mih_business_details_view.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_packages/mzansi_profile/business_profile/package_tools/mih_business_reviews.dart';
|
||||
|
||||
class MzansiBusinessProfileView extends StatefulWidget {
|
||||
final Business business;
|
||||
@@ -54,6 +55,11 @@ class _MzansiBusinessProfileViewState extends State<MzansiBusinessProfileView> {
|
||||
_selcetedIndex = 0;
|
||||
});
|
||||
};
|
||||
temp[const Icon(Icons.star_rate_rounded)] = () {
|
||||
setState(() {
|
||||
_selcetedIndex = 1;
|
||||
});
|
||||
};
|
||||
return MihPackageTools(
|
||||
tools: temp,
|
||||
selcetedIndex: _selcetedIndex,
|
||||
@@ -63,6 +69,7 @@ class _MzansiBusinessProfileViewState extends State<MzansiBusinessProfileView> {
|
||||
List<Widget> getToolBody() {
|
||||
List<Widget> toolBodies = [
|
||||
MihBusinessDetailsView(business: widget.business),
|
||||
MihBusinessReviews(businessId: widget.business.business_id),
|
||||
];
|
||||
return toolBodies;
|
||||
}
|
||||
@@ -70,6 +77,7 @@ class _MzansiBusinessProfileViewState extends State<MzansiBusinessProfileView> {
|
||||
List<String> getToolTitle() {
|
||||
List<String> toolTitles = [
|
||||
"Profile",
|
||||
"Reviews",
|
||||
];
|
||||
return toolTitles;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,98 @@
|
||||
import 'package:custom_rating_bar/custom_rating_bar.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:mzansi_innovation_hub/main.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_services/mih_mzansi_directory_services.dart';
|
||||
|
||||
class MihBusinessReviews extends StatefulWidget {
|
||||
final String businessId;
|
||||
const MihBusinessReviews({
|
||||
super.key,
|
||||
required this.businessId,
|
||||
});
|
||||
|
||||
@override
|
||||
State<MihBusinessReviews> createState() => _MihBusinessReviewsState();
|
||||
}
|
||||
|
||||
class _MihBusinessReviewsState extends State<MihBusinessReviews> {
|
||||
// late Future<List<BusinessReview>> _reviews;
|
||||
|
||||
// @override
|
||||
// void initState() {
|
||||
// super.initState();
|
||||
// _reviews = MihMzansiDirectoryServices().getAllReviewsofBusiness(
|
||||
// widget.businessId,
|
||||
// );
|
||||
// }
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return FutureBuilder(
|
||||
future: MihMzansiDirectoryServices().getAllReviewsofBusiness(
|
||||
widget.businessId,
|
||||
),
|
||||
builder: (context, asyncSnapshot) {
|
||||
if (asyncSnapshot.connectionState == ConnectionState.waiting) {
|
||||
return const Mihloadingcircle();
|
||||
} else if (asyncSnapshot.connectionState == ConnectionState.done &&
|
||||
asyncSnapshot.hasData) {
|
||||
List<BusinessReview> reviews = asyncSnapshot.data!;
|
||||
return ListView.separated(
|
||||
itemCount: reviews.length,
|
||||
separatorBuilder: (context, index) => Divider(),
|
||||
itemBuilder: (context, index) {
|
||||
return ListTile(
|
||||
title: RatingBar.readOnly(
|
||||
size: 25,
|
||||
alignment: Alignment.centerLeft,
|
||||
filledIcon: Icons.star,
|
||||
emptyIcon: Icons.star_border,
|
||||
halfFilledIcon: Icons.star_half,
|
||||
filledColor:
|
||||
MzansiInnovationHub.of(context)!.theme.secondaryColor(),
|
||||
emptyColor:
|
||||
MzansiInnovationHub.of(context)!.theme.secondaryColor(),
|
||||
halfFilledColor:
|
||||
MzansiInnovationHub.of(context)!.theme.secondaryColor(),
|
||||
isHalfAllowed: true,
|
||||
initialRating: double.parse(reviews[index].rating_score),
|
||||
maxRating: 5,
|
||||
),
|
||||
subtitle: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Text(
|
||||
reviews[index].rating_title,
|
||||
style: TextStyle(
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
Text(
|
||||
reviews[index].rating_description,
|
||||
style: TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.normal,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
} else {
|
||||
return Center(child: Text('Error'));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user