Skip to content

Commit d2b15db

Browse files
committed
Merge branch 'master' of github.com:wix/react-native-ui-lib into release
# Conflicts: # src/components/sortableGridList/SortableItem.tsx
2 parents 14924cd + adeef99 commit d2b15db

File tree

227 files changed

+4685
-1126
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

227 files changed

+4685
-1126
lines changed

.bundle/config

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
BUNDLE_PATH: "vendor/bundle"
2+
2 BUNDLE_FORCE_RUBY_PLATFORM: 1

.flowconfig

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ node_modules/react-native/Libraries/polyfills/.*
1111
; Flow doesn't support platforms
1212
.*/Libraries/Utilities/LoadingView.js
1313

14+
.*/node_modules/resolve/test/resolver/malformed_package_json/package\.json$
15+
1416
[untyped]
1517
.*/node_modules/@react-native-community/cli/.*/.*
1618

@@ -62,4 +64,4 @@ untyped-import
6264
untyped-type-import
6365

6466
[version]
65-
^0.158.0
67+
^0.170.0

.gitattributes

Lines changed: 0 additions & 2 deletions
This file was deleted.

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,10 @@ yarn.lock
6767
package-lock.json
6868
docs/**/*.md
6969

70-
# CocoaPods
70+
# Ruby / CocoaPods
7171
/ios/Pods/
72+
/vendor/bundle/
7273
/ios/Podfile.lock
7374
expoDemo/ios/Pods
7475

76+
.reassure

.ruby-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2.7.4

Gemfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
source 'https://rubygems.org'
2+
2
3+
3 # You may use http://rbenv.org/ or https://rvm.io/ to install and use this version
4+
4 ruby '2.7.4'
5+
5
6+
6 gem 'cocoapods', '~> 1.11', '>= 1.11.2'

android/app/build.gradle

Lines changed: 99 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
apply plugin: "com.android.application"
22

33
import com.android.build.OutputFile
4+
import org.apache.tools.ant.taskdefs.condition.Os
45

