Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix scroll to last item to take section inset into account #1832

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

hidoon
Copy link

@hidoon hidoon commented Feb 20, 2024

What does this implement/fix? Explain your changes.

This correction addresses the bug (issue #1830) where scrollToLastItem(at:animated:) didn't perform as expected. Previously, it would scroll to the last item without considering the sectionInset, eliminating the gap between the last cell and inputBarAccessoryView.

Does this close any currently open issues?

Yes it does, (issue #1830 )

Where has this been tested?

Devices/Simulators:

  • IOS Simulator iPhone 15 Pro Max / iOS 17.0.1
  • Physical Device iPhone 13 / iOS 17.2.1
    iOS Version:
  • IOS Simulator iPhone 15 Pro Max / iOS 17.0.1
  • Physical Device iPhone 13 / iOS 17.2.1
    Swift Version:
  • Swift 5.9
    MessageKit Version:
  • 4.2.0

Copy link
Member

@Kaspik Kaspik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you have a video with the fix implemented?

@luoshuaiqing
Copy link

luoshuaiqing commented Mar 10, 2024

Hi @hidoon ! It looks like this issue did not fully still not solved. For example, in the Example code's Advanced VC, after entering the advanced vc, it is also not scrolling correctly to the bottom. Would you mind helping take a look what is wrong? Thank you so much! (I was using a similar approach in the example code for my own project, and have spent 10+ hrs already but still couldn't solve the issue myself 😢 )

Update - It seems like the issue happens when the custom input bar's height is larger than the default input bar's

Screenshot 2024-03-10 at 12 12 36 PM

@luoshuaiqing
Copy link

Another issue I found is: if I created a custom footer view for the messages collection view, scroll to bottom has a large and very noticeable padding at the bottom, and seems to be the exactly one footer cell's height.

@hidoon
Copy link
Author

hidoon commented Mar 10, 2024

hi @luoshuaiqing, as far as I know, the messagesCollectionView is not related to inputBarAccessoryView, if you are talking about scrolling down. I don't know what to do to make pull request accepted and merged, but if you can, you can try to use my pull request to see if it fixes your issue. Btw, is the footer view you are talking about inputBarAccessoryView?

@luoshuaiqing
Copy link

hi @luoshuaiqing, as far as I know, the messagesCollectionView is not related to inputBarAccessoryView, if you are talking about scrolling down.

Oh I am not talking about scrolling down. I am talking about scrollToBottom() implementation in MessageKit is not correctly scrolling to bottom with custom input bar. (aka when I set messageInputBar = MyCustomView() and inputBarType = .custom(MyCustomView(). The fix in this PR didn't solve this issue unfortunately 😢

Btw, is the footer view you are talking about inputBarAccessoryView?

I am referring to messagesCollectionView.dequeueReusableFooterView(MyCustomFooterView.self, for: indexPath)

@hidoon
Copy link
Author

hidoon commented Mar 10, 2024

@luoshuaiqing Oh, I see. I think the problem you face is the height of your custom view is not taken into account and messagesCollectionView stays behind your custom view. Idk if there is a data source or delegate function to specify the height of your custom view, but if there is not, maybe you can set a specific contentInset to messagesCollectionView. That's a hacky way but it may work.

@luoshuaiqing
Copy link

Thanks for the advice, but it looks like it didn't work after I do something like messagesCollectionView.contentInset = UIEdgeInsets(top: 0, left: 0, bottom: messageInputBar.frame.height, right: 0), and also I don't think there is a delegate method for accessory view size calculator

@hidoon
Copy link
Author

hidoon commented May 17, 2024

hey luoshuaiqing and other who needs help, there is a function in InputBarAccessoryViewDelegate, which is delegate of messageInputBar, func inputBar(_ inputBar: InputBarAccessoryView, didChangeIntrinsicContentTo size: CGSize) gives new size.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants