Example #1
0
        internal override int IndexFromContainerInner(DependencyObject container)
        {
            if (_isProcessingReorder)
            {
                // When we process a re-ordering, the "attached" indexes (IndexForItemContainerProperty) are known to be valid,
                // but the native (NativePanel) is not (moved item is still at it's original location / index).

                return(base.IndexFromContainerInner(container));
            }

            if (NativePanel != null)
            {
                var selectorItem = container as SelectorItem;
                if (selectorItem == null)
                {
                    return(-1);
                }

                if (selectorItem.LayoutParameters is RecyclerView.LayoutParams)
                {
                    var displayPosition = NativePanel.GetChildLayoutPosition(selectorItem);
                    var index           = ConvertDisplayPositionToIndex(displayPosition);
                    return(index);
                }
            }

            return(base.IndexFromContainerInner(container));
        }
Example #2
0
        public void ScrollIntoView(object item, ScrollIntoViewAlignment alignment)
        {
            var index           = IndexFromItem(item);
            var displayPosition = ConvertIndexToDisplayPosition(index);

            NativePanel?.ScrollIntoView(displayPosition, alignment);
        }
Example #3
0
        private void ReplaceGroup(int groupIndexInView)
        {
            NativePanel?.ReloadSections(NSIndexSet.FromIndex(groupIndexInView));

            if (ManagedVirtualizingPanel != null)
            {
                Refresh();
            }
        }
Example #4
0
        /// <summary>
        /// Add a group using the native in-place modifier.
        /// </summary>
        /// <param name="groupIndexInView">The index of the group from the native collection view's perspective, ie ignoring empty groups
        /// if HidesIfEmpty=true.</param>
        private void AddGroup(int groupIndexInView)
        {
            NativePanel?.InsertSections(NSIndexSet.FromIndex(groupIndexInView));

            if (ManagedVirtualizingPanel != null)
            {
                Refresh();
            }
        }
Example #5
0
 public void ScrollIntoView(object item, ScrollIntoViewAlignment alignment)
 {
     // Dispatching ScrollIntoView on Android prevents issues where layout/render changes
     // occuring during scrolling are not always properly picked up by the layouting/rendering engine.
     Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
     {
         var index           = IndexFromItem(item);
         var displayPosition = ConvertIndexToDisplayPosition(index);
         NativePanel?.ScrollIntoView(displayPosition, alignment);
     });
 }
Example #6
0
 protected internal override IEnumerable <DependencyObject> GetItemsPanelChildren()
 {
     if (NativePanel != null)
     {
         return(NativePanel.GetChildren().OfType <DependencyObject>());
     }
     else
     {
         return(base.GetItemsPanelChildren());
     }
 }
Example #7
0
        private void Refresh()
        {
            NativePanel?.Refresh();

            if (ManagedVirtualizingPanel != null)
            {
                ManagedVirtualizingPanel.GetLayouter().Refresh();

                InvalidateMeasure();
            }
        }
Example #8
0
 public void ScrollIntoView(object item)
 {
     if (NativePanel != null)
     {
         NativePanel.ScrollIntoView(item);
     }
     else if (this.Log().IsEnabled(LogLevel.Warning))
     {
         this.Log().LogWarning($"{nameof(ScrollIntoView)} not supported when using non-virtualizing panels.");
     }
 }
Example #9
0
        private protected override void Refresh()
        {
            base.Refresh();

            NativePanel?.Refresh();

            if (ManagedVirtualizingPanel != null)
            {
                ManagedVirtualizingPanel.GetLayouter().Refresh();

                InvalidateMeasure();
            }
        }
Example #10
0
        internal override DependencyObject ContainerFromIndexInner(int index)
        {
            if (NativePanel != null)
            {
                var indexPath = GetIndexPathFromIndex(index)?.ToNSIndexPath();
                if (indexPath != null)
                {
                    return(NativePanel.ContainerFromIndex(indexPath));
                }
            }

            return(base.ContainerFromIndexInner(index));
        }
Example #11
0
 internal override int IndexFromContainerInner(DependencyObject container)
 {
     if (NativePanel != null)
     {
         var nativeContainer = (container as SelectorItem)?.FindFirstParent <ListViewBaseInternalContainer>();
         if (nativeContainer == null)
         {
             return(-1);
         }
         var indexPath = NativePanel.IndexPathForCell(nativeContainer);
         if (indexPath != null)
         {
             return(GetIndexFromIndexPath(indexPath.ToIndexPath()));
         }
     }
     return(base.IndexFromContainerInner(container));
 }
