UNPKG

react-native-easy-calendar

Version:

Customizable, easy-to-use, performant calendar components for React Native

42 lines (36 loc) 1.12 kB
import React from 'react'; import dayjs from 'dayjs'; import utc from 'dayjs/plugin/utc'; import { Text, TouchableOpacity } from 'react-native'; import { VIEW } from '../Constants'; import { ThemeContext } from '../Contexts'; dayjs.extend(utc); const Title = ({ activeView, date, onPress, isDisabled, locale }) => { const theme = React.useContext(ThemeContext); const _date = dayjs(date).locale(locale).local(); const title = activeView === VIEW.MONTH ? _date.format('MMMM YYYY') : _date.format('YYYY'); const _onPress = React.useCallback(() => onPress(date), [date, onPress]); return /*#__PURE__*/React.createElement(TouchableOpacity, { testID: 'title', accessibilityRole: 'button', accessibilityHint: 'Press to switch calendar views', accessibilityLabel: title, accessibilityState: { disabled: isDisabled }, style: theme.titleContainer, disabled: isDisabled, onPress: _onPress }, /*#__PURE__*/React.createElement(Text, { testID: 'title-text', style: theme.titleText }, title)); }; export default Title; //# sourceMappingURL=Title.js.map