@lodev09/react-native-true-sheet 2.0.5 → 4.0.0-beta.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.
Files changed (194) hide show
  1. package/README.md +36 -8
  2. package/RNTrueSheet.podspec +20 -0
  3. package/android/build.gradle +26 -14
  4. package/android/src/main/java/com/lodev09/truesheet/TrueSheetContainerView.kt +108 -0
  5. package/android/src/main/java/com/lodev09/truesheet/TrueSheetContainerViewManager.kt +21 -0
  6. package/android/src/main/java/com/lodev09/truesheet/TrueSheetContentView.kt +46 -0
  7. package/android/src/main/java/com/lodev09/truesheet/TrueSheetContentViewManager.kt +21 -0
  8. package/android/src/main/java/com/lodev09/truesheet/TrueSheetFooterView.kt +47 -0
  9. package/android/src/main/java/com/lodev09/truesheet/TrueSheetFooterViewManager.kt +21 -0
  10. package/android/src/main/java/com/lodev09/truesheet/TrueSheetModule.kt +165 -0
  11. package/android/src/main/java/com/lodev09/truesheet/TrueSheetPackage.kt +36 -4
  12. package/android/src/main/java/com/lodev09/truesheet/TrueSheetView.kt +257 -299
  13. package/android/src/main/java/com/lodev09/truesheet/TrueSheetViewController.kt +855 -0
  14. package/android/src/main/java/com/lodev09/truesheet/TrueSheetViewManager.kt +104 -82
  15. package/android/src/main/java/com/lodev09/truesheet/events/DetentChangeEvent.kt +26 -0
  16. package/android/src/main/java/com/lodev09/truesheet/events/DidDismissEvent.kt +20 -0
  17. package/android/src/main/java/com/lodev09/truesheet/events/DidPresentEvent.kt +26 -0
  18. package/android/src/main/java/com/lodev09/truesheet/events/DragBeginEvent.kt +26 -0
  19. package/android/src/main/java/com/lodev09/truesheet/events/DragChangeEvent.kt +26 -0
  20. package/android/src/main/java/com/lodev09/truesheet/events/DragEndEvent.kt +26 -0
  21. package/android/src/main/java/com/lodev09/truesheet/events/MountEvent.kt +20 -0
  22. package/android/src/main/java/com/lodev09/truesheet/events/PositionChangeEvent.kt +32 -0
  23. package/android/src/main/java/com/lodev09/truesheet/events/SizeChangeEvent.kt +27 -0
  24. package/android/src/main/java/com/lodev09/truesheet/events/WillDismissEvent.kt +20 -0
  25. package/android/src/main/java/com/lodev09/truesheet/events/WillPresentEvent.kt +26 -0
  26. package/android/src/main/java/com/lodev09/truesheet/{core/Utils.kt → utils/ScreenUtils.kt} +47 -17
  27. package/android/src/main/res/values/styles.xml +8 -0
  28. package/ios/TrueSheetComponentDescriptor.h +24 -0
  29. package/ios/TrueSheetContainerView.h +47 -0
  30. package/ios/TrueSheetContainerView.mm +117 -0
  31. package/ios/TrueSheetContentView.h +37 -0
  32. package/ios/TrueSheetContentView.mm +114 -0
  33. package/ios/TrueSheetFooterView.h +27 -0
  34. package/ios/TrueSheetFooterView.mm +101 -0
  35. package/ios/TrueSheetModule.h +44 -0
  36. package/ios/TrueSheetModule.mm +133 -0
  37. package/ios/TrueSheetView.h +53 -0
  38. package/ios/TrueSheetView.mm +433 -0
  39. package/ios/TrueSheetViewController.h +53 -0
  40. package/ios/TrueSheetViewController.mm +649 -0
  41. package/ios/events/OnDetentChangeEvent.h +28 -0
  42. package/ios/events/OnDetentChangeEvent.mm +30 -0
  43. package/ios/events/OnDidDismissEvent.h +26 -0
  44. package/ios/events/OnDidDismissEvent.mm +25 -0
  45. package/ios/events/OnDidPresentEvent.h +28 -0
  46. package/ios/events/OnDidPresentEvent.mm +30 -0
  47. package/ios/events/OnDragBeginEvent.h +28 -0
  48. package/ios/events/OnDragBeginEvent.mm +30 -0
  49. package/ios/events/OnDragChangeEvent.h +28 -0
  50. package/ios/events/OnDragChangeEvent.mm +30 -0
  51. package/ios/events/OnDragEndEvent.h +28 -0
  52. package/ios/events/OnDragEndEvent.mm +30 -0
  53. package/ios/events/OnMountEvent.h +26 -0
  54. package/ios/events/OnMountEvent.mm +25 -0
  55. package/ios/events/OnPositionChangeEvent.h +29 -0
  56. package/ios/events/OnPositionChangeEvent.mm +32 -0
  57. package/ios/events/OnSizeChangeEvent.h +28 -0
  58. package/ios/events/OnSizeChangeEvent.mm +30 -0
  59. package/ios/events/OnWillDismissEvent.h +26 -0
  60. package/ios/events/OnWillDismissEvent.mm +25 -0
  61. package/ios/events/OnWillPresentEvent.h +28 -0
  62. package/ios/events/OnWillPresentEvent.mm +30 -0
  63. package/ios/utils/GestureUtil.h +25 -0
  64. package/ios/utils/GestureUtil.mm +26 -0
  65. package/ios/utils/LayoutUtil.h +44 -0
  66. package/ios/utils/LayoutUtil.mm +50 -0
  67. package/ios/utils/WindowUtil.h +27 -0
  68. package/ios/utils/WindowUtil.mm +42 -0
  69. package/lib/module/TrueSheet.js +231 -135
  70. package/lib/module/TrueSheet.js.map +1 -1
  71. package/lib/module/TrueSheetGrabber.js +16 -14
  72. package/lib/module/TrueSheetGrabber.js.map +1 -1
  73. package/lib/module/fabric/TrueSheetContainerViewNativeComponent.ts +8 -0
  74. package/lib/module/fabric/TrueSheetContentViewNativeComponent.ts +8 -0
  75. package/lib/module/fabric/TrueSheetFooterViewNativeComponent.ts +8 -0
  76. package/lib/module/fabric/TrueSheetViewNativeComponent.ts +63 -0
  77. package/lib/module/index.js +1 -0
  78. package/lib/module/index.js.map +1 -1
  79. package/lib/module/reanimated/ReanimatedTrueSheet.js +87 -0
  80. package/lib/module/reanimated/ReanimatedTrueSheet.js.map +1 -0
  81. package/lib/module/reanimated/ReanimatedTrueSheetProvider.js +72 -0
  82. package/lib/module/reanimated/ReanimatedTrueSheetProvider.js.map +1 -0
  83. package/lib/module/reanimated/index.js +6 -0
  84. package/lib/module/reanimated/index.js.map +1 -0
  85. package/lib/module/reanimated/useReanimatedPositionChangeHandler.js +19 -0
  86. package/lib/module/reanimated/useReanimatedPositionChangeHandler.js.map +1 -0
  87. package/lib/module/specs/NativeTrueSheetModule.js +12 -0
  88. package/lib/module/specs/NativeTrueSheetModule.js.map +1 -0
  89. package/lib/typescript/package.json +1 -0
  90. package/lib/typescript/src/TrueSheet.d.ts +79 -0
  91. package/lib/typescript/src/TrueSheet.d.ts.map +1 -0
  92. package/lib/typescript/src/TrueSheet.types.d.ts +260 -0
  93. package/lib/typescript/src/TrueSheet.types.d.ts.map +1 -0
  94. package/lib/typescript/{commonjs/src → src}/TrueSheetGrabber.d.ts +1 -1
  95. package/lib/typescript/src/TrueSheetGrabber.d.ts.map +1 -0
  96. package/lib/typescript/src/fabric/TrueSheetContainerViewNativeComponent.d.ts +6 -0
  97. package/lib/typescript/src/fabric/TrueSheetContainerViewNativeComponent.d.ts.map +1 -0
  98. package/lib/typescript/src/fabric/TrueSheetContentViewNativeComponent.d.ts +6 -0
  99. package/lib/typescript/src/fabric/TrueSheetContentViewNativeComponent.d.ts.map +1 -0
  100. package/lib/typescript/src/fabric/TrueSheetFooterViewNativeComponent.d.ts +6 -0
  101. package/lib/typescript/src/fabric/TrueSheetFooterViewNativeComponent.d.ts.map +1 -0
  102. package/lib/typescript/src/fabric/TrueSheetViewNativeComponent.d.ts +44 -0
  103. package/lib/typescript/src/fabric/TrueSheetViewNativeComponent.d.ts.map +1 -0
  104. package/lib/typescript/{commonjs/src → src}/index.d.ts +1 -0
  105. package/lib/typescript/src/index.d.ts.map +1 -0
  106. package/lib/typescript/src/reanimated/ReanimatedTrueSheet.d.ts +43 -0
  107. package/lib/typescript/src/reanimated/ReanimatedTrueSheet.d.ts.map +1 -0
  108. package/lib/typescript/src/reanimated/ReanimatedTrueSheetProvider.d.ts +57 -0
  109. package/lib/typescript/src/reanimated/ReanimatedTrueSheetProvider.d.ts.map +1 -0
  110. package/lib/typescript/src/reanimated/index.d.ts +4 -0
  111. package/lib/typescript/src/reanimated/index.d.ts.map +1 -0
  112. package/lib/typescript/src/reanimated/useReanimatedPositionChangeHandler.d.ts +6 -0
  113. package/lib/typescript/src/reanimated/useReanimatedPositionChangeHandler.d.ts.map +1 -0
  114. package/lib/typescript/src/specs/NativeTrueSheetModule.d.ts +34 -0
  115. package/lib/typescript/src/specs/NativeTrueSheetModule.d.ts.map +1 -0
  116. package/package.json +104 -75
  117. package/react-native.config.js +17 -0
  118. package/src/TrueSheet.tsx +285 -188
  119. package/src/TrueSheet.types.ts +119 -106
  120. package/src/TrueSheetGrabber.tsx +29 -28
  121. package/src/__mocks__/index.js +60 -12
  122. package/src/fabric/TrueSheetContainerViewNativeComponent.ts +8 -0
  123. package/src/fabric/TrueSheetContentViewNativeComponent.ts +8 -0
  124. package/src/fabric/TrueSheetFooterViewNativeComponent.ts +8 -0
  125. package/src/fabric/TrueSheetViewNativeComponent.ts +63 -0
  126. package/src/index.ts +4 -3
  127. package/src/reanimated/ReanimatedTrueSheet.tsx +95 -0
  128. package/src/reanimated/ReanimatedTrueSheetProvider.tsx +92 -0
  129. package/src/reanimated/index.ts +3 -0
  130. package/src/reanimated/useReanimatedPositionChangeHandler.ts +26 -0
  131. package/src/specs/NativeTrueSheetModule.ts +38 -0
  132. package/TrueSheet.podspec +0 -49
  133. package/android/src/main/java/com/lodev09/truesheet/TrueSheetDialog.kt +0 -400
  134. package/android/src/main/java/com/lodev09/truesheet/TrueSheetEvent.kt +0 -22
  135. package/android/src/main/java/com/lodev09/truesheet/TrueSheetViewModule.kt +0 -63
  136. package/android/src/main/java/com/lodev09/truesheet/core/KeyboardManager.kt +0 -58
  137. package/android/src/main/java/com/lodev09/truesheet/core/RootSheetView.kt +0 -102
  138. package/ios/Extensions/UIBlurEffect+withTint.swift +0 -62
  139. package/ios/Extensions/UIView+pinTo.swift +0 -74
  140. package/ios/Extensions/UIViewController+detentForSize.swift +0 -134
  141. package/ios/TrueSheet-Bridging-Header.h +0 -14
  142. package/ios/TrueSheetEvent.swift +0 -48
  143. package/ios/TrueSheetView.swift +0 -461
  144. package/ios/TrueSheetViewController.swift +0 -275
  145. package/ios/TrueSheetViewManager.m +0 -53
  146. package/ios/TrueSheetViewManager.swift +0 -48
  147. package/ios/Utils/Logger.swift +0 -39
  148. package/ios/Utils/Promise.swift +0 -25
  149. package/lib/commonjs/TrueSheet.js +0 -258
  150. package/lib/commonjs/TrueSheet.js.map +0 -1
  151. package/lib/commonjs/TrueSheet.types.js +0 -6
  152. package/lib/commonjs/TrueSheet.types.js.map +0 -1
  153. package/lib/commonjs/TrueSheetFooter.js +0 -19
  154. package/lib/commonjs/TrueSheetFooter.js.map +0 -1
  155. package/lib/commonjs/TrueSheetGrabber.js +0 -54
  156. package/lib/commonjs/TrueSheetGrabber.js.map +0 -1
  157. package/lib/commonjs/TrueSheetModule.js +0 -19
  158. package/lib/commonjs/TrueSheetModule.js.map +0 -1
  159. package/lib/commonjs/__mocks__/index.js +0 -52
  160. package/lib/commonjs/__mocks__/index.js.map +0 -1
  161. package/lib/commonjs/index.js +0 -39
  162. package/lib/commonjs/index.js.map +0 -1
  163. package/lib/module/TrueSheetFooter.js +0 -14
  164. package/lib/module/TrueSheetFooter.js.map +0 -1
  165. package/lib/module/TrueSheetModule.js +0 -15
  166. package/lib/module/TrueSheetModule.js.map +0 -1
  167. package/lib/module/__mocks__/index.js +0 -21
  168. package/lib/module/__mocks__/index.js.map +0 -1
  169. package/lib/typescript/commonjs/package.json +0 -1
  170. package/lib/typescript/commonjs/src/TrueSheet.d.ts +0 -70
  171. package/lib/typescript/commonjs/src/TrueSheet.d.ts.map +0 -1
  172. package/lib/typescript/commonjs/src/TrueSheet.types.d.ts +0 -241
  173. package/lib/typescript/commonjs/src/TrueSheet.types.d.ts.map +0 -1
  174. package/lib/typescript/commonjs/src/TrueSheetFooter.d.ts +0 -7
  175. package/lib/typescript/commonjs/src/TrueSheetFooter.d.ts.map +0 -1
  176. package/lib/typescript/commonjs/src/TrueSheetGrabber.d.ts.map +0 -1
  177. package/lib/typescript/commonjs/src/TrueSheetModule.d.ts +0 -2
  178. package/lib/typescript/commonjs/src/TrueSheetModule.d.ts.map +0 -1
  179. package/lib/typescript/commonjs/src/index.d.ts.map +0 -1
  180. package/lib/typescript/module/src/TrueSheet.d.ts +0 -70
  181. package/lib/typescript/module/src/TrueSheet.d.ts.map +0 -1
  182. package/lib/typescript/module/src/TrueSheet.types.d.ts +0 -241
  183. package/lib/typescript/module/src/TrueSheet.types.d.ts.map +0 -1
  184. package/lib/typescript/module/src/TrueSheetFooter.d.ts +0 -7
  185. package/lib/typescript/module/src/TrueSheetFooter.d.ts.map +0 -1
  186. package/lib/typescript/module/src/TrueSheetGrabber.d.ts +0 -39
  187. package/lib/typescript/module/src/TrueSheetGrabber.d.ts.map +0 -1
  188. package/lib/typescript/module/src/TrueSheetModule.d.ts +0 -2
  189. package/lib/typescript/module/src/TrueSheetModule.d.ts.map +0 -1
  190. package/lib/typescript/module/src/index.d.ts +0 -4
  191. package/lib/typescript/module/src/index.d.ts.map +0 -1
  192. package/src/TrueSheetFooter.tsx +0 -17
  193. package/src/TrueSheetModule.ts +0 -19
  194. /package/lib/{typescript/module → module}/package.json +0 -0
