Skip to content

pantoken / platforms/android/src / toAndroid

函数: toAndroid()

toAndroid(tokens, options): Promise<string[]>

实验性

为显式令牌 IR 生成 Android 资源 XML。

参数

tokens

只读 Token[]

options

GenerateAndroidOptions

返回值

Promise<string[]>

已写入的 colors.xmldimens.xml 的路径。

示例

生成特定主题的 IR

ts
import { toAndroid } from "@pantoken/android";
import { byTheme } from "@pantoken/tokens";

const [colors, dimens] = await toAndroid(byTheme("canvas"), { outDir: "./app/src/main" });
// writes ./app/src/main/res/values/colors.xml and dimens.xml

使用图标 VectorDrawables 的暗色模式

ts
import { toAndroid } from "@pantoken/android";
import { byTheme } from "@pantoken/tokens";

await toAndroid(byTheme("rebrand"), {
  outDir: "./app/src/main",
  mode: "dark",
  icons: ["add", "check"], // also emits res/drawable/ic_add.xml, ic_check.xml
});