Skip to content
This repository has been archived by the owner on Apr 22, 2024. It is now read-only.

Commit

Permalink
Create getPlatformSpecificIconName helper function
Browse files Browse the repository at this point in the history
  • Loading branch information
CarsonHoffman committed May 18, 2019
1 parent 450d4c3 commit 2906a0c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
17 changes: 6 additions & 11 deletions components/TabNavigator.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import {Platform} from 'react-native';
import { Platform } from 'react-native';
import { createBottomTabNavigator } from 'react-navigation';
import { Ionicons, Entypo } from '@expo/vector-icons';

Expand All @@ -10,43 +10,38 @@ import AnnouncementsScreen from '../screens/Announcements';
import TicketScreen from '../screens/Ticket';

import Config from '../config/config';

// Gets the name of the icon for the specific platform.
// If iOS, returns ios-name, else md-name.
function getPlatformIconName(name) {
return (Platform.OS === 'ios' ? 'ios' : 'md') + '-' + name;
}
import { getPlatformSpecificIconName } from '../utils/Icons';

export default createBottomTabNavigator({
Schedule: {
screen: ScheduleScreen,
navigationOptions: {
tabBarIcon: ({ tintColor }) => (
<Ionicons name={getPlatformIconName('calendar')} color={tintColor} size={Config.TAB_NAVIGATOR_ICON_SIZE} />
<Ionicons name={getPlatformSpecificIconName('calendar')} color={tintColor} size={Config.TAB_NAVIGATOR_ICON_SIZE} />
)
}
},
Map: {
screen: MapScreen,
navigationOptions: {
tabBarIcon: ({ tintColor }) => (
<Ionicons name={getPlatformIconName('pin')} color={tintColor} size={Config.TAB_NAVIGATOR_ICON_SIZE} />
<Ionicons name={getPlatformSpecificIconName('pin')} color={tintColor} size={Config.TAB_NAVIGATOR_ICON_SIZE} />
)
}
},
Countdown: {
screen: CountdownScreen,
navigationOptions: {
tabBarIcon: ({ tintColor }) => (
<Ionicons name={getPlatformIconName('hourglass')} color={tintColor} size={Config.TAB_NAVIGATOR_ICON_SIZE} />
<Ionicons name={getPlatformSpecificIconName('hourglass')} color={tintColor} size={Config.TAB_NAVIGATOR_ICON_SIZE} />
)
}
},
News: {
screen: AnnouncementsScreen,
navigationOptions: {
tabBarIcon: ({ tintColor }) => (
<Ionicons name={getPlatformIconName('notifications')} color={tintColor} size={Config.TAB_NAVIGATOR_ICON_SIZE} />
<Ionicons name={getPlatformSpecificIconName('notifications')} color={tintColor} size={Config.TAB_NAVIGATOR_ICON_SIZE} />
)
}
},
Expand Down
7 changes: 7 additions & 0 deletions utils/Icons.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { Platform } from 'react-native';

// Gets the name of the icon for the specific platform.
// If iOS, returns ios-name, else md-name.
export function getPlatformSpecificIconName(name) {
return (Platform.OS === 'ios' ? 'ios' : 'md') + '-' + name;
}

0 comments on commit 2906a0c

Please sign in to comment.