예제 #1
0
        public static GroupedCollectionViewSourceBinding <TSource, IEnumerable <IGrouping <TSection, TItem> >, TSection, TItem, TCell, THeaderCell> Source <TSource, TSection, TItem, THeaderCell, TCell>(this Binder <TSource, UICollectionView> binder, Expression <Func <TSource, IEnumerable <IGrouping <TSection, TItem> > > > property, Action <TSection, int, THeaderCell> prepareHeader, Action <TItem, Index, TCell> prepareCell, ICommand select = null, bool fromNib = true, Action <float, float> onScroll = null)
            where TSource : class
            where THeaderCell : UICollectionReusableView
            where TCell : UICollectionViewCell
        {
            var s = new BindableGroupedCollectionSource <TSource, TSection, TItem, UICollectionView, TCell, THeaderCell>(binder.Source, property, binder.Target, (obj) => obj.ReloadData(), prepareCell, prepareHeader, select);

            var result = new GroupedCollectionViewSourceBinding <TSource, IEnumerable <IGrouping <TSection, TItem> >, TSection, TItem, TCell, THeaderCell>(s, fromNib, onScroll);

            binder.Target.Source = result;
            return(result);
        }
예제 #2
0
        public GroupedCollectionViewSourceBinding(BindableGroupedCollectionSource <TOwner, TCollection, TSection, TItem, UICollectionView, TCellView, THeaderCellView> source, bool fromNib, Action <float, float> onScroll = null)
        {
            this.source = source;

            this.cellIdentifier   = typeof(TCellView).Name;
            this.headerIdentifier = typeof(THeaderCellView).Name;
            this.onScroll         = onScroll;

            var view = this.source.Target;

            if (fromNib)
            {
                view.RegisterNibForCell(NibLocator <TCellView> .Nib, cellIdentifier);
                view.RegisterNibForSupplementaryView(NibLocator <THeaderCellView> .Nib, UICollectionElementKindSection.Header, headerIdentifier);
            }
            else
            {
                view.RegisterClassForCell(typeof(TCellView), cellIdentifier);
                view.RegisterClassForSupplementaryView(typeof(THeaderCellView), UICollectionElementKindSection.Header, headerIdentifier);
            }
        }
예제 #3
0
        public GroupedTableViewSourceBinding(BindableGroupedCollectionSource <TOwner, TCollection, TSection, TItem, UITableView, TCellView, THeaderCellView> source, Func <Index, nfloat> heightForItem, Func <int, nfloat> heightForHeader, bool fromNib, Action <float> onScroll = null)
        {
            this.source          = source;
            this.heightForItem   = heightForItem;
            this.heightForHeader = heightForHeader;
            this.onScroll        = onScroll;

            var view = this.source.Target;

            cellIdentifier   = typeof(TCellView).Name;
            headerIdentifier = typeof(THeaderCellView).Name;

            if (fromNib)
            {
                view.RegisterNibForCellReuse(NibLocator <TCellView> .Nib, cellIdentifier);
                view.RegisterNibForHeaderFooterViewReuse(NibLocator <THeaderCellView> .Nib, headerIdentifier);
            }
            else
            {
                view.RegisterClassForCellReuse(typeof(TCellView), cellIdentifier);
                view.RegisterClassForHeaderFooterViewReuse(typeof(THeaderCellView), headerIdentifier);
            }
        }