diff --git a/index.js b/index.js index 68c440d..865280b 100644 --- a/index.js +++ b/index.js @@ -9,9 +9,13 @@ import { export default class Calendar extends PureComponent { + isSelected = true + static get defaultProps() { return { date: new Date(), + todayDayInnerStyle: styles.todayDayInner, + dayWeekendTextStyle: styles.dayWeekendText, onDateSelect: null, onPrevButtonPress: null, onNextButtonPress: null, @@ -31,6 +35,8 @@ export default class Calendar extends PureComponent { static get propTypes() { return { date: React.PropTypes.object, + todayDayInnerStyle: React.PropTypes.object, + dayWeekendTextStyle: React.PropTypes.object, onDateSelect: React.PropTypes.func, onPrevButtonPress: React.PropTypes.func, onNextButtonPress: React.PropTypes.func, @@ -42,12 +48,14 @@ export default class Calendar extends PureComponent { handleNextButtonPress() { if (this.props.onNextButtonPress !== null) { + this.isSelected = false this.props.onNextButtonPress(); } } handlePrevButtonPress() { if (this.props.onPrevButtonPress !== null) { + this.isSelected = false this.props.onPrevButtonPress(); } } @@ -57,7 +65,7 @@ export default class Calendar extends PureComponent { const month = this.props.date.getMonth(); const year = this.props.date.getFullYear(); const selectedDate = new Date(year, month, dateNumber); - + this.isSelected = true this.props.onDateSelect(selectedDate); } } @@ -126,16 +134,15 @@ export default class Calendar extends PureComponent { const isWeekend = weekDay === 0 || weekDay === 6; const today = new Date(); - const isToday = this.props.date.getDate() === dateNumber && - this.props.date.getMonth() === today.getMonth() && - this.props.date.getFullYear() === today.getFullYear(); + + const isToday = this.props.date.getDate() === dateNumber return ( this.handleDayPress(dateNumber)}> - - - {dateNumber} + + + {`${dateNumber}`} @@ -269,4 +276,4 @@ const styles = StyleSheet.create({ schadedText: { color: "#AAAAAA", } -}); \ No newline at end of file +});