Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix setRoot animations on iOS #7071

Merged
merged 1 commit into from
Apr 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion lib/src/commands/OptionsProcessor.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { AssetService } from '../adapters/AssetResolver';
import { Deprecations } from './Deprecations';
import { CommandName } from '../interfaces/CommandName';
import { OptionsProcessor as Processor } from '../interfaces/Processors';
import { Platform } from 'react-native';

describe('navigation options', () => {
let uut: OptionsProcessor;
Expand Down Expand Up @@ -52,7 +53,8 @@ describe('navigation options', () => {
);
});

it('processes old setRoot animation value to new enter exit format', () => {
it('processes old setRoot animation value to new enter exit format on Android', () => {
Platform.OS = 'android';
const options: Options = {
animations: {
setRoot: {
Expand Down Expand Up @@ -84,6 +86,7 @@ describe('navigation options', () => {
uut.processOptions(options, CommandName.SetRoot);
expect(options).toEqual(expectedOptions);
});

describe('Modal Animation Options', () => {
describe('Show Modal', () => {
it('processes old options into new options,backwards compatibility ', () => {
Expand Down
5 changes: 4 additions & 1 deletion lib/src/commands/OptionsProcessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
import { Deprecations } from './Deprecations';
import { OptionProcessorsStore } from '../processors/OptionProcessorsStore';
import { CommandName } from '../interfaces/CommandName';
import { Platform } from 'react-native';

export class OptionsProcessor {
constructor(
Expand Down Expand Up @@ -284,10 +285,12 @@ export class OptionsProcessor {
parentOptions: AnimationOptions
) {
if (key !== 'setRoot') return;
if (!('enter' in animation)) {
if (Platform.OS === 'android' && !('enter' in animation)) {
parentOptions.setRoot = {
enter: animation,
} as EnterExitAnimationOptions;
} else if (Platform.OS === 'ios' && 'enter' in animation) {
parentOptions.setRoot = animation;
}
}

Expand Down