提交 7ab2a3de 编写于 作者: E ester.zhou

Update docs (22577)

Signed-off-by: Nester.zhou <ester.zhou@huawei.com>
上级 23e539b5
......@@ -214,7 +214,7 @@ struct AnimateToExample {
### showAlertDialog
showAlertDialog(options: AlertDialogParamWithConfirm | AlertDialogParamWithButtons): void
showAlertDialog(options: AlertDialogParamWithConfirm | AlertDialogParamWithButtons | AlertDialogParamWithOptions): void
Shows an alert dialog box.
......@@ -224,7 +224,8 @@ Shows an alert dialog box.
| Name | Type | Mandatory| Description|
| ---- | --------------- | -------- | -------- |
| options | [AlertDialogParamWithConfirm](../arkui-ts/ts-methods-alert-dialog-box.md#alertdialogparamwithconfirm) \| [AlertDialogParamWithButtons](../arkui-ts/ts-methods-alert-dialog-box.md#alertdialogparamwithbuttons) | Yes| Defines and displays the **\<AlertDialog>** component.|
| options | [AlertDialogParamWithConfirm](../arkui-ts/ts-methods-alert-dialog-box.md#alertdialogparamwithconfirm) \| [AlertDialogParamWithButtons](../arkui-ts/ts-methods-alert-dialog-box.md#alertdialogparamwithbuttons) \| [AlertDialogParamWithOptions](../arkui-ts/ts-methods-alert-dialog-box.md#alertdialogparamwithoptions10) | Yes| Defines and displays the **\<AlertDialog>** component.|
**Example**
......@@ -579,7 +580,7 @@ Obtains information about a system font based on the font name.
| Type | Description |
| ------------------------------------ | -------------- |
| [FontInfo](js-apis-font.md#fontinfo) | Information about the system font.|
| [FontInfo](js-apis-font.md#fontinfo10) | Information about the system font.|
**Example**
......@@ -1201,7 +1202,7 @@ try {
### pushNamedRoute
pushNamedRoute(options: router.NamedRouterOptions, mode: RouterMode, callback: AsyncCallback&lt;void&gt;): void
pushNamedRoute(options: router.NamedRouterOptions, mode: router.RouterMode, callback: AsyncCallback&lt;void&gt;): void
Navigates to a page using the named route. This API uses a promise to return the result.
......@@ -1361,7 +1362,7 @@ For details about the error codes, see [Router Error Codes](../errorcodes/errorc
| ID | Error Message|
| --------- | ------- |
| 100001 | if UI execution context not found, only throw in standard system. |
| 100001 | if can not get the delegate, only throw in standard system. |
| 100004 | if the named route is not exist. |
**Example**
......@@ -1425,7 +1426,7 @@ router.replaceNamedRoute({
### back
back(options: router.RouterOptions ): void
back(options?: router.RouterOptions ): void
Returns to the previous page or a specified page.
......@@ -1435,7 +1436,7 @@ Returns to the previous page or a specified page.
| Name | Type | Mandatory| Description |
| ------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ |
| options | [router.RouterOptions](js-apis-router.md#routeroptions) | Yes | Description of the page. The **url** parameter indicates the URL of the page to return to. If the specified page does not exist in the page stack, the application does not respond. If no URL is set, the application returns to the previous page, and the page is not rebuilt. The page in the page stack is not reclaimed. It will be reclaimed after being popped up.|
| options | [router.RouterOptions](js-apis-router.md#routeroptions) | No | Description of the page. The **url** parameter indicates the URL of the page to return to. If the specified page does not exist in the page stack, the application does not respond. If no URL is set, the application returns to the previous page, and the page is not rebuilt. The page in the page stack is not reclaimed. It will be reclaimed after being popped up.|
**Example**
......@@ -1618,7 +1619,7 @@ try {
### showDialog
showDialog(options: promptAction.ShowDialogOptions, callback: AsyncCallback&lt;promptAction.ShowDialogSuccessResponse&lt;): void
showDialog(options: promptAction.ShowDialogOptions, callback: AsyncCallback&lt;promptAction.ShowDialogSuccessResponse&gt;): void
Shows a dialog box. This API uses an asynchronous callback to return the result.
......
......@@ -63,9 +63,9 @@ struct DragControllerPage {
extraParams: ''
}
dragController.executeDrag(this.DraggingBuilder.bind(this), dragInfo, (err, {event, extraParams}) => {
if (event.getResult() == DragRet.DRAG_SUCCESS) {
if (event.getResult() == DragResult.DRAG_SUCCESSFUL) {
// ...
} else if (event.getResult() == DragRet.DRAG_FAILED) {
} else if (event.getResult() == DragResult.DRAG_FAILED) {
// ...
}
})
......@@ -151,9 +151,9 @@ struct DragControllerPage {
dragController.executeDrag(dragItemInfo, dragInfo)
.then(({event, extraParams}) => {
if (event.getResult() == DragRet.DRAG_SUCCESS) {
if (event.getResult() == DragResult.DRAG_SUCCESSFUL) {
// ...
} else if (event.getResult() == DragRet.DRAG_FAILED) {
} else if (event.getResult() == DragResult.DRAG_FAILED) {
// ...
}
})
......
......@@ -141,7 +141,7 @@ Obtains the **DrawableDescriptor** object of the background.
**Example**
```ts
let resManager = getContext().resourceManager
drawable: DrawableDescriptor = (<LayeredDrawableDescriptor> (resManager.getDrawableDescriptor($r('app.media.icon')
let drawable: DrawableDescriptor = (<LayeredDrawableDescriptor> (resManager.getDrawableDescriptor($r('app.media.icon')
.id))).getBackground();
```
......
......@@ -316,7 +316,7 @@ Since API version 9, this API is supported in ArkTS widgets.
```ts
import Curves from '@ohos.curves'
let curve = Curves.initCurve(Curve.EaseIn) // Create an ease-in curve.
let curveValue = Curves.initCurve(Curve.EaseIn) // Create an ease-in curve.
let value: number = curve.interpolate(0.5) // Calculate the interpolation for half of the time.
```
......
......@@ -191,7 +191,10 @@ Describes the options for showing the dialog box.
| ------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| title | string\| [Resource](../arkui-ts/ts-types.md#resource)<sup>9+</sup>| No | Title of the dialog box. |
| message | string\| [Resource](../arkui-ts/ts-types.md#resource)<sup>9+</sup>| No | Text body. |
| buttons | [[Button](#button),[Button](#button)?,[Button](#button)?] | No | Array of buttons in the dialog box. The array structure is **{text:'button', color: '\#666666'}**. Up 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.|
| buttons | Array&lt;[Button](#button)&gt; | No | Array of buttons in the dialog box. The array structure is {text:'button', color: '\#666666'}. More than one button is supported.
| alignment<sup>10+</sup> | [DialogAlignment](../arkui-ts/ts-methods-alert-dialog-box.md#dialogalignment) | No | Alignment mode of the dialog box in the vertical direction.<br>Default value: **DialogAlignment.Default**|
| offset<sup>10+</sup> | [Offset](../arkui-ts/ts-types.md#offset) | No | Offset of the dialog box based on the **alignment** settings.<br>Default value: **{ dx: 0 , dy: 0 }**|
| maskRect<sup>10+</sup>| [Rectangle](../arkui-ts/ts-methods-alert-dialog-box.md#rectangle10) | No | Mask area of the dialog box. Events outside the mask area are transparently transmitted, and events within the mask area are not.<br>Default value: **{ x: 0, y: 0, width: '100%', height: '100%' }**|
## ShowDialogSuccessResponse
......
......@@ -29,12 +29,17 @@ Checks whether a SysCap is supported.
**Example**
```js
import geolocation from '@ohos.geolocation'
import geoLocationManager from '@ohos.geoLocationManager'
const isLocationAvailable = canIUse('SystemCapability.Location.Location');
const isLocationAvailable = canIUse('SystemCapability.Location.Location.Core');
if (isLocationAvailable) {
geolocation.getCurrentLocation((location) => {
console.log(location.latitude, location.longitue);
geoLocationManager.getCurrentLocation((err, location) => {
if (err) {
console.log('err=' + JSON.stringify(err));
}
if (location) {
console.log('location=' + JSON.stringify(location));
}
});
} else {
console.log('Location not by this device.');
......
......@@ -14,32 +14,105 @@ You can set the text content and response callback for an alert dialog box.
| Name | Type | Description|
| ---- | --------------- | -------- |
| show | [AlertDialogParamWithConfirm](#alertdialogparamwithconfirm) \| [AlertDialogParamWithButtons](#alertdialogparamwithbuttons) | Defines and displays the **\<AlertDialog>** component. |
| show | [AlertDialogParamWithConfirm](#alertdialogparamwithconfirm) \| [AlertDialogParamWithButtons](#alertdialogparamwithbuttons) \| [AlertDialogParamWithOptions](#alertdialogparamwithoptions10) | Defines and displays the **\<AlertDialog>** component.|
## AlertDialogParamWithConfirm
| Name | Type | Mandatory | Description |
| ---------- | ---------------- | ---------- | ------------------------------- |
| title | [ResourceStr](ts-types.md#resourcestr) | No | Title of the dialog box.|
| subtitle<sup>10+</sup> | [ResourceStr](ts-types.md#resourcestr) | No| Subtitle of the dialog box.|
| message | [ResourceStr](ts-types.md#resourcestr) | Yes | Content of the dialog box.|
| autoCancel | boolean | No | Whether to close the dialog box when the overlay is clicked.<br>Default value: **true**|
| confirm | {<br>value: [ResourceStr](ts-types.md#resourcestr),<br>fontColor?: [ResourceColor](ts-types.md#resourcecolor),<br>backgroundColor?: [ResourceColor](ts-types.md#resourcecolor),<br>action: () =&gt; void<br>} | No | Text content, text color, background color, and click callback of the confirm button.|
| confirm | {<br>enabled<sup>10+</sup>?: boolean,<br>defaultFocus<sup>10+</sup>?: boolean,<br>style<sup>10+</sup>?: [DialogButtonStyle](#dialogbuttonstyle10),<br>value: [ResourceStr](ts-types.md#resourcestr),<br>fontColor?: [ResourceColor](ts-types.md#resourcecolor),<br>backgroundColor?: [ResourceColor](ts-types.md#resourcecolor),<br>action: () =&gt; void<br>} | No | Information about the confirm button.<br>**enabled**: whether to respond when the button is clicked.<br>Default value: **true**<br>**defaultFocus**: whether the button is the default focus.<br>Default value: **false**<br>**style**: button style.<br>Default value: **DialogButtonStyle.DEFAULT**<br>**value**: text of the button.<br>**fontColor**: font color of the button.<br>**backgroundColor**: background color of the button.<br>**action**: callback when the button is selected.|
| cancel | () =&gt; void | No | Callback invoked when the dialog box is closed after the overlay is clicked.|
| alignment | [DialogAlignment](#dialogalignment) | No | Alignment mode of the dialog box in the vertical direction.<br>Default value: **DialogAlignment.Default**|
| offset | [Offset](ts-types.md#offset) | No | Offset of the dialog box relative to the alignment position.<br>Default value: **{ dx: 0 , dy: 0 }**|
| gridCount | number | No | Number of grid columns occupied by the width of the dialog box.<br>Default value: **4**|
| maskRect<sup>10+</sup>| [Rectangle](#rectangle10) | No | Mask area of the dialog box. Events outside the mask area are transparently transmitted, and events within the mask area are not.<br>Default value: **{ x: 0, y: 0, width: '100%', height: '100%' }**|
Priorities of the **confirm** parameters: **fontColor** and **backgroundColor** > **style** > **defaultFocus**
| backgroundColor | fontColor | style | defaultFocus | Effect |
| --------------- | --------- | --------------------------- | ------------ | -------- |
| Green | Red | - | - | Red text on green background|
| Green | - | DialogButtonStyle.HIGHLIGHT | - | White text on green background|
| Green | - | DialogButtonStyle.DEFAULT | - | Blue text on green background|
| Green | - | - | TRUE | White text on green background|
| Green | - | - | FALSE/- | Blue text on green background|
| - | Red | DialogButtonStyle.HIGHLIGHT | - | Red text on blue background|
| - | Red | DialogButtonStyle.DEFAULT | - | Red text on white background|
| - | Red | - | TRUE | Red text on blue background|
| - | Red | - | FALSE/- | Red text on white background|
| - | - | DialogButtonStyle.HIGHLIGHT | - | White text on blue background|
| - | - | DialogButtonStyle.DEFAULT | - | Blue text on white background|
| - | - | - | TRUE | White text on blue background|
| - | - | - | FALSE/- | Blue text on white background|
## AlertDialogParamWithButtons
| Name | Type | Mandatory | Description |
| --------------- | ---------------------- | ------------ | --------------------- |
| title | [ResourceStr](ts-types.md#resourcestr) | No | Title of the dialog box. |
| subtitle<sup>10+</sup> | [ResourceStr](ts-types.md#resourcestr) | No| Subtitle of the dialog box.|
| message | [ResourceStr](ts-types.md#resourcestr) | Yes | Content of the dialog box. |
| autoCancel | boolean | No | Whether to close the dialog box when the overlay is clicked.<br>Default value: **true** |
| primaryButton | {<br>enabled<sup>10+</sup>?: boolean,<br>defaultFocus<sup>10+</sup>?: boolean,<br>style<sup>10+</sup>?: [DialogButtonStyle](#dialogbuttonstyle10),<br>value: [ResourceStr](ts-types.md#resourcestr),<br>fontColor?: [ResourceColor](ts-types.md#resourcecolor),<br>backgroundColor?: [ResourceColor](ts-types.md#resourcecolor),<br>action: () =&gt; void;<br>} | No| Information about the confirm button.<br>**enabled**: whether to respond when the button is clicked.<br>Default value: **true**<br>**defaultFocus**: whether the button is the default focus.<br>Default value: **false**<br>**style**: button style.<br>Default value: **DialogButtonStyle.DEFAULT**<br>**value**: text of the button.<br>**fontColor**: font color of the button.<br>**backgroundColor**: background color of the button.<br>**action**: callback when the button is selected.|
| secondaryButton | {<br>enabled<sup>10+</sup>?: boolean,<br>defaultFocus<sup>10+</sup>?: boolean,<br>style<sup>10+</sup>?: [DialogButtonStyle](#dialogbuttonstyle10),<br>value: [ResourceStr](ts-types.md#resourcestr),<br>fontColor?: [ResourceColor](ts-types.md#resourcecolor),<br>backgroundColor?: [ResourceColor](ts-types.md#resourcecolor),<br>action: () =&gt; void;<br>} | No | Information about the confirm button.<br>**enabled**: whether to respond when the button is clicked.<br>Default value: **true**<br>**defaultFocus**: whether the button is the default focus.<br>Default value: **false**<br>**style**: button style.<br>Default value: **DialogButtonStyle.DEFAULT**<br>**value**: text of the button.<br>**fontColor**: font color of the button.<br>**backgroundColor**: background color of the button.<br>**action**: callback when the button is selected.|
| cancel | () =&gt; void | No | Callback invoked when the dialog box is closed after the overlay is clicked. |
| alignment | [DialogAlignment](#dialogalignment) | No | Alignment mode of the dialog box in the vertical direction.<br>Default value: **DialogAlignment.Default**|
| offset | [Offset](ts-types.md#offset) | No | Offset of the dialog box relative to the alignment position.|
| gridCount | number | No | Number of grid columns occupied by the width of the dialog box.|
| maskRect<sup>10+</sup> | [Rectangle](#rectangle10) | No | Mask area of the dialog box. Events outside the mask area are transparently transmitted, and events within the mask area are not.<br>Default value: **{ x: 0, y: 0, width: '100%', height: '100%' }**|
## AlertDialogParamWithOptions<sup>10+</sup>
| Name | Type | Mandatory | Description |
| --------------- | ---------------------- | ------------ | --------------------- |
| title | [ResourceStr](ts-types.md#resourcestr) | No | Title of the dialog box. |
| subtitle<sup>10+</sup> | [ResourceStr](ts-types.md#resourcestr) | No | Subtitle of the dialog box. |
| message | [ResourceStr](ts-types.md#resourcestr) | Yes | Content of the dialog box. |
| autoCancel | boolean | No | Whether to close the dialog box when the overlay is clicked.<br>Default value: **true** |
| primaryButton | {<br>value: [ResourceStr](ts-types.md#resourcestr),<br>fontColor?: [ResourceColor](ts-types.md#resourcecolor),<br>backgroundColor?: [ResourceColor](ts-types.md#resourcecolor),<br>action: () =&gt; void;<br>} | No| Text content, text color, background color, and click callback of the primary button.|
| secondaryButton | {<br>value: [ResourceStr](ts-types.md#resourcestr),<br>fontColor?: [ResourceColor](ts-types.md#resourcecolor),<br>backgroundColor?: [ResourceColor](ts-types.md#resourcecolor),<br>action: () =&gt; void;<br>} | No | Text content, text color, background color, and click callback of the secondary button.|
| cancel | () =&gt; void | No | Callback invoked when the dialog box is closed after the overlay is clicked. |
| alignment | [DialogAlignment](#dialogalignment) | No | Alignment mode of the dialog box in the vertical direction.<br>Default value: **DialogAlignment.Default**|
| offset | [Offset](ts-types.md#offset) | No | Offset of the dialog box relative to the alignment position.|
| gridCount | number | No | Number of grid columns occupied by the width of the dialog box.|
| maskRect<sup>10+</sup>| [Rectangle](#rectangle10) | No | Mask area of the dialog box. Events outside the mask area are transparently transmitted, and events within the mask area are not.<br>Default value: **{ x: 0, y: 0, width: '100%', height: '100%' }**|
| buttons<sup>10+</sup> | Array&lt;[AlertDialogButtonOptions](#alertdialogbuttonoptions10)&gt; | No | Buttons in the dialog box.|
|buttonDirection<sup>10+</sup> | [DialogButtonDirection](#dialogbuttondirection10)| No | Direction in which buttons are laid out.<br>Default value: **DialogButtonDirection.AUTO**<br>When there are more than three buttons, the Auto mode (which automatically switches to the vertical layout when there are more than two buttons) is recommended. In non-Auto mode, buttons that extend beyond the display area are clipped.|
## AlertDialogButtonOptions<sup>10+</sup>
| Name | Type | Mandatory | Description |
| ------------------| ---------------------- | ------------ | --------------------- |
| enabled | boolean | No | Whether to respond when the button is clicked.<br>Default value: **true** |
| defaultFocus | boolean | No | Whether the button is the default focus.<br>Default value: **false** |
| style | [DialogButtonStyle](#dialogbuttonstyle10) | No | Style of the button.<br>Default value: **DialogButtonStyle.DEFAULT** |
| value | [ResourceStr](ts-types.md#resourcestr) | Yes | Text of the button. If the value is null, the button is not displayed. |
| fontColor | [ResourceColor](ts-types.md#resourcecolor) | No | Font color of the button. |
| backgroundColor | [ResourceColor](ts-types.md#resourcecolor) | No | Background color of the button. |
| action | () => void | Yes | Callback when the button is selected. |
## DialogButtonDirection<sup>10+</sup>
| Name | Description |
| -------------------------- | --------- |
| AUTO | Buttons are laid out horizontally when there are two or fewer buttons and vertically otherwise.|
| HORIZONTAL | Buttons are laid out horizontally.|
| VERTICAL | Buttons are laid out vertically.|
Priorities of the **confirm** parameters: **fontColor** and **backgroundColor** > **style** > **defaultFocus**
| backgroundColor | fontColor | style | defaultFocus | Effect |
| --------------- | --------- | --------------------------- | ------------ | -------- |
| Green | Red | - | - | Red text on green background|
| Green | - | DialogButtonStyle.HIGHLIGHT | - | White text on green background|
| Green | - | DialogButtonStyle.DEFAULT | - | Blue text on green background|
| Green | - | - | TRUE | White text on green background|
| Green | - | - | FALSE/- | Blue text on green background|
| - | Red | DialogButtonStyle.HIGHLIGHT | - | Red text on blue background|
| - | Red | DialogButtonStyle.DEFAULT | - | Red text on white background|
| - | Red | - | TRUE | Red text on blue background|
| - | Red | - | FALSE/- | Red text on white background|
| - | - | DialogButtonStyle.HIGHLIGHT | - | White text on blue background|
| - | - | DialogButtonStyle.DEFAULT | - | Blue text on white background|
| - | - | - | TRUE | White text on blue background|
| - | - | - | FALSE/- | Blue text on white background|
## DialogAlignment
......@@ -56,6 +129,32 @@ You can set the text content and response callback for an alert dialog box.
| BottomStart<sup>8+</sup> | Bottom left alignment. |
| BottomEnd<sup>8+</sup> | Bottom right alignment. |
## Rectangle<sup>10+</sup>
The **Rectangle** type is used to represent a mask area of a dialog box.
| Name | Type | Mandatory| Description |
|--------|------------------------------|----|-----------------------------------|
| x | [Length](ts-types.md#length) | No | X coordinate of the mask area of the dialog box relative to the upper left corner of the window.<br>Default value: **0vp**|
| y | [Length](ts-types.md#length) | No | Y coordinate of the mask area of the dialog box relative to the upper left corner of the window.<br>Default value: **0vp**|
| width | [Length](ts-types.md#length) | No | Width of the mask area of the dialog box.<br>Default value: **'100%'** |
| height | [Length](ts-types.md#length) | No | Height of the mask area of the dialog box.<br>Default value: **'100%'** |
> **NOTE**
>
> **x** and **y** can be set to a positive or negative percentage value. When **x** is set to **'100%'**, the mask area is moved rightward by the window width. When **x** is set to **'-100%'**, the mask area is moved leftward by the window width. When **y** is set to **'100%'**, the mask area is moved downward by the window height. When **y** is set to **'-100%'**, the mask area is moved upward by the window height.
>
> **width** and **height** can be set in percentage and can only be set to positive values. If they are set to negative values, the default values are used instead.
>
> The percentage is calculated based on the width and height of the window.
## DialogButtonStyle<sup>10+</sup>
| Name | Description |
| --------- | --------------------------------- |
| DEFAULT | Blue text on white background (black background under the dark theme).|
| HIGHLIGHT | White text on blue background. |
## Example
```ts
......@@ -93,6 +192,7 @@ struct AlertDialogExample {
AlertDialog.show(
{
title: 'title',
subtitle: 'subtitle',
message: 'text',
autoCancel: true,
alignment: DialogAlignment.Bottom,
......@@ -105,6 +205,9 @@ struct AlertDialogExample {
}
},
secondaryButton: {
enabled: true,
defaultFocus: true,
style: DialogButtonStyle.HIGHLIGHT,
value: 'ok',
action: () => {
console.info('Callback when the second button is clicked')
......@@ -116,9 +219,50 @@ struct AlertDialogExample {
}
)
}).backgroundColor(0x317aff)
Button('three button dialog')
.onClick(() => {
AlertDialog.show(
{
title: 'title',
subtitle: 'subtitle',
message: 'text',
autoCancel: true,
alignment: DialogAlignment.Bottom,
gridCount: 4,
offset: { dx: 0, dy: -20 },
buttonDirection: DialogButtonDirection.HORIZONTAL,
buttons: [
{
value: 'Button',
action: () => {
console.info('Callback when button1 is clicked')
}
},
{
value: 'Button',
action: () => {
console.info('Callback when button2 is clicked')
}
},
{
value: 'Button',
enabled: true,
defaultFocus: true,
style: DialogButtonStyle.HIGHLIGHT,
action: () => {
console.info('Callback when button3 is clicked')
}
},
],
cancel: () => {
console.info('Closed callbacks')
}
}
)
}).backgroundColor(0x317aff)
}.width('100%').margin({ top: 5 })
}
}
```
![en-us_image_0000001174582844](figures/en-us_image_0000001174582844.gif)
![en-us_image_alert](figures/en-us_image_alert.gif)
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册