roubachof / Sharpnado.CollectionView

A performant list view supporting: grid, horizontal and vertical layout, drag and drop, and reveal animations.
The Unlicense
244 stars 30 forks source link

[Feature Request] Reverse CollectionView layout #67

Closed KazysNoobiys closed 2 years ago

KazysNoobiys commented 2 years ago

I am making an application which has a chat room, for the chat need that the items would appear from the bottom up in a vertical list. Is it possible to add this functionality? Or at least tell me where to start. If for android it seems to be done simply, but for ios it looks like a difficult problem.

roubachof commented 2 years ago

There is a cool trick that works pretty well, I called it the double 180 trick.

First you add a rotatex=180 on your cells, then you add another rotatex=180 to the CollectionView itself and boom 🤯

Le mar. 24 mai 2022 à 09:37, KazysNoobiys @.***> a écrit :

I am making an application which has a chat room, for the chat need that the items would appear from the bottom up in a vertical list. Is it possible to add this functionality? Or at least tell me where to start. If for android it seems to be done simply, but for ios it looks like a difficult problem.

— Reply to this email directly, view it on GitHub https://github.com/roubachof/Sharpnado.CollectionView/issues/67, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAERXJYAPLEIWOVOFERPUSDVLSBKFANCNFSM5WYRW62A . You are receiving this because you are subscribed to this thread.Message ID: @.***>

KazysNoobiys commented 2 years ago

It looks cool! Thank you so much! Does this method have any hidden problems?

roubachof commented 2 years ago

I already used this trick and I didn't find any issues so far:

https://youtu.be/J9BTJyVFPfo?t=5799

KazysNoobiys commented 2 years ago

Really cool! Thanks for the response!

KazysNoobiys commented 2 years ago

Hmm hmm. I tried this method. On ios, at first glance, everything works correctly. But on android there is a problem with scrolling. In the end for android I decided to use the native way and for ios I used a double 180 degree rotation. Android:

public class ChatCollectionViewRenderer : CollectionViewRenderer
{
    public ChatCollectionViewRenderer(Context context) : base(context)
    {

    }
    protected override LayoutManager SelectLayoutManager(IItemsLayout layoutSpecification)
    {
        var layoutManager = base.SelectLayoutManager(layoutSpecification);
        if (layoutManager is LinearLayoutManager linearLayoutManager)
        {
            linearLayoutManager.ReverseLayout = true;
        }
        return layoutManager;
    }
}