Skip to content

Commit

Permalink
Fix empty dynamic colors object when using PlatformColors on iOS (#7259)
Browse files Browse the repository at this point in the history
Fixes the original error mentioned here: #7216 (comment)

Co-authored-by: Ward Abbass <warda@wix.com>
  • Loading branch information
svbutko and swabbass authored Oct 4, 2021
1 parent 588e908 commit cce64b9
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions lib/src/commands/OptionsProcessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import {
import { Deprecations } from './Deprecations';
import { OptionProcessorsStore } from '../processors/OptionProcessorsStore';
import { CommandName } from '../interfaces/CommandName';
import { Platform, DynamicColorIOS } from 'react-native';
import { Platform, DynamicColorIOS, ColorValue } from 'react-native';

export class OptionsProcessor {
constructor(
Expand Down Expand Up @@ -126,13 +126,18 @@ export class OptionsProcessor {
if (value === null) {
options[key] = 'NoColor';
} else if (value instanceof Object) {
if ('dynamic' in value) {
options[key].dynamic.light = this.colorService.toNativeColor(value.dynamic.light);
options[key].dynamic.dark = this.colorService.toNativeColor(value.dynamic.dark);
if ('semantic' in value) {
options[key] = value;
} else if ('dynamic' in value) {
options[key] = DynamicColorIOS({
light: this.colorService.toNativeColor(value.dynamic.light) as ColorValue,
dark: this.colorService.toNativeColor(value.dynamic.dark) as ColorValue,
});
} else {
options[key].light = this.colorService.toNativeColor(value.light);
options[key].dark = this.colorService.toNativeColor(value.dark);
options[key] = DynamicColorIOS(options[key]);
options[key] = DynamicColorIOS({
light: this.colorService.toNativeColor(value.light) as ColorValue,
dark: this.colorService.toNativeColor(value.dark) as ColorValue
});
}
} else {
options[key] = this.colorService.toNativeColor(value);
Expand Down

0 comments on commit cce64b9

Please sign in to comment.