├── .eslintignore
├── .eslintrc.js
├── .gitattributes
├── .gitignore
├── .prettierrc
├── .watchmanconfig
├── LICENSE
├── README.md
├── android
├── .classpath
├── .project
├── .settings
│ └── org.eclipse.buildship.core.prefs
├── README.md
├── build.gradle
└── src
│ └── main
│ ├── AndroidManifest.xml
│ └── java
│ └── io
│ └── expo
│ └── appearance
│ ├── RNCAppearanceModule.java
│ └── RNCAppearancePackage.java
├── app.json
├── babel.config.js
├── example
├── .gitignore
├── App.tsx
├── android
│ ├── app
│ │ ├── _BUCK
│ │ ├── build.gradle
│ │ ├── build_defs.bzl
│ │ ├── proguard-rules.pro
│ │ └── src
│ │ │ ├── debug
│ │ │ └── AndroidManifest.xml
│ │ │ └── main
│ │ │ ├── AndroidManifest.xml
│ │ │ ├── java
│ │ │ └── com
│ │ │ │ └── appearanceexample
│ │ │ │ ├── MainActivity.java
│ │ │ │ └── MainApplication.java
│ │ │ └── res
│ │ │ ├── mipmap-hdpi
│ │ │ ├── ic_launcher.png
│ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-mdpi
│ │ │ ├── ic_launcher.png
│ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-xhdpi
│ │ │ ├── ic_launcher.png
│ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-xxhdpi
│ │ │ ├── ic_launcher.png
│ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-xxxhdpi
│ │ │ ├── ic_launcher.png
│ │ │ └── ic_launcher_round.png
│ │ │ └── values
│ │ │ ├── strings.xml
│ │ │ └── styles.xml
│ ├── build.gradle
│ ├── gradle.properties
│ ├── gradle
│ │ └── wrapper
│ │ │ ├── gradle-wrapper.jar
│ │ │ └── gradle-wrapper.properties
│ ├── gradlew
│ ├── gradlew.bat
│ └── settings.gradle
├── index.js
├── index.web.js
└── ios
│ ├── AppearanceExample-tvOS
│ └── Info.plist
│ ├── AppearanceExample-tvOSTests
│ └── Info.plist
│ ├── AppearanceExample.xcodeproj
│ ├── project.pbxproj
│ └── xcshareddata
│ │ └── xcschemes
│ │ └── SafeAreaViewExample.xcscheme
│ ├── AppearanceExample.xcworkspace
│ ├── contents.xcworkspacedata
│ └── xcshareddata
│ │ └── IDEWorkspaceChecks.plist
│ ├── AppearanceExample
│ ├── AppDelegate.h
│ ├── AppDelegate.m
│ ├── Base.lproj
│ │ └── LaunchScreen.xib
│ ├── Images.xcassets
│ │ ├── AppIcon.appiconset
│ │ │ └── Contents.json
│ │ └── Contents.json
│ ├── Info.plist
│ └── main.m
│ ├── Podfile
│ └── Podfile.lock
├── ios
├── Appearance.xcodeproj
│ └── project.pbxproj
└── Appearance
│ ├── RNCAppearance.h
│ ├── RNCAppearance.m
│ ├── RNCAppearanceProvider.h
│ ├── RNCAppearanceProvider.m
│ ├── RNCAppearanceProviderManager.h
│ └── RNCAppearanceProviderManager.m
├── metro.config.js
├── package.json
├── react-native-appearance.podspec
├── src
├── @types
│ └── use-subscription.d.ts
├── Appearance.types.ts
├── NativeAppearance.tsx
├── NativeAppearance.web.tsx
├── index.tsx
├── mock.tsx
└── web
│ ├── SyntheticPlatformEmitter.ts
│ └── emitter-polyfill.ts
├── tsconfig.json
└── yarn.lock
/.eslintignore:
--------------------------------------------------------------------------------
1 | typings
2 | node_modules
3 | example/android-bundle.js
4 | example/ios-bundle.js
5 |
6 | # generated by bob
7 | lib/
8 |
--------------------------------------------------------------------------------
/.eslintrc.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) Facebook, Inc. and its affiliates.
3 | *
4 | * This source code is licensed under the MIT license found in the
5 | * LICENSE file in the root directory of this source tree.
6 | *
7 | * @format
8 | */
9 |
10 | const typescriptEslintRecommended = require('@typescript-eslint/eslint-plugin/dist/configs/recommended.json');
11 | const typescriptEslintPrettier = require('eslint-config-prettier/@typescript-eslint');
12 |
13 | module.exports = {
14 | extends: ['@react-native-community'],
15 | overrides: [
16 | {
17 | files: ['*.ts', '*.tsx'],
18 | // Apply the recommended Typescript defaults and the prettier overrides to all Typescript files
19 | rules: Object.assign(
20 | typescriptEslintRecommended.rules,
21 | typescriptEslintPrettier.rules,
22 | {
23 | '@typescript-eslint/explicit-member-accessibility': 'off',
24 | '@typescript-eslint/explicit-function-return-type': 'off',
25 | '@typescript-eslint/no-use-before-define': 'off',
26 | 'react-native/no-inline-styles': 'off',
27 | },
28 | ),
29 | },
30 | ],
31 | };
32 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | *.pbxproj -text
2 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .expo
2 |
3 | # OSX
4 | #
5 | .DS_Store
6 |
7 | # node.js
8 | #
9 | node_modules/
10 | npm-debug.log
11 | yarn-error.log
12 |
13 |
14 | # Xcode
15 | #
16 | build/
17 | *.pbxuser
18 | !default.pbxuser
19 | *.mode1v3
20 | !default.mode1v3
21 | *.mode2v3
22 | !default.mode2v3
23 | *.perspectivev3
24 | !default.perspectivev3
25 | xcuserdata
26 | *.xccheckout
27 | *.moved-aside
28 | DerivedData
29 | *.hmap
30 | *.ipa
31 | *.xcuserstate
32 | project.xcworkspace
33 |
34 |
35 | # Android/IntelliJ
36 | #
37 | build/
38 | .idea
39 | .gradle
40 | local.properties
41 | *.iml
42 |
43 | # BUCK
44 | buck-out/
45 | \.buckd/
46 | debug.keystore
47 |
48 | # Editor config
49 | .vscode
50 |
51 | # Outputs
52 | coverage
53 |
54 | .tmp
55 | example/android-bundle.js
56 | example/ios-bundle.js
57 | index.android.bundle
58 | index.ios.bundle
59 |
60 | # generated by bob
61 | lib/
62 |
--------------------------------------------------------------------------------
/.prettierrc:
--------------------------------------------------------------------------------
1 | {
2 | "singleQuote": true,
3 | "trailingComma": "all",
4 | "bracketSpacing": true,
5 | "jsxBracketSameLine": false,
6 | "printWidth": 100
7 | }
8 |
--------------------------------------------------------------------------------
/.watchmanconfig:
--------------------------------------------------------------------------------
1 | {}
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) Facebook, Inc. and its affiliates.
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # react-native-appearance
2 |
3 | Access operating system appearance information on iOS, Android, and web. Currently supports detecting preferred color scheme (light/dark).
4 |
5 | > ⚠️ [Appearance](https://reactnative.dev/docs/appearance) in React Native core is recommended unless you have a good reason to use the library (eg: you're on an older React Native version.) This project is archived now that it will not be needed going forward.
6 |
7 | ## Installation
8 |
9 | Installation instructions vary depending on whether you're using a managed Expo project or a bare React Native project.
10 |
11 | ### Managed Expo project
12 |
13 | This library is supported in Expo SDK 35+ (SDK 35 includes iOS support, SDK 36 and higher includes support for all platforms).
14 |
15 | ```sh
16 | expo install react-native-appearance
17 | ```
18 |
19 | Then, in **app.json**, include `"userInterfaceStyle"` to listen to the device's appearance settings:
20 |
21 | ```js
22 | {
23 | "expo": {
24 | /*
25 | Supported user interface styles. If left blank, "light" will be used. Use "automatic" if you would like to support either "light" or "dark" depending on device settings.
26 | */
27 | "userInterfaceStyle": "automatic" | "light" | "dark"
28 | }
29 | }
30 | ```
31 |
32 | > Android support and web support are available on SDK36+.
33 |
34 | ### Bare React Native project
35 |
36 | ```sh
37 | yarn add react-native-appearance
38 | ```
39 |
40 | ## Linking
41 |
42 | > If you are not using AndroidX on your project already (this is the default on React Native 0.60+, but not on lower versions) you will want to use the `jetifier` npm package. Install the package with `yarn add -D jetifier` and then under `scripts` add `"postinstall": "jetify -r"`. Next run `yarn jetify`.
43 |
44 | After installing the package you need to link the native parts of the library for the platforms you are using. The easiest way to link the library is using the CLI tool by running this command from the root of your project:
45 |
46 | ```sh
47 | react-native link react-native-appearance
48 | ```
49 |
50 | If you can't or don't want to use the CLI tool, you can also manually link the library using the instructions below (click on the arrow to show them):
51 |
52 |
53 | Manually link the library on iOS
54 |
55 | Either follow the [instructions in the React Native documentation](https://facebook.github.io/react-native/docs/linking-libraries-ios#manual-linking) to manually link the framework or link using [Cocoapods](https://cocoapods.org) by adding this to your `Podfile`:
56 |
57 | ```ruby
58 | pod 'react-native-appearance', :path => '../node_modules/react-native-appearance'
59 | ```
60 |
61 |
62 |
63 |
64 | Manually link the library on Android
65 |
66 | 1. Open up `android/app/src/main/java/[...]/MainApplication.java`
67 |
68 | - Add `import io.expo.appearance.RNCAppearancePackage;` to the imports at the top of the file
69 | - Add `new RNCAppearancePackage()` to the list returned by the `getPackages()` method
70 |
71 | 2. Append the following lines to `android/settings.gradle`:
72 |
73 | ```
74 | include ':react-native-appearance'
75 | project(':react-native-appearance').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-appearance/android')
76 |
77 | ```
78 |
79 | 3. Insert the following lines inside the dependencies block in `android/app/build.gradle`:
80 |
81 | ```
82 | implementation project(':react-native-appearance')
83 | ```
84 |
85 |
86 |
87 | ## Configuration
88 |
89 |
90 | iOS configuration
91 |
92 | In Expo managed projects, add `ios.userInterfaceStyle` to your `app.json`:
93 |
94 | ```json
95 | {
96 | "expo": {
97 | "ios": {
98 | "userInterfaceStyle": "automatic"
99 | }
100 | }
101 | }
102 | ```
103 |
104 | For bare React Native apps, run `npx pod-install`. You can configure supported styles with the [UIUserInterfaceStyle](https://developer.apple.com/documentation/bundleresources/information_property_list/uiuserinterfacestyle) key in your app `Info.plist`.
105 |
106 |
107 |
108 |
109 | Android configuration
110 |
111 | Add the `uiMode` flag in `AndroidManifest.xml`:
112 |
113 | ```xml
114 |
117 | ```
118 |
119 | Implement the `onConfigurationChanged` method in `MainActivity.java`:
120 |
121 | ```java
122 | import android.content.Intent; // <--- import
123 | import android.content.res.Configuration; // <--- import
124 |
125 | public class MainActivity extends ReactActivity {
126 | ......
127 |
128 | // copy these lines
129 | @Override
130 | public void onConfigurationChanged(Configuration newConfig) {
131 | super.onConfigurationChanged(newConfig);
132 | Intent intent = new Intent("onConfigurationChanged");
133 | intent.putExtra("newConfig", newConfig);
134 | sendBroadcast(intent);
135 | }
136 |
137 | ......
138 | }
139 | ```
140 |
141 |
142 |
143 | ## Usage
144 |
145 | First, you need to wrap your app in the `AppearanceProvider`. At the root of your app, do the following:
146 |
147 | ```js
148 | import { AppearanceProvider } from 'react-native-appearance';
149 |
150 | export default () => (
151 |
152 |
153 |
154 | );
155 | ```
156 |
157 | Now you can use `Appearance` and `useColorScheme` anywhere in your app.
158 |
159 | ```js
160 | import { Appearance, useColorScheme } from 'react-native-appearance';
161 |
162 | /**
163 | * Get the current color scheme
164 | */
165 | Appearance.getColorScheme();
166 |
167 | /**
168 | * Subscribe to color scheme changes with a hook
169 | */
170 | function MyComponent() {
171 | const colorScheme = useColorScheme();
172 | if (colorScheme === 'dark') {
173 | // render some dark thing
174 | } else {
175 | // render some light thing
176 | }
177 | }
178 |
179 | /**
180 | * Subscribe to color scheme without a hook
181 | */
182 | const subscription = Appearance.addChangeListener(({ colorScheme }) => {
183 | // do something with color scheme
184 | });
185 |
186 | // Remove the subscription at some point
187 | subscription.remove();
188 | ```
189 |
190 | ## Attribution
191 |
192 | This was mostly written by Facebook for inclusion in React Native core.
193 |
--------------------------------------------------------------------------------
/android/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/android/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | android
4 | Project android_ created by Buildship.
5 |
6 |
7 |
8 |
9 | org.eclipse.jdt.core.javabuilder
10 |
11 |
12 |
13 |
14 | org.eclipse.buildship.core.gradleprojectbuilder
15 |
16 |
17 |
18 |
19 |
20 | org.eclipse.jdt.core.javanature
21 | org.eclipse.buildship.core.gradleprojectnature
22 |
23 |
24 |
--------------------------------------------------------------------------------
/android/.settings/org.eclipse.buildship.core.prefs:
--------------------------------------------------------------------------------
1 | arguments=
2 | auto.sync=false
3 | build.scans.enabled=false
4 | connection.gradle.distribution=GRADLE_DISTRIBUTION(VERSION(5.6.1))
5 | connection.project.dir=
6 | eclipse.preferences.version=1
7 | gradle.user.home=
8 | java.home=
9 | jvm.arguments=
10 | offline.mode=false
11 | override.workspace.settings=true
12 | show.console.view=true
13 | show.executions.view=true
14 |
--------------------------------------------------------------------------------
/android/README.md:
--------------------------------------------------------------------------------
1 | README
2 | ======
3 |
4 | If you want to publish the lib as a maven dependency, follow these steps before publishing a new version to npm:
5 |
6 | 1. Be sure to have the Android [SDK](https://developer.android.com/studio/index.html) and [NDK](https://developer.android.com/ndk/guides/index.html) installed
7 | 2. Be sure to have a `local.properties` file in this folder that points to the Android SDK and NDK
8 | ```
9 | ndk.dir=/Users/{username}/Library/Android/sdk/ndk-bundle
10 | sdk.dir=/Users/{username}/Library/Android/sdk
11 | ```
12 | 3. Delete the `maven` folder
13 | 4. Run `./gradlew installArchives`
14 | 5. Verify that latest set of generated files is in the maven folder with the correct version number
15 |
--------------------------------------------------------------------------------
/android/build.gradle:
--------------------------------------------------------------------------------
1 | // android/build.gradle
2 |
3 | def safeExtGet(prop, fallback) {
4 | rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
5 | }
6 |
7 | buildscript {
8 | // The Android Gradle plugin is only required when opening the android folder stand-alone.
9 | // This avoids unnecessary downloads and potential conflicts when the library is included as a
10 | // module dependency in an application project.
11 | if (project == rootProject) {
12 | repositories {
13 | google()
14 | jcenter()
15 | }
16 | dependencies {
17 | classpath 'com.android.tools.build:gradle:3.4.1'
18 | }
19 | }
20 | }
21 |
22 | apply plugin: 'com.android.library'
23 | apply plugin: 'maven'
24 |
25 | // Matches values in recent template from React Native 0.59 / 0.60
26 | // https://github.com/facebook/react-native/blob/0.59-stable/template/android/build.gradle#L5-L9
27 | // https://github.com/facebook/react-native/blob/0.60-stable/template/android/build.gradle#L5-L9
28 | def DEFAULT_COMPILE_SDK_VERSION = 28
29 | def DEFAULT_BUILD_TOOLS_VERSION = "28.0.3"
30 | def DEFAULT_MIN_SDK_VERSION = 16
31 | def DEFAULT_TARGET_SDK_VERSION = 28
32 |
33 | android {
34 | compileSdkVersion safeExtGet('compileSdkVersion', DEFAULT_COMPILE_SDK_VERSION)
35 | buildToolsVersion safeExtGet('buildToolsVersion', DEFAULT_BUILD_TOOLS_VERSION)
36 | defaultConfig {
37 | minSdkVersion safeExtGet('minSdkVersion', DEFAULT_MIN_SDK_VERSION)
38 | targetSdkVersion safeExtGet('targetSdkVersion', DEFAULT_TARGET_SDK_VERSION)
39 | versionCode 1
40 | versionName "1.0"
41 | }
42 | lintOptions {
43 | abortOnError false
44 | }
45 | }
46 |
47 | repositories {
48 | mavenLocal()
49 | maven {
50 | // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
51 | url "$rootDir/../node_modules/react-native/android"
52 | }
53 | maven {
54 | // Android JSC is installed from npm
55 | url "$rootDir/../node_modules/jsc-android/dist"
56 | }
57 | google()
58 | jcenter()
59 | }
60 |
61 | dependencies {
62 | // ref:
63 | // https://github.com/facebook/react-native/blob/0.61-stable/template/android/app/build.gradle#L192
64 | //noinspection GradleDynamicVersion
65 | implementation 'com.facebook.react:react-native:+' // From node_modules
66 | }
67 |
68 | def configureReactNativePom(def pom) {
69 | def packageJson = new groovy.json.JsonSlurper().parseText(file('../package.json').text)
70 |
71 | pom.project {
72 | name packageJson.title
73 | artifactId packageJson.name
74 | version = packageJson.version
75 | group = "io.expo.appearance"
76 | description packageJson.description
77 | url packageJson.repository.baseUrl
78 |
79 | licenses {
80 | license {
81 | name packageJson.license
82 | url packageJson.repository.baseUrl + '/blob/master/' + packageJson.licenseFilename
83 | distribution 'repo'
84 | }
85 | }
86 |
87 | developers {
88 | developer {
89 | id "brentvatne"
90 | name "Brent Vatne"
91 | }
92 | }
93 | }
94 | }
95 |
96 | afterEvaluate { project ->
97 | // some Gradle build hooks ref:
98 | // https://www.oreilly.com/library/view/gradle-beyond-the/9781449373801/ch03.html
99 | task androidJavadoc(type: Javadoc) {
100 | source = android.sourceSets.main.java.srcDirs
101 | classpath += files(android.bootClasspath)
102 | classpath += files(project.getConfigurations().getByName('compile').asList())
103 | include '**/*.java'
104 | }
105 |
106 | task androidJavadocJar(type: Jar, dependsOn: androidJavadoc) {
107 | classifier = 'javadoc'
108 | from androidJavadoc.destinationDir
109 | }
110 |
111 | task androidSourcesJar(type: Jar) {
112 | classifier = 'sources'
113 | from android.sourceSets.main.java.srcDirs
114 | include '**/*.java'
115 | }
116 |
117 | android.libraryVariants.all { variant ->
118 | def name = variant.name.capitalize()
119 | task "jar${name}"(type: Jar, dependsOn: variant.javaCompileProvider.get()) {
120 | from variant.javaCompileProvider.get().destinationDir
121 | }
122 | }
123 |
124 | artifacts {
125 | archives androidSourcesJar
126 | archives androidJavadocJar
127 | }
128 |
129 | task installArchives(type: Upload) {
130 | configuration = configurations.archives
131 | repositories.mavenDeployer {
132 | // Deploy to react-native-event-bridge/maven, ready to publish to npm
133 | repository url: "file://${projectDir}/../android/maven"
134 | configureReactNativePom pom
135 | }
136 | }
137 | }
138 |
--------------------------------------------------------------------------------
/android/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/android/src/main/java/io/expo/appearance/RNCAppearanceModule.java:
--------------------------------------------------------------------------------
1 | package io.expo.appearance;
2 |
3 | import android.app.Activity;
4 | import android.content.BroadcastReceiver;
5 | import android.content.Context;
6 | import android.content.Intent;
7 | import android.content.IntentFilter;
8 | import android.content.res.Configuration;
9 | import android.os.Build;
10 |
11 | import androidx.annotation.NonNull;
12 | import androidx.annotation.Nullable;
13 |
14 | import com.facebook.common.logging.FLog;
15 | import com.facebook.react.bridge.Arguments;
16 | import com.facebook.react.bridge.LifecycleEventListener;
17 | import com.facebook.react.bridge.ReactApplicationContext;
18 | import com.facebook.react.bridge.ReactContext;
19 | import com.facebook.react.bridge.ReactContextBaseJavaModule;
20 | import com.facebook.react.bridge.WritableMap;
21 | import com.facebook.react.common.ReactConstants;
22 | import com.facebook.react.modules.core.DeviceEventManagerModule;
23 |
24 | import java.util.HashMap;
25 | import java.util.Map;
26 |
27 | public class RNCAppearanceModule extends ReactContextBaseJavaModule implements LifecycleEventListener {
28 | public static final String REACT_CLASS = "RNCAppearance";
29 | private BroadcastReceiver mBroadcastReceiver = null;
30 |
31 | public RNCAppearanceModule(@NonNull ReactApplicationContext reactContext) {
32 | super(reactContext);
33 | // Only Android 10+ supports dark mode
34 | if (Build.VERSION.SDK_INT > Build.VERSION_CODES.P) {
35 | final ReactApplicationContext ctx = reactContext;
36 | mBroadcastReceiver = new BroadcastReceiver() {
37 | @Override
38 | public void onReceive(Context context, Intent intent) {
39 | Configuration newConfig = intent.getParcelableExtra("newConfig");
40 | sendEvent(ctx, "appearanceChanged", getPreferences());
41 | }
42 | };
43 | ctx.addLifecycleEventListener(this);
44 | }
45 | }
46 |
47 | @NonNull
48 | @Override
49 | public String getName() {
50 | return REACT_CLASS;
51 | }
52 |
53 | // `protected` to allow overriding in Expo client for scoping purposes
54 | protected String getColorScheme(Configuration config) {
55 | String colorScheme = "no-preference";
56 |
57 | // Only Android 10+ support dark mode
58 | if (Build.VERSION.SDK_INT > Build.VERSION_CODES.P) {
59 | int currentNightMode = config.uiMode & Configuration.UI_MODE_NIGHT_MASK;
60 | switch (currentNightMode) {
61 | case Configuration.UI_MODE_NIGHT_NO:
62 | case Configuration.UI_MODE_NIGHT_UNDEFINED:
63 | colorScheme = "light";
64 | break;
65 | case Configuration.UI_MODE_NIGHT_YES:
66 | colorScheme = "dark";
67 | break;
68 |
69 | }
70 | }
71 |
72 | return colorScheme;
73 | }
74 |
75 | private WritableMap getPreferences() {
76 | WritableMap preferences = Arguments.createMap();
77 |
78 | // Attempt to use the Activity context first in order to get the most up to date
79 | // scheme. This covers the scenario when AppCompatDelegate.setDefaultNightMode()
80 | // is called directly (which can occur in Brownfield apps for example).
81 | Activity activity = getCurrentActivity();
82 | Context context = activity != null ? activity : getReactApplicationContext();
83 |
84 | String colorScheme = getColorScheme(context.getResources().getConfiguration());
85 | preferences.putString("colorScheme", colorScheme);
86 | return preferences;
87 | }
88 |
89 | @Nullable
90 | @Override
91 | public Map getConstants() {
92 | HashMap constants = new HashMap();
93 | constants.put("initialPreferences", getPreferences());
94 | return constants;
95 | }
96 |
97 | private void sendEvent(ReactContext reactContext, String eventName, @Nullable WritableMap params) {
98 | if (reactContext.hasActiveCatalystInstance()) {
99 | FLog.i("sendEvent", eventName + ": " + params.toString());
100 | reactContext
101 | .getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
102 | .emit(eventName, params);
103 | }
104 |
105 | }
106 |
107 | private void sendEvent(String eventName, @Nullable WritableMap params) {
108 | if (getReactApplicationContext().hasActiveCatalystInstance()) {
109 | FLog.i("sendEvent", eventName + ": " + params.toString());
110 | getReactApplicationContext()
111 | .getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
112 | .emit(eventName, params);
113 | }
114 |
115 | }
116 |
117 | // We don't do any validation on whether the appearance has actually changed since the last
118 | // event was sent. We ignore this on the JS side if unchanged.
119 | private void updateAndSendAppearancePreferences() {
120 | WritableMap preferences = getPreferences();
121 | sendEvent("appearanceChanged", preferences);
122 | }
123 |
124 | @Override
125 | public void onHostResume() {
126 | final Activity activity = getCurrentActivity();
127 |
128 | if (activity == null) {
129 | FLog.e(ReactConstants.TAG, "no activity to register receiver");
130 | return;
131 | }
132 | activity.registerReceiver(mBroadcastReceiver, new IntentFilter("onConfigurationChanged"));
133 |
134 | // Send updated preferences to JS when the app is resumed, because we don't receive updates
135 | // when backgrounded
136 | updateAndSendAppearancePreferences();
137 | }
138 |
139 | @Override
140 | public void onHostPause() {
141 | final Activity activity = getCurrentActivity();
142 | if (activity == null) return;
143 | try {
144 | activity.unregisterReceiver(mBroadcastReceiver);
145 | } catch (java.lang.IllegalArgumentException e) {
146 | FLog.e(ReactConstants.TAG, "mBroadcastReceiver already unregistered", e);
147 | }
148 | }
149 |
150 | @Override
151 | public void onHostDestroy() {
152 | // No need to do anything as far as I know?
153 | }
154 | }
155 |
--------------------------------------------------------------------------------
/android/src/main/java/io/expo/appearance/RNCAppearancePackage.java:
--------------------------------------------------------------------------------
1 | package io.expo.appearance;
2 |
3 | import androidx.annotation.NonNull;
4 |
5 | import com.facebook.react.ReactPackage;
6 | import com.facebook.react.bridge.NativeModule;
7 | import com.facebook.react.bridge.ReactApplicationContext;
8 | import com.facebook.react.uimanager.ViewManager;
9 |
10 | import java.util.ArrayList;
11 | import java.util.Arrays;
12 | import java.util.Collections;
13 | import java.util.List;
14 |
15 | public class RNCAppearancePackage implements ReactPackage {
16 | @NonNull
17 | @Override
18 | public List createNativeModules(@NonNull ReactApplicationContext reactContext) {
19 | List modules = new ArrayList();
20 | modules.add(new RNCAppearanceModule(reactContext));
21 | return modules;
22 | }
23 |
24 | @Override
25 | @SuppressWarnings("rawtypes")
26 | public List createViewManagers(ReactApplicationContext reactContext) {
27 | return Collections.emptyList();
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/app.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "AppearanceExample",
3 | "displayName": "AppearanceExample",
4 | "expo": {
5 | "entryPoint": "./example/index.web.js",
6 | "sdkVersion": "34.0.0",
7 | "name": "react-native-appearance",
8 | "slug": "react-native-appearance",
9 | "version": "0.1.0",
10 | "platforms": ["web"],
11 | "web": {
12 | "display": "fullscreen",
13 | "barStyle": "black-translucent"
14 | }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/babel.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | presets: ['module:metro-react-native-babel-preset'],
3 | };
4 |
--------------------------------------------------------------------------------
/example/.gitignore:
--------------------------------------------------------------------------------
1 | # OSX
2 | #
3 | .DS_Store
4 |
5 | # Expo
6 | #
7 | .expo
8 |
9 | # Xcode
10 | #
11 | build/
12 | *.pbxuser
13 | !default.pbxuser
14 | *.mode1v3
15 | !default.mode1v3
16 | *.mode2v3
17 | !default.mode2v3
18 | *.perspectivev3
19 | !default.perspectivev3
20 | xcuserdata
21 | *.xccheckout
22 | *.moved-aside
23 | DerivedData
24 | *.hmap
25 | *.ipa
26 | *.xcuserstate
27 | project.xcworkspace
28 |
29 | # Android/IntelliJ
30 | #
31 | build/
32 | .idea
33 | .gradle
34 | local.properties
35 | *.iml
36 |
37 | # node.js
38 | #
39 | node_modules/
40 | npm-debug.log
41 | yarn-error.log
42 |
43 | # BUCK
44 | buck-out/
45 | \.buckd/
46 | *.keystore
47 |
48 | # fastlane
49 | #
50 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
51 | # screenshots whenever they are needed.
52 | # For more information about the recommended setup visit:
53 | # https://docs.fastlane.tools/best-practices/source-control/
54 |
55 | */fastlane/report.xml
56 | */fastlane/Preview.html
57 | */fastlane/screenshots
58 |
59 | # Bundle artifact
60 | *.jsbundle
61 |
62 | # CocoaPods
63 | /ios/Pods/
64 |
--------------------------------------------------------------------------------
/example/App.tsx:
--------------------------------------------------------------------------------
1 | import * as React from 'react';
2 | import { StyleSheet, Text, View, Button } from 'react-native';
3 |
4 | import { Appearance, AppearanceProvider, useColorScheme } from '..';
5 |
6 | export default () => {
7 | const colorScheme = useColorScheme();
8 | const isDark = colorScheme === 'dark';
9 |
10 | const color = isDark ? '#f1f1f1' : '#333';
11 | return (
12 |
13 |
14 | {colorScheme}
15 |
17 |
18 | );
19 | };
20 |
21 | const styles = StyleSheet.create({
22 | container: {
23 | flex: 1,
24 | alignItems: 'center',
25 | justifyContent: 'center',
26 | },
27 | text: {
28 | fontSize: 16,
29 | marginBottom: 24,
30 | fontWeight: 'bold',
31 | },
32 | footer: {
33 | position: 'absolute',
34 | bottom: 8,
35 | left: 8,
36 | right: 8,
37 | alignItems: 'center',
38 | justifyContent: 'center',
39 | flexDirection: 'row',
40 | },
41 | });
42 |
--------------------------------------------------------------------------------
/example/android/app/_BUCK:
--------------------------------------------------------------------------------
1 | # To learn about Buck see [Docs](https://buckbuild.com/).
2 | # To run your application with Buck:
3 | # - install Buck
4 | # - `npm start` - to start the packager
5 | # - `cd android`
6 | # - `keytool -genkey -v -keystore keystores/debug.keystore -storepass android -alias androiddebugkey -keypass android -dname "CN=Android Debug,O=Android,C=US"`
7 | # - `./gradlew :app:copyDownloadableDepsToLibs` - make all Gradle compile dependencies available to Buck
8 | # - `buck install -r android/app` - compile, install and run application
9 | #
10 |
11 | load(":build_defs.bzl", "create_aar_targets", "create_jar_targets")
12 |
13 | lib_deps = []
14 |
15 | create_aar_targets(glob(["libs/*.aar"]))
16 |
17 | create_jar_targets(glob(["libs/*.jar"]))
18 |
19 | android_library(
20 | name = "all-libs",
21 | exported_deps = lib_deps,
22 | )
23 |
24 | android_library(
25 | name = "app-code",
26 | srcs = glob([
27 | "src/main/java/**/*.java",
28 | ]),
29 | deps = [
30 | ":all-libs",
31 | ":build_config",
32 | ":res",
33 | ],
34 | )
35 |
36 | android_build_config(
37 | name = "build_config",
38 | package = "com.appearanceexample",
39 | )
40 |
41 | android_resource(
42 | name = "res",
43 | package = "com.appearanceexample",
44 | res = "src/main/res",
45 | )
46 |
47 | android_binary(
48 | name = "app",
49 | keystore = "//android/keystores:debug",
50 | manifest = "src/main/AndroidManifest.xml",
51 | package_type = "debug",
52 | deps = [
53 | ":app-code",
54 | ],
55 | )
56 |
--------------------------------------------------------------------------------
/example/android/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: "com.android.application"
2 |
3 | import com.android.build.OutputFile
4 |
5 | /**
6 | * The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets
7 | * and bundleReleaseJsAndAssets).
8 | * These basically call `react-native bundle` with the correct arguments during the Android build
9 | * cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the
10 | * bundle directly from the development server. Below you can see all the possible configurations
11 | * and their defaults. If you decide to add a configuration block, make sure to add it before the
12 | * `apply from: "../../node_modules/react-native/react.gradle"` line.
13 | *
14 | * project.ext.react = [
15 | * // the name of the generated asset file containing your JS bundle
16 | * bundleAssetName: "index.android.bundle",
17 | *
18 | * // the entry file for bundle generation
19 | * entryFile: "index.android.js",
20 | *
21 | * // https://facebook.github.io/react-native/docs/performance#enable-the-ram-format
22 | * bundleCommand: "ram-bundle",
23 | *
24 | * // whether to bundle JS and assets in debug mode
25 | * bundleInDebug: false,
26 | *
27 | * // whether to bundle JS and assets in release mode
28 | * bundleInRelease: true,
29 | *
30 | * // whether to bundle JS and assets in another build variant (if configured).
31 | * // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants
32 | * // The configuration property can be in the following formats
33 | * // 'bundleIn${productFlavor}${buildType}'
34 | * // 'bundleIn${buildType}'
35 | * // bundleInFreeDebug: true,
36 | * // bundleInPaidRelease: true,
37 | * // bundleInBeta: true,
38 | *
39 | * // whether to disable dev mode in custom build variants (by default only disabled in release)
40 | * // for example: to disable dev mode in the staging build type (if configured)
41 | * devDisabledInStaging: true,
42 | * // The configuration property can be in the following formats
43 | * // 'devDisabledIn${productFlavor}${buildType}'
44 | * // 'devDisabledIn${buildType}'
45 | *
46 | * // the root of your project, i.e. where "package.json" lives
47 | * root: "../../",
48 | *
49 | * // where to put the JS bundle asset in debug mode
50 | * jsBundleDirDebug: "$buildDir/intermediates/assets/debug",
51 | *
52 | * // where to put the JS bundle asset in release mode
53 | * jsBundleDirRelease: "$buildDir/intermediates/assets/release",
54 | *
55 | * // where to put drawable resources / React Native assets, e.g. the ones you use via
56 | * // require('./image.png')), in debug mode
57 | * resourcesDirDebug: "$buildDir/intermediates/res/merged/debug",
58 | *
59 | * // where to put drawable resources / React Native assets, e.g. the ones you use via
60 | * // require('./image.png')), in release mode
61 | * resourcesDirRelease: "$buildDir/intermediates/res/merged/release",
62 | *
63 | * // by default the gradle tasks are skipped if none of the JS files or assets change; this means
64 | * // that we don't look at files in android/ or ios/ to determine whether the tasks are up to
65 | * // date; if you have any other folders that you want to ignore for performance reasons (gradle
66 | * // indexes the entire tree), add them here. Alternatively, if you have JS files in android/
67 | * // for example, you might want to remove it from here.
68 | * inputExcludes: ["android/**", "ios/**"],
69 | *
70 | * // override which node gets called and with what additional arguments
71 | * nodeExecutableAndArgs: ["node"],
72 | *
73 | * // supply additional arguments to the packager
74 | * extraPackagerArgs: []
75 | * ]
76 | */
77 |
78 | project.ext.react = [
79 | entryFile: "index.js",
80 | enableHermes: false, // clean and rebuild if changing
81 | ]
82 |
83 | apply from: "../../../node_modules/react-native/react.gradle"
84 |
85 | /**
86 | * Set this to true to create two separate APKs instead of one:
87 | * - An APK that only works on ARM devices
88 | * - An APK that only works on x86 devices
89 | * The advantage is the size of the APK is reduced by about 4MB.
90 | * Upload all the APKs to the Play Store and people will download
91 | * the correct one based on the CPU architecture of their device.
92 | */
93 | def enableSeparateBuildPerCPUArchitecture = false
94 |
95 | /**
96 | * Run Proguard to shrink the Java bytecode in release builds.
97 | */
98 | def enableProguardInReleaseBuilds = false
99 |
100 | /**
101 | * The preferred build flavor of JavaScriptCore.
102 | *
103 | * For example, to use the international variant, you can use:
104 | * `def jscFlavor = 'org.webkit:android-jsc-intl:+'`
105 | *
106 | * The international variant includes ICU i18n library and necessary data
107 | * allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that
108 | * give correct results when using with locales other than en-US. Note that
109 | * this variant is about 6MiB larger per architecture than default.
110 | */
111 | def jscFlavor = 'org.webkit:android-jsc:+'
112 |
113 | /**
114 | * Whether to enable the Hermes VM.
115 | *
116 | * This should be set on project.ext.react and mirrored here. If it is not set
117 | * on project.ext.react, JavaScript will not be compiled to Hermes Bytecode
118 | * and the benefits of using Hermes will therefore be sharply reduced.
119 | */
120 | def enableHermes = project.ext.react.get("enableHermes", false);
121 |
122 | android {
123 | compileSdkVersion rootProject.ext.compileSdkVersion
124 |
125 | compileOptions {
126 | sourceCompatibility JavaVersion.VERSION_1_8
127 | targetCompatibility JavaVersion.VERSION_1_8
128 | }
129 |
130 | defaultConfig {
131 | applicationId "com.appearanceexample"
132 | minSdkVersion rootProject.ext.minSdkVersion
133 | targetSdkVersion rootProject.ext.targetSdkVersion
134 | versionCode 1
135 | versionName "1.0"
136 | }
137 | splits {
138 | abi {
139 | reset()
140 | enable enableSeparateBuildPerCPUArchitecture
141 | universalApk false // If true, also generate a universal APK
142 | include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
143 | }
144 | }
145 | signingConfigs {
146 | debug {
147 | storeFile file('debug.keystore')
148 | storePassword 'android'
149 | keyAlias 'androiddebugkey'
150 | keyPassword 'android'
151 | }
152 | }
153 | buildTypes {
154 | debug {
155 | signingConfig signingConfigs.debug
156 | }
157 | release {
158 | // Caution! In production, you need to generate your own keystore file.
159 | // see https://facebook.github.io/react-native/docs/signed-apk-android.
160 | signingConfig signingConfigs.debug
161 | minifyEnabled enableProguardInReleaseBuilds
162 | proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
163 | }
164 | }
165 | // applicationVariants are e.g. debug, release
166 | applicationVariants.all { variant ->
167 | variant.outputs.each { output ->
168 | // For each separate APK per architecture, set a unique version code as described here:
169 | // https://developer.android.com/studio/build/configure-apk-splits.html
170 | def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4]
171 | def abi = output.getFilter(OutputFile.ABI)
172 | if (abi != null) { // null for the universal-debug, universal-release variants
173 | output.versionCodeOverride =
174 | versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
175 | }
176 |
177 | }
178 | }
179 |
180 | packagingOptions {
181 | pickFirst '**/armeabi-v7a/libc++_shared.so'
182 | pickFirst '**/x86/libc++_shared.so'
183 | pickFirst '**/arm64-v8a/libc++_shared.so'
184 | pickFirst '**/x86_64/libc++_shared.so'
185 | pickFirst '**/x86/libjsc.so'
186 | pickFirst '**/armeabi-v7a/libjsc.so'
187 | }
188 | }
189 |
190 | dependencies {
191 | implementation fileTree(dir: "libs", include: ["*.jar"])
192 | implementation "com.facebook.react:react-native:+" // From node_modules
193 |
194 | if (enableHermes) {
195 | def hermesPath = "../../../node_modules/hermesvm/android/";
196 | debugImplementation files(hermesPath + "hermes-debug.aar")
197 | releaseImplementation files(hermesPath + "hermes-release.aar")
198 | } else {
199 | implementation jscFlavor
200 | }
201 |
202 | implementation project(":react-native-appearance")
203 | }
204 |
205 | // Run this once to be able to run the application with BUCK
206 | // puts all compile dependencies into folder libs for BUCK to use
207 | task copyDownloadableDepsToLibs(type: Copy) {
208 | from configurations.compile
209 | into 'libs'
210 | }
211 |
--------------------------------------------------------------------------------
/example/android/app/build_defs.bzl:
--------------------------------------------------------------------------------
1 | """Helper definitions to glob .aar and .jar targets"""
2 |
3 | def create_aar_targets(aarfiles):
4 | for aarfile in aarfiles:
5 | name = "aars__" + aarfile[aarfile.rindex("/") + 1:aarfile.rindex(".aar")]
6 | lib_deps.append(":" + name)
7 | android_prebuilt_aar(
8 | name = name,
9 | aar = aarfile,
10 | )
11 |
12 | def create_jar_targets(jarfiles):
13 | for jarfile in jarfiles:
14 | name = "jars__" + jarfile[jarfile.rindex("/") + 1:jarfile.rindex(".jar")]
15 | lib_deps.append(":" + name)
16 | prebuilt_jar(
17 | name = name,
18 | binary_jar = jarfile,
19 | )
20 |
--------------------------------------------------------------------------------
/example/android/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /usr/local/Cellar/android-sdk/24.3.3/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
--------------------------------------------------------------------------------
/example/android/app/src/debug/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/example/android/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
13 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/example/android/app/src/main/java/com/appearanceexample/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.appearanceexample;
2 |
3 | import android.content.Intent;
4 | import android.content.res.Configuration;
5 | import com.facebook.react.ReactActivity;
6 |
7 | public class MainActivity extends ReactActivity {
8 |
9 | /**
10 | * Returns the name of the main component registered from JavaScript.
11 | * This is used to schedule rendering of the component.
12 | */
13 | @Override
14 | protected String getMainComponentName() {
15 | return "AppearanceExample";
16 | }
17 |
18 | @Override
19 | public void onConfigurationChanged(Configuration newConfig) {
20 | super.onConfigurationChanged(newConfig);
21 | Intent intent = new Intent("onConfigurationChanged");
22 | intent.putExtra("newConfig", newConfig);
23 | sendBroadcast(intent);
24 | }
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/example/android/app/src/main/java/com/appearanceexample/MainApplication.java:
--------------------------------------------------------------------------------
1 | package com.appearanceexample;
2 |
3 | import android.app.Application;
4 |
5 | import io.expo.appearance.RNCAppearancePackage;
6 | import com.facebook.react.ReactApplication;
7 | import com.facebook.react.ReactNativeHost;
8 | import com.facebook.react.ReactPackage;
9 | import com.facebook.react.shell.MainReactPackage;
10 | import com.facebook.soloader.SoLoader;
11 |
12 | import java.util.Arrays;
13 | import java.util.List;
14 |
15 | public class MainApplication extends Application implements ReactApplication {
16 |
17 | private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
18 | @Override
19 | public boolean getUseDeveloperSupport() {
20 | return BuildConfig.DEBUG;
21 | }
22 |
23 | @Override
24 | protected List getPackages() {
25 | return Arrays.asList(
26 | new MainReactPackage(),
27 | new RNCAppearancePackage()
28 | );
29 | }
30 |
31 | @Override
32 | protected String getJSMainModuleName() {
33 | return "example/index";
34 | }
35 | };
36 |
37 | @Override
38 | public ReactNativeHost getReactNativeHost() {
39 | return mReactNativeHost;
40 | }
41 |
42 | @Override
43 | public void onCreate() {
44 | super.onCreate();
45 | SoLoader.init(this, /* native exopackage */ false);
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/expo/react-native-appearance/3340d85df16edf05c45f7880b9a9cc4647cb351b/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/expo/react-native-appearance/3340d85df16edf05c45f7880b9a9cc4647cb351b/example/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/expo/react-native-appearance/3340d85df16edf05c45f7880b9a9cc4647cb351b/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/expo/react-native-appearance/3340d85df16edf05c45f7880b9a9cc4647cb351b/example/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/expo/react-native-appearance/3340d85df16edf05c45f7880b9a9cc4647cb351b/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/expo/react-native-appearance/3340d85df16edf05c45f7880b9a9cc4647cb351b/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/expo/react-native-appearance/3340d85df16edf05c45f7880b9a9cc4647cb351b/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/expo/react-native-appearance/3340d85df16edf05c45f7880b9a9cc4647cb351b/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/expo/react-native-appearance/3340d85df16edf05c45f7880b9a9cc4647cb351b/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/expo/react-native-appearance/3340d85df16edf05c45f7880b9a9cc4647cb351b/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/example/android/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Hello App Display Name
3 |
4 |
--------------------------------------------------------------------------------
/example/android/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/example/android/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | ext {
5 | buildToolsVersion = "28.0.3"
6 | minSdkVersion = 16
7 | compileSdkVersion = 28
8 | targetSdkVersion = 28
9 | supportLibVersion = "28.0.0"
10 | }
11 | repositories {
12 | google()
13 | jcenter()
14 | }
15 | dependencies {
16 | classpath('com.android.tools.build:gradle:3.5.1')
17 |
18 | // NOTE: Do not place your application dependencies here; they belong
19 | // in the individual module build.gradle files
20 | }
21 | }
22 |
23 | allprojects {
24 | repositories {
25 | mavenLocal()
26 | maven {
27 | // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
28 | url("$rootDir/../../node_modules/react-native/android")
29 | }
30 | maven {
31 | // Android JSC is installed from npm
32 | url("$rootDir/../../node_modules/jsc-android/dist")
33 | }
34 |
35 | google()
36 | jcenter()
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/example/android/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m
13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
14 |
15 | # When configured, Gradle will run in incubating parallel mode.
16 | # This option should only be used with decoupled projects. More details, visit
17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18 | # org.gradle.parallel=true
19 |
20 | android.useAndroidX=true
21 | android.enableJetifier=true
22 |
--------------------------------------------------------------------------------
/example/android/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/expo/react-native-appearance/3340d85df16edf05c45f7880b9a9cc4647cb351b/example/android/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/example/android/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 |
--------------------------------------------------------------------------------
/example/android/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | #
4 | # Copyright 2015 the original author or authors.
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # http://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | #
18 |
19 | ##############################################################################
20 | ##
21 | ## Gradle start up script for UN*X
22 | ##
23 | ##############################################################################
24 |
25 | # Attempt to set APP_HOME
26 | # Resolve links: $0 may be a link
27 | PRG="$0"
28 | # Need this for relative symlinks.
29 | while [ -h "$PRG" ] ; do
30 | ls=`ls -ld "$PRG"`
31 | link=`expr "$ls" : '.*-> \(.*\)$'`
32 | if expr "$link" : '/.*' > /dev/null; then
33 | PRG="$link"
34 | else
35 | PRG=`dirname "$PRG"`"/$link"
36 | fi
37 | done
38 | SAVED="`pwd`"
39 | cd "`dirname \"$PRG\"`/" >/dev/null
40 | APP_HOME="`pwd -P`"
41 | cd "$SAVED" >/dev/null
42 |
43 | APP_NAME="Gradle"
44 | APP_BASE_NAME=`basename "$0"`
45 |
46 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
47 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
48 |
49 | # Use the maximum available, or set MAX_FD != -1 to use that value.
50 | MAX_FD="maximum"
51 |
52 | warn () {
53 | echo "$*"
54 | }
55 |
56 | die () {
57 | echo
58 | echo "$*"
59 | echo
60 | exit 1
61 | }
62 |
63 | # OS specific support (must be 'true' or 'false').
64 | cygwin=false
65 | msys=false
66 | darwin=false
67 | nonstop=false
68 | case "`uname`" in
69 | CYGWIN* )
70 | cygwin=true
71 | ;;
72 | Darwin* )
73 | darwin=true
74 | ;;
75 | MINGW* )
76 | msys=true
77 | ;;
78 | NONSTOP* )
79 | nonstop=true
80 | ;;
81 | esac
82 |
83 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
84 |
85 | # Determine the Java command to use to start the JVM.
86 | if [ -n "$JAVA_HOME" ] ; then
87 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
88 | # IBM's JDK on AIX uses strange locations for the executables
89 | JAVACMD="$JAVA_HOME/jre/sh/java"
90 | else
91 | JAVACMD="$JAVA_HOME/bin/java"
92 | fi
93 | if [ ! -x "$JAVACMD" ] ; then
94 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
95 |
96 | Please set the JAVA_HOME variable in your environment to match the
97 | location of your Java installation."
98 | fi
99 | else
100 | JAVACMD="java"
101 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
102 |
103 | Please set the JAVA_HOME variable in your environment to match the
104 | location of your Java installation."
105 | fi
106 |
107 | # Increase the maximum file descriptors if we can.
108 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
109 | MAX_FD_LIMIT=`ulimit -H -n`
110 | if [ $? -eq 0 ] ; then
111 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
112 | MAX_FD="$MAX_FD_LIMIT"
113 | fi
114 | ulimit -n $MAX_FD
115 | if [ $? -ne 0 ] ; then
116 | warn "Could not set maximum file descriptor limit: $MAX_FD"
117 | fi
118 | else
119 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
120 | fi
121 | fi
122 |
123 | # For Darwin, add options to specify how the application appears in the dock
124 | if $darwin; then
125 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
126 | fi
127 |
128 | # For Cygwin, switch paths to Windows format before running java
129 | if $cygwin ; then
130 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
131 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
132 | JAVACMD=`cygpath --unix "$JAVACMD"`
133 |
134 | # We build the pattern for arguments to be converted via cygpath
135 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
136 | SEP=""
137 | for dir in $ROOTDIRSRAW ; do
138 | ROOTDIRS="$ROOTDIRS$SEP$dir"
139 | SEP="|"
140 | done
141 | OURCYGPATTERN="(^($ROOTDIRS))"
142 | # Add a user-defined pattern to the cygpath arguments
143 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
144 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
145 | fi
146 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
147 | i=0
148 | for arg in "$@" ; do
149 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
150 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
151 |
152 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
153 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
154 | else
155 | eval `echo args$i`="\"$arg\""
156 | fi
157 | i=$((i+1))
158 | done
159 | case $i in
160 | (0) set -- ;;
161 | (1) set -- "$args0" ;;
162 | (2) set -- "$args0" "$args1" ;;
163 | (3) set -- "$args0" "$args1" "$args2" ;;
164 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
165 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
166 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
167 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
168 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
169 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
170 | esac
171 | fi
172 |
173 | # Escape application args
174 | save () {
175 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
176 | echo " "
177 | }
178 | APP_ARGS=$(save "$@")
179 |
180 | # Collect all arguments for the java command, following the shell quoting and substitution rules
181 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
182 |
183 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
184 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
185 | cd "$(dirname "$0")"
186 | fi
187 |
188 | exec "$JAVACMD" "$@"
189 |
--------------------------------------------------------------------------------
/example/android/gradlew.bat:
--------------------------------------------------------------------------------
1 | @rem
2 | @rem Copyright 2015 the original author or authors.
3 | @rem
4 | @rem Licensed under the Apache License, Version 2.0 (the "License");
5 | @rem you may not use this file except in compliance with the License.
6 | @rem You may obtain a copy of the License at
7 | @rem
8 | @rem http://www.apache.org/licenses/LICENSE-2.0
9 | @rem
10 | @rem Unless required by applicable law or agreed to in writing, software
11 | @rem distributed under the License is distributed on an "AS IS" BASIS,
12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | @rem See the License for the specific language governing permissions and
14 | @rem limitations under the License.
15 | @rem
16 |
17 | @if "%DEBUG%" == "" @echo off
18 | @rem ##########################################################################
19 | @rem
20 | @rem Gradle startup script for Windows
21 | @rem
22 | @rem ##########################################################################
23 |
24 | @rem Set local scope for the variables with windows NT shell
25 | if "%OS%"=="Windows_NT" setlocal
26 |
27 | set DIRNAME=%~dp0
28 | if "%DIRNAME%" == "" set DIRNAME=.
29 | set APP_BASE_NAME=%~n0
30 | set APP_HOME=%DIRNAME%
31 |
32 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
33 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
34 |
35 | @rem Find java.exe
36 | if defined JAVA_HOME goto findJavaFromJavaHome
37 |
38 | set JAVA_EXE=java.exe
39 | %JAVA_EXE% -version >NUL 2>&1
40 | if "%ERRORLEVEL%" == "0" goto init
41 |
42 | echo.
43 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
44 | echo.
45 | echo Please set the JAVA_HOME variable in your environment to match the
46 | echo location of your Java installation.
47 |
48 | goto fail
49 |
50 | :findJavaFromJavaHome
51 | set JAVA_HOME=%JAVA_HOME:"=%
52 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
53 |
54 | if exist "%JAVA_EXE%" goto init
55 |
56 | echo.
57 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
58 | echo.
59 | echo Please set the JAVA_HOME variable in your environment to match the
60 | echo location of your Java installation.
61 |
62 | goto fail
63 |
64 | :init
65 | @rem Get command-line arguments, handling Windows variants
66 |
67 | if not "%OS%" == "Windows_NT" goto win9xME_args
68 |
69 | :win9xME_args
70 | @rem Slurp the command line arguments.
71 | set CMD_LINE_ARGS=
72 | set _SKIP=2
73 |
74 | :win9xME_args_slurp
75 | if "x%~1" == "x" goto execute
76 |
77 | set CMD_LINE_ARGS=%*
78 |
79 | :execute
80 | @rem Setup the command line
81 |
82 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
83 |
84 | @rem Execute Gradle
85 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
86 |
87 | :end
88 | @rem End local scope for the variables with windows NT shell
89 | if "%ERRORLEVEL%"=="0" goto mainEnd
90 |
91 | :fail
92 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
93 | rem the _cmd.exe /c_ return code!
94 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
95 | exit /b 1
96 |
97 | :mainEnd
98 | if "%OS%"=="Windows_NT" endlocal
99 |
100 | :omega
101 |
--------------------------------------------------------------------------------
/example/android/settings.gradle:
--------------------------------------------------------------------------------
1 | rootProject.name = 'AppearanceExample'
2 | include ':app'
3 |
4 | include ':react-native-appearance'
5 | project(':react-native-appearance').projectDir = new File(rootProject.projectDir, '../../android')
6 |
--------------------------------------------------------------------------------
/example/index.js:
--------------------------------------------------------------------------------
1 | import { AppRegistry } from 'react-native';
2 | import App from './App';
3 | import { name as appName } from '../app.json';
4 |
5 | AppRegistry.registerComponent(appName, () => App);
6 |
--------------------------------------------------------------------------------
/example/index.web.js:
--------------------------------------------------------------------------------
1 | import { registerRootComponent } from 'expo';
2 | import App from './App';
3 | registerRootComponent(App);
--------------------------------------------------------------------------------
/example/ios/AppearanceExample-tvOS/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | APPL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1
23 | LSRequiresIPhoneOS
24 |
25 | NSAppTransportSecurity
26 |
27 | NSExceptionDomains
28 |
29 | localhost
30 |
31 | NSExceptionAllowsInsecureHTTPLoads
32 |
33 |
34 |
35 |
36 | NSLocationWhenInUseUsageDescription
37 |
38 | UILaunchStoryboardName
39 | LaunchScreen
40 | UIRequiredDeviceCapabilities
41 |
42 | armv7
43 |
44 | UISupportedInterfaceOrientations
45 |
46 | UIInterfaceOrientationPortrait
47 | UIInterfaceOrientationLandscapeLeft
48 | UIInterfaceOrientationLandscapeRight
49 |
50 | UIViewControllerBasedStatusBarAppearance
51 |
52 |
53 |
54 |
--------------------------------------------------------------------------------
/example/ios/AppearanceExample-tvOSTests/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | BNDL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1
23 |
24 |
25 |
--------------------------------------------------------------------------------
/example/ios/AppearanceExample.xcodeproj/project.pbxproj:
--------------------------------------------------------------------------------
1 | // !$*UTF8*$!
2 | {
3 | archiveVersion = 1;
4 | classes = {
5 | };
6 | objectVersion = 46;
7 | objects = {
8 |
9 | /* Begin PBXBuildFile section */
10 | 13B07FBC1A68108700A75B9A /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB01A68108700A75B9A /* AppDelegate.m */; };
11 | 13B07FBD1A68108700A75B9A /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB11A68108700A75B9A /* LaunchScreen.xib */; };
12 | 13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB51A68108700A75B9A /* Images.xcassets */; };
13 | 13B07FC11A68108700A75B9A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB71A68108700A75B9A /* main.m */; };
14 | D590E4D001221F6B5AF11381 /* libPods-AppearanceExample.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 275F94A75481D4E6C652CF4F /* libPods-AppearanceExample.a */; };
15 | /* End PBXBuildFile section */
16 |
17 | /* Begin PBXFileReference section */
18 | 008F07F21AC5B25A0029DE68 /* main.jsbundle */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = main.jsbundle; sourceTree = ""; };
19 | 0A89B68A414A9ACE6081995A /* Pods-AppearanceExample.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-AppearanceExample.debug.xcconfig"; path = "Target Support Files/Pods-AppearanceExample/Pods-AppearanceExample.debug.xcconfig"; sourceTree = ""; };
20 | 13B07F961A680F5B00A75B9A /* AppearanceExample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = AppearanceExample.app; sourceTree = BUILT_PRODUCTS_DIR; };
21 | 13B07FAF1A68108700A75B9A /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AppDelegate.h; path = AppearanceExample/AppDelegate.h; sourceTree = ""; };
22 | 13B07FB01A68108700A75B9A /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AppDelegate.m; path = AppearanceExample/AppDelegate.m; sourceTree = ""; };
23 | 13B07FB21A68108700A75B9A /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = ""; };
24 | 13B07FB51A68108700A75B9A /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Images.xcassets; path = AppearanceExample/Images.xcassets; sourceTree = ""; };
25 | 13B07FB61A68108700A75B9A /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = AppearanceExample/Info.plist; sourceTree = ""; };
26 | 13B07FB71A68108700A75B9A /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = main.m; path = AppearanceExample/main.m; sourceTree = ""; };
27 | 275F94A75481D4E6C652CF4F /* libPods-AppearanceExample.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-AppearanceExample.a"; sourceTree = BUILT_PRODUCTS_DIR; };
28 | 69AAEDE94ED39E6A720417AA /* Pods-AppearanceExample.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-AppearanceExample.release.xcconfig"; path = "Target Support Files/Pods-AppearanceExample/Pods-AppearanceExample.release.xcconfig"; sourceTree = ""; };
29 | ED297162215061F000B7C4FE /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaScriptCore.framework; path = System/Library/Frameworks/JavaScriptCore.framework; sourceTree = SDKROOT; };
30 | ED2971642150620600B7C4FE /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaScriptCore.framework; path = Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS12.0.sdk/System/Library/Frameworks/JavaScriptCore.framework; sourceTree = DEVELOPER_DIR; };
31 | /* End PBXFileReference section */
32 |
33 | /* Begin PBXFrameworksBuildPhase section */
34 | 13B07F8C1A680F5B00A75B9A /* Frameworks */ = {
35 | isa = PBXFrameworksBuildPhase;
36 | buildActionMask = 2147483647;
37 | files = (
38 | D590E4D001221F6B5AF11381 /* libPods-AppearanceExample.a in Frameworks */,
39 | );
40 | runOnlyForDeploymentPostprocessing = 0;
41 | };
42 | /* End PBXFrameworksBuildPhase section */
43 |
44 | /* Begin PBXGroup section */
45 | 13B07FAE1A68108700A75B9A /* AppearanceExample */ = {
46 | isa = PBXGroup;
47 | children = (
48 | 008F07F21AC5B25A0029DE68 /* main.jsbundle */,
49 | 13B07FAF1A68108700A75B9A /* AppDelegate.h */,
50 | 13B07FB01A68108700A75B9A /* AppDelegate.m */,
51 | 13B07FB51A68108700A75B9A /* Images.xcassets */,
52 | 13B07FB61A68108700A75B9A /* Info.plist */,
53 | 13B07FB11A68108700A75B9A /* LaunchScreen.xib */,
54 | 13B07FB71A68108700A75B9A /* main.m */,
55 | );
56 | name = AppearanceExample;
57 | sourceTree = "";
58 | };
59 | 2D16E6871FA4F8E400B85C8A /* Frameworks */ = {
60 | isa = PBXGroup;
61 | children = (
62 | ED297162215061F000B7C4FE /* JavaScriptCore.framework */,
63 | ED2971642150620600B7C4FE /* JavaScriptCore.framework */,
64 | 275F94A75481D4E6C652CF4F /* libPods-AppearanceExample.a */,
65 | );
66 | name = Frameworks;
67 | sourceTree = "";
68 | };
69 | 832341AE1AAA6A7D00B99B32 /* Libraries */ = {
70 | isa = PBXGroup;
71 | children = (
72 | );
73 | name = Libraries;
74 | sourceTree = "";
75 | };
76 | 83CBB9F61A601CBA00E9B192 = {
77 | isa = PBXGroup;
78 | children = (
79 | 13B07FAE1A68108700A75B9A /* AppearanceExample */,
80 | 832341AE1AAA6A7D00B99B32 /* Libraries */,
81 | 83CBBA001A601CBA00E9B192 /* Products */,
82 | 2D16E6871FA4F8E400B85C8A /* Frameworks */,
83 | 8420299E7589F138B56B721A /* Pods */,
84 | );
85 | indentWidth = 2;
86 | sourceTree = "";
87 | tabWidth = 2;
88 | usesTabs = 0;
89 | };
90 | 83CBBA001A601CBA00E9B192 /* Products */ = {
91 | isa = PBXGroup;
92 | children = (
93 | 13B07F961A680F5B00A75B9A /* AppearanceExample.app */,
94 | );
95 | name = Products;
96 | sourceTree = "";
97 | };
98 | 8420299E7589F138B56B721A /* Pods */ = {
99 | isa = PBXGroup;
100 | children = (
101 | 0A89B68A414A9ACE6081995A /* Pods-AppearanceExample.debug.xcconfig */,
102 | 69AAEDE94ED39E6A720417AA /* Pods-AppearanceExample.release.xcconfig */,
103 | );
104 | path = Pods;
105 | sourceTree = "";
106 | };
107 | /* End PBXGroup section */
108 |
109 | /* Begin PBXNativeTarget section */
110 | 13B07F861A680F5B00A75B9A /* AppearanceExample */ = {
111 | isa = PBXNativeTarget;
112 | buildConfigurationList = 13B07F931A680F5B00A75B9A /* Build configuration list for PBXNativeTarget "AppearanceExample" */;
113 | buildPhases = (
114 | 583C785316E508E312E6F376 /* [CP] Check Pods Manifest.lock */,
115 | FD10A7F022414F080027D42C /* Start Packager */,
116 | 13B07F871A680F5B00A75B9A /* Sources */,
117 | 13B07F8C1A680F5B00A75B9A /* Frameworks */,
118 | 13B07F8E1A680F5B00A75B9A /* Resources */,
119 | 00DD1BFF1BD5951E006B06BC /* Bundle React Native code and images */,
120 | );
121 | buildRules = (
122 | );
123 | dependencies = (
124 | );
125 | name = AppearanceExample;
126 | productName = AppearanceExample;
127 | productReference = 13B07F961A680F5B00A75B9A /* AppearanceExample.app */;
128 | productType = "com.apple.product-type.application";
129 | };
130 | /* End PBXNativeTarget section */
131 |
132 | /* Begin PBXProject section */
133 | 83CBB9F71A601CBA00E9B192 /* Project object */ = {
134 | isa = PBXProject;
135 | attributes = {
136 | LastUpgradeCheck = 1030;
137 | ORGANIZATIONNAME = Facebook;
138 | };
139 | buildConfigurationList = 83CBB9FA1A601CBA00E9B192 /* Build configuration list for PBXProject "AppearanceExample" */;
140 | compatibilityVersion = "Xcode 3.2";
141 | developmentRegion = en;
142 | hasScannedForEncodings = 0;
143 | knownRegions = (
144 | en,
145 | Base,
146 | );
147 | mainGroup = 83CBB9F61A601CBA00E9B192;
148 | productRefGroup = 83CBBA001A601CBA00E9B192 /* Products */;
149 | projectDirPath = "";
150 | projectRoot = "";
151 | targets = (
152 | 13B07F861A680F5B00A75B9A /* AppearanceExample */,
153 | );
154 | };
155 | /* End PBXProject section */
156 |
157 | /* Begin PBXResourcesBuildPhase section */
158 | 13B07F8E1A680F5B00A75B9A /* Resources */ = {
159 | isa = PBXResourcesBuildPhase;
160 | buildActionMask = 2147483647;
161 | files = (
162 | 13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */,
163 | 13B07FBD1A68108700A75B9A /* LaunchScreen.xib in Resources */,
164 | );
165 | runOnlyForDeploymentPostprocessing = 0;
166 | };
167 | /* End PBXResourcesBuildPhase section */
168 |
169 | /* Begin PBXShellScriptBuildPhase section */
170 | 00DD1BFF1BD5951E006B06BC /* Bundle React Native code and images */ = {
171 | isa = PBXShellScriptBuildPhase;
172 | buildActionMask = 2147483647;
173 | files = (
174 | );
175 | inputPaths = (
176 | );
177 | name = "Bundle React Native code and images";
178 | outputPaths = (
179 | );
180 | runOnlyForDeploymentPostprocessing = 0;
181 | shellPath = /bin/sh;
182 | shellScript = "export NODE_BINARY=node\n../../node_modules/react-native/scripts/react-native-xcode.sh\n";
183 | };
184 | 583C785316E508E312E6F376 /* [CP] Check Pods Manifest.lock */ = {
185 | isa = PBXShellScriptBuildPhase;
186 | buildActionMask = 2147483647;
187 | files = (
188 | );
189 | inputFileListPaths = (
190 | );
191 | inputPaths = (
192 | "${PODS_PODFILE_DIR_PATH}/Podfile.lock",
193 | "${PODS_ROOT}/Manifest.lock",
194 | );
195 | name = "[CP] Check Pods Manifest.lock";
196 | outputFileListPaths = (
197 | );
198 | outputPaths = (
199 | "$(DERIVED_FILE_DIR)/Pods-AppearanceExample-checkManifestLockResult.txt",
200 | );
201 | runOnlyForDeploymentPostprocessing = 0;
202 | shellPath = /bin/sh;
203 | shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
204 | showEnvVarsInLog = 0;
205 | };
206 | FD10A7F022414F080027D42C /* Start Packager */ = {
207 | isa = PBXShellScriptBuildPhase;
208 | buildActionMask = 2147483647;
209 | files = (
210 | );
211 | inputFileListPaths = (
212 | );
213 | inputPaths = (
214 | );
215 | name = "Start Packager";
216 | outputFileListPaths = (
217 | );
218 | outputPaths = (
219 | );
220 | runOnlyForDeploymentPostprocessing = 0;
221 | shellPath = /bin/sh;
222 | shellScript = "export RCT_METRO_PORT=\"${RCT_METRO_PORT:=8081}\"\necho \"export RCT_METRO_PORT=${RCT_METRO_PORT}\" > \"${SRCROOT}/../../node_modules/react-native/scripts/.packager.env\"\nif [ -z \"${RCT_NO_LAUNCH_PACKAGER+xxx}\" ] ; then\n if nc -w 5 -z localhost ${RCT_METRO_PORT} ; then\n if ! curl -s \"http://localhost:${RCT_METRO_PORT}/status\" | grep -q \"packager-status:running\" ; then\n echo \"Port ${RCT_METRO_PORT} already in use, packager is either not running or not running correctly\"\n exit 2\n fi\n else\n open \"$SRCROOT/../node_modules/react-native/scripts/launchPackager.command\" || echo \"Can't start packager automatically\"\n fi\nfi\n";
223 | showEnvVarsInLog = 0;
224 | };
225 | /* End PBXShellScriptBuildPhase section */
226 |
227 | /* Begin PBXSourcesBuildPhase section */
228 | 13B07F871A680F5B00A75B9A /* Sources */ = {
229 | isa = PBXSourcesBuildPhase;
230 | buildActionMask = 2147483647;
231 | files = (
232 | 13B07FBC1A68108700A75B9A /* AppDelegate.m in Sources */,
233 | 13B07FC11A68108700A75B9A /* main.m in Sources */,
234 | );
235 | runOnlyForDeploymentPostprocessing = 0;
236 | };
237 | /* End PBXSourcesBuildPhase section */
238 |
239 | /* Begin PBXVariantGroup section */
240 | 13B07FB11A68108700A75B9A /* LaunchScreen.xib */ = {
241 | isa = PBXVariantGroup;
242 | children = (
243 | 13B07FB21A68108700A75B9A /* Base */,
244 | );
245 | name = LaunchScreen.xib;
246 | path = AppearanceExample;
247 | sourceTree = "";
248 | };
249 | /* End PBXVariantGroup section */
250 |
251 | /* Begin XCBuildConfiguration section */
252 | 13B07F941A680F5B00A75B9A /* Debug */ = {
253 | isa = XCBuildConfiguration;
254 | baseConfigurationReference = 0A89B68A414A9ACE6081995A /* Pods-AppearanceExample.debug.xcconfig */;
255 | buildSettings = {
256 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
257 | CURRENT_PROJECT_VERSION = 1;
258 | DEAD_CODE_STRIPPING = NO;
259 | INFOPLIST_FILE = AppearanceExample/Info.plist;
260 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
261 | OTHER_LDFLAGS = (
262 | "$(inherited)",
263 | "-ObjC",
264 | "-lc++",
265 | );
266 | PRODUCT_BUNDLE_IDENTIFIER = "org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)";
267 | PRODUCT_NAME = AppearanceExample;
268 | VERSIONING_SYSTEM = "apple-generic";
269 | };
270 | name = Debug;
271 | };
272 | 13B07F951A680F5B00A75B9A /* Release */ = {
273 | isa = XCBuildConfiguration;
274 | baseConfigurationReference = 69AAEDE94ED39E6A720417AA /* Pods-AppearanceExample.release.xcconfig */;
275 | buildSettings = {
276 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
277 | CURRENT_PROJECT_VERSION = 1;
278 | INFOPLIST_FILE = AppearanceExample/Info.plist;
279 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
280 | OTHER_LDFLAGS = (
281 | "$(inherited)",
282 | "-ObjC",
283 | "-lc++",
284 | );
285 | PRODUCT_BUNDLE_IDENTIFIER = "org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)";
286 | PRODUCT_NAME = AppearanceExample;
287 | VERSIONING_SYSTEM = "apple-generic";
288 | };
289 | name = Release;
290 | };
291 | 83CBBA201A601CBA00E9B192 /* Debug */ = {
292 | isa = XCBuildConfiguration;
293 | buildSettings = {
294 | ALWAYS_SEARCH_USER_PATHS = NO;
295 | CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
296 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
297 | CLANG_CXX_LIBRARY = "libc++";
298 | CLANG_ENABLE_MODULES = YES;
299 | CLANG_ENABLE_OBJC_ARC = YES;
300 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
301 | CLANG_WARN_BOOL_CONVERSION = YES;
302 | CLANG_WARN_COMMA = YES;
303 | CLANG_WARN_CONSTANT_CONVERSION = YES;
304 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
305 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
306 | CLANG_WARN_EMPTY_BODY = YES;
307 | CLANG_WARN_ENUM_CONVERSION = YES;
308 | CLANG_WARN_INFINITE_RECURSION = YES;
309 | CLANG_WARN_INT_CONVERSION = YES;
310 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
311 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
312 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
313 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
314 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
315 | CLANG_WARN_STRICT_PROTOTYPES = YES;
316 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
317 | CLANG_WARN_UNREACHABLE_CODE = YES;
318 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
319 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
320 | COPY_PHASE_STRIP = NO;
321 | ENABLE_STRICT_OBJC_MSGSEND = YES;
322 | ENABLE_TESTABILITY = YES;
323 | GCC_C_LANGUAGE_STANDARD = gnu99;
324 | GCC_DYNAMIC_NO_PIC = NO;
325 | GCC_NO_COMMON_BLOCKS = YES;
326 | GCC_OPTIMIZATION_LEVEL = 0;
327 | GCC_PREPROCESSOR_DEFINITIONS = (
328 | "DEBUG=1",
329 | "$(inherited)",
330 | );
331 | GCC_SYMBOLS_PRIVATE_EXTERN = NO;
332 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
333 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
334 | GCC_WARN_UNDECLARED_SELECTOR = YES;
335 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
336 | GCC_WARN_UNUSED_FUNCTION = YES;
337 | GCC_WARN_UNUSED_VARIABLE = YES;
338 | IPHONEOS_DEPLOYMENT_TARGET = 9.0;
339 | MTL_ENABLE_DEBUG_INFO = YES;
340 | ONLY_ACTIVE_ARCH = YES;
341 | SDKROOT = iphoneos;
342 | };
343 | name = Debug;
344 | };
345 | 83CBBA211A601CBA00E9B192 /* Release */ = {
346 | isa = XCBuildConfiguration;
347 | buildSettings = {
348 | ALWAYS_SEARCH_USER_PATHS = NO;
349 | CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
350 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
351 | CLANG_CXX_LIBRARY = "libc++";
352 | CLANG_ENABLE_MODULES = YES;
353 | CLANG_ENABLE_OBJC_ARC = YES;
354 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
355 | CLANG_WARN_BOOL_CONVERSION = YES;
356 | CLANG_WARN_COMMA = YES;
357 | CLANG_WARN_CONSTANT_CONVERSION = YES;
358 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
359 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
360 | CLANG_WARN_EMPTY_BODY = YES;
361 | CLANG_WARN_ENUM_CONVERSION = YES;
362 | CLANG_WARN_INFINITE_RECURSION = YES;
363 | CLANG_WARN_INT_CONVERSION = YES;
364 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
365 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
366 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
367 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
368 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
369 | CLANG_WARN_STRICT_PROTOTYPES = YES;
370 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
371 | CLANG_WARN_UNREACHABLE_CODE = YES;
372 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
373 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
374 | COPY_PHASE_STRIP = YES;
375 | ENABLE_NS_ASSERTIONS = NO;
376 | ENABLE_STRICT_OBJC_MSGSEND = YES;
377 | GCC_C_LANGUAGE_STANDARD = gnu99;
378 | GCC_NO_COMMON_BLOCKS = YES;
379 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
380 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
381 | GCC_WARN_UNDECLARED_SELECTOR = YES;
382 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
383 | GCC_WARN_UNUSED_FUNCTION = YES;
384 | GCC_WARN_UNUSED_VARIABLE = YES;
385 | IPHONEOS_DEPLOYMENT_TARGET = 9.0;
386 | MTL_ENABLE_DEBUG_INFO = NO;
387 | SDKROOT = iphoneos;
388 | VALIDATE_PRODUCT = YES;
389 | };
390 | name = Release;
391 | };
392 | /* End XCBuildConfiguration section */
393 |
394 | /* Begin XCConfigurationList section */
395 | 13B07F931A680F5B00A75B9A /* Build configuration list for PBXNativeTarget "AppearanceExample" */ = {
396 | isa = XCConfigurationList;
397 | buildConfigurations = (
398 | 13B07F941A680F5B00A75B9A /* Debug */,
399 | 13B07F951A680F5B00A75B9A /* Release */,
400 | );
401 | defaultConfigurationIsVisible = 0;
402 | defaultConfigurationName = Release;
403 | };
404 | 83CBB9FA1A601CBA00E9B192 /* Build configuration list for PBXProject "AppearanceExample" */ = {
405 | isa = XCConfigurationList;
406 | buildConfigurations = (
407 | 83CBBA201A601CBA00E9B192 /* Debug */,
408 | 83CBBA211A601CBA00E9B192 /* Release */,
409 | );
410 | defaultConfigurationIsVisible = 0;
411 | defaultConfigurationName = Release;
412 | };
413 | /* End XCConfigurationList section */
414 | };
415 | rootObject = 83CBB9F71A601CBA00E9B192 /* Project object */;
416 | }
417 |
--------------------------------------------------------------------------------
/example/ios/AppearanceExample.xcodeproj/xcshareddata/xcschemes/SafeAreaViewExample.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
29 |
35 |
36 |
37 |
43 |
49 |
50 |
51 |
52 |
53 |
58 |
59 |
65 |
66 |
67 |
68 |
70 |
76 |
77 |
78 |
79 |
80 |
90 |
92 |
98 |
99 |
100 |
101 |
107 |
109 |
115 |
116 |
117 |
118 |
120 |
121 |
124 |
125 |
126 |
--------------------------------------------------------------------------------
/example/ios/AppearanceExample.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/example/ios/AppearanceExample.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/example/ios/AppearanceExample/AppDelegate.h:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) Facebook, Inc. and its affiliates.
3 | *
4 | * This source code is licensed under the MIT license found in the
5 | * LICENSE file in the root directory of this source tree.
6 | */
7 |
8 | #import
9 | #import
10 |
11 | @interface AppDelegate : UIResponder
12 |
13 | @property (nonatomic, strong) UIWindow *window;
14 |
15 | @end
16 |
--------------------------------------------------------------------------------
/example/ios/AppearanceExample/AppDelegate.m:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) Facebook, Inc. and its affiliates.
3 | *
4 | * This source code is licensed under the MIT license found in the
5 | * LICENSE file in the root directory of this source tree.
6 | */
7 |
8 | #import "AppDelegate.h"
9 |
10 | #import
11 | #import
12 | #import
13 |
14 | @implementation AppDelegate
15 |
16 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
17 | {
18 | RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions];
19 | RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge
20 | moduleName:@"AppearanceExample"
21 | initialProperties:nil];
22 |
23 | rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1];
24 |
25 | self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
26 | UIViewController *rootViewController = [UIViewController new];
27 | rootViewController.view = rootView;
28 | self.window.rootViewController = rootViewController;
29 | [self.window makeKeyAndVisible];
30 | return YES;
31 | }
32 |
33 | - (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
34 | {
35 | #if DEBUG
36 | return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"example/index" fallbackResource:nil];
37 | #else
38 | return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
39 | #endif
40 | }
41 |
42 | @end
43 |
--------------------------------------------------------------------------------
/example/ios/AppearanceExample/Base.lproj/LaunchScreen.xib:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
21 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
--------------------------------------------------------------------------------
/example/ios/AppearanceExample/Images.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "iphone",
5 | "size" : "29x29",
6 | "scale" : "2x"
7 | },
8 | {
9 | "idiom" : "iphone",
10 | "size" : "29x29",
11 | "scale" : "3x"
12 | },
13 | {
14 | "idiom" : "iphone",
15 | "size" : "40x40",
16 | "scale" : "2x"
17 | },
18 | {
19 | "idiom" : "iphone",
20 | "size" : "40x40",
21 | "scale" : "3x"
22 | },
23 | {
24 | "idiom" : "iphone",
25 | "size" : "60x60",
26 | "scale" : "2x"
27 | },
28 | {
29 | "idiom" : "iphone",
30 | "size" : "60x60",
31 | "scale" : "3x"
32 | }
33 | ],
34 | "info" : {
35 | "version" : 1,
36 | "author" : "xcode"
37 | }
38 | }
--------------------------------------------------------------------------------
/example/ios/AppearanceExample/Images.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "version" : 1,
4 | "author" : "xcode"
5 | }
6 | }
7 |
--------------------------------------------------------------------------------
/example/ios/AppearanceExample/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleDisplayName
8 | Hello App Display Name
9 | CFBundleExecutable
10 | $(EXECUTABLE_NAME)
11 | CFBundleIdentifier
12 | $(PRODUCT_BUNDLE_IDENTIFIER)
13 | CFBundleInfoDictionaryVersion
14 | 6.0
15 | CFBundleName
16 | $(PRODUCT_NAME)
17 | CFBundlePackageType
18 | APPL
19 | CFBundleShortVersionString
20 | 1.0
21 | CFBundleSignature
22 | ????
23 | CFBundleVersion
24 | 1
25 | LSRequiresIPhoneOS
26 |
27 | NSAppTransportSecurity
28 |
29 | NSAllowsArbitraryLoads
30 |
31 | NSExceptionDomains
32 |
33 | localhost
34 |
35 | NSExceptionAllowsInsecureHTTPLoads
36 |
37 |
38 |
39 |
40 | NSLocationWhenInUseUsageDescription
41 |
42 | UILaunchStoryboardName
43 | LaunchScreen
44 | UIRequiredDeviceCapabilities
45 |
46 | armv7
47 |
48 | UISupportedInterfaceOrientations
49 |
50 | UIInterfaceOrientationPortrait
51 | UIInterfaceOrientationLandscapeLeft
52 | UIInterfaceOrientationLandscapeRight
53 |
54 | UIViewControllerBasedStatusBarAppearance
55 |
56 |
57 |
58 |
--------------------------------------------------------------------------------
/example/ios/AppearanceExample/main.m:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) Facebook, Inc. and its affiliates.
3 | *
4 | * This source code is licensed under the MIT license found in the
5 | * LICENSE file in the root directory of this source tree.
6 | */
7 |
8 | #import
9 |
10 | #import "AppDelegate.h"
11 |
12 | int main(int argc, char * argv[]) {
13 | @autoreleasepool {
14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/example/ios/Podfile:
--------------------------------------------------------------------------------
1 | platform :ios, '9.0'
2 |
3 | target 'AppearanceExample' do
4 | # Pods for AppearanceExample
5 | pod 'React', :path => '../../node_modules/react-native/'
6 | pod 'React-Core', :path => '../../node_modules/react-native/React'
7 | pod 'React-DevSupport', :path => '../../node_modules/react-native/React'
8 | pod 'React-RCTActionSheet', :path => '../../node_modules/react-native/Libraries/ActionSheetIOS'
9 | pod 'React-RCTAnimation', :path => '../../node_modules/react-native/Libraries/NativeAnimation'
10 | pod 'React-RCTBlob', :path => '../../node_modules/react-native/Libraries/Blob'
11 | pod 'React-RCTImage', :path => '../../node_modules/react-native/Libraries/Image'
12 | pod 'React-RCTLinking', :path => '../../node_modules/react-native/Libraries/LinkingIOS'
13 | pod 'React-RCTNetwork', :path => '../../node_modules/react-native/Libraries/Network'
14 | pod 'React-RCTSettings', :path => '../../node_modules/react-native/Libraries/Settings'
15 | pod 'React-RCTText', :path => '../../node_modules/react-native/Libraries/Text'
16 | pod 'React-RCTVibration', :path => '../../node_modules/react-native/Libraries/Vibration'
17 | pod 'React-RCTWebSocket', :path => '../../node_modules/react-native/Libraries/WebSocket'
18 |
19 | pod 'React-cxxreact', :path => '../../node_modules/react-native/ReactCommon/cxxreact'
20 | pod 'React-jsi', :path => '../../node_modules/react-native/ReactCommon/jsi'
21 | pod 'React-jsiexecutor', :path => '../../node_modules/react-native/ReactCommon/jsiexecutor'
22 | pod 'React-jsinspector', :path => '../../node_modules/react-native/ReactCommon/jsinspector'
23 | pod 'yoga', :path => '../../node_modules/react-native/ReactCommon/yoga'
24 |
25 | pod 'DoubleConversion', :podspec => '../../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec'
26 | pod 'glog', :podspec => '../../node_modules/react-native/third-party-podspecs/glog.podspec'
27 | pod 'Folly', :podspec => '../../node_modules/react-native/third-party-podspecs/Folly.podspec'
28 |
29 | pod 'react-native-appearance', :path => '../../'
30 | end
31 |
--------------------------------------------------------------------------------
/example/ios/Podfile.lock:
--------------------------------------------------------------------------------
1 | PODS:
2 | - boost-for-react-native (1.63.0)
3 | - DoubleConversion (1.1.6)
4 | - Folly (2018.10.22.00):
5 | - boost-for-react-native
6 | - DoubleConversion
7 | - Folly/Default (= 2018.10.22.00)
8 | - glog
9 | - Folly/Default (2018.10.22.00):
10 | - boost-for-react-native
11 | - DoubleConversion
12 | - glog
13 | - glog (0.3.5)
14 | - React (0.60.5):
15 | - React-Core (= 0.60.5)
16 | - React-DevSupport (= 0.60.5)
17 | - React-RCTActionSheet (= 0.60.5)
18 | - React-RCTAnimation (= 0.60.5)
19 | - React-RCTBlob (= 0.60.5)
20 | - React-RCTImage (= 0.60.5)
21 | - React-RCTLinking (= 0.60.5)
22 | - React-RCTNetwork (= 0.60.5)
23 | - React-RCTSettings (= 0.60.5)
24 | - React-RCTText (= 0.60.5)
25 | - React-RCTVibration (= 0.60.5)
26 | - React-RCTWebSocket (= 0.60.5)
27 | - React-Core (0.60.5):
28 | - Folly (= 2018.10.22.00)
29 | - React-cxxreact (= 0.60.5)
30 | - React-jsiexecutor (= 0.60.5)
31 | - yoga (= 0.60.5.React)
32 | - React-cxxreact (0.60.5):
33 | - boost-for-react-native (= 1.63.0)
34 | - DoubleConversion
35 | - Folly (= 2018.10.22.00)
36 | - glog
37 | - React-jsinspector (= 0.60.5)
38 | - React-DevSupport (0.60.5):
39 | - React-Core (= 0.60.5)
40 | - React-RCTWebSocket (= 0.60.5)
41 | - React-jsi (0.60.5):
42 | - boost-for-react-native (= 1.63.0)
43 | - DoubleConversion
44 | - Folly (= 2018.10.22.00)
45 | - glog
46 | - React-jsi/Default (= 0.60.5)
47 | - React-jsi/Default (0.60.5):
48 | - boost-for-react-native (= 1.63.0)
49 | - DoubleConversion
50 | - Folly (= 2018.10.22.00)
51 | - glog
52 | - React-jsiexecutor (0.60.5):
53 | - DoubleConversion
54 | - Folly (= 2018.10.22.00)
55 | - glog
56 | - React-cxxreact (= 0.60.5)
57 | - React-jsi (= 0.60.5)
58 | - React-jsinspector (0.60.5)
59 | - react-native-appearance (0.2.0):
60 | - React
61 | - React-RCTActionSheet (0.60.5):
62 | - React-Core (= 0.60.5)
63 | - React-RCTAnimation (0.60.5):
64 | - React-Core (= 0.60.5)
65 | - React-RCTBlob (0.60.5):
66 | - React-Core (= 0.60.5)
67 | - React-RCTNetwork (= 0.60.5)
68 | - React-RCTWebSocket (= 0.60.5)
69 | - React-RCTImage (0.60.5):
70 | - React-Core (= 0.60.5)
71 | - React-RCTNetwork (= 0.60.5)
72 | - React-RCTLinking (0.60.5):
73 | - React-Core (= 0.60.5)
74 | - React-RCTNetwork (0.60.5):
75 | - React-Core (= 0.60.5)
76 | - React-RCTSettings (0.60.5):
77 | - React-Core (= 0.60.5)
78 | - React-RCTText (0.60.5):
79 | - React-Core (= 0.60.5)
80 | - React-RCTVibration (0.60.5):
81 | - React-Core (= 0.60.5)
82 | - React-RCTWebSocket (0.60.5):
83 | - React-Core (= 0.60.5)
84 | - yoga (0.60.5.React)
85 |
86 | DEPENDENCIES:
87 | - DoubleConversion (from `../../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec`)
88 | - Folly (from `../../node_modules/react-native/third-party-podspecs/Folly.podspec`)
89 | - glog (from `../../node_modules/react-native/third-party-podspecs/glog.podspec`)
90 | - React (from `../../node_modules/react-native/`)
91 | - React-Core (from `../../node_modules/react-native/React`)
92 | - React-cxxreact (from `../../node_modules/react-native/ReactCommon/cxxreact`)
93 | - React-DevSupport (from `../../node_modules/react-native/React`)
94 | - React-jsi (from `../../node_modules/react-native/ReactCommon/jsi`)
95 | - React-jsiexecutor (from `../../node_modules/react-native/ReactCommon/jsiexecutor`)
96 | - React-jsinspector (from `../../node_modules/react-native/ReactCommon/jsinspector`)
97 | - react-native-appearance (from `../../`)
98 | - React-RCTActionSheet (from `../../node_modules/react-native/Libraries/ActionSheetIOS`)
99 | - React-RCTAnimation (from `../../node_modules/react-native/Libraries/NativeAnimation`)
100 | - React-RCTBlob (from `../../node_modules/react-native/Libraries/Blob`)
101 | - React-RCTImage (from `../../node_modules/react-native/Libraries/Image`)
102 | - React-RCTLinking (from `../../node_modules/react-native/Libraries/LinkingIOS`)
103 | - React-RCTNetwork (from `../../node_modules/react-native/Libraries/Network`)
104 | - React-RCTSettings (from `../../node_modules/react-native/Libraries/Settings`)
105 | - React-RCTText (from `../../node_modules/react-native/Libraries/Text`)
106 | - React-RCTVibration (from `../../node_modules/react-native/Libraries/Vibration`)
107 | - React-RCTWebSocket (from `../../node_modules/react-native/Libraries/WebSocket`)
108 | - yoga (from `../../node_modules/react-native/ReactCommon/yoga`)
109 |
110 | SPEC REPOS:
111 | https://github.com/cocoapods/specs.git:
112 | - boost-for-react-native
113 |
114 | EXTERNAL SOURCES:
115 | DoubleConversion:
116 | :podspec: "../../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec"
117 | Folly:
118 | :podspec: "../../node_modules/react-native/third-party-podspecs/Folly.podspec"
119 | glog:
120 | :podspec: "../../node_modules/react-native/third-party-podspecs/glog.podspec"
121 | React:
122 | :path: "../../node_modules/react-native/"
123 | React-Core:
124 | :path: "../../node_modules/react-native/React"
125 | React-cxxreact:
126 | :path: "../../node_modules/react-native/ReactCommon/cxxreact"
127 | React-DevSupport:
128 | :path: "../../node_modules/react-native/React"
129 | React-jsi:
130 | :path: "../../node_modules/react-native/ReactCommon/jsi"
131 | React-jsiexecutor:
132 | :path: "../../node_modules/react-native/ReactCommon/jsiexecutor"
133 | React-jsinspector:
134 | :path: "../../node_modules/react-native/ReactCommon/jsinspector"
135 | react-native-appearance:
136 | :path: "../../"
137 | React-RCTActionSheet:
138 | :path: "../../node_modules/react-native/Libraries/ActionSheetIOS"
139 | React-RCTAnimation:
140 | :path: "../../node_modules/react-native/Libraries/NativeAnimation"
141 | React-RCTBlob:
142 | :path: "../../node_modules/react-native/Libraries/Blob"
143 | React-RCTImage:
144 | :path: "../../node_modules/react-native/Libraries/Image"
145 | React-RCTLinking:
146 | :path: "../../node_modules/react-native/Libraries/LinkingIOS"
147 | React-RCTNetwork:
148 | :path: "../../node_modules/react-native/Libraries/Network"
149 | React-RCTSettings:
150 | :path: "../../node_modules/react-native/Libraries/Settings"
151 | React-RCTText:
152 | :path: "../../node_modules/react-native/Libraries/Text"
153 | React-RCTVibration:
154 | :path: "../../node_modules/react-native/Libraries/Vibration"
155 | React-RCTWebSocket:
156 | :path: "../../node_modules/react-native/Libraries/WebSocket"
157 | yoga:
158 | :path: "../../node_modules/react-native/ReactCommon/yoga"
159 |
160 | SPEC CHECKSUMS:
161 | boost-for-react-native: 39c7adb57c4e60d6c5479dd8623128eb5b3f0f2c
162 | DoubleConversion: 5805e889d232975c086db112ece9ed034df7a0b2
163 | Folly: 30e7936e1c45c08d884aa59369ed951a8e68cf51
164 | glog: 1f3da668190260b06b429bb211bfbee5cd790c28
165 | React: 53c53c4d99097af47cf60594b8706b4e3321e722
166 | React-Core: ba421f6b4f4cbe2fb17c0b6fc675f87622e78a64
167 | React-cxxreact: 8384287780c4999351ad9b6e7a149d9ed10a2395
168 | React-DevSupport: 197fb409737cff2c4f9986e77c220d7452cb9f9f
169 | React-jsi: 4d8c9efb6312a9725b18d6fc818ffc103f60fec2
170 | React-jsiexecutor: 90ad2f9db09513fc763bc757fdc3c4ff8bde2a30
171 | React-jsinspector: e08662d1bf5b129a3d556eb9ea343a3f40353ae4
172 | react-native-appearance: 98ca18f056bb17c7eddcd2205f895bed3229be9f
173 | React-RCTActionSheet: b0f1ea83f4bf75fb966eae9bfc47b78c8d3efd90
174 | React-RCTAnimation: 359ba1b5690b1e87cc173558a78e82d35919333e
175 | React-RCTBlob: 5e2b55f76e9a1c7ae52b826923502ddc3238df24
176 | React-RCTImage: f5f1c50922164e89bdda67bcd0153952a5cfe719
177 | React-RCTLinking: d0ecbd791e9ddddc41fa1f66b0255de90e8ee1e9
178 | React-RCTNetwork: e26946300b0ab7bb6c4a6348090e93fa21f33a9d
179 | React-RCTSettings: d0d37cb521b7470c998595a44f05847777cc3f42
180 | React-RCTText: b074d89033583d4f2eb5faf7ea2db3a13c7553a2
181 | React-RCTVibration: 2105b2e0e2b66a6408fc69a46c8a7fb5b2fdade0
182 | React-RCTWebSocket: cd932a16b7214898b6b7f788c8bddb3637246ac4
183 | yoga: 312528f5bbbba37b4dcea5ef00e8b4033fdd9411
184 |
185 | PODFILE CHECKSUM: ab2e6f34591fa4a16fc096bc207588893e8d59ca
186 |
187 | COCOAPODS: 1.7.5
188 |
--------------------------------------------------------------------------------
/ios/Appearance.xcodeproj/project.pbxproj:
--------------------------------------------------------------------------------
1 | // !$*UTF8*$!
2 | {
3 | archiveVersion = 1;
4 | classes = {
5 | };
6 | objectVersion = 46;
7 | objects = {
8 |
9 | /* Begin PBXBuildFile section */
10 | 19AC186D23048EBB0093B581 /* RNCAppearance.m in Sources */ = {isa = PBXBuildFile; fileRef = 19AC186C23048EBB0093B581 /* RNCAppearance.m */; };
11 | BB9D66DA230F4333009ADF60 /* RNCAppearanceProviderManager.m in Sources */ = {isa = PBXBuildFile; fileRef = BB9D66D6230F4332009ADF60 /* RNCAppearanceProviderManager.m */; };
12 | BB9D66DB230F4333009ADF60 /* RNCAppearanceProvider.m in Sources */ = {isa = PBXBuildFile; fileRef = BB9D66D9230F4333009ADF60 /* RNCAppearanceProvider.m */; };
13 | C923EDBC220C2C1A00D3100F /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C923EDBB220C2C1A00D3100F /* SystemConfiguration.framework */; };
14 | /* End PBXBuildFile section */
15 |
16 | /* Begin PBXCopyFilesBuildPhase section */
17 | 58B511D91A9E6C8500147676 /* CopyFiles */ = {
18 | isa = PBXCopyFilesBuildPhase;
19 | buildActionMask = 2147483647;
20 | dstPath = "include/$(PRODUCT_NAME)";
21 | dstSubfolderSpec = 16;
22 | files = (
23 | );
24 | runOnlyForDeploymentPostprocessing = 0;
25 | };
26 | /* End PBXCopyFilesBuildPhase section */
27 |
28 | /* Begin PBXFileReference section */
29 | 134814201AA4EA6300B7C361 /* libRNCAppearance.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libRNCAppearance.a; sourceTree = BUILT_PRODUCTS_DIR; };
30 | 19AC186B23048EBB0093B581 /* RNCAppearance.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = RNCAppearance.h; path = Appearance/RNCAppearance.h; sourceTree = ""; };
31 | 19AC186C23048EBB0093B581 /* RNCAppearance.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = RNCAppearance.m; path = Appearance/RNCAppearance.m; sourceTree = ""; };
32 | BB9D66D6230F4332009ADF60 /* RNCAppearanceProviderManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = RNCAppearanceProviderManager.m; path = Appearance/RNCAppearanceProviderManager.m; sourceTree = ""; };
33 | BB9D66D7230F4333009ADF60 /* RNCAppearanceProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RNCAppearanceProvider.h; path = Appearance/RNCAppearanceProvider.h; sourceTree = ""; };
34 | BB9D66D8230F4333009ADF60 /* RNCAppearanceProviderManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RNCAppearanceProviderManager.h; path = Appearance/RNCAppearanceProviderManager.h; sourceTree = ""; };
35 | BB9D66D9230F4333009ADF60 /* RNCAppearanceProvider.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = RNCAppearanceProvider.m; path = Appearance/RNCAppearanceProvider.m; sourceTree = ""; };
36 | C923EDBB220C2C1A00D3100F /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = System/Library/Frameworks/SystemConfiguration.framework; sourceTree = SDKROOT; };
37 | /* End PBXFileReference section */
38 |
39 | /* Begin PBXFrameworksBuildPhase section */
40 | 58B511D81A9E6C8500147676 /* Frameworks */ = {
41 | isa = PBXFrameworksBuildPhase;
42 | buildActionMask = 2147483647;
43 | files = (
44 | C923EDBC220C2C1A00D3100F /* SystemConfiguration.framework in Frameworks */,
45 | );
46 | runOnlyForDeploymentPostprocessing = 0;
47 | };
48 | /* End PBXFrameworksBuildPhase section */
49 |
50 | /* Begin PBXGroup section */
51 | 134814211AA4EA7D00B7C361 /* Products */ = {
52 | isa = PBXGroup;
53 | children = (
54 | 134814201AA4EA6300B7C361 /* libRNCAppearance.a */,
55 | );
56 | name = Products;
57 | sourceTree = "";
58 | };
59 | 58B511D21A9E6C8500147676 = {
60 | isa = PBXGroup;
61 | children = (
62 | 19AC186B23048EBB0093B581 /* RNCAppearance.h */,
63 | 19AC186C23048EBB0093B581 /* RNCAppearance.m */,
64 | BB9D66D7230F4333009ADF60 /* RNCAppearanceProvider.h */,
65 | BB9D66D9230F4333009ADF60 /* RNCAppearanceProvider.m */,
66 | BB9D66D8230F4333009ADF60 /* RNCAppearanceProviderManager.h */,
67 | BB9D66D6230F4332009ADF60 /* RNCAppearanceProviderManager.m */,
68 | 134814211AA4EA7D00B7C361 /* Products */,
69 | C923EDBA220C2C1A00D3100F /* Frameworks */,
70 | );
71 | sourceTree = "";
72 | };
73 | C923EDBA220C2C1A00D3100F /* Frameworks */ = {
74 | isa = PBXGroup;
75 | children = (
76 | C923EDBB220C2C1A00D3100F /* SystemConfiguration.framework */,
77 | );
78 | name = Frameworks;
79 | sourceTree = "";
80 | };
81 | /* End PBXGroup section */
82 |
83 | /* Begin PBXNativeTarget section */
84 | 58B511DA1A9E6C8500147676 /* RNCAppearance */ = {
85 | isa = PBXNativeTarget;
86 | buildConfigurationList = 58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget "RNCAppearance" */;
87 | buildPhases = (
88 | 58B511D71A9E6C8500147676 /* Sources */,
89 | 58B511D81A9E6C8500147676 /* Frameworks */,
90 | 58B511D91A9E6C8500147676 /* CopyFiles */,
91 | );
92 | buildRules = (
93 | );
94 | dependencies = (
95 | );
96 | name = RNCAppearance;
97 | productName = RCTDataManager;
98 | productReference = 134814201AA4EA6300B7C361 /* libRNCAppearance.a */;
99 | productType = "com.apple.product-type.library.static";
100 | };
101 | /* End PBXNativeTarget section */
102 |
103 | /* Begin PBXProject section */
104 | 58B511D31A9E6C8500147676 /* Project object */ = {
105 | isa = PBXProject;
106 | attributes = {
107 | LastUpgradeCheck = 1030;
108 | ORGANIZATIONNAME = Facebook;
109 | TargetAttributes = {
110 | 58B511DA1A9E6C8500147676 = {
111 | CreatedOnToolsVersion = 6.1.1;
112 | };
113 | };
114 | };
115 | buildConfigurationList = 58B511D61A9E6C8500147676 /* Build configuration list for PBXProject "Appearance" */;
116 | compatibilityVersion = "Xcode 3.2";
117 | developmentRegion = en;
118 | hasScannedForEncodings = 0;
119 | knownRegions = (
120 | en,
121 | Base,
122 | );
123 | mainGroup = 58B511D21A9E6C8500147676;
124 | productRefGroup = 58B511D21A9E6C8500147676;
125 | projectDirPath = "";
126 | projectRoot = "";
127 | targets = (
128 | 58B511DA1A9E6C8500147676 /* RNCAppearance */,
129 | );
130 | };
131 | /* End PBXProject section */
132 |
133 | /* Begin PBXSourcesBuildPhase section */
134 | 58B511D71A9E6C8500147676 /* Sources */ = {
135 | isa = PBXSourcesBuildPhase;
136 | buildActionMask = 2147483647;
137 | files = (
138 | BB9D66DA230F4333009ADF60 /* RNCAppearanceProviderManager.m in Sources */,
139 | BB9D66DB230F4333009ADF60 /* RNCAppearanceProvider.m in Sources */,
140 | 19AC186D23048EBB0093B581 /* RNCAppearance.m in Sources */,
141 | );
142 | runOnlyForDeploymentPostprocessing = 0;
143 | };
144 | /* End PBXSourcesBuildPhase section */
145 |
146 | /* Begin XCBuildConfiguration section */
147 | 58B511ED1A9E6C8500147676 /* Debug */ = {
148 | isa = XCBuildConfiguration;
149 | buildSettings = {
150 | ALWAYS_SEARCH_USER_PATHS = NO;
151 | CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
152 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
153 | CLANG_CXX_LIBRARY = "libc++";
154 | CLANG_ENABLE_MODULES = YES;
155 | CLANG_ENABLE_OBJC_ARC = YES;
156 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
157 | CLANG_WARN_BOOL_CONVERSION = YES;
158 | CLANG_WARN_COMMA = YES;
159 | CLANG_WARN_CONSTANT_CONVERSION = YES;
160 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
161 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
162 | CLANG_WARN_EMPTY_BODY = YES;
163 | CLANG_WARN_ENUM_CONVERSION = YES;
164 | CLANG_WARN_INFINITE_RECURSION = YES;
165 | CLANG_WARN_INT_CONVERSION = YES;
166 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
167 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
168 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
169 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
170 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
171 | CLANG_WARN_STRICT_PROTOTYPES = YES;
172 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
173 | CLANG_WARN_UNREACHABLE_CODE = YES;
174 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
175 | COPY_PHASE_STRIP = NO;
176 | ENABLE_STRICT_OBJC_MSGSEND = YES;
177 | ENABLE_TESTABILITY = YES;
178 | GCC_C_LANGUAGE_STANDARD = gnu99;
179 | GCC_DYNAMIC_NO_PIC = NO;
180 | GCC_NO_COMMON_BLOCKS = YES;
181 | GCC_OPTIMIZATION_LEVEL = 0;
182 | GCC_PREPROCESSOR_DEFINITIONS = (
183 | "DEBUG=1",
184 | "$(inherited)",
185 | );
186 | GCC_SYMBOLS_PRIVATE_EXTERN = NO;
187 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
188 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
189 | GCC_WARN_UNDECLARED_SELECTOR = YES;
190 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
191 | GCC_WARN_UNUSED_FUNCTION = YES;
192 | GCC_WARN_UNUSED_VARIABLE = YES;
193 | IPHONEOS_DEPLOYMENT_TARGET = 9.0;
194 | MTL_ENABLE_DEBUG_INFO = YES;
195 | ONLY_ACTIVE_ARCH = YES;
196 | SDKROOT = iphoneos;
197 | };
198 | name = Debug;
199 | };
200 | 58B511EE1A9E6C8500147676 /* Release */ = {
201 | isa = XCBuildConfiguration;
202 | buildSettings = {
203 | ALWAYS_SEARCH_USER_PATHS = NO;
204 | CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
205 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
206 | CLANG_CXX_LIBRARY = "libc++";
207 | CLANG_ENABLE_MODULES = YES;
208 | CLANG_ENABLE_OBJC_ARC = YES;
209 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
210 | CLANG_WARN_BOOL_CONVERSION = YES;
211 | CLANG_WARN_COMMA = YES;
212 | CLANG_WARN_CONSTANT_CONVERSION = YES;
213 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
214 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
215 | CLANG_WARN_EMPTY_BODY = YES;
216 | CLANG_WARN_ENUM_CONVERSION = YES;
217 | CLANG_WARN_INFINITE_RECURSION = YES;
218 | CLANG_WARN_INT_CONVERSION = YES;
219 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
220 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
221 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
222 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
223 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
224 | CLANG_WARN_STRICT_PROTOTYPES = YES;
225 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
226 | CLANG_WARN_UNREACHABLE_CODE = YES;
227 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
228 | COPY_PHASE_STRIP = YES;
229 | ENABLE_NS_ASSERTIONS = NO;
230 | ENABLE_STRICT_OBJC_MSGSEND = YES;
231 | GCC_C_LANGUAGE_STANDARD = gnu99;
232 | GCC_NO_COMMON_BLOCKS = YES;
233 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
234 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
235 | GCC_WARN_UNDECLARED_SELECTOR = YES;
236 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
237 | GCC_WARN_UNUSED_FUNCTION = YES;
238 | GCC_WARN_UNUSED_VARIABLE = YES;
239 | IPHONEOS_DEPLOYMENT_TARGET = 9.0;
240 | MTL_ENABLE_DEBUG_INFO = NO;
241 | SDKROOT = iphoneos;
242 | VALIDATE_PRODUCT = YES;
243 | };
244 | name = Release;
245 | };
246 | 58B511F01A9E6C8500147676 /* Debug */ = {
247 | isa = XCBuildConfiguration;
248 | buildSettings = {
249 | HEADER_SEARCH_PATHS = (
250 | "$(inherited)",
251 | /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
252 | "$(SRCROOT)/../../../React/**",
253 | "$(SRCROOT)/../../react-native/React/**",
254 | );
255 | LIBRARY_SEARCH_PATHS = "$(inherited)";
256 | OTHER_LDFLAGS = "-ObjC";
257 | PRODUCT_NAME = RNCAppearance;
258 | SKIP_INSTALL = YES;
259 | };
260 | name = Debug;
261 | };
262 | 58B511F11A9E6C8500147676 /* Release */ = {
263 | isa = XCBuildConfiguration;
264 | buildSettings = {
265 | HEADER_SEARCH_PATHS = (
266 | "$(inherited)",
267 | /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
268 | "$(SRCROOT)/../../../React/**",
269 | "$(SRCROOT)/../../react-native/React/**",
270 | );
271 | LIBRARY_SEARCH_PATHS = "$(inherited)";
272 | OTHER_LDFLAGS = "-ObjC";
273 | PRODUCT_NAME = RNCAppearance;
274 | SKIP_INSTALL = YES;
275 | };
276 | name = Release;
277 | };
278 | /* End XCBuildConfiguration section */
279 |
280 | /* Begin XCConfigurationList section */
281 | 58B511D61A9E6C8500147676 /* Build configuration list for PBXProject "Appearance" */ = {
282 | isa = XCConfigurationList;
283 | buildConfigurations = (
284 | 58B511ED1A9E6C8500147676 /* Debug */,
285 | 58B511EE1A9E6C8500147676 /* Release */,
286 | );
287 | defaultConfigurationIsVisible = 0;
288 | defaultConfigurationName = Release;
289 | };
290 | 58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget "RNCAppearance" */ = {
291 | isa = XCConfigurationList;
292 | buildConfigurations = (
293 | 58B511F01A9E6C8500147676 /* Debug */,
294 | 58B511F11A9E6C8500147676 /* Release */,
295 | );
296 | defaultConfigurationIsVisible = 0;
297 | defaultConfigurationName = Release;
298 | };
299 | /* End XCConfigurationList section */
300 | };
301 | rootObject = 58B511D31A9E6C8500147676 /* Project object */;
302 | }
303 |
--------------------------------------------------------------------------------
/ios/Appearance/RNCAppearance.h:
--------------------------------------------------------------------------------
1 | #import
2 | #import
3 |
4 | NSString *const RNCUserInterfaceStyleDidChangeNotification = @"RNCUserInterfaceStyleDidChangeNotification";
5 |
6 | @interface RNCAppearance : RCTEventEmitter
7 |
8 |
9 | @end
10 |
--------------------------------------------------------------------------------
/ios/Appearance/RNCAppearance.m:
--------------------------------------------------------------------------------
1 | #import "RNCAppearance.h"
2 |
3 | #import
4 | #import
5 |
6 | NSString *const RNCAppearanceColorSchemeLight = @"light";
7 | NSString *const RNCAppearanceColorSchemeDark = @"dark";
8 | NSString *const RNCAppearanceColorSchemeNoPreference = @"no-preference";
9 |
10 | static NSString *RNCColorSchemePreference(UITraitCollection *traitCollection)
11 | {
12 | #if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && defined(__IPHONE_13_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_13_0
13 | if (@available(iOS 13.0, *)) {
14 | static NSDictionary *appearances;
15 | static dispatch_once_t onceToken;
16 |
17 | dispatch_once(&onceToken, ^{
18 | appearances = @{
19 | @(UIUserInterfaceStyleLight): RNCAppearanceColorSchemeLight,
20 | @(UIUserInterfaceStyleDark): RNCAppearanceColorSchemeDark,
21 | @(UIUserInterfaceStyleUnspecified): RNCAppearanceColorSchemeNoPreference
22 | };
23 | });
24 |
25 | traitCollection = traitCollection ?: [UITraitCollection currentTraitCollection];
26 | return appearances[@(traitCollection.userInterfaceStyle)] ?: RNCAppearanceColorSchemeNoPreference;
27 | }
28 | #endif
29 |
30 | return RNCAppearanceColorSchemeNoPreference;
31 | }
32 |
33 | @implementation RNCAppearance
34 |
35 | RCT_EXPORT_MODULE();
36 |
37 | + (BOOL)requiresMainQueueSetup
38 | {
39 | return YES;
40 | }
41 |
42 | - (dispatch_queue_t)methodQueue
43 | {
44 | return dispatch_get_main_queue();
45 | }
46 |
47 | - (NSDictionary *)constantsToExport
48 | {
49 | return @{
50 | @"initialPreferences":
51 | @{ @"colorScheme": RNCColorSchemePreference(nil) }
52 | };
53 | }
54 |
55 | - (void)appearanceChanged:(NSNotification *)notification
56 | {
57 | NSDictionary *userInfo = [notification userInfo];
58 | UITraitCollection *traitCollection = nil;
59 | if (userInfo) {
60 | traitCollection = userInfo[@"traitCollection"];
61 | }
62 | [self sendEventWithName:@"appearanceChanged" body:@{@"colorScheme": RNCColorSchemePreference(traitCollection)}];
63 | }
64 |
65 | #pragma mark - RCTEventEmitter
66 |
67 | - (NSArray *)supportedEvents
68 | {
69 | return @[@"appearanceChanged"];
70 | }
71 |
72 | - (void)startObserving
73 | {
74 | if (@available(iOS 13.0, *)) {
75 | [[NSNotificationCenter defaultCenter] addObserver:self
76 | selector:@selector(appearanceChanged:)
77 | name:RNCUserInterfaceStyleDidChangeNotification
78 | object:self.bridge];
79 | }
80 | }
81 |
82 | - (void)stopObserving
83 | {
84 | if (@available(iOS 13.0, *)) {
85 | [[NSNotificationCenter defaultCenter] removeObserver:self
86 | name:RNCUserInterfaceStyleDidChangeNotification
87 | object:self.bridge];
88 | }
89 | }
90 |
91 | @end
92 |
--------------------------------------------------------------------------------
/ios/Appearance/RNCAppearanceProvider.h:
--------------------------------------------------------------------------------
1 | #import
2 | #import
3 | #import
4 |
5 | NS_ASSUME_NONNULL_BEGIN
6 |
7 | @interface RNCAppearanceProvider : RCTView
8 |
9 | - (instancetype)initWithBridge:(nonnull RCTBridge *)bridge;
10 |
11 | @end
12 |
13 | NS_ASSUME_NONNULL_END
14 |
--------------------------------------------------------------------------------
/ios/Appearance/RNCAppearanceProvider.m:
--------------------------------------------------------------------------------
1 |
2 | #import "RNCAppearanceProvider.h"
3 |
4 | @interface RNCAppearanceProvider ()
5 |
6 | @property (nonatomic, weak) RCTBridge *bridge;
7 |
8 | @end
9 |
10 | @implementation RNCAppearanceProvider
11 |
12 | - (instancetype)initWithBridge:(nonnull RCTBridge *)bridge
13 | {
14 | if (self = [super init]) {
15 | _bridge = bridge;
16 | }
17 | return self;
18 | }
19 |
20 | #if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && defined(__IPHONE_13_0) && \
21 | __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_13_0
22 | - (void)traitCollectionDidChange:(UITraitCollection *)previousTraitCollection
23 | {
24 | [super traitCollectionDidChange:previousTraitCollection];
25 |
26 | if (@available(iOS 13.0, *)) {
27 | if ([previousTraitCollection hasDifferentColorAppearanceComparedToTraitCollection:self.traitCollection]) {
28 | // note(brentvatne):
29 | // When backgrounding the app, perhaps due to a bug on iOS 13 beta the
30 | // user interface style changes to the opposite color scheme and then back to
31 | // the current color scheme immediately afterwards. I'm not sure how to prevent
32 | // this so instead I debounce the notification calls by 10ms.
33 | [NSObject cancelPreviousPerformRequestsWithTarget:self selector: @selector(notifyUserInterfaceStyleChanged) object:nil];
34 | [self performSelector:@selector(notifyUserInterfaceStyleChanged) withObject:nil afterDelay:0.01];
35 | }
36 | }
37 | }
38 |
39 | - (void)notifyUserInterfaceStyleChanged
40 | {
41 | // @tsapeta: Check whether bridge object still exists (it's weakly-referenced) as it could have been released (we don't want to post a notification to `nil`).
42 | if (self.bridge) {
43 | [[NSNotificationCenter defaultCenter] postNotificationName:@"RNCUserInterfaceStyleDidChangeNotification"
44 | object:self.bridge
45 | userInfo:@{@"traitCollection": self.traitCollection}];
46 | }
47 | }
48 | #endif
49 |
50 | @end
51 |
--------------------------------------------------------------------------------
/ios/Appearance/RNCAppearanceProviderManager.h:
--------------------------------------------------------------------------------
1 | #import
2 |
3 | NS_ASSUME_NONNULL_BEGIN
4 |
5 | @interface RNCAppearanceProviderManager : RCTViewManager
6 |
7 | @end
8 |
9 | NS_ASSUME_NONNULL_END
10 |
--------------------------------------------------------------------------------
/ios/Appearance/RNCAppearanceProviderManager.m:
--------------------------------------------------------------------------------
1 |
2 | #import "RNCAppearanceProviderManager.h"
3 | #import "RNCAppearanceProvider.h"
4 |
5 | @implementation RNCAppearanceProviderManager
6 |
7 | RCT_EXPORT_MODULE(RNCAppearanceProvider)
8 |
9 | - (UIView *)view
10 | {
11 | return [[RNCAppearanceProvider alloc] initWithBridge:self.bridge];
12 | }
13 |
14 | @end
15 |
--------------------------------------------------------------------------------
/metro.config.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Metro configuration for React Native
3 | * https://github.com/facebook/react-native
4 | *
5 | * @format
6 | */
7 |
8 | module.exports = {
9 | transformer: {
10 | getTransformOptions: async () => ({
11 | transform: {
12 | experimentalImportSupport: false,
13 | inlineRequires: false,
14 | },
15 | }),
16 | },
17 | };
18 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "react-native-appearance",
3 | "version": "0.3.4",
4 | "description": "Polyfill for `Appearance` API which will be available in `react-native@0.62`.",
5 | "main": "lib/commonjs/index.js",
6 | "module": "lib/module/index.js",
7 | "react-native": "src/index",
8 | "types": "lib/typescript/index.d.ts",
9 | "sideEffects": false,
10 | "nativePackage": true,
11 | "files": [
12 | "!/example",
13 | "/lib",
14 | "/src",
15 | "/android",
16 | "!/android/build",
17 | "/ios",
18 | "/*.podspec"
19 | ],
20 | "author": "Brent Vatne ",
21 | "homepage": "https://github.com/expo/react-native-appearance#readme",
22 | "license": "MIT",
23 | "scripts": {
24 | "prepare": "bob build",
25 | "start": "react-native start",
26 | "start:web": "expo start --web --config example/app.json",
27 | "test": "yarn validate:prettier && yarn validate:eslint && yarn validate:typescript",
28 | "validate:eslint": "eslint \"src/**/*.{js,ts,tsx}\" \"example/**/*.{js,ts,tsx}\"",
29 | "validate:typescript": "tsc --project ./ --noEmit",
30 | "validate:prettier": "prettier \"src/**/*.{js,ts,tsx}\" \"example/**/*.{js,ts,tsx}\" --check"
31 | },
32 | "jest": {
33 | "preset": "react-native",
34 | "testEnvironment": "node",
35 | "coveragePathIgnorePatterns": [
36 | "jest-setup.js"
37 | ],
38 | "modulePathIgnorePatterns": [
39 | "/example/",
40 | "/lib/"
41 | ]
42 | },
43 | "@react-native-community/bob": {
44 | "source": "src",
45 | "output": "lib",
46 | "targets": [
47 | "commonjs",
48 | "module",
49 | "typescript"
50 | ]
51 | },
52 | "keywords": [
53 | "react-native",
54 | "react native",
55 | "react-native-web",
56 | "expo-web",
57 | "appearance"
58 | ],
59 | "dependencies": {
60 | "fbemitter": "^2.1.1",
61 | "invariant": "^2.2.4",
62 | "use-subscription": "^1.0.0"
63 | },
64 | "devDependencies": {
65 | "@babel/core": "^7.0.0",
66 | "@react-native-community/bob": "^0.7.0",
67 | "@react-native-community/eslint-config": "^0.0.5",
68 | "@types/react-native": "^0.60.5",
69 | "@typescript-eslint/eslint-plugin": "^1.7.0",
70 | "@typescript-eslint/parser": "^1.7.0",
71 | "eslint": "5.16.0",
72 | "eslint-config-prettier": "^4.2.0",
73 | "eslint-plugin-prettier": "3.0.1",
74 | "expo": "^34.0.4",
75 | "metro-react-native-babel-preset": "^0.55.0",
76 | "prettier": "^1.18.2",
77 | "react": "16.8.6",
78 | "react-dom": "16.8.6",
79 | "react-native": "~0.60.3",
80 | "react-native-web": "^0.11.7",
81 | "typescript": "^3.5.3"
82 | },
83 | "repository": {
84 | "type": "git",
85 | "url": "https://github.com/expo/react-native-appearance.git"
86 | }
87 | }
88 |
--------------------------------------------------------------------------------
/react-native-appearance.podspec:
--------------------------------------------------------------------------------
1 | require 'json'
2 |
3 | package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
4 |
5 | Pod::Spec.new do |s|
6 | s.name = "react-native-appearance"
7 | s.version = package['version']
8 | s.summary = package['description']
9 | s.license = package['license']
10 |
11 | s.authors = package['author']
12 | s.homepage = package['homepage']
13 | s.platforms = { :ios => "9.0", :tvos => "9.2" }
14 |
15 | s.source = { :git => "https://github.com/expo/react-native-appearance.git", :tag => "v#{s.version}" }
16 | s.source_files = "ios/**/*.{h,m}"
17 |
18 | s.dependency 'React-Core'
19 | end
20 |
--------------------------------------------------------------------------------
/src/@types/use-subscription.d.ts:
--------------------------------------------------------------------------------
1 | declare module 'use-subscription' {
2 | export function useSubscription(subscription: any): T;
3 | }
4 |
--------------------------------------------------------------------------------
/src/Appearance.types.ts:
--------------------------------------------------------------------------------
1 | export type ColorSchemeName = 'light' | 'dark' | 'no-preference';
2 |
3 | export interface AppearancePreferences {
4 | colorScheme: ColorSchemeName;
5 | }
6 |
7 | export type AppearanceListener = (preferences: AppearancePreferences) => void;
--------------------------------------------------------------------------------
/src/NativeAppearance.tsx:
--------------------------------------------------------------------------------
1 | import * as React from 'react';
2 | import { NativeModules, Platform, View, requireNativeComponent } from 'react-native';
3 |
4 | let FallbackAppearanceProvider = (props: any) => ;
5 |
6 | // Native modules
7 | export const NativeAppearance = NativeModules.RNCAppearance;
8 | export const NativeAppearanceProvider =
9 | Platform.OS === 'android'
10 | ? FallbackAppearanceProvider
11 | : requireNativeComponent('RNCAppearanceProvider');
12 |
--------------------------------------------------------------------------------
/src/NativeAppearance.web.tsx:
--------------------------------------------------------------------------------
1 | import * as React from 'react';
2 | import { View } from 'react-native';
3 |
4 | import { AppearancePreferences } from './Appearance.types';
5 | // @ts-ignore
6 | import SyntheticPlatformEmitter from './web/SyntheticPlatformEmitter';
7 |
8 | function getQuery(): MediaQueryList | null {
9 | if (typeof window === 'undefined' || !window.matchMedia) return null;
10 | return window.matchMedia('(prefers-color-scheme: dark)');
11 | }
12 |
13 | function isMediaQueryList(query: any): query is MediaQueryList {
14 | return query && query.addListener && query.removeListener && typeof query.matches === 'boolean';
15 | }
16 |
17 | export const NativeAppearance = {
18 | get name(): string {
19 | return 'NativeAppearance';
20 | },
21 | get initialPreferences(): AppearancePreferences {
22 | const query = getQuery();
23 | if (isMediaQueryList(query)) {
24 | return { colorScheme: query.matches ? 'dark' : 'light' }
25 | }
26 | return { colorScheme: 'no-preference' };
27 | },
28 | };
29 |
30 | export function NativeAppearanceProvider(props: any) {
31 | React.useEffect(() => {
32 | const query = getQuery();
33 |
34 | function listener({ matches }: MediaQueryListEvent) {
35 | const colorScheme = matches ? 'dark' : 'light';
36 | SyntheticPlatformEmitter.emit('appearanceChanged', {
37 | colorScheme,
38 | });
39 | }
40 |
41 | if (query)
42 | query.addListener(listener);
43 |
44 | return () => {
45 | if (query) {
46 | query.removeListener(listener)
47 | }
48 | }
49 | }, []);
50 |
51 | return
52 | };
53 |
--------------------------------------------------------------------------------
/src/index.tsx:
--------------------------------------------------------------------------------
1 | import React, { useMemo } from 'react';
2 | import { NativeEventEmitter } from 'react-native';
3 | import { EventEmitter, EventSubscription } from 'fbemitter';
4 | import { useSubscription } from 'use-subscription';
5 | import { AppearancePreferences, ColorSchemeName, AppearanceListener } from './Appearance.types';
6 | export * from './Appearance.types';
7 |
8 | // Native modules
9 | import { NativeAppearance, NativeAppearanceProvider } from './NativeAppearance';
10 |
11 | // Initialize the user-facing event emitter
12 | const eventEmitter = new EventEmitter();
13 |
14 | // Initialize preferences synchronously
15 | let appearancePreferences: AppearancePreferences = NativeAppearance.initialPreferences;
16 |
17 | // Initialize the native event emitter
18 | const nativeEventEmitter = new NativeEventEmitter(NativeAppearance);
19 | nativeEventEmitter.addListener('appearanceChanged', (newAppearance: AppearancePreferences) => {
20 | Appearance.set(newAppearance);
21 | });
22 |
23 | export class Appearance {
24 | /**
25 | * Note: Although appearance is available immediately, it may change (e.g
26 | * Dark Mode) so any rendering logic or styles that depend on this should try
27 | * to call this function on every render, rather than caching the value (for
28 | * example, using inline styles rather than setting a value in a
29 | * `StyleSheet`).
30 | *
31 | * Example: `const colorScheme = Appearance.get('colorScheme');`
32 | *
33 | * @param {string} preference Name of preference (e.g. 'colorScheme').
34 | * @returns {ColorSchemeName} Value for the preference.
35 | */
36 | static getColorScheme(): ColorSchemeName {
37 | return appearancePreferences.colorScheme;
38 | }
39 |
40 | /**
41 | * This should only be called from native code by sending the
42 | * appearanceChanged event.
43 | *
44 | * @param {object} appearancePreferences Simple string-keyed object of
45 | * appearance preferences to set.
46 | */
47 | static set(preferences: AppearancePreferences): void {
48 | let { colorScheme } = preferences;
49 |
50 | // Don't bother emitting if it's the same value
51 | if (appearancePreferences.colorScheme !== colorScheme) {
52 | appearancePreferences = { colorScheme };
53 | eventEmitter.emit('change', preferences);
54 | }
55 | }
56 |
57 | /**
58 | * Add an event handler that is fired when appearance preferences change.
59 | */
60 | static addChangeListener(listener: AppearanceListener): EventSubscription {
61 | return eventEmitter.addListener('change', listener);
62 | }
63 | }
64 |
65 | /**
66 | * Temporarily require a Provider since the upstream implementation uses root view customizations
67 | * to accomplish this same behavior
68 | */
69 | export const AppearanceProvider = (props: { children: any }) => (
70 |
71 | );
72 |
73 | /**
74 | * Subscribe to color scheme updates
75 | */
76 | export function useColorScheme(): ColorSchemeName {
77 | const subscription = useMemo(
78 | () => ({
79 | getCurrentValue: () => Appearance.getColorScheme(),
80 | subscribe: (callback: AppearanceListener) => {
81 | let eventSubscription = Appearance.addChangeListener(callback);
82 | return () => eventSubscription.remove();
83 | },
84 | }),
85 | [],
86 | );
87 |
88 | return useSubscription(subscription);
89 | }
90 |
--------------------------------------------------------------------------------
/src/mock.tsx:
--------------------------------------------------------------------------------
1 | import * as React from 'react';
2 | import { View } from 'react-native';
3 | import { AppearancePreferences, ColorSchemeName, AppearanceListener } from './Appearance.types';
4 |
5 | interface FakeEventSubscription {
6 | remove: () => void;
7 | }
8 |
9 | function noop() {}
10 |
11 | export class Appearance {
12 | static getColorScheme(): ColorSchemeName {
13 | return 'no-preference';
14 | }
15 |
16 | static set(_preferences: AppearancePreferences): void {}
17 |
18 | static addChangeListener(_listener: AppearanceListener): FakeEventSubscription {
19 | return { remove: () => noop };
20 | }
21 |
22 | /**
23 | * Unused: some people might expect to remove the listener like this, but they shouldn't.
24 | */
25 | static removeChangeListener(_listener: AppearanceListener): void {}
26 | }
27 |
28 | export const AppearanceProvider = (props: any) => ;
29 |
30 | export function useColorScheme(): ColorSchemeName {
31 | return 'no-preference';
32 | }
33 |
--------------------------------------------------------------------------------
/src/web/SyntheticPlatformEmitter.ts:
--------------------------------------------------------------------------------
1 | let emitters: any;
2 | try {
3 | emitters = require('@unimodules/react-native-adapter').SyntheticPlatformEmitter;
4 | } catch (_) {
5 | emitters = require('./emitter-polyfill').default;
6 | }
7 |
8 | // @ts-ignore: Don't mix import/export with require/module.exports
9 | module.exports = emitters;
10 |
--------------------------------------------------------------------------------
/src/web/emitter-polyfill.ts:
--------------------------------------------------------------------------------
1 | // Copyright 2018-present 650 Industries. All rights reserved.
2 | // Polyfill the @unimodules/react-native-adapter used for Expo web.
3 |
4 | // @ts-ignore: react-native-web is a peer dependency
5 | import RCTEventEmitter from 'react-native-web/dist/vendor/react-native/emitter/EventEmitter';
6 | // @ts-ignore: react-native-web is a peer dependency
7 | import RCTDeviceEventEmitter from 'react-native-web/dist/vendor/react-native/NativeEventEmitter/RCTDeviceEventEmitter';
8 |
9 | /**
10 | * This emitter is used for sending synthetic native events to listeners
11 | * registered in the API layer with `NativeEventEmitter`.
12 | */
13 | class SyntheticPlatformEmitter {
14 | _emitter = new RCTEventEmitter(RCTDeviceEventEmitter.sharedSubscriber);
15 |
16 | emit(eventName: string, props: any): void {
17 | this._emitter.emit(eventName, props);
18 | }
19 | }
20 |
21 | export default new SyntheticPlatformEmitter();
22 |
--------------------------------------------------------------------------------
/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "include": [
3 | "src/**/*.ts",
4 | "src/**/*.tsx"
5 | ],
6 | "compilerOptions": {
7 | "esModuleInterop": true,
8 | "target": "es5",
9 | "module": "commonjs",
10 | "strict": true,
11 | "moduleResolution": "node",
12 | "skipLibCheck": true,
13 | "lib": ["dom", "es2015", "es2016", "esnext"],
14 | "jsx": "react-native"
15 | },
16 | "exclude": ["node_modules"]
17 | }
18 |
--------------------------------------------------------------------------------