@lodev09/react-native-true-sheet 2.0.2 → 2.0.4
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/android/src/main/java/com/lodev09/truesheet/TrueSheetView.kt +23 -13
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetViewManager.kt +14 -1
- package/android/src/main/java/com/lodev09/truesheet/core/RootSheetView.kt +15 -24
- package/package.json +3 -3
- package/react-native-true-sheet.podspec +11 -4
|
@@ -19,7 +19,6 @@ import com.lodev09.truesheet.core.Utils
|
|
|
19
19
|
class TrueSheetView(context: Context) :
|
|
20
20
|
ViewGroup(context),
|
|
21
21
|
LifecycleEventListener {
|
|
22
|
-
private var eventDispatcher: EventDispatcher? = null
|
|
23
22
|
|
|
24
23
|
private val reactContext: ThemedReactContext
|
|
25
24
|
get() = context as ThemedReactContext
|
|
@@ -27,6 +26,12 @@ class TrueSheetView(context: Context) :
|
|
|
27
26
|
private val surfaceId: Int
|
|
28
27
|
get() = UIManagerHelper.getSurfaceId(this)
|
|
29
28
|
|
|
29
|
+
var eventDispatcher: EventDispatcher?
|
|
30
|
+
get() = rootSheetView.eventDispatcher
|
|
31
|
+
set(eventDispatcher) {
|
|
32
|
+
rootSheetView.eventDispatcher = eventDispatcher
|
|
33
|
+
}
|
|
34
|
+
|
|
30
35
|
var initialIndex: Int = -1
|
|
31
36
|
var initialIndexAnimated: Boolean = true
|
|
32
37
|
|
|
@@ -62,11 +67,8 @@ class TrueSheetView(context: Context) :
|
|
|
62
67
|
|
|
63
68
|
init {
|
|
64
69
|
reactContext.addLifecycleEventListener(this)
|
|
65
|
-
eventDispatcher = UIManagerHelper.getEventDispatcherForReactTag(reactContext, id)
|
|
66
70
|
|
|
67
71
|
rootSheetView = RootSheetView(context)
|
|
68
|
-
rootSheetView.eventDispatcher = eventDispatcher
|
|
69
|
-
|
|
70
72
|
sheetDialog = TrueSheetDialog(reactContext, rootSheetView)
|
|
71
73
|
|
|
72
74
|
// Configure Sheet Dialog
|
|
@@ -173,6 +175,13 @@ class TrueSheetView(context: Context) :
|
|
|
173
175
|
// Do nothing as we are laid out by UIManager
|
|
174
176
|
}
|
|
175
177
|
|
|
178
|
+
override fun setId(id: Int) {
|
|
179
|
+
super.setId(id)
|
|
180
|
+
|
|
181
|
+
// Forward the ID to our content view, so event dispatching behaves correctly
|
|
182
|
+
rootSheetView.id = id
|
|
183
|
+
}
|
|
184
|
+
|
|
176
185
|
override fun onAttachedToWindow() {
|
|
177
186
|
super.onAttachedToWindow()
|
|
178
187
|
|
|
@@ -193,7 +202,7 @@ class TrueSheetView(context: Context) :
|
|
|
193
202
|
|
|
194
203
|
override fun onDetachedFromWindow() {
|
|
195
204
|
super.onDetachedFromWindow()
|
|
196
|
-
|
|
205
|
+
onDropInstance()
|
|
197
206
|
}
|
|
198
207
|
|
|
199
208
|
override fun addView(child: View, index: Int) {
|
|
@@ -219,7 +228,6 @@ class TrueSheetView(context: Context) :
|
|
|
219
228
|
|
|
220
229
|
override fun removeViewAt(index: Int) {
|
|
221
230
|
UiThreadUtil.assertOnUiThread()
|
|
222
|
-
|
|
223
231
|
val child = getChildAt(index)
|
|
224
232
|
rootSheetView.removeView(child)
|
|
225
233
|
}
|
|
@@ -229,14 +237,12 @@ class TrueSheetView(context: Context) :
|
|
|
229
237
|
// Those will be handled by the rootView which lives in the dialog
|
|
230
238
|
}
|
|
231
239
|
|
|
232
|
-
override
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
return false
|
|
236
|
-
}
|
|
240
|
+
// Explicitly override this to prevent accessibility events being passed down to children
|
|
241
|
+
// Those will be handled by the mHostView which lives in the dialog
|
|
242
|
+
public override fun dispatchPopulateAccessibilityEvent(event: AccessibilityEvent): Boolean = false
|
|
237
243
|
|
|
238
244
|
override fun onHostResume() {
|
|
239
|
-
|
|
245
|
+
configureIfShowing()
|
|
240
246
|
}
|
|
241
247
|
|
|
242
248
|
override fun onHostPause() {
|
|
@@ -245,6 +251,10 @@ class TrueSheetView(context: Context) :
|
|
|
245
251
|
|
|
246
252
|
override fun onHostDestroy() {
|
|
247
253
|
// Drop the instance if the host is destroyed which will dismiss the dialog
|
|
254
|
+
onDropInstance()
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
fun onDropInstance() {
|
|
248
258
|
reactContext.removeLifecycleEventListener(this)
|
|
249
259
|
sheetDialog.dismiss()
|
|
250
260
|
}
|
|
@@ -311,7 +321,7 @@ class TrueSheetView(context: Context) :
|
|
|
311
321
|
eventDispatcher?.dispatchEvent(TrueSheetEvent(surfaceId, id, name, data))
|
|
312
322
|
}
|
|
313
323
|
|
|
314
|
-
|
|
324
|
+
fun configureIfShowing() {
|
|
315
325
|
if (sheetDialog.isShowing) {
|
|
316
326
|
sheetDialog.configure()
|
|
317
327
|
sheetDialog.positionFooter()
|
|
@@ -8,6 +8,7 @@ import com.facebook.react.bridge.ReadableArray
|
|
|
8
8
|
import com.facebook.react.bridge.ReadableType
|
|
9
9
|
import com.facebook.react.common.MapBuilder
|
|
10
10
|
import com.facebook.react.uimanager.ThemedReactContext
|
|
11
|
+
import com.facebook.react.uimanager.UIManagerHelper
|
|
11
12
|
import com.facebook.react.uimanager.ViewGroupManager
|
|
12
13
|
import com.facebook.react.uimanager.annotations.ReactProp
|
|
13
14
|
import com.lodev09.truesheet.core.Utils
|
|
@@ -19,7 +20,19 @@ class TrueSheetViewManager : ViewGroupManager<TrueSheetView>() {
|
|
|
19
20
|
|
|
20
21
|
override fun onDropViewInstance(view: TrueSheetView) {
|
|
21
22
|
super.onDropViewInstance(view)
|
|
22
|
-
view.
|
|
23
|
+
view.onDropInstance()
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
override fun addEventEmitters(reactContext: ThemedReactContext, view: TrueSheetView) {
|
|
27
|
+
val dispatcher = UIManagerHelper.getEventDispatcherForReactTag(reactContext, view.id)
|
|
28
|
+
dispatcher?.let {
|
|
29
|
+
view.eventDispatcher = it
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
override fun onAfterUpdateTransaction(view: TrueSheetView) {
|
|
34
|
+
super.onAfterUpdateTransaction(view)
|
|
35
|
+
view.configureIfShowing()
|
|
23
36
|
}
|
|
24
37
|
|
|
25
38
|
override fun getExportedCustomDirectEventTypeConstants(): MutableMap<String, Any> =
|
|
@@ -32,8 +32,8 @@ class RootSheetView(private val context: Context?) :
|
|
|
32
32
|
|
|
33
33
|
private val jSTouchDispatcher = JSTouchDispatcher(this)
|
|
34
34
|
private var jSPointerDispatcher: JSPointerDispatcher? = null
|
|
35
|
-
var sizeChangeListener: ((w: Int, h: Int) -> Unit)? = null
|
|
36
35
|
|
|
36
|
+
var sizeChangeListener: ((w: Int, h: Int) -> Unit)? = null
|
|
37
37
|
var eventDispatcher: EventDispatcher? = null
|
|
38
38
|
|
|
39
39
|
private val reactContext: ThemedReactContext
|
|
@@ -59,53 +59,44 @@ class RootSheetView(private val context: Context?) :
|
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
override fun onInterceptTouchEvent(event: MotionEvent): Boolean {
|
|
62
|
-
eventDispatcher?.let {
|
|
63
|
-
|
|
62
|
+
eventDispatcher?.let { eventDispatcher ->
|
|
63
|
+
jSTouchDispatcher.handleTouchEvent(event, eventDispatcher, reactContext)
|
|
64
|
+
jSPointerDispatcher?.handleMotionEvent(event, eventDispatcher, true)
|
|
65
|
+
}
|
|
64
66
|
return super.onInterceptTouchEvent(event)
|
|
65
67
|
}
|
|
66
68
|
|
|
67
69
|
@SuppressLint("ClickableViewAccessibility")
|
|
68
70
|
override fun onTouchEvent(event: MotionEvent): Boolean {
|
|
69
|
-
eventDispatcher?.let {
|
|
70
|
-
|
|
71
|
+
eventDispatcher?.let { eventDispatcher ->
|
|
72
|
+
jSTouchDispatcher.handleTouchEvent(event, eventDispatcher, reactContext)
|
|
73
|
+
jSPointerDispatcher?.handleMotionEvent(event, eventDispatcher, false)
|
|
74
|
+
}
|
|
71
75
|
super.onTouchEvent(event)
|
|
72
|
-
|
|
73
76
|
// In case when there is no children interested in handling touch event, we return true from
|
|
74
77
|
// the root view in order to receive subsequent events related to that gesture
|
|
75
78
|
return true
|
|
76
79
|
}
|
|
77
80
|
|
|
78
81
|
override fun onInterceptHoverEvent(event: MotionEvent): Boolean {
|
|
79
|
-
jSPointerDispatcher?.handleMotionEvent(event,
|
|
82
|
+
eventDispatcher?.let { jSPointerDispatcher?.handleMotionEvent(event, it, true) }
|
|
80
83
|
return super.onHoverEvent(event)
|
|
81
84
|
}
|
|
82
85
|
|
|
83
86
|
override fun onHoverEvent(event: MotionEvent): Boolean {
|
|
84
|
-
jSPointerDispatcher?.handleMotionEvent(event,
|
|
87
|
+
eventDispatcher?.let { jSPointerDispatcher?.handleMotionEvent(event, it, false) }
|
|
85
88
|
return super.onHoverEvent(event)
|
|
86
89
|
}
|
|
87
90
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
jSTouchDispatcher.onChildStartedNativeGesture(ev, it)
|
|
93
|
-
}
|
|
91
|
+
override fun onChildStartedNativeGesture(childView: View, ev: MotionEvent) {
|
|
92
|
+
eventDispatcher?.let { eventDispatcher ->
|
|
93
|
+
jSTouchDispatcher.onChildStartedNativeGesture(ev, eventDispatcher)
|
|
94
|
+
jSPointerDispatcher?.onChildStartedNativeGesture(childView, ev, eventDispatcher)
|
|
94
95
|
}
|
|
95
96
|
}
|
|
96
97
|
|
|
97
|
-
override fun onChildStartedNativeGesture(childView: View?, ev: MotionEvent) {
|
|
98
|
-
eventDispatcher?.let { jSTouchDispatcher.onChildStartedNativeGesture(ev, it) }
|
|
99
|
-
jSPointerDispatcher?.onChildStartedNativeGesture(childView, ev, eventDispatcher)
|
|
100
|
-
}
|
|
101
|
-
|
|
102
98
|
override fun onChildEndedNativeGesture(childView: View, ev: MotionEvent) {
|
|
103
99
|
eventDispatcher?.let { jSTouchDispatcher.onChildEndedNativeGesture(ev, it) }
|
|
104
100
|
jSPointerDispatcher?.onChildEndedNativeGesture()
|
|
105
101
|
}
|
|
106
|
-
|
|
107
|
-
override fun requestDisallowInterceptTouchEvent(disallowIntercept: Boolean) {
|
|
108
|
-
// No-op - override in order to still receive events to onInterceptTouchEvent
|
|
109
|
-
// even when some other view disallow that
|
|
110
|
-
}
|
|
111
102
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lodev09/react-native-true-sheet",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.4",
|
|
4
4
|
"description": "The true native bottom sheet experience for your React Native Apps.",
|
|
5
5
|
"source": "./src/index.ts",
|
|
6
6
|
"main": "./lib/commonjs/index.js",
|
|
@@ -41,8 +41,8 @@
|
|
|
41
41
|
"docs": "yarn workspace docs",
|
|
42
42
|
"test": "jest",
|
|
43
43
|
"typecheck": "tsc",
|
|
44
|
-
"lint": "eslint --fix \"**/*.{
|
|
45
|
-
"format": "prettier --write \"**/*.{
|
|
44
|
+
"lint": "eslint --fix \"**/*.{ts,tsx}\"",
|
|
45
|
+
"format": "prettier --write \"**/*.{ts,tsx}\"",
|
|
46
46
|
"tidy": "yarn typecheck && yarn lint && yarn format && scripts/swiftlint.sh && scripts/ktlint.sh",
|
|
47
47
|
"clean": "scripts/clean.sh",
|
|
48
48
|
"prepare": "bob build",
|
|
@@ -16,6 +16,13 @@ Pod::Spec.new do |s|
|
|
|
16
16
|
|
|
17
17
|
s.source_files = "ios/**/*.{h,m,mm,swift}"
|
|
18
18
|
|
|
19
|
+
if ENV['RCT_NEW_ARCH_ENABLED'] == '1' then
|
|
20
|
+
s.pod_target_xcconfig = {
|
|
21
|
+
# Detect if new arch is enabled in Swift code
|
|
22
|
+
"OTHER_SWIFT_FLAGS" => "-DRCT_NEW_ARCH_ENABLED"
|
|
23
|
+
}
|
|
24
|
+
end
|
|
25
|
+
|
|
19
26
|
# Use install_modules_dependencies helper to install the dependencies if React Native version >=0.71.0.
|
|
20
27
|
# See https://github.com/facebook/react-native/blob/febf6b7f33fdb4904669f99d795eba4c0f95d7bf/scripts/cocoapods/new_architecture.rb#L79.
|
|
21
28
|
if respond_to?(:install_modules_dependencies, true)
|
|
@@ -26,10 +33,10 @@ Pod::Spec.new do |s|
|
|
|
26
33
|
# Don't install the dependencies when we run `pod install` in the old architecture.
|
|
27
34
|
if ENV['RCT_NEW_ARCH_ENABLED'] == '1' then
|
|
28
35
|
s.compiler_flags = folly_compiler_flags + " -DRCT_NEW_ARCH_ENABLED=1"
|
|
29
|
-
s.pod_target_xcconfig
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
36
|
+
s.pod_target_xcconfig = s.pod_target_xcconfig | {
|
|
37
|
+
"HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\"",
|
|
38
|
+
"OTHER_CPLUSPLUSFLAGS" => "-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1",
|
|
39
|
+
"CLANG_CXX_LANGUAGE_STANDARD" => "c++17"
|
|
33
40
|
}
|
|
34
41
|
s.dependency "React-RCTFabric"
|
|
35
42
|
s.dependency "React-Codegen"
|