1/* 2 * Copyright (c) 2024 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 LinearIndicatorIndicatorStyleModifier extends ModifierWithKey<LinearIndicatorStyle> { 18 constructor(value: LinearIndicatorStyle) { 19 super(value); 20 } 21 static identity = Symbol('linearIndicatorIndicatorStyle'); 22 applyPeer(node: KNode, reset: boolean): void { 23 if (reset) { 24 getUINativeModule().linearIndicator.resetIndicatorStyle(node); 25 } else { 26 getUINativeModule().linearIndicator.setIndicatorStyle(node, this.value); 27 } 28 } 29 checkObjectDiff(): boolean { 30 return this.stageValue !== this.value; 31 } 32} 33 34class LinearIndicatorIndicatorLoopModifier extends ModifierWithKey<boolean> { 35 constructor(value: boolean) { 36 super(value); 37 } 38 static identity = Symbol('linearIndicatorIndicatorLoop'); 39 applyPeer(node: KNode, reset: boolean): void { 40 if (reset) { 41 getUINativeModule().linearIndicator.resetIndicatorLoop(node); 42 } else { 43 getUINativeModule().linearIndicator.setIndicatorLoop(node, this.value); 44 } 45 } 46 checkObjectDiff(): boolean { 47 return this.stageValue !== this.value; 48 } 49} 50 51class LinearIndicatorOnChangeModifier extends ModifierWithKey<OnLinearIndicatorChangeCallback> { 52 constructor(value: OnLinearIndicatorChangeCallback) { 53 super(value); 54 } 55 static identity = Symbol('linearIndicatorOnChange'); 56 applyPeer(node: KNode, reset: boolean): void { 57 if (reset) { 58 getUINativeModule().linearIndicator.resetOnChange(node); 59 } else { 60 getUINativeModule().linearIndicator.setOnChange(node, this.value); 61 } 62 } 63} 64 65class ArkLinearIndicatorComponent extends ArkComponent implements CommonMethod<LinearIndicatorAttribute> { 66 constructor(nativePtr: KNode, classType?: ModifierType) { 67 super(nativePtr, classType); 68 } 69 70 indicatorStyle(value: LinearIndicatorStyle): LinearIndicatorAttribute { 71 modifierWithKey(this._modifiersWithKeys, LinearIndicatorIndicatorStyleModifier.identity, LinearIndicatorIndicatorStyleModifier, value); 72 return this; 73 } 74 75 indicatorLoop(value: boolean): LinearIndicatorAttribute { 76 modifierWithKey(this._modifiersWithKeys, LinearIndicatorIndicatorLoopModifier.identity, LinearIndicatorIndicatorLoopModifier, value); 77 return this; 78 } 79 80 onChange(value: OnLinearIndicatorChangeCallback): LinearIndicatorAttribute { 81 modifierWithKey(this._modifiersWithKeys, LinearIndicatorOnChangeModifier.identity, LinearIndicatorOnChangeModifier, value); 82 return this; 83 } 84 85} 86 87// @ts-ignore 88globalThis.LinearIndicator.attributeModifier = function (modifier: ArkComponent): void { 89 attributeModifierFunc.call(this, modifier, (nativePtr: KNode) => { 90 return new ArkLinearIndicatorComponent(nativePtr); 91 }, (nativePtr: KNode, classType: ModifierType, modifierJS: ModifierJS) => { 92 return new modifierJS.LinearIndicatorModifier(nativePtr, classType); 93 }); 94}; 95