Skip to content

Commit d2c2b32

Browse files
committed
React Navigation v5 compatibility is here with new version, new example and new logos
1 parent 51d8061 commit d2c2b32

File tree

38 files changed

+4195
-3585
lines changed

38 files changed

+4195
-3585
lines changed

example/.eslintrc.js

Lines changed: 4 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,4 @@
1-
{
2-
"parser": "babel-eslint",
3-
"parserOptions": {
4-
"ecmaVersion": 6,
5-
"sourceType": "module",
6-
"ecmaFeatures": {
7-
"jsx": true,
8-
"modules": true,
9-
"experimentalObjectRestSpread": true
10-
}
11-
},
12-
"plugins": ["prettier", "react"],
13-
"extends": ["airbnb", "prettier/react"],
14-
"rules": {
15-
"class-methods-use-this": "off",
16-
"comma-dangle": 0,
17-
"indent": [2, "tab"],
18-
"react/jsx-uses-vars": 1,
19-
"react/display-name": 1,
20-
"no-unused-vars": "warn",
21-
"no-console": 0,
22-
"no-unexpected-multiline": "warn",
23-
"quotes": "off",
24-
"react/destructuring-assignment": "off",
25-
"react/jsx-no-bind": "off",
26-
"react/jsx-filename-extension": "off",
27-
"react/prefer-stateless-function": "off",
28-
"react/prop-types": "off",
29-
"no-alert": "off",
30-
"no-tabs": 0,
31-
"linebreak-style": 0,
32-
"no-underscore-dangle": 0,
33-
"react/no-string-refs": 0,
34-
"eqeqeq": "error"
35-
},
36-
"settings": {
37-
"react": {
38-
"pragma": "React",
39-
"version": "15.6.1"
40-
}
41-
},
42-
"globals": {
43-
"navigator": true,
44-
"alert": true,
45-
"fetch": true,
46-
"coordinate": true,
47-
"isFunction": true,
48-
"FormData": true
49-
}
50-
}
1+
module.exports = {
2+
root: true,
3+
extends: '@react-native-community',
4+
};

example/.flowconfig

Lines changed: 5 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,6 @@
55
; Ignore "BUCK" generated dirs
66
<PROJECT_ROOT>/\.buckd/
77

8-
; Ignore unexpected extra "@providesModule"
9-
.*/node_modules/.*/node_modules/fbjs/.*
10-
11-
; Ignore duplicate module providers
12-
; For RN Apps installed via npm, "Libraries" folder is inside
13-
; "node_modules/react-native" but in the source repo it is in the root
14-
node_modules/react-native/Libraries/react-native/React.js
15-
168
; Ignore polyfills
179
node_modules/react-native/Libraries/polyfills/.*
1810

@@ -21,15 +13,15 @@ node_modules/react-native/Libraries/polyfills/.*
2113
node_modules/warning/.*
2214

2315
; Flow doesn't support platforms
24-
.*/Libraries/Utilities/HMRLoadingView.js
16+
.*/Libraries/Utilities/LoadingView.js
2517

2618
[untyped]
2719
.*/node_modules/@react-native-community/cli/.*/.*
2820

2921
[include]
3022

3123
[libs]
32-
node_modules/react-native/Libraries/react-native/react-native-interface.js
24+
node_modules/react-native/interface.js
3325
node_modules/react-native/flow/
3426

3527
[options]
@@ -42,27 +34,10 @@ module.file_ext=.js
4234
module.file_ext=.json
4335
module.file_ext=.ios.js
4436

