Esempio n. 1
0
        private TabView configuredTabView()
        {
            tabView = new TabView(isInfinity, option);
            tabView.TranslatesAutoresizingMaskIntoConstraints = false;

            //add constraints
            var height = NSLayoutConstraint.Create(tabView, NSLayoutAttribute.Height, NSLayoutRelation.Equal, null, NSLayoutAttribute.Height, 1.0f, option.tabHeight);

            tabView.AddConstraint(height);
            View.AddSubview(tabView);

            var top   = NSLayoutConstraint.Create(tabView, NSLayoutAttribute.Top, NSLayoutRelation.Equal, TopLayoutGuide, NSLayoutAttribute.Bottom, 1.0f, 0.0f);
            var left  = NSLayoutConstraint.Create(tabView, NSLayoutAttribute.Leading, NSLayoutRelation.Equal, View, NSLayoutAttribute.Leading, 1.0f, 0.0f);
            var right = NSLayoutConstraint.Create(tabView, NSLayoutAttribute.Trailing, NSLayoutRelation.Equal, tabView, NSLayoutAttribute.Trailing, 1.0f, 0.0f);

            View.AddConstraints(new[] { top, left, right });

            tabView.pageTabItems = tabItems.Select(x => x.title).ToArray();
            tabView.updateCurrentIndex(beforeIndex, true);

            tabView.pageItemPressedBlock += (index, direction) =>
            {
                this.displayControllerWithIndex((int)index, direction, true);
            };

            return(tabView);
        }
Esempio n. 2
0
        public void configureCell(TabCollectionCell cell, NSIndexPath indexPath, TabView tabView)
        {
            var fixedIndex = tabView.isInfinity ? indexPath.Item % tabView.pageTabItemsCount : indexPath.Item;

            cell.item      = tabView.pageTabItems[fixedIndex];
            cell.option    = tabView.option;
            cell.isCurrent = fixedIndex == (tabView.currentIndex % tabView.pageTabItemsCount);

            cell.tabItemButtonPressedBlock = (arg1, arg2) =>
            {
                var direction         = UIPageViewControllerNavigationDirection.Forward;
                var pageTabItemsCount = arg1.pageTabItemsCount;
                var currentIndex      = arg1.currentIndex;
                if (arg1.isInfinity)
                {
                    if (indexPath.Item < pageTabItemsCount || indexPath.Item < currentIndex)
                    {
                        direction = UIPageViewControllerNavigationDirection.Reverse;
                    }
                }
                else
                {
                    if (indexPath.Item < currentIndex)
                    {
                        direction = UIPageViewControllerNavigationDirection.Reverse;
                    }
                }

                arg1.pageItemPressedBlock(fixedIndex, direction);

                if (arg2?.isCurrent == false)
                {
                    arg1.updateCollectionViewUserInteractionEnabled(false);
                }

                arg1.updateCurrentIndexForTap((int)indexPath.Item);
            };
        }
Esempio n. 3
0
 public TabViewCollectionDataSource(TabView _tabView)
 {
     tabView = _tabView;
 }