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_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_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_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_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_alert_services.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_services/mih_location_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_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_time_field.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_toggle.dart';
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_toggle.dart';
|
||||||
|
import 'package:redacted/redacted.dart';
|
||||||
|
|
||||||
class PackageToolOne extends StatefulWidget {
|
class PackageToolOne extends StatefulWidget {
|
||||||
final AppUser user;
|
final AppUser user;
|
||||||
@@ -291,16 +293,34 @@ class _PackageToolOneState extends State<PackageToolOne> {
|
|||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
const SizedBox(height: 10),
|
const SizedBox(height: 10),
|
||||||
// MihBusinessCard(
|
Text("This text should be redacted").redacted(
|
||||||
// businessid: "123456",
|
context: context,
|
||||||
// businessName: "Mzansi Innovation Hub",
|
redact: true,
|
||||||
// cellNumber: "0788300006",
|
),
|
||||||
// email: "yasien.meth@mzansi-innovation-hub.co.za",
|
MihBusinessCard(
|
||||||
// gpsLocation: "-26.1853611, 28.134664",
|
business: Business(
|
||||||
// website:
|
"business_id",
|
||||||
// "https://app.mzansi-innovation-hub.co.za/privacy.html",
|
"Name",
|
||||||
// rating: 3.25,
|
"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),
|
const SizedBox(height: 10),
|
||||||
Divider(
|
Divider(
|
||||||
color:
|
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_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_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';
|
||||||
|
import 'package:redacted/redacted.dart';
|
||||||
import 'package:supertokens_flutter/supertokens.dart';
|
import 'package:supertokens_flutter/supertokens.dart';
|
||||||
import 'package:url_launcher/url_launcher.dart';
|
import 'package:url_launcher/url_launcher.dart';
|
||||||
|
|
||||||
@@ -41,6 +42,7 @@ class MihBusinessCard extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _MihBusinessCardState extends State<MihBusinessCard> {
|
class _MihBusinessCardState extends State<MihBusinessCard> {
|
||||||
|
Future<BusinessReview?>? _businessReviewFuture;
|
||||||
Future<void> _makePhoneCall(String phoneNumber) async {
|
Future<void> _makePhoneCall(String phoneNumber) async {
|
||||||
final Uri url = Uri(scheme: 'tel', path: phoneNumber);
|
final Uri url = Uri(scheme: 'tel', path: phoneNumber);
|
||||||
if (await canLaunchUrl(url)) {
|
if (await canLaunchUrl(url)) {
|
||||||
@@ -345,6 +347,12 @@ class _MihBusinessCardState extends State<MihBusinessCard> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
_businessReviewFuture = getUserReview();
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
// double screenWidth = MediaQuery.of(context).size.width;
|
// 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(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 10.0),
|
padding: const EdgeInsets.symmetric(horizontal: 10.0),
|
||||||
child: Divider(
|
child: Divider(
|
||||||
@@ -437,31 +507,16 @@ class _MihBusinessCardState extends State<MihBusinessCard> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
_buildContactInfo(
|
_buildContactInfo(
|
||||||
"Rate Us",
|
"Bookmark",
|
||||||
"Let us know how we are doing.",
|
"Save us for later.",
|
||||||
Icons.star_rate_rounded,
|
Icons.bookmark_add_rounded,
|
||||||
MihColors.getYellowColor(context),
|
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),
|
const SizedBox(height: 10),
|
||||||
// Padding(
|
// Padding(
|
||||||
// padding: const EdgeInsets.symmetric(horizontal: 10.0),
|
// padding: const EdgeInsets.symmetric(horizontal: 10.0),
|
||||||
@@ -476,7 +531,7 @@ class _MihBusinessCardState extends State<MihBusinessCard> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> businessReviewRatingWindow(
|
Future<void> businessReviewRatingWindow(
|
||||||
bool previouslyRated, double width) async {
|
BusinessReview? myReview, bool previouslyRated, double width) async {
|
||||||
showDialog(
|
showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (context) => FutureBuilder(
|
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() {
|
void showBookmarkAlert() {
|
||||||
showDialog(
|
showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
|
|||||||
Reference in New Issue
Block a user