56
project.ext.react = [
67
entryFile: "index.js",
@@ -14,9 +15,12 @@ def jscFlavor = 'org.webkit:android-jsc:+'
1415
def enableHermes = project.ext.react.get("enableHermes", false)
1516

1617
/**
17-
* Architectures to build native code for in debug.
18+
* Architectures to build native code for.
1819
*/
19-
def nativeArchitectures = project.getProperties().get("reactNativeDebugArchitectures")
20+
def reactNativeArchitectures() {
21+
def value = project.getProperties().get("reactNativeArchitectures")
22+
return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
23+
}
2024

2125
android {
2226
compileSdkVersion rootProject.ext.compileSdkVersion
@@ -29,13 +33,85 @@ android {
2933
versionCode 1
3034
versionName "1.0"
3135
multiDexEnabled true
36+
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
37+
38+
if (isNewArchitectureEnabled()) {
39+
// We configure the NDK build only if you decide to opt-in for the New Architecture.
40+
externalNativeBuild {
41+
ndkBuild {
42+
arguments "APP_PLATFORM=android-21",
43+
"APP_STL=c++_shared",
44+
"NDK_TOOLCHAIN_VERSION=clang",
45+
"GENERATED_SRC_DIR=$buildDir/generated/source",
46+
"PROJECT_BUILD_DIR=$buildDir",
47+
"REACT_ANDROID_DIR=$rootDir/../node_modules/react-native/ReactAndroid",
48+
"REACT_ANDROID_BUILD_DIR=$rootDir/../node_modules/react-native/ReactAndroid/build"
49+
cFlags "-Wall", "-Werror", "-fexceptions", "-frtti", "-DWITH_INSPECTOR=1"
50+
cppFlags "-std=c++17"
51+
// Make sure this target name is the same you specify inside the
52+
// src/main/jni/Android.mk file for the `LOCAL_MODULE` variable.
53+
targets "rnuilib_appmodules"
54+
// Fix for windows limit on number of character in file paths and in command lines
55+
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
56+
arguments "NDK_APP_SHORT_COMMANDS=true"
57+
}
58+
}
59+
}
60+
if (!enableSeparateBuildPerCPUArchitecture) {
61+
ndk {
62+
abiFilters (*reactNativeArchitectures())
63+
}
64+
}
65+
}
66+
}
67+
68+
if (isNewArchitectureEnabled()) {
69+
// We configure the NDK build only if you decide to opt-in for the New Architecture.
70+
externalNativeBuild {
71+
ndkBuild {
72+
path "$projectDir/src/main/jni/Android.mk"
73+
}
74+
}
75+
def reactAndroidProjectDir = project(':ReactAndroid').projectDir
76+
def packageReactNdkDebugLibs = tasks.register("packageReactNdkDebugLibs", Copy) {
77+
dependsOn(":ReactAndroid:packageReactNdkDebugLibsForBuck")
78+
from("$reactAndroidProjectDir/src/main/jni/prebuilt/lib")
79+
into("$buildDir/react-ndk/exported")
80+
}
81+
def packageReactNdkReleaseLibs = tasks.register("packageReactNdkReleaseLibs", Copy) {
82+
dependsOn(":ReactAndroid:packageReactNdkReleaseLibsForBuck")
83+
from("$reactAndroidProjectDir/src/main/jni/prebuilt/lib")
84+
into("$buildDir/react-ndk/exported")
85+
}
86+
afterEvaluate {
87+
// If you wish to add a custom TurboModule or component locally,
88+
// you should uncomment this line.
89+
// preBuild.dependsOn("generateCodegenArtifactsFromSchema")
90+
preDebugBuild.dependsOn(packageReactNdkDebugLibs)
91+
preReleaseBuild.dependsOn(packageReactNdkReleaseLibs)
92+
93+
// Due to a bug inside AGP, we have to explicitly set a dependency
94+
// between configureNdkBuild* tasks and the preBuild tasks.
95+
// This can be removed once this is solved: https://issuetracker.google.com/issues/207403732
96+
configureNdkBuildRelease.dependsOn(preReleaseBuild)
97+
configureNdkBuildDebug.dependsOn(preDebugBuild)
98+
reactNativeArchitectures().each { architecture ->
99+
tasks.findByName("configureNdkBuildDebug[${architecture}]")?.configure {
100+
dependsOn("preDebugBuild")
101+
}
102+
tasks.findByName("configureNdkBuildRelease[${architecture}]")?.configure {
103+
dependsOn("preReleaseBuild")
104+
}
105+
}
106+
}
32107
}
108+
33109
splits {
34110
abi {
35111
reset()
36112
enable enableSeparateBuildPerCPUArchitecture
37113
universalApk false // If true, also generate a universal APK
38-
include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
114+
include (*reactNativeArchitectures())
39115
}
40116
}
41117
signingConfigs {
@@ -49,11 +125,6 @@ android {
49125
buildTypes {
50126
debug {
51127
signingConfig signingConfigs.debug
52-
if (nativeArchitectures) {
53-
ndk {
54-
abiFilters nativeArchitectures.split(',')
55-
}
56-
}
57128
}
58129
release {
59130
// Caution! In production, you need to generate your own keystore file.
@@ -113,6 +184,18 @@ dependencies {
113184
}
114185
}
115186

187+
if (isNewArchitectureEnabled()) {
188+
// If new architecture is enabled, we let you build RN from source
189+
// Otherwise we fallback to a prebuilt .aar bundled in the NPM package.
190+
// This will be applied to all the imported transtitive dependency.
191+
configurations.all {
192+
resolutionStrategy.dependencySubstitution {
193+
substitute(module("com.facebook.react:react-native"))
194+
.using(project(":ReactAndroid")).because("On New Architecture we're building React Native from source")
195+
}
196+
}
197+
}
198+
116199
// Run this once to be able to run the application with BUCK
117200
// puts all compile dependencies into folder libs for BUCK to use
118201
task copyDownloadableDepsToLibs(type: Copy) {
@@ -121,3 +204,11 @@ task copyDownloadableDepsToLibs(type: Copy) {
121204
}
122205

123206
apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
207+
208+
def isNewArchitectureEnabled() {
209+
// To opt-in for the New Architecture, you can either:
210+
// - Set `newArchEnabled` to true inside the `gradle.properties` file
211+
// - Invoke gradle with `-newArchEnabled=true`
212+
// - Set an environment variable `ORG_GRADLE_PROJECT_newArchEnabled=true`
213+
return project.hasProperty("newArchEnabled") && project.newArchEnabled == "true"
214+
}

android/app/src/debug/AndroidManifest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
66

77
<application android:usesCleartextTraffic="true" tools:targetApi="28" tools:ignore="GoogleAppIndexingWarning">
8-
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
8+
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" android:exported="false" />
99
</application>
1010
</manifest>

android/app/src/debug/java/com/rndiffapp/ReactNativeFlipper.java renamed to android/app/src/debug/java/com/rnuilib/ReactNativeFlipper.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
/**
2-
* Copyright (c) Facebook, Inc. and its affiliates.
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
33
*
44
* <p>This source code is licensed under the MIT license found in the LICENSE file in the root
55
* directory of this source tree.
66
*/
7-
package com.rndiffapp;
7+
package com.rnuilib;
88

99
import android.content.Context;
1010
import com.facebook.flipper.android.AndroidFlipperClient;
@@ -19,6 +19,7 @@
1919
import com.facebook.flipper.plugins.network.NetworkFlipperPlugin;
2020
import com.facebook.flipper.plugins.react.ReactFlipperPlugin;
2121
import com.facebook.flipper.plugins.sharedpreferences.SharedPreferencesFlipperPlugin;
22+
import com.facebook.react.ReactInstanceEventListener;
2223
import com.facebook.react.ReactInstanceManager;
2324
import com.facebook.react.bridge.ReactContext;
2425
import com.facebook.react.modules.network.NetworkingModule;
@@ -51,7 +52,7 @@ public void apply(OkHttpClient.Builder builder) {
5152
ReactContext reactContext = reactInstanceManager.getCurrentReactContext();
5253
if (reactContext == null) {
5354
reactInstanceManager.addReactInstanceEventListener(
54-
new ReactInstanceManager.ReactInstanceEventListener() {
55+
new ReactInstanceEventListener() {
5556
@Override
5657
public void onReactContextInitialized(ReactContext reactContext) {
5758
reactInstanceManager.removeReactInstanceEventListener(this);

android/app/src/main/AndroidManifest.xml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@
1313
<activity
1414
android:name=".MainActivity"
1515
android:label="@string/app_name"
16-
android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode"
16+
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|screenSize|smallestScreenSize|uiMode"
1717
android:launchMode="singleTask"
18-
android:windowSoftInputMode="adjustResize">
18+
android:windowSoftInputMode="adjustResize"
19+
android:exported="true">
1920
<intent-filter>
2021
<action android:name="android.intent.action.MAIN" />
2122
<category android:name="android.intent.category.LAUNCHER" />

android/app/src/main/java/com/rnuilib/MainActivity.java

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,35 @@
11
package com.rnuilib;
22

3+
//import com.facebook.react.ReactActivity;
34
//import com.facebook.react.ReactActivity;
45
import com.reactnativenavigation.NavigationActivity;
6+
//import com.facebook.react.ReactActivityDelegate;
7+
//import com.facebook.react.ReactRootView;
58

9+
public class MainActivity extends NavigationActivity {
610

7-
public class MainActivity extends NavigationActivity {}
11+
// This is needed for the new architecture, RNN needs to support this first (see https://github.com/wix/react-native-navigation/issues/7466)
12+
// /**
13+
// * Returns the instance of the {@link ReactActivityDelegate}. There the RootView is created and
14+
// * you can specify the rendered you wish to use (Fabric or the older renderer).
15+
// */
16+
// @Override
17+
// protected ReactActivityDelegate createReactActivityDelegate() {
18+
// return new MainActivityDelegate(this, getMainComponentName());
19+
// }
20+
// public static class MainActivityDelegate extends ReactActivityDelegate {
21+
// public MainActivityDelegate(ReactActivity activity, String mainComponentName) {
22+
// super(activity, mainComponentName);
23+
// }
24+
// @Override
25+
// protected ReactRootView createRootView() {
26+
// ReactRootView reactRootView = new ReactRootView(getContext());
27+
// // If you opted-in for the New Architecture, we enable the Fabric Renderer.
28+
// reactRootView.setIsFabric(BuildConfig.IS_NEW_ARCHITECTURE_ENABLED);
29+
// return reactRootView;
30+
// }
31+
// }
32+
}
833

934
//public class MainActivity extends ReactActivity {
1035
//

android/app/src/main/java/com/rnuilib/MainApplication.java

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import com.facebook.react.ReactInstanceManager;
77
import com.facebook.react.ReactNativeHost;
88
import com.facebook.react.ReactPackage;
9+
import com.facebook.react.config.ReactFeatureFlags;
910
import com.reactnativenavigation.NavigationApplication;
1011
import com.reactnativenavigation.react.NavigationReactNativeHost;
1112
import com.wix.reactnativeuilib.UiLibPackageList;
@@ -17,7 +18,7 @@
1718

1819
public class MainApplication extends NavigationApplication {
1920

20-
private final ReactNativeHost reactNativeHost = new NavigationReactNativeHost(this) {
21+
private final ReactNativeHost mReactNativeHost = new NavigationReactNativeHost(this) {
2122
@Override
2223
protected String getJSMainModuleName() {
2324
return "demo";
@@ -41,14 +42,22 @@ protected List<ReactPackage> getPackages() {
4142
}
4243
};
4344

45+
private final ReactNativeHost mNewArchitectureNativeHost = new MainApplicationReactNativeHost(this);
46+
4447
@Override
4548
public ReactNativeHost getReactNativeHost() {
46-
return reactNativeHost;
49+
if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) {
50+
return mNewArchitectureNativeHost;
51+
} else {
52+
return mReactNativeHost;
53+
}
4754
}
4855

4956
@Override
5057
public void onCreate() {
5158
super.onCreate();
59+
// If you opted-in for the New Architecture, we enable the TurboModule system
60+
// ReactFeatureFlags.useTurboModules = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED;
5261
initializeFlipper(this, getReactNativeHost().getReactInstanceManager());
5362
}
5463

@@ -67,7 +76,7 @@ private static void initializeFlipper(
6776
We use reflection here to pick up the class that initializes Flipper,
6877
since Flipper library is not available in release mode
6978
*/
70-
Class<?> aClass = Class.forName("com.rndiffapp.ReactNativeFlipper");
79+
Class<?> aClass = Class.forName("com.rnuilib.ReactNativeFlipper");
7180
aClass
7281
.getMethod("initializeFlipper", Context.class, ReactInstanceManager.class)
7382
.invoke(null, context, reactInstanceManager);

0 commit comments

Comments
 (0)