44 lines
1.4 KiB
PHP
44 lines
1.4 KiB
PHP
<?php
|
|
|
|
use PHPNative\Ui\Widget\Container;
|
|
use PHPNative\Ui\Widget\Label;
|
|
|
|
require_once __DIR__ . '/../vendor/autoload.php';
|
|
|
|
// Check PHP version
|
|
if (PHP_VERSION_ID < 80100) {
|
|
die("This demo requires PHP 8.1+ for Fiber support.\nYour version: " . PHP_VERSION . "\n");
|
|
}
|
|
|
|
$app = new \PHPNative\Framework\Application('ToDo Demo', 700, 500);
|
|
$container = new \PHPNative\Ui\Widget\Container(style: 'm-10 p-10 flex-row rounded-xl bg-lime-200');
|
|
$containerContent = new \PHPNative\Ui\Widget\Container(style: 'flex-1 bg-lime-700');
|
|
$labelContent = new Label(
|
|
text: 'Todo App',
|
|
style: 'text-xl2 text-red-500',
|
|
);
|
|
$containerContent->addComponent($labelContent);
|
|
$container->addComponent($containerContent);
|
|
$containerMenu = new \PHPNative\Ui\Widget\Container(style: 'w-200 bg-lime-200');
|
|
$label = new Label(
|
|
text: 'Menu App',
|
|
style: 'text-red-500',
|
|
);
|
|
$containerMenu->addComponent($label);
|
|
$scrollContainer = new Container(style: 'overflow-y-auto bg-white m-4 p-4');
|
|
|
|
// Add many items to trigger overflow
|
|
for ($i = 1; $i <= 20; $i++) {
|
|
$item = new Container(style: 'bg-blue-500 m-2 p-3 rounded-lg');
|
|
$label = new Label(
|
|
text: "Item {$i} - Scroll vertically with mouse wheel or drag the scrollbar",
|
|
style: 'text-white',
|
|
);
|
|
$item->addComponent($label);
|
|
$scrollContainer->addComponent($item);
|
|
}
|
|
$containerMenu->addComponent($scrollContainer);
|
|
$container->addComponent($containerMenu);
|
|
$app->setRoot($container);
|
|
$app->run();
|