@@ -126,6 +126,7 @@ const ExpandableCalendar = (props: ExpandableCalendarProps) => {
126126 } = props ;
127127
128128 /** Date */
129+
129130 const { date, setDate} = useContext ( Context ) ;
130131 const initialDate = date ;
131132 const getYear = ( date : string ) => {
@@ -161,13 +162,15 @@ const ExpandableCalendar = (props: ExpandableCalendarProps) => {
161162 } , [ markedDates , date ] ) ;
162163
163164 /** Number of weeks */
165+
164166 const getNumberOfWeeksInMonth = ( month : string ) => {
165167 const days = page ( parseDate ( month ) , firstDay ) ;
166168 return days . length / 7 ;
167169 } ;
168170 const numberOfWeeks = useRef ( getNumberOfWeeksInMonth ( date ) ) ;
169171
170172 /** Position */
173+
171174 const closedHeight = CLOSED_HEIGHT + ( hideKnob ? 0 : KNOB_CONTAINER_HEIGHT ) ;
172175 const getOpenHeight = ( ) => {
173176 if ( ! horizontal ) {
@@ -186,13 +189,15 @@ const ExpandableCalendar = (props: ExpandableCalendarProps) => {
186189 const isOpen = position === Positions . OPEN ;
187190
188191 /** Components' refs */
192+
189193 const wrapper = useRef < any > ( ) ;
190194 const calendar = useRef < any > ( ) ;
191195 const header = useRef < any > ( ) ;
192196 const weekCalendar = useRef < any > ( ) ;
193197
194198
195199 /** Styles */
200+
196201 const style = useRef ( styleConstructor ( theme ) ) ;
197202 const themeObject = Object . assign ( headerStyleOverride , theme ) ;
198203
@@ -212,7 +217,7 @@ const ExpandableCalendar = (props: ExpandableCalendarProps) => {
212217 }
213218 } ;
214219
215- const getWeekDaysStyle = useMemo ( ( ) => {
220+ const weekDaysStyle = useMemo ( ( ) => {
216221 const leftPaddings = calendarStyle ?. paddingLeft ;
217222 const rightPaddings = calendarStyle ?. paddingRight ;
218223
@@ -225,7 +230,24 @@ const ExpandableCalendar = (props: ExpandableCalendarProps) => {
225230 ] ;
226231 } , [ calendarStyle ] ) ;
227232
233+ const headerStyle = useMemo ( ( ) => {
234+ return [ style . current . header , { height : HEADER_HEIGHT + 10 , top : headerDeltaY . current } ] ;
235+ } , [ headerDeltaY . current ] ) ;
236+
237+ const weekCalendarStyle = useMemo ( ( ) => {
238+ return [ style . current . weekContainer , isOpen ? style . current . hidden : style . current . visible ] ;
239+ } , [ isOpen ] ) ;
240+
241+ const containerStyle = useMemo ( ( ) => {
242+ return [ allowShadow && style . current . containerShadow , propsStyle ] ;
243+ } , [ allowShadow , propsStyle ] ) ;
244+
245+ const wrapperStyle = useMemo ( ( ) => {
246+ return { height : deltaY . current } ;
247+ } , [ deltaY . current ] ) ;
248+
228249 /** Effects */
250+
229251 useEffect ( ( ) => {
230252 if ( AccessibilityInfo ) {
231253 if ( AccessibilityInfo . isScreenReaderEnabled ) {
@@ -436,10 +458,10 @@ const ExpandableCalendar = (props: ExpandableCalendarProps) => {
436458 ) , [ date ] ) ;
437459
438460 /** Renders */
439-
461+
440462 const renderWeekDaysNames = ( ) => {
441463 return (
442- < View style = { getWeekDaysStyle } >
464+ < View style = { weekDaysStyle } >
443465 < WeekDaysNames
444466 firstDay = { firstDay }
445467 style = { style . current . dayHeader }
@@ -454,7 +476,7 @@ const ExpandableCalendar = (props: ExpandableCalendarProps) => {
454476 return (
455477 < Animated . View
456478 ref = { header }
457- style = { [ style . current . header , { height : HEADER_HEIGHT + 10 , top : headerDeltaY . current } ] }
479+ style = { headerStyle }
458480 pointerEvents = { 'none' }
459481 >
460482 < Text allowFontScaling = { false } style = { style . current . headerTitle } >
@@ -472,7 +494,7 @@ const ExpandableCalendar = (props: ExpandableCalendarProps) => {
472494 return (
473495 < Animated . View
474496 ref = { weekCalendar }
475- style = { [ style . current . weekContainer , isOpen ? style . current . hidden : style . current . visible ] }
497+ style = { weekCalendarStyle }
476498 pointerEvents = { position === Positions . CLOSED ? 'auto' : 'none' }
477499 >
478500 < WeekComponent
@@ -513,7 +535,7 @@ const ExpandableCalendar = (props: ExpandableCalendarProps) => {
513535 } ;
514536
515537 return (
516- < View testID = { testID } style = { [ allowShadow && style . current . containerShadow , propsStyle ] } >
538+ < View testID = { testID } style = { containerStyle } >
517539 { screenReaderEnabled ? (
518540 < Calendar
519541 testID = "calendar"
@@ -524,7 +546,7 @@ const ExpandableCalendar = (props: ExpandableCalendarProps) => {
524546 renderArrow = { _renderArrow }
525547 />
526548 ) : (
527- < Animated . View ref = { wrapper } style = { { height : deltaY . current } } { ...panResponder . panHandlers } >
549+ < Animated . View ref = { wrapper } style = { wrapperStyle } { ...panResponder . panHandlers } >
528550 < CalendarList
529551 testID = "calendar"
530552 horizontal = { horizontal }
0 commit comments