📱 AndroidModule - Wprowadzenie

AndroidModule pozwala tworzyć i manipulować natywne widoki Android bezpośrednio ze skryptu.

Instalacja

// 1. Zarejestruj moduł (raz w Application lub Activity) AndroidModule.register(context) // 2. Ustaw root view przed uruchomieniem skryptu AndroidModule.setCurrentRootView(binding.container) // lub AndroidModule.setCurrentActivity(activity)

Użycie w skrypcie

use "android"; // Pobierz root let root = getRootView(); // Stwórz przycisk let button = createView("button", { text: "Kliknij mnie!", onClick: fn() { toast("Kliknięto!"); } }); // Dodaj do UI addViewTo(root, button);

Pełny przykład

use "android"; let root = getRootView(); // Nagłówek let header = createView("text", { text: "🦊 Demo App", textSize: 24, bold: true, gravity: "center" }); // Licznik let counter = 0; let counterText = createView("text", { text: "Licznik: 0", textSize: 18, gravity: "center" }); // Przycisk let btn = createView("button", { text: "Zwiększ", onClick: fn() { counter = counter + 1; setText(counterText, "Licznik: " + counter); if (counter % 5 == 0) { animate(counterText, "bounce", 200); toast("Brawo! " + counter); } } }); // Dodaj elementy addViewTo(root, header); addViewTo(root, createView("spacer", {size: 16})); addViewTo(root, counterText); addViewTo(root, createView("spacer", {size: 8})); addViewTo(root, btn);