Skip to content

Commit

Permalink
Merge branch 'master' into discord-fork-4.6.1
Browse files Browse the repository at this point in the history
  • Loading branch information
haileyok authored Apr 29, 2024
2 parents 54dc2e0 + 855024f commit 3f7a1b1
Show file tree
Hide file tree
Showing 11 changed files with 28 additions and 140 deletions.
13 changes: 0 additions & 13 deletions src/components/bottomSheet/BottomSheet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,6 @@ import {
INITIAL_CONTAINER_OFFSET,
INITIAL_VALUE,
DEFAULT_DYNAMIC_SIZING,
DEFAULT_ACCESSIBLE,
DEFAULT_ACCESSIBILITY_LABEL,
DEFAULT_ACCESSIBILITY_ROLE
} from './constants';
import type { BottomSheetMethods, Insets } from '../../types';
import type { BottomSheetProps, AnimateToPositionType } from './types';
Expand Down Expand Up @@ -164,13 +161,6 @@ const BottomSheetComponent = forwardRef<BottomSheet, BottomSheetProps>(
backgroundComponent,
renderFooter,
children: Content,

// accessibility
accessible: _providedAccessible = DEFAULT_ACCESSIBLE,
accessibilityLabel:
_providedAccessibilityLabel = DEFAULT_ACCESSIBILITY_LABEL,
accessibilityRole:
_providedAccessibilityRole = DEFAULT_ACCESSIBILITY_ROLE,
} = props;
//#endregion

