react-native-controlled-input 0.12.1 → 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,6 +43,29 @@ 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() {
48
71
  super.onAttachedToWindow()
@@ -80,7 +103,8 @@ class ControlledInputView : LinearLayout, LifecycleOwner {
80
103
  LayoutParams.MATCH_PARENT
81
104
  )
82
105
 
83
- ComposeView(context).also {
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-controlled-input",
3
- "version": "0.12.1",
3
+ "version": "0.12.3",
4
4
  "description": "React Native Controlled Inputative Controlled Input",
5
5
  "main": "./lib/module/index.js",
6
6
  "types": "./lib/typescript/src/index.d.ts",