MM-36745 Fix animation for showModalOverCurrentContext (#5507) (#5510)

(cherry picked from commit df26a363bc)

Co-authored-by: Elias Nahum <nahumhbl@gmail.com>
This commit is contained in:
Mattermost Build
2021-07-06 20:31:15 +02:00
committed by GitHub
parent 9c15ae1c5b
commit ac5914ef15
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: {},
},
},
};