Skip to content

Commit 3817566

Browse files
committed
Comment some code in calendar
1 parent 97c3fa3 commit 3817566

File tree

3 files changed

+28
-27
lines changed

3 files changed

+28
-27
lines changed

demo/src/screens/incubatorScreens/IncubatorCalendarScreen/index.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ export default class CalendarScreen extends Component {
3939
};
4040

4141
render() {
42-
const {date, events, showLoader} = this.state;
42+
const {date, events/* , showLoader */} = this.state;
4343
return (
44-
<Incubator.Calendar data={events} initialDate={date} onChangeDate={this.onChangeDate} staticHeader>
45-
<Incubator.Calendar.Agenda onEndReached={this.onEndReached} showLoader={showLoader}/>
44+
<Incubator.Calendar data={events} initialDate={date} /* onChangeDate={this.onChangeDate} */ staticHeader>
45+
{/* <Incubator.Calendar.Agenda onEndReached={this.onEndReached} showLoader={showLoader}/> */}
4646
</Incubator.Calendar>
4747
);
4848
}

src/incubator/Calendar/index.tsx

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {FlashListPackage} from 'optionalDeps';
44
import {Constants} from '../../commons/new';
55
import {generateMonthItems} from './helpers/CalendarProcessor';
66
import {addHeaders} from './helpers/DataProcessor';
7-
import {isSameMonth, addYears, getDateObject} from './helpers/DateUtils';
7+
import {isSameMonth, /* addYears, */ getDateObject} from './helpers/DateUtils';
88
import {CalendarContextProps, CalendarProps, FirstDayOfWeek, UpdateSource, DateObjectWithOptionalDay} from './types';
99
import CalendarContext from './CalendarContext';
1010
import CalendarItem from './CalendarItem';
@@ -32,7 +32,7 @@ function Calendar(props: PropsWithChildren<CalendarProps>) {
3232
} = props;
3333

3434
const initialItems = generateMonthItems(initialDate, YEARS_RANGE, YEARS_RANGE);
35-
const [items, setItems] = useState<DateObjectWithOptionalDay[]>(initialItems);
35+
const [items/* , setItems */] = useState<DateObjectWithOptionalDay[]>(initialItems);
3636

3737
const getItemIndex = useCallback((date: number) => {
3838
'worklet';
@@ -101,26 +101,27 @@ function Calendar(props: PropsWithChildren<CalendarProps>) {
101101

102102
/** Pages reload */
103103

104-
const mergeArrays = (prepend: boolean, array: DateObjectWithOptionalDay[], newArray: DateObjectWithOptionalDay[]) => {
105-
const arr: DateObjectWithOptionalDay[] = array.slice();
106-
if (prepend) {
107-
arr.unshift(...newArray);
108-
} else {
109-
arr.push(...newArray);
110-
}
111-
return arr;
112-
};
113-
114-
const addPages = useCallback((index: number) => {
115-
const prepend = index < PAGE_RELOAD_THRESHOLD;
116-
const append = index > items.length - PAGE_RELOAD_THRESHOLD;
117-
const pastRange = prepend ? YEARS_RANGE : 0;
118-
const futureRange = append ? YEARS_RANGE : 0;
119-
const newDate = addYears(current.value, prepend ? -1 : 1);
120-
const newItems = generateMonthItems(newDate, pastRange, futureRange);
121-
const newArray = mergeArrays(prepend, items, newItems);
122-
setItems(newArray);
123-
// eslint-disable-next-line react-hooks/exhaustive-deps
104+
// const mergeArrays = (prepend: boolean, array: DateObjectWithOptionalDay[], newArray: DateObjectWithOptionalDay[]) => {
105+
// const arr: DateObjectWithOptionalDay[] = array.slice();
106+
// if (prepend) {
107+
// arr.unshift(...newArray);
108+
// } else {
109+
// arr.push(...newArray);
110+
// }
111+
// return arr;
112+
// };
113+
114+
const addPages = useCallback((/* index: number */) => {
115+
116+
// const prepend = index < PAGE_RELOAD_THRESHOLD;
117+
// const append = index > items.length - PAGE_RELOAD_THRESHOLD;
118+
// const pastRange = prepend ? YEARS_RANGE : 0;
119+
// const futureRange = append ? YEARS_RANGE : 0;
120+
// const newDate = addYears(current.value, prepend ? -1 : 1);
121+
// const newItems = generateMonthItems(newDate, pastRange, futureRange);
122+
// const newArray = mergeArrays(prepend, items, newItems);
123+
// setItems(newArray);
124+
// // eslint-disable-next-line react-hooks/exhaustive-deps
124125
}, [items]);
125126

126127
const shouldAddPages = useCallback((index: number) => {
@@ -138,7 +139,7 @@ function Calendar(props: PropsWithChildren<CalendarProps>) {
138139

139140
if (shouldAddPages(index)) {
140141
console.log('Add new pages: ', index, items.length);
141-
runOnJS(addPages)(index);
142+
runOnJS(addPages)(/* index */);
142143
} else if (lastUpdateSource.value !== UpdateSource.MONTH_SCROLL) {
143144
if (previous && !isSameMonth(selected, previous)) {
144145
runOnJS(scrollToIndex)(index);

src/incubator/Calendar/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ export enum DayNamesFormat {
118118
export interface CalendarProps {
119119
data: Data;
120120
initialDate?: number;
121-
onChangeDate: (date: number) => void;
121+
onChangeDate?: (date: number) => void;
122122
firstDayOfWeek?: /* `${FirstDayOfWeek}` & */ FirstDayOfWeek; // NOTE: template literals usage depends on ts min version ^4.3.2
123123
staticHeader?: boolean;
124124
showExtraDays?: boolean;

0 commit comments

Comments
 (0)