Skip to content

Commit 29e8016

Browse files
author
Tautvilas Mecinskas
committed
api: simplify period marking even further
1 parent 436763d commit 29e8016

File tree

4 files changed

+21
-21
lines changed

4 files changed

+21
-21
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -159,10 +159,10 @@ Period marking
159159
<Calendar
160160
// Collection of dates that have to be colored in a special way. Default = {}
161161
markedDates={
162-
{'2012-05-20': {periods: [{textColor: 'green'}]},
163-
'2012-05-22': {periods: [{startingDay: true, color: 'green'}]},
164-
'2012-05-23': {selected: true, periods: [{endingDay: true, color: 'green', textColor: 'gray'}]},
165-
'2012-05-04': {disabled: true, periods: [{startingDay: true, color: 'green'}, {endingDay: true, color: 'green'}]}
162+
{'2012-05-20': {textColor: 'green'},
163+
'2012-05-22': {startingDay: true, color: 'green'},
164+
'2012-05-23': {selected: true, endingDay: true, color: 'green', textColor: 'gray'},
165+
'2012-05-04': {disabled: true, startingDay: true, color: 'green', endingDay: true}
166166
}}
167167
// Date marking style [simple/period/multi-dot]. Default = 'simple'
168168
markingType={'period'}

example/src/screens/agenda.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@ export default class AgendaScreen extends Component {
2525
rowHasChanged={this.rowHasChanged.bind(this)}
2626
// markingType={'period'}
2727
// markedDates={{
28-
// '2017-05-08': {periods: [{textColor: '#666'}]},
29-
// '2017-05-09': {periods: [{textColor: '#666'}]},
30-
// '2017-05-14': {periods: [{startingDay: true, color: 'blue'}, {endingDay: true, color: 'blue'}]},
31-
// '2017-05-21': {periods: [{startingDay: true, color: 'blue'}]},
32-
// '2017-05-22': {periods: [{endingDay: true, color: 'gray'}]},
33-
// '2017-05-24': {periods: [{startingDay: true, color: 'gray'}]},
34-
// '2017-05-25': {periods: [{color: 'gray'}]},
35-
// '2017-05-26': {periods: [{endingDay: true, color: 'gray'}]}}}
28+
// '2017-05-08': {textColor: '#666'},
29+
// '2017-05-09': {textColor: '#666'},
30+
// '2017-05-14': {startingDay: true, endingDay: true, color: 'blue'},
31+
// '2017-05-21': {startingDay: true, color: 'blue'},
32+
// '2017-05-22': {endingDay: true, color: 'gray'},
33+
// '2017-05-24': {startingDay: true, color: 'gray'},
34+
// '2017-05-25': {color: 'gray'},
35+
// '2017-05-26': {endingDay: true, color: 'gray'}}}
3636
// monthFormat={'yyyy'}
3737
// theme={{calendarBackground: 'red', agendaKnobColor: 'green'}}
3838
//renderDay={(day, item) => (<Text>{day ? day.day: 'item'}</Text>)}

example/src/screens/calendars.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,14 @@ export default class CalendarsScreen extends Component {
6565
}}
6666
markedDates={{
6767
'2012-05-17': {disabled: true},
68-
'2012-05-08': {periods: [{textColor: '#666'}]},
69-
'2012-05-09': {periods: [{textColor: '#666'}]},
70-
'2012-05-14': {periods: [{startingDay: true, color: 'blue'}, {endingDay: true, color: 'blue'}]},
71-
'2012-05-21': {periods: [{startingDay: true, color: 'blue'}]},
72-
'2012-05-22': {periods: [{endingDay: true, color: 'gray'}]},
73-
'2012-05-24': {periods: [{startingDay: true, color: 'gray'}]},
74-
'2012-05-25': {periods: [{color: 'gray'}]},
75-
'2012-05-26': {periods: [{endingDay: true, color: 'gray'}]}}}
68+
'2012-05-08': {textColor: '#666'},
69+
'2012-05-09': {textColor: '#666'},
70+
'2012-05-14': {startingDay: true, color: 'blue', endingDay: true},
71+
'2012-05-21': {startingDay: true, color: 'blue'},
72+
'2012-05-22': {endingDay: true, color: 'gray'},
73+
'2012-05-24': {startingDay: true, color: 'gray'},
74+
'2012-05-25': {color: 'gray'},
75+
'2012-05-26': {endingDay: true, color: 'gray'}}}
7676
hideArrows={false}
7777
/>
7878
<Calendar

src/calendar/day/period/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ class Day extends Component {
6363
} else if (this.props.marked.selected) {
6464
defaultStyle.textStyle.color = this.theme.selectedDayTextColor;
6565
}
66-
const resultStyle = (marking.periods || []).reduce((prev, next) => {
66+
const resultStyle = ([marking]).reduce((prev, next) => {
6767
if (next.quickAction) {
6868
if (next.first || next.last) {
6969
prev.containerStyle = this.style.firstQuickAction;

0 commit comments

Comments
 (0)