react-native-controlled-input 0.12.2 → 0.12.3
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.
|
@@ -43,11 +43,34 @@ class ControlledInputView : LinearLayout, LifecycleOwner {
|
|
|
43
43
|
internal lateinit var viewModel: JetpackComposeViewModel
|
|
44
44
|
private val blurSignal = MutableStateFlow(0)
|
|
45
45
|
private val focusSignal = MutableStateFlow(0)
|
|
46
|
+
private lateinit var composeView: ComposeView
|
|
47
|
+
|
|
48
|
+
override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
|
|
49
|
+
if (composeView.isAttachedToWindow) {
|
|
50
|
+
super.onMeasure(widthMeasureSpec, heightMeasureSpec)
|
|
51
|
+
} else {
|
|
52
|
+
val width = maxOf(0, MeasureSpec.getSize(widthMeasureSpec) - paddingLeft - paddingRight)
|
|
53
|
+
val height = maxOf(0, MeasureSpec.getSize(heightMeasureSpec) - paddingTop - paddingBottom)
|
|
54
|
+
val child = composeView.getChildAt(0)
|
|
55
|
+
if (child == null) {
|
|
56
|
+
setMeasuredDimension(width, height)
|
|
57
|
+
return
|
|
58
|
+
}
|
|
59
|
+
child.measure(
|
|
60
|
+
MeasureSpec.makeMeasureSpec(width, MeasureSpec.getMode(widthMeasureSpec)),
|
|
61
|
+
MeasureSpec.makeMeasureSpec(height, MeasureSpec.getMode(heightMeasureSpec)),
|
|
62
|
+
)
|
|
63
|
+
setMeasuredDimension(
|
|
64
|
+
child.measuredWidth + paddingLeft + paddingRight,
|
|
65
|
+
child.measuredHeight + paddingTop + paddingBottom
|
|
66
|
+
)
|
|
67
|
+
}
|
|
68
|
+
}
|
|
46
69
|
|
|
47
70
|
override fun onAttachedToWindow() {
|
|
71
|
+
super.onAttachedToWindow()
|
|
48
72
|
setViewTreeLifecycleOwner(this)
|
|
49
73
|
lifecycleRegistry.currentState = Lifecycle.State.RESUMED
|
|
50
|
-
super.onAttachedToWindow()
|
|
51
74
|
}
|
|
52
75
|
|
|
53
76
|
override fun onDetachedFromWindow() {
|
|
@@ -80,7 +103,8 @@ class ControlledInputView : LinearLayout, LifecycleOwner {
|
|
|
80
103
|
LayoutParams.MATCH_PARENT
|
|
81
104
|
)
|
|
82
105
|
|
|
83
|
-
ComposeView(context)
|
|
106
|
+
composeView = ComposeView(context)
|
|
107
|
+
composeView.also { it ->
|
|
84
108
|
it.layoutParams = LayoutParams(
|
|
85
109
|
LayoutParams.MATCH_PARENT,
|
|
86
110
|
LayoutParams.MATCH_PARENT
|
package/package.json
CHANGED