@@ -1,22 +0,0 @@
1
- package com.lodev09.truesheet
2
-
3
- import com.facebook.react.bridge.Arguments
4
- import com.facebook.react.bridge.WritableMap
5
- import com.facebook.react.uimanager.events.Event
6
-
7
- class TrueSheetEvent(surfaceId: Int, viewId: Int, private val name: String, private val data: WritableMap?) :
8
- Event<TrueSheetEvent>(surfaceId, viewId) {
9
- override fun getEventName() = name
10
- override fun getEventData(): WritableMap = data ?: Arguments.createMap()
11
-
12
- companion object {
13
- const val MOUNT = "topMount"
14
- const val PRESENT = "topPresent"
15
- const val DISMISS = "topDismiss"
16
- const val SIZE_CHANGE = "topSizeChange"
17
- const val DRAG_BEGIN = "topDragBegin"
18
- const val DRAG_CHANGE = "topDragChange"
19
- const val DRAG_END = "topDragEnd"
20
- const val CONTAINER_SIZE_CHANGE = "topContainerSizeChange"
21
- }
22
- }
@@ -1,63 +0,0 @@
1
- package com.lodev09.truesheet
2
-
3
- import android.util.Log
4
- import com.facebook.react.bridge.Promise
5
- import com.facebook.react.bridge.ReactApplicationContext
6
- import com.facebook.react.bridge.ReactContextBaseJavaModule
7
- import com.facebook.react.bridge.ReactMethod
8
- import com.facebook.react.bridge.UiThreadUtil
9
- import com.facebook.react.module.annotations.ReactModule
10
- import com.facebook.react.uimanager.UIManagerHelper
11
- import com.lodev09.truesheet.core.Utils
12
-
13
- @ReactModule(name = TrueSheetViewModule.TAG)
14
- class TrueSheetViewModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaModule(reactContext) {
15
- override fun getName(): String = TAG
16
-
17
- private fun withTrueSheetView(tag: Int, closure: (trueSheetView: TrueSheetView) -> Unit) {
18
- UiThreadUtil.runOnUiThread {
19
- try {
20
- val manager = UIManagerHelper.getUIManagerForReactTag(reactApplicationContext, tag)
21
- val view = manager?.resolveView(tag)
22
- if (view == null) {
23
- Log.d(TAG, "Tag $tag not found")
24
- return@runOnUiThread
25
- }
26
-
27
- if (view is TrueSheetView) {
28
- closure(view)
29
- } else {
30
- Log.d(TAG, "Tag $tag does not match")
31
- }
32
- } catch (e: Exception) {
33
- e.printStackTrace()
34
- }
35
- }
36
- }
37
-
38
- @ReactMethod
39
- fun present(tag: Int, index: Int, promise: Promise) {
40
- withTrueSheetView(tag) {
41
- it.present(index) {
42
- Utils.withPromise(promise) {
43
- return@withPromise null
44
- }
45
- }
46
- }
47
- }
48
-
49
- @ReactMethod
50
- fun dismiss(tag: Int, promise: Promise) {
51
- withTrueSheetView(tag) {
52
- it.dismiss {
53
- Utils.withPromise(promise) {
54
- return@withPromise null
55
- }
56
- }
57
- }
58
- }
59
-
60
- companion object {
61
- const val TAG = "TrueSheetView"
62
- }
63
- }
@@ -1,58 +0,0 @@
1
- package com.lodev09.truesheet.core
2
-
3
- import android.content.Context
4
- import android.view.View
5
- import android.view.ViewTreeObserver.OnGlobalLayoutListener
6
- import android.view.inputmethod.InputMethodManager
7
- import com.facebook.react.bridge.ReactContext
8
-
9
- class KeyboardManager(reactContext: ReactContext) {
10
- interface OnKeyboardChangeListener {
11
- fun onKeyboardStateChange(isVisible: Boolean, visibleHeight: Int?)
12
- }
13
-
14
- private var contentView: View? = null
15
- private var onGlobalLayoutListener: OnGlobalLayoutListener? = null
16
- private var isKeyboardVisible = false
17
-
18
- init {
19
- val activity = reactContext.currentActivity
20
- contentView = activity?.findViewById(android.R.id.content)
21
- }
22
-
23
- fun registerKeyboardListener(listener: OnKeyboardChangeListener?) {
24
- contentView?.apply {
25
- unregisterKeyboardListener()
26
-
27
- onGlobalLayoutListener = object : OnGlobalLayoutListener {
28
- private var previousHeight = 0
29
-
30
- override fun onGlobalLayout() {
31
- val heightDiff = rootView.height - height
32
- if (heightDiff > Utils.toPixel(200.0)) {
33
- // Will ask InputMethodManager.isAcceptingText() to detect if keyboard appeared or not.
34
- val inputManager = context.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
35
- if (height != previousHeight && inputManager.isAcceptingText()) {
36
- listener?.onKeyboardStateChange(true, height)
37
-
38
- previousHeight = height
39
- isKeyboardVisible = true
40
- }
41
- } else if (isKeyboardVisible) {
42
- listener?.onKeyboardStateChange(false, null)
43
- previousHeight = 0
44
- isKeyboardVisible = false
45
- }
46
- }
47
- }
48
-
49
- getViewTreeObserver().addOnGlobalLayoutListener(onGlobalLayoutListener)
50
- }
51
- }
52
-
53
- fun unregisterKeyboardListener() {
54
- onGlobalLayoutListener?.let {
55
- contentView?.getViewTreeObserver()?.removeOnGlobalLayoutListener(onGlobalLayoutListener)
56
- }
57
- }
58
- }
@@ -1,102 +0,0 @@
1
- package com.lodev09.truesheet.core
2
-
3
- import android.annotation.SuppressLint
4
- import android.content.Context
5
- import android.view.MotionEvent
6
- import android.view.View
7
- import com.facebook.react.config.ReactFeatureFlags
8
- import com.facebook.react.uimanager.JSPointerDispatcher
9
- import com.facebook.react.uimanager.JSTouchDispatcher
10
- import com.facebook.react.uimanager.RootView
11
- import com.facebook.react.uimanager.ThemedReactContext
12
- import com.facebook.react.uimanager.events.EventDispatcher
13
- import com.facebook.react.views.view.ReactViewGroup
14
-
15
- /**
16
- * RootSheetView is the ViewGroup which contains all the children of a Modal. It gets all
17
- * child information forwarded from TrueSheetView and uses that to create children. It is
18
- * also responsible for acting as a RootView and handling touch events. It does this the same way
19
- * as ReactRootView.
20
- *
21
- *
22
- * To get layout to work properly, we need to layout all the elements within the Modal as if
23
- * they can fill the entire window. To do that, we need to explicitly set the styleWidth and
24
- * styleHeight on the LayoutShadowNode to be the window size. This is done through the
25
- * UIManagerModule, and will then cause the children to layout as if they can fill the window.
26
- */
27
- class RootSheetView(private val context: Context?) :
28
- ReactViewGroup(context),
29
- RootView {
30
- private var viewWidth = 0
31
- private var viewHeight = 0
32
-
33
- private val jSTouchDispatcher = JSTouchDispatcher(this)
34
- private var jSPointerDispatcher: JSPointerDispatcher? = null
35
-
36
- var sizeChangeListener: ((w: Int, h: Int) -> Unit)? = null
37
- var eventDispatcher: EventDispatcher? = null
38
-
39
- private val reactContext: ThemedReactContext
40
- get() = context as ThemedReactContext
41
-
42
- init {
43
- if (ReactFeatureFlags.dispatchPointerEvents) {
44
- jSPointerDispatcher = JSPointerDispatcher(this)
45
- }
46
- }
47
-
48
- override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) {
49
- super.onSizeChanged(w, h, oldw, oldh)
50
-
51
- viewWidth = w
52
- viewHeight = h
53
-
54
- sizeChangeListener?.let { it(viewWidth, viewHeight) }
55
- }
56
-
57
- override fun handleException(t: Throwable) {
58
- reactContext.reactApplicationContext.handleException(RuntimeException(t))
59
- }
60
-
61
- override fun onInterceptTouchEvent(event: MotionEvent): Boolean {
62
- eventDispatcher?.let { eventDispatcher ->
63
- jSTouchDispatcher.handleTouchEvent(event, eventDispatcher, reactContext)
64
- jSPointerDispatcher?.handleMotionEvent(event, eventDispatcher, true)
65
- }
66
- return super.onInterceptTouchEvent(event)
67
- }
68
-
69
- @SuppressLint("ClickableViewAccessibility")
70
- override fun onTouchEvent(event: MotionEvent): Boolean {
71
- eventDispatcher?.let { eventDispatcher ->
72
- jSTouchDispatcher.handleTouchEvent(event, eventDispatcher, reactContext)
73
- jSPointerDispatcher?.handleMotionEvent(event, eventDispatcher, false)
74
- }
75
- super.onTouchEvent(event)
76
- // In case when there is no children interested in handling touch event, we return true from
77
- // the root view in order to receive subsequent events related to that gesture
78
- return true
79
- }
80
-
81
- override fun onInterceptHoverEvent(event: MotionEvent): Boolean {
82
- eventDispatcher?.let { jSPointerDispatcher?.handleMotionEvent(event, it, true) }
83
- return super.onHoverEvent(event)
84
- }
85
-
86
- override fun onHoverEvent(event: MotionEvent): Boolean {
87
- eventDispatcher?.let { jSPointerDispatcher?.handleMotionEvent(event, it, false) }
88
- return super.onHoverEvent(event)
89
- }
90
-
91
- override fun onChildStartedNativeGesture(childView: View?, ev: MotionEvent) {
92
- eventDispatcher?.let { eventDispatcher ->
93
- jSTouchDispatcher.onChildStartedNativeGesture(ev, eventDispatcher)
94
- jSPointerDispatcher?.onChildStartedNativeGesture(childView, ev, eventDispatcher)
95
- }
96
- }
97
-
98
- override fun onChildEndedNativeGesture(childView: View, ev: MotionEvent) {
99
- eventDispatcher?.let { jSTouchDispatcher.onChildEndedNativeGesture(ev, it) }
100
- jSPointerDispatcher?.onChildEndedNativeGesture()
101
- }
102
- }
@@ -1,62 +0,0 @@
1
- //
2
- // Created by Jovanni Lo (@lodev09)
3
- // Copyright (c) 2024-present. All rights reserved.
4
- //
5
- // This source code is licensed under the MIT license found in the
6
- // LICENSE file in the root directory of this source tree.
7
- //
8
-
9
- extension UIBlurEffect {
10
- convenience init(with tint: String) {
11
- var blurStyle: Style
12
-
13
- switch tint {
14
- case "default":
15
- blurStyle = .regular
16
- case "extraLight":
17
- blurStyle = .extraLight
18
- case "light":
19
- blurStyle = .light
20
- case "regular":
21
- blurStyle = .regular
22
- case "dark":
23
- blurStyle = .dark
24
- case "prominent":
25
- blurStyle = .prominent
26
- case "systemUltraThinMaterial":
27
- blurStyle = .systemUltraThinMaterial
28
- case "systemThinMaterial":
29
- blurStyle = .systemThinMaterial
30
- case "systemMaterial":
31
- blurStyle = .systemMaterial
32
- case "systemThickMaterial":
33
- blurStyle = .systemThickMaterial
34
- case "systemChromeMaterial":
35
- blurStyle = .systemChromeMaterial
36
- case "systemUltraThinMaterialLight":
37
- blurStyle = .systemUltraThinMaterialLight
38
- case "systemThickMaterialLight":
39
- blurStyle = .systemThickMaterialLight
40
- case "systemThinMaterialLight":
41
- blurStyle = .systemThinMaterialLight
42
- case "systemMaterialLight":
43
- blurStyle = .systemMaterialLight
44
- case "systemChromeMaterialLight":
45
- blurStyle = .systemChromeMaterialLight
46
- case "systemUltraThinMaterialDark":
47
- blurStyle = .systemUltraThinMaterialDark
48
- case "systemThinMaterialDark":
49
- blurStyle = .systemThinMaterialDark
50
- case "systemMaterialDark":
51
- blurStyle = .systemMaterialDark
52
- case "systemThickMaterialDark":
53
- blurStyle = .systemThickMaterialDark
54
- case "systemChromeMaterialDark":
55
- blurStyle = .systemChromeMaterialDark
56
- default:
57
- blurStyle = .light
58
- }
59
-
60
- self.init(style: blurStyle)
61
- }
62
- }
@@ -1,74 +0,0 @@
1
- //
2
- // Created by Jovanni Lo (@lodev09)
3
- // Copyright (c) 2024-present. All rights reserved.
4
- //
5
- // This source code is licensed under the MIT license found in the
6
- // LICENSE file in the root directory of this source tree.
7
- //
8
-
9
- // MARK: - Constraints
10
-
11
- struct Constraints {
12
- var top: NSLayoutConstraint?
13
- var bottom: NSLayoutConstraint?
14
- var left: NSLayoutConstraint?
15
- var right: NSLayoutConstraint?
16
- var height: NSLayoutConstraint?
17
- }
18
-
19
- extension UIView {
20
- /// Pin a view to the given view.
21
- /// Optionally accepts a completion handler for the resulting constraints
22
- func pinTo(
23
- view: UIView,
24
- from edges: UIRectEdge = .all,
25
- with height: CGFloat? = nil,
26
- constraints: ((Constraints) -> Void)?
27
- ) {
28
- translatesAutoresizingMaskIntoConstraints = false
29
-
30
- var topConstraint: NSLayoutConstraint?
31
- var bottomConstraint: NSLayoutConstraint?
32
- var leftConstraint: NSLayoutConstraint?
33
- var rightConstraint: NSLayoutConstraint?
34
- var heightConstraint: NSLayoutConstraint?
35
-
36
- if edges.contains(.top) {
37
- topConstraint = topAnchor.constraint(equalTo: view.topAnchor)
38
- topConstraint?.isActive = true
39
- }
40
-
41
- if edges.contains(.bottom) {
42
- bottomConstraint = bottomAnchor.constraint(equalTo: view.bottomAnchor)
43
- bottomConstraint?.isActive = true
44
- }
45
-
46
- if edges.contains(.left) {
47
- leftConstraint = leadingAnchor.constraint(equalTo: view.leadingAnchor)
48
- leftConstraint?.isActive = true
49
- }
50
-
51
- if edges.contains(.right) {
52
- rightConstraint = trailingAnchor.constraint(equalTo: view.trailingAnchor)
53
- rightConstraint?.isActive = true
54
- }
55
-
56
- if let height {
57
- heightConstraint = heightAnchor.constraint(equalToConstant: height)
58
- heightConstraint?.isActive = true
59
- }
60
-
61
- constraints?(Constraints(
62
- top: topConstraint,
63
- bottom: bottomConstraint,
64
- left: leftConstraint,
65
- right: rightConstraint,
66
- height: heightConstraint
67
- ))
68
- }
69
-
70
- func unpin() {
71
- translatesAutoresizingMaskIntoConstraints = true
72
- removeConstraints(constraints)
73
- }
74
- }
@@ -1,134 +0,0 @@
1
- //
2
- // Created by Jovanni Lo (@lodev09)
3
- // Copyright (c) 2024-present. All rights reserved.
4
- //
5
- // This source code is licensed under the MIT license found in the
6
- // LICENSE file in the root directory of this source tree.
7
- //
8
-
9
- @available(iOS 15.0, *)
10
- extension UISheetPresentationController.Detent.Identifier {
11
- static let small = UISheetPresentationController.Detent.Identifier("small")
12
- }
13
-
14
- @available(iOS 15.0, *)
15
- extension UIViewController {
16
- private func minValue(_ x: CGFloat?, _ maxHeight: CGFloat?) -> CGFloat {
17
- let x = x ?? 0
18
- guard let maxHeight else {
19
- return x
20
- }
21
-
22
- return min(x, maxHeight)
23
- }
24
-
25
- private func detentFor(identifier: UISheetPresentationController.Detent.Identifier,
26
- with maxHeight: CGFloat?,
27
- _ resolution: @escaping (CGFloat) -> Void) -> UISheetPresentationController.Detent {
28
- switch identifier {
29
- case .large:
30
- if #available(iOS 16.0, *) {
31
- return .custom(identifier: .large) { context in
32
- let value = self.minValue(UISheetPresentationController.Detent.large().resolvedValue(in: context), maxHeight)
33
- resolution(value)
34
- return value
35
- }
36
- } else {
37
- resolution(view.frame.height)
38
- return .large()
39
- }
40
- case .medium:
41
- if #available(iOS 16.0, *) {
42
- return .custom(identifier: .medium) { context in
43
- let value = self.minValue(UISheetPresentationController.Detent.medium().resolvedValue(in: context), maxHeight)
44
- resolution(value)
45
- return value
46
- }
47
- }
48
- case .small:
49
- if #available(iOS 16.0, *) {
50
- return .custom { context in
51
- let value = self.minValue(0.25 * context.maximumDetentValue, maxHeight)
52
- resolution(value)
53
- return value
54
- }
55
- }
56
- default:
57
- break
58
- }
59
-
60
- resolution(view.frame.height / 2)
61
- return .medium()
62
- }
63
-
64
- /// Get the custom detent based on the given size and view frame size
65
- func detentFor(_ anySize: Any,
66
- with height: CGFloat?,
67
- with maxHeight: CGFloat?,
68
- _ resolution: @escaping (String, CGFloat) -> Void) -> UISheetPresentationController.Detent {
69
- let id = "custom-\(anySize)"
70
-
71
- if let floatSize = anySize as? CGFloat {
72
- if #available(iOS 16.0, *) {
73
- return .custom(identifier: identifier(from: id)) { context in
74
- let value = min(floatSize, self.minValue(context.maximumDetentValue, maxHeight))
75
- resolution(id, value)
76
- return value
77
- }
78
- } else {
79
- return detentFor(identifier: .medium, with: maxHeight) { value in
80
- resolution(id, value)
81
- }
82
- }
83
- }
84
-
85
- if var stringSize = anySize as? String {
86
- switch stringSize {
87
- case "small":
88
- return detentFor(identifier: .small, with: maxHeight) { value in
89
- resolution(UISheetPresentationController.Detent.Identifier.small.rawValue, value)
90
- }
91
- case "medium":
92
- return detentFor(identifier: .medium, with: maxHeight) { value in
93
- resolution(UISheetPresentationController.Detent.Identifier.medium.rawValue, value)
94
- }
95
- case "large":
96
- return detentFor(identifier: .large, with: maxHeight) { value in
97
- resolution(UISheetPresentationController.Detent.Identifier.large.rawValue, value)
98
- }
99
- default:
100
- if #available(iOS 16.0, *) {
101
- if stringSize == "auto" {
102
- return .custom(identifier: identifier(from: id)) { context in
103
- let value = min(height ?? context.maximumDetentValue / 2, self.minValue(context.maximumDetentValue, maxHeight))
104
- resolution(id, value)
105
- return value
106
- }
107
- } else {
108
- // Percent
109
- stringSize.removeAll(where: { $0 == "%" })
110
- let floatSize = CGFloat((stringSize as NSString).floatValue)
111
- if floatSize > 0.0 {
112
- return .custom(identifier: identifier(from: id)) { context in
113
- let value = min((floatSize / 100) * context.maximumDetentValue, self.minValue(context.maximumDetentValue, maxHeight))
114
- resolution(id, value)
115
- return value
116
- }
117
- }
118
- }
119
- } else {
120
- return detentFor(identifier: .medium, with: maxHeight) { value in
121
- resolution(id, value)
122
- }
123
- }
124
- }
125
- }
126
-
127
- resolution(id, view.frame.height / 2)
128
- return .medium()
129
- }
130
-
131
- func identifier(from id: String) -> UISheetPresentationController.Detent.Identifier {
132
- return UISheetPresentationController.Detent.Identifier(id)
133
- }
134
- }
@@ -1,14 +0,0 @@
1
- //
2
- // Created by Jovanni Lo (@lodev09)
3
- // Copyright (c) 2024-present. All rights reserved.
4
- //
5
- // This source code is licensed under the MIT license found in the
6
- // LICENSE file in the root directory of this source tree.
7
- //
8
-
9
- #import <React/RCTBridgeModule.h>
10
- #import <React/RCTViewManager.h>
11
- #import <React/RCTUIManager.h>
12
- #import <React/RCTTouchHandler.h>
13
- #import <React/RCTSurfaceTouchHandler.h>
14
- #import <React/RCTScrollView.h>
@@ -1,48 +0,0 @@
1
- //
2
- // Created by Jovanni Lo (@lodev09)
3
- // Copyright (c) 2024-present. All rights reserved.
4
- //
5
- // This source code is licensed under the MIT license found in the
6
- // LICENSE file in the root directory of this source tree.
7
- //
8
-
9
- class TrueSheetEvent: NSObject, RCTEvent {
10
- var viewTag: NSNumber
11
-
12
- private var name: String
13
- private var data: [String: Any]?
14
-
15
- var eventName: String {
16
- return name
17
- }
18
-
19
- var coalescingKey: UInt16 {
20
- return 0
21
- }
22
-
23
- init(viewTag: NSNumber, name: String, data: [String: Any]?) {
24
- self.name = name
25
- self.viewTag = viewTag
26
- self.data = data
27
- }
28
-
29
- static func moduleDotMethod() -> String {
30
- return "RCTEventEmitter.receiveEvent"
31
- }
32
-
33
- func arguments() -> [Any] {
34
- return [
35
- viewTag,
36
- RCTNormalizeInputEventName(eventName)!,
37
- data ?? [:],
38
- ]
39
- }
40
-
41
- func canCoalesce() -> Bool {
42
- return true
43
- }
44
-
45
- func coalesce(with newEvent: RCTEvent) -> RCTEvent {
46
- return newEvent
47
- }
48
- }