Skip to content

pantoken / platforms/android/src / toAndroid

ฟังก์ชัน: toAndroid()

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

ทดลอง

สร้างไฟล์ Android resource XML สำหรับ IR ของโทเค็นที่ระบุ

พารามิเตอร์

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

โหมดมืดพร้อมไอคอน 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
});