react-native-override-color-scheme
TypeScript icon, indicating that this package has built-in type declarations

1.0.3 • Public • Published

react-native-override-color-scheme

React Native package to let users override the app's color scheme/theme.

Installation

npm install react-native-override-color-scheme

or

yarn add react-native-override-color-scheme

RN >= 0.60

If you are using RN >= 0.60, only run npx pod-install. Then rebuild your project.

iOS

Optional support for alerts on iOS

⚠️ We use method swizzling to enable support for alerts on iOS. Method swizzling is used by Firebase iOS SDK as well, but it can be problematic in some cases, especially when another library is also swizzling the same method. That’s why we have made this step optional.

To enable support for alerts on iOS, please follow the steps below:

  1. Open your /ios/{projectName}/AppDelegate.m file
  2. At the top of the file, import the OverrideColorScheme module: #import <OverrideColorScheme.h>
  3. And then, within your existing didFinishLaunchingWithOptions method, add [OverrideColorScheme enableAlertSupport]; to the top of the method (see below).
#import <OverrideColorScheme.h> // <--- import

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  [OverrideColorScheme enableAlertSupport]; // <--- and add this line
  //...
}

Android

No additional step is required.

Usage

import overrideColorScheme from 'react-native-override-color-scheme';

// ...

overrideColorScheme.setScheme('dark'); // or `light` or `undefined` for system default

See the example for advanced use cases.

Supporting

This package is maintained by the Plum Village App team and used by the App. You can set up a donation if you would like to financially support the further development of Plum Village App and this package.

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT

Package Sidebar

Install

npm i react-native-override-color-scheme

Weekly Downloads

419

Version

1.0.3

License

MIT

Unpacked Size

44.9 kB

Total Files

26

Last publish

Collaborators

  • polarisation
  • rkbhochalya