• 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 ArkStepperItemComponent extends ArkComponent implements StepperItemAttribute {
18  constructor(nativePtr: KNode) {
19    super(nativePtr);
20  }
21  prevLabel(value: string): this {
22    throw new Error('Method not implemented.');
23  }
24  nextLabel(value: string): this {
25    modifierWithKey(this._modifiersWithKeys, NextLabelModifier.identity, NextLabelModifier, value);
26    return this;
27  }
28  status(value?: ItemState | undefined): this {
29    throw new Error('Method not implemented.');
30  }
31}
32
33class NextLabelModifier extends ModifierWithKey<string> {
34  constructor(value: string) {
35    super(value);
36  }
37  static identity: Symbol = Symbol('NextLabel');
38
39  applyPeer(node: KNode, reset: boolean): void {
40    if (reset) {
41      getUINativeModule().stepperItem.resetNextLabel(node);
42    } else {
43      getUINativeModule().stepperItem.setNextLabel(node, this.value);
44    }
45  }
46}
47
48// @ts-ignore
49globalThis.StepperItem.attributeModifier = function (modifier) {
50  const elmtId = ViewStackProcessor.GetElmtIdToAccountFor();
51  let nativeNode = getUINativeModule().getFrameNodeById(elmtId);
52  let component = this.createOrGetNode(elmtId, () => {
53    return new ArkStepperItemComponent(nativeNode);
54  });
55  applyUIAttributes(modifier, nativeNode, component);
56  component.applyModifierPatch();
57};
58