Last active
January 20, 2017 15:39
-
-
Save ssomnoremac/c45135ca3b607533c321863b44fea6f0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import RN from 'react-native'; | |
// http://stackoverflow.com/questions/32947036/how-to-set-font-size-for-different-ios-devices-in-react-native | |
import { getCorrectFontSizeForScreen } from '../services/Design'; | |
const RNText = RN.Text; | |
const Platform = RN.Platform; | |
const FONTS = Platform.OS === 'ios' ? { | |
'light': 'AvenirNext-Light', | |
'regular':'AvenirNext-Regular', | |
'medium': 'AvenirNext-Medium', | |
'bold': 'AvenirNext-Bold', | |
} : { | |
'light': 'AvenirNext_light', | |
'regular':'AvenirNext_regular', | |
'medium': 'AvenirNext_medium', | |
'bold': 'AvenirNext_bold', | |
}; | |
const Text = (props) => { | |
const { | |
type = 'regular', | |
lines = 1, | |
color, | |
style, | |
center, | |
right, | |
transparent, | |
} = props; | |
const textAlign = center ? 'center' : right ? 'right' : null; | |
const fontSize = props.fontSize ? getCorrectFontSizeForScreen(props.fontSize) : getCorrectFontSizeForScreen(12); | |
const backgroundColor = transparent ? 'transparent' : null | |
return( | |
<RNText | |
style={[{fontFamily: FONTS[type], fontSize, textAlign, color, backgroundColor}, style]} | |
numberOfLines={lines} | |
> | |
{props.children} | |
</RNText> | |
); | |
} | |
export default Text; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment