File tree Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -12,5 +12,9 @@ public function __destruct()
12
12
protected function open (): void
13
13
{
14
14
$ this ->client ->post ('window/open ' , $ this ->toArray ());
15
+
16
+ foreach ($ this ->afterOpenCallbacks as $ cb ) {
17
+ $ cb ($ this );
18
+ }
15
19
}
16
20
}
Original file line number Diff line number Diff line change 6
6
use Native \Laravel \Concerns \HasDimensions ;
7
7
use Native \Laravel \Concerns \HasUrl ;
8
8
use Native \Laravel \Concerns \HasVibrancy ;
9
+ use Native \Laravel \Facades \Window as WindowFacade ;
9
10
10
11
class Window
11
12
{
@@ -53,6 +54,8 @@ class Window
53
54
54
55
protected Client $ client ;
55
56
57
+ protected array $ afterOpenCallbacks = [];
58
+
56
59
public function __construct (string $ id )
57
60
{
58
61
$ this ->id = $ id ;
@@ -181,6 +184,16 @@ public function maximizable($maximizable = true): static
181
184
return $ this ;
182
185
}
183
186
187
+ public function minimized (): static
188
+ {
189
+ $ this ->afterOpen (fn () => WindowFacade::minimize ($ this ->id ));
190
+ }
191
+
192
+ public function maximized (): static
193
+ {
194
+ $ this ->afterOpen (fn () => WindowFacade::maximize ($ this ->id ));
195
+ }
196
+
184
197
public function closable ($ closable = true ): static
185
198
{
186
199
$ this ->closable = $ closable ;
@@ -261,4 +274,11 @@ public function toArray()
261
274
'autoHideMenuBar ' => $ this ->autoHideMenuBar ,
262
275
];
263
276
}
277
+
278
+ public function afterOpen (callable $ cb ): static
279
+ {
280
+ $ this ->afterOpenCallbacks [] = $ cb ;
281
+
282
+ return $ this ;
283
+ }
264
284
}
You can’t perform that action at this time.
0 commit comments