React Native package to let users override the app's color scheme/theme.
npm install react-native-override-color-scheme
or
yarn add react-native-override-color-scheme
If you are using RN >= 0.60, only run npx pod-install
. Then rebuild your project.
⚠️ 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:
- Open your
/ios/{projectName}/AppDelegate.m
file - At the top of the file, import the OverrideColorScheme module:
#import <OverrideColorScheme.h>
- 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
//...
}
No additional step is required.
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.
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.
See the contributing guide to learn how to contribute to the repository and the development workflow.
MIT