Skip to content

Commit d400aac

Browse files
committed
Update README
Update JS component
1 parent 5250bcd commit d400aac

2 files changed

Lines changed: 68 additions & 21 deletions

File tree

README.md

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -57,20 +57,18 @@ import Calendar from 'react-native-material-calendarview';
5757
style={{alignSelf: 'center'}}
5858
topbarVisible={true}
5959
datesSelection={'single'}
60-
arrowColor="#DAFACD"
6160
firstDayOfWeek="monday"
61+
showOtherDates="none"
6262
currentDate={this.state.today}
63-
selectionColor="#FF3430"
6463
selectedDates={this.state.dates}
65-
weekendsDecorator={true}
6664
eventsDates={["2016/11/20", "2016/11/29"]}
67-
onDateChange={
68-
(data) => {
69-
this.setState({
70-
dates: [data.date]
71-
})
72-
}
73-
}
65+
eventsColor="#9C27B0"
66+
onDateChange={data => {
67+
console.log(data);
68+
}}
69+
onMonthChange={month => {
70+
console.log(month);
71+
}}
7472
/>
7573
)
7674
}
@@ -127,13 +125,23 @@ import Calendar from 'react-native-material-calendarview';
127125
* Set date
128126
- *String* **currentDate** (format 'yyyy/mm/dd')
129127
Set the focus of the calendar.
128+
129+
- *Array[String]* **selectedDates**
130+
Set selected dates to the calendar.
131+
132+
- *Array[String]* **eventsDates**
133+
Set events dates to the calendar.
130134

131135
* Color customizations
132136
- *String* **selectionColor** (format #RRGGBB of #AARRGGBB)
133137
Set the color of the selection circle.
138+
134139
- *String* **weekendsColor** (format #RRGGBB of #AARRGGBB)
135140
Set the color of the weekend.
136141

142+
- *String* **eventsColor** (format #RRGGBB of #AARRGGBB)
143+
Set the color of the events.
144+
137145
## Event
138146

139147
- onDateChange

src/RCTMaterialCalendarView.js

Lines changed: 50 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -54,37 +54,76 @@ var FIRST_DAY_OF_WEEK = [
5454
];
5555

5656
var SHOWING_DATE = [
57-
'default',
58-
'none',
5957
'all',
60-
'decoratedDisabled',
58+
'none'
6159
];
6260

6361
var SELECTION_MODES = [
6462
'none',
65-
'single',
6663
'range',
67-
'multiple',
64+
'single',
65+
'multiple'
6866
];
6967

68+
const colorType = function (props, propName, componentName, ...rest) {
69+
var checker = function () {
70+
var color = props[propName];
71+
var regex = /^#([0-9A-Fa-f]{6}|[0-9A-Fa-f]{8})$/;
72+
if (color && !regex.test(color)) {
73+
return new Error('Only accept color formats: #RRGGBB and #AARRGGBB');
74+
}
75+
};
76+
return PropTypes.string(props, propName, componentName, ...rest) || checker();
77+
};
78+
79+
const ColorValidator = function (props, propName, componentName, ...rest) {
80+
var checker = function () {
81+
var color = props[propName];
82+
var regex = /^#([0-9A-Fa-f]{6}|[0-9A-Fa-f]{8})$/;
83+
if (color && !regex.test(color)) {
84+
return new Error('Color accept formats: #RRGGBB and #AARRGGBB');
85+
}
86+
};
87+
return PropTypes.string(props, propName, componentName, ...rest) || checker();
88+
};
89+
90+
const DatesValidator = function (props, propName, componentName, ...rest) {
91+
console.log('DatesValidator');
92+
var checker = function () {
93+
var date = props[propName];
94+
var regex = /^(19|20)\d\d[/](0[1-9]|1[012])[/](0[1-9]|[12][0-9]|3[01])/;
95+
if (date && !regex.test(date)) {
96+
return new Error('Date should be: YYYY/MM/DD');
97+
}
98+
};
99+
return PropTypes.string(props, propName, componentName, ...rest) || checker();
100+
};
70101

71102
ReactMaterialCalendarView.propTypes = {
72103
...View.propTypes,
73104
width: PropTypes.number.isRequired,
74105
height: PropTypes.number,
106+
// Tile size
75107
tileWidth: PropTypes.number,
76108
tileHeight: PropTypes.number,
77109
tileSize: PropTypes.number,
110+
// Toolbar options
78111
topbarVisible: PropTypes.bool,
79-
arrowColor: PropTypes.string,
112+
arrowColor: ColorValidator,
113+
// Calendar config
80114
firstDayOfWeek: PropTypes.oneOf(FIRST_DAY_OF_WEEK),
81-
minimumDate: PropTypes.string,
82-
maximumDate: PropTypes.string,
115+
minimumDate: DatesValidator,
116+
maximumDate: DatesValidator,
83117
datesSelection: PropTypes.oneOf(SELECTION_MODES),
84118
showOtherDates: PropTypes.oneOf(SHOWING_DATE),
85-
currentDate: PropTypes.string,
86-
onDateChange: PropTypes.func,
87-
onMonthChange: PropTypes.func,
119+
// Set date
120+
currentDate: DatesValidator,
121+
selectedDates: PropTypes.arrayOf(DatesValidator),
122+
eventsDates: PropTypes.arrayOf(DatesValidator),
123+
// Color customizations
124+
selectionColor: ColorValidator,
125+
weekendsColor: ColorValidator,
126+
eventsColor: ColorValidator,
88127
};
89128

90129
ReactMaterialCalendarView.defaultProps = {

0 commit comments

Comments
 (0)