• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2023 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/// <reference path='./import.ts' />
17
18import { ArkScrollable } from "./ArkScrollable";
19
20class ArkGridComponent extends ArkScrollable<GridAttribute> implements GridAttribute {
21  constructor(nativePtr: KNode, classType?: ModifierType) {
22    super(nativePtr, classType);
23  }
24  allowChildTypes(): string[] {
25    return ['GridItem'];
26  }
27  initialize(value: Object[]): void {
28    if (value.length === 1 && isObject(value[0])) {
29      modifierWithKey(this._modifiersWithKeys, GridScrollerModifier.identity, GridScrollerModifier, value[0]);
30      modifierWithKey(this._modifiersWithKeys, GridLayoutOptionsModifier.identity, GridLayoutOptionsModifier, undefined);
31    } else if (value.length === 2 && isObject(value[0]) && isObject(value[1])) {
32      modifierWithKey(this._modifiersWithKeys, GridScrollerModifier.identity, GridScrollerModifier, value[0]);
33      modifierWithKey(this._modifiersWithKeys, GridLayoutOptionsModifier.identity, GridLayoutOptionsModifier, value[1]);
34    } else {
35      modifierWithKey(this._modifiersWithKeys, GridScrollerModifier.identity, GridScrollerModifier, undefined);
36      modifierWithKey(this._modifiersWithKeys, GridLayoutOptionsModifier.identity, GridLayoutOptionsModifier, undefined);
37    }
38  }
39  columnsTemplate(value: string): this {
40    modifierWithKey(this._modifiersWithKeys, GridColumnsTemplateModifier.identity, GridColumnsTemplateModifier, value);
41    return this;
42  }
43  rowsTemplate(value: string): this {
44    modifierWithKey(this._modifiersWithKeys, GridRowsTemplateModifier.identity, GridRowsTemplateModifier, value);
45    return this;
46  }
47  columnsGap(value: Length): this {
48    modifierWithKey(this._modifiersWithKeys, GridColumnsGapModifier.identity, GridColumnsGapModifier, value);
49    return this;
50  }
51  rowsGap(value: Length): this {
52    modifierWithKey(this._modifiersWithKeys, GridRowsGapModifier.identity, GridRowsGapModifier, value);
53    return this;
54  }
55  scrollBarWidth(value: string | number): this {
56    modifierWithKey(this._modifiersWithKeys, GridScrollBarWidthModifier.identity, GridScrollBarWidthModifier, value);
57    return this;
58  }
59  scrollBarColor(value: string | number | Color): this {
60    modifierWithKey(this._modifiersWithKeys, GridScrollBarColorModifier.identity, GridScrollBarColorModifier, value);
61    return this;
62  }
63  scrollBar(value: BarState): this {
64    modifierWithKey(this._modifiersWithKeys, GridScrollBarModifier.identity, GridScrollBarModifier, value);
65    return this;
66  }
67  onScrollBarUpdate(event: (index: number, offset: number) => ComputedBarAttribute): this {
68    modifierWithKey(this._modifiersWithKeys, GridOnScrollBarUpdateModifier.identity, GridOnScrollBarUpdateModifier, event);
69    return this;
70  }
71  onScrollIndex(event: (first: number, last: number) => void): this {
72    modifierWithKey(this._modifiersWithKeys, GridOnScrollIndexModifier.identity, GridOnScrollIndexModifier, event);
73    return this;
74  }
75  cachedCount(count: number, show?: boolean): GridAttribute {
76    let opt = new ArkScrollableCacheOptions(count, show ? show : false);
77    modifierWithKey(this._modifiersWithKeys, GridCachedCountModifier.identity, GridCachedCountModifier, opt);
78    return this;
79  }
80  editMode(value: boolean): this {
81    modifierWithKey(this._modifiersWithKeys, GridEditModeModifier.identity, GridEditModeModifier, value);
82    return this;
83  }
84  multiSelectable(value: boolean): this {
85    modifierWithKey(this._modifiersWithKeys, GridMultiSelectableModifier.identity, GridMultiSelectableModifier, value);
86    return this;
87  }
88  maxCount(value: number): this {
89    modifierWithKey(this._modifiersWithKeys, GridMaxCountModifier.identity, GridMaxCountModifier, value);
90    return this;
91  }
92  minCount(value: number): this {
93    modifierWithKey(this._modifiersWithKeys, GridMinCountModifier.identity, GridMinCountModifier, value);
94    return this;
95  }
96  cellLength(value: number): this {
97    modifierWithKey(this._modifiersWithKeys, GridCellLengthModifier.identity, GridCellLengthModifier, value);
98    return this;
99  }
100  layoutDirection(value: GridDirection): this {
101    modifierWithKey(this._modifiersWithKeys, GridLayoutDirectionModifier.identity, GridLayoutDirectionModifier, value);
102    return this;
103  }
104  supportAnimation(value: boolean): this {
105    modifierWithKey(this._modifiersWithKeys, GridSupportAnimationModifier.identity, GridSupportAnimationModifier, value);
106    return this;
107  }
108  onItemDragStart(event: (event: ItemDragInfo, itemIndex: number) => void | (() => any)): this {
109    modifierWithKey(this._modifiersWithKeys, GridOnItemDragStartModifier.identity, GridOnItemDragStartModifier, event);
110    return this;
111  }
112  onItemDragEnter(event: (event: ItemDragInfo) => void): this {
113    modifierWithKey(this._modifiersWithKeys, GridOnItemDragEnterModifier.identity, GridOnItemDragEnterModifier, event);
114    return this;
115  }
116  onItemDragMove(event: (event: ItemDragInfo, itemIndex: number, insertIndex: number) => void): this {
117    modifierWithKey(this._modifiersWithKeys, GridOnItemDragMoveModifier.identity, GridOnItemDragMoveModifier, event);
118    return this;
119  }
120  onItemDragLeave(event: (event: ItemDragInfo, itemIndex: number) => void): this {
121    modifierWithKey(this._modifiersWithKeys, GridOnItemDragLeaveModifier.identity, GridOnItemDragLeaveModifier, event);
122    return this;
123  }
124  onItemDrop(event: (event: ItemDragInfo, itemIndex: number, insertIndex: number, isSuccess: boolean) => void): this {
125    modifierWithKey(this._modifiersWithKeys, GridOnItemDropModifier.identity, GridOnItemDropModifier, event);
126    return this;
127  }
128  nestedScroll(value: NestedScrollOptions): this {
129    modifierWithKey(this._modifiersWithKeys, GridNestedScrollModifier.identity, GridNestedScrollModifier, value);
130    return this;
131  }
132  enableScrollInteraction(value: boolean): this {
133    modifierWithKey(this._modifiersWithKeys, GridEnableScrollModifier.identity, GridEnableScrollModifier, value);
134    return this;
135  }
136  friction(value: number | Resource): this {
137    modifierWithKey(this._modifiersWithKeys, GridFrictionModifier.identity, GridFrictionModifier, value);
138    return this;
139  }
140  onScroll(event: (scrollOffset: number, scrollState: ScrollState) => void): this {
141    throw new Error('Method not implemented.');
142  }
143  onReachStart(event: () => void): this {
144    modifierWithKey(this._modifiersWithKeys, GridOnReachStartModifier.identity, GridOnReachStartModifier, event);
145    return this;
146  }
147  onReachEnd(event: () => void): this {
148    modifierWithKey(this._modifiersWithKeys, GridOnReachEndModifier.identity, GridOnReachEndModifier, event);
149    return this;
150  }
151  onScrollStart(event: () => void): this {
152    modifierWithKey(this._modifiersWithKeys, GridOnScrollStartModifier.identity, GridOnScrollStartModifier, event);
153    return this;
154  }
155  onScrollStop(event: () => void): this {
156    modifierWithKey(this._modifiersWithKeys, GridOnScrollStopModifier.identity, GridOnScrollStopModifier, event);
157    return this;
158  }
159  onScrollFrameBegin(callback: (offset: number, state: ScrollState) => { offsetRemain: number; }): this {
160    modifierWithKey(this._modifiersWithKeys, GridOnScrollFrameBeginModifier.identity, GridOnScrollFrameBeginModifier, callback);
161    return this;
162  }
163  clip(value: boolean | CircleAttribute | EllipseAttribute | PathAttribute | RectAttribute): this {
164    modifierWithKey(this._modifiersWithKeys, GridClipModifier.identity, GridClipModifier, value);
165    return this;
166  }
167  flingSpeedLimit(value: number): this {
168    modifierWithKey(this._modifiersWithKeys, GridFlingSpeedLimitModifier.identity, GridFlingSpeedLimitModifier, value);
169    return this;
170  }
171  alignItems(value: GridItemAlignment): this {
172    modifierWithKey(this._modifiersWithKeys, GridAlignItemsModifier.identity, GridAlignItemsModifier, value);
173    return this;
174  }
175  onWillScroll(callback: (xOffset: number, yOffset: number,
176    scrollState: ScrollState, scrollSource: ScrollSource) => void | OffsetResult): this {
177    modifierWithKey(this._modifiersWithKeys, GridOnWillScrollModifier.identity, GridOnWillScrollModifier, callback);
178    return this;
179  }
180  onDidScroll(callback: (xOffset: number, yOffset: number, scrollState: ScrollState) => void): this {
181    modifierWithKey(this._modifiersWithKeys, GridOnDidScrollModifier.identity, GridOnDidScrollModifier, callback);
182    return this;
183  }
184}
185
186class GridScrollerModifier extends ModifierWithKey<Scroller> {
187  constructor(value: Scroller) {
188    super(value);
189  }
190  static identity: Symbol = Symbol('gridScroller');
191  applyPeer(node: KNode, reset: boolean): void {
192    if (reset) {
193      getUINativeModule().grid.setGridScroller(node, undefined);
194    } else {
195      getUINativeModule().grid.setGridScroller(node, this.value);
196    }
197  }
198  checkObjectDiff(): boolean {
199    return !isBaseOrResourceEqual(this.stageValue, this.value);
200  }
201}
202
203class GridLayoutOptionsModifier extends ModifierWithKey<GridLayoutOptions> {
204  constructor(value: GridLayoutOptions) {
205    super(value);
206  }
207  static identity: Symbol = Symbol('gridLayoutOptions');
208  applyPeer(node: KNode, reset: boolean): void {
209    if (reset) {
210      getUINativeModule().grid.setGridLayoutOptions(node, undefined, undefined, undefined, undefined, undefined);
211    } else {
212      getUINativeModule().grid.setGridLayoutOptions(node,
213        isArray(this.value.regularSize) ? this.value.regularSize : undefined,
214        isArray(this.value?.irregularIndexes) ? this.value.irregularIndexes : undefined,
215        isArray(this.value?.irregularIndexes) ? this.value.irregularIndexes.length : undefined,
216        isFunction(this.value?.onGetIrregularSizeByIndex) ? this.value.onGetIrregularSizeByIndex : undefined,
217        isFunction(this.value?.onGetRectByIndex) ? this.value.onGetRectByIndex : undefined);
218    }
219  }
220  checkObjectDiff(): boolean {
221    return !isBaseOrResourceEqual(this.stageValue?.regularSize, this.value?.regularSize) ||
222      !isBaseOrResourceEqual(this.stageValue?.irregularIndexes, this.value?.irregularIndexes) ||
223      !isBaseOrResourceEqual(this.stageValue?.onGetIrregularSizeByIndex, this.value?.onGetIrregularSizeByIndex) ||
224      !isBaseOrResourceEqual(this.stageValue?.onGetRectByIndex, this.value?.onGetRectByIndex);
225  }
226}
227
228class GridColumnsTemplateModifier extends ModifierWithKey<string> {
229  constructor(value: string) {
230    super(value);
231  }
232  static identity: Symbol = Symbol('gridColumnsTemplate');
233  applyPeer(node: KNode, reset: boolean): void {
234    if (reset) {
235      getUINativeModule().grid.resetColumnsTemplate(node);
236    } else {
237      getUINativeModule().grid.setColumnsTemplate(node, this.value);
238    }
239  }
240}
241
242class GridRowsTemplateModifier extends ModifierWithKey<string> {
243  constructor(value: string) {
244    super(value);
245  }
246  static identity: Symbol = Symbol('gridRowsTemplate');
247  applyPeer(node: KNode, reset: boolean): void {
248    if (reset) {
249      getUINativeModule().grid.resetRowsTemplate(node);
250    } else {
251      getUINativeModule().grid.setRowsTemplate(node, this.value);
252    }
253  }
254}
255
256class GridColumnsGapModifier extends ModifierWithKey<Length> {
257  constructor(value: Length) {
258    super(value);
259  }
260  static identity: Symbol = Symbol('gridColumnsGap');
261  applyPeer(node: KNode, reset: boolean): void {
262    if (reset) {
263      getUINativeModule().grid.resetColumnsGap(node);
264    } else {
265      getUINativeModule().grid.setColumnsGap(node, this.value!);
266    }
267  }
268  checkObjectDiff(): boolean {
269    return !isBaseOrResourceEqual(this.stageValue, this.value);
270  }
271}
272
273class GridRowsGapModifier extends ModifierWithKey<Length> {
274  constructor(value: Length) {
275    super(value);
276  }
277  static identity: Symbol = Symbol('gridRowsGap');
278  applyPeer(node: KNode, reset: boolean): void {
279    if (reset) {
280      getUINativeModule().grid.resetRowsGap(node);
281    } else {
282      getUINativeModule().grid.setRowsGap(node, this.value!);
283    }
284  }
285  checkObjectDiff(): boolean {
286    return !isBaseOrResourceEqual(this.stageValue, this.value);
287  }
288}
289
290class GridScrollBarWidthModifier extends ModifierWithKey<string | number> {
291  constructor(value: string | number) {
292    super(value);
293  }
294  static identity: Symbol = Symbol('gridScrollBarWidth');
295  applyPeer(node: KNode, reset: boolean): void {
296    if (reset) {
297      getUINativeModule().grid.resetScrollBarWidth(node);
298    } else {
299      getUINativeModule().grid.setScrollBarWidth(node, this.value);
300    }
301  }
302}
303
304class GridScrollBarModifier extends ModifierWithKey<BarState> {
305  constructor(value: BarState) {
306    super(value);
307  }
308  static identity: Symbol = Symbol('gridScrollBar');
309  applyPeer(node: KNode, reset: boolean): void {
310    if (reset) {
311      getUINativeModule().grid.resetScrollBar(node);
312    } else {
313      getUINativeModule().grid.setScrollBar(node, this.value);
314    }
315  }
316}
317
318class GridScrollBarColorModifier extends ModifierWithKey<string | number | Color> {
319  constructor(value: string | number | Color) {
320    super(value);
321  }
322  static identity: Symbol = Symbol('gridScrollBarColor');
323  applyPeer(node: KNode, reset: boolean): void {
324    if (reset) {
325      getUINativeModule().grid.resetScrollBarColor(node);
326    } else {
327      getUINativeModule().grid.setScrollBarColor(node, this.value);
328    }
329  }
330}
331
332class GridEditModeModifier extends ModifierWithKey<boolean> {
333  constructor(value: boolean) {
334    super(value);
335  }
336  static identity: Symbol = Symbol('gridEditMode');
337  applyPeer(node: KNode, reset: boolean): void {
338    if (reset) {
339      getUINativeModule().grid.resetEditMode(node);
340    } else {
341      getUINativeModule().grid.setEditMode(node, this.value);
342    }
343  }
344}
345
346class GridCachedCountModifier extends ModifierWithKey<ArkScrollableCacheOptions> {
347  constructor(value: ArkScrollableCacheOptions) {
348    super(value);
349  }
350  static identity: Symbol = Symbol('gridCachedCount');
351  applyPeer(node: KNode, reset: boolean): void {
352    if (reset) {
353      getUINativeModule().grid.resetCachedCount(node);
354    } else {
355      getUINativeModule().grid.setCachedCount(node, this.value.count, this.value.show);
356    }
357  }
358}
359
360class GridMultiSelectableModifier extends ModifierWithKey<boolean> {
361  constructor(value: boolean) {
362    super(value);
363  }
364  static identity: Symbol = Symbol('gridMultiSelectable');
365  applyPeer(node: KNode, reset: boolean): void {
366    if (reset) {
367      getUINativeModule().grid.resetMultiSelectable(node);
368    } else {
369      getUINativeModule().grid.setMultiSelectable(node, this.value);
370    }
371  }
372}
373
374class GridNestedScrollModifier extends ModifierWithKey<NestedScrollOptions> {
375  constructor(value: NestedScrollOptions) {
376    super(value);
377  }
378  static identity: Symbol = Symbol('gridNestedScroll');
379  applyPeer(node: KNode, reset: boolean): void {
380    if (reset) {
381      getUINativeModule().grid.resetNestedScroll(node);
382    } else {
383      getUINativeModule().grid.setNestedScroll(node, this.value?.scrollForward, this.value?.scrollBackward);
384    }
385  }
386
387  checkObjectDiff(): boolean {
388    return !((this.stageValue.scrollForward === this.value.scrollForward) &&
389      (this.stageValue.scrollBackward === this.value.scrollBackward));
390  }
391}
392
393class GridEnableScrollModifier extends ModifierWithKey<boolean> {
394  constructor(value: boolean) {
395    super(value);
396  }
397  static identity: Symbol = Symbol('gridEnableScroll');
398  applyPeer(node: KNode, reset: boolean): void {
399    if (reset) {
400      getUINativeModule().grid.resetEnableScroll(node);
401    } else {
402      getUINativeModule().grid.setEnableScroll(node, this.value);
403    }
404  }
405}
406
407class GridFrictionModifier extends ModifierWithKey<number | Resource> {
408  constructor(value: number | Resource) {
409    super(value);
410  }
411  static identity: Symbol = Symbol('gridFriction');
412  applyPeer(node: KNode, reset: boolean): void {
413    if (reset) {
414      getUINativeModule().grid.resetFriction(node);
415    } else {
416      getUINativeModule().grid.setFriction(node, this.value);
417    }
418  }
419
420  checkObjectDiff(): boolean {
421    return !isBaseOrResourceEqual(this.stageValue, this.value);
422  }
423}
424
425class GridOnScrollFrameBeginModifier extends ModifierWithKey<(offset: number, state: ScrollState) => { offsetRemain: number }> {
426  constructor(value: (offset: number, state: ScrollState) => { offsetRemain: number; }) {
427    super(value);
428  }
429  static identity: Symbol = Symbol('gridOnScrollFrameBegin');
430  applyPeer(node: KNode, reset: boolean): void {
431    if (reset) {
432      getUINativeModule().grid.resetOnScrollFrameBegin(node);
433    } else {
434      getUINativeModule().grid.setOnScrollFrameBegin(node, this.value);
435    }
436  }
437}
438
439class GridOnWillScrollModifier extends ModifierWithKey<(xOffset: number, yOffset: number,
440  scrollState: ScrollState, scrollSource: ScrollSource) => void | OffsetResult> {
441  constructor(value: (xOffset: number, yOffset: number,
442    scrollState: ScrollState, scrollSource: ScrollSource) => void | OffsetResult) {
443    super(value);
444  }
445  static identity: Symbol = Symbol('gridOnWillScroll');
446  applyPeer(node: KNode, reset: boolean): void {
447    if (reset) {
448      getUINativeModule().grid.resetOnWillScroll(node);
449    } else {
450      getUINativeModule().grid.setOnWillScroll(node, this.value);
451    }
452  }
453}
454
455class GridOnDidScrollModifier extends ModifierWithKey<(xOffset: number, yOffset: number, scrollState: ScrollState) => void> {
456  constructor(value: (xOffset: number, yOffset: number, scrollState: ScrollState) => void) {
457    super(value);
458  }
459  static identity: Symbol = Symbol('gridOnDidScroll');
460  applyPeer(node: KNode, reset: boolean): void {
461    if (reset) {
462      getUINativeModule().grid.resetOnDidScroll(node);
463    } else {
464      getUINativeModule().grid.setOnDidScroll(node, this.value);
465    }
466  }
467}
468
469class GridOnReachStartModifier extends ModifierWithKey<() => void> {
470  constructor(value: () => void) {
471    super(value);
472  }
473  static identity: Symbol = Symbol('gridOnReachStart');
474  applyPeer(node: KNode, reset: boolean): void {
475    if (reset) {
476      getUINativeModule().grid.resetOnReachStart(node);
477    } else {
478      getUINativeModule().grid.setOnReachStart(node, this.value);
479    }
480  }
481}
482
483class GridOnReachEndModifier extends ModifierWithKey<() => void> {
484  constructor(value: () => void) {
485    super(value);
486  }
487  static identity: Symbol = Symbol('gridOnReachEnd');
488  applyPeer(node: KNode, reset: boolean): void {
489    if (reset) {
490      getUINativeModule().grid.resetOnReachEnd(node);
491    } else {
492      getUINativeModule().grid.setOnReachEnd(node, this.value);
493    }
494  }
495}
496
497class GridOnScrollStartModifier extends ModifierWithKey<() => void> {
498  constructor(value: () => void) {
499    super(value);
500  }
501  static identity: Symbol = Symbol('gridOnScrollStart');
502  applyPeer(node: KNode, reset: boolean): void {
503    if (reset) {
504      getUINativeModule().grid.resetOnScrollStart(node);
505    } else {
506      getUINativeModule().grid.setOnScrollStart(node, this.value);
507    }
508  }
509}
510
511class GridOnScrollStopModifier extends ModifierWithKey<() => void> {
512  constructor(value: () => void) {
513    super(value);
514  }
515  static identity: Symbol = Symbol('gridOnScrollStop');
516  applyPeer(node: KNode, reset: boolean): void {
517    if (reset) {
518      getUINativeModule().grid.resetOnScrollStop(node);
519    } else {
520      getUINativeModule().grid.setOnScrollStop(node, this.value);
521    }
522  }
523}
524
525class GridOnScrollBarUpdateModifier extends ModifierWithKey<(index: number, offset: number) => ComputedBarAttribute> {
526  constructor(value: (index: number, offset: number) => ComputedBarAttribute) {
527    super(value);
528  }
529  static identity: Symbol = Symbol('gridOnScrollBarUpdate');
530  applyPeer(node: KNode, reset: boolean): void {
531    if (reset) {
532      getUINativeModule().grid.resetOnScrollBarUpdate(node);
533    } else {
534      getUINativeModule().grid.setOnScrollBarUpdate(node, this.value);
535    }
536  }
537}
538
539class GridOnScrollIndexModifier extends ModifierWithKey<(first: number, last: number) => void> {
540  constructor(value: (first: number, last: number) => void) {
541    super(value);
542  }
543  static identity: Symbol = Symbol('gridOnScrollIndex');
544  applyPeer(node: KNode, reset: boolean): void {
545    if (reset) {
546      getUINativeModule().grid.resetOnScrollIndex(node);
547    } else {
548      getUINativeModule().grid.setOnScrollIndex(node, this.value);
549    }
550  }
551}
552
553class GridOnItemDragStartModifier extends ModifierWithKey<(event: ItemDragInfo, itemIndex: number) => void | (() => any)> {
554  constructor(value: (event: ItemDragInfo, itemIndex: number) => void | (() => any)) {
555    super(value);
556  }
557  static identity: Symbol = Symbol('gridOnItemDragStart');
558  applyPeer(node: KNode, reset: boolean): void {
559    if (reset) {
560      getUINativeModule().grid.resetOnItemDragStart(node);
561    } else {
562      getUINativeModule().grid.setOnItemDragStart(node, this.value);
563    }
564  }
565}
566
567class GridOnItemDragEnterModifier extends ModifierWithKey<(event: ItemDragInfo) => void> {
568  constructor(value: (event: ItemDragInfo) => void) {
569    super(value);
570  }
571  static identity: Symbol = Symbol('gridOnItemDragEnter');
572  applyPeer(node: KNode, reset: boolean): void {
573    if (reset) {
574      getUINativeModule().grid.resetOnItemDragEnter(node);
575    } else {
576      getUINativeModule().grid.setOnItemDragEnter(node, this.value);
577    }
578  }
579}
580
581class GridOnItemDragMoveModifier extends ModifierWithKey<(event: ItemDragInfo, itemIndex: number, insertIndex: number) => void> {
582  constructor(value: (event: ItemDragInfo, itemIndex: number, insertIndex: number) => void) {
583    super(value);
584  }
585  static identity: Symbol = Symbol('gridOnItemDragMove');
586  applyPeer(node: KNode, reset: boolean): void {
587    if (reset) {
588      getUINativeModule().grid.resetOnItemDragMove(node);
589    } else {
590      getUINativeModule().grid.setOnItemDragMove(node, this.value);
591    }
592  }
593}
594
595class GridOnItemDragLeaveModifier extends ModifierWithKey<(event: ItemDragInfo, itemIndex: number) => void> {
596  constructor(value: (event: ItemDragInfo, itemIndex: number) => void) {
597    super(value);
598  }
599  static identity: Symbol = Symbol('gridOnItemDragLeave');
600  applyPeer(node: KNode, reset: boolean): void {
601    if (reset) {
602      getUINativeModule().grid.resetOnItemDragLeave(node);
603    } else {
604      getUINativeModule().grid.setOnItemDragLeave(node, this.value);
605    }
606  }
607}
608
609class GridOnItemDropModifier extends ModifierWithKey<(event: ItemDragInfo, itemIndex: number, insertIndex: number, isSuccess: boolean) => void> {
610  constructor(value: (event: ItemDragInfo, itemIndex: number, insertIndex: number, isSuccess: boolean) => void) {
611    super(value);
612  }
613  static identity: Symbol = Symbol('gridOnItemDrop');
614  applyPeer(node: KNode, reset: boolean): void {
615    if (reset) {
616      getUINativeModule().grid.resetOnItemDrop(node);
617    } else {
618      getUINativeModule().grid.setOnItemDrop(node, this.value);
619    }
620  }
621}
622
623class GridMaxCountModifier extends ModifierWithKey<number> {
624  constructor(value: number) {
625    super(value);
626  }
627  static identity: Symbol = Symbol('gridMaxCount');
628  applyPeer(node: KNode, reset: boolean): void {
629    if (reset) {
630      getUINativeModule().grid.resetMaxCount(node);
631    } else {
632      getUINativeModule().grid.setMaxCount(node, this.value);
633    }
634  }
635}
636
637class GridMinCountModifier extends ModifierWithKey<number> {
638  constructor(value: number) {
639    super(value);
640  }
641  static identity: Symbol = Symbol('gridMinCount');
642  applyPeer(node: KNode, reset: boolean): void {
643    if (reset) {
644      getUINativeModule().grid.resetMinCount(node);
645    } else {
646      getUINativeModule().grid.setMinCount(node, this.value);
647    }
648  }
649}
650
651class GridCellLengthModifier extends ModifierWithKey<number> {
652  constructor(value: number) {
653    super(value);
654  }
655  static identity: Symbol = Symbol('gridCellLength');
656  applyPeer(node: KNode, reset: boolean): void {
657    if (reset) {
658      getUINativeModule().grid.resetCellLength(node);
659    } else {
660      getUINativeModule().grid.setCellLength(node, this.value);
661    }
662  }
663}
664
665class GridLayoutDirectionModifier extends ModifierWithKey<GridDirection> {
666  constructor(value: GridDirection) {
667    super(value);
668  }
669  static identity: Symbol = Symbol('gridLayoutDirection');
670  applyPeer(node: KNode, reset: boolean): void {
671    if (reset) {
672      getUINativeModule().grid.resetLayoutDirection(node);
673    } else {
674      getUINativeModule().grid.setLayoutDirection(node, this.value);
675    }
676  }
677}
678
679class GridSupportAnimationModifier extends ModifierWithKey<boolean> {
680  constructor(value: boolean) {
681    super(value);
682  }
683  static identity: Symbol = Symbol('gridSupportAnimation');
684  applyPeer(node: KNode, reset: boolean): void {
685    if (reset) {
686      getUINativeModule().grid.resetSupportAnimation(node);
687    } else {
688      getUINativeModule().grid.setSupportAnimation(node, this.value);
689    }
690  }
691}
692
693class GridClipModifier extends ModifierWithKey<boolean | object> {
694  constructor(value: boolean | object) {
695    super(value);
696  }
697  static identity: Symbol = Symbol('gridClip');
698  applyPeer(node: KNode, reset: boolean): void {
699    if (reset) {
700      getUINativeModule().common.resetClipWithEdge(node);
701    } else {
702      getUINativeModule().common.setClipWithEdge(node, this.value);
703    }
704  }
705  checkObjectDiff(): boolean {
706    return true;
707  }
708}
709
710class GridFlingSpeedLimitModifier extends ModifierWithKey<number> {
711  constructor(value: number) {
712    super(value);
713  }
714  static identity: Symbol = Symbol('gridFlingSpeedLimit');
715  applyPeer(node: KNode, reset: boolean): void {
716    if (reset) {
717      getUINativeModule().grid.resetFlingSpeedLimit(node);
718    } else {
719      getUINativeModule().grid.setFlingSpeedLimit(node, this.value);
720    }
721  }
722}
723
724class GridAlignItemsModifier extends ModifierWithKey<GridItemAlignment> {
725  constructor(value: GridItemAlignment) {
726    super(value);
727  }
728  static identity: Symbol = Symbol('gridAlignItems');
729  applyPeer(node: KNode, reset: boolean): void {
730    if (reset) {
731      getUINativeModule().grid.resetAlignItems(node);
732    } else {
733      getUINativeModule().grid.setAlignItems(node, this.value);
734    }
735  }
736}
737
738// @ts-ignore
739globalThis.Grid.attributeModifier = function (modifier: ArkComponent): void {
740  attributeModifierFunc.call(this, modifier, (nativePtr: KNode) => {
741    return new ArkGridComponent(nativePtr);
742  }, (nativePtr: KNode, classType: ModifierType, modifierJS: ModifierJS) => {
743    return new modifierJS.GridModifier(nativePtr, classType);
744  });
745};
746