First Commit
This commit is contained in:
commit
147e3ba5f6
5
.gitignore
vendored
Normal file
5
.gitignore
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
.cache/
|
||||
.idea/
|
||||
build/
|
||||
vendor/
|
||||
composer.lock
|
||||
18
app/App.php
Normal file
18
app/App.php
Normal 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;
|
||||
}
|
||||
}
|
||||
10
app/Views/Components/MainLayout.php
Normal file
10
app/Views/Components/MainLayout.php
Normal file
@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Views\Components;
|
||||
|
||||
use PHPNative\UI\Widget\Container;
|
||||
|
||||
class MainLayout extends Container
|
||||
{
|
||||
public string $style = "flex";
|
||||
}
|
||||
10
app/Views/Components/TestButton.php
Normal file
10
app/Views/Components/TestButton.php
Normal 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
30
app/Views/MainView.php
Normal 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
|
||||
]);
|
||||
}
|
||||
}
|
||||
28
app/Windows/MainWindow.php
Normal file
28
app/Windows/MainWindow.php
Normal 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
26
composer.json
Normal 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
14
phpnative
Executable 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;
|
||||
Loading…
Reference in New Issue
Block a user