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