Created
September 18, 2017 13:10
-
-
Save renso3x/797da53324fee0bee23806ed2175974a to your computer and use it in GitHub Desktop.
This file contains hidden or 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 { View, Platform, PickerIOS, Text } from 'react-native'; | |
| import PickerAndroid from 'react-native-picker-android'; | |
| import styles from './styles/LanguagePickerStyles'; | |
| let PickerList = Platform.OS === 'ios' ? PickerIOS : PickerAndroid; | |
| let PickerItem = PickerList.Item; | |
| const LANGUAGES = [ | |
| { name: 'Chinese(Mandarin)', key: 'cn' }, | |
| { name: 'Dutch', key: 'du' }, | |
| { name: 'English', key: 'en' }, | |
| { name: 'French', key: 'fr'}, | |
| { name: 'German', key: 'gr' } | |
| ]; | |
| const LanguagePicker = ({ | |
| language, | |
| selectedLanguage | |
| }) => | |
| <View> | |
| <PickerList | |
| selectedValue={'en'} | |
| itemStyle={{ | |
| fontSize: 25, | |
| color: '#fff', | |
| fontWeight: 'bold', | |
| backgroundColor: 'red', | |
| borderColor: 'blue', | |
| borderWidth: 2, | |
| }} | |
| onValueChange={(key) => console.log(key)}> | |
| { | |
| LANGUAGES.map((langLabel, index) => ( | |
| <PickerItem | |
| key={index} | |
| value={langLabel.key} | |
| label={langLabel.name} | |
| /> | |
| )) | |
| } | |
| </PickerList> | |
| </View> | |
| export default LanguagePicker; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment