react-native-navigation 7.26.0-alpha.1 → 7.26.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/Mock/Components/NavigationButton.tsx +1 -0
- package/lib/Mock/mocks/NativeCommandsSender.tsx +16 -11
- package/lib/android/app/build.gradle +7 -11
- package/lib/android/app/src/main/java/com/reactnativenavigation/options/Orientation.java +2 -1
- package/lib/android/app/src/main/java/com/reactnativenavigation/options/OrientationOptions.java +2 -0
- package/lib/android/app/src/main/java/com/reactnativenavigation/react/NavigationModule.java +2 -2
- package/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/component/ComponentViewController.java +2 -1
- package/lib/android/app/src/{main → reactNative51}/java/com/reactnativenavigation/react/modal/ModalContentLayout.kt +0 -0
- package/lib/android/app/src/reactNative55/java/com/reactnativenavigation/react/modal/ModalContentLayout.kt +81 -0
- package/lib/android/app/src/reactNative56/java/com/reactnativenavigation/react/modal/ModalContentLayout.kt +81 -0
- package/lib/android/app/src/reactNative57/java/com/reactnativenavigation/react/modal/ModalContentLayout.kt +81 -0
- package/lib/android/app/src/reactNative57_5/java/com/reactnativenavigation/react/modal/ModalContentLayout.kt +81 -0
- package/lib/android/app/src/reactNative60/java/com/reactnativenavigation/react/modal/ModalContentLayout.kt +81 -0
- package/lib/android/app/src/reactNative62/java/com/reactnativenavigation/react/modal/ModalContentLayout.kt +81 -0
- package/lib/android/app/src/reactNative63/java/com/reactnativenavigation/react/modal/ModalContentLayout.kt +81 -0
- package/lib/android/app/src/reactNative68/java/com/reactnativenavigation/options/parsers/ColorParser.kt +38 -0
- package/lib/android/app/src/reactNative68/java/com/reactnativenavigation/react/DevBundleDownloadListenerAdapter.java +22 -0
- package/lib/android/app/src/reactNative68/java/com/reactnativenavigation/react/JsDevReloadHandlerFacade.java +22 -0
- package/lib/android/app/src/reactNative68/java/com/reactnativenavigation/react/NavigationReactNativeHost.java +66 -0
- package/lib/android/app/src/reactNative68/java/com/reactnativenavigation/react/ReactGateway.java +72 -0
- package/lib/android/app/src/reactNative68/java/com/reactnativenavigation/react/ReloadHandlerFacade.java +22 -0
- package/lib/android/app/src/reactNative68/java/com/reactnativenavigation/react/modal/ModalContentLayout.kt +87 -0
- package/lib/android/app/src/reactNative68/java/com/reactnativenavigation/viewcontrollers/viewcontroller/YellowBoxHelper.java +12 -0
- package/lib/dist/Mock/Components/NavigationButton.js +1 -1
- package/lib/dist/Mock/mocks/NativeCommandsSender.js +17 -11
- package/lib/dist/src/interfaces/Options.d.ts +1 -1
- package/lib/ios/RNNComponentRootView.m +14 -0
- package/lib/src/interfaces/Options.ts +6 -1
- package/package.json +1 -1
|
@@ -18,6 +18,7 @@ export const NavigationButton = class extends Component<ButtonProps> {
|
|
|
18
18
|
testID={button.testID}
|
|
19
19
|
key={button.id}
|
|
20
20
|
title={button.text || ''}
|
|
21
|
+
disabled={button.enabled === false}
|
|
21
22
|
onPress={() =>
|
|
22
23
|
button.enabled !== false &&
|
|
23
24
|
events.invokeNavigationButtonPressed({
|
|
@@ -77,17 +77,22 @@ export class NativeCommandsSender {
|
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
dismissModal(_commandId: string, componentId: string, _options?: object) {
|
|
80
|
-
return new Promise((resolve) => {
|
|
81
|
-
const modal = LayoutStore.getModalById(componentId)
|
|
82
|
-
modal
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
80
|
+
return new Promise((resolve, reject) => {
|
|
81
|
+
const modal = LayoutStore.getModalById(componentId);
|
|
82
|
+
if (modal) {
|
|
83
|
+
const modalTopParent = modal.getTopParent();
|
|
84
|
+
modalTopParent.componentDidDisappear();
|
|
85
|
+
LayoutStore.dismissModal(componentId);
|
|
86
|
+
events.invokeModalDismissed({
|
|
87
|
+
componentName: modalTopParent.data.name,
|
|
88
|
+
componentId: modalTopParent.nodeId,
|
|
89
|
+
modalsDismissed: 1,
|
|
90
|
+
});
|
|
91
|
+
resolve(modalTopParent.nodeId);
|
|
92
|
+
LayoutStore.getVisibleLayout().componentDidAppear();
|
|
93
|
+
} else {
|
|
94
|
+
reject(`component with id: ${componentId} is not a modal`);
|
|
95
|
+
}
|
|
91
96
|
});
|
|
92
97
|
}
|
|
93
98
|
|
|
@@ -106,6 +106,10 @@ android {
|
|
|
106
106
|
dimension "RNN.reactNativeVersion"
|
|
107
107
|
buildConfigField("int", "REACT_NATVE_VERSION_MINOR", "63")
|
|
108
108
|
}
|
|
109
|
+
reactNative68 {
|
|
110
|
+
dimension "RNN.reactNativeVersion"
|
|
111
|
+
buildConfigField("int", "REACT_NATVE_VERSION_MINOR", "68")
|
|
112
|
+
}
|
|
109
113
|
}
|
|
110
114
|
|
|
111
115
|
def flavor = resolveFlavor()
|
|
@@ -122,7 +126,9 @@ String resolveFlavor() {
|
|
|
122
126
|
Integer reactNativeMinorComponent = reactNativeVersionComponents[1].toInteger()
|
|
123
127
|
Integer reactNativePatchComponent = reactNativeVersionComponents[2].toInteger()
|
|
124
128
|
|
|
125
|
-
if (reactNativeMinorComponent >=
|
|
129
|
+
if (reactNativeMinorComponent >= 68) {
|
|
130
|
+
return "reactNative68"
|
|
131
|
+
} else if (reactNativeMinorComponent >= 63) {
|
|
126
132
|
return "reactNative63"
|
|
127
133
|
} else if (reactNativeMinorComponent >= 62) {
|
|
128
134
|
return "reactNative62"
|
|
@@ -161,16 +167,6 @@ List reactNativeVersionComponents(rnPackageJsonFile) {
|
|
|
161
167
|
return reactNativeVersion.tokenize('-')[0].tokenize('.')
|
|
162
168
|
}
|
|
163
169
|
|
|
164
|
-
allprojects { p ->
|
|
165
|
-
p.afterEvaluate {
|
|
166
|
-
p.android.compileOptions.sourceCompatibility JavaVersion.VERSION_1_8
|
|
167
|
-
p.android.compileOptions.targetCompatibility JavaVersion.VERSION_1_8
|
|
168
|
-
}
|
|
169
|
-
p.repositories {
|
|
170
|
-
maven { url "https://jitpack.io" }
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
|
|
174
170
|
dependencies {
|
|
175
171
|
|
|
176
172
|
implementation "androidx.core:core-ktx:1.6.0"
|
|
@@ -8,7 +8,8 @@ public enum Orientation {
|
|
|
8
8
|
Landscape("landscape", ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE),
|
|
9
9
|
Portrait("portrait", ActivityInfo.SCREEN_ORIENTATION_PORTRAIT),
|
|
10
10
|
PortraitLandscape("sensor", ActivityInfo.SCREEN_ORIENTATION_USER),
|
|
11
|
-
SensorLandscape("sensorLandscape", ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE)
|
|
11
|
+
SensorLandscape("sensorLandscape", ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE),
|
|
12
|
+
SensorPortrait("sensorPortrait", ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT);
|
|
12
13
|
|
|
13
14
|
public String name;
|
|
14
15
|
public int orientationCode;
|
package/lib/android/app/src/main/java/com/reactnativenavigation/options/OrientationOptions.java
CHANGED
|
@@ -44,6 +44,8 @@ public class OrientationOptions {
|
|
|
44
44
|
return orientations.contains(Orientation.Landscape) ? Orientation.PortraitLandscape.orientationCode : Orientation.Portrait.orientationCode;
|
|
45
45
|
case SensorLandscape:
|
|
46
46
|
return Orientation.SensorLandscape.orientationCode;
|
|
47
|
+
case SensorPortrait:
|
|
48
|
+
return Orientation.SensorPortrait.orientationCode;
|
|
47
49
|
default:
|
|
48
50
|
case Default:
|
|
49
51
|
return Orientation.Default.orientationCode;
|
|
@@ -59,7 +59,7 @@ public class NavigationModule extends ReactContextBaseJavaModule {
|
|
|
59
59
|
@Override
|
|
60
60
|
public void onHostPause() {
|
|
61
61
|
super.onHostPause();
|
|
62
|
-
navigator().onHostPause();
|
|
62
|
+
UiUtils.runOnMainThread(() -> navigator().onHostPause());
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
@Override
|
|
@@ -72,7 +72,7 @@ public class NavigationModule extends ReactContextBaseJavaModule {
|
|
|
72
72
|
navigator().getChildRegistry(),
|
|
73
73
|
((NavigationApplication) activity().getApplication()).getExternalComponents()
|
|
74
74
|
);
|
|
75
|
-
navigator().onHostResume();
|
|
75
|
+
UiUtils.runOnMainThread(() -> navigator().onHostResume());
|
|
76
76
|
}
|
|
77
77
|
});
|
|
78
78
|
}
|
|
@@ -81,7 +81,8 @@ public class ComponentViewController extends ChildController<ComponentLayout> {
|
|
|
81
81
|
if (view != null)
|
|
82
82
|
view.sendComponentWillStart();
|
|
83
83
|
super.onViewDidAppear();
|
|
84
|
-
view
|
|
84
|
+
if (view != null)
|
|
85
|
+
view.requestApplyInsets();
|
|
85
86
|
if (view != null && lastVisibilityState == VisibilityState.Disappear)
|
|
86
87
|
view.sendComponentStart();
|
|
87
88
|
lastVisibilityState = VisibilityState.Appear;
|
|
File without changes
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
package com.reactnativenavigation.react.modal
|
|
2
|
+
|
|
3
|
+
import android.content.Context
|
|
4
|
+
import android.view.MotionEvent
|
|
5
|
+
import android.view.View
|
|
6
|
+
import com.facebook.react.bridge.*
|
|
7
|
+
import com.facebook.react.uimanager.*
|
|
8
|
+
import com.facebook.react.uimanager.events.EventDispatcher
|
|
9
|
+
import com.facebook.react.views.view.ReactViewGroup
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class ModalContentLayout(context: Context?) : ReactViewGroup(context), RootView{
|
|
13
|
+
private var hasAdjustedSize = false
|
|
14
|
+
private var viewWidth = 0
|
|
15
|
+
private var viewHeight = 0
|
|
16
|
+
private val mJSTouchDispatcher = JSTouchDispatcher(this)
|
|
17
|
+
|
|
18
|
+
override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) {
|
|
19
|
+
super.onSizeChanged(w, h, oldw, oldh)
|
|
20
|
+
viewWidth = w
|
|
21
|
+
viewHeight = h
|
|
22
|
+
this.updateFirstChildView()
|
|
23
|
+
}
|
|
24
|
+
private fun updateFirstChildView() {
|
|
25
|
+
if (this.childCount > 0) {
|
|
26
|
+
hasAdjustedSize = false
|
|
27
|
+
val viewTag = getChildAt(0).id
|
|
28
|
+
val reactContext: ReactContext = this.getReactContext()
|
|
29
|
+
reactContext.runOnNativeModulesQueueThread(object : GuardedRunnable(reactContext) {
|
|
30
|
+
override fun runGuarded() {
|
|
31
|
+
val uiManager = this@ModalContentLayout.getReactContext().getNativeModule(
|
|
32
|
+
UIManagerModule::class.java
|
|
33
|
+
) as UIManagerModule
|
|
34
|
+
uiManager.updateNodeSize(
|
|
35
|
+
viewTag,
|
|
36
|
+
this@ModalContentLayout.viewWidth,
|
|
37
|
+
this@ModalContentLayout.viewHeight
|
|
38
|
+
)
|
|
39
|
+
}
|
|
40
|
+
})
|
|
41
|
+
} else {
|
|
42
|
+
hasAdjustedSize = true
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
override fun addView(child: View?, index: Int, params: LayoutParams?) {
|
|
47
|
+
super.addView(child, index, params)
|
|
48
|
+
if (hasAdjustedSize) {
|
|
49
|
+
updateFirstChildView()
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
override fun onChildStartedNativeGesture(androidEvent: MotionEvent?) {
|
|
53
|
+
mJSTouchDispatcher.onChildStartedNativeGesture(androidEvent, this.getEventDispatcher())
|
|
54
|
+
}
|
|
55
|
+
override fun requestDisallowInterceptTouchEvent(disallowIntercept: Boolean) {}
|
|
56
|
+
private fun getEventDispatcher(): EventDispatcher? {
|
|
57
|
+
val reactContext: ReactContext = this.getReactContext()
|
|
58
|
+
return reactContext.getNativeModule(UIManagerModule::class.java)!!.eventDispatcher
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
override fun handleException(t: Throwable?) {
|
|
63
|
+
getReactContext().handleException(RuntimeException(t))
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
private fun getReactContext(): ReactContext {
|
|
67
|
+
return this.context as ReactContext
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
override fun onInterceptTouchEvent(event: MotionEvent?): Boolean {
|
|
71
|
+
mJSTouchDispatcher.handleTouchEvent(event, getEventDispatcher())
|
|
72
|
+
return super.onInterceptTouchEvent(event)
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
override fun onTouchEvent(event: MotionEvent?): Boolean {
|
|
76
|
+
mJSTouchDispatcher.handleTouchEvent(event, getEventDispatcher())
|
|
77
|
+
super.onTouchEvent(event)
|
|
78
|
+
return true
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
package com.reactnativenavigation.react.modal
|
|
2
|
+
|
|
3
|
+
import android.content.Context
|
|
4
|
+
import android.view.MotionEvent
|
|
5
|
+
import android.view.View
|
|
6
|
+
import com.facebook.react.bridge.*
|
|
7
|
+
import com.facebook.react.uimanager.*
|
|
8
|
+
import com.facebook.react.uimanager.events.EventDispatcher
|
|
9
|
+
import com.facebook.react.views.view.ReactViewGroup
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class ModalContentLayout(context: Context?) : ReactViewGroup(context), RootView{
|
|
13
|
+
private var hasAdjustedSize = false
|
|
14
|
+
private var viewWidth = 0
|
|
15
|
+
private var viewHeight = 0
|
|
16
|
+
private val mJSTouchDispatcher = JSTouchDispatcher(this)
|
|
17
|
+
|
|
18
|
+
override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) {
|
|
19
|
+
super.onSizeChanged(w, h, oldw, oldh)
|
|
20
|
+
viewWidth = w
|
|
21
|
+
viewHeight = h
|
|
22
|
+
this.updateFirstChildView()
|
|
23
|
+
}
|
|
24
|
+
private fun updateFirstChildView() {
|
|
25
|
+
if (this.childCount > 0) {
|
|
26
|
+
hasAdjustedSize = false
|
|
27
|
+
val viewTag = getChildAt(0).id
|
|
28
|
+
val reactContext: ReactContext = this.getReactContext()
|
|
29
|
+
reactContext.runOnNativeModulesQueueThread(object : GuardedRunnable(reactContext) {
|
|
30
|
+
override fun runGuarded() {
|
|
31
|
+
val uiManager = this@ModalContentLayout.getReactContext().getNativeModule(
|
|
32
|
+
UIManagerModule::class.java
|
|
33
|
+
) as UIManagerModule
|
|
34
|
+
uiManager.updateNodeSize(
|
|
35
|
+
viewTag,
|
|
36
|
+
this@ModalContentLayout.viewWidth,
|
|
37
|
+
this@ModalContentLayout.viewHeight
|
|
38
|
+
)
|
|
39
|
+
}
|
|
40
|
+
})
|
|
41
|
+
} else {
|
|
42
|
+
hasAdjustedSize = true
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
override fun addView(child: View?, index: Int, params: LayoutParams?) {
|
|
47
|
+
super.addView(child, index, params)
|
|
48
|
+
if (hasAdjustedSize) {
|
|
49
|
+
updateFirstChildView()
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
override fun onChildStartedNativeGesture(androidEvent: MotionEvent?) {
|
|
53
|
+
mJSTouchDispatcher.onChildStartedNativeGesture(androidEvent, this.getEventDispatcher())
|
|
54
|
+
}
|
|
55
|
+
override fun requestDisallowInterceptTouchEvent(disallowIntercept: Boolean) {}
|
|
56
|
+
private fun getEventDispatcher(): EventDispatcher? {
|
|
57
|
+
val reactContext: ReactContext = this.getReactContext()
|
|
58
|
+
return reactContext.getNativeModule(UIManagerModule::class.java)!!.eventDispatcher
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
override fun handleException(t: Throwable?) {
|
|
63
|
+
getReactContext().handleException(RuntimeException(t))
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
private fun getReactContext(): ReactContext {
|
|
67
|
+
return this.context as ReactContext
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
override fun onInterceptTouchEvent(event: MotionEvent?): Boolean {
|
|
71
|
+
mJSTouchDispatcher.handleTouchEvent(event, getEventDispatcher())
|
|
72
|
+
return super.onInterceptTouchEvent(event)
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
override fun onTouchEvent(event: MotionEvent?): Boolean {
|
|
76
|
+
mJSTouchDispatcher.handleTouchEvent(event, getEventDispatcher())
|
|
77
|
+
super.onTouchEvent(event)
|
|
78
|
+
return true
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
package com.reactnativenavigation.react.modal
|
|
2
|
+
|
|
3
|
+
import android.content.Context
|
|
4
|
+
import android.view.MotionEvent
|
|
5
|
+
import android.view.View
|
|
6
|
+
import com.facebook.react.bridge.*
|
|
7
|
+
import com.facebook.react.uimanager.*
|
|
8
|
+
import com.facebook.react.uimanager.events.EventDispatcher
|
|
9
|
+
import com.facebook.react.views.view.ReactViewGroup
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class ModalContentLayout(context: Context?) : ReactViewGroup(context), RootView{
|
|
13
|
+
private var hasAdjustedSize = false
|
|
14
|
+
private var viewWidth = 0
|
|
15
|
+
private var viewHeight = 0
|
|
16
|
+
private val mJSTouchDispatcher = JSTouchDispatcher(this)
|
|
17
|
+
|
|
18
|
+
override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) {
|
|
19
|
+
super.onSizeChanged(w, h, oldw, oldh)
|
|
20
|
+
viewWidth = w
|
|
21
|
+
viewHeight = h
|
|
22
|
+
this.updateFirstChildView()
|
|
23
|
+
}
|
|
24
|
+
private fun updateFirstChildView() {
|
|
25
|
+
if (this.childCount > 0) {
|
|
26
|
+
hasAdjustedSize = false
|
|
27
|
+
val viewTag = getChildAt(0).id
|
|
28
|
+
val reactContext: ReactContext = this.getReactContext()
|
|
29
|
+
reactContext.runOnNativeModulesQueueThread(object : GuardedRunnable(reactContext) {
|
|
30
|
+
override fun runGuarded() {
|
|
31
|
+
val uiManager = this@ModalContentLayout.getReactContext().getNativeModule(
|
|
32
|
+
UIManagerModule::class.java
|
|
33
|
+
) as UIManagerModule
|
|
34
|
+
uiManager.updateNodeSize(
|
|
35
|
+
viewTag,
|
|
36
|
+
this@ModalContentLayout.viewWidth,
|
|
37
|
+
this@ModalContentLayout.viewHeight
|
|
38
|
+
)
|
|
39
|
+
}
|
|
40
|
+
})
|
|
41
|
+
} else {
|
|
42
|
+
hasAdjustedSize = true
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
override fun addView(child: View?, index: Int, params: LayoutParams?) {
|
|
47
|
+
super.addView(child, index, params)
|
|
48
|
+
if (hasAdjustedSize) {
|
|
49
|
+
updateFirstChildView()
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
override fun onChildStartedNativeGesture(androidEvent: MotionEvent?) {
|
|
53
|
+
mJSTouchDispatcher.onChildStartedNativeGesture(androidEvent, this.getEventDispatcher())
|
|
54
|
+
}
|
|
55
|
+
override fun requestDisallowInterceptTouchEvent(disallowIntercept: Boolean) {}
|
|
56
|
+
private fun getEventDispatcher(): EventDispatcher? {
|
|
57
|
+
val reactContext: ReactContext = this.getReactContext()
|
|
58
|
+
return reactContext.getNativeModule(UIManagerModule::class.java)!!.eventDispatcher
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
override fun handleException(t: Throwable?) {
|
|
63
|
+
getReactContext().handleException(RuntimeException(t))
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
private fun getReactContext(): ReactContext {
|
|
67
|
+
return this.context as ReactContext
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
override fun onInterceptTouchEvent(event: MotionEvent?): Boolean {
|
|
71
|
+
mJSTouchDispatcher.handleTouchEvent(event, getEventDispatcher())
|
|
72
|
+
return super.onInterceptTouchEvent(event)
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
override fun onTouchEvent(event: MotionEvent?): Boolean {
|
|
76
|
+
mJSTouchDispatcher.handleTouchEvent(event, getEventDispatcher())
|
|
77
|
+
super.onTouchEvent(event)
|
|
78
|
+
return true
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
package com.reactnativenavigation.react.modal
|
|
2
|
+
|
|
3
|
+
import android.content.Context
|
|
4
|
+
import android.view.MotionEvent
|
|
5
|
+
import android.view.View
|
|
6
|
+
import com.facebook.react.bridge.*
|
|
7
|
+
import com.facebook.react.uimanager.*
|
|
8
|
+
import com.facebook.react.uimanager.events.EventDispatcher
|
|
9
|
+
import com.facebook.react.views.view.ReactViewGroup
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class ModalContentLayout(context: Context?) : ReactViewGroup(context), RootView{
|
|
13
|
+
private var hasAdjustedSize = false
|
|
14
|
+
private var viewWidth = 0
|
|
15
|
+
private var viewHeight = 0
|
|
16
|
+
private val mJSTouchDispatcher = JSTouchDispatcher(this)
|
|
17
|
+
|
|
18
|
+
override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) {
|
|
19
|
+
super.onSizeChanged(w, h, oldw, oldh)
|
|
20
|
+
viewWidth = w
|
|
21
|
+
viewHeight = h
|
|
22
|
+
this.updateFirstChildView()
|
|
23
|
+
}
|
|
24
|
+
private fun updateFirstChildView() {
|
|
25
|
+
if (this.childCount > 0) {
|
|
26
|
+
hasAdjustedSize = false
|
|
27
|
+
val viewTag = getChildAt(0).id
|
|
28
|
+
val reactContext: ReactContext = this.getReactContext()
|
|
29
|
+
reactContext.runOnNativeModulesQueueThread(object : GuardedRunnable(reactContext) {
|
|
30
|
+
override fun runGuarded() {
|
|
31
|
+
val uiManager = this@ModalContentLayout.getReactContext().getNativeModule(
|
|
32
|
+
UIManagerModule::class.java
|
|
33
|
+
) as UIManagerModule
|
|
34
|
+
uiManager.updateNodeSize(
|
|
35
|
+
viewTag,
|
|
36
|
+
this@ModalContentLayout.viewWidth,
|
|
37
|
+
this@ModalContentLayout.viewHeight
|
|
38
|
+
)
|
|
39
|
+
}
|
|
40
|
+
})
|
|
41
|
+
} else {
|
|
42
|
+
hasAdjustedSize = true
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
override fun addView(child: View?, index: Int, params: LayoutParams?) {
|
|
47
|
+
super.addView(child, index, params)
|
|
48
|
+
if (hasAdjustedSize) {
|
|
49
|
+
updateFirstChildView()
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
override fun onChildStartedNativeGesture(androidEvent: MotionEvent?) {
|
|
53
|
+
mJSTouchDispatcher.onChildStartedNativeGesture(androidEvent, this.getEventDispatcher())
|
|
54
|
+
}
|
|
55
|
+
override fun requestDisallowInterceptTouchEvent(disallowIntercept: Boolean) {}
|
|
56
|
+
private fun getEventDispatcher(): EventDispatcher? {
|
|
57
|
+
val reactContext: ReactContext = this.getReactContext()
|
|
58
|
+
return reactContext.getNativeModule(UIManagerModule::class.java)!!.eventDispatcher
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
override fun handleException(t: Throwable?) {
|
|
63
|
+
getReactContext().handleException(RuntimeException(t))
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
private fun getReactContext(): ReactContext {
|
|
67
|
+
return this.context as ReactContext
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
override fun onInterceptTouchEvent(event: MotionEvent?): Boolean {
|
|
71
|
+
mJSTouchDispatcher.handleTouchEvent(event, getEventDispatcher())
|
|
72
|
+
return super.onInterceptTouchEvent(event)
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
override fun onTouchEvent(event: MotionEvent?): Boolean {
|
|
76
|
+
mJSTouchDispatcher.handleTouchEvent(event, getEventDispatcher())
|
|
77
|
+
super.onTouchEvent(event)
|
|
78
|
+
return true
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
package com.reactnativenavigation.react.modal
|
|
2
|
+
|
|
3
|
+
import android.content.Context
|
|
4
|
+
import android.view.MotionEvent
|
|
5
|
+
import android.view.View
|
|
6
|
+
import com.facebook.react.bridge.*
|
|
7
|
+
import com.facebook.react.uimanager.*
|
|
8
|
+
import com.facebook.react.uimanager.events.EventDispatcher
|
|
9
|
+
import com.facebook.react.views.view.ReactViewGroup
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class ModalContentLayout(context: Context?) : ReactViewGroup(context), RootView{
|
|
13
|
+
private var hasAdjustedSize = false
|
|
14
|
+
private var viewWidth = 0
|
|
15
|
+
private var viewHeight = 0
|
|
16
|
+
private val mJSTouchDispatcher = JSTouchDispatcher(this)
|
|
17
|
+
|
|
18
|
+
override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) {
|
|
19
|
+
super.onSizeChanged(w, h, oldw, oldh)
|
|
20
|
+
viewWidth = w
|
|
21
|
+
viewHeight = h
|
|
22
|
+
this.updateFirstChildView()
|
|
23
|
+
}
|
|
24
|
+
private fun updateFirstChildView() {
|
|
25
|
+
if (this.childCount > 0) {
|
|
26
|
+
hasAdjustedSize = false
|
|
27
|
+
val viewTag = getChildAt(0).id
|
|
28
|
+
val reactContext: ReactContext = this.getReactContext()
|
|
29
|
+
reactContext.runOnNativeModulesQueueThread(object : GuardedRunnable(reactContext) {
|
|
30
|
+
override fun runGuarded() {
|
|
31
|
+
val uiManager = this@ModalContentLayout.getReactContext().getNativeModule(
|
|
32
|
+
UIManagerModule::class.java
|
|
33
|
+
) as UIManagerModule
|
|
34
|
+
uiManager.updateNodeSize(
|
|
35
|
+
viewTag,
|
|
36
|
+
this@ModalContentLayout.viewWidth,
|
|
37
|
+
this@ModalContentLayout.viewHeight
|
|
38
|
+
)
|
|
39
|
+
}
|
|
40
|
+
})
|
|
41
|
+
} else {
|
|
42
|
+
hasAdjustedSize = true
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
override fun addView(child: View?, index: Int, params: LayoutParams?) {
|
|
47
|
+
super.addView(child, index, params)
|
|
48
|
+
if (hasAdjustedSize) {
|
|
49
|
+
updateFirstChildView()
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
override fun onChildStartedNativeGesture(androidEvent: MotionEvent?) {
|
|
53
|
+
mJSTouchDispatcher.onChildStartedNativeGesture(androidEvent, this.getEventDispatcher())
|
|
54
|
+
}
|
|
55
|
+
override fun requestDisallowInterceptTouchEvent(disallowIntercept: Boolean) {}
|
|
56
|
+
private fun getEventDispatcher(): EventDispatcher? {
|
|
57
|
+
val reactContext: ReactContext = this.getReactContext()
|
|
58
|
+
return reactContext.getNativeModule(UIManagerModule::class.java)!!.eventDispatcher
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
override fun handleException(t: Throwable?) {
|
|
63
|
+
getReactContext().handleException(RuntimeException(t))
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
private fun getReactContext(): ReactContext {
|
|
67
|
+
return this.context as ReactContext
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
override fun onInterceptTouchEvent(event: MotionEvent?): Boolean {
|
|
71
|
+
mJSTouchDispatcher.handleTouchEvent(event, getEventDispatcher())
|
|
72
|
+
return super.onInterceptTouchEvent(event)
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
override fun onTouchEvent(event: MotionEvent?): Boolean {
|
|
76
|
+
mJSTouchDispatcher.handleTouchEvent(event, getEventDispatcher())
|
|
77
|
+
super.onTouchEvent(event)
|
|
78
|
+
return true
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
package com.reactnativenavigation.react.modal
|
|
2
|
+
|
|
3
|
+
import android.content.Context
|
|
4
|
+
import android.view.MotionEvent
|
|
5
|
+
import android.view.View
|
|
6
|
+
import com.facebook.react.bridge.*
|
|
7
|
+
import com.facebook.react.uimanager.*
|
|
8
|
+
import com.facebook.react.uimanager.events.EventDispatcher
|
|
9
|
+
import com.facebook.react.views.view.ReactViewGroup
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class ModalContentLayout(context: Context?) : ReactViewGroup(context), RootView{
|
|
13
|
+
private var hasAdjustedSize = false
|
|
14
|
+
private var viewWidth = 0
|
|
15
|
+
private var viewHeight = 0
|
|
16
|
+
private val mJSTouchDispatcher = JSTouchDispatcher(this)
|
|
17
|
+
|
|
18
|
+
override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) {
|
|
19
|
+
super.onSizeChanged(w, h, oldw, oldh)
|
|
20
|
+
viewWidth = w
|
|
21
|
+
viewHeight = h
|
|
22
|
+
this.updateFirstChildView()
|
|
23
|
+
}
|
|
24
|
+
private fun updateFirstChildView() {
|
|
25
|
+
if (this.childCount > 0) {
|
|
26
|
+
hasAdjustedSize = false
|
|
27
|
+
val viewTag = getChildAt(0).id
|
|
28
|
+
val reactContext: ReactContext = this.getReactContext()
|
|
29
|
+
reactContext.runOnNativeModulesQueueThread(object : GuardedRunnable(reactContext) {
|
|
30
|
+
override fun runGuarded() {
|
|
31
|
+
val uiManager = this@ModalContentLayout.getReactContext().getNativeModule(
|
|
32
|
+
UIManagerModule::class.java
|
|
33
|
+
) as UIManagerModule
|
|
34
|
+
uiManager.updateNodeSize(
|
|
35
|
+
viewTag,
|
|
36
|
+
this@ModalContentLayout.viewWidth,
|
|
37
|
+
this@ModalContentLayout.viewHeight
|
|
38
|
+
)
|
|
39
|
+
}
|
|
40
|
+
})
|
|
41
|
+
} else {
|
|
42
|
+
hasAdjustedSize = true
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
override fun addView(child: View?, index: Int, params: LayoutParams?) {
|
|
47
|
+
super.addView(child, index, params)
|
|
48
|
+
if (hasAdjustedSize) {
|
|
49
|
+
updateFirstChildView()
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
override fun onChildStartedNativeGesture(androidEvent: MotionEvent?) {
|
|
53
|
+
mJSTouchDispatcher.onChildStartedNativeGesture(androidEvent, this.getEventDispatcher())
|
|
54
|
+
}
|
|
55
|
+
override fun requestDisallowInterceptTouchEvent(disallowIntercept: Boolean) {}
|
|
56
|
+
private fun getEventDispatcher(): EventDispatcher? {
|
|
57
|
+
val reactContext: ReactContext = this.getReactContext()
|
|
58
|
+
return reactContext.getNativeModule(UIManagerModule::class.java)!!.eventDispatcher
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
override fun handleException(t: Throwable?) {
|
|
63
|
+
getReactContext().handleException(RuntimeException(t))
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
private fun getReactContext(): ReactContext {
|
|
67
|
+
return this.context as ReactContext
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
override fun onInterceptTouchEvent(event: MotionEvent?): Boolean {
|
|
71
|
+
mJSTouchDispatcher.handleTouchEvent(event, getEventDispatcher())
|
|
72
|
+
return super.onInterceptTouchEvent(event)
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
override fun onTouchEvent(event: MotionEvent?): Boolean {
|
|
76
|
+
mJSTouchDispatcher.handleTouchEvent(event, getEventDispatcher())
|
|
77
|
+
super.onTouchEvent(event)
|
|
78
|
+
return true
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
package com.reactnativenavigation.react.modal
|
|
2
|
+
|
|
3
|
+
import android.content.Context
|
|
4
|
+
import android.view.MotionEvent
|
|
5
|
+
import android.view.View
|
|
6
|
+
import com.facebook.react.bridge.*
|
|
7
|
+
import com.facebook.react.uimanager.*
|
|
8
|
+
import com.facebook.react.uimanager.events.EventDispatcher
|
|
9
|
+
import com.facebook.react.views.view.ReactViewGroup
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class ModalContentLayout(context: Context?) : ReactViewGroup(context), RootView{
|
|
13
|
+
private var hasAdjustedSize = false
|
|
14
|
+
private var viewWidth = 0
|
|
15
|
+
private var viewHeight = 0
|
|
16
|
+
private val mJSTouchDispatcher = JSTouchDispatcher(this)
|
|
17
|
+
|
|
18
|
+
override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) {
|
|
19
|
+
super.onSizeChanged(w, h, oldw, oldh)
|
|
20
|
+
viewWidth = w
|
|
21
|
+
viewHeight = h
|
|
22
|
+
this.updateFirstChildView()
|
|
23
|
+
}
|
|
24
|
+
private fun updateFirstChildView() {
|
|
25
|
+
if (this.childCount > 0) {
|
|
26
|
+
hasAdjustedSize = false
|
|
27
|
+
val viewTag = getChildAt(0).id
|
|
28
|
+
val reactContext: ReactContext = this.getReactContext()
|
|
29
|
+
reactContext.runOnNativeModulesQueueThread(object : GuardedRunnable(reactContext) {
|
|
30
|
+
override fun runGuarded() {
|
|
31
|
+
val uiManager = this@ModalContentLayout.getReactContext().getNativeModule(
|
|
32
|
+
UIManagerModule::class.java
|
|
33
|
+
) as UIManagerModule
|
|
34
|
+
uiManager.updateNodeSize(
|
|
35
|
+
viewTag,
|
|
36
|
+
this@ModalContentLayout.viewWidth,
|
|
37
|
+
this@ModalContentLayout.viewHeight
|
|
38
|
+
)
|
|
39
|
+
}
|
|
40
|
+
})
|
|
41
|
+
} else {
|
|
42
|
+
hasAdjustedSize = true
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
override fun addView(child: View?, index: Int, params: LayoutParams?) {
|
|
47
|
+
super.addView(child, index, params)
|
|
48
|
+
if (hasAdjustedSize) {
|
|
49
|
+
updateFirstChildView()
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
override fun onChildStartedNativeGesture(androidEvent: MotionEvent?) {
|
|
53
|
+
mJSTouchDispatcher.onChildStartedNativeGesture(androidEvent, this.getEventDispatcher())
|
|
54
|
+
}
|
|
55
|
+
override fun requestDisallowInterceptTouchEvent(disallowIntercept: Boolean) {}
|
|
56
|
+
private fun getEventDispatcher(): EventDispatcher? {
|
|
57
|
+
val reactContext: ReactContext = this.getReactContext()
|
|
58
|
+
return reactContext.getNativeModule(UIManagerModule::class.java)!!.eventDispatcher
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
override fun handleException(t: Throwable?) {
|
|
63
|
+
getReactContext().handleException(RuntimeException(t))
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
private fun getReactContext(): ReactContext {
|
|
67
|
+
return this.context as ReactContext
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
override fun onInterceptTouchEvent(event: MotionEvent?): Boolean {
|
|
71
|
+
mJSTouchDispatcher.handleTouchEvent(event, getEventDispatcher())
|
|
72
|
+
return super.onInterceptTouchEvent(event)
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
override fun onTouchEvent(event: MotionEvent?): Boolean {
|
|
76
|
+
mJSTouchDispatcher.handleTouchEvent(event, getEventDispatcher())
|
|
77
|
+
super.onTouchEvent(event)
|
|
78
|
+
return true
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
package com.reactnativenavigation.options.parsers
|
|
2
|
+
|
|
3
|
+
import android.content.Context
|
|
4
|
+
import com.facebook.react.bridge.ColorPropConverter
|
|
5
|
+
import com.reactnativenavigation.options.params.Colour
|
|
6
|
+
import com.reactnativenavigation.options.params.DontApplyColour
|
|
7
|
+
import com.reactnativenavigation.options.params.NullColor
|
|
8
|
+
import com.reactnativenavigation.options.params.ReactPlatformColor
|
|
9
|
+
import org.json.JSONObject
|
|
10
|
+
|
|
11
|
+
object ColorParser {
|
|
12
|
+
private const val KEY_RESOURCE_PATHS = "resource_paths"
|
|
13
|
+
private const val VAL_NO_COLOR = "NoColor"
|
|
14
|
+
|
|
15
|
+
@JvmStatic
|
|
16
|
+
fun parse(context: Context?, json: JSONObject, colorName: String?): Colour {
|
|
17
|
+
if (json.has(KEY_RESOURCE_PATHS)) {
|
|
18
|
+
return ReactPlatformColor(JSONParser.convert(json))
|
|
19
|
+
}
|
|
20
|
+
return when (val color = json.opt(colorName)) {
|
|
21
|
+
null, VAL_NO_COLOR -> {
|
|
22
|
+
DontApplyColour()
|
|
23
|
+
}
|
|
24
|
+
is Int -> {
|
|
25
|
+
Colour(json.optInt(colorName))
|
|
26
|
+
}
|
|
27
|
+
is JSONObject -> {
|
|
28
|
+
ColorPropConverter.getColor(color, context)?.let {
|
|
29
|
+
Colour(it)
|
|
30
|
+
} ?: NullColor()
|
|
31
|
+
}
|
|
32
|
+
else -> {
|
|
33
|
+
NullColor()
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
package com.reactnativenavigation.react;
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.devsupport.interfaces.DevBundleDownloadListener;
|
|
4
|
+
|
|
5
|
+
import javax.annotation.Nullable;
|
|
6
|
+
|
|
7
|
+
public class DevBundleDownloadListenerAdapter implements DevBundleDownloadListener, NavigationDevBundleDownloadListener {
|
|
8
|
+
@Override
|
|
9
|
+
public void onSuccess() {
|
|
10
|
+
onSuccess();
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
@Override
|
|
14
|
+
public void onProgress(@Nullable String status, @Nullable Integer done, @Nullable Integer total) {
|
|
15
|
+
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
@Override
|
|
19
|
+
public void onFailure(Exception cause) {
|
|
20
|
+
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
package com.reactnativenavigation.react;
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.devsupport.interfaces.DevBundleDownloadListener;
|
|
4
|
+
|
|
5
|
+
import javax.annotation.Nullable;
|
|
6
|
+
|
|
7
|
+
public class JsDevReloadHandlerFacade implements DevBundleDownloadListener, NavigationDevBundleDownloadListener {
|
|
8
|
+
@Override
|
|
9
|
+
public void onSuccess() {
|
|
10
|
+
onSuccess();
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
@Override
|
|
14
|
+
public void onProgress(@Nullable String status, @Nullable Integer done, @Nullable Integer total) {
|
|
15
|
+
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
@Override
|
|
19
|
+
public void onFailure(Exception cause) {
|
|
20
|
+
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
package com.reactnativenavigation.react;
|
|
2
|
+
|
|
3
|
+
import com.facebook.infer.annotation.Assertions;
|
|
4
|
+
import com.facebook.react.ReactInstanceManager;
|
|
5
|
+
import com.facebook.react.ReactInstanceManagerBuilder;
|
|
6
|
+
import com.facebook.react.ReactNativeHost;
|
|
7
|
+
import com.facebook.react.ReactPackage;
|
|
8
|
+
import com.facebook.react.common.LifecycleState;
|
|
9
|
+
import com.facebook.react.devsupport.interfaces.DevBundleDownloadListener;
|
|
10
|
+
import com.reactnativenavigation.NavigationApplication;
|
|
11
|
+
|
|
12
|
+
import androidx.annotation.NonNull;
|
|
13
|
+
import androidx.annotation.Nullable;
|
|
14
|
+
|
|
15
|
+
public abstract class NavigationReactNativeHost extends ReactNativeHost implements BundleDownloadListenerProvider {
|
|
16
|
+
|
|
17
|
+
private @Nullable NavigationDevBundleDownloadListener bundleListener;
|
|
18
|
+
private final DevBundleDownloadListener bundleListenerMediator = new DevBundleDownloadListenerAdapter() {
|
|
19
|
+
@Override
|
|
20
|
+
public void onSuccess() {
|
|
21
|
+
if (bundleListener != null) {
|
|
22
|
+
bundleListener.onSuccess();
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
public NavigationReactNativeHost(NavigationApplication application) {
|
|
28
|
+
super(application);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
@Override
|
|
32
|
+
public void setBundleLoaderListener(NavigationDevBundleDownloadListener listener) {
|
|
33
|
+
bundleListener = listener;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
protected ReactInstanceManager createReactInstanceManager() {
|
|
37
|
+
ReactInstanceManagerBuilder builder = ReactInstanceManager.builder()
|
|
38
|
+
.setApplication(getApplication())
|
|
39
|
+
.setJSMainModulePath(getJSMainModuleName())
|
|
40
|
+
.setUseDeveloperSupport(getUseDeveloperSupport())
|
|
41
|
+
.setRedBoxHandler(getRedBoxHandler())
|
|
42
|
+
.setJavaScriptExecutorFactory(getJavaScriptExecutorFactory())
|
|
43
|
+
.setUIImplementationProvider(getUIImplementationProvider())
|
|
44
|
+
.setInitialLifecycleState(LifecycleState.BEFORE_CREATE)
|
|
45
|
+
.setJSIModulesPackage(getJSIModulePackage())
|
|
46
|
+
.setDevBundleDownloadListener(getDevBundleDownloadListener());
|
|
47
|
+
|
|
48
|
+
for (ReactPackage reactPackage : getPackages()) {
|
|
49
|
+
builder.addPackage(reactPackage);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
String jsBundleFile = getJSBundleFile();
|
|
53
|
+
if (jsBundleFile != null) {
|
|
54
|
+
builder.setJSBundleFile(jsBundleFile);
|
|
55
|
+
} else {
|
|
56
|
+
builder.setBundleAssetName(Assertions.assertNotNull(getBundleAssetName()));
|
|
57
|
+
}
|
|
58
|
+
return builder.build();
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
@SuppressWarnings("WeakerAccess")
|
|
62
|
+
@NonNull
|
|
63
|
+
protected DevBundleDownloadListener getDevBundleDownloadListener() {
|
|
64
|
+
return bundleListenerMediator;
|
|
65
|
+
}
|
|
66
|
+
}
|
package/lib/android/app/src/reactNative68/java/com/reactnativenavigation/react/ReactGateway.java
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
package com.reactnativenavigation.react;
|
|
2
|
+
|
|
3
|
+
import android.app.Activity;
|
|
4
|
+
import android.content.Intent;
|
|
5
|
+
import android.content.res.Configuration;
|
|
6
|
+
|
|
7
|
+
import com.facebook.react.ReactNativeHost;
|
|
8
|
+
import com.reactnativenavigation.NavigationActivity;
|
|
9
|
+
|
|
10
|
+
import androidx.annotation.NonNull;
|
|
11
|
+
|
|
12
|
+
public class ReactGateway {
|
|
13
|
+
|
|
14
|
+
private final ReactNativeHost host;
|
|
15
|
+
private final NavigationReactInitializer initializer;
|
|
16
|
+
private final JsDevReloadHandler jsDevReloadHandler;
|
|
17
|
+
|
|
18
|
+
public ReactGateway(ReactNativeHost host) {
|
|
19
|
+
this.host = host;
|
|
20
|
+
initializer = new NavigationReactInitializer(host.getReactInstanceManager(), host.getUseDeveloperSupport());
|
|
21
|
+
jsDevReloadHandler = new JsDevReloadHandler(host.getReactInstanceManager().getDevSupportManager());
|
|
22
|
+
if (host instanceof BundleDownloadListenerProvider) {
|
|
23
|
+
((BundleDownloadListenerProvider) host).setBundleLoaderListener(jsDevReloadHandler);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
public void onActivityCreated(NavigationActivity activity) {
|
|
28
|
+
initializer.onActivityCreated();
|
|
29
|
+
jsDevReloadHandler.setReloadListener(activity);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
public void onActivityResumed(NavigationActivity activity) {
|
|
33
|
+
initializer.onActivityResumed(activity);
|
|
34
|
+
jsDevReloadHandler.onActivityResumed(activity);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
public boolean onNewIntent(Intent intent) {
|
|
38
|
+
if (host.hasInstance()) {
|
|
39
|
+
host.getReactInstanceManager().onNewIntent(intent);
|
|
40
|
+
return true;
|
|
41
|
+
}
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
public void onConfigurationChanged(NavigationActivity activity, @NonNull Configuration newConfig) {
|
|
46
|
+
if (host.hasInstance()) {
|
|
47
|
+
host.getReactInstanceManager().onConfigurationChanged(activity, newConfig);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
public void onActivityPaused(NavigationActivity activity) {
|
|
52
|
+
initializer.onActivityPaused(activity);
|
|
53
|
+
jsDevReloadHandler.onActivityPaused(activity);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
public void onActivityDestroyed(NavigationActivity activity) {
|
|
57
|
+
jsDevReloadHandler.removeReloadListener(activity);
|
|
58
|
+
initializer.onActivityDestroyed(activity);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
public boolean onKeyUp(Activity activity, int keyCode) {
|
|
62
|
+
return jsDevReloadHandler.onKeyUp(activity, keyCode);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
public void onBackPressed() {
|
|
66
|
+
host.getReactInstanceManager().onBackPressed();
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
public void onActivityResult(Activity activity, int requestCode, int resultCode, Intent data) {
|
|
70
|
+
host.getReactInstanceManager().onActivityResult(activity, requestCode, resultCode, data);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
package com.reactnativenavigation.react;
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.devsupport.interfaces.DevBundleDownloadListener;
|
|
4
|
+
|
|
5
|
+
import javax.annotation.Nullable;
|
|
6
|
+
|
|
7
|
+
public abstract class ReloadHandlerFacade implements DevBundleDownloadListener {
|
|
8
|
+
@Override
|
|
9
|
+
public void onSuccess() {
|
|
10
|
+
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
@Override
|
|
14
|
+
public void onProgress(@Nullable String status, @Nullable Integer done, @Nullable Integer total) {
|
|
15
|
+
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
@Override
|
|
19
|
+
public void onFailure(Exception cause) {
|
|
20
|
+
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
package com.reactnativenavigation.react.modal
|
|
2
|
+
|
|
3
|
+
import android.content.Context
|
|
4
|
+
import android.view.MotionEvent
|
|
5
|
+
import android.view.View
|
|
6
|
+
import com.facebook.react.bridge.*
|
|
7
|
+
import com.facebook.react.uimanager.*
|
|
8
|
+
import com.facebook.react.uimanager.events.EventDispatcher
|
|
9
|
+
import com.facebook.react.views.view.ReactViewGroup
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class ModalContentLayout(context: Context?) : ReactViewGroup(context), RootView{
|
|
13
|
+
private var hasAdjustedSize = false
|
|
14
|
+
private var viewWidth = 0
|
|
15
|
+
private var viewHeight = 0
|
|
16
|
+
private val mJSTouchDispatcher = JSTouchDispatcher(this)
|
|
17
|
+
|
|
18
|
+
override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) {
|
|
19
|
+
super.onSizeChanged(w, h, oldw, oldh)
|
|
20
|
+
viewWidth = w
|
|
21
|
+
viewHeight = h
|
|
22
|
+
this.updateFirstChildView()
|
|
23
|
+
}
|
|
24
|
+
private fun updateFirstChildView() {
|
|
25
|
+
if (this.childCount > 0) {
|
|
26
|
+
hasAdjustedSize = false
|
|
27
|
+
val viewTag = getChildAt(0).id
|
|
28
|
+
val reactContext: ReactContext = this.getReactContext()
|
|
29
|
+
reactContext.runOnNativeModulesQueueThread(object : GuardedRunnable(reactContext) {
|
|
30
|
+
override fun runGuarded() {
|
|
31
|
+
val uiManager = this@ModalContentLayout.getReactContext().getNativeModule(
|
|
32
|
+
UIManagerModule::class.java
|
|
33
|
+
) as UIManagerModule
|
|
34
|
+
uiManager.updateNodeSize(
|
|
35
|
+
viewTag,
|
|
36
|
+
this@ModalContentLayout.viewWidth,
|
|
37
|
+
this@ModalContentLayout.viewHeight
|
|
38
|
+
)
|
|
39
|
+
}
|
|
40
|
+
})
|
|
41
|
+
} else {
|
|
42
|
+
hasAdjustedSize = true
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
override fun addView(child: View?, index: Int, params: LayoutParams?) {
|
|
47
|
+
super.addView(child, index, params)
|
|
48
|
+
if (hasAdjustedSize) {
|
|
49
|
+
updateFirstChildView()
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
override fun onChildStartedNativeGesture(child: View, androidEvent: MotionEvent?) {
|
|
53
|
+
mJSTouchDispatcher.onChildStartedNativeGesture(androidEvent, this.getEventDispatcher())
|
|
54
|
+
}
|
|
55
|
+
override fun onChildStartedNativeGesture(androidEvent: MotionEvent?) {
|
|
56
|
+
mJSTouchDispatcher.onChildStartedNativeGesture(androidEvent, this.getEventDispatcher())
|
|
57
|
+
}
|
|
58
|
+
override fun onChildEndedNativeGesture(child: View, androidEvent: MotionEvent?) {
|
|
59
|
+
mJSTouchDispatcher.onChildEndedNativeGesture(androidEvent, this.getEventDispatcher())
|
|
60
|
+
}
|
|
61
|
+
override fun requestDisallowInterceptTouchEvent(disallowIntercept: Boolean) {}
|
|
62
|
+
private fun getEventDispatcher(): EventDispatcher? {
|
|
63
|
+
val reactContext: ReactContext = this.getReactContext()
|
|
64
|
+
return reactContext.getNativeModule(UIManagerModule::class.java)!!.eventDispatcher
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
override fun handleException(t: Throwable?) {
|
|
69
|
+
getReactContext().handleException(RuntimeException(t))
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
private fun getReactContext(): ReactContext {
|
|
73
|
+
return this.context as ReactContext
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
override fun onInterceptTouchEvent(event: MotionEvent?): Boolean {
|
|
77
|
+
mJSTouchDispatcher.handleTouchEvent(event, getEventDispatcher())
|
|
78
|
+
return super.onInterceptTouchEvent(event)
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
override fun onTouchEvent(event: MotionEvent?): Boolean {
|
|
82
|
+
mJSTouchDispatcher.handleTouchEvent(event, getEventDispatcher())
|
|
83
|
+
super.onTouchEvent(event)
|
|
84
|
+
return true
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
package com.reactnativenavigation.viewcontrollers.viewcontroller;
|
|
2
|
+
|
|
3
|
+
import android.view.View;
|
|
4
|
+
import android.view.ViewGroup;
|
|
5
|
+
|
|
6
|
+
public class YellowBoxHelper {
|
|
7
|
+
boolean isYellowBox(View parent, View child) {
|
|
8
|
+
return parent instanceof ViewGroup &&
|
|
9
|
+
child instanceof ViewGroup &&
|
|
10
|
+
((ViewGroup) parent).indexOfChild(child) >= 1;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -12,7 +12,7 @@ const NavigationButton = class extends react_1.Component {
|
|
|
12
12
|
const { button, componentId } = this.props;
|
|
13
13
|
if (button.component)
|
|
14
14
|
return this.renderButtonComponent();
|
|
15
|
-
return (react_1.default.createElement(react_native_1.Button, { testID: button.testID, key: button.id, title: button.text || '', onPress: () => button.enabled !== false &&
|
|
15
|
+
return (react_1.default.createElement(react_native_1.Button, { testID: button.testID, key: button.id, title: button.text || '', disabled: button.enabled === false, onPress: () => button.enabled !== false &&
|
|
16
16
|
EventsStore_1.events.invokeNavigationButtonPressed({
|
|
17
17
|
buttonId: button.id,
|
|
18
18
|
componentId,
|
|
@@ -65,17 +65,23 @@ class NativeCommandsSender {
|
|
|
65
65
|
});
|
|
66
66
|
}
|
|
67
67
|
dismissModal(_commandId, componentId, _options) {
|
|
68
|
-
return new Promise((resolve) => {
|
|
69
|
-
const modal = LayoutStore_1.LayoutStore.getModalById(componentId)
|
|
70
|
-
modal
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
68
|
+
return new Promise((resolve, reject) => {
|
|
69
|
+
const modal = LayoutStore_1.LayoutStore.getModalById(componentId);
|
|
70
|
+
if (modal) {
|
|
71
|
+
const modalTopParent = modal.getTopParent();
|
|
72
|
+
modalTopParent.componentDidDisappear();
|
|
73
|
+
LayoutStore_1.LayoutStore.dismissModal(componentId);
|
|
74
|
+
EventsStore_1.events.invokeModalDismissed({
|
|
75
|
+
componentName: modalTopParent.data.name,
|
|
76
|
+
componentId: modalTopParent.nodeId,
|
|
77
|
+
modalsDismissed: 1,
|
|
78
|
+
});
|
|
79
|
+
resolve(modalTopParent.nodeId);
|
|
80
|
+
LayoutStore_1.LayoutStore.getVisibleLayout().componentDidAppear();
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
reject(`component with id: ${componentId} is not a modal`);
|
|
84
|
+
}
|
|
79
85
|
});
|
|
80
86
|
}
|
|
81
87
|
dismissAllModals(_commandId, _options) {
|
|
@@ -4,7 +4,7 @@ declare type FontFamily = string;
|
|
|
4
4
|
declare type FontStyle = 'normal' | 'italic';
|
|
5
5
|
declare type FontWeightIOS = 'normal' | 'ultralight' | 'thin' | 'light' | 'regular' | 'medium' | 'semibold' | 'demibold' | 'extrabold' | 'ultrabold' | 'bold' | 'heavy' | 'black';
|
|
6
6
|
declare type FontWeight = 'normal' | 'bold' | '100' | '200' | '300' | '400' | '500' | '600' | '700' | '800' | '900' | FontWeightIOS;
|
|
7
|
-
export declare type LayoutOrientation = 'portrait' | 'landscape';
|
|
7
|
+
export declare type LayoutOrientation = 'portrait' | 'landscape' | 'sensor' | 'sensorLandscape' | 'sensorPortrait';
|
|
8
8
|
declare type AndroidDensityNumber = number;
|
|
9
9
|
export declare type SystemItemIcon = 'done' | 'cancel' | 'edit' | 'save' | 'add' | 'flexibleSpace' | 'fixedSpace' | 'compose' | 'reply' | 'action' | 'organize' | 'bookmarks' | 'search' | 'refresh' | 'stop' | 'camera' | 'trash' | 'play' | 'pause' | 'rewind' | 'fastForward' | 'undo' | 'redo';
|
|
10
10
|
export declare type Interpolation = {
|
|
@@ -2,6 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
@implementation RNNComponentRootView
|
|
4
4
|
|
|
5
|
+
- (instancetype)initWithBridge:(RCTBridge *)bridge
|
|
6
|
+
moduleName:(NSString *)moduleName
|
|
7
|
+
initialProperties:(NSDictionary *)initialProperties
|
|
8
|
+
eventEmitter:(RNNEventEmitter *)eventEmitter
|
|
9
|
+
reactViewReadyBlock:(RNNReactViewReadyCompletionBlock)reactViewReadyBlock {
|
|
10
|
+
self = [super initWithBridge:bridge
|
|
11
|
+
moduleName:moduleName
|
|
12
|
+
initialProperties:initialProperties
|
|
13
|
+
eventEmitter:eventEmitter
|
|
14
|
+
reactViewReadyBlock:reactViewReadyBlock];
|
|
15
|
+
[bridge.uiManager setAvailableSize:UIScreen.mainScreen.bounds.size forRootView:self];
|
|
16
|
+
return self;
|
|
17
|
+
}
|
|
18
|
+
|
|
5
19
|
- (NSString *)componentType {
|
|
6
20
|
return ComponentTypeScreen;
|
|
7
21
|
}
|
|
@@ -33,7 +33,12 @@ type FontWeight =
|
|
|
33
33
|
| '800'
|
|
34
34
|
| '900'
|
|
35
35
|
| FontWeightIOS;
|
|
36
|
-
export type LayoutOrientation =
|
|
36
|
+
export type LayoutOrientation =
|
|
37
|
+
| 'portrait'
|
|
38
|
+
| 'landscape'
|
|
39
|
+
| 'sensor'
|
|
40
|
+
| 'sensorLandscape'
|
|
41
|
+
| 'sensorPortrait';
|
|
37
42
|
type AndroidDensityNumber = number;
|
|
38
43
|
export type SystemItemIcon =
|
|
39
44
|
| 'done'
|