diff --git a/src/collectionview/index-common.d.ts b/src/collectionview/index-common.d.ts new file mode 100644 index 00000000..43f797d7 --- /dev/null +++ b/src/collectionview/index-common.d.ts @@ -0,0 +1,160 @@ +import { ChangedData, CoreTypes, ItemsSource, KeyedTemplate, Label, Property, Template, View } from '@nativescript/core'; +import { CollectionView as CollectionViewDefinition, Orientation } from '.'; +export declare const CollectionViewTraceCategory = "NativescriptCollectionView"; +export declare enum ContentInsetAdjustmentBehavior { + Always = 0, + Automatic = 1, + Never = 2, + ScrollableAxes = 3 +} +export declare enum CLogTypes { + log, + info, + warning, + error +} +export declare const CLog: (type: CLogTypes, ...args: any[]) => void; +export declare enum ListViewViewTypes { + ItemView = 0 +} +export declare namespace knownTemplates { + const itemTemplate = "itemTemplate"; +} +export declare namespace knownMultiTemplates { + const itemTemplates = "itemTemplates"; +} +export interface Plugin { + onLayout?: Function; +} +export declare abstract class CollectionViewBase extends View implements CollectionViewDefinition { + static itemLoadingEvent: string; + static scrollEvent: string; + static scrollStartEvent: string; + static scrollEndEvent: string; + static itemTapEvent: string; + static displayItemEvent: string; + static itemReorderedEvent: string; + static itemReorderStartingEvent: string; + static itemReorderStartedEvent: string; + static loadMoreItemsEvent: string; + static dataPopulatedEvent: string; + static knownFunctions: string[]; + isBounceEnabled: boolean; + isScrollEnabled: boolean; + reverseLayout: boolean; + orientation: Orientation; + itemTemplate: string | Template; + itemTemplates: string | KeyedTemplate[]; + isItemsSourceIn: boolean; + rowHeight: CoreTypes.PercentLengthType; + colWidth: CoreTypes.PercentLengthType; + verticalSpacing: CoreTypes.LengthType; + horizontalSpacing: CoreTypes.LengthType; + _innerWidth: number; + _innerHeight: number; + _effectiveRowHeight: number; + _effectiveColWidth: number; + loadMoreThreshold: number; + scrollOffset: number; + reorderEnabled: boolean; + reorderLongPressEnabled: boolean; + protected _dataUpdatesSuspended: boolean; + scrollBarIndicatorVisible: boolean; + layoutStyle: string; + plugins: string[]; + static plugins: { + [k: string]: Plugin; + }; + static registerPlugin(key: string, plugin: Plugin): void; + static layoutStyles: { + [k: string]: { + createLayout: Function; + createDelegate?: Function; + }; + }; + static registerLayoutStyle(style: string, generator: { + createLayout: Function; + createDelegate?: Function; + }): void; + protected _itemTemplatesInternal: Map; + protected _defaultTemplate: KeyedTemplate; + constructor(); + abstract refresh(): any; + abstract refreshVisibleItems(): any; + abstract isItemAtIndexVisible(index: number): any; + abstract scrollToIndex(index: number, animated: boolean): any; + protected updateInnerSize(): void; + onLayout(left: number, top: number, right: number, bottom: number): void; + items: any[] | ItemsSource; + _prepareItem(item: View, index: number): any; + notifyLoading(args: any): void; + getItemAtIndex(index: number): any; + isHorizontal(): boolean; + computeSpanCount(): number; + _onRowHeightPropertyChanged(oldValue: CoreTypes.PercentLengthType, newValue: CoreTypes.PercentLengthType): void; + _onColWidthPropertyChanged(oldValue: CoreTypes.PercentLengthType, newValue: CoreTypes.PercentLengthType): void; + onItemViewLoaderChanged(): void; + _itemViewLoader: any; + get itemViewLoader(): any; + set itemViewLoader(value: any); + get padding(): string | CoreTypes.LengthType; + set padding(value: string | CoreTypes.LengthType); + get paddingTop(): CoreTypes.LengthType; + set paddingTop(value: CoreTypes.LengthType); + get paddingRight(): CoreTypes.LengthType; + set paddingRight(value: CoreTypes.LengthType); + get paddingBottom(): CoreTypes.LengthType; + set paddingBottom(value: CoreTypes.LengthType); + get paddingLeft(): CoreTypes.LengthType; + set paddingLeft(value: CoreTypes.LengthType); + resolveTemplateView(template: any): View; + _getDefaultItemContent(): Label; + getTemplateFromSelector(templateKey: any): KeyedTemplate; + getViewForViewType(viewType: ListViewViewTypes, templateKey: string): any; + private _itemTemplateSelectorBindable; + _itemTemplateSelector: Function; + onItemTemplateSelectorChanged(oldValue: any, newValue: any): void; + private _itemIdGeneratorBindable; + _itemIdGenerator: (item: any, index: number, items: any) => number; + onItemIdGeneratorChanged(oldValue: any, newValue: any): void; + onTemplateAdded(t: any): void; + onTemplateRemoved(key: any): void; + addTemplate(key: any, t: any): void; + removeTemplate(key: any): void; + onItemTemplatesChanged(oldValue: any, newValue: any): void; + onItemTemplateChanged(oldValue: any, newValue: any): void; + onItemTemplatesPropertyChanged(oldValue: any, newValue: any): void; + onItemTemplatePropertyChanged(oldValue: any, newValue: any): void; + onItemsChangedInternal: (oldValue: any, newValue: any) => void; + spanSize: (item: any, index: number) => number; + onSpanSizeChangedInternal: (oldValue: any, newValue: any) => void; + _isDataDirty: boolean; + onLoaded(): void; + onSourceCollectionChanged(event: ChangedData): void; + onSourceCollectionChangedInternal(event: ChangedData): void; + suspendUpdates(): void; + updatesSuspended(): boolean; + resumeUpdates(refresh: boolean): void; + abstract getViewForItemAtIndex(index: number): View; + abstract startDragging(index: number): any; + draggingView: View; + _callItemReorderedEvent(oldPosition: any, newPosition: any, item: any): void; + _reorderItemInSource(oldPosition: number, newPosition: number, callEvents?: boolean): void; + shouldMoveItemAtIndex(index: number): boolean; +} +export declare const rowHeightProperty: Property; +export declare const colWidthProperty: Property; +export declare const orientationProperty: Property; +export declare const itemTemplateProperty: Property; +export declare const itemTemplatesProperty: Property; +export declare const itemTemplateSelectorProperty: Property; +export declare const itemIdGeneratorProperty: Property; +export declare const itemsProperty: Property; +export declare const spanSizeProperty: Property; +export declare const isScrollEnabledProperty: Property; +export declare const isBounceEnabledProperty: Property; +export declare const reverseLayoutProperty: Property; +export declare const loadMoreThresholdProperty: Property; +export declare const reorderingEnabledProperty: Property; +export declare const reorderLongPressEnabledProperty: Property; +export declare const scrollBarIndicatorVisibleProperty: Property; diff --git a/src/collectionview/collectionview-common.ts b/src/collectionview/index-common.ts similarity index 99% rename from src/collectionview/collectionview-common.ts rename to src/collectionview/index-common.ts index b3a642a4..449830f0 100755 --- a/src/collectionview/collectionview-common.ts +++ b/src/collectionview/index-common.ts @@ -25,7 +25,7 @@ import { removeWeakEventListener, widthProperty } from '@nativescript/core'; -import { CollectionView as CollectionViewDefinition, CollectionViewItemEventData, Orientation } from './collectionview'; +import { CollectionView as CollectionViewDefinition, CollectionViewItemEventData, Orientation } from '.' export const CollectionViewTraceCategory = 'NativescriptCollectionView'; diff --git a/src/collectionview/collectionview.android.ts b/src/collectionview/index.android.ts similarity index 99% rename from src/collectionview/collectionview.android.ts rename to src/collectionview/index.android.ts index c6fe3ae4..ac82e442 100755 --- a/src/collectionview/collectionview.android.ts +++ b/src/collectionview/index.android.ts @@ -26,10 +26,10 @@ import { reorderingEnabledProperty, reverseLayoutProperty, scrollBarIndicatorVisibleProperty -} from './collectionview'; -import { CLog, CLogTypes, CollectionViewBase, ListViewViewTypes, isScrollEnabledProperty, orientationProperty } from './collectionview-common'; +} from '.'; +import { CLog, CLogTypes, CollectionViewBase, ListViewViewTypes, isScrollEnabledProperty, orientationProperty } from './index-common'; -export * from './collectionview-common'; +export * from './index-common'; declare module '@nativescript/core/ui/core/view' { interface View { diff --git a/src/collectionview/collectionview.d.ts b/src/collectionview/index.d.ts similarity index 92% rename from src/collectionview/collectionview.d.ts rename to src/collectionview/index.d.ts index 891bae14..5a103c99 100755 --- a/src/collectionview/collectionview.d.ts +++ b/src/collectionview/index.d.ts @@ -1,7 +1,7 @@ import { EventData, View } from '@nativescript/core'; import { Pointer } from '@nativescript/core/ui/gestures'; -import { CollectionViewBase } from './collectionview-common'; -export * from './collectionview-common'; +import { CollectionViewBase } from './index-common'; +export * from './index-common'; export type Orientation = 'horizontal' | 'vertical'; diff --git a/src/collectionview/collectionview.ios.ts b/src/collectionview/index.ios.ts similarity index 99% rename from src/collectionview/collectionview.ios.ts rename to src/collectionview/index.ios.ts index 2e96446e..7ead94c2 100755 --- a/src/collectionview/collectionview.ios.ts +++ b/src/collectionview/index.ios.ts @@ -21,10 +21,10 @@ import { } from '@nativescript/core'; import { Pointer } from '@nativescript/core/ui/gestures'; import { layout } from '@nativescript/core/utils/utils'; -import { CollectionViewItemEventData, Orientation, reorderLongPressEnabledProperty, reorderingEnabledProperty, reverseLayoutProperty, scrollBarIndicatorVisibleProperty } from './collectionview'; -import { CLog, CLogTypes, CollectionViewBase, ListViewViewTypes, isBounceEnabledProperty, isScrollEnabledProperty, itemTemplatesProperty, orientationProperty } from './collectionview-common'; +import { CollectionViewItemEventData, Orientation, reorderLongPressEnabledProperty, reorderingEnabledProperty, reverseLayoutProperty, scrollBarIndicatorVisibleProperty } from '.'; +import { CLog, CLogTypes, CollectionViewBase, ListViewViewTypes, isBounceEnabledProperty, isScrollEnabledProperty, itemTemplatesProperty, orientationProperty } from './index-common'; -export * from './collectionview-common'; +export * from './index-common'; const infinity = layout.makeMeasureSpec(0, layout.UNSPECIFIED); diff --git a/src/collectionview/react/index.tsx b/src/collectionview/react/index.tsx index 74483b89..38204b60 100755 --- a/src/collectionview/react/index.tsx +++ b/src/collectionview/react/index.tsx @@ -1,14 +1,14 @@ import * as React from 'react'; import { CoreTypes, ItemEventData, ItemsSource, KeyedTemplate, View } from '@nativescript/core'; import { NSVElement, NSVRoot, NativeScriptProps, render as RNSRender, ViewAttributes, registerElement, unmountComponentAtNode } from 'react-nativescript'; -import { CollectionView as NativeScriptCollectionView } from '../collectionview'; +import { CollectionView as NativeScriptCollectionView } from '..' export type CellViewContainer = View; type CellFactory = (item: any) => React.ReactElement; export function registerCollectionView() { - registerElement('collectionView', () => require('../collectionview').CollectionView); + registerElement('collectionView', () => require('..').CollectionView); } interface CollectionViewAttributes extends ViewAttributes { diff --git a/src/collectionview/svelte/index.ts b/src/collectionview/svelte/index.ts index 82362ab9..9309433c 100755 --- a/src/collectionview/svelte/index.ts +++ b/src/collectionview/svelte/index.ts @@ -3,7 +3,7 @@ import { profile } from '@nativescript/core/profiling'; import { ContentView, LayoutBase, StackLayout, ViewBase } from '@nativescript/core/ui'; import { NativeViewElementNode, TemplateElement, ViewNode, createElement, registerElement } from 'svelte-native/dom'; import { flush } from 'svelte/internal'; -import { CollectionView } from '../collectionview'; +import { CollectionView } from '..' declare module '@nativescript/core/ui/core/view-base' { interface ViewBase { diff --git a/src/collectionview/vue/component.ts b/src/collectionview/vue/component.ts index 9576c8b6..567fb6d1 100755 --- a/src/collectionview/vue/component.ts +++ b/src/collectionview/vue/component.ts @@ -1,7 +1,7 @@ import { profile } from '@nativescript/core'; import { Observable } from '@nativescript/core/data/observable'; import { ObservableArray } from '@nativescript/core/data/observable-array'; -import { CollectionView } from '../collectionview'; +import { CollectionView } from '..' function extend(to, _from): any { for (const key in _from) { diff --git a/src/collectionview/vue/index.ts b/src/collectionview/vue/index.ts index 5007fe32..57598cc0 100755 --- a/src/collectionview/vue/index.ts +++ b/src/collectionview/vue/index.ts @@ -1,4 +1,4 @@ -import { CollectionView } from '../collectionview'; +import { CollectionView } from '..' const CollectionViewPlugin = { install(Vue, options) { diff --git a/src/waterfall/waterfall.android.ts b/src/waterfall/index.android.ts similarity index 99% rename from src/waterfall/waterfall.android.ts rename to src/waterfall/index.android.ts index b5d5b11a..6481f462 100755 --- a/src/waterfall/waterfall.android.ts +++ b/src/waterfall/index.android.ts @@ -1,4 +1,5 @@ import { CollectionView } from '@nativescript-community/ui-collectionview'; + export default function install() { CollectionView.registerLayoutStyle('waterfall', { createLayout: (collectionview: CollectionView) => new androidx.recyclerview.widget.StaggeredGridLayoutManager(1, 1), diff --git a/src/waterfall/waterfall.d.ts b/src/waterfall/index.d.ts similarity index 100% rename from src/waterfall/waterfall.d.ts rename to src/waterfall/index.d.ts diff --git a/src/waterfall/waterfall.ios.ts b/src/waterfall/index.ios.ts similarity index 100% rename from src/waterfall/waterfall.ios.ts rename to src/waterfall/index.ios.ts