@nstudio/ui-collectionview
Version:
Customized NativeScript CollectionView for high performance lists. Supports vertical and horizontal modes, templating, and more.
180 lines (179 loc) • 10.5 kB
TypeScript
import { ChangedData, Property, TouchGestureEventData, View, ViewBase } from '@nativescript/core';
import { Pointer } from '@nativescript/core/ui/gestures';
import { CollectionViewBase } from './common';
export * from './common';
export declare enum ContentInsetAdjustmentBehavior {
Always = 3,
Automatic = 0,
Never = 2,
ScrollableAxes = 1
}
export declare const contentInsetAdjustmentBehaviorProperty: Property<CollectionView, ContentInsetAdjustmentBehavior>;
export declare const estimatedItemSizeProperty: Property<CollectionView, boolean>;
export declare const autoSizeProperty: Property<CollectionView, boolean>;
export declare enum SnapPosition {
START = -1,// = androidx.recyclerview.widget.LinearSmoothScroller.SNAP_TO_START,
END = 1
}
export declare class CollectionView extends CollectionViewBase {
_layout: UICollectionViewLayout;
_dataSource: CollectionViewDataSource;
_delegate: UICollectionViewDelegateImpl | UICollectionViewDelegateFixedSizeImpl;
private _preparingCell;
private _map;
_measureCellMap: Map<string, {
cell: CollectionViewCell;
view: View;
}>;
_lastLayoutKey: string;
autoSize: boolean;
reorderLongPressGesture: UILongPressGestureRecognizer;
reorderLongPressHandler: ReorderLongPressImpl;
reorderStartingRow: number;
reorderEndingRow: number;
manualDragging: boolean;
scrollEnabledBeforeDragging: boolean;
estimatedItemSize: boolean;
draggingStartDelta: [number, number];
nativeViewProtected: UICollectionView;
constructor();
createNativeView(): UICollectionViewImpl;
onTemplateAdded(t: any): void;
initNativeView(): void;
disposeNativeView(): void;
get _childrenCount(): number;
onLoaded(): void;
eachChild(callback: (child: ViewBase) => boolean): void;
eachChildAsync(callback: any): Promise<void>;
getViewForItemAtIndex(index: number): View;
startDragging(index: number, pointer?: Pointer): void;
onReorderingTouch(event: TouchGestureEventData): void;
handleReorderEnd(): void;
onReorderLongPress(gesture: UILongPressGestureRecognizer): void;
protected updateScrollBarVisibility(value: any): void;
eachChildView(callback: (child: View) => boolean): void;
onLayout(left: number, top: number, right: number, bottom: number): void;
updateRowColSize(): void;
_onRowHeightPropertyChanged(oldValue: any, newValue: any): void;
_onColWidthPropertyChanged(oldValue: any, newValue: any): void;
isHorizontal(): boolean;
clearCachedSize(...indexes: number[]): void;
layoutAttributesForElementsInRect(attributesArray: NSArray<UICollectionViewLayoutAttributes>, rect: CGRect): void;
onSourceCollectionChanged(event: ChangedData<any>): void;
onItemTemplatesChanged(oldValue: any, newValue: any): void;
private unbindUnusedCells;
refreshVisibleItems(): void;
isItemAtIndexVisible(itemIndex: number): boolean;
findFirstVisibleItemIndex(): number;
findLastVisibleItemIndex(): number;
private getRowIndexPath;
refresh(): void;
get scrollOffset(): number;
get verticalOffsetX(): number;
get verticalOffsetY(): number;
scrollToIndex(index: number, animated?: boolean, snap?: SnapPosition): void;
scrollToOffset(value: any, animated: any): void;
requestLayout(): void;
_setNativeClipToBounds(): void;
notifyForItemAtIndex(eventName: string, view: View, index: number, bindingContext?: any, native?: any): any;
_getItemTemplateType(indexPath: any): string;
getItemTemplateContent(index: any, templateType: any): any;
_prepareCell(cell: CollectionViewCell, indexPath: NSIndexPath, templateType: string, notForCellSizeComp?: boolean): [number, number];
getCellSize(index: number): any;
private measureCell;
layoutCell(index: number, cell: CollectionViewCell, cellView: View): any;
private clearRealizedCells;
private _clearCellViews;
private _removeContainer;
private _setPadding;
numberOfSectionsInCollectionView(collectionView: UICollectionView): 0 | 1;
collectionViewNumberOfItemsInSection(collectionView: UICollectionView, section: number): number;
collectionViewCellForItemAtIndexPath(collectionView: UICollectionView, indexPath: NSIndexPath): UICollectionViewCell;
collectionViewWillDisplayCellForItemAtIndexPath(collectionView: UICollectionView, cell: UICollectionViewCell, indexPath: NSIndexPath): void;
collectionViewDidSelectItemAtIndexPath(collectionView: UICollectionView, indexPath: NSIndexPath): NSIndexPath;
collectionViewDidHighlightItemAtIndexPath(collectionView: UICollectionView, indexPath: NSIndexPath): void;
collectionViewDidUnhighlightItemAtIndexPath(collectionView: UICollectionView, indexPath: NSIndexPath): void;
collectionViewLayoutSizeForItemAtIndexPath(collectionView: UICollectionView, collectionViewLayout: UICollectionViewLayout, indexPath: NSIndexPath): CGSize;
private computeScrollEventData;
lastContentOffset: CGPoint;
needsScrollStartEvent: boolean;
isScrolling: boolean;
scrollViewWillBeginDragging(scrollView: UIScrollView): void;
scrollViewDidScroll(scrollView: UIScrollView): void;
stopScrolling(scrollView: UIScrollView): void;
scrollViewDidEndDecelerating(scrollView: UIScrollView): void;
scrollViewWillEndDraggingWithVelocityTargetContentOffset?(scrollView: UIScrollView, velocity: CGPoint, targetContentOffset: interop.Pointer | interop.Reference<CGPoint>): void;
scrollViewDidEndDraggingWillDecelerate(scrollView: UIScrollView, decelerate: boolean): void;
scrollViewDidEndScrollingAnimation(scrollView: UIScrollView): void;
}
interface ViewItemIndex {
}
type ItemView = View & ViewItemIndex;
declare class CollectionViewCell extends UICollectionViewCell {
owner: WeakRef<ItemView>;
currentIndex: number;
get view(): ItemView;
systemLayoutSizeFittingSizeWithHorizontalFittingPriorityVerticalFittingPriority(targetSize: CGSize, horizontalFittingPriority: number, verticalFittingPriority: number): CGSize;
}
declare class UICollectionViewImpl extends UICollectionView {
_owner: WeakRef<CollectionView>;
sizeThatFits(size: CGSize): CGSize;
static initWithOwner(owner: CollectionView, layout: any): UICollectionViewImpl;
}
declare class CollectionViewDataSource extends NSObject implements UICollectionViewDataSource {
_owner: WeakRef<CollectionView>;
static ObjCProtocols: {
prototype: UICollectionViewDataSource;
}[];
static initWithOwner(owner: CollectionView): CollectionViewDataSource;
numberOfSectionsInCollectionView(collectionView: UICollectionView): 0 | 1;
collectionViewNumberOfItemsInSection(collectionView: UICollectionView, section: number): number;
collectionViewCellForItemAtIndexPath(collectionView: UICollectionView, indexPath: NSIndexPath): UICollectionViewCell;
collectionViewMoveItemAtIndexPathToIndexPath(collectionView: UICollectionView, sourceIndexPath: NSIndexPath, destinationIndexPath: NSIndexPath): void;
collectionViewTargetIndexPathForMoveFromItemAtIndexPathToProposedIndexPath?(collectionView: UICollectionView, originalIndexPath: NSIndexPath, proposedIndexPath: NSIndexPath): NSIndexPath;
collectionViewCanMoveItemAtIndexPath(collectionView: UICollectionView, indexPath: NSIndexPath): boolean;
}
declare class UICollectionViewDelegateImpl extends UICollectionViewCacheDelegateFlowLayout implements UICollectionViewDelegate {
_owner: WeakRef<CollectionView>;
static ObjCProtocols: {
prototype: UICollectionViewDelegate;
}[];
static initWithOwner(owner: CollectionView): UICollectionViewDelegateImpl;
collectionViewWillDisplayCellForItemAtIndexPath(collectionView: UICollectionView, cell: UICollectionViewCell, indexPath: NSIndexPath): void;
collectionViewDidSelectItemAtIndexPath(collectionView: UICollectionView, indexPath: NSIndexPath): NSIndexPath;
collectionViewLayoutComputedSizeForItemAtIndexPath(collectionView: UICollectionView, collectionViewLayout: UICollectionViewLayout, indexPath: NSIndexPath): CGSize;
scrollViewDidScroll(scrollView: UIScrollView): void;
scrollViewWillBeginDragging(scrollView: UIScrollView): void;
scrollViewDidEndDecelerating(scrollView: UIScrollView): void;
scrollViewWillEndDraggingWithVelocityTargetContentOffset?(scrollView: UIScrollView, velocity: CGPoint, targetContentOffset: interop.Pointer | interop.Reference<CGPoint>): void;
scrollViewDidEndDraggingWillDecelerate(scrollView: UIScrollView, decelerate: boolean): void;
scrollViewDidEndScrollingAnimation(scrollView: UIScrollView): void;
collectionViewTargetIndexPathForMoveFromItemAtIndexPathToProposedIndexPath(collectionView: UICollectionView, currentIndexPath: NSIndexPath, proposedIndexPath: NSIndexPath): NSIndexPath;
}
declare class UICollectionViewDelegateFixedSizeImpl extends NSObject implements UICollectionViewDelegate, UICollectionViewDelegateFlowLayout {
_owner: WeakRef<CollectionView>;
static ObjCProtocols: {
prototype: UICollectionViewDelegate;
}[];
static initWithOwner(owner: CollectionView): UICollectionViewDelegateFixedSizeImpl;
collectionViewWillDisplayCellForItemAtIndexPath(collectionView: UICollectionView, cell: UICollectionViewCell, indexPath: NSIndexPath): void;
collectionViewDidSelectItemAtIndexPath(collectionView: UICollectionView, indexPath: NSIndexPath): NSIndexPath;
scrollViewDidScroll(scrollView: UIScrollView): void;
scrollViewWillBeginDragging(scrollView: UIScrollView): void;
scrollViewDidEndDecelerating(scrollView: UIScrollView): void;
scrollViewWillEndDraggingWithVelocityTargetContentOffset?(scrollView: UIScrollView, velocity: CGPoint, targetContentOffset: interop.Pointer | interop.Reference<CGPoint>): void;
scrollViewDidEndDraggingWillDecelerate(scrollView: UIScrollView, decelerate: boolean): void;
scrollViewDidEndScrollingAnimation(scrollView: UIScrollView): void;
collectionViewTargetIndexPathForMoveFromItemAtIndexPathToProposedIndexPath(collectionView: UICollectionView, currentIndexPath: NSIndexPath, proposedIndexPath: NSIndexPath): NSIndexPath;
}
declare class ReorderLongPressImpl extends NSObject {
private _owner;
static initWithOwner(owner: WeakRef<CollectionView>): ReorderLongPressImpl;
longPress(recognizer: UILongPressGestureRecognizer): void;
static ObjCExposedMethods: {
longPress: {
returns: interop.Type<void>;
params: interop.Type<any>[];
};
};
}