66 lines
1.5 KiB
PHP
66 lines
1.5 KiB
PHP
<?php
|
|
|
|
require_once __DIR__ . '/../vendor/autoload.php';
|
|
|
|
use PHPNative\Framework\Application;
|
|
use PHPNative\Ui\Widget\Button;
|
|
use PHPNative\Ui\Widget\Container;
|
|
use PHPNative\Ui\Widget\Label;
|
|
|
|
// Create application
|
|
$app = new Application();
|
|
|
|
// Create a single window (simple usage)
|
|
$window = $app->createWindow('Simple Window Example', 800, 600);
|
|
|
|
// Create UI
|
|
$container = new Container('flex flex-col p-6 gap-4 bg-gradient-to-br from-blue-400 to-purple-500');
|
|
|
|
$title = new Label(
|
|
text: 'Willkommen zu PHPNative!',
|
|
style: 'text-3xl text-white'
|
|
);
|
|
|
|
$description = new Label(
|
|
text: 'Dies ist ein einfaches Beispiel mit einem Window.',
|
|
style: 'text-lg text-white'
|
|
);
|
|
|
|
$button = new Button(
|
|
text: 'Klick mich!',
|
|
style: 'bg-white hover:bg-gray-100 text-blue-600 p-4 rounded-lg'
|
|
);
|
|
|
|
$statusLabel = new Label(
|
|
text: '',
|
|
style: 'text-base text-white'
|
|
);
|
|
|
|
$clickCount = 0;
|
|
$button->setOnClick(function() use ($statusLabel, &$clickCount) {
|
|
$clickCount++;
|
|
$statusLabel->setText("Button wurde $clickCount mal geklickt!");
|
|
});
|
|
|
|
$quitButton = new Button(
|
|
text: 'Beenden',
|
|
style: 'bg-red-500 hover:bg-red-700 text-white p-4 rounded-lg mt-4'
|
|
);
|
|
|
|
$quitButton->setOnClick(function() use ($app) {
|
|
$app->quit();
|
|
});
|
|
|
|
// Add components
|
|
$container->addComponent($title);
|
|
$container->addComponent($description);
|
|
$container->addComponent($button);
|
|
$container->addComponent($statusLabel);
|
|
$container->addComponent($quitButton);
|
|
|
|
// Set window root
|
|
$window->setRoot($container);
|
|
|
|
// Run application
|
|
$app->run();
|