@@ -48,79 +48,79 @@ class Calendar extends Component {
4848 return ;
4949 }
5050 this . setState ( {
51- currentMonth : day . clone ( )
52- } , ( ) => {
53- if ( ! doNotTriggerListeners ) {
54- const currMont = this . state . currentMonth . clone ( ) ;
55- if ( this . props . onMonthChange ) {
56- this . props . onMonthChange ( xdateToData ( currMont ) ) ;
51+ currentMonth : day . clone ( )
52+ } , ( ) => {
53+ if ( ! doNotTriggerListeners ) {
54+ const currMont = this . state . currentMonth . clone ( ) ;
55+ if ( this . props . onMonthChange ) {
56+ this . props . onMonthChange ( xdateToData ( currMont ) ) ;
57+ }
58+ if ( this . props . onVisibleMonthsChange ) {
59+ this . props . onVisibleMonthsChange ( [ xdateToData ( currMont ) ] ) ;
60+ }
5761 }
58- if ( this . props . onVisibleMonthsChange ) {
59- this . props . onVisibleMonthsChange ( [ xdateToData ( currMont ) ] ) ;
60- }
61- }
62- } ) ;
63- }
62+ } ) ;
63+ }
6464
65- pressDay ( day ) {
66- const minDate = parseDate ( this . props . minDate ) ;
67- if ( ! minDate || dateutils . isGTE ( day , minDate ) ) {
68- this . updateMonth ( day ) ;
69- if ( this . props . onDayPress ) {
70- this . props . onDayPress ( xdateToData ( day ) ) ;
65+ pressDay ( day ) {
66+ const minDate = parseDate ( this . props . minDate ) ;
67+ if ( ! minDate || dateutils . isGTE ( day , minDate ) ) {
68+ this . updateMonth ( day ) ;
69+ if ( this . props . onDayPress ) {
70+ this . props . onDayPress ( xdateToData ( day ) ) ;
71+ }
7172 }
7273 }
73- }
74-
75- addMonth ( count ) {
76- this . updateMonth ( this . state . currentMonth . clone ( ) . addMonths ( count , true ) ) ;
77- }
7874
79- isSelected ( day ) {
80- let selectedDays = [ ] ;
81- if ( this . props . selected ) {
82- selectedDays = this . props . selected ;
75+ addMonth ( count ) {
76+ this . updateMonth ( this . state . currentMonth . clone ( ) . addMonths ( count , true ) ) ;
8377 }
84- for ( let i = 0 ; i < selectedDays . length ; i ++ ) {
85- if ( dateutils . sameDate ( day , parseDate ( selectedDays [ i ] ) ) ) {
86- return true ;
78+
79+ isSelected ( day ) {
80+ let selectedDays = [ ] ;
81+ if ( this . props . selected ) {
82+ selectedDays = this . props . selected ;
8783 }
84+ for ( let i = 0 ; i < selectedDays . length ; i ++ ) {
85+ if ( dateutils . sameDate ( day , parseDate ( selectedDays [ i ] ) ) ) {
86+ return true ;
87+ }
88+ }
89+ return false ;
8890 }
89- return false ;
90- }
9191
92- renderDay ( day , id ) {
93- const minDate = parseDate ( this . props . minDate ) ;
94- let state = '' ;
95- if ( this . isSelected ( day ) ) {
96- state = 'selected' ;
97- } else if ( minDate && ! dateutils . isGTE ( day , minDate ) ) {
98- state = 'disabled' ;
99- } else if ( ! dateutils . sameMonth ( day , this . state . currentMonth ) ) {
100- state = 'disabled' ;
101- } else if ( dateutils . sameDate ( day , XDate ( ) ) ) {
102- state = 'today' ;
103- }
104- let dayComp ;
105- if ( ! dateutils . sameMonth ( day , this . state . currentMonth ) && this . props . hideExtraDays ) {
106- if ( this . props . markingType === 'interactive' ) {
107- dayComp = ( < View key = { id } style = { { flex : 1 } } /> ) ;
108- } else {
109- dayComp = ( < View key = { id } style = { { width : 32 } } /> ) ;
92+ renderDay ( day , id ) {
93+ const minDate = parseDate ( this . props . minDate ) ;
94+ let state = '' ;
95+ if ( this . isSelected ( day ) ) {
96+ state = 'selected' ;
97+ } else if ( minDate && ! dateutils . isGTE ( day , minDate ) ) {
98+ state = 'disabled' ;
99+ } else if ( ! dateutils . sameMonth ( day , this . state . currentMonth ) ) {
100+ state = 'disabled' ;
101+ } else if ( dateutils . sameDate ( day , XDate ( ) ) ) {
102+ state = 'today' ;
110103 }
111- } else {
112- const DayComp = this . props . markingType === 'interactive' ? UnitDay : Day ;
113- dayComp = (
114- < DayComp
115- key = { id }
116- state = { state }
117- theme = { this . props . theme }
118- onPress = { this . pressDay . bind ( this , day ) }
119- marked = { this . getDateMarking ( day ) }
120- >
121- { day . getDate ( ) }
122- </ DayComp >
123- ) ;
104+ let dayComp ;
105+ if ( ! dateutils . sameMonth ( day , this . state . currentMonth ) && this . props . hideExtraDays ) {
106+ if ( this . props . markingType === 'interactive' ) {
107+ dayComp = ( < View key = { id } style = { { flex : 1 } } /> ) ;
108+ } else {
109+ dayComp = ( < View key = { id } style = { { width : 32 } } /> ) ;
110+ }
111+ } else {
112+ const DayComp = this . props . markingType === 'interactive' ? UnitDay : Day ;
113+ dayComp = (
114+ < DayComp
115+ key = { id }
116+ state = { state }
117+ theme = { this . props . theme }
118+ onPress = { this . pressDay . bind ( this , day ) }
119+ marked = { this . getDateMarking ( day ) }
120+ >
121+ { day . getDate ( ) }
122+ </ DayComp >
123+ ) ;
124124 }
125125 return dayComp ;
126126 }
0 commit comments