/**
 * React Native Full App (https://store.enappd.com/product/react-native-full-app)
 *
 * Copyright © 2019-present Enappd. All rights reserved.
 *
 * This source code is licensed as per the terms found in the
 * LICENSE.md file in the root directory of this source tree.
 */
import React, { Component } from 'react';
import { DatePickerIOS, View, StyleSheet, Text } from 'react-native';
import { Container } from 'native-base';
import HeaderCommon from '../../components/common/header';
import { NavigationDrawerScreenProps } from 'react-navigation-drawer';
interface Iprops extends NavigationDrawerScreenProps {
}
export default class IOSDateTimePickerExample extends Component<Iprops> {
  state = {
    chosenDate: new Date()
  }
  constructor(props) {
    super(props);
    this.state = { chosenDate: new Date() };

    this.setDate = this.setDate.bind(this);
  }

  setDate(newDate) {
    this.setState({ chosenDate: newDate });
  }
  toggleMenu = () => this.props.navigation.toggleDrawer();

  render() {
    const { chosenDate } = this.state;
    return (
      <Container>
        <Text>{chosenDate}</Text>
        <HeaderCommon title='IOS Time Picker' toggleMenu={this.toggleMenu} />
        <View style={styles.container}>
          <DatePickerIOS
            date={this.state.chosenDate}
            onDateChange={this.setDate}
          />
        </View>
      </Container>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
  },
});