Skip to content

Commit 375636d

Browse files
authored
Feat/rn76 oldarch (#7967)
* Upgraded android to work with rn 77 * Upgraded to the latest version of detox * Added react types. Fixed ios pod file * Updated pod filke * Fixed es lint error * Upgraded reanimated * Fixed ios build * Fixed ios build * Fixed one test in android * Fixed android tests * Fixed android unit tests * Fixed android unit tests * Fixed android tests * Fixed mocked tests * Downgrade to RN 76 * support ios * fixed android screenshot * fixed android screenshot * Reimplemented missing bar style in iOS * Reimplemented missing bar style in iOS * Fixed ios bar styling * Removed unused library * Upgraded roboletric to run on updated sdk * Revert "Upgraded roboletric to run on updated sdk" This reverts commit 1ed449b. * Fixes for PR * Fixed ios build
1 parent 82cbbc2 commit 375636d

File tree

64 files changed

+549
-456
lines changed

Some content is hidden

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

64 files changed

+549
-456
lines changed

.eslintrc.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@ module.exports = {
55
plugins: ['@typescript-eslint'],
66
env: {
77
jest: true,
8+
'jest/globals': true,
89
},
910
};

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,3 +244,4 @@ Mock.js
244244
Mock.d.ts
245245

246246
Gemfile.lock
247+
/playground/ios/.xcode.env.local

babel.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module.exports = function (api) {
22
api && api.cache(false);
33
return {
4-
presets: ['module:metro-react-native-babel-preset'],
4+
presets: ['module:@react-native/babel-preset'],
55
plugins: [
66
'@babel/plugin-proposal-export-namespace-from',
77
'@babel/plugin-proposal-export-default-from',

e2e/StaticLifecycleEvents.test.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import Utils from './Utils';
22
import TestIDs from '../playground/src/testIDs';
33

4-
const { elementByLabel, elementById } = Utils;
4+
const { elementByLabel, elementById, sleep } = Utils;
55

66
describe('static lifecycle events', () => {
77
beforeEach(async () => {
@@ -93,6 +93,9 @@ describe('static lifecycle events', () => {
9393
await elementById(TestIDs.SET_ROOT_BTN).tap();
9494
await elementById(TestIDs.CLEAR_OVERLAY_EVENTS_BTN).tap();
9595
await elementById(TestIDs.SET_ROOT_BTN).tap();
96+
// This sleep is needed in order to synchronize the test rendered with state changes. We can remove it after moving
97+
// our mock to work with act(()=>{}) from react-test-renderer
98+
await sleep(10);
9699
await expect(elementByLabel('setRoot complete - previous root is unmounted')).toBeVisible();
97100
});
98101

-31.1 KB
Loading

lib/Mock/Components/ComponentScreen.tsx

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, { Component } from 'react';
2-
import { View, Text, TouchableOpacity, Image, ImageURISource} from 'react-native';
3-
import { Navigation, ImageResource} from 'react-native-navigation';
2+
import { View, Text, TouchableOpacity, Image, ImageURISource } from 'react-native';
3+
import { Navigation, ImageResource } from 'react-native-navigation';
44
import { ComponentProps } from '../ComponentProps';
55
import { VISIBLE_SCREEN_TEST_ID } from '../constants';
66
import { LayoutStore } from '../Stores/LayoutStore';
@@ -10,8 +10,7 @@ import { events } from '../Stores/EventsStore';
1010
import _ from 'lodash';
1111
import { switchTabByIndex } from '../actions/layoutActions';
1212

13-
14-
function isURISource(src: ImageResource| undefined): src is ImageURISource {
13+
function isURISource(src: ImageResource | undefined): src is ImageURISource {
1514
return !!src && typeof src === 'object' && 'uri' in src;
1615
}
1716

@@ -36,12 +35,15 @@ export const ComponentScreen = connect(
3635
if (bottomTabsOptions?.visible === false) return null;
3736
const buttons = bottomTabs!.children!.map((child, i) => {
3837
const bottomTabOptions = child.resolveOptions().bottomTab;
39-
const icon = (bottomTabs as any).selectedIndex === i ? bottomTabOptions?.selectedIcon : bottomTabOptions?.icon;
38+
const icon =
39+
(bottomTabs as any).selectedIndex === i
40+
? bottomTabOptions?.selectedIcon
41+
: bottomTabOptions?.icon;
4042
const iconURI = isURISource(icon) ? icon.uri : undefined;
4143
return (
4244
<View key={`tab-${i}`}>
4345
<TouchableOpacity
44-
style={{padding:10}}
46+
style={{ padding: 10 }}
4547
testID={bottomTabOptions?.testID}
4648
onPress={() => {
4749
events.invokeBottomTabPressed({
@@ -51,22 +53,34 @@ export const ComponentScreen = connect(
5153
switchTabByIndex(this.props.layoutNode.getBottomTabs(), i);
5254
}}
5355
>
54-
<View style={{justifyContent: 'center', alignItems: 'center'}}>
55-
<Text>{bottomTabOptions?.badge}</Text>
56-
{iconURI && <Image style={{width: 18, height: 18, marginBottom: 5}} source={{uri: iconURI}}/>}
57-
<Text style={{fontSize: 12}}>{bottomTabOptions?.text || ''}</Text>
58-
</View>
56+
<View style={{ justifyContent: 'center', alignItems: 'center' }}>
57+
<Text>{bottomTabOptions?.badge}</Text>
58+
{iconURI && (
59+
<Image
60+
style={{ width: 18, height: 18, marginBottom: 5 }}
61+
source={{ uri: iconURI }}
62+
/>
63+
)}
64+
<Text style={{ fontSize: 12 }}>{bottomTabOptions?.text || ''}</Text>
65+
</View>
5966
</TouchableOpacity>
6067
</View>
6168
);
6269
});
6370

6471
return (
65-
<View
66-
testID={bottomTabsOptions?.testID}
67-
style={{flexDirection: 'row',justifyContent: 'center', width: '100%', backgroundColor: '#F0F2F5'}}>
72+
<View
73+
testID={bottomTabsOptions?.testID}
74+
style={{
75+
flexDirection: 'row',
76+
justifyContent: 'center',
77+
width: '100%',
78+
backgroundColor: '#F0F2F5',
79+
}}
80+
>
6881
{buttons}
69-
</View>);
82+
</View>
83+
);
7084
}
7185

7286
render() {

lib/Mock/Components/LayoutComponent.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ export const LayoutComponent = class extends Component<ComponentProps> {
1919
return <View />;
2020
}
2121
componentDidCatch(error: Error, errorInfo: React.ErrorInfo) {
22-
const err = new Error(
23-
`Error while trying to render layout ${this.props.layoutNode.nodeId} of type ${this.props.layoutNode.type}: ${error}\n${errorInfo?.componentStack}`,
22+
const err = new Error(
23+
`Error while trying to render layout ${this.props.layoutNode.nodeId} of type ${this.props.layoutNode.type}: ${error}\n${errorInfo?.componentStack}`
2424
);
2525
(err as any).cause = error;
2626
throw err;

lib/android/app/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ def DEFAULT_KOTLIN_STDLIB = 'kotlin-stdlib-jdk8'
2020
def kotlinVersion = safeExtGet("RNNKotlinVersion", DEFAULT_KOTLIN_VERSION)
2121
def kotlinStdlib = safeExtGet('RNNKotlinStdlib',DEFAULT_KOTLIN_STDLIB )
2222
def kotlinCoroutinesCore = safeExtGet('RNNKotlinCoroutinesCore', '1.5.2')
23+
2324
android {
2425
namespace 'com.reactnativenavigation'
2526
compileSdkVersion safeExtGetFallbackLowerBound('compileSdkVersion', DEFAULT_COMPILE_SDK_VERSION)

lib/android/app/src/main/java/com/reactnativenavigation/NavigationApplication.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@
44

55
import com.facebook.react.ReactApplication;
66
import com.facebook.react.ReactNativeHost;
7+
import com.facebook.react.soloader.OpenSourceMergedSoMapping;
78
import com.facebook.soloader.SoLoader;
89
import com.reactnativenavigation.react.ReactGateway;
910
import com.reactnativenavigation.viewcontrollers.externalcomponent.ExternalComponentCreator;
1011

12+
import java.io.IOException;
1113
import java.util.HashMap;
1214
import java.util.Map;
1315

@@ -23,7 +25,11 @@ public abstract class NavigationApplication extends Application implements React
2325
public void onCreate() {
2426
super.onCreate();
2527
instance = this;
26-
SoLoader.init(this, false);
28+
try {
29+
SoLoader.init(this, OpenSourceMergedSoMapping.INSTANCE);
30+
} catch (IOException e) {
31+
throw new RuntimeException(e);
32+
}
2733
reactGateway = createReactGateway();
2834
}
2935

lib/android/app/src/main/java/com/reactnativenavigation/react/ReactView.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,21 @@
55
import android.os.Bundle;
66
import android.view.MotionEvent;
77

8+
import androidx.annotation.RestrictTo;
9+
810
import com.facebook.react.ReactInstanceManager;
911
import com.facebook.react.ReactRootView;
1012
import com.facebook.react.bridge.ReactContext;
1113
import com.facebook.react.config.ReactFeatureFlags;
1214
import com.facebook.react.uimanager.JSTouchDispatcher;
1315
import com.facebook.react.uimanager.UIManagerModule;
1416
import com.facebook.react.uimanager.events.EventDispatcher;
15-
import com.reactnativenavigation.viewcontrollers.viewcontroller.ScrollEventListener;
1617
import com.reactnativenavigation.react.events.ComponentType;
1718
import com.reactnativenavigation.react.events.EventEmitter;
1819
import com.reactnativenavigation.viewcontrollers.viewcontroller.IReactView;
20+
import com.reactnativenavigation.viewcontrollers.viewcontroller.ScrollEventListener;
1921
import com.reactnativenavigation.views.component.Renderable;
2022

21-
import androidx.annotation.RestrictTo;
22-
2323
@SuppressLint("ViewConstructor")
2424
public class ReactView extends ReactRootView implements IReactView, Renderable {
2525

0 commit comments

Comments
 (0)