2
2
title : System
3
3
order : 800
4
4
---
5
+
5
6
## The System
6
7
7
8
One of the main advantages of building a native application is having more direct access to system resources, such as
8
- peripherals connected to the physical device and APIs that aren't typically accessible inside a browser's sandbox.
9
+ peripherals connected to the physical device and APIs that aren't typically accessible inside a browser's sandbox.
9
10
10
11
NativePHP makes it trivial to access these resources and APIs.
11
12
@@ -19,6 +20,7 @@ While some features are platform-specific, NativePHP gracefully handles this for
19
20
about whether something is Linux-, Mac-, or Windows-only.
20
21
21
22
Most of the system-related features are available through the ` System ` facade.
23
+
22
24
``` php
23
25
use Native\Laravel\Facades\System;
24
26
```
@@ -123,7 +125,8 @@ You can also print directly to PDF:
123
125
System::printToPDF('<html >...');
124
126
```
125
127
126
- This returns the PDF data in a ` base64_encoded ` binary string. So be sure to ` base64_decode ` it before storing it to disk:
128
+ This returns the PDF data in a ` base64_encoded ` binary string. So be sure to ` base64_decode ` it before storing it to
129
+ disk:
127
130
128
131
``` php
129
132
use Illuminate\Support\Facades\Storage;
@@ -160,3 +163,25 @@ $timezone = System::timezone();
160
163
161
164
// $timezone => 'Europe/London'
162
165
```
166
+
167
+ ## Theme
168
+
169
+ NativePHP allows you to detect the current theme of the user's operating system. This is useful for applications that
170
+ want to adapt their UI to match the user's preferences.
171
+ You can use the ` System::theme() ` method to get the current theme of the user's operating system.
172
+
173
+ ``` php
174
+ $theme = System::theme();
175
+ // $theme => SystemThemesEnum::LIGHT, SystemThemesEnum::DARK or SystemThemesEnum::SYSTEM
176
+ ```
177
+
178
+ You can also set the theme of your application using the ` System::theme() ` method. This will change the theme of your
179
+ application to the specified value. The available options are ` SystemThemesEnum::LIGHT ` , ` SystemThemesEnum::DARK ` and
180
+ ` SystemThemesEnum::SYSTEM ` .
181
+
182
+ ``` php
183
+ System::theme(SystemThemesEnum::DARK);
184
+ ```
185
+
186
+ Setting the theme to ` SystemThemesEnum::SYSTEM ` will remove the override and everything will be reset to the OS default.
187
+ By default themeSource is ` SystemThemesEnum::SYSTEM ` .
0 commit comments