Skip to content

Commit e9a97e3

Browse files
committed
feat: platformColor parsing
1 parent 316ec91 commit e9a97e3

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { PlatformColor } from "react-native";
2+
import type { StyleFunctionResolver } from "./resolve";
3+
4+
export const platformColor: StyleFunctionResolver = (resolveValue, value) => {
5+
const color: unknown = resolveValue(value[2]);
6+
if (Array.isArray(color)) {
7+
return PlatformColor(...(color as string[]));
8+
} else if (typeof color === "string") {
9+
return PlatformColor(color);
10+
}
11+
12+
return;
13+
};

src/runtime/native/styles/resolve.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { type Getter, type VariableContextValue } from "../reactivity";
99
import { animation } from "./animation";
1010
import { calc } from "./calc";
1111
import { transformKeys } from "./defaults";
12+
import { platformColor } from "./platform-functions";
1213
import { textShadow } from "./text-shadow";
1314
import { transform } from "./transform";
1415
import { em, rem, vh, vw } from "./units";
@@ -32,6 +33,7 @@ const functions: Record<string, StyleFunctionResolver> = {
3233
vw,
3334
vh,
3435
rem,
36+
platformColor,
3537
"@textShadow": textShadow,
3638
"@transform": transform,
3739
animationName: animation,

0 commit comments

Comments
 (0)