Last active
June 3, 2017 11:34
-
-
Save siwananda/01df08dcf8e7845af0463654e90fda5b 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, { Component } from "react"; | |
import { View, Platform } from "react-native"; | |
import Icon from 'react-native-vector-icons/Ionicons'; | |
const getTypedIcon = name => { | |
return Platform.OS === "ios" ? `ios-${name}` : `md-${name}`; | |
}; | |
export default class App extends Component { | |
render(){ | |
return ( | |
<View style={{ flex: 1 }}> | |
<Icon name={getTypedIcon("unlock")} /> | |
</View> | |
) | |
} | |
} |
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
Several ways to differentiate platform in react-native |
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, { Component } from "react"; | |
import { View } from "react-native"; | |
import Navigator from "./Navigator"; | |
export default class App extends Component { | |
render(){ | |
return ( | |
<View style={{ flex: 1 }}> | |
<Navigator /> | |
</View> | |
) | |
} | |
} |
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, { Component } from "react"; | |
import { View, Text, Platform, StyleSheet } from "react-native"; | |
export default class App extends Component { | |
render(){ | |
return ( | |
<View style={{ flex: 1 }}> | |
<Text style={[style.platformBasedText]}> | |
I am different | |
</Text> | |
</View> | |
) | |
} | |
} | |
const style = StyleSheet.create( | |
{ | |
platformBasedText: { | |
...Platform.select({ | |
ios: { | |
color: "blue", | |
}, | |
android: { | |
color: "red", | |
}, | |
}) | |
} | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment