handleNavigationItemTap method

void handleNavigationItemTap(
  1. BuildContext context,
  2. FastItem<T> item
)

Implementation

void handleNavigationItemTap(BuildContext context, FastItem<T> item) {
  if (onNavigationItemTap != null) {
    onNavigationItemTap!(context, item);
  } else if (item.value != null && item.value is String) {
    final value = item.value as String;

    if (value.startsWith('action://')) {
      final action = value.replaceFirst('action://', '');
      final appInfoBloc = FastAppInfoBloc.instance;
      final appInfo = appInfoBloc.currentState;

      switch (action) {
        case 'contact-us':
          if (appInfo.supportEmail != null) {
            FastMessenger.writeEmail(
              appInfo.supportEmail!,
              subject: appInfo.appName,
            );
          }
        case 'bug-report':
          if (appInfo.bugReportEmail != null) {
            FastMessenger.writeErrorEmail(
              appInfo.bugReportEmail!,
              subject: appInfo.appName,
            );
          }
        case 'rate-us':
          final rateService = FastAppRatingService(appInfo.toDocument());
          rateService.showAppRatingDialog(context);
        case 'share':
          FastShare.shareApp(context);
        case 'site':
          if (appInfo.homepageUrl != null) {
            FastMessenger.launchUrl(appInfo.homepageUrl!);
          }
        case 'facebook':
          if (appInfo.facebookUrl != null) {
            FastMessenger.launchUrl(
              appInfo.facebookUrl!,
              mode: LaunchMode.externalApplication,
            );
          }
        case 'twitter':
          if (appInfo.twitterUrl != null) {
            FastMessenger.launchUrl(
              appInfo.twitterUrl!,
              mode: LaunchMode.externalApplication,
            );
          }
        case 'instagram':
          if (appInfo.instagramUrl != null) {
            FastMessenger.launchUrl(
              appInfo.instagramUrl!,
              mode: LaunchMode.externalApplication,
            );
          }

        default:
          debugPrint('Unknown action: $action');
          break;
      }
    } else {
      GoRouter.of(context).push(value);
    }
  }
}