Skip to content

feat: add theme method to System class and create SystemThemesEnum #530

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
feat: add theme method to System class and create SystemThemesEnum
  • Loading branch information
WINBIGFOX committed Mar 30, 2025
commit 62e3f9eeb9d203696b7ba8c6997a12da1272994e
10 changes: 10 additions & 0 deletions src/Enums/SystemThemesEnum.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace Native\Laravel\Enums;

enum SystemThemesEnum: string
{
case SYSTEM = 'system';
case LIGHT = 'light';
case DARK = 'dark';
}
2 changes: 2 additions & 0 deletions src/Facades/System.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Native\Laravel\Facades;

use Illuminate\Support\Facades\Facade;
use Native\Laravel\Enums\SystemThemesEnum;

/**
* @method static bool canPromptTouchID()
Expand All @@ -14,6 +15,7 @@
* @method static void print(string $html, ?\Native\Laravel\DataObjects\Printer $printer = null)
* @method static string printToPDF(string $reason)
* @method static string timezone()
* @method static SystemThemesEnum theme(?SystemThemesEnum $theme = null)
*/
class System extends Facade
{
Expand Down
14 changes: 14 additions & 0 deletions src/System.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Native\Laravel\Client\Client;
use Native\Laravel\DataObjects\Printer;
use Native\Laravel\Enums\SystemThemesEnum;
use Native\Laravel\Support\Environment;
use Native\Laravel\Support\Timezones;

Expand Down Expand Up @@ -88,4 +89,17 @@ public function timezone(): string

return $timezone;
}

public function theme(?SystemThemesEnum $theme = null): SystemThemesEnum
{
if ($theme) {
$result = $this->client->post('system/theme', [
'theme' => $theme,
])->json('result');
} else {
$result = $this->client->get('system/theme')->json('result');
}

return SystemThemesEnum::from($result);
}
}
Loading