forked from yaso_meth/mih-project
load review on business click
This commit is contained in:
@@ -9,6 +9,7 @@ import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_business_profile_preview.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_personal_profile_preview.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_business_info_card.dart';
|
||||
// import 'package:mzansi_innovation_hub/mih_packages/mzansi_profile/business_profile/components/mih_business_info_card.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_services/mih_alert_services.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_services/mih_location_services.dart';
|
||||
@@ -30,6 +31,7 @@ import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_text_form_field.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_time_field.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_toggle.dart';
|
||||
import 'package:redacted/redacted.dart';
|
||||
|
||||
class PackageToolOne extends StatefulWidget {
|
||||
final AppUser user;
|
||||
@@ -291,16 +293,34 @@ class _PackageToolOneState extends State<PackageToolOne> {
|
||||
}
|
||||
}),
|
||||
const SizedBox(height: 10),
|
||||
// MihBusinessCard(
|
||||
// businessid: "123456",
|
||||
// businessName: "Mzansi Innovation Hub",
|
||||
// cellNumber: "0788300006",
|
||||
// email: "yasien.meth@mzansi-innovation-hub.co.za",
|
||||
// gpsLocation: "-26.1853611, 28.134664",
|
||||
// website:
|
||||
// "https://app.mzansi-innovation-hub.co.za/privacy.html",
|
||||
// rating: 3.25,
|
||||
// ),
|
||||
Text("This text should be redacted").redacted(
|
||||
context: context,
|
||||
redact: true,
|
||||
),
|
||||
MihBusinessCard(
|
||||
business: Business(
|
||||
"business_id",
|
||||
"Name",
|
||||
"type",
|
||||
"registration_no",
|
||||
"logo_name",
|
||||
"logo_path",
|
||||
"contact_no",
|
||||
"bus_email",
|
||||
"app_id",
|
||||
"gps_location",
|
||||
"practice_no",
|
||||
"vat_no",
|
||||
"website",
|
||||
"rating",
|
||||
"mission_vision",
|
||||
),
|
||||
startUpSearch: '',
|
||||
width: 300,
|
||||
).redacted(
|
||||
context: context,
|
||||
redact: true,
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Divider(
|
||||
color:
|
||||
|
||||
@@ -8,6 +8,7 @@ import 'package:mzansi_innovation_hub/mih_components/mih_pop_up_messages/mih_loa
|
||||
import 'package:mzansi_innovation_hub/mih_config/mih_colors.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:redacted/redacted.dart';
|
||||
import 'package:supertokens_flutter/supertokens.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
|
||||
@@ -41,6 +42,7 @@ class MihBusinessCard extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _MihBusinessCardState extends State<MihBusinessCard> {
|
||||
Future<BusinessReview?>? _businessReviewFuture;
|
||||
Future<void> _makePhoneCall(String phoneNumber) async {
|
||||
final Uri url = Uri(scheme: 'tel', path: phoneNumber);
|
||||
if (await canLaunchUrl(url)) {
|
||||
@@ -345,6 +347,12 @@ class _MihBusinessCardState extends State<MihBusinessCard> {
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_businessReviewFuture = getUserReview();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// double screenWidth = MediaQuery.of(context).size.width;
|
||||
@@ -430,6 +438,68 @@ class _MihBusinessCardState extends State<MihBusinessCard> {
|
||||
},
|
||||
),
|
||||
),
|
||||
FutureBuilder(
|
||||
future: _businessReviewFuture,
|
||||
builder: (context, asyncSnapshot) {
|
||||
if (asyncSnapshot.connectionState ==
|
||||
ConnectionState.waiting) {
|
||||
// return SizedBox();
|
||||
return Column(
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10.0),
|
||||
child: Divider(
|
||||
color: MzansiInnovationHub.of(context)!
|
||||
.theme
|
||||
.primaryColor(),
|
||||
),
|
||||
),
|
||||
Container(
|
||||
child: _buildContactInfo(
|
||||
"Rate Us",
|
||||
"Let us know how we are doing.",
|
||||
Icons.star_rate_rounded,
|
||||
MihColors.getYellowColor(context),
|
||||
() {
|
||||
// businessReviewRatingWindow(
|
||||
// businessReview, true, widget.width);
|
||||
},
|
||||
),
|
||||
).redacted(context: context, redact: true),
|
||||
],
|
||||
);
|
||||
} else {
|
||||
BusinessReview? businessReview = asyncSnapshot.data;
|
||||
String ratingDisplayTitle = "";
|
||||
if (businessReview == null) {
|
||||
ratingDisplayTitle = "Rate Us";
|
||||
} else {
|
||||
ratingDisplayTitle = "Update Rating";
|
||||
}
|
||||
return Column(
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10.0),
|
||||
child: Divider(
|
||||
color: MzansiInnovationHub.of(context)!
|
||||
.theme
|
||||
.primaryColor(),
|
||||
),
|
||||
),
|
||||
_buildContactInfo(
|
||||
ratingDisplayTitle,
|
||||
"Let us know how we are doing.",
|
||||
Icons.star_rate_rounded,
|
||||
MihColors.getYellowColor(context),
|
||||
() {
|
||||
businessReviewRatingWindow(
|
||||
businessReview, true, widget.width);
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10.0),
|
||||
child: Divider(
|
||||
@@ -437,31 +507,16 @@ class _MihBusinessCardState extends State<MihBusinessCard> {
|
||||
),
|
||||
),
|
||||
_buildContactInfo(
|
||||
"Rate Us",
|
||||
"Let us know how we are doing.",
|
||||
Icons.star_rate_rounded,
|
||||
MihColors.getYellowColor(context),
|
||||
"Bookmark",
|
||||
"Save us for later.",
|
||||
Icons.bookmark_add_rounded,
|
||||
MihColors.getBluishPurpleColor(context),
|
||||
() {
|
||||
businessReviewRatingWindow(true, widget.width);
|
||||
// _launchWebsite(widget.website);
|
||||
print("Saving ${widget.business.Name} to Directory");
|
||||
showBookmarkAlert();
|
||||
},
|
||||
),
|
||||
// Padding(
|
||||
// padding: const EdgeInsets.symmetric(horizontal: 10.0),
|
||||
// child: Divider(
|
||||
// color: MzansiInnovationHub.of(context)!.theme.primaryColor(),
|
||||
// ),
|
||||
// ),
|
||||
// _buildContactInfo(
|
||||
// "Bookmark",
|
||||
// "Save us for later.",
|
||||
// Icons.bookmark_add_rounded,
|
||||
// MihColors.getBluishPurpleColor(context),
|
||||
// () {
|
||||
// // _launchWebsite(widget.website);
|
||||
// print("Saving ${widget.business.Name} to Directory");
|
||||
// showBookmarkAlert();
|
||||
// },
|
||||
// ),
|
||||
const SizedBox(height: 10),
|
||||
// Padding(
|
||||
// padding: const EdgeInsets.symmetric(horizontal: 10.0),
|
||||
@@ -476,7 +531,7 @@ class _MihBusinessCardState extends State<MihBusinessCard> {
|
||||
}
|
||||
|
||||
Future<void> businessReviewRatingWindow(
|
||||
bool previouslyRated, double width) async {
|
||||
BusinessReview? myReview, bool previouslyRated, double width) async {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) => FutureBuilder(
|
||||
@@ -523,6 +578,54 @@ class _MihBusinessCardState extends State<MihBusinessCard> {
|
||||
);
|
||||
}
|
||||
|
||||
// Future<void> businessReviewRatingWindow(
|
||||
// bool previouslyRated, double width) async {
|
||||
// showDialog(
|
||||
// context: context,
|
||||
// builder: (context) => FutureBuilder(
|
||||
// future: getUserReview(),
|
||||
// builder: (context, asyncSnapshot) {
|
||||
// if (asyncSnapshot.connectionState == ConnectionState.waiting) {
|
||||
// return const Mihloadingcircle(
|
||||
// message: "Checking for previous reviews...",
|
||||
// );
|
||||
// } else if (asyncSnapshot.connectionState == ConnectionState.done) {
|
||||
// return MihReviewBusinessWindow(
|
||||
// business: widget.business,
|
||||
// businessReview: asyncSnapshot.data,
|
||||
// screenWidth: width,
|
||||
// readOnly: false,
|
||||
// startUpSearch: widget.startUpSearch,
|
||||
// );
|
||||
// } else {
|
||||
// return MihPackageAlert(
|
||||
// alertColour: MzansiInnovationHub.of(context)!.theme.errorColor(),
|
||||
// alertIcon: Icon(
|
||||
// Icons.warning_rounded,
|
||||
// size: 100,
|
||||
// color: MzansiInnovationHub.of(context)!.theme.errorColor(),
|
||||
// ),
|
||||
// alertTitle: "Error Pulling Data",
|
||||
// alertBody: Column(
|
||||
// children: [
|
||||
// Text(
|
||||
// "Please ensure you are connectede top the internet and you are running the latest version of MIH then try again.",
|
||||
// style: TextStyle(
|
||||
// color: MzansiInnovationHub.of(context)!
|
||||
// .theme
|
||||
// .secondaryColor(),
|
||||
// fontSize: 15,
|
||||
// ),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// );
|
||||
// }
|
||||
// },
|
||||
// ),
|
||||
// );
|
||||
// }
|
||||
|
||||
void showBookmarkAlert() {
|
||||
showDialog(
|
||||
context: context,
|
||||
|
||||
Reference in New Issue
Block a user