|
|
@ -5,9 +5,9 @@ import DeviceInfo from 'react-native-device-info'; |
|
|
|
import DatePicker from 'react-native-date-picker-x'; |
|
|
|
import locales from '../locales'; |
|
|
|
|
|
|
|
Date.prototype.addHours = function(h) { |
|
|
|
this.setTime(this.getTime() + (h*60*60*1000)); |
|
|
|
return this; |
|
|
|
Date.prototype.addHours = function (h) { |
|
|
|
this.setTime(this.getTime() + (h * 60 * 60 * 1000)); |
|
|
|
return this; |
|
|
|
} |
|
|
|
|
|
|
|
export default class App extends Component { |
|
|
@ -19,8 +19,8 @@ export default class App extends Component { |
|
|
|
} |
|
|
|
|
|
|
|
render() { |
|
|
|
const result = locales.filter(createFilter(this.state.searchTerm)).slice(0, 5); |
|
|
|
|
|
|
|
const result = locales.filter(createFilter(this.state.searchTerm)).slice(0, 5); |
|
|
|
const { backgroundColor } = this.props; |
|
|
|
return ( |
|
|
|
<View style={styles.container}> |
|
|
|
<DatePicker |
|
|
@ -29,12 +29,13 @@ export default class App extends Component { |
|
|
|
locale={this.state.locale} |
|
|
|
minuteInterval={1} |
|
|
|
minimumDate={new Date()} |
|
|
|
maximumDate={(new Date()).addHours(24*5)} |
|
|
|
maximumDate={(new Date()).addHours(24 * 5)} |
|
|
|
style={this.style()} |
|
|
|
/> |
|
|
|
|
|
|
|
<Text>Current locale: {this.state.locale}</Text> |
|
|
|
<Text>Current date: {this.state.chosenDate.toISOString()}</Text> |
|
|
|
<Text></Text> |
|
|
|
<Text /> |
|
|
|
|
|
|
|
<Button title='Change date' |
|
|
|
onPress={() => this.setState({ |
|
|
@ -54,21 +55,25 @@ export default class App extends Component { |
|
|
|
)) |
|
|
|
} |
|
|
|
</ScrollView> |
|
|
|
<Text /> |
|
|
|
|
|
|
|
<Button title={'Change background color'} onPress={() => this.props.setBackground(randomColor())} /> |
|
|
|
</View> |
|
|
|
); |
|
|
|
} |
|
|
|
setDate = (newDate) => this.setState({ chosenDate: newDate }) |
|
|
|
searchUpdated = (term) => this.setState({ searchTerm: term }) |
|
|
|
style = () => this.props.backgroundColor && ({ backgroundColor: this.props.backgroundColor }) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
const randomColor = () => '#' + Math.floor(Math.random() * 16777215).toString(16); |
|
|
|
|
|
|
|
const styles = StyleSheet.create({ |
|
|
|
container: { |
|
|
|
flex: 1, |
|
|
|
alignItems: 'center', |
|
|
|
justifyContent: 'center', |
|
|
|
backgroundColor: 'white', |
|
|
|
marginTop: 15, |
|
|
|
}, |
|
|
|
item: { |
|
|
|