Skip to content

Commit

Permalink
Merge pull request #112 from metrique/window-position
Browse files Browse the repository at this point in the history
add windowPosition
  • Loading branch information
mpociot committed Aug 3, 2023
2 parents 9c7e7aa + 263bca3 commit 6904745
Show file tree
Hide file tree
Showing 3 changed files with 94 additions and 0 deletions.
90 changes: 90 additions & 0 deletions src/Concerns/HasPositioner.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
<?php

namespace Native\Laravel\Concerns;

trait HasPositioner
{
protected string $windowPosition = 'trayCenter';

public function windowPosition(string $position): self
{
$this->windowPosition = $position;

return $this;
}

public function trayLeft(): self
{
return $this->windowPosition('trayLeft');
}

public function trayBottomLeft(): self
{
return $this->windowPosition('trayBottomLeft');
}

public function trayRight(): self
{
return $this->windowPosition('trayRight');
}

public function trayBottomRight(): self
{
return $this->windowPosition('trayBottomRight');
}

public function trayCenter(): self
{
return $this->windowPosition('trayCenter');
}

public function trayBottomCenter(): self
{
return $this->windowPosition('trayBottomCenter');
}

public function topLeft(): self
{
return $this->windowPosition('topLeft');
}

public function topRight(): self
{
return $this->windowPosition('topRight');
}

public function bottomLeft(): self
{
return $this->windowPosition('bottomLeft');
}

public function bottomRight(): self
{
return $this->windowPosition('bottomRight');
}

public function topCenter(): self
{
return $this->windowPosition('topCenter');
}

public function bottomCenter(): self
{
return $this->windowPosition('bottomCenter');
}

public function leftCenter(): self
{
return $this->windowPosition('leftCenter');
}

public function rightCenter(): self
{
return $this->windowPosition('rightCenter');
}

public function center(): self
{
return $this->windowPosition('center');
}
}
3 changes: 3 additions & 0 deletions src/MenuBar/MenuBar.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Native\Laravel\Client\Client;
use Native\Laravel\Concerns\HasDimensions;
use Native\Laravel\Concerns\HasPositioner;
use Native\Laravel\Concerns\HasUrl;
use Native\Laravel\Concerns\HasVibrancy;
use Native\Laravel\Menu\Menu;
Expand All @@ -12,6 +13,7 @@ class MenuBar
{
use HasVibrancy;
use HasDimensions;
use HasPositioner;
use HasUrl;

protected string $icon = '';
Expand Down Expand Up @@ -94,6 +96,7 @@ public function toArray(): array
return [
'url' => $this->url,
'icon' => $this->icon,
'windowPosition' => $this->windowPosition,
'x' => $this->x,
'y' => $this->y,
'label' => $this->label,
Expand Down
1 change: 1 addition & 0 deletions tests/MenuBar/MenuBarTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@
$this->assertEquals('milwad', $menuBarArray['label']);
$this->assertEquals('https://github.com/milwad-dev', $menuBarArray['url']);
$this->assertEquals('nativephp.png', $menuBarArray['icon']);
$this->assertEquals('trayCenter', $menuBarArray['windowPosition']);
$this->assertIsArray($menuBarArray['contextMenu']);
});

0 comments on commit 6904745

Please sign in to comment.