Example #12
0
        internal override int IndexFromContainerInner(DependencyObject container)
        {
            if (NativePanel != null)
            {
                var selectorItem = container as SelectorItem;
                if (selectorItem == null)
                {
                    return(-1);
                }

                if (selectorItem.LayoutParameters is RecyclerView.LayoutParams)
                {
                    var displayPosition = NativePanel.GetChildLayoutPosition(selectorItem);
                    var index           = ConvertDisplayPositionToIndex(displayPosition);
                    return(index);
                }
            }

            return(base.IndexFromContainerInner(container));
        }
        public Rect MakeVisible(UIElement visual, Rect rectangle)
        {
            if (visual is FrameworkElement fe)
            {
                var scrollRect = new Rect(
                    _occludedRectPadding.Left,
                    _occludedRectPadding.Top,
                    ActualWidth - _occludedRectPadding.Right,
                    ActualHeight - _occludedRectPadding.Bottom
                    );

                var visualPoint = UIElement.TransformToVisual(visual, null).TransformPoint(new Point());
                var visualRect  = new Rect(visualPoint, new Size(fe.ActualWidth, fe.ActualHeight));

                var deltaX = Math.Min(visualRect.Left - scrollRect.Left, Math.Max(0, visualRect.Right - scrollRect.Right));
                var deltaY = Math.Min(visualRect.Top - scrollRect.Top, Math.Max(0, visualRect.Bottom - scrollRect.Bottom));

                NativePanel.SmoothScrollBy(ViewHelper.LogicalToPhysicalPixels(deltaX), ViewHelper.LogicalToPhysicalPixels(deltaY));
            }

            return(rectangle);
        }
Example #14
0
        partial void OnApplyTemplatePartial()
        {
            var source = new ListViewBaseSource(NativePanel);

            NativePanel.Source = source;
            NativePanel.NativeLayout.Source = new WeakReference <ListViewBaseSource>(NativePanel.Source);

            BindToPanel(nameof(ItemsSource));

            NativePanel.AnimateScrollIntoView = AnimateScrollIntoView;

            var disposables = new CompositeDisposable();

            Action headerFooterCallback = () => NativePanel?.UpdateHeaderAndFooter();

            RegisterCallback(HeaderProperty, headerFooterCallback).DisposeWith(disposables);
            RegisterCallback(HeaderTemplateProperty, headerFooterCallback).DisposeWith(disposables);
            RegisterCallback(FooterProperty, headerFooterCallback).DisposeWith(disposables);
            RegisterCallback(FooterTemplateProperty, headerFooterCallback).DisposeWith(disposables);

            _callbackSubscriptions.Disposable = disposables;
        }
Example #15
0
        private protected override void Refresh()
        {
            base.Refresh();

            NativePanel?.Refresh();
        }
Example #16
0
 /// <summary>
 /// Add a group using the native in-place modifier.
 /// </summary>
 /// <param name="groupIndexInView">The index of the group from the native collection view's perspective, ie ignoring empty groups
 /// if HidesIfEmpty=true.</param>
 private void AddGroup(int groupIndexInView)
 {
     NativePanel?.InsertSections(NSIndexSet.FromIndex(groupIndexInView));
 }
 public override void ScrollTo(int x, int y)
 {
     NativePanel?.ScrollTo(x, y);
 }
Example #18
0
 private void Refresh()
 {
     NativePanel?.Refresh();
 }
 void IScrollContentPresenter.SmoothScrollTo(int physicalDeltaX, int physicalDeltaY)
 => NativePanel?.SmoothScrollTo(physicalDeltaX, physicalDeltaY);
Example #20
0
 /// <summary>
 /// Bind a property on the native collection panel to its equivalent on ListViewBase
 /// </summary>
 private void BindToPanel(string propertyName, BindingMode bindingMode = BindingMode.OneWay)
 {
     NativePanel.Binding(propertyName, propertyName, this, bindingMode);
 }
Example #21
0
 private void ReplaceGroup(int groupIndexInView)
 {
     NativePanel?.ReloadSections(NSIndexSet.FromIndex(groupIndexInView));
 }
Example #22
0
 private void RemoveGroup(int groupIndexInView)
 {
     NativePanel?.DeleteSections(NSIndexSet.FromIndex(groupIndexInView));
 }
 public void SmoothScrollTo(int x, int y)
 {
     NativePanel?.SmoothScrollTo(x, y);
 }
Example #24
0
        public override bool DispatchTouchEvent(MotionEvent e)
        {
            NativePanel?.TrackMotionDirections(e);

            return(base.DispatchTouchEvent(e));
        }
Example #25
0
        private void RemoveItems(int firstItem, int count, int section)
        {
            NativePanel?.DeleteItems(GetIndexPathsFromStartAndCount(firstItem, count, section));

            ManagedVirtualizingPanel?.GetLayouter().RemoveItems(firstItem, count, section);
        }
Example #26
0
 partial void NativeReplaceItems(int firstItem, int count, int section)
 {
     NativePanel?.ReloadItems(GetIndexPathsFromStartAndCount(firstItem, count, section));
 }
Example #27
0
 private void AddItems(int firstItem, int count, int section)
 {
     NativePanel?.InsertItems(GetIndexPathsFromStartAndCount(firstItem, count, section));
 }
Example #28
0
 private ContentControl ContainerFromGroupIndex(int groupIndex)
 {
     return(NativePanel?.ContainerFromGroupIndex(NSIndexPath.FromRowSection(0, groupIndex)));
 }
Example #29
0
 private void RemoveItems(int firstItem, int count, int section)
 {
     NativePanel?.DeleteItems(GetIndexPathsFromStartAndCount(firstItem, count, section));
 }