11package com.reactnativeavoidsoftinput
22
3- import com.facebook.react.bridge.ReadableArray
43import com.facebook.react.module.annotations.ReactModule
5- import com.facebook.react.uimanager.BaseViewManagerDelegate
64import com.facebook.react.uimanager.ThemedReactContext
75import com.facebook.react.uimanager.annotations.ReactProp
86import com.facebook.react.viewmanagers.AvoidSoftInputViewManagerInterface
@@ -16,60 +14,14 @@ import com.reactnativeavoidsoftinput.events.AvoidSoftInputShownEvent
1614@ReactModule(name = AvoidSoftInputView .NAME )
1715class AvoidSoftInputViewManager :
1816 ReactViewManager (), AvoidSoftInputViewManagerInterface <AvoidSoftInputView > {
19- private val delegate =
20- object : BaseViewManagerDelegate <ReactViewGroup , AvoidSoftInputViewManager >(this ) {
21- override fun setProperty (view : ReactViewGroup , propName : String , value : Any? ) {
22- when (propName) {
23- " avoidOffset" ->
24- mViewManager.setAvoidOffset(
25- view as AvoidSoftInputView ,
26- (value as Double? )?.toFloat() ? : 0f
27- )
28- " easing" -> mViewManager.setEasing(view as AvoidSoftInputView , value as String? )
29- " enabled" ->
30- mViewManager.setEnabled(
31- view as AvoidSoftInputView ,
32- value as Boolean? ? : true
33- )
34- " hideAnimationDelay" ->
35- mViewManager.setHideAnimationDelay(
36- view as AvoidSoftInputView ,
37- (value as Double? )?.toInt() ? : 300
38- )
39- " hideAnimationDuration" ->
40- mViewManager.setHideAnimationDuration(
41- view as AvoidSoftInputView ,
42- (value as Double? )?.toInt() ? : 220
43- )
44- " showAnimationDelay" ->
45- mViewManager.setShowAnimationDelay(
46- view as AvoidSoftInputView ,
47- (value as Double? )?.toInt() ? : 0
48- )
49- " showAnimationDuration" ->
50- mViewManager.setShowAnimationDuration(
51- view as AvoidSoftInputView ,
52- (value as Double? )?.toInt() ? : 660
53- )
54- else -> super .setProperty(view, propName, value)
55- }
56- }
57-
58- override fun receiveCommand (
59- view : ReactViewGroup ,
60- commandName : String ,
61- args : ReadableArray ?
62- ) {
63- super .receiveCommand(view, commandName, args)
64- }
65- }
17+ private val delegate = AvoidSoftInputViewManagerDelegate (this )
6618
6719 override fun getName () = AvoidSoftInputView .NAME
6820
6921 override fun getDelegate () = delegate
7022
71- override fun createViewInstance (reactContext : ThemedReactContext ): AvoidSoftInputView {
72- return AvoidSoftInputView (reactContext )
23+ override fun createViewInstance (context : ThemedReactContext ): AvoidSoftInputView {
24+ return AvoidSoftInputView (context )
7325 }
7426
7527 override fun prepareToRecycleView (
0 commit comments