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 * Enumerates the icon styles. 18 * 19 * @enum { number } 20 * @syscap SystemCapability.ArkUI.ArkUI.Full 21 * @since 10 22 */ 23declare enum SaveIconStyle { 24 /** 25 * Icon filled with the specified color. 26 * 27 * @syscap SystemCapability.ArkUI.ArkUI.Full 28 * @since 10 29 */ 30 FULL_FILLED = 0, 31 32 /** 33 * Icon rendered as lines. 34 * 35 * @syscap SystemCapability.ArkUI.ArkUI.Full 36 * @since 10 37 */ 38 LINES = 1 39} 40 41/** 42 * Enumerates the text that can be displayed on the save button. 43 * 44 * @enum { number } 45 * @syscap SystemCapability.ArkUI.ArkUI.Full 46 * @since 10 47 */ 48declare enum SaveDescription { 49 /** 50 * Download 51 * 52 * @syscap SystemCapability.ArkUI.ArkUI.Full 53 * @since 10 54 */ 55 DOWNLOAD = 0, 56 57 /** 58 * Download File 59 * 60 * @syscap SystemCapability.ArkUI.ArkUI.Full 61 * @since 10 62 */ 63 DOWNLOAD_FILE = 1, 64 65 /** 66 * Save 67 * 68 * @syscap SystemCapability.ArkUI.ArkUI.Full 69 * @since 10 70 */ 71 SAVE = 2, 72 73 /** 74 * Save Image 75 * 76 * @syscap SystemCapability.ArkUI.ArkUI.Full 77 * @since 10 78 */ 79 SAVE_IMAGE = 3, 80 81 /** 82 * Save File 83 * 84 * @syscap SystemCapability.ArkUI.ArkUI.Full 85 * @since 10 86 */ 87 SAVE_FILE = 4, 88 89 /** 90 * Download and Share 91 * 92 * @syscap SystemCapability.ArkUI.ArkUI.Full 93 * @since 10 94 */ 95 DOWNLOAD_AND_SHARE = 5, 96 97 /** 98 * Receive 99 * 100 * @syscap SystemCapability.ArkUI.ArkUI.Full 101 * @since 10 102 */ 103 RECEIVE = 6, 104 105 /** 106 * Continue to Receive 107 * 108 * @syscap SystemCapability.ArkUI.ArkUI.Full 109 * @since 10 110 */ 111 CONTINUE_TO_RECEIVE = 7 112} 113 114/** 115 * Declares the interface for setting the save button options. 116 * 117 * @interface SaveButtonOptions 118 * @syscap SystemCapability.ArkUI.ArkUI.Full 119 * @since 10 120 */ 121declare interface SaveButtonOptions { 122 /** 123 * Style of the icon to be drawn. 124 * 125 * @type { ?SaveIconStyle } 126 * @syscap SystemCapability.ArkUI.ArkUI.Full 127 * @since 10 128 */ 129 icon?: SaveIconStyle; 130 131 /** 132 * Text to be displayed on the button. 133 * 134 * @type { ?SaveDescription } 135 * @syscap SystemCapability.ArkUI.ArkUI.Full 136 * @since 10 137 */ 138 text?: SaveDescription; 139 140 /** 141 * Type of the button. 142 * 143 * @type { ?ButtonType } 144 * @syscap SystemCapability.ArkUI.ArkUI.Full 145 * @since 10 146 */ 147 buttonType?: ButtonType; 148} 149 150/** 151 * Enumerates the click event results of the save button. 152 * 153 * @enum { number } 154 * @syscap SystemCapability.ArkUI.ArkUI.Full 155 * @since 10 156 */ 157declare enum SaveButtonOnClickResult { 158 /** 159 * Success. 160 * 161 * @syscap SystemCapability.ArkUI.ArkUI.Full 162 * @since 10 163 */ 164 SUCCESS = 0, 165 166 /** 167 * Failure because the application is not temporarily authorized for saving files. 168 * 169 * @syscap SystemCapability.ArkUI.ArkUI.Full 170 * @since 10 171 */ 172 TEMPORARY_AUTHORIZATION_FAILED = 1 173} 174 175/** 176 * Defines the interface for setting a save button. 177 * 178 * @interface SaveButtonInterface 179 * @syscap SystemCapability.ArkUI.ArkUI.Full 180 * @since 10 181 */ 182interface SaveButtonInterface { 183 /** 184 * Creates a save button. 185 * 186 * @returns { SaveButtonAttribute } Returns the attribute of the save button. 187 * @syscap SystemCapability.ArkUI.ArkUI.Full 188 * @since 10 189 */ 190 (): SaveButtonAttribute; 191 192 /** 193 * Creates a save button with the specified composition. 194 * If an attribute is not set, the corresponding element will not be drawn. 195 * 196 * @param { SaveButtonOptions } options - Indicates the options of the save button. 197 * @returns { SaveButtonAttribute } Returns the attribute of the save button. 198 * @syscap SystemCapability.ArkUI.ArkUI.Full 199 * @since 10 200 */ 201 (options: SaveButtonOptions): SaveButtonAttribute; 202} 203 204/** 205 * Defines the attributes of the save button. 206 * 207 * @extends SecurityComponentMethod<SaveButtonAttribute> 208 * @syscap SystemCapability.ArkUI.ArkUI.Full 209 * @since 10 210 */ 211declare class SaveButtonAttribute extends SecurityComponentMethod<SaveButtonAttribute> { 212 /** 213 * Called when the save button is clicked. 214 * 215 * @param { function } event 216 * @returns { SaveButtonAttribute } Returns the attribute of the save button. 217 * @syscap SystemCapability.ArkUI.ArkUI.Full 218 * @since 10 219 */ 220 onClick(event: (event: ClickEvent, result: SaveButtonOnClickResult) => void): SaveButtonAttribute; 221} 222 223/** 224 * Defines a button that interacts with the security component service to 225 * request the permission for saving files in the media library. 226 * 227 * @syscap SystemCapability.ArkUI.ArkUI.Full 228 * @since 10 229 */ 230declare const SaveButton: SaveButtonInterface; 231 232/** 233 * Defines a save button instance for secure access. 234 * 235 * @syscap SystemCapability.ArkUI.ArkUI.Full 236 * @since 10 237 */ 238declare const SaveButtonInstance: SaveButtonAttribute; 239