-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathAvoidSoftInputViewManager.kt
More file actions
87 lines (71 loc) · 3.29 KB
/
AvoidSoftInputViewManager.kt
File metadata and controls
87 lines (71 loc) · 3.29 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
package com.reactnativeavoidsoftinput
import com.facebook.react.module.annotations.ReactModule
import com.facebook.react.uimanager.ThemedReactContext
import com.facebook.react.uimanager.annotations.ReactProp
import com.facebook.react.viewmanagers.AvoidSoftInputViewManagerInterface
import com.facebook.react.views.view.ReactViewGroup
import com.facebook.react.views.view.ReactViewManager
import com.reactnativeavoidsoftinput.events.AvoidSoftInputAppliedOffsetChangedEvent
import com.reactnativeavoidsoftinput.events.AvoidSoftInputHeightChangedEvent
import com.reactnativeavoidsoftinput.events.AvoidSoftInputHiddenEvent
import com.reactnativeavoidsoftinput.events.AvoidSoftInputShownEvent
@ReactModule(name = AvoidSoftInputView.NAME)
class AvoidSoftInputViewManager :
ReactViewManager(), AvoidSoftInputViewManagerInterface<AvoidSoftInputView> {
private val delegate = AvoidSoftInputViewManagerDelegate(this)
override fun getName() = AvoidSoftInputView.NAME
override fun getDelegate() = delegate
override fun createViewInstance(context: ThemedReactContext): AvoidSoftInputView {
return AvoidSoftInputView(context)
}
override fun prepareToRecycleView(
reactContext: ThemedReactContext,
view: ReactViewGroup
): ReactViewGroup {
(view as AvoidSoftInputView).cleanup()
super.prepareToRecycleView(reactContext, view)
return view
}
@ReactProp(name = "avoidOffset")
override fun setAvoidOffset(view: AvoidSoftInputView, avoidOffset: Float) {
view.setAvoidOffset(avoidOffset)
}
@ReactProp(name = "easing")
override fun setEasing(view: AvoidSoftInputView, easing: String?) {
view.setEasing(easing)
}
@ReactProp(name = "enabled", defaultBoolean = true)
override fun setEnabled(view: AvoidSoftInputView, enabled: Boolean) {
view.setIsEnabled(enabled)
}
@ReactProp(name = "hideAnimationDelay")
override fun setHideAnimationDelay(view: AvoidSoftInputView, delay: Int) {
view.setHideAnimationDelay(delay)
}
@ReactProp(name = "hideAnimationDuration")
override fun setHideAnimationDuration(view: AvoidSoftInputView, duration: Int) {
view.setHideAnimationDuration(duration)
}
@ReactProp(name = "showAnimationDelay")
override fun setShowAnimationDelay(view: AvoidSoftInputView, delay: Int) {
view.setShowAnimationDelay(delay)
}
@ReactProp(name = "showAnimationDuration")
override fun setShowAnimationDuration(view: AvoidSoftInputView, duration: Int) {
view.setShowAnimationDuration(duration)
}
override fun getExportedCustomDirectEventTypeConstants(): MutableMap<String, Any> {
return hashMapOf(
AvoidSoftInputAppliedOffsetChangedEvent.NAME to
hashMapOf(
"registrationName" to AvoidSoftInputView.ON_SOFT_INPUT_APPLIED_OFFSET_CHANGE
),
AvoidSoftInputHeightChangedEvent.NAME to
hashMapOf("registrationName" to AvoidSoftInputView.ON_SOFT_INPUT_HEIGHT_CHANGE),
AvoidSoftInputHiddenEvent.NAME to
hashMapOf("registrationName" to AvoidSoftInputView.ON_SOFT_INPUT_HIDDEN),
AvoidSoftInputShownEvent.NAME to
hashMapOf("registrationName" to AvoidSoftInputView.ON_SOFT_INPUT_SHOWN)
)
}
}