Skip to content

Commit c2f195b

Browse files
authored
Merge pull request #73 from callstack/@okwasniewski/chore/upgradeRN
chore: upgrade example to RN 0.74, move to typescript, update deprecated code
2 parents 8c23dee + 4a5d897 commit c2f195b

Some content is hidden

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

53 files changed

+18543
-6405
lines changed

.circleci/config.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ version: 2.1
33
jobs:
44
analyse:
55
docker:
6-
- image: circleci/node:10
6+
- image: cimg/node:current
77
steps:
88
- checkout
99
- restore_cache:
@@ -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

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

.flowconfig

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

.gitignore

Lines changed: 15 additions & 0 deletions
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

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

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

Lines changed: 6 additions & 3 deletions
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

Lines changed: 10 additions & 5 deletions
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

Lines changed: 7 additions & 5 deletions
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

Lines changed: 1 addition & 1 deletion
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

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

0 commit comments

Comments
 (0)