Unplanned
Last Updated: 18 Sep 2024 11:34 by ADMIN
Matthew
Created on: 17 Sep 2024 20:31
Category: CollectionView
Type: Feature Request
7
CollectionView: Add support for sticky group headers

Add support for sticky group headers (iOS, Android)

This feature is available in the ListView control. E.g. On iOS using the built-in CollectionView it can be added this way:

public class CollectionViewPlatformHandler : CollectionViewHandler { /// <inheritdoc /> protected override ItemsViewLayout SelectLayout() { var layout = base.SelectLayout(); if (ItemsView.IsGrouped && layout is UICollectionViewFlowLayout flowLayout) { // Enable sticky section headers. flowLayout.SectionHeadersPinToVisibleBounds = true; } return layout; } }

Add support for scrollable index titles (iOS).

This feature is available in the ListView control. E.g. On iOS using the built-in CollectionView it can be added this way:

    public class CollectionViewPlatformHandler : CollectionViewHandler
    {
        /// <inheritdoc />
        protected override UIView CreatePlatformView()
        {
            var platformView = base.CreatePlatformView();
            if (ItemsView.IsGrouped && ItemsView.ItemsSource is IEnumerable<IGrouping<string, object>> groups && platformView.Subviews[0] is UICollectionView collectionView)
            {
                // Enable index titles.
                collectionView.DataSource = new GroupedCollectionViewDataSource(collectionView.DataSource, groups.Select(q => q.Key));
            }

            return platformView;
        }
        
        private class GroupedCollectionViewDataSource(IUICollectionViewDataSource datasource, IEnumerable<string> sections) : UICollectionViewDataSource
        {
            public override nint NumberOfSections(UICollectionView collectionView) => datasource.NumberOfSections(collectionView);
            public override nint GetItemsCount(UICollectionView collectionView, nint section) => datasource.GetItemsCount(collectionView, section);
            public override UICollectionViewCell GetCell(UICollectionView collectionView, NSIndexPath indexPath) => datasource.GetCell(collectionView, indexPath);
            public override UICollectionReusableView GetViewForSupplementaryElement(UICollectionView collectionView, NSString elementKind, NSIndexPath indexPath) => datasource.GetViewForSupplementaryElement(collectionView, elementKind, indexPath);
            public override string[] GetIndexTitles(UICollectionView collectionView) => sections.ToArray();
        }
    }
 

Note: This is available out-of-the-box on iOS 14 and above for a native UICollectionView. See documentation.

https://developer.apple.com/documentation/uikit/uicollectionviewdatasource/2851455-indextitlesforcollectionview

3 comments
ADMIN
Didi
Posted on: 18 Sep 2024 11:34

Hi Matthew,

The Telerik MAUI CollectionView does not depend on the native iOS CollectionView. In general, the Telerik MAUI CollectionView is not a native control as the Telerik MAUI RadListView.

I have logged this feature for all platforms as I think such feature will be a good addition to the control's features set. Here is the link: https://feedback.telerik.com/maui/1664774-collectionview-add-support-for-scrollable-index-titles 

If you have any additional feedback and comments on the Telerik MAUI RadCollectionView, let me know.

Regards,
Didi
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Matthew
Posted on: 18 Sep 2024 10:56

Thanks Didi.

Unfortunately Android's RecyclerView does not have a built-in feature for index titles (like the right-aligned, scrollable list of titles in UICollectionView on iOS) for quick navigation. However it may be possible to implement using "fast-scroll support" e.g. https://medium.com/android-news/fast-scrolling-with-recyclerview-2b89d4574688

However it would be sufficient to implement this on iOS only initially since it is supported out-of-the-box.

Regards,

Matthew

ADMIN
Didi
Posted on: 18 Sep 2024 10:32

Hi Matthew,

Thank you for your feedback. 

I noticed you listed two different requests here. I will separate them as they are different requests. I will keep the first in this item and will log the second separately. But to be sure I understand your point could you please share whether the requested scenario for scrollable index title is only on iOS?

Looking forward to your reply.

Regards,
Didi
Progress Telerik