public void ItemSelected(UICollectionView collectionView, NSIndexPath indexPath) { if (indexPath.Item == CurrentIndex) return; ButtonBarView.MoveTo(indexPath.Item, true, SwipeDirection.None, PagerScroll.Yes); ShouldUpdateButtonBarView = false; var oldCell = ButtonBarView.CellForItem(NSIndexPath.FromItemSection(CurrentIndex, 0)) as ButtonBarViewCell; var newCell = ButtonBarView.CellForItem(NSIndexPath.FromItemSection(indexPath.Item, 0)) as ButtonBarViewCell; if (PagerBehaviour.ProgressiveIndicator) { if (ChangeCurrentIndexProgressive != null) { ChangeCurrentIndexProgressive(oldCell, newCell, 1f, true, true); } } else { if (ChangeCurrentIndex != null) { ChangeCurrentIndex(oldCell, newCell, true); } } MoveToViewController(indexPath.Item); }
void ReleaseDesignerOutlets() { if (ButtonBarView != null) { ButtonBarView.Dispose(); ButtonBarView = null; } }
public void UpdateIndicator(PagerTabStripViewController viewController, nint fromIndex, nint toIndex, nfloat progressPercentage, bool indexWasChanged) { if (!ShouldUpdateButtonBarView) return; ButtonBarView.Move(fromIndex, toIndex, progressPercentage, PagerScroll.Yes); if (ChangeCurrentIndexProgressive != null) { var oldCell = ButtonBarView.CellForItem(NSIndexPath.FromItemSection(CurrentIndex != fromIndex ? fromIndex : toIndex, 0)) as ButtonBarViewCell; var newCell = ButtonBarView.CellForItem(NSIndexPath.FromItemSection(CurrentIndex, 0)) as ButtonBarViewCell; ChangeCurrentIndexProgressive(oldCell, newCell, progressPercentage, indexWasChanged, true); } }
public override void ReloadPagerTabStripView() { base.ReloadPagerTabStripView(); if (IsViewLoaded) { ButtonBarView.ReloadData(); CachedCellWidths = CalculateWidths(); ButtonBarView.MoveTo(CurrentIndex, false, SwipeDirection.None, PagerScroll.Yes); } }
public void UpdateIndicator(PagerTabStripViewController viewController, nint fromIndex, nint toIndex) { if (!ShouldUpdateButtonBarView) return; ButtonBarView.MoveTo(toIndex, true, toIndex < fromIndex ? SwipeDirection.Right : SwipeDirection.Left, PagerScroll.Yes); if (ChangeCurrentIndex != null) { var oldCell = ButtonBarView.CellForItem(NSIndexPath.FromItemSection(CurrentIndex != fromIndex ? fromIndex : toIndex, 0)) as ButtonBarViewCell; var newCell = ButtonBarView.CellForItem(NSIndexPath.FromItemSection(CurrentIndex, 0)) as ButtonBarViewCell; ChangeCurrentIndex(oldCell, newCell, true); } }
public override void ViewDidLayoutSubviews() { base.ViewDidLayoutSubviews(); if (IsViewAppearing || IsViewRotating) { CachedCellWidths = CalculateWidths(); ButtonBarView.CollectionViewLayout.InvalidateLayout(); ButtonBarView.MoveTo(CurrentIndex, false, SwipeDirection.None, PagerScroll.ScrollOnlyIfOutOfScreen); } }
public override void ViewWillAppear(bool animated) { base.ViewWillAppear(animated); ButtonBarView.LayoutIfNeeded(); }
public override void ViewDidLoad() { base.ViewDidLoad(); ButtonBarItemSpec = ButtonBarItemSpec.NibFile( nibName: "ButtonCell", bundle: NSBundle.FromClass(new ObjCRuntime.Class(typeof(ButtonBarViewCell))), width: (childItemInfo) => { var label = new UILabel(); label.TranslatesAutoresizingMaskIntoConstraints = false; label.Font = this.Settings.Style.ButtonBarItemFont; label.Text = childItemInfo.Title; var labelSize = label.IntrinsicContentSize; return labelSize.Width + (this.Settings.Style.ButtonBarItemLeftRightMargin?? 8) * 2; }); UICollectionViewFlowLayout flowLayout; if (ButtonBarView == null) { flowLayout = new UICollectionViewFlowLayout(); flowLayout.ScrollDirection = UICollectionViewScrollDirection.Horizontal; var buttonBarHeight = Settings.Style.ButtonBarHeight ?? 44f; var buttonBar = new ButtonBarView(new CGRect(0, 0, View.Frame.Width, buttonBarHeight), flowLayout); buttonBar.BackgroundColor = UIColor.Orange; buttonBar.SelectedBar.BackgroundColor = UIColor.Black; buttonBar.AutoresizingMask = UIViewAutoresizing.FlexibleWidth; var newContainerViewFrame = ContainerView.Frame; newContainerViewFrame.Y = buttonBarHeight; newContainerViewFrame.Height = ContainerView.Frame.Height - (buttonBarHeight - ContainerView.Frame.Y); ContainerView.Frame = newContainerViewFrame; ButtonBarView = buttonBar; } if (ButtonBarView.Superview == null) { View.AddSubview(ButtonBarView); } if (ButtonBarView.Delegate == null) { ButtonBarView.Delegate = this; } if (ButtonBarView.DataSource == null) { ButtonBarView.DataSource = this; } ButtonBarView.ScrollsToTop = false; flowLayout = ButtonBarView.CollectionViewLayout as UICollectionViewFlowLayout; flowLayout.ScrollDirection = UICollectionViewScrollDirection.Horizontal; flowLayout.MinimumInteritemSpacing = 0; flowLayout.MinimumLineSpacing = Settings.Style.ButtonBarMinimumLineSpacing ?? flowLayout.MinimumLineSpacing; var sectionInset = flowLayout.SectionInset; flowLayout.SectionInset = new UIEdgeInsets(sectionInset.Top, Settings.Style.ButtonBarLeftContentInset ?? sectionInset.Left, sectionInset.Bottom, Settings.Style.ButtonBarRightContentInset ?? sectionInset.Right); ButtonBarView.ShowsHorizontalScrollIndicator = false; ButtonBarView.BackgroundColor = Settings.Style.ButtonBarBackgroundColor ?? ButtonBarView.BackgroundColor; ButtonBarView.SelectedBar.BackgroundColor = Settings.Style.SelectedBarBackgroundColor; ButtonBarView.SelectedBarHeight = Settings.Style.SelectedBarHeight; switch (ButtonBarItemSpec.ButtonBarItemSpecType) { case ButtonBarItemSpecType.NibFile: { ButtonBarView.RegisterNibForCell(UINib.FromName(ButtonBarItemSpec.NibName, ButtonBarItemSpec.Bundle), "Cell"); } break; case ButtonBarItemSpecType.CellClass: { ButtonBarView.RegisterClassForCell(typeof(ButtonBarViewCell), "Cell"); } break; } }