22title : System
33order : 800
44---
5+
56## The System
67
78One 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.
910
1011NativePHP makes it trivial to access these resources and APIs.
1112
@@ -19,6 +20,7 @@ While some features are platform-specific, NativePHP gracefully handles this for
1920about whether something is Linux-, Mac-, or Windows-only.
2021
2122Most of the system-related features are available through the ` System ` facade.
23+
2224``` php
2325use Native\Laravel\Facades\System;
2426```
@@ -123,7 +125,8 @@ You can also print directly to PDF:
123125System::printToPDF('<html >...');
124126```
125127
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:
127130
128131``` php
129132use Illuminate\Support\Facades\Storage;
@@ -160,3 +163,25 @@ $timezone = System::timezone();
160163
161164// $timezone => 'Europe/London'
162165```
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