45-
module.system=haste
46-
module.system.haste.use_name_reducers=true
47-
# get basename
48-
module.system.haste.name_reducers='^.*/\([a-zA-Z0-9$_.-]+\.js\(\.flow\)?\)$' -> '\1'
49-
# strip .js or .js.flow suffix
50-
module.system.haste.name_reducers='^\(.*\)\.js\(\.flow\)?$' -> '\1'
51-
# strip .ios suffix
52-
module.system.haste.name_reducers='^\(.*\)\.ios$' -> '\1'
53-
module.system.haste.name_reducers='^\(.*\)\.android$' -> '\1'
54-
module.system.haste.name_reducers='^\(.*\)\.native$' -> '\1'
55-
module.system.haste.paths.blacklist=.*/__tests__/.*
56-
module.system.haste.paths.blacklist=.*/__mocks__/.*
57-
module.system.haste.paths.whitelist=<PROJECT_ROOT>/node_modules/react-native/Libraries/.*
58-
module.system.haste.paths.whitelist=<PROJECT_ROOT>/node_modules/react-native/RNTester/.*
59-
module.system.haste.paths.whitelist=<PROJECT_ROOT>/node_modules/react-native/IntegrationTests/.*
60-
module.system.haste.paths.blacklist=<PROJECT_ROOT>/node_modules/react-native/Libraries/react-native/react-native-implementation.js
61-
module.system.haste.paths.blacklist=<PROJECT_ROOT>/node_modules/react-native/Libraries/Animated/src/polyfills/.*
62-
6337
munge_underscores=true
6438

65-
module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> 'RelativeImageStub'
39+
module.name_mapper='^react-native/\(.*\)$' -> '<PROJECT_ROOT>/node_modules/react-native/\1'
40+
module.name_mapper='^@?[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> '<PROJECT_ROOT>/node_modules/react-native/Libraries/Image/RelativeImageStub'
6641

6742
suppress_type=$FlowIssue
6843
suppress_type=$FlowFixMe
@@ -81,7 +56,6 @@ untyped-type-import=warn
8156
nonstrict-import=warn
8257
deprecated-type=warn
8358
unsafe-getters-setters=warn
84-
inexact-spread=warn
8559
unnecessary-invariant=warn
8660
signature-verification-failure=warn
8761
deprecated-utility=error
@@ -96,4 +70,4 @@ untyped-import
9670
untyped-type-import
9771

9872
[version]
99-
^0.98.0
73+
^0.122.0

example/.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ DerivedData
2020
*.hmap
2121
*.ipa
2222
*.xcuserstate
23-
project.xcworkspace
2423

2524
# Android/IntelliJ
2625
#
@@ -40,6 +39,7 @@ yarn-error.log
4039
buck-out/
4140
\.buckd/
4241
*.keystore
42+
!debug.keystore
4343

4444
# fastlane
4545
#

example/App.js

Lines changed: 37 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,46 @@
1-
import React, { Fragment } from "react";
1+
import "react-native-gesture-handler";
2+
import React, { useEffect } from "react";
23
import { StatusBar } from "react-native";
3-
import NavigationService from "react-navigation-helpers";
4-
import Navigation from "./src/services/navigation/Navigation";
4+
import { NavigationContainer } from "@react-navigation/native";
5+
import { createStackNavigator } from "@react-navigation/stack";
6+
import { createBottomTabNavigator } from "@react-navigation/bottom-tabs";
7+
8+
import { isReadyRef, navigationRef } from "./lib/src/NavigationService";
9+
10+
// ? Screens
11+
import HomeScreen from "./screens/HomeScreen";
12+
import WelcomeScreen from "./screens/WelcomeScreen";
13+
14+
const Stack = createStackNavigator();
15+
const Tab = createBottomTabNavigator();
516

617
const App = () => {
7-
const MainNavigator = Navigation.createBottomTabNavigator();
18+
useEffect(() => {
19+
return () => (isReadyRef.current = false);
20+
}, []);
821

922
return (
10-
<Fragment>
23+
<>
1124
<StatusBar barStyle="dark-content" />
12-
<MainNavigator
13-
ref={navigatorRef =>
14-
NavigationService.setGlobalLevelNavigator(navigatorRef)
15-
}
16-
/>
17-
</Fragment>
25+
<NavigationContainer
26+
ref={navigationRef}
27+
onReady={() => {
28+
isReadyRef.current = true;
29+
}}
30+
>
31+
{/*
32+
// ? Tab Example, do not forget to use `goBack` instead of `pop` function
33+
<Tab.Navigator>
34+
<Tab.Screen name="Welcome" component={WelcomeScreen} />
35+
<Tab.Screen name="Home" component={HomeScreen} />
36+
</Tab.Navigator>
37+
*/}
38+
<Stack.Navigator>
39+
<Stack.Screen name="Welcome" component={WelcomeScreen} />
40+
<Stack.Screen name="Home" component={HomeScreen} />
41+
</Stack.Navigator>
42+
</NavigationContainer>
43+
</>
1844
);
1945
};
2046

