MM-36745 Fix animation for showModalOverCurrentContext (#5507)

This commit is contained in:
Elias Nahum 2021-07-06 14:04:31 -04:00 committed by GitHub
parent 2754b00f83
commit df26a363bc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 45 additions and 34 deletions

View file

@ -293,7 +293,44 @@ export function showModal(name, title, passProps = {}, options = {}) {
export function showModalOverCurrentContext(name, passProps = {}, options = {}) {
const title = '';
const animationsEnabled = (Platform.OS === 'android').toString();
let animations;
switch (Platform.OS) {
case 'android':
animations = {
showModal: {
waitForRender: true,
alpha: {
from: 0,
to: 1,
duration: 250,
},
},
dismissModal: {
alpha: {
from: 1,
to: 0,
duration: 250,
},
},
};
break;
default:
animations = {
showModal: {
enabled: false,
enter: {},
exit: {},
},
dismissModal: {
enabled: false,
enter: {},
exit: {},
},
};
break;
}
const defaultOptions = {
modalPresentationStyle: 'overCurrentContext',
layout: {
@ -304,25 +341,7 @@ export function showModalOverCurrentContext(name, passProps = {}, options = {})
visible: false,
height: 0,
},
animations: {
showModal: {
waitForRender: true,
enabled: animationsEnabled,
alpha: {
from: 0,
to: 1,
duration: 250,
},
},
dismissModal: {
enabled: animationsEnabled,
alpha: {
from: 1,
to: 0,
duration: 250,
},
},
},
animations,
};
const mergeOptions = merge(defaultOptions, options);

View file

@ -301,7 +301,6 @@ describe('@actions/navigation', () => {
test('showModalOverCurrentContext should call Navigation.showModal', () => {
const showModal = jest.spyOn(Navigation, 'showModal');
const animationsEnabled = (Platform.OS === 'android').toString();
const showModalOverCurrentContextTitle = '';
const showModalOverCurrentContextOptions = {
modalPresentationStyle: 'overCurrentContext',
@ -315,21 +314,14 @@ describe('@actions/navigation', () => {
},
animations: {
showModal: {
waitForRender: true,
enabled: animationsEnabled,
alpha: {
from: 0,
to: 1,
duration: 250,
},
enabled: false,
enter: {},
exit: {},
},
dismissModal: {
enabled: animationsEnabled,
alpha: {
from: 1,
to: 0,
duration: 250,
},
enabled: false,
enter: {},
exit: {},
},
},
};