text: import React, { useMemo } from 'react';
  import { format } from 'date-fns';
  import { DatePickerAndroid } from 'react-native';
  import pt from 'date-fns/locale/pt';
  import Icon from 'react-native-vector-icons/MaterialIcons';
  import { Container, DateButton, DateText } from './styles';
  
  const DateTimeInput = ({ date, onChange }) => {
    const dateFormatted = useMemo(
      () => format(date, "dd 'de' MMMM 'de' yyyy", { locale: pt }),
      [date]
    );
  
    async function handleOpenPicker() {
      const { action, year, month, day } = await DatePickerAndroid.open({
        mode: 'spinner',
        date,
      });
      if (action === DatePickerAndroid.dateSetAction) {
        const selectedDate = new Date(year, month, day);
        onChange(selectedDate);
      }
    }
  
    return (
      <Container>
        <DateButton onPress={handleOpenPicker}>
          <Icon name="event" size={20} color="#fff" />
          <DateText>{dateFormatted}</DateText>
        </DateButton>
      </Container>
    );
  };
  
  export default DateTimeInput;
  