-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add countrypicker component to select countries
- Loading branch information
Showing
7 changed files
with
98 additions
and
7 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
import App from './app/index'; | ||
import {AppRegistry} from 'react-native'; | ||
|
||
export default App; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import React, {Component} from 'react'; | ||
import SimplePicker from 'react-native-simple-picker'; | ||
import {Text, TouchableOpacity, View, Keyboard} from "react-native"; | ||
import {Button, FormInput} from 'react-native-elements' | ||
import Icon from "react-native-elements/src/icons/Icon"; | ||
|
||
class CountryPicker extends Component { | ||
|
||
constructor(props) { | ||
super(props); | ||
this.state = { | ||
selectedOption: '', | ||
}; | ||
} | ||
|
||
state = {country: ""}; | ||
|
||
options = this.props.pickerData.map((item) => item.value); | ||
labels = this.props.pickerData.map((item) => item.name); | ||
|
||
render() { | ||
return ( | ||
<View> | ||
<TouchableOpacity> | ||
<View> | ||
<FormInput | ||
ref={(ref) => { this.selectInput = ref; }} | ||
editable={true} | ||
placeholder={this.props.placeholder} | ||
clearButtonMode="always" | ||
onFocus={() => { | ||
Keyboard.dismiss(); | ||
this.refs.picker.show(); | ||
this.selectInput.blur(); | ||
}} | ||
value={ | ||
this.props.pickerData.find(element => element.value === this.state.selectedOption) ? | ||
this.props.pickerData.find(element => element.value === this.state.selectedOption).name : "" | ||
} | ||
/> | ||
</View> | ||
</TouchableOpacity> | ||
<SimplePicker | ||
ref={'picker'} | ||
options={this.options} | ||
labels={this.labels} | ||
onSubmit={(option) => { | ||
this.setState({ | ||
selectedOption: option, | ||
}); | ||
}} | ||
/> | ||
</View> | ||
) | ||
} | ||
} | ||
|
||
export default CountryPicker |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import React from 'react'; | ||
import {ScrollView, View, Picker} from "react-native"; | ||
import CountryPicker from "../countryPicker/countryPicker"; | ||
|
||
class MainPartComponent extends React.Component { | ||
constructor() { | ||
super(); | ||
} | ||
|
||
countries = [ | ||
{name: "Italien", value: 0}, | ||
{name: "Spanien", value: 1} | ||
]; | ||
|
||
|
||
render() { | ||
return ( | ||
<CountryPicker placeholder={"Land auswählen"} pickerData={this.countries}/> | ||
) | ||
} | ||
} | ||
|
||
|
||
export default MainPartComponent; |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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