react-native-override-color-scheme
v1.0.3
Published
React Native package to let users override the app's color scheme/theme
Downloads
911
Readme
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
:warning: 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
//...
}
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