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: 18

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

1.1.0 2026-10-06 17:49 UTC

This package is auto-updated.

Last update: 2026-10-06 17:49:57 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 — API 31+ uses UiModeManager.setApplicationNightMode, the OS's own per-app override. Below API 31 (Android 8–11) the plugin overrides the activity's configuration itself and re-applies it after rotations or an OS theme change. That override isn't persisted, so call setMode() again on launch (e.g. in your first screen's mount()).

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 result to branch on. The switch reaches PHP as the core Native\Mobile\Events\System\AppearanceChanged event, so theme() and System::isDarkMode() follow it; listen for that event to re-render anything colored from theme().

License

MIT