diff --git a/ios/Runner/Info.plist b/ios/Runner/Info.plist index a18c2e54..4c92c6e0 100644 --- a/ios/Runner/Info.plist +++ b/ios/Runner/Info.plist @@ -86,5 +86,6 @@ io.flutter.embedded_views_preview + diff --git a/lib/common_components/custom_card.dart b/lib/common_components/custom_card.dart index 33fd5231..0bc623de 100644 --- a/lib/common_components/custom_card.dart +++ b/lib/common_components/custom_card.dart @@ -44,11 +44,75 @@ class CustomCard extends StatelessWidget { subtitle != null ? GestureDetector( onTap: () async { - if (!isUrl) { - return; - } - SetupRoutes.push(context, Routes.WEB_VIEW, - arguments: {'title': title, 'url': subtitle}); + if (subtitle != null) { + if (title!.contains("Phone")) { + showBottomSheet( + context: context, + builder: (context) { + return Container( + height: 120, + width: MediaQuery.of(context).size.width, + child: Column( + mainAxisAlignment: + MainAxisAlignment.spaceEvenly, + children: [ + const SizedBox(height: 5), + Container( + margin: const EdgeInsets.only(left: 10), + alignment: Alignment.centerLeft, + child: Text( + "Select Action", + style: TextStyle( + fontSize: 18, + ), + ), + ), + const SizedBox( + height: 10, + ), + Row( + children: [ + const SizedBox(width: 5), + IconButton( + onPressed: () async { + await launch("tel:$subtitle") + .catchError((val) { + // Error handling + }); + }, + icon: Icon( + Icons.phone, + size: 30, + color: Colors.green, + )), + const SizedBox(width: 10), + IconButton( + onPressed: () async { + await launch("sms:$subtitle") + .catchError((val) { + // Error handling + }); + }, + icon: Icon( + Icons.message, + size: 30, + color: Colors.lightBlue, + )), + ], + ), + const SizedBox(height: 5), + ], + ), + ); + }); + } else if (title!.contains("Email")) { + await launch("mailto:$subtitle").catchError((val) { + // Error handling + }); + } else { + SetupRoutes.push(context, Routes.WEB_VIEW, + arguments: {'title': title, 'url': subtitle}); + } }, child: HtmlWidget( subtitle!, @@ -68,3 +132,9 @@ class CustomCard extends StatelessWidget { ); } } + +class CallsAndMessagesService { + void call(String number) => launch("tel:$number"); + void sendSms(String number) => launch("sms:$number"); + void sendEmail(String email) => launch("mailto:$email"); +} diff --git a/pubspec.lock b/pubspec.lock index 9e3ab889..c8d87203 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -1216,7 +1216,7 @@ packages: source: hosted version: "0.3.1" url_launcher: - dependency: transitive + dependency: "direct main" description: name: url_launcher url: "https://pub.dartlang.org" diff --git a/pubspec.yaml b/pubspec.yaml index 2d43414c..803ff8c3 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -52,8 +52,11 @@ dependencies: at_follows_flutter: ^3.0.5 at_location_flutter: ^3.1.2 uni_links: ^0.5.1 + + flutter_dotenv: ^5.0.2 + open_mail_app: + url_launcher: - flutter_dotenv: ^5.0.2 dependency_overrides: permission_handler: ^9.2.0