mirror of
https://github.com/zhigang1992/react-navigation.git
synced 2026-02-10 09:13:43 +08:00
fix: remove dep on react-native-iphonex-helper
This commit is contained in:
@@ -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 }],
|
||||
|
||||
Reference in New Issue
Block a user