react-native-schedule-week-view
Version:
Week View Calendar for React Native
45 lines (39 loc) • 1.08 kB
JavaScript
import React from 'react';
import { Text, View } from 'react-native';
import PropTypes from 'prop-types';
import { getCurrentMonth, availableNumberOfDays } from '../utils';
import styles from './Title.styles';
const getFontSizeHeader = (numberOfDays) => {
if (numberOfDays > 1) {
return 12;
}
return 16;
};
const Title = ({ style, showTitle, numberOfDays, selectedDate, textStyle }) => {
//console.log(numberOfDays, selectedDate)
return (
<View style={[styles.title, style]}>
{showTitle ? (
<Text
style={[
{
fontSize: getFontSizeHeader(numberOfDays),
textAlign: 'center',
},
textStyle,
]}
>
{getCurrentMonth(selectedDate)}
</Text>
) : null}
</View>
);
};
Title.propTypes = {
showTitle: PropTypes.bool,
numberOfDays: PropTypes.oneOf(availableNumberOfDays).isRequired,
selectedDate: PropTypes.instanceOf(Date).isRequired,
style: PropTypes.object,
textStyle: PropTypes.object,
};
export default React.memo(Title);