Skip to content

pantoken / platforms/android/src / toAndroid

Funzione: toAndroid()

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

Sperimentale

Genera XML di risorse Android per un IR di token esplicito.

Parametri

tokens

readonly Token[]

options

GenerateAndroidOptions

Restituisce

Promise<string[]>

I percorsi dei colors.xml e dimens.xml scritti.

Esempi

Genera l'IR di un tema specifico

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

Modalità scura con icone 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
});