Skip to content

pantoken-root / platforms/android/src / toAndroid

関数: toAndroid() ​

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

実験的

明示的なトークンIR用の Android リソース XML を出力します。

パラメーター ​

tokens ​

読み取り専用 Token[]

options ​

GenerateAndroidOptions

戻り値 ​

Promise<string[]>

書き出された colors.xml と dimens.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

アイコンの VectorDrawable を用いたダークモード

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
});