@lodev09/react-native-true-sheet 0.11.3 → 0.12.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 (42) hide show
  1. package/README.md +1 -1
  2. package/android/src/main/java/com/lodev09/truesheet/TrueSheetDialog.kt +27 -11
  3. package/android/src/main/java/com/lodev09/truesheet/TrueSheetView.kt +50 -16
  4. package/android/src/main/java/com/lodev09/truesheet/TrueSheetViewManager.kt +15 -3
  5. package/android/src/main/java/com/lodev09/truesheet/core/KeyboardManager.kt +2 -2
  6. package/android/src/main/java/com/lodev09/truesheet/core/RootSheetView.kt +26 -15
  7. package/android/src/main/java/com/lodev09/truesheet/events/DismissEvent.kt +16 -0
  8. package/android/src/main/java/com/lodev09/truesheet/events/MountEvent.kt +16 -0
  9. package/android/src/main/java/com/lodev09/truesheet/events/PresentEvent.kt +23 -0
  10. package/android/src/main/java/com/lodev09/truesheet/events/SizeChangeEvent.kt +23 -0
  11. package/ios/TrueSheetView.swift +71 -19
  12. package/ios/TrueSheetViewManager.m +3 -0
  13. package/lib/commonjs/TrueSheet.js +10 -0
  14. package/lib/commonjs/TrueSheet.js.map +1 -1
  15. package/lib/commonjs/{types.js → TrueSheet.types.js} +1 -1
  16. package/lib/commonjs/TrueSheet.types.js.map +1 -0
  17. package/lib/commonjs/index.js +8 -8
  18. package/lib/commonjs/index.js.map +1 -1
  19. package/lib/module/TrueSheet.js +10 -0
  20. package/lib/module/TrueSheet.js.map +1 -1
  21. package/lib/module/TrueSheet.types.js +2 -0
  22. package/lib/module/TrueSheet.types.js.map +1 -0
  23. package/lib/module/index.js +1 -1
  24. package/lib/module/index.js.map +1 -1
  25. package/lib/typescript/src/TrueSheet.d.ts +2 -1
  26. package/lib/typescript/src/TrueSheet.d.ts.map +1 -1
  27. package/lib/typescript/src/{types.d.ts → TrueSheet.types.d.ts} +19 -1
  28. package/lib/typescript/src/TrueSheet.types.d.ts.map +1 -0
  29. package/lib/typescript/src/TrueSheetFooter.d.ts +1 -1
  30. package/lib/typescript/src/TrueSheetFooter.d.ts.map +1 -1
  31. package/lib/typescript/src/index.d.ts +1 -1
  32. package/lib/typescript/src/index.d.ts.map +1 -1
  33. package/package.json +2 -2
  34. package/src/TrueSheet.tsx +12 -1
  35. package/src/{types.ts → TrueSheet.types.ts} +21 -0
  36. package/src/TrueSheetFooter.tsx +1 -1
  37. package/src/index.ts +1 -1
  38. package/android/src/main/java/com/lodev09/truesheet/core/Events.kt +0 -51
  39. package/lib/commonjs/types.js.map +0 -1
  40. package/lib/module/types.js +0 -2
  41. package/lib/module/types.js.map +0 -1
  42. package/lib/typescript/src/types.d.ts.map +0 -1
package/README.md CHANGED
@@ -6,7 +6,7 @@
6
6
 
7
7
  The true native bottom sheet experience for your React Native Apps. 💩
8
8
 
9
- <img alt="React Native True Sheet" src="docs/static/img/preview.gif" width="600px" />
9
+ <img alt="React Native True Sheet - IOS" src="docs/static/img/preview.gif" width="300" height="600" /><img alt="React Native True Sheet - Android" src="docs/static/img/preview-2.gif" width="300" height="600" />
10
10
 
11
11
  ## Features
12
12
 
