Skip to content

Commit d00bf22

Browse files
guycayogevbd
authored andcommitted
Support RN 0.59 (#5050)
* Support RN 0.59 * Fix yellow box detection on Android * Manually link jsc on iOS in playground app * Fix android unit tests * Add JavaScriptCore.framework to iOS unit tests * Download licenses before unit and e2e tests * Update gradle-wrapper.properties
1 parent 0f4ecf4 commit d00bf22

File tree

14 files changed

+155
-171
lines changed

14 files changed

+155
-171
lines changed

babel.config.js

+7-10
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
module.exports = function (api) {
22
api && api.cache(false);
33
return {
4-
env: {
5-
test: {
6-
presets: [
7-
"module:metro-react-native-babel-preset"
8-
],
9-
plugins: [
10-
"@babel/plugin-proposal-class-properties"
11-
]
12-
}
13-
}
4+
presets: [
5+
"module:metro-react-native-babel-preset"
6+
],
7+
plugins: [
8+
"@babel/plugin-proposal-export-namespace-from",
9+
"@babel/plugin-proposal-export-default-from"
10+
]
1411
};
1512
}

lib/android/app/build.gradle

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ def safeExtGet(prop, fallback) {
55
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
66
}
77

8-
def DEFAULT_COMPILE_SDK_VERSION = 26
8+
def DEFAULT_COMPILE_SDK_VERSION = 28
99
def DEFAULT_MIN_SDK_VERSION = 19
10-
def DEFAULT_SUPPORT_LIB_VERSION = '26.1.0'
11-
def DEFAULT_TARGET_SDK_VERSION = 25
10+
def DEFAULT_SUPPORT_LIB_VERSION = '28.0.0'
11+
def DEFAULT_TARGET_SDK_VERSION = 28
1212

1313
android {
1414
compileSdkVersion safeExtGet('compileSdkVersion', DEFAULT_COMPILE_SDK_VERSION)
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,12 @@
11
package com.reactnativenavigation.viewcontrollers;
22

3-
import android.support.annotation.NonNull;
43
import android.view.View;
54
import android.view.ViewGroup;
65

7-
import com.facebook.react.views.view.ReactViewBackgroundDrawable;
8-
import com.reactnativenavigation.utils.ViewUtils;
9-
10-
public class YellowBoxHelper {
11-
private final static int YELLOW_BOX_COLOR = -218449360;
12-
13-
public boolean isYellowBox(View parent, View child) {
6+
class YellowBoxHelper {
7+
boolean isYellowBox(View parent, View child) {
148
return parent instanceof ViewGroup &&
159
child instanceof ViewGroup &&
16-
((ViewGroup) parent).getChildCount() > 1 &&
17-
!ViewUtils.findChildrenByClassRecursive((ViewGroup) child, View.class, YellowBackgroundMather()).isEmpty();
18-
}
19-
20-
@NonNull
21-
private static ViewUtils.Matcher<View> YellowBackgroundMather() {
22-
return child1 -> child1.getBackground() instanceof ReactViewBackgroundDrawable && ((ReactViewBackgroundDrawable) child1.getBackground()).getColor() == YELLOW_BOX_COLOR;
10+
((ViewGroup) parent).getChildCount() > 1;
2311
}
2412
}

lib/android/app/src/test/java/com/reactnativenavigation/mocks/MockPromise.java

-50
This file was deleted.

lib/android/app/src/test/java/com/reactnativenavigation/utils/TypefaceLoaderTest.java

+14-17
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import android.content.*;
44
import android.graphics.*;
5-
import android.test.mock.*;
65

76
import com.reactnativenavigation.*;
87

@@ -12,47 +11,45 @@
1211
import static org.assertj.core.api.Java6Assertions.*;
1312

1413
public class TypefaceLoaderTest extends BaseTest {
14+
private TypefaceLoader uut;
15+
@Override
16+
public void beforeEach() {
17+
Context context = Mockito.mock(Context.class);
18+
uut = Mockito.spy(new TypefaceLoader(context));
19+
}
1520

1621
@Test
1722
public void loadTypefaceNoAssets() {
18-
Context context = new MockContext();
19-
TypefaceLoader mockedLoader = Mockito.spy(new TypefaceLoader(context));
20-
Mockito.doReturn(null).when(mockedLoader).getTypefaceFromAssets("Helvetica-Bold");
23+
Mockito.doReturn(null).when(uut).getTypefaceFromAssets("Helvetica-Bold");
2124

22-
Typeface typeface = mockedLoader.getTypeFace("Helvetica-Bold");
25+
Typeface typeface = uut.getTypeFace("Helvetica-Bold");
2326
assertThat(typeface).isNotNull();
2427
assertThat(typeface.getStyle()).isEqualTo(Typeface.BOLD);
2528
}
2629

2730
@Test
2831
public void loadTypefaceWithAssets() {
29-
Context context = new MockContext();
30-
TypefaceLoader mockedLoader = Mockito.spy(new TypefaceLoader(context));
31-
Mockito.doReturn(Typeface.create("Helvetica-Italic", Typeface.ITALIC)).when(mockedLoader).getTypefaceFromAssets("Helvetica-Italic");
32+
Mockito.doReturn(Typeface.create("Helvetica-Italic", Typeface.ITALIC)).when(uut).getTypefaceFromAssets("Helvetica-Italic");
3233

33-
Typeface typeface = mockedLoader.getTypeFace("Helvetica-Italic");
34+
Typeface typeface = uut.getTypeFace("Helvetica-Italic");
3435
assertThat(typeface).isNotNull();
3536
assertThat(typeface.getStyle()).isEqualTo(Typeface.ITALIC);
3637
}
3738

3839
@Test
3940
public void loadTypefaceWrongName() {
40-
Context context = new MockContext();
41-
TypefaceLoader mockedLoader = Mockito.spy(new TypefaceLoader(context));
42-
Mockito.doReturn(null).when(mockedLoader).getTypefaceFromAssets("Some-name");
41+
Mockito.doReturn(null).when(uut).getTypefaceFromAssets("Some-name");
4342

44-
Typeface typeface = mockedLoader.getTypeFace("Some-name");
43+
Typeface typeface = uut.getTypeFace("Some-name");
4544
assertThat(typeface).isNotNull();
4645
assertThat(typeface.getStyle()).isEqualTo(Typeface.NORMAL);
4746
}
4847

4948
@Test
5049
public void loadTypefaceNull() {
51-
Context context = new MockContext();
52-
TypefaceLoader mockedLoader = Mockito.spy(new TypefaceLoader(context));
53-
Mockito.doReturn(null).when(mockedLoader).getTypefaceFromAssets(null);
50+
Mockito.doReturn(null).when(uut).getTypefaceFromAssets(null);
5451

55-
Typeface typeface = mockedLoader.getTypeFace(null);
52+
Typeface typeface = uut.getTypeFace(null);
5653
assertThat(typeface).isNull();
5754
}
5855
}

lib/ios/ReactNativeNavigation.xcodeproj/project.pbxproj

+4-2
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@
213213
50887C1620ECC5C200D06111 /* RNNButtonOptions.m in Sources */ = {isa = PBXBuildFile; fileRef = 50887C1420ECC5C200D06111 /* RNNButtonOptions.m */; };
214214
50887CA920F26BFE00D06111 /* RNNOverlayWindow.m in Sources */ = {isa = PBXBuildFile; fileRef = 50887CA720F26BFD00D06111 /* RNNOverlayWindow.m */; };
215215
50887CAA20F26BFE00D06111 /* RNNOverlayWindow.h in Headers */ = {isa = PBXBuildFile; fileRef = 50887CA820F26BFE00D06111 /* RNNOverlayWindow.h */; };
216+
508EBDBD2278746400BEC144 /* JavaScriptCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 508EBDBA2278742700BEC144 /* JavaScriptCore.framework */; };
216217
509B2480217873FF00C83C23 /* UINavigationController+RNNOptionsTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 509B247F217873FF00C83C23 /* UINavigationController+RNNOptionsTest.m */; };
217218
509B258F2178BE7A00C83C23 /* RNNNavigationControllerPresenterTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 509B258E2178BE7A00C83C23 /* RNNNavigationControllerPresenterTest.m */; };
218219
50A00C37200F84D6000F01A6 /* RNNOverlayOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 50A00C35200F84D6000F01A6 /* RNNOverlayOptions.h */; };
@@ -266,7 +267,6 @@
266267
7B49FECE1E95098500DEB3EA /* RNNCommandsHandlerTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 7B49FEC91E95098500DEB3EA /* RNNCommandsHandlerTest.m */; };
267268
7B49FECF1E95098500DEB3EA /* RNNNavigationStackManagerTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 7B49FECA1E95098500DEB3EA /* RNNNavigationStackManagerTest.m */; };
268269
7B49FEDF1E950A7A00DEB3EA /* libcxxreact.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 7B49FED11E950A7A00DEB3EA /* libcxxreact.a */; };
269-
7B49FEE01E950A7A00DEB3EA /* libjschelpers.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 7B49FED21E950A7A00DEB3EA /* libjschelpers.a */; };
270270
7B49FEE11E950A7A00DEB3EA /* libRCTActionSheet.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 7B49FED31E950A7A00DEB3EA /* libRCTActionSheet.a */; };
271271
7B49FEE21E950A7A00DEB3EA /* libRCTAnimation.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 7B49FED41E950A7A00DEB3EA /* libRCTAnimation.a */; };
272272
7B49FEE31E950A7A00DEB3EA /* libRCTGeolocation.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 7B49FED51E950A7A00DEB3EA /* libRCTGeolocation.a */; };
@@ -554,6 +554,7 @@
554554
50887C1420ECC5C200D06111 /* RNNButtonOptions.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RNNButtonOptions.m; sourceTree = "<group>"; };
555555
50887CA720F26BFD00D06111 /* RNNOverlayWindow.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNNOverlayWindow.m; sourceTree = "<group>"; };
556556
50887CA820F26BFE00D06111 /* RNNOverlayWindow.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RNNOverlayWindow.h; sourceTree = "<group>"; };
557+
508EBDBA2278742700BEC144 /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaScriptCore.framework; path = System/Library/Frameworks/JavaScriptCore.framework; sourceTree = SDKROOT; };
557558
509B247F217873FF00C83C23 /* UINavigationController+RNNOptionsTest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "UINavigationController+RNNOptionsTest.m"; sourceTree = "<group>"; };
558559
509B258E2178BE7A00C83C23 /* RNNNavigationControllerPresenterTest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RNNNavigationControllerPresenterTest.m; sourceTree = "<group>"; };
559560
50A00C35200F84D6000F01A6 /* RNNOverlayOptions.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RNNOverlayOptions.h; sourceTree = "<group>"; };
@@ -680,8 +681,8 @@
680681
isa = PBXFrameworksBuildPhase;
681682
buildActionMask = 2147483647;
682683
files = (
684+
508EBDBD2278746400BEC144 /* JavaScriptCore.framework in Frameworks */,
683685
7B49FEDF1E950A7A00DEB3EA /* libcxxreact.a in Frameworks */,
684-
7B49FEE01E950A7A00DEB3EA /* libjschelpers.a in Frameworks */,
685686
7B49FEE11E950A7A00DEB3EA /* libRCTActionSheet.a in Frameworks */,
686687
7B49FEE21E950A7A00DEB3EA /* libRCTAnimation.a in Frameworks */,
687688
7B49FEE31E950A7A00DEB3EA /* libRCTGeolocation.a in Frameworks */,
@@ -1093,6 +1094,7 @@
10931094
7B49FED01E950A7A00DEB3EA /* Frameworks */ = {
10941095
isa = PBXGroup;
10951096
children = (
1097+
508EBDBA2278742700BEC144 /* JavaScriptCore.framework */,
10961098
501214C8217741A000435148 /* libOCMock.a */,
10971099
7B49FED11E950A7A00DEB3EA /* libcxxreact.a */,
10981100
7B49FED21E950A7A00DEB3EA /* libjschelpers.a */,

metro.config.js

+10-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,16 @@ module.exports = {
33
watchFolders: [
44
__dirname
55
],
6+
resolver: {
7+
sourceExts: ['ts', 'tsx', 'js']
8+
},
69
transformer: {
7-
babelTransformerPath: require.resolve('react-native-typescript-transformer')
10+
babelTransformerPath: require.resolve('react-native-typescript-transformer'),
11+
getTransformOptions: async () => ({
12+
transform: {
13+
experimentalImportSupport: false,
14+
inlineRequires: false,
15+
},
16+
})
817
}
918
};
10-

package.json

+8-6
Original file line numberDiff line numberDiff line change
@@ -53,21 +53,23 @@
5353
"tslib": "1.9.3"
5454
},
5555
"devDependencies": {
56+
"@babel/plugin-proposal-export-default-from": "7.2.0",
57+
"@babel/plugin-proposal-export-namespace-from": "7.2.0",
5658
"@types/hoist-non-react-statics": "^3.0.1",
5759
"@types/jest": "23.x.x",
5860
"@types/lodash": "4.x.x",
5961
"@types/react": "16.x.x",
6062
"@types/react-native": "0.57.7",
6163
"@types/react-test-renderer": "16.x.x",
62-
"jsc-android": "236355.x.x",
6364
"detox": "12.x.x",
6465
"react-native-ui-lib": "3.24.2",
6566
"handlebars": "4.x.x",
66-
"jest": "23.x.x",
67-
"metro-react-native-babel-preset": "0.50.0",
68-
"react": "16.6.1",
69-
"react-native": "0.57.7",
70-
"react-native-typescript-transformer": "^1.2.10",
67+
"jest": "24.0.0-alpha.6",
68+
"jsc-android": "236355.x.x",
69+
"metro-react-native-babel-preset": "0.52.x",
70+
"react": "16.8.3",
71+
"react-native": "0.59.5",
72+
"react-native-typescript-transformer": "1.2.12",
7173
"react-native-view-overflow": "0.0.3",
7274
"react-redux": "5.x.x",
7375
"react-test-renderer": "16.6.1",

playground/android/build.gradle

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Top-level build file where you can add configuration options common to all sub-projects/modules.
22

33
buildscript {
4-
ext.kotlinVersion = '1.3.21'
4+
ext.kotlinVersion = '1.3.31'
55
ext.detoxKotlinVersion = ext.kotlinVersion
66

77
repositories {
@@ -11,7 +11,7 @@ buildscript {
1111
jcenter()
1212
}
1313
dependencies {
14-
classpath 'com.android.tools.build:gradle:3.2.1'
14+
classpath 'com.android.tools.build:gradle:3.3.1'
1515
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
1616

1717
// NOTE: Do not place your application dependencies here; they belong

playground/android/gradle/wrapper/gradle-wrapper.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10-all.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip

0 commit comments

Comments
 (0)