diff --git a/Datepick.js b/Datepick.js index 02926a2..023f975 100644 --- a/Datepick.js +++ b/Datepick.js @@ -3,18 +3,24 @@ import { Text, TouchableOpacity, View } from 'react-native'; import DateTimePicker from 'react-native-modal-datetime-picker'; export default class DateTimePickerTester extends Component { - state = { - isDateTimePickerVisible: false, - date: '' - }; + constructor(props) { + super(props); + this.state = { + isDateTimePickerVisible: false, + date: '' + }; + } + _showDateTimePicker = () => this.setState({ isDateTimePickerVisible: true }); _hideDateTimePicker = () => this.setState({ isDateTimePickerVisible: false }); _handleDatePicked = (date) => { - console.log('A date has been picked: ', date); + date = date.toString(); + date = date.substring(0, date.length-18); this.setState({date: {date}}) + this.props.onChange(date); this._hideDateTimePicker(); }; diff --git a/Popup.js b/Popup.js index 60c4a09..276b1da 100644 --- a/Popup.js +++ b/Popup.js @@ -6,24 +6,22 @@ class Popup extends React.Component{ state = { name: '', details: '', - lat: 0.0, - long: 0.0, + eventStartDate: 'Choose Event Start Time', + eventEndDate: 'Choose Event End Time', } - show(lat, long) { + show(long, lat) { this.popupDialog.show(); - this.setState({lat: {lat}}) - this.setState({long: {long}}) } sendInformation() { console.log('hi') console.log(this.state.name) console.log(this.state.details) console.log(this._startDateTimePicker.state.date) - console.log(this._endDateTimePicker.state.date) - console.log(this.state.long) - console.log(this.state.lat) - this.popupDialog.close() } + + setStartDate = (date) => this.setState({eventStartDate: date}); + setEndDate = (date) => this.setState({eventEndDate: date}); + render() { return ( this.setState({name})} ref = {(textInput) => {this.textInput = textInput; }} /> - {this._startDateTimePicker = startDateTimePicker;}}/> + {this._startDateTimePicker = startDateTimePicker;}} + onChange={this.setStartDate}/>