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"/","sourcesContent":["import { ListItemProps, ListViewProps, ListView } from \"../ListView\";\nimport { CCPureSubview, CCPureView } from \"../../../../common/classbase/CCViewBase\";\nimport { DummyLayout, DummyScrollView } from \"../../../../common/CCDummyObjects\";\nimport { shallowEqual, delay } from \"simba-utils\";\n\nconst { ccclass, property } = cc._decorator;\n\n@ccclass\nexport abstract class ListSubviewImpl<I extends ListItemProps, T extends ListViewProps<I>> extends CCPureSubview<T> implements ListView {\n //#region editor bindings\n @property(cc.Layout)\n protected contentLayout: cc.Layout = DummyLayout;\n @property(cc.ScrollView)\n protected scrollView: cc.ScrollView = DummyScrollView;\n //#endregion\n\n protected _refreshing = false;\n\n protected _itemViews: { [key: string]: CCPureView<I> & { index: number } } = {};\n\n private _viewCache: CCPureView<I>[] = [];\n\n protected abstract createListItemView(index: number): Promise<CCPureView<I>>;\n\n onLoad() {\n console.log(\"ListViewImpl onLoad\", this.scrollView);\n }\n\n //#region base class overrides\n onPropsReceive() {\n (this._props as any).items = [...this._props.items];\n if (this._prevProps) {\n if (!shallowEqual(this._props.items, this._prevProps.items)) {\n this.refreshList(this._props.items);\n }\n }\n }\n\n onPropsLoad(props: T) {\n super.onPropsLoad(props);\n this.refreshList(props.items);\n }\n //#endregion\n\n //#region interface impl\n scrollToTop() {\n this.scrollView.scrollToTop();\n }\n\n scrollToBottom(animate = false) {\n if (this.contentLayout.node.height > this.scrollView.node.height) {\n this.scrollView.scrollToBottom(animate ? 0.3 : undefined);\n }\n }\n //#endregion\n\n onItemClick = (key: string) => {\n return () => {\n if (this._props.onItemClick) {\n this._props.onItemClick(key);\n }\n }\n }\n\n refreshList = async (list: I[]) => {\n while (this._refreshing) {\n await delay(0.5);\n }\n this._refreshing = true;\n let allKeys = new Set(Object.keys(this._itemViews));\n for (let i = 0; i < list.length; i++) {\n let view = this._itemViews[list[i].key];\n allKeys.delete(list[i].key);\n if (!view) {\n view = (this._viewCache.pop() || await this.createListItemView(i)) as (CCPureView<I> & { index: number });\n view.index = i;\n view.node.parent = this.contentLayout.node;\n view.node.setSiblingIndex(i);\n this._itemViews[list[i].key] = view;\n } else if (view.index !== i) {\n view.node.setSiblingIndex(i);\n view.index = i;\n }\n view.setProps({ ...list[i], onClick: this.onItemClick(list[i].key) });\n }\n for (let key of allKeys) {\n let view = this._itemViews[key];\n view.node.removeFromParent(false);\n delete this._itemViews[key];\n this._viewCache.push(view);\n }\n this._refreshing = false;\n this.onRefreshListEnd();\n }\n\n onRefreshListEnd() { }\n}"]}