Skip to content

Commit

Permalink
Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
cdosoftei committed Jun 19, 2024
1 parent 4f65218 commit 4cffb7a
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 10 deletions.
11 changes: 7 additions & 4 deletions src/Admin/Main/Window.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Ardillo\Examples\Admin\App;
use Ardillo\{
VerticalBox,
WebViewParams,
Window as ArdilloWindow
};

Expand All @@ -27,19 +28,21 @@ public function setup(): void
$this->vb = new VerticalBox();
$this->vb->setPadded(false);

$this->webView = new WebView;
$this->webView->registerUriScheme('admin');
$this->webView->setInitScript(<<<EOD
$wParams = new WebViewParams;

Check failure on line 31 in src/Admin/Main/Window.php

View workflow job for this annotation

GitHub Actions / Static Analysis (PHP 8.2 on ubuntu-22.04)

Instantiated class Ardillo\WebViewParams not found.
$wParams->setEnableDevTools(true);

Check failure on line 32 in src/Admin/Main/Window.php

View workflow job for this annotation

GitHub Actions / Static Analysis (PHP 8.2 on ubuntu-22.04)

Call to method setEnableDevTools() on an unknown class Ardillo\WebViewParams.
$wParams->setInitScript(<<<EOD

Check failure on line 33 in src/Admin/Main/Window.php

View workflow job for this annotation

GitHub Actions / Static Analysis (PHP 8.2 on ubuntu-22.04)

Call to method setInitScript() on an unknown class Ardillo\WebViewParams.
/* Get rid of the demo.js greeting */
localStorage.setItem('AdminLTE:Demo:MessageShowed', (Date.now()) + (3600 * 1000))
EOD);
$wParams->setCustomUriSchemes('admin');

Check failure on line 37 in src/Admin/Main/Window.php

View workflow job for this annotation

GitHub Actions / Static Analysis (PHP 8.2 on ubuntu-22.04)

Call to method setCustomUriSchemes() on an unknown class Ardillo\WebViewParams.

$this->webView = new WebView($wParams);

$this->vb->append($this->webView, true);

$this->setMargined(false);
$this->setChild($this->vb);

$this->webView->enableDevTools(true);
$this->webView->setUri('admin:///index.html');
}
}
24 changes: 18 additions & 6 deletions src/Browser/Main/Window.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
HorizontalBox,
Label,
VerticalBox,
WebViewParams,
Window as ArdilloWindow
};

Expand Down Expand Up @@ -44,13 +45,26 @@ public function setup(): void
$this->button = new GoButton('Go');
$this->hb->append($this->button, false);

$this->webView = new WebView;
$this->webView->setInitScript(<<<EOD
function onNavChange() { webkit.messageHandlers.webview.postMessage(document.location.href); }
$wParams = new WebViewParams;
$wParams->setEnableDevTools(true);
$wParams->setInitScript(<<<EOD
function onNavChange() {
if (typeof webkit !== 'undefined') {
/* Unices */
webkit.messageHandlers.webview.postMessage(document.location.href);
} else if (typeof chrome !== 'undefined') {
/* Windows */
chrome.webview.postMessage(document.location.href);
} else {
console.error('Unsupported webview engine');
}
}
window.addEventListener('popstate', onNavChange);
onNavChange();
EOD);
$this->webView->registerUriScheme('custom');
$wParams->setCustomUriSchemes('custom');

$this->webView = new WebView($wParams);

$this->statusBar = new Label('Ready');

Expand All @@ -61,8 +75,6 @@ function onNavChange() { webkit.messageHandlers.webview.postMessage(document.loc
$this->setMargined(false);
$this->setChild($this->vb);

$this->webView->enableDevTools(true);

assert($this->app instanceof App);

$this->webView->setHtml($this->app->startHtml);
Expand Down

0 comments on commit 4cffb7a

Please sign in to comment.