ayodele
12/19/2022, 8:15 AMayodele
12/19/2022, 8:16 AMdisplay += listOf(email, password, button)
display.layout = constrain(email, password,button){view1, view2, view3 ->
<http://view1.top|view1.top> eq 10
view1.left eq 10
<http://view2.top|view2.top> eq view1.bottom + 10
view2.left eq 10
<http://view3.top|view3.top> eq view2.bottom + 10
view3.left eq 10
}
ayodele
12/19/2022, 8:16 AMNick
12/19/2022, 3:33 PMright
and bottom
are actually composite constraints that look like this:
view.right == view.left + view.width
view.bottom == <http://view.top|view.top> + view.height
This means your constraints are equivalent to writing:
display.layout = constrain(email, password, button) { view1, view2, view3 ->
<http://view1.top|view1.top> eq 10
view1.left eq 10
<http://view2.top|view2.top> eq <http://view1.top|view1.top> + view1.height + 10
view2.left eq 10
<http://view3.top|view3.top> eq <http://view2.top|view2.top> + view2.height + 10
view3.left eq 10
}
The constraint layout is therefor free to modify the height
value for both view1
and view2
. It chose to make view1.height
== 0
in this case, which is a valid solution. You can control this by doing one of two things: adding constraints to hold the heights, or expanding bottom
so you can make the height
components readOnly
Option 1
// preserve asks that a property remain unchanged
display.layout = constrain(email, password, button) { view1, view2, view3 ->
<http://view1.top|view1.top> eq 10
view1.left eq 10
view1.height.preserve // equivalent to view1.height = view1.height.readonly
<http://view2.top|view2.top> eq view1.bottom + 10
view2.left eq 10
view2.height.preserve // equivalent to view1.height = view1.height.readonly
<http://view3.top|view3.top> eq view2.bottom + 10
view3.left eq 10
}
Option 2
// expand bottom and ensure height is readOnly
display.layout = constrain(email, password, button) { view1, view2, view3 ->
<http://view1.top|view1.top> eq 10
view1.left eq 10
<http://view2.top|view2.top> eq <http://view1.top|view1.top> + view1.height.readOnly + 10
view2.left eq 10
<http://view3.top|view3.top> eq <http://view2.top|view2.top> + view2.height.readOnly + 10
view3.left eq 10
}
Cherrio LLC
12/21/2022, 9:13 AMTextField
?Nick
12/21/2022, 3:20 PMTextField
. In fact, the docs site has Accessibility enabled, so you can explore what is implemented for the components you see in the apps there.
There are still gaps, and this support only works for Web today. Please take a look and provide any feedback.