Skip to content

Commit ba722f8

Browse files
authored
Support DynamicColorIOS (#7248)
* Support DynamicColorIOS * Update OptionsProcessor.ts
1 parent 67b5798 commit ba722f8

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

lib/src/commands/OptionsProcessor.test.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { AssetService } from '../adapters/AssetResolver';
1313
import { Deprecations } from './Deprecations';
1414
import { CommandName } from '../interfaces/CommandName';
1515
import { OptionsProcessor as Processor } from '../interfaces/Processors';
16-
import { Platform } from 'react-native';
16+
import { DynamicColorIOS, Platform } from 'react-native';
1717

1818
describe('navigation options', () => {
1919
let uut: OptionsProcessor;
@@ -574,6 +574,17 @@ describe('navigation options', () => {
574574
},
575575
});
576576
});
577+
578+
it('supports DynamicColorIOS', () => {
579+
const options: Options = {
580+
topBar: { background: { color: DynamicColorIOS({ light: 'red', dark: 'blue' }) } },
581+
};
582+
583+
uut.processOptions(options, CommandName.SetRoot);
584+
expect(options).toEqual({
585+
topBar: { background: { color: { dynamic: { light: 0xffff0000, dark: 0xff0000ff } } } },
586+
});
587+
});
577588
});
578589
});
579590

lib/src/commands/OptionsProcessor.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,12 @@ export class OptionsProcessor {
123123
if ('semantic' in value || 'resource_paths' in value) {
124124
options[key] = value;
125125
return;
126+
} else if ('dynamic' in value) {
127+
for (let keyColor in value.dynamic) {
128+
newColorObj[keyColor] = this.colorService.toNativeColor(value.dynamic[keyColor]);
129+
}
130+
131+
options[key] = newColorObj;
126132
} else {
127133
for (let keyColor in value) {
128134
newColorObj[keyColor] = this.colorService.toNativeColor(value[keyColor]);

0 commit comments

Comments
 (0)