public virtual void ReloadPagerTabStripView() { if (IsViewLoaded) { foreach (UIViewController childController in ViewControllers) { if (childController.ParentViewController != null) { childController.BeginAppearanceTransition(false, false); childController.WillMoveToParentViewController(null); childController.View.RemoveFromSuperview(); childController.RemoveFromParentViewController(); childController.EndAppearanceTransition(); } } ReloadViewControllers(); ContainerView.ContentSize = new CGSize(ContainerView.Bounds.Width * new nfloat(ViewControllers.Count()), ContainerView.ContentSize.Height); if (CurrentIndex >= ViewControllers.Count()) { CurrentIndex = (uint)ViewControllers.Count() - 1; } ContainerView.ContentOffset = new CGPoint(PageOffsetForChildIndex(CurrentIndex), 0); UpdateContent(); } }
public nfloat?[] CalculateWidths() { var flowLayout = ButtonBarView.CollectionViewLayout as UICollectionViewFlowLayout; var numberOfCells = ViewControllers.Count(); List <nfloat> minimumCellWidths = new List <nfloat>(); nfloat collectionViewContentWidth = 0; foreach (var viewController in ViewControllers) { var childController = viewController as IIndicatorInfoProvider; var indicatorInfo = childController.IndicatorInfoForPagerTabStrip(this); if (ButtonBarItemSpec.NibName == null) { nfloat width = width = ButtonBarItemSpec.WidthCallback(indicatorInfo); minimumCellWidths.Add(width); collectionViewContentWidth += width; } else { nfloat width = width = ButtonBarItemSpec.WidthCallback(indicatorInfo); minimumCellWidths.Add(width); collectionViewContentWidth += width; } } var cellSpacingTotal = new nfloat(numberOfCells - 1) * flowLayout.MinimumLineSpacing; collectionViewContentWidth += cellSpacingTotal; nfloat collectionViewAvailableVisibleWidth = ButtonBarView.Frame.Size.Width - flowLayout.SectionInset.Left - flowLayout.SectionInset.Right; if (!Settings.Style.ButtonBarItemsShouldFillAvailiableWidth || collectionViewAvailableVisibleWidth < collectionViewContentWidth) { return(minimumCellWidths.Select(i => (nfloat?)i).ToList().ToArray()); } else { var stretchedCellWidthIfAllEqual = (collectionViewAvailableVisibleWidth - cellSpacingTotal) / new nfloat(numberOfCells); var generalMinimumCellWidth = CalculateStretchedCellWidths(minimumCellWidths.ToArray(), suggestedStretchedCellWidth: stretchedCellWidthIfAllEqual, previousNumberOfLargeCells: 0); List <nfloat> stretchedCellWidths = new List <nfloat>(); foreach (nfloat minimumCellWidthValue in minimumCellWidths) { var cellWidth = (minimumCellWidthValue > generalMinimumCellWidth) ? minimumCellWidthValue : generalMinimumCellWidth; stretchedCellWidths.Add(cellWidth); } return(stretchedCellWidths.Select(i => (nfloat?)i).ToList().ToArray()); } }
public int PageForVirtualPage(int virtualPage) { if (virtualPage < 0) { return(0); } if (virtualPage > ViewControllers.Count() - 1) { return(ViewControllers.Count() - 1); } return(virtualPage); }
private Tuple <int, int, nfloat> ProgressiveIndicatorData(uint virtualPage) { var count = ViewControllers.Count(); int fromIndex = (int)CurrentIndex; int toIndex = (int)CurrentIndex; SwipeDirection direction = SwipeDirection; if (direction == SwipeDirection.Left) { if (virtualPage > count - 1) { fromIndex = count - 1; toIndex = count; } else { if (ScrollPercentage >= 0.5) { fromIndex = Math.Max(toIndex - 1, 0); } else { toIndex = fromIndex + 1; } } } else if (direction == SwipeDirection.Right) { if (virtualPage < 0) { fromIndex = 0; toIndex = -1; } else { if (ScrollPercentage > 0.5) { fromIndex = Math.Min(toIndex + 1, count - 1); } else { toIndex = fromIndex - 1; } } } var scrollPercentage = PagerBehaviour.ElasticIndicatorLimit == true ? ScrollPercentage : ((toIndex < 0 || toIndex >= count) ? 0.0 : ScrollPercentage); return(new Tuple <int, int, nfloat>(fromIndex, toIndex, new nfloat(scrollPercentage))); }
public override IMXView PopView() { if (ViewControllers.Count(vc => !(vc is VanityView)) < 2 && PresentingViewController != null) { var view = base.PopViewController(false); ModalManager.EnqueueModalTransition(PresentingViewController, null, true); var pair = view as IPairable; if (pair == null) { return(view as IMXView); } return((pair.Pair as IMXView) ?? pair as IMXView); } else { return(base.PopView()); } }
private void ReloadViewControllers() { if (DataSource == null) { throw new NullReferenceException("DataSource cannot be null"); } else { ViewControllers = DataSource.ViewControllersForPagerTabStrip(this); // viewControllers if (ViewControllers.Count() < 1) { throw new Exception("ViewControllersForPagerTabStrip should provide at least one child view controller"); } foreach (UIViewController childController in ViewControllers) { if (!(childController is IIndicatorInfoProvider)) { throw new Exception("Every view controller provided by PagerTabStripDataSource's viewControllersForPagerTabStrip method must conform to InfoProvider"); } } } }
public nint GetItemsCount(UICollectionView collectionView, nint section) { return(ViewControllers.Count()); }
public bool CanMoveToIndex(nint index) { return(CurrentIndex != index && ViewControllers.Count() > index); }