Skip to content

Commit 6904745

Browse files
authored
Merge pull request #112 from metrique/window-position
add windowPosition
2 parents 9c7e7aa + 263bca3 commit 6904745

File tree

3 files changed

+94
-0
lines changed

3 files changed

+94
-0
lines changed

src/Concerns/HasPositioner.php

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
<?php
2+
3+
namespace Native\Laravel\Concerns;
4+
5+
trait HasPositioner
6+
{
7+
protected string $windowPosition = 'trayCenter';
8+
9+
public function windowPosition(string $position): self
10+
{
11+
$this->windowPosition = $position;
12+
13+
return $this;
14+
}
15+
16+
public function trayLeft(): self
17+
{
18+
return $this->windowPosition('trayLeft');
19+
}
20+
21+
public function trayBottomLeft(): self
22+
{
23+
return $this->windowPosition('trayBottomLeft');
24+
}
25+
26+
public function trayRight(): self
27+
{
28+
return $this->windowPosition('trayRight');
29+
}
30+
31+
public function trayBottomRight(): self
32+
{
33+
return $this->windowPosition('trayBottomRight');
34+
}
35+
36+
public function trayCenter(): self
37+
{
38+
return $this->windowPosition('trayCenter');
39+
}
40+
41+
public function trayBottomCenter(): self
42+
{
43+
return $this->windowPosition('trayBottomCenter');
44+
}
45+
46+
public function topLeft(): self
47+
{
48+
return $this->windowPosition('topLeft');
49+
}
50+
51+
public function topRight(): self
52+
{
53+
return $this->windowPosition('topRight');
54+
}
55+
56+
public function bottomLeft(): self
57+
{
58+
return $this->windowPosition('bottomLeft');
59+
}
60+
61+
public function bottomRight(): self
62+
{
63+
return $this->windowPosition('bottomRight');
64+
}
65+
66+
public function topCenter(): self
67+
{
68+
return $this->windowPosition('topCenter');
69+
}
70+
71+
public function bottomCenter(): self
72+
{
73+
return $this->windowPosition('bottomCenter');
74+
}
75+
76+
public function leftCenter(): self
77+
{
78+
return $this->windowPosition('leftCenter');
79+
}
80+
81+
public function rightCenter(): self
82+
{
83+
return $this->windowPosition('rightCenter');
84+
}
85+
86+
public function center(): self
87+
{
88+
return $this->windowPosition('center');
89+
}
90+
}

src/MenuBar/MenuBar.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Native\Laravel\Client\Client;
66
use Native\Laravel\Concerns\HasDimensions;
7+
use Native\Laravel\Concerns\HasPositioner;
78
use Native\Laravel\Concerns\HasUrl;
89
use Native\Laravel\Concerns\HasVibrancy;
910
use Native\Laravel\Menu\Menu;
@@ -12,6 +13,7 @@ class MenuBar
1213
{
1314
use HasVibrancy;
1415
use HasDimensions;
16+
use HasPositioner;
1517
use HasUrl;
1618

1719
protected string $icon = '';
@@ -94,6 +96,7 @@ public function toArray(): array
9496
return [
9597
'url' => $this->url,
9698
'icon' => $this->icon,
99+
'windowPosition' => $this->windowPosition,
97100
'x' => $this->x,
98101
'y' => $this->y,
99102
'label' => $this->label,

tests/MenuBar/MenuBarTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,6 @@
2222
$this->assertEquals('milwad', $menuBarArray['label']);
2323
$this->assertEquals('https://github.com/milwad-dev', $menuBarArray['url']);
2424
$this->assertEquals('nativephp.png', $menuBarArray['icon']);
25+
$this->assertEquals('trayCenter', $menuBarArray['windowPosition']);
2526
$this->assertIsArray($menuBarArray['contextMenu']);
2627
});

0 commit comments

Comments
 (0)