Skip to content

Commit cb8ae11

Browse files
authored
Merge pull request #1811 from wix/infra/more_functional_components
Migrate to functional components - 2
2 parents 336f694 + f32c084 commit cb8ae11

File tree

6 files changed

+309
-381
lines changed

6 files changed

+309
-381
lines changed

example/src/screens/calendars.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ const CalendarsScreen = () => {
4343
return (
4444
<Fragment>
4545
<Text style={styles.text}>Calendar with week numbers</Text>
46-
<Calendar style={styles.calendar} hideExtraDays showWeekNumbers />
46+
<Calendar style={styles.calendar} hideExtraDays showWeekNumbers/>
4747
</Fragment>
4848
);
4949
};
@@ -183,7 +183,7 @@ const CalendarsScreen = () => {
183183
}
184184
},
185185
'2012-05-23': {color: '#70d7c7', textColor: 'white', marked: true, dotColor: 'white'},
186-
'2012-05-24': {color: '#70d7c7', textColor: 'white'},
186+
'2012-05-24': {color: '#70d7c7', inactive: true},
187187
'2012-05-25': {
188188
endingDay: true,
189189
color: '#50cebb',
@@ -193,13 +193,16 @@ const CalendarsScreen = () => {
193193
borderBottomRightRadius: 5
194194
}
195195
},
196-
'2012-05-30': {disabled: true, disableTouchEvent: true}
196+
'2012-05-30': {inactive: true, disableTouchEvent: true}
197197
}}
198198
disabledDaysIndexes={[0, 6]}
199199
theme={{
200+
textInactiveColor: '#a68a9f',
200201
textSectionTitleDisabledColor: 'grey',
201-
textSectionTitleColor: '#00BBF2'
202+
textSectionTitleColor: '#319e8e',
203+
arrowColor: '#319e8e'
202204
}}
205+
onDayPress={(day) => console.warn(`${day.dateString} pressed`)}
203206
/>
204207
</Fragment>
205208
);

example/src/screens/expandableCalendar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ export default class ExpandableCalendarScreen extends Component<Props> {
181181
render() {
182182
return (
183183
<CalendarProvider
184-
date={ITEMS[0].title}
184+
date={ITEMS[1].title}
185185
onDateChanged={this.onDateChanged}
186186
onMonthChange={this.onMonthChange}
187187
showTodayButton

example/src/screens/horizontalCalendarList.tsx

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,36 @@
1-
import React, {useState} from 'react';
1+
import React, {useState, useMemo, useCallback} from 'react';
22
// @ts-expect-error
33
import {CalendarList} from 'react-native-calendars';
44
import testIDs from '../testIDs';
55

6-
const initialDate = '2020-05-16';
6+
const INITIAL_DATE = '2020-05-16';
77

88
const HorizontalCalendarList = () => {
9-
const [selected, setSelected] = useState(initialDate);
10-
const markedDates = {
11-
[selected]: {
12-
selected: true,
13-
selectedColor: '#DFA460'
14-
}
15-
};
9+
const [selected, setSelected] = useState(INITIAL_DATE);
10+
const markedDates = useMemo(() => {
11+
return {
12+
[selected]: {
13+
selected: true,
14+
selectedColor: '#DFA460'
15+
}
16+
};
17+
}, [selected]);
1618

17-
const onDayPress = day => {
19+
const onDayPress = useCallback((day) => {
1820
setSelected(day.dateString);
19-
};
21+
}, []);
2022

2123
return (
2224
<CalendarList
23-
testID={testIDs.horizontalList.CONTAINER}
25+
current={INITIAL_DATE}
2426
markedDates={markedDates}
25-
current={initialDate}
2627
pastScrollRange={24}
2728
futureScrollRange={24}
2829
horizontal
2930
pagingEnabled
3031
onDayPress={onDayPress}
32+
testID={testIDs.horizontalList.CONTAINER}
33+
staticHeader
3134
/>
3235
);
3336
};

0 commit comments

Comments
 (0)