Search by

smronju / nativephp-appearance

smronju

Force the app into light or dark mode independent of the system setting, or release it back to following the system automatically.

Package info

github.com/smronju/nativephp-appearance

Type:nativephp-plugin

pkg:composer/smronju/nativephp-appearance

Statistics

Installs: 5

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

1.0.0 2026-08-16 17:47 UTC

This package is auto-updated.

Last update: 2026-08-16 17:53:09 UTC


README

Forces a NativePHP Mobile app into light or dark mode independent of the OS setting, or releases it back to following the system automatically.

bg-theme-*/text-theme-* classes already resolve their dark companion natively based on the OS color scheme — there is no PHP-facing API to override that, only to read it (Native\Mobile\Facades\System::appearance()). This plugin adds the missing write side.

Requirements

  • nativephp/mobile ^3.0 or ^4.0
  • iOS 15.0+ — fully supported via UIWindow.overrideUserInterfaceStyle.
  • Android — requires API 31+ (UiModeManager.setApplicationNightMode, the only per-app override Android exposes outside of AppCompatActivity). Below API 31, setMode() silently no-ops rather than partially applying.

Installation

composer require smronju/nativephp-appearance
php artisan vendor:publish --tag=nativephp-plugins-provider
php artisan native:plugin:register smronju/nativephp-appearance

Then rebuild: php artisan native:run.

Usage

use Smronju\NativephpAppearance\Facades\NativephpAppearance;

NativephpAppearance::setMode('dark');   // force dark
NativephpAppearance::setMode('light');  // force light
NativephpAppearance::setMode('system'); // follow the OS again

Fire-and-forget: there's no event to listen for, and no result to branch on — either the override applies (iOS always; Android on API 31+) or the call is a safe no-op (Android below API 31).

License

MIT