Expand Down Expand Up @@ -1666,9 +1656,6 @@ const BottomSheetComponent = forwardRef<BottomSheet, BottomSheetProps>(
<Animated.View
pointerEvents="box-none"
style={contentMaskContainerStyle}
accessible={_providedAccessible ?? undefined}
accessibilityRole={_providedAccessibilityRole ?? undefined}
accessibilityLabel={_providedAccessibilityLabel ?? undefined}
>
<BottomSheetDraggableView
key="BottomSheetRootDraggableView"
Expand Down
15 changes: 0 additions & 15 deletions src/components/bottomSheet/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,6 @@ const INITIAL_CONTAINER_OFFSET = {
const INITIAL_HANDLE_HEIGHT = -999;
const INITIAL_POSITION = SCREEN_HEIGHT;

// accessibility
const DEFAULT_ACCESSIBLE = true;
const DEFAULT_ACCESSIBILITY_LABEL = 'Bottom Sheet';
const DEFAULT_ACCESSIBILITY_ROLE = 'adjustable';
const DEFAULT_ENABLE_ACCESSIBILITY_CHANGE_ANNOUNCEMENT = true;
const DEFAULT_ACCESSIBILITY_POSITION_CHANGE_ANNOUNCEMENT = (
positionInScreen: string
) => `Bottom sheet snapped to ${positionInScreen}% of the screen`;

export {
DEFAULT_HANDLE_HEIGHT,
DEFAULT_OVER_DRAG_RESISTANCE_FACTOR,
Expand All @@ -62,10 +53,4 @@ export {
INITIAL_HANDLE_HEIGHT,
INITIAL_SNAP_POINT,
INITIAL_VALUE,
// accessibility
DEFAULT_ACCESSIBLE,
DEFAULT_ACCESSIBILITY_LABEL,
DEFAULT_ACCESSIBILITY_ROLE,
DEFAULT_ENABLE_ACCESSIBILITY_CHANGE_ANNOUNCEMENT,
DEFAULT_ACCESSIBILITY_POSITION_CHANGE_ANNOUNCEMENT,
};
8 changes: 2 additions & 6 deletions src/components/bottomSheet/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@ import type {
KEYBOARD_BLUR_BEHAVIOR,
KEYBOARD_INPUT_MODE,
} from '../../constants';
import type {
GestureEventsHandlersHookType,
NullableAccessibilityProps,
} from '../../types';
import type { GestureEventsHandlersHookType } from '../../types';

export interface BottomSheetProps
extends BottomSheetAnimationConfigs,
Expand All @@ -34,8 +31,7 @@ export interface BottomSheetProps
| 'waitFor'
| 'simultaneousHandlers'
>
>,
Omit<NullableAccessibilityProps, 'accessibilityHint'> {
> {
//#region configuration
/**
* Initial snap point index, provide `-1` to initiate bottom sheet in closed state.
Expand Down
64 changes: 17 additions & 47 deletions src/components/bottomSheetBackdrop/BottomSheetBackdrop.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
import React, {
memo,
useCallback,
useEffect,
useMemo,
useRef,
useState,
} from 'react';
import type { ViewProps } from 'react-native';
import React, { memo, useCallback, useMemo, useRef, useState } from 'react';
import { ViewProps } from 'react-native';
import Animated, {
interpolate,
Extrapolate,
Expand All @@ -26,10 +19,6 @@ import {
DEFAULT_DISAPPEARS_ON_INDEX,
DEFAULT_ENABLE_TOUCH_THROUGH,
DEFAULT_PRESS_BEHAVIOR,
DEFAULT_ACCESSIBLE,
DEFAULT_ACCESSIBILITY_ROLE,
DEFAULT_ACCESSIBILITY_LABEL,
DEFAULT_ACCESSIBILITY_HINT,
} from './constants';
import { styles } from './styles';
import type { BottomSheetDefaultBackdropProps } from './types';
Expand All @@ -44,10 +33,6 @@ const BottomSheetBackdropComponent = ({
onPress,
style,
children,
accessible: _providedAccessible = DEFAULT_ACCESSIBLE,
accessibilityRole: _providedAccessibilityRole = DEFAULT_ACCESSIBILITY_ROLE,
accessibilityLabel: _providedAccessibilityLabel = DEFAULT_ACCESSIBILITY_LABEL,
accessibilityHint: _providedAccessibilityHint = DEFAULT_ACCESSIBILITY_HINT,
}: BottomSheetDefaultBackdropProps) => {
//#region hooks
const { snapToIndex, close } = useBottomSheet();
Expand Down Expand Up @@ -129,43 +114,28 @@ const BottomSheetBackdropComponent = ({
},
[disappearsOnIndex]
);

// addressing updating the state after unmounting.
// [link](https://github.com/gorhom/react-native-bottom-sheet/issues/1376)
useEffect(() => {
isMounted.current = true;
return () => {
isMounted.current = false;
};
}, []);
//#endregion

const AnimatedView = (
<Animated.View
style={containerStyle}
pointerEvents={pointerEvents}
accessible={_providedAccessible ?? undefined}
accessibilityRole={_providedAccessibilityRole ?? undefined}
accessibilityLabel={_providedAccessibilityLabel ?? undefined}
accessibilityHint={
_providedAccessibilityHint
? _providedAccessibilityHint
: `Tap to ${
typeof pressBehavior === 'string' ? pressBehavior : 'move'
} the Bottom Sheet`
}
>
{children}
</Animated.View>
);

return pressBehavior !== 'none' ? (
// @ts-ignore
<TapGestureHandler onGestureEvent={gestureHandler}>
{AnimatedView}
<Animated.View
style={containerStyle}
pointerEvents={pointerEvents}
accessible={true}
accessibilityRole="button"
accessibilityLabel="Bottom Sheet backdrop"
accessibilityHint={`Tap to ${
typeof pressBehavior === 'string' ? pressBehavior : 'move'
} the Bottom Sheet`}
>
{children}
</Animated.View>
</TapGestureHandler>
) : (
AnimatedView
<Animated.View pointerEvents={pointerEvents} style={containerStyle}>
{children}
</Animated.View>
);
};

Expand Down
9 changes: 0 additions & 9 deletions src/components/bottomSheetBackdrop/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,10 @@ const DEFAULT_DISAPPEARS_ON_INDEX = 0;
const DEFAULT_ENABLE_TOUCH_THROUGH = false;
const DEFAULT_PRESS_BEHAVIOR = 'close' as const;

const DEFAULT_ACCESSIBLE = true;
const DEFAULT_ACCESSIBILITY_ROLE = 'button';
const DEFAULT_ACCESSIBILITY_LABEL = 'Bottom sheet backdrop';
const DEFAULT_ACCESSIBILITY_HINT = 'Tap to close the bottom sheet';

export {
DEFAULT_OPACITY,
DEFAULT_APPEARS_ON_INDEX,
DEFAULT_DISAPPEARS_ON_INDEX,
DEFAULT_ENABLE_TOUCH_THROUGH,
DEFAULT_PRESS_BEHAVIOR,
DEFAULT_ACCESSIBLE,
DEFAULT_ACCESSIBILITY_ROLE,
DEFAULT_ACCESSIBILITY_LABEL,
DEFAULT_ACCESSIBILITY_HINT,
};
8 changes: 2 additions & 6 deletions src/components/bottomSheetBackdrop/types.d.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import { ReactNode } from 'react';
import type { ViewProps } from 'react-native';
import type {
BottomSheetVariables,
NullableAccessibilityProps,
} from '../../types';
import type { BottomSheetVariables } from '../../types';

export interface BottomSheetBackdropProps
extends Pick<ViewProps, 'style'>,
Expand All @@ -12,8 +9,7 @@ export interface BottomSheetBackdropProps
export type BackdropPressBehavior = 'none' | 'close' | 'collapse' | number;

export interface BottomSheetDefaultBackdropProps
extends BottomSheetBackdropProps,
NullableAccessibilityProps {
extends BottomSheetBackdropProps {
/**
* Backdrop opacity.
* @type number
Expand Down
18 changes: 1 addition & 17 deletions src/components/bottomSheetHandle/BottomSheetHandle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,11 @@ import React, { memo, useMemo } from 'react';
import Animated from 'react-native-reanimated';
import { styles } from './styles';
import type { BottomSheetDefaultHandleProps } from './types';
import {
DEFAULT_ACCESSIBLE,
DEFAULT_ACCESSIBILITY_ROLE,
DEFAULT_ACCESSIBILITY_LABEL,
DEFAULT_ACCESSIBILITY_HINT,
} from './constants';

const BottomSheetHandleComponent = ({
style,
indicatorStyle: _indicatorStyle,
children,
accessible = DEFAULT_ACCESSIBLE,
accessibilityRole = DEFAULT_ACCESSIBILITY_ROLE,
accessibilityLabel = DEFAULT_ACCESSIBILITY_LABEL,
accessibilityHint = DEFAULT_ACCESSIBILITY_HINT,
}: BottomSheetDefaultHandleProps) => {
// styles
const containerStyle = useMemo(
Expand All @@ -33,13 +23,7 @@ const BottomSheetHandleComponent = ({

// render
return (
<Animated.View
style={containerStyle}
accessible={accessible ?? undefined}
accessibilityRole={accessibilityRole ?? undefined}
accessibilityLabel={accessibilityLabel ?? undefined}
accessibilityHint={accessibilityHint ?? undefined}
>
<Animated.View style={containerStyle}>
<Animated.View style={indicatorStyle} />
{children}
</Animated.View>
Expand Down
12 changes: 0 additions & 12 deletions src/components/bottomSheetHandle/constants.ts

This file was deleted.

9 changes: 2 additions & 7 deletions src/components/bottomSheetHandle/types.d.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
import type React from 'react';
import type { ViewProps } from 'react-native';
import type { AnimateProps } from 'react-native-reanimated';
import type {
BottomSheetVariables,
NullableAccessibilityProps,
} from '../../types';
import type { BottomSheetVariables } from '../../types';

export interface BottomSheetHandleProps extends BottomSheetVariables {}

export interface BottomSheetDefaultHandleProps
extends BottomSheetHandleProps,
NullableAccessibilityProps {
export interface BottomSheetDefaultHandleProps extends BottomSheetHandleProps {
/**
* View style to be applied to the handle container.
* @type Animated.AnimateStyle<ViewStyle> | ViewStyle
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ function BottomSheetHandleContainerComponent({
>
<Animated.View
key="BottomSheetHandleContainer"
accessible={true}
accessibilityRole="adjustable"
accessibilityLabel="Bottom Sheet handle"
accessibilityHint="Drag up or down to extend or minimize the Bottom Sheet"
onLayout={handleContainerLayout}
>
<HandleComponent
Expand Down
8 changes: 0 additions & 8 deletions src/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import type {
SectionList,
NativeScrollEvent,
NativeSyntheticEvent,
AccessibilityProps,
} from 'react-native';
import type {
GestureEventPayload,
Expand Down Expand Up @@ -168,10 +167,3 @@ export type ScrollEventsHandlersHookType = (
handleOnMomentumEnd?: ScrollEventHandlerCallbackType;
};
//#endregion

export interface NullableAccessibilityProps extends AccessibilityProps {
accessible?: AccessibilityProps['accessible'] | null;
accessibilityLabel?: AccessibilityProps['accessibilityLabel'] | null;
accessibilityHint?: AccessibilityProps['accessibilityHint'] | null;
accessibilityRole?: AccessibilityProps['accessibilityRole'] | null;
}

0 comments on commit 3f7a1b1

Please sign in to comment.