Skip to content

Commit

Permalink
Fixed issue that would cause iOS recycler view to push a small list d…
Browse files Browse the repository at this point in the history
…own to the bottom of the collection view.
  • Loading branch information
shanelk authored and bjsvedin committed Dec 12, 2024
1 parent 2f19aea commit f675cee
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -482,10 +482,10 @@ object ControlPerformanceTesting : Screen {
val text = Property("text")
h2 { content = "Text Fields" }
text { (::content)("Set without bind") { "Text: ${text()}" } }
textField { content bind text }
textField { content bind text } in card
textField { content bind text } in important
textField { content bind text } in critical
textInput { content bind text }
textInput { content bind text } in card
textInput { content bind text } in important
textInput { content bind text } in critical
} in card

col {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ object FormsScreen : Screen {
editor = {
label {
content = propName
textField { content bind prop }
textInput { content bind prop }
}
},
viewer = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,19 @@ actual class NRecyclerView(): UIScrollView(CGRectMake(0.0, 0.0, 0.0, 0.0)),

var capViewAtBottom: Boolean = false
set(value) {
field = value
if (value) {
val height = frame.useContents { this.size.height }
val lastSubViewBottom = if (allSubviews.isNotEmpty()) {
allSubviews.last().startPosition
+ allSubviews.last().element.frame.useContents { this.size.height }
} else {
0.0
}
field = if (lastSubViewBottom > height) {
value
} else {
false
}
if (field) {
val s = allSubviews.lastOrNull { it.visible }?.let { it.startPosition + it.size + spacingRaw } ?: return
setContentSize(if(vertical) CGSizeMake(0.0, s) else CGSizeMake(s, 0.0))
} else {
Expand Down Expand Up @@ -621,6 +632,7 @@ actual class NRecyclerView(): UIScrollView(CGRectMake(0.0, 0.0, 0.0, 0.0)),
viewportOffset = reservedScrollingSpace / 2
val element = makeSubview(startCreatingViewsAt.first.coerceIn(dataDirect.min, dataDirect.max), false)
element.measure()
log.log("View port offset $viewportOffset, SPACING ${spacing.value}")
element.startPosition = when(startCreatingViewsAt.second) {
Align.Start -> viewportOffset + spacing.value
Align.End -> viewportOffset + viewportSize - spacing.value - element.size
Expand Down

0 comments on commit f675cee

Please sign in to comment.