• 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' />
17class ColumnAlignItemsModifier extends ModifierWithKey<number> {
18  constructor(value: number) {
19    super(value);
20  }
21  static identity: Symbol = Symbol('columnAlignItems');
22  applyPeer(node: KNode, reset: boolean): void {
23    if (reset) {
24      getUINativeModule().column.resetAlignItems(node);
25    } else {
26      getUINativeModule().column.setAlignItems(node, this.value!);
27    }
28  }
29  checkObjectDiff(): boolean {
30    return this.stageValue !== this.value;
31  }
32}
33
34class ColumnJustifyContentModifier extends ModifierWithKey<number> {
35  constructor(value: number) {
36    super(value);
37  }
38  static identity: Symbol = Symbol('columnJustifyContent');
39  applyPeer(node: KNode, reset: boolean): void {
40    if (reset) {
41      getUINativeModule().column.resetJustifyContent(node);
42    } else {
43      getUINativeModule().column.setJustifyContent(node, this.value!);
44    }
45  }
46  checkObjectDiff(): boolean {
47    return this.stageValue !== this.value;
48  }
49}
50
51class ArkColumnComponent extends ArkComponent implements CommonMethod<ColumnAttribute> {
52  constructor(nativePtr: KNode) {
53    super(nativePtr);
54  }
55  alignItems(value: HorizontalAlign): ColumnAttribute {
56    modifierWithKey(this._modifiersWithKeys, ColumnAlignItemsModifier.identity, ColumnAlignItemsModifier, value);
57    return this;
58  }
59  justifyContent(value: FlexAlign): ColumnAttribute {
60    modifierWithKey(this._modifiersWithKeys, ColumnJustifyContentModifier.identity, ColumnJustifyContentModifier, value);
61    return this;
62  }
63  pointLight(value: PointLightStyle): ColumnAttribute {
64    throw new Error('Method not implemented.');
65  }
66}
67// @ts-ignore
68globalThis.Column.attributeModifier = function (modifier) {
69  const elmtId = ViewStackProcessor.GetElmtIdToAccountFor();
70  let nativeNode = getUINativeModule().getFrameNodeById(elmtId);
71  let component = this.createOrGetNode(elmtId, () => {
72    return new ArkColumnComponent(nativeNode);
73  });
74  applyUIAttributes(modifier, nativeNode, component);
75  component.applyModifierPatch();
76};