mirror of
https://github.com/zhigang1992/react-navigation.git
synced 2026-03-06 17:34:59 +08:00
feat: add approximate android Q transition
This commit is contained in:
@@ -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 }],
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
@@ -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),
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user