First Commit

This commit is contained in:
Thomas Peterson 2024-09-17 21:35:27 +02:00
commit 147e3ba5f6
8 changed files with 141 additions and 0 deletions

5
.gitignore vendored Normal file
View File

@ -0,0 +1,5 @@
.cache/
.idea/
build/
vendor/
composer.lock

18
app/App.php Normal file
View File

@ -0,0 +1,18 @@
<?php
namespace App;
use App\Windows\MainWindow;
class App implements \PHPNative\Framework\App
{
public function getName(): string
{
return 'Demo Application';
}
public function getStartWindow(): string
{
return MainWindow::class;
}
}

View File

@ -0,0 +1,10 @@
<?php
namespace App\Views\Components;
use PHPNative\UI\Widget\Container;
class MainLayout extends Container
{
public string $style = "flex";
}

View File

@ -0,0 +1,10 @@
<?php
namespace App\Views\Components;
use PHPNative\UI\Widget\Button;
class TestButton extends Button
{
public string $style = "bg-slate-200 hover:bg-slate-600 md:bg-sky-100 md:hover:bg-sky-600 m-50 w-full";
}

30
app/Views/MainView.php Normal file
View File

@ -0,0 +1,30 @@
<?php
namespace App\Views;
use App\Views\Components\MainLayout;
use App\Views\Components\TestButton;
use PHPNative\UI\BaseView;
use PHPNative\UI\View;
use PHPNative\UI\Widget\Container;
class MainView extends BaseView implements View
{
public TestButton $testButton;
public TestButton $test1Button;
public function __construct()
{
$this->style = "bg-white p-6";
$this->testButton = new TestButton(label: "Exit");
$this->test1Button = new TestButton(label: "Login");
}
public function getView(): View
{
return new MainLayout([
$this->test1Button,
$this->testButton
]);
}
}

View File

@ -0,0 +1,28 @@
<?php
namespace App\Windows;
use App\Views\MainView;
use PHPNative\Framework\Application\Window;
use PHPNative\UI\View;
class MainWindow implements Window
{
public function __construct(private MainView $mainView)
{
$this->mainView->testButton->setOnClick(function () use ($mainView) {
echo $this->mainView->testButton->label;
});
}
public function getView(): View
{
return $this->mainView;
}
public function getTitle(): string
{
return "DEMO APP";
}
}

26
composer.json Normal file
View File

@ -0,0 +1,26 @@
{
"name": "phpnative/app",
"type": "project",
"license": "MIT",
"require": {
"phpnative/framework": "@dev"
},
"autoload": {
"psr-4": {
"App\\": "app/"
}
},
"repositories": [
{
"type": "path",
"url": "../framework"
}
],
"authors": [
{
"name": "Thomas Peterson",
"email": "info@thomas-peterson.de"
}
],
"minimum-stability": "dev"
}

14
phpnative Executable file
View File

@ -0,0 +1,14 @@
#!/usr/bin/env php
<?php
use PHPNative\Framework\Application\Gui;
try {
require_once __DIR__ . '/vendor/autoload.php';
} catch (Throwable) {
require_once getcwd() . '/../autoload.php';
}
Gui::boot(__DIR__)->run(\App\Windows\MainWindow::class);
exit;