ruslanshigabutdinov/nativephp-color-scheme

NativePHP Mobile plugin for reading and controlling the app color scheme.

Maintainers

Package info

github.com/RuslanShigabutdinov/nativephp-color-scheme

Type:nativephp-plugin

pkg:composer/ruslanshigabutdinov/nativephp-color-scheme

Statistics

Installs: 1

Dependents: 0

Suggesters: 0

Stars: 3

Open Issues: 0

v0.1.0 2026-05-22 10:30 UTC

This package is not auto-updated.

Last update: 2026-05-23 08:51:27 UTC


README

Read and control your NativePHP Mobile app's native appearance preference from Laravel.

The plugin supports the common theme flow:

  • system
  • light
  • dark

When the preference is system, the effective color scheme follows the device appearance.

Installation

composer require ruslanshigabutdinov/nativephp-color-scheme

Register the plugin:

php artisan native:plugin:register ruslanshigabutdinov/nativephp-color-scheme

If your app does not have app/Providers/NativeServiceProvider.php yet, publish it first:

php artisan vendor:publish --tag=nativephp-plugins-provider

Usage

use RuslanShigabutdinov\NativeColorScheme\Facades\NativeColorScheme;

NativeColorScheme::getPreference();  // system, light, dark, or null
NativeColorScheme::getColorScheme(); // effective light, dark, or null

NativeColorScheme::isSystem();
NativeColorScheme::isDark();
NativeColorScheme::isLight();

Set the app preference:

NativeColorScheme::useSystem();
NativeColorScheme::useLight();
NativeColorScheme::useDark();

NativeColorScheme::setPreference('system');
NativeColorScheme::setPreference('light');
NativeColorScheme::setPreference('dark');

auto, device, and os are accepted aliases for system:

NativeColorScheme::setPreference('auto');

Read the full state:

NativeColorScheme::state();

// [
//     'preference' => 'system',
//     'colorScheme' => 'dark',
//     'systemColorScheme' => 'dark',
//     'isSystem' => true,
//     'isDark' => true,
//     'isLight' => false,
// ]

Notes

Android is tested on device. iOS support is implemented, but still needs device/simulator validation.

On Android 12/API 31 and newer, the plugin applies the saved preference with native app night mode, which can help Android splash screens use the matching light or dark resources.

Because this package includes native Kotlin and Swift code, rebuild your NativePHP app after installing or updating it:

php artisan native:run

If native changes do not appear during development:

php artisan native:install --force
php artisan native:run