File renamed without changes.

example/android/app/build.gradle

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,12 @@ import com.android.build.OutputFile
1515
* // the name of the generated asset file containing your JS bundle
1616
* bundleAssetName: "index.android.bundle",
1717
*
18-
* // the entry file for bundle generation
18+
* // the entry file for bundle generation. If none specified and
19+
* // "index.android.js" exists, it will be used. Otherwise "index.js" is
20+
* // default. Can be overridden with ENTRY_FILE environment variable.
1921
* entryFile: "index.android.js",
2022
*
21-
* // https://facebook.github.io/react-native/docs/performance#enable-the-ram-format
23+
* // https://reactnative.dev/docs/performance#enable-the-ram-format
2224
* bundleCommand: "ram-bundle",
2325
*
2426
* // whether to bundle JS and assets in debug mode
@@ -76,7 +78,6 @@ import com.android.build.OutputFile
7678
*/
7779

7880
project.ext.react = [
79-
entryFile: "index.js",
8081
enableHermes: false, // clean and rebuild if changing
8182
]
8283

@@ -156,12 +157,13 @@ android {
156157
}
157158
release {
158159
// Caution! In production, you need to generate your own keystore file.
159-
// see https://facebook.github.io/react-native/docs/signed-apk-android.
160+
// see https://reactnative.dev/docs/signed-apk-android.
160161
signingConfig signingConfigs.debug
161162
minifyEnabled enableProguardInReleaseBuilds
162163
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
163164
}
164165
}
166+
165167
// applicationVariants are e.g. debug, release
166168
applicationVariants.all { variant ->
167169
variant.outputs.each { output ->
@@ -176,28 +178,34 @@ android {
176178

177179
}
178180
}
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-
}
188181
}
189182

190183
dependencies {
191-
implementation project(':react-native-gesture-handler')
192184
implementation fileTree(dir: "libs", include: ["*.jar"])
185+
//noinspection GradleDynamicVersion
193186
implementation "com.facebook.react:react-native:+" // From node_modules
194187

188+
implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"
189+
190+
debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") {
191+
exclude group:'com.facebook.fbjni'
192+
}
193+
194+
debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
195+
exclude group:'com.facebook.flipper'
196+
exclude group:'com.squareup.okhttp3', module:'okhttp'
197+
}
198+
199+
debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") {
200+
exclude group:'com.facebook.flipper'
201+
}
202+
195203
if (enableHermes) {
196-
def hermesPath = "../../node_modules/hermesvm/android/";
197-
debugImplementation files(hermesPath + "hermes-debug.aar")
198-
releaseImplementation files(hermesPath + "hermes-release.aar")
204+
def hermesPath = "../../node_modules/hermes-engine/android/";
205+
debugImplementation files(hermesPath + "hermes-debug.aar")
206+
releaseImplementation files(hermesPath + "hermes-release.aar")
199207
} else {
200-
implementation jscFlavor
208+
implementation jscFlavor
201209
}
202210
}
203211

example/android/app/debug.keystore

