widget/material: prevent invalid list item constraints

Previously, a bug in the ListStyle could result in items being
passed a negative value in the minimum constraints.

Signed-off-by: Chris Waldon <christopher.waldon.dev@gmail.com>
This commit is contained in:
Chris Waldon
2022-05-27 15:14:40 -04:00
committed by Elias Naur
parent cbbb5865e5
commit 99d0332067
2 changed files with 11 additions and 0 deletions
+6
View File
@@ -257,7 +257,13 @@ func (l ListStyle) Layout(gtx layout.Context, length int, w layout.ListElement)
max := l.state.Axis.Convert(gtx.Constraints.Max)
min := l.state.Axis.Convert(gtx.Constraints.Min)
max.Y -= barWidth
if max.Y < 0 {
max.Y = 0
}
min.Y -= barWidth
if min.Y < 0 {
min.Y = 0
}
gtx.Constraints.Max = l.state.Axis.Convert(max)
gtx.Constraints.Min = l.state.Axis.Convert(min)
}