Skip to content

pantoken / platforms/android/src / toAndroid

Hàm: toAndroid()

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

Thử nghiệm

Phát sinh XML tài nguyên Android cho một token IR cụ thể.

Tham số

tokens

chỉ đọc Token[]

options

GenerateAndroidOptions

Trả về

Promise<string[]>

Các đường dẫn tới colors.xmldimens.xml đã được ghi.

Các ví dụ

Phát sinh IR của một chủ đề cụ thể

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

Chế độ tối với biểu tượng 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
});