@lodev09/react-native-true-sheet 3.1.0-beta.1 → 3.1.0-beta.10
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/TrueSheetModule.kt +12 -10
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetView.kt +19 -7
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetViewController.kt +119 -208
- package/android/src/main/java/com/lodev09/truesheet/core/RNScreensFragmentObserver.kt +17 -5
- package/android/src/main/jni/CMakeLists.txt +6 -30
- package/android/src/main/res/anim/true_sheet_slide_in.xml +4 -4
- package/android/src/main/res/anim/true_sheet_slide_out.xml +4 -3
- package/ios/TrueSheetContainerView.mm +4 -4
- package/ios/TrueSheetContentView.mm +4 -4
- package/ios/TrueSheetFooterView.mm +4 -4
- package/ios/TrueSheetHeaderView.mm +4 -4
- package/ios/TrueSheetModule.mm +24 -5
- package/ios/TrueSheetView.h +2 -0
- package/ios/TrueSheetView.mm +17 -5
- package/ios/TrueSheetViewController.h +3 -2
- package/ios/TrueSheetViewController.mm +204 -95
- package/lib/module/TrueSheet.js +12 -8
- package/lib/module/TrueSheet.js.map +1 -1
- package/lib/module/navigation/TrueSheetRouter.js +119 -0
- package/lib/module/navigation/TrueSheetRouter.js.map +1 -0
- package/lib/module/navigation/TrueSheetView.js +169 -0
- package/lib/module/navigation/TrueSheetView.js.map +1 -0
- package/lib/module/navigation/createTrueSheetNavigator.js +59 -0
- package/lib/module/navigation/createTrueSheetNavigator.js.map +1 -0
- package/lib/module/navigation/index.js +6 -0
- package/lib/module/navigation/index.js.map +1 -0
- package/lib/module/navigation/types.js +4 -0
- package/lib/module/navigation/types.js.map +1 -0
- package/lib/module/navigation/useTrueSheetNavigation.js +26 -0
- package/lib/module/navigation/useTrueSheetNavigation.js.map +1 -0
- package/lib/module/reanimated/ReanimatedTrueSheetProvider.js +3 -3
- package/lib/module/reanimated/ReanimatedTrueSheetProvider.js.map +1 -1
- package/lib/module/specs/NativeTrueSheetModule.js.map +1 -1
- package/lib/typescript/src/TrueSheet.d.ts +8 -4
- package/lib/typescript/src/TrueSheet.d.ts.map +1 -1
- package/lib/typescript/src/navigation/TrueSheetRouter.d.ts +57 -0
- package/lib/typescript/src/navigation/TrueSheetRouter.d.ts.map +1 -0
- package/lib/typescript/src/navigation/TrueSheetView.d.ts +10 -0
- package/lib/typescript/src/navigation/TrueSheetView.d.ts.map +1 -0
- package/lib/typescript/src/navigation/createTrueSheetNavigator.d.ts +35 -0
- package/lib/typescript/src/navigation/createTrueSheetNavigator.d.ts.map +1 -0
- package/lib/typescript/src/navigation/index.d.ts +6 -0
- package/lib/typescript/src/navigation/index.d.ts.map +1 -0
- package/lib/typescript/src/navigation/types.d.ts +125 -0
- package/lib/typescript/src/navigation/types.d.ts.map +1 -0
- package/lib/typescript/src/navigation/useTrueSheetNavigation.d.ts +23 -0
- package/lib/typescript/src/navigation/useTrueSheetNavigation.d.ts.map +1 -0
- package/lib/typescript/src/reanimated/ReanimatedTrueSheetProvider.d.ts.map +1 -1
- package/lib/typescript/src/specs/NativeTrueSheetModule.d.ts +4 -2
- package/lib/typescript/src/specs/NativeTrueSheetModule.d.ts.map +1 -1
- package/package.json +13 -2
- package/src/TrueSheet.tsx +16 -8
- package/src/__mocks__/index.js +6 -5
- package/src/navigation/TrueSheetRouter.ts +172 -0
- package/src/navigation/TrueSheetView.tsx +271 -0
- package/src/navigation/createTrueSheetNavigator.tsx +89 -0
- package/src/navigation/index.ts +14 -0
- package/src/navigation/types.ts +176 -0
- package/src/navigation/useTrueSheetNavigation.ts +28 -0
- package/src/reanimated/ReanimatedTrueSheetProvider.tsx +6 -9
- package/src/specs/NativeTrueSheetModule.ts +4 -2
|
@@ -22,10 +22,6 @@ class TrueSheetModule(reactContext: ReactApplicationContext) :
|
|
|
22
22
|
|
|
23
23
|
override fun getName(): String = NAME
|
|
24
24
|
|
|
25
|
-
override fun initialize() {
|
|
26
|
-
super.initialize()
|
|
27
|
-
}
|
|
28
|
-
|
|
29
25
|
override fun invalidate() {
|
|
30
26
|
super.invalidate()
|
|
31
27
|
// Clear all registered views and observer on module invalidation
|
|
@@ -46,12 +42,12 @@ class TrueSheetModule(reactContext: ReactApplicationContext) :
|
|
|
46
42
|
* @throws OPERATION_FAILED if the operation fails for any other reason
|
|
47
43
|
*/
|
|
48
44
|
@ReactMethod
|
|
49
|
-
fun presentByRef(viewTag: Double, index: Double, promise: Promise) {
|
|
45
|
+
fun presentByRef(viewTag: Double, index: Double, animated: Boolean, promise: Promise) {
|
|
50
46
|
val tag = viewTag.toInt()
|
|
51
47
|
val detentIndex = index.toInt()
|
|
52
48
|
|
|
53
49
|
withTrueSheetView(tag, promise) { view ->
|
|
54
|
-
view.present(detentIndex) {
|
|
50
|
+
view.present(detentIndex, animated) {
|
|
55
51
|
promise.resolve(null)
|
|
56
52
|
}
|
|
57
53
|
}
|
|
@@ -67,11 +63,11 @@ class TrueSheetModule(reactContext: ReactApplicationContext) :
|
|
|
67
63
|
* @throws OPERATION_FAILED if the operation fails for any other reason
|
|
68
64
|
*/
|
|
69
65
|
@ReactMethod
|
|
70
|
-
fun dismissByRef(viewTag: Double, promise: Promise) {
|
|
66
|
+
fun dismissByRef(viewTag: Double, animated: Boolean, promise: Promise) {
|
|
71
67
|
val tag = viewTag.toInt()
|
|
72
68
|
|
|
73
69
|
withTrueSheetView(tag, promise) { view ->
|
|
74
|
-
view.dismiss {
|
|
70
|
+
view.dismiss(animated) {
|
|
75
71
|
promise.resolve(null)
|
|
76
72
|
}
|
|
77
73
|
}
|
|
@@ -89,8 +85,14 @@ class TrueSheetModule(reactContext: ReactApplicationContext) :
|
|
|
89
85
|
*/
|
|
90
86
|
@ReactMethod
|
|
91
87
|
fun resizeByRef(viewTag: Double, index: Double, promise: Promise) {
|
|
92
|
-
|
|
93
|
-
|
|
88
|
+
val tag = viewTag.toInt()
|
|
89
|
+
val detentIndex = index.toInt()
|
|
90
|
+
|
|
91
|
+
withTrueSheetView(tag, promise) { view ->
|
|
92
|
+
view.resize(detentIndex) {
|
|
93
|
+
promise.resolve(null)
|
|
94
|
+
}
|
|
95
|
+
}
|
|
94
96
|
}
|
|
95
97
|
|
|
96
98
|
/**
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
package com.lodev09.truesheet
|
|
2
2
|
|
|
3
3
|
import android.annotation.SuppressLint
|
|
4
|
+
import android.util.Log
|
|
4
5
|
import android.view.View
|
|
5
6
|
import android.view.ViewStructure
|
|
6
7
|
import android.view.accessibility.AccessibilityEvent
|
|
@@ -12,6 +13,7 @@ import com.facebook.react.uimanager.StateWrapper
|
|
|
12
13
|
import com.facebook.react.uimanager.ThemedReactContext
|
|
13
14
|
import com.facebook.react.uimanager.UIManagerHelper
|
|
14
15
|
import com.facebook.react.uimanager.events.EventDispatcher
|
|
16
|
+
import com.facebook.react.util.RNLog
|
|
15
17
|
import com.facebook.react.views.view.ReactViewGroup
|
|
16
18
|
import com.lodev09.truesheet.core.GrabberOptions
|
|
17
19
|
import com.lodev09.truesheet.core.TrueSheetDialogObserver
|
|
@@ -92,7 +94,6 @@ class TrueSheetView(private val reactContext: ThemedReactContext) :
|
|
|
92
94
|
viewController.setupBackground()
|
|
93
95
|
viewController.setupGrabber()
|
|
94
96
|
updateSheetIfNeeded()
|
|
95
|
-
viewController.setStateForDetentIndex(viewController.currentDetentIndex)
|
|
96
97
|
}
|
|
97
98
|
}
|
|
98
99
|
|
|
@@ -157,15 +158,15 @@ class TrueSheetView(private val reactContext: ThemedReactContext) :
|
|
|
157
158
|
override fun viewControllerWillPresent(index: Int, position: Float, detent: Float) {
|
|
158
159
|
val surfaceId = UIManagerHelper.getSurfaceId(this)
|
|
159
160
|
eventDispatcher?.dispatchEvent(WillPresentEvent(surfaceId, id, index, position, detent))
|
|
161
|
+
|
|
162
|
+
// Enable touch event dispatching to React Native
|
|
163
|
+
viewController.eventDispatcher = eventDispatcher
|
|
164
|
+
containerView?.footerView?.eventDispatcher = eventDispatcher
|
|
160
165
|
}
|
|
161
166
|
|
|
162
167
|
override fun viewControllerDidPresent(index: Int, position: Float, detent: Float) {
|
|
163
168
|
val surfaceId = UIManagerHelper.getSurfaceId(this)
|
|
164
169
|
eventDispatcher?.dispatchEvent(DidPresentEvent(surfaceId, id, index, position, detent))
|
|
165
|
-
|
|
166
|
-
// Enable touch event dispatching to React Native
|
|
167
|
-
viewController.eventDispatcher = eventDispatcher
|
|
168
|
-
containerView?.footerView?.eventDispatcher = eventDispatcher
|
|
169
170
|
}
|
|
170
171
|
|
|
171
172
|
override fun viewControllerWillDismiss() {
|
|
@@ -326,9 +327,20 @@ class TrueSheetView(private val reactContext: ThemedReactContext) :
|
|
|
326
327
|
}
|
|
327
328
|
|
|
328
329
|
@UiThread
|
|
329
|
-
fun dismiss(promiseCallback: () -> Unit) {
|
|
330
|
+
fun dismiss(animated: Boolean = true, promiseCallback: () -> Unit) {
|
|
330
331
|
viewController.dismissPromise = promiseCallback
|
|
331
|
-
viewController.dismiss()
|
|
332
|
+
viewController.dismiss(animated)
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
@UiThread
|
|
336
|
+
fun resize(detentIndex: Int, promiseCallback: () -> Unit) {
|
|
337
|
+
if (!viewController.isPresented) {
|
|
338
|
+
RNLog.w(reactContext, "TrueSheet: Cannot resize. Sheet is not presented.")
|
|
339
|
+
promiseCallback()
|
|
340
|
+
return
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
present(detentIndex, true, promiseCallback)
|
|
332
344
|
}
|
|
333
345
|
|
|
334
346
|
/**
|