react-native-toggle-calendar
Version:
Horizontal as well as Grid calendar built on top of react-native-calendars
60 lines (54 loc) • 1.98 kB
JavaScript
import React, {Component} from 'react';
import {Text, View} from 'react-native';
import Calendar from '../calendar';
import styleConstructor from './style';
class CalendarListItem extends Component {
static defaultProps = {
hideArrows: true,
hideExtraDays: true,
};
constructor(props) {
super(props);
this.style = styleConstructor(props.theme);
}
shouldComponentUpdate(nextProps) {
const r1 = this.props.item;
const r2 = nextProps.item;
return r1.toString('yyyy MM') !== r2.toString('yyyy MM') || !!(r2.propbump && r2.propbump !== r1.propbump);
}
render() {
const row = this.props.item;
if (row.getTime) {
return (
<Calendar
theme={this.props.theme}
style={[{height: this.props.calendarHeight, width: this.props.calendarWidth}, this.style.calendar]}
current={row}
hideArrows={this.props.hideArrows}
hideExtraDays={this.props.hideExtraDays}
disableMonthChange
markedDates={this.props.markedDates}
markingType={this.props.markingType}
hideDayNames={this.props.hideDayNames}
onDayPress={this.props.onDayPress}
onDayLongPress={this.props.onDayLongPress}
displayLoadingIndicator={this.props.displayLoadingIndicator}
minDate={this.props.minDate}
maxDate={this.props.maxDate}
firstDay={this.props.firstDay}
monthFormat={this.props.monthFormat}
dayComponent={this.props.dayComponent}
disabledByDefault={this.props.disabledByDefault}
showWeekNumbers={this.props.showWeekNumbers}
/>);
} else {
const text = row.toString();
return (
<View style={[{height: this.props.calendarHeight, width: this.props.calendarWidth}, this.style.placeholder]}>
<Text allowFontScaling={false} style={this.style.placeholderText}>{text}</Text>
</View>
);
}
}
}
export default CalendarListItem;