react-native-controlled-input 0.16.0 → 0.17.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.
|
@@ -2,6 +2,7 @@ package com.controlledinput
|
|
|
2
2
|
|
|
3
3
|
import android.content.Context
|
|
4
4
|
import android.util.AttributeSet
|
|
5
|
+
import android.util.TypedValue
|
|
5
6
|
import android.view.View
|
|
6
7
|
import android.view.inputmethod.InputMethodManager
|
|
7
8
|
import android.widget.EditText
|
|
@@ -84,7 +85,17 @@ class ControlledInputView : LinearLayout, LifecycleOwner {
|
|
|
84
85
|
}
|
|
85
86
|
|
|
86
87
|
private fun requestFocusProxy() {
|
|
88
|
+
// Sync textSize so KeyboardControllerSelectionWatcher computes the correct
|
|
89
|
+
// cursor Y via android.text.Layout.getLineBottom() — used as `customHeight`
|
|
90
|
+
// in KeyboardAwareScrollView to determine how far to scroll.
|
|
91
|
+
viewModel.inputStyle.value?.fontSize?.toFloat()?.let { fontSize ->
|
|
92
|
+
focusProxy.setTextSize(TypedValue.COMPLEX_UNIT_SP, fontSize)
|
|
93
|
+
}
|
|
87
94
|
focusProxy.requestFocus()
|
|
95
|
+
// setSelection triggers a selection change (lastSelectionStart starts at -1),
|
|
96
|
+
// guaranteeing the watcher fires on the next pre-draw frame even if focus
|
|
97
|
+
// was just transferred.
|
|
98
|
+
focusProxy.setSelection(0)
|
|
88
99
|
}
|
|
89
100
|
|
|
90
101
|
private fun clearFocusProxy() {
|
package/package.json
CHANGED