11
11
/* eslint no-bitwise: 0 */
12
12
'use strict' ;
13
13
14
- const Platform = require ( 'Platform' ) ; // [TODO(macOS ISS#2323203)
15
-
16
- export type SemanticOrDynamicColorType = {
17
- semantic ?: string ,
18
- dynamic ?: {
19
- light : ?( string | number | SemanticOrDynamicColorType ) ,
20
- dark : ?( string | number | SemanticOrDynamicColorType ) ,
21
- } ,
22
- } ; // ]TODO(macOS ISS#2323203)
14
+ const normalizeColorObject = require ( 'normalizeColorObject' ) ; // TODO(macOS ISS#2323203)
15
+ import type { NativeOrDynamicColorType } from 'normalizeColorObject' ; // TODO(macOS ISS#2323203)
23
16
24
17
function normalizeColor (
25
18
color : ?(
26
19
| string
27
20
| number
28
- | SemanticOrDynamicColorType
21
+ | NativeOrDynamicColorType
29
22
) /* TODO(macOS ISS#2323203) */ ,
30
- ) : ?( number | SemanticOrDynamicColorType ) /* TODO(macOS ISS#2323203) */ {
23
+ ) : ?( number | NativeOrDynamicColorType ) /* TODO(macOS ISS#2323203) */ {
31
24
const matchers = getMatchers ( ) ;
32
25
let match ;
33
26
@@ -39,26 +32,14 @@ function normalizeColor(
39
32
}
40
33
41
34
// [TODO(macOS ISS#2323203)
42
- if (
43
- typeof color === 'object' &&
44
- color !== null &&
45
- ( Platform . OS === 'macos' || Platform . OS === 'ios' )
46
- ) {
47
- if ( 'semantic' in color ) {
48
- // a macos semantic color
35
+ if ( typeof color === 'object' && color !== null ) {
36
+ const normalizedColorObj = normalizeColorObject ( color ) ;
37
+
38
+ if ( normalizedColorObj !== null ) {
49
39
return color ;
50
- } else if ( 'dynamic' in color && color . dynamic !== undefined ) {
51
- // a dynamic, appearance aware color
52
- const dynamic = color . dynamic ;
53
- const dynamicColor : SemanticOrDynamicColorType = {
54
- dynamic : {
55
- light : normalizeColor ( dynamic . light ) ,
56
- dark : normalizeColor ( dynamic . dark ) ,
57
- } ,
58
- } ;
59
- return dynamicColor ;
60
40
}
61
41
}
42
+
62
43
if ( typeof color !== 'string' ) {
63
44
return null ;
64
45
} // ]TODO(macOS ISS#2323203)
0 commit comments