• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2022-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 AbilityKit
19 */
20
21 /*** if arkts 1.1 */
22import Want from './@ohos.app.ability.Want';
23/*** endif */
24
25/**
26 * Interface of request dialog.
27 *
28 * @namespace dialogRequest
29 * @syscap SystemCapability.Ability.AbilityRuntime.Core
30 * @since arkts {'1.1':'9', '1.2':'20'}
31 * @arkts 1.1&1.2
32 */
33declare namespace dialogRequest {
34  /**
35   * Window Rectangle
36   *
37   * @typedef WindowRect
38   * @syscap SystemCapability.Ability.AbilityRuntime.Core
39   * @StageModelOnly
40   * @since 10
41   */
42  export interface WindowRect {
43    /**
44     * The left position of WindowRect
45     *
46     * @type { number }
47     * @syscap SystemCapability.Ability.AbilityRuntime.Core
48     * @StageModelOnly
49     * @since 10
50     */
51    left: number;
52
53    /**
54     * The top position of WindowRect
55     *
56     * @type { number }
57     * @syscap SystemCapability.Ability.AbilityRuntime.Core
58     * @StageModelOnly
59     * @since 10
60     */
61    top: number;
62
63    /**
64     * The width of WindowRect
65     *
66     * @type { number }
67     * @syscap SystemCapability.Ability.AbilityRuntime.Core
68     * @StageModelOnly
69     * @since 10
70     */
71    width: number;
72
73    /**
74     * The height of WindowRect
75     *
76     * @type { number }
77     * @syscap SystemCapability.Ability.AbilityRuntime.Core
78     * @StageModelOnly
79     * @since 10
80     */
81    height: number;
82  }
83  /**
84   * Request info of a request.
85   *
86   * @typedef RequestInfo
87   * @syscap SystemCapability.Ability.AbilityRuntime.Core
88   * @since 9
89   */
90  export interface RequestInfo {
91    /**
92     * The Window of caller.
93     *
94     * @type { ?WindowRect }
95     * @syscap SystemCapability.Ability.AbilityRuntime.Core
96     * @StageModelOnly
97     * @since 10
98     */
99    windowRect?: WindowRect
100  }
101
102  /**
103   * The modal bullet box requests the result code.
104   *
105   * @enum { number }
106   * @syscap SystemCapability.Ability.AbilityRuntime.Core
107   * @since 9
108   */
109  export enum ResultCode {
110    /**
111     * The modal bullet box requests succeeded.
112     *
113     * @syscap SystemCapability.Ability.AbilityRuntime.Core
114     * @since 9
115     */
116    RESULT_OK = 0,
117
118    /**
119     * The modal bullet box requests Failed.
120     *
121     * @syscap SystemCapability.Ability.AbilityRuntime.Core
122     * @since 9
123     */
124    RESULT_CANCEL = 1
125  }
126
127  /**
128   * The result of requestDialogService with asynchronous callback.
129   *
130   * @typedef RequestResult
131   * @syscap SystemCapability.Ability.AbilityRuntime.Core
132   * @StageModelOnly
133   * @since 9
134   */
135  export interface RequestResult {
136    /**
137     * The request result passed in by the user.
138     *
139     * @type { ResultCode }
140     * @syscap SystemCapability.Ability.AbilityRuntime.Core
141     * @StageModelOnly
142     * @since 9
143     */
144    result: ResultCode;
145
146    /**
147     * The request additional want data passed in by the user.
148     *
149     * @type { ?Want }
150     * @syscap SystemCapability.Ability.AbilityRuntime.Core
151     * @StageModelOnly
152     * @since 10
153     */
154    want?: Want;
155  }
156
157  /**
158   * Provides methods for request callback.
159   *
160   * @interface RequestCallback
161   * @syscap SystemCapability.Ability.AbilityRuntime.Core
162   * @since 9
163   */
164  export interface RequestCallback {
165    /**
166     * Send request result to caller.
167     *
168     * @param { RequestResult } result - result for request.
169     * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
170     * 2. Incorrect parameter types; 3. Parameter verification failed.
171     * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore
172     * @StageModelOnly
173     * @since 9
174     */
175    setRequestResult(result: RequestResult): void;
176  }
177
178  /**
179   * Get request info from caller want.
180   *
181   * @param { Want } want - want from caller.
182   * @returns { RequestInfo } Returns the request info from caller.
183   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
184   * 2. Incorrect parameter types; 3. Parameter verification failed.
185   * @syscap SystemCapability.Ability.AbilityRuntime.Core
186   * @since 9
187   */
188  function getRequestInfo(want: Want): RequestInfo;
189
190  /**
191   * Get request callback from caller want.
192   *
193   * @param { Want } want - want from caller.
194   * @returns { RequestCallback } Returns the request callback.
195   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
196   * 2. Incorrect parameter types; 3. Parameter verification failed.
197   * @syscap SystemCapability.Ability.AbilityRuntime.Core
198   * @since 9
199   */
200  function getRequestCallback(want: Want): RequestCallback;
201}
202
203export default dialogRequest;
204