• 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/**
17 * @file
18 * @kit ArkUI
19 */
20
21/**
22 * Enumerates the icon styles.
23 *
24 * @enum { number }
25 * @syscap SystemCapability.ArkUI.ArkUI.Full
26 * @since 10
27 */
28/**
29 * Enumerates the icon styles.
30 *
31 * @enum { number }
32 * @syscap SystemCapability.ArkUI.ArkUI.Full
33 * @atomicservice
34 * @since 11
35 */
36declare enum SaveIconStyle {
37  /**
38   * Icon filled with the specified color.
39   *
40   * @syscap SystemCapability.ArkUI.ArkUI.Full
41   * @since 10
42   */
43  /**
44   * Icon filled with the specified color.
45   *
46   * @syscap SystemCapability.ArkUI.ArkUI.Full
47   * @atomicservice
48   * @since 11
49   */
50  FULL_FILLED = 0,
51
52  /**
53   * Icon rendered as lines.
54   *
55   * @syscap SystemCapability.ArkUI.ArkUI.Full
56   * @since 10
57   */
58  /**
59   * Icon rendered as lines.
60   *
61   * @syscap SystemCapability.ArkUI.ArkUI.Full
62   * @atomicservice
63   * @since 11
64   */
65  LINES = 1,
66
67  /**
68   * Icon rendered as picture.
69   *
70   * @syscap SystemCapability.ArkUI.ArkUI.Full
71   * @systemapi
72   * @since 12
73   */
74  PICTURE = 2
75}
76
77/**
78 * Enumerates the text that can be displayed on the save button.
79 *
80 * @enum { number }
81 * @syscap SystemCapability.ArkUI.ArkUI.Full
82 * @since 10
83 */
84/**
85 * Enumerates the text that can be displayed on the save button.
86 *
87 * @enum { number }
88 * @syscap SystemCapability.ArkUI.ArkUI.Full
89 * @atomicservice
90 * @since 11
91 */
92declare enum SaveDescription {
93  /**
94   * Download
95   *
96   * @syscap SystemCapability.ArkUI.ArkUI.Full
97   * @since 10
98   */
99  /**
100   * Download
101   *
102   * @syscap SystemCapability.ArkUI.ArkUI.Full
103   * @atomicservice
104   * @since 11
105   */
106  DOWNLOAD = 0,
107
108  /**
109   * Download File
110   *
111   * @syscap SystemCapability.ArkUI.ArkUI.Full
112   * @since 10
113   */
114  /**
115   * Download File
116   *
117   * @syscap SystemCapability.ArkUI.ArkUI.Full
118   * @atomicservice
119   * @since 11
120   */
121  DOWNLOAD_FILE = 1,
122
123  /**
124   * Save
125   *
126   * @syscap SystemCapability.ArkUI.ArkUI.Full
127   * @since 10
128   */
129  /**
130   * Save
131   *
132   * @syscap SystemCapability.ArkUI.ArkUI.Full
133   * @atomicservice
134   * @since 11
135   */
136  SAVE = 2,
137
138  /**
139   * Save Image
140   *
141   * @syscap SystemCapability.ArkUI.ArkUI.Full
142   * @since 10
143   */
144  /**
145   * Save Image
146   *
147   * @syscap SystemCapability.ArkUI.ArkUI.Full
148   * @atomicservice
149   * @since 11
150   */
151  SAVE_IMAGE = 3,
152
153  /**
154   * Save File
155   *
156   * @syscap SystemCapability.ArkUI.ArkUI.Full
157   * @since 10
158   */
159  /**
160   * Save File
161   *
162   * @syscap SystemCapability.ArkUI.ArkUI.Full
163   * @atomicservice
164   * @since 11
165   */
166  SAVE_FILE = 4,
167
168  /**
169   * Download and Share
170   *
171   * @syscap SystemCapability.ArkUI.ArkUI.Full
172   * @since 10
173   */
174  /**
175   * Download and Share
176   *
177   * @syscap SystemCapability.ArkUI.ArkUI.Full
178   * @atomicservice
179   * @since 11
180   */
181  DOWNLOAD_AND_SHARE = 5,
182
183  /**
184   * Receive
185   *
186   * @syscap SystemCapability.ArkUI.ArkUI.Full
187   * @since 10
188   */
189  /**
190   * Receive
191   *
192   * @syscap SystemCapability.ArkUI.ArkUI.Full
193   * @atomicservice
194   * @since 11
195   */
196  RECEIVE = 6,
197
198  /**
199   * Continue to Receive
200   *
201   * @syscap SystemCapability.ArkUI.ArkUI.Full
202   * @since 10
203   */
204  /**
205   * Continue to Receive
206   *
207   * @syscap SystemCapability.ArkUI.ArkUI.Full
208   * @atomicservice
209   * @since 11
210   */
211  CONTINUE_TO_RECEIVE = 7,
212
213  /**
214   * Save to gallery
215   *
216   * @syscap SystemCapability.ArkUI.ArkUI.Full
217   * @atomicservice
218   * @since 12
219   */
220  SAVE_TO_GALLERY = 8,
221
222  /**
223   * Export to gallery
224   *
225   * @syscap SystemCapability.ArkUI.ArkUI.Full
226   * @atomicservice
227   * @since 12
228   */
229  EXPORT_TO_GALLERY = 9,
230
231  /**
232   * Quick save to gallery
233   *
234   * @syscap SystemCapability.ArkUI.ArkUI.Full
235   * @atomicservice
236   * @since 12
237   */
238  QUICK_SAVE_TO_GALLERY = 10,
239
240  /**
241   * Resave to gallery
242   *
243   * @syscap SystemCapability.ArkUI.ArkUI.Full
244   * @atomicservice
245   * @since 12
246   */
247  RESAVE_TO_GALLERY = 11,
248
249  /**
250   * Save all
251   *
252   * @syscap SystemCapability.ArkUI.ArkUI.Full
253   * @atomicservice
254   * @since 18
255   */
256  SAVE_ALL = 12
257}
258
259/**
260 * Declares the interface for setting the save button options.
261 *
262 * @interface SaveButtonOptions
263 * @syscap SystemCapability.ArkUI.ArkUI.Full
264 * @since 10
265 */
266/**
267 * Declares the interface for setting the save button options.
268 *
269 * @interface SaveButtonOptions
270 * @syscap SystemCapability.ArkUI.ArkUI.Full
271 * @atomicservice
272 * @since 11
273 */
274declare interface SaveButtonOptions {
275  /**
276   * Style of the icon to be drawn.
277   *
278   * @type { ?SaveIconStyle }
279   * @syscap SystemCapability.ArkUI.ArkUI.Full
280   * @since 10
281   */
282  /**
283   * Style of the icon to be drawn.
284   *
285   * @type { ?SaveIconStyle }
286   * @syscap SystemCapability.ArkUI.ArkUI.Full
287   * @atomicservice
288   * @since 11
289   */
290  icon?: SaveIconStyle;
291
292  /**
293   * Text to be displayed on the button.
294   *
295   * @type { ?SaveDescription }
296   * @syscap SystemCapability.ArkUI.ArkUI.Full
297   * @since 10
298   */
299  /**
300   * Text to be displayed on the button.
301   *
302   * @type { ?SaveDescription }
303   * @syscap SystemCapability.ArkUI.ArkUI.Full
304   * @atomicservice
305   * @since 11
306   */
307  text?: SaveDescription;
308
309  /**
310   * Type of the button.
311   *
312   * @type { ?ButtonType }
313   * @syscap SystemCapability.ArkUI.ArkUI.Full
314   * @since 10
315   */
316  /**
317   * Type of the button.
318   *
319   * @type { ?ButtonType }
320   * @syscap SystemCapability.ArkUI.ArkUI.Full
321   * @atomicservice
322   * @since 11
323   */
324  buttonType?: ButtonType;
325}
326
327/**
328 * Enumerates the click event results of the save button.
329 *
330 * @enum { number }
331 * @syscap SystemCapability.ArkUI.ArkUI.Full
332 * @since 10
333 */
334/**
335 * Enumerates the click event results of the save button.
336 *
337 * @enum { number }
338 * @syscap SystemCapability.ArkUI.ArkUI.Full
339 * @atomicservice
340 * @since 11
341 */
342declare enum SaveButtonOnClickResult {
343  /**
344   * Success.
345   *
346   * @syscap SystemCapability.ArkUI.ArkUI.Full
347   * @since 10
348   */
349  /**
350   * Success.
351   *
352   * @syscap SystemCapability.ArkUI.ArkUI.Full
353   * @atomicservice
354   * @since 11
355   */
356  SUCCESS = 0,
357
358  /**
359   * Failure because the application is not temporarily authorized for saving files.
360   *
361   * @syscap SystemCapability.ArkUI.ArkUI.Full
362   * @since 10
363   */
364  /**
365   * Failure because the application is not temporarily authorized for saving files.
366   *
367   * @syscap SystemCapability.ArkUI.ArkUI.Full
368   * @atomicservice
369   * @since 11
370   */
371  TEMPORARY_AUTHORIZATION_FAILED = 1
372}
373
374/**
375 * Defines the interface for setting a save button.
376 *
377 * @interface SaveButtonInterface
378 * @syscap SystemCapability.ArkUI.ArkUI.Full
379 * @since 10
380 */
381/**
382 * Defines the interface for setting a save button.
383 *
384 * @interface SaveButtonInterface
385 * @syscap SystemCapability.ArkUI.ArkUI.Full
386 * @atomicservice
387 * @since 11
388 */
389interface SaveButtonInterface {
390  /**
391   * Creates a save button.
392   *
393   * @returns { SaveButtonAttribute } Returns the attribute of the save button.
394   * @syscap SystemCapability.ArkUI.ArkUI.Full
395   * @since 10
396   */
397  /**
398   * Creates a save button.
399   *
400   * @returns { SaveButtonAttribute } Returns the attribute of the save button.
401   * @syscap SystemCapability.ArkUI.ArkUI.Full
402   * @atomicservice
403   * @since 11
404   */
405  (): SaveButtonAttribute;
406
407  /**
408   * Creates a save button with the specified composition.
409   * If an attribute is not set, the corresponding element will not be drawn.
410   *
411   * @param { SaveButtonOptions } options - Indicates the options of the save button.
412   * @returns { SaveButtonAttribute } Returns the attribute of the save button.
413   * @syscap SystemCapability.ArkUI.ArkUI.Full
414   * @since 10
415   */
416  /**
417   * Creates a save button with the specified composition.
418   * If an attribute is not set, the corresponding element will not be drawn.
419   *
420   * @param { SaveButtonOptions } options - Indicates the options of the save button.
421   * @returns { SaveButtonAttribute } Returns the attribute of the save button.
422   * @syscap SystemCapability.ArkUI.ArkUI.Full
423   * @atomicservice
424   * @since 11
425   */
426  (options: SaveButtonOptions): SaveButtonAttribute;
427}
428
429/**
430 * Callback function when the save button is clicked.
431 *
432 * @typedef { function } SaveButtonCallback
433 * @param { ClickEvent } event - The click event.
434 * @param { SaveButtonOnClickResult } result - The result of click event.
435 * @param { BusinessError<void> } [error] - The error code and message of click event.
436 * @syscap SystemCapability.ArkUI.ArkUI.Full
437 * @atomicservice
438 * @since 18
439 */
440type SaveButtonCallback = (event: ClickEvent, result: SaveButtonOnClickResult, error?: BusinessError<void>) => void;
441
442/**
443 * Defines the attributes of the save button.
444 *
445 * @extends SecurityComponentMethod<SaveButtonAttribute>
446 * @syscap SystemCapability.ArkUI.ArkUI.Full
447 * @since 10
448 */
449/**
450 * Defines the attributes of the save button.
451 *
452 * @extends SecurityComponentMethod<SaveButtonAttribute>
453 * @syscap SystemCapability.ArkUI.ArkUI.Full
454 * @atomicservice
455 * @since 11
456 */
457declare class SaveButtonAttribute extends SecurityComponentMethod<SaveButtonAttribute> {
458  /**
459   * Called when the save button is clicked.
460   *
461   * @param { function } event
462   * @returns { SaveButtonAttribute } Returns the attribute of the save button.
463   * @syscap SystemCapability.ArkUI.ArkUI.Full
464   * @since 10
465   */
466  /**
467   * Called when the save button is clicked.
468   *
469   * @param { function } event
470   * @returns { SaveButtonAttribute } Returns the attribute of the save button.
471   * @syscap SystemCapability.ArkUI.ArkUI.Full
472   * @atomicservice
473   * @since 11
474   */
475  /**
476   * Called when the save button is clicked.
477   *
478   * @param { SaveButtonCallback } event
479   * @returns { SaveButtonAttribute } Returns the attribute of the save button.
480   * @syscap SystemCapability.ArkUI.ArkUI.Full
481   * @atomicservice
482   * @since 18
483   */
484  onClick(event: SaveButtonCallback): SaveButtonAttribute;
485
486  /**
487   * Sets the icon of the save button.
488   *
489   * @permission ohos.permission.CUSTOMIZE_SAVE_BUTTON
490   * @param { Resource } icon - Source of the icon.
491   * @returns { SaveButtonAttribute } Returns the attributes of the save button.
492   * @syscap SystemCapability.ArkUI.ArkUI.Full
493   * @atomicservice
494   * @since 20
495   */
496  setIcon(icon: Resource): SaveButtonAttribute;
497
498  /**
499   * Sets the text of the save button.
500   *
501   * @permission ohos.permission.CUSTOMIZE_SAVE_BUTTON
502   * @param { string | Resource } text - Content of text.
503   * @returns { SaveButtonAttribute } Returns the attributes of the save button.
504   * @syscap SystemCapability.ArkUI.ArkUI.Full
505   * @atomicservice
506   * @since 20
507   */
508  setText(text: string | Resource): SaveButtonAttribute;
509
510  /**
511   * Sets the size of the icon.
512   *
513   * @param { Dimension | SizeOptions } size - Dimensions of the icon to set.
514   * @returns { SaveButtonAttribute } Returns the attributes of the save button.
515   * @syscap SystemCapability.ArkUI.ArkUI.Full
516   * @atomicservice
517   * @since 20
518   */
519  iconSize(size: Dimension | SizeOptions): SaveButtonAttribute;
520
521  /**
522   * Sets the border radius of the icon.
523   *
524   * @permission ohos.permission.CUSTOMIZE_SAVE_BUTTON
525   * @param { Dimension | BorderRadiuses } radius - Border radius of the icon to set.
526   * @returns { SaveButtonAttribute } Returns the attributes of the save button.
527   * @syscap SystemCapability.ArkUI.ArkUI.Full
528   * @atomicservice
529   * @since 20
530   */
531  iconBorderRadius(radius: Dimension | BorderRadiuses): SaveButtonAttribute;
532
533  /**
534   * Enables the press effect of the button.
535   *
536   * @permission ohos.permission.CUSTOMIZE_SAVE_BUTTON
537   * @param { boolean } enabled - Whether to enable the press effect. The value true means to enable the press effect;
538   * the value false means the opposite.
539   * @returns { SaveButtonAttribute} Returns the attributes of the save button.
540   * @syscap SystemCapability.ArkUI.ArkUI.Full
541   * @atomicservice
542   * @since 20
543   */
544  stateEffect(enabled: boolean): SaveButtonAttribute;
545
546}
547
548/**
549 * Defines a button that interacts with the security component service to
550 * request the permission for saving files in the media library.
551 *
552 * @syscap SystemCapability.ArkUI.ArkUI.Full
553 * @since 10
554 */
555/**
556 * Defines a button that interacts with the security component service to
557 * request the permission for saving files in the media library.
558 *
559 * @syscap SystemCapability.ArkUI.ArkUI.Full
560 * @atomicservice
561 * @since 11
562 */
563declare const SaveButton: SaveButtonInterface;
564
565/**
566 * Defines a save button instance for secure access.
567 *
568 * @syscap SystemCapability.ArkUI.ArkUI.Full
569 * @since 10
570 */
571/**
572 * Defines a save button instance for secure access.
573 *
574 * @syscap SystemCapability.ArkUI.ArkUI.Full
575 * @atomicservice
576 * @since 11
577 */
578declare const SaveButtonInstance: SaveButtonAttribute;
579