Skip to content

Add runtime appearance overrides without restarting the app - #412

Closed
jeremyfrancis55 wants to merge 1 commit into
NativePHP:mainfrom
jeremyfrancis55:feat/runtime-appearance-without-restart
Closed

Add runtime appearance overrides without restarting the app#412
jeremyfrancis55 wants to merge 1 commit into
NativePHP:mainfrom
jeremyfrancis55:feat/runtime-appearance-without-restart

Conversation

@jeremyfrancis55

@jeremyfrancis55 jeremyfrancis55 commented Sep 2, 2026

Copy link
Copy Markdown

Summary

  • add System::setAppearance() for light, dark, and system app-local overrides
  • add Android and iOS System.SetAppearance bridge functions
  • drive Android Material chrome and native node dark variants from shared Compose state
  • update system bar styling and System.GetAppearance without recreating MainActivity

Problem

Using Android's normal day/night delegate recreates the activity so Compose picks up the new theme. In a NativePHP app that also restarts the PHP host and can clear the authenticated runtime session, making an in-app light/dark toggle appear to log the user out. Updating only system bars avoids the restart but leaves Compose/native renderers on the old palette.

This change applies the override as snapshot state instead. Compose recomposes in place, the PID and PHP runtime remain alive, and AppearanceChanged still reaches PHP. iOS uses the existing window-level overrideUserInterfaceStyle mechanism.

Testing

  • full PHP suite: 928 tests, 3,079 assertions (pass; existing PHP 8.5 deprecation/risky notices remain)
  • PHPStan on changed PHP API: pass
  • Pint on changed PHP files: pass
  • Android Gradle :app:assembleDebug: pass in a NativePHP app using these templates
  • emulator dark -> light -> dark: full native UI and system bars update; PID remains unchanged and no activity relaunch occurs

Companion PR

NativePHP/mobile-ui#84 updates every Android plugin renderer to consume the shared state: NativePHP/mobile-ui#84

@jeremyfrancis55

Copy link
Copy Markdown
Author

I realized I can just store the logged in credentials in secure storage..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant