Skip to content

Commit c9c67bb

Browse files
Change naming
1 parent 93a8cac commit c9c67bb

25 files changed

+1458
-234
lines changed

.eslintrc.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module.exports = {
2+
extends: '@react-native-community',
3+
env: {
4+
es6: true
5+
}
6+
}

.flowconfig

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
[ignore]
2+
; We fork some components by platform
3+
.*/*[.]android.js
4+
5+
; Ignore "BUCK" generated dirs
6+
<PROJECT_ROOT>/\.buckd/
7+
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+
16+
; Ignore polyfills
17+
node_modules/react-native/Libraries/polyfills/.*
18+
19+
; These should not be required directly
20+
; require from fbjs/lib instead: require('fbjs/lib/warning')
21+
node_modules/warning/.*
22+
23+
; Flow doesn't support platforms
24+
.*/Libraries/Utilities/HMRLoadingView.js
25+
26+
[untyped]
27+
.*/node_modules/@react-native-community/cli/.*/.*
28+
29+
[include]
30+
31+
[libs]
32+
node_modules/react-native/Libraries/react-native/react-native-interface.js
33+
node_modules/react-native/flow/
34+
35+
[options]
36+
emoji=true
37+
38+
esproposal.optional_chaining=enable
39+
esproposal.nullish_coalescing=enable
40+
41+
module.file_ext=.js
42+
module.file_ext=.json
43+
module.file_ext=.ios.js
44+
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+
63+
munge_underscores=true
64+
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'
66+
module.name_mapper='^\@react-native-community/slider\(.*\)$' -> '<PROJECT_ROOT>/js/Slider.js\1'
67+
68+
suppress_type=$FlowIssue
69+
suppress_type=$FlowFixMe
70+
suppress_type=$FlowFixMeProps
71+
suppress_type=$FlowFixMeState
72+
73+
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native\\(_ios\\)?_\\(oss\\|fb\\)[a-z,_]*\\)?)\\)
74+
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native\\(_ios\\)?_\\(oss\\|fb\\)[a-z,_]*\\)?)\\)?:? #[0-9]+
75+
suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError
76+
77+
[lints]
78+
sketchy-null-number=warn
79+
sketchy-null-mixed=warn
80+
sketchy-number=warn
81+
untyped-type-import=warn
82+
nonstrict-import=warn
83+
deprecated-type=warn
84+
unsafe-getters-setters=warn
85+
inexact-spread=warn
86+
unnecessary-invariant=warn
87+
signature-verification-failure=warn
88+
deprecated-utility=error
89+
90+
[strict]
91+
deprecated-type
92+
nonstrict-import
93+
sketchy-null
94+
unclear-type
95+
unsafe-getters-setters
96+
untyped-import
97+
untyped-type-import
98+
99+
[version]
100+
^0.98.0

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

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class ReactNativeActivity : ReactActivity(), DefaultHardwareBackBtnHandler, Perm
3333

3434
reactRootView = ReactRootView(this)
3535
reactRootView?.startReactApplication(
36-
BridgeManager.shared.reactNativeHost.reactInstanceManager,
36+
ReactNativeBrownfield.shared.reactNativeHost.reactInstanceManager,
3737
moduleName,
3838
initialProps
3939
)
@@ -50,22 +50,22 @@ class ReactNativeActivity : ReactActivity(), DefaultHardwareBackBtnHandler, Perm
5050
reactRootView?.unmountReactApplication()
5151
reactRootView = null
5252

53-
if (BridgeManager.shared.reactNativeHost.hasInstance()) {
54-
BridgeManager.shared.reactNativeHost.reactInstanceManager?.onHostDestroy(this)
55-
BridgeManager.shared.reactNativeHost.clear()
53+
if (ReactNativeBrownfield.shared.reactNativeHost.hasInstance()) {
54+
ReactNativeBrownfield.shared.reactNativeHost.reactInstanceManager?.onHostDestroy(this)
55+
ReactNativeBrownfield.shared.reactNativeHost.clear()
5656
}
5757
}
5858

5959
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
6060
super.onActivityResult(requestCode, resultCode, data)
61-
if (BridgeManager.shared.reactNativeHost.hasInstance()) {
62-
BridgeManager.shared.reactNativeHost.reactInstanceManager?.onActivityResult(this, requestCode, resultCode, data)
61+
if (ReactNativeBrownfield.shared.reactNativeHost.hasInstance()) {
62+
ReactNativeBrownfield.shared.reactNativeHost.reactInstanceManager?.onActivityResult(this, requestCode, resultCode, data)
6363
}
6464
}
6565

