Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set option to show filler days #170

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions components/Calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export default class Calendar extends Component {
selectedDate: PropTypes.any,
showControls: PropTypes.bool,
showEventIndicators: PropTypes.bool,
showFillerDays: PropTypes.bool,
startDate: PropTypes.any,
titleFormat: PropTypes.string,
today: PropTypes.any,
Expand All @@ -76,6 +77,7 @@ export default class Calendar extends Component {
scrollEnabled: false,
showControls: false,
showEventIndicators: false,
showFillerDays: false,
startDate: moment().format('YYYY-MM-DD'),
titleFormat: 'MMMM YYYY',
weekStart: 1,
Expand Down Expand Up @@ -279,6 +281,9 @@ export default class Calendar extends Component {
key: renderIndex,
filler: true,
customStyle: this.props.customStyle,
caption: thisMoment.format('D'),
showFillerDays: this.props.showFillerDays,
showEventIndicators: this.props.showEventIndicators,
})
);
}
Expand Down
13 changes: 12 additions & 1 deletion components/Day.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export default class Day extends Component {
onPress: PropTypes.func,
onLongPress: PropTypes.func,
showEventIndicators: PropTypes.bool,
showFillerDays: PropTypes.bool,
}

dayCircleStyle = (isWeekend, isSelected, isToday, event) => {
Expand Down Expand Up @@ -90,6 +91,7 @@ export default class Day extends Component {
let { caption, customStyle } = this.props;
const {
filler,
showFillerDays,
event,
isWeekend,
isSelected,
Expand All @@ -105,11 +107,20 @@ export default class Day extends Component {
dayButtonFillerStyle = [styles.dayButtonFiller, customStyle.dayButtonFiller, {width: dayWidth}];
}

if (showFillerDays) {
dayButtonFillerStyle.unshift(styles.dayButton);
}

return filler
? (
<TouchableWithoutFeedback>
<View style={dayButtonFillerStyle}>
<Text style={[styles.day, customStyle.day]} />
{showFillerDays &&
<Text style={[styles.day, styles.fillerDay, customStyle.fillerDay]}>
{caption}
</Text>
}
{showEventIndicators && <View style={styles.eventIndicatorFiller}/>}
</View>
</TouchableWithoutFeedback>
)
Expand Down
3 changes: 3 additions & 0 deletions components/styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ const styles = StyleSheet.create({
fontSize: 16,
alignSelf: 'center',
},
fillerDay: {
color: '#cccccc',
},
eventIndicatorFiller: {
marginTop: 3,
borderColor: 'transparent',
Expand Down
3 changes: 2 additions & 1 deletion example/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class App extends Component {
<View style={styles.container}>
<Calendar
ref="calendar"
showFillerDays
eventDates={eventDates}
scrollEnabled
showControls
Expand All @@ -71,7 +72,7 @@ class App extends Component {
onSwipePrev={(e) => console.log('onSwipePrev: ', e)}
onSwipeNext={(e) => console.log('onSwipeNext', e)}
selectedDate={this.state.selectedDate}
showEventIndicators={true}
showEventIndicators
/>
<Text>Selected Date: {moment(this.state.selectedDate).format('MMMM DD YYYY')}</Text>
</View>
Expand Down