fix: remove dep on react-native-iphonex-helper

This commit is contained in:
Satyajit Sahoo
2021-07-31 01:25:15 +02:00
parent 6d518a46b8
commit 8a95fb588b
3 changed files with 10 additions and 7 deletions

View File

@@ -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 }],