Skip to content

Commit 902938b

Browse files
author
Tautvilas Mecinskas
committed
extend api for disabling dates in basic marking
1 parent 6a4022f commit 902938b

File tree

3 files changed

+9
-10
lines changed

3 files changed

+9
-10
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,8 @@ Dot marking
120120
markedDates={{
121121
'2012-05-16': {selected: true, marked: true},
122122
'2012-05-17': {marked: true},
123-
'2012-05-18': {marked: true, dotColor: 'red'},
124-
'2012-05-19': {disabled: true}
123+
'2012-05-18': {marked: true, dotColor: 'red', activeOpacity: 0},
124+
'2012-05-19': {disabled: true, disableTouchEvent: true}
125125
}}
126126
/>
127127
```

example/src/screens/calendars.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export default class CalendarsScreen extends Component {
2222
onDayPress={this.onDayPress}
2323
style={styles.calendar}
2424
hideExtraDays
25-
markedDates={{[this.state.selected]: {selected: true}}}
25+
markedDates={{[this.state.selected]: {selected: true, disableTouchEvent: true}}}
2626
/>
2727
<Text style={styles.text}>Calendar with marked dates and hidden arrows</Text>
2828
<Calendar
@@ -36,7 +36,7 @@ export default class CalendarsScreen extends Component {
3636
'2012-05-24': {selected: true, marked: true, dotColor: 'green'},
3737
'2012-05-25': {marked: true, dotColor: 'red'},
3838
'2012-05-26': {marked: true},
39-
'2012-05-27': {disabled: true}
39+
'2012-05-27': {disabled: true, activeOpacity: 0}
4040
}}
4141
// disabledByDefault={true}
4242
hideArrows={true}

src/calendar/day/basic/index.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ class Day extends Component {
6969
marking: true
7070
};
7171
}
72+
const isDisabled = typeof marking.disabled !== 'undefined' ? marking.disabled : this.props.state === 'disabled';
7273
let dot;
7374
if (marking.marked) {
7475
dotStyle.push(this.style.visibleDot);
@@ -82,20 +83,18 @@ class Day extends Component {
8283
containerStyle.push(this.style.selected);
8384
dotStyle.push(this.style.selectedDot);
8485
textStyle.push(this.style.selectedText);
85-
} else if (typeof marking.disabled !== 'undefined' ? marking.disabled : this.props.state === 'disabled') {
86+
} else if (isDisabled) {
8687
textStyle.push(this.style.disabledText);
8788
} else if (this.props.state === 'today') {
8889
textStyle.push(this.style.todayText);
8990
}
91+
9092
return (
9193
<TouchableOpacity
9294
style={containerStyle}
9395
onPress={this.onDayPress}
94-
disabled={
95-
typeof marking.disabled !== 'undefined'
96-
? marking.disabled
97-
: this.props.state === 'disabled'
98-
}
96+
activeOpacity={marking.activeOpacity}
97+
disabled={marking.disableTouchEvent}
9998
>
10099
<Text allowFontScaling={false} style={textStyle}>{String(this.props.children)}</Text>
101100
{dot}

0 commit comments

Comments
 (0)