Skip to content

Commit

Permalink
fix: remove dep on react-native-iphonex-helper
Browse files Browse the repository at this point in the history
  • Loading branch information
satya164 committed Jul 30, 2021
1 parent 6d518a4 commit 8a95fb5
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
1 change: 0 additions & 1 deletion packages/stack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
14 changes: 9 additions & 5 deletions packages/stack/src/TransitionConfigs/CardStyleInterpolators.tsx
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand All @@ -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 }],
Expand Down
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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==
Expand Down

0 comments on commit 8a95fb5

Please sign in to comment.