daily pastebin goal
34%
SHARE
TWEET

Untitled

a guest Feb 23rd, 2019 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import React from "react";
  2. import MaterialCommunityIcon from "react-native-vector-icons/MaterialCommunityIcons";
  3. import { NavigationRouteId } from "../NavigationRouteId";
  4. import {
  5.   NavigationScreenConfigProps,
  6.   NavigationTabScreenOptions
  7. } from "react-navigation";
  8. import NavigationService from "../NavigationService";
  9.  
  10. export const getIconForRouteName = (routeName: string, focused: boolean) => {
  11.   const tabIconSize = 32;
  12.   const iconColor = "#000000";
  13.  
  14.   let iconName = "help";
  15.  
  16.   switch (routeName) {
  17.     case NavigationRouteId.BottomTabHome:
  18.       iconName = focused ? "home" : "home-outline";
  19.       break;
  20.     case NavigationRouteId.BottomTabExplore:
  21.       iconName = "magnify";
  22.       break;
  23.     case NavigationRouteId.BottomTabCreate:
  24.       iconName = focused ? "plus-box" : "plus-box-outline";
  25.       break;
  26.     case NavigationRouteId.BottomTabLike:
  27.       iconName = focused ? "heart" : "heart-outline";
  28.       break;
  29.     case NavigationRouteId.BottomTabAccount:
  30.       iconName = focused ? "account" : "account-outline";
  31.     default:
  32.       return null;
  33.   }
  34.  
  35.   return (
  36.     <MaterialCommunityIcon
  37.       name={iconName}
  38.       color={iconColor}
  39.       size={tabIconSize}
  40.     />
  41.   );
  42. };
  43.  
  44. export const bottomTabNavigationOptions = ({
  45.   navigation
  46. }: NavigationScreenConfigProps): NavigationTabScreenOptions => {
  47.   return {
  48.     tabBarOnPress: () => {
  49.       const isLoggedIn = true;
  50.  
  51.       if (!isLoggedIn) {
  52.         return NavigationService.navigate(NavigationRouteId.AuthStackRegister);
  53.       }
  54.  
  55.       return NavigationService.navigate(navigation.state.routeName);
  56.     }
  57.   };
  58. };
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top