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 ListItemGroupDividerModifier extends ModifierWithKey<DividerStyle> { 18 constructor(value: DividerStyle) { 19 super(value); 20 } 21 static identity: Symbol = Symbol('listItemGroupDivider'); 22 applyPeer(node: KNode, reset: boolean): void { 23 if (reset) { 24 getUINativeModule().listItemGroup.resetDivider(node); 25 } else { 26 getUINativeModule().listItemGroup.setDivider(node, this.value?.strokeWidth!, this.value?.color, this.value?.startMargin, this.value?.endMargin); 27 } 28 } 29 30 checkObjectDiff(): boolean { 31 return !(this.stageValue?.strokeWidth === this.value?.strokeWidth && 32 this.stageValue?.color === this.value?.color && 33 this.stageValue?.startMargin === this.value?.startMargin && 34 this.stageValue?.endMargin === this.value?.endMargin); 35 } 36} 37 38class ArkListItemGroupComponent extends ArkComponent implements ListItemGroupAttribute { 39 constructor(nativePtr: KNode) { 40 super(nativePtr); 41 } 42 divider(value: { strokeWidth: any; color?: any; startMargin?: any; endMargin?: any; } | null): this { 43 modifierWithKey(this._modifiersWithKeys, ListItemGroupDividerModifier.identity, ListItemGroupDividerModifier, value); 44 return this; 45 } 46} 47 48// @ts-ignore 49globalThis.ListItemGroup.attributeModifier = function (modifier) { 50 const elmtId = ViewStackProcessor.GetElmtIdToAccountFor(); 51 let nativeNode = getUINativeModule().getFrameNodeById(elmtId); 52 let component = this.createOrGetNode(elmtId, () => { 53 return new ArkListItemGroupComponent(nativeNode); 54 }); 55 applyUIAttributes(modifier, nativeNode, component); 56 component.applyModifierPatch(); 57}; 58