• 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, classType?: ModifierType) {
19    super(nativePtr, classType);
20  }
21  prevLabel(value: string): this {
22    modifierWithKey(this._modifiersWithKeys, PrevLabelModifier.identity, PrevLabelModifier, value);
23    return this;
24  }
25  nextLabel(value: string): this {
26    modifierWithKey(this._modifiersWithKeys, NextLabelModifier.identity, NextLabelModifier, value);
27    return this;
28  }
29  status(value?: ItemState | undefined): this {
30    modifierWithKey(this._modifiersWithKeys, StatusModifier.identity, StatusModifier, value);
31    return this;
32  }
33}
34
35class NextLabelModifier extends ModifierWithKey<string> {
36  static identity: Symbol = Symbol('NextLabel');
37
38  applyPeer(node: KNode, reset: boolean): void {
39    if (reset) {
40      getUINativeModule().stepperItem.resetNextLabel(node);
41    } else {
42      getUINativeModule().stepperItem.setNextLabel(node, this.value);
43    }
44  }
45}
46
47class PrevLabelModifier extends ModifierWithKey<string> {
48  constructor(value: string) {
49    super(value);
50  }
51  static identity: Symbol = Symbol('prevLabel');
52
53  applyPeer(node: KNode, reset: boolean): void {
54    if (reset) {
55      getUINativeModule().stepperItem.resetPrevLabel(node);
56    } else {
57      getUINativeModule().stepperItem.setPrevLabel(node, this.value);
58    }
59  }
60}
61
62class StatusModifier extends ModifierWithKey<ItemState | undefined> {
63  constructor(value: ItemState | undefined) {
64    super(value);
65  }
66  static identity: Symbol = Symbol('status');
67
68  applyPeer(node: KNode, reset: boolean): void {
69    if (reset) {
70      getUINativeModule().stepperItem.resetStatus(node);
71    } else {
72      getUINativeModule().stepperItem.setStatus(node, this.value);
73    }
74  }
75}
76// @ts-ignore
77globalThis.StepperItem.attributeModifier = function (modifier: ArkComponent): void {
78  attributeModifierFunc.call(this, modifier, (nativePtr: KNode) => {
79    return new ArkStepperItemComponent(nativePtr);
80  }, (nativePtr: KNode, classType: ModifierType, modifierJS: ModifierJS) => {
81    return new modifierJS.StepperItemModifier(nativePtr, classType);
82  });
83};
84