diff --git a/assets/images/facebook.svg b/assets/images/facebook.svg new file mode 100644 index 000000000..d5176eed1 --- /dev/null +++ b/assets/images/facebook.svg @@ -0,0 +1,3 @@ + + + diff --git a/assets/images/instagram.svg b/assets/images/instagram.svg new file mode 100644 index 000000000..bebd00468 --- /dev/null +++ b/assets/images/instagram.svg @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/assets/images/instagram_png.png b/assets/images/instagram_png.png new file mode 100644 index 000000000..59b6ecbc2 Binary files /dev/null and b/assets/images/instagram_png.png differ diff --git a/assets/images/telegram.svg b/assets/images/telegram.svg new file mode 100644 index 000000000..f682bdbfc --- /dev/null +++ b/assets/images/telegram.svg @@ -0,0 +1,3 @@ + + + diff --git a/assets/images/x.svg b/assets/images/x.svg new file mode 100644 index 000000000..99db8184f --- /dev/null +++ b/assets/images/x.svg @@ -0,0 +1,3 @@ + + + diff --git a/lib/account/follow_us.dart b/lib/account/follow_us.dart index 0ccf9606d..1906cdf48 100644 --- a/lib/account/follow_us.dart +++ b/lib/account/follow_us.dart @@ -1,15 +1,22 @@ +import 'package:url_launcher/url_launcher.dart'; + import '../common/common.dart'; -enum _social { +enum _Social { facebook, x, instagram, telegram, } -class FollowUs extends StatelessWidget { - const FollowUs({super.key}); +class FollowUs extends StatefulWidget { + FollowUs({super.key}); + + @override + State createState() => _FollowUsState(); +} +class _FollowUsState extends State { @override Widget build(BuildContext context) { return Padding( @@ -22,28 +29,28 @@ class FollowUs extends StatelessWidget { const SizedBox(height: 5), const CDivider(), ListItemFactory.settingsItem( - icon: ImagePaths.thumbUp, + icon: ImagePaths.telegram, content: 'follow_us_telegram'.i18n, height: 60, - onTap: () => onSocialTap(_social.telegram), + onTap: () => onSocialTap(_Social.telegram), ), ListItemFactory.settingsItem( - icon: ImagePaths.thumbUp, + icon: ImagePaths.x, content: 'follow_us_x'.i18n, height: 60, - onTap: () => onSocialTap(_social.x), + onTap: () => onSocialTap(_Social.x), ), ListItemFactory.settingsItem( - icon: ImagePaths.thumbUp, + icon: ImagePaths.instagram, content: 'follow_us_instagram'.i18n, height: 60, - onTap: () => onSocialTap(_social.instagram), + onTap: () => onSocialTap(_Social.instagram), ), ListItemFactory.settingsItem( - icon: ImagePaths.thumbUp, + icon: ImagePaths.facebook, content: 'follow_us_facebook'.i18n, height: 60, - onTap: () => onSocialTap(_social.facebook), + onTap: () => onSocialTap(_Social.facebook), ), const SizedBox(height: 20), ], @@ -51,16 +58,99 @@ class FollowUs extends StatelessWidget { ); } - void onSocialTap(_social social) { - switch (social) { - case _social.facebook: - // TODO: Handle this case. - case _social.x: - // TODO: Handle this case. - case _social.instagram: - // TODO: Handle this case. - case _social.telegram: - // TODO: Handle this case. + final countryMap = { + //Russia + 'ru': { + _Social.facebook: + 'https://www.facebook.com/profile.php?id=61555417626781', + _Social.x: 'https://twitter.com/Lantern_Russia', + _Social.instagram: 'https://www.instagram.com/lantern.io_ru', + _Social.telegram: 'https://t.me/lantern_russia', + }, + //iran + 'ir': { + _Social.facebook: 'https://www.facebook.com/getlanternpersian', + _Social.x: 'https://twitter.com/getlantern_fa', + _Social.instagram: 'https://www.instagram.com/getlantern_fa/', + _Social.telegram: 'https://t.me/LanternFarsi', + }, + //Ukraine + 'ua': { + _Social.facebook: + 'https://www.facebook.com/profile.php?id=61554740875416', + _Social.x: ' https://twitter.com/LanternUA', + _Social.instagram: 'https://www.instagram.com/getlantern_ua/', + _Social.telegram: ' https://t.me/lanternukraine', + }, + //Belarus + 'by': { + _Social.facebook: + 'https://www.facebook.com/profile.php?id=61554406268221', + _Social.x: 'https://twitter.com/LanternBelarus', + _Social.instagram: 'https://www.instagram.com/getlantern_belarus/', + _Social.telegram: 'https://t.me/lantern_belarus', + }, + //United Arab Emirates + 'uae': { + _Social.facebook: + 'https://www.facebook.com/profile.php?id=61554655199439', + _Social.x: ' https://twitter.com/getlantern_UAE', + _Social.instagram: 'https://www.instagram.com/lanternio_uae/', + _Social.telegram: 'https://t.me/lantern_uae', + }, + //Guinea + 'gn': { + _Social.facebook: + 'https://www.facebook.com/profile.php?id=61554620251833', + _Social.x: 'https://twitter.com/getlantern_gu', + _Social.instagram: 'https://www.instagram.com/lanternio_guinea/', + _Social.telegram: ': https://t.me/LanternGuinea', + }, + 'all': { + _Social.facebook: ' https://www.facebook.com/getlantern', + _Social.x: 'https://twitter.com/getlantern', + _Social.instagram: 'https://www.instagram.com/getlantern/', + _Social.telegram: '', + }, + }; + + void onSocialTap(_Social social) { + //find the country of user + final countryCode = sessionModel.country.value ?? ''; + if (countryCode != '') { + final currentSocialMap = countryMap[countryCode]; + if (currentSocialMap != null) { + // we have fine country in our list + final url = currentSocialMap[social]!; + shareTap( + Uri.parse(url), + ); + } else { + // we don't have country in our list + // use all country + final currentSocialMap = countryMap['all']!; + final url = currentSocialMap[social]!; + shareTap(Uri.parse(url)); + } + } else { + // we don't have country in our list + // use all country + final currentSocialMap = countryMap['all']!; + final url = currentSocialMap[social]!; + shareTap(Uri.parse(url)); + } + } + + Future shareTap(Uri url) async { + context.maybePop(); + if (url.hasEmptyPath) { + showSnackbar( + context: context, + content: + 'We are currently experiencing technical difficulties with retrieving the link. Please try again later.', + duration: const Duration(seconds: 2)); + return; } + await launchUrl(url, mode: LaunchMode.externalApplication); } } diff --git a/lib/common/ui/image_paths.dart b/lib/common/ui/image_paths.dart index 255042755..e040e2327 100644 --- a/lib/common/ui/image_paths.dart +++ b/lib/common/ui/image_paths.dart @@ -38,6 +38,11 @@ class ImagePaths { static const webMoney = 'assets/images/webmoney.svg'; static const bitcoin = 'assets/images/bitcoin.svg'; static const thumbUp = 'assets/images/thumb_up.svg'; + static const facebook = 'assets/images/facebook.svg'; + static const instagram = 'assets/images/instagram.svg'; + static const x = 'assets/images/x.svg'; + static const telegram = 'assets/images/telegram.svg'; + static const instagramPng = 'assets/images/instagram_png.png'; // Messaging static const more_vert = 'assets/images/more_vert.svg'; diff --git a/pubspec.yaml b/pubspec.yaml index 21f23b25a..376b556c5 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -90,7 +90,7 @@ dependencies: hexcolor: ^3.0.1 # URL & Sharing utilities - url_launcher: ^6.1.12 + url_launcher: ^6.2.5 share_plus: ^7.1.0 flutter_inappwebview: ^6.0.0 flutter_windows_webview: