4
4
*/
5
5
'use strict' ;
6
6
7
- import React , { Component } from 'react' ;
7
+ import React from 'react' ;
8
8
import {
9
9
Dimensions ,
10
10
StyleSheet ,
11
11
View ,
12
12
Text ,
13
- TouchableOpacity ,
13
+ TouchableOpacity
14
14
} from 'react-native' ;
15
15
16
16
var {
17
17
WEEKDAYS ,
18
18
MONTHS ,
19
19
MAX_ROWS ,
20
20
MAX_COLUMNS ,
21
- getDaysInMonth,
21
+ getDaysInMonth
22
22
} = require ( './Util' ) ;
23
23
24
24
var makeStyles = require ( './makeStyles' ) ;
25
25
26
26
//The styles in makeStyles are intially scaled to this width
27
- const IPHONE6_WIDTH = 375
27
+ const IPHONE6_WIDTH = 375 ;
28
28
var initialScale = Dimensions . get ( 'window' ) . width / IPHONE6_WIDTH ;
29
- var styles = StyleSheet . create ( makeStyles ( initialScale ) )
29
+ var styles = StyleSheet . create ( makeStyles ( initialScale ) ) ;
30
30
31
31
var Day = React . createClass ( {
32
32
propTypes : {
33
33
onDayChange : React . PropTypes . func ,
34
34
selected : React . PropTypes . bool ,
35
35
day : React . PropTypes . oneOfType ( [
36
- React . PropTypes . number ,
37
- React . PropTypes . string
36
+ React . PropTypes . number ,
37
+ React . PropTypes . string
38
38
] ) . isRequired ,
39
39
screenWidth : React . PropTypes . number ,
40
40
startFromMonday : React . PropTypes . bool ,
41
41
selectedDayColor : React . PropTypes . string ,
42
- selectedDayTextColor : React . PropTypes . string ,
42
+ selectedDayTextColor : React . PropTypes . string
43
43
} ,
44
44
getDefaultProps ( ) {
45
45
return {
46
46
onDayChange ( ) { }
47
- }
47
+ } ;
48
48
} ,
49
49
50
50
getInitialState ( ) {
@@ -56,8 +56,8 @@ var Day = React.createClass({
56
56
57
57
render ( ) {
58
58
if ( this . props . selected ) {
59
- var selectedDayColorStyle = this . props . selectedDayColor ? { backgroundColor : this . props . selectedDayColor } : { }
60
- var selectedDayTextColorStyle = this . props . selectedDayTextColor ? { color : this . props . selectedDayTextColor } : { }
59
+ var selectedDayColorStyle = this . props . selectedDayColor ? { backgroundColor : this . props . selectedDayColor } : { } ;
60
+ var selectedDayTextColorStyle = this . props . selectedDayTextColor ? { color : this . props . selectedDayTextColor } : { } ;
61
61
return (
62
62
< View style = { styles . dayWrapper } >
63
63
< View style = { [ styles . dayButtonSelected , selectedDayColorStyle ] } >
@@ -94,11 +94,11 @@ var Days = React.createClass({
94
94
year : React . PropTypes . number . isRequired ,
95
95
onDayChange : React . PropTypes . func . isRequired ,
96
96
selectedDayColor : React . PropTypes . string ,
97
- selectedDayTextColor : React . PropTypes . string ,
97
+ selectedDayTextColor : React . PropTypes . string
98
98
} ,
99
99
getInitialState ( ) {
100
100
return {
101
- selectedStates : [ ] ,
101
+ selectedStates : [ ]
102
102
} ;
103
103
} ,
104
104
@@ -120,7 +120,7 @@ var Days = React.createClass({
120
120
}
121
121
122
122
this . setState ( {
123
- selectedStates : selectedStates ,
123
+ selectedStates : selectedStates
124
124
} ) ;
125
125
126
126
} ,
@@ -143,8 +143,7 @@ var Days = React.createClass({
143
143
year = this . props . year ,
144
144
currentDay = 0 ,
145
145
thisMonthFirstDay = this . props . startFromMonday ? new Date ( year , month , 0 ) : new Date ( year , month , 1 ) ,
146
- slotsAccumulator = 0 ,
147
- slotsAccumulatorOffset = this . props . startFromMonday ? 1 : 0 ;
146
+ slotsAccumulator = 0 ;
148
147
149
148
for ( i = 0 ; i < MAX_ROWS ; i ++ ) { // Week rows
150
149
columns = [ ] ;
@@ -164,7 +163,7 @@ var Days = React.createClass({
164
163
currentDay ++ ;
165
164
}
166
165
} else {
167
- columns . push ( < Day
166
+ columns . push ( < Day
168
167
key = { j }
169
168
day = { '' }
170
169
screenWidth = { this . props . screenWidth } /> ) ;
@@ -196,7 +195,7 @@ var WeekDaysLabels = React.createClass({
196
195
render ( ) {
197
196
return (
198
197
< View style = { styles . dayLabelsWrapper } >
199
- { ( this . props . weekdays || WEEKDAYS ) . map ( ( day , key ) => { return < Text key = { key } style = { styles . dayLabels } > { day } </ Text > } ) }
198
+ { ( this . props . weekdays || WEEKDAYS ) . map ( ( day , key ) => { return < Text key = { key } style = { styles . dayLabels } > { day } </ Text > ; } ) }
200
199
</ View >
201
200
) ;
202
201
}
@@ -279,43 +278,43 @@ var CalendarPicker = React.createClass({
279
278
nextTitle : React . PropTypes . string ,
280
279
selectedDayColor : React . PropTypes . string ,
281
280
selectedDayTextColor : React . PropTypes . string ,
282
- scaleFactor : React . PropTypes . number ,
281
+ scaleFactor : React . PropTypes . number
283
282
} ,
284
283
getDefaultProps ( ) {
285
284
return {
286
285
onDateChange ( ) { }
287
- }
286
+ } ;
288
287
} ,
289
288
getInitialState ( ) {
290
289
if ( this . props . scaleFactor !== undefined ) {
291
- styles = StyleSheet . create ( makeStyles ( this . props . scaleFactor ) )
290
+ styles = StyleSheet . create ( makeStyles ( this . props . scaleFactor ) ) ;
292
291
}
293
292
return {
294
293
date : this . props . selectedDate ,
295
294
day : this . props . selectedDate . getDate ( ) ,
296
295
month : this . props . selectedDate . getMonth ( ) ,
297
296
year : this . props . selectedDate . getFullYear ( ) ,
298
- selectedDay : [ ] ,
297
+ selectedDay : [ ]
299
298
} ;
300
299
} ,
301
300
302
301
onDayChange ( day ) {
303
- this . setState ( { day : day . day , } ) ;
302
+ this . setState ( { day : day . day } ) ;
304
303
this . onDateChange ( ) ;
305
304
} ,
306
305
307
306
onMonthChange ( month ) {
308
- this . setState ( { month : month , } ) ;
307
+ this . setState ( { month : month } ) ;
309
308
this . onDateChange ( ) ;
310
309
} ,
311
310
312
311
getNextYear ( ) {
313
- this . setState ( { year : this . state . year + 1 , } ) ;
312
+ this . setState ( { year : this . state . year + 1 } ) ;
314
313
this . onDateChange ( ) ;
315
314
} ,
316
315
317
316
getPrevYear ( ) {
318
- this . setState ( { year : this . state . year - 1 , } ) ;
317
+ this . setState ( { year : this . state . year - 1 } ) ;
319
318
this . onDateChange ( ) ;
320
319
} ,
321
320
@@ -327,8 +326,8 @@ var CalendarPicker = React.createClass({
327
326
} = this . state ,
328
327
date = new Date ( year , month , day ) ;
329
328
330
- this . setState ( { date : date , } ) ;
331
- this . props . onDateChange ( date ) ;
329
+ this . setState ( { date : date } ) ;
330
+ this . props . onDateChange ( date ) ;
332
331
} ,
333
332
334
333
render ( ) {
@@ -364,4 +363,4 @@ var CalendarPicker = React.createClass({
364
363
}
365
364
} ) ;
366
365
367
- module . exports = CalendarPicker ;
366
+ module . exports = CalendarPicker ;
0 commit comments