loading indicator on business card
This commit is contained in:
@@ -4,7 +4,6 @@ import 'package:mzansi_innovation_hub/mih_components/mih_objects/bookmarked_busi
|
|||||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/business.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_package_components/mih_package_alert.dart';
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_alert.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_pop_up_messages/mih_loading_circle.dart';
|
|
||||||
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_add_bookmark_alert.dart';
|
import 'package:mzansi_innovation_hub/mih_packages/mzansi_profile/business_profile/components/mih_add_bookmark_alert.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_packages/mzansi_profile/business_profile/components/mih_delete_bookmark_alert.dart';
|
import 'package:mzansi_innovation_hub/mih_packages/mzansi_profile/business_profile/components/mih_delete_bookmark_alert.dart';
|
||||||
@@ -17,25 +16,11 @@ import 'package:url_launcher/url_launcher.dart';
|
|||||||
class MihBusinessCard extends StatefulWidget {
|
class MihBusinessCard extends StatefulWidget {
|
||||||
final Business business;
|
final Business business;
|
||||||
final String? startUpSearch;
|
final String? startUpSearch;
|
||||||
// final String businessid;
|
|
||||||
// final String businessName;
|
|
||||||
// final String cellNumber;
|
|
||||||
// final String email;
|
|
||||||
// final String gpsLocation;
|
|
||||||
// final String? website;
|
|
||||||
// final double rating;
|
|
||||||
final double width;
|
final double width;
|
||||||
const MihBusinessCard({
|
const MihBusinessCard({
|
||||||
super.key,
|
super.key,
|
||||||
required this.business,
|
required this.business,
|
||||||
required this.startUpSearch,
|
required this.startUpSearch,
|
||||||
// required this.businessid,
|
|
||||||
// required this.businessName,
|
|
||||||
// required this.cellNumber,
|
|
||||||
// required this.email,
|
|
||||||
// required this.gpsLocation,
|
|
||||||
// required this.rating,
|
|
||||||
// this.website,
|
|
||||||
required this.width,
|
required this.width,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -47,6 +32,13 @@ class _MihBusinessCardState extends State<MihBusinessCard> {
|
|||||||
Future<BusinessReview?>? _businessReviewFuture;
|
Future<BusinessReview?>? _businessReviewFuture;
|
||||||
Future<BookmarkedBusiness?>? _bookmarkedBusinessFuture;
|
Future<BookmarkedBusiness?>? _bookmarkedBusinessFuture;
|
||||||
|
|
||||||
|
RedactedConfiguration getRedactedConfiguration() {
|
||||||
|
return RedactedConfiguration(
|
||||||
|
// redactedColor: Colors.pink,
|
||||||
|
redactedColor: MzansiInnovationHub.of(context)!.theme.primaryColor(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
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)) {
|
||||||
@@ -275,6 +267,7 @@ class _MihBusinessCardState extends State<MihBusinessCard> {
|
|||||||
String subLabel,
|
String subLabel,
|
||||||
IconData icon,
|
IconData icon,
|
||||||
Color? iconColor,
|
Color? iconColor,
|
||||||
|
bool redacted,
|
||||||
Function()? ontap,
|
Function()? ontap,
|
||||||
) {
|
) {
|
||||||
return Material(
|
return Material(
|
||||||
@@ -294,16 +287,25 @@ class _MihBusinessCardState extends State<MihBusinessCard> {
|
|||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
Container(
|
Container(
|
||||||
|
width: 45,
|
||||||
|
height: 45,
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: iconColor,
|
color: iconColor,
|
||||||
borderRadius: BorderRadius.circular(15),
|
borderRadius: BorderRadius.circular(15),
|
||||||
),
|
),
|
||||||
padding: const EdgeInsets.all(5.0),
|
padding: const EdgeInsets.all(5.0),
|
||||||
child: Icon(
|
child: FittedBox(
|
||||||
icon,
|
child: Icon(
|
||||||
size: 35,
|
icon,
|
||||||
color: MzansiInnovationHub.of(context)!.theme.primaryColor(),
|
// size: 35,
|
||||||
|
color:
|
||||||
|
MzansiInnovationHub.of(context)!.theme.primaryColor(),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
|
).redacted(
|
||||||
|
context: context,
|
||||||
|
redact: redacted,
|
||||||
|
configuration: getRedactedConfiguration(),
|
||||||
),
|
),
|
||||||
SizedBox(width: 20),
|
SizedBox(width: 20),
|
||||||
Expanded(
|
Expanded(
|
||||||
@@ -322,6 +324,10 @@ class _MihBusinessCardState extends State<MihBusinessCard> {
|
|||||||
.primaryColor(),
|
.primaryColor(),
|
||||||
height: 1.0,
|
height: 1.0,
|
||||||
),
|
),
|
||||||
|
).redacted(
|
||||||
|
context: context,
|
||||||
|
redact: redacted,
|
||||||
|
configuration: getRedactedConfiguration(),
|
||||||
),
|
),
|
||||||
Text(
|
Text(
|
||||||
subLabel,
|
subLabel,
|
||||||
@@ -332,6 +338,10 @@ class _MihBusinessCardState extends State<MihBusinessCard> {
|
|||||||
.theme
|
.theme
|
||||||
.primaryColor(),
|
.primaryColor(),
|
||||||
),
|
),
|
||||||
|
).redacted(
|
||||||
|
context: context,
|
||||||
|
redact: redacted,
|
||||||
|
configuration: getRedactedConfiguration(),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@@ -396,6 +406,7 @@ class _MihBusinessCardState extends State<MihBusinessCard> {
|
|||||||
"Give us a quick call.",
|
"Give us a quick call.",
|
||||||
Icons.phone,
|
Icons.phone,
|
||||||
MihColors.getGreenColor(context),
|
MihColors.getGreenColor(context),
|
||||||
|
false,
|
||||||
() {
|
() {
|
||||||
// print("Calling ${widget.cellNumber}");
|
// print("Calling ${widget.cellNumber}");
|
||||||
_makePhoneCall(widget.business.contact_no);
|
_makePhoneCall(widget.business.contact_no);
|
||||||
@@ -409,6 +420,7 @@ class _MihBusinessCardState extends State<MihBusinessCard> {
|
|||||||
"Send us an email.",
|
"Send us an email.",
|
||||||
Icons.email,
|
Icons.email,
|
||||||
MihColors.getPinkColor(context),
|
MihColors.getPinkColor(context),
|
||||||
|
false,
|
||||||
() {
|
() {
|
||||||
// print("Emailing ${widget.email}");
|
// print("Emailing ${widget.email}");
|
||||||
_launchEmail(
|
_launchEmail(
|
||||||
@@ -431,6 +443,7 @@ class _MihBusinessCardState extends State<MihBusinessCard> {
|
|||||||
"Come visit us.",
|
"Come visit us.",
|
||||||
Icons.location_on,
|
Icons.location_on,
|
||||||
MihColors.getOrangeColor(context),
|
MihColors.getOrangeColor(context),
|
||||||
|
false,
|
||||||
() {
|
() {
|
||||||
final latitude = double.parse(
|
final latitude = double.parse(
|
||||||
widget.business.gps_location.split(',')[0]);
|
widget.business.gps_location.split(',')[0]);
|
||||||
@@ -459,6 +472,7 @@ class _MihBusinessCardState extends State<MihBusinessCard> {
|
|||||||
"Find out more about us.",
|
"Find out more about us.",
|
||||||
Icons.vpn_lock,
|
Icons.vpn_lock,
|
||||||
MihColors.getRedColor(context),
|
MihColors.getRedColor(context),
|
||||||
|
false,
|
||||||
() {
|
() {
|
||||||
_launchWebsite(widget.business.website);
|
_launchWebsite(widget.business.website);
|
||||||
},
|
},
|
||||||
@@ -470,7 +484,7 @@ class _MihBusinessCardState extends State<MihBusinessCard> {
|
|||||||
future: _businessReviewFuture,
|
future: _businessReviewFuture,
|
||||||
builder: (context, asyncSnapshot) {
|
builder: (context, asyncSnapshot) {
|
||||||
if (asyncSnapshot.connectionState == ConnectionState.waiting) {
|
if (asyncSnapshot.connectionState == ConnectionState.waiting) {
|
||||||
// return SizedBox();
|
// return const SizedBox.shrink();
|
||||||
return Column(
|
return Column(
|
||||||
children: [
|
children: [
|
||||||
Padding(
|
Padding(
|
||||||
@@ -487,10 +501,8 @@ class _MihBusinessCardState extends State<MihBusinessCard> {
|
|||||||
"Loading your rating.",
|
"Loading your rating.",
|
||||||
Icons.star_rate_rounded,
|
Icons.star_rate_rounded,
|
||||||
MihColors.getYellowColor(context),
|
MihColors.getYellowColor(context),
|
||||||
() {
|
true,
|
||||||
// businessReviewRatingWindow(
|
null,
|
||||||
// businessReview, true, widget.width);
|
|
||||||
},
|
|
||||||
),
|
),
|
||||||
).redacted(context: context, redact: true),
|
).redacted(context: context, redact: true),
|
||||||
],
|
],
|
||||||
@@ -518,6 +530,7 @@ class _MihBusinessCardState extends State<MihBusinessCard> {
|
|||||||
"Let us know how we are doing.",
|
"Let us know how we are doing.",
|
||||||
Icons.star_rate_rounded,
|
Icons.star_rate_rounded,
|
||||||
MihColors.getYellowColor(context),
|
MihColors.getYellowColor(context),
|
||||||
|
false,
|
||||||
() {
|
() {
|
||||||
businessReviewRatingWindow(
|
businessReviewRatingWindow(
|
||||||
businessReview, true, widget.width);
|
businessReview, true, widget.width);
|
||||||
@@ -532,7 +545,7 @@ class _MihBusinessCardState extends State<MihBusinessCard> {
|
|||||||
future: _bookmarkedBusinessFuture,
|
future: _bookmarkedBusinessFuture,
|
||||||
builder: (context, asyncSnapshot) {
|
builder: (context, asyncSnapshot) {
|
||||||
if (asyncSnapshot.connectionState == ConnectionState.waiting) {
|
if (asyncSnapshot.connectionState == ConnectionState.waiting) {
|
||||||
// return SizedBox();
|
// return const SizedBox.shrink();
|
||||||
return Column(
|
return Column(
|
||||||
children: [
|
children: [
|
||||||
Padding(
|
Padding(
|
||||||
@@ -549,14 +562,10 @@ class _MihBusinessCardState extends State<MihBusinessCard> {
|
|||||||
"Loading your bookmark.",
|
"Loading your bookmark.",
|
||||||
Icons.bookmark_add_rounded,
|
Icons.bookmark_add_rounded,
|
||||||
MihColors.getBluishPurpleColor(context),
|
MihColors.getBluishPurpleColor(context),
|
||||||
() {
|
true,
|
||||||
// _launchWebsite(widget.website);
|
null,
|
||||||
// print(
|
|
||||||
// "Saving ${widget.business.Name} to Directory");
|
|
||||||
// showBookmarkAlert();
|
|
||||||
},
|
|
||||||
),
|
),
|
||||||
).redacted(context: context, redact: true),
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
@@ -584,6 +593,7 @@ class _MihBusinessCardState extends State<MihBusinessCard> {
|
|||||||
? Icons.bookmark_add_rounded
|
? Icons.bookmark_add_rounded
|
||||||
: Icons.bookmark_remove_rounded,
|
: Icons.bookmark_remove_rounded,
|
||||||
MihColors.getBluishPurpleColor(context),
|
MihColors.getBluishPurpleColor(context),
|
||||||
|
false,
|
||||||
() {
|
() {
|
||||||
// _launchWebsite(widget.website);
|
// _launchWebsite(widget.website);
|
||||||
if (bookmarkBusiness == null) {
|
if (bookmarkBusiness == null) {
|
||||||
@@ -632,46 +642,12 @@ class _MihBusinessCardState extends State<MihBusinessCard> {
|
|||||||
BusinessReview? myReview, bool previouslyRated, double width) async {
|
BusinessReview? myReview, bool previouslyRated, double width) async {
|
||||||
showDialog(
|
showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (context) => FutureBuilder(
|
builder: (context) => MihReviewBusinessWindow(
|
||||||
future: getUserReview(),
|
business: widget.business,
|
||||||
builder: (context, asyncSnapshot) {
|
businessReview: myReview,
|
||||||
if (asyncSnapshot.connectionState == ConnectionState.waiting) {
|
screenWidth: width,
|
||||||
return const Mihloadingcircle(
|
readOnly: false,
|
||||||
message: "Checking for previous reviews...",
|
startUpSearch: widget.startUpSearch,
|
||||||
);
|
|
||||||
} 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,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user