mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2025-03-14 09:45:42 +00:00
ios: fix small scroll on new message (#5721)
* ios: fix small scroll on new message * added inset in calculation of offset
This commit is contained in:
parent
f53b21f8c6
commit
ad4adf66ec
2 changed files with 10 additions and 12 deletions
|
@ -570,6 +570,14 @@ struct ChatView: View {
|
|||
.onChange(of: im.reversedChatItems) { items in
|
||||
mergedItems.boxedValue = MergedItems.create(items, revealedItems, im.chatState)
|
||||
scrollView.updateItems(mergedItems.boxedValue.items)
|
||||
if im.itemAdded {
|
||||
im.itemAdded = false
|
||||
if scrollView.listState.firstVisibleItemIndex < 2 {
|
||||
scrollView.scrollToBottomAnimated()
|
||||
} else {
|
||||
scrollView.scroll(by: 34)
|
||||
}
|
||||
}
|
||||
}
|
||||
.onChange(of: revealedItems) { revealed in
|
||||
mergedItems.boxedValue = MergedItems.create(im.reversedChatItems, revealed, im.chatState)
|
||||
|
@ -589,16 +597,6 @@ struct ChatView: View {
|
|||
searchTextChanged(s)
|
||||
}
|
||||
}
|
||||
.onChange(of: im.itemAdded) { added in
|
||||
if added {
|
||||
im.itemAdded = false
|
||||
if scrollView.listState.firstVisibleItemIndex < 2 {
|
||||
scrollView.scrollToBottomAnimated()
|
||||
} else {
|
||||
scrollView.scroll(by: 34)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -517,7 +517,7 @@ class EndlessScrollView<ScrollItem>: UIScrollView, UIScrollViewDelegate, UIGestu
|
|||
let y = if top {
|
||||
min(estimatedContentHeight.bottomOffsetY - bounds.height, item.view.frame.origin.y - insetTop)
|
||||
} else {
|
||||
max(estimatedContentHeight.topOffsetY - insetTop, item.view.frame.origin.y + item.view.bounds.height - bounds.height + insetBottom)
|
||||
max(estimatedContentHeight.topOffsetY - insetTop - insetBottom, item.view.frame.origin.y + item.view.bounds.height - bounds.height + insetBottom)
|
||||
}
|
||||
setContentOffset(CGPointMake(contentOffset.x, y), animated: false)
|
||||
scrollBarView.flashScrollIndicators()
|
||||
|
@ -568,7 +568,7 @@ class EndlessScrollView<ScrollItem>: UIScrollView, UIScrollViewDelegate, UIGestu
|
|||
let y = if top {
|
||||
min(estimatedContentHeight.bottomOffsetY - bounds.height, item.view.frame.origin.y - insetTop)
|
||||
} else {
|
||||
max(estimatedContentHeight.topOffsetY - insetTop, item.view.frame.origin.y + item.view.bounds.height - bounds.height + insetBottom)
|
||||
max(estimatedContentHeight.topOffsetY - insetTop - insetBottom, item.view.frame.origin.y + item.view.bounds.height - bounds.height + insetBottom)
|
||||
}
|
||||
setContentOffset(CGPointMake(contentOffset.x, y), animated: true)
|
||||
scrollBarView.flashScrollIndicators()
|
||||
|
|
Loading…
Add table
Reference in a new issue