|
#nullable disable
using System;
using System.Collections.Generic;
using System.Text;
using Foundation;
using Microsoft.Maui.Handlers;
using ObjCRuntime;
using UIKit;
namespace Microsoft.Maui.Controls.Handlers.Items
{
public partial class GroupableItemsViewHandler<TItemsView> : SelectableItemsViewHandler<TItemsView> where TItemsView : GroupableItemsView
{
protected override ItemsViewController<TItemsView> CreateController(TItemsView itemsView, ItemsViewLayout layout)
=> new GroupableItemsViewController<TItemsView>(itemsView, layout);
protected override void ScrollToRequested(object sender, ScrollToRequestEventArgs args)
{
if (WillNeedScrollAdjustment(args))
{
if (args.IsAnimated)
{
(Controller as GroupableItemsViewController<TItemsView>).SetScrollAnimationEndedCallback(() => base.ScrollToRequested(sender, args));
}
else
{
base.ScrollToRequested(sender, args);
}
}
base.ScrollToRequested(sender, args);
}
public static void MapIsGrouped(GroupableItemsViewHandler<TItemsView> handler, GroupableItemsView itemsView)
{
handler.Controller?.UpdateItemsSource();
}
bool WillNeedScrollAdjustment(ScrollToRequestEventArgs args)
{
return ItemsView.ItemSizingStrategy == ItemSizingStrategy.MeasureAllItems
&& ItemsView.IsGrouped
&& (args.ScrollToPosition == ScrollToPosition.End || args.ScrollToPosition == ScrollToPosition.MakeVisible);
}
}
}
|