Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions src/BottomSheetBackdrop.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import Animated, {
useAnimatedStyle,
} from 'react-native-reanimated';
import { getAnimatedIndex } from './animatedRegistry';
import { useSheetStatus } from './bottomSheet.store';

interface BottomSheetBackdropProps {
sheetId: string;
Expand All @@ -16,9 +15,7 @@ export function BottomSheetBackdrop({
sheetId,
onPress,
}: BottomSheetBackdropProps) {
const status = useSheetStatus(sheetId);
const animatedIndex = getAnimatedIndex(sheetId);
const isInteractive = status === 'open';

const animatedStyle = useAnimatedStyle(() => {
const opacity = interpolate(
Expand All @@ -35,9 +32,7 @@ export function BottomSheetBackdrop({
<Pressable
style={StyleSheet.absoluteFillObject}
onPress={() => {
if (isInteractive) {
onPress?.();
}
onPress?.();
}}
>
<Animated.View
Expand Down
4 changes: 4 additions & 0 deletions src/store/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ export function isHidden(sheet: BottomSheetState | undefined): boolean {
return sheet?.status === 'hidden';
}

export function isOpening(sheet: BottomSheetState | undefined): boolean {
return sheet?.status === 'opening';
}

export function updateSheet(
sheetsById: Record<string, BottomSheetState>,
id: string,
Expand Down
3 changes: 2 additions & 1 deletion src/store/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
getTopSheetId,
isActivatableKeepMounted,
isHidden,
isOpening,
removeFromStack,
updateSheet,
} from './helpers';
Expand Down Expand Up @@ -66,7 +67,7 @@ export const useBottomSheetStore = create(
startClosing: (id) =>
set((state) => {
const sheet = state.sheetsById[id];
if (!sheet || isHidden(sheet)) return state;
if (!sheet || isHidden(sheet) || isOpening(sheet)) return state;

let updatedSheetsById = updateSheet(state.sheetsById, id, {
status: 'closing',
Expand Down
Loading