You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

react-native-override-color-scheme

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-override-color-scheme

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

0.1.1
Source
npmnpm
Version published
Weekly downloads
186
50%
Maintainers
1
Weekly downloads
 
Created
Source

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: By default, overriding the interface style (light or dark) using this package doesn't work for alerts on iOS. We use method swizzling for the viewWillAppear method of UIAlertController class which might create problems in some cases (for example, if another package is also swizzling the same class method). That's why we have made this step optional.

To enable this, 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 fixAlerts]; to the top of the method (see below).

#import <OverrideColorScheme.h> // <--- import

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  [OverrideColorScheme fixAlerts]; // <--- 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.

Contributing

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

License

MIT

Keywords

react-native

FAQs

Package last updated on 24 Mar 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts