• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2025 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
18class ArkLazyGridLayout<T> extends ArkComponent implements LazyGridLayoutAttribute<T> {
19  constructor(nativePtr: KNode, classType?: ModifierType) {
20    super(nativePtr, classType);
21  }
22  columnsGap(value: LengthMetrics): this {
23    modifierWithKey(this._modifiersWithKeys, LazyGridColumnsGapModifier.identity, LazyGridColumnsGapModifier, value);
24    return this;
25  }
26  rowsGap(value: LengthMetrics): this {
27    modifierWithKey(this._modifiersWithKeys, LazyGridRowsGapModifier.identity, LazyGridRowsGapModifier, value);
28    return this;
29  }
30}
31
32class ArkLazyVGridLayoutComponent extends ArkLazyGridLayout<ArkLazyVGridLayoutComponent> implements LazyVGridLayoutAttribute {
33  constructor(nativePtr: KNode, classType?: ModifierType) {
34    super(nativePtr, classType);
35  }
36  columnsTemplate(value: string): this {
37    modifierWithKey(this._modifiersWithKeys, LazyGridColumnsTemplateModifier.identity, LazyGridColumnsTemplateModifier, value);
38    return this;
39  }
40}
41
42class LazyGridColumnsTemplateModifier extends ModifierWithKey<string> {
43  constructor(value: string) {
44    super(value);
45  }
46  static identity: Symbol = Symbol('lazyGridColumnsTemplate');
47  applyPeer(node: KNode, reset: boolean): void {
48    if (reset) {
49      getUINativeModule().lazyVGridLayout.resetColumnsTemplate(node);
50    } else {
51      getUINativeModule().lazyVGridLayout.setColumnsTemplate(node, this.value);
52    }
53  }
54}
55
56class LazyGridColumnsGapModifier extends ModifierWithKey<LengthMetrics> {
57  constructor(value: LengthMetrics) {
58    super(value);
59  }
60  static identity: Symbol = Symbol('lazyGridColumnsGap');
61  applyPeer(node: KNode, reset: boolean): void {
62    if (reset || !isObject(this.value)) {
63      getUINativeModule().lazyGridLayout.resetColumnsGap(node);
64    } else {
65      getUINativeModule().lazyGridLayout.setColumnsGap(node, this.value!);
66    }
67  }
68  checkObjectDiff(): boolean {
69    return !isBaseOrResourceEqual(this.stageValue, this.value);
70  }
71}
72
73class LazyGridRowsGapModifier extends ModifierWithKey<LengthMetrics> {
74  constructor(value: LengthMetrics) {
75    super(value);
76  }
77  static identity: Symbol = Symbol('lazyGridRowsGap');
78  applyPeer(node: KNode, reset: boolean): void {
79    if (reset || !isObject(this.value)) {
80      getUINativeModule().lazyGridLayout.resetRowsGap(node);
81    } else {
82      getUINativeModule().lazyGridLayout.setRowsGap(node, this.value!);
83    }
84  }
85  checkObjectDiff(): boolean {
86    return !isBaseOrResourceEqual(this.stageValue, this.value);
87  }
88}
89
90// @ts-ignore
91globalThis.LazyVGridLayout.attributeModifier = function (modifier: ArkComponent): void {
92  attributeModifierFunc.call(this, modifier, (nativePtr: KNode) => {
93    return new ArkLazyVGridLayoutComponent(nativePtr);
94  }, (nativePtr: KNode, classType: ModifierType, modifierJS: ModifierJS) => {
95    return new modifierJS.LazyVGridLayoutModifier(nativePtr, classType);
96  });
97};
98