From fcf3cd3c8ac7b8ed485a08837e26dbce70a87dcb Mon Sep 17 00:00:00 2001 From: "satyajit.happy" Date: Tue, 8 Oct 2019 15:46:16 +0200 Subject: [PATCH] fix: make modal presentation mode fullscreen on landscape --- .../CardStyleInterpolators.tsx | 34 ++++++++++++------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/src/TransitionConfigs/CardStyleInterpolators.tsx b/src/TransitionConfigs/CardStyleInterpolators.tsx index c24db38da..16192490d 100644 --- a/src/TransitionConfigs/CardStyleInterpolators.tsx +++ b/src/TransitionConfigs/CardStyleInterpolators.tsx @@ -82,7 +82,8 @@ export function forModalPresentationIOS({ layouts: { screen }, insets, }: CardInterpolationProps): CardInterpolatedStyle { - const topOffset = 10; + const isLandscape = screen.width > screen.height; + const topOffset = isLandscape ? 0 : 10; const statusBarHeight = insets.top; const aspectRatio = screen.height / screen.width; @@ -102,18 +103,25 @@ export function forModalPresentationIOS({ outputRange: [0, 0.3, 1], }); - const scale = interpolate(progress, { - inputRange: [0, 1, 2], - outputRange: [1, 1, screen.width ? 1 - (topOffset * 2) / screen.width : 1], - }); - - const borderRadius = - index === 0 - ? interpolate(progress, { - inputRange: [0, 1, 2], - outputRange: [0, 0, 10], - }) - : 10; + const scale = isLandscape + ? 1 + : interpolate(progress, { + inputRange: [0, 1, 2], + outputRange: [ + 1, + 1, + screen.width ? 1 - (topOffset * 2) / screen.width : 1, + ], + }); + + const borderRadius = isLandscape + ? 0 + : index === 0 + ? interpolate(progress, { + inputRange: [0, 1, 2], + outputRange: [0, 0, 10], + }) + : 10; return { cardStyle: {