Skip to content

Commit 939bcef

Browse files
authored
Merge pull request #101 from WINBIGFOX/feature/add-system-theme-doc
Add theme detection and management to the System documentation
2 parents 99ec32a + 1ad06ef commit 939bcef

File tree

1 file changed

+27
-2
lines changed
  • resources/views/docs/desktop/1/the-basics

1 file changed

+27
-2
lines changed

resources/views/docs/desktop/1/the-basics/system.md

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22
title: System
33
order: 800
44
---
5+
56
## The System
67

78
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.
910

1011
NativePHP 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
1920
about whether something is Linux-, Mac-, or Windows-only.
2021

2122
Most of the system-related features are available through the `System` facade.
23+
2224
```php
2325
use Native\Laravel\Facades\System;
2426
```
@@ -123,7 +125,8 @@ You can also print directly to PDF:
123125
System::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
129132
use 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

Comments
 (0)