Skip to content

Commit

Permalink
Show deprecation warning while toggling bottomTabs visibility on iOS (#…
Browse files Browse the repository at this point in the history
…6409)

On iOS the system doesn't support dynamically toggling bottomTabs at all so we had to hack through it which resulted in many issues with this feature. We plan on entirely removing it and stick to the framework's guidelines which means that toggling the bottomTabs will not be possible at all and controlling it with static options will be the only option.
  • Loading branch information
yogevbd authored Jul 22, 2020
1 parent 4f4a04e commit aaef66b
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 5 deletions.
22 changes: 18 additions & 4 deletions lib/src/commands/Deprecations.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,24 @@
import once from 'lodash/once';
import { Platform } from 'react-native';

export class Deprecations {
public onProcessOptions(_key: string, _parentOptions: Record<string, any>) {

public onProcessOptions(key: string, parentOptions: Record<string, any>, commandName: string) {
if (
key === 'bottomTabs' &&
parentOptions[key].visible !== undefined &&
Platform.OS === 'ios' &&
commandName === 'mergeOptions'
) {
this.deprecateBottomTabsVisibility(parentOptions);
}
}

public onProcessDefaultOptions(_key: string, _parentOptions: Record<string, any>) {
public onProcessDefaultOptions(_key: string, _parentOptions: Record<string, any>) {}

}
private deprecateBottomTabsVisibility = once((parentOptions: object) => {
console.warn(
`toggling bottomTabs visibility is deprecated on iOS. For more information see https://github.com/wix/react-native-navigation/issues/6416`,
parentOptions
);
});
}
11 changes: 11 additions & 0 deletions lib/src/commands/OptionsProcessor.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,4 +208,15 @@ describe('navigation options', () => {
verify(mockedStore.ensureClassForName('helloThere1')).called();
verify(mockedStore.ensureClassForName('helloThere2')).called();
});

it('show warning on iOS when toggling bottomTabs visibility through mergeOptions', () => {
jest.spyOn(console, 'warn');
uut.processOptions({ bottomTabs: { visible: false } }, 'mergeOptions');
expect(console.warn).toBeCalledWith(
'toggling bottomTabs visibility is deprecated on iOS. For more information see https://github.com/wix/react-native-navigation/issues/6416',
{
bottomTabs: { visible: false },
}
);
});
});
2 changes: 1 addition & 1 deletion lib/src/commands/OptionsProcessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export class OptionsProcessor {
options,
clone(options),
(key, parentOptions) => {
this.deprecations.onProcessOptions(key, parentOptions);
this.deprecations.onProcessOptions(key, parentOptions, commandName);
},
commandName
);
Expand Down

0 comments on commit aaef66b

Please sign in to comment.