From 8a95fb588bd1f8a72fc4ef4e847f06e103ed55fe Mon Sep 17 00:00:00 2001 From: Satyajit Sahoo Date: Sat, 31 Jul 2021 01:25:15 +0200 Subject: [PATCH] fix: remove dep on react-native-iphonex-helper --- packages/stack/package.json | 1 - .../TransitionConfigs/CardStyleInterpolators.tsx | 14 +++++++++----- yarn.lock | 2 +- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/packages/stack/package.json b/packages/stack/package.json index f599f8cd..cf082562 100644 --- a/packages/stack/package.json +++ b/packages/stack/package.json @@ -42,7 +42,6 @@ "dependencies": { "@react-navigation/elements": "^1.0.0-next.21", "color": "^3.1.3", - "react-native-iphone-x-helper": "^1.3.0", "warn-once": "^0.1.0" }, "devDependencies": { diff --git a/packages/stack/src/TransitionConfigs/CardStyleInterpolators.tsx b/packages/stack/src/TransitionConfigs/CardStyleInterpolators.tsx index 1a089200..a59b8d73 100644 --- a/packages/stack/src/TransitionConfigs/CardStyleInterpolators.tsx +++ b/packages/stack/src/TransitionConfigs/CardStyleInterpolators.tsx @@ -1,5 +1,4 @@ -import { Animated } from 'react-native'; -import { isIphoneX } from 'react-native-iphone-x-helper'; +import { Animated, Platform } from 'react-native'; import type { StackCardInterpolatedStyle, @@ -99,6 +98,11 @@ export function forModalPresentationIOS({ layouts: { screen }, insets, }: StackCardInterpolationProps): StackCardInterpolatedStyle { + const hasNotchIos = + Platform.OS === 'ios' && + !Platform.isPad && + !Platform.isTVOS && + insets.top > 20; const isLandscape = screen.width > screen.height; const topOffset = isLandscape ? 0 : 10; const statusBarHeight = insets.top; @@ -154,7 +158,7 @@ export function forModalPresentationIOS({ : isFirst ? progress.interpolate({ inputRange: [0, 1, 1.0001, 2], - outputRange: [0, 0, isIphoneX() ? 38 : 0, 10], + outputRange: [0, 0, hasNotchIos ? 38 : 0, 10], }) : 10; @@ -165,8 +169,8 @@ export function forModalPresentationIOS({ borderTopRightRadius: borderRadius, // We don't need these for the animation // But different border radius for corners improves animation perf - borderBottomLeftRadius: isIphoneX() ? borderRadius : 0, - borderBottomRightRadius: isIphoneX() ? borderRadius : 0, + borderBottomLeftRadius: hasNotchIos ? borderRadius : 0, + borderBottomRightRadius: hasNotchIos ? borderRadius : 0, marginTop: isFirst ? 0 : statusBarHeight, marginBottom: isFirst ? 0 : topOffset, transform: [{ translateY }, { scale }], diff --git a/yarn.lock b/yarn.lock index 3f72c988..59112eaa 100644 --- a/yarn.lock +++ b/yarn.lock @@ -17744,7 +17744,7 @@ react-native-gesture-handler@~1.10.2: invariant "^2.2.4" prop-types "^15.7.2" -react-native-iphone-x-helper@^1.3.0, react-native-iphone-x-helper@^1.3.1: +react-native-iphone-x-helper@^1.3.1: version "1.3.1" resolved "https://registry.yarnpkg.com/react-native-iphone-x-helper/-/react-native-iphone-x-helper-1.3.1.tgz#20c603e9a0e765fd6f97396638bdeb0e5a60b010" integrity sha512-HOf0jzRnq2/aFUcdCJ9w9JGzN3gdEg0zFE4FyYlp4jtidqU03D5X7ZegGKfT1EWteR0gPBGp9ye5T5FvSWi9Yg==