Fixed issue updating the PeekAreaInsets property value (#7382)

This commit is contained in:
Javier Suárez Ruiz 2019-09-05 00:52:21 +02:00 коммит произвёл Rui Marinho
Родитель 79dd23edcb
Коммит b4c24ac249
1 изменённых файлов: 23 добавлений и 8 удалений

Просмотреть файл

@ -57,19 +57,13 @@ namespace Xamarin.Forms.Platform.Android
protected override void UpdateItemsSource()
{
// By default the CollectionViewAdapter creates the items at whatever size the template calls for
// But for the Carousel, we want it to create the items to fit the width/height of the viewport
// So we give it an alternate delegate for creating the views
ItemsViewAdapter = new ItemsViewAdapter<ItemsView, IItemsViewSource>(ItemsView,
(view, context) => new SizedItemContentView(Context, GetItemWidth, GetItemHeight));
SwapAdapter(ItemsViewAdapter, false);
UpdateAdapter();
}
protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs changedProperty)
{
if (changedProperty.Is(CarouselView.PeekAreaInsetsProperty))
Tracker?.UpdateLayout();
UpdatePeekAreaInsets();
else if (changedProperty.Is(CarouselView.IsSwipeEnabledProperty))
UpdateIsSwipeEnabled();
else if (changedProperty.Is(CarouselView.IsBounceEnabledProperty))
@ -186,6 +180,27 @@ namespace Xamarin.Forms.Platform.Android
OverScrollMode = Carousel.IsBounceEnabled ? OverScrollMode.Always : OverScrollMode.Never;
}
void UpdatePeekAreaInsets()
{
UpdateAdapter();
}
void UpdateAdapter()
{
// By default the CollectionViewAdapter creates the items at whatever size the template calls for
// But for the Carousel, we want it to create the items to fit the width/height of the viewport
// So we give it an alternate delegate for creating the views
var oldItemViewAdapter = ItemsViewAdapter;
ItemsViewAdapter = new ItemsViewAdapter<ItemsView, IItemsViewSource>(ItemsView,
(view, context) => new SizedItemContentView(Context, GetItemWidth, GetItemHeight));
SwapAdapter(ItemsViewAdapter, false);
oldItemViewAdapter?.Dispose();
}
void UpdatePositionFromScroll()
{
var snapHelper = GetSnapManager()?.GetCurrentSnapHelper();