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/**
17 * Defines the LinearIndicator Controller.
18 *
19 * @interface LinearIndicatorController
20 * @syscap SystemCapability.ArkUI.ArkUI.Full
21 * @crossplatform
22 * @atomicservice
23 * @since 13
24 */
25declare class LinearIndicatorController {
26  /**
27   * constructor.
28   *
29   * @syscap SystemCapability.ArkUI.ArkUI.Full
30   * @crossplatform
31   * @atomicservice
32   * @since 13
33   */
34  constructor();
35
36  /**
37   * Sets the progress of indicator.
38   *
39   * @param { number } index - the index of current indicator,  value range: [0, count - 1].
40   * If index value is out of range, do nothing.
41   * @param { number } progress - current indicator progress value, value range: [0, 100].
42   * If the progress value is out of range, do nothing.
43   * @syscap SystemCapability.ArkUI.ArkUI.Full
44   * @crossplatform
45   * @atomicservice
46   * @since 13
47   */
48  setProgress(index: number, progress: number): void;
49
50  /**
51   * Start indicator auto play.
52   *
53   * @param { LinearIndicatorStartOptions } [options] - the options of indicator auto play.
54   * @syscap SystemCapability.ArkUI.ArkUI.Full
55   * @crossplatform
56   * @atomicservice
57   * @since 13
58   */
59  start(options?: LinearIndicatorStartOptions): void;
60
61  /**
62   * Pause indicator auto play. 
63   * Start auto play will be resumed from this paused position.
64   *
65   * @syscap SystemCapability.ArkUI.ArkUI.Full
66   * @crossplatform
67   * @atomicservice
68   * @since 13
69   */
70  pause(): void;
71
72  /**
73   * Stop indicator auto play.
74   * Start auto play will restart from the very beginning.
75   *
76   * @syscap SystemCapability.ArkUI.ArkUI.Full
77   * @crossplatform
78   * @atomicservice
79   * @since 13
80   */
81  stop(): void;
82}
83
84/**
85 * Provides options of indicator auto play.
86 *
87 * @interface LinearIndicatorAutoPlayOptions
88 * @syscap SystemCapability.ArkUI.ArkUI.Full
89 * @crossplatform
90 * @atomicservice
91 * @since 13
92 */
93declare interface LinearIndicatorStartOptions {
94  /**
95   * The interval between twice auto play. The unit is ms.
96   *
97   * @type { ?number }
98   * @default The default value is 0. if value is less than 0, the value will be 0.
99   * @syscap SystemCapability.ArkUI.ArkUI.Full
100   * @crossplatform
101   * @atomicservice
102   * @since 13
103   */
104  interval?: number;
105
106  /**
107   * The animation curve duration. The unit is ms.
108   *
109   * @type { ?number }
110   * @default 4000
111   * @syscap SystemCapability.ArkUI.ArkUI.Full
112   * @crossplatform
113   * @atomicservice
114   * @since 13
115   */
116  duration?: number;
117}
118
119/**
120 * Provides linear indicator style.
121 *
122 * @interface LinearIndicatorStyle
123 * @syscap SystemCapability.ArkUI.ArkUI.Full
124 * @crossplatform
125 * @atomicservice
126 * @since 13
127 */
128declare interface LinearIndicatorStyle {
129  /**
130   * The space of two linear indicator.
131   *
132   * @type { ?LengthMetrics }
133   * @default The default value is 4.0vp. if value is less than 0, the value will be 4.0vp.
134   * @syscap SystemCapability.ArkUI.ArkUI.Full
135   * @crossplatform
136   * @atomicservice
137   * @since 13
138   */
139  space?: LengthMetrics;
140
141  /**
142   * Stroke width of the progress indicator.
143   *
144   * @type { ?LengthMetrics }
145   * @default The default value is 2.0vp. if value is less than 0, the value will be 2.0vp.
146   * @syscap SystemCapability.ArkUI.ArkUI.Full
147   * @crossplatform
148   * @atomicservice
149   * @since 13
150   */
151  strokeWidth?: LengthMetrics;
152
153  /**
154   * The stroke radius of linear indicator.
155   *
156   * @type { ?LengthMetrics }
157   * @default The default value is 1.0vp. if value is more than strokeWidth/2, the value will be strokeWidth/2.
158   * @syscap SystemCapability.ArkUI.ArkUI.Full
159   * @crossplatform
160   * @atomicservice
161   * @since 13
162   */
163  strokeRadius?: LengthMetrics;
164
165  /**
166   * The track background color of linear indicator.
167   *
168   * @type { ?ColorMetrics }
169   * @default comp_background_tertiary
170   * @syscap SystemCapability.ArkUI.ArkUI.Full
171   * @crossplatform
172   * @atomicservice
173   * @since 13
174   */
175  trackBackgroundColor?: ColorMetrics;
176
177  /**
178   * The track color of linear indicator.
179   *
180   * @type { ?ColorMetrics }
181   * @default comp_background_emphasize
182   * @syscap SystemCapability.ArkUI.ArkUI.Full
183   * @crossplatform
184   * @atomicservice
185   * @since 13
186   */
187  trackColor?: ColorMetrics;
188}
189
190/**
191 * Provides an interface for indicator.
192 *
193 * @interface LinearIndicatorInterface
194 * @syscap SystemCapability.ArkUI.ArkUI.Full
195 * @crossplatform
196 * @atomicservice
197 * @since 13
198 */
199interface LinearIndicatorInterface {
200  /**
201   * Constructor parameters
202   *
203   * @param { number } count - the number of progress in LinearIndicator. minimum value is 2(default is 5).
204   * if count is less than 2, the value will be 2.
205   * @param { LinearIndicatorController } controller - Controller of LinearIndicator.
206   * @returns { LinearIndicatorAttribute } return the instance of the LinearIndicatorAttribute
207   * @syscap SystemCapability.ArkUI.ArkUI.Full
208   * @crossplatform
209   * @atomicservice
210   * @since 13
211   */
212   (count?: number, controller?: LinearIndicatorController): LinearIndicatorAttribute;
213}
214
215/**
216 * Defines the Indicator attribute functions.
217 *
218 * @extends CommonMethod<LinearIndicatorAttribute>
219 * @syscap SystemCapability.ArkUI.ArkUI.Full
220 * @crossplatform
221 * @atomicservice
222 * @since 13
223 */
224declare class LinearIndicatorAttribute extends CommonMethod<LinearIndicatorAttribute> {
225  /**
226   * Sets the indicator style.
227   *
228   * @param { Optional<LinearIndicatorStyle> } style - the style of LinearIndicator
229   * @returns { LinearIndicatorAttribute } return the instance of the LinearIndicatorAttribute
230   * @syscap SystemCapability.ArkUI.ArkUI.Full
231   * @crossplatform
232   * @atomicservice
233   * @since 13
234   */
235  indicatorStyle(style: Optional<LinearIndicatorStyle>): LinearIndicatorAttribute;
236
237  /**
238   * Sets whether indicator supports loop, default is true.
239   *
240   * @param { Optional<boolean> } loop - indicate whether loop playback is supported
241   * @returns { LinearIndicatorAttribute } return the instance of the LinearIndicatorAttribute
242   * @syscap SystemCapability.ArkUI.ArkUI.Full
243   * @crossplatform
244   * @atomicservice
245   * @since 13
246   */
247  indicatorLoop(loop: Optional<boolean>): LinearIndicatorAttribute;
248
249  /**
250   * Called when progress value update.
251   *
252   * @param { Optional<OnLinearIndicatorChangeCallback> } callback - callback of the progress change event.
253   * @returns { LinearIndicatorAttribute } return the instance of the LinearIndicatorAttribute
254   * @syscap SystemCapability.ArkUI.ArkUI.Full
255   * @crossplatform
256   * @atomicservice
257   * @since 13
258   */
259  onChange(callback: Optional<OnLinearIndicatorChangeCallback>): LinearIndicatorAttribute;
260}
261
262/**
263 * Defines the callback type used in  the indicator progress change event.
264 *
265 * @typedef { function } OnLinearIndicatorChangeCallback
266 * @param { number } index - index of current indicator.
267 * @param { number } progress - current indicator progress value.
268 * @syscap SystemCapability.ArkUI.ArkUI.Full
269 * @crossplatform
270 * @atomicservice
271 * @since 13
272 */
273declare type OnLinearIndicatorChangeCallback = (index: number, progress: number) => void;
274
275/**
276 * Defines Indicator Component.
277 *
278 * @syscap SystemCapability.ArkUI.ArkUI.Full
279 * @crossplatform
280 * @atomicservice
281 * @since 13
282 */
283declare const LinearIndicator: LinearIndicatorInterface;
284
285/**
286 * Defines Indicator Component instance.
287 *
288 * @syscap SystemCapability.ArkUI.ArkUI.Full
289 * @crossplatform
290 * @atomicservice
291 * @since 13
292 */
293declare const LinearIndicatorInstance: LinearIndicatorAttribute
294