-
Notifications
You must be signed in to change notification settings - Fork 66
Expand file tree
/
Copy pathOnMentionEvent.kt
More file actions
40 lines (32 loc) · 1.21 KB
/
Copy pathOnMentionEvent.kt
File metadata and controls
40 lines (32 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package com.swmansion.enriched.textinput.events
import com.facebook.react.bridge.Arguments
import com.facebook.react.bridge.WritableMap
import com.facebook.react.uimanager.events.Event
class OnMentionEvent(
surfaceId: Int,
viewId: Int,
private val indicator: String,
private val text: String?,
private val experimentalSynchronousEvents: Boolean,
) : Event<OnMentionEvent>(surfaceId, viewId) {
override fun getEventName(): String = EVENT_NAME
// start/change/end can be emitted as a burst within a single frame
// (e.g. when switching mentions: end -> start -> change).
// The default coalescing would merge them in the batch and drop the
// intermediate ones, so it must be disabled to deliver every event in order.
override fun canCoalesce(): Boolean = false
override fun getEventData(): WritableMap? {
val eventData: WritableMap = Arguments.createMap()
eventData.putString("indicator", indicator)
if (text == null) {
eventData.putNull("text")
} else {
eventData.putString("text", text)
}
return eventData
}
override fun experimental_isSynchronous(): Boolean = experimentalSynchronousEvents
companion object {
const val EVENT_NAME: String = "onMention"
}
}