• 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 ArkXComponentComponent implements CommonMethod<XComponentAttribute> {
18  _modifiersWithKeys: Map<Symbol, ModifierWithKey<number | string | boolean | object>>;
19  nativePtr: KNode;
20
21  constructor(nativePtr: KNode) {
22    this._modifiersWithKeys = new Map();
23    this.nativePtr = nativePtr;
24  }
25
26  applyModifierPatch(): void {
27    let expiringItemsWithKeys = [];
28    this._modifiersWithKeys.forEach((value, key) => {
29      if (value.applyStage(this.nativePtr)) {
30        expiringItemsWithKeys.push(key);
31      }
32    });
33    expiringItemsWithKeys.forEach(key => {
34      this._modifiersWithKeys.delete(key);
35    });
36  }
37  outline(value: OutlineOptions): this {
38    throw new Error('Method not implemented.');
39  }
40  outlineColor(value: ResourceColor | EdgeColors): this {
41    throw new Error('Method not implemented.');
42  }
43  outlineRadius(value: Dimension | OutlineRadiuses): this {
44    throw new Error('Method not implemented.');
45  }
46  outlineStyle(value: OutlineStyle | EdgeOutlineStyles): this {
47    throw new Error('Method not implemented.');
48  }
49  outlineWidth(value: Dimension | EdgeOutlineWidths): this {
50    throw new Error('Method not implemented.');
51  }
52  width(value: Length): this {
53    throw new Error('Method not implemented.');
54  }
55  height(value: Length): this {
56    throw new Error('Method not implemented.');
57  }
58  expandSafeArea(types?: SafeAreaType[], edges?: SafeAreaEdge[]): this {
59    throw new Error('Method not implemented.');
60  }
61  responseRegion(value: Rectangle | Rectangle[]): this {
62    throw new Error('Method not implemented.');
63  }
64  mouseResponseRegion(value: Rectangle | Rectangle[]): this {
65    throw new Error('Method not implemented.');
66  }
67  size(value: SizeOptions): this {
68    throw new Error('Method not implemented.');
69  }
70  constraintSize(value: ConstraintSizeOptions): this {
71    throw new Error('Method not implemented.');
72  }
73  touchable(value: boolean): this {
74    throw new Error('Method not implemented.');
75  }
76  hitTestBehavior(value: HitTestMode): this {
77    throw new Error('Method not implemented.');
78  }
79  layoutWeight(value: string | number): this {
80    throw new Error('Method not implemented.');
81  }
82  padding(value: Length | Padding): this {
83    throw new Error('Method not implemented.');
84  }
85  margin(value: Length | Padding): this {
86    throw new Error('Method not implemented.');
87  }
88  background(builder: CustomBuilder, options?: { align?: Alignment; }): this {
89    throw new Error('Method not implemented.');
90  }
91  backgroundColor(value: ResourceColor): this {
92    modifierWithKey(this._modifiersWithKeys, XComponentBackgroundColorModifier.identity,
93      XComponentBackgroundColorModifier, value);
94    return this;
95  }
96  backgroundImage(src: ResourceStr, repeat?: ImageRepeat): this {
97    let arkBackgroundImage = new ArkBackgroundImage();
98    arkBackgroundImage.src = src;
99    arkBackgroundImage.repeat = repeat;
100    modifierWithKey(this._modifiersWithKeys, XComponentBackgroundImageModifier.identity, XComponentBackgroundImageModifier, arkBackgroundImage);
101    return this;
102  }
103  backgroundImageSize(value: SizeOptions | ImageSize): this {
104    modifierWithKey(this._modifiersWithKeys, XComponentBackgroundImageSizeModifier.identity, XComponentBackgroundImageSizeModifier, value);
105    return this;
106  }
107  backgroundImagePosition(value: Alignment | Position): this {
108    modifierWithKey(this._modifiersWithKeys, XComponentBackgroundImagePositionModifier.identity, XComponentBackgroundImagePositionModifier, value);
109    return this;
110  }
111  backgroundBlurStyle(value: BlurStyle, options?: BackgroundBlurStyleOptions): this {
112    throw new Error('Method not implemented.');
113  }
114  foregroundBlurStyle(value: BlurStyle, options?: ForegroundBlurStyleOptions): this {
115    throw new Error('Method not implemented.');
116  }
117  opacity(value: number | Resource): this {
118    modifierWithKey(this._modifiersWithKeys, XComponentOpacityModifier.identity, XComponentOpacityModifier, value);
119    return this;
120  }
121  border(value: BorderOptions): this {
122    throw new Error('Method not implemented.');
123  }
124  borderStyle(value: BorderStyle | EdgeStyles): this {
125    throw new Error('Method not implemented.');
126  }
127  borderWidth(value: Length | EdgeWidths): this {
128    throw new Error('Method not implemented.');
129  }
130  borderColor(value: ResourceColor | EdgeColors): this {
131    throw new Error('Method not implemented.');
132  }
133  borderRadius(value: Length | BorderRadiuses): this {
134    throw new Error('Method not implemented.');
135  }
136  borderImage(value: BorderImageOption): this {
137    throw new Error('Method not implemented.');
138  }
139  foregroundColor(value: string | number | Resource | Color): this {
140    throw new Error('Method not implemented.');
141  }
142  onClick(event: (event: ClickEvent) => void): this {
143    throw new Error('Method not implemented.');
144  }
145  onHover(event: (isHover: boolean, event: HoverEvent) => void): this {
146    throw new Error('Method not implemented.');
147  }
148  hoverEffect(value: HoverEffect): this {
149    throw new Error('Method not implemented.');
150  }
151  onMouse(event: (event: MouseEvent) => void): this {
152    throw new Error('Method not implemented.');
153  }
154  onTouch(event: (event: TouchEvent) => void): this {
155    throw new Error('Method not implemented.');
156  }
157  onKeyEvent(event: (event: KeyEvent) => void): this {
158    throw new Error('Method not implemented.');
159  }
160  focusable(value: boolean): this {
161    throw new Error('Method not implemented.');
162  }
163  onFocus(event: () => void): this {
164    throw new Error('Method not implemented.');
165  }
166  onBlur(event: () => void): this {
167    throw new Error('Method not implemented.');
168  }
169  tabIndex(index: number): this {
170    throw new Error('Method not implemented.');
171  }
172  defaultFocus(value: boolean): this {
173    throw new Error('Method not implemented.');
174  }
175  groupDefaultFocus(value: boolean): this {
176    throw new Error('Method not implemented.');
177  }
178  focusOnTouch(value: boolean): this {
179    throw new Error('Method not implemented.');
180  }
181  animation(value: AnimateParam): this {
182    throw new Error('Method not implemented.');
183  }
184  transition(value: TransitionOptions | TransitionEffect): this {
185    throw new Error('Method not implemented.');
186  }
187  gesture(gesture: GestureType, mask?: GestureMask): this {
188    throw new Error('Method not implemented.');
189  }
190  priorityGesture(gesture: GestureType, mask?: GestureMask): this {
191    throw new Error('Method not implemented.');
192  }
193  parallelGesture(gesture: GestureType, mask?: GestureMask): this {
194    throw new Error('Method not implemented.');
195  }
196  blur(value: number): this {
197    modifierWithKey(this._modifiersWithKeys, XComponentBlurModifier.identity, XComponentBlurModifier, value);
198    return this;
199  }
200  linearGradientBlur(value: number, options: LinearGradientBlurOptions): this {
201    if (isUndefined(value) || isNull(value) || isUndefined(options) || isNull(options)) {
202      modifierWithKey(this._modifiersWithKeys, XComponentLinearGradientBlurModifier.identity, XComponentLinearGradientBlurModifier,
203        undefined);
204      return this;
205    }
206    let arkLinearGradientBlur = new ArkLinearGradientBlur();
207    arkLinearGradientBlur.blurRadius = value;
208    arkLinearGradientBlur.fractionStops = options.fractionStops;
209    arkLinearGradientBlur.direction = options.direction;
210    modifierWithKey(this._modifiersWithKeys, XComponentLinearGradientBlurModifier.identity, XComponentLinearGradientBlurModifier,
211      arkLinearGradientBlur);
212    return this;
213  }
214  brightness(value: number): this {
215    modifierWithKey(this._modifiersWithKeys, XComponentBrightnessModifier.identity, XComponentBrightnessModifier, value);
216    return this;
217  }
218  contrast(value: number): this {
219    modifierWithKey(this._modifiersWithKeys, XComponentContrastModifier.identity, XComponentContrastModifier, value);
220    return this;
221  }
222  grayscale(value: number): this {
223    modifierWithKey(this._modifiersWithKeys, XComponentGrayscaleModifier.identity, XComponentGrayscaleModifier, value);
224    return this;
225  }
226  colorBlend(value: string | Resource | Color): this {
227    modifierWithKey(this._modifiersWithKeys, XComponentColorBlendModifier.identity, XComponentColorBlendModifier, value);
228    return this;
229  }
230  saturate(value: number): this {
231    modifierWithKey(this._modifiersWithKeys, XComponentSaturateModifier.identity, XComponentSaturateModifier, value);
232    return this;
233  }
234  sepia(value: number): this {
235    modifierWithKey(this._modifiersWithKeys, XComponentSepiaModifier.identity, XComponentSepiaModifier, value);
236    return this;
237  }
238  invert(value: number): this {
239    modifierWithKey(this._modifiersWithKeys, XComponentInvertModifier.identity, XComponentInvertModifier, value);
240    return this;
241  }
242  hueRotate(value: string | number): this {
243    modifierWithKey(this._modifiersWithKeys, XComponentHueRotateModifier.identity, XComponentHueRotateModifier, value);
244    return this;
245  }
246  useEffect(value: boolean): this {
247    throw new Error('Method not implemented.');
248  }
249  backdropBlur(value: number): this {
250    modifierWithKey(this._modifiersWithKeys, XComponentBackdropBlurModifier.identity, XComponentBackdropBlurModifier, value);
251    return this;
252  }
253  renderGroup(value: boolean): this {
254    throw new Error('Method not implemented.');
255  }
256  translate(value: TranslateOptions): this {
257    throw new Error('Method not implemented.');
258  }
259  scale(value: ScaleOptions): this {
260    throw new Error('Method not implemented.');
261  }
262  gridSpan(value: number): this {
263    throw new Error('Method not implemented.');
264  }
265  gridOffset(value: number): this {
266    throw new Error('Method not implemented.');
267  }
268  rotate(value: RotateOptions): this {
269    throw new Error('Method not implemented.');
270  }
271  transform(value: object): this {
272    throw new Error('Method not implemented.');
273  }
274  onAppear(event: () => void): this {
275    throw new Error('Method not implemented.');
276  }
277  onDisAppear(event: () => void): this {
278    throw new Error('Method not implemented.');
279  }
280  onAreaChange(event: (oldValue: Area, newValue: Area) => void): this {
281    throw new Error('Method not implemented.');
282  }
283  visibility(value: Visibility): this {
284    throw new Error('Method not implemented.');
285  }
286  flexGrow(value: number): this {
287    throw new Error('Method not implemented.');
288  }
289  flexShrink(value: number): this {
290    throw new Error('Method not implemented.');
291  }
292  flexBasis(value: string | number): this {
293    throw new Error('Method not implemented.');
294  }
295  alignSelf(value: ItemAlign): this {
296    throw new Error('Method not implemented.');
297  }
298  displayPriority(value: number): this {
299    throw new Error('Method not implemented.');
300  }
301  zIndex(value: number): this {
302    throw new Error('Method not implemented.');
303  }
304  sharedTransition(id: string, options?: sharedTransitionOptions): this {
305    throw new Error('Method not implemented.');
306  }
307  direction(value: Direction): this {
308    throw new Error('Method not implemented.');
309  }
310  align(value: Alignment): this {
311    throw new Error('Method not implemented.');
312  }
313  position(value: Position): this {
314    throw new Error('Method not implemented.');
315  }
316  markAnchor(value: Position): this {
317    throw new Error('Method not implemented.');
318  }
319  offset(value: Position): this {
320    throw new Error('Method not implemented.');
321  }
322  enabled(value: boolean): this {
323    throw new Error('Method not implemented.');
324  }
325  useSizeType(value: {
326    xs?: number | { span: number; offset: number };
327    sm?: number | { span: number; offset: number };
328    md?: number | { span: number; offset: number };
329    lg?: number | { span: number; offset: number };
330  }): this {
331    throw new Error('Method not implemented.');
332  }
333  alignRules(value: AlignRuleOption): this {
334    throw new Error('Method not implemented.');
335  }
336  aspectRatio(value: number): this {
337    throw new Error('Method not implemented.');
338  }
339  clickEffect(value: ClickEffect): this {
340    throw new Error('Method not implemented.');
341  }
342  onDragStart(event: (event: DragEvent, extraParams?: string) => CustomBuilder | DragItemInfo): this {
343    throw new Error('Method not implemented.');
344  }
345  onDragEnter(event: (event: DragEvent, extraParams?: string) => void): this {
346    throw new Error('Method not implemented.');
347  }
348  onDragMove(event: (event: DragEvent, extraParams?: string) => void): this {
349    throw new Error('Method not implemented.');
350  }
351  onDragLeave(event: (event: DragEvent, extraParams?: string) => void): this {
352    throw new Error('Method not implemented.');
353  }
354  onDrop(event: (event: DragEvent, extraParams?: string) => void): this {
355    throw new Error('Method not implemented.');
356  }
357  onDragEnd(event: (event: DragEvent, extraParams?: string) => void): this {
358    throw new Error('Method not implemented.');
359  }
360  allowDrop(value: Array<UniformDataType>): this {
361    throw new Error('Method not implemented.');
362  }
363  draggable(value: boolean): this {
364    throw new Error('Method not implemented.');
365  }
366  overlay(value: string | CustomBuilder, options?: { align?: Alignment; offset?: { x?: number; y?: number; }; }): this {
367    throw new Error('Method not implemented.');
368  }
369  linearGradient(value: {
370    angle?: number | string;
371    direction?: GradientDirection;
372    colors: Array<any>;
373    repeating?: boolean;
374  }): this {
375    throw new Error('Method not implemented.');
376  }
377  sweepGradient(value: {
378    center: Array<any>;
379    start?: number | string;
380    end?: number | string;
381    rotation?: number | string;
382    colors: Array<any>;
383    repeating?: boolean;
384  }): this {
385    throw new Error('Method not implemented.');
386  }
387  radialGradient(value: { center: Array<any>; radius: number | string; colors: Array<any>; repeating?: boolean }): this {
388    throw new Error('Method not implemented.');
389  }
390  motionPath(value: MotionPathOptions): this {
391    throw new Error('Method not implemented.');
392  }
393  shadow(value: ShadowOptions | ShadowStyle): this {
394    modifierWithKey(this._modifiersWithKeys, ShadowModifier.identity, ShadowModifier, value);
395    return this;
396  }
397  blendMode(value: BlendMode): this {
398    throw new Error('Method not implemented.');
399  }
400  clip(value: boolean | CircleAttribute | EllipseAttribute | PathAttribute | RectAttribute): this {
401    throw new Error('Method not implemented.');
402  }
403  mask(value: CircleAttribute | EllipseAttribute | PathAttribute | RectAttribute | ProgressMask): this {
404    throw new Error('Method not implemented.');
405  }
406  key(value: string): this {
407    throw new Error('Method not implemented.');
408  }
409  id(value: string): this {
410    throw new Error('Method not implemented.');
411  }
412  geometryTransition(id: string): this {
413    throw new Error('Method not implemented.');
414  }
415  bindPopup(show: boolean, popup: PopupOptions | CustomPopupOptions): this {
416    throw new Error('Method not implemented.');
417  }
418  bindMenu(content: CustomBuilder | MenuElement[], options?: MenuOptions): this {
419    throw new Error('Method not implemented.');
420  }
421  bindContextMenu(content: CustomBuilder, responseType: ResponseType, options?: ContextMenuOptions): this {
422    throw new Error('Method not implemented.');
423  }
424  bindContentCover(isShow: unknown, builder: unknown, options?: unknown): this {
425    throw new Error('Method not implemented.');
426  }
427  bindSheet(isShow: boolean, builder: CustomBuilder, options?: SheetOptions): this {
428    throw new Error('Method not implemented.');
429  }
430  stateStyles(value: StateStyles): this {
431    throw new Error('Method not implemented.');
432  }
433  restoreId(value: number): this {
434    throw new Error('Method not implemented.');
435  }
436  onVisibleAreaChange(ratios: number[], event: (isVisible: boolean, currentRatio: number) => void): this {
437    throw new Error('Method not implemented.');
438  }
439  sphericalEffect(value: number): this {
440    modifierWithKey(this._modifiersWithKeys, XComponentSphericalEffectModifier.identity, XComponentSphericalEffectModifier, value);
441    return this;
442  }
443  lightUpEffect(value: number): this {
444    modifierWithKey(this._modifiersWithKeys, XComponentLightUpEffectModifier.identity, XComponentLightUpEffectModifier, value);
445    return this;
446  }
447  pixelStretchEffect(options: PixelStretchEffectOptions): this {
448    modifierWithKey(this._modifiersWithKeys, XComponentPixelStretchEffectModifier.identity, XComponentPixelStretchEffectModifier, options);
449    return this;
450  }
451  keyboardShortcut(value: string | FunctionKey, keys: ModifierKey[], action?: () => void): this {
452    throw new Error('Method not implemented.');
453  }
454  accessibilityGroup(value: boolean): this {
455    throw new Error('Method not implemented.');
456  }
457  accessibilityText(value: string): this {
458    throw new Error('Method not implemented.');
459  }
460  accessibilityDescription(value: string): this {
461    throw new Error('Method not implemented.');
462  }
463  accessibilityLevel(value: string): this {
464    throw new Error('Method not implemented.');
465  }
466  obscured(reasons: ObscuredReasons[]): this {
467    throw new Error('Method not implemented.');
468  }
469  reuseId(id: string): this {
470    throw new Error('Method not implemented.');
471  }
472  renderFit(fitMode: RenderFit): this {
473    throw new Error('Method not implemented.');
474  }
475  attributeModifier(modifier: AttributeModifier<CommonAttribute>): this {
476    return this;
477  }
478  onGestureJudgeBegin(callback: (gestureInfo: GestureInfo, event: BaseGestureEvent) => GestureJudgeResult): this {
479    throw new Error('Method not implemented.');
480  }
481  onLoad(callback: (event?: object) => void): this {
482    throw new Error('Method not implemented.');
483  }
484  onDestroy(event: () => void): this {
485    throw new Error('Method not implemented.');
486  }
487
488}
489
490// @ts-ignore
491globalThis.XComponent.attributeModifier = function (modifier) {
492  const elmtId = ViewStackProcessor.GetElmtIdToAccountFor();
493  let nativeNode = getUINativeModule().getFrameNodeById(elmtId);
494  let component = this.createOrGetNode(elmtId, () => {
495    return new ArkXComponentComponent(nativeNode);
496  });
497  applyUIAttributes(modifier, nativeNode, component);
498  component.applyModifierPatch();
499};
500
501class XComponentOpacityModifier extends ModifierWithKey<number | Resource> {
502  constructor(value: number | Resource) {
503    super(value);
504  }
505  static identity: Symbol = Symbol('xComponentOpacity');
506  applyPeer(node: KNode, reset: boolean): void {
507    if (reset) {
508      getUINativeModule().xComponent.resetOpacity(node);
509    } else {
510      getUINativeModule().xComponent.setOpacity(node, this.value);
511    }
512  }
513
514  checkObjectDiff(): boolean {
515    return !isBaseOrResourceEqual(this.stageValue, this.value);
516  }
517}
518
519class XComponentBackgroundColorModifier extends ModifierWithKey<ResourceColor> {
520  constructor(value: ResourceColor) {
521    super(value);
522  }
523  static identity: Symbol = Symbol('xComponentBackgroundColor');
524  applyPeer(node: KNode, reset: boolean): void {
525    if (reset) {
526      getUINativeModule().xComponent.resetBackgroundColor(node);
527    } else {
528      getUINativeModule().xComponent.setBackgroundColor(node, this.value);
529    }
530  }
531
532  checkObjectDiff(): boolean {
533    return !isBaseOrResourceEqual(this.stageValue, this.value);
534  }
535}
536
537class XComponentBackgroundImageModifier extends ModifierWithKey<ArkBackgroundImage> {
538  constructor(value: ArkBackgroundImage) {
539    super(value);
540  }
541  static identity: Symbol = Symbol('xComponentBackgroundImage');
542  applyPeer(node: KNode, reset: boolean): void {
543    if (reset) {
544      getUINativeModule().xComponent.resetBackgroundImage(node);
545    } else {
546      getUINativeModule().xComponent.setBackgroundImage(node, this.value.src, this.value.repeat);
547    }
548  }
549
550  checkObjectDiff(): boolean {
551    return !((this.stageValue as ArkBackgroundImage).src === (this.value as ArkBackgroundImage).src &&
552      (this.stageValue as ArkBackgroundImage).repeat === (this.value as ArkBackgroundImage).repeat);
553  }
554}
555
556class XComponentBackgroundImageSizeModifier extends ModifierWithKey<SizeOptions | ImageSize> {
557  constructor(value: SizeOptions | ImageSize) {
558    super(value);
559  }
560  static identity: Symbol = Symbol('xComponentBackgroundImageSize');
561  applyPeer(node: KNode, reset: boolean): void {
562    if (reset) {
563      getUINativeModule().xComponent.resetBackgroundImageSize(node);
564    } else {
565      if (isNumber(this.value)) {
566        getUINativeModule().xComponent.setBackgroundImageSize(node, this.value, undefined, undefined);
567      } else {
568        getUINativeModule().xComponent.setBackgroundImageSize(node, undefined, (this.value as SizeOptions)?.width, (this.value as SizeOptions)?.height);
569      }
570    }
571  }
572  checkObjectDiff(): boolean {
573    return !((this.value as SizeOptions).width === (this.stageValue as SizeOptions).width &&
574      (this.value as SizeOptions).height === (this.stageValue as SizeOptions).height);
575  }
576}
577
578class XComponentBackgroundImagePositionModifier extends ModifierWithKey<Position | Alignment> {
579  constructor(value: Position | Alignment) {
580    super(value);
581  }
582  static identity: Symbol = Symbol('xComponentBackgroundImagePosition');
583  applyPeer(node: KNode, reset: boolean): void {
584    if (reset) {
585      getUINativeModule().xComponent.resetBackgroundImagePosition(node);
586    } else {
587      if (isNumber(this.value)) {
588        getUINativeModule().xComponent.setBackgroundImagePosition(node, this.value, undefined, undefined);
589      } else {
590        getUINativeModule().xComponent.setBackgroundImagePosition(node, undefined, (this.value as Position)?.x, (this.value as Position)?.y);
591      }
592    }
593  }
594  checkObjectDiff(): boolean {
595    return !((this.value as Position)?.x === (this.stageValue as Position)?.x &&
596      (this.value as Position)?.y === (this.stageValue as Position)?.y);
597  }
598}
599
600class XComponentBlurModifier extends ModifierWithKey<number> {
601  constructor(value: number) {
602    super(value);
603  }
604  static identity: Symbol = Symbol('xComponentBlur');
605  applyPeer(node: KNode, reset: boolean): void {
606    if (reset) {
607      getUINativeModule().xComponent.resetBlur(node);
608    } else {
609      getUINativeModule().xComponent.setBlur(node, this.value);
610    }
611  }
612}
613
614class XComponentBackdropBlurModifier extends ModifierWithKey<number> {
615  constructor(value: number) {
616    super(value);
617  }
618  static identity: Symbol = Symbol('xComponentBackdropBlur');
619  applyPeer(node: KNode, reset: boolean): void {
620    if (reset) {
621      getUINativeModule().xComponent.resetBackdropBlur(node);
622    } else {
623      getUINativeModule().xComponent.setBackdropBlur(node, this.value);
624    }
625  }
626}
627
628class XComponentGrayscaleModifier extends ModifierWithKey<number> {
629  constructor(value: number) {
630    super(value);
631  }
632  static identity: Symbol = Symbol('xComponentGrayscale');
633  applyPeer(node: KNode, reset: boolean): void {
634    if (reset) {
635      getUINativeModule().xComponent.resetGrayscale(node);
636    } else {
637      getUINativeModule().xComponent.setGrayscale(node, this.value);
638    }
639  }
640}
641
642class XComponentBrightnessModifier extends ModifierWithKey<number> {
643  constructor(value: number) {
644    super(value);
645  }
646  static identity: Symbol = Symbol('xComponentBrightness');
647  applyPeer(node: KNode, reset: boolean): void {
648    if (reset) {
649      getUINativeModule().xComponent.resetBrightness(node);
650    } else {
651      getUINativeModule().xComponent.setBrightness(node, this.value);
652    }
653  }
654}
655
656class XComponentSaturateModifier extends ModifierWithKey<number> {
657  constructor(value: number) {
658    super(value);
659  }
660  static identity: Symbol = Symbol('xComponentSaturate');
661  applyPeer(node: KNode, reset: boolean): void {
662    if (reset) {
663      getUINativeModule().xComponent.resetSaturate(node);
664    } else {
665      getUINativeModule().xComponent.setSaturate(node, this.value);
666    }
667  }
668}
669
670class XComponentContrastModifier extends ModifierWithKey<number> {
671  constructor(value: number) {
672    super(value);
673  }
674  static identity: Symbol = Symbol('xComponentContrast');
675  applyPeer(node: KNode, reset: boolean): void {
676    if (reset) {
677      getUINativeModule().xComponent.resetContrast(node);
678    } else {
679      getUINativeModule().xComponent.setContrast(node, this.value);
680    }
681  }
682}
683
684class XComponentInvertModifier extends ModifierWithKey<number> {
685  constructor(value: number) {
686    super(value);
687  }
688  static identity: Symbol = Symbol('xComponentInvert');
689  applyPeer(node: KNode, reset: boolean): void {
690    if (reset) {
691      getUINativeModule().xComponent.resetInvert(node);
692    } else {
693      getUINativeModule().xComponent.setInvert(node, this.value);
694    }
695  }
696}
697
698class XComponentSepiaModifier extends ModifierWithKey<number> {
699  constructor(value: number) {
700    super(value);
701  }
702  static identity: Symbol = Symbol('xComponentSepia');
703  applyPeer(node: KNode, reset: boolean): void {
704    if (reset) {
705      getUINativeModule().xComponent.resetSepia(node);
706    } else {
707      getUINativeModule().xComponent.setSepia(node, this.value);
708    }
709  }
710}
711
712class XComponentHueRotateModifier extends ModifierWithKey<number | string> {
713  constructor(value: number | string) {
714    super(value);
715  }
716  static identity: Symbol = Symbol('xComponentHueRotate');
717  applyPeer(node: KNode, reset: boolean): void {
718    if (reset) {
719      getUINativeModule().xComponent.resetHueRotate(node);
720    } else {
721      getUINativeModule().xComponent.setHueRotate(node, this.value);
722    }
723  }
724}
725
726class XComponentColorBlendModifier extends ModifierWithKey<Color | string | Resource> {
727  constructor(value: Color | string | Resource) {
728    super(value);
729  }
730  static identity: Symbol = Symbol('xComponentColorBlend');
731  applyPeer(node: KNode, reset: boolean): void {
732    if (reset) {
733      getUINativeModule().xComponent.resetColorBlend(node);
734    } else {
735      getUINativeModule().xComponent.setColorBlend(node, this.value);
736    }
737  }
738
739  checkObjectDiff(): boolean {
740    return !isBaseOrResourceEqual(this.stageValue, this.value);
741  }
742}
743
744class XComponentSphericalEffectModifier extends ModifierWithKey<number> {
745  constructor(value: number) {
746    super(value);
747  }
748  static identity: Symbol = Symbol('xComponentSphericalEffect');
749  applyPeer(node: KNode, reset: boolean): void {
750    if (reset) {
751      getUINativeModule().xComponent.resetSphericalEffect(node);
752    } else {
753      getUINativeModule().xComponent.setSphericalEffect(node, this.value);
754    }
755  }
756}
757
758class XComponentLightUpEffectModifier extends ModifierWithKey<number> {
759  constructor(value: number) {
760    super(value);
761  }
762  static identity: Symbol = Symbol('xComponentLightUpEffect');
763  applyPeer(node: KNode, reset: boolean): void {
764    if (reset) {
765      getUINativeModule().xComponent.resetLightUpEffect(node);
766    } else {
767      getUINativeModule().xComponent.setLightUpEffect(node, this.value);
768    }
769  }
770}
771
772class XComponentPixelStretchEffectModifier extends ModifierWithKey<PixelStretchEffectOptions> {
773  constructor(value: PixelStretchEffectOptions) {
774    super(value);
775  }
776  static identity: Symbol = Symbol('xComponentPixelStretchEffect');
777  applyPeer(node: KNode, reset: boolean): void {
778    if (reset) {
779      getUINativeModule().xComponent.resetPixelStretchEffect(node);
780    } else {
781      getUINativeModule().xComponent.setPixelStretchEffect(node,
782        this.value.top, this.value.right, this.value.bottom, this.value.left);
783    }
784  }
785
786  checkObjectDiff(): boolean {
787    return !((this.stageValue as PixelStretchEffectOptions).left === (this.value as PixelStretchEffectOptions).left &&
788      (this.stageValue as PixelStretchEffectOptions).right === (this.value as PixelStretchEffectOptions).right &&
789      (this.stageValue as PixelStretchEffectOptions).top === (this.value as PixelStretchEffectOptions).top &&
790      (this.stageValue as PixelStretchEffectOptions).bottom === (this.value as PixelStretchEffectOptions).bottom);
791  }
792}
793
794class XComponentLinearGradientBlurModifier extends ModifierWithKey<ArkLinearGradientBlur> {
795  constructor(value: ArkLinearGradientBlur) {
796    super(value);
797  }
798  static identity: Symbol = Symbol('xComponentlinearGradientBlur');
799  applyPeer(node: KNode, reset: boolean): void {
800    if (reset) {
801      getUINativeModule().xComponent.resetLinearGradientBlur(node);
802    } else {
803      getUINativeModule().xComponent.setLinearGradientBlur(node,
804        this.value.blurRadius, this.value.fractionStops, this.value.direction);
805    }
806  }
807  checkObjectDiff(): boolean {
808    return !this.value.isEqual(this.stageValue);
809  }
810}
811