feat: add approximate android Q transition

This commit is contained in:
satyajit.happy
2019-09-04 11:36:00 +02:00
parent a022860317
commit 196cce0803
3 changed files with 59 additions and 1 deletions

View File

@@ -198,3 +198,34 @@ export function forRevealFromBottomAndroid({
overlayStyle: { opacity: overlayOpacity },
};
}
/**
* Standard Android-style reveal from the bottom for Android Q.
* TODO: Update this with correct values when AOSP is updated.
*/
export function forScaleFromCenterAndroid({
current,
next,
}: CardInterpolationProps): CardInterpolatedStyle {
const cardOpacityFocused = interpolate(current.progress, {
inputRange: [0, 0.5, 1],
outputRange: [0, 1, 1],
});
const cardScaleFocused = interpolate(current.progress, {
inputRange: [0, 1],
outputRange: [0.9, 1],
});
const cardScaleUnFocused = next
? interpolate(next.progress, {
inputRange: [0, 1],
outputRange: [1, 1.1],
})
: 1;
return {
containerStyle: {
opacity: cardOpacityFocused,
transform: [{ scale: cardScaleFocused }, { scale: cardScaleUnFocused }],
},
};
}

View File

@@ -1,6 +1,7 @@
import {
forHorizontalIOS,
forVerticalIOS,
forScaleFromCenterAndroid,
forRevealFromBottomAndroid,
forFadeFromBottomAndroid,
forModalPresentationIOS,
@@ -8,6 +9,7 @@ import {
import { forNoAnimation, forFade } from './HeaderStyleInterpolators';
import {
TransitionIOSSpec,
ScaleFromCenterAndroidSpec,
RevealFromBottomAndroidSpec,
FadeOutToBottomAndroidSpec,
FadeInFromBottomAndroidSpec,
@@ -70,7 +72,7 @@ export const FadeFromBottomAndroid: TransitionPreset = {
};
/**
* Standard Android navigation transition when opening or closing an Activity on Android >= 9 (Pie).
* Standard Android navigation transition when opening or closing an Activity on Android 9 (Pie).
*/
export const RevealFromBottomAndroid: TransitionPreset = {
gestureDirection: 'vertical',
@@ -82,6 +84,19 @@ export const RevealFromBottomAndroid: TransitionPreset = {
headerStyleInterpolator: forNoAnimation,
};
/**
* Standard Android navigation transition when opening or closing an Activity on Android 10 (Q).
*/
export const ScaleFromCenterAndroid: TransitionPreset = {
gestureDirection: 'horizontal',
transitionSpec: {
open: ScaleFromCenterAndroidSpec,
close: ScaleFromCenterAndroidSpec,
},
cardStyleInterpolator: forScaleFromCenterAndroid,
headerStyleInterpolator: forNoAnimation,
};
/**
* Default navigation transition for the current platform.
*/

View File

@@ -53,3 +53,15 @@ export const RevealFromBottomAndroidSpec: TransitionSpec = {
easing: Easing.bezier(0.35, 0.45, 0, 1),
},
};
/**
* Approximate configuration for activity open animation from Android Q.
* TODO: Update this with correct values when AOSP is updated.
*/
export const ScaleFromCenterAndroidSpec: TransitionSpec = {
animation: 'timing',
config: {
duration: 425,
easing: Easing.bezier(0.35, 0.45, 0, 1),
},
};