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 LocationIconStyle { 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 location button. 43 * 44 * @enum { number } 45 * @syscap SystemCapability.ArkUI.ArkUI.Full 46 * @since 10 47 */ 48declare enum LocationDescription { 49 /** 50 * Current Location 51 * 52 * @syscap SystemCapability.ArkUI.ArkUI.Full 53 * @since 10 54 */ 55 CURRENT_LOCATION = 0, 56 57 /** 58 * Add Location 59 * 60 * @syscap SystemCapability.ArkUI.ArkUI.Full 61 * @since 10 62 */ 63 ADD_LOCATION = 1, 64 65 /** 66 * Select Location 67 * 68 * @syscap SystemCapability.ArkUI.ArkUI.Full 69 * @since 10 70 */ 71 SELECT_LOCATION = 2, 72 73 /** 74 * Share Location 75 * 76 * @syscap SystemCapability.ArkUI.ArkUI.Full 77 * @since 10 78 */ 79 SHARE_LOCATION = 3, 80 81 /** 82 * Send Location 83 * 84 * @syscap SystemCapability.ArkUI.ArkUI.Full 85 * @since 10 86 */ 87 SEND_LOCATION = 4, 88 89 /** 90 * Locating 91 * 92 * @syscap SystemCapability.ArkUI.ArkUI.Full 93 * @since 10 94 */ 95 LOCATING = 5, 96 97 /** 98 * Location 99 * 100 * @syscap SystemCapability.ArkUI.ArkUI.Full 101 * @since 10 102 */ 103 LOCATION = 6, 104 105 /** 106 * Send Current Location 107 * 108 * @syscap SystemCapability.ArkUI.ArkUI.Full 109 * @since 10 110 */ 111 SEND_CURRENT_LOCATION = 7, 112 113 /** 114 * Relocation 115 * 116 * @syscap SystemCapability.ArkUI.ArkUI.Full 117 * @since 10 118 */ 119 RELOCATION = 8, 120 121 /** 122 * Punch In 123 * 124 * @syscap SystemCapability.ArkUI.ArkUI.Full 125 * @since 10 126 */ 127 PUNCH_IN = 9, 128 129 /** 130 * Current Position 131 * 132 * @syscap SystemCapability.ArkUI.ArkUI.Full 133 * @since 10 134 */ 135 CURRENT_POSITION = 10 136} 137 138/** 139 * Declares the interface for setting the location button options. 140 * 141 * @interface LocationButtonOptions 142 * @syscap SystemCapability.ArkUI.ArkUI.Full 143 * @since 10 144 */ 145declare interface LocationButtonOptions { 146 /** 147 * Style of the icon to be drawn. 148 * 149 * @type { ?LocationIconStyle } 150 * @syscap SystemCapability.ArkUI.ArkUI.Full 151 * @since 10 152 */ 153 icon?: LocationIconStyle; 154 155 /** 156 * Text to be displayed on the button. 157 * 158 * @type { ?LocationDescription } 159 * @syscap SystemCapability.ArkUI.ArkUI.Full 160 * @since 10 161 */ 162 text?: LocationDescription; 163 164 /** 165 * Type of the button. 166 * 167 * @type { ?ButtonType } 168 * @syscap SystemCapability.ArkUI.ArkUI.Full 169 * @since 10 170 */ 171 buttonType?: ButtonType; 172} 173 174/** 175 * Enumerates the click event results of the location button. 176 * 177 * @enum { number } 178 * @syscap SystemCapability.ArkUI.ArkUI.Full 179 * @since 10 180 */ 181declare enum LocationButtonOnClickResult { 182 /** 183 * Success. 184 * 185 * @syscap SystemCapability.ArkUI.ArkUI.Full 186 * @since 10 187 */ 188 SUCCESS = 0, 189 190 /** 191 * Failure because the application is not temporarily authorized for accessing location data. 192 * 193 * @syscap SystemCapability.ArkUI.ArkUI.Full 194 * @since 10 195 */ 196 TEMPORARY_AUTHORIZATION_FAILED = 1 197} 198 199/** 200 * Defines the interface for setting a location button. 201 * 202 * @interface LocationButtonInterface 203 * @syscap SystemCapability.ArkUI.ArkUI.Full 204 * @since 10 205 */ 206interface LocationButtonInterface { 207 /** 208 * Creates a location button. 209 * 210 * @returns { LocationButtonAttribute } TReturns the attribute of the location button. 211 * @syscap SystemCapability.ArkUI.ArkUI.Full 212 * @since 10 213 */ 214 (): LocationButtonAttribute; 215 216 /** 217 * Creates a location button with the specified composition. 218 * If an attribute is not set, the corresponding element will not be drawn. 219 * 220 * @param { LocationButtonOptions } options - Indicates the options of the location button. 221 * @returns { LocationButtonAttribute } Returns the attribute of the location button. 222 * @syscap SystemCapability.ArkUI.ArkUI.Full 223 * @since 10 224 */ 225 (options: LocationButtonOptions): LocationButtonAttribute; 226} 227 228/** 229 * Defines the attributes of the location button. 230 * 231 * @extends SecurityComponentMethod<LocationButtonAttribute> 232 * @syscap SystemCapability.ArkUI.ArkUI.Full 233 * @since 10 234 */ 235declare class LocationButtonAttribute extends SecurityComponentMethod<LocationButtonAttribute> { 236 /** 237 * Called when the location button is clicked. 238 * 239 * @param { function } event 240 * @returns { LocationButtonAttribute } Returns the attribute of the location button. 241 * @syscap SystemCapability.ArkUI.ArkUI.Full 242 * @since 10 243 */ 244 onClick(event: (event: ClickEvent, result: LocationButtonOnClickResult) => void): LocationButtonAttribute; 245} 246 247/** 248 * Defines a button that interacts with the security component service to 249 * request the authorization for accessing location data. 250 * 251 * @syscap SystemCapability.ArkUI.ArkUI.Full 252 * @since 10 253 */ 254declare const LocationButton: LocationButtonInterface; 255 256/** 257 * Defines a location button instance for secure access. 258 * 259 * @syscap SystemCapability.ArkUI.ArkUI.Full 260 * @since 10 261 */ 262declare const LocationButtonInstance: LocationButtonAttribute; 263