@super-calendar/native 2.19.0 → 2.20.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +19 -1
- package/dist/{MonthList-DeO-x5VW.js → MonthList-CGgy0Juh.js} +28 -7
- package/dist/{MonthList-BGl1gTDr.mjs → MonthList-CPpsr5Oa.mjs} +28 -7
- package/dist/index.d.mts +47 -1
- package/dist/index.d.ts +47 -1
- package/dist/index.js +110 -34
- package/dist/index.mjs +110 -34
- package/dist/picker.js +1 -1
- package/dist/picker.mjs +1 -1
- package/package.json +3 -3
- package/src/components/Calendar.tsx +17 -0
- package/src/components/MonthList.tsx +13 -3
- package/src/components/MonthPager.tsx +21 -5
- package/src/components/MonthView.tsx +11 -4
- package/src/components/TimeGrid.tsx +173 -46
- package/src/index.tsx +1 -0
|
@@ -1265,12 +1265,15 @@ type HourLabelProps = {
|
|
|
1265
1265
|
label: string;
|
|
1266
1266
|
ampm: boolean;
|
|
1267
1267
|
hourComponent?: HourRenderer;
|
|
1268
|
+
/** Leave the label out, because the now label sits on top of it. */
|
|
1269
|
+
hidden?: boolean;
|
|
1268
1270
|
};
|
|
1269
1271
|
|
|
1270
1272
|
// The hour-axis label: the consumer's `hourComponent`, or the themed text.
|
|
1271
|
-
const HourLabel = ({ hour, width, label, ampm, hourComponent }: HourLabelProps) => {
|
|
1273
|
+
const HourLabel = ({ hour, width, label, ampm, hourComponent, hidden }: HourLabelProps) => {
|
|
1272
1274
|
const theme = useCalendarTheme();
|
|
1273
1275
|
const slot = useSlots<TimeGridSlot>();
|
|
1276
|
+
if (hidden) return null;
|
|
1274
1277
|
return hourComponent ? (
|
|
1275
1278
|
<View style={{ width }}>{hourComponent(hour, ampm)}</View>
|
|
1276
1279
|
) : (
|
|
@@ -1321,6 +1324,12 @@ const HourLines = memo(function HourLines({ hours, timeslots }: HourLinesProps)
|
|
|
1321
1324
|
);
|
|
1322
1325
|
});
|
|
1323
1326
|
|
|
1327
|
+
function getNowPosition(time: Date, days: Date[], minHour: number, maxHour: number) {
|
|
1328
|
+
const hours = getHours(time) + getMinutes(time) / MINUTES_PER_HOUR;
|
|
1329
|
+
const dayIndex = days.findIndex((day) => isSameCalendarDay(day, time));
|
|
1330
|
+
return dayIndex >= 0 && hours >= minHour && hours <= maxHour ? { time, hours, dayIndex } : null;
|
|
1331
|
+
}
|
|
1332
|
+
|
|
1324
1333
|
type HourGutterProps = {
|
|
1325
1334
|
width: number;
|
|
1326
1335
|
minHour: number;
|
|
@@ -1343,8 +1352,14 @@ type HourGutterProps = {
|
|
|
1343
1352
|
weekNumber: string | null;
|
|
1344
1353
|
ampm: boolean;
|
|
1345
1354
|
hourComponent?: HourRenderer;
|
|
1355
|
+
/** Draws the current time in the hour column, level with the now line. */
|
|
1356
|
+
renderNowLabel?: (now: Date) => React.ReactNode;
|
|
1357
|
+
nowPosition: ReturnType<typeof getNowPosition>;
|
|
1346
1358
|
};
|
|
1347
1359
|
|
|
1360
|
+
// How close, in hours, an hour label may sit to the now label before it is left out.
|
|
1361
|
+
const NOW_LABEL_CLEARANCE_HOURS = 0.25;
|
|
1362
|
+
|
|
1348
1363
|
// The hour-axis column beside the pager. It is part of the grid's one vertical
|
|
1349
1364
|
// scroll content, so it scrolls and zooms with the pages and holds still while
|
|
1350
1365
|
// they swipe. Its "all-day" cell rides the scroll offset to stay pinned at the
|
|
@@ -1364,15 +1379,24 @@ const HourGutterInner = ({
|
|
|
1364
1379
|
weekNumber,
|
|
1365
1380
|
ampm,
|
|
1366
1381
|
hourComponent,
|
|
1382
|
+
renderNowLabel,
|
|
1383
|
+
nowPosition,
|
|
1367
1384
|
}: HourGutterProps) => {
|
|
1368
1385
|
const theme = useCalendarTheme();
|
|
1369
1386
|
const slot = useSlots<TimeGridSlot>();
|
|
1370
1387
|
const hours = useMemo(() => hourRange(minHour, maxHour), [minHour, maxHour]);
|
|
1388
|
+
const label = nowPosition && renderNowLabel?.(nowPosition.time);
|
|
1389
|
+
const labelHours = label == null || typeof label === "boolean" ? undefined : nowPosition?.hours;
|
|
1371
1390
|
// Height and offset are separate styles: a style that returns a transform is
|
|
1372
1391
|
// re-applied every time it runs, so keeping the offset apart means a swipe
|
|
1373
1392
|
// (which only moves the band's height) sends nothing to the view.
|
|
1374
1393
|
const laneCellHeightStyle = useAnimatedStyle(() => ({ height: laneHeight.value }));
|
|
1375
|
-
|
|
1394
|
+
// Pinned to the viewport top only for real offsets. During the iOS top bounce the offset goes
|
|
1395
|
+
// negative, which lifted the pinned header and all-day band out of view while the hours slid
|
|
1396
|
+
// down; clamped at 0 they ride down with the hours instead, like a sticky header.
|
|
1397
|
+
const pinStyle = useAnimatedStyle(() => ({
|
|
1398
|
+
transform: [{ translateY: Math.max(0, scrollY.value) }],
|
|
1399
|
+
}));
|
|
1376
1400
|
const rowsStyle = useAnimatedStyle(
|
|
1377
1401
|
() => ({
|
|
1378
1402
|
top: headerHeight + laneHeight.value + HOUR_LABEL_TOP_INSET,
|
|
@@ -1439,10 +1463,25 @@ const HourGutterInner = ({
|
|
|
1439
1463
|
label={formatHour(hour, { ampm })}
|
|
1440
1464
|
ampm={ampm}
|
|
1441
1465
|
hourComponent={hourComponent}
|
|
1466
|
+
hidden={
|
|
1467
|
+
labelHours != null && Math.abs(hour - labelHours) < NOW_LABEL_CLEARANCE_HOURS
|
|
1468
|
+
}
|
|
1442
1469
|
/>
|
|
1443
1470
|
</View>
|
|
1444
1471
|
</View>
|
|
1445
1472
|
))}
|
|
1473
|
+
{labelHours != null ? (
|
|
1474
|
+
// A percentage of the rows' height, so it follows the zoom without a worklet.
|
|
1475
|
+
<View
|
|
1476
|
+
style={[
|
|
1477
|
+
styles.nowLabel,
|
|
1478
|
+
styles.nonInteractive,
|
|
1479
|
+
{ width, top: `${((labelHours - minHour) / (maxHour - minHour)) * 100}%` },
|
|
1480
|
+
]}
|
|
1481
|
+
>
|
|
1482
|
+
{label}
|
|
1483
|
+
</View>
|
|
1484
|
+
) : null}
|
|
1446
1485
|
</Animated.View>
|
|
1447
1486
|
</View>
|
|
1448
1487
|
);
|
|
@@ -1806,15 +1845,10 @@ function TimetablePageInner<T>({
|
|
|
1806
1845
|
|
|
1807
1846
|
const hoursRange = useMemo(() => hourRange(minHour, maxHour), [minHour, maxHour]);
|
|
1808
1847
|
|
|
1809
|
-
const
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
const
|
|
1813
|
-
// "Today" follows the (possibly zone-shifted or overridden) now, so the line
|
|
1814
|
-
// lands in the column the events are displayed in.
|
|
1815
|
-
const nowDayIndex = days.findIndex((day) => isSameCalendarDay(day, now));
|
|
1816
|
-
const nowHours = (getHours(now) * MINUTES_PER_HOUR + getMinutes(now)) / MINUTES_PER_HOUR;
|
|
1817
|
-
const nowInWindow = nowHours >= minHour && nowHours <= maxHour;
|
|
1848
|
+
const tickOnPage = showNowIndicator && isActive && nowProp == null;
|
|
1849
|
+
const pageClock = useNow(tickOnPage, { now: nowProp, timeZone: nowTimeZone });
|
|
1850
|
+
const today = tickOnPage ? pageClock : nowInTimeZone(nowProp, nowTimeZone);
|
|
1851
|
+
const nowPosition = showNowIndicator ? getNowPosition(today, days, minHour, maxHour) : null;
|
|
1818
1852
|
|
|
1819
1853
|
const fullHeightStyle = useAnimatedStyle(
|
|
1820
1854
|
() => ({ height: (maxHour - minHour) * heightSource.value }),
|
|
@@ -1842,7 +1876,12 @@ function TimetablePageInner<T>({
|
|
|
1842
1876
|
height: Math.max(LANE_BAND_FLOOR, laneHeight.value),
|
|
1843
1877
|
borderBottomWidth: laneHeight.value >= LANE_BAND_FLOOR ? StyleSheet.hairlineWidth : 0,
|
|
1844
1878
|
}));
|
|
1845
|
-
|
|
1879
|
+
// Pinned to the viewport top only for real offsets. During the iOS top bounce the offset goes
|
|
1880
|
+
// negative, which lifted the pinned header and all-day band out of view while the hours slid
|
|
1881
|
+
// down; clamped at 0 they ride down with the hours instead, like a sticky header.
|
|
1882
|
+
const pinStyle = useAnimatedStyle(() => ({
|
|
1883
|
+
transform: [{ translateY: Math.max(0, scrollY.value) }],
|
|
1884
|
+
}));
|
|
1846
1885
|
const reportLaneLayout = useCallback(
|
|
1847
1886
|
(event: LayoutChangeEvent) => {
|
|
1848
1887
|
onLaneLayout(pageIndex, event.nativeEvent.layout.height);
|
|
@@ -2441,12 +2480,12 @@ function TimetablePageInner<T>({
|
|
|
2441
2480
|
/>
|
|
2442
2481
|
) : null}
|
|
2443
2482
|
|
|
2444
|
-
{
|
|
2483
|
+
{nowPosition ? (
|
|
2445
2484
|
<NowIndicator
|
|
2446
2485
|
cellHeight={heightSource}
|
|
2447
|
-
nowHours={
|
|
2486
|
+
nowHours={nowPosition.hours}
|
|
2448
2487
|
minHour={minHour}
|
|
2449
|
-
left={dayLeft(
|
|
2488
|
+
left={dayLeft(nowPosition.dayIndex)}
|
|
2450
2489
|
width={dayWidth}
|
|
2451
2490
|
color={theme.colors.nowIndicator}
|
|
2452
2491
|
/>
|
|
@@ -2662,6 +2701,36 @@ export type TimeGridProps<T> = SlotStyleProps<TimeGridSlot> & {
|
|
|
2662
2701
|
onChangeDate: (date: Date) => void;
|
|
2663
2702
|
/** Optional header above the grid (e.g. weekday labels). Rendered full-width. */
|
|
2664
2703
|
renderHeader?: (days: Date[]) => React.ReactNode;
|
|
2704
|
+
/**
|
|
2705
|
+
* Draw a label in the hour column when the current-time line is visible.
|
|
2706
|
+
* A custom label replaces hour labels less than 15 minutes away.
|
|
2707
|
+
*/
|
|
2708
|
+
renderNowLabel?: (now: Date) => React.ReactNode;
|
|
2709
|
+
/**
|
|
2710
|
+
* Extra scrollable space below the last hour, inside the vertical scroll view,
|
|
2711
|
+
* so the end of the day can scroll clear of something floating over the grid
|
|
2712
|
+
* (a tab bar, a button). Default 0.
|
|
2713
|
+
*/
|
|
2714
|
+
contentPaddingBottom?: number;
|
|
2715
|
+
/**
|
|
2716
|
+
* The vertical scroll view's scroll events, on the JS thread. Use it to react
|
|
2717
|
+
* to the hours scrolling, such as collapsing a toolbar.
|
|
2718
|
+
*/
|
|
2719
|
+
onVerticalScroll?: (event: VerticalScrollEvent) => void;
|
|
2720
|
+
/**
|
|
2721
|
+
* Overscroll on the hours: iOS `bounces`, Android `overScrollMode`. Set
|
|
2722
|
+
* `false` to stop the grid at its ends. Default true.
|
|
2723
|
+
*/
|
|
2724
|
+
verticalBounces?: boolean;
|
|
2725
|
+
};
|
|
2726
|
+
|
|
2727
|
+
/** The scroll event `onVerticalScroll` receives, shaped like React Native's scroll event. */
|
|
2728
|
+
export type VerticalScrollEvent = {
|
|
2729
|
+
nativeEvent: {
|
|
2730
|
+
contentOffset: { x: number; y: number };
|
|
2731
|
+
contentSize: { width: number; height: number };
|
|
2732
|
+
layoutMeasurement: { width: number; height: number };
|
|
2733
|
+
};
|
|
2665
2734
|
};
|
|
2666
2735
|
|
|
2667
2736
|
function TimeGridInner<T>(
|
|
@@ -2709,7 +2778,7 @@ function TimeGridInner<T>(
|
|
|
2709
2778
|
verticalScrollEnabled = true,
|
|
2710
2779
|
weekNumberPrefix = "W",
|
|
2711
2780
|
hiddenDays,
|
|
2712
|
-
now,
|
|
2781
|
+
now: nowProp,
|
|
2713
2782
|
timeZone,
|
|
2714
2783
|
hourComponent,
|
|
2715
2784
|
activeDate,
|
|
@@ -2730,6 +2799,10 @@ function TimeGridInner<T>(
|
|
|
2730
2799
|
onPressDateHeader,
|
|
2731
2800
|
onChangeDate,
|
|
2732
2801
|
renderHeader,
|
|
2802
|
+
renderNowLabel,
|
|
2803
|
+
contentPaddingBottom = 0,
|
|
2804
|
+
onVerticalScroll,
|
|
2805
|
+
verticalBounces = true,
|
|
2733
2806
|
classNames,
|
|
2734
2807
|
styles: styleOverrides,
|
|
2735
2808
|
}: TimeGridProps<T>,
|
|
@@ -2740,6 +2813,10 @@ function TimeGridInner<T>(
|
|
|
2740
2813
|
const clampedMaxHour = Math.max(clampedMinHour + 1, Math.min(maxHour, HOURS_PER_DAY));
|
|
2741
2814
|
// Collapse the hour gutter to zero when hours are hidden.
|
|
2742
2815
|
const hourColumnWidth = hideHours ? 0 : hourColumnWidthProp;
|
|
2816
|
+
// A custom gutter label and its line must tick on the same minute, including after paging.
|
|
2817
|
+
const hasNowLabel = showNowIndicator && renderNowLabel != null && hourColumnWidth > 0;
|
|
2818
|
+
const labelClock = useNow(hasNowLabel, { now: nowProp });
|
|
2819
|
+
const now = nowProp ?? (hasNowLabel ? labelClock : undefined);
|
|
2743
2820
|
const labels = useMemo(() => resolveCalendarLabels(labelsProp), [labelsProp]);
|
|
2744
2821
|
const todayLabel = labels.today;
|
|
2745
2822
|
// The built-in day header pages with the columns (rendered inside each page). A
|
|
@@ -2811,12 +2888,27 @@ function TimeGridInner<T>(
|
|
|
2811
2888
|
// scrolls with the content, so a finger's window position maps into the grid
|
|
2812
2889
|
// through it.
|
|
2813
2890
|
const scrollY = useSharedValue(seedDefaultY);
|
|
2814
|
-
const scrollHandler = useAnimatedScrollHandler(
|
|
2815
|
-
|
|
2816
|
-
|
|
2817
|
-
|
|
2891
|
+
const scrollHandler = useAnimatedScrollHandler(
|
|
2892
|
+
{
|
|
2893
|
+
onScroll: (event) => {
|
|
2894
|
+
// eslint-disable-next-line react-hooks/immutability -- Reanimated shared value: assigning .value is the intended mutation API
|
|
2895
|
+
scrollY.value = event.contentOffset.y;
|
|
2896
|
+
if (onVerticalScroll) {
|
|
2897
|
+
runOnJS(onVerticalScroll)({
|
|
2898
|
+
nativeEvent: {
|
|
2899
|
+
contentOffset: { x: event.contentOffset.x, y: event.contentOffset.y },
|
|
2900
|
+
contentSize: { width: event.contentSize.width, height: event.contentSize.height },
|
|
2901
|
+
layoutMeasurement: {
|
|
2902
|
+
width: event.layoutMeasurement.width,
|
|
2903
|
+
height: event.layoutMeasurement.height,
|
|
2904
|
+
},
|
|
2905
|
+
},
|
|
2906
|
+
});
|
|
2907
|
+
}
|
|
2908
|
+
},
|
|
2818
2909
|
},
|
|
2819
|
-
|
|
2910
|
+
[onVerticalScroll],
|
|
2911
|
+
);
|
|
2820
2912
|
// The scroll view's `contentOffset` holds the mount offset; a later
|
|
2821
2913
|
// `scrollOffsetMinutes` is scrolled to by the effect further down.
|
|
2822
2914
|
const [mountOffsetY] = useState(seedDefaultY);
|
|
@@ -3154,20 +3246,17 @@ function TimeGridInner<T>(
|
|
|
3154
3246
|
|
|
3155
3247
|
// Header days track the active page (page-aligned), so they always match the
|
|
3156
3248
|
// columns below and a swipe never flashes another day's label.
|
|
3249
|
+
const activePageDate = pageDates[activeIndex] ?? date;
|
|
3157
3250
|
const headerDays = useMemo(
|
|
3158
3251
|
() =>
|
|
3159
|
-
getViewDays(
|
|
3160
|
-
|
|
3161
|
-
pageDates[activeIndex] ?? date,
|
|
3162
|
-
weekStartsOn,
|
|
3163
|
-
numberOfDays,
|
|
3164
|
-
isRTL,
|
|
3165
|
-
weekEndsOn,
|
|
3166
|
-
hiddenDays,
|
|
3167
|
-
),
|
|
3168
|
-
[mode, pageDates, activeIndex, date, weekStartsOn, numberOfDays, isRTL, weekEndsOn, hiddenDays],
|
|
3252
|
+
getViewDays(mode, activePageDate, weekStartsOn, numberOfDays, isRTL, weekEndsOn, hiddenDays),
|
|
3253
|
+
[mode, activePageDate, weekStartsOn, numberOfDays, isRTL, weekEndsOn, hiddenDays],
|
|
3169
3254
|
);
|
|
3170
3255
|
|
|
3256
|
+
const gutterNow = hasNowLabel
|
|
3257
|
+
? getNowPosition(nowInTimeZone(now, timeZone), headerDays, clampedMinHour, clampedMaxHour)
|
|
3258
|
+
: null;
|
|
3259
|
+
|
|
3171
3260
|
// Keep the cross-week drop's page columns + handler current without changing the
|
|
3172
3261
|
// identity-stable EdgePaging callbacks (see dropRef).
|
|
3173
3262
|
dropRef.current = {
|
|
@@ -3220,13 +3309,27 @@ function TimeGridInner<T>(
|
|
|
3220
3309
|
// eslint-disable-next-line react-hooks/exhaustive-deps -- columnsWidth/pagerOffset are stable per width
|
|
3221
3310
|
}, [activeIndex]);
|
|
3222
3311
|
|
|
3223
|
-
// The list reports its offset only as it scrolls; seed it whenever the
|
|
3224
|
-
//
|
|
3225
|
-
|
|
3312
|
+
// The list reports its offset only as it scrolls; seed it whenever the pages are
|
|
3313
|
+
// laid out at a new width. A mounted list resizes its pages in place (see
|
|
3314
|
+
// `listExtraData`), but its native offset keeps the old `index * width`, so
|
|
3315
|
+
// scroll back to the active page. Before paint, so Android's one frame between
|
|
3316
|
+
// the resize and the scroll is blank rather than another page.
|
|
3317
|
+
const laidOutWidthRef = useRef<number | null>(null);
|
|
3318
|
+
useLayoutEffect(() => {
|
|
3226
3319
|
// eslint-disable-next-line react-hooks/immutability -- Reanimated shared value: assigning .value is the intended mutation API
|
|
3227
3320
|
pagerOffset.value = activeIndex * columnsWidth;
|
|
3321
|
+
// The list unmounts at width 0 and remounts on the active page at the next width.
|
|
3322
|
+
if (!pagerReady) {
|
|
3323
|
+
laidOutWidthRef.current = null;
|
|
3324
|
+
return;
|
|
3325
|
+
}
|
|
3326
|
+
const previous = laidOutWidthRef.current;
|
|
3327
|
+
laidOutWidthRef.current = columnsWidth;
|
|
3328
|
+
// The list mounts on its first measured width and opens on the active page.
|
|
3329
|
+
if (previous == null || previous === columnsWidth) return;
|
|
3330
|
+
void listRef.current?.scrollToIndex({ index: activeIndex, animated: false });
|
|
3228
3331
|
// eslint-disable-next-line react-hooks/exhaustive-deps -- reseed on width only; scroll events track index changes
|
|
3229
|
-
}, [columnsWidth, pagerOffset]);
|
|
3332
|
+
}, [columnsWidth, pagerOffset, pagerReady]);
|
|
3230
3333
|
|
|
3231
3334
|
// react-native-web ignores `contentOffset`: retry the seed each frame until the
|
|
3232
3335
|
// scroll view can hold it (the viewport's `onLayout` also tries).
|
|
@@ -3283,7 +3386,7 @@ function TimeGridInner<T>(
|
|
|
3283
3386
|
};
|
|
3284
3387
|
const raf = requestAnimationFrame(lockHorizontal);
|
|
3285
3388
|
return () => cancelAnimationFrame(raf);
|
|
3286
|
-
// Re-run once the list exists at its
|
|
3389
|
+
// Re-run once the list exists at its measured width, and after each resize.
|
|
3287
3390
|
// eslint-disable-next-line react-hooks/exhaustive-deps -- containerRef is stable
|
|
3288
3391
|
}, [columnsWidth]);
|
|
3289
3392
|
|
|
@@ -3337,6 +3440,11 @@ function TimeGridInner<T>(
|
|
|
3337
3440
|
[columnsWidth, pageDates, onChangeDate],
|
|
3338
3441
|
);
|
|
3339
3442
|
|
|
3443
|
+
// Whether a finger is on the pager, between its drag begin and end.
|
|
3444
|
+
const pagerDraggingRef = useRef(false);
|
|
3445
|
+
// Set when the user starts dragging the pager and cleared by the settle it leads to.
|
|
3446
|
+
const pagerUserScrollRef = useRef(false);
|
|
3447
|
+
|
|
3340
3448
|
// A fast fling can outrun the list's on-demand mounting and leave the pager
|
|
3341
3449
|
// blank until something nudges it. When momentum ends, re-anchor the list on
|
|
3342
3450
|
// the page the offset landed on: `scrollToIndex` forces it to recompute its
|
|
@@ -3346,6 +3454,13 @@ function TimeGridInner<T>(
|
|
|
3346
3454
|
const handlePagerSettled = useCallback(
|
|
3347
3455
|
(event: NativeSyntheticEvent<NativeScrollEvent>) => {
|
|
3348
3456
|
if (columnsWidth <= 0) return;
|
|
3457
|
+
// iOS also ends momentum for a programmatic, non-animated scroll, including
|
|
3458
|
+
// the re-anchor below. Settling those would re-anchor every frame and report
|
|
3459
|
+
// a stale page back as the date, so only settle a scroll the user started.
|
|
3460
|
+
// A momentum end while the finger is still down (a snap the new drag cut
|
|
3461
|
+
// short) is not that scroll's settle; keep the flag for the fling that follows.
|
|
3462
|
+
if (!pagerUserScrollRef.current || pagerDraggingRef.current) return;
|
|
3463
|
+
pagerUserScrollRef.current = false;
|
|
3349
3464
|
// Only a user fling can leave the pager blank; a programmatic scroll
|
|
3350
3465
|
// (goToPage, realign) sets `pendingScrollIndexRef` and repaints itself, so
|
|
3351
3466
|
// skip those to avoid a redundant re-anchor during held edge paging.
|
|
@@ -3364,7 +3479,6 @@ function TimeGridInner<T>(
|
|
|
3364
3479
|
// offset left between pages back onto the nearest page (or onto the target of
|
|
3365
3480
|
// an interrupted programmatic scroll). A drag that began and has not reported
|
|
3366
3481
|
// its end waits longer, in case a finger is still holding it.
|
|
3367
|
-
const pagerDraggingRef = useRef(false);
|
|
3368
3482
|
const lastPagerScrollRef = useRef({ offsetX: 0, at: 0 });
|
|
3369
3483
|
const pagerIdleTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
|
|
3370
3484
|
useEffect(
|
|
@@ -3412,6 +3526,7 @@ function TimeGridInner<T>(
|
|
|
3412
3526
|
);
|
|
3413
3527
|
const handlePagerDragStart = useCallback(() => {
|
|
3414
3528
|
pagerDraggingRef.current = true;
|
|
3529
|
+
pagerUserScrollRef.current = true;
|
|
3415
3530
|
}, []);
|
|
3416
3531
|
const handlePagerDragEnd = useCallback(() => {
|
|
3417
3532
|
pagerDraggingRef.current = false;
|
|
@@ -3550,7 +3665,7 @@ function TimeGridInner<T>(
|
|
|
3550
3665
|
// `columnsWidth` resizes the mounted pages when the grid is re-measured.
|
|
3551
3666
|
// `showDragHandle` refreshes grips without requiring an event-data change, and
|
|
3552
3667
|
// `renderCreateGhost` swaps the preview content of mounted pages.
|
|
3553
|
-
//
|
|
3668
|
+
// Refresh mounted pages when the clock, visible days, or indicator setting changes.
|
|
3554
3669
|
const nowTime = now?.getTime();
|
|
3555
3670
|
const listExtraData = useMemo(
|
|
3556
3671
|
() => ({
|
|
@@ -3563,6 +3678,8 @@ function TimeGridInner<T>(
|
|
|
3563
3678
|
dragStepMinutes,
|
|
3564
3679
|
minHour,
|
|
3565
3680
|
maxHour,
|
|
3681
|
+
headerDays,
|
|
3682
|
+
showNowIndicator,
|
|
3566
3683
|
nowTime,
|
|
3567
3684
|
timeZone,
|
|
3568
3685
|
}),
|
|
@@ -3576,6 +3693,8 @@ function TimeGridInner<T>(
|
|
|
3576
3693
|
dragStepMinutes,
|
|
3577
3694
|
minHour,
|
|
3578
3695
|
maxHour,
|
|
3696
|
+
headerDays,
|
|
3697
|
+
showNowIndicator,
|
|
3579
3698
|
nowTime,
|
|
3580
3699
|
timeZone,
|
|
3581
3700
|
],
|
|
@@ -3616,6 +3735,11 @@ function TimeGridInner<T>(
|
|
|
3616
3735
|
scrollEventThrottle={16}
|
|
3617
3736
|
refreshControl={verticalScrollEnabled ? refreshControl : undefined}
|
|
3618
3737
|
contentOffset={{ x: 0, y: mountOffsetY }}
|
|
3738
|
+
contentContainerStyle={
|
|
3739
|
+
contentPaddingBottom > 0 ? { paddingBottom: contentPaddingBottom } : undefined
|
|
3740
|
+
}
|
|
3741
|
+
bounces={verticalBounces}
|
|
3742
|
+
overScrollMode={verticalBounces ? undefined : "never"}
|
|
3619
3743
|
>
|
|
3620
3744
|
<Animated.View testID="time-grid-hours" style={[styles.gridRow, gridHeightStyle]}>
|
|
3621
3745
|
{hourColumnWidth > 0 ? (
|
|
@@ -3633,6 +3757,8 @@ function TimeGridInner<T>(
|
|
|
3633
3757
|
weekNumber={weekNumber}
|
|
3634
3758
|
ampm={ampm}
|
|
3635
3759
|
hourComponent={hourComponent}
|
|
3760
|
+
renderNowLabel={renderNowLabel}
|
|
3761
|
+
nowPosition={gutterNow}
|
|
3636
3762
|
/>
|
|
3637
3763
|
) : null}
|
|
3638
3764
|
<View
|
|
@@ -3659,9 +3785,7 @@ function TimeGridInner<T>(
|
|
|
3659
3785
|
{pagerReady ? (
|
|
3660
3786
|
<AnimatedLegendList
|
|
3661
3787
|
// Mounts once the pager has measured, so the fixed item size is
|
|
3662
|
-
// right from the list's first layout
|
|
3663
|
-
// later width change (a rotation, a re-measured container).
|
|
3664
|
-
key={`grid-${columnsWidth}`}
|
|
3788
|
+
// right from the list's first layout.
|
|
3665
3789
|
ref={listRef}
|
|
3666
3790
|
style={isWeb ? [styles.pagerList, styles.webNoScroll] : styles.pagerList}
|
|
3667
3791
|
data={pageDates}
|
|
@@ -3697,12 +3821,10 @@ function TimeGridInner<T>(
|
|
|
3697
3821
|
disableIntervalMomentum: !freeSwipe,
|
|
3698
3822
|
scrollEventThrottle: 16,
|
|
3699
3823
|
onMomentumScrollEnd: handlePagerSettled,
|
|
3824
|
+
onScrollBeginDrag: handlePagerDragStart,
|
|
3825
|
+
onScrollEndDrag: handlePagerDragEnd,
|
|
3700
3826
|
...(Platform.OS === "android"
|
|
3701
|
-
? {
|
|
3702
|
-
onScroll: handlePagerScroll,
|
|
3703
|
-
onScrollBeginDrag: handlePagerDragStart,
|
|
3704
|
-
onScrollEndDrag: handlePagerDragEnd,
|
|
3705
|
-
}
|
|
3827
|
+
? { onScroll: handlePagerScroll }
|
|
3706
3828
|
: null),
|
|
3707
3829
|
})}
|
|
3708
3830
|
initialScrollIndex={activeIndex}
|
|
@@ -4025,6 +4147,11 @@ const styles = StyleSheet.create({
|
|
|
4025
4147
|
textAlign: "right",
|
|
4026
4148
|
paddingRight: 6,
|
|
4027
4149
|
},
|
|
4150
|
+
nowLabel: {
|
|
4151
|
+
position: "absolute",
|
|
4152
|
+
left: 0,
|
|
4153
|
+
marginTop: -HOUR_LABEL_NUDGE,
|
|
4154
|
+
},
|
|
4028
4155
|
gutterRows: {
|
|
4029
4156
|
position: "absolute",
|
|
4030
4157
|
left: 0,
|
package/src/index.tsx
CHANGED