Skip to content

Commit 20163b5

Browse files
committed
wip
1 parent ac86689 commit 20163b5

20 files changed

+410
-74
lines changed

src/ContextMenu.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,9 @@ public function register(Menu $menu)
1919
'entries' => $items,
2020
]);
2121
}
22+
23+
public function remove()
24+
{
25+
$this->client->delete('context');
26+
}
2227
}

src/Dialog.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,16 @@
22

33
namespace Native\Laravel;
44

5+
use Illuminate\Support\Traits\Conditionable;
6+
use Illuminate\Support\Traits\Macroable;
57
use Native\Laravel\Client\Client;
8+
use Native\Laravel\Facades\Window;
69

710
class Dialog
811
{
12+
use Conditionable;
13+
use Macroable;
14+
915
protected $title;
1016

1117
protected $defaultPath;
@@ -18,6 +24,8 @@ class Dialog
1824

1925
protected $filters = [];
2026

27+
protected $windowReference;
28+
2129
public function __construct(protected Client $client)
2230
{
2331
}
@@ -69,6 +77,13 @@ public function singleFile()
6977
return $this;
7078
}
7179

80+
public function dontResolveSymlinks(): self
81+
{
82+
$this->properties[] = 'noResolveAliases';
83+
84+
return $this;
85+
}
86+
7287
public function filter(string $name, array $extensions): self
7388
{
7489
$this->filters[] = [
@@ -86,10 +101,22 @@ public function properties(array $properties): self
86101
return $this;
87102
}
88103

104+
public function asSheet(string $windowId = null): self
105+
{
106+
if (is_null($windowId)) {
107+
$this->windowReference = Window::current()->id;
108+
} else {
109+
$this->windowReference = $windowId;
110+
}
111+
112+
return $this;
113+
}
114+
89115
public function show()
90116
{
91117
$result = $this->client->post('dialog/open', [
92118
'title' => $this->title,
119+
'windowReference' => $this->windowReference,
93120
'defaultPath' => $this->defaultPath,
94121
'filters' => $this->filters,
95122
'buttonLabel' => $this->buttonLabel,
@@ -107,6 +134,7 @@ public function save()
107134
{
108135
return $this->client->post('dialog/save', [
109136
'title' => $this->title,
137+
'windowReference' => $this->windowReference,
110138
'defaultPath' => $this->defaultPath,
111139
'filters' => $this->filters,
112140
'buttonLabel' => $this->buttonLabel,

src/Events/Menu/MenuItemClicked.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
namespace Native\Laravel\Events\Menu;
4+
5+
use Illuminate\Broadcasting\Channel;
6+
use Illuminate\Broadcasting\InteractsWithSockets;
7+
use Illuminate\Contracts\Broadcasting\ShouldBroadcastNow;
8+
use Illuminate\Foundation\Events\Dispatchable;
9+
use Illuminate\Queue\SerializesModels;
10+
11+
class MenuItemClicked implements ShouldBroadcastNow
12+
{
13+
use Dispatchable, InteractsWithSockets, SerializesModels;
14+
15+
public function __construct(public array $item)
16+
{
17+
}
18+
19+
public function broadcastOn()
20+
{
21+
return [
22+
new Channel('nativephp'),
23+
];
24+
}
25+
}

src/Events/Windows/WindowBlurred.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
namespace Native\Laravel\Events\Windows;
4+
5+
use Illuminate\Broadcasting\Channel;
6+
use Illuminate\Broadcasting\InteractsWithSockets;
7+
use Illuminate\Contracts\Broadcasting\ShouldBroadcastNow;
8+
use Illuminate\Foundation\Events\Dispatchable;
9+
use Illuminate\Queue\SerializesModels;
10+
11+
class WindowBlurred implements ShouldBroadcastNow
12+
{
13+
use Dispatchable, InteractsWithSockets, SerializesModels;
14+
15+
public function __construct(public string $id)
16+
{
17+
//
18+
}
19+
20+
public function broadcastOn()
21+
{
22+
return [
23+
new Channel('nativephp'),
24+
];
25+
}
26+
}

src/Events/Windows/WindowClosed.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
namespace Native\Laravel\Events\Windows;
4+
5+
use Illuminate\Broadcasting\Channel;
6+
use Illuminate\Broadcasting\InteractsWithSockets;
7+
use Illuminate\Contracts\Broadcasting\ShouldBroadcastNow;
8+
use Illuminate\Foundation\Events\Dispatchable;
9+
use Illuminate\Queue\SerializesModels;
10+
11+
class WindowClosed implements ShouldBroadcastNow
12+
{
13+
use Dispatchable, InteractsWithSockets, SerializesModels;
14+
15+
public function __construct(public string $id)
16+
{
17+
}
18+
19+
public function broadcastOn()
20+
{
21+
return [
22+
new Channel('nativephp'),
23+
];
24+
}
25+
}

src/Events/Windows/WindowFocused.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
namespace Native\Laravel\Events\Windows;
4+
5+
use Illuminate\Broadcasting\Channel;
6+
use Illuminate\Broadcasting\InteractsWithSockets;
7+
use Illuminate\Contracts\Broadcasting\ShouldBroadcastNow;
8+
use Illuminate\Foundation\Events\Dispatchable;
9+
use Illuminate\Queue\SerializesModels;
10+
11+
class WindowFocused implements ShouldBroadcastNow
12+
{
13+
use Dispatchable, InteractsWithSockets, SerializesModels;
14+
15+
public function __construct(public string $id)
16+
{
17+
//
18+
}
19+
20+
public function broadcastOn()
21+
{
22+
return [
23+
new Channel('nativephp'),
24+
];
25+
}
26+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
namespace Native\Laravel\Events\Windows;
4+
5+
use Illuminate\Broadcasting\Channel;
6+
use Illuminate\Broadcasting\InteractsWithSockets;
7+
use Illuminate\Contracts\Broadcasting\ShouldBroadcastNow;
8+
use Illuminate\Foundation\Events\Dispatchable;
9+
use Illuminate\Queue\SerializesModels;
10+
11+
class WindowMinimized implements ShouldBroadcastNow
12+
{
13+
use Dispatchable, InteractsWithSockets, SerializesModels;
14+
15+
public function broadcastOn()
16+
{
17+
return [
18+
new Channel('nativephp'),
19+
];
20+
}
21+
}

src/Events/Windows/WindowResized.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
namespace Native\Laravel\Events\Windows;
4+
5+
use Illuminate\Broadcasting\Channel;
6+
use Illuminate\Broadcasting\InteractsWithSockets;
7+
use Illuminate\Contracts\Broadcasting\ShouldBroadcastNow;
8+
use Illuminate\Foundation\Events\Dispatchable;
9+
use Illuminate\Queue\SerializesModels;
10+
11+
class WindowResized implements ShouldBroadcastNow
12+
{
13+
use Dispatchable, InteractsWithSockets, SerializesModels;
14+
15+
public function __construct(public string $id, public int $width, public int $height)
16+
{
17+
//
18+
}
19+
20+
public function broadcastOn()
21+
{
22+
return [
23+
new Channel('nativephp'),
24+
];
25+
}
26+
}

src/Facades/Window.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ class Window extends Facade
88
{
99
protected static function getFacadeAccessor()
1010
{
11+
self::clearResolvedInstance(\Native\Laravel\Window::class);
12+
1113
return \Native\Laravel\Window::class;
1214
}
1315
}

src/Menu/Items/Checkbox.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
namespace Native\Laravel\Menu\Items;
4+
5+
class Checkbox extends MenuItem
6+
{
7+
protected string $type = 'checkbox';
8+
9+
public function __construct(string $label, protected bool $isChecked = false)
10+
{
11+
$this->label = $label;
12+
}
13+
}

0 commit comments

Comments
 (0)