• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2022-2024 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16/**
17 * ForEach for partial update
18 * Repeat aka ForEach and LazyForEach with child update
19 *
20 * all definitions in this file are framework internal
21 *
22 * Note: the API for ForEach with partial update and with full update
23 * are different. Only this declaration file or the one for full update
24 * can be used. Using both would lead to syntax error.
25 *
26 */
27
28declare class ForEach {
29  static create(): void;
30  static pop(): void;
31  static setIdArray(elmtId: number, newIdArray: string[], diffIndexArray: number[],
32    duplicateIds: number[], removedChildElmtIds: number[]): void;
33  static createNewChildStart(id: string, parentView: NativeViewPartialUpdate): void;
34  static createNewChildFinish(id: string, parentView: NativeViewPartialUpdate): void;
35}
36
37// Repeat maps to C++ RepeatNode
38declare class RepeatNative {
39  static startRender(): void;
40  static finishRender(removedChildElmtIds: Array<number>): void;
41  static moveChild(fromIndex: number): void;
42  static createNewChildStart(id: string): void;
43  static createNewChildFinish(id: string): void;
44  static onMove(handler: (from: number, to: number) => void);
45}
46
47// Repeat.virtualScroll maps to C++ RepeatVirtualScrollNode
48declare class RepeatVirtualScrollNative {
49  static create(
50    totalCount: number,
51    templateOptions: [string, RepeatTemplateOptions][],
52    handlers: {
53      onCreateNode: (forIndex: number) => void;
54      onUpdateNode: (fromKey: string, forIndex: number) => void;
55      onGetKeys4Range: (from: number, toNumber: number) => Array<string>;
56      onGetTypes4Range: (from: number, toNumber: number) => Array<string>;
57      onSetActiveRange: (from: number, to: number) => void;
58    },
59    reusable: boolean
60  ): void;
61  // invalidate caches in C++ side, trigger render if needed
62  static updateRenderState(totalCount: number, visibleItemsChanged: boolean): void;
63  // drag and drop
64  static onMove(handler: (from: number, to: number) => void, eventHandler?: ItemDragEventHandler);
65  static setCreateByTemplate(isCreatedByTemplate: boolean): void;
66}
67