@@ -5,23 +5,21 @@ import React, {Component} from 'react';
55import { StyleSheet , Animated , TouchableOpacity , View , StyleProp , ViewStyle } from 'react-native' ;
66
77import { toMarkingFormat } from '../../interface' ;
8- import { Theme , UpdateSource , DateData } from '../../types' ;
8+ import { Theme , DateData } from '../../types' ;
99import styleConstructor from '../style' ;
1010import CalendarContext from '.' ;
1111import Presenter from './Presenter' ;
12+ import { UpdateSources } from '../commons' ;
1213
13-
14- const commons = require ( '../commons' ) ;
15- const updateSources = commons . UpdateSources ;
1614const TOP_POSITION = 65 ;
1715
1816interface Props {
1917 /** Initial date in 'yyyy-MM-dd' format. Default = now */
2018 date : string ;
2119 /** Callback for date change event */
22- onDateChanged ?: ( date : string , updateSource : UpdateSource ) => void ;
20+ onDateChanged ?: ( date : string , updateSource : UpdateSources ) => void ;
2321 /** Callback for month change event */
24- onMonthChange ?: ( date : DateData , updateSource : UpdateSource ) => void ;
22+ onMonthChange ?: ( date : DateData , updateSource : UpdateSources ) => void ;
2523 /** Whether to show the today button */
2624 showTodayButton ?: boolean ;
2725 /** Today button's top position */
@@ -62,11 +60,10 @@ class CalendarProvider extends Component<Props> {
6260 style = styleConstructor ( this . props . theme ) ;
6361 presenter = new Presenter ( ) ;
6462
65-
6663 state = {
6764 prevDate : this . getDate ( this . props . date ) ,
6865 date : this . getDate ( this . props . date ) ,
69- updateSource : updateSources . CALENDAR_INIT ,
66+ updateSource : UpdateSources . CALENDAR_INIT ,
7067 buttonY : new Animated . Value ( this . props . todayBottomMargin ? - this . props . todayBottomMargin : - TOP_POSITION ) ,
7168 buttonIcon : this . presenter . getButtonIcon ( this . getDate ( this . props . date ) , this . props . showTodayButton ) ,
7269 disabled : false ,
@@ -75,7 +72,7 @@ class CalendarProvider extends Component<Props> {
7572
7673 componentDidUpdate ( prevProps : Props ) {
7774 if ( this . props . date && prevProps . date !== this . props . date ) {
78- this . setDate ( this . props . date , updateSources . PROP_UPDATE ) ;
75+ this . setDate ( this . props . date , UpdateSources . PROP_UPDATE ) ;
7976 }
8077 }
8178
@@ -93,7 +90,7 @@ class CalendarProvider extends Component<Props> {
9390 } ;
9491 } ;
9592
96- setDate = ( date : string , updateSource : UpdateSource ) => {
93+ setDate = ( date : string , updateSource : UpdateSources ) => {
9794 const { setDate} = this . presenter ;
9895
9996 const updateState = ( buttonIcon : number ) => {
@@ -143,7 +140,7 @@ class CalendarProvider extends Component<Props> {
143140
144141 onTodayPress = ( ) => {
145142 const today = this . presenter . getTodayDate ( ) ;
146- this . setDate ( today , updateSources . TODAY_PRESS ) ;
143+ this . setDate ( today , UpdateSources . TODAY_PRESS ) ;
147144 } ;
148145
149146 renderTodayButton ( ) {
0 commit comments