• 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 PatternLockActiveColorModifier extends ModifierWithKey<ResourceColor> {
18  static identity: Symbol = Symbol('patternLockActiveColor');
19  applyPeer(node: KNode, reset: boolean): void {
20    if (reset) {
21      getUINativeModule().patternLock.resetActiveColor(node);
22    } else {
23      getUINativeModule().patternLock.setActiveColor(node, this.value!);
24    }
25  }
26  checkObjectDiff(): boolean {
27    return !isBaseOrResourceEqual(this.stageValue, this.value);
28  }
29}
30
31class PatternLockSelectedColorModifier extends ModifierWithKey<ResourceColor> {
32  static identity: Symbol = Symbol('patternLockSelectedColor');
33  applyPeer(node: KNode, reset: boolean): void {
34    if (reset) {
35      getUINativeModule().patternLock.resetSelectedColor(node);
36    } else {
37      getUINativeModule().patternLock.setSelectedColor(node, this.value!);
38    }
39  }
40  checkObjectDiff(): boolean {
41    return !isBaseOrResourceEqual(this.stageValue, this.value);
42  }
43}
44
45class PatternLockPathColorModifier extends ModifierWithKey<ResourceColor> {
46  static identity: Symbol = Symbol('patternLockPathColor');
47  applyPeer(node: KNode, reset: boolean): void {
48    if (reset) {
49      getUINativeModule().patternLock.resetPathColor(node);
50    } else {
51      getUINativeModule().patternLock.setPathColor(node, this.value!);
52    }
53  }
54  checkObjectDiff(): boolean {
55    return !isBaseOrResourceEqual(this.stageValue, this.value);
56  }
57}
58
59class PatternLockRegularColorModifier extends ModifierWithKey<ResourceColor> {
60  static identity: Symbol = Symbol('patternLockRegularColor');
61  applyPeer(node: KNode, reset: boolean): void {
62    if (reset) {
63      getUINativeModule().patternLock.resetRegularColor(node);
64    } else {
65      getUINativeModule().patternLock.setRegularColor(node, this.value!);
66    }
67  }
68  checkObjectDiff(): boolean {
69    return !isBaseOrResourceEqual(this.stageValue, this.value);
70  }
71}
72
73class PatternLockSideLengthModifier extends ModifierWithKey<Length> {
74  static identity: Symbol = Symbol('patternLockSideLength');
75  applyPeer(node: KNode, reset: boolean): void {
76    if (reset) {
77      getUINativeModule().patternLock.resetSideLength(node);
78    } else {
79      getUINativeModule().patternLock.setSideLength(node, this.value!);
80    }
81  }
82  checkObjectDiff(): boolean {
83    return !isBaseOrResourceEqual(this.stageValue, this.value);
84  }
85}
86
87class PatternLockPathStrokeModifier extends ModifierWithKey<number | string> {
88  static identity: Symbol = Symbol('patternLockPathStroke');
89  applyPeer(node: KNode, reset: boolean): void {
90    if (reset) {
91      getUINativeModule().patternLock.resetPathStrokeWidth(node);
92    } else {
93      getUINativeModule().patternLock.setPathStrokeWidth(node, this.value!);
94    }
95  }
96  checkObjectDiff(): boolean {
97    return this.stageValue !== this.value;
98  }
99}
100
101class PatternLockCircleRadiusModifier extends ModifierWithKey<Length> {
102  static identity: Symbol = Symbol('patternLockCircleRadius');
103  applyPeer(node: KNode, reset: boolean): void {
104    if (reset) {
105      getUINativeModule().patternLock.resetCircleRadius(node);
106    } else {
107      getUINativeModule().patternLock.setCircleRadius(node, this.value!);
108    }
109  }
110  checkObjectDiff(): boolean {
111    return !isBaseOrResourceEqual(this.stageValue, this.value);
112  }
113}
114
115class PatternLockAutoResetModifier extends ModifierWithKey<boolean> {
116  static identity: Symbol = Symbol('patternlockautoreset');
117  applyPeer(node: KNode, reset: boolean): void {
118    if (reset) {
119      getUINativeModule().patternLock.resetAutoReset(node);
120    } else {
121      getUINativeModule().patternLock.setAutoReset(node, this.value!);
122    }
123  }
124  checkObjectDiff(): boolean {
125    return this.stageValue !== this.value;
126  }
127}
128
129class PatternLockActivateCircleStyleModifier extends ModifierWithKey<CircleStyleOptions> {
130  constructor(value: CircleStyleOptions) {
131    super(value);
132  }
133  static identity: Symbol = Symbol('patternLockActivateCircleStyle');
134  applyPeer(node: KNode, reset: boolean): void {
135    if (reset) {
136      getUINativeModule().patternLock.resetActivateCircleStyle(node);
137    } else {
138      getUINativeModule().patternLock.setActivateCircleStyle(node, this.value!);
139    }
140  }
141  checkObjectDiff(): boolean {
142    return !isBaseOrResourceEqual(this.stageValue, this.value);
143  }
144}
145
146class ArkPatternLockComponent extends ArkComponent implements PatternLockAttribute {
147  constructor(nativePtr: KNode, classType?: ModifierType) {
148    super(nativePtr, classType);
149  }
150  sideLength(value: Length): PatternLockAttribute {
151    modifierWithKey(this._modifiersWithKeys, PatternLockSideLengthModifier.identity,
152      PatternLockSideLengthModifier, value);
153    return this;
154  }
155  circleRadius(value: Length): PatternLockAttribute {
156    modifierWithKey(this._modifiersWithKeys, PatternLockCircleRadiusModifier.identity,
157      PatternLockCircleRadiusModifier, value);
158    return this;
159  }
160  regularColor(value: ResourceColor): PatternLockAttribute {
161    modifierWithKey(this._modifiersWithKeys, PatternLockRegularColorModifier.identity,
162      PatternLockRegularColorModifier, value);
163    return this;
164  }
165  selectedColor(value: ResourceColor): PatternLockAttribute {
166    modifierWithKey(this._modifiersWithKeys, PatternLockSelectedColorModifier.identity,
167      PatternLockSelectedColorModifier, value);
168    return this;
169  }
170  activeColor(value: ResourceColor): PatternLockAttribute {
171    modifierWithKey(this._modifiersWithKeys, PatternLockActiveColorModifier.identity,
172      PatternLockActiveColorModifier, value);
173    return this;
174  }
175  pathColor(value: ResourceColor): PatternLockAttribute {
176    modifierWithKey(this._modifiersWithKeys, PatternLockPathColorModifier.identity,
177      PatternLockPathColorModifier, value);
178    return this;
179  }
180  pathStrokeWidth(value: number | string): PatternLockAttribute {
181    modifierWithKey(this._modifiersWithKeys, PatternLockPathStrokeModifier.identity,
182      PatternLockPathStrokeModifier, value);
183    return this;
184  }
185  autoReset(value: boolean): PatternLockAttribute {
186    modifierWithKey(this._modifiersWithKeys, PatternLockAutoResetModifier.identity,
187      PatternLockAutoResetModifier, value);
188    return this;
189  }
190  activateCircleStyle(value: CircleStyleOptions): PatternLockAttribute {
191    modifierWithKey(this._modifiersWithKeys, PatternLockActivateCircleStyleModifier.identity,
192      PatternLockActivateCircleStyleModifier, value);
193    return this;
194  }
195  onPatternComplete(callback: (input: Array<number>) => void): PatternLockAttribute {
196    throw new Error('Method not implemented.');
197  }
198  onDotConnect(callback: any): PatternLockAttribute {
199    throw new Error('Method not implemented.');
200  }
201}
202// @ts-ignore
203globalThis.PatternLock.attributeModifier = function (modifier: ArkComponent): void {
204  attributeModifierFunc.call(this, modifier, (nativePtr: KNode) => {
205    return new ArkPatternLockComponent(nativePtr);
206  }, (nativePtr: KNode, classType: ModifierType, modifierJS: ModifierJS) => {
207    return new modifierJS.PatternLockModifier(nativePtr, classType);
208  });
209};
210