Skip to content

Commit 86f4389

Browse files
committed
Merge branch 'master' of github.com:wix/react-native-calendars into release
2 parents df14a5d + fa70446 commit 86f4389

File tree

25 files changed

+406
-197
lines changed

25 files changed

+406
-197
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -793,4 +793,4 @@
793793
- 'input.js' - renaming 'velocityTracker'.
794794
- 'test.js' - renaming 'testUtils' and removing from folder.
795795

796-
*** End of changelog - please see release tags for notes ***
796+
*** End of changelog - please see release tags for notes ***

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,10 @@ An advanced `Agenda` component that can display interactive listings for calenda
557557
renderKnob={() => {
558558
return <View />;
559559
}}
560+
// Override inner list with a custom implemented component
561+
renderList={(listProps) => {
562+
return <MyCustomList {...listProps} />
563+
}}
560564
// Specify what should be rendered instead of ActivityIndicator
561565
renderEmptyData={() => {
562566
return <View />;

docsRNC/docs/Calendar.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,10 @@ Whether to hide the days names
130130
Whether to hide the arrows
131131
<span style={{color: 'grey'}}>boolean</span>
132132

133+
### arrowsHitSlop
134+
135+
Left & Right arrows. Additional distance outside of the buttons in which a press is detected, default: 20
136+
<span style={{color: 'grey'}}>null | Insets | number</span>
133137
### disableArrowLeft
134138

135139
Whether to disable the left arrow

example/src/mocks/AgendaItem.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ const AgendaItem = (props: ItemProps) => {
4141
);
4242
};
4343

44-
export default AgendaItem;
44+
export default React.memo(AgendaItem);
4545

4646

4747
const styles = StyleSheet.create({

example/src/mocks/agendaItems.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import isEmpty from 'lodash/isEmpty';
2+
import {MarkedDates} from '../../../src/types';
23

34
const today = new Date().toISOString().split('T')[0];
45
const fastDate = getPastDate(3);
@@ -116,12 +117,8 @@ export const agendaItems = [
116117
}
117118
];
118119

119-
type MarkedDate = {
120-
[key: string]: object;
121-
}
122-
123120
export function getMarkedDates() {
124-
const marked: MarkedDate = {};
121+
const marked: MarkedDates = {};
125122

126123
agendaItems.forEach(item => {
127124
// NOTE: only mark dates with data

example/src/screens/calendarListScreen.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,6 @@ const CalendarListScreen = (props: Props) => {
1717
const [selected, setSelected] = useState(initialDate);
1818
const marked = useMemo(() => {
1919
return {
20-
[selected]: {
21-
selected: true,
22-
disableTouchEvent: true,
23-
selectedColor: '#5E60CE',
24-
selectedTextColor: 'white'
25-
},
2620
[nextWeekDate]: {
2721
selected: selected === nextWeekDate,
2822
selectedTextColor: '#5E60CE',
@@ -32,6 +26,12 @@ const CalendarListScreen = (props: Props) => {
3226
selected: selected === nextMonthDate,
3327
selectedTextColor: '#5E60CE',
3428
marked: true
29+
},
30+
[selected]: {
31+
selected: true,
32+
disableTouchEvent: true,
33+
selectedColor: '#5E60CE',
34+
selectedTextColor: 'white'
3535
}
3636
};
3737
}, [selected]);

example/src/screens/calendarPlaygroundScreen.tsx

Lines changed: 33 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,20 @@
11
import times from 'lodash/times';
2-
import React, {useState, Fragment, useCallback, useMemo, useRef} from 'react';
2+
import React, {useState, useCallback, useMemo, useRef} from 'react';
33
import {StyleSheet, View, ScrollView, Text, TouchableOpacity, Switch, Alert} from 'react-native';
44
import {Calendar, CalendarUtils} from 'react-native-calendars';
5+
56
import testIDs from '../testIDs';
7+
import Marking from '../../../src/calendar/day/marking';
68

79
const INITIAL_DATE = '2022-07-06';
810
const GREEN = '#13ba7d';
911
const PINK = '#a68a9f';
1012
const RED = '#ba1313';
11-
enum Markings {
12-
DOT = 'dot',
13-
MULTI_DOT = 'multi-dot',
14-
PERIOD = 'period',
15-
MULTI_PERIOD = 'multi-period',
16-
CUSTOM = 'custom'
17-
}
1813

1914
const NewCalendarScreen = () => {
2015
const [selected, setSelected] = useState(INITIAL_DATE);
2116
const [currentMonth, setCurrentMonth] = useState(INITIAL_DATE);
22-
const [markingType, setMarkingType] = useState(Markings.DOT);
17+
const [markingType, setMarkingType] = useState(Marking.markings.DOT);
2318
const [selectedButtonIndex, setSelectedButtonIndex] = useState(0);
2419

2520
/** props */
@@ -91,16 +86,20 @@ const NewCalendarScreen = () => {
9186

9287
const dotMarks = useMemo(() => {
9388
return {
89+
[getDate(1)]: {
90+
disabled: true,
91+
dotColor: RED,
92+
marked: true
93+
},
94+
[getDate(2)]: {
95+
dotColor: RED,
96+
marked: true
97+
},
9498
[selected]: {
9599
selected: true,
96100
disableTouchEvent: true,
97101
selectedColor: PINK,
98102
selectedTextColor: RED
99-
},
100-
[getDate(1)]: {
101-
disabled: true,
102-
dotColor: RED,
103-
marked: true
104103
}
105104
};
106105
}, [selected]);
@@ -289,15 +288,15 @@ const NewCalendarScreen = () => {
289288

290289
const markingForType = useCallback(() => {
291290
switch (markingType) {
292-
case Markings.DOT:
291+
case Marking.markings.DOT:
293292
return dotMarks;
294-
case Markings.MULTI_DOT:
293+
case Marking.markings.MULTI_DOT:
295294
return multiDotMarks;
296-
case Markings.PERIOD:
295+
case Marking.markings.PERIOD:
297296
return periodWithDotsMarks; //periodMarks;
298-
case Markings.MULTI_PERIOD:
297+
case Marking.markings.MULTI_PERIOD:
299298
return multiPeriodMarks;
300-
case Markings.CUSTOM:
299+
case Marking.markings.CUSTOM:
301300
return customMarks;
302301
}
303302
}, [markingType, selected]);
@@ -450,32 +449,36 @@ const NewCalendarScreen = () => {
450449
return (
451450
<View>
452451
{renderSwitch('Min and Max Dates', minAndMax, toggleMinAndMax)}
453-
{renderSwitch('Allow Selection Out Of Range', allowSelectionOutOfRange, toggleAllowSelectionOutOfRange)}
452+
<View style={styles.subSwitchContainer}>
453+
{minAndMax && renderSwitch('Allow Selection Out Of Range', allowSelectionOutOfRange, toggleAllowSelectionOutOfRange)}
454+
</View>
454455
{renderSwitch('Enable Swipe Months', enableSwipeMonths, toggleEnableSwipeMonths)}
455456
{renderSwitch('Disable Month Change', disableMonthChange, toggleDisableMonthChange)}
456457
{renderSwitch('Show Week Numbers', showWeekNumbers, toggleShowWeekNumbers)}
457458
{renderSwitch('Show Six Weeks', showSixWeeks, toggleShowSixWeeks)}
458459
{renderSwitch('Hide Extra Days', hideExtraDays, toggleHideExtraDays)}
459460
{renderSwitch('Hide Day Names', hideDayNames, toggleHideDayNames)}
460-
{renderSwitch('Hide Arrows', hideArrows, toggleHideArrows)}
461461
{renderSwitch('Disabled By Default', disabledByDefault, toggleDisabledByDefault)}
462462
{renderSwitch('Disable All Touch Events For Disabled Days', disableAllTouchEventsForDisabledDays, toggleDisableAllTouchEventsForDisabledDays)}
463463
{renderSwitch('Disable All Touch Events For Inactive Days', disableAllTouchEventsForInactiveDays, toggleDisableAllTouchEventsForInactiveDays)}
464464
{renderSwitch('Display Loading Indicator', displayLoadingIndicator, toggleDisplayLoadingIndicator)}
465465
{renderSwitch('Disabled Days Indexes', disabledDaysIndexes, toggleDisabledDaysIndexes)}
466+
{renderSwitch('Hide Arrows', hideArrows, toggleHideArrows)}
467+
<View style={styles.subSwitchContainer}>
468+
{!hideArrows && renderSwitch('Disable Arrow Left', disableArrowLeft, toggleDisableArrowLeft)}
469+
{!hideArrows && renderSwitch('Disable Arrow Right', disableArrowRight, toggleDisableArrowRight)}
470+
{!hideArrows && renderSwitch('Render Arrow', renderArrow, toggleRenderArrow)}
471+
</View>
466472
{renderSwitch('Day Component', dayComponent, toggleDayComponent)}
467473
{renderSwitch('Custom Header', customHeader, toggleCustomHeader)}
468474
{renderSwitch('Custom Header Title', customHeaderTitle, toggleCustomHeaderTitle)}
469-
{renderSwitch('Render Arrow', renderArrow, toggleRenderArrow)}
470-
{renderSwitch('Disable Arrow Left', disableArrowLeft, toggleDisableArrowLeft)}
471-
{renderSwitch('Disable Arrow Right', disableArrowRight, toggleDisableArrowRight)}
472475
</View>
473476
);
474477
};
475478

476479
/** Buttons */
477480
const getValue = (index = 0) => {
478-
return Object.values(Markings)[index];
481+
return Object.values(Marking.markings)[index];
479482
};
480483

481484
const setType = (index = 0) => {
@@ -528,12 +531,12 @@ const NewCalendarScreen = () => {
528531
};
529532

530533
return (
531-
<Fragment>
534+
<>
532535
{renderCalendar()}
533536
<ScrollView showsVerticalScrollIndicator={false} testID={testIDs.calendars.CONTAINER}>
534537
{renderOptions()}
535538
</ScrollView>
536-
</Fragment>
539+
</>
537540
);
538541
};
539542

@@ -578,6 +581,9 @@ const styles = StyleSheet.create({
578581
switchText: {
579582
marginHorizontal: 10
580583
},
584+
subSwitchContainer: {
585+
marginLeft: 20
586+
},
581587
buttonsContainer: {
582588
margin: 10
583589
},

0 commit comments

Comments
 (0)