/* * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * @file * @kit ArkUI */ /*** if arkts 1.1 */ import { AsyncCallback } from './@ohos.base'; /*** endif */ /*** if arkts 1.2 */ import { ResourceColor, Offset, Dimension, EdgeStyles, EdgeColors,EdgeWidths, BorderRadiuses } from './arkui/component/units'; import { AsyncCallback, Callback } from './@ohos.base'; import { BlurStyle, ShadowOptions, ShadowStyle, HoverModeAreaType, Rectangle, TransitionEffect, KeyboardAvoidMode, DismissReason, BackgroundBlurStyleOptions, BackgroundEffectOptions } from './arkui/component/common'; import { CustomBuilder } from './arkui/component/builder'; import { DialogAlignment } from './arkui/component/alertDialog'; import { BorderStyle,Alignment } from './arkui/component/enums'; import { Resource } from './global/resource'; import { LengthMetrics } from './arkui/Graphics'; /*** endif */ /** * Define the display mode of all kind of dialog * * @enum { number } * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice * @since arkts {'1.1':'15','1.2':'20'} * @arkts 1.1&1.2 */ export enum LevelMode { /** * Display above all page levels. * * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice * @since arkts {'1.1':'15','1.2':'20'} * @arkts 1.1&1.2 */ OVERLAY = 0, /** * Display within the current page. * * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice * @since arkts {'1.1':'15','1.2':'20'} * @arkts 1.1&1.2 */ EMBEDDED = 1, } /** * Define the immersive mode of all kind of dialog * * @enum { number } * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice * @since arkts {'1.1':'15','1.2':'20'} * @arkts 1.1&1.2 */ export enum ImmersiveMode { /** * Mask covering the parent node. * * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice * @since arkts {'1.1':'15','1.2':'20'} * @arkts 1.1&1.2 */ DEFAULT = 0, /** * Mask extend safe area includes status bar and navigation bar. * * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice * @since arkts {'1.1':'15','1.2':'20'} * @arkts 1.1&1.2 */ EXTEND = 1, } /** * Defines level order. * * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice * @since arkts {'1.1':'18','1.2':'20'} * @arkts 1.1&1.2 */ export declare class LevelOrder { /** * Generate valid level order. * * @param { number } order - Clamp order with mininum number -100000 and maximum number 100000. * @returns { LevelOrder } the order object. * @static * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice * @since arkts {'1.1':'18','1.2':'20'} * @arkts 1.1&1.2 */ static clamp(order: number): LevelOrder; /** * Get the order from LevelOrder object. * * @returns { number } the order number. * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice * @since arkts {'1.1':'18','1.2':'20'} * @arkts 1.1&1.2 */ getOrder(): number; } /** * @namespace promptAction * @syscap SystemCapability.ArkUI.ArkUI.Full * @since 9 */ /** * @namespace promptAction * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @since 10 */ /** * @namespace promptAction * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice * @since arkts {'1.1':'11','1.2':'20'} * @arkts 1.1&1.2 */ declare namespace promptAction { /** * @typedef ShowToastOptions * @syscap SystemCapability.ArkUI.ArkUI.Full * @since 9 */ /** * @typedef ShowToastOptions * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @since 10 */ /** * @typedef ShowToastOptions * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice * @since arkts {'1.1':'11','1.2':'20'} * @arkts 1.1&1.2 */ export interface ShowToastOptions { /** * Text to display. * * @type { string | Resource } * @syscap SystemCapability.ArkUI.ArkUI.Full * @since 9 */ /** * Text to display. * * @type { string | Resource } * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @since 10 */ /** * Text to display. * * @type { string | Resource } * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice * @since arkts {'1.1':'11','1.2':'20'} * @arkts 1.1&1.2 */ message: string | Resource; /** * Duration of toast dialog box. The default value is 1500. * The recommended value ranges from 1500ms to 10000ms. * NOTE: A value less than 1500 is automatically changed to 1500. The maximum value is 10000ms. * * @type { ?number } * @syscap SystemCapability.ArkUI.ArkUI.Full * @since 9 */ /** * Duration of toast dialog box. The default value is 1500. * The recommended value ranges from 1500ms to 10000ms. * NOTE: A value less than 1500 is automatically changed to 1500. The maximum value is 10000ms. * * @type { ?number } * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @since 10 */ /** * Duration of toast dialog box. The default value is 1500. * The recommended value ranges from 1500ms to 10000ms. * NOTE: A value less than 1500 is automatically changed to 1500. The maximum value is 10000ms. * * @type { ?number } * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice * @since arkts {'1.1':'11','1.2':'20'} * @arkts 1.1&1.2 */ duration?: number; /** * The distance between toast dialog box and the bottom of screen. * * @type { ?(string | number) } * @syscap SystemCapability.ArkUI.ArkUI.Full * @since 9 */ /** * The distance between toast dialog box and the bottom of screen. * * @type { ?(string | number) } * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @since 10 */ /** * The distance between toast dialog box and the bottom of screen. * * @type { ?(string | number) } * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice * @since arkts {'1.1':'11','1.2':'20'} * @arkts 1.1&1.2 */ bottom?: string | number; /** * Determine the show mode of the toast. * * @type { ?ToastShowMode } * @default ToastShowMode.DEFAULT * @syscap SystemCapability.ArkUI.ArkUI.Full * @since 11 */ /** * Determine the show mode of the toast. * * @type { ?ToastShowMode } * @default ToastShowMode.DEFAULT * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice * @since arkts {'1.1':'12','1.2':'20'} * @arkts 1.1&1.2 */ showMode?: ToastShowMode; /** * Defines the toast alignment of the screen. * * @type { ?Alignment } * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice * @since arkts {'1.1':'12','1.2':'20'} * @arkts 1.1&1.2 */ alignment?: Alignment; /** * Defines the toast offset. * * @type { ?Offset } * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice * @since arkts {'1.1':'12','1.2':'20'} * @arkts 1.1&1.2 */ offset?: Offset; /** * Background color of toast. * * @type { ?ResourceColor } * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice * @since arkts {'1.1':'12','1.2':'20'} * @arkts 1.1&1.2 */ backgroundColor?: ResourceColor; /** * Text color of toast. * * @type { ?ResourceColor } * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice * @since arkts {'1.1':'12','1.2':'20'} * @arkts 1.1&1.2 */ textColor?: ResourceColor; /** * Background blur Style of toast. * * @type { ?BlurStyle } * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice * @since arkts {'1.1':'12','1.2':'20'} * @arkts 1.1&1.2 */ backgroundBlurStyle?: BlurStyle; /** * Shadow of toast. * * @type { ?(ShadowOptions | ShadowStyle) } * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice * @since arkts {'1.1':'12','1.2':'20'} * @arkts 1.1&1.2 */ shadow?: ShadowOptions | ShadowStyle; /** * Define whether to respond to the hover mode. * * @type { ?boolean } * @default false * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice * @since arkts {'1.1':'14','1.2':'20'} * @arkts 1.1&1.2 */ enableHoverMode?: boolean; /** * Defines the toast's display area in hover mode. * * @type { ?HoverModeAreaType } * @default HoverModeAreaType.BOTTOM_SCREEN * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice * @since arkts {'1.1':'14','1.2':'20'} * @arkts 1.1&1.2 */ hoverModeArea?: HoverModeAreaType; } /** * Enum for the toast showMode. * * @enum { number } * @syscap SystemCapability.ArkUI.ArkUI.Full * @since 11 */ /** * Enum for the toast showMode. * * @enum { number } * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice * @since arkts {'1.1':'12','1.2':'20'} * @arkts 1.1&1.2 */ export enum ToastShowMode { /** * Toast shows in app. * * @syscap SystemCapability.ArkUI.ArkUI.Full * @since 11 */ /** * Toast shows in app. * * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice * @since arkts {'1.1':'12','1.2':'20'} * @arkts 1.1&1.2 */ DEFAULT = 0, /** * Toast shows at the top. * * @syscap SystemCapability.ArkUI.ArkUI.Full * @since 11 */ /** * Toast shows at the top. * * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice * @since arkts {'1.1':'12','1.2':'20'} * @arkts 1.1&1.2 */ TOP_MOST = 1, /** * Toast shows in SYSTEM_TOAST window. * * @syscap SystemCapability.ArkUI.ArkUI.Full * @systemapi * @since arkts {'1.1':'12','1.2':'20'} * @arkts 1.1&1.2 */ SYSTEM_TOP_MOST = 2 } /** * @typedef Button * @syscap SystemCapability.ArkUI.ArkUI.Full * @since 9 */ /** * @typedef Button * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @since 10 */ /** * @typedef Button * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice * @since arkts {'1.1':'11','1.2':'20'} * @arkts 1.1&1.2 */ export interface Button { /** * The text displayed in the button. * * @type { string | Resource } * @syscap SystemCapability.ArkUI.ArkUI.Full * @since 9 */ /** * The text displayed in the button. * * @type { string | Resource } * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @since 10 */ /** * The text displayed in the button. * * @type { string | Resource } * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice * @since arkts {'1.1':'11','1.2':'20'} * @arkts 1.1&1.2 */ text: string | Resource; /** * The foreground color of button. * * @type { string | Resource } * @syscap SystemCapability.ArkUI.ArkUI.Full * @since 9 */ /** * The foreground color of button. * * @type { string | Resource } * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @since 10 */ /** * The foreground color of button. * * @type { string | Resource } * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice * @since arkts {'1.1':'11','1.2':'20'} * @arkts 1.1&1.2 */ color: string | Resource; /** * Define whether the button responds to Enter/Space key by default. * * @type { ?boolean } * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice * @since arkts {'1.1':'12','1.2':'20'} * @arkts 1.1&1.2 */ primary?: boolean; } /** * Defines the one-button array. * * @typedef { [Button] } PromptActionSingleButton * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice * @since 20 * @arkts 1.2 */ export type PromptActionSingleButton = [Button]; /** * Defines the two-buttons array. * * @typedef { [Button, Button | undefined] } PromptActionDoubleButtons * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice * @since 20 * @arkts 1.2 */ export type PromptActionDoubleButtons = [Button, Button | undefined]; /** * Defines the three-buttons array. * * @typedef { [Button, Button | undefined, Button | undefined] } PromptActionTripleButtons * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice * @since 20 * @arkts 1.2 */ export type PromptActionTripleButtons = [Button, Button | undefined, Button | undefined]; /** * Defines the four-buttons array. * * @typedef { [Button, Button | undefined, Button | undefined, Button | undefined] } PromptActionQuadrupleButtons * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice * @since 20 * @arkts 1.2 */ export type PromptActionQuadrupleButtons = [Button, Button | undefined, Button | undefined, Button | undefined]; /** * Defines the five-buttons array. * * @typedef { [Button, Button | undefined, Button | undefined, Button | undefined, Button | undefined] } PromptActionQuintupleButtons * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice * @since 20 * @arkts 1.2 */ export type PromptActionQuintupleButtons = [Button, Button | undefined, Button | undefined, Button | undefined, Button | undefined]; /** * Defines the six-buttons array. * * @typedef { [Button, Button | undefined, Button | undefined, Button | undefined, Button | undefined, Button | undefined] } PromptActionSextupleButtons * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice * @since 20 * @arkts 1.2 */ export type PromptActionSextupleButtons = [Button, Button | undefined, Button | undefined, Button | undefined, Button | undefined, Button | undefined]; /** * Defines success response of show dialog. * * @typedef ShowDialogSuccessResponse * @syscap SystemCapability.ArkUI.ArkUI.Full * @since 9 */ /** * @typedef ShowDialogSuccessResponse * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @since 10 */ /** * @typedef ShowDialogSuccessResponse * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice * @since arkts {'1.1':'11','1.2':'20'} * @arkts 1.1&1.2 */ export interface ShowDialogSuccessResponse { /** * Index of the selected button, starting from 0. * * @type { number } * @syscap SystemCapability.ArkUI.ArkUI.Full * @since 9 */ /** * Index of the selected button, starting from 0. * * @type { number } * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @since 10 */ /** * Index of the selected button, starting from 0. * * @type { number } * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice * @since arkts {'1.1':'11','1.2':'20'} * @arkts 1.1&1.2 */ index: number; } /** * @typedef ShowDialogOptions * @syscap SystemCapability.ArkUI.ArkUI.Full * @since 9 */ /** * @typedef ShowDialogOptions * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @since 10 */ /** * @typedef ShowDialogOptions * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice * @since arkts {'1.1':'11','1.2':'20'} * @arkts 1.1&1.2 */ export interface ShowDialogOptions { /** * Title of the text to display. * * @type { ?(string | Resource) } * @syscap SystemCapability.ArkUI.ArkUI.Full * @since 9 */ /** * Title of the text to display. * * @type { ?(string | Resource) } * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @since 10 */ /** * Title of the text to display. * * @type { ?(string | Resource) } * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice * @since arkts {'1.1':'11','1.2':'20'} * @arkts 1.1&1.2 */ title?: string | Resource; /** * Text body. * * @type { ?(string | Resource) } * @syscap SystemCapability.ArkUI.ArkUI.Full * @since 9 */ /** * Text body. * * @type { ?(string | Resource) } * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @since 10 */ /** * Text body. * * @type { ?(string | Resource) } * @syscap SystemCapability.ArkUI.ArkUI.Full * @crossplatform * @atomicservice * @since arkts {'1.1':'11','1.2':'20'} * @arkts 1.1&1.2 */ message?: string | Resource; /** * Array of buttons in the dialog box. * The array structure is {text:'button', color: '#666666'}. * One to three buttons are supported. * The first button is of the positiveButton type, the second is of the negativeButton type, and the third is of the neutralButton type. * * @type { ?Array