new error messages and add website launch
This commit is contained in:
@@ -8,14 +8,14 @@ class MihBusinessCard extends StatefulWidget {
|
|||||||
final String cellNumber;
|
final String cellNumber;
|
||||||
final String email;
|
final String email;
|
||||||
final String gpsLocation;
|
final String gpsLocation;
|
||||||
final String website;
|
final String? website;
|
||||||
const MihBusinessCard({
|
const MihBusinessCard({
|
||||||
super.key,
|
super.key,
|
||||||
required this.businessName,
|
required this.businessName,
|
||||||
required this.cellNumber,
|
required this.cellNumber,
|
||||||
required this.email,
|
required this.email,
|
||||||
required this.gpsLocation,
|
required this.gpsLocation,
|
||||||
required this.website,
|
this.website,
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -35,15 +35,17 @@ class _MihBusinessCardState extends State<MihBusinessCard> {
|
|||||||
alertIcon: Icon(
|
alertIcon: Icon(
|
||||||
Icons.warning_rounded,
|
Icons.warning_rounded,
|
||||||
size: 100,
|
size: 100,
|
||||||
|
color: MzanziInnovationHub.of(context)!.theme.errorColor(),
|
||||||
),
|
),
|
||||||
alertTitle: "Error Making Call",
|
alertTitle: "Error Making Call",
|
||||||
alertBody: Column(
|
alertBody: Column(
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
"Unable to lauch phone to call ${widget.cellNumber}",
|
"We couldn't open your phone app to call ${widget.cellNumber}. To fix this, make sure you have a phone application installed and it's set as your default dialer.",
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color:
|
color: MzanziInnovationHub.of(context)!
|
||||||
MzanziInnovationHub.of(context)!.theme.errorColor(),
|
.theme
|
||||||
|
.secondaryColor(),
|
||||||
fontSize: 15,
|
fontSize: 15,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -83,15 +85,17 @@ class _MihBusinessCardState extends State<MihBusinessCard> {
|
|||||||
alertIcon: Icon(
|
alertIcon: Icon(
|
||||||
Icons.warning_rounded,
|
Icons.warning_rounded,
|
||||||
size: 100,
|
size: 100,
|
||||||
|
color: MzanziInnovationHub.of(context)!.theme.errorColor(),
|
||||||
),
|
),
|
||||||
alertTitle: "Error Creating Email",
|
alertTitle: "Error Creating Email",
|
||||||
alertBody: Column(
|
alertBody: Column(
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
"Unable to lauch email to ${widget.email}",
|
"We couldn't launch your email app to send a message to ${widget.email}. To fix this, please confirm that you have an email application installed and that it's set as your default.",
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color:
|
color: MzanziInnovationHub.of(context)!
|
||||||
MzanziInnovationHub.of(context)!.theme.errorColor(),
|
.theme
|
||||||
|
.secondaryColor(),
|
||||||
fontSize: 15,
|
fontSize: 15,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -115,8 +119,6 @@ class _MihBusinessCardState extends State<MihBusinessCard> {
|
|||||||
if (await canLaunchUrl(googleMapsUrl)) {
|
if (await canLaunchUrl(googleMapsUrl)) {
|
||||||
await launchUrl(googleMapsUrl);
|
await launchUrl(googleMapsUrl);
|
||||||
} else {
|
} else {
|
||||||
print(
|
|
||||||
'Could not launch Google Maps. Make sure the Google Maps app is installed or an internet connection is available.');
|
|
||||||
showDialog(
|
showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (context) {
|
builder: (context) {
|
||||||
@@ -124,15 +126,17 @@ class _MihBusinessCardState extends State<MihBusinessCard> {
|
|||||||
alertIcon: Icon(
|
alertIcon: Icon(
|
||||||
Icons.warning_rounded,
|
Icons.warning_rounded,
|
||||||
size: 100,
|
size: 100,
|
||||||
|
color: MzanziInnovationHub.of(context)!.theme.errorColor(),
|
||||||
),
|
),
|
||||||
alertTitle: "Error Creating Maps",
|
alertTitle: "Error Creating Maps",
|
||||||
alertBody: Column(
|
alertBody: Column(
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
"Unable to lauch maps to ${widget.businessName}",
|
"There was an issue opening maps for ${widget.businessName}. This usually happens if you don't have a maps app installed or it's not set as your default. Please install one to proceed.",
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color:
|
color: MzanziInnovationHub.of(context)!
|
||||||
MzanziInnovationHub.of(context)!.theme.errorColor(),
|
.theme
|
||||||
|
.secondaryColor(),
|
||||||
fontSize: 15,
|
fontSize: 15,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -151,15 +155,17 @@ class _MihBusinessCardState extends State<MihBusinessCard> {
|
|||||||
alertIcon: Icon(
|
alertIcon: Icon(
|
||||||
Icons.warning_rounded,
|
Icons.warning_rounded,
|
||||||
size: 100,
|
size: 100,
|
||||||
|
color: MzanziInnovationHub.of(context)!.theme.errorColor(),
|
||||||
),
|
),
|
||||||
alertTitle: "Error Creating Maps",
|
alertTitle: "Error Creating Maps",
|
||||||
alertBody: Column(
|
alertBody: Column(
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
"Unable to lauch maps to ${widget.businessName}",
|
"There was an issue opening maps for ${widget.businessName}. This usually happens if you don't have a maps app installed or it's not set as your default. Please install one to proceed.",
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color:
|
color: MzanziInnovationHub.of(context)!
|
||||||
MzanziInnovationHub.of(context)!.theme.errorColor(),
|
.theme
|
||||||
|
.secondaryColor(),
|
||||||
fontSize: 15,
|
fontSize: 15,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -171,66 +177,74 @@ class _MihBusinessCardState extends State<MihBusinessCard> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Future<void> _launchWebsite(String urlString) async {
|
Future<void> _launchWebsite(String urlString) async {
|
||||||
// final Uri url = Uri.parse(urlString);
|
String newUrl = urlString;
|
||||||
// try {
|
if (!newUrl.startsWith("https://")) {
|
||||||
// if (await canLaunchUrl(url)) {
|
newUrl = "https://$urlString";
|
||||||
// await launchUrl(url);
|
}
|
||||||
// } else {
|
final Uri url = Uri.parse(newUrl);
|
||||||
// print('Could not launch $urlString');
|
try {
|
||||||
// showDialog(
|
if (await canLaunchUrl(url)) {
|
||||||
// context: context,
|
await launchUrl(url);
|
||||||
// builder: (context) {
|
} else {
|
||||||
// return MihPackageAlert(
|
print('Could not launch $urlString');
|
||||||
// alertIcon: Icon(
|
showDialog(
|
||||||
// Icons.warning_rounded,
|
context: context,
|
||||||
// size: 100,
|
builder: (context) {
|
||||||
// ),
|
return MihPackageAlert(
|
||||||
// alertTitle: "Error Opening Website",
|
alertIcon: Icon(
|
||||||
// alertBody: Column(
|
Icons.warning_rounded,
|
||||||
// children: [
|
size: 100,
|
||||||
// Text(
|
color: MzanziInnovationHub.of(context)!.theme.errorColor(),
|
||||||
// "Unable to lauch ${widget.businessName}",
|
),
|
||||||
// style: TextStyle(
|
alertTitle: "Error Opening Website",
|
||||||
// color:
|
alertBody: Column(
|
||||||
// MzanziInnovationHub.of(context)!.theme.errorColor(),
|
children: [
|
||||||
// fontSize: 15,
|
Text(
|
||||||
// ),
|
"We couldn't open the link to $newUrl. To view this website, please ensure you have a web browser installed and set as your default.",
|
||||||
// ),
|
style: TextStyle(
|
||||||
// ],
|
color: MzanziInnovationHub.of(context)!
|
||||||
// ),
|
.theme
|
||||||
// alertColour:
|
.secondaryColor(),
|
||||||
// MzanziInnovationHub.of(context)!.theme.errorColor(),
|
fontSize: 15,
|
||||||
// );
|
),
|
||||||
// });
|
),
|
||||||
// }
|
],
|
||||||
// } catch (e) {
|
),
|
||||||
// showDialog(
|
alertColour:
|
||||||
// context: context,
|
MzanziInnovationHub.of(context)!.theme.errorColor(),
|
||||||
// builder: (context) {
|
);
|
||||||
// return MihPackageAlert(
|
});
|
||||||
// alertIcon: Icon(
|
}
|
||||||
// Icons.warning_rounded,
|
} catch (e) {
|
||||||
// size: 100,
|
showDialog(
|
||||||
// ),
|
context: context,
|
||||||
// alertTitle: "Error Opening Website",
|
builder: (context) {
|
||||||
// alertBody: Column(
|
return MihPackageAlert(
|
||||||
// children: [
|
alertIcon: Icon(
|
||||||
// Text(
|
Icons.warning_rounded,
|
||||||
// "Unable to lauch ${widget.businessName}",
|
size: 100,
|
||||||
// style: TextStyle(
|
color: MzanziInnovationHub.of(context)!.theme.errorColor(),
|
||||||
// color:
|
),
|
||||||
// MzanziInnovationHub.of(context)!.theme.errorColor(),
|
alertTitle: "Error Opening Website",
|
||||||
// fontSize: 15,
|
alertBody: Column(
|
||||||
// ),
|
children: [
|
||||||
// ),
|
Text(
|
||||||
// ],
|
"We couldn't open the link to $newUrl. To view this website, please ensure you have a web browser installed and set as your default.",
|
||||||
// ),
|
style: TextStyle(
|
||||||
// alertColour: MzanziInnovationHub.of(context)!.theme.errorColor(),
|
color: MzanziInnovationHub.of(context)!
|
||||||
// );
|
.theme
|
||||||
// });
|
.secondaryColor(),
|
||||||
// }
|
fontSize: 15,
|
||||||
// }
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
alertColour: MzanziInnovationHub.of(context)!.theme.errorColor(),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Widget _buildContactInfo(
|
Widget _buildContactInfo(
|
||||||
String label,
|
String label,
|
||||||
@@ -364,21 +378,24 @@ class _MihBusinessCardState extends State<MihBusinessCard> {
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
// Padding(
|
Visibility(
|
||||||
// padding: const EdgeInsets.symmetric(horizontal: 10.0),
|
visible: widget.website != null,
|
||||||
// child: Divider(
|
child: Padding(
|
||||||
// color: MzanziInnovationHub.of(context)!.theme.primaryColor(),
|
padding: const EdgeInsets.symmetric(horizontal: 10.0),
|
||||||
// ),
|
child: Divider(
|
||||||
// ),
|
color: MzanziInnovationHub.of(context)!.theme.primaryColor(),
|
||||||
// _buildContactInfo(
|
),
|
||||||
// "Website",
|
),
|
||||||
// "Find out more about us.",
|
),
|
||||||
// Icons.vpn_lock,
|
_buildContactInfo(
|
||||||
// const Color(0xffd67d8a),
|
"Website",
|
||||||
// () {
|
"Find out more about us.",
|
||||||
// _launchWebsite(widget.website);
|
Icons.vpn_lock,
|
||||||
// },
|
const Color(0xffd67d8a),
|
||||||
// ),
|
() {
|
||||||
|
_launchWebsite(widget.website!);
|
||||||
|
},
|
||||||
|
),
|
||||||
// Padding(
|
// Padding(
|
||||||
// padding: const EdgeInsets.symmetric(horizontal: 10.0),
|
// padding: const EdgeInsets.symmetric(horizontal: 10.0),
|
||||||
// child: Divider(
|
// child: Divider(
|
||||||
|
|||||||
Reference in New Issue
Block a user