6666
override fun onKeyDown(keyCode: Int, event: KeyEvent): Boolean {
67-
if (BridgeManager.shared.reactNativeHost.hasInstance()
68-
&& BridgeManager.shared.reactNativeHost.useDeveloperSupport
67+
if (ReactNativeBrownfield.shared.reactNativeHost.hasInstance()
68+
&& ReactNativeBrownfield.shared.reactNativeHost.useDeveloperSupport
6969
&& keyCode == KeyEvent.KEYCODE_MEDIA_FAST_FORWARD
7070
) {
7171
event.startTracking()
@@ -79,28 +79,28 @@ class ReactNativeActivity : ReactActivity(), DefaultHardwareBackBtnHandler, Perm
7979
onBackPressed()
8080
return true
8181
}
82-
if (BridgeManager.shared.reactNativeHost.hasInstance()
83-
&& BridgeManager.shared.reactNativeHost.useDeveloperSupport) {
82+
if (ReactNativeBrownfield.shared.reactNativeHost.hasInstance()
83+
&& ReactNativeBrownfield.shared.reactNativeHost.useDeveloperSupport) {
8484
if (keyCode == KeyEvent.KEYCODE_MENU) {
85-
BridgeManager.shared.reactNativeHost.reactInstanceManager.showDevOptionsDialog()
85+
ReactNativeBrownfield.shared.reactNativeHost.reactInstanceManager.showDevOptionsDialog()
8686
return true
8787
}
8888
val didDoubleTapR = Assertions.assertNotNull(doubleTapReloadRecognizer)
8989
.didDoubleTapR(keyCode, this.currentFocus)
9090
if (didDoubleTapR) {
91-
BridgeManager.shared.reactNativeHost.reactInstanceManager.devSupportManager.handleReloadJS()
91+
ReactNativeBrownfield.shared.reactNativeHost.reactInstanceManager.devSupportManager.handleReloadJS()
9292
return true
9393
}
9494
}
9595
return false
9696
}
9797

9898
override fun onKeyLongPress(keyCode: Int, event: KeyEvent): Boolean {
99-
if (BridgeManager.shared.reactNativeHost.hasInstance()
100-
&& BridgeManager.shared.reactNativeHost.useDeveloperSupport
99+
if (ReactNativeBrownfield.shared.reactNativeHost.hasInstance()
100+
&& ReactNativeBrownfield.shared.reactNativeHost.useDeveloperSupport
101101
&& keyCode == KeyEvent.KEYCODE_MEDIA_FAST_FORWARD
102102
) {
103-
BridgeManager.shared.reactNativeHost.reactInstanceManager.showDevOptionsDialog()
103+
ReactNativeBrownfield.shared.reactNativeHost.reactInstanceManager.showDevOptionsDialog()
104104
return true
105105
}
106106
return false
@@ -109,8 +109,8 @@ class ReactNativeActivity : ReactActivity(), DefaultHardwareBackBtnHandler, Perm
109109
override fun onBackPressed() {
110110
if(ReactNativeBrownfieldModule.shouldPopToNative) {
111111
super.invokeDefaultOnBackPressed()
112-
} else if (BridgeManager.shared.reactNativeHost.hasInstance()) {
113-
BridgeManager.shared.reactNativeHost.reactInstanceManager.onBackPressed()
112+
} else if (ReactNativeBrownfield.shared.reactNativeHost.hasInstance()) {
113+
ReactNativeBrownfield.shared.reactNativeHost.reactInstanceManager.onBackPressed()
114114
}
115115
}
116116

android/src/main/java/com/callstack/reactnativebrownfield/BridgeManager.kt renamed to android/src/main/java/com/callstack/reactnativebrownfield/ReactNativeBrownfield.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,18 @@ interface InitializedCallback {
1010
operator fun invoke(initialized: Boolean)
1111
}
1212

13-
class BridgeManager private constructor(val reactNativeHost: ReactNativeHost) {
13+
class ReactNativeBrownfield private constructor(val reactNativeHost: ReactNativeHost) {
1414
companion object {
15-
private lateinit var instance: BridgeManager
15+
private lateinit var instance: ReactNativeBrownfield
1616
private val initialized = AtomicBoolean()
1717

1818
@JvmStatic
19-
val shared: BridgeManager get() = instance
19+
val shared: ReactNativeBrownfield get() = instance
2020

2121
@JvmStatic
2222
fun initialize(rnHost: ReactNativeHost, application: Application) {
2323
if(!initialized.getAndSet(true)) {
24-
instance = BridgeManager(rnHost)
24+
instance = ReactNativeBrownfield(rnHost)
2525
SoLoader.init(application.applicationContext,false)
2626
}
2727
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ class ReactNativeBrownfieldModule(reactContext: ReactApplicationContext) : React
1010
}
1111

1212
@ReactMethod
13-
fun popToNative(test: Boolean) {
13+
fun popToNative() {
1414
shouldPopToNative = true
1515
onBackPressed()
1616
}
1717

1818
@ReactMethod
19-
fun setPopGestureRecognizer(isFirstRoute: Boolean) {
19+
fun setHardwareBackButtonEnabled(isFirstRoute: Boolean) {
2020
shouldPopToNative = isFirstRoute
2121
}
2222

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

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class ReactNativeFragment : Fragment(), PermissionAwareActivity {
3737

3838
reactRootView = ReactRootView(context)
3939
reactRootView?.startReactApplication(
40-
BridgeManager.shared.reactNativeHost.reactInstanceManager,
40+
ReactNativeBrownfield.shared.reactNativeHost.reactInstanceManager,
4141
moduleName,
4242
initialProps
4343
)
@@ -54,8 +54,8 @@ class ReactNativeFragment : Fragment(), PermissionAwareActivity {
5454

5555
override fun onResume() {
5656
super.onResume()
57-
if (BridgeManager.shared.reactNativeHost.hasInstance()) {
58-
BridgeManager.shared.reactNativeHost.reactInstanceManager?.onHostResume(
57+
if (ReactNativeBrownfield.shared.reactNativeHost.hasInstance()) {
58+
ReactNativeBrownfield.shared.reactNativeHost.reactInstanceManager?.onHostResume(
5959
activity,
6060
activity as DefaultHardwareBackBtnHandler
6161
)
@@ -64,8 +64,8 @@ class ReactNativeFragment : Fragment(), PermissionAwareActivity {
6464

6565
override fun onPause() {
6666
super.onPause()
67-
if (BridgeManager.shared.reactNativeHost.hasInstance()) {
68-
BridgeManager.shared.reactNativeHost.reactInstanceManager?.onHostPause(
67+
if (ReactNativeBrownfield.shared.reactNativeHost.hasInstance()) {
68+
ReactNativeBrownfield.shared.reactNativeHost.reactInstanceManager?.onHostPause(
6969
activity
7070
)
7171
}
@@ -75,12 +75,12 @@ class ReactNativeFragment : Fragment(), PermissionAwareActivity {
7575
super.onDestroy()
7676
reactRootView?.unmountReactApplication()
7777
reactRootView = null
78-
if (BridgeManager.shared.reactNativeHost.hasInstance()) {
79-
val reactInstanceMgr = BridgeManager.shared.reactNativeHost.reactInstanceManager
78+
if (ReactNativeBrownfield.shared.reactNativeHost.hasInstance()) {
79+
val reactInstanceMgr = ReactNativeBrownfield.shared.reactNativeHost.reactInstanceManager
8080

8181
if (reactInstanceMgr.lifecycleState != LifecycleState.RESUMED) {
8282
reactInstanceMgr.onHostDestroy(activity)
83-
BridgeManager.shared.reactNativeHost.clear()
83+
ReactNativeBrownfield.shared.reactNativeHost.clear()
8484
}
8585
}
8686
}
@@ -124,15 +124,15 @@ class ReactNativeFragment : Fragment(), PermissionAwareActivity {
124124

125125
fun onKeyUp(keyCode: Int, event: KeyEvent): Boolean {
126126
var handled = false
127-
if (BridgeManager.shared.reactNativeHost.useDeveloperSupport && BridgeManager.shared.reactNativeHost.hasInstance()) {
127+
if (ReactNativeBrownfield.shared.reactNativeHost.useDeveloperSupport && ReactNativeBrownfield.shared.reactNativeHost.hasInstance()) {
128128
if (keyCode == KeyEvent.KEYCODE_MENU) {
129-
BridgeManager.shared.reactNativeHost.reactInstanceManager.showDevOptionsDialog()
129+
ReactNativeBrownfield.shared.reactNativeHost.reactInstanceManager.showDevOptionsDialog()
130130
handled = true
131131
}
132132
val didDoubleTapR = Assertions.assertNotNull(doubleTapReloadRecognizer)
133133
.didDoubleTapR(keyCode, activity?.currentFocus)
134134
if (didDoubleTapR) {
135-
BridgeManager.shared.reactNativeHost.reactInstanceManager.devSupportManager.handleReloadJS()
135+
ReactNativeBrownfield.shared.reactNativeHost.reactInstanceManager.devSupportManager.handleReloadJS()
136136
handled = true
137137
}
138138
}
@@ -142,8 +142,8 @@ class ReactNativeFragment : Fragment(), PermissionAwareActivity {
142142
fun onBackPressed(backBtnHandler: DefaultHardwareBackBtnHandler) {
143143
if(ReactNativeBrownfieldModule.shouldPopToNative) {
144144
backBtnHandler.invokeDefaultOnBackPressed()
145-
} else if (BridgeManager.shared.reactNativeHost.hasInstance()) {
146-
BridgeManager.shared.reactNativeHost.reactInstanceManager.onBackPressed()
145+
} else if (ReactNativeBrownfield.shared.reactNativeHost.hasInstance()) {
146+
ReactNativeBrownfield.shared.reactNativeHost.reactInstanceManager.onBackPressed()
147147
}
148148
}
149149

babel.config.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
module.exports = {
2+
presets: ['module:metro-react-native-babel-preset'],
3+
plugins: [
4+
[
5+
'module-resolver',
6+
{
7+
alias: {
8+
'@callstack/react-native-brownfield': './src',
9+
},
10+
},
11+
],
12+
],
13+
};

0 commit comments

Comments
 (0)