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