Skip to content

Commit 1b63508

Browse files
authored
ExpandableCalendar - fix passing 'headerStyle' to horizontal header (#2018)
* ExpandableCalendar - fix passing 'headerStyle' to horizontal header * lint fix
1 parent 18001b0 commit 1b63508

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

example/src/screens/expandableCalendarScreen.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ const ExpandableCalendarScreen = (props: Props) => {
5555
// hideKnob
5656
// initialPosition={ExpandableCalendar.positions.OPEN}
5757
// calendarStyle={styles.calendar}
58-
// headerStyle={styles.calendar} // for horizontal only
58+
// headerStyle={styles.header} // for horizontal only
5959
// disableWeekScroll
6060
theme={theme.current}
6161
// disableAllTouchEventsForDisabledDays
@@ -72,7 +72,7 @@ const ExpandableCalendarScreen = (props: Props) => {
7272
renderItem={renderItem}
7373
// scrollToNextEvent
7474
sectionStyle={styles.section}
75-
// dayFormat={'YYYY-MM-d'}
75+
// dayFormat={'yyyy-MM-d'}
7676
/>
7777
</CalendarProvider>
7878
);
@@ -85,6 +85,9 @@ const styles = StyleSheet.create({
8585
paddingLeft: 20,
8686
paddingRight: 20
8787
},
88+
header: {
89+
backgroundColor: 'lightgrey'
90+
},
8891
section: {
8992
backgroundColor: lightThemeColor,
9093
color: 'grey',

src/calendar/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export interface CalendarProps extends CalendarHeaderProps, DayProps {
6060
/** Disable days by default */
6161
disabledByDefault?: boolean;
6262
/** Style passed to the header */
63-
headerStyle?: ViewStyle;
63+
headerStyle?: StyleProp<ViewStyle>;
6464
/** Allow rendering a totally custom header */
6565
customHeader?: any;
6666
/** Allow selection of dates before minDate or after maxDate */

src/expandableCalendar/index.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ const ExpandableCalendar = (props: ExpandableCalendarProps) => {
225225
];
226226
}, [calendarStyle]);
227227

228-
const headerStyle = useMemo(() => {
228+
const animatedHeaderStyle = useMemo(() => {
229229
return [style.current.header, {height: HEADER_HEIGHT + 10, top: headerDeltaY.current}];
230230
}, [headerDeltaY.current]);
231231

@@ -497,7 +497,7 @@ const ExpandableCalendar = (props: ExpandableCalendarProps) => {
497497
return (
498498
<Animated.View
499499
ref={header}
500-
style={headerStyle}
500+
style={animatedHeaderStyle}
501501
pointerEvents={'none'}
502502
>
503503
<Text allowFontScaling={false} style={style.current.headerTitle}>
@@ -548,6 +548,10 @@ const ExpandableCalendar = (props: ExpandableCalendarProps) => {
548548
}
549549
}, [numberOfDays]);
550550

551+
const _headerStyle = useMemo(() => {
552+
return [numberOfDaysHeaderStyle, props.headerStyle];
553+
}, [props.headerStyle]);
554+
551555
const renderCalendarList = () => {
552556
return (
553557
<CalendarList
@@ -570,7 +574,7 @@ const ExpandableCalendar = (props: ExpandableCalendarProps) => {
570574
renderArrow={_renderArrow}
571575
staticHeader
572576
numberOfDays={numberOfDays}
573-
headerStyle={numberOfDaysHeaderStyle}
577+
headerStyle={_headerStyle}
574578
timelineLeftInset={timelineLeftInset}
575579
/>
576580
);

0 commit comments

Comments
 (0)