2.2 KB
Binary file not shown.
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
/**
2+
* Copyright (c) Facebook, Inc. and its affiliates.
3+
*
4+
* <p>This source code is licensed under the MIT license found in the LICENSE file in the root
5+
* directory of this source tree.
6+
*/
7+
package com.example;
8+
9+
import android.content.Context;
10+
import com.facebook.flipper.android.AndroidFlipperClient;
11+
import com.facebook.flipper.android.utils.FlipperUtils;
12+
import com.facebook.flipper.core.FlipperClient;
13+
import com.facebook.flipper.plugins.crashreporter.CrashReporterPlugin;
14+
import com.facebook.flipper.plugins.databases.DatabasesFlipperPlugin;
15+
import com.facebook.flipper.plugins.fresco.FrescoFlipperPlugin;
16+
import com.facebook.flipper.plugins.inspector.DescriptorMapping;
17+
import com.facebook.flipper.plugins.inspector.InspectorFlipperPlugin;
18+
import com.facebook.flipper.plugins.network.FlipperOkhttpInterceptor;
19+
import com.facebook.flipper.plugins.network.NetworkFlipperPlugin;
20+
import com.facebook.flipper.plugins.react.ReactFlipperPlugin;
21+
import com.facebook.flipper.plugins.sharedpreferences.SharedPreferencesFlipperPlugin;
22+
import com.facebook.react.ReactInstanceManager;
23+
import com.facebook.react.bridge.ReactContext;
24+
import com.facebook.react.modules.network.NetworkingModule;
25+
import okhttp3.OkHttpClient;
26+
27+
public class ReactNativeFlipper {
28+
public static void initializeFlipper(Context context, ReactInstanceManager reactInstanceManager) {
29+
if (FlipperUtils.shouldEnableFlipper(context)) {
30+
final FlipperClient client = AndroidFlipperClient.getInstance(context);
31+
32+
client.addPlugin(new InspectorFlipperPlugin(context, DescriptorMapping.withDefaults()));
33+
client.addPlugin(new ReactFlipperPlugin());
34+
client.addPlugin(new DatabasesFlipperPlugin(context));
35+
client.addPlugin(new SharedPreferencesFlipperPlugin(context));
36+
client.addPlugin(CrashReporterPlugin.getInstance());
37+
38+
NetworkFlipperPlugin networkFlipperPlugin = new NetworkFlipperPlugin();
39+
NetworkingModule.setCustomClientBuilder(
40+
new NetworkingModule.CustomClientBuilder() {
41+
@Override
42+
public void apply(OkHttpClient.Builder builder) {
43+
builder.addNetworkInterceptor(new FlipperOkhttpInterceptor(networkFlipperPlugin));
44+
}
45+
});
46+
client.addPlugin(networkFlipperPlugin);
47+
client.start();
48+
49+
// Fresco Plugin needs to ensure that ImagePipelineFactory is initialized
50+
// Hence we run if after all native modules have been initialized
51+
ReactContext reactContext = reactInstanceManager.getCurrentReactContext();
52+
if (reactContext == null) {
53+
reactInstanceManager.addReactInstanceEventListener(
54+
new ReactInstanceManager.ReactInstanceEventListener() {
55+
@Override
56+
public void onReactContextInitialized(ReactContext reactContext) {
57+
reactInstanceManager.removeReactInstanceEventListener(this);
58+
reactContext.runOnNativeModulesQueueThread(
59+
new Runnable() {
60+
@Override
61+
public void run() {
62+
client.addPlugin(new FrescoFlipperPlugin());
63+
}
64+
});
65+
}
66+
});
67+
} else {
68+
client.addPlugin(new FrescoFlipperPlugin());
69+
}
70+
}
71+
}
72+
}

example/android/app/src/main/AndroidManifest.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
<activity
1414
android:name=".MainActivity"
1515
android:label="@string/app_name"
16-
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
16+
android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode"
17+
android:launchMode="singleTask"
1718
android:windowSoftInputMode="adjustResize">
1819
<intent-filter>
1920
<action android:name="android.intent.action.MAIN" />

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44

55
public class MainActivity extends ReactActivity {
66

7-
/**
8-
* Returns the name of the main component registered from JavaScript.
9-
* This is used to schedule rendering of the component.
10-
*/
11-
@Override
12-
protected String getMainComponentName() {
13-
return "example";
14-
}
7+
/**
8+
* Returns the name of the main component registered from JavaScript. This is used to schedule
9+
* rendering of the component.
10+
*/
11+
@Override
12+
protected String getMainComponentName() {
13+
return "example";
14+
}
1515
}

0 commit comments

Comments
 (0)