Skip to content

Commit

Permalink
Support DynamicColorIOS (#7248)
Browse files Browse the repository at this point in the history
* Support DynamicColorIOS

* Update OptionsProcessor.ts
  • Loading branch information
yogevbd authored Sep 5, 2021
1 parent 67b5798 commit ba722f8
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
13 changes: 12 additions & 1 deletion lib/src/commands/OptionsProcessor.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +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';
import { DynamicColorIOS, Platform } from 'react-native';

describe('navigation options', () => {
let uut: OptionsProcessor;
Expand Down Expand Up @@ -574,6 +574,17 @@ describe('navigation options', () => {
},
});
});

it('supports DynamicColorIOS', () => {
const options: Options = {
topBar: { background: { color: DynamicColorIOS({ light: 'red', dark: 'blue' }) } },
};

uut.processOptions(options, CommandName.SetRoot);
expect(options).toEqual({
topBar: { background: { color: { dynamic: { light: 0xffff0000, dark: 0xff0000ff } } } },
});
});
});
});

Expand Down
6 changes: 6 additions & 0 deletions lib/src/commands/OptionsProcessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,12 @@ export class OptionsProcessor {
if ('semantic' in value || 'resource_paths' in value) {
options[key] = value;
return;
} else if ('dynamic' in value) {
for (let keyColor in value.dynamic) {
newColorObj[keyColor] = this.colorService.toNativeColor(value.dynamic[keyColor]);
}

options[key] = newColorObj;
} else {
for (let keyColor in value) {
newColorObj[keyColor] = this.colorService.toNativeColor(value[keyColor]);
Expand Down

0 comments on commit ba722f8

Please sign in to comment.