コード例 #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));
        }
コード例 #2
0
        public void ScrollIntoView(object item, ScrollIntoViewAlignment alignment)
        {
            var index           = IndexFromItem(item);
            var displayPosition = ConvertIndexToDisplayPosition(index);

            NativePanel?.ScrollIntoView(displayPosition, alignment);
        }
コード例 #3
0
ファイル: ListViewBase.iOS.cs プロジェクト: unoplatform/uno
        private void ReplaceGroup(int groupIndexInView)
        {
            NativePanel?.ReloadSections(NSIndexSet.FromIndex(groupIndexInView));

            if (ManagedVirtualizingPanel != null)
            {
                Refresh();
            }
        }
コード例 #4
0
ファイル: ListViewBase.iOS.cs プロジェクト: unoplatform/uno
        /// <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();
            }
        }
コード例 #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);
     });
 }
コード例 #6
0
 protected internal override IEnumerable <DependencyObject> GetItemsPanelChildren()
 {
     if (NativePanel != null)
     {
         return(NativePanel.GetChildren().OfType <DependencyObject>());
     }
     else
     {
         return(base.GetItemsPanelChildren());
     }
 }
コード例 #7
0
        private void Refresh()
        {
            NativePanel?.Refresh();

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

                InvalidateMeasure();
            }
        }
コード例 #8
0
ファイル: ListViewBase.iOS.cs プロジェクト: unoplatform/uno
 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.");
     }
 }
コード例 #9
0
ファイル: ListViewBase.iOS.cs プロジェクト: unoplatform/uno
        private protected override void Refresh()
        {
            base.Refresh();

            NativePanel?.Refresh();

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

                InvalidateMeasure();
            }
        }
コード例 #10
0
ファイル: ListViewBase.iOS.cs プロジェクト: unoplatform/uno
        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));
        }
コード例 #11
0
ファイル: ListViewBase.iOS.cs プロジェクト: unoplatform/uno
 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));
 }
コード例 #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));
        }
コード例 #13
0
        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);
        }
コード例 #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;
        }
コード例 #15
0
        private protected override void Refresh()
        {
            base.Refresh();

            NativePanel?.Refresh();
        }
コード例 #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));
 }
コード例 #17
0
 public override void ScrollTo(int x, int y)
 {
     NativePanel?.ScrollTo(x, y);
 }
コード例 #18
0
 private void Refresh()
 {
     NativePanel?.Refresh();
 }
コード例 #19
0
 void IScrollContentPresenter.SmoothScrollTo(int physicalDeltaX, int physicalDeltaY)
 => NativePanel?.SmoothScrollTo(physicalDeltaX, physicalDeltaY);
コード例 #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);
 }
コード例 #21
0
 private void ReplaceGroup(int groupIndexInView)
 {
     NativePanel?.ReloadSections(NSIndexSet.FromIndex(groupIndexInView));
 }
コード例 #22
0
 private void RemoveGroup(int groupIndexInView)
 {
     NativePanel?.DeleteSections(NSIndexSet.FromIndex(groupIndexInView));
 }
コード例 #23
0
 public void SmoothScrollTo(int x, int y)
 {
     NativePanel?.SmoothScrollTo(x, y);
 }
コード例 #24
0
        public override bool DispatchTouchEvent(MotionEvent e)
        {
            NativePanel?.TrackMotionDirections(e);

            return(base.DispatchTouchEvent(e));
        }
コード例 #25
0
ファイル: ListViewBase.iOS.cs プロジェクト: unoplatform/uno
        private void RemoveItems(int firstItem, int count, int section)
        {
            NativePanel?.DeleteItems(GetIndexPathsFromStartAndCount(firstItem, count, section));

            ManagedVirtualizingPanel?.GetLayouter().RemoveItems(firstItem, count, section);
        }
コード例 #26
0
ファイル: ListViewBase.iOS.cs プロジェクト: unoplatform/uno
 partial void NativeReplaceItems(int firstItem, int count, int section)
 {
     NativePanel?.ReloadItems(GetIndexPathsFromStartAndCount(firstItem, count, section));
 }
コード例 #27
0
 private void AddItems(int firstItem, int count, int section)
 {
     NativePanel?.InsertItems(GetIndexPathsFromStartAndCount(firstItem, count, section));
 }
コード例 #28
0
ファイル: ListViewBase.iOS.cs プロジェクト: unoplatform/uno
 private ContentControl ContainerFromGroupIndex(int groupIndex)
 {
     return(NativePanel?.ContainerFromGroupIndex(NSIndexPath.FromRowSection(0, groupIndex)));
 }
コード例 #29
0
 private void RemoveItems(int firstItem, int count, int section)
 {
     NativePanel?.DeleteItems(GetIndexPathsFromStartAndCount(firstItem, count, section));
 }