Skip to content

Commit 4a5d897

Browse files
committed
chore: bump to RN 0.74
1 parent 812511a commit 4a5d897

38 files changed

+17659
-7042
lines changed

.circleci/config.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ jobs:
1919
name: Lint JS Code (ESLint)
2020
command: yarn run lint
2121
- run:
22-
name: Flow
23-
command: yarn run flow
22+
name: Typescript Type Checking (tsc)
23+
command: yarn run typecheck
2424

2525
workflows:
2626
test:
2727
jobs:
28-
- analyse
28+
- analyse

.eslintrc.js

-7
This file was deleted.

.flowconfig

-100
This file was deleted.

.gitignore

+15
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ DerivedData
2121
*.ipa
2222
*.xcuserstate
2323
project.xcworkspace
24+
**/.xcode.env.local
2425

2526
# Android/IntelliJ
2627
#
@@ -57,3 +58,17 @@ buck-out/
5758

5859
# CocoaPods
5960
**/Pods
61+
62+
63+
# Yarn
64+
.yarn/*
65+
!.yarn/patches
66+
!.yarn/plugins
67+
!.yarn/releases
68+
!.yarn/sdks
69+
!.yarn/versions
70+
.yarnrc.yml
71+
72+
# generated by bob
73+
lib/
74+

.yarnrc.yml

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
nodeLinker: node-modules

android/src/main/java/com/callstack/reactnativebrownfield/ReactNativeActivity.kt

+6-3
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,11 @@ class ReactNativeActivity : ReactActivity(), DefaultHardwareBackBtnHandler, Perm
8484
ReactNativeBrownfield.shared.reactNativeHost.reactInstanceManager.showDevOptionsDialog()
8585
return true
8686
}
87-
val didDoubleTapR = Assertions.assertNotNull(doubleTapReloadRecognizer)
88-
.didDoubleTapR(keyCode, this.currentFocus)
89-
if (didDoubleTapR) {
87+
val didDoubleTapR = this.currentFocus?.let {
88+
Assertions.assertNotNull(doubleTapReloadRecognizer)
89+
.didDoubleTapR(keyCode, it)
90+
}
91+
if (didDoubleTapR == true) {
9092
ReactNativeBrownfield.shared.reactNativeHost.reactInstanceManager.devSupportManager.handleReloadJS()
9193
return true
9294
}
@@ -132,6 +134,7 @@ class ReactNativeActivity : ReactActivity(), DefaultHardwareBackBtnHandler, Perm
132134
permissions: Array<String>,
133135
grantResults: IntArray
134136
) {
137+
super.onRequestPermissionsResult(requestCode, permissions, grantResults)
135138
permissionsCallback = Callback {
136139
if (permissionListener != null) {
137140
permissionListener?.onRequestPermissionsResult(

android/src/main/java/com/callstack/reactnativebrownfield/ReactNativeBrownfield.kt

+10-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
package com.callstack.reactnativebrownfield
22

33
import android.app.Application
4+
import com.facebook.react.ReactInstanceEventListener
45
import com.facebook.react.ReactNativeHost
56
import com.facebook.react.ReactPackage
7+
import com.facebook.react.bridge.ReactContext
68
import com.facebook.soloader.SoLoader
79
import java.util.concurrent.atomic.AtomicBoolean
810

@@ -60,10 +62,13 @@ class ReactNativeBrownfield private constructor(val reactNativeHost: ReactNative
6062

6163
@JvmName("startReactNativeKotlin")
6264
fun startReactNative(callback: ((initialized: Boolean) -> Unit)?) {
63-
if (callback != null) {
64-
reactNativeHost.reactInstanceManager?.addReactInstanceEventListener { callback(true) }
65-
}
66-
65+
reactNativeHost.reactInstanceManager.addReactInstanceEventListener(object : ReactInstanceEventListener {
66+
override fun onReactContextInitialized(reactContext: ReactContext) {
67+
callback?.let { it(true) }
68+
reactNativeHost.reactInstanceManager.removeReactInstanceEventListener(this)
69+
}
70+
})
6771
reactNativeHost.reactInstanceManager?.createReactContextInBackground()
6872
}
69-
}
73+
}
74+

android/src/main/java/com/callstack/reactnativebrownfield/ReactNativeFragment.kt

+7-5
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,12 @@ class ReactNativeFragment : Fragment(), PermissionAwareActivity {
103103
}
104104

105105
override fun checkPermission(permission: String, pid: Int, uid: Int): Int {
106-
return activity!!.checkPermission(permission, pid, uid)
106+
return requireActivity().checkPermission(permission, pid, uid)
107107
}
108108

109109
@TargetApi(Build.VERSION_CODES.M)
110110
override fun checkSelfPermission(permission: String): Int {
111-
return activity!!.checkSelfPermission(permission)
111+
return requireActivity().checkSelfPermission(permission)
112112
}
113113

114114
@TargetApi(Build.VERSION_CODES.M)
@@ -128,9 +128,11 @@ class ReactNativeFragment : Fragment(), PermissionAwareActivity {
128128
ReactNativeBrownfield.shared.reactNativeHost.reactInstanceManager.showDevOptionsDialog()
129129
handled = true
130130
}
131-
val didDoubleTapR = Assertions.assertNotNull(doubleTapReloadRecognizer)
132-
.didDoubleTapR(keyCode, activity?.currentFocus)
133-
if (didDoubleTapR) {
131+
val didDoubleTapR = activity?.currentFocus?.let {
132+
Assertions.assertNotNull(doubleTapReloadRecognizer)
133+
.didDoubleTapR(keyCode, it)
134+
}
135+
if (didDoubleTapR == true) {
134136
ReactNativeBrownfield.shared.reactNativeHost.reactInstanceManager.devSupportManager.handleReloadJS()
135137
handled = true
136138
}

babel.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module.exports = {
2-
presets: ['module:metro-react-native-babel-preset'],
2+
presets: ['module:@react-native/babel-preset'],
33
plugins: [
44
[
55
'module-resolver',

example/index.js renamed to example/index.tsx

+21-10
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,39 @@
11
import React, {useEffect} from 'react';
22
import {AppRegistry, StyleSheet, Text, View, Button} from 'react-native';
3-
import {NavigationContainer} from '@react-navigation/native';
4-
import {createNativeStackNavigator} from '@react-navigation/native-stack';
3+
import {
4+
createNativeStackNavigator,
5+
type NativeStackScreenProps,
6+
} from '@react-navigation/native-stack';
57
import ReactNativeBrownfield from '@callstack/react-native-brownfield';
8+
import {NavigationContainer} from '@react-navigation/native';
69

10+
const getRandomValue = () => Math.round(Math.random() * 255);
711
const getRandomTheme = () => {
8-
const getRandomValue = () => Math.round(Math.random() * 255);
9-
1012
const primary = [getRandomValue(), getRandomValue(), getRandomValue()];
11-
const secondary = [255 - primary[0], 255 - primary[1], 255 - primary[2]];
13+
const secondary = [
14+
255 - (primary?.[0] || 0),
15+
255 - (primary?.[1] || 0),
16+
255 - (primary?.[2] || 0),
17+
];
1218

1319
return {
1420
primary: `rgb(${primary[0]}, ${primary[1]}, ${primary[2]})`,
1521
secondary: `rgb(${secondary[0]}, ${secondary[1]}, ${secondary[2]})`,
1622
};
1723
};
1824

19-
function HomeScreen({navigation}) {
20-
const colors = navigation.params?.theme || getRandomTheme();
25+
type Props = NativeStackScreenProps<RootStackParamList, 'Home'>;
26+
27+
function HomeScreen({navigation, route}: Props) {
28+
const colors = route.params?.theme || getRandomTheme();
2129

2230
useEffect(() => {
23-
const unsubscribe = navigation.addListener('focus', (e) => {
31+
const unsubscribe = navigation.addListener('focus', () => {
2432
const isFirstRoute = !navigation.canGoBack();
2533
ReactNativeBrownfield.setNativeBackGestureAndButtonEnabled(isFirstRoute);
2634
});
2735
return unsubscribe;
28-
}, []);
36+
}, [navigation]);
2937

3038
return (
3139
<View style={[styles.container, {backgroundColor: colors.primary}]}>
@@ -57,8 +65,11 @@ function HomeScreen({navigation}) {
5765
</View>
5866
);
5967
}
68+
type RootStackParamList = {
69+
Home: {theme: {primary: string, secondary: string}},
70+
};
6071

61-
const Stack = createNativeStackNavigator();
72+
const Stack = createNativeStackNavigator<RootStackParamList>();
6273

6374
function App() {
6475
return (

example/java/app/build.gradle

+3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ react {
1010
def jscFlavor = 'org.webkit:android-jsc:+'
1111

1212
android {
13+
namespace "com.callstack.nativeexample"
1314
ndkVersion rootProject.ext.ndkVersion
15+
16+
buildToolsVersion rootProject.ext.buildToolsVersion
1417
compileSdkVersion rootProject.ext.compileSdkVersion
1518

1619
compileOptions {

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

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3-
package="com.callstack.nativeexample">
4-
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
53
<uses-permission android:name="android.permission.INTERNET"/>
64
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
75

@@ -25,4 +23,4 @@
2523
<activity android:name="com.callstack.reactnativebrownfield.ReactNativeActivity"/>
2624
</application>
2725

28-
</manifest>
26+
</manifest>

example/java/build.gradle

+11-8
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,31 @@
22

33
buildscript {
44
ext {
5-
buildToolsVersion = "33.0.0"
6-
minSdkVersion = 21
7-
compileSdkVersion = 33
8-
targetSdkVersion = 33
9-
supportLibVersion = "28.0.0"
10-
kotlinVersion = '1.9.10'
5+
buildToolsVersion = "34.0.0"
6+
minSdkVersion = 23
7+
compileSdkVersion = 34
8+
targetSdkVersion = 34
9+
ndkVersion = "26.1.10909125"
10+
kotlinVersion = "1.9.22"
1111

1212
// We use NDK 23 which has both M1 support and is the side-by-side NDK version from AGP.
1313
ndkVersion = "23.1.7779620"
1414
}
1515
repositories {
16-
google()
17-
jcenter()
1816
mavenCentral()
17+
google()
18+
gradlePluginPortal()
1919
}
2020
dependencies {
2121
classpath "com.android.tools.build:gradle"
2222
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
2323
classpath "com.facebook.react:react-native-gradle-plugin"
24+
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin"
2425
}
2526
}
2627

2728
task clean(type: Delete) {
2829
delete rootProject.buildDir
2930
}
31+
32+
apply plugin: "com.facebook.react.rootproject"
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-all.zip
4+
networkTimeout=10000
5+
validateDistributionUrl=true
46
zipStoreBase=GRADLE_USER_HOME
57
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)