Skip to content

Commit afe7316

Browse files
authored
feat: add theme method to System class and create SystemThemesEnum (#530)
1 parent 29b8779 commit afe7316

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

src/Enums/SystemThemesEnum.php

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
3+
namespace Native\Laravel\Enums;
4+
5+
enum SystemThemesEnum: string
6+
{
7+
case SYSTEM = 'system';
8+
case LIGHT = 'light';
9+
case DARK = 'dark';
10+
}

src/Facades/System.php

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Native\Laravel\Facades;
44

55
use Illuminate\Support\Facades\Facade;
6+
use Native\Laravel\Enums\SystemThemesEnum;
67

78
/**
89
* @method static bool canPromptTouchID()
@@ -14,6 +15,7 @@
1415
* @method static void print(string $html, ?\Native\Laravel\DataObjects\Printer $printer = null)
1516
* @method static string printToPDF(string $reason)
1617
* @method static string timezone()
18+
* @method static SystemThemesEnum theme(?SystemThemesEnum $theme = null)
1719
*/
1820
class System extends Facade
1921
{

src/System.php

+14
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Native\Laravel\Client\Client;
66
use Native\Laravel\DataObjects\Printer;
7+
use Native\Laravel\Enums\SystemThemesEnum;
78
use Native\Laravel\Support\Environment;
89
use Native\Laravel\Support\Timezones;
910

@@ -88,4 +89,17 @@ public function timezone(): string
8889

8990
return $timezone;
9091
}
92+
93+
public function theme(?SystemThemesEnum $theme = null): SystemThemesEnum
94+
{
95+
if ($theme) {
96+
$result = $this->client->post('system/theme', [
97+
'theme' => $theme,
98+
])->json('result');
99+
} else {
100+
$result = $this->client->get('system/theme')->json('result');
101+
}
102+
103+
return SystemThemesEnum::from($result);
104+
}
91105
}

0 commit comments

Comments
 (0)