@@ -19,6 +19,8 @@ class TrueSheetDialog(private val reactContext: ThemedReactContext, private val
19
19
  BottomSheetDialog(reactContext) {
20
20
 
21
21
  private var keyboardManager = KeyboardManager(reactContext)
22
+ private var sheetView: ViewGroup
23
+ private var windowAnimation: Int = 0
22
24
 
23
25
  /**
24
26
  * Specify whether the sheet background is dimmed.
@@ -53,19 +55,20 @@ class TrueSheetDialog(private val reactContext: ThemedReactContext, private val
53
55
 
54
56
  var sizes: Array<Any> = arrayOf("medium", "large")
55
57
 
56
- private var sheetView: ViewGroup
57
-
58
58
  init {
59
59
  setContentView(rootSheetView)
60
60
  sheetView = rootSheetView.parent as ViewGroup
61
61
  sheetView.setBackgroundColor(Color.TRANSPARENT)
62
62
 
63
- // Setup window params to adjust layout based on Keyboard state.
63
+ // Setup window params to adjust layout based on Keyboard state
64
64
  window?.apply {
65
65
  // SOFT_INPUT_ADJUST_RESIZE to resize the sheet above the keyboard
66
66
  setSoftInputMode(
67
67
  WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE
68
68
  )
69
+
70
+ // Store current windowAnimation value to toggle later
71
+ windowAnimation = attributes.windowAnimations
69
72
  }
70
73
 
71
74
  // Update the usable sheet height
@@ -107,10 +110,16 @@ class TrueSheetDialog(private val reactContext: ThemedReactContext, private val
107
110
  }
108
111
  }
109
112
 
113
+ fun resetAnimation() {
114
+ window?.apply {
115
+ setWindowAnimations(windowAnimation)
116
+ }
117
+ }
118
+
110
119
  /**
111
120
  * Present the sheet.
112
121
  */
113
- fun present(sizeIndex: Int) {
122
+ fun present(sizeIndex: Int, animated: Boolean = true) {
114
123
  setupDimmedBackground(sizeIndex)
115
124
  if (isShowing) {
116
125
  setStateForSizeIndex(sizeIndex)
@@ -118,7 +127,12 @@ class TrueSheetDialog(private val reactContext: ThemedReactContext, private val
118
127
  configure()
119
128
  setStateForSizeIndex(sizeIndex)
120
129
 
121
- this.show()
130
+ if (!animated) {
131
+ // Disable animation
132
+ window?.setWindowAnimations(0)
133
+ }
134
+
135
+ show()
122
136
  }
123
137
  }
124
138
 
@@ -178,10 +192,7 @@ class TrueSheetDialog(private val reactContext: ThemedReactContext, private val
178
192
  else -> (maxScreenHeight * 0.5).toInt()
179
193
  }
180
194
 
181
- return when (maxSheetHeight) {
182
- null -> height
183
- else -> minOf(height, maxSheetHeight ?: maxScreenHeight)
184
- }
195
+ return maxSheetHeight?.let { minOf(height, it, maxScreenHeight) } ?: minOf(height, maxScreenHeight)
185
196
  }
186
197
 
187
198
  /**
@@ -216,7 +227,7 @@ class TrueSheetDialog(private val reactContext: ThemedReactContext, private val
216
227
  * Also update footer's Y position.
217
228
  */
218
229
  fun registerKeyboardManager() {
219
- keyboardManager.registerKeyboardListener(object : KeyboardManager.OnKeyboardListener {
230
+ keyboardManager.registerKeyboardListener(object : KeyboardManager.OnKeyboardChangeListener {
220
231
  override fun onKeyboardStateChange(isVisible: Boolean, visibleHeight: Int?) {
221
232
  maxScreenHeight = when (isVisible) {
222
233
  true -> visibleHeight ?: 0
@@ -228,6 +239,10 @@ class TrueSheetDialog(private val reactContext: ThemedReactContext, private val
228
239
  })
229
240
  }
230
241
 
242
+ fun setOnSizeChangeListener(listener: RootSheetView.OnSizeChangeListener) {
243
+ rootSheetView.setOnSizeChangeListener(listener)
244
+ }
245
+
231
246
  /**
232
247
  * Remove keyboard listener.
233
248
  */
@@ -263,7 +278,8 @@ class TrueSheetDialog(private val reactContext: ThemedReactContext, private val
263
278
  isFitToContents = false
264
279
 
265
280
  setPeekHeight(getSizeHeight(sizes[0]), isShowing)
266
- halfExpandedRatio = getSizeHeight(sizes[1]).toFloat() / maxScreenHeight.toFloat()
281
+
282
+ halfExpandedRatio = minOf(getSizeHeight(sizes[1]).toFloat() / maxScreenHeight.toFloat(), 1.0f)
267
283
  maxHeight = getSizeHeight(sizes[2])
268
284
  }
269
285
  }
@@ -11,10 +11,11 @@ import com.facebook.react.uimanager.ThemedReactContext
11
11
  import com.facebook.react.uimanager.UIManagerHelper
12
12
  import com.facebook.react.uimanager.events.EventDispatcher
13
13
  import com.google.android.material.bottomsheet.BottomSheetBehavior
14
- import com.lodev09.truesheet.core.DismissEvent
15
- import com.lodev09.truesheet.core.PresentEvent
16
14
  import com.lodev09.truesheet.core.RootSheetView
17
- import com.lodev09.truesheet.core.SizeChangeEvent
15
+ import com.lodev09.truesheet.events.DismissEvent
16
+ import com.lodev09.truesheet.events.MountEvent
17
+ import com.lodev09.truesheet.events.PresentEvent
18
+ import com.lodev09.truesheet.events.SizeChangeEvent
18
19
 
19
20
  class TrueSheetView(context: Context) :
20
21
  ViewGroup(context),
@@ -27,6 +28,9 @@ class TrueSheetView(context: Context) :
27
28
  private val surfaceId: Int
28
29
  get() = UIManagerHelper.getSurfaceId(this)
29
30
 
31
+ var initialIndex: Int = -1
32
+ var initialIndexAnimated: Boolean = true
33
+
30
34
  /**
31
35
  * Current activeIndex.
32
36
  */
@@ -52,11 +56,6 @@ class TrueSheetView(context: Context) :
52
56
  */
53
57
  private val rootSheetView: RootSheetView
54
58
 
55
- /**
56
- * 2nd child of the container view.
57
- */
58
- private var footerView: ViewGroup? = null
59
-
60
59
  init {
61
60
  reactContext.addLifecycleEventListener(this)
62
61
  eventDispatcher = UIManagerHelper.getEventDispatcherForReactTag(reactContext, id)
@@ -77,13 +76,16 @@ class TrueSheetView(context: Context) :
77
76
  positionFooter()
78
77
  }
79
78
 
79
+ // Re-enable animation
80
+ resetAnimation()
81
+
80
82
  // Resolve the present promise
81
83
  presentPromise?.let { promise ->
82
84
  promise()
83
85
  presentPromise = null
84
86
  }
85
87
 
86
- // dispatch onPresent event
88
+ // Dispatch onPresent event
87
89
  eventDispatcher?.dispatchEvent(PresentEvent(surfaceId, id, sheetDialog.getSizeInfoForIndex(currentSizeIndex)))
88
90
  }
89
91
 
@@ -97,10 +99,17 @@ class TrueSheetView(context: Context) :
97
99
  dismissPromise = null
98
100
  }
99
101
 
100
- // dispatch onDismiss event
102
+ // Dispatch onDismiss event
101
103
  eventDispatcher?.dispatchEvent(DismissEvent(surfaceId, id))
102
104
  }
103
105
 
106
+ // Configure when showing and size changed
107
+ setOnSizeChangeListener(object : RootSheetView.OnSizeChangeListener {
108
+ override fun onSizeChange(width: Int, height: Int) {
109
+ maxScreenHeight = height
110
+ }
111
+ })
112
+
104
113
  // Configure sheet behavior events
105
114
  behavior.addBottomSheetCallback(
106
115
  object : BottomSheetBehavior.BottomSheetCallback() {
@@ -132,7 +141,7 @@ class TrueSheetView(context: Context) :
132
141
  currentSizeIndex = sizeInfo.index
133
142
  setupDimmedBackground(sizeInfo.index)
134
143
 
135
- // dispatch onSizeChange event
144
+ // Dispatch onSizeChange event
136
145
  eventDispatcher?.dispatchEvent(SizeChangeEvent(surfaceId, id, sizeInfo))
137
146
  }
138
147
  }
@@ -164,13 +173,28 @@ class TrueSheetView(context: Context) :
164
173
  visibility = GONE
165
174
 
166
175
  (child as ViewGroup).let {
167
- // Container View's first child is the Content View
168
- footerView = it.getChildAt(1) as ViewGroup
169
-
170
- sheetDialog.footerView = footerView
171
-
172
176
  // rootView's first child is the Container View
173
177
  rootSheetView.addView(it, index)
178
+
179
+ // Initialize content
180
+ UiThreadUtil.runOnUiThread {
181
+ // 1st child is the content view
182
+ val contentView = it.getChildAt(0) as ViewGroup
183
+ setContentHeight(contentView.height)
184
+
185
+ // 2nd child is the footer view
186
+ val footerView = it.getChildAt(1) as ViewGroup
187
+ sheetDialog.footerView = footerView
188
+ setFooterHeight(footerView.height)
189
+
190
+ if (initialIndex >= 0) {
191
+ currentSizeIndex = initialIndex
192
+ sheetDialog.present(initialIndex, initialIndexAnimated)
193
+ }
194
+
195
+ // Dispatch onMount event
196
+ eventDispatcher?.dispatchEvent(MountEvent(surfaceId, id))
197
+ }
174
198
  }
175
199
  }
176
200
 
@@ -224,21 +248,29 @@ class TrueSheetView(context: Context) :
224
248
  }
225
249
 
226
250
  fun setMaxHeight(height: Int) {
251
+ if (sheetDialog.maxSheetHeight == height) return
252
+
227
253
  sheetDialog.maxSheetHeight = height
228
254
  configureIfShowing()
229
255
  }
230
256
 
231
257
  fun setContentHeight(height: Int) {
258
+ if (sheetDialog.contentHeight == height) return
259
+
232
260
  sheetDialog.contentHeight = height
233
261
  configureIfShowing()
234
262
  }
235
263
 
236
264
  fun setFooterHeight(height: Int) {
265
+ if (sheetDialog.footerHeight == height) return
266
+
237
267
  sheetDialog.footerHeight = height
238
268
  configureIfShowing()
239
269
  }
240
270
 
241
271
  fun setDimmed(dimmed: Boolean) {
272
+ if (sheetDialog.dimmed == dimmed) return
273
+
242
274
  sheetDialog.dimmed = dimmed
243
275
  if (sheetDialog.isShowing) {
244
276
  sheetDialog.setupDimmedBackground(currentSizeIndex)
@@ -246,6 +278,8 @@ class TrueSheetView(context: Context) :
246
278
  }
247
279
 
248
280
  fun setDimmedIndex(index: Int) {
281
+ if (sheetDialog.dimmedIndex == index) return
282
+
249
283
  sheetDialog.dimmedIndex = index
250
284
  if (sheetDialog.isShowing) {
251
285
  sheetDialog.setupDimmedBackground(currentSizeIndex)
@@ -7,10 +7,11 @@ import com.facebook.react.common.MapBuilder
7
7
  import com.facebook.react.uimanager.ThemedReactContext
8
8
  import com.facebook.react.uimanager.ViewGroupManager
9
9
  import com.facebook.react.uimanager.annotations.ReactProp
10
- import com.lodev09.truesheet.core.DismissEvent
11
- import com.lodev09.truesheet.core.PresentEvent
12
- import com.lodev09.truesheet.core.SizeChangeEvent
13
10
  import com.lodev09.truesheet.core.Utils
11
+ import com.lodev09.truesheet.events.DismissEvent
12
+ import com.lodev09.truesheet.events.MountEvent
13
+ import com.lodev09.truesheet.events.PresentEvent
14
+ import com.lodev09.truesheet.events.SizeChangeEvent
14
15
 
15
16
  class TrueSheetViewManager : ViewGroupManager<TrueSheetView>() {
16
17
  override fun getName() = TAG
@@ -24,6 +25,7 @@ class TrueSheetViewManager : ViewGroupManager<TrueSheetView>() {
24
25
 
25
26
  override fun getExportedCustomDirectEventTypeConstants(): MutableMap<String, Any>? =
26
27
  MapBuilder.builder<String, Any>()
28
+ .put(MountEvent.EVENT_NAME, MapBuilder.of("registrationName", "onMount"))
27
29
  .put(PresentEvent.EVENT_NAME, MapBuilder.of("registrationName", "onPresent"))
28
30
  .put(DismissEvent.EVENT_NAME, MapBuilder.of("registrationName", "onDismiss"))
29
31
  .put(SizeChangeEvent.EVENT_NAME, MapBuilder.of("registrationName", "onSizeChange"))
@@ -44,6 +46,16 @@ class TrueSheetViewManager : ViewGroupManager<TrueSheetView>() {
44
46
  view.setDimmed(dimmed)
45
47
  }
46
48
 
49
+ @ReactProp(name = "initialIndex")
50
+ fun setInitialIndex(view: TrueSheetView, index: Int) {
51
+ view.initialIndex = index
52
+ }
53
+
54
+ @ReactProp(name = "initialIndexAnimated")
55
+ fun setInitialIndexAnimated(view: TrueSheetView, animate: Boolean) {
56
+ view.initialIndexAnimated = animate
57
+ }
58
+
47
59
  @ReactProp(name = "dimmedIndex")
48
60
  fun setDimmedIndex(view: TrueSheetView, index: Int) {
49
61
  view.setDimmedIndex(index)
@@ -7,7 +7,7 @@ import android.view.inputmethod.InputMethodManager
7
7
  import com.facebook.react.bridge.ReactContext
8
8
 
9
9
  class KeyboardManager(reactContext: ReactContext) {
10
- interface OnKeyboardListener {
10
+ interface OnKeyboardChangeListener {
11
11
  fun onKeyboardStateChange(isVisible: Boolean, visibleHeight: Int?)
12
12
  }
13
13
 
@@ -20,7 +20,7 @@ class KeyboardManager(reactContext: ReactContext) {
20
20
  contentView = activity?.findViewById(android.R.id.content)
21
21
  }
22
22
 
23
- fun registerKeyboardListener(listener: OnKeyboardListener?) {
23
+ fun registerKeyboardListener(listener: OnKeyboardChangeListener?) {
24
24
  contentView?.apply {
25
25
  unregisterKeyboardListener()
26
26
 
@@ -26,21 +26,26 @@ import com.facebook.react.views.view.ReactViewGroup
26
26
  * styleHeight on the LayoutShadowNode to be the window size. This is done through the
27
27
  * UIManagerModule, and will then cause the children to layout as if they can fill the window.
28
28
  */
29
- class RootSheetView(context: Context?) :
29
+ class RootSheetView(private val context: Context?) :
30
30
  ReactViewGroup(context),
31
31
  RootView {
32
32
  private var hasAdjustedSize = false
33
33
  private var viewWidth = 0
34
34
  private var viewHeight = 0
35
35
 
36
- private val mJSTouchDispatcher = JSTouchDispatcher(this)
37
- private var mJSPointerDispatcher: JSPointerDispatcher? = null
36
+ private val jSTouchDispatcher = JSTouchDispatcher(this)
37
+ private var jSPointerDispatcher: JSPointerDispatcher? = null
38
+ private var sizeChangeListener: OnSizeChangeListener? = null
38
39
 
39
40
  var eventDispatcher: EventDispatcher? = null
40
41
 
42
+ interface OnSizeChangeListener {
43
+ fun onSizeChange(width: Int, height: Int)
44
+ }
45
+
41
46
  init {
42
47
  if (ReactFeatureFlags.dispatchPointerEvents) {
43
- mJSPointerDispatcher = JSPointerDispatcher(this)
48
+ jSPointerDispatcher = JSPointerDispatcher(this)
44
49
  }
45
50
  }
46
51
 
@@ -50,6 +55,12 @@ class RootSheetView(context: Context?) :
50
55
  viewWidth = w
51
56
  viewHeight = h
52
57
  updateFirstChildView()
58
+
59
+ sizeChangeListener?.onSizeChange(w, h)
60
+ }
61
+
62
+ fun setOnSizeChangeListener(listener: OnSizeChangeListener) {
63
+ sizeChangeListener = listener
53
64
  }
54
65
 
55
66
  private fun updateFirstChildView() {
@@ -88,15 +99,15 @@ class RootSheetView(context: Context?) :
88
99
  get() = context as ThemedReactContext
89
100
 
90
101
  override fun onInterceptTouchEvent(event: MotionEvent): Boolean {
91
- mJSTouchDispatcher.handleTouchEvent(event, eventDispatcher)
92
- mJSPointerDispatcher?.handleMotionEvent(event, eventDispatcher, true)
102
+ jSTouchDispatcher.handleTouchEvent(event, eventDispatcher)
103
+ jSPointerDispatcher?.handleMotionEvent(event, eventDispatcher, true)
93
104
  return super.onInterceptTouchEvent(event)
94
105
  }
95
106
 
96
107
  @SuppressLint("ClickableViewAccessibility")
97
108
  override fun onTouchEvent(event: MotionEvent): Boolean {
98
- mJSTouchDispatcher.handleTouchEvent(event, eventDispatcher)
99
- mJSPointerDispatcher?.handleMotionEvent(event, eventDispatcher, false)
109
+ jSTouchDispatcher.handleTouchEvent(event, eventDispatcher)
110
+ jSPointerDispatcher?.handleMotionEvent(event, eventDispatcher, false)
100
111
  super.onTouchEvent(event)
101
112
 
102
113
  // In case when there is no children interested in handling touch event, we return true from
@@ -105,28 +116,28 @@ class RootSheetView(context: Context?) :
105
116
  }
106
117
 
107
118
  override fun onInterceptHoverEvent(event: MotionEvent): Boolean {
108
- mJSPointerDispatcher?.handleMotionEvent(event, eventDispatcher, true)
119
+ jSPointerDispatcher?.handleMotionEvent(event, eventDispatcher, true)
109
120
  return super.onHoverEvent(event)
110
121
  }
111
122
 
112
123
  override fun onHoverEvent(event: MotionEvent): Boolean {
113
- mJSPointerDispatcher?.handleMotionEvent(event, eventDispatcher, false)
124
+ jSPointerDispatcher?.handleMotionEvent(event, eventDispatcher, false)
114
125
  return super.onHoverEvent(event)
115
126
  }
116
127
 
117
128
  @Deprecated("Deprecated in Java")
118
129
  override fun onChildStartedNativeGesture(ev: MotionEvent?) {
119
- mJSTouchDispatcher.onChildStartedNativeGesture(ev, eventDispatcher)
130
+ jSTouchDispatcher.onChildStartedNativeGesture(ev, eventDispatcher)
120
131
  }
121
132
 
122
133
  override fun onChildStartedNativeGesture(childView: View, ev: MotionEvent) {
123
- mJSTouchDispatcher.onChildStartedNativeGesture(ev, eventDispatcher)
124
- mJSPointerDispatcher?.onChildStartedNativeGesture(childView, ev, eventDispatcher)
134
+ jSTouchDispatcher.onChildStartedNativeGesture(ev, eventDispatcher)
135
+ jSPointerDispatcher?.onChildStartedNativeGesture(childView, ev, eventDispatcher)
125
136
  }
126
137
 
127
138
  override fun onChildEndedNativeGesture(childView: View, ev: MotionEvent) {
128
- mJSTouchDispatcher.onChildEndedNativeGesture(ev, eventDispatcher)
129
- mJSPointerDispatcher?.onChildEndedNativeGesture()
139
+ jSTouchDispatcher.onChildEndedNativeGesture(ev, eventDispatcher)
140
+ jSPointerDispatcher?.onChildEndedNativeGesture()
130
141
  }
131
142
 
132
143
  override fun requestDisallowInterceptTouchEvent(disallowIntercept: Boolean) {
@@ -0,0 +1,16 @@
1
+ package com.lodev09.truesheet.events
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
+ // onDismiss
8
+ class DismissEvent(surfaceId: Int, viewId: Int) : Event<DismissEvent>(surfaceId, viewId) {
9
+ override fun getEventName() = EVENT_NAME
10
+
11
+ override fun getEventData(): WritableMap = Arguments.createMap()
12
+
13
+ companion object {
14
+ const val EVENT_NAME = "dismiss"
15
+ }
16
+ }
@@ -0,0 +1,16 @@
1
+ package com.lodev09.truesheet.events
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
+ // onMount
8
+ class MountEvent(surfaceId: Int, viewId: Int) : Event<MountEvent>(surfaceId, viewId) {
9
+ override fun getEventName() = EVENT_NAME
10
+
11
+ override fun getEventData(): WritableMap = Arguments.createMap()
12
+
13
+ companion object {
14
+ const val EVENT_NAME = "ready"
15
+ }
16
+ }
@@ -0,0 +1,23 @@
1
+ package com.lodev09.truesheet.events
2
+
3
+ import com.facebook.react.bridge.Arguments
4
+ import com.facebook.react.bridge.WritableMap
5
+ import com.facebook.react.uimanager.events.Event
6
+ import com.lodev09.truesheet.SizeInfo
7
+
8
+ // onPresent
9
+ class PresentEvent(surfaceId: Int, viewId: Int, private val sizeInfo: SizeInfo) : Event<PresentEvent>(surfaceId, viewId) {
10
+ override fun getEventName() = EVENT_NAME
11
+
12
+ override fun getEventData(): WritableMap {
13
+ val data = Arguments.createMap()
14
+ data.putInt("index", sizeInfo.index)
15
+ data.putDouble("value", sizeInfo.value.toDouble())
16
+
17
+ return data
18
+ }
19
+
20
+ companion object {
21
+ const val EVENT_NAME = "present"
22
+ }
23
+ }
@@ -0,0 +1,23 @@
1
+ package com.lodev09.truesheet.events
2
+
3
+ import com.facebook.react.bridge.Arguments
4
+ import com.facebook.react.bridge.WritableMap
5
+ import com.facebook.react.uimanager.events.Event
6
+ import com.lodev09.truesheet.SizeInfo
7
+
8
+ // onSizeChange
9
+ class SizeChangeEvent(surfaceId: Int, viewId: Int, private val sizeInfo: SizeInfo) : Event<SizeChangeEvent>(surfaceId, viewId) {
10
+ override fun getEventName() = EVENT_NAME
11
+
12
+ override fun getEventData(): WritableMap {
13
+ val data = Arguments.createMap()
14
+ data.putInt("index", sizeInfo.index)
15
+ data.putDouble("value", sizeInfo.value.toDouble())
16
+
17
+ return data
18
+ }
19
+
20
+ companion object {
21
+ const val EVENT_NAME = "sizeChange"
22
+ }
23
+ }