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()
1212 protected function open (): void
1313 {
1414 $ this ->client ->post ('window/open ' , $ this ->toArray ());
15+
16+ foreach ($ this ->afterOpenCallbacks as $ cb ) {
17+ $ cb ($ this );
18+ }
1519 }
1620}
Original file line number Diff line number Diff line change 66use Native \Laravel \Concerns \HasDimensions ;
77use Native \Laravel \Concerns \HasUrl ;
88use Native \Laravel \Concerns \HasVibrancy ;
9+ use Native \Laravel \Facades \Window as WindowFacade ;
910
1011class Window
1112{
@@ -53,6 +54,8 @@ class Window
5354
5455 protected Client $ client ;
5556
57+ protected array $ afterOpenCallbacks = [];
58+
5659 public function __construct (string $ id )
5760 {
5861 $ this ->id = $ id ;
@@ -181,6 +184,16 @@ public function maximizable($maximizable = true): static
181184 return $ this ;
182185 }
183186
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+
184197 public function closable ($ closable = true ): static
185198 {
186199 $ this ->closable = $ closable ;
@@ -261,4 +274,11 @@ public function toArray()
261274 'autoHideMenuBar ' => $ this ->autoHideMenuBar ,
262275 ];
263276 }
277+
278+ public function afterOpen (callable $ cb ): static
279+ {
280+ $ this ->afterOpenCallbacks [] = $ cb ;
281+
282+ return $ this ;
283+ }
264284}
You can’t perform that action at this time.
0 commit comments