diff --git a/en/application-dev/quick-start/basic-resource-file-categories.md b/en/application-dev/quick-start/basic-resource-file-categories.md new file mode 100644 index 0000000000000000000000000000000000000000..db223b338d505727b8194c50ebc2e228daed89ec --- /dev/null +++ b/en/application-dev/quick-start/basic-resource-file-categories.md @@ -0,0 +1,79 @@ +# Resource File Categories + + +## resources Directory + +All the application resource files, such as strings, images, and audio files, are stored in the **resources** directory, allowing you to easily access, use, and maintain them. The **resources** directory consists of two types of sub-directories: the **base** sub-directory and qualifiers sub-directories, and the **rawfile** sub-directory. For details, see Categories of the **resources** directory. + + Example of the **resources** directory: + +``` +resources +|---base // Default directory +| |---element +| | |---string.json +| |---media +| | |---icon.png +|---en_GB-vertical-car-mdpi // Example of a qualifiers sub-directory, which needs to be created on your own +| |---element +| | |---string.json +| |---media +| | |---icon.png +|---rawfile // Default directory +``` + + **Table 1** Categories of the **resources** directory + +| Category | base and Qualifiers Sub-directories | rawfile Sub-directory | +| -------- | -------- | -------- | +| Structure | Sub-directories are structured in two levels. The directory name must comply with specified naming conventions so that its target resource file in the correct directory can be matched based on the device status.
  The **base** sub-directory and qualifiers sub-directories are the first level of sub-directories under **resources**.
- The **base** sub-directory is generated by default. If no qualifiers sub-directories in the **resources** directory of the application match the device status, the resource file in the **base** sub-directory will be automatically referenced.
- You need to create qualifiers sub-directories on your own. Each directory name consists of one or more qualifiers that represent the application scenarios or device characteristics. For details, see [Qualifiers Sub-directories](#qualifiers-sub-directories).
Resource group sub-directories are located at the second level of sub-directories to store basic elements such as strings, colors, and boolean values, as well as resource files such as media, animations, and layouts. For details, see [Resource Group Sub-directories](#resource-group-sub-directories). | You can create multiple levels of sub-directories with custom directory names. They can be used to store various resource files.
However, resource files in the **rawfile** sub-directory will not be matched based on the device status. | +| Compilation | Resource files in the sub-directories are compiled into binary files, and each resource file is assigned an ID. | Resource files in the sub-directory are directly packed into the application without being compiled, and no IDs will be assigned to the resource files. | +| Reference | Resource files in the sub-directories are referenced based on the resource type and resource name. | Resource files in the sub-directories are referenced based on the specified file path and file name. | + + +## Qualifiers Sub-directories + +The name of a qualifiers sub-directory consists of one or more qualifiers that represent the application scenarios or device characteristics, covering the mobile country code (MCC), mobile network code (MNC), language, script, country or region, screen orientation, device type, color mode, and screen density. The qualifiers are separated using underscores (_) or hyphens (-). When creating a qualifiers sub-directory, you need to understand the directory naming conventions and the rules for matching qualifiers sub-directories and the device status. + +**Naming Conventions for Qualifiers Sub-directories** + +- Qualifiers are ordered in the following sequence: _MCC_MNC-language_script_country/region-screen orientation-device type-color mode-screen density_. You can select one or multiple qualifiers to name your sub-directory based on your application scenarios and device characteristics. + +- Separation between qualifiers: The language, script, and country/region qualifiers are separated using underscores (_); the MNC and MCC qualifiers are also separated using underscores (_); other qualifiers are separated using hyphens (-). For example, **zh_Hant_CN** and **zh_CN-car-ldpi**. + +- Value range of qualifiers: The value of each qualifier must meet the requirements. Otherwise, the resource files in the sub-directory cannot be matched. + **Table 2** Requirements for qualifier values + + | Qualifier Type | Description and Value Range | + | -------- | -------- | + | MCC&MNC | Indicates the MCC and MNC, which are obtained from the network where the device is registered. The MCC can be either followed by the MNC with an underscore (_) in between or be used independently. For example, **mcc460** represents China, and **mcc460_mnc00** represents China Mobile.
For details about the value range, refer to **ITU-T E.212** (the international identification plan for public networks and subscriptions). | + | Language | Indicates the language used by the device. The value consists of two or three lowercase letters, for example, **zh** indicates Chinese, **en** indicates English, and **mai** indicates Maithili.
For details about the value range, refer to **ISO 639** (codes for the representation of names of languages). | + | Script | Indicates the script type used by the device. The value starts with one uppercase letter followed by three lowercase letters, for example, **Hans** indicates simplified Chinese and **Hant** indicates traditional Chinese.
For details about the value range, refer to **ISO 15924** (codes for the representation of names of scripts). | + | Country/Region | Indicates the country or region where a user is located. The value consists of two or three uppercase letters or three digits, for example, **CN** indicates China and **GB** indicates the United Kingdom.
For details about the value range, refer to **ISO 3166-1** (codes for the representation of names of countries and their subdivisions). | + | Screen orientation | Indicates the screen orientation of the device. The value can be:
- **vertical**: portrait orientation
- **horizontal**: landscape orientation | + | Device type | Indicates the device type. The value can be:
- **phone**: smartphones
- **tablet**: tablets
- **car**: head units
- **tv**: smart TVs
- **wearable**: wearables | + | Color mode | Indicates the color mode of the device. The value can be:
- **dark**: dark mode
- **light**: light mode | + | Screen density | Indicates the screen density of the device, in dpi. The value can be:
- **sdpi**: screen density with small-scale dots per inch (SDPI). This value is applicable for devices with a DPI range of (0, 120].
- **mdpi**: screen density with medium-scale dots per inch (MDPI). This value is applicable for devices with a DPI range of (120, 160].
- **ldpi**: screen density with large-scale dots per inch (LDPI). This value is applicable for devices with a DPI range of (160, 240].
- **xldpi**: screen density with extra-large-scale dots per inch (XLDPI). This value is applicable for devices with a DPI range of (240, 320].
- **xxldpi**: screen density with extra-extra-large-scale dots per inch (XXLDPI). This value is applicable for devices with a DPI range of (320, 480].
- **xxxldpi**: screen density with extra-extra-extra-large-scale dots per inch (XXXLDPI). This value is applicable for devices with a DPI range of (480, 640]. | + +**Rules for Matching Qualifiers Sub-directories and Device Resources** + +- Qualifiers are matched with the device resources in the following priorities: MCC&MNC > locale (options: language, language_script, language_country/region, and language_script_country/region) > screen orientation > device type > color mode > screen density + +- If the qualifiers sub-directories contain the **MCC, MNC, language, script, screen orientation, device type, and color mode** qualifiers, their values must be consistent with the current device status so that the sub-directories can be used for matching the device resources. For example, the qualifiers sub-directory **zh_CN-car-ldpi** cannot be used for matching the resource files labeled **en_US**. + + +## Resource Group Sub-directories + +You can create resource group sub-directories (including element, media, animation, layout, graphic, and profile) in the **base** and qualifiers sub-directories to store resource files of specific types. For details, see Resource group sub-directories. + + + **Table 3** Resource group sub-directories + +| Resource Group Sub-directory | Description | Resource File | +| -------- | -------- | -------- | +| element | Indicates element resources. Each type of data is represented by a JSON file. The options are as follows:
- **boolean**: boolean data
- **color**: color data
- **float**: floating-point data
- **intarray**: array of integer
- **integer**: integer data
- **pattern**: pattern data
- **plural**: plural form data
- **strarray**: array of strings
- **string**: string data | It is recommended that files in the **element** sub-directory be named the same as the following files, each of which can contain only data of the same type:
- boolean.json
- color.json
- float.json
- intarray.json
- integer.json
- pattern.json
- plural.json
- strarray.json
- string.json | +| media | Indicates media resources, including non-text files such as images, audios, and videos. | The file name can be customized, for example, **icon.png**. | +| animation | Indicates animation resources, in XML format. | The file name can be customized, for example, **zoom_in.xml**. | +| layout | Indicates layout resources, in XML format. | The file name can be customized, for example, **home_layout.xml**. | +| graphic | Indicates graphic resources, in XML format. | The file name can be customized, for example, **notifications_dark.xml**. | +| profile | Indicates other types of files, which are stored in their raw formats. | The file name can be customized. | diff --git a/en/application-dev/reference/apis/figures/en-us_image_0000001164217678.png b/en/application-dev/reference/apis/figures/en-us_image_0000001164217678.png deleted file mode 100644 index 2128f0852380b2895198ab725a2f9d299c480d84..0000000000000000000000000000000000000000 Binary files a/en/application-dev/reference/apis/figures/en-us_image_0000001164217678.png and /dev/null differ diff --git a/en/application-dev/reference/arkui-ts/Readme-CN.md b/en/application-dev/reference/arkui-ts/Readme-CN.md new file mode 100644 index 0000000000000000000000000000000000000000..50acfac05c7c49fba421388be57e3dc97d7f113e --- /dev/null +++ b/en/application-dev/reference/arkui-ts/Readme-CN.md @@ -0,0 +1,132 @@ +# reference/arkui-ts + +- Components + - Universal Components + - Universal Events + - [Click Event](ts-universal-events-click.md) + - [Touch Event](ts-universal-events-touch.md) + - [Show/Hide Event](ts-universal-events-show-hide.md) + - [Drag/Drop Event](ts-universal-events-drag-drop.md) + - [Key Event](ts-universal-events-key.md) + - [Focus Event](ts-universal-focus-event.md) + - [Mouse Event](ts-universal-mouse-key.md) + - [Component Area Change Event](ts-universal-component-area-change-event.md) + - Universal Attributes + - [Size](ts-universal-attributes-size.md) + - [Location](ts-universal-attributes-location.md) + - [Layout Constraints](ts-universal-attributes-layout-constraints.md) + - [Flex Layout](ts-universal-attributes-flex-layout.md) + - [Border](ts-universal-attributes-border.md) + - [Background](ts-universal-attributes-background.md) + - [Opacity](ts-universal-attributes-opacity.md) + - [Visibility](ts-universal-attributes-visibility.md) + - [Enable/Disable](ts-universal-attributes-enable.md) + - [Overlay](ts-universal-attributes-overlay.md) + - [Z-order Control](ts-universal-attributes-z-order.md) + - [Transformation](ts-universal-attributes-transformation.md) + - [Image Effect Configuration](ts-universal-attributes-image-effect.md) + - [Shape Clipping](ts-universal-attributes-sharp-clipping.md) + - [Text Style](ts-universal-attributes-text-style.md) + - [Grid](ts-universal-attributes-grid.md) + - [Gradient Color](ts-universal-attributes-gradient-color.md) + - [Popup Control](ts-universal-attributes-popup.md) + - [Menu Control](ts-universal-attributes-menu.md) + - [Click Control](ts-universal-attributes-click.md) + - [Focus Control](ts-universal-attributes-focus.md) + - [Hover Effect](ts-universal-attributes-hover-effect.md) + - [Component ID](ts-universal-attributes-component-id.md) + - [Touch Target](ts-universal-attributes-touch-target.md) + - [Polymorphic Style](ts-universal-attributes-polymorphic-style.md) + - Gesture Processing + - [Gesture Binding Methods](ts-gesture-settings.md) + - Basic Gestures + - [TapGesture](ts-basic-gestures-tapgesture.md) + - [LongPressGesture](ts-basic-gestures-longpressgesture.md) + - [PanGesture](ts-basic-gestures-pangesture.md) + - [PinchGesture](ts-basic-gestures-pinchgesture.md) + - [RotationGesture](ts-basic-gestures-rotationgesture.md) + - [SwipeGesture](ts-basic-gestures-swipegesture.md) + - [Combined Gestures](ts-combined-gestures.md) + - Basic Components + - [Blank](ts-basic-components-blank.md) + - [Button](ts-basic-components-button.md) + - [DataPanel](ts-basic-components-datapanel.md) + - [DatePicker](ts-basic-components-datepicker.md) + - [Divider](ts-basic-components-divider.md) + - [Image](ts-basic-components-image.md) + - [ImageAnimator](ts-basic-components-imageanimator.md) + - [Progress](ts-basic-components-progress.md) + - [QRCode](ts-basic-components-qrcode.md) + - [Rating](ts-basic-components-rating.md) + - [Select](ts-basic-components-rating.md) + - [Span](ts-basic-components-span.md) + - [Slider](ts-basic-components-slider.md) + - [Text](ts-basic-components-text.md) + - [TextArea](ts-basic-components-textarea.md) + - [TextInput](ts-basic-components-textinput.md) + - [TextPicker](ts-basic-components-textpicker.md) + - [TextTimer](ts-basic-components-texttimer.md) + - [Toggle](ts-basic-components-toggle.md) + - [TextClock](ts-basic-components-textclock.md) + - Container Components + - [AlphabetIndexer](ts-container-alphabet-indexer.md) + - [Badge](ts-container-badge.md) + - [Column](ts-container-column.md) + - [ColumnSplit](ts-container-columnsplit.md) + - [Counter](ts-container-counter.md) + - [Flex](ts-container-flex.md) + - [GridContainer](ts-container-gridcontainer.md) + - [Grid](ts-container-grid.md) + - [GridItem](ts-container-griditem.md) + - [List](ts-container-list.md) + - [ListItem](ts-container-listitem.md) + - [Navigator](ts-container-navigator.md) + - [Navigation](ts-basic-components-navigation.md) + - [Panel](ts-container-panel.md) + - [Row](ts-container-row.md) + - [RowSplit](ts-container-rowsplit.md) + - [Scroll](ts-container-scroll.md) + - [ScrollBar](ts-basic-components-scrollbar.md) + - [Stack](ts-container-stack.md) + - [Swiper](ts-container-swiper.md) + - [Tabs](ts-container-tabs.md) + - [TabContent](ts-container-tabcontent.md) + - Media Components + - [Video](ts-media-components-video.md) + - Drawing Components + - [Circle](ts-drawing-components-circle.md) + - [Ellipse](ts-drawing-components-ellipse.md) + - [Line](ts-drawing-components-line.md) + - [Polyline](ts-drawing-components-polyline.md) + - [Polygon](ts-drawing-components-polygon.md) + - [Path](ts-drawing-components-path.md) + - [Rect](ts-drawing-components-rect.md) + - [Shape](ts-drawing-components-shape.md) + - Canvas Components + - [Canvas](ts-components-canvas-canvas.md) + - [CanvasRenderingContext2D](ts-canvasrenderingcontext2d.md) + - [OffscreenCanvasRenderingConxt2D](ts-offscreencanvasrenderingcontext2d.md) + - [Lottie](ts-components-canvas-lottie.md) + - [Path2D](ts-components-canvas-path2d.md) + - [CanvasGradient](ts-components-canvas-canvasgradient.md) + - [ImageBitmap](ts-components-canvas-imagebitmap.md) + - [ImageData](ts-components-canvas-imagedata.md) +- Animation + - [AnimatorProperty](ts-animatorproperty.md) + - [Explicit Animation](ts-explicit-animation.md) + - Transition Animation + - [Page Transition](ts-page-transition-animation.md) + - [Component Transition](ts-transition-animation-component.md) + - [Transition of Shared Elements](ts-transition-animation-shared-elements.md) + - [Motion Path Animation](ts-motion-path-animation.md) + - [Matrix Transformation](ts-matrix-transformation.md) + - [Interpolation Calculation](ts-interpolation-calculation.md) +- Global UI Methods + - [Image Cache](ts-methods-image-cache.md) + - [Media Query](ts-methods-media-query.md) + - Pop-up Window + - [Alert Dialog Box](ts-methods-alert-dialog-box.md) + - [Action Sheet](ts-methods-action-sheet.md) + - [Custom Dialog Box](ts-methods-custom-dialog-box.md) +- Appendix + - [Built-in Enums](ts-appendix-enums.md) diff --git a/en/application-dev/reference/arkui-ts/Readme-EN.md b/en/application-dev/reference/arkui-ts/Readme-EN.md deleted file mode 100644 index 775bd3d067c466e6415a565eaefb15964956c61e..0000000000000000000000000000000000000000 --- a/en/application-dev/reference/arkui-ts/Readme-EN.md +++ /dev/null @@ -1,136 +0,0 @@ -# TypeScript-based Declarative Development Paradigm - -- [Components](ts-components.md) - - [Universal Components](ts-universal-components.md) - - [Universal Events](ts-universal-events.md) - - [Click Event](ts-universal-events-click.md) - - [Touch](ts-universal-events-touch.md) - - [Show/Hide Event](ts-universal-events-show-hide.md) - - [Key Event](ts-universal-events-key.md) - - [Component Area Change Event](ts-universal-events-component-area-change.md) - - - [Universal Attributes](ts-universal-attributes.md) - - [Size](ts-universal-attributes-size.md) - - [Location](ts-universal-attributes-location.md) - - [Layout Constraints](ts-universal-attributes-layout-constraints.md) - - [Flex Layout](ts-universal-attributes-flex-layout.md) - - [Border Configuration](ts-universal-attributes-border.md) - - [Background](ts-universal-attributes-background.md) - - [Opacity](ts-universal-attributes-opacity.md) - - [Visibility](ts-universal-attributes-visibility.md) - - [Enable/Disable](ts-universal-attributes-enable.md) - - [Overlay](ts-universal-attributes-overlay.md) - - [Z-order Control](ts-universal-attributes-z-order.md) - - [Transformation](ts-universal-attributes-transformation.md) - - [Image Effect Configuration](ts-universal-attributes-image-effect.md) - - [Shape Clipping](ts-universal-attributes-sharp-clipping.md) - - [Text Style](ts-universal-attributes-text-style.md) - - [Grid](ts-universal-attributes-grid.md) - - [Gradient Color](ts-universal-attributes-gradient-color.md) - - [Popup Control](ts-universal-attributes-popup.md) - - [Menu Control](ts-universal-attributes-menu.md) - - [Click Control](ts-universal-attributes-touchable.md) - - [Touch Target](ts-universal-attributes-response-region.md) - - - [Gesture Processing](ts-gesture-processing.md) - - [Gesture Binding Methods](ts-gesture-settings.md) - - [Basic Gestures](ts-basic-gestures.md) - - [TapGesture](ts-basic-gestures-tapgesture.md) - - [LongPressGesture](ts-basic-gestures-longpressgesture.md) - - [PanGesture](ts-basic-gestures-pangesture.md) - - [PinchGesture](ts-basic-gestures-pinchgesture.md) - - [RotationGesture](ts-basic-gestures-rotationgesture.md) - - [SwipeGesture](ts-basic-gestures-swipegesture.md) - - - [Combined Gestures](ts-combined-gestures.md) - - - [Basic Components](ts-basic-components.md) - - [Blank](ts-basic-components-blank.md) - - [Button](ts-basic-components-button.md) - - [DataPanel](ts-basic-components-datapanel.md) - - [Divider](ts-basic-components-divider.md) - - [Gauge](ts-basic-components-gauge.md) - - [Image](ts-basic-components-image.md) - - [ImageAnimator](ts-basic-components-imageanimator.md) - - [LoadingProgress](ts-basic-components-loadingprogress.md) - - [Marquee](ts-basic-components-marquee.md) - - [Progress](ts-basic-components-progress.md) - - [QRCode](ts-basic-components-qrcode.md) - - [Rating](ts-basic-components-rating.md) - - [Select](ts-basic-components-select.md) - - [Slider](ts-basic-components-slider.md) - - [Span](ts-basic-components-span.md) - - [Text](ts-basic-components-text.md) - - [TextArea](ts-basic-components-textarea.md) - - [TextInput](ts-basic-components-textinput.md) - - [Toggle](ts-basic-components-toggle.md) - - [TextClock](ts-basic-components-textclock.md) - - - [Container Components](ts-components-container.md) - - [AlphabetIndexer](ts-container-alphabet-indexer.md) - - [Badge](ts-container-badge.md) - - [Column](ts-container-column.md) - - [ColumnSplit](ts-container-columnsplit.md) - - [Counter](ts-container-counter.md) - - [Flex](ts-container-flex.md) - - [GridContainer](ts-container-gridcontainer.md) - - [Grid](ts-container-grid.md) - - [GridItem](ts-container-griditem.md) - - [List](ts-container-list.md) - - [ListItem](ts-container-listitem.md) - - [Navigator](ts-container-navigator.md) - - [Navigation](ts-container-navigation.md) - - [Panel](ts-container-panel.md) - - [Row](ts-container-row.md) - - [RowSplit](ts-container-rowsplit.md) - - [Scroll](ts-container-scroll.md) - - [ScrollBar](ts-container-scrollbar.md) - - [Stack](ts-container-stack.md) - - [Swiper](ts-container-swiper.md) - - [Tabs](ts-container-tabs.md) - - [TabContent](ts-container-tabcontent.md) - - - [Refresh](ts-container-refresh.md) - - [Drawing Components](ts-drawing-components.md) - - - [Circle](ts-drawing-components-circle.md) - - [Ellipse](ts-drawing-components-ellipse.md) - - [Line](ts-drawing-components-line.md) - - [Polyline](ts-drawing-components-polyline.md) - - [Polygon](ts-drawing-components-polygon.md) - - [Path](ts-drawing-components-path.md) - - [Rect](ts-drawing-components-rect.md) - - [Shape](ts-drawing-components-shape.md) - - - [Canvas Components](ts-components-canvas.md) - - [Canvas](ts-components-canvas-canvas.md) - - [CanvasRenderingContext2D](ts-canvasrenderingcontext2d.md) - - [OffscreenCanvasRenderingConxt2D](ts-offscreencanvasrenderingcontext2d.md) - - [Lottie](ts-components-canvas-lottie.md) - - [Path2D](ts-components-canvas-path2d.md) - - [CanvasGradient](ts-components-canvas-canvasgradient.md) - - [ImageBitmap](ts-components-canvas-imagebitmap.md) - - [ImageData](ts-components-canvas-imagedata.md) -- [Animation](ts-animation.md) - - [Attribute Animation](ts-animatorproperty.md) - - [Explicit Animation](ts-explicit-animation.md) - - [Transition Animation](ts-transition-animation.md) - - [Page Transition](ts-page-transition-animation.md) - - [Component Transition](ts-transition-animation-component.md) - - [Transition of Shared Elements](ts-transition-animation-shared-elements.md) - - - [Motion Path Animation](ts-motion-path-animation.md) - - [Matrix Transformation](ts-matrix-transformation.md) - - [Interpolation Calculation](ts-interpolation-calculation.md) - -- [Global UI Methods](ts-global-ui-methods.md) - - [Alert Dialog Box](ts-methods-alert-dialog-box.md) - - [Custom Dialog box](ts-methods-custom-dialog-box.md) - - [Image Cache](ts-methods-image-cache.md) - - [Media Query](ts-methods-media-query.md) - - [List Selection Dialog Box](ts-methods-action-sheet.md) - -- [Appendix](ts-appendix.md) - - - [Built-in Enums](ts-appendix-enums.md) - diff --git a/en/application-dev/reference/arkui-ts/figures/column.gif b/en/application-dev/reference/arkui-ts/figures/column.gif deleted file mode 100644 index 3213fc124d255584be8f21a3074806c304953e7b..0000000000000000000000000000000000000000 Binary files a/en/application-dev/reference/arkui-ts/figures/column.gif and /dev/null differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001192595194.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001192595194.png deleted file mode 100644 index 348499bc3787a833ab3da5f87500b11c9c93773e..0000000000000000000000000000000000000000 Binary files a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001192595194.png and /dev/null differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001192915178.gif b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001192915178.gif deleted file mode 100644 index b1808e80a0e4d055d54b886ecca3ddc8efa64b9a..0000000000000000000000000000000000000000 Binary files a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001192915178.gif and /dev/null differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001196780640.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001196780640.png deleted file mode 100644 index 857e773f72d0cd7cd9ae13f50aa843a11aae4f97..0000000000000000000000000000000000000000 Binary files a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001196780640.png and /dev/null differ diff --git a/en/application-dev/reference/arkui-ts/figures/border.gif b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001211898466.gif similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/border.gif rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001211898466.gif diff --git a/en/application-dev/reference/arkui-ts/figures/appear.gif b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001211898468.gif similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/appear.gif rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001211898468.gif diff --git a/en/application-dev/reference/arkui-ts/figures/imageanimator.gif b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001211898470.gif similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/imageanimator.gif rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001211898470.gif diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193322910.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001211898472.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193322910.png rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001211898472.png diff --git a/en/application-dev/reference/arkui-ts/figures/swiper.gif b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001211898474.gif similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/swiper.gif rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001211898474.gif diff --git a/en/application-dev/reference/arkui-ts/figures/datapanel.jpg b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001211898476.jpg similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/datapanel.jpg rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001211898476.jpg diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193642848.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001211898480.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193642848.png rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001211898480.png diff --git a/en/application-dev/reference/arkui-ts/figures/11111-5.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001211898482.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/11111-5.png rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001211898482.png diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001239925031.gif b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001211898484.gif similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/en-us_image_0000001239925031.gif rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001211898484.gif diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001211898486.gif b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001211898486.gif new file mode 100644 index 0000000000000000000000000000000000000000..ccfd08401bceb09625add910f66bea401bcaf173 Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001211898486.gif differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001192595238.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001211898488.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/en-us_image_0000001192595238.png rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001211898488.png diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001238401029.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001211898490.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/en-us_image_0000001238401029.png rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001211898490.png diff --git a/en/application-dev/reference/arkui-ts/figures/slider.gif b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001211898492.gif similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/slider.gif rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001211898492.gif diff --git a/en/application-dev/reference/arkui-ts/figures/sharedtransition.gif b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001211898494.gif similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/sharedtransition.gif rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001211898494.gif diff --git a/en/application-dev/reference/arkui-ts/figures/en_image_0000001174582862.gif b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001211898496.gif similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/en_image_0000001174582862.gif rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001211898496.gif diff --git a/en/application-dev/reference/arkui-ts/figures/transition.gif b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001211898498.gif similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/transition.gif rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001211898498.gif diff --git a/en/application-dev/reference/arkui-ts/figures/flex02.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001211898500.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/flex02.png rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001211898500.png diff --git a/en/application-dev/reference/arkui-ts/figures/back.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001211898502.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/back.png rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001211898502.png diff --git a/en/application-dev/reference/arkui-ts/figures/1.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001211898504.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/1.png rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001211898504.png diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237715165.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001211898506.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237715165.png rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001211898506.png diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193075164.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001211898508.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193075164.png rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001211898508.png diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193322850.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001211898510.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193322850.png rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001211898510.png diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001211898512.gif b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001211898512.gif new file mode 100644 index 0000000000000000000000000000000000000000..18bc8e9fbfba12c94b617b372b9c85d92c00088a Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001211898512.gif differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001192755182.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001211898514.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/en-us_image_0000001192755182.png rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001211898514.png diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001192755178.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001211898516.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/en-us_image_0000001192755178.png rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001211898516.png diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237715159.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001211898518.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237715159.png rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001211898518.png diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001192595216.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001211898520.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/en-us_image_0000001192595216.png rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001211898520.png diff --git a/en/application-dev/reference/arkui-ts/figures/toggle.gif b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001211898522.gif similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/toggle.gif rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001211898522.gif diff --git a/en/application-dev/reference/arkui-ts/figures/5.gif b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212058456.gif similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/5.gif rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212058456.gif diff --git a/en/application-dev/reference/arkui-ts/figures/popup.gif b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212058458.gif similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/popup.gif rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212058458.gif diff --git a/en/application-dev/reference/arkui-ts/figures/pagetransition2.gif b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212058460.gif similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/pagetransition2.gif rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212058460.gif diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193075180.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212058462.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193075180.png rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212058462.png diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212058464.gif b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212058464.gif new file mode 100644 index 0000000000000000000000000000000000000000..f0962619f5df0fec543cd693195045c9203378d9 Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212058464.gif differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001192915154.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212058466.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/en-us_image_0000001192915154.png rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212058466.png diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212058468.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212058468.png new file mode 100644 index 0000000000000000000000000000000000000000..b15b9d83968672a6771322069b47394cfb3b8c1f Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212058468.png differ diff --git a/en/application-dev/reference/arkui-ts/figures/customdialog.gif b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212058470.gif similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/customdialog.gif rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212058470.gif diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001194911566.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212058472.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/en-us_image_0000001194911566.png rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212058472.png diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001194605518.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212058474.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/en-us_image_0000001194605518.png rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212058474.png diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212058476.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212058476.png new file mode 100644 index 0000000000000000000000000000000000000000..77113dac339f335dc44b3fb4a271e92f7c8cbb00 Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212058476.png differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001238556395.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212058478.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/en-us_image_0000001238556395.png rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212058478.png diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237555181.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212058480.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237555181.png rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212058480.png diff --git a/en/application-dev/reference/arkui-ts/figures/rowsplit.gif b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212058482.gif similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/rowsplit.gif rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212058482.gif diff --git a/en/application-dev/reference/arkui-ts/figures/duande.gif b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212058484.gif similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/duande.gif rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212058484.gif diff --git a/en/application-dev/reference/arkui-ts/figures/navigator.gif b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212058486.gif similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/navigator.gif rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212058486.gif diff --git a/en/application-dev/reference/arkui-ts/figures/ellipse.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212058488.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/ellipse.png rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212058488.png diff --git a/en/application-dev/reference/arkui-ts/figures/gesturegroup.gif b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212058490.gif similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/gesturegroup.gif rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212058490.gif diff --git a/en/application-dev/reference/arkui-ts/figures/path.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212058492.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/path.png rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212058492.png diff --git a/en/application-dev/reference/arkui-ts/figures/s3.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212058494.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/s3.png rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212058494.png diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193075134.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212058496.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193075134.png rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212058496.png diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001192595228.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212058498.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/en-us_image_0000001192595228.png rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212058498.png diff --git a/en/application-dev/reference/arkui-ts/figures/11111.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212058500.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/11111.png rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212058500.png diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237555155.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212058502.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237555155.png rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212058502.png diff --git a/en/application-dev/reference/arkui-ts/figures/displaypriorityexample.gif b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212058504.gif similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/displaypriorityexample.gif rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212058504.gif diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001238282827.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212058506.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/en-us_image_0000001238282827.png rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212058506.png diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001201475612.gif b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212058508.gif similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/en-us_image_0000001201475612.gif rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212058508.gif diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001192755172.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212058510.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/en-us_image_0000001192755172.png rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212058510.png diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237555151.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212058512.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237555151.png rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212058512.png diff --git a/en/application-dev/reference/arkui-ts/figures/enabled.gif b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212218428.gif similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/enabled.gif rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212218428.gif diff --git a/en/application-dev/reference/arkui-ts/figures/tabs.gif b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212218430.gif similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/tabs.gif rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212218430.gif diff --git a/en/application-dev/reference/arkui-ts/figures/polyline.gif b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212218432.gif similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/polyline.gif rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212218432.gif diff --git a/en/application-dev/reference/arkui-ts/figures/grid-3.gif b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212218434.gif similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/grid-3.gif rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212218434.gif diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193075168.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212218436.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193075168.png rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212218436.png diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193802788.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212218438.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193802788.png rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212218438.png diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193737314.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212218440.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193737314.png rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212218440.png diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237355133.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212218442.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237355133.png rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212218442.png diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001238402777.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212218444.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/en-us_image_0000001238402777.png rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212218444.png diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237355135.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212218446.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237355135.png rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212218446.png diff --git a/en/application-dev/reference/arkui-ts/figures/2222.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212218448.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/2222.png rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212218448.png diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212218450.gif b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212218450.gif new file mode 100644 index 0000000000000000000000000000000000000000..a5092180309ecb061248cc205e4bd667eb290085 Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212218450.gif differ diff --git a/en/application-dev/reference/arkui-ts/figures/clip.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212218452.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/clip.png rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212218452.png diff --git a/en/application-dev/reference/arkui-ts/figures/rect.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212218454.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/rect.png rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212218454.png diff --git a/en/application-dev/reference/arkui-ts/figures/position.gif b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212218456.gif similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/position.gif rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212218456.gif diff --git a/en/application-dev/reference/arkui-ts/figures/polygon.gif b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212218458.gif similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/polygon.gif rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212218458.gif diff --git a/en/application-dev/reference/arkui-ts/figures/flex03.gif b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212218462.gif similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/flex03.gif rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212218462.gif diff --git a/en/application-dev/reference/arkui-ts/figures/222.gif b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212218464.gif similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/222.gif rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212218464.gif diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193756416.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212218466.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193756416.png rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212218466.png diff --git a/en/application-dev/reference/arkui-ts/figures/gif1.gif b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212218468.gif similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/gif1.gif rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212218468.gif diff --git a/en/application-dev/reference/arkui-ts/figures/badge.gif b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212218470.gif similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/badge.gif rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212218470.gif diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193075178.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212218472.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193075178.png rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212218472.png diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237355137.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212218474.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237355137.png rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212218474.png diff --git a/en/application-dev/reference/arkui-ts/figures/landscape-display.gif b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212218476.gif similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/landscape-display.gif rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212218476.gif diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001238281069.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212218478.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/en-us_image_0000001238281069.png rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212218478.png diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001192755188.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212218480.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/en-us_image_0000001192755188.png rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212218480.png diff --git a/en/application-dev/reference/arkui-ts/figures/unnaming-(4).png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212218482.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/unnaming-(4).png rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212218482.png diff --git a/en/application-dev/reference/arkui-ts/figures/colorgradient.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212218484.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/colorgradient.png rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212218484.png diff --git a/en/application-dev/reference/arkui-ts/figures/alphabetindexer.gif b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212378392.gif similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/alphabetindexer.gif rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212378392.gif diff --git a/en/application-dev/reference/arkui-ts/figures/flex.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212378394.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/flex.png rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212378394.png diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193075170.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212378396.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193075170.png rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212378396.png diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001238522733.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212378398.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/en-us_image_0000001238522733.png rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212378398.png diff --git a/en/application-dev/reference/arkui-ts/figures/stack.jpg b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212378400.jpg similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/stack.jpg rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212378400.jpg diff --git a/en/application-dev/reference/arkui-ts/figures/textinput1.gif b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212378402.gif similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/textinput1.gif rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212378402.gif diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001192595226.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212378404.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/en-us_image_0000001192595226.png rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212378404.png diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001192595232.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212378406.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/en-us_image_0000001192595232.png rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212378406.png diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001192755194.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212378408.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/en-us_image_0000001192755194.png rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212378408.png diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237475139.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212378410.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237475139.png rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212378410.png diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001192915130.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212378412.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/en-us_image_0000001192915130.png rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212378412.png diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193481094.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212378414.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193481094.png rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212378414.png diff --git a/en/application-dev/reference/arkui-ts/figures/device-width-type-lg.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212378416.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/device-width-type-lg.png rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212378416.png diff --git a/en/application-dev/reference/arkui-ts/figures/blank2.gif b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212378418.gif similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/blank2.gif rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212378418.gif diff --git a/en/application-dev/reference/arkui-ts/figures/motion.gif b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212378420.gif similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/motion.gif rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212378420.gif diff --git a/en/application-dev/reference/arkui-ts/figures/columnsplit.gif b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212378422.gif similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/columnsplit.gif rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212378422.gif diff --git a/en/application-dev/reference/arkui-ts/figures/counter.gif b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212378424.gif similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/counter.gif rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212378424.gif diff --git a/en/application-dev/reference/arkui-ts/figures/flex04-2.gif b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212378426.gif similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/flex04-2.gif rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212378426.gif diff --git a/en/application-dev/reference/arkui-ts/figures/q1.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212378428.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/q1.png rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212378428.png diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193801070.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212378430.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193801070.png rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212378430.png diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212378432.gif b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212378432.gif new file mode 100644 index 0000000000000000000000000000000000000000..b0667769e77a2a2d1b131736bdce96489b7e064e Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212378432.gif differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001192915162.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212378434.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/en-us_image_0000001192915162.png rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212378434.png diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001192755180.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212378436.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/en-us_image_0000001192755180.png rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212378436.png diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001192595230.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212378438.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/en-us_image_0000001192595230.png rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212378438.png diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237555163.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212378440.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237555163.png rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212378440.png diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237715153.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212378442.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237715153.png rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212378442.png diff --git a/en/application-dev/reference/arkui-ts/figures/attranimation.gif b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212378444.gif similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/attranimation.gif rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212378444.gif diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001192595214.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212378446.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/en-us_image_0000001192595214.png rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001212378446.png diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237355087.gif b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237355087.gif deleted file mode 100644 index 38502c83c52aa9229da69d638e4b9b1f5a35009b..0000000000000000000000000000000000000000 Binary files a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237355087.gif and /dev/null differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237475107.gif b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237475107.gif deleted file mode 100644 index b3966d0abb39044241ee174a126fcf919f402d98..0000000000000000000000000000000000000000 Binary files a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237475107.gif and /dev/null differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237555149.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001256858381.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237555149.png rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001256858381.png diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001256858383.gif b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001256858383.gif new file mode 100644 index 0000000000000000000000000000000000000000..b8a7961adce1b592b8fdbce98966c70cf1da68e8 Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001256858383.gif differ diff --git a/en/application-dev/reference/arkui-ts/figures/opacity.gif b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001256858385.gif similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/opacity.gif rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001256858385.gif diff --git a/en/application-dev/reference/arkui-ts/figures/line.jpg b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001256858387.jpg similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/line.jpg rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001256858387.jpg diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193075166.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001256858389.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193075166.png rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001256858389.png diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237715151.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001256858391.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237715151.png rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001256858391.png diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193801072.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001256858393.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193801072.png rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001256858393.png diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001238521021.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001256858395.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/en-us_image_0000001238521021.png rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001256858395.png diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001194942468.gif b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001256858397.gif similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/en-us_image_0000001194942468.gif rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001256858397.gif diff --git a/en/application-dev/reference/arkui-ts/figures/textarea1.gif b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001256858399.gif similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/textarea1.gif rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001256858399.gif diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001256858401.gif b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001256858401.gif new file mode 100644 index 0000000000000000000000000000000000000000..587325d41b6320ff8e25afd9d2b19e3d1b5a11d5 Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001256858401.gif differ diff --git a/en/application-dev/reference/arkui-ts/figures/rotationgesture.gif b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001256858403.gif similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/rotationgesture.gif rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001256858403.gif diff --git a/en/application-dev/reference/arkui-ts/figures/device-width-type-sm.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001256858405.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/device-width-type-sm.png rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001256858405.png diff --git a/en/application-dev/reference/arkui-ts/figures/blank1.gif b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001256858407.gif similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/blank1.gif rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001256858407.gif diff --git a/en/application-dev/reference/arkui-ts/figures/position2.gif b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001256858409.gif similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/position2.gif rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001256858409.gif diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001256858411.gif b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001256858411.gif new file mode 100644 index 0000000000000000000000000000000000000000..7b839683df88c833812ce75bd656abd22dae950f Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001256858411.gif differ diff --git a/en/application-dev/reference/arkui-ts/figures/flex05.gif b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001256858413.gif similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/flex05.gif rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001256858413.gif diff --git a/en/application-dev/reference/arkui-ts/figures/qrcode.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001256858415.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/qrcode.png rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001256858415.png diff --git a/en/application-dev/reference/arkui-ts/figures/tapgesture.gif b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001256858417.gif similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/tapgesture.gif rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001256858417.gif diff --git a/en/application-dev/reference/arkui-ts/figures/s1.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001256858419.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/s1.png rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001256858419.png diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193321138.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001256858421.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193321138.png rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001256858421.png diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193481096.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001256858423.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193481096.png rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001256858423.png diff --git a/en/application-dev/reference/arkui-ts/figures/grid.gif b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001256858425.gif similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/grid.gif rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001256858425.gif diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193642802.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001256858427.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193642802.png rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001256858427.png diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237715141.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001256858429.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237715141.png rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001256858429.png diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193075172.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001256858431.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193075172.png rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001256858431.png diff --git a/en/application-dev/reference/arkui-ts/figures/griditem.gif b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001256858433.gif similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/griditem.gif rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001256858433.gif diff --git a/en/application-dev/reference/arkui-ts/figures/unnaming-(3).png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001256858435.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/unnaming-(3).png rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001256858435.png diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193075122.gif b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001256978331.gif similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193075122.gif rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001256978331.gif diff --git a/en/application-dev/reference/arkui-ts/figures/textstyle.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001256978333.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/textstyle.png rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001256978333.png diff --git a/en/application-dev/reference/arkui-ts/figures/pagetransition1.gif b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001256978335.gif similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/pagetransition1.gif rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001256978335.gif diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237355131.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001256978339.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237355131.png rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001256978339.png diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237715155.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001256978341.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237715155.png rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001256978341.png diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193802836.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001256978343.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193802836.png rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001256978343.png diff --git a/en/application-dev/reference/arkui-ts/figures/animateto.gif b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001256978345.gif similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/animateto.gif rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001256978345.gif diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001192595224.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001256978347.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/en-us_image_0000001192595224.png rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001256978347.png diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237715149.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001256978349.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237715149.png rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001256978349.png diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001192595234.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001256978351.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/en-us_image_0000001192595234.png rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001256978351.png diff --git a/en/application-dev/reference/arkui-ts/figures/circle.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001256978353.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/circle.png rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001256978353.png diff --git a/en/application-dev/reference/arkui-ts/figures/lottie-ark-2-0-canvas-ui-animate.gif b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001256978355.gif similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/lottie-ark-2-0-canvas-ui-animate.gif rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001256978355.gif diff --git a/en/application-dev/reference/arkui-ts/figures/list.gif b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001256978357.gif similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/list.gif rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001256978357.gif diff --git a/en/application-dev/reference/arkui-ts/figures/66666.gif b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001256978359.gif similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/66666.gif rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001256978359.gif diff --git a/en/application-dev/reference/arkui-ts/figures/en_image_0000001186807708.gif b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001256978361.gif similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/en_image_0000001186807708.gif rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001256978361.gif diff --git a/en/application-dev/reference/arkui-ts/figures/scroll.gif b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001256978363.gif similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/scroll.gif rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001256978363.gif diff --git a/en/application-dev/reference/arkui-ts/figures/flex01.gif b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001256978365.gif similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/flex01.gif rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001256978365.gif diff --git a/en/application-dev/reference/arkui-ts/figures/s4-(1).png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001256978367.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/s4-(1).png rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001256978367.png diff --git a/en/application-dev/reference/arkui-ts/figures/f.gif b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001256978369.gif similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/f.gif rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001256978369.gif diff --git a/en/application-dev/reference/arkui-ts/figures/pangesture.gif b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001256978371.gif similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/pangesture.gif rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001256978371.gif diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193481098.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001256978373.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193481098.png rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001256978373.png diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193322872.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001256978375.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193322872.png rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001256978375.png diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001192915180.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001256978377.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/en-us_image_0000001192915180.png rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001256978377.png diff --git a/en/application-dev/reference/arkui-ts/figures/portrait-display.gif b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001256978379.gif similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/portrait-display.gif rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001256978379.gif diff --git a/en/application-dev/reference/arkui-ts/figures/panel.gif b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001256978381.gif similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/panel.gif rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001256978381.gif diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001192915184.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001256978383.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/en-us_image_0000001192915184.png rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001256978383.png diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001192755174.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001256978385.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/en-us_image_0000001192755174.png rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001256978385.png diff --git a/en/application-dev/reference/arkui-ts/figures/alertdialog.gif b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001256978387.gif similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/alertdialog.gif rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001256978387.gif diff --git a/en/application-dev/reference/arkui-ts/figures/text2.gif b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001257058391.gif similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/text2.gif rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001257058391.gif diff --git a/en/application-dev/reference/arkui-ts/figures/2-01.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001257058393.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/2-01.png rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001257058393.png diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237555173.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001257058395.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237555173.png rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001257058395.png diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193641084.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001257058397.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193641084.png rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001257058397.png diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237555165.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001257058399.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237555165.png rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001257058399.png diff --git a/en/application-dev/reference/arkui-ts/figures/1111.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001257058401.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/1111.png rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001257058401.png diff --git a/en/application-dev/reference/arkui-ts/figures/gif4.gif b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001257058403.gif similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/gif4.gif rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001257058403.gif diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237555179.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001257058405.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237555179.png rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001257058405.png diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001257058407.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001257058407.png new file mode 100644 index 0000000000000000000000000000000000000000..f2deeb8445fe0f3b66d2b0facbf9e0f0ed9911ca Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001257058407.png differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193482814.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001257058409.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193482814.png rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001257058409.png diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001192595220.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001257058411.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/en-us_image_0000001192595220.png rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001257058411.png diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237555167.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001257058413.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237555167.png rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001257058413.png diff --git a/en/application-dev/reference/arkui-ts/figures/device-width-type-md.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001257058415.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/device-width-type-md.png rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001257058415.png diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001257058417.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001257058417.png new file mode 100644 index 0000000000000000000000000000000000000000..999ad44c80a018d45353044e13923a8566bf3cf0 Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001257058417.png differ diff --git a/en/application-dev/reference/arkui-ts/figures/pinchgesture.gif b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001257058419.gif similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/pinchgesture.gif rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001257058419.gif diff --git a/en/application-dev/reference/arkui-ts/figures/visibility.gif b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001257058421.gif similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/visibility.gif rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001257058421.gif diff --git a/en/application-dev/reference/arkui-ts/figures/rating.gif b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001257058423.gif similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/rating.gif rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001257058423.gif diff --git a/en/application-dev/reference/arkui-ts/figures/longpressgesture.gif b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001257058425.gif similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/longpressgesture.gif rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001257058425.gif diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001238602821.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001257058427.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/en-us_image_0000001238602821.png rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001257058427.png diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001238282783.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001257058429.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/en-us_image_0000001238282783.png rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001257058429.png diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193321136.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001257058431.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193321136.png rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001257058431.png diff --git a/en/application-dev/reference/arkui-ts/figures/keyevent.gif b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001257058433.gif similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/keyevent.gif rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001257058433.gif diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001238601051.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001257058435.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/en-us_image_0000001238601051.png rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001257058435.png diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001238537297.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001257058437.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/en-us_image_0000001238537297.png rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001257058437.png diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001238402745.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001257058439.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/en-us_image_0000001238402745.png rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001257058439.png diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001238401031.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001257058441.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/en-us_image_0000001238401031.png rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001257058441.png diff --git a/en/application-dev/reference/arkui-ts/figures/zindex.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001257058443.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/zindex.png rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001257058443.png diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001192915158.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001257058445.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/en-us_image_0000001192915158.png rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001257058445.png diff --git a/en/application-dev/reference/arkui-ts/figures/text1.gif b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001257138337.gif similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/text1.gif rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001257138337.gif diff --git a/en/application-dev/reference/arkui-ts/figures/listitem.gif b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001257138339.gif similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/listitem.gif rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001257138339.gif diff --git a/en/application-dev/reference/arkui-ts/figures/button.gif b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001257138341.gif similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/button.gif rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001257138341.gif diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001238476361.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001257138343.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/en-us_image_0000001238476361.png rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001257138343.png diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001257138345.gif b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001257138345.gif new file mode 100644 index 0000000000000000000000000000000000000000..32d2334360f9fd90afd1709f50a39add4e2196c1 Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001257138345.gif differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193641086.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001257138347.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193641086.png rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001257138347.png diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001238281067.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001257138349.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/en-us_image_0000001238281067.png rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001257138349.png diff --git a/en/application-dev/reference/arkui-ts/figures/gif2.gif b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001257138351.gif similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/gif2.gif rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001257138351.gif diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001238522783.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001257138353.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/en-us_image_0000001238522783.png rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001257138353.png diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001257138355.gif b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001257138355.gif new file mode 100644 index 0000000000000000000000000000000000000000..c269eab06d9dd52463481510edc7089be19cb2b6 Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001257138355.gif differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237475137.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001257138357.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237475137.png rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001257138357.png diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001238457271.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001257138359.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/en-us_image_0000001238457271.png rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001257138359.png diff --git a/en/application-dev/reference/arkui-ts/figures/span.gif b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001257138363.gif similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/span.gif rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001257138363.gif diff --git a/en/application-dev/reference/arkui-ts/figures/gif-0.gif b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001257138365.gif similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/gif-0.gif rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001257138365.gif diff --git a/en/application-dev/reference/arkui-ts/figures/size.gif b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001257138367.gif similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/size.gif rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001257138367.gif diff --git a/en/application-dev/reference/arkui-ts/figures/mediaquery.gif b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001257138369.gif similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/mediaquery.gif rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001257138369.gif diff --git a/en/application-dev/reference/arkui-ts/figures/flex04.jpg b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001257138371.jpg similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/flex04.jpg rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001257138371.jpg diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193436448.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001257138373.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193436448.png rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001257138373.png diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237475123.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001257138375.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237475123.png rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001257138375.png diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001238602771.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001257138377.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/en-us_image_0000001238602771.png rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001257138377.png diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193482866.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001257138379.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193482866.png rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001257138379.png diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001238601053.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001257138381.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/en-us_image_0000001238601053.png rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001257138381.png diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001238521019.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001257138383.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/en-us_image_0000001238521019.png rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001257138383.png diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237355121.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001257138385.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237355121.png rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001257138385.png diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237475133.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001257138387.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237475133.png rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001257138387.png diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237475113.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001257138389.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237475113.png rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001257138389.png diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193075154.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001257138391.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193075154.png rename to en/application-dev/reference/arkui-ts/figures/en-us_image_0000001257138391.png diff --git a/en/application-dev/reference/arkui-ts/figures/gif-4.gif b/en/application-dev/reference/arkui-ts/figures/gif-4.gif deleted file mode 100644 index 5bcc79b53b227b6bd0484045d20743d9686c8e08..0000000000000000000000000000000000000000 Binary files a/en/application-dev/reference/arkui-ts/figures/gif-4.gif and /dev/null differ diff --git a/en/application-dev/reference/arkui-ts/figures/gif.gif b/en/application-dev/reference/arkui-ts/figures/gif.gif deleted file mode 100644 index 8eceb3bf5313485a1fedda5768e70cdb5febc464..0000000000000000000000000000000000000000 Binary files a/en/application-dev/reference/arkui-ts/figures/gif.gif and /dev/null differ diff --git a/en/application-dev/reference/arkui-ts/figures/loadingProgress.png b/en/application-dev/reference/arkui-ts/figures/loadingProgress.png deleted file mode 100644 index afc52b1a469c858e3029282e193b684114803db0..0000000000000000000000000000000000000000 Binary files a/en/application-dev/reference/arkui-ts/figures/loadingProgress.png and /dev/null differ diff --git a/en/application-dev/reference/arkui-ts/figures/progress.png b/en/application-dev/reference/arkui-ts/figures/progress.png deleted file mode 100644 index 0ff7595bc619e62c05376cd7b57a473dde3e9386..0000000000000000000000000000000000000000 Binary files a/en/application-dev/reference/arkui-ts/figures/progress.png and /dev/null differ diff --git a/en/application-dev/reference/arkui-ts/ts-animation.md b/en/application-dev/reference/arkui-ts/ts-animation.md index b5406cb67c82d3843280685dfc33bde75a76d689..3334eabe046e1539342decebfc232028fcf4a31b 100644 --- a/en/application-dev/reference/arkui-ts/ts-animation.md +++ b/en/application-dev/reference/arkui-ts/ts-animation.md @@ -1,15 +1,15 @@ -# Animation +# Animation -- **[Attribute Animation](ts-animatorproperty.md)** -- **[Explicit Animation](ts-explicit-animation.md)** -- **[Transition Animation](ts-transition-animation.md)** +- **[AnimatorProperty](ts-animatorproperty.md)** -- **[Motion Path Animation](ts-motion-path-animation.md)** +- **[Explicit Animation](ts-explicit-animation.md)** -- **[Matrix Transformation](ts-matrix-transformation.md)** +- **[Transition Animation](ts-transition-animation.md)** -- **[Interpolation Calculation](ts-interpolation-calculation.md)** +- **[Motion Path Animation](ts-motion-path-animation.md)** +- **[Matrix Transformation](ts-matrix-transformation.md)** +- **[Interpolation Calculation](ts-interpolation-calculation.md)** \ No newline at end of file diff --git a/en/application-dev/reference/arkui-ts/ts-animatorproperty.md b/en/application-dev/reference/arkui-ts/ts-animatorproperty.md index 1e78fb758a57f820506df5029e8e3283108e602c..f7073f5ef9a06093ff96768acf5c99585fbca0fe 100644 --- a/en/application-dev/reference/arkui-ts/ts-animatorproperty.md +++ b/en/application-dev/reference/arkui-ts/ts-animatorproperty.md @@ -1,148 +1,42 @@ -# Attribute Animation +# AnimatorProperty ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->This gesture is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -When the universal attributes of a component change, you can create an **AnimatorProperty** for gradient to improve user experience. +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** +> This animation is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Default Value

-

Description

-

duration

-

number

-

1000

-

Animation duration, in ms. The default duration is 1000 ms.

-

curve

-

Curve

-

Linear

-

The default curve is linear. For details about the valid values, see Curve enums.

-

delay

-

number

-

0

-

Delay of animation playback, in ms. By default, the playback is not delayed.

-

iterations

-

number

-

1

-

Number of times that the animation is played. By default, the animation is played once. The value -1 indicates that the animation is played for an unlimited number of times.

-

playMode

-

PlayMode

-

Normal

-

Playback mode. By default, the animation is played from the beginning after the playback is complete.

-
-- Curve enums +When the universal attributes of a component change, you can create an **AnimatorProperty** for gradient to improve user experience. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Description

-

Linear

-

The animation speed keeps unchanged.

-

Ease

-

The animation starts at a low speed and then accelerates. It slows down before the animation ends. The cubic-bezier curve (0.25, 0.1, 0.25, 1.0) is used.

-

EaseIn

-

The animation starts at a low speed. The cubic-bezier curve (0.42, 0.0, 1.0, 1.0) is used.

-

EaseOut

-

The animation ends at a low speed. The cubic-bezier curve (0.0, 0.0, 0.58, 1.0) is used.

-

EaseInOut

-

The animation starts and ends at a low speed. The cubic-bezier curve (0.42, 0.0, 0.58, 1.0) is used.

-

FastOutSlowIn

-

The animation uses the standard cubic-bezier curve (0.4, 0.0, 0.2, 1.0).

-

LinearOutSlowIn

-

The animation uses the deceleration cubic-bezier curve (0.0, 0.0, 0.2, 1.0).

-

FastOutLinearIn

-

The animation uses the acceleration cubic-bezier curve (0.4, 0.0, 1.0, 1.0).

-

ExtremeDeceleration

-

The animation uses the extreme deceleration cubic-bezier curve (0.0, 0.0, 0.0, 1.0).

-

Sharp

-

The animation uses the sharp cubic-bezier curve (0.33, 0.0, 0.67, 1.0).

-

Rhythm

-

The animation uses the rhythm cubic-bezier curve (0.7, 0.0, 0.2, 1.0).

-

Smooth

-

The animation uses the smooth cubic-bezier curve (0.4, 0.0, 0.4, 1.0).

-

Friction

-

Damping curve. The cubic-bezier curve (0.2, 0.0, 0.2, 1.0) is used.

-
+| Name | Type | Default Value | Description | +| -------- | -------- | -------- | -------- | +| duration | number | 1000 | Animation duration, in ms. The default duration is 1000 ms. | +| curve | Curve | Curve.Linear | Animation curve. The default curve is linear. | +| delay | number | 0 | Delay of animation playback, in ms. By default, the playback is not delayed. | +| iterations | number | 1 | Number of times that the animation is played. By default, the animation is played once. The value **-1** indicates that the animation is played for an unlimited number of times. | +| playMode | [PlayMode](ts-appendix-enums.md#playmode-enums) | PlayMode.Normal | Playback mode. By default, the animation is played from the beginning after the playback is complete. | + + +- Curve enums + | Name | Description | + | -------- | -------- | + | Linear | The animation speed keeps unchanged. | + | Ease | The animation starts at a low speed and then accelerates. It slows down before the animation ends. The cubic-bezier curve (0.25, 0.1, 0.25, 1.0) is used. | + | EaseIn | The animation starts at a low speed. The cubic-bezier curve (0.42, 0.0, 1.0, 1.0) is used. | + | EaseOut | The animation ends at a low speed. The cubic-bezier curve (0.0, 0.0, 0.58, 1.0) is used. | + | EaseInOut | The animation starts and ends at a low speed. The cubic-bezier curve (0.42, 0.0, 0.58, 1.0) is used. | + | FastOutSlowIn | The animation uses the standard cubic-bezier curve (0.4, 0.0, 0.2, 1.0). | + | LinearOutSlowIn | The animation uses the deceleration cubic-bezier curve (0.0, 0.0, 0.2, 1.0). | + | FastOutLinearIn | The animation uses the acceleration cubic-bezier curve (0.4, 0.0, 1.0, 1.0). | + | ExtremeDeceleration | The animation uses the extreme deceleration cubic-bezier curve (0.0, 0.0, 0.0, 1.0). | + | Sharp | The animation uses the sharp cubic-bezier curve (0.33, 0.0, 0.67, 1.0). | + | Rhythm | The animation uses the rhythm cubic-bezier curve (0.7, 0.0, 0.2, 1.0). | + | Smooth | The animation uses the smooth cubic-bezier curve (0.4, 0.0, 0.4, 1.0). | + | Friction | Damping curve. The cubic-bezier curve (0.2, 0.0, 0.2, 1.0) is used. | + + +## Example -## Example ``` @Entry @@ -178,5 +72,4 @@ struct AttrAnimationExample { } ``` -![](figures/attranimation.gif) - +![en-us_image_0000001212378444](figures/en-us_image_0000001212378444.gif) diff --git a/en/application-dev/reference/arkui-ts/ts-appendix-enums.md b/en/application-dev/reference/arkui-ts/ts-appendix-enums.md index 0947abd4085bdedcb912f38a114c22cfacc492c1..b45cb8914b740ede872e18625116671f13449994 100644 --- a/en/application-dev/reference/arkui-ts/ts-appendix-enums.md +++ b/en/application-dev/reference/arkui-ts/ts-appendix-enums.md @@ -1,300 +1,103 @@ -# Built-in Enums +# Built-in Enums -## Alignment Enums - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Description

-

TopStart

-

Top start.

-

Top

-

Horizontally centered on the top.

-

TopEnd

-

Top end.

-

Start

-

Vertically centered start.

-

Center

-

Horizontally and vertically centered.

-

End

-

Vertically centered end.

-

BottomStart

-

Bottom start.

-

Bottom

-

Horizontally centered on the bottom.

-

BottomEnd

-

Bottom end.

-
+## Alignment Enums -## Axis enums + | Name | Description | +| -------- | -------- | +| TopStart | Top start. | +| Top | Horizontally centered on the top. | +| TopEnd | Top end. | +| Start | Vertically centered start. | +| Center | Horizontally and vertically centered. | +| End | Vertically centered end. | +| BottomStart | Bottom start. | +| Bottom | Horizontally centered on the bottom. | +| BottomEnd | Bottom end. | - - - - - - - - - - - - -

Name

-

Description

-

Vertical

-

Vertical direction.

-

Horizontal

-

Horizontal direction.

-
-## ItemAlign Enums +## Axis Enums - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Description

-

Auto

-

The default configuration in the Flex container is used.

-

Start

-

The elements are in the Flex container, top-aligned in the cross-axis direction

-

Center

-

The elements are in the Flex container, centered in the cross-axis direction.

-

End

-

The elements are in the Flex container, bottom-aligned in the cross-axis direction.

-

Stretch

-

The elements are in the Flex container, stretched and padded in the cross-axis direction. If the size is not set, the elements are stretched to the container size.

-

Baseline

-

The elements are in the Flex container, text baseline aligned in the cross-axis direction.

-
+ | Name | Description | +| -------- | -------- | +| Vertical | Vertical direction. | +| Horizontal | Horizontal direction. | -## LineCapStyle Enums - - - - - - - - - - - - - - - -

Name

-

Description

-

Butt

-

The ends of dividing lines are square.

-

Round

-

The ends of dividing lines are rounded.

-

Square

-

The ends of dividing lines are square.

-
+## ItemAlign Enums -## PlayMode Enums + | Name | Description | +| -------- | -------- | +| Auto | The default configuration in the Flex container is used. | +| Start | The elements are in the Flex container, top-aligned in the cross-axis direction | +| Center | The elements are in the Flex container, centered in the cross-axis direction. | +| End | The elements are in the Flex container, bottom-aligned in the cross-axis direction. | +| Stretch | The elements are in the Flex container, stretched and padded in the cross-axis direction. If the size is not set, the elements are stretched to the container size. | +| Baseline | The elements are in the Flex container, text baseline aligned in the cross-axis direction. | - - - - - - - - - - - - - - - - - - -

Name

-

Description

-

Normal

-

The animation is played normally.

-

Reverse

-

The animation is played reversely.

-

Alternate

-

The animation is played normally for an odd number of times (1, 3, 5...) and reversely for an even number of times (2, 4, 6...).

-

AlternateReverse

-

The animation is played reversely for an odd number of times (1, 3, 5...) and normally for an even number of times (2, 4, 6...).

-
-## ImageRepeat Enums +## LineCapStyle Enums - - - - - - - - - - - - - - - - - - -

Name

-

Description

-

X

-

Images are repeatedly drawn only on the horizontal axis.

-

Y

-

Images are repeatedly drawn only on the vertical axis.

-

XY

-

Images are repeatedly drawn on both axes.

-

NoRepeat

-

Images are not repeatedly drawn.

-
+ | Name | Description | +| -------- | -------- | +| Butt | The ends of dividing lines are square. | +| Round | The ends of dividing lines are rounded. | +| Square | The ends of dividing lines are square. | -## TextDecorationType Enums - - - - - - - - - - - - - - - - - - -

Name

-

Description

-

Underline

-

Line under the text.

-

LineThrough

-

Line through the text.

-

Overline

-

Line over the text.

-

None

-

No decorative lines.

-
+## PlayMode Enums -## TextCase Enums + | Name | Description | +| -------- | -------- | +| Normal | The animation is played normally. | +| Reverse | The animation is played reversely. | +| Alternate | The animation is played normally for an odd number of times (1, 3, 5...) and reversely for an even number of times (2, 4, 6...). | +| AlternateReverse | The animation is played reversely for an odd number of times (1, 3, 5...) and normally for an even number of times (2, 4, 6...). | - - - - - - - - - - - - - - - -

Name

-

Description

-

Normal

-

Normal case.

-

LowerCase

-

All lowercase.

-

UpperCase

-

All uppercase.

-
-## BarState Enums +## ImageRepeat Enums - - - - - - - - - - - - - - - -

Name

-

Description

-

Off

-

Hide.

-

On

-

Display.

-

Auto

-

Display on demand (displays when the screen is touched and disappears after 2s).

-
+ | Name | Description | +| -------- | -------- | +| X | Images are repeatedly drawn only on the horizontal axis. | +| Y | Images are repeatedly drawn only on the vertical axis. | +| XY | Images are repeatedly drawn on both axes. | +| NoRepeat | Images are not repeatedly drawn. | + + +## TextDecorationType Enums + + | Name | Description | +| -------- | -------- | +| Underline | Line under the text. | +| LineThrough | Line through the text. | +| Overline | Line over the text. | +| None | No decorative lines. | + + +## TextCase Enums + + | Name | Description | +| -------- | -------- | +| Normal | Normal case. | +| LowerCase | All lowercase. | +| UpperCase | All uppercase. | + + +## BarState Enums + + | Name | Description | +| -------- | -------- | +| Off | Hide. | +| On | Display. | +| Auto | Display on demand (displays when the screen is touched and disappears after 2s). | + +## LayoutDirection Enums + +| Name | Description | +| ------------- | ------------------------------------------------------------ | +| Row | The child components are arranged in the same direction as the main axis runs along the rows. | +| Column | The child components are arranged in the same direction as the main axis runs down the columns. | +| RowReverse | The child components are arranged opposite to the **Row** direction. | +| ColumnReverse | The child components are arranged opposite to the **Column** direction. | diff --git a/en/application-dev/reference/arkui-ts/ts-appendix.md b/en/application-dev/reference/arkui-ts/ts-appendix.md index 3ba8ba978eabe4cc2cae5d35bcbd82d57ca61141..1c5695fcbd4625299dc554d307cc7993d4603add 100644 --- a/en/application-dev/reference/arkui-ts/ts-appendix.md +++ b/en/application-dev/reference/arkui-ts/ts-appendix.md @@ -1,5 +1,5 @@ -# Appendix +# Appendix -- **[Built-in Enums](ts-appendix-enums.md)** +- **[Built-in Enums](ts-appendix-enums.md)** \ No newline at end of file diff --git a/en/application-dev/reference/arkui-ts/ts-basic-components-blank.md b/en/application-dev/reference/arkui-ts/ts-basic-components-blank.md index d005082951b2e5846084878df9a411a3d1fa021b..12a4e44539e3d688c6a3d867dbf6254c69e05275 100644 --- a/en/application-dev/reference/arkui-ts/ts-basic-components-blank.md +++ b/en/application-dev/reference/arkui-ts/ts-basic-components-blank.md @@ -1,82 +1,46 @@ -# Blank +# Blank ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -The **** component supports automatic filling of the empty part of the container along the main axis. This component is valid only when the parent component is **** or ****. +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** +> This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -## Required Permissions + +The **<Blank>** component supports automatic filling of the empty part of the container along the main axis. This component is valid only when the parent component is **<Row>** or **<Column>**. + + +## Required Permissions None -## Child Components + +## Child Components None -## APIs - -Blank\(min?: Length\) - -- Parameters - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

min

-

Length

-

No

-

0

-

Minimum size of the <Blank> component in the container along the main axis.

-
- - -## Attributes - - - - - - - - - - - - - - -

Name

-

Type

-

Default Value

-

Description

-

color

-

Color

-

0x00000000

-

Color to fill the blank.

-
- ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->- Universal attribute methods are not supported. - -## Example +## APIs + +Blank(min?: Length) + +- Parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | min | Length | No | 0 | Minimum size of the **<Blank>** component in the container along the main axis. | + + +## Attributes + + | Name | Type | Default Value | Description | +| -------- | -------- | -------- | -------- | +| color | Color | 0x00000000 | Color to fill the blank. | + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** +> - Universal attribute methods are not supported. + + +## Example + + ``` @Entry @Component @@ -95,9 +59,8 @@ struct BlankExample { Portrait mode -![](figures/blank1.gif) +![en-us_image_0000001256858407](figures/en-us_image_0000001256858407.gif) Landscape mode -![](figures/blank2.gif) - +![en-us_image_0000001212378418](figures/en-us_image_0000001212378418.gif) diff --git a/en/application-dev/reference/arkui-ts/ts-basic-components-button.md b/en/application-dev/reference/arkui-ts/ts-basic-components-button.md index 8f39a509ef8286766236ff37112df6a4db590729..ef11b28c3564d70642a90d6e4325d872a9b8528d 100644 --- a/en/application-dev/reference/arkui-ts/ts-basic-components-button.md +++ b/en/application-dev/reference/arkui-ts/ts-basic-components-button.md @@ -1,175 +1,67 @@ -# Button +# Button ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -The **** component represents a component that can trigger actions. +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** +> This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -## Required Permissions + +The **<Button>** component represents a component that can trigger actions. + + +## Required Permissions None -## Child Components - -This component can contain a single child component. - -## APIs - -- Button\(options?: \{type?: ButtonType, stateEffect?: boolean\}\) - - **Table 1** **options** parameters - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

type

-

ButtonType

-

No

-

Capsule

-

Button type.

-

stateEffect

-

boolean

-

No

-

true

-

Whether to enable the state switchover effect when a button is pressed. When the state is set to false, the state switchover effect is disabled.

-
- - -- Button\(label?: string, options?: \{ type?: ButtonType, stateEffect?: boolean \}\) - - Creates a button component based on text content. In this case, the **** component cannot contain subcomponents. - - **Table 2** **value** parameters - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

label

-

string

-

No

-

-

-

Button text.

-

options

-

Object

-

No

-

-

-

For details, see the options parameters.

-
- - -## Attributes - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Default Value

-

Description

-

type

-

ButtonType

-

Capsule

-

Button type.

-

stateEffect

-

boolean

-

true

-

Whether to enable the state switchover effect. When the state is set to false, the state switchover effect is disabled.

-
- -- ButtonType enums - - - - - - - - - - - - - - - - -

Name

-

Description

-

Capsule

-

Capsule-type button (the round corner is half of the height by default).

-

Circle

-

Circle button.

-

Normal

-

Normal button (without rounded corners by default).

-
- - ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->- The rounded corner of a button is set by using [**borderRadius**](ts-universal-attributes-border.md). \(The rounded corner cannot be set by using a border API.\) ->- The button text is set using the [common text style](ts-universal-attributes-text-style.md). - -## Example + +## Child Component + +This component can contain child components. + + +## APIs + +- Button(options?: {type?: ButtonType, stateEffect?: boolean}) + **Table1** options parameters + + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | type | ButtonType | No | Capsule | Button type. | + | stateEffect | boolean | No | true | Whether to enable the state switchover effect when a button is pressed. When the state is set to **false**, the state switchover effect is disabled. | + + +- Button(label?: string, options?: { type?: ButtonType, stateEffect?: boolean }) + Creates a button component based on text content. In this case, the **<Button>** component cannot contain subcomponents. + + **Table2** value parameters + + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | label | string | No | - | Button text. | + | options | Object | No | - | For details, see the **options** parameters. | + + +## Attributes + + | Name | Type | Default Value | Description | +| -------- | -------- | -------- | -------- | +| type | ButtonType | Capsule | Button type. | +| stateEffect | boolean | true | Whether to enable the state switchover effect. When the state is set to **false**, the state switchover effect is disabled. | + +- ButtonType enums + | Name | Description | + | -------- | -------- | + | Capsule | Capsule-type button (the round corner is half of the height by default). | + | Circle | Circle button. | + | Normal | Normal button (without rounded corners by default). | + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** +> - The rounded corner of a button is set by using [Border](ts-universal-attributes-border.md). (The rounded corner cannot be set by using a border API.) +> +> - The button text is set using the [common text style](ts-universal-attributes-text-style.md). + + +## Example + ``` @Entry @@ -220,5 +112,4 @@ struct ButtonExample { } ``` -![](figures/button.gif) - +![en-us_image_0000001257138341](figures/en-us_image_0000001257138341.gif) diff --git a/en/application-dev/reference/arkui-ts/ts-basic-components-datapanel.md b/en/application-dev/reference/arkui-ts/ts-basic-components-datapanel.md index 2045636c93f2fba167e4c6c4c84aa699b09efe7f..5369c7767ed5f2ddcfd0b90b055cf72ec3046982 100644 --- a/en/application-dev/reference/arkui-ts/ts-basic-components-datapanel.md +++ b/en/application-dev/reference/arkui-ts/ts-basic-components-datapanel.md @@ -1,96 +1,44 @@ -# DataPanel +# DataPanel -The **** component displays proportions in a chart. -## Required Permissions +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** +> This component is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version. + + +The **<DataPanel>** component displays proportions in a chart. + + +## Required Permissions None -## Child Components + +## Child Components None -## APIs - -DataPanel\(value:\{values: number\[\], max?: number, type?: DataPanelType\}\) - -- Parameters - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

values

-

number[]

-

Yes

-

-

-

Value list. A maximum of nine values are supported.

-

max

-

number

-

No

-

100

-

1. When set to a value greater than 0, this parameter indicates the maximum value in the values list.

-

2. When set to a value equal to or smaller than 0, this parameter indicates the sum of values in the values list. The values are displayed in proportion.

-

type8+

-

DataPanelType

-

No

-

DataPanelType.Circle

-

Type of the data panel.

-
- - -- DataPanelType enums - - - - - - - - - - - - - -

Name

-

Description

-

Line

-

Line data panel.

-

Circle

-

Circle data panel.

-
- - -## Example + +## APIs + +DataPanel(value:{values: number[], max?: number, type?: DataPanelType}) + +- Parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | values | number[] | Yes | - | Value list. A maximum of nine values are supported. | + | max | number | No | 100 | - When set to a value greater than 0, this parameter indicates the maximum value in the **values** list.
- When set to a value equal to or smaller than 0, this parameter indicates the sum of values in the **values** list. The values are displayed in proportion. | + | type8+ | DataPanelType | No | DataPanelType.Circle | Type of the data panel. | + + +- DataPanelType enums + | Name | Description | + | -------- | -------- | + | Line | Line data panel. | + | Circle | Circle data panel. | + + +## Example + ``` @Entry @@ -110,5 +58,4 @@ struct DataPanelExample { } ``` -![](figures/datapanel.jpg) - +![en-us_image_0000001211898476](figures/en-us_image_0000001211898476.jpg) diff --git a/en/application-dev/reference/arkui-ts/ts-basic-components-datepicker.md b/en/application-dev/reference/arkui-ts/ts-basic-components-datepicker.md new file mode 100644 index 0000000000000000000000000000000000000000..28230a8c6c0c890f2cccc60a2b076f90e79a9e94 --- /dev/null +++ b/en/application-dev/reference/arkui-ts/ts-basic-components-datepicker.md @@ -0,0 +1,153 @@ +# DatePicker + + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** +> This component is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version. + + +The **<DatePicker>** component allows users to select date and time. + + +## Required Permissions + +None + + +## Child Component + +None + + +## APIs + +DatePicker(value:{start?: Date, end?: Date, selected?: Date, type?: DatePickerType}) + +Creates a date picker that allows users to select a date or time within the specified range. + +- Parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | start | Date | No | Date('1970-1-1') | Start date of the date picker. | + | end | Date | No | Date('2100-12-31') | End date of the date picker. | + | selected | Date | No | Current system date or time | Selected date when **type** is set to **DatePickerType.Date** and selected time when **type** is set to **DatePickerType.Time**. | + | type | DatePickerType | No | DatePickerType.Date | Picker type, which can be date picker and time picker. The date picker is used by default. | + +- DatePickerType enums + | Name | Description | + | -------- | -------- | + | Date | Date picker. | + | Time | Time picker. | + + +## Attributes + + | Name | Type | Default Value | Description | +| -------- | -------- | -------- |-------- | +| lunar | boolean | false | Whether to display the lunar calendar.
- **true**: The lunar calendar is displayed.
- **false**: The lunar calendar is not displayed. | +| useMilitaryTime | boolean | false | Whether the display time is in 24-hour format. | + + +## Events + + | Name | Description | +| -------- | -------- | +| onChange(callback: (value: DatePickerResult) => void) | This event is triggered when a date or time is selected. | + +- DatePickerResult object description + | Name | Type | Description | + | -------- | -------- | -------- | + | year | number | Year of the selected date (when **type** is **DatePickerType.Date**). | + | month | number | Month of the selected date (when **type** is **DatePickerType.Date**). | + | day | number | Date of the selected date (when **type** is **DatePickerType.Date**). | + | hour | number | Hour portion of the selected time (when **type** is **DatePickerType.Time**). | + | minute | number | Minute portion of the selected time (when **type** is **DatePickerType.Time**). | + + +## Example + + +### Date Picker (with Lunar Calendar) + + +``` +@Entry +@Component +struct DatePickerExample01 { + private selectedDate: Date = new Date('2021-08-08') + + build() { + Column() { + DatePicker({ + start: new Date('1970-1-1'), + end: new Date('2200-1-1'), + selected: this.selectedDate, + type: DatePickerType.Date + }) + .lunar(true) + .onChange((date: DatePickerResult) => { + console.info('select current date is: ' + JSON.stringify(date)) + }) + }.width('100%') + } +} +``` + +![en-us_image_0000001211898486](figures/en-us_image_0000001211898486.gif) + + +### Date Picker (Without Lunar Calendar) + + +``` +@Entry +@Component +struct DatePickerExample02 { + private selectedDate: Date = new Date('2021-08-08') + + build() { + Column() { + DatePicker({ + start: new Date('1970-1-1'), + end: new Date('2200-1-1'), + selected: this.selectedDate, + type: DatePickerType.Date + }) + .lunar(false) + .onChange((date: DatePickerResult) => { + console.info('select current date is: ' + JSON.stringify(date)) + }) + }.width('100%') + } +} +``` + +![en-us_image_0000001257138355](figures/en-us_image_0000001257138355.gif) + + +### Time Picker + + +``` +@Entry +@Component +struct DatePickerExample03 { + private selectedTime: Date = new Date('2021-9-29 08:00:00') + + build() { + Column() { + DatePicker({ + start: new Date('00:00:00'), + end: new Date('23:59:59'), + selected: this.selectedTime, + type: DatePickerType.Time + }) + .useMilitaryTime(true) + .onChange((date: DatePickerResult) => { + console.info('select current date is: ' + JSON.stringify(date)) + }) + }.width('100%') + } +} +``` + +![en-us_image_0000001256858401](figures/en-us_image_0000001256858401.gif) diff --git a/en/application-dev/reference/arkui-ts/ts-basic-components-divider.md b/en/application-dev/reference/arkui-ts/ts-basic-components-divider.md index 975737f94d718f15edb7ea3e3c37cdaf7998e50a..748bdec42a3608c783135d773b43c6a4a813ab24 100644 --- a/en/application-dev/reference/arkui-ts/ts-basic-components-divider.md +++ b/en/application-dev/reference/arkui-ts/ts-basic-components-divider.md @@ -1,79 +1,45 @@ -# Divider +# Divider ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -The **** component is used to separate content blocks and content elements. +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** +> This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -## Required Permissions + +The **<Divider>** component is used to separate content blocks and content elements. + + +## Required Permissions None -## Child Components + +## Child Components None -## APIs - -Divider\(\) - -## Attributes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Default Value

-

Description

-

vertical

-

boolean

-

false

-

Whether a vertical divider is used. The value true means that a vertical divider is used, and false means that a horizontal divider is used.

-

color

-

Color

-

-

-

Color of the divider.

-

strokeWidth

-

Length

-

1

-

Width of the divider.

-

lineCap

-

LineCapStyle

-

Butt

-

Cap style of the divider. The default value is Butt.

-
- -## Events + +## APIs + +Divider() + + +## Attributes + +| Name | Type | Default Value | Description | +| -------- | -------- | -------- | -------- | +| vertical | boolean | false | Whether a vertical divider is used. The value **true** means that a vertical divider is used, and **false** means that a horizontal divider is used. | +| color | Color | - | Color of the divider. | +| strokeWidth | Length | 1 | Width of the divider. | +| lineCap | [LineCapStyle](ts-appendix-enums.md#linecapstyle-enums) | LineCapStyle.Butt | Cap style of the divider. | + + +## Events Universal events are not supported. -## Example + +## Example + ``` @Entry @@ -104,5 +70,4 @@ struct DividerExample { } ``` -![](figures/en-us_image_0000001196780640.png) - +![en-us_image_0000001257058407](figures/en-us_image_0000001257058407.png) diff --git a/en/application-dev/reference/arkui-ts/ts-basic-components-gauge.md b/en/application-dev/reference/arkui-ts/ts-basic-components-gauge.md deleted file mode 100644 index 1f6b9bc92c5d1508850b1ee64dd90088e8652c1b..0000000000000000000000000000000000000000 --- a/en/application-dev/reference/arkui-ts/ts-basic-components-gauge.md +++ /dev/null @@ -1,152 +0,0 @@ -# Gauge - ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->This component is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version. - -Data gauge chart widget, which is used to display data in a ring chart. - -## Required Permissions - -None - -## Child Component - -N/A - -## APIs - -Gauge\(value:\{value: number, min?: number, max?: number\}\) - -- Parameter - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

value

-

number

-

Yes

-

-

-

Current data value.

-

min

-

number

-

No

-

0

-

Minimum value of the current data segment.

-

max

-

number

-

No

-

100

-

Maximum value of the current data segment.

-
- - -## Attributes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Default Value

-

Description

-

value

-

number

-

0

-

Sets the value of the current data chart.

-

startAngle

-

Angle

-

-150

-

Set the start angle. Clock 0 indicates 0 degree, and the clockwise direction indicates the positive angle.

-

endAngle

-

Angle

-

150

-

Sets the end angle position. The clock 0 point is 0 degree, and the clockwise direction is the positive angle.

-

colors

-

Color | Array<ColorStop>

-

-

-

Set the color of the chart. You can set the pure color or segmental gradient color.

-

strokeWidth

-

Length

-

-

-

Sets the ring thickness of a ring chart.

-
- -## Example - -``` -@Entry -@Component -struct GaugeExample { - build() { - Column() { - Gauge({ value: 50, min: 0, max: 100 }) - .startAngle(210).endAngle(150) - .colors([[0x317AF7, 1], [0x5BA854, 1], [0xE08C3A, 1], [0x9C554B, 1], [0xD94838, 1]]) - .strokeWidth(20) - .width(200).height(200) - }.width('100%').margin({ top: 5 }) - } -} -``` - -![](figures/gauge.png) - diff --git a/en/application-dev/reference/arkui-ts/ts-basic-components-image.md b/en/application-dev/reference/arkui-ts/ts-basic-components-image.md index 9909adf2dab633a418cc4c473ef04c3a0f3b01e8..ce5beb1a61e330811d97a6ec4ab85c933a343db3 100644 --- a/en/application-dev/reference/arkui-ts/ts-basic-components-image.md +++ b/en/application-dev/reference/arkui-ts/ts-basic-components-image.md @@ -1,271 +1,87 @@ -# Image +# Image ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -The **** component is used to render and display images. +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** +> This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -## Required Permissions -ohos.permission.INTERNET \(using Internet images\) +The **<Image>** component is used to render and display images. -## Child Components + +## Required Permissions + +ohos.permission.INTERNET (using Internet images) + + +## Child Components None -## APIs - -Image\(value: \{uri: string | PixelMap\}\) - -- Parameters - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

uri

-

string

-

Yes

-

-

-

Image URI. Both local and Internal URIs are supported.

-
- - -## Attributes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Default Value

-

Description

-

alt

-

string

-

-

-

Placeholder image displayed during loading. Both local and Internal URIs are supported.

-

objectFit

-

ImageFit

-

Cover

-

Image scale type.

-

objectRepeat

-

ImageRepeat

-

NoRepeat

-

Whether the image is repeated.

-
NOTE:
  • This attribute is not applicable to SVG images.
-
-

interpolation

-

ImageInterpolation

-

None

-

Interpolation effect of the image. This attribute is valid only when the image is zoomed in.

-
NOTE:
  • This attribute is not applicable to SVG images.
  • This attribute is not applicable to a PixelMap object.
-
-

renderMode

-

ImageRenderMode

-

Original

-

Rendering mode of the image.

-
NOTE:
  • This attribute is not applicable to SVG images.
-
-

sourceSize

-

{

-

width: number,

-

height: number

-

}

-

-

-

Decoding size of the image. The original image is decoded into an image of the specified size. If the value is of the number type, the unit px is used.

-
NOTE:

This attribute is not applicable to a PixelMap object.

-
-

syncLoad8+

-

boolean

-

false

-

Whether to load images synchronously. By default, images are loaded asynchronously. During synchronous loading, the UI thread is blocked and the placeholder diagram is not displayed.

-
- -- ImageFit enums - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Description

-

Cover

-

The image is scaled with its aspect ratio retained for both sides to be greater than or equal to the display boundaries.

-

Contain

-

The image is scaled with its aspect ratio retained for the content to be completely displayed within the display boundaries.

-

Fill

-

The video content is resized to fill the display area while retaining its aspect ratio.

-

None

-

The original size is retained. Generally, this enum is used together with the objectRepeat attribute.

-

ScaleDown

-

The image content is displayed with its aspect ratio retained. The size is smaller than or equal to the original size.

-
- - -- ImageInterpolation enums - - - - - - - - - - - - - - - - - - - -

Name

-

Description

-

None

-

Interpolation image data is not used.

-

High

-

The interpolation image data is used at the high level. The use of the interpolation image data may affect the image rendering speed.

-

Medium

-

The interpolation image data is used at the medium level.

-

Low

-

The interpolation image data is used at the low level.

-
- - -- ImageRenderMode enums - - - - - - - - - - - - - -

Name

-

Description

-

Original

-

The image is rendered based on the original image, including the color.

-

Template

-

The image is rendered as a template image, and its color is ignored.

-
- - -## Events - - - - - - - - - - - - - - - - -

Name

-

Description

-

onComplete(callback: (event?: { width: number, height: number, componentWidth: number, componentHeight: number, loadingStatus: number }) => void)

-

Triggered when an image is successfully loaded. The loaded image is returned.

-

onError(callback: (event?: { componentWidth: number, componentHeight: number }) => void)

-

An exception occurs during image loading.

-

onFinish(callback: () => void)

-

If the source file to be loaded is an SVG image, this callback is invoked when the SVG animation playback is complete. If the animation is an infinite loop, this callback is not triggered.

-
- -## Example + +## APIs + +Image(value: {uri: string | PixelMap}) + +- Parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | uri | string | Yes | - | Image URI. Both local and Internal URIs are supported. | + + +## Attributes + +| Name | Type | Default Value | Description | +| -------- | -------- | -------- | -------- | +| alt | string | - | Placeholder image displayed during loading. Both local and Internal URIs are supported. | +| objectFit | ImageFit | ImageFit.Cover | Image scale type. | +| objectRepeat | [ImageRepeat](ts-appendix-enums.md#imagerepeat enums) | ImageRepeat.NoRepeat | Whether the image is repeated.
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:**
> - This attribute is not applicable to SVG images. | +| interpolation | ImageInterpolation | ImageInterpolation.None | Interpolation effect of the image. This attribute is valid only when the image is zoomed in.
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:**
> - This attribute is not applicable to SVG images.

> - This attribute is not applicable to a **PixelMap** object. | +| renderMode | ImageRenderMode | ImageRenderMode.Original | Rendering mode of the image.
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:**
> - This attribute is not applicable to SVG images. | +| sourceSize | {
width: number,
height: number
} | - | Decoding size of the image. The original image is decoded into an image of the specified size. If the value is of the number type, the unit px is used.
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:**
> This attribute is not applicable to a **PixelMap** object. | +| syncLoad8+ | boolean | false | Whether to load images synchronously. By default, images are loaded asynchronously. During synchronous loading, the UI thread is blocked and the placeholder diagram is not displayed. | + +- ImageFit enums + | Name | Description | + | -------- | -------- | + | Cover | The image is scaled with its aspect ratio retained for both sides to be greater than or equal to the display boundaries. | + | Contain | The image is scaled with its aspect ratio retained for the content to be completely displayed within the display boundaries. | + | Fill | The video content is resized to fill the display area while retaining its aspect ratio. | + | None | The original size is retained. Generally, this enum is used together with the **objectRepeat** attribute. | + | ScaleDown | The image content is displayed with its aspect ratio retained. The size is smaller than or equal to the original size. | + +- ImageInterpolation enums + | Name | Description | + | -------- | -------- | + | None | Interpolation image data is not used. | + | High | The interpolation image data is used at the high level. The use of the interpolation image data may affect the image rendering speed. | + | Medium | The interpolation image data is used at the medium level. | + | Low | The interpolation image data is used at the low level. | + +- ImageRenderMode enums + | Name | Description | + | -------- | -------- | + | Original | The image is rendered based on the original image, including the color. | + | Template | The image is rendered as a template image, and its color is ignored. | + + +## Events + + | Name | Description | +| -------- | -------- | +| onComplete(callback: (event?: { width: number, height: number, componentWidth: number, componentHeight: number, loadingStatus: number }) => void) | Triggered when an image is successfully loaded. The loaded image is returned. | +| onError(callback: (event?: { componentWidth: number, componentHeight: number }) => void) | An exception occurs during image loading. | +| onFinish(callback: () => void) | If the source file to be loaded is an SVG image, this callback is invoked when the SVG animation playback is complete. If the animation is an infinite loop, this callback is not triggered. | + + +## Example + ``` // Image1 @Entry @Component struct ImageExample1 { - private on: string = 'www.example.com' + private on: string = 'www.example.com' @State src: string = this.on build() { @@ -325,7 +141,8 @@ struct ImageExample1 { } ``` -![](figures/en-us_image_0000001239925031.gif) +![en-us_image_0000001211898484](figures/en-us_image_0000001211898484.gif) + ``` // Image2 @@ -394,7 +211,8 @@ struct ImageExample2 { } ``` -![](figures/en-us_image_0000001194605518.png) +![en-us_image_0000001212058474](figures/en-us_image_0000001212058474.png) + ``` // Image3 @@ -456,5 +274,4 @@ struct ImageExample3 { } ``` -![](figures/en-us_image_0000001194942468.gif) - +![en-us_image_0000001256858397](figures/en-us_image_0000001256858397.gif) diff --git a/en/application-dev/reference/arkui-ts/ts-basic-components-imageanimator.md b/en/application-dev/reference/arkui-ts/ts-basic-components-imageanimator.md index af1a3aaaa8f9297be8efbb28d8455d4c46f5ab5e..a80064b6e432469b98b5361cb293c8ada80af1dd 100644 --- a/en/application-dev/reference/arkui-ts/ts-basic-components-imageanimator.md +++ b/en/application-dev/reference/arkui-ts/ts-basic-components-imageanimator.md @@ -1,245 +1,69 @@ -# ImageAnimator +# ImageAnimator ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -The **** component enables images to be played frame by frame. The list of images to be played can be configured, and the duration of each image can be configured. +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** +> This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -## Required Permissions + +The **<ImageAnimator>** component enables images to be played frame by frame. The list of images to be played can be configured, and the duration of each image can be configured. + + +## Required Permissions None -## Child Components + +## Child Components None -## APIs -ImageAnimator\(\) +## APIs + +ImageAnimator() -## Attributes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Default Value

-

Mandatory

-

Description

-

images

-

Array<{

-

src:string,

-

width?:Length,

-

height?:Length,

-

top?:Length,

-

left?:Length,

-

duration?:number

-

}>

-

[]

-

Yes

-

Image frame information. The information of each frame includes the image path, image size, image position, and image playback duration. The detailed description is as follows:

-

src: image path. The image format can be SVG, PNG, or JPG.

-

width: image width.

-

height: image height.

-

top: vertical coordinate of the image relative to the upper left corner of the component.

-

left: horizontal coordinate of the image relative to the upper left corner of the component.

-

duration: playback duration of the image, in ms.

-

state

-

AnimationStatus

-

Initial

-

No

-

Playback status of the animation. The default status is Initial.

-

duration

-

number

-

1000

-

No

-

Playback duration, in ms. The default duration is 1000 ms. When the duration is 0, no image is played. The value change takes effect only at the beginning of the next cycle. When a separate duration is set in images, the setting of this attribute is invalid.

-

reverse

-

boolean

-

false

-

No

-

Playback sequence. The value false indicates that images are played from the first one to the last one, and true indicates that images are played from the last one to the first one.

-

fixedSize

-

boolean

-

true

-

No

-

Whether the image size is the same as the component size. true: The image size is the same as the component size. In this case, the width, height, top, and left attributes of the image are invalid. false: The width, height, top, and left attributes of each image must be set separately.

-

preDecode

-

number

-

0

-

No

-

Whether to enable pre-decoding. The default value 0 indicates that pre-decoding is disabled. If this attribute is set to 2, two images following the currently playing frame will be cached in advance to improve performance.

-

fillMode

-

FillMode

-

Forwards

-

No

-

Status before and after the animation starts. For details about the options, see FillMode.

-

iterations

-

number

-

1

-

No

-

By default, the animation is played once. The value -1 indicates that the animation is played for an unlimited number of times.

-
+## Attributes -- AnimationStatus enums +| Name | Type | Default Value | Mandatory | Description | +| -------- | -------- | -------- | -------- | -------- | +| images | Array<{
src:string,
width?:Length,
height?:Length,
top?:Length,
left?:Length,
duration?:number
}> | [] | Yes | Image frame information. The information of each frame includes the image path, image size, image position, and image playback duration. The detailed description is as follows:
**src**: image path. The image format can be SVG, PNG, or JPG.
**width**: image width.
**height**: image height.
**top**: vertical coordinate of the image relative to the upper left corner of the component.
**left**: horizontal coordinate of the image relative to the upper left corner of the component.
**duration**: playback duration of the image, in ms. | +| state | AnimationStatus | AnimationStatus.Initial | No | Playback status of the animation. The default status is **Initial**. | +| duration | number | 1000 | No | Playback duration, in ms. The default duration is 1000 ms. When the duration is **0**, no image is played. The value change takes effect only at the beginning of the next cycle. When a separate duration is set in images, the setting of this attribute is invalid. | +| reverse | boolean | false | No | Playback sequence. The value **false** indicates that images are played from the first one to the last one, and **true** indicates that images are played from the last one to the first one. | +| fixedSize | boolean | true | No | Whether the image size is the same as the component size. **true**: The image size is the same as the component size. In this case, the width, height, top, and left attributes of the image are invalid. **false**: The width, height, top, and left attributes of each image must be set separately. | +| preDecode | number | 0 | No | Whether to enable pre-decoding. The default value **0** indicates that pre-decoding is disabled. If this attribute is set to **2**, two images following the currently playing frame will be cached in advance to improve performance. | +| fillMode | FillMode | FillMode.Forwards | No | Status before and after the animation starts. For details about the options, see **FillMode**. | +| iterations | number | 1 | No | By default, the animation is played once. The value **-1** indicates that the animation is played for an unlimited number of times. | - - - - - - - - - - - - - - - - - - -

Name

-

Description

-

Initial

-

The animation is in the initial state.

-

Running

-

The animation is being played.

-

Paused

-

The animation is paused.

-

Stopped

-

The animation is stopped.

-
+- AnimationStatus enums + | Name | Description | + | -------- | -------- | + | Initial | The animation is in the initial state. | + | Running | The animation is being played. | + | Paused | The animation is paused. | + | Stopped | The animation is stopped. | +- FillMode enums + | Name | Description | + | -------- | -------- | + | None | After the playback is complete, the animation restores to the initial state. | + | Forwards | After the playback is complete, the animation remains in the end state. | -- FillMode enums - - - - - - - - - - - - - - - - - - -

Name

-

Description

-

None

-

After the playback is complete, the animation restores to the initial state.

-

Forwards

-

After the playback is complete, the animation remains in the end state.

-

Backwards

-

The attribute value is applied during the period specified by animation-delay and before the animation is played.

-

Both

-

Both the Forwards and Backwards values are applied.

-
+## Events + | Name | Description | +| -------- | -------- | -------- | +| onStart() => void | Triggered when the animation starts to play. | +| onPause() => void | Triggered when the animation playback is paused. | +| onRepeat() => void | Triggered when the animation playback is repeated. | +| onCancel() => void | Triggered when the animation playback is canceled. | +| onFinish() => void | Triggered when the animation playback is complete. | -## Events - - - - - - - - - - - - - - - - - - - - - -

Name

-

Description

-

onStart() => void

-

Triggered when the animation starts to play.

-

onPause() => void

-

Triggered when the animation playback is paused.

-

onRepeat() => void

-

Triggered when the animation playback is repeated.

-

onCancel() => void

-

Triggered when the animation playback is canceled.

-

onFinish() => void

-

Triggered when the animation playback is complete.

-
+## Example -## Example ``` @Entry @@ -331,5 +155,4 @@ struct ImageAnimatorExample { } ``` -![](figures/imageanimator.gif) - +![en-us_image_0000001211898470](figures/en-us_image_0000001211898470.gif) diff --git a/en/application-dev/reference/arkui-ts/ts-basic-components-loadingprogress.md b/en/application-dev/reference/arkui-ts/ts-basic-components-loadingprogress.md deleted file mode 100644 index c7e5d0022e7b90ef0fa6a4755bbd3e7a4cdd8b47..0000000000000000000000000000000000000000 --- a/en/application-dev/reference/arkui-ts/ts-basic-components-loadingprogress.md +++ /dev/null @@ -1,51 +0,0 @@ -# LoadingProgress - -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** -> This component is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version. - -The **** component is used to display the loading progress. - - -## Required Permissions - -None - - -## Child Components - -None - - -## APIs - -LoadingProgress() - -Creates a **LoadingProgress** instance. - - - -## Attributes - -| Name| Type| Default Value| Description| -| -------- | -------- | -------- | -------- | -| color | Color | - | Foreground color of the loading progress bar.| - - - -## Example - -``` -@Entry -@Component -struct LoadingProgressExample { - build() { - Column({ space: 5 }) { - Text('Orbital LoadingProgress ').fontSize(9).fontColor(0xCCCCCC).width('90%') - LoadingProgress() - .color(Color.Blue) - }.width('100%').margin({ top: 5 }) - } -} -``` - -![zh-cn_image_0000001198839004](figures/loadingProgress.png) diff --git a/en/application-dev/reference/arkui-ts/ts-basic-components-marquee.md b/en/application-dev/reference/arkui-ts/ts-basic-components-marquee.md deleted file mode 100644 index 5348e4f44d4442d67cc63f1e0491aaa3a0d9976f..0000000000000000000000000000000000000000 --- a/en/application-dev/reference/arkui-ts/ts-basic-components-marquee.md +++ /dev/null @@ -1,172 +0,0 @@ -# Marquee - ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->This component is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version. - -The **** component displays single-line scrolling text. - -## Required Permissions - -None - -## Child Components - -None - -## APIs - -Marquee\(value: \{ start: boolean, step?: number, loop?: number, fromStart?: boolean, src: string \}\) - -- Parameters - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

start

-

boolean

-

Yes

-

-

-

Whether to set the marquee scroll.

-

step

-

number

-

No

-

6

-

Scroll step of the marquee text.

-

loop

-

number

-

No

-

-1

-

Number of times the marquee scrolls. If the value is less than or equal to 0, the marquee scrolls continuously.

-

fromStart

-

boolean

-

No

-

true

-

Whether the marquee scrolls from the start of the text. If the value is false, the marquee scrolls from the end of the text.

-

src

-

string

-

Yes

-

-

-

Text to be scrolled.

-
- - -## Events - - - - - - - - - - - - - - - - -

Name

-

Description

-

onStart(callback: () => void)

-

Invoked when scrolling starts.

-

onBounce(callback: () => void)

-

Invoked when scrolling reaches the end.

-

onFinish(callback: () => void)

-

Invoked when scrolling is complete.

-
- -## Example - -``` -@Entry -@Component -struct MarqueeExample { - @State start: boolean = false - @State fromStart: boolean = true - @State step: number = 50 - @State loop: number = 3 - @State src: string = "Running Marquee starts rolling" - - build() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Marquee({ - start: this.start, - step: this.step, - loop: this.loop, - fromStart: this.fromStart, - src: this.src - }) - .fontColor(Color.White) - .fontSize(50) - .allowScale(false) - .fontWeight(FontWeight.Bold) - .backgroundColor(Color.Black) - .margin({bottom:40}) - .onStart(() => { - console.log('Marquee animation complete onStart') - }) - .onBounce(() => { - console.log('Marquee animation complete onBounce') - }) - .onFinish(() => { - console.log('Marquee animation complete onFinish') - }) - Button('start') - .onClick(() => { - this.start = true - }) - .width(200) - .height(60) - .margin({bottom:20}) - } - .width('100%') - .height('100%') - } -} -``` - -![](figures/gif-1.gif) - diff --git a/en/application-dev/reference/arkui-ts/ts-basic-components-navigation.md b/en/application-dev/reference/arkui-ts/ts-basic-components-navigation.md new file mode 100644 index 0000000000000000000000000000000000000000..14c7af39a01f94de4daa5bb820d43615a1dabc2b --- /dev/null +++ b/en/application-dev/reference/arkui-ts/ts-basic-components-navigation.md @@ -0,0 +1,222 @@ +# Navigation + + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** +> This component is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version. + + +The **<Navigation>** component typically functions as the root container of a page and displays the page title, toolbar, and menu based on the attribute settings. + + +## Required Permissions + +None + + +## Child Component + +It can contain subcomponents. + + +## APIs + +Navigation() + +Creates a component that can automatically display the navigation bar, title, and toolbar based on the attribute settings. + + +## Attributes + +| Name | Type | Default Value | Description | +| -------- | -------- | -------- | -------- | +| title | string \| [Custom Builder](../../ui/ts-types.md) | - | Page title. | +| subtitle | string | - | Subtitle of the page. | +| menus | Array<NavigationMenuItem> \| [Custom Builder](../../ui/ts-types.md) | - | Menu in the upper right corner of the page. | +| titleMode | NavigationTitleMode | NavigationTitleMode.Free | Display mode of the page title bar. | +| toolBar | {
items:[
Object
] }
\| [Custom Builder](../../ui/ts-types.md) | - | Content of the toolbar.
**items**: all items on the toolbar. | +| hideToolBar | boolean | false | Whether to hide the toolbar.
**true**: Hide the toolbar.
**false**: Show the toolbar. | +| hideTitleBar | boolean | false | Whether to hide the title bar. | +| hideBackButton | boolean | false | Whether to hide the back button. | + +- NavigationMenuItem attributes + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | value | string | Yes | - | Text of an option on the menu bar. | + | icon | string | No | - | Icon path of an option on the menu bar. | + | action | () => void | No | - | Callback invoked when an option is selected. | + +- Object attributes + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | value | string | Yes | - | Text of an option on the toolbar. | + | icon | string | No | - | Icon path of an option on the toolbar. | + | action | () => void | No | - | Callback invoked when an option is selected. | + +- NavigationTitleMode enums + | Name | Description | + | -------- | -------- | + | Free | When the content is a scrollable component, the title shrinks as the content scrolls up (the subtitle fades out with its size remaining unchanged) and restores as the content scrolls down. | + | Mini | The mode is fixed at mini mode (icon + main title and subtitle). | + | Full | The mode is fixed at full mode (main title and subtitle). | + + > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** + > Currently, only the scrollable component **<List>** is supported. + + +## Events + + | Name | Description | +| -------- | -------- | +| onTitleModeChanged(callback: (titleMode: NavigationTitleMode) => void) | Triggered when **titleMode** is set to **NavigationTitleMode.Free** and the title bar mode changes as content scrolls. | + + +## Example + + +``` +// Example 01 +@Entry +@Component +struct NavigationExample { + private arr: number[] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] + @State hideBar: boolean = true + + @Builder NavigationTitle() { + Column() { + Text('title') + .width(80) + .height(60) + .fontColor(Color.Blue) + .fontSize(30) + } + .onClick(() => { + console.log("title") + }) + } + + @Builder NavigationMenus() { + Row() { + Image('images/add.png') + .width(25) + .height(25) + Image('comment/more.png') + .width(25) + .height(25) + .margin({ left: 30 }) + }.width(100) + } + + build() { + Column() { + Navigation() { + Search({ value: '', placeholder: "" }).width('85%').margin(26) + List({ space: 5, initialIndex: 0 }) { + ForEach(this.arr, (item) => { + ListItem() { + Text('' + item) + .width('90%') + .height(80) + .backgroundColor('#3366CC') + .borderRadius(15) + .fontSize(16) + .textAlign(TextAlign.Center) + }.editable(true) + }, item => item) + } + .listDirection(Axis.Vertical) + .height(300) + .margin({ top: 10, left: 18 }) + .width('100%') + + Button(this.hideBar ? "tool bar" : "hide bar") + .onClick(() => { + this.hideBar = !this.hideBar + }) + .margin({ left: 135, top: 60 }) + } + .title(this.NavigationTitle) + .subTitle('subtitle') + .menus(this.NavigationMenus) + .titleMode(NavigationTitleMode.Free) + .hideTitleBar(false) + .hideBackButton(false) + .onTitleModeChanged((titleModel: NavigationTitleMode) => { + console.log('titleMode') + }) + .toolBar({ items: [ + { value: 'app', icon: 'images/grid.svg', action: () => { + console.log("app") + } }, + { value: 'add', icon: 'images/add.svg', action: () => { + console.log("add") + } }, + { value: 'collect', icon: 'images/collect.svg', action: () => { + console.log("collect") + } }] }) + .hideToolBar(this.hideBar) + } + } +} +``` + +![en-us_image_0000001256978359](figures/en-us_image_0000001256978359.gif) + + +``` +// Example 02 +@Entry +@Component +struct ToolbarBuilderExample { + @State currentIndex: number = 0 + @State Build: Array = [ + { + icon: $r('app.media.ic_public_add'), + icon_after: $r('app.media.ic_public_addcolor'), + text: 'add', + num: 0 + }, + { + icon: $r('app.media.ic_public_app'), + icon_after: $r('app.media.ic_public_appcolor'), + text: 'app', + num: 1 + }, + { + icon: $r('app.media.ic_public_collect'), + icon_after: $r('app.media.ic_public_collectcolor'), + text: 'collect', + num: 2 + } + ] + + @Builder NavigationToolbar() { + Row() { + ForEach(this.Build, item => { + Column() { + Image(this.currentIndex == item.num ? item.icon_after : item.icon) + .width(25) + .height(25) + Text(item.text) + .fontColor(this.currentIndex == item.num ? "#ff7500" : "#000000") + } + .onClick(() => { + this.currentIndex = item.num + }) + .margin({ left: 70 }) + }) + } + } + + build() { + Column() { + Navigation() { + Flex() { + } + } + .toolBar(this.NavigationToolbar) + } + } +} +``` + +![en-us_image_0000001212058484](figures/en-us_image_0000001212058484.gif) diff --git a/en/application-dev/reference/arkui-ts/ts-basic-components-progress.md b/en/application-dev/reference/arkui-ts/ts-basic-components-progress.md index 8652d7554cb1d95285770d158fff4df3aa4b8b0b..cc242502989bfed47fd22a63fe7071bdbff0c194 100644 --- a/en/application-dev/reference/arkui-ts/ts-basic-components-progress.md +++ b/en/application-dev/reference/arkui-ts/ts-basic-components-progress.md @@ -1,145 +1,99 @@ -# Progress +# Progress ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -The **** component is used to provide a progress bar that displays the progress of content loading or an operation. +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** +> This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -## Required Permissions + +The **<Progress>** component is used to provide a progress bar that displays the progress of content loading or an operation. + + +## Required Permissions None -## Child Components + +## Child Components None -## APIs - -Progress\(value: \{value: number, total?: number, style?: ProgressStyle\}\) - -Creates a progress bar with a specified progress value. - -- Parameters - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

value

-

number

-

Yes

-

-

-

Current progress.

-

total

-

number

-

No

-

100

-

Total progress.

-

style

-

ProgressStyle

-

No

-

Linear

-

Style of the progress bar.

-
- - -- ProgressStyle enums - - - - - - - - - - -

Name

-

Description

-

Linear

-

Linear progress bar.

-
- - -## Attributes - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Default Value

-

Description

-

value

-

number

-

-

-

Current progress.

-

color

-

Color

-

-

-

Background color of the progress bar.

-
- -## Example +## APIs + +Progress(value: {value: number, total?: number, style?: ProgressStyle}) + +Creates a progress bar. + +- Parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | value | number | Yes | - | Current progress. | + | total | number | No | 100 | Total progress. | + | style | ProgressStyle | No | ProgressStyle.Linear | Style of the progress bar. | + + +- ProgressStyle enums + | Name | Description | + | -------- | -------- | + | Linear | Linear style. | + | Ring8+ | Ring style without scale. The ring fills up as the progress increases. | + | Eclipse | Eclipse style, which visualizes the progress in a way similar to the moon waxing from new to full. | + | ScaleRing8+ | Ring style with scale, which is similar to the clock scale style. | + | Capsule8+ | Capsule style. At both ends, the progress bar changes from an arc to a straight line and from a straight line to an arc. In the middle part of the capsule, the progress bar moves to the right. | + + +## Attributes + + | Name | Type | Default Value | Description | +| -------- | -------- | -------- | -------- | +| value | number | - | Current progress. | +| color | Color | - | Background color of the progress bar. | +| style8+ | {
strokeWidth? : Length,
scaleCount? : number,
scaleWidth? : Length
} | - | Component style.
- **strokeWidth**: width of the progress bar.
- **scaleCount**: scale count of the circular progress bar.
- **scaleWidth**: scale width of the circular progress bar.
If the scale thickness is greater than the progress bar width, the default scale thickness is used. | + + +## Example + + ``` @Entry @Component struct ProgressExample { build() { - Column({ space: 5 }) { + Column({ space: 15 }) { Text('Linear Progress').fontSize(9).fontColor(0xCCCCCC).width('90%') Progress({ value: 10, style: ProgressStyle.Linear }).width(200) - - Text('Linear Progress Color').fontSize(9).fontColor(0xCCCCCC).width('90%') - Progress({ value: 20, total: 150, style: ProgressStyle.Linear }).color(Color.Red).value(50).width(200) - }.width('100%').margin({ top: 5 }) + Progress({ value: 20, total: 150, style: ProgressStyle.Linear }).color(Color.Grey).value(50).width(200) + + Text('Eclipse Progress').fontSize(9).fontColor(0xCCCCCC).width('90%') + Row({ space: 40 }) { + Progress({ value: 10, style: ProgressStyle.Eclipse }).width(100) + Progress({ value: 20, total: 150, style: ProgressStyle.Eclipse }).color(Color.Grey).value(50).width(100) + } + + Text('ScaleRing Progress').fontSize(9).fontColor(0xCCCCCC).width('90%') + Row({ space: 40 }) { + Progress({ value: 10, style: ProgressStyle.ScaleRing }).width(100) + Progress({ value: 20, total: 150, style: ProgressStyle.ScaleRing }) + .color(Color.Grey).value(50).width(100) + .style({ strokeWidth: 15, scaleCount: 15, scaleWidth: 5 }) + } + + Text('Ring Progress').fontSize(9).fontColor(0xCCCCCC).width('90%') + Row({ space: 40 }) { + Progress({ value: 10, style: ProgressStyle.Ring }).width(100) + Progress({ value: 20, total: 150, style: ProgressStyle.Ring }) + .color(Color.Grey).value(50).width(100) + .style({ strokeWidth: 20, scaleCount: 30, scaleWidth: 20 }) + } + + Text('Capsule Progress').fontSize(9).fontColor(0xCCCCCC).width('90%') + Row({ space: 40 }) { + Progress({ value: 10, style: ProgressStyle.Capsule }).width(100) + Progress({ value: 20, total: 150, style: ProgressStyle.Capsule }).color(Color.Grey).value(50).width(100) + } + }.width('100%').margin({ top: 30 }) } } ``` -![](figures/progress.png) - +![en-us_image_0000001212378432](figures/en-us_image_0000001212378432.gif) diff --git a/en/application-dev/reference/arkui-ts/ts-basic-components-qrcode.md b/en/application-dev/reference/arkui-ts/ts-basic-components-qrcode.md index 05e0575e6178ffe6028062fe936635c48ec99605..612fdfeb294d65a1e74b69c4e63063991547b5fe 100644 --- a/en/application-dev/reference/arkui-ts/ts-basic-components-qrcode.md +++ b/en/application-dev/reference/arkui-ts/ts-basic-components-qrcode.md @@ -1,83 +1,48 @@ -# QRCode +# QRCode ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -The **** component is used to display QR code information. +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** +> This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -## Required Permissions + +The **<QRCode>** component is used to display QR code information. + + +## Required Permissions None -## Child Components + +## Child Components None -## APIs - -QRCode\(value: string\) - -- Parameters - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

value

-

string

-

Yes

-

-

-

QR code content string.

-
- - -## Attributes - - - - - - - - - - - - - - -

Name

-

Type

-

Default Value

-

Description

-

color

-

Color

-

Black

-

QR code color.

-
- -## Events + +## APIs + +QRCode(value: string) + +- Parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | value | string | Yes | - | QR code content string. | + + +## Attributes + + | Name | Type | Default Value | Description | +| -------- | -------- | -------- | -------- | +| color | Color | Black | QR code color. | + + +## Events Among all the universal events, only the click event is supported. -## Example +## Example + + ``` @Entry @Component @@ -96,5 +61,4 @@ struct QRCodeExample { } ``` -![](figures/qrcode.png) - +![en-us_image_0000001256858415](figures/en-us_image_0000001256858415.png) diff --git a/en/application-dev/reference/arkui-ts/ts-basic-components-rating.md b/en/application-dev/reference/arkui-ts/ts-basic-components-rating.md index 240dd361951228d2c0202167e6eb3f93218494fc..b7de6f882cb5b0b6787888cdeade4f50c4bfda36 100644 --- a/en/application-dev/reference/arkui-ts/ts-basic-components-rating.md +++ b/en/application-dev/reference/arkui-ts/ts-basic-components-rating.md @@ -1,130 +1,52 @@ -# Rating +# Rating ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -The **** component provides a rating bar. +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** +> This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -## Required Permissions + +The **<Rating>** component provides a rating bar. + + +## Required Permissions None -## Child Components + +## Child Components None -## APIs - -Rating\(options?: \{ rating: number, indicator?: boolean \}\) - -- Parameters - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

rating

-

number

-

Yes

-

0

-

Value to rate.

-

indicator

-

boolean

-

No

-

false

-

Used only as an indicator and cannot be operated.

-
- - -## Attributes - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Default Value

-

Description

-

stars

-

number

-

5

-

Total number of stars.

-

stepSize

-

number

-

0.5

-

Step of an operation.

-

starStyle

-

{

-

backgroundUri: string,

-

foregroundUri: string,

-

secondaryUri?: string

-

}

-

-

-

backgroundSrc: image link of the unselected star. You can customize the image or use the default image. Only local images are supported.

-

foregroundSrc: image path of the selected star. You can customize the image or use the default image. Only local images are supported.

-

secondarySrc: image path of the partially selected star. You can customize the image or use the default image. Only local images are supported.

-
- -## Events - - - - - - - - - - -

Name

-

Description

-

onChange(callback:(value: number) => void)

-

Triggered when the rating value changes.

-
- -## Example + +## APIs + +Rating(options?: { rating: number, indicator?: boolean }) + +- Parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | rating | number | Yes | 0 | Value to rate. | + | indicator | boolean | No | false | Used only as an indicator and cannot be operated. | + + +## Attributes + + | Name | Type | Default Value | Description | +| -------- | -------- | -------- | -------- | +| stars | number | 5 | Total number of stars. | +| stepSize | number | 0.5 | Step of an operation. | +| starStyle | {
backgroundUri: string,
foregroundUri: string,
secondaryUri?: string
} | - | **backgroundSrc**: image link of the unselected star. You can customize the image or use the default image. Only local images are supported.
**foregroundSrc**: image path of the selected star. You can customize the image or use the default image. Only local images are supported.
**secondarySrc**: image path of the partially selected star. You can customize the image or use the default image. Only local images are supported. | + + +## Events + + | Name | Description | +| -------- | -------- | +| onChange(callback:(value: number) => void) | Triggered when the rating value changes. | + + +## Example + ``` @Entry @@ -147,5 +69,4 @@ struct RatingExample { } ``` -![](figures/rating.gif) - +![en-us_image_0000001257058423](figures/en-us_image_0000001257058423.gif) diff --git a/en/application-dev/reference/arkui-ts/ts-basic-components-scrollbar.md b/en/application-dev/reference/arkui-ts/ts-basic-components-scrollbar.md new file mode 100644 index 0000000000000000000000000000000000000000..1d0e8d4d760779a50a02301f0793867829753319 --- /dev/null +++ b/en/application-dev/reference/arkui-ts/ts-basic-components-scrollbar.md @@ -0,0 +1,96 @@ +# ScrollBar + + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** +> This component is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version. + + +The **<ScrollBar>** is used together with scrollable components, such as **<List>**, **<Grid>**, and **<Scroll>**. + + +## Required Permissions + +None + + +## Child Components + +This component can contain a single child component. + + +## APIs + +ScrollBar(value: ScrollBarOption) + +- ScrollBarOption parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | scroller | [Scroller](ts-container-scroll.md#scroller) | Yes | - | Scroller, which can be bound to and control scrollable components. | + | direction | ScrollBarDirection | No | ScrollBarDirection.Vertical | Scrollbar direction in which scrollable components scroll. | + | state | BarState | No | BarState.Auto | Scrollbar state. | + + > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** + > The **<ScrollBar>** component defines the behavior style of the scrollable area, and its subnodes define the behavior style of the scrollbar. + > + > This component is bound to a scrollable component through **scroller**, and can be used to scroll the scrollable component only when their directions are the same. The **<ScrollBar>** component can be bound to only one scrollable component, and vice versa. + +- ScrollBarDirection enums + | Name | Description | + | -------- | -------- | + | Vertical | Vertical scrollbar. | + | Horizontal | Horizontal scrollbar. | + +- BarState enums + | Name | Description | + | -------- | -------- | + | On | Always display. | + | Off | Hide. | + | Auto | Display on demand (displays when the screen is touched and disappears after 2s of inactivity). | + + +## Example + + +``` +@Entry +@Component +struct ScrollBarExample { + private scroller: Scroller = new Scroller() + private arr: number[] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] + + build() { + Column() { + Stack({ alignContent: Alignment.End }) { + Scroll(this.scroller) { + Flex({ direction: FlexDirection.Column }) { + ForEach(this.arr, (item) => { + Row() { + Text(item.toString()) + .width('90%') + .height(100) + .backgroundColor('#3366CC') + .borderRadius(15) + .fontSize(16) + .textAlign(TextAlign.Center) + .margin({ top: 5 }) + } + }, item => item) + }.margin({ left: 52 }) + } + .scrollBar(BarState.Off) + .scrollable(ScrollDirection.Vertical) + ScrollBar({ scroller: this.scroller, direction: ScrollBarDirection.Vertical,state: BarState.Auto }) { + Text() + .width(30) + .height(100) + .borderRadius(10) + .backgroundColor('#C0C0C0') + }.width(30).backgroundColor('#ededed') + } + } + } +} +``` + + +![en-us_image_0000001256978369](figures/en-us_image_0000001256978369.gif) diff --git a/en/application-dev/reference/arkui-ts/ts-basic-components-select.md b/en/application-dev/reference/arkui-ts/ts-basic-components-select.md index 25d73234a372a9e13f9a693e2e834e45d6bf9cda..1f4891eb9c210fd3e59f9338e52359408dd98c87 100644 --- a/en/application-dev/reference/arkui-ts/ts-basic-components-select.md +++ b/en/application-dev/reference/arkui-ts/ts-basic-components-select.md @@ -20,8 +20,8 @@ Select(options: Array) | Name| Type| Mandatory| Default Value| Description| | ------ | ----------------------------------------------- | ---- | ------ | -------------- | - | value | [ResourceStr](../../ui/ts-types.md#ResourceStr) | Yes| - | Value of an option in the drop-down list box.| - | icon | [ResourceStr](../../ui/ts-types.md#ResourceStr) | No| - | Icon of an option in the drop-down list box.| + | value | [ResourceStr](../../ui/ts-types.md#resourcestr) | Yes| - | Value of an option in the drop-down list box.| + | icon | [ResourceStr](../../ui/ts-types.md#resourcestr) | No| - | Icon of an option in the drop-down list box.| ## Attributes @@ -30,13 +30,13 @@ Select(options: Array) | selected | number | - | Index of the initial selected option in the drop-down list box. The index of the first option is **0**.| | value | string | - | Text of the drop-down button.| | font | [Font](../../ui/ts-types.md) | - | Text font of the drop-down button.| -| fontColor | [ResourceColor](../../ui/ts-types.md#ResourceColor) | - | Text color of the drop-down button.| -| selectedOptionBgColor | [ResourceColor](../../ui/ts-types.md#ResourceColor) | - | Background color of the selected option in the drop-down list box.| +| fontColor | [ResourceColor](../../ui/ts-types.md#resourcecolor) | - | Text color of the drop-down button.| +| selectedOptionBgColor | [ResourceColor](../../ui/ts-types.md#resourcecolor) | - | Background color of the selected option in the drop-down list box.| | selectedOptionFont | [Font](../../ui/ts-types.md) | - | Text font of the selected option in the drop-down list box.| -| selectedOptionFontColor | [ResourceColor](../../ui/ts-types.md#ResourceColor) | - | Text color of the selected option in the drop-down list box.| -| optionBgColor | [ResourceColor](../../ui/ts-types.md#ResourceColor) | - | Background color of an option in the drop-down list box.| +| selectedOptionFontColor | [ResourceColor](../../ui/ts-types.md#resourcecolor) | - | Text color of the selected option in the drop-down list box.| +| optionBgColor | [ResourceColor](../../ui/ts-types.md#resourcecolor) | - | Background color of an option in the drop-down list box.| | optionFont | [Font](../../ui/ts-types.md) | - | Text font of an option in the drop-down list box.| -| optionFontColor | [ResourceColor](../../ui/ts-types.md#ResourceColor) | - | Text color of an option in the drop-down list box.| +| optionFontColor | [ResourceColor](../../ui/ts-types.md#resourcecolor) | - | Text color of an option in the drop-down list box.| ## Events diff --git a/en/application-dev/reference/arkui-ts/ts-basic-components-slider.md b/en/application-dev/reference/arkui-ts/ts-basic-components-slider.md index 009ab92e5a7e8646b6d7ba79b0ce0d34755ac809..5635d1fbed14354d7249b4499813f5c1e43eda94 100644 --- a/en/application-dev/reference/arkui-ts/ts-basic-components-slider.md +++ b/en/application-dev/reference/arkui-ts/ts-basic-components-slider.md @@ -1,242 +1,76 @@ -# Slider +# Slider ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -The **** component is used to quickly adjust settings, such as the volume and brightness. +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** +> This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -## Required Permissions + +The **<Slider>** component is used to quickly adjust settings, such as the volume and brightness. + + +## Required Permissions None -## Child Components + +## Child Components None -## APIs - -Slider\(value:\{value?: number, min?: number, max?: number, step?: number, style?: SliderStyle, direction?: Axis\}\) - -- Parameters - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

value

-

number

-

No

-

0

-

Current progress.

-

min

-

number

-

No

-

0

-

Minimum value.

-

max

-

number

-

No

-

100

-

Maximum value.

-

step

-

number

-

No

-

1

-

Step of the slider. When the corresponding step is set, the slider slides intermittently.

-

style

-

SliderStyle

-

No

-

SliderStyle.OutSet

-

Style of the slider.

-

direction8+

-

Axis

-

No

-

Axis.Horizontal

-

Whether the slider moves horizontally or vertically.

-
- -- SliderStyle enums - - - - - - - - - - - - - -

Name

-

Description

-

OutSet

-

The slider is on the slider rail.

-

InSet

-

The slider is in the slider rail.

-
- - -## Attributes + +## APIs + +Slider(value:{value?: number, min?: number, max?: number, step?: number, style?: SliderStyle, direction?: Axis}) + +- Parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | value | number | No | 0 | Current progress. | + | min | number | No | 0 | Minimum value. | + | max | number | No | 100 | Maximum value. | + | step | number | No | 1 | Step of the slider. When the corresponding step is set, the slider slides intermittently. | + | style | SliderStyle | No | SliderStyle.OutSet | Style of the slider. | + | direction8+ | [Axis](ts-appendix-enums.md) | No | Axis.Horizontal | Whether the slider moves horizontally or vertically. | + | reverse8+ | boolean | No | false | Whether the slider values are reversed. | + +- SliderStyle enums + | Name | Description | + | -------- | -------- | + | OutSet | The slider is on the slider rail. | + | InSet | The slider is in the slider rail. | + + +## Attributes Touch target configuration is not supported. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Default Value

-

Description

-

blockColor

-

Color

-

-

-

Color of the slider.

-

trackColor

-

Color

-

-

-

Background color of the slider.

-

selectedColor

-

Color

-

-

-

Color of the slider rail that has been slid.

-

showSteps

-

boolean

-

false

-

Whether to display the current step.

-

showTips

-

boolean

-

false

-

Whether to display a bubble to indicate the percentage when sliding.

-
- -## Events - -Among all the universal events, only **OnAppear** and **OnDisAppear** are supported. - - - - - - - - - - -

Name

-

Description

-

onChange(callback: (value: number, mode: SliderChangeMode) => void)

-

Callback invoked when the slider slides.

-

value: current progress.

-

mode: dragging state.

-
- -- SliderChangeMode enums - - - - - - - - - - - - - - - - -

Name

-

Description

-

Begin

-

The user starts to drag the slider.

-

Moving

-

The user is dragging the slider.

-

End

-

The user stops dragging the slider.

-
- - -## Example + | Name | Type | Default Value | Description | +| -------- | -------- | -------- | -------- | +| blockColor | Color | - | Color of the slider. | +| trackColor | Color | - | Background color of the slider. | +| selectedColor | Color | - | Color of the slider rail that has been slid. | +| showSteps | boolean | false | Whether to display the current step. | +| showTips | boolean | false | Whether to display a bubble to indicate the percentage when sliding. | + + +## Events + +Among all the universal events, only **OnAppear** and **OnDisAppear** are supported. + +| Name | Description | +| -------- | -------- | +| onChange(callback: (value: number, mode: SliderChangeMode) => void) | Callback invoked when the slider slides.
**value**: current progress.
**mode**: dragging state. | + +- SliderChangeMode enums + | Name | Description | + | -------- | -------- | + | Begin | The user starts to drag the slider. | + | Moving | The user is dragging the slider. | + | End | The user stops dragging the slider. | + + +## Example + ``` @Entry @@ -345,5 +179,4 @@ struct SliderExample { } ``` -![](figures/slider.gif) - +![en-us_image_0000001211898492](figures/en-us_image_0000001211898492.gif) diff --git a/en/application-dev/reference/arkui-ts/ts-basic-components-span.md b/en/application-dev/reference/arkui-ts/ts-basic-components-span.md index 5ff2deb2320b6195d66fb3ff38516ff3b59abc3a..568211d1bbc795d6242fa49597b03c871b9016ed 100644 --- a/en/application-dev/reference/arkui-ts/ts-basic-components-span.md +++ b/en/application-dev/reference/arkui-ts/ts-basic-components-span.md @@ -1,101 +1,53 @@ -# Span +# Span ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -The component is used to display a paragraph of textual information. It can be used only as a child component in the **** component. +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** +> This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -## Required Permissions + +The **<Span>** component is used to display a paragraph of textual information. It can be used only as a child component in the **<Text>** component. + + +## Required Permissions None -## Child Components + +## Child Components None -## APIs - -Span\(content: string\) - -- Parameters - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

content

-

string

-

Yes

-

-

-

Text content.

-
- - -## Attributes + +## APIs + +Span(content: string) + +- Parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | content | string | Yes | - | Text content. | + + +## Attributes In addition to the text style attributes, the attributes below are supported. - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Default Value

-

Description

-

decoration

-

{

-

type: TextDecorationType,

-

color?: Color

-

}

-

{

-

type: TextDecorationType.None

-

}

-

Style and color of the text decorative line.

-

textCase

-

TextCase

-

Normal

-

Text case.

-
- -## Events +| Name | Type | Default Value | Description | +| -------- | -------- | -------- | -------- | +| decoration | {
type: [TextDecorationType](ts-appendix-enums.md#textdecorationtype-enums),
color?: Color
} | {
type: TextDecorationType.None
} | Style and color of the text decorative line. | +| textCase | [TextCase](ts-appendix-enums.md#textcase-enums) | Normal | Text case. | + + +## Events Among all the universal events, only the click event is supported. ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->As the **** component does not have size information, the **target** attribute of the **ClickEvent** object returned by the click event is invalid. +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** +> As the **<Span>** component does not have size information, the **target** attribute of the **ClickEvent** object returned by the click event is invalid. + + +## Example -## Example ``` @Entry @@ -134,5 +86,4 @@ struct SpanExample { } ``` -![](figures/span.gif) - +![en-us_image_0000001257138363](figures/en-us_image_0000001257138363.gif) diff --git a/en/application-dev/reference/arkui-ts/ts-basic-components-text.md b/en/application-dev/reference/arkui-ts/ts-basic-components-text.md index 6973ed419c06f81dc200b425fa815ae79ec41e22..89ca41780e4a619c2628db67f2c205bd924d79c2 100644 --- a/en/application-dev/reference/arkui-ts/ts-basic-components-text.md +++ b/en/application-dev/reference/arkui-ts/ts-basic-components-text.md @@ -1,258 +1,80 @@ -# Text +# Text ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -The **** component is used to display a paragraph of textual information. +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** +> This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -## Required Permissions + +The **<Text>** component is used to display a paragraph of textual information. + + +## Required Permissions None -## Child Components - -The **** component can contain the child component [](ts-basic-components-span.md). - -## APIs - -Text\(content?: string\) - -- Parameters - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

content

-

string

-

No

-

''

-

Text content, which is the content of the child component <Span>. This parameter does not take effect when the child component <Span> is contained.

-
- - -## Attributes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Default Value

-

Description

-

textAlign

-

TextAlign

-

Start

-

Text alignment mode of multiple lines of text.

-

textOverflow

-

{overflow: TextOverflow}

-

{overflow: TextOverflow.Clip}

-

Display mode when the text is too long.

-

maxLines

-

number

-

Infinity

-

Maximum number of lines in the text.

-

lineHeight

-

Length

-

-

-

Text line height. If the value is less than or equal to 0, the line height is not limited and the font size is adaptive. If the value of the number type, the unit fp is used.

-

decoration

-

{

-

type: TextDecorationType,

-

color?: Color

-

}

-

{

-

type: TextDecorationType.None,

-

color: Color.Black

-

}

-

Style and color of the text decorative line.

-

baselineOffset

-

Length

-

-

-

Offset of the text baseline.

-

textCase

-

TextCase

-

Normal

-

Text case.

-
- -- TextAlign enums - - - - - - - - - - - - - - - - -

Name

-

Description

-

Center

-

The text is center-aligned.

-

Start

-

The text is aligned with the direction in which the text is written.

-

End

-

The text is aligned with the opposite direction in which the text is written.

-
- - -- TextOverflow enums - - - - - - - - - - - - - - - - -

Name

-

Description

-

Clip

-

Extra text is truncated.

-

Ellipsis

-

The ellipsis (...) is used for extra-long text.

-

None

-

No truncation or ellipsis is used for extra-long text.

-
- - -- TextDecorationType enums - - - - - - - - - - - - - - - - - - - -

Name

-

Description

-

Underline

-

An underline is used.

-

LineThrough

-

A strikethrough is used.

-

Overline

-

An overline is used.

-

None

-

No decorative line is used.

-
- - -- TextCase enums - - - - - - - - - - - - - - - - -

Name

-

Description

-

Normal

-

The original case of the text is retained.

-

LowerCase

-

All letters in the text are in lowercase.

-

UpperCase

-

All letters in the text are in uppercase.

-
- - ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->The **** component cannot contain both the text and the child component ****. If both of them exist, only the content in **** is displayed. - -## Example + +## Child Components + +The **<Text>** component can contain the child component [](../reference/arkui-ts/ts-basic-components-span.md). + + +## APIs + +Text(content?: string) + +- Parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | content | string | No | '' | Text content, which is the content of the child component **<Span>**. This parameter does not take effect when the child component **<Span>** is contained. | + + +## Attributes + +| Name | Type | Default Value | Description | +| -------- | -------- | -------- | -------- | +| textAlign | TextAlign | TextAlign.Start | Text alignment mode of multiple lines of text. | +| textOverflow | {overflow: TextOverflow} | {overflow: TextOverflow.Clip} | Display mode when the text is too long. | +| maxLines | number | Infinity | Maximum number of lines in the text. | +| lineHeight | Length | - | Text line height. If the value is less than or equal to **0**, the line height is not limited and the font size is adaptive. If the value of the number type, the unit fp is used. | +| decoration | {
type: TextDecorationType,
color?: Color
} | {
type: TextDecorationType.None,
color: Color.Black
} | Style and color of the text decorative line. | +| baselineOffset | Length | - | Offset of the text baseline. | +| textCase | TextCase | TextCase.Normal | Text case. | + +- TextAlign enums + | Name | Description | + | -------- | -------- | + | Center | The text is center-aligned. | + | Start | The text is aligned with the direction in which the text is written. | + | End | The text is aligned with the opposite direction in which the text is written. | + +- TextOverflow enums + | Name | Description | + | -------- | -------- | + | Clip | Extra text is truncated. | + | Ellipsis | The ellipsis (...) is used for extra-long text. | + | None | No truncation or ellipsis is used for extra-long text. | + +- TextDecorationType enums + | Name | Description | + | -------- | -------- | + | Underline | An underline is used. | + | LineThrough | A strikethrough is used. | + | Overline | An overline is used. | + | None | No decorative line is used. | + +- TextCase enums + | Name | Description | + | -------- | -------- | + | Normal | The original case of the text is retained. | + | LowerCase | All letters in the text are in lowercase. | + | UpperCase | All letters in the text are in uppercase. | + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** +> The **<Text>** component cannot contain both the text and the child component **<Span>**. If both of them exist, only the content in **<Span>** is displayed. + + +## Example + ``` @Entry @@ -290,7 +112,8 @@ struct TextExample1 { } ``` -![](figures/text1.gif) +![en-us_image_0000001257138337](figures/en-us_image_0000001257138337.gif) + ``` @Entry @@ -332,5 +155,4 @@ struct TextExample2 { } ``` -![](figures/text2.gif) - +![en-us_image_0000001257058391](figures/en-us_image_0000001257058391.gif) diff --git a/en/application-dev/reference/arkui-ts/ts-basic-components-textarea.md b/en/application-dev/reference/arkui-ts/ts-basic-components-textarea.md index 8ea07e9d812d3895368a806b700121997598e308..5f0d05bb0a5f8b57ad2e9e3336eefef0609cd7a6 100644 --- a/en/application-dev/reference/arkui-ts/ts-basic-components-textarea.md +++ b/en/application-dev/reference/arkui-ts/ts-basic-components-textarea.md @@ -1,168 +1,87 @@ -# TextArea +# TextArea ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -Provides the multi-line text input component. +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** +> This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -## Required Permissions + +The **<TextArea>** component provides multi-line text input. + + +## Required Permissions None -## Child Component + +## Child Component N/A -## APIs - -TextArea\(value?: \{ placeholder?: string \}\) - -- Parameters - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

placeholder

-

string

-

No

-

-

-

Text displayed when there is no input.

-
- - -## Attributes - -In addition to the attributes in [Universal Attributes](ts-universal-attributes.md), the following attributes are supported. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Default Value

-

Description

-

placeholderColor

-

Color

-

-

-

Placeholder text color.

-

placeholderFont

-

{

-

size?: number,

-

weight?:number | FontWeight,

-

family?: string,

-

style?: FontStyle

-

}

-

-

-

Placeholder text style.

-
  • size: font size. If the value is of the number type, the unit fp is used.
  • weight: font weight. For the number type, the value ranges from 100 to 900, at an interval of 100. The default value is 400. A larger value indicates a larger font weight.
  • family: font family. Use commas (,) to separate multiple fonts. The priority of the fonts is the sequence in which they are placed. An example value is Arial, sans-serif.
  • style: font style.
-

textAlign

-

TextAlign

-

TextAlign.Start

-

Sets the text horizontal alignment mode.

-

caretColor

-

Color

-

-

-

Sets the color of the cursor in the text box.

-
- -- TextAlign enumeration description - - - - - - - - - - - - - - - - -

Name

-

Description

-

Start

-

Aligns the header horizontally.

-

Center

-

Horizontal center alignment.

-

End

-

Align the tail horizontally.

-
- - -## Events - - - - - - - - - - -

Name

-

Description

-

onChange(callback: (value: string) => void)

-

When the input changes, the callback function is triggered.

-
- -## Example + +## APIs + +TextArea(value?:{placeholder?: string controller?: TextAreaController}) + +- Parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | placeholder | string | No | - | Text displayed when there is no input. | + | controller8+ | [TextAreaController](#textareacontroller8) | No | - | Text area controller. | + + +## Attributes + +In addition to [universal attributes](ts-universal-attributes.md), the following attributes are supported. + +| Name | Type | Default Value | Description | +| -------- | -------- | -------- | -------- | +| placeholderColor | Color | - | Placeholder text color. | +| placeholderFont | {
size?: number,
weight?:number \| [FontWeight](ts-universal-attributes-text-style.md),
family?: string,
style?: [FontStyle](ts-universal-attributes-text-style.md)
} | - | Placeholder text style.
- **size**: font size. If the value is of the number type, the unit fp is used.
- **weight**: font weight. For the number type, the value ranges from 100 to 900, at an interval of 100. The default value is **400**. A larger value indicates a larger font weight.
- **family**: font family. Use commas (,) to separate multiple fonts, for example, **'Arial, sans-serif'**. The priority of the fonts is the sequence in which they are placed.
- **style**: font style. | +| textAlign | TextAlign | Start | Sets the text horizontal alignment mode. | +| caretColor | Color | - | Sets the color of the cursor in the text box. | +| inputFilter8+ | {
value: [ResourceStr](../../ui/ts-types.md),
error?: (value: string)
} | - | Regular expression for input filtering. Only inputs that comply with the regular expression can be displayed. Other inputs are ignored. The specified regular expression can match single characters, but not strings. Example: ^(? =.\*\d)(? =.\*[a-z])(? =.\*[A-Z]).{8,10}$. Strong passwords containing 8 to 10 characters cannot be filtered.
- **value**: indicates the regular expression to set.
- **error**: returns the ignored content when regular expression matching fails. | + +- TextAlign enums + | Name | Description | + | -------- | -------- | + | Start | Aligns the header horizontally. | + | Center | Horizontal center alignment. | + | End | Align the tail horizontally. | + + +### TextAreaController8+ + +Defines the controller for controlling the **<TextArea>** component. + + | Name | Description | +| -------- | -------- | +| caretPosition(value: number): void | Position of the input cursor.
**value**: indicates the length from the start of the string to the position where the input cursor is located. | + + +## Events + + | Name | Description | +| -------- | -------- | +| onChange(callback: (value: string) => void) | Triggered when the input changes. | +| onCopy8+(callback:(value: string) => void) | Triggered when the copy button on the pasteboard, which displays when the text box is long pressed, is clicked.
**value**: text to be copied. | +| onCut8+(callback:(value: string) => void) | Triggered when the cut button on the pasteboard, which displays when the text box is long pressed, is clicked.
**value**: text to be cut. | +| onPaste8+(callback:(value: string) => void) | Triggered when the paste button on the pasteboard, which displays when the text box is long pressed, is clicked.
**value**: text to be pasted. | + + +## Example + + +### Multi-line Text Input + ``` @Entry @Component -struct TextAreaExample { +struct TextAreaExample2 { @State text: string = '' - build() { Column() { - TextArea({ placeholder: 'input your word' }) + TextArea({ placeholder: 'input your word'}) .placeholderColor("rgb(0,0,225)") .placeholderFont({ size: 30, weight: 100, family: 'cursive', style: FontStyle.Italic }) .textAlign(TextAlign.Center) @@ -173,6 +92,9 @@ struct TextAreaExample { .fontFamily("sans-serif") .fontStyle(FontStyle.Normal) .fontColor(Color.Red) + .inputFilter('^[\u4E00-\u9FA5A-Za-z0-9_]+$',(value: string) => { + console.info("hyb"+value) + }) .onChange((value: string) => { this.text = value }) @@ -182,5 +104,27 @@ struct TextAreaExample { } ``` -![](figures/textarea1.gif) +![en-us_image_0000001256858399](figures/en-us_image_0000001256858399.gif) + + +### Setting the Input Cursor + + +``` +@Entry +@Component +struct TextAreaTest { + controller: TextAreaController = new TextAreaController() + build() { + Column() { + TextArea({ placeholder: 'input your word',controller:this.controller }) + Button('caretPosition') + .onClick(() => { + this.controller.caretPosition(4) + }) + } + } +} +``` +![en-us_image_0000001212058476](figures/en-us_image_0000001212058476.png) diff --git a/en/application-dev/reference/arkui-ts/ts-basic-components-textinput.md b/en/application-dev/reference/arkui-ts/ts-basic-components-textinput.md index c2073e5be95e0abef7bccb498ab11d0d4a014702..e805c5feaacb318a1d68128cbb943c8310cb3620 100644 --- a/en/application-dev/reference/arkui-ts/ts-basic-components-textinput.md +++ b/en/application-dev/reference/arkui-ts/ts-basic-components-textinput.md @@ -1,268 +1,164 @@ -# TextInput +# TextInput ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -The **** component provides single-line text input. +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** +> This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -## Required Permissions + +The **<TextInput>** component provides single-line text input. + + +## Required Permissions None -## Child Components + +## Child Components None -## APIs - -TextInput\(value?: \{ placeholder?: string \}\) - -- Parameters - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

placeholder

-

string

-

No

-

-

-

Text displayed when there is no input.

-
- - -## Attributes - -In addition to the attributes in [Universal Attributes](ts-universal-attributes.md), the following attributes are supported. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Default Value

-

Description

-

type

-

InputType

-

InputType.Normal

-

Input box type.

-

placeholderColor

-

Color

-

-

-

Placeholder color.

-

placeholderFont

-

{

-

size?: Length,

-

weight?: number | FontWeight,

-

family?: string,

-

style?: FontStyle

-

}

-

-

-

Placeholder text style.

-
  • size: font size. If the value is of the number type, the unit fp is used.
  • weight: font weight. For the number type, the value ranges from 100 to 900, at an interval of 100. The default value is 400. A larger value indicates a larger font weight.
  • family: font family. Use commas (,) to separate multiple fonts. The priority of the fonts is the sequence in which they are placed. An example value is Arial, sans-serif.
  • style: font style.
-

enterKeyType

-

EnterKeyType

-

EnterKeyType.Done

-

How the Enter key is labeled.

-

caretColor

-

Color

-

-

-

Color of the caret (also known as the text insertion cursor).

-

maxLength

-

number

-

-

-

Maximum number of characters in the text input.

-
- -- EnterKeyType enums - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Description

-

Go

-

The Enter key is labeled "Go."

-

Search

-

The Enter key is labeled "Search."

-

Send

-

The Enter key is labeled "Send."

-

Next

-

The Enter key is labeled "Next."

-

Done

-

The Enter key is labeled "Done."

-
- - -- InputType enums - - - - - - - - - - - - - - - - - - - -

Name

-

Description

-

Normal

-

Normal input mode.

-

Password

-

Password input mode.

-

Email

-

Email address input mode.

-

Number

-

Digit input mode.

-
- - -## Events - - - - - - - - - - - - - - - - -

Name

-

Description

-

onChange(value: string) => void

-

Triggered when the input changes.

-

onSubmit(callback: (enterKey: EnterKeyType) => void)

-

Triggered when the Enter key on the physical or soft keyboard is pressed.

-

onEditChanged(callback: (isEditing: boolean) => void)

-

Triggered when the input status changes.

-
- -## Example + +## APIs + +TextInput(value?:{placeholder?: string controller?: TextInputController}) + +- Parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | placeholder | string | No | - | Text displayed when there is no input. | + | controller8+ | [TextInputController](#textinputcontroller8) | No | - | Text input controller. | + + +## Attributes + +In addition to [universal attributes](ts-universal-attributes.md), the following attributes are supported. + +| Name | Type | Default Value | Description | +| -------- | -------- | -------- | -------- | +| type | InputType | InputType.Normal | Input box type. | +| placeholderColor | Color | - | Placeholder color. | +| placeholderFont | {
size?: Length,
weight?: number\|[FontWeight](ts-universal-attributes-text-style.md),
family?: string,
style?: [FontStyle](ts-universal-attributes-text-style.md)
} | - | Placeholder text style.
- **size**: font size. If the value is of the number type, the unit fp is used.
- **weight**: font weight. For the number type, the value ranges from 100 to 900, at an interval of 100. The default value is **400**. A larger value indicates a larger font weight.
- **family**: font family. Use commas (,) to separate multiple fonts, for example, **'Arial, sans-serif'**. The priority of the fonts is the sequence in which they are placed.
- **style**: font style. | +| enterKeyType | EnterKeyType | EnterKeyType.Done | How the Enter key is labeled. | +| caretColor | Color | - | Color of the caret (also known as the text insertion cursor). | +| maxLength8+ | number | - | Maximum number of characters in the text input. | +| inputFilter8+ | {
value: [ResourceStr](../../ui/ts-types.md#resourcestr8),
error?: (value: string)
} | - | Regular expression for input filtering. Only inputs that comply with the regular expression can be displayed. Other inputs are ignored. The specified regular expression can match single characters, but not strings. Example: ^(? =.\*\d)(? =.\*[a-z])(? =.\*[A-Z]).{8,10}$. Strong passwords containing 8 to 10 characters cannot be filtered.
- **value**: indicates the regular expression to set.
- **error**: returns the ignored content when regular expression matching fails. | + +- EnterKeyType enums + | Name | Description | + | -------- | -------- | + | EnterKeyType.Go | The Enter key is labeled "Go." | + | EnterKeyType.Search | The Enter key is labeled "Search." | + | EnterKeyType.Send | The Enter key is labeled "Send." | + | EnterKeyType.Next | The Enter key is labeled "Next." | + | EnterKeyType.Done | The Enter key is labeled "Done." | + +- InputType enums + | Name | Description | + | -------- | -------- | + | InputType.Normal | Normal input mode. | + | InputType.Password | Password input mode. | + | InputType.Email | Email address input mode. | + | InputType.Number | Digit input mode. | + + +### TextInputController8+ + +Implements the controller of the **<TextInput>** component. + + | Name | Description | +| -------- | -------- | +| caretPosition(value: number):void | Position of the input cursor.
**value**: indicates the length from the start of the string to the position where the input cursor is located. | + + +### Objects to Import + + +``` +controller: TextInputController = new TextInputController() +``` + + +### controller.createPosition + +caretPosition(value: number): void + +Sets the cursor in a specified position. + +- Parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | value | number | Yes | - | Position of the input cursor.
**value**: indicates the length from the start of the string to the position where the input cursor is located. | + + +## Events + + | Name | Description | +| -------- | -------- | +| onChange(value: string) => void | Triggered when the input changes. | +| onSubmit(callback: (enterKey: EnterKeyType) => void) | Triggered when the Enter key on the physical or soft keyboard is pressed. | +| onEditChanged(callback: (isEditing: boolean) => void) | Triggered when the input status changes. | +| onCopy8+(callback:(value: string) => void) | Triggered when the copy button on the pasteboard, which displays when the text box is long pressed, is clicked.
**value**: text to be copied. | +| onCut8+(callback:(value: string) => void) | Triggered when the cut button on the pasteboard, which displays when the text box is long pressed, is clicked.
**value**: text to be cut. | +| onPaste8+(callback:(value: string) => void) | Triggered when the paste button on the pasteboard, which displays when the text box is long pressed, is clicked.
**value**: text to be pasted. | + + +## Example + + +### Single-line Text Input + + +``` +@Entry +@Component +struct TextAreaExample2 { + @State text: string = '' + + build() { + Column() { + TextArea({ placeholder: 'input your word' }) + .placeholderColor("rgb(0,0,225)") + .placeholderFont({ size: 30, weight: 100, family: 'cursive', style: FontStyle.Italic }) + .textAlign(TextAlign.Center) + .caretColor(Color.Blue) + .height(50) + .fontSize(30) + .fontWeight(FontWeight.Bold) + .fontFamily("sans-serif") + .fontStyle(FontStyle.Normal) + .fontColor(Color.Red) + .onChange((value: string) => { + this.text = value + }) + Text(this.text).width('90%') + } + } +} +``` + + +![en-us_image_0000001212378402](figures/en-us_image_0000001212378402.gif) + + +### Setting the Input Cursor + ``` @Entry @Component struct TextInputTest { @State text: string = '' - @State text1: string = '' - @State text2: string = '' + controller: TextInputController = new TextInputController() build() { - Column() { - TextInput({ placeholder: 'input your word' }) - .type(InputType.Normal) - .placeholderColor(Color.Blue) - .placeholderFont({ size: 40, weight: FontWeight.Normal, family: "sans-serif", style: FontStyle.Normal }) - .enterKeyType(EnterKeyType.Next) - .caretColor(Color.Green) - .height(60) - .fontSize(30) - .fontWeight(FontWeight.Bold) - .fontFamily("cursive") - .fontStyle(FontStyle.Italic) - .fontColor(Color.Red) - .maxLength(20) - .onChange((value: string) => { - this.text = value - }) - .onSubmit((enterKey) => { - this.text1 = 'onSubmit' - }) - .onEditChanged((isEditing) => { - this.text2 = 'onEditChanged' - }) - Text(this.text) - Text(this.text1) - Text(this.text2) + Column() { + TextInput({ placeholder: 'Please input your words.', controller:this.controller}) + Button('caretPosition') + .onClick(() => { + this.controller.caretPosition(4) + }) } } } ``` -![](figures/textinput1.gif) - +![en-us_image_0000001212058468](figures/en-us_image_0000001212058468.png) diff --git a/en/application-dev/reference/arkui-ts/ts-basic-components-textpicker.md b/en/application-dev/reference/arkui-ts/ts-basic-components-textpicker.md new file mode 100644 index 0000000000000000000000000000000000000000..c9557ccbc4b443674bb9f18a346064be7d8d7ac8 --- /dev/null +++ b/en/application-dev/reference/arkui-ts/ts-basic-components-textpicker.md @@ -0,0 +1,69 @@ +# TextPicker + + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** +> This component is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version. + + +The **<TextPicker>** component allows users to select text from a list of options. + + +## Required Permissions + +None + + +## Child Component + +None + + +## APIs + +TextPicker(value: {range: string[], selected?: number}) + +Creates a text picker based on the selection range specified by **range**. + +- Parameter + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | range | string[] | Yes | - | Data selection range of the picker. | + | selected | number | No | First element | Index value of the selected item in the array. | + + +## Attributes + + | Name | Type | Default Value | Description | +| -------- | -------- | -------- | -------- | +| defaultPickerItemHeight | Length | - | Default height of a Picker content item element. | + + +## Events + + | Name | Description | +| -------- | -------- | +| onChange(callback: (value: string, index: number) => void) | Triggered when an item in the picker is selected.
- **value**: text of the selected item.
- **index**: index of the selected item. | + + +## Example + + +``` +@Entry +@Component +struct TextPickerExample { + private select: number = 1 + private fruits: string[] = ['apple1', 'orange2', 'peach3', 'grape4'] + + build() { + Column() { + TextPicker({range: this.fruits, selected: this.select}) + .onChange((value: string, index: number) => { + console.info('Picker item changed, value: ' + value + ', index: ' + index) + }) + } + } +} +``` + +![en-us_image_0000001257058417](figures/en-us_image_0000001257058417.png) diff --git a/en/application-dev/reference/arkui-ts/ts-basic-components-texttimer.md b/en/application-dev/reference/arkui-ts/ts-basic-components-texttimer.md new file mode 100644 index 0000000000000000000000000000000000000000..a56349de2246384b00990476735a8876643a04ae --- /dev/null +++ b/en/application-dev/reference/arkui-ts/ts-basic-components-texttimer.md @@ -0,0 +1,94 @@ +# TextTimer + + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** +> This component is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version. + + +The **<TextTimer>** component supports custom time formats. + + +## Required Permissions + +None + + +## Child Components + +None + + +## APIs + +TextTimer(options: { isCountDown?: boolean, count?: number, controller?: TextTimerController }) + +- Parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | isCountDown | boolean | No | false | Whether to count down. | + | count | number | No | 60000 | Countdown time, in milliseconds. This parameter is valid only when **isCountDown** is set to **true**.
- If the value of **count** is less than or equal to 0, the default value is used.
- If the value of **count** is greater than 0, it is used. | + | controller | [TextTimerController](#texttimercontroller) | No | null | **<TextTimer>** controller. | + + +### TextTimerController + +Defines the controller for controlling the **<TextTimer>** component. + + | Name | Description | +| -------- | -------- | +| start() | Starts the timer. | +| pause() | Pauses the timer. | +| reset() | Resets the timer. | + + +## Attributes + + | Name | Type | Default Value | Description | +| -------- | -------- | -------- | -------- | +| format | string | 'hh:mm:ss.ms' | Custom format. The value must contain at least one of the following keywords: **hh**, **mm**, **ss**, and **ms**. | + + +## Events + + | Name | Description | +| -------- | -------- | +| onTimer(callback: (utc: number, elapsedTime: number) => void) | Triggered when the time text changes.
**utc**: currently displayed time, in milliseconds.
**elapsedTime**: elapsed time of the timer, in milliseconds. | + + +## Example + + +``` +@Entry +@Component +struct TextTimerExample { + myTimerController: TextTimerController = new TextTimerController() + @State format: string = 'hh:mm:ss.ms' + + build() { + Column() { + TextTimer({controller: this.myTimerController}) + .format(this.format) + .fontColor(Color.Black) + .fontSize(this.textSize) + .onTimer((utc: number, elapsedTime: number) => { + console.info('textTimer notCountDown utc is:' + utc + ', elapsedTime: ' + elapsedTime) + }) + Row() { + Button("start").onClick(() => { + this.myTimerController.start(); + }); + Button("pause").onClick(() => { + this.myTimerController.pause(); + }); + Button("reset").onClick(() => { + this.myTimerController.reset(); + }); + } + } + } +} +``` + + +![en-us_image_0000001257138345](figures/en-us_image_0000001257138345.gif) diff --git a/en/application-dev/reference/arkui-ts/ts-basic-components-toggle.md b/en/application-dev/reference/arkui-ts/ts-basic-components-toggle.md index 2d4f723cbbf7002e12748e661c13ad3f15345026..a969be1ae9968b38172a7a9d3f60bc1c2aa9e1be 100644 --- a/en/application-dev/reference/arkui-ts/ts-basic-components-toggle.md +++ b/en/application-dev/reference/arkui-ts/ts-basic-components-toggle.md @@ -1,145 +1,56 @@ -# Toggle +# Toggle ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->This component is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version. -## Required Permissions +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** +> This component is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version. + + +## Required Permissions None -## Child Components + +## Child Components None -## APIs - -Toggle\(options: \{ type: ToggleType, isOn?: boolean \}\) - -- Parameters - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

type

-

ToggleType

-

Yes

-

-

-

Type of the toggle.

-

isOn

-

boolean

-

No

-

false

-

Initial state of the toggle.

-
NOTE:

If isOn is not set during component creation, the selected state can be retained during component reuse. If isOn is set, the selected state needs to be retained during component reuse after the selected state is recorded using an event method.

-
-
- - -- ToggleType enums - - - - - - - - - - - - - - - - -

Name

-

Description

-

Checkbox

-

A checkbox is provided. The text setting of the child component does not take effect. If the text setting is required, you can place the <Text> component and the current component in the layout component.

-

Button

-

A button is provided. If the text setting is available, the corresponding text content is displayed inside the button.

-

Switch

-

A switch is provided. The text setting of the child component does not take effect. If the text setting is required, you can place the <Text> component and the current component in the layout component.

-
- - -## Attributes - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Default Value

-

Description

-

selectedColor

-

Color

-

-

-

Background color of the toggle when it is enabled.

-

switchPointColor

-

Color

-

-

-

Color of the circular slider of the Switch type.

-
NOTE:

This attribute is valid only when type is set to ToggleType.Switch.

-
-
- -## Events - - - - - - - - - - -

Name

-

Description

-

onChange(callback: (isOn: boolean) => void)

-

Triggered when the switch status changes.

-
- -## Example + +## APIs + +Toggle(options: { type: ToggleType, isOn?: boolean }) + +- Parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | type | ToggleType | Yes | - | Type of the toggle. | + | isOn | boolean | No | false | Initial state of the toggle.
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:**
> If **isOn** is not set during component creation, the selected state can be retained during component reuse. If **isOn** is set, the selected state needs to be retained during component reuse after the selected state is recorded using an event method. | + + +- ToggleType enums + | Name | Description | + | -------- | -------- | + | Checkbox | A checkbox is provided. The text setting of the child component does not take effect. If the text setting is required, you can place the **<Text>** component and the current component in the layout component. | + | Button | A button is provided. If the text setting is available, the corresponding text content is displayed inside the button. | + | Switch | A switch is provided. The text setting of the child component does not take effect. If the text setting is required, you can place the **<Text>** component and the current component in the layout component. | + + +## Attributes + + | Name | Type | Default Value | Description | +| -------- | -------- | -------- | -------- | +| selectedColor | Color | - | Background color of the toggle when it is enabled. | +| switchPointColor | Color | - | Color of the circular slider of the **Switch** type.
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:**
> This attribute is valid only when type is set to **ToggleType.Switch**. | + + +## Events + + | Name | Description | +| -------- | -------- | +| onChange(callback: (isOn: boolean) => void) | Triggered when the switch status changes. | + + +## Example + ``` @Entry @@ -204,5 +115,4 @@ struct ToggleExample { } ``` -![](figures/toggle.gif) - +![en-us_image_0000001211898522](figures/en-us_image_0000001211898522.gif) diff --git a/en/application-dev/reference/arkui-ts/ts-basic-components.md b/en/application-dev/reference/arkui-ts/ts-basic-components.md index 4d256bb16eafa12eaac506f2f931431abc08a772..657554b6f2feb37910b9991e8ecb79cf0ec8812c 100644 --- a/en/application-dev/reference/arkui-ts/ts-basic-components.md +++ b/en/application-dev/reference/arkui-ts/ts-basic-components.md @@ -1,37 +1,39 @@ -# Basic Components +# Basic Components -- **[Blank](ts-basic-components-blank.md)** -- **[Button](ts-basic-components-button.md)** -- **[DataPanel](ts-basic-components-datapanel.md)** +- **[Blank](ts-basic-components-blank.md)** -- **[Divider](ts-basic-components-divider.md)** +- **[Button](ts-basic-components-button.md)** -- **[Gauge](ts-basic-components-gauge.md)** +- **[DataPanel](ts-basic-components-datapanel.md)** -- **[Image](ts-basic-components-image.md)** +- **[DatePicker](ts-basic-components-datepicker.md)** -- **[ImageAnimator](ts-basic-components-imageanimator.md)** +- **[Divider](ts-basic-components-divider.md)** -- **[Marquee](ts-basic-components-marquee.md)** +- **[Image](ts-basic-components-image.md)** -- **[Progress](ts-basic-components-progress.md)** +- **[ImageAnimator](ts-basic-components-imageanimator.md)** -- **[QRCode](ts-basic-components-qrcode.md)** +- **[Progress](ts-basic-components-progress.md)** -- **[Rating](ts-basic-components-rating.md)** +- **[QRCode](ts-basic-components-qrcode.md)** -- **[Span](ts-basic-components-span.md)** +- **[Rating](ts-basic-components-rating.md)** -- **[Slider](ts-basic-components-slider.md)** +- **[Span](ts-basic-components-span.md)** -- **[Text](ts-basic-components-text.md)** +- **[Slider](ts-basic-components-slider.md)** -- **[TextArea](ts-basic-components-textarea.md)** +- **[Text](ts-basic-components-text.md)** -- **[TextInput](ts-basic-components-textinput.md)** +- **[TextArea](ts-basic-components-textarea.md)** -- **[Toggle](ts-basic-components-toggle.md)** +- **[TextInput](ts-basic-components-textinput.md)** +- **[TextPicker](ts-basic-components-textpicker.md)** +- **[TextTimer](ts-basic-components-texttimer.md)** + +- **[Toggle](ts-basic-components-toggle.md)** \ No newline at end of file diff --git a/en/application-dev/reference/arkui-ts/ts-basic-gestures-longpressgesture.md b/en/application-dev/reference/arkui-ts/ts-basic-gestures-longpressgesture.md index ffef167c0a41c16297c6de534e027ff2418031c2..952bf6d555f0997770a6d2e3ca5e783ec51bfe5b 100644 --- a/en/application-dev/reference/arkui-ts/ts-basic-gestures-longpressgesture.md +++ b/en/application-dev/reference/arkui-ts/ts-basic-gestures-longpressgesture.md @@ -1,120 +1,43 @@ -# LongPressGesture +# LongPressGesture ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->This gesture is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -## Required Permissions +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** +> This gesture is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. + + +## Required Permissions None -## APIs - -LongPressGesture\(options?: \{ fingers?: number, repeat?: boolean, duration?: number \}\) - -- Parameters - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

fingers

-

number

-

No

-

1

-

Minimum number of fingers to trigger a long press gesture. The value ranges from 1 to 10.

-

repeat

-

boolean

-

No

-

false

-

Whether to continuously trigger the event callback.

-

duration

-

number

-

No

-

500

-

Minimum hold-down time, in ms.

-
- - -## Events - - - - - - - - - - - - - - - - -

Name

-

Description

-

onAction((event?: LongPressGestureEvent) => void)

-

Callback invoked when a long press gesture is recognized.

-

onActionEnd((event?: LongPressGestureEvent) => void)

-

Callback invoked when the finger used for a long press gesture is lift.

-

onActionCancel(event: () => void)

-

Callback invoked when a tap cancellation event is received after a long press gesture is recognized.

-
- -- LongPressGestureEvent attributes8+ - - Inherited from [GestureEvent](ts-gesture-settings.md#table290mcpsimp). - - - - - - - - - - - - -

Name

-

Type

-

Description

-

repeat

-

boolean

-

Whether the event is repeated.

-
- - -## Example + +## APIs + +LongPressGesture(options?: { fingers?: number, repeat?: boolean, duration?: number }) + +- Parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | fingers | number | No | 1 | Minimum number of fingers to trigger a long press gesture. The value ranges from 1 to 10. | + | repeat | boolean | No | false | Whether to continuously trigger the event callback. | + | duration | number | No | 500 | Minimum hold-down time, in ms. | + + +## Events + + | Name | Description | +| -------- | -------- | +| onAction((event?: LongPressGestureEvent) => void) | Callback invoked when a long press gesture is recognized. | +| onActionEnd((event?: LongPressGestureEvent) => void) | Callback invoked when the finger used for a long press gesture is lift. | +| onActionCancel(event: () => void) | Callback invoked when a tap cancellation event is received after a long press gesture is recognized. | + +- LongPressGestureEvent8+ attributes + | Name | Type | Description | + | -------- | -------- | -------- | + | repeat | boolean | Whether the event is repeated. | + + +## Example + ``` @Entry @@ -142,5 +65,4 @@ struct LongPressGestureExample { } ``` -![](figures/longpressgesture.gif) - +![en-us_image_0000001257058425](figures/en-us_image_0000001257058425.gif) diff --git a/en/application-dev/reference/arkui-ts/ts-basic-gestures-pangesture.md b/en/application-dev/reference/arkui-ts/ts-basic-gestures-pangesture.md index 176c52260ab026e9a4d3e41eb7eb2355220170ea..9cf81839bae55d25d71ab296debbf4ea9c891283 100644 --- a/en/application-dev/reference/arkui-ts/ts-basic-gestures-pangesture.md +++ b/en/application-dev/reference/arkui-ts/ts-basic-gestures-pangesture.md @@ -1,223 +1,74 @@ -# PanGesture +# PanGesture ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->This gesture is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -## Required Permissions +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** +> This gesture is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. + + +## Required Permissions None -## APIs - -PanGesture\(options?: \{ fingers?: number, direction?: PanDirection, distance?: number \} | [PanGestureOption](#section14214195212149)\) - -- Parameters - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

fingers

-

number

-

No

-

1

-

Minimum number of fingers to trigger a long press gesture. The value ranges from 1 to 10.

-

direction

-

PanDirection

-

No

-

All

-

Slide direction. The enumerated value supports the AND (&) and OR (|) operations.

-

distance

-

number

-

No

-

5.0

-

Minimum slide recognition distance, in vp.

-
- -- PanDirection enums - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Description

-

All

-

All directions.

-

Horizontal

-

Horizontal slide.

-

Vertical

-

Vertical slide.

-

Left

-

Slide to the left.

-

Right

-

Slide to the right.

-

Up

-

Slide up.

-

Down

-

Slide down.

-

None

-

Slide disabled.

-
- - -### PanGestureOption - -The attributes of the slide gesture recognizer can be dynamically modified using the **PanGestureOption** AP. This avoids modifying attributes through status variables, which will cause the UI to be refreshed. - -PanGestureOption\(options?: \{ fingers?: number, direction?: PanDirection, distance?: number \}\) - -- Parameters - - For details, see the parameter description of [PanGesture](#li118312377710). - - -- APIs - - - - - - - - - - - - - - - - -

Name

-

Description

-

setDirection(value: PanDirection)

-

Sets the direction.

-

setDistance(value: number)

-

Sets the distance.

-

setFingers(value: number)

-

Sets the number of fingers.

-
- - -## Events - - - - - - - - - - - - - - - - - - - -

Name

-

Description

-

onActionStart(callback: (event?: PanGestureEvent) => void)

-

Callback for the pan gestures recognition event.

-

onActionUpdate(callback: (event?: PanGestureEvent) => void)

-

Callback for the pan gesture movement event.

-

onActionEnd(callback: (event?: PanGestureEvent) => void)

-

Callback for fingers pick-up.

-

onActionCancel(callback: () => void)

-

Callback for the touch cancellation event.

-
- -- PanGestureEvent attributes8+ - - Inherited from [GestureEvent](ts-gesture-settings.md#table290mcpsimp). - - - - - - - - - - - - - - - - -

Name

-

Type

-

Description

-

offsetX

-

number

-

Offset of the gesture event, in vp.

-

offsetY

-

number

-

Offset of the gesture event, in vp.

-
- - -## Example + +## APIs + +PanGesture(options?: { fingers?: number, direction?: PanDirection, distance?: number } | [PanGestureOption](#pangestureoption)) + +- Parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | fingers | number | No | 1 | Minimum number of fingers to trigger a long press gesture. The value ranges from 1 to 10. | + | direction | PanDirection | No | All | Slide direction. The enumerated value supports the AND (&) and OR (\|) operations. | + | distance | number | No | 5.0 | Minimum slide recognition distance, in vp. | + +- PanDirection enums + | Name | Description | + | -------- | -------- | + | All | All directions. | + | Horizontal | Horizontal slide. | + | Vertical | Vertical slide. | + | Left | Slide to the left. | + | Right | Slide to the right. | + | Up | Slide up. | + | Down | Slide down. | + | None | Slide disabled. | + + +### PanGestureOption + +The attributes of the slide gesture recognizer can be dynamically modified using the **PanGestureOption** AP. This avoids modifying attributes through status variables, which will cause the UI to be refreshed. + +PanGestureOption(options?: { fingers?: number, direction?: PanDirection, distance?: number }) + +- Parameters + For details, see **PanGesture**. + +- APIs + | Name | Description | + | -------- | -------- | + | setDirection(value: PanDirection) | Sets the direction. | + | setDistance(value: number) | Sets the distance. | + | setFingers(value: number) | Sets the number of fingers. | + + +## Events + + | Name | Description | +| -------- | -------- | +| onActionStart(callback: (event?: PanGestureEvent) => void) | Callback for the pan gestures reorganization event. | +| onActionUpdate(callback: (event?: PanGestureEvent) => void) | Callback invoked when a pan gesture is recognized. | +| onActionEnd(callback: (event?: PanGestureEvent) => void) | Callback invoked when the finger used for a pan gesture is lift. | +| onActionCancel(callback: () => void) | Callback invoked when a tap cancellation event is received after a pan gesture is recognized. | + +- PanGestureEvent8+ attributes + | Name | Type | Description | + | -------- | -------- | -------- | + | offsetX | number | Offset of the gesture event, in vp. | + | offsetY | number | Offset of the gesture event, in vp. | + + +## Example + ``` @Entry @@ -249,5 +100,4 @@ struct PanGestureExample { } ``` -![](figures/pangesture.gif) - +![en-us_image_0000001256978371](figures/en-us_image_0000001256978371.gif) diff --git a/en/application-dev/reference/arkui-ts/ts-basic-gestures-pinchgesture.md b/en/application-dev/reference/arkui-ts/ts-basic-gestures-pinchgesture.md index 0906de7217ea2259a8aad053fcc0f38ddd4e68f6..a3eab5de94e653faee5826987a619e45eb84faf9 100644 --- a/en/application-dev/reference/arkui-ts/ts-basic-gestures-pinchgesture.md +++ b/en/application-dev/reference/arkui-ts/ts-basic-gestures-pinchgesture.md @@ -1,128 +1,45 @@ -# PinchGesture +# PinchGesture ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->This gesture is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -## Required Permissions +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** +> This gesture is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. + + +## Required Permissions None -## APIs - -PinchGesture\(options?: \{ fingers?: number, distance?: number \}\) - -- Parameters - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

fingers

-

number

-

No

-

2

-

Minimum number of fingers to trigger a pinch. The value ranges from 2 to 5.

-

distance

-

number

-

No

-

3.0

-

Minimum recognition distance, in vp.

-
- - -## Events - - - - - - - - - - - - - - - - - - - -

Name

-

Description

-

onActionStart((event?: PinchGestureEvent) => void)

-

Callback invoked when a pinch gesture is recognized.

-

onActionUpdate((event?: PinchGestureEvent) => void)

-

Callback invoked during the movement of a pinch gesture.

-

onActionEnd((event?: PinchGestureEvent) => void)

-

Callback invoked when the finger used for a pinch gesture is lift.

-

onActionCancel(event: () => void)

-

Callback invoked when a tap cancellation event is received after a pinch gesture is recognized.

-
- -- PinchGestureEvent attributes8+ - - Inherited from [GestureEvent](ts-gesture-settings.md#table290mcpsimp). - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Description

-

scale

-

number

-

Scale ratio. This attribute is used for the pinch gesture.

-

pinchCenterX

-

number

-

X coordinate of the center of the pinch, in px.

-

pinchCenterY

-

number

-

Y coordinate of the center of the pinch, in px.

-
- - -## Example + +## APIs + +PinchGesture(options?: { fingers?: number, distance?: number }) + +- Parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | fingers | number | No | 2 | Minimum number of fingers to trigger a pinch. The value ranges from 2 to 5. | + | distance | number | No | 3.0 | Minimum recognition distance, in vp. | + + +## Events + + | Name | Description | +| -------- | -------- | +| onActionStart((event?: PinchGestureEvent) => void) | Callback invoked when a pinch gesture is recognized. | +| onActionUpdate((event?: PinchGestureEvent) => void) | Callback invoked during the movement of a pinch gesture. | +| onActionEnd((event?: PinchGestureEvent) => void) | Callback invoked when the finger used for a pinch gesture is lift. | +| onActionCancel(event: () => void) | Callback invoked when a tap cancellation event is received after a pinch gesture is recognized. | + +- PinchGestureEvent8+ attributes + | Name | Type | Description | + | -------- | -------- | -------- | + | scale | number | Scale ratio. This attribute is used for the pinch gesture. | + | pinchCenterX | number | X-coordinate of the center of the pinch gesture, in px. | + | pinchCenterY | number | Y-coordinate of the center of the pinch gesture, in px. | + + +## Example + ``` @Entry @@ -152,5 +69,4 @@ struct PinchGestureExample { } ``` -![](figures/pinchgesture.gif) - +![en-us_image_0000001257058419](figures/en-us_image_0000001257058419.gif) diff --git a/en/application-dev/reference/arkui-ts/ts-basic-gestures-rotationgesture.md b/en/application-dev/reference/arkui-ts/ts-basic-gestures-rotationgesture.md index a5b02f328549297bea12cb3f00c82afd3c77abfc..f8aba766277511d75bc2fa2b29bcb726e8c978e0 100644 --- a/en/application-dev/reference/arkui-ts/ts-basic-gestures-rotationgesture.md +++ b/en/application-dev/reference/arkui-ts/ts-basic-gestures-rotationgesture.md @@ -1,128 +1,43 @@ -# RotationGesture +# RotationGesture ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->This gesture is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -## Required Permissions +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** +> This gesture is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. + + +## Required Permissions None -## APIs - -RotationGesture\(options?: \{ fingers?: number, angle?: number \}\) - -- Parameters - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

fingers

-

number

-

No

-

2

-

Minimum number of fingers to trigger a rotation. The value ranges from 2 to 5.

-

angle

-

number

-

No

-

1.0

-

Minimum degree that can trigger the rotation gesture.

-
- - -## Events - - - - - - - - - - - - - - - - - - - -

Name

-

Description

-

onActionStart((event?: RotationGestureEvent) => void)

-

Callback invoked when a rotation gesture is recognized.

-

onActionUpdate((event?: RotationGestureEvent) => void)

-

Callback invoked during the movement of the rotation gesture.

-

onActionEnd((event?: RotationGestureEvent) => void)

-

Callback invoked when the finger used for the rotation gesture is lift.

-

onActionCancel(event: () => void)

-

Callback invoked when a tap cancellation event is received after the rotation gesture is recognized.

-
- -- RotationGestureEvent attributes8+ - - Inherited from [GestureEvent](ts-gesture-settings.md#table290mcpsimp). - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Description

-

angle

-

number

-

Rotation angle.

-

pinchCenterX

-

number

-

X coordinate of the center of the pinch, in px.

-

pinchCenterY

-

number

-

Y coordinate of the center of the pinch, in px.

-
- - -## Example + +## APIs + +RotationGesture(options?: { fingers?: number, angle?: number }) + +- Parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | fingers | number | No | 2 | Minimum number of fingers to trigger a rotation. The value ranges from 2 to 5. | + | angle | number | No | 1.0 | Minimum degree that can trigger the rotation gesture. | + + +## Events + + | Name | Description | +| -------- | -------- | +| onActionStart((event?: RotationGestureEvent) => void) | Callback invoked when a rotation gesture is recognized. | +| onActionUpdate((event?: RotationGestureEvent) => void) | Callback invoked during the movement of the rotation gesture. | +| onActionEnd((event?: RotationGestureEvent) => void) | Callback invoked when the finger used for the rotation gesture is lift. | +| onActionCancel(event: () => void) | Callback invoked when a tap cancellation event is received after the rotation gesture is recognized. | + +- RotationGestureEvent8+ attributes + | Name | Type | Description | + | -------- | -------- | -------- | + | angle | number | Rotation angle. | + + +## Example + ``` @Entry @@ -152,5 +67,4 @@ struct RotationGestureExample { } ``` -![](figures/rotationgesture.gif) - +![en-us_image_0000001256858403](figures/en-us_image_0000001256858403.gif) diff --git a/en/application-dev/reference/arkui-ts/ts-basic-gestures-swipegesture.md b/en/application-dev/reference/arkui-ts/ts-basic-gestures-swipegesture.md index 77bb943dc66d8e4a410a25196678f4d914e1ef79..f4431bc7986b9ebe020d6629e8f26ee766b75259 100644 --- a/en/application-dev/reference/arkui-ts/ts-basic-gestures-swipegesture.md +++ b/en/application-dev/reference/arkui-ts/ts-basic-gestures-swipegesture.md @@ -1,144 +1,50 @@ -# SwipeGesture +# SwipeGesture ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->This attribute is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version. -## Required Permissions +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** +> This gesture is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version. + + +## Required Permissions None -## APIs - -SwipeGesture\(value?: \{ fingers?: number; direction?: SwipeDirection; speed?: number \}\) - -- Parameters - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

fingers

-

number

-

No

-

1

-

Minimum number of fingers to trigger a swipe gesture. The value ranges from 1 to 10.

-

direction

-

SwipeDirection

-

No

-

SwipeDirection.All

-

Swipe direction

-

speed

-

number

-

No

-

100

-

Minimum speed of the swipe operation (100 vp/s).

-
- -- SwipeDirection enums - - - - - - - - - - - - - - - - -

Name

-

Description

-

All

-

All directions.

-

Horizontal

-

Horizontal direction.

-

Vertical

-

Vertical direction.

-
- - -## Events - - - - - - - - - - -

Name

-

Description

-

onAction(callback:(event?: SwipeGestureEvent) => void)

-

Callback for the swipe gesture recognition event.

-
- -- SwipeGestureEvent attributes - - Inherited from [GestureEvent](ts-gesture-settings.md#table290mcpsimp). - - - - - - - - - - - - - - - - -

Name

-

Type

-

Description

-

angle

-

number

-

Angle of the swipe gesture.

-

speed

-

number

-

Speed of the swipe gesture.

-
- - -## Example + +## APIs + +SwipeGesture(value?: { fingers?: number; direction?: SwipeDirection; speed?: number }) + +- Parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | fingers | number | No | 1 | Minimum number of fingers to trigger a swipe gesture. The value ranges from 1 to 10. | + | direction | SwipeDirection | No | SwipeDirection.All | Swipe direction. | + | speed | number | No | 100 | Minimum speed of the swipe gesture (100 vp/s). | + +- SwipeDirection enums + | Name | Description | + | -------- | -------- | + | All | All directions. | + | Horizontal | Horizontal direction. | + | Vertical | Vertical direction. | + + +## Events + + | Name | Description | +| -------- | -------- | +| onAction(callback:(event?: SwipeGestureEvent) => void) | Callback invoked when a swipe gesture is recognized. | + + +- SwipeGestureEvent attributes + | Name | Type | Description | + | -------- | -------- | -------- | + | angle | number | Angle of the swipe gesture. | + | speed | number | Speed of the swipe gesture. | + + +## Example + ``` @Entry @@ -149,8 +55,8 @@ struct SwipeGestureExample { build() { Column() { - Text("SwipGesture speed : " + this.speed) - Text("SwipGesture angle : " + this.rotateAngle) + Text("SwipGesture speed : " + this.speed) + Text("SwipGesture angle : " + this.rotateAngle) } .position({x: 80, y: 200}) .border({width:2}) @@ -167,5 +73,4 @@ struct SwipeGestureExample { } ``` -![](figures/gif-0.gif) - +![en-us_image_0000001257138365](figures/en-us_image_0000001257138365.gif) diff --git a/en/application-dev/reference/arkui-ts/ts-basic-gestures-tapgesture.md b/en/application-dev/reference/arkui-ts/ts-basic-gestures-tapgesture.md index 79dc179371733d521140bff5f07045ea09372e82..f0e6dd76bd653d1685b80e8e67b09b89cf4c18cf 100644 --- a/en/application-dev/reference/arkui-ts/ts-basic-gestures-tapgesture.md +++ b/en/application-dev/reference/arkui-ts/ts-basic-gestures-tapgesture.md @@ -1,85 +1,35 @@ -# TapGesture +# TapGesture ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->This gesture is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -## Required Permissions +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** +> This gesture is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. + + +## Required Permissions None -## APIs - -TapGesture\(options?: \{ count?: number, fingers?: number \}\) - -- Parameters - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

count

-

number

-

No

-

1

-

Number of consecutive taps. If this parameter is set to a value less than 1, the default value will be used.

-
NOTE:

If multi-tap is configured, the timeout interval between a lift and the next tap is 300 ms.

-
-

fingers

-

number

-

No

-

1

-

Minimum number of fingers to trigger a tap. The value ranges from 1 to 10.

-
NOTE:

1. When multi-finger is configured, if the number of fingers used for tap does not reach the specified number within 300 ms after the first finger is tapped, the gesture fails to be recognized.

-

2. Gesture recognition fails if the number of fingers used for tap exceeds the configured number.

-
-
- - -## Events - - - - - - - - - - -

Name

-

Description

-

onAction((event?: TapGestureEvent) => void)

-

Callback invoked when a tap gesture is recognized.

-
- -- TapGestureEvent attributes8+ - - Inherited from [GestureEvent](ts-gesture-settings.md#table290mcpsimp). - - -## Example + +## APIs + +TapGesture(options?: { count?: number, fingers?: number }) + +- Parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | count | number | No | 1 | Number of consecutive taps. If this parameter is set to a value less than **1**, the default value will be used.
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:**
> If multi-tap is configured, the timeout interval between a lift and the next tap is 300 ms. | + | fingers | number | No | 1 | Minimum number of fingers to trigger a tap. The value ranges from 1 to 10.
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:**
> 1. When multi-finger is configured, if the number of fingers used for tap does not reach the specified number within 300 ms after the first finger is tapped, the gesture fails to be recognized.

> 2. Gesture recognition fails if the number of fingers used for tap exceeds the configured number. | + + +## Events + + | Name | Description | +| -------- | -------- | +| onAction((event?: GestureEvent) => void) | Callback invoked when a tap gesture is recognized. | + + +## Example + ``` @Entry @@ -103,5 +53,4 @@ struct TapGestureExample { } ``` -![](figures/tapgesture.gif) - +![en-us_image_0000001256858417](figures/en-us_image_0000001256858417.gif) diff --git a/en/application-dev/reference/arkui-ts/ts-basic-gestures.md b/en/application-dev/reference/arkui-ts/ts-basic-gestures.md index 1dca7a6b84f0ef88837ed77e3530986a78a8f139..25046a17e29a8eb3effb693fcc1b698be32d24dd 100644 --- a/en/application-dev/reference/arkui-ts/ts-basic-gestures.md +++ b/en/application-dev/reference/arkui-ts/ts-basic-gestures.md @@ -1,15 +1,15 @@ -# Basic Gestures +# Basic Gestures -- **[TapGesture](ts-basic-gestures-tapgesture.md)** -- **[LongPressGesture](ts-basic-gestures-longpressgesture.md)** -- **[PanGesture](ts-basic-gestures-pangesture.md)** +- **[TapGesture](ts-basic-gestures-tapgesture.md)** -- **[PinchGesture](ts-basic-gestures-pinchgesture.md)** +- **[LongPressGesture](ts-basic-gestures-longpressgesture.md)** -- **[RotationGesture](ts-basic-gestures-rotationgesture.md)** +- **[PanGesture](ts-basic-gestures-pangesture.md)** -- **[SwipeGesture](ts-basic-gestures-swipegesture.md)** +- **[PinchGesture](ts-basic-gestures-pinchgesture.md)** +- **[RotationGesture](ts-basic-gestures-rotationgesture.md)** +- **[SwipeGesture](ts-basic-gestures-swipegesture.md)** \ No newline at end of file diff --git a/en/application-dev/reference/arkui-ts/ts-canvasrenderingcontext2d.md b/en/application-dev/reference/arkui-ts/ts-canvasrenderingcontext2d.md index 542885a1c19801d87cb3a26899ecd6d041aebf93..75926592770220faf93644706762de670b11feaf 100644 --- a/en/application-dev/reference/arkui-ts/ts-canvasrenderingcontext2d.md +++ b/en/application-dev/reference/arkui-ts/ts-canvasrenderingcontext2d.md @@ -1,274 +1,64 @@ -# CanvasRenderingContext2D - ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->This component is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version. - -Use **RenderingContext** to draw rectangles, text, images, and other objects on a canvas. - -## APIs - -CanvasRenderingContext2D\(setting: RenderingContextSettings\) - -- Parameters - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

setting

-

RenderingContextSettings

-

Yes

-

-

-

See RenderingContextSettings.

-
- - -### RenderingContextSettings - -RenderingContextSettings\(antialias?: bool\) - -Configures the settings of a **CanvasRenderingContext2D** object, including whether to enable antialiasing. - -- Parameters - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

antialias

-

bool

-

No

-

false

-

Whether antialiasing is enabled.

-
- - -## Attributes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Default Value

-

Description

-

fillStyle

-

<color> | CanvasGradient | CanvasPattern

-

-

-

Style to fill an area.

-
  • When the type is <color>, this parameter indicates the color of the filling area.
  • When the type is CanvasGradient, this parameter indicates a gradient object, which is created using the createLinearGradient method.
  • When the type is CanvasPattern, use the createPattern method to create a pattern.
-

lineWidth

-

number

-

-

-

Line width.

-

strokeStyle

-

<color> | CanvasGradient | CanvasPattern

-

-

-

Stroke style.

-
  • When the type is <color>, this parameter indicates the stroke color.
  • When the type is CanvasGradient, this parameter indicates a gradient object, which is created using the createLinearGradient method.
  • When the type is CanvasPattern, use the createPattern method to create a pattern.
-

lineCap

-

string

-

'butt'

-

Style of the specified line endpoint. The options are as follows:

-
  • butt: The endpoints of the line are squared off.
  • round: The endpoints of the line are rounded.
  • square: The endpoints of the line are squared off, and each endpoint has added a rectangle whose length is the same as the line thickness and whose width is half of the line thickness.
-

lineJoin

-

string

-

'miter'

-

Style of the intersection point between line segments. The options are as follows:

-
  • 'round': The intersection is a sector, whose radius at the rounded corner is equal to the line width.
  • 'bevel': The intersection is a triangle. The rectangular corner of each line is independent.
  • 'miter': The intersection has a miter corner by extending the outside edges of the lines until they meet. You can view the effect of this attribute in miterLimit.
-

miterLimit

-

number

-

10

-

Maximum miter length. The miter length is the distance between the inner corner and the outer corner where two lines meet.

-

font

-

string

-

'normal normal 14px sans-serif'

-

Font style.

-

Syntax: ctx.font="font-size font-family"

-
  • (Optional) font-size: font size and row height. The unit can only be pixels.
  • (Optional) font-family: font family.
-

Syntax: ctx.font="font-style font-weight font-size font-family"

-
  • (Optional) font-style: font style. Available values are 'normal' and 'italic'.
  • (Optional) font-weight: font weight. Available values are as follows: 'normal', 'bold', 'bolder', 'lighter', 100, 200, 300, 400, 500, 600, 700, 800, 900
  • (Optional) font-size: font size and row height. The unit can only be pixels.
  • (Optional) font-family: font family. Available values are 'sans-serif', 'serif', and 'monospace'.
-

textAlign

-

string

-

'left'

-

Text alignment mode. Available values are as follows:

-
  • 'left': The text is left-aligned.
  • 'right': The text is right-aligned.
  • 'center': The text is center-aligned.
  • 'start': The text is aligned with the start bound.
  • 'end': The text is aligned with the end bound.
-
NOTE:

In the ltr layout mode, the value 'start' equals 'left'. In the rtl layout mode, the value 'start' equals 'right'.

-
-

textBaseline

-

string

-

'alphabetic'

-

Horizontal alignment mode of text. Available values are as follows:

-
  • 'alphabetic': The text baseline is the normal alphabetic baseline.
  • 'top': The text baseline is on the top of the text bounding box.
  • 'hanging': The text baseline is a hanging baseline over the text.
  • 'middle': The text baseline is in the middle of the text bounding box.
  • 'ideographic': The text baseline is the ideographic baseline. If a character exceeds the alphabetic baseline, the ideographic baseline is located at the bottom of the excess character.
  • 'bottom': The text baseline is at the bottom of the text bounding box. Its difference from the ideographic baseline is that the ideographic baseline does not consider letters in the next line.
-

globalAlpha

-

number

-

-

-

Opacity. 0.0: completely transparent; 1.0: completely opaque.

-

lineDashOffset

-

number

-

0.0

-

Offset of the dashed line. The precision is float.

-

globalCompositeOperation

-

string

-

'source-over'

-

Composition operation type. Available values are as follows: 'source-over', 'source-atop', 'source-in', 'source-out', 'destination-over', 'destination-atop', 'destination-in', 'destination-out', 'lighter', 'copy', and 'xor'.

-

shadowBlur

-

number

-

0.0

-

Blur level during shadow drawing. A larger value indicates a more blurred effect. The precision is float.

-

shadowColor

-

<color>

-

-

-

Shadow color.

-

shadowOffsetX

-

number

-

-

-

X-axis shadow offset relative to the original object.

-

shadowOffsetY

-

number

-

-

-

Y-axis shadow offset relative to the original object.

-

imageSmoothingEnabled

-

boolean

-

true

-

Whether to adjust the image smoothness during image drawing. The value true means to enable this feature, and false means the opposite.

-

imageSmoothingQuality

-

string

-

'low'

-

Image smoothness. The value can be 'low', 'medium', or 'high'.

-
- ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->The value of the **** type can be in 'rgb\(255, 255, 255\)', 'rgba\(255, 255, 255, 1.0\)', or '\#FFFFFF' format. - -### fillStyle +# CanvasRenderingContext2D + + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** +> This component is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version. + + +Use **RenderingContext** to draw rectangles, text, images, and other objects on a canvas. + + +## APIs + +CanvasRenderingContext2D(setting: RenderingContextSetting) + +- Parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | setting | [RenderingContextSettings](#renderingcontextsettings) | Yes | - | See RenderingContextSettings. | + + +### RenderingContextSettings + +RenderingContextSettings(antialias?: bool) + +Configures the settings of a **CanvasRenderingContext2D** object, including whether to enable antialiasing. + +- Parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | antialias | bool | No | false | Whether antialiasing is enabled. | + + +## Attributes + +| Name | Type | Default Value | Description | +| -------- | -------- | -------- | -------- | +| [fillStyle](#fillstyle) | <color> \| [CanvasGradient](ts-components-canvas-canvasgradient.md) \| [CanvasPattern](#canvaspattern) | - | Style used to fill an area.
- When the type is **<color>**, this attribute indicates the fill color.
- When the type is **CanvasGradient**, this attribute indicates a gradient object, which is created using the [createLinearGradient](#createlineargradient) method.
- When the type is **CanvasPattern**, this attribute indicates a pattern, which is created using the [createPattern](#createpattern) method. | +| [lineWidth](#linewidth) | number | - | Line width. | +| [strokeStyle](#strokestyle) | <color> \| [CanvasGradient](ts-components-canvas-canvasgradient.md) \| [CanvasPattern](#canvaspattern) | - | Stroke style.
- When the type is **<color>**, this attribute indicates the stroke color.
- When the type is **CanvasGradient**, this attribute indicates a gradient object, which is created using the [createLinearGradient](#createlineargradient) method.
- When the type is **CanvasPattern**, this attribute indicates a pattern, which is created using the [createPattern](#createpattern) method. | +| [lineCap](#linecap) | string | 'butt' | Style of the line endpoints. The options are as follows:
- **'butt'**: The endpoints of the line are squared off.
- **'round'**: The endpoints of the line are rounded.
- **'square'**: The endpoints of the line are squared off by adding a box with an equal width and half the height of the line's thickness. | +| [lineJoin](#linejoin) | string | 'miter' | Style of the shape used to join line segments. The options are as follows:
- **'round'**: The shape used to join line segments is a rounded corner with the radius equal to the line width.
- **'bevel'**: The shape used to join line segments is a beveled corner. The rectangular corner of each line is independent.
- **'miter'**: The shape used to join line segments is a mitered corner. The corner is formed by extending the outside edges of the lines until they meet. You can adjust the effect of this attribute using **miterLimit**. | +| [miterLimit](#miterlimit) | number | 10 | Maximum miter length. The miter length is the distance between the inner corner and the outer corner where two lines meet. | +| [font](#font) | string | 'normal normal 14px sans-serif' | Font style.
Syntax: ctx.font='font-size font-family'
- (Optional) **font-size**: font size and row height. The unit can only be px.
- (Optional) **font-family**: font family.
Syntax: ctx.font='font-style font-weight font-size font-family'
- (Optional) **font-style**: font style. Available values are **'normal'** and **'italic'**.
- (Optional) **font-weight**: font weight. Available values are as follows: **'normal'**, **'bold'**, **'bolder'**, **'lighter'**, **100**, **200**, **300**, **400**, **500**, **600**, **700**, **800**, **900**
- (Optional) **font-size**: font size and row height. The unit can only be px.
- (Optional) **font-family**: font family. Available values are **'sans-serif'**, **'serif'**, and **'monospace'**. | +| [textAlign](#textalign) | string | 'left' | Text alignment mode. Available values are as follows:
- **'left'**: The text is left-aligned.
- **'right'**: The text is right-aligned.
- **'center'**: The text is center-aligned.
- **'start'**: The text is aligned with the start bound.
- **'end'**: The text is aligned with the end bound.
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:**
> In the **ltr** layout mode, the value **'start'** equals **'left'**. In the **rtl** layout mode, the value **'start'** equals **'right'**. | +| [textBaseline](#textbaseline) | string | 'alphabetic' | Horizontal alignment mode of text. Available values are as follows:
- **'alphabetic'**: The text baseline is the normal alphabetic baseline.
- **'top'**: The text baseline is on the top of the text bounding box.
- **'hanging'**: The text baseline is a hanging baseline over the text.
- **'middle'**: The text baseline is in the middle of the text bounding box.
- **'ideographic'**: The text baseline is the ideographic baseline. If a character exceeds the alphabetic baseline, the ideographic baseline is located at the bottom of the excess character.
- **'bottom'**: The text baseline is at the bottom of the text bounding box. Its difference from the ideographic baseline is that the ideographic baseline does not consider letters in the next line. | +| [globalAlpha](#globalalpha) | number | - | Opacity. **0.0**: completely transparent; **1.0**: completely opaque. | +| [lineDashOffset](#linedashoffset) | number | 0.0 | Offset of the dashed line. The precision is float. | +| [globalCompositeOperation](#globalcompositeoperation) | string | 'source-over' | Composition operation type. Available values are as follows: **'source-over'**, **'source-atop'**, **'source-in'**, **'source-out'**, **'destination-over'**, **'destination-atop'**, **'destination-in'**, **'destination-out'**, **'lighter'**, **'copy'**, and **'xor'**. | +| [shadowBlur](#shadowblur) | number | 0.0 | Blur level during shadow drawing. A larger value indicates a more blurred effect. The precision is float. | +| [shadowColor](#shadowcolor) | <color> | - | Shadow color. | +| [shadowOffsetX](#shadowoffsetx) | number | - | X-axis shadow offset relative to the original object. | +| [shadowOffsetY](#shadowoffsety) | number | - | Y-axis shadow offset relative to the original object. | +| [imageSmoothingEnabled](#imagesmoothingenabled) | boolean | true | Whether to adjust the image smoothness during image drawing. The value **true** means to enable this feature, and **false** means the opposite. | +| imageSmoothingQuality | string | 'low' | Image smoothness. The value can be **'low'**, **'medium'**, or **'high'**. | + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** +> The value of the **<color>** type can be in 'rgb(255, 255, 255)', 'rgba(255, 255, 255, 1.0)', or '\#FFFFFF' format. + + +### fillStyle + ``` @Entry @@ -294,9 +84,11 @@ struct FillStyleExample { } ``` -![](figures/en-us_image_0000001193322850.png) +![en-us_image_0000001257058395](figures/en-us_image_0000001257058395.png) + + +### lineWidth -### lineWidth ``` @Entry @@ -322,9 +114,11 @@ struct LineWidthExample { } ``` -![](figures/en-us_image_0000001238402745.png) +![en-us_image_0000001212378408](figures/en-us_image_0000001212378408.png) + + +### strokeStyle -### strokeStyle ``` @Entry @@ -351,9 +145,12 @@ struct StrokeStyleExample { } ``` -![](figures/en-us_image_0000001238282783.png) -### lineCap +![en-us_image_0000001212218446](figures/en-us_image_0000001212218446.png) + + +### lineCap + ``` @Entry @@ -383,9 +180,11 @@ struct LineCapExample { } ``` -![](figures/en-us_image_0000001193642802.png) +![en-us_image_0000001212378406](figures/en-us_image_0000001212378406.png) + + +### lineJoin -### lineJoin ``` @Entry @@ -416,9 +215,11 @@ struct LineJoinExample { } ``` -![](figures/en-us_image_0000001193802788.png) +![en-us_image_0000001212218438](figures/en-us_image_0000001212218438.png) + + +### miterLimit -### miterLimit ``` @Entry @@ -449,9 +250,11 @@ struct MiterLimit { } ``` -![](figures/en-us_image_0000001238522733.png) +![en-us_image_0000001212378398](figures/en-us_image_0000001212378398.png) + + +### font -### font ``` @Entry @@ -477,9 +280,11 @@ struct Font { } ``` -![](figures/en-us_image_0000001193482814.png) +![en-us_image_0000001257058409](figures/en-us_image_0000001257058409.png) + + +### textAlign -### textAlign ``` @Entry @@ -520,9 +325,11 @@ struct CanvasExample { } ``` -![](figures/en-us_image_0000001238602771.png) +![en-us_image_0000001256978351](figures/en-us_image_0000001256978351.png) + + +### textBaseline -### textBaseline ``` @Entry @@ -563,9 +370,11 @@ struct TextBaseline { } ``` -![](figures/en-us_image_0000001193322872.png) +![en-us_image_0000001212058462](figures/en-us_image_0000001212058462.png) + + +### globalAlpha -### globalAlpha ``` @Entry @@ -594,9 +403,11 @@ struct GlobalAlpha { } ``` -![](figures/en-us_image_0000001238402777.png) +![en-us_image_0000001212218444](figures/en-us_image_0000001212218444.png) + + +### lineDashOffset -### lineDashOffset ``` @Entry @@ -623,74 +434,25 @@ struct LineDashOffset { } ``` -![](figures/en-us_image_0000001238282827.png) - -### globalCompositeOperation - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Description

-

source-over

-

Displays the new drawing above the existing drawing. This attribute is used by default.

-

source-atop

-

Displays the new drawing on the top of the existing drawing.

-

source-in

-

Displays the new drawing inside the existing drawing.

-

source-out

-

Displays the part of the new drawing that is outside of the existing drawing.

-

destination-over

-

Displays the existing drawing above the new drawing.

-

destination-atop

-

Displays the existing drawing above the new drawing.

-

destination-in

-

Displays the existing drawing inside the new drawing.

-

destination-out

-

Displays the part of the existing drawing that is outside of the new drawing.

-

lighter

-

Displays both the new drawing and the existing drawing.

-

copy

-

Displays the new drawing and neglects the existing drawing.

-

xor

-

Combines the new drawing and existing drawing using the XOR operation.

-
+![en-us_image_0000001212058480](figures/en-us_image_0000001212058480.png) + + +### globalCompositeOperation + + | Name | Description | +| -------- | -------- | +| source-over | Displays the new drawing above the existing drawing. This attribute is used by default. | +| source-atop | Displays the new drawing on the top of the existing drawing. | +| source-in | Displays the new drawing inside the existing drawing. | +| source-out | Displays the part of the new drawing that is outside of the existing drawing. | +| destination-over | Displays the existing drawing above the new drawing. | +| destination-atop | Displays the existing drawing on the top of the new drawing. | +| destination-in | Displays the existing drawing inside the new drawing. | +| destination-out | Displays the part of the existing drawing that is outside of the new drawing. | +| lighter | Displays both the new drawing and the existing drawing. | +| copy | Displays the new drawing and neglects the existing drawing. | +| xor | Combines the new drawing and existing drawing using the XOR operation. | + ``` @Entry @@ -724,9 +486,11 @@ struct GlobalCompositeOperation { } ``` -![](figures/en-us_image_0000001193642848.png) +![en-us_image_0000001211898480](figures/en-us_image_0000001211898480.png) + + +### shadowBlur -### shadowBlur ``` @Entry @@ -754,9 +518,11 @@ struct ShadowBlur { } ``` -![](figures/en-us_image_0000001193802836.png) +![en-us_image_0000001256978343](figures/en-us_image_0000001256978343.png) + + +### shadowColor -### shadowColor ``` @Entry @@ -784,9 +550,11 @@ struct ShadowColor { } ``` -![](figures/en-us_image_0000001238522783.png) +![en-us_image_0000001257138353](figures/en-us_image_0000001257138353.png) + + +### shadowOffsetX -### shadowOffsetX ``` @Entry @@ -815,9 +583,11 @@ struct ShadowOffsetX { } ``` -![](figures/en-us_image_0000001193482866.png) +![en-us_image_0000001212218436](figures/en-us_image_0000001212218436.png) + + +### shadowOffsetY -### shadowOffsetY ``` @Entry @@ -845,9 +615,11 @@ struct ShadowOffsetY { } ``` -![](figures/en-us_image_0000001238602821.png) +![en-us_image_0000001212378410](figures/en-us_image_0000001212378410.png) + + +### imageSmoothingEnabled -### imageSmoothingEnabled ``` @Entry @@ -874,2932 +646,1399 @@ struct ImageSmoothingEnabled { } ``` -![](figures/en-us_image_0000001193322910.png) +![en-us_image_0000001211898472](figures/en-us_image_0000001211898472.png) -## Methods -### fillRect +## Methods -fillRect\(x: number, y: number, w: number, h: number\): void + +### fillRect + +fillRect(x: number, y: number, w: number, h: number): void Fills a rectangle on the canvas. -- Parameters - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

x

-

number

-

Yes

-

0

-

X-coordinate of the upper left corner of the rectangle.

-

y

-

number

-

Yes

-

0

-

Y-coordinate of the upper left corner of the rectangle.

-

width

-

number

-

Yes

-

0

-

Width of the rectangle.

-

height

-

number

-

Yes

-

0

-

Height of the rectangle.

-
- - -- Example - - ``` - @Entry - @Component - struct FillRect { - private settings: RenderingContextSettings = new RenderingContextSettings(true) - private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) - - build() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Canvas(this.context) - .width('100%') - .height('100%') - .backgroundColor('#ffff00') - .onReady(() =>{ - this.context.fillRect(0,30,100,100) - }) - } - .width('100%') - .height('100%') - } - } - ``` - - ![](figures/en-us_image_0000001193737314.png) - - -### strokeRect - -strokeRect\(x: number, y: number, w: number, h: number\): void - -Draws a rectangle stroke on the canvas. - -- Parameters - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

x

-

number

-

Yes

-

0

-

X-coordinate of the upper left corner of the rectangle stroke.

-

y

-

number

-

Yes

-

0

-

Y-coordinate of the upper left corner of the rectangle stroke.

-

width

-

number

-

Yes

-

0

-

Width of the rectangle.

-

height

-

number

-

Yes

-

0

-

Height of the rectangle.

-
- - -- Example - - ``` - @Entry - @Component - struct StrokeRect { - private settings: RenderingContextSettings = new RenderingContextSettings(true) - private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) - build() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Canvas(this.context) - .width('100%') - .height('100%') - .backgroundColor('#ffff00') - .onReady(() =>{ - this.context.strokeRect(30, 30, 200, 150) - }) +- Parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | x | number | Yes | 0 | X-coordinate of the upper left corner of the rectangle. | + | y | number | Yes | 0 | Y-coordinate of the upper left corner of the rectangle. | + | width | number | Yes | 0 | Width of the rectangle. | + | height | number | Yes | 0 | Height of the rectangle. | + +- Example + + ``` + @Entry + @Component + struct FillRect { + private settings: RenderingContextSettings = new RenderingContextSettings(true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.context.fillRect(0,30,100,100) + }) } - .width('100%') - .height('100%') + .width('100%') + .height('100%') + } + } + ``` + + ![en-us_image_0000001212218440](figures/en-us_image_0000001212218440.png) + + +### strokeRect + +strokeRect(x: number, y: number, w: number, h: number): void + +Draws an outlined rectangle on the canvas. + +- Parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | x | number | Yes | 0 | X-coordinate of the upper left corner of the rectangle. | + | y | number | Yes | 0 | Y-coordinate of the upper left corner of the rectangle. | + | width | number | Yes | 0 | Width of the rectangle. | + | height | number | Yes | 0 | Height of the rectangle. | + +- Example + + ``` + @Entry + @Component + struct StrokeRect { + private settings: RenderingContextSettings = new RenderingContextSettings(true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.context.strokeRect(30, 30, 200, 150) + }) } + .width('100%') + .height('100%') } - ``` + } + ``` - ![](figures/en-us_image_0000001238457271.png) + ![en-us_image_0000001257138359](figures/en-us_image_0000001257138359.png) -### clearRect +### clearRect -clearRect\(x: number, y: number, w: number, h: number\): void +clearRect(x: number, y: number, w: number, h: number): void Clears the content in a rectangle on the canvas. -- Parameters - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

x

-

number

-

Yes

-

0

-

X-coordinate of the upper left corner of the rectangle.

-

y

-

number

-

Yes

-

0

-

Y-coordinate of the upper left corner of the rectangle.

-

width

-

number

-

Yes

-

0

-

Width of the rectangle.

-

height

-

number

-

Yes

-

0

-

Height of the rectangle.

-
- - -- Example - - ``` - @Entry - @Component - struct ClearRect { - private settings: RenderingContextSettings = new RenderingContextSettings(true) - private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) - build() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Canvas(this.context) - .width('100%') - .height('100%') - .backgroundColor('#ffff00') - .onReady(() =>{ - this.context.fillStyle = 'rgb(0,0,255)' - this.context.fillRect(0,0,500,500) - this.context.clearRect(20,20,150,100) - }) - } - .width('100%') - .height('100%') +- Parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | x | number | Yes | 0 | X-coordinate of the upper left corner of the rectangle. | + | y | number | Yes | 0 | Y-coordinate of the upper left corner of the rectangle. | + | width | number | Yes | 0 | Width of the rectangle. | + | height | number | Yes | 0 | Height of the rectangle. | + +- Example + + ``` + @Entry + @Component + struct ClearRect { + private settings: RenderingContextSettings = new RenderingContextSettings(true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.context.fillStyle = 'rgb(0,0,255)' + this.context.fillRect(0,0,500,500) + this.context.clearRect(20,20,150,100) + }) } + .width('100%') + .height('100%') } - ``` + } + ``` - ![](figures/11111.png) + ![en-us_image_0000001211898482](figures/en-us_image_0000001211898482.png) -### fillText +### fillText -fillText\(text: string, x: number, y: number\): void +fillText(text: string, x: number, y: number): void Draws filled text on the canvas. -- Parameters - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

text

-

string

-

Yes

-

""

-

Text to draw.

-

x

-

number

-

Yes

-

0

-

X-coordinate of the lower left corner of the text.

-

y

-

number

-

Yes

-

0

-

Y-coordinate of the lower left corner of the text.

-
- - -- Example - - ``` - @Entry - @Component - struct FillText { - private settings: RenderingContextSettings = new RenderingContextSettings(true) - private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) - build() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Canvas(this.context) - .width('100%') - .height('100%') - .backgroundColor('#ffff00') - .onReady(() =>{ - this.context.font = '30px sans-serif' - this.context.fillText("Hello World!", 20, 100) - }) - } - .width('100%') - .height('100%') +- Parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | text | string | Yes | "" | Text to draw. | + | x | number | Yes | 0 | X-coordinate of the lower left corner of the text. | + | y | number | Yes | 0 | Y-coordinate of the lower left corner of the text. | + +- Example + + ``` + @Entry + @Component + struct FillText { + private settings: RenderingContextSettings = new RenderingContextSettings(true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.context.font = '30px sans-serif' + this.context.fillText("Hello World!", 20, 100) + }) } + .width('100%') + .height('100%') } - ``` + } + ``` - ![](figures/en-us_image_0000001238537297.png) + ![en-us_image_0000001257058399](figures/en-us_image_0000001257058399.png) -### strokeText +### strokeText -strokeText\(text: string, x: number, y: number\): void +strokeText(text: string, x: number, y: number): void Draws a text stroke on the canvas. -- Parameters - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

text

-

string

-

Yes

-

""

-

Text to draw.

-

x

-

number

-

Yes

-

0

-

X-coordinate of the lower left corner of the text.

-

y

-

number

-

Yes

-

0

-

Y-coordinate of the lower left corner of the text.

-
- - -- Example - - ``` - @Entry - @Component - struct StrokeText { - private settings: RenderingContextSettings = new RenderingContextSettings(true) - private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) - build() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Canvas(this.context) - .width('100%') - .height('100%') - .backgroundColor('#ffff00') - .onReady(() =>{ - this.context.font = '55px sans-serif' - this.context.strokeText("Hello World!", 20, 60) - }) - } - .width('100%') - .height('100%') +- Parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | text | string | Yes | "" | Text to draw. | + | x | number | Yes | 0 | X-coordinate of the lower left corner of the text. | + | y | number | Yes | 0 | Y-coordinate of the lower left corner of the text. | + +- Example + + ``` + @Entry + @Component + struct StrokeText { + private settings: RenderingContextSettings = new RenderingContextSettings(true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.context.font = '55px sans-serif' + this.context.strokeText("Hello World!", 20, 60) + }) } + .width('100%') + .height('100%') } - ``` - - ![](figures/en-us_image_0000001193756416.png) - - -### measureText - -measureText\(text: string\): TextMetrics - -Returns a **TextMetrics** object used to obtain the width of specified text. - -- Parameters - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

text

-

string

-

Yes

-

""

-

Text to be measured.

-
- - -- Return values - - - - - - - - - - -

Type

-

Description

-

TextMetrics

-

TextMetrics object.

-
- -- **TextMetrics** attributes - - - - - - - - - - - - -

Attribute

-

Type

-

Description

-

width

-

number

-

Width of the text string.

-
- - -- Example - - ``` - @Entry - @Component - struct MeasureText { - private settings: RenderingContextSettings = new RenderingContextSettings(true) - private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) - build() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Canvas(this.context) - .width('100%') - .height('100%') - .backgroundColor('#ffff00') - .onReady(() =>{ - this.context.font = '50px sans-serif' - this.context.fillText("Hello World!", 20, 100) - this.context.fillText("width:" + this.context.measureText("Hello World!").width, 20, 200) - }) - } - .width('100%') - .height('100%') + } + ``` + + ![en-us_image_0000001256978349](figures/en-us_image_0000001256978349.png) + + +### measureText + +measureText(text: string): TextMetrics + +Returns a **TextMetrics** object used to obtain the width of specified text. + +- Parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | text | string | Yes | "" | Text to be measured. | + +- Return value + | Type | Description | + | -------- | -------- | + | TextMetrics | **TextMetrics** object. | + +- **TextMetrics** attributes + | Name | Type | Description | + | -------- | -------- | -------- | + | width | number | Width of the text. | + +- Example + + ``` + @Entry + @Component + struct MeasureText { + private settings: RenderingContextSettings = new RenderingContextSettings(true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.context.font = '50px sans-serif' + this.context.fillText("Hello World!", 20, 100) + this.context.fillText("width:" + this.context.measureText("Hello World!").width, 20, 200) + }) } + .width('100%') + .height('100%') } - ``` + } + ``` - ![](figures/en-us_image_0000001238476361.png) + ![en-us_image_0000001257138343](figures/en-us_image_0000001257138343.png) -### stroke +### stroke -stroke\(path?: Path2D\): void +stroke(path?: Path2D): void Strokes a path. -- Parameters - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

path

-

Path2D

-

No

-

null

-

A Path2D path to draw.

-
- - -- Example - - ``` - @Entry - @Component - struct CanvasExample { - private settings: RenderingContextSettings = new RenderingContextSettings(true) - private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) - - build() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Canvas(this.context) - .width('100%') - .height('100%') - .backgroundColor('#ffff00') - .onReady(() =>{ - this.context.moveTo(25, 25) - this.context.lineTo(25, 105) - this.context.strokeStyle = 'rgb(0,0,255)' - this.context.stroke() - }) - } - .width('100%') - .height('100%') +- Parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | path | [Path2D](../reference/arkui-ts/ts-components-canvas-path2d.md) | No | null | A **Path2D** path to draw. | + +- Example + + ``` + @Entry + @Component + struct Stroke { + private settings: RenderingContextSettings = new RenderingContextSettings(true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.context.moveTo(25, 25) + this.context.lineTo(25, 105) + this.context.strokeStyle = 'rgb(0,0,255)' + this.context.stroke() + }) } + .width('100%') + .height('100%') } - ``` + } + ``` - ![](figures/en-us_image_0000001193436448.png) + ![en-us_image_0000001257058411](figures/en-us_image_0000001257058411.png) -### beginPath +### beginPath -beginPath\(\): void +beginPath(): void Creates a drawing path. -- Example - - ``` - @Entry - @Component - struct BeginPath { - private settings: RenderingContextSettings = new RenderingContextSettings(true) - private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) - - build() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Canvas(this.context) - .width('100%') - .height('100%') - .backgroundColor('#ffff00') - .onReady(() =>{ - this.context.beginPath() - this.context.lineWidth = 6 - this.context.strokeStyle = '#0000ff' - this.context.moveTo(15, 80) - this.context.lineTo(280, 160) - this.context.stroke() - }) - } - .width('100%') - .height('100%') +- Example + + ``` + @Entry + @Component + struct BeginPath { + private settings: RenderingContextSettings = new RenderingContextSettings(true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.context.beginPath() + this.context.lineWidth = 6 + this.context.strokeStyle = '#0000ff' + this.context.moveTo(15, 80) + this.context.lineTo(280, 160) + this.context.stroke() + }) } + .width('100%') + .height('100%') } - ``` + } + ``` - ![](figures/en-us_image_0000001238556395.png) + ![en-us_image_0000001212058478](figures/en-us_image_0000001212058478.png) -### moveTo +### moveTo -moveTo\(x: number, y: number\): void +moveTo(x: number, y: number): void Moves a drawing path to a target position on the canvas. -- Parameters - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

x

-

number

-

Yes

-

0

-

X-coordinate of the target position.

-

y

-

number

-

Yes

-

0

-

Y-coordinate of the target position.

-
- - -- Example - - ``` - @Entry - @Component - struct MoveTo { - private settings: RenderingContextSettings = new RenderingContextSettings(true) - private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) - - build() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Canvas(this.context) - .width('100%') - .height('100%') - .backgroundColor('#ffff00') - .onReady(() =>{ - this.context.beginPath() - this.context.moveTo(10, 10) - this.context.lineTo(280, 160) - this.context.stroke() - }) - } - .width('100%') - .height('100%') +- Parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | x | number | Yes | 0 | X-coordinate of the target position. | + | y | number | Yes | 0 | Y-coordinate of the target position. | + +- Example + + ``` + @Entry + @Component + struct MoveTo { + private settings: RenderingContextSettings = new RenderingContextSettings(true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.context.beginPath() + this.context.moveTo(10, 10) + this.context.lineTo(280, 160) + this.context.stroke() + }) } + .width('100%') + .height('100%') } - ``` + } + ``` - ![](figures/en-us_image_0000001193481094.png) + ![en-us_image_0000001256858391](figures/en-us_image_0000001256858391.png) -### lineTo +### lineTo -lineTo\(x: number, y: number\): void +lineTo(x: number, y: number): void Connects the current point to a target position using a straight line. -- Parameters - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

x

-

number

-

Yes

-

0

-

X-coordinate of the target position.

-

y

-

number

-

Yes

-

0

-

Y-coordinate of the target position.

-
- - -- Example - - ``` - @Entry - @Component - struct LineTo { - private settings: RenderingContextSettings = new RenderingContextSettings(true) - private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) - - build() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Canvas(this.context) - .width('100%') - .height('100%') - .backgroundColor('#ffff00') - .onReady(() =>{ - this.context.beginPath() - this.context.moveTo(10, 10) - this.context.lineTo(280, 160) - this.context.stroke() - }) - } - .width('100%') - .height('100%') +- Parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | x | number | Yes | 0 | X-coordinate of the target position. | + | y | number | Yes | 0 | Y-coordinate of the target position. | + +- Example + + ``` + @Entry + @Component + struct LineTo { + private settings: RenderingContextSettings = new RenderingContextSettings(true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.context.beginPath() + this.context.moveTo(10, 10) + this.context.lineTo(280, 160) + this.context.stroke() + }) } + .width('100%') + .height('100%') } - ``` + } + ``` - ![](figures/en-us_image_0000001238601051.png) + ![en-us_image_0000001212378414](figures/en-us_image_0000001212378414.png) -### closePath +### closePath -closePath\(\): void +closePath(): void Draws a closed path. -- Example - - ``` - @Entry - @Component - struct ClosePath { - private settings: RenderingContextSettings = new RenderingContextSettings(true) - private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) - - build() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Canvas(this.context) - .width('100%') - .height('100%') - .backgroundColor('#ffff00') - .onReady(() =>{ - this.context.beginPath() - this.context.moveTo(30, 30) - this.context.lineTo(110, 30) - this.context.lineTo(70, 90) - this.context.closePath() - this.context.stroke() - }) - } - .width('100%') - .height('100%') +- Example + + ``` + @Entry + @Component + struct ClosePath { + private settings: RenderingContextSettings = new RenderingContextSettings(true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.context.beginPath() + this.context.moveTo(30, 30) + this.context.lineTo(110, 30) + this.context.lineTo(70, 90) + this.context.closePath() + this.context.stroke() + }) } + .width('100%') + .height('100%') } - ``` + } + ``` - ![](figures/en-us_image_0000001193321136.png) + ![en-us_image_0000001256978347](figures/en-us_image_0000001256978347.png) -### createPattern +### createPattern -createPattern\(image: ImageBitmap, repetition: string\): void +createPattern(image: ImageBitmap, repetition: string): void Creates a pattern for image filling based on a specified source image and repetition mode. -- Parameters - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

image

-

ImageBitmap

-

Yes

-

null

-

Source image. For details, see ImageBitmap.

-

repetition

-

string

-

Yes

-

""

-

Repetition mode. The value can be 'repeat', 'repeat-x', 'repeat-y', or 'no-repeat'.

-
- -- Example - - ``` - @Entry - @Component - struct CreatePattern { - private settings: RenderingContextSettings = new RenderingContextSettings(true) - private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) - private img:ImageBitmap = new ImageBitmap("common/images/icon.jpg") - - build() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Canvas(this.context) - .width('100%') - .height('100%') - .backgroundColor('#ffff00') - .onReady(() =>{ - var pattern = this.context.createPattern(this.img, 'repeat') - this.context.fillStyle = pattern - this.context.fillRect(0, 0, 200, 200) - }) - } - .width('100%') - .height('100%') +- Parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | image | [ERROR:Invalid link:en-us_topic_0000001212378364.xml#en-us_topic_0000001193075104_xref1892917323814,link:en-us_topic_0000001192915114.xml](en-us_topic_0000001192915114.xml) | Yes | null | Source image. For details, see [ERROR:Invalid link:en-us_topic_0000001212378364.xml#xref539610179238,link:en-us_topic_0000001192915114.xml](en-us_topic_0000001192915114.xml). | + | repetition | string | Yes | "" | Repetition mode. The value can be **'repeat'**, **'repeat-x'**, **'repeat-y'**, or **'no-repeat'**. | + +- Example + + ``` + @Entry + @Component + struct CreatePattern { + private settings: RenderingContextSettings = new RenderingContextSettings(true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + private img:ImageBitmap = new ImageBitmap("common/images/icon.jpg") + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + var pattern = this.context.createPattern(this.img, 'repeat') + this.context.fillStyle = pattern + this.context.fillRect(0, 0, 200, 200) + }) } + .width('100%') + .height('100%') } - ``` + } + ``` - ![](figures/en-us_image_0000001238401029.png) + ![en-us_image_0000001211898490](figures/en-us_image_0000001211898490.png) -### bezierCurveTo +### bezierCurveTo -bezierCurveTo\(cp1x: number, cp1y: number, cp2x: number, cp2y: number, x: number, y: number\): void +bezierCurveTo(cp1x: number, cp1y: number, cp2x: number, cp2y: number, x: number, y: number): void Draws a cubic bezier curve on the canvas. -- Parameters - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

cp1x

-

number

-

Yes

-

0

-

X-coordinate of the first parameter of the bezier curve.

-

cp1y

-

number

-

Yes

-

0

-

Y-coordinate of the first parameter of the bezier curve.

-

cp2x

-

number

-

Yes

-

0

-

X-coordinate of the second parameter of the bezier curve.

-

cp2y

-

number

-

Yes

-

0

-

Y-coordinate of the second parameter of the bezier curve.

-

x

-

number

-

Yes

-

0

-

X-coordinate of the end point on the bezier curve.

-

y

-

number

-

Yes

-

0

-

Y-coordinate of the end point on the bezier curve.

-
- - -- Example - - ``` - @Entry - @Component - struct BezierCurveTo { - private settings: RenderingContextSettings = new RenderingContextSettings(true) - private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) - - build() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Canvas(this.context) - .width('100%') - .height('100%') - .backgroundColor('#ffff00') - .onReady(() =>{ - this.context.beginPath() - this.context.moveTo(10, 10) - this.context.bezierCurveTo(20, 100, 200, 100, 200, 20) - this.context.stroke() - }) - } - .width('100%') - .height('100%') +- Parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | cp1x | number | Yes | 0 | X-coordinate of the first parameter of the bezier curve. | + | cp1y | number | Yes | 0 | Y-coordinate of the first parameter of the bezier curve. | + | cp2x | number | Yes | 0 | X-coordinate of the second parameter of the bezier curve. | + | cp2y | number | Yes | 0 | Y-coordinate of the second parameter of the bezier curve. | + | x | number | Yes | 0 | X-coordinate of the end point on the bezier curve. | + | y | number | Yes | 0 | Y-coordinate of the end point on the bezier curve. | + +- Example + + ``` + @Entry + @Component + struct BezierCurveTo { + private settings: RenderingContextSettings = new RenderingContextSettings(true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.context.beginPath() + this.context.moveTo(10, 10) + this.context.bezierCurveTo(20, 100, 200, 100, 200, 20) + this.context.stroke() + }) } + .width('100%') + .height('100%') } - ``` + } + ``` - ![](figures/en-us_image_0000001238281067.png) + ![en-us_image_0000001257138349](figures/en-us_image_0000001257138349.png) -### quadraticCurveTo +### quadraticCurveTo -quadraticCurveTo\(cpx: number, cpy: number, x: number, y: number\): void +quadraticCurveTo(cpx: number, cpy: number, x: number, y: number): void Draws a quadratic curve on the canvas. -- Parameters - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

cpx

-

number

-

Yes

-

0

-

X-coordinate of the bezier curve parameter.

-

cpy

-

number

-

Yes

-

0

-

Y-coordinate of the bezier curve parameter.

-

x

-

number

-

Yes

-

0

-

X-coordinate of the end point on the bezier curve.

-

y

-

number

-

Yes

-

0

-

Y-coordinate of the end point on the bezier curve.

-
- - -- Example - - ``` - @Entry - @Component - struct QuadraticCurveTo { - private settings: RenderingContextSettings = new RenderingContextSettings(true); - private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings); - build() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Canvas(this.context) - .width('100%') - .height('100%') - .backgroundColor('#ffff00') - .onReady(() =>{ - this.context.beginPath(); - this.context.moveTo(20, 20); - this.context.quadraticCurveTo(100, 100, 200, 20); - this.context.stroke(); - }) - } - .width('100%') - .height('100%') +- Parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | cpx | number | Yes | 0 | X-coordinate of the bezier curve parameter. | + | cpy | number | Yes | 0 | Y-coordinate of the bezier curve parameter. | + | x | number | Yes | 0 | X-coordinate of the end point on the bezier curve. | + | y | number | Yes | 0 | Y-coordinate of the end point on the bezier curve. | + +- Example + + ``` + @Entry + @Component + struct QuadraticCurveTo { + private settings: RenderingContextSettings = new RenderingContextSettings(true); + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings); + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.context.beginPath(); + this.context.moveTo(20, 20); + this.context.quadraticCurveTo(100, 100, 200, 20); + this.context.stroke(); + }) } + .width('100%') + .height('100%') } - ``` + } + ``` - ![](figures/en-us_image_0000001193641084.png) + ![en-us_image_0000001257058397](figures/en-us_image_0000001257058397.png) -### arc +### arc -arc\(x: number, y: number, radius: number, startAngle: number, endAngle: number, anticlockwise?: boolean\): void +arc(x: number, y: number, radius: number, startAngle: number, endAngle: number, anticlockwise?: boolean): void Draws an arc on the canvas. -- Parameters - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

x

-

number

-

Yes

-

0

-

X-coordinate of the center point of the arc.

-

y

-

number

-

Yes

-

0

-

Y-coordinate of the center point of the arc.

-

radius

-

number

-

Yes

-

0

-

Radius of the arc.

-

startAngle

-

number

-

Yes

-

0

-

Start radian of the arc.

-

endAngle

-

number

-

Yes

-

0

-

End radian of the arc.

-

anticlockwise

-

boolean

-

No

-

false

-

Whether to draw the arc counterclockwise.

-
- - -- Example - - ``` - @Entry - @Component - struct Arc { - private settings: RenderingContextSettings = new RenderingContextSettings(true) - private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) - - build() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Canvas(this.context) - .width('100%') - .height('100%') - .backgroundColor('#ffff00') - .onReady(() =>{ - this.context.beginPath() - this.context.arc(100, 75, 50, 0, 6.28) - this.context.stroke() - }) - } - .width('100%') - .height('100%') +- Parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | x | number | Yes | 0 | X-coordinate of the center point of the arc. | + | y | number | Yes | 0 | Y-coordinate of the center point of the arc. | + | radius | number | Yes | 0 | Radius of the arc. | + | startAngle | number | Yes | 0 | Start radian of the arc. | + | endAngle | number | Yes | 0 | End radian of the arc. | + | anticlockwise | boolean | No | false | Whether to draw the arc counterclockwise. | + +- Example + + ``` + @Entry + @Component + struct Arc { + private settings: RenderingContextSettings = new RenderingContextSettings(true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.context.beginPath() + this.context.arc(100, 75, 50, 0, 6.28) + this.context.stroke() + }) } + .width('100%') + .height('100%') } - ``` + } + ``` - ![](figures/en-us_image_0000001193801070.png) + ![en-us_image_0000001212378404](figures/en-us_image_0000001212378404.png) -### arcTo +### arcTo -arcTo\(x1: number, y1: number, x2: number, y2: number, radius: number\): void +arcTo(x1: number, y1: number, x2: number, y2: number, radius: number): void Draws an arc based on the radius and points on the arc. -- Parameters - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

x1

-

number

-

Yes

-

0

-

X-coordinate of the first point on the arc.

-

y1

-

number

-

Yes

-

0

-

Y-coordinate of the first point on the arc.

-

x2

-

number

-

Yes

-

0

-

X-coordinate of the second point on the arc.

-

y2

-

number

-

Yes

-

0

-

Y-coordinate of the second point on the arc.

-

radius

-

number

-

Yes

-

0

-

Radius of the arc.

-
- - -- Example - - ``` - @Entry - @Component - struct ArcTo { - private settings: RenderingContextSettings = new RenderingContextSettings(true) - private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) - - build() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Canvas(this.context) - .width('100%') - .height('100%') - .backgroundColor('#ffff00') - .onReady(() =>{ - this.context.moveTo(100, 20); - this.context.arcTo(150, 20, 150, 70, 50); - this.context.stroke(); - }) - } - .width('100%') - .height('100%') +- Parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | x1 | number | Yes | 0 | X-coordinate of the first point on the arc. | + | y1 | number | Yes | 0 | Y-coordinate of the first point on the arc. | + | x2 | number | Yes | 0 | X-coordinate of the second point on the arc. | + | y2 | number | Yes | 0 | Y-coordinate of the second point on the arc. | + | radius | number | Yes | 0 | Radius of the arc. | + +- Example + + ``` + @Entry + @Component + struct ArcTo { + private settings: RenderingContextSettings = new RenderingContextSettings(true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.context.moveTo(100, 20); + this.context.arcTo(150, 20, 150, 70, 50); + this.context.stroke(); + }) } + .width('100%') + .height('100%') } - ``` + } + ``` - ![](figures/en-us_image_0000001238521019.png) + ![en-us_image_0000001257058413](figures/en-us_image_0000001257058413.png) -### ellipse +### ellipse -ellipse\(x: number, y: number, radiusX: number, radiusY: number, rotation: number, startAngle: number, endAngle: number, anticlockwise?: boolean\): void +ellipse(x: number, y: number, radiusX: number, radiusY: number, rotation: number, startAngle: number, endAngle: number, anticlockwise?: boolean): void Draws an ellipse in the specified rectangular region. -- Parameters - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

x

-

number

-

Yes

-

0

-

X-coordinate of the ellipse center.

-

y

-

number

-

Yes

-

0

-

Y-coordinate of the ellipse center.

-

radiusX

-

number

-

Yes

-

0

-

Ellipse radius on the x-axis.

-

radiusY

-

number

-

Yes

-

0

-

Ellipse radius on the y-axis.

-

rotation

-

number

-

Yes

-

0

-

Rotation angle of the ellipse, in radians.

-

startAngle

-

number

-

Yes

-

0

-

Angle of the start point for drawing the ellipse, in radians.

-

endAngle

-

number

-

Yes

-

0

-

Angle of the end point for drawing the ellipse, in radians.

-

anticlockwise

-

number

-

No

-

0

-

Whether to draw the ellipse in the counterclockwise direction. The value 0 means to draw the ellipse in the clockwise direction, and 1 means to draw the ellipse in the counterclockwise direction. This parameter is optional. The default value is 0.

-
- - -- Example - - ``` - @Entry - @Component - struct Ellipse { - private settings: RenderingContextSettings = new RenderingContextSettings(true) - private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) - - build() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Canvas(this.context) - .width('100%') - .height('100%') - .backgroundColor('#ffff00') - .onReady(() =>{ - this.context.beginPath() - this.context.ellipse(200, 200, 50, 100, Math.PI * 0.25, Math.PI * 0.5, Math.PI, true) - this.context.stroke() - }) - Button('back') - .onClick(() => { - router.back() - }) - } - .width('100%') - .height('100%') +- Parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | x | number | Yes | 0 | X-coordinate of the ellipse center. | + | y | number | Yes | 0 | Y-coordinate of the ellipse center. | + | radiusX | number | Yes | 0 | Ellipse radius on the x-axis. | + | radiusY | number | Yes | 0 | Ellipse radius on the y-axis. | + | rotation | number | Yes | 0 | Rotation angle of the ellipse, in radians. | + | startAngle | number | Yes | 0 | Angle of the start point for drawing the ellipse, in radians. | + | endAngle | number | Yes | 0 | Angle of the end point for drawing the ellipse, in radians. | + | anticlockwise | boolean | No | false | Whether to draw the ellipse in the counterclockwise direction. | + +- Example + + + ``` + @Entry + @Component + struct CanvasExample { + private settings: RenderingContextSettings = new RenderingContextSettings(true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.context.beginPath() + this.context.ellipse(200, 200, 50, 100, Math.PI * 0.25, Math.PI * 0.5, Math.PI) + this.context.stroke() + }) } + .width('100%') + .height('100%') } - ``` + } + ``` - ![](figures/en-us_image_0000001193481096.png) + ![en-us_image_0000001256978339](figures/en-us_image_0000001256978339.png) -### rect +### rect -rect\(x: number, y: number, width: number, height: number\): void +rect(x: number, y: number, width: number, height: number): void Creates a rectangle. -- Parameters - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

x

-

number

-

Yes

-

0

-

X-coordinate of the upper left corner of the rectangle.

-

y

-

number

-

Yes

-

0

-

Y-coordinate of the upper left corner of the rectangle.

-

width

-

number

-

Yes

-

0

-

Width of the rectangle.

-

height

-

number

-

Yes

-

0

-

Height of the rectangle.

-
- - -- Example - - ``` - @Entry - @Component - struct CanvasExample { - private settings: RenderingContextSettings = new RenderingContextSettings(true) - private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) - - build() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Canvas(this.context) - .width('100%') - .height('100%') - .backgroundColor('#ffff00') - .onReady(() =>{ - this.context.rect(20, 20, 100, 100) // Create a 100*100 rectangle at (20, 20) - this.context.stroke() - }) - } - .width('100%') - .height('100%') +- Parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | x | number | Yes | 0 | X-coordinate of the upper left corner of the rectangle. | + | y | number | Yes | 0 | Y-coordinate of the upper left corner of the rectangle. | + | width | number | Yes | 0 | Width of the rectangle. | + | height | number | Yes | 0 | Height of the rectangle. | + +- Example + + ``` + @Entry + @Component + struct CanvasExample { + private settings: RenderingContextSettings = new RenderingContextSettings(true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.context.rect(20, 20, 100, 100) // Create a 100*100 rectangle at (20, 20) + this.context.stroke() + }) } + .width('100%') + .height('100%') } - ``` + } + ``` - ![](figures/en-us_image_0000001238601053.png) + ![en-us_image_0000001256978341](figures/en-us_image_0000001256978341.png) -### fill +### fill -fill\(\): void +fill(): void Fills the area inside a closed path. -- Example - - ``` - @Entry - @Component - struct Fill { - private settings: RenderingContextSettings = new RenderingContextSettings(true) - private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) - - build() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Canvas(this.context) - .width('100%') - .height('100%') - .backgroundColor('#ffff00') - .onReady(() =>{ - this.context.rect(20, 20, 100, 100) // Create a 100*100 rectangle at (20, 20) - this.context.fill() - }) - } - .width('100%') - .height('100%') +- Example + + ``` + @Entry + @Component + struct Fill { + private settings: RenderingContextSettings = new RenderingContextSettings(true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.context.rect(20, 20, 100, 100) // Create a 100*100 rectangle at (20, 20) + this.context.fill() + }) } + .width('100%') + .height('100%') } - ``` + } + ``` - ![](figures/en-us_image_0000001193321138.png) + ![en-us_image_0000001256858389](figures/en-us_image_0000001256858389.png) -### clip +### clip -clip\(\): void +clip(): void Sets the current path to a clipping path. -- Example - - ``` - @Entry - @Component - struct Clip { - private settings: RenderingContextSettings = new RenderingContextSettings(true) - private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) - - build() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Canvas(this.context) - .width('100%') - .height('100%') - .backgroundColor('#ffff00') - .onReady(() =>{ - this.context.rect(0, 0, 200, 200) - this.context.stroke() - this.context.clip() - this.context.fillStyle = "rgb(255,0,0)" - this.context.fillRect(0, 0, 150, 150) - }) - Button('back') - .onClick(() => { - router.back() - }) - } - .width('100%') - .height('100%') +- Example + + ``` + @Entry + @Component + struct Clip { + private settings: RenderingContextSettings = new RenderingContextSettings(true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.context.rect(0, 0, 200, 200) + this.context.stroke() + this.context.clip() + this.context.fillStyle = "rgb(255,0,0)" + this.context.fillRect(0, 0, 150, 150) + }) } + .width('100%') + .height('100%') } - ``` + } + ``` - ![](figures/en-us_image_0000001238401031.png) + ![en-us_image_0000001211898488](figures/en-us_image_0000001211898488.png) -### rotate +### rotate -rotate\(rotate: number\): void +rotate(rotate: number): void Rotates a canvas clockwise around its coordinate axes. -- Parameters - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

rotate

-

number

-

Yes

-

0

-

Clockwise rotation angle. You can use Math.PI / 180 to convert the angle to a radian.

-
- - -- Example - - ``` - @Entry - @Component - struct Rotate { - private settings: RenderingContextSettings = new RenderingContextSettings(true) - private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) - - build() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Canvas(this.context) - .width('100%') - .height('100%') - .backgroundColor('#ffff00') - .onReady(() =>{ - this.context.rotate(45 * Math.PI / 180) // Rotate the rectangle 45 degrees - this.context.fillRect(70, 20, 50, 50) - }) - } - .width('100%') - .height('100%') +- Parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | rotate | number | Yes | 0 | Clockwise rotation angle. You can use **Math.PI / 180** to convert the angle to a radian. | + +- Example + + ``` + @Entry + @Component + struct Rotate { + private settings: RenderingContextSettings = new RenderingContextSettings(true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.context.rotate(45 * Math.PI / 180) // Rotate the rectangle 45 degrees + this.context.fillRect(70, 20, 50, 50) + }) } + .width('100%') + .height('100%') } - ``` - - ![](figures/en-us_image_0000001238281069.png) - - -### scale - -scale\(x: number, y: number\): void - -Scales a canvas based on scaling factors. - -- Parameters - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

x

-

number

-

Yes

-

0

-

Horizontal scale factor.

-

y

-

number

-

Yes

-

0

-

Vertical scale factor.

-
- - -- Example - - ``` - @Entry - @Component - struct Scale { - private settings: RenderingContextSettings = new RenderingContextSettings(true) - private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) - - build() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Canvas(this.context) - .width('100%') - .height('100%') - .backgroundColor('#ffff00') - .onReady(() =>{ - this.context.strokeRect(10, 10, 25, 25) - this.context.scale(2, 2) // Scale to 200% - this.context.strokeRect(10, 10, 25, 25) - }) - } - .width('100%') - .height('100%') + } + ``` + + ![en-us_image_0000001212218442](figures/en-us_image_0000001212218442.png) + + +### scale + +scale(x: number, y: number): void + +Scales a canvas based on scale factors. + +- Parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | x | number | Yes | 0 | Horizontal scale factor. | + | y | number | Yes | 0 | Vertical scale factor. | + +- Example + + ``` + @Entry + @Component + struct Scale { + private settings: RenderingContextSettings = new RenderingContextSettings(true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.context.strokeRect(10, 10, 25, 25) + this.context.scale(2, 2) // Scale to 200% + this.context.strokeRect(10, 10, 25, 25) + }) } + .width('100%') + .height('100%') } - ``` + } + ``` - ![](figures/en-us_image_0000001193641086.png) + ![en-us_image_0000001257138347](figures/en-us_image_0000001257138347.png) -### transform +### transform -transform\(scaleX: number, skewX: number, skewY: number, scaleY: number, translateX: number, translateY: number\): void +transform(scaleX: number, skewX: number, skewY: number, scaleY: number, translateX: number, translateY: number): void Defines a transformation matrix. To transform a graph, you only need to set parameters of the matrix. The coordinates of the graph are multiplied by the matrix values to obtain new coordinates of the transformed graph. You can use the matrix to implement multiple transform effects. ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->The following formulas calculate coordinates of the transformed graph. **x** and **y** represent coordinates before transformation, and **x'** and **y'** represent coordinates after transformation. ->- x' = scaleX \* x + skewY \* y + translateX ->- y' = skewX \* x + scaleY \* y + translateY - -- Parameters - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

scaleX

-

number

-

Yes

-

0

-

X-axis scale.

-

skewX

-

number

-

Yes

-

0

-

X-axis skew.

-

skewY

-

number

-

Yes

-

0

-

Y-axis skew.

-

scaleY

-

number

-

Yes

-

0

-

Y-axis scale.

-

translateX

-

number

-

Yes

-

0

-

X-axis translation.

-

translateY

-

number

-

Yes

-

0

-

Y-axis translation.

-
- -- Example - - ``` - @Entry - @Component - struct Transform { - private settings: RenderingContextSettings = new RenderingContextSettings(true) - private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) - build() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Canvas(this.context) - .width('100%') - .height('100%') - .backgroundColor('#ffff00') - .onReady(() =>{ - this.context.fillStyle = 'rgb(0,0,0)' - this.context.fillRect(0, 0, 100, 100) - this.context.transform(1, 0.5, -0.5, 1, 10, 10) - this.context.fillStyle = 'rgb(255,0,0)' - this.context.fillRect(0, 0, 100, 100) - this.context.transform(1, 0.5, -0.5, 1, 10, 10) - this.context.fillStyle = 'rgb(0,0,255)' - this.context.fillRect(0, 0, 100, 100) - }) - } - .width('100%') - .height('100%') +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** +> The following formulas calculate coordinates of the transformed graph. **x** and **y** represent coordinates before transformation, and **x'** and **y'** represent coordinates after transformation. +> +> - x' = scaleX \* x + skewY \* y + translateX +> +> - y' = skewX \* x + scaleY \* y + translateY + +- Parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | scaleX | number | Yes | 0 | X-axis scale. | + | skewX | number | Yes | 0 | X-axis skew. | + | skewY | number | Yes | 0 | Y-axis skew. | + | scaleY | number | Yes | 0 | Y-axis scale. | + | translateX | number | Yes | 0 | X-axis translation. | + | translateY | number | Yes | 0 | Y-axis translation. | + +- Example + + ``` + @Entry + @Component + struct Transform { + private settings: RenderingContextSettings = new RenderingContextSettings(true) + private context: RenderingContext = new RenderingContext(this.settings) + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.context.fillStyle = 'rgb(0,0,0)' + this.context.fillRect(0, 0, 100, 100) + this.context.transform(1, 0.5, -0.5, 1, 10, 10) + this.context.fillStyle = 'rgb(255,0,0)' + this.context.fillRect(0, 0, 100, 100) + this.context.transform(1, 0.5, -0.5, 1, 10, 10) + this.context.fillStyle = 'rgb(0,0,255)' + this.context.fillRect(0, 0, 100, 100) + }) } + .width('100%') + .height('100%') } - ``` - - ![](figures/en-us_image_0000001193801072.png) - - -### setTransform - -setTransform\(scaleX: number, skewX: number, skewY: number, scale: number, translateX: number, translateY: number\): void - -Resets the existing transformation matrix and creates a new transformation matrix by using the same parameters as the **transform\(\)** function. - -- Parameters - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

scaleX

-

number

-

Yes

-

0

-

X-axis scale.

-

skewX

-

number

-

Yes

-

0

-

X-axis skew.

-

skewY

-

number

-

Yes

-

0

-

Y-axis skew.

-

scaleY

-

number

-

Yes

-

0

-

Y-axis scale.

-

translateX

-

number

-

Yes

-

0

-

X-axis translation.

-

translateY

-

number

-

Yes

-

0

-

Y-axis translation.

-
- -- Example - - ``` - @Entry - @Component - struct SetTransform { - private settings: RenderingContextSettings = new RenderingContextSettings(true) - private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) - - build() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Canvas(this.context) - .width('100%') - .height('100%') - .backgroundColor('#ffff00') - .onReady(() =>{ - this.context.fillStyle = 'rgb(255,0,0)' - this.context.fillRect(0, 0, 100, 100) - this.context.setTransform(1,0.5, -0.5, 1, 10, 10) - this.context.fillStyle = 'rgb(0,0,255)' - this.context.fillRect(0, 0, 100, 100) - }) - } - .width('100%') - .height('100%') + } + ``` + + ![en-us_image_0000001256858393](figures/en-us_image_0000001256858393.png) + + +### setTransform + +setTransform(scaleX: number, skewX: number, skewY: number, scale: number, translateX: number, translateY: number): void + +Resets the existing transformation matrix and creates a new transformation matrix by using the same parameters as the **transform()** function. + +- Parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | scaleX | number | Yes | 0 | X-axis scale. | + | skewX | number | Yes | 0 | X-axis skew. | + | skewY | number | Yes | 0 | Y-axis skew. | + | scaleY | number | Yes | 0 | Y-axis scale. | + | translateX | number | Yes | 0 | X-axis translation. | + | translateY | number | Yes | 0 | Y-axis translation. | + +- Example + + ``` + @Entry + @Component + struct SetTransform { + private settings: RenderingContextSettings = new RenderingContextSettings(true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.context.fillStyle = 'rgb(255,0,0)' + this.context.fillRect(0, 0, 100, 100) + this.context.setTransform(1,0.5, -0.5, 1, 10, 10) + this.context.fillStyle = 'rgb(0,0,255)' + this.context.fillRect(0, 0, 100, 100) + }) } + .width('100%') + .height('100%') } - ``` + } + ``` - ![](figures/en-us_image_0000001238521021.png) + ![en-us_image_0000001256858395](figures/en-us_image_0000001256858395.png) -### translate +### translate -translate\(x: number, y: number\): void +translate(x: number, y: number): void Moves the origin of the coordinate system. -- Parameters - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

x

-

number

-

Yes

-

0

-

X-axis translation

-

y

-

number

-

Yes

-

0

-

Y-axis translation.

-
- -- Example - - ``` - @Entry - @Component - struct Translate { - private settings: RenderingContextSettings = new RenderingContextSettings(true) - private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) - - build() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Canvas(this.context) - .width('100%') - .height('100%') - .backgroundColor('#ffff00') - .onReady(() =>{ - this.context.fillRect(10, 10, 50, 50) - this.context.translate(70, 70) - this.context.fillRect(10, 10, 50, 50) - }) - } - .width('100%') - .height('100%') +- Parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | x | number | Yes | 0 | X-axis translation. | + | y | number | Yes | 0 | Y-axis translation. | + +- Example + + ``` + @Entry + @Component + struct Translate { + private settings: RenderingContextSettings = new RenderingContextSettings(true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.context.fillRect(10, 10, 50, 50) + this.context.translate(70, 70) + this.context.fillRect(10, 10, 50, 50) + }) } + .width('100%') + .height('100%') } - ``` + } + ``` - ![](figures/en-us_image_0000001193481098.png) + ![en-us_image_0000001257138357](figures/en-us_image_0000001257138357.png) -### drawImage +### drawImage -drawImage\(image: ImageBitmap, dx: number, dy: number\): void +drawImage(image: ImageBitmap, dx: number, dy: number): void -drawImage\(image: ImageBitmap, dx: number, dy: number, dWidth: number, dHeight: number\): void +drawImage(image: ImageBitmap, dx: number, dy: number, dWidth: number, dHeight: number): void -drawImage\(image: ImageBitmap, sx: number, sy: number, sWidth: number, sHeight: number, dx: number, dy: number, dWidth: number, dHeight: number\):void +drawImage(image: ImageBitmap, sx: number, sy: number, sWidth: number, sHeight: number, dx: number, dy: number, dWidth: number, dHeight: number):void Draws an image. -- Parameters - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

image

-

ImageBitmap

-

Yes

-

null

-

Image resource. For details, see ImageBitmap.

-

sx

-

number

-

No

-

0

-

X-coordinate of the upper left corner of the rectangle used to crop the source image.

-

sy

-

number

-

No

-

0

-

Y-coordinate of the upper left corner of the rectangle used to crop the source image.

-

sWidth

-

number

-

No

-

0

-

Target width to crop the source image.

-

sHeight

-

number

-

No

-

0

-

Target height to crop the source image.

-

dx

-

number

-

Yes

-

0

-

X-coordinate of the upper left corner of the drawing area on the canvas.

-

dy

-

number

-

Yes

-

0

-

Y-coordinate of the upper left corner of the drawing area on the canvas.

-

dWidth

-

number

-

No

-

0

-

Width of the drawing area.

-

dHeight

-

number

-

No

-

0

-

Height of the drawing area.

-
- - -- Example - - ``` - @Entry - @Component - struct ImageExample { - private settings: RenderingContextSettings = new RenderingContextSettings(true); - private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings); - private img:ImageBitmap = new ImageBitmap("common/images/example.jpg"); - build() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Canvas(this.context) - .width('100%') - .height('100%') - .backgroundColor('#ffff00') - .onReady(() =>{ - this.context.drawImage( this.img,0,0,500,500,0,0,400,200); - }) - } - .width('100%') - .height('100%') +- Parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | image | [ERROR:Invalid link:en-us_topic_0000001212378364.xml#en-us_topic_0000001193075104_xref962584519412,link:en-us_topic_0000001192915114.xml](en-us_topic_0000001192915114.xml) | Yes | null | Image resource. For details, see [ERROR:Invalid link:en-us_topic_0000001212378364.xml#xref29052050153012,link:en-us_topic_0000001192915114.xml](en-us_topic_0000001192915114.xml). | + | sx | number | No | 0 | X-coordinate of the upper left corner of the rectangle used to crop the source image. | + | sy | number | No | 0 | Y-coordinate of the upper left corner of the rectangle used to crop the source image. | + | sWidth | number | No | 0 | Target width to crop the source image. | + | sHeight | number | No | 0 | Target height to crop the source image. | + | dx | number | Yes | 0 | X-coordinate of the upper left corner of the drawing area on the canvas. | + | dy | number | Yes | 0 | Y-coordinate of the upper left corner of the drawing area on the canvas. | + | dWidth | number | No | 0 | Width of the drawing area. | + | dHeight | number | No | 0 | Height of the drawing area. | + + +- Example + + ``` + @Entry + @Component + struct ImageExample { + private settings: RenderingContextSettings = new RenderingContextSettings(true); + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings); + private img:ImageBitmap = new ImageBitmap("common/images/example.jpg"); + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.context.drawImage( this.img,0,0,500,500,0,0,400,200); + }) } + .width('100%') + .height('100%') } - ``` - - ![](figures/en-us_image_0000001192915154.png) - - -### createImageData - -createImageData\(width: number, height: number\): Object - -Creates an **ImageData** object. For details, see [ImageData](ts-components-canvas-imagedata.md). - -- Parameters - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default

-

Description

-

width

-

number

-

Yes

-

0

-

Width of the ImageData object.

-

height

-

number

-

Yes

-

0

-

Height of the ImageData object.

-
- - -### createImageData - -createImageData\(imageData: Object\): Object - -Creates an **ImageData** object. For details, see [ImageData](ts-components-canvas-imagedata.md). - -- Parameters - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default

-

Description

-

imagedata

-

Object

-

Yes

-

null

-

ImageData object with the same width and height copied from the original ImageData object.

-
- - -### getImageData - -getImageData\(sx: number, sy: number, sw: number, sh: number\): Object - -Creates an [ImageData](ts-components-canvas-imagedata.md) object with pixels in the specified area on the canvas. - -- Parameters - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

sx

-

number

-

Yes

-

0

-

X-coordinate of the upper left corner of the output area.

-

sy

-

number

-

Yes

-

0

-

Y-coordinate of the upper left corner of the output area.

-

sw

-

number

-

Yes

-

0

-

Width of the output area.

-

sh

-

number

-

Yes

-

0

-

Height of the output area.

-
- - -### putImageData - -putImageData\(imageData: Object, dx: number, dy: number, dirtyX?: number, dirtyY?: number, dirtyWidth?: number, dirtyHeight?: number\): void - -Puts the [ImageData](ts-components-canvas-imagedata.md) onto a rectangular area on the canvas. - -- Parameters - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

imagedata

-

Object

-

Yes

-

null

-

ImageData object with pixels to put onto the canvas.

-

dx

-

number

-

Yes

-

0

-

X-axis offset of the rectangular area on the canvas.

-

dy

-

number

-

Yes

-

0

-

Y-axis offset of the rectangular area on the canvas.

-

dirtyX

-

number

-

No

-

0

-

X-axis offset of the upper left corner of the rectangular area relative to that of the source image.

-

dirtyY

-

number

-

No

-

0

-

Y-axis offset of the upper left corner of the rectangular area relative to that of the source image.

-

dirtyWidth

-

number

-

No

-

Width of the ImageData object

-

Width of the rectangular area to crop the source image.

-

dirtyHeight

-

number

-

No

-

Height of the ImageData object

-

Height of the rectangular area to crop the source image.

-
- -- Example - - ``` - @Entry - @Component - struct PutImageData { - private settings: RenderingContextSettings = new RenderingContextSettings(true) - private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) - - build() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Canvas(this.context) - .width('100%') - .height('100%') - .backgroundColor('#ffff00') - .onReady(() =>{ - var imageData = this.context.createImageData(100, 100) - for (var i = 0; i < imageData.data.length; i += 4) { - imageData.data[i + 0] = 255 - imageData.data[i + 1] = 0 - imageData.data[i + 2] = 255 - imageData.data[i + 3] = 255 - } - this.context.putImageData(imageData, 10, 10) - }) - } - .width('100%') - .height('100%') + } + ``` + + ![en-us_image_0000001212058466](figures/en-us_image_0000001212058466.png) + + +### createImageData + +createImageData(width: number, height: number): Object + +Creates an **ImageData** object. For details, see [ImageData](../reference/arkui-ts/ts-components-canvas-imagebitmap.md). + +- Parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | width | number | Yes | 0 | Width of the **ImageData** object. | + | height | number | Yes | 0 | Height of the **ImageData** object. | + + +### createImageData + +createImageData(imageData: Object): Object + +Creates an **ImageData** object. For details, see [ImageData](../reference/arkui-ts/ts-components-canvas-imagebitmap.md). + +- Parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | imagedata | Object | Yes | null | **ImageData** object with the same width and height copied from the original **ImageData** object. | + + +### getImageData + +getImageData(sx: number, sy: number, sw: number, sh: number): Object + + Creates an [ImageData](../reference/arkui-ts/ts-components-canvas-imagebitmap.md) object with pixels in the specified area on the canvas. +- Parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | sx | number | Yes | 0 | X-coordinate of the upper left corner of the output area. | + | sy | number | Yes | 0 | Y-coordinate of the upper left corner of the output area. | + | sw | number | Yes | 0 | Width of the output area. | + | sh | number | Yes | 0 | Height of the output area. | + + +### putImageData + +putImageData(imageData: Object, dx: number, dy: number, dirtyX?: number, dirtyY?: number, dirtyWidth?: number, dirtyHeight?: number): void + +Puts the [ImageData](../reference/arkui-ts/ts-components-canvas-imagebitmap.md) onto a rectangular area on the canvas. + +- Parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | imagedata | Object | Yes | null | **ImageData** object with pixels to put onto the canvas. | + | dx | number | Yes | 0 | X-axis offset of the rectangular area on the canvas. | + | dy | number | Yes | 0 | Y-axis offset of the rectangular area on the canvas. | + | dirtyX | number | No | 0 | X-axis offset of the upper left corner of the rectangular area relative to that of the source image. | + | dirtyY | number | No | 0 | Y-axis offset of the upper left corner of the rectangular area relative to that of the source image. | + | dirtyWidth | number | No | Width of the **ImageData** object | Width of the rectangular area to crop the source image. | + | dirtyHeight | number | No | Height of the **ImageData** object | Height of the rectangular area to crop the source image. | + +- Example + + ``` + @Entry + @Component + struct PutImageData { + private settings: RenderingContextSettings = new RenderingContextSettings(true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + var imageData = this.context.createImageData(100, 100) + for (var i = 0; i < imageData.data.length; i += 4) { + imageData.data[i + 0] = 255 + imageData.data[i + 1] = 0 + imageData.data[i + 2] = 255 + imageData.data[i + 3] = 255 + } + this.context.putImageData(imageData, 10, 10) + }) } + .width('100%') + .height('100%') } - ``` + } + ``` - ![](figures/en-us_image_0000001193075134.png) + ![en-us_image_0000001212378396](figures/en-us_image_0000001212378396.png) -### restore +### restore -restore\(\): void +restore(): void Restores the saved drawing context. -- Example - - ``` - @Entry - @Component - struct CanvasExample { - private settings: RenderingContextSettings = new RenderingContextSettings(true) - private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) - - build() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Canvas(this.context) - .width('100%') - .height('100%') - .backgroundColor('#ffff00') - .onReady(() =>{ - this.context.restore() - }) - } - .width('100%') - .height('100%') +- Example + + ``` + @Entry + @Component + struct CanvasExample { + private settings: RenderingContextSettings = new RenderingContextSettings(true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.context.restore() + }) } + .width('100%') + .height('100%') } - ``` + } + ``` -### save +### save -save\(\): void +save(): void Saves the current drawing context. -- Example - - ``` - @Entry - @Component - struct CanvasExample { - private settings: RenderingContextSettings = new RenderingContextSettings(true) - private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) - - build() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Canvas(this.context) - .width('100%') - .height('100%') - .backgroundColor('#ffff00') - .onReady(() =>{ - this.context.save() - }) - } - .width('100%') - .height('100%') +- Example + + ``` + @Entry + @Component + struct CanvasExample { + private settings: RenderingContextSettings = new RenderingContextSettings(true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.context.save() + }) } + .width('100%') + .height('100%') } - ``` + } + ``` -### createLinearGradient +### createLinearGradient -createLinearGradient\(x0: number, y0: number, x1: number, y1: number\): void +createLinearGradient(x0: number, y0: number, x1: number, y1: number): void Creates a linear gradient. -- Parameters - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

x0

-

number

-

Yes

-

0

-

X-coordinate of the start point.

-

y0

-

number

-

Yes

-

0

-

Y-coordinate of the start point.

-

x1

-

number

-

Yes

-

0

-

X-coordinate of the end point.

-

y1

-

number

-

Yes

-

0

-

Y-coordinate of the end point.

-
- -- Example - - ``` - @Entry - @Component - struct CreateLinearGradient { - private settings: RenderingContextSettings = new RenderingContextSettings(true) - private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) +- Parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | x0 | number | Yes | 0 | X-coordinate of the start point. | + | y0 | number | Yes | 0 | Y-coordinate of the start point. | + | x1 | number | Yes | 0 | X-coordinate of the end point. | + | y1 | number | Yes | 0 | Y-coordinate of the end point. | + +- Example + + ``` + @Entry + @Component + struct CreateLinearGradient { + private settings: RenderingContextSettings = new RenderingContextSettings(true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) - build() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Canvas(this.context) - .width('100%') - .height('100%') - .backgroundColor('#ffff00') - .onReady(() =>{ - var grad = this.context.createLinearGradient(50,0, 300,100) - gra.addColorStop(0.0, 'red') - gra.addColorStop(0.5, 'white') - gra.addColorStop(1.0, 'green') - this.context.fillStyle = grad - this.context.fillRect(0, 0, 500, 500) - }) - } - .width('100%') - .height('100%') + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + var grad = this.context.createLinearGradient(50,0, 300,100) + this.grad.addColorStop(0.0, 'red') + this.grad.addColorStop(0.5, 'white') + this.grad.addColorStop(1.0, 'green') + this.context.fillStyle = grad + this.context.fillRect(0, 0, 500, 500) + }) } + .width('100%') + .height('100%') } - ``` - + } + ``` -![](figures/en-us_image_0000001237555149.png) + ![en-us_image_0000001212378412](figures/en-us_image_0000001212378412.png) -### createRadialGradient +### createRadialGradient -createRadialGradient\(x0: number, y0: number, r0: number, x1: number, y1: number, r1: number\): void +createRadialGradient(x0: number, y0: number, r0: number, x1: number, y1: number, r1: number): void Creates a linear gradient. -- Parameters - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

x0

-

number

-

Yes

-

0

-

X-coordinate of the center of the start circle.

-

y0

-

number

-

Yes

-

0

-

Y-coordinate of the center of the start circle.

-

r0

-

number

-

Yes

-

0

-

Radius of the start circle, which must be a non-negative finite number.

-

x1

-

number

-

Yes

-

0

-

X-coordinate of the center of the end circle.

-

y1

-

number

-

Yes

-

0

-

Y-coordinate of the center of the end circle.

-

r1

-

number

-

Yes

-

0

-

Radius of the end circle, which must be a non-negative finite number.

-
- -- Example - - ``` - @Entry - @Component - struct CreateRadialGradient { - private settings: RenderingContextSettings = new RenderingContextSettings(true) - private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) - - build() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Canvas(this.context) - .width('100%') - .height('100%') - .backgroundColor('#ffff00') - .onReady(() =>{ - var grad = this.context.createRadialGradient(200,200,50, 200,200,200) - gra.addColorStop(0.0, 'red') - gra.addColorStop(0.5, 'white') - gra.addColorStop(1.0, 'green') - this.context.fillStyle = grad - this.context.fillRect(0, 0, 500, 500) - }) - } - .width('100%') - .height('100%') +- Parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | x0 | number | Yes | 0 | X-coordinate of the center of the start circle. | + | y0 | number | Yes | 0 | Y-coordinate of the center of the start circle. | + | r0 | number | Yes | 0 | Radius of the start circle, which must be a non-negative finite number. | + | x1 | number | Yes | 0 | X-coordinate of the center of the end circle. | + | y1 | number | Yes | 0 | Y-coordinate of the center of the end circle. | + | r1 | number | Yes | 0 | Radius of the end circle, which must be a non-negative finite number. | + +- Example + + ``` + @Entry + @Component + struct CreateRadialGradient { + private settings: RenderingContextSettings = new RenderingContextSettings(true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + var grad = this.context.createRadialGradient(200,200,50, 200,200,200) + this.grad.addColorStop(0.0, 'red') + this.grad.addColorStop(0.5, 'white') + this.grad.addColorStop(1.0, 'green') + this.context.fillStyle = grad + this.context.fillRect(0, 0, 500, 500) + }) } + .width('100%') + .height('100%') } - ``` - -![](figures/en-us_image_0000001192755188.png) + } + ``` + ![en-us_image_0000001257058405](figures/en-us_image_0000001257058405.png) -## CanvasPattern -Defines an object created by using the [createPattern](#section1643216163371) method. +## CanvasPattern +Defines an object created by using the [createPattern](#createpattern) method. diff --git a/en/application-dev/reference/arkui-ts/ts-combined-gestures.md b/en/application-dev/reference/arkui-ts/ts-combined-gestures.md index bbcfb02bb9daa3fc81bf01a900c2ad8315238d69..cbfe726ced5593f908adcef668b7a61789841c3f 100644 --- a/en/application-dev/reference/arkui-ts/ts-combined-gestures.md +++ b/en/application-dev/reference/arkui-ts/ts-combined-gestures.md @@ -1,106 +1,42 @@ -# Combined Gestures +# Combined Gestures ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->This gesture is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -## Required Permissions +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** +> Combined gestures are supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. + + +## Required Permissions None -## APIs - -GestureGroup\(mode: GestureMode, ...gesture: GestureType\[\]\) - -- Parameters - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

mode

-

GestureMode

-

Yes

-

-

-

Recognition mode of combined gestures.

-

gesture

-

TapGesture

-

| LongPressGesture

-

| PanGesture

-

| PinchGesture

-

| RotationGesture

-

Yes

-

-

-

Variable-length parameter, indicating one or more basic gesture types. These gestures are recognized in combination.

-
- -- GestureMode enums - - - - - - - - - - - - - - - - -

Name

-

Description

-

Sequence

-

Sequential recognition: Gestures are recognized in the registration sequence until all gestures are recognized successfully. When one gesture fails to be recognized, all gestures fail to be recognized.

-

Parallel

-

Parallel recognition. Registered gestures are recognized concurrently until all gestures are recognized. The recognition result of each gesture does not affect each other.

-

Exclusive

-

Exclusive recognition. Registered gestures are identified concurrently. If one gesture is successfully recognized, gesture recognition ends.

-
- - -## Events - - - - - - - - - - -

Name

-

Description

-

onCancel(event: () => void)

-

Callback for the GestureMode.Sequence cancellation event.

-
- -## Example + +## APIs + +GestureGroup(mode: GestureMode, ...gesture: GestureType[]) + +- Parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | mode | GestureMode | Yes | - | Recognition mode of combined gestures. | + | gesture | [TapGesture](ts-basic-gestures-tapgesture.md)
\| [LongPressGesture](ts-basic-gestures-longpressgesture.md)
\| [PanGesture](ts-basic-gestures-pangesture.md)
\| [PinchGesture](ts-basic-gestures-pinchgesture.md)
\| [RotationGesture](ts-basic-gestures-rotationgesture.md) | Yes | - | Variable-length parameter, indicating one or more basic gesture types. These gestures are recognized in combination. | + +- GestureMode enums + | Name | Description | + | -------- | -------- | + | Sequence | Sequential recognition: Gestures are recognized in the registration sequence until all gestures are recognized successfully. When one gesture fails to be recognized, all gestures fail to be recognized. | + | Parallel | Parallel recognition. Registered gestures are recognized concurrently until all gestures are recognized. The recognition result of each gesture does not affect each other. | + | Exclusive | Exclusive recognition. Registered gestures are identified concurrently. If one gesture is successfully recognized, gesture recognition ends. | + + +## Events + + | Name | Description | +| -------- | -------- | +| onCancel(event: () => void) | Callback for the GestureMode.Sequence cancellation event. | + + +## Example + ``` @Entry @@ -145,5 +81,4 @@ struct GestureGroupExample { } ``` -![](figures/gesturegroup.gif) - +![en-us_image_0000001212058490](figures/en-us_image_0000001212058490.gif) diff --git a/en/application-dev/reference/arkui-ts/ts-components-canvas-canvas.md b/en/application-dev/reference/arkui-ts/ts-components-canvas-canvas.md index f34c7ce4e16a6aa3e97fb37d4c1f2b30de43dac3..1fd47e4c50e772548d9392df87f77addeb4508a2 100644 --- a/en/application-dev/reference/arkui-ts/ts-components-canvas-canvas.md +++ b/en/application-dev/reference/arkui-ts/ts-components-canvas-canvas.md @@ -1,80 +1,49 @@ -# Canvas +# Canvas ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->This component is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version. -The **** component can be used to customize drawings. +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** +> This component is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version. -## Required Permissions + +The **<Canvas>** component can be used to customize drawings. + + +## Required Permissions None -## Child Components + +## Child Components None -## APIs - -Canvas\(context: CanvasRenderingContext2D\) - -- Parameters - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

context

-

CanvasRenderingContext2D

-

Yes

-

-

-

For details, see CanvasRenderingContext2D.

-
- - -## Attributes - -[Universal attributes](ts-universal-attributes-size.md) are supported. - -## Events - -In addition to [universal events](ts-universal-events-click.md), the following events are supported. - - - - - - - - - - - - -

Name

-

Parameter

-

Description

-

onReady(callback: () => void)

-

None

-

Triggered when .

-
- -## Example + +## APIs + +Canvas(context: CanvasRenderingContext2D) + +- Parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | context | [CanvasRenderingContext2D](ts-canvasrenderingcontext2d.md) | Yes | - | For details, see CanvasRenderingContext2D. | + + +## Attributes + +[Universal attributes](ts-universal-attributes-size.md) are supported. + + +## Events + +In addition to [universal events](ts-universal-events-click.md), the following events are supported. + + | Name | Parameter | Description | +| -------- | -------- | -------- | +| onReady(callback: () => void) | None | Triggered when . | + + +## Example + ``` @Entry @@ -98,4 +67,3 @@ struct CanvasExample { } } ``` - diff --git a/en/application-dev/reference/arkui-ts/ts-components-canvas-canvasgradient.md b/en/application-dev/reference/arkui-ts/ts-components-canvas-canvasgradient.md index b601e5821a052b5d077692a6a22dfe8b34e33718..c218127bbbd13f612e56f6e9a518682efdfe07ee 100644 --- a/en/application-dev/reference/arkui-ts/ts-components-canvas-canvasgradient.md +++ b/en/application-dev/reference/arkui-ts/ts-components-canvas-canvasgradient.md @@ -1,86 +1,53 @@ -# CanvasGradient +# CanvasGradient ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->This component is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version. -**CanvasGradient** provides a gradient object. +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** +> This component is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version. -## addColorStop -addColorStop\(offset: number, color: string\): void +**CanvasGradient** provides a gradient object. -Adds a color stop for the **CanvasGradient** object based on the specified offset and gradient color. -- Parameters +## addColorStop - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

offset

-

number

-

Yes

-

0

-

Proportion of the distance between the color stop and the start point to the total length. The value ranges from 0 to 1.

-

color

-

string

-

Yes

-

'ffffff'

-

Gradient color to set.

-
+addColorStop(offset: number, color: string): void -- Example +Adds a color stop for the **CanvasGradient** object based on the specified offset and gradient color. - ``` - @Entry - @Component - struct Page45 { - private settings: RenderingContextSettings = new RenderingContextSettings(true) - private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) - private gra:CanvasGradient = new CanvasGradient() +- Parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | offset | number | Yes | 0 | Proportion of the distance between the color stop and the start point to the total length. The value ranges from 0 to 1. | + | color | string | Yes | 'ffffff' | Gradient color to set. | + +- Example - build() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Canvas(this.context) - .width('100%') - .height('100%') - .backgroundColor('#ffff00') - .onReady(() =>{ - var grad = this.context.createLinearGradient(50,0, 300,100) - gra.addColorStop(0.0, 'red') - gra.addColorStop(0.5, 'white') - gra.addColorStop(1.0, 'green') - this.context.fillStyle = grad - this.context.fillRect(0, 0, 500, 500) - }) - } - .width('100%') - .height('100%') + ``` + @Entry + @Component + struct Page45 { + private settings: RenderingContextSettings = new RenderingContextSettings(true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + var grad = this.context.createLinearGradient(50,0, 300,100) + this.grad.addColorStop(0.0, 'red') + this.grad.addColorStop(0.5, 'white') + this.grad.addColorStop(1.0, 'green') + this.context.fillStyle = grad + this.context.fillRect(0, 0, 500, 500) + }) } + .width('100%') + .height('100%') } - ``` - - ![](figures/en-us_image_0000001192915130.png) + } + ``` + ![en-us_image_0000001256858381](figures/en-us_image_0000001256858381.png) diff --git a/en/application-dev/reference/arkui-ts/ts-components-canvas-imagebitmap.md b/en/application-dev/reference/arkui-ts/ts-components-canvas-imagebitmap.md index ad48b3ddbedceba5f3e68743ebf8cf55fd3a76a9..4c19546b8c0b96ead05ae454c90621551f70bbb2 100644 --- a/en/application-dev/reference/arkui-ts/ts-components-canvas-imagebitmap.md +++ b/en/application-dev/reference/arkui-ts/ts-components-canvas-imagebitmap.md @@ -1,109 +1,17 @@ -# ImageBitmap +# ImageBitmap ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->This component is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version. -**ImageBitmap** allows you to add an image bitmap. +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** +> This component is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version. -## APIs -ImageBitmap\(src: string\) +**CanvasImageData** stores pixel data rendered on a canvas. -- Parameters - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

src

-

string

-

Yes

-

-

-

Path of the image bitmap object.

-
- - -## Attributes - - - - - - - - - - - - - - - - - - - - - - -

Attribute

-

Type

-

Default Value

-

Mandatory

-

Description

-

width

-

Length

-

0px

-

No

-

Image width.

-

height

-

Length

-

0px

-

No

-

Image height.

-
- -Example - -``` -@Entry -@Component -struct DrawImageExample { - private settings:RenderingContextSettings = new RenderingContextSettings(true) - private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) - private img:ImageBitmap = new ImageBitmap("common/images/example.jpg") - - build() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Canvas(this.context) - .width('100%') - .height('100%') - .backgroundColor('#ffff00') - .onReady(() =>{ - this.context.drawImage( this.img,0,0,400,200) - }) - } - .width('100%') - .height('100%') - } -} -``` - -![](figures/en-us_image_0000001192595194.png) +## Attributes + | Name | Type | Description | +| -------- | -------- | -------- | +| width | number | Actual width of the rectangle on the canvas, in pixels. | +| height | number | Actual height of the rectangle on the canvas, in pixels. | +| data | <Uint8ClampedArray> | A one-dimensional array of color values. The values range from 0 to 255. | diff --git a/en/application-dev/reference/arkui-ts/ts-components-canvas-imagedata.md b/en/application-dev/reference/arkui-ts/ts-components-canvas-imagedata.md index 43aa9147a1cad5c71649bac3f948aa1fc09675b6..5b749411fcb8551906e806d8b830c67c2d14865b 100644 --- a/en/application-dev/reference/arkui-ts/ts-components-canvas-imagedata.md +++ b/en/application-dev/reference/arkui-ts/ts-components-canvas-imagedata.md @@ -1,42 +1,17 @@ -# ImageData +# ImageData ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->This component is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version. -**CanvasImageData** stores pixel data rendered on a canvas. +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** +> This component is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version. -## Attributes - - - - - - - - - - - - - - - - - - - -

Attribute

-

Type

-

Description

-

width

-

number

-

Actual width of the rectangle on the canvas, in pixels.

-

height

-

number

-

Actual height of the rectangle on the canvas, in pixels.

-

data

-

<Uint8ClampedArray>

-

A one-dimensional array of color values. The values range from 0 to 255.

-
+**ImageData** stores pixel data rendered on a canvas. + +## Attributes + + | Name | Type | Description | +| -------- | -------- | -------- | +| width | number | Actual width of the rectangle on the canvas, in pixels. | +| height | number | Actual height of the rectangle on the canvas, in pixels. | +| data | <Uint8ClampedArray> | A one-dimensional array of color values. The values range from 0 to 255. | diff --git a/en/application-dev/reference/arkui-ts/ts-components-canvas-lottie.md b/en/application-dev/reference/arkui-ts/ts-components-canvas-lottie.md index b2a63e4de072dc9aebade58e2caeec761a522240..2a3247ecc08cf5597aedd5319b3602a61616bfe8 100644 --- a/en/application-dev/reference/arkui-ts/ts-components-canvas-lottie.md +++ b/en/application-dev/reference/arkui-ts/ts-components-canvas-lottie.md @@ -1,1343 +1,589 @@ -# Lottie +# Lottie ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->This component is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version. -Lottie is a third-party open-source library and depends on **Canvas** and **RenderingContext**. +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** +> This component is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version. -## Required Permissions + +## Required Permissions None -## Modules to Import +## Modules to Import + + ``` -import lottie from 'lottie-web' +import lottie from 'lottie-ohos-ets' ``` ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->**'lottie-web'** is subject to the actual released name. - -## lottie.loadAnimation - -loadAnimation\( - -path: string, container: object, render: string, loop: boolean, autoplay: boolean, name: string \): AnimationItem - -Loads an animation. Before calling this method, declare the **Animator\('\_\_lottie\_ets'\)** object and check that the canvas layout is complete. This method can be used together with a lifecycle callback of the **Canvas** component, for example, **onAppear\(\)** and **onPageShow\(\)**. - -- Parameters - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

path

-

string

-

Yes

-

Path of the animation resource file in the HAP file. The resource file must be in JSON format. Example: path: "common/lottie/data.json".

-

container

-

object

-

Yes

-

Canvas drawing context. A CanvasRenderingContext2D object must be declared in advance.

-

render

-

string

-

Yes

-

Rendering type. Only canvas is supported.

-

loop

-

boolean | number

-

No

-

If the value is of the Boolean type, this parameter indicates whether to repeat the animation cyclically after the animation ends; the default value is true. If the value is of the number type and is greater than or equal to 1, this parameter indicates the number of times the animation plays.

-

autoplay

-

boolean

-

No

-

Whether to automatically play the animation. The default value is true.

-

name

-

string

-

No

-

Custom animation name. In later versions, the name can be used to reference and control the animation. The default value is null.

-

initialSegment

-

[number, number]

-

No

-

Start frame and end frame of the animation, respectively.

-
- - -## lottie.destroy - -destroy\(name: string\): void - -Destroys the animation. This method must be called when a page exits. This method can be used together with a lifecycle callback of the **Canvas** component, for example, **onDisappear\(\)** and **onPageHide\(\)**. - -- Parameters - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

name

-

string

-

Yes

-

Name of the animation to destroy, which is the same as the name in the loadAnimation interface. By default, all animations are destroyed.

-
- -- Example - - ``` - import lottie from 'lottie-web' - - @Entry - @Component - struct Index { - private controller: CanvasRenderingContext2D = new CanvasRenderingContext2D() - private animateName: string = "animate" - private animatePath: string = "common/lottie/data.json" - private animateItem: any = null - - private onPageHide(): void { - console.log('onPageHide') - lottie.destroy() - } +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** +> In the **Terminal** window, run the **npm install'lottie-ohos-ets...** command to download Lottie. + + +## lottie.loadAnimation + +loadAnimation( + +path: string, container: object, render: string, loop: boolean, autoplay: boolean, name: string ): AnimationItem + +Loads an animation. Before calling this method, declare the **Animator('__lottie_ets')** object and check that the canvas layout is complete. This method can be used together with a lifecycle callback of the **Canvas** component, for example, **onAppear()** and **onPageShow()**. + +- Parameters + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | path | string | Yes | Path of the animation resource file in the HAP file. The resource file must be in JSON format. Example: **path: "common/lottie/data.json"**. | + | container | object | Yes | Canvas drawing context. A **CanvasRenderingContext2D** object must be declared in advance. | + | render | string | Yes | Rendering type. The value can only be **"canvas"**. | + | loop | boolean \| number | No | If the value is of the Boolean type, this parameter indicates whether to repeat the animation cyclically after the animation ends; the default value is **true**. If the value is of the number type and is greater than or equal to 1, this parameter indicates the number of times the animation plays. | + | autoplay | boolean | No | Whether to automatically play the animation. The default value is **true**. | + | name | string | No | Custom animation name. In later versions, the name can be used to reference and control the animation. The default value is null. | + | initialSegment | [number, number] | No | Start frame and end frame of the animation, respectively. | + + +## lottie.destroy + +destroy(name: string): void + +Destroys the animation. This method must be called when a page exits. This method can be used together with a lifecycle callback of the **Canvas** component, for example, **onDisappear()** and **onPageHide()**. + +- Parameters + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | name | string | Yes | Name of the animation to destroy, which is the same as the **name** in the **loadAnimation** interface. By default, all animations are destroyed. | + +- Example - build() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Canvas(this.controller) - .width('30%') - .height('20%') - .backgroundColor('#0D9FFB') - .onAppear(() => { - console.log('canvas onAppear'); - this.animateItem = lottie.loadAnimation({ - container: this.controller, - renderer: 'canvas', - loop: true, - autoplay: true, - name: this.animateName, - path: this.animatePath, - }) + ``` + import lottie from 'lottie-web' + + @Entry + @Component + struct Index { + private controller: CanvasRenderingContext2D = new CanvasRenderingContext2D() + private animateName: string = "animate" + private animatePath: string = "common/lottie/data.json" + private animateItem: any = null + + private onPageHide(): void { + console.log('onPageHide') + lottie.destroy() + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.controller) + .width('30%') + .height('20%') + .backgroundColor('#0D9FFB') + .onAppear(() => { + console.log('canvas onAppear'); + this.animateItem = lottie.loadAnimation({ + container: this.controller, + renderer: 'canvas', + loop: true, + autoplay: true, + name: this.animateName, + path: this.animatePath, }) - - Animator('__lottie_ets') // declare Animator('__lottie_ets') when use lottie - Button('load animation') - .onClick(() => { - if (this.animateItem != null) { - this.animateItem.destroy() - this.animateItem = null - } - this.animateItem = lottie.loadAnimation({ - container: this.controller, - renderer: 'canvas', - loop: true, - autoplay: true, - name: this.animateName, - path: this.animatePath, - initialSegment: [10, 50], - }) + }) + + Animator('__lottie_ets') // declare Animator('__lottie_ets') when use lottie + Button('load animation') + .onClick(() => { + if (this.animateItem != null) { + this.animateItem.destroy() + this.animateItem = null + } + this.animateItem = lottie.loadAnimation({ + container: this.controller, + renderer: 'canvas', + loop: true, + autoplay: true, + name: this.animateName, + path: this.animatePath, + initialSegment: [10, 50], + }) + }) + + Button('destroy animation') + .onClick(() => { + lottie.destroy(this.animateName) + this.animateItem = null }) - - Button('destroy animation') - .onClick(() => { - lottie.destroy(this.animateName) - this.animateItem = null - }) - } - .width('100%') - .height('100%') } + .width('100%') + .height('100%') } - ``` + } + ``` - ![](figures/lottie-ark-2-0-canvas-ui-animate.gif) + ![en-us_image_0000001256978355](figures/en-us_image_0000001256978355.gif) -## lottie.play +## lottie.play -play\(name: string\): void +play(name: string): void Plays a specified animation. -- Parameters - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

name

-

string

-

Yes

-

Name of the animation to play, which is the same as the name in the loadAnimation interface. By default, all animations are played.

-
- -- Example - - ``` - lottie.play(this.animateName) - ``` - - -## lottie.pause - -pause\(name: string\): void - -Pauses a specified animation. The next time **lottie.play\(\)** is called, the animation starts from the current frame. - -- Parameters - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

name

-

string

-

Yes

-

Name of the animation to pause, which is the same as the name in the loadAnimation interface. By default, all animations are paused.

-
- -- Example - - ``` - lottie.pause(this.animateName) - ``` - - -## lottie.togglePause - -togglePause\(name: string\): void - -Pauses or plays a specified animation. This method is equivalent to the switching between **lottie.play\(\)** and **lottie.pause\(\)**. - -- Parameters - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

name

-

string

-

Yes

-

Name of the target animation, which is the same as the name in the loadAnimation interface. By default, all animations are paused.

-
- -- Example - - ``` - lottie.togglePause(this.animateName) - ``` - - -## lottie.stop - -stop\(name: string\): void - -Stops the specified animation. The next time **lottie.play\(\)** is called, the animation starts from the first frame. - -- Parameters - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

name

-

string

-

Yes

-

Name of the animation to stop, which is the same as the name in the loadAnimation interface. By default, all animations are stopped.

-
- -- Example - - ``` - lottie.stop(this.animateName) - ``` - - -## lottie.setSpeed - -setSpeed\(speed: number, name: string\): void +- Parameters + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | name | string | Yes | Name of the animation to play, which is the same as the **name** in the **loadAnimation** interface. By default, all animations are played. | + +- Example + + ``` + lottie.play(this.animateName) + ``` + + +## lottie.pause + +pause(name: string): void + +Pauses a specified animation. The next time **lottie.play()** is called, the animation starts from the current frame. + +- Parameters + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | name | string | Yes | Name of the animation to pause, which is the same as the **name** in the **loadAnimation** interface. By default, all animations are paused. | + +- Example + + ``` + lottie.pause(this.animateName) + ``` + + +## lottie.togglePause + +togglePause(name: string): void + +Pauses or plays a specified animation. This method is equivalent to the switching between **lottie.play()** and **lottie.pause()**. + +- Parameters + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | name | string | Yes | Name of the target animation, which is the same as the **name** in the **loadAnimation** interface. By default, all animations are paused. | + +- Example + + ``` + lottie.togglePause(this.animateName) + ``` + + +## lottie.stop + +stop(name: string): void + +Stops the specified animation. The next time **lottie.play()** is called, the animation starts from the first frame. + +- Parameters + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | name | string | Yes | Name of the target animation, which is the same as the **name** in the **loadAnimation** interface. By default, all animations are paused. | + +- Example + + ``` + lottie.stop(this.animateName) + ``` + + +## lottie.setSpeed + +setSpeed(speed: number, name: string): void Sets the playback speed of the specified animation. -- Parameters - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

speed

-

number

-

Yes

-

Playback speed. The value is a floating-point number. If the value is greater than 0, the animation plays in forward direction. If the value is less than 0, the animation plays in reversed direction. If the value is 0, the animation is paused. If the value is 1.0 or -1.0, the animation plays at the normal speed.

-

name

-

string

-

Yes

-

Name of the target animation, which is the same as the name in the loadAnimation interface. By default, all animations are stopped.

-
- -- Example - - ``` - lottie.setSpeed(5, this.animateName) - ``` - - -## lottie.setDirection - -setDirection\(direction: AnimationDirection, name: string\): void - -Sets the dierection in which the specified animation plays. - -- Parameters - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

direction

-

AnimationDirection

-

Yes

-

Direction in which the animation plays. 1: forwards; -1: backwards. When set to play backwards, the animation plays from the current playback progress to the first frame. When this setting is combined with loop being set to true, the animation plays backwards continuously. When the value of speed is less than 0, the animation also plays backwards.

-

AnimationDirection: 1 | -1

-

name

-

string

-

Yes

-

Name of the target animation, which is the same as the name in the loadAnimation interface. By default, all animations are set.

-
- - -- Example - - ``` - lottie.setDirection(-1, this.controlName) - ``` - - -## AnimationItem - -Defines an **AnimationItem** object, which is returned by the **loadAnimation** interface and has attributes and interfaces. The attributes are described as follows: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Description

-

name

-

string

-

Animation name.

-

isLoaded

-

boolean

-

Whether the animation is loaded.

-

currentFrame

-

number

-

Frame that is being played. The default precision is a floating-point number greater than or equal to 0.0. After setSubframe(false) is called, the value is a positive integer without decimal points.

-

currentRawFrame

-

number

-

Number of frames that are being played. The precision is a floating point number greater than or equal to 0.0.

-

firstFrame

-

number

-

First frame of the animation segment that is being played.

-

totalFrames

-

number

-

Total number of frames in the animation segment that is being played.

-

frameRate

-

number

-

Frame rate (frame/s).

-

frameMult

-

number

-

Frame rate (frame/ms).

-

playSpeed

-

number

-

Playback speed. The value is a floating-point number. If the value is greater than 0, the animation plays in forward direction. If the value is less than 0, the animation plays in reversed direction. If the value is 0, the animation is paused. If the value is 1.0 or -1.0, the animation plays at the normal speed.

-

playDirection

-

number

-

Playback direction. The options are 1 (forward) and -1 (backward).

-

playCount

-

number

-

Number of times the animation plays.

-

isPaused

-

boolean

-

Whether the current animation is paused. The value true means that the animation is paused.

-

autoplay

-

boolean

-

Whether to automatically play the animation upon completion of the loading. The value false means that the play() interface needs to be called to start playing.

-

loop

-

boolean | number

-

If the value is of the Boolean type, this parameter indicates whether to repeat the animation cyclically after the animation ends. If the value is of the number type and is greater than or equal to 1, this parameter indicates the number of times the animation plays.

-

renderer

-

any

-

Animation rendering object, which depends on the rendering type.

-

animationID

-

string

-

Animation ID.

-

timeCompleted

-

number

-

Number of frames that are played for an animation sequence. The value is affected by the setting of AnimationSegment and is the same as the value of totalFrames.

-

segmentPos

-

number

-

ID of the current animation segment. The value is a positive integer greater than or equal to 0.

-

isSubframeEnabled

-

boolean

-

Whether the precision of currentFrame is a floating point number.

-

segments

-

AnimationSegment | AnimationSegment[]

-

Current segment of the animation.

-
- -## AnimationItem.play - -play\(name?: string\): void +- Parameters + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | speed | number | Yes | Playback speed. The value is a floating-point number. If the value is greater than 0, the animation plays in forward direction. If the value is less than 0, the animation plays in reversed direction. If the value is 0, the animation is paused. If the value is 1.0 or -1.0, the animation plays at the normal speed. | + | name | string | Yes | Name of the target animation, which is the same as the **name** in the **loadAnimation** interface. By default, all animations are stopped. | + +- Example + + ``` + lottie.setSpeed(5, this.animateName) + ``` + + +## lottie.setDirection + +setDirection(direction: AnimationDirection, name: string): void + +Sets the direction in which the specified animation plays. + +- Parameters + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | direction | AnimationDirection | Yes | Direction in which the animation plays. **1**: forwards; **-1**: backwards. When set to play backwards, the animation plays from the current playback progress to the first frame. When this setting is combined with **loop** being set to **true**, the animation plays backwards continuously. When the value of **speed** is less than 0, the animation also plays backwards.
**AnimationDirection**: 1 \| -1. | + | name | string | Yes | Name of the target animation, which is the same as the **name** in the **loadAnimation** interface. By default, all animations are set. | + +- Example + + ``` + lottie.setDirection(-1, this.animateName) + ``` + + +## AnimationItem + +Defines an **AnimationItem** object, which is returned by the **loadAnimation** interface and has attributes and interfaces. The attributes are described as follows: + + | Name | Type | Description | +| -------- | -------- | -------- | +| name | string | Animation name. | +| isLoaded | boolean | Whether the animation is loaded. | +| currentFrame | number | Frame that is being played. The default precision is a floating-point number greater than or equal to 0.0. After **setSubframe(false)** is called, the value is a positive integer without decimal points. | +| currentRawFrame | number | Number of frames that are being played. The precision is a floating point number greater than or equal to 0.0. | +| firstFrame | number | First frame of the animation segment that is being played. | +| totalFrames | number | Total number of frames in the animation segment that is being played. | +| frameRate | number | Frame rate (frame/s). | +| frameMult | number | Frame rate (frame/ms). | +| playSpeed | number | Playback speed. The value is a floating-point number. If the value is greater than 0, the animation plays in forward direction. If the value is less than 0, the animation plays in reversed direction. If the value is 0, the animation is paused. If the value is **1.0** or **-1.0**, the animation plays at the normal speed. | +| playDirection | number | Playback direction. The options are **1** (forward) and **-1** (backward). | +| playCount | number | Number of times the animation plays. | +| isPaused | boolean | Whether the current animation is paused. The value **true** means that the animation is paused. | +| autoplay | boolean | Whether to automatically play the animation upon completion of the loading. The value **false** means that the **play()** interface needs to be called to start playing. | +| loop | boolean \| number | If the value is of the Boolean type, this parameter indicates whether to repeat the animation cyclically after the animation ends. If the value is of the number type and is greater than or equal to 1, this parameter indicates the number of times the animation plays. | +| renderer | any | Animation rendering object, which depends on the rendering type. | +| animationID | string | Animation ID. | +| timeCompleted | number | Number of frames that are played for an animation sequence. The value is affected by the setting of **AnimationSegment** and is the same as the value of **totalFrames**. | +| segmentPos | number | ID of the current animation segment. The value is a positive integer greater than or equal to 0. | +| isSubframeEnabled | boolean | Whether the precision of **currentFrame** is a floating point number. | +| segments | AnimationSegment \| AnimationSegment[] | Current segment of the animation. | + + +## AnimationItem.play + +play(name?: string): void Plays an animation. -- Parameters - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

name

-

string

-

No

-

Name of the target animation. By default, the value is null.

-
- -- Example - - ``` - this.anim.play() - ``` - - -## AnimationItem.destroy - -destroy\(name?: string\): void +- Parameters + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | name | string | No | Name of the target animation. By default, the value is null. | + +- Example + + ``` + this.animateItem.play() + ``` + + +## AnimationItem.destroy + +destroy(name?: string): void Destroys an animation. -- Parameters - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

name

-

string

-

No

-

Name of the target animation. By default, the value is null.

-
- -- Example - - ``` - this.anim.destroy() - ``` - - -## AnimationItem.pause - -pause\(name?: string\): void - -Pauses an animation. When the **play** interface is called next time, the animation is played from the current frame. - -- Parameters - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

name

-

string

-

No

-

Name of the target animation. By default, the value is null.

-
- -- Example - - ``` - this.anim.pause() - ``` - - -## AnimationItem.togglePause - -togglePause\(name?: string\): void - -Pauses or plays an animation. This method is equivalent to the switching between **play** and **pause**. - -- Parameters - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

name

-

string

-

No

-

Name of the target animation. By default, the value is null.

-
- -- Example - - ``` - this.anim.togglePause() - ``` - - -## AnimationItem.stop - -stop\(name?: string\): void - -Stops an animation. When the **play** interface is called next time, the animation is played from the first frame. - -- Parameters - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

name

-

string

-

No

-

Name of the target animation. By default, the value is null.

-
- -- Example - - ``` - this.anim.stop() - ``` - - -## AnimationItem.setSpeed - -setSpeed\(speed: number\): void +- Parameters + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | name | string | No | Name of the target animation. By default, the value is null. | + +- Example + + ``` + this.animateItem.destroy() + ``` + + +## AnimationItem.pause + +pause(name?: string): void + +Pauses an animation. When the **play** interface is called next time, the animation is played from the current frame. + +- Parameters + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | name | string | No | Name of the target animation. By default, the value is null. | + +- Example + + ``` + this.animateItem.pause() + ``` + + +## AnimationItem.togglePause + +togglePause(name?: string): void + +Pauses or plays an animation. This method is equivalent to the switching between **play** and **pause**. + +- Parameters + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | name | string | No | Name of the target animation. By default, the value is null. | + +- Example + + ``` + this.animateItem.togglePause() + ``` + + +## AnimationItem.stop + +stop(name?: string): void + +Stops an animation. When the **play** interface is called next time, the animation is played from the first frame. + +- Parameters + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | name | string | No | Name of the target animation. By default, the value is null. | + +- Example + + ``` + this.animateItem.stop() + ``` + + +## AnimationItem.setSpeed + +setSpeed(speed: number): void Sets the playback speed of an animation. -- Parameters - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

speed

-

number

-

Yes

-

Playback speed. The value is a floating-point number. If the value is greater than 0, the animation plays in forward direction. If the value is less than 0, the animation plays in reversed direction. If the value is 0, the animation is paused. If the value is 1.0 or -1.0, the animation plays at the normal speed.

-
- -- Example - - ``` - this.anim.setSpeed(5); - ``` - - -## AnimationItem.setDirection - -setDirection\(direction: AnimationDirection\): void +- Parameters + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | speed | number | Yes | Playback speed. The value is a floating-point number. If the value is greater than 0, the animation plays in forward direction. If the value is less than 0, the animation plays in reversed direction. If the value is 0, the animation is paused. If the value is **1.0** or **-1.0**, the animation plays at the normal speed. | + +- Example + + ``` + this.animateItem.setSpeed(5); + ``` -Sets the playback direction of an animation. -- Parameters +## AnimationItem.setDirection - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

direction

-

AnimationDirection

-

Yes

-

Direction in which the animation plays. 1: forwards; -1: backwards. When set to play backwards, the animation plays from the current playback progress to the first frame. When this setting is combined with loop being set to true, the animation plays backwards continuously. When the value of speed is less than 0, the animation also plays backwards.

-

AnimationDirection: 1 | -1.

-
+setDirection(direction: AnimationDirection): void +Sets the playback direction of an animation. -- Example +- Parameters + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | direction | AnimationDirection | Yes | Direction in which the animation plays. **1**: forwards; **-1**: backwards. When set to play backwards, the animation plays from the current playback progress to the first frame. When this setting is combined with **loop** being set to **true**, the animation plays backwards continuously. When the value of **speed** is less than 0, the animation also plays backwards.
**AnimationDirection**: 1 \| -1. | - ``` - this.anim.setDirection(-1) - ``` +- Example + + ``` + this.animateItem.setDirection(-1) + ``` -## AnimationItem.goToAndStop +## AnimationItem.goToAndStop -goToAndStop\(value: number, isFrame: boolean\): void +goToAndStop(value: number, isFrame: boolean): void Sets the animation to stop at the specified frame or time. -- Parameters - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

value

-

number

-

Yes

-

Frame ID (greater than or equal to 0) or time progress (ms) at which the animation will stop.

-

isFrame

-

boolean

-

No

-

Whether to set the animation to stop at the specified frame. The value true means to set the animation to stop at the specified frame, and false means to set the animation to stop at the specified time progress. The default value is false.

-

name

-

string

-

No

-

Name of the target animation. By default, the value is null.

-
- - -- Example - - ``` - // Set the animation to stop at the specified frame. - this.anim.goToAndStop(25, true) - // Set the animation to stop at the specified time progress. - this.anim.goToAndStop(300, false, this.animateName) - ``` - - -## AnimationItem.goToAndPlay - -goToAndPlay\(value: number, isFrame: boolean\): void +- Parameters + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | value | number | Yes | Frame ID (greater than or equal to 0) or time progress (ms) at which the animation will stop. | + | isFrame | boolean | No | Whether to set the animation to stop at the specified frame. The value **true** means to set the animation to stop at the specified frame, and **false** means to set the animation to stop at the specified time progress. The default value is **false**. | + | name | string | No | Name of the target animation. By default, the value is null. | + +- Example + + ``` + // Set the animation to stop at the specified frame. + this.animateItem.goToAndStop(25, true) + // Set the animation to stop at the specified time progress. + this.animateItem.goToAndStop(300, false, this.animateName) + ``` + + +## AnimationItem.goToAndPlay + +goToAndPlay(value: number, isFrame: boolean): void Sets the animation to start from the specified frame or time progress. -- Parameters - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

value

-

number

-

Yes

-

Frame ID (greater than or equal to 0) or time progress (ms) at which the animation will start.

-

isFrame

-

boolean

-

Yes

-

Whether to set the animation to start from the specified frame. The value true means to set the animation to start from the specified frame, and false means to set the animation to start from the specified time progress. The default value is false.

-

name

-

string

-

No

-

Name of the target animation. By default, the value is null.

-
- - -- Example - - ``` - // Set the animation to start from the specified frame. - this.anim.goToAndPlay(25, true) - // Set the animation to start from the specified time progress. - this.anim.goToAndPlay(300, false, this.animateName) - ``` - - -## AnimationItem.playSegments - -playSegments\(segments: AnimationSegment | AnimationSegment\[\], forceFlag: boolean\): void +- Parameters + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | value | number | Yes | Frame ID (greater than or equal to 0) or time progress (ms) at which the animation will start. | + | isFrame | boolean | Yes | Whether to set the animation to start from the specified frame. The value **true** means to set the animation to start from the specified frame, and **false** means to set the animation to start from the specified time progress. The default value is **false**. | + | name | string | No | Name of the target animation. By default, the value is null. | + +- Example + + ``` + // Set the animation to stop at the specified frame. + this.animateItem.goToAndPlay(25, true) + // Set the animation to stop at the specified time progress. + this.animateItem.goToAndPlay(300, false, this.animateName) + ``` + + +## AnimationItem.playSegments + +playSegments(segments: AnimationSegment | AnimationSegment[], forceFlag: boolean): void Sets the animation to play only the specified segment. -- Parameters - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

segments

-

AnimationSegment = [number, number] | AnimationSegment[]

-

Yes

-

Segment or segment list.

-

If all segments in the segment list are played, only the last segment is played in the next cycle.

-

forceFlag

-

boolean

-

Yes

-

Whether the settings take effect immediately. The value true means the settings take effect immediately, and false means the settings take effect until the current cycle of playback is completed.

-
- - -- Example - - ``` - // Set the animation to play the specified segment. - this.anim.playSegments([10, 20], false) - // Set the animation to play the specified segment list. - this.anim.playSegments([[0, 5], [20, 30]], true) - ``` - - -## AnimationItem.resetSegments - -resetSegments\(forceFlag: boolean\): void - -Resets the settings configured by the **playSegments** method to play all the frames. - -- Parameters - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

forceFlag

-

boolean

-

Yes

-

Whether the settings take effect immediately. The value true means the settings take effect immediately, and false means the settings take effect until the current cycle of playback is completed.

-
- - -- Example - - ``` - this.anim.resetSegments(true) - ``` - - -## AnimationItem.resize - -resize\(\): void - -Refreshes the animation layout. - -- Example - - ``` - this.anim.resize() - ``` - - -## AnimationItem.setSubframe - -setSubframe\(useSubFrame: boolean\): void - -Sets the precision of the **currentFrame** attribute to display floating-point numbers. - -- Parameters - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

useSubFrames

-

boolean

-

Yes

-

Whether the currentFrame attribute displays floating-point numbers. By default, the attribute displays floating-point numbers.

-

true: The currentFrame attribute displays floating-point numbers.

-

false: The currentFrame attribute displays an integer and does not display floating-point numbers.

-
+- Parameters + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | segments | AnimationSegment = [number, number] \| AnimationSegment[] | Yes | Segment or segment list.
If all segments in the segment list are played, only the last segment is played in the next cycle. | + | forceFlag | boolean | Yes | Whether the settings take effect immediately. The value **true** means the settings take effect immediately, and **false** means the settings take effect until the current cycle of playback is completed. | +- Example + + ``` + // Set the animation to play the specified segment. + this.animateItem.playSegments([10, 20], false) + // Set the animation to play the specified segment list. + this.animateItem.playSegments([[0, 5], [20, 30]], true) + ``` -- Example - ``` - this.anim.setSubframe(false) - ``` +## AnimationItem.resetSegments +resetSegments(forceFlag: boolean): void -## AnimationItem.getDuration +Resets the settings configured by the **playSegments** method to play all the frames. -getDuration\(inFrames?: boolean\): void +- Parameters + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | forceFlag | boolean | Yes | Whether the settings take effect immediately. The value **true** means the settings take effect immediately, and **false** means the settings take effect until the current cycle of playback is completed. | + +- Example + + ``` + this.animateItem.resetSegments(true) + ``` -Obtains the duration \(irrelevant to the playback speed\) or number of frames for playing an animation sequence. The settings are related to the input parameter **initialSegment** of the **Lottie.loadAnimation** interface. -- Parameters +## AnimationItem.resize + +resize(): void + +Resizes the animation layout. + +- Example + + ``` + this.animateItem.resize() + ``` - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

inFrames

-

boolean

-

No

-

Whether to obtain the duration or number of frames. true: number of frames. false: duration, in ms. The default value is false.

-
+## AnimationItem.setSubframe -- Example +setSubframe(useSubFrame: boolean): void - ``` - this.anim.setSubframe(true) - ``` +Sets the precision of the **currentFrame** attribute to display floating-point numbers. +- Parameters + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | useSubFrames | boolean | Yes | Whether the **currentFrame** attribute displays floating-point numbers. By default, the attribute displays floating-point numbers.
**true**: The **currentFrame** attribute displays floating-point numbers.
**false**: The **currentFrame** attribute displays an integer and does not display floating-point numbers. | -## AnimationItem.addEventListener +- Example + + ``` + this.animateItem.setSubframe(false) + ``` + + +## AnimationItem.getDuration + +getDuration(inFrames?: boolean): void + +Obtains the duration (irrelevant to the playback speed) or number of frames for playing an animation sequence. The settings are related to the input parameter **initialSegment** of the **Lottie.loadAnimation** interface. + +- Parameters + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | inFrames | boolean | No | Whether to obtain the duration or number of frames. **true**: number of frames. **false**: duration, in ms. The default value is **false**. | + +- Example + + ``` + this.animateItem.getDuration(true) + ``` -addEventListener\(name: AnimationEventName, callback: AnimationEventCallback\): \(\) =\> void + +## AnimationItem.addEventListener + +addEventListener<T = any>(name: AnimationEventName, callback: AnimationEventCallback<T>): () => void Adds an event listener. After the event is complete, the specified callback function is triggered. This method returns the function object that can delete the event listener. -- Parameters - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

name

-

AnimationEventName

-

Yes

-

Animation event type. The available options are as follows:

-

'enterFrame', 'loopComplete', 'complete', 'segmentStart', 'destroy', 'config_ready', 'data_ready', 'DOMLoaded', 'error', 'data_failed', 'loaded_images'

-

callback

-

AnimationEventCallback<T>

-

Yes

-

Custom callback.

-
- - -- Example - - ``` - private callbackItem: any = function() { - console.log("grunt loopComplete") - } - let delFunction = this.animateItem.addEventListener('loopComplete', this.callbackItem) +- Parameters + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | name | AnimationEventName | Yes | Animation event type. The available options are as follows:
'enterFrame', 'loopComplete', 'complete', 'segmentStart', 'destroy', 'config_ready', 'data_ready', 'DOMLoaded', 'error', 'data_failed', 'loaded_images' | + | callback | AnimationEventCallback<T> | Yes | Custom callback. | + +- Example - // Delete the event listener. - delFunction() - ``` - - -## AnimationItem.removeEventListener - -removeEventListener\(name: AnimationEventName, callback?: AnimationEventCallback\): void - -Deletes an event listener. - -- Parameters - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

name

-

AnimationEventName

-

Yes

-

Animation event type. The available options are as follows:

-

'enterFrame', 'loopComplete', 'complete', 'segmentStart', 'destroy', 'config_ready', 'data_ready', 'DOMLoaded', 'error', 'data_failed', 'loaded_images'

-

callback

-

AnimationEventCallback<T>

-

Yes

-

Custom callback. By default, the value is null, meaning that all callbacks of the event will be removed.

-
- - -- Example - - ``` - this.animateItem.removeEventListener('loopComplete', this.callbackItem) - ``` - - -## AnimationItem.triggerEvent - -triggerEvent\(name: AnimationEventName, args: T\): void + ``` + private callbackItem: any = function() { + console.log("grunt loopComplete") + } + let delFunction = this.animateItem.addEventListener('loopComplete', this.animateName) + + // Delete the event listener. + delFunction() + ``` -Directly triggers all configured callbacks of a specified event. -- Parameters - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

name

-

AnimationEventName

-

Yes

-

Animation event type.

-

-

args

-

any

-

Yes

-

Custom callback parameters.

-
- - -- Example - - ``` - private triggerCallBack: any = function(item) { - console.log("trigger loopComplete, name:" + item.name) - } +## AnimationItem.removeEventListener + +removeEventListener<T = any>(name: AnimationEventName, callback?: AnimationEventCallback<T>): void + +Removes an event listener. + +- Parameters + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | name | AnimationEventName | Yes | Animation event type. The available options are as follows:
'enterFrame', 'loopComplete', 'complete', 'segmentStart', 'destroy', 'config_ready', 'data_ready', 'DOMLoaded', 'error', 'data_failed', 'loaded_images' | + | callback | AnimationEventCallback<T> | Yes | Custom callback. By default, the value is null, meaning that all callbacks of the event will be removed. | + +- Example - this.animateItem.addEventListener('loopComplete', this.triggerCallBack) - this.animateItem.triggerEvent('loopComplete', this.animateItem) - this.animateItem.removeEventListener('loopComplete', this.triggerCallBack) - ``` + ``` + this.animateItem.removeEventListener('loopComplete', this.animateName) + ``` + + +## AnimationItem.triggerEvent +triggerEvent<T = any>(name: AnimationEventName, args: T): void +Directly triggers all configured callbacks of a specified event. + +- Parameters + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | name | AnimationEventName | Yes | Animation event type. | + | args | any | Yes | Custom callback parameters. | + +- Example + + ``` + private triggerCallBack: any = function(item) { + console.log("trigger loopComplete, name:" + item.name) + } + + this.animateItem.addEventListener('loopComplete', this.triggerCallBack) + this.animateItem.triggerEvent('loopComplete', this.animateItem) + this.animateItem.removeEventListener('loopComplete', this.triggerCallBack) + ``` diff --git a/en/application-dev/reference/arkui-ts/ts-components-canvas-path2d.md b/en/application-dev/reference/arkui-ts/ts-components-canvas-path2d.md index d86cfb307868e8b4d2f0bf4cd4aa29891df1f7bd..1bf9a31ed4887b3d54e583d42691079277531839 100644 --- a/en/application-dev/reference/arkui-ts/ts-components-canvas-path2d.md +++ b/en/application-dev/reference/arkui-ts/ts-components-canvas-path2d.md @@ -1,958 +1,453 @@ -# Path2D +# Path2D ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->This component is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version. -**Path2D** allows you to describe a path through an existing path. This path can be drawn through the **stroke** API of **Canvas**. +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** +> This component is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version. -## addPath -addPath\(path: Object\): void +**Path2D** allows you to describe a path through an existing path. This path can be drawn through the **stroke** API of **Canvas**. + + +## addPath + +addPath(path: Object): void Adds a path to this path. -- Parameters - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

path

-

Object

-

Yes

-

null

-

Path to be added to this path.

-
- -- Example - - ``` - @Entry - @Component - struct AddPath { - private settings: RenderingContextSettings = new RenderingContextSettings(true) - private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) - - private path2Da: Path2D = new Path2D("M250 150 L150 350 L350 350 Z") - private path2Db: Path2D = new Path2D() +- Parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | path | Object | Yes | null | Path to be added to this path. | + +- Example - build() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Canvas(this.context) - .width('100%') - .height('100%') - .backgroundColor('#ffff00') - .onReady(() =>{ - this.path2Db.addPath(this.path2Da) - this.context.stroke(this.path2Db) - }) - } - .width('100%') - .height('100%') + ``` + @Entry + @Component + struct AddPath { + private settings: RenderingContextSettings = new RenderingContextSettings(true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + + private path2Da: Path2D = new Path2D("M250 150 L150 350 L350 350 Z") + private path2Db: Path2D = new Path2D() + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.path2Db.addPath(this.path2Da) + this.context.stroke(this.path2Db) + }) } + .width('100%') + .height('100%') } - ``` + } + ``` - ![](figures/en-us_image_0000001192595216.png) + ![en-us_image_0000001211898520](figures/en-us_image_0000001211898520.png) -## closePath +## closePath -closePath\(\): void +closePath(): void -Moves the current point of the path back to the start point of the path, and draws a straight line between the current point and the start point. If the shape is closed or has only one point, this method does not perform any action. +Moves the current point of the path back to the start point of the path, and draws a straight line between the current point and the start point. If the shape has already been closed or has only one point, this method does nothing. -- Example - - ``` - @Entry - @Component - struct ClosePath { - private settings: RenderingContextSettings = new RenderingContextSettings(true) - private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) - private path2Db: Path2D = new Path2D() +- Example - build() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Canvas(this.context) - .width('100%') - .height('100%') - .backgroundColor('#ffff00') - .onReady(() =>{ - this.path2Db.moveTo(200, 100) - this.path2Db.lineTo(300, 100) - this.path2Db.lineTo(200, 200) - this.path2Db.closePath() - this.context.stroke(this.path2Db) - }) - } - .width('100%') - .height('100%') + ``` + @Entry + @Component + struct ClosePath { + private settings: RenderingContextSettings = new RenderingContextSettings(true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + private path2Db: Path2D = new Path2D() + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.path2Db.moveTo(200, 100) + this.path2Db.lineTo(300, 100) + this.path2Db.lineTo(200, 200) + this.path2Db.closePath() + this.context.stroke(this.path2Db) + }) } + .width('100%') + .height('100%') } - ``` + } + ``` - ![](figures/unnaming-(4).png) + ![en-us_image_0000001212218482](figures/en-us_image_0000001212218482.png) -## moveTo +## moveTo -moveTo\(x: number, y: number\): void +moveTo(x: number, y: number): void Moves the current coordinate point of the path to the target point, without drawing a line during the movement. -- Parameters - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

x

-

number

-

Yes

-

0

-

X-coordinate of the target point.

-

y

-

number

-

Yes

-

0

-

Y-coordinate of the target point.

-
- -- Example - - ``` - @Entry - @Component - struct MoveTo { - private settings: RenderingContextSettings = new RenderingContextSettings(true) - private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) - private path2Db: Path2D = new Path2D() +- Parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | x | number | Yes | 0 | X-coordinate of the target point. | + | y | number | Yes | 0 | Y-coordinate of the target point. | + +- Example - build() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Canvas(this.context) - .width('100%') - .height('100%') - .backgroundColor('#ffff00') - .onReady(() =>{ - this.path2Db.moveTo(50, 100) - this.path2Db.lineTo(250, 100) - this.path2Db.lineTo(150, 200) - this.path2Db.closePath() - this.context.stroke(this.path2Db) - }) - } - .width('100%') - .height('100%') + ``` + @Entry + @Component + struct MoveTo { + private settings: RenderingContextSettings = new RenderingContextSettings(true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + private path2Db: Path2D = new Path2D() + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.path2Db.moveTo(50, 100) + this.path2Db.lineTo(250, 100) + this.path2Db.lineTo(150, 200) + this.path2Db.closePath() + this.context.stroke(this.path2Db) + }) } + .width('100%') + .height('100%') } - ``` + } + ``` - ![](figures/en-us_image_0000001237475113.png) + ![en-us_image_0000001257138389](figures/en-us_image_0000001257138389.png) -## lineTo +## lineTo -lineTo\(x: number, y: number\): void +lineTo(x: number, y: number): void Draws a straight line from the current point to the target point. -- Parameters - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

x

-

number

-

Yes

-

0

-

X-coordinate of the target point.

-

y

-

number

-

Yes

-

0

-

Y-coordinate of the target point.

-
- -- Example - - ``` - @Entry - @Component - struct LineTo { - private settings: RenderingContextSettings = new RenderingContextSettings(true) - private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) - private path2Db: Path2D = new Path2D() +- Parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | x | number | Yes | 0 | X-coordinate of the target point. | + | y | number | Yes | 0 | Y-coordinate of the target point. | + +- Example - build() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Canvas(this.context) - .width('100%') - .height('100%') - .backgroundColor('#ffff00') - .onReady(() =>{ - this.path2Db.moveTo(100, 100) - this.path2Db.lineTo(100, 200) - this.path2Db.lineTo(200, 200) - this.path2Db.lineTo(200, 100) - this.path2Db.closePath() - this.context.stroke(this.path2Db) - }) - } - .width('100%') - .height('100%') + ``` + @Entry + @Component + struct LineTo { + private settings: RenderingContextSettings = new RenderingContextSettings(true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + private path2Db: Path2D = new Path2D() + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.path2Db.moveTo(100, 100) + this.path2Db.lineTo(100, 200) + this.path2Db.lineTo(200, 200) + this.path2Db.lineTo(200, 100) + this.path2Db.closePath() + this.context.stroke(this.path2Db) + }) } + .width('100%') + .height('100%') } - ``` + } + ``` - ![](figures/unnaming-(3).png) + ![en-us_image_0000001256858435](figures/en-us_image_0000001256858435.png) -## bezierCurveTo +## bezierCurveTo -bezierCurveTo\(cp1x: number, cp1y: number, cp2x: number, cp2y: number, x: number, y: number\): void +bezierCurveTo(cp1x: number, cp1y: number, cp2x: number, cp2y: number, x: number, y: number): void Draws a cubic bezier curve on the canvas. -- Parameters - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

cp1x

-

number

-

Yes

-

0

-

X-coordinate of the first parameter of the bezier curve.

-

cp1y

-

number

-

Yes

-

0

-

Y-coordinate of the first parameter of the bezier curve.

-

cp2x

-

number

-

Yes

-

0

-

X-coordinate of the second parameter of the bezier curve.

-

cp2y

-

number

-

Yes

-

0

-

Y-coordinate of the second parameter of the bezier curve.

-

x

-

number

-

Yes

-

0

-

X-coordinate of the end point on the bezier curve.

-

y

-

number

-

Yes

-

0

-

Y-coordinate of the end point on the bezier curve.

-
- - -- Example - - ``` - @Entry - @Component - struct BezierCurveTo { - private settings: RenderingContextSettings = new RenderingContextSettings(true) - private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) - private path2Db: Path2D = new Path2D() +- Parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | cp1x | number | Yes | 0 | X-coordinate of the first parameter of the bezier curve. | + | cp1y | number | Yes | 0 | Y-coordinate of the first parameter of the bezier curve. | + | cp2x | number | Yes | 0 | X-coordinate of the second parameter of the bezier curve. | + | cp2y | number | Yes | 0 | Y-coordinate of the second parameter of the bezier curve. | + | x | number | Yes | 0 | X-coordinate of the end point on the bezier curve. | + | y | number | Yes | 0 | Y-coordinate of the end point on the bezier curve. | + +- Example - build() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Canvas(this.context) - .width('100%') - .height('100%') - .backgroundColor('#ffff00') - .onReady(() =>{ - this.path2Db.moveTo(10, 10) - this.path2Db.bezierCurveTo(20, 100, 200, 100, 200, 20);this.context.stroke(this.path2Db) - }) - } - .width('100%') - .height('100%') + ``` + @Entry + @Component + struct BezierCurveTo { + private settings: RenderingContextSettings = new RenderingContextSettings(true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + private path2Db: Path2D = new Path2D() + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.path2Db.moveTo(10, 10) + this.path2Db.bezierCurveTo(20, 100, 200, 100, 200, 20);this.context.stroke(this.path2Db) + }) } + .width('100%') + .height('100%') } - ``` + } + ``` - ![](figures/en-us_image_0000001192915158.png) + ![en-us_image_0000001257058445](figures/en-us_image_0000001257058445.png) -## quadraticCurveTo +## quadraticCurveTo -quadraticCurveTo\(cpx: number, cpy: number, x: number ,y: number\): void +quadraticCurveTo(cpx: number, cpy: number, x: number ,y: number): void Draws a quadratic curve on the canvas. -- Parameters - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

cpx

-

number

-

Yes

-

0

-

X-coordinate of the bezier curve parameter.

-

cpy

-

number

-

Yes

-

0

-

Y-coordinate of the bezier curve parameter.

-

x

-

number

-

Yes

-

0

-

X-coordinate of the end point on the bezier curve.

-

y

-

number

-

Yes

-

0

-

Y-coordinate of the end point on the bezier curve.

-
- -- Example - - ``` - @Entry - @Component - struct QuadraticCurveTo { - private settings: RenderingContextSettings = new RenderingContextSettings(true) - private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) - private path2Db: Path2D = new Path2D() +- Parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | cpx | number | Yes | 0 | X-coordinate of the bezier curve parameter. | + | cpy | number | Yes | 0 | Y-coordinate of the bezier curve parameter. | + | x | number | Yes | 0 | X-coordinate of the end point on the bezier curve. | + | y | number | Yes | 0 | Y-coordinate of the end point on the bezier curve. | + +- Example - build() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Canvas(this.context) - .width('100%') - .height('100%') - .backgroundColor('#ffff00') - .onReady(() =>{ - this.path2Db.moveTo(10, 10) - this.path2Db.quadraticCurveTo(100, 100, 200, 20) - this.context.stroke(this.path2Db) - }) - } - .width('100%') - .height('100%') + ``` + @Entry + @Component + struct QuadraticCurveTo { + private settings: RenderingContextSettings = new RenderingContextSettings(true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + private path2Db: Path2D = new Path2D() + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.path2Db.moveTo(10, 10) + this.path2Db.quadraticCurveTo(100, 100, 200, 20) + this.context.stroke(this.path2Db) + }) } + .width('100%') + .height('100%') } - ``` + } + ``` - ![](figures/en-us_image_0000001237555151.png) + ![en-us_image_0000001212058512](figures/en-us_image_0000001212058512.png) -## arc +## arc -arc\(x: number, y: number, radius: number, startAngle: number, endAngle: number, anticlockwise?: number\): void +arc(x: number, y: number, radius: number, startAngle: number, endAngle: number, anticlockwise?: number): void Draws an arc on the canvas. -- Parameters - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

x

-

number

-

Yes

-

0

-

X-coordinate of the center point of the arc.

-

y

-

number

-

Yes

-

0

-

Y-coordinate of the center point of the arc.

-

radius

-

number

-

Yes

-

0

-

Radius of the arc.

-

startAngle

-

number

-

Yes

-

0

-

Start radian of the arc.

-

endAngle

-

number

-

Yes

-

0

-

End radian of the arc.

-

anticlockwise

-

boolean

-

No

-

false

-

Whether to draw the arc counterclockwise.

-
- -- Example - - ``` - @Entry - @Component - struct Arc { - private settings: RenderingContextSettings = new RenderingContextSettings(true) - private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) - private path2Db: Path2D = new Path2D() +- Parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | x | number | Yes | 0 | X-coordinate of the center point of the arc. | + | y | number | Yes | 0 | Y-coordinate of the center point of the arc. | + | radius | number | Yes | 0 | Radius of the arc. | + | startAngle | number | Yes | 0 | Start radian of the arc. | + | endAngle | number | Yes | 0 | End radian of the arc. | + | anticlockwise | boolean | No | false | Whether to draw the arc counterclockwise. | + +- Example - build() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Canvas(this.context) - .width('100%') - .height('100%') - .backgroundColor('#ffff00') - .onReady(() =>{ - this.path2Db.arc(100, 75, 50, 0, 6.28);this.context.stroke(this.path2Db) - }) - } - .width('100%') - .height('100%') + ``` + @Entry + @Component + struct Arc { + private settings: RenderingContextSettings = new RenderingContextSettings(true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + private path2Db: Path2D = new Path2D() + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.path2Db.arc(100, 75, 50, 0, 6.28);this.context.stroke(this.path2Db) + }) } + .width('100%') + .height('100%') } - ``` + } + ``` - ![](figures/en-us_image_0000001192595214.png) + ![en-us_image_0000001212378446](figures/en-us_image_0000001212378446.png) -## arcTo +## arcTo -arcTo\(x1: number, y1: number, x2: number, y2: number, radius: number\): void +arcTo(x1: number, y1: number, x2: number, y2: number, radius: number): void Draws an arc based on the radius and points on the arc. -- Parameters - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

x1

-

number

-

Yes

-

0

-

X-coordinate of the first point on the arc.

-

y1

-

number

-

Yes

-

0

-

Y-coordinate of the first point on the arc.

-

x2

-

number

-

Yes

-

0

-

X-coordinate of the second point on the arc.

-

y2

-

number

-

Yes

-

0

-

Y-coordinate of the second point on the arc.

-

radius

-

number

-

Yes

-

0

-

Radius of the arc.

-
- -- Example - - ``` - @Entry - @Component - struct ArcTo { - private settings: RenderingContextSettings = new RenderingContextSettings(true) - private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) - private path2Db: Path2D = new Path2D() +- Parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | x1 | number | Yes | 0 | X-coordinate of the first point on the arc. | + | y1 | number | Yes | 0 | Y-coordinate of the first point on the arc. | + | x2 | number | Yes | 0 | X-coordinate of the second point on the arc. | + | y2 | number | Yes | 0 | Y-coordinate of the second point on the arc. | + | radius | number | Yes | 0 | Radius of the arc. | + +- Example - build() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Canvas(this.context) - .width('100%') - .height('100%') - .backgroundColor('#ffff00') - .onReady(() =>{ - this.path2Db.arcTo(150, 20, 150, 70, 50) - this.context.stroke(this.path2Db) - }) - } - .width('100%') - .height('100%') + ``` + @Entry + @Component + struct ArcTo { + private settings: RenderingContextSettings = new RenderingContextSettings(true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + private path2Db: Path2D = new Path2D() + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.path2Db.arcTo(150, 20, 150, 70, 50) + this.context.stroke(this.path2Db) + }) } + .width('100%') + .height('100%') } - ``` + } + ``` - ![](figures/en-us_image_0000001192755172.png) + ![en-us_image_0000001212058510](figures/en-us_image_0000001212058510.png) -## ellipse +## ellipse -ellipse\(x: number, y: number, radiusX: number, radiusY: number, rotation: number, startAngle: number, endAngle: number, anticlockwise?: number\): void +ellipse(x: number, y: number, radiusX: number, radiusY: number, rotation: number, startAngle: number, endAngle: number, anticlockwise?: number): void Draws an ellipse in the specified rectangular region. -- Parameters - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

x

-

number

-

Yes

-

0

-

X-coordinate of the ellipse center.

-

y

-

number

-

Yes

-

0

-

Y-coordinate of the ellipse center.

-

radiusX

-

number

-

Yes

-

0

-

Ellipse radius on the x-axis.

-

radiusY

-

number

-

Yes

-

0

-

Ellipse radius on the y-axis.

-

rotation

-

number

-

Yes

-

0

-

Rotation angle of the ellipse, in radians.

-

startAngle

-

number

-

Yes

-

0

-

Angle of the start point for drawing the ellipse, in radians.

-

endAngle

-

number

-

Yes

-

0

-

Angle of the end point for drawing the ellipse, in radians.

-

anticlockwise

-

number

-

No

-

0

-

Whether to draw the ellipse in the counterclockwise direction. The value 0 means to draw the ellipse in the clockwise direction, and 1 means to draw the ellipse in the counterclockwise direction. This parameter is optional. The default value is 0.

-
- -- Example - - ``` - @Entry - @Component - struct CanvasExample { - private settings: RenderingContextSettings = new RenderingContextSettings(true) - private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) - private path2Db: Path2D = new Path2D() +- Parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | x | number | Yes | 0 | X-coordinate of the ellipse center. | + | y | number | Yes | 0 | Y-coordinate of the ellipse center. | + | radiusX | number | Yes | 0 | Ellipse radius on the x-axis. | + | radiusY | number | Yes | 0 | Ellipse radius on the y-axis. | + | rotation | number | Yes | 0 | Rotation angle of the ellipse, in radians. | + | startAngle | number | Yes | 0 | Angle of the start point for drawing the ellipse, in radians. | + | endAngle | number | Yes | 0 | Angle of the end point for drawing the ellipse, in radians. | + | anticlockwise | number | No | 0 | Whether to draw the ellipse in the counterclockwise direction. The value **0** means to draw the ellipse in the clockwise direction, and **1** means to draw the ellipse in the counterclockwise direction. This parameter is optional. The default value is **0**. | + +- Example - build() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Canvas(this.context) - .width('100%') - .height('100%') - .backgroundColor('#ffff00') - .onReady(() =>{ - this.path2Db.ellipse(200, 200, 50, 100, Math.PI * 0.25, Math.PI * 0.5, Math.PI, true) - this.context.stroke(this.path2Db) - }) - } - .width('100%') - .height('100%') + ``` + @Entry + @Component + struct CanvasExample { + private settings: RenderingContextSettings = new RenderingContextSettings(true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + private path2Db: Path2D = new Path2D() + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.path2Db.ellipse(200, 200, 50, 100, Math.PI * 0.25, Math.PI * 0.5, Math.PI) + this.context.stroke(this.path2Db) + }) } + .width('100%') + .height('100%') } - ``` + } + ``` - ![](figures/en-us_image_0000001193075154.png) + ![en-us_image_0000001257138391](figures/en-us_image_0000001257138391.png) -## rect +## rect -rect\(x: number, y: number, width: number, height: number\): void +rect(x: number, y: number, width: number, height: number): void Creates a rectangle. -- Parameters - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

x

-

number

-

Yes

-

0

-

X-coordinate of the upper left corner of the rectangle.

-

y

-

number

-

Yes

-

0

-

Y-coordinate of the upper left corner of the rectangle.

-

width

-

number

-

Yes

-

0

-

Width of the rectangle.

-

height

-

number

-

Yes

-

0

-

Height of the rectangle.

-
- -- Example - - ``` - @Entry - @Component - struct CanvasExample { - private settings: RenderingContextSettings = new RenderingContextSettings(true) - private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) - private path2Db: Path2D = new Path2D() +- Parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | x | number | Yes | 0 | X-coordinate of the upper left corner of the rectangle. | + | y | number | Yes | 0 | Y-coordinate of the upper left corner of the rectangle. | + | width | number | Yes | 0 | Width of the rectangle. | + | height | number | Yes | 0 | Height of the rectangle. | + +- Example - build() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Canvas(this.context) - .width('100%') - .height('100%') - .backgroundColor('#ffff00') - .onReady(() =>{ - this.path2Db.rect(20, 20, 100, 100);this.context.stroke(this.path2Db) - }) - } - .width('100%') - .height('100%') + ``` + @Entry + @Component + struct CanvasExample { + private settings: RenderingContextSettings = new RenderingContextSettings(true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + private path2Db: Path2D = new Path2D() + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.path2Db.rect(20, 20, 100, 100);this.context.stroke(this.path2Db) + }) } + .width('100%') + .height('100%') } - ``` - - ![](figures/en-us_image_0000001192755174.png) + } + ``` + ![en-us_image_0000001256978385](figures/en-us_image_0000001256978385.png) diff --git a/en/application-dev/reference/arkui-ts/ts-components-canvas.md b/en/application-dev/reference/arkui-ts/ts-components-canvas.md index c28d94e917737bd4625cb335bf388ae50bc7b5f9..c6dfbdb87c20e7b51fcc1b300e85f217ec6352bd 100644 --- a/en/application-dev/reference/arkui-ts/ts-components-canvas.md +++ b/en/application-dev/reference/arkui-ts/ts-components-canvas.md @@ -1,19 +1,19 @@ -# Canvas Components +# Canvas Components -- **[Canvas](ts-components-canvas-canvas.md)** -- **[CanvasRenderingContext2D](ts-canvasrenderingcontext2d.md)** -- **[OffscreenCanvasRenderingConxt2D](ts-offscreencanvasrenderingcontext2d.md)** +- **[Canvas](ts-components-canvas-canvas.md)** -- **[Lottie](ts-components-canvas-lottie.md)** +- **[CanvasRenderingContext2D](ts-canvasrenderingcontext2d.md)** -- **[Path2D](ts-components-canvas-path2d.md)** +- **[OffscreenCanvasRenderingConxt2D](ts-offscreencanvasrenderingcontext2d.md)** -- **[CanvasGradient](ts-components-canvas-canvasgradient.md)** +- **[Lottie](ts-components-canvas-lottie.md)** -- **[ImageBitmap](ts-components-canvas-imagebitmap.md)** +- **[Path2D](ts-components-canvas-path2d.md)** -- **[ImageData](ts-components-canvas-imagedata.md)** +- **[CanvasGradient](ts-components-canvas-canvasgradient.md)** +- **[ImageBitmap](ts-components-canvas-imagebitmap.md)** +- **[ImageData](ts-components-canvas-imagedata.md)** \ No newline at end of file diff --git a/en/application-dev/reference/arkui-ts/ts-components-container.md b/en/application-dev/reference/arkui-ts/ts-components-container.md index 3350d2b43e33b0334e4f45ae321cc1bce612d93e..8ec33a004054eafdace9fbfbd19e75c7f6734df7 100644 --- a/en/application-dev/reference/arkui-ts/ts-components-container.md +++ b/en/application-dev/reference/arkui-ts/ts-components-container.md @@ -1,51 +1,47 @@ -# Container Components +# Container Components -- **[AlphabetIndexer](ts-container-alphabet-indexer.md)** -- **[Badge](ts-container-badge.md)** -- **[Column](ts-container-column.md)** +- **[AlphabetIndexer](ts-container-alphabet-indexer.md)** -- **[ColumnSplit](ts-container-columnsplit.md)** +- **[Badge](ts-container-badge.md)** -- **[Counter](ts-container-counter.md)** +- **[Column](ts-container-column.md)** -- **[Flex](ts-container-flex.md)** +- **[ColumnSplit](ts-container-columnsplit.md)** -- **[GridContainer](ts-container-gridcontainer.md)** +- **[Counter](ts-container-counter.md)** -- **[Grid](ts-container-grid.md)** +- **[Flex](ts-container-flex.md)** -- **[GridItem](ts-container-griditem.md)** +- **[GridContainer](ts-container-gridcontainer.md)** -- **[List](ts-container-list.md)** +- **[Grid](ts-container-grid.md)** -- **[ListItem](ts-container-listitem.md)** +- **[GridItem](ts-container-griditem.md)** -- **[Navigator](ts-container-navigator.md)** +- **[List](ts-container-list.md)** -- **[Navigation](ts-container-navigation.md)** +- **[ListItem](ts-container-listitem.md)** -- **[Panel](ts-container-panel.md)** +- **[Navigator](ts-container-navigator.md)** -- **[Row](ts-container-row.md)** +- **[Navigation](ts-basic-components-navigation.md)** -- **[RowSplit](ts-container-rowsplit.md)** +- **[Panel](ts-container-panel.md)** -- **[Scroll](ts-container-scroll.md)** +- **[Row](ts-container-row.md)** -- **[ScrollBar](ts-container-scrollbar.md)** +- **[RowSplit](ts-container-rowsplit.md)** -- **[Stack](ts-container-stack.md)** +- **[Scroll](ts-container-scroll.md)** -- **[Swiper](ts-container-swiper.md)** +- **[ScrollBar](ts-basic-components-scrollbar.md)** -- **[Tabs](ts-container-tabs.md)** +- **[Stack](ts-container-stack.md)** -- **[TabContent](ts-container-tabcontent.md)** - -- **[Stepper](ts-container-stepper.md)** - -- **[StepperItem](ts-container-stepperitem.md)** +- **[Swiper](ts-container-swiper.md)** +- **[Tabs](ts-container-tabs.md)** +- **[TabContent](ts-container-tabcontent.md)** \ No newline at end of file diff --git a/en/application-dev/reference/arkui-ts/ts-components.md b/en/application-dev/reference/arkui-ts/ts-components.md index 6dd3d6a512fa63959867b3c52e47aba7349f8f06..dc08067174dd0cadf9f8dcdb56142ca008fa6344 100644 --- a/en/application-dev/reference/arkui-ts/ts-components.md +++ b/en/application-dev/reference/arkui-ts/ts-components.md @@ -1,13 +1,15 @@ -# Components +# Components -- **[Universal Components](ts-universal-components.md)** -- **[Basic Components](ts-basic-components.md)** -- **[Container Components](ts-components-container.md)** +- **[Universal Components](ts-universal-components.md)** -- **[Drawing Components](ts-drawing-components.md)** +- **[Basic Components](ts-basic-components.md)** -- **[Canvas Components](ts-components-canvas.md)** +- **[Container Components](ts-components-container.md)** +- **[Media Components](ts-media-components.md)** +- **[Drawing Components](ts-drawing-components.md)** + +- **[Canvas Components](ts-components-canvas.md)** \ No newline at end of file diff --git a/en/application-dev/reference/arkui-ts/ts-container-alphabet-indexer.md b/en/application-dev/reference/arkui-ts/ts-container-alphabet-indexer.md index 4009d2f45471877baaf05483dee27055009169a1..8af93f953f37ce9fc68331b0b068c8b238dae85f 100644 --- a/en/application-dev/reference/arkui-ts/ts-container-alphabet-indexer.md +++ b/en/application-dev/reference/arkui-ts/ts-container-alphabet-indexer.md @@ -1,244 +1,72 @@ -# AlphabetIndexer +# AlphabetIndexer ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -The **** component provides an alphabetic index bar. +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** +> This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -## Applicable Devices - - - - - - - - - - - - - -

Phone

-

Tablet

-

Smart TV

-

Wearable

-

Yes

-

Yes

-

No

-

No

-
+The **<AlphabetIndexer>** component provides an alphabetic index bar. -## Required Permissions + +## Required Permissions None -## Child Components + +## Child Components None -## APIs -AlphabetIndexer\(value: \{arrayValue : Array, selected : number\}\) +## APIs -- Parameters +AlphabetIndexer(value: {arrayValue : Array<string>, selected : number}) - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

arrayValue

-

Array<string>

-

Yes

-

-

-

Array of strings to be displayed in the alphabetic index bar.

-

selected

-

number

-

Yes

-

-

-

ID of a selected item.

-
+- Parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | arrayValue | Array<string> | Yes | - | Array of strings to be displayed in the alphabetic index bar. | + | selected | number | Yes | - | ID of a selected item. | -## Attributes +## Attributes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Description

-

selectedColor

-

Color

-

Font color of the selected text.

-

popupColor

-

Color

-

Font color of the pop-up text.

-

selectedBackgroundColor

-

Color

-

Background color of the selected text.

-

popupBackground

-

Color

-

Background color of the pop-up text.

-

usingPopup

-

boolean

-

Whether to use pop-up text.

-

selectedFont

-

{

-

size?: number,

-

weight?: FontWeight,

-

family?: string,

-

style?: FontStyle

-

}

-

Font style of the selected text.

-

popupFont

-

{

-

size?: number,

-

weight?: FontWeight,

-

family?: string,

-

style?: FontStyle

-

}

-

Font style of the pop-up text.

-

font

-

{

-

size?: number,

-

weight?: FontWeight,

-

family?: string,

-

style?: FontStyle

-

}

-

Default font style of the alphabetic index bar.

-

itemSize

-

Length

-

Size of an item in the alphabetic index bar. The item is a square, and the side length needs to be set.

-

alignStyle

-

IndexerAlign

-

Alignment style of the alphabetic index bar. Left alignment and right alignment are supported. The alignment style affects the position of the pop-up window.

-
+ | Name | Type | Description | +| -------- | -------- | -------- | +| selectedColor | Color | Font color of the selected text. | +| popupColor | Color | Font color of the pop-up text. | +| selectedBackgroundColor | Color | Background color of the selected text. | +| popupBackground | Color | Background color of the pop-up text. | +| usingPopup | boolean | Whether to use pop-up text. | +| selectedFont | {
size?: number,
weight?: FontWeight,
family?: string,
style?: FontStyle
} | Font style of the selected text. | +| popupFont | {
size?: number,
weight?: FontWeight,
family?: string,
style?: FontStyle
} | Font style of the pop-up text. | +| font | {
size?: number,
weight?: FontWeight,
family?: string,
style?: FontStyle
} | Default font style of the alphabetic index bar. | +| itemSize | Length | Size of an item in the alphabetic index bar. The item is a square, and the side length needs to be set. | +| alignStyle | IndexerAlign | Alignment style of the alphabetic index bar. Left alignment and right alignment are supported. The alignment style affects the position of the pop-up window. | -- IndexerAlign enums +- IndexerAlign enums + | Name | Description | + | -------- | -------- | + | Left | The pop-up window is displayed on the right of the alphabetic indexer bar. | + | Right | The pop-up window is displayed on the left of the alphabetic indexer bar. | - - - - - - - - - - - - -

Name

-

Description

-

Left

-

The pop-up window is displayed on the right of the alphabetic indexer bar.

-

Right

-

The pop-up window is displayed on the left of the alphabetic indexer bar.

-
+## Events -## Events + | Name | Description | +| -------- | -------- | +| onSelected(index: number) => void | Callback invoked when an item in the alphabetic indexer bar is selected. | +| onRequestPopupData(callback: (index: number) => Array<string>)8+ | Invoked when a request for displaying content in the index prompt window is sent when an item in the alphabetic indexer bar is selected.
The return value is a string array corresponding to the indexes. The string array is displayed vertically in the pop-up window. It can display up to five strings at a time and allows scrolling. | +| onPopupSelected(callback: (index: number) => void)8+ | Invoked when an item in the index pop-up window is selected. | - - - - - - - - - - - - - - - -

Name

-

Description

-

onSelected(index: number) => void

-

Invoked when an item in the alphabetic indexer bar is selected.

-

onRequestPopupData(callback: (index: number) => Array<string>)8+

-

Invoked when a request for displaying content in the index prompt window is sent when an item in the alphabetic indexer bar is selected.

-

The return value is a string array corresponding to the indexes. The string array is displayed vertically in the pop-up window. It can display up to five strings at a time and allows scrolling.

-

onPopupSelected(callback: (index: number) => void)8+

-

Invoked when an item in the index prompt window is selected.

-
-## Example +## Example + ``` @Entry @Component -struct AlphabetIndexerComponent { +struct AlphabetIndexerSample { private value: string[] = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'] build() { @@ -260,5 +88,4 @@ struct AlphabetIndexerComponent { } ``` -![](figures/alphabetindexer.gif) - +![en-us_image_0000001212378392](figures/en-us_image_0000001212378392.gif) diff --git a/en/application-dev/reference/arkui-ts/ts-container-badge.md b/en/application-dev/reference/arkui-ts/ts-container-badge.md index ccb15c953951d277547b7db473e5e642e6cad89f..9ab237910aa3d2443e9df09a1f5a9d7703a8034e 100644 --- a/en/application-dev/reference/arkui-ts/ts-container-badge.md +++ b/en/application-dev/reference/arkui-ts/ts-container-badge.md @@ -1,233 +1,64 @@ -# Badge +# Badge ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -The **** component presents event information on a component. +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** +> This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -## Required Permissions -None - -## Child Components +The **<Badge>** component presents event information on a component. -This component supports only one child component. -## APIs +## Required Permissions -Badge\(value: \{count: number, position?: BadgePosition, maxCount?: number, style?: BadgeStyle\}\) +None -- Parameters - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

count

-

number

-

Yes

-

-

-

Number of prompt messages.

-

position

-

BadgePosition

-

No

-

RightTop

-

Position to display the badge relative to the parent component.

-

maxCount

-

number

-

No

-

99

-

Maximum number of prompt messages. When the maximum number is reached, only maxCount+ is displayed.

-

style

-

BadgeStyle

-

No

-

-

-

Style of the <Badge> component, including the text color, text size, badge color, and badge size.

-
+## Child Components +This component supports only one child component. -Badge\(value: \{value: string, position?: BadgePosition, style?: BadgeStyle\}\) -Creates a **** component based on the string. +## APIs -- Parameters +Badge(value: {count: number, position?: BadgePosition, maxCount?: number, style?: BadgeStyle}) - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

value

-

string

-

Yes

-

-

-

String of the content to prompt.

-

position

-

BadgePosition

-

No

-

RightTop

-

Display position of the badge.

-

style

-

BadgeStyle

-

No

-

-

-

Style of the <Badge> component, including the text color, text size, badge color, and badge size.

-
+- Parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | count | number | Yes | - | Number of prompt messages. | + | position | BadgePosition | No | BadgePosition.RightTop | Position to display the badge relative to the parent component. | + | maxCount | number | No | 99 | Maximum number of prompt messages. When the maximum number is reached, only **maxCount+** is displayed. | + | style | BadgeStyle | No | - | Style of the **<Badge>** component, including the text color, text size, badge color, and badge size. | +Badge(value: {value: string, position?: BadgePosition, style?: BadgeStyle}) -- BadgeStyle object +Creates a **<Badge>** component based on the string. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

color

-

Color

-

No

-

White

-

Text color.

-

fontSize

-

number | string

-

No

-

10

-

Text size.

-

badgeSize

-

number | string

-

Yes

-

-

-

Size of the badge.

-

badgeColor

-

Color

-

No

-

Red

-

Color of the badge.

-
+- Parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | value | string | Yes | - | String of the content to prompt. | + | position | BadgePosition | No | BadgePosition.RightTop | Display position of the badge. | + | style | BadgeStyle | No | - | Style of the **<Badge>** component, including the text color, text size, badge color, and badge size. | +- BadgeStyle object + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | color | Color | No | Color.White | Text color. | + | fontSize | number \| string | No | 10 | Text size. | + | badgeSize | number \| string | Yes | - | Size of the badge. | + | badgeColor | Color | No | Color.Red | Color of the badge. | -- BadgePosition enums +- BadgePosition enums + | Name | Description | + | -------- | -------- | + | Right | The badge is vertically centered on the right of the parent component. | + | RightTop | The badge is displayed in the upper right corner of the parent component. | + | Left | The badge is vertically centered on the left of the parent component. | - - - - - - - - - - - - - - - -

Name

-

Description

-

Right

-

The badge is vertically centered on the right of the parent component.

-

RightTop

-

The badge is displayed in the upper right corner of the parent component.

-

Left

-

The badge is vertically centered on the left of the parent component.

-
+## Example -## Example ``` @Entry @@ -273,5 +104,4 @@ struct BadgeExample { } ``` -![](figures/badge.gif) - +![en-us_image_0000001212218470](figures/en-us_image_0000001212218470.gif) diff --git a/en/application-dev/reference/arkui-ts/ts-container-column.md b/en/application-dev/reference/arkui-ts/ts-container-column.md index a1638e11f806aa2ee6291c034d6f96a3b10fac1a..e0e60472e1fe83911dc23e5a36d6ab444132a282 100644 --- a/en/application-dev/reference/arkui-ts/ts-container-column.md +++ b/en/application-dev/reference/arkui-ts/ts-container-column.md @@ -1,10 +1,11 @@ # Column -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** > This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -The **** component lays out child components vertically. +The **<Column>** component lays out child components vertically. ## Required Permissions @@ -14,7 +15,7 @@ None ## Child Components -Supported +This component can contain child components. ## APIs @@ -23,29 +24,29 @@ Column(value:{space?: Length}) - Parameters - | Name| Type| Mandatory| Default Value| Description| + | Name | Type | Mandatory | Default Value | Description | | -------- | -------- | -------- | -------- | -------- | - | space | Length | No| 0 | Space between two adjacent child components in the vertical layout.| + | space | Length | No | 0 | Space between any two adjacent child components in the vertical layout. | ## Attributes -| Name| Type| Default Value| Description| +| Name | Type | Default Value | Description | | -------- | -------- | -------- | -------- | -| alignItems | HorizontalAlign | HorizontalAlign.Center | Alignment mode of the child components in the horizontal direction.| -| justifyContent8+ | [FlexAlign](ts-container-flex.md) | FlexAlign.Start | Alignment mode of the child components in the vertical direction.| +| alignItems | HorizontalAlign | HorizontalAlign.Center | Alignment mode of child components in the horizontal direction. | +| justifyContent8+ | [FlexAlign](ts-container-flex.md) | FlexAlign.Start | Alignment mode of child components in the vertical direction. | - HorizontalAlign enums - | Name| Description| + | Name | Description | | -------- | -------- | - | Start | Aligned with the start edge in the same direction as the language in use.| - | Center | Center aligned. This is the default alignment mode.| - | End | Aligned with the end edge in the same direction as the language in use.| - + | Start | Aligned with the start edge in the same direction as the language in use. | + | Center | Center alignment. This is the default alignment mode. | + | End | Aligned with the end edge in the same direction as the language in use. | ## Example + ``` @Entry @Component @@ -75,7 +76,6 @@ struct ColumnExample { Column().width('30%').height(30).backgroundColor(0xAFEEEE) Column().width('30%').height(30).backgroundColor(0x00FFFF) }.height('15%').border({ width: 1 }).justifyContent(FlexAlign.Center) - Text('justifyContent(End)').fontSize(9).fontColor(0xCCCCCC).width('90%') Column() { Column().width('30%').height(30).backgroundColor(0xAFEEEE) @@ -86,4 +86,4 @@ struct ColumnExample { } ``` -![zh-cn_image_0000001219982721](figures/Column.png) +![](figures/column.png) diff --git a/en/application-dev/reference/arkui-ts/ts-container-columnsplit.md b/en/application-dev/reference/arkui-ts/ts-container-columnsplit.md index 362c327301ae8d94d92a47637bd08f841557e7ba..97e29299d78e965706d02225033a3c752e5b12e0 100644 --- a/en/application-dev/reference/arkui-ts/ts-container-columnsplit.md +++ b/en/application-dev/reference/arkui-ts/ts-container-columnsplit.md @@ -1,48 +1,41 @@ -# ColumnSplit +# ColumnSplit ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -The **** lays out child components vertically and inserts a horizontal divider between every two child components. +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** +> This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -## Required Permissions + +The **<ColumnSplit>** lays out child components vertically and inserts a horizontal divider between every two child components. + + +## Required Permissions None -## Child Components + +## Child Components This component can contain child components. -## APIs -ColumnSplit\(\) +## APIs -## Attributes +ColumnSplit() - - - - - - - - - - - -

Name

-

Type

-

Description

-

resizeable

-

boolean

-

Whether the divider can be dragged. The default value is false.

-
->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->Similar to ****, the divider of **** can be dragged to a position that just fully holds a component. +## Attributes -## Example + | Name | Type | Description | +| -------- | -------- | -------- | +| resizeable | boolean | Whether the divider can be dragged. The default value is **false**. | +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** +> Similar to **<RowSplit>**, the divider of **<ColumnSplit>** can be dragged to a position that just fully holds a component. + + +## Example + + ``` @Entry @Component @@ -64,5 +57,4 @@ struct ColumnSplitExample { } ``` -![](figures/columnsplit.gif) - +![en-us_image_0000001212378422](figures/en-us_image_0000001212378422.gif) diff --git a/en/application-dev/reference/arkui-ts/ts-container-counter.md b/en/application-dev/reference/arkui-ts/ts-container-counter.md index 5a4c49aa9a83320590730fe01d32949eb2eaa732..e9a959bdaf6ec41a969d743c55610a29bc608c34 100644 --- a/en/application-dev/reference/arkui-ts/ts-container-counter.md +++ b/en/application-dev/reference/arkui-ts/ts-container-counter.md @@ -1,47 +1,40 @@ -# Counter +# Counter ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -The **** component provides an operation to increase or decrease the number. +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** +> This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -## Required Permissions + +The **<Counter>** component provides an operation to increase or decrease the number. + + +## Required Permissions None -## Child Components + +## Child Components This component can contain child components. -## APIs -Counter\(\) +## APIs + +Counter() -## Events + +## Events Universal events and gestures are not supported. Only the events listed below are supported. - - - - - - - - - - - - -

Name

-

Description

-

onInc(event: () => void)

-

Event indicating that the number of monitored objects is increased.

-

onDec(event: () => void)

-

Event indicating that the number of monitored objects is decreased.

-
- -## Example + | Name | Description | +| -------- | -------- | +| onInc(event: () => void) | Event indicating that the number of monitored objects is increased. | +| onDec(event: () => void) | Event indicating that the number of monitored objects is decreased. | + + +## Example + ``` @Entry @@ -65,5 +58,4 @@ struct CounterExample { } ``` -![](figures/counter.gif) - +![en-us_image_0000001212378424](figures/en-us_image_0000001212378424.gif) diff --git a/en/application-dev/reference/arkui-ts/ts-container-flex.md b/en/application-dev/reference/arkui-ts/ts-container-flex.md index e548366843bb3bc04feac69c5050642858b0bc1b..f0392afc2f55f47066b91fd89bbb90a23519fee2 100644 --- a/en/application-dev/reference/arkui-ts/ts-container-flex.md +++ b/en/application-dev/reference/arkui-ts/ts-container-flex.md @@ -1,202 +1,66 @@ -# Flex +# Flex ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -The **** component allows for an elastic layout. +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** +> This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -## Required Permissions + +The **<Flex>** component allows for an elastic layout. + + +## Required Permissions None -## Child Components + +## Child Components This component can contain child components. -## APIs - -Flex\(options?: \{ direction?: FlexDirection, wrap?: FlexWrap, justifyContent?: FlexAlign, alignItems?: ItemAlign, alignContent?: FlexAlign \}\) - -Creates a standard **** component. - -- Parameters - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

direction

-

FlexDirection

-

No

-

Row

-

Direction in which child components are arranged in the <Flex> component, that is, the direction of the main axis.

-

wrap

-

FlexWrap

-

No

-

NoWrap

-

Whether the <Flex> component has a single line or multiple lines.

-

justifyContent

-

FlexAlign

-

No

-

Start

-

Alignment mode of the child components in the <Flex> component along the main axis.

-

alignItems

-

ItemAlign

-

No

-

Stretch

-

Alignment mode of the child components in the <Flex> component along the cross axis.

-

alignContent

-

FlexAlign

-

No

-

Start

-

Alignment mode of the child components in a multi-line <Flex> component along the cross axis. This parameter is valid only when wrap is set to Wrap or WrapReverse.

-
- -- FlexDirection enums - - - - - - - - - - - - - - - - - - - -

Name

-

Description

-

Row

-

The child components are arranged in the same direction as the main axis runs along the rows.

-

RowReverse

-

The child components are arranged opposite to the Row direction.

-

Column

-

The child components are arranged in the same direction as the main axis runs down the columns.

-

ColumnReverse

-

The child components are arranged opposite to the Column direction.

-
- - -- FlexWrap enums - - - - - - - - - - - - - - - - -

Name

-

Description

-

NoWrap

-

The child components in the <Flex> component are arranged in a single line, and they may overflow.

-

Wrap

-

The child components in the <Flex> component are arranged in multiple lines, and they may overflow.

-

WrapReverse

-

The child components in the <Flex> component are reversely arranged in multiple lines, and they may overflow.

-
- - -- FlexAlign enums - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Description

-

Start

-

The child components are aligned with the start edge of the main axis. The first component is aligned with the main-start, and subsequent components are aligned with the previous one.

-

Center

-

The child components are aligned in the center of the main axis. The space between the first component and the main-start is the same as that between the last component and the main-end.

-

End

-

The child components are aligned with the end edge of the main axis. The last component is aligned with the main-end, and other components are aligned with the next one.

-

SpaceBetween

-

The child components are evenly distributed along the main axis. The first component is aligned with the main-start, the last component is aligned with the main-end, and the remaining components are distributed so that the space between any two adjacent components is the same.

-

SpaceAround

-

The child components are evenly distributed along the main axis, with a half-size space on either end. The space between any two adjacent components is the same. The space between the first component and main-start, and that between the last component and cross-main are both half the size of the space between two adjacent components.

-

SpaceEvenly

-

The child components are equally distributed along the main axis. The space between the first component and main-start, the space between the last component and main-end, and the space between two adjacent components are the same.

-
- - -## Example + +## APIs + +Flex(options?: { direction?: FlexDirection, wrap?: FlexWrap, justifyContent?: FlexAlign, alignItems?: ItemAlign, alignContent?: FlexAlign }) + +Creates a standard **<Flex>** component. + +- Parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | direction | FlexDirection | No | FlexDirection.Row | Direction in which child components are arranged in the **<Flex>** component, that is, the direction of the main axis. | + | wrap | FlexWrap | No | FlexWrap.NoWrap | Whether the **<Flex>** component has a single line or multiple lines. | + | justifyContent | FlexAlign | No | FlexAlign.Start | Alignment mode of the child components in the **<Flex>** component along the main axis. | + | alignItems | [ItemAlign](ts-appendix-enums.md#itemalign-enums) | No | ItemAlign.Stretch | Alignment mode of the child components in the **<Flex>** component along the cross axis. | + | alignContent | FlexAlign | No | FlexAlign.Start | Alignment mode of the child components in a multi-line **<Flex>** component along the cross axis. This parameter is valid only when **wrap** is set to **Wrap** or **WrapReverse**. | + +- FlexDirection enums + | Name | Description | + | -------- | -------- | + | Row | The child components are arranged in the same direction as the main axis runs along the rows. | + | RowReverse | The child components are arranged opposite to the **Row** direction. | + | Column | The child components are arranged in the same direction as the main axis runs down the columns. | + | ColumnReverse | The child components are arranged opposite to the **Column** direction. | + +- FlexWrap enums + | Name | Description | + | -------- | -------- | + | NoWrap | The child components in the **<Flex>** component are arranged in a single line, and they may overflow. | + | Wrap | The child components in the **<Flex>** component are arranged in multiple lines, and they may overflow. | + | WrapReverse | The child components in the **<Flex>** component are reversely arranged in multiple lines, and they may overflow. | + +- FlexAlign enums + | Name | Description | + | -------- | -------- | + | Start | The child components are aligned with the start edge of the main axis. The first component is aligned with the main-start, and subsequent components are aligned with the previous one. | + | Center | The child components are aligned in the center of the main axis. The space between the first component and the main-start is the same as that between the last component and the main-end. | + | End | The child components are aligned with the end edge of the main axis. The last component is aligned with the main-end, and other components are aligned with the next one. | + | SpaceBetween | The child components are evenly distributed along the main axis. The first component is aligned with the main-start, the last component is aligned with the main-end, and the remaining components are distributed so that the space between any two adjacent components is the same. | + | SpaceAround | The child components are evenly distributed along the main axis, with a half-size space on either end. The space between any two adjacent components is the same. The space between the first component and main-start, and that between the last component and cross-main are both half the size of the space between two adjacent components. | + | SpaceEvenly | The child components are equally distributed along the main axis. The space between the first component and main-start, the space between the last component and main-end, and the space between two adjacent components are the same. | + + +## Example + ``` // Example 01 @@ -259,7 +123,8 @@ struct FlexExample1 { } ``` -![](figures/flex01.gif) +![en-us_image_0000001256978365](figures/en-us_image_0000001256978365.gif) + ``` // Example 02 @@ -305,7 +170,8 @@ struct FlexExample2 { } ``` -![](figures/flex02.png) +![en-us_image_0000001211898500](figures/en-us_image_0000001211898500.png) + ``` // Example 03 @@ -354,7 +220,8 @@ struct FlexExample3 { } ``` -![](figures/flex03.gif) +![en-us_image_0000001212218462](figures/en-us_image_0000001212218462.gif) + ``` // Example 04 @@ -403,9 +270,10 @@ struct FlexExample4 { } ``` -![](figures/flex04.jpg) +![en-us_image_0000001257138371](figures/en-us_image_0000001257138371.jpg) + +![en-us_image_0000001212378426](figures/en-us_image_0000001212378426.gif) -![](figures/flex04-2.gif) ``` // Example 05 @@ -454,5 +322,4 @@ struct FlexExample5 { } ``` -![](figures/flex05.gif) - +![en-us_image_0000001256858413](figures/en-us_image_0000001256858413.gif) diff --git a/en/application-dev/reference/arkui-ts/ts-container-grid.md b/en/application-dev/reference/arkui-ts/ts-container-grid.md index 6d142f9eec1c3bb7a631f05611e7f82806129f3a..9dcde4d28f857984dcea9bc7a37d22948df9ab87 100644 --- a/en/application-dev/reference/arkui-ts/ts-container-grid.md +++ b/en/application-dev/reference/arkui-ts/ts-container-grid.md @@ -1,92 +1,60 @@ -# Grid +# Grid ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -The **** component is a two-dimensional layout. The component is divided into rows and columns, to form cells. You can specify the cell where an item is located and combine different grids to form various layouts. +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** +> This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -## Required Permissions + +The **<Grid>** component is a two-dimensional layout. The component is divided into rows and columns, to form cells. You can specify the cell where an item is located and combine different grids to form various layouts. + + +## Required Permissions None -## Child Components - -This component contains the child component [](ts-container-griditem.md). - -## APIs - -Grid\(\) - -## Attributes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Default Value

-

Description

-

columnsTemplate

-

string

-

'1fr'

-

Number of columns in the current grid layout. If this parameter is not set, one column is used by default. For example, '1fr 1fr 2fr' divides the component into three columns, with four equal parts. The first column occupies one part, the second column occupies one part, and the third column occupies two parts.

-

rowsTemplate

-

string

-

'1fr'

-

Number of rows in the current grid layout. If this parameter is not set, one row is used by default. For example, '1fr 1fr 2fr' divides the component into three rows. The width allowed by the parent component is divided into four equal parts. The first row occupies one part, the second row occupies one part, and the third row occupies two parts.

-

columnsGap

-

Length

-

0

-

Spacing between columns.

-

rowsGap

-

Length

-

0

-

Spacing between rows.

-
- -## Events - - - - - - - - - - -

Name

-

Description

-

onScrollIndex(first: number) => void

-

Triggered when the start item of the grid changes.

-
- -## Example + +## Child Components + +This component contains the child component [](ts-container-griditem.md). + + +## APIs + +Grid() + + +## Attributes + +| Name | Type | Default Value | Description | +| -------- | -------- | -------- | -------- | +| columnsTemplate | string | '1fr' | Number of columns in the current grid layout. If this parameter is not set, one column is used by default. For example, '1fr 1fr 2fr' divides the component into three columns, with four equal parts. The first column occupies one part, the second column occupies one part, and the third column occupies two parts. | +| rowsTemplate | string | '1fr' | Number of rows in the current grid layout. If this parameter is not set, one row is used by default. For example, '1fr 1fr 2fr' divides the component into three rows. The width allowed by the parent component is divided into four equal parts. The first row occupies one part, the second row occupies one part, and the third row occupies two parts. | +| columnsGap | Length | 0 | Spacing between columns. | +| rowsGap | Length | 0 | Spacing between rows. | +| editMode8+ | boolean | false | Whether to enter editing mode. In editing mode, you can drag the **<[GridItem](ts-container-griditem.md)>** in the **<Gird>** component. | +| layoutDirection8+ | [LayoutDirection](ts-appendix-enums.md#layoutdirection-enums) | LayoutDirection.Row | Main axis direction of the layout. The options are as follows:- **LayoutDirection.Row**: Horizontal layout, where the child components are arranged in the same direction as the main axis runs along the rows.- **LayoutDirection.Column**: Vertical layout, where the child components are arranged in the same direction as the main axis runs down the columns. | +| maxCount8+ | number | 1 | Maximum number of rows that can be displayed. | +| minCount8+ | number | 1 | Minimum number of rows that can be displayed. | +| cellLength8+ | number | 0 | Fixed height per row. | +| multiSelectable8+ | boolean | false | Whether to enable mouse frame selection.
- **false**: The mouse frame selection is disabled.
- **true**: The mouse frame selection is disabled. | +| edgeEffection8+ | EdgeEffect | EdgeEffect.Spring | Edge effect. For details, see **EdgeEffect**. | + +- EdgeEffect enums + + | Name | Description | + | ------ | ------------------------------------------------------------ | + | Spring | Similar to the physical dynamic effect of a spring. After scrolling to the edge, you can continue to scroll for a distance based on the initial speed or by touching the knob of the scrollbar. After you release your hand, the knob is rebounded. | + | None | No effect after the scrollbar is moved to the edge. | + +## Events + + | Name | Description | +| -------- | -------- | +| onScrollIndex(first: number) => void | Triggered when the start item of the grid changes. | + + +## Example + ``` @Entry @@ -147,5 +115,5 @@ struct GridExample { } ``` -![](figures/grid-3.gif) +![en-us_image_0000001212218434](figures/en-us_image_0000001212218434.gif) diff --git a/en/application-dev/reference/arkui-ts/ts-container-gridcontainer.md b/en/application-dev/reference/arkui-ts/ts-container-gridcontainer.md index 034b5719ead7182bf945a2640366583a458e4755..5db6c9fc044571a2e9bd6ac1cb013111d0bd11cb 100644 --- a/en/application-dev/reference/arkui-ts/ts-container-gridcontainer.md +++ b/en/application-dev/reference/arkui-ts/ts-container-gridcontainer.md @@ -1,131 +1,57 @@ -# GridContainer +# GridContainer ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -The **** component lays out components vertically. It is used only in the grid layout. +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** +> This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -## Required Permissions + +The **<GridContainer>** component lays out components vertically. It is used only in the grid layout. + + +## Required Permissions None -## Child Components + +## Child Components This component can contain child components. -## APIs - -GridContainer\(options?: \{ columns?: number | 'auto', sizeType?: SizeType, gutter?: Length, margin?: Length\}\) - -- Parameter - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

columns

-

number

-

No

-

'auto'

-

Total number of columns in the current layout.

-

sizeType

-

SizeType

-

No

-

Auto

-

Device size type.

-

gutter

-

Length

-

No

-

-

-

Gutter of the grid layout.

-

margin

-

Length

-

No

-

-

-

Margin of the grid layout.

-
- -- SizeType enums - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Description

-

XS

-

Device of the minimum size.

-

SM

-

Small-sized device.

-

MD

-

Medium-sized device.

-

LG

-

Large-sized device.

-

Auto

-

Auto. The size type is selected based on the device type.

-
- - -## Attributes - -Universal attributes and [attributes](ts-container-column.md#section358284262918) of the **** component are supported. - -## Events + +## APIs + +GridContainer(options?: { columns?: number | 'auto', sizeType?: SizeType, gutter?: Length, margin?: Length}) + +- Parameter + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | columns | number \| 'auto' | No | 'auto' | Total number of columns in the current layout. | + | sizeType | SizeType | No | SizeType.Auto | Device size type. | + | gutter | Length | No | - | Gutter of the grid layout. | + | margin | Length | No | - | Margin of the grid layout. | + +- SizeType enums + | Name | Description | + | -------- | -------- | + | XS | Device of the minimum size. | + | SM | Small-sized device. | + | MD | Medium-sized device. | + | LG | Large-sized device. | + | Auto | Auto. The size type is selected based on the device type. | + + +## Attributes + +Universal attributes and [attributes](ts-container-column.md#attributes) of the **<Column>** component are supported. + + +## Events Universal events are supported. -## Example + +## Example + ``` @Entry @@ -196,5 +122,4 @@ struct GridContainerExample { } ``` -![](figures/grid.gif) - +![en-us_image_0000001256858425](figures/en-us_image_0000001256858425.gif) diff --git a/en/application-dev/reference/arkui-ts/ts-container-griditem.md b/en/application-dev/reference/arkui-ts/ts-container-griditem.md index a839e1cb6b9b0be44c627a26b873745b20d3c9b2..e035bee25bf7b1f93205c1efa4d5b5c6c9f3364f 100644 --- a/en/application-dev/reference/arkui-ts/ts-container-griditem.md +++ b/en/application-dev/reference/arkui-ts/ts-container-griditem.md @@ -1,85 +1,50 @@ -# GridItem +# GridItem ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -The **** component provides a single item in a grid. +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** +> This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -## Required Permissions + +The **<GridItem>** component provides a single item in a grid. + + +## Required Permissions None -## Child Component + +## Child Component This component can contain child components. -## APIs - -GridItem\(\) - -## Attributes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Default Value

-

Description

-

rowStart

-

number

-

-

-

Start row number of the component.

-

rowEnd

-

number

-

-

-

End row number of the component.

-

columnStart

-

number

-

-

-

Start column number of the component.

-

columnEnd

-

number

-

-

-

End column number of the component.

-

forceRebuild

-

boolean

-

false

-

Whether to re-create this node when the component is being built.

-
- -## Example +## APIs + +GridItem() + + +## Attributes + + | Name | Type | Default Value | Description | +| -------- | -------- | -------- | -------- | +| rowStart | number | - | Start row number of the component. | +| rowEnd | number | - | End row number of the component. | +| columnStart | number | - | Start column number of the component. | +| columnEnd | number | - | End column number of the component. | +| forceRebuild | boolean | false | Whether to re-create this node when the component is being built. | +| selectable8+ | boolean | true | Whether the current **<GridItem>** is selectable by the mouse.
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:**
> This attribute takes effect only when mouse frame selection is enabled for the parent **<Grid>** container. | + + +## Events + + | Name | Description | +| -------- | -------- | +| onSelect(callback: (isSelected: boolean) => any)8+ | Triggered when the selected state of the **<GridItem>** changes.
**isSelected**: Returns **true** if the **<GridItem>** is selected by the mouse; returns **false** otherwise. | + + +## Example + + ``` @Entry @Component @@ -117,5 +82,4 @@ struct GridItemExample { } ``` -![](figures/griditem.gif) - +![en-us_image_0000001256858433](figures/en-us_image_0000001256858433.gif) diff --git a/en/application-dev/reference/arkui-ts/ts-container-list.md b/en/application-dev/reference/arkui-ts/ts-container-list.md index fffebb7e5072c2bbce95200fb5091f265b874e80..afd97f25485b0924c910d6c8387cd564e436a0b3 100644 --- a/en/application-dev/reference/arkui-ts/ts-container-list.md +++ b/en/application-dev/reference/arkui-ts/ts-container-list.md @@ -1,262 +1,78 @@ -# List +# List ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -The **** component provides a list container that presents a series of list items arranged in a column with the same width. It supports presentations of the same type of data in a multiple and coherent row style, for example, images or text. +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** +> This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -## Required Permissions -None +The **<List>** component provides a list container that presents a series of list items arranged in a column with the same width. It supports presentations of the same type of data in a multiple and coherent row style, for example, images or text. + -## Child Components +## Required Permissions -This component contains the child component [](ts-container-listitem.md). +None -## APIs -List\(value:\{space?: number, initialIndex?: number\}\) +## Child Components -- Parameters +This component contains the child component [](../reference/arkui-ts/ts-container-listitem.md). - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

space

-

number

-

No

-

0

-

Spacing between list items.

-

initialIndex

-

number

-

No

-

0

-

Item displayed at the beginning of the component when the current list is loaded for the first time, that is, the first item to be displayed. If the configured sequence number is greater than the sequence number of the last item, the setting does not take effect.

-
+## APIs -## Attributes +List(value:{space?: number, initialIndex?: number}) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Default Value

-

Description

-

listDirection

-

Axis

-

Vertical

-

Direction in which the list items are arranged. For details, see Axis enums.

-

divider

-

{

-

strokeWidth: Length,

-

color?:Color,

-

startMargin?: Length,

-

endMargin?: Length

-

}

-

-

-

Style of the divider for the list items. By default, there is no divider.

-

strokeWidth: stroke width of the divider.

-

color: color of the divider.

-

startMargin: distance between the divider and the start of the list.

-

endMargin: distance between the divider and the end of the list.

-

editMode

-

boolean

-

false

-

Whether the <List> component is in editable mode.

-

edgeEffect

-

EdgeEffect

-

Spring

-

Sliding effect. For details, see EdgeEffect enums.

-

chainAnimation

-

boolean

-

false

-

Whether to display chained animations on this list when it slides or its top and bottom are dragged. The list items are separated with even space, and one item animation starts after the previous animation during basic sliding interactions. The chained animation effect is similar with spring physics.

-
  • false: No chained animations are displayed.
  • true: Chained animations are displayed.
-
+- Parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | space | number | No | 0 | Spacing between list items. | + | initialIndex | number | No | 0 | Item displayed at the beginning of the component when the current list is loaded for the first time, that is, the first item to be displayed. If the configured sequence number is greater than the sequence number of the last item, the setting does not take effect. | -- EdgeEffect enums - - - - - - - - - - - - -

Name

-

Description

-

Spring

-

Similar to the physical dynamic effect of a spring. After scrolling to the edge, you can continue to scroll for a distance based on the initial speed or by touching the knob of the scrollbar. After you release your hand, the knob is rebounded.

-

None

-

No effect after the scroll bar is moved to the edge.

-
+## Attributes +| Name | Type | Default Value | Description | +| -------- | -------- | -------- | -------- | +| listDirection | [Axis](ts-appendix-enums.md#axis-enums) | Vertical | Direction in which the list items are arranged. For details, see **Axis** enums. | +| divider | {
strokeWidth: Length,
color?:Color,
startMargin?: Length,
endMargin?: Length
} | - | Style of the divider for the list items. By default, there is no divider.
**strokeWidth**: stroke width of the divider.
**color**: color of the divider.
**startMargin**: distance between the divider and the start of the list.
**endMargin**: distance between the divider and the end of the list. | +| editMode | boolean | false | Whether the **<List>** component is in editable mode. | +| edgeEffect | EdgeEffect | EdgeEffect.Spring | Sliding effect. For details, see EdgeEffect enums. | +| chainAnimation | boolean | false | Whether to display chained animations on this list when it slides or its top and bottom are dragged. The list items are separated with even space, and one item animation starts after the previous animation during basic sliding interactions. The chained animation effect is similar with spring physics.
- **false**: No chained animations are displayed.
- **true**: Chained animations are displayed. | +| multiSelectable8+ | boolean | false | Whether to enable mouse frame selection.
- **false**: The mouse frame selection is disabled.
- **true**: The mouse frame selection is disabled. | +| restoreId8+ | number | - | Migration ID of the component. During application migration, the status of the component is migrated to the component with the same migration ID on the peer end.
For a **<List>** component, the status includes the item serial number displayed at the start position. | -## Events +- EdgeEffect enums + | Name | Description | + | -------- | -------- | + | Spring | Similar to the physical dynamic effect of a spring. After scrolling to the edge, you can continue to scroll for a distance based on the initial speed or by touching the knob of the scrollbar. After you release your hand, the knob is rebounded. | + | None | No effect after the scroll bar is moved to the edge. | - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Description

-

onItemDelete(index: number) => boolean

-

Triggered when a list item is deleted.

-

onScrollIndex(firstIndex: number, lastIndex: number) => void

-

Triggered when the start position and end position of the current list are changed.

-

onItemDragEnter(callback: (event: ItemDragInfo) => void)

-

Triggered when the list item that is bound to the drag event enters a valid drop target.

-
  • itemIndex: original index of the list item that is being dragged.
  • insertIndex: index of the list item after it is dragged and inserted into the list.
-
NOTE:

This event is valid only when the onDrop event is listened to.

-
-

onItemDragMove(callback: (event: ItemDragInfo, itemIndex: number, insertIndex: number) => void)

-

-

Triggered when the list item that is bound to the drag event enters a valid drop target.

-
  • itemIndex: original index of the list item that is being dragged.
  • insertIndex: index of the list item after it is dragged and inserted into the list.
-
NOTE:

This event is valid only when the onDrop event is listened to.

-
-

onItemDragLeave(callback: (event: ItemDragInfo, itemIndex: number) => void)

-

-

Triggered when the list item that is bound to the drag event leaves a valid drop target.

-
  • itemIndex: original index of the list item that is being dragged.
-
NOTE:

This event is valid only when the onDrop event is listened to.

-
-

onItemDragStart(callback: (event: ItemDragInfo, itemIndex: number) => CustomBuilder)

-

-

Triggered when the list item that is bound to the drag event is dragged for the first time.

-
  • itemIndex: original index of the list item that is being dragged.
  • Return value: floating UI layout of the list item that is being dragged.
-
NOTE:

This event is valid only when the onDrop event is listened to.

-
-

onItemDrop(callback: (event: ItemDragInfo, itemIndex: number, insertIndex: number, isSuccess: boolean) => void)

-

-

Triggered when the list item that is bound to the drag event is dropped on a valid drop target.

-
  • itemIndex: original index of the list item that is being dragged.
  • insertIndex: index of the list item after it is dragged and inserted into the list.
  • isSuccess: whether the insertion is successful after the list item is dropped.
-
NOTE:

This event is valid only when the onDrop event is listened to.

-
-
->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->To enable the editable mode for a list, the following conditions must be met: ->- **editMode** is set to **true**. ->- The list is bound to the **onItemDelete** event and the event returns **true** during event callback. ->- The **editable** attribute of **ListItem** is set to **true**. ->To enable for a list item, the following conditions must be met: ->- **editMode** is set to **true**. ->- The list item is bound to the **onItemDragStart** event and the event returns a floating UI during event callback. +## Events -- ItemDragInfo attributes + | Name | Description | +| -------- | -------- | +| onItemDelete(index: number) => boolean | Triggered when a list item is deleted. | +| onScrollIndex(firstIndex: number, lastIndex: number) => void | Triggered when the start position and end position of the current list are changed. | - - - - - - - - - - - - - - - -

Name

-

Type

-

Description

-

x

-

number

-

X-coordinate of the item that is being dragged.

-

y

-

number

-

Y-coordinate of the item that is being dragged.

-
+> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** +> To enable the editable mode for a list, the following conditions must be met: +> +> - **editMode** is set to **true**. +> +> - The list is bound to the **onItemDelete** event and the event returns **true** during event callback. +> +> - The **editable** attribute of **ListItem** is set to **true**. +> +> To enable dragging for a list item, the following conditions must be met: +> +> - **editMode** is set to **true**. +> +> - The list item is bound to the **onDragStart** event and the event returns a floating UI during event callback. -## Example +## Example + ``` @Entry @@ -277,7 +93,7 @@ struct ListExample { }.editable(true) }, item => item) } - .listDirection(Axis.Vertical) //Arrangement direction + .listDirection(Axis.Vertical) // Arrangement direction .divider({ strokeWidth: 2, color: 0xFFFFFF, startMargin: 20, endMargin: 20 }) // Divider line .edgeEffect(EdgeEffect.None) // No effect when sliding to the edge .chainAnimation(false) // Chained animations are disabled. @@ -304,123 +120,4 @@ struct ListExample { } ``` -![](figures/list.gif) - -``` -@Entry -@Component -struct DragListExample { - @State number1: string[] = ['0', '1', '2'] - @State number2: string[] = ['one', 'two', 'three'] - @State text: string = '' - @State bool1: boolean = false - @State bool2: boolean = false - - @Builder pixelMapBuilder() { - Text('-1') - .width('100%').height(100).fontSize(16) - .textAlign(TextAlign.Center).borderRadius(10).backgroundColor(0xFFFFFF) - } - - build() { - Column() { - List() { - ForEach(this.number1, (item) => { - ListItem() { - Text('' + item) - .width('100%').height(100).fontSize(16) - .textAlign(TextAlign.Center).borderRadius(10).backgroundColor(0xF666FF) - } - }, item => item) - } - .editMode(true) - .width('90%').divider({ strokeWidth: 2, color: 0xFFFFFF, startMargin: 20, endMargin: 20 }) - .onItemDelete((index: number) => { - console.info(this.Number1[index] + 'Delete') - this.Number1.splice(index, 1) - console.info(JSON.stringify(this.Number1)) - return true - }) - .onItemDragStart((event: ItemDragInfo, itemIndex: number) => { - this.bool1 = true - this.text = this.number1[itemIndex] - console.log("List1 onItemDragStart, itemIndex:" + itemIndex + ", ItemDragInfo:"+`${JSON.stringify(event)}`) - return this.pixelMapBuilder - }) - .onItemDragEnter((event: ItemDragInfo) => { - console.log("List1 onItemDragEnter") - }) - .onItemDragMove((event: ItemDragInfo, itemIndex: number, insertIndex: number) => { - console.log("List1 onItemDragMove, itemIndex:" + itemIndex + ", insertIndex:" + insertIndex) - }) - .onItemDragLeave((event: ItemDragInfo, itemIndex: number) => { - console.log("List1 onItemDragLeave, itemIndex:" + itemIndex) - }) - .onItemDrop((event: ItemDragInfo, itemIndex: number, insertIndex: number, isSuccess: boolean) => { - if (isSuccess) { - if (this.bool2) { - this.number2.splice(itemIndex, 1) - this.number1.splice(insertIndex, 0, this.text) - this.bool1 = false - this.bool2 = false - } else if (this.bool1) { - this.number1.splice(itemIndex, 1) - this.number1.splice(insertIndex, 0, this.text) - this.bool1 = false - this.bool2 = false - } - } - console.log("List1 onItemDrop, itemIndex:" + itemIndex + ", insertIndex:" + insertIndex + ", isSuccess:" + isSuccess) - }) - Divider().strokeWidth(5).color(0x2788D9).lineCap(LineCapStyle.Round).margin(20) - List() { - ForEach(this.Number2, (item) => { - ListItem() { - Text('' + item) - .width('100%').height(100).fontSize(16) - .textAlign(TextAlign.Center).borderRadius(10).backgroundColor(0xFFF888) - } - }, item => item) - } - .edgeEffect(EdgeEffect.None) - .width('90%') - .editMode(true) - .divider({ strokeWidth: 2, color: 0xFFFFFF, startMargin: 20, endMargin: 20 }) - .onItemDragStart((event: ItemDragInfo, itemIndex: number) => { - this.bool2 = true - this.text = this.number2[itemIndex] - console.log("List2 onItemDragStart, itemIndex:" + itemIndex) - return this.pixelMapBuilder - }) - .onItemDragEnter((event: ItemDragInfo) => { - console.log("List2 onItemDragEnter") - }) - .onItemDragMove((event: ItemDragInfo, itemIndex: number, insertIndex: number) => { - console.log("List2 onItemDragMove, itemIndex:" + itemIndex + ", insertIndex:" + insertIndex) - }) - .onItemDragLeave((event: ItemDragInfo, itemIndex: number) => { - console.log("List2 onItemDragLeave, itemIndex:" + itemIndex) - }) - .onItemDrop((event: ItemDragInfo, itemIndex: number, insertIndex: number, isSuccess: boolean) => { - if (isSuccess) { - if (this.bool1) { - this.number1.splice(itemIndex, 1) - this.number2.splice(insertIndex, 0, this.text) - this.bool1 = false - this.bool2 = false - } else if (this.bool2) { - this.number2.splice(itemIndex, 1) - this.number2.splice(insertIndex, 0, this.text) - this.bool1 = false - this.bool2 = false - } - } - console.log("List2 onItemDrop, itemIndex:" + itemIndex + ", insertIndex:" + insertIndex + ", isSuccess:" + isSuccess) - }) - }.width('100%').height('100%').backgroundColor(0xE600000).padding({ top: 25 }) - } -} -``` - -![](figures/gif-4.gif) - +![en-us_image_0000001256978357](figures/en-us_image_0000001256978357.gif) diff --git a/en/application-dev/reference/arkui-ts/ts-container-listitem.md b/en/application-dev/reference/arkui-ts/ts-container-listitem.md index e96b60c18f19ce2fb07cde2b64d1790fcb350c1b..0d25e6da92d97adc98d06916695f585d668673d2 100644 --- a/en/application-dev/reference/arkui-ts/ts-container-listitem.md +++ b/en/application-dev/reference/arkui-ts/ts-container-listitem.md @@ -1,80 +1,52 @@ -# ListItem +# ListItem ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -The **** component displays specific items in the list. Its width occupies the **** component by default and must be used together with ****. +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** +> This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -## Required Permissions + +The **<ListItem>** component displays specific items in the list. Its width occupies the **<List>** component by default and must be used together with **<List>**. + + +## Required Permissions None -## Child Components + +## Child Components This component can contain a single child component. -## APIs - -ListItem\(\) - -## Attributes - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Default Value

-

Description

-

sticky

-

Sticky

-

None

-

Sticky effect of the list item. For details, see Sticky enums.

-

editable

-

boolean

-

false

-

Whether the list item is editable. A list item can be deleted in editing mode.

-
- -- Sticky enums - - - - - - - - - - - - - -

Name

-

Description

-

None

-

No sticky.

-

Normal

-

The list item is sticky and disappears when you slide it.

-
- - -## Example + +## APIs + +ListItem() + + +## Attributes + +| Name | Type | Default Value | Description | +| -------- | -------- | -------- | -------- | +| sticky | Sticky | Sticky.None | Sticky effect of the list item. For details, see Sticky enums. | +| editable | boolean | false | Whether the list item is editable. A list item can be deleted in editing mode. | +| selectable8+ | boolean | true | Whether the current **<ListItem>** is selectable by the mouse.
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:**
> This attribute takes effect only when mouse frame selection is enabled for the parent **<List>** container. | + +- Sticky enums + | Name | Description | + | -------- | -------- | + | None | No sticky. | + | Normal | The list item is sticky. | + + +## Events + + | Name | Description | +| -------- | -------- | +| onSelect(callback: (isSelected: boolean) => any)8+ | Triggered when the selected state of the **<ListItem>** changes.
**isSelected**: Returns **true** if the **<ListItem>** is selected by the mouse; returns **false** otherwise. | + + +## Example + ``` @Entry @@ -115,5 +87,4 @@ struct ListItemExample { } ``` -![](figures/listitem.gif) - +![en-us_image_0000001257138339](figures/en-us_image_0000001257138339.gif) diff --git a/en/application-dev/reference/arkui-ts/ts-container-navigation.md b/en/application-dev/reference/arkui-ts/ts-container-navigation.md deleted file mode 100644 index d0b68b8fbfae41d3c239ea93237214a192b4ae1a..0000000000000000000000000000000000000000 --- a/en/application-dev/reference/arkui-ts/ts-container-navigation.md +++ /dev/null @@ -1,418 +0,0 @@ -# Navigation - ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->This component is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version. - -The **** component typically functions as the root container of a page and displays the page title, toolbar, and menu through attribute settings. - -## Required Permissions - -None - -## Child Components - -This component can contain child components. - -## APIs - -Navigation\(\) - -Creates a component that can automatically display the navigation bar, title, and toolbar based on the attribute settings. - -## Attributes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Default Value

-

Description

-

title

-

string | CustomBuilder

-

-

-

No title

-

subtitle

-

string

-

-

-

Subtitle of the page.

-

menus

-

Array<NavigationMenuItem> | CustomBuilder

-

-

-

Menu in the upper right corner of the page.

-

-

titleMode

-

NavigationTitleMode

-

NavigationTitleMode.Free

-

Display mode of the page title bar.

-

toolBar

-

{

-

items:[

-

Object

-

] }

-

| CustomBuilder

-

-

-

-

Content of the toolbar.

-

items: all items on the toolbar.

-

hideToolBar

-

boolean

-

false

-

Whether the toolbar is shown or hidden.

-

true: The toolbar is hidden.

-

false: The toolbar is shown.

-

hideTitleBar

-

boolean

-

false

-

Whether the title bar is hidden.

-

hideBackButton

-

boolean

-

false

-

Whether the back key is hidden.

-
- -- NavigationMenuItem parameters - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

value

-

string

-

Yes

-

-

-

Text of a single option on the menu bar.

-

icon

-

string

-

No

-

-

-

Icon path of a single option on the menu bar.

-

action

-

() => void

-

No

-

-

-

Callback invoked when the option is selected.

-
- - -- Object attributes - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

value

-

string

-

Yes

-

-

-

Text of a single option on the toolbar.

-

icon

-

string

-

No

-

-

-

Icon path of a single option on the toolbar.

-

action

-

() => void

-

No

-

-

-

Callback invoked when the option is selected.

-
- -- NavigationTitleMode enums - - - - - - - - - - - - - - - - -

Name

-

Description

-

Free

-

When the content is a scrollable component, the title shrinks as the content scrolls up (the subtitle fades out with its size remaining unchanged) and restores to the original one as the content scrolls down.

-

Mini

-

The mode is fixed at subtitle mode (icon + main title and subtitle).

-

Full

-

The mode is fixed at main title mode (main title and subtitle).

-
- - >![](../../public_sys-resources/icon-note.gif) **NOTE:** - >Currently, only the scrollable component **** is supported. - - -## Events - - - - - - - - - - -

Name

-

Description

-

onTitleModeChanged(callback: (titleMode: NavigationTitleMode) => void)

-

Triggered when titleMode is set to NavigationTitleMode.Free and the title bar mode changes as content scrolls.

-
- -## Example - -``` -/ Example 01 -@Entry -@Component -struct NavigationExample { - private arr: number[] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] - @State hideBar: boolean = true - - @Builder NavigationTitle() { - Column() { - Text('title') - .width(80) - .height(60) - .fontColor(Color.Blue) - .fontSize(30) - } - .onClick(() => { - console.log("title") - }) - } - - @Builder NavigationMenus() { - Row() { - Image('images/add.png') - .width(25) - .height(25) - Image('comment/more.png') - .width(25) - .height(25) - .margin({ left: 30 }) - }.width(100) - } - - build() { - Column() { - Navigation() { - Search({ value: '', placeholder: "" }).width('85%').margin(26) - List({ space: 5, initialIndex: 0 }) { - ForEach(this.arr, (item) => { - ListItem() { - Text('' + item) - .width('90%') - .height(80) - .backgroundColor('#3366CC') - .borderRadius(15) - .fontSize(16) - .textAlign(TextAlign.Center) - }.editable(true) - }, item => item) - } - .listDirection(Axis.Vertical) - .height(300) - .margin({ top: 10, left: 18 }) - .width('100%') - - Button(this.hideBar ? "tool bar" : "hide bar") - .onClick(() => { - this.hideBar = !this.hideBar - }) - .margin({ left: 135, top: 60 }) - } - .title(this.NavigationTitle) - .subTitle('subtitle') - .menus(this.NavigationMenus) - .titleMode(NavigationTitleMode.Free) - .hideTitleBar(false) - .hideBackButton(false) - .onTitleModeChanged((titleModel: NavigationTitleMode) => { - console.log('titleMode') - }) - .toolBar({ items: [ - { value: 'app', icon: 'images/grid.svg', action: () => { - console.log("app") - } }, - { value: 'add', icon: 'images/add.svg', action: () => { - console.log("add") - } }, - { value: 'collect', icon: 'images/collect.svg', action: () => { - console.log("collect") - } }] }) - .hideToolBar(this.hideBar) - } - } -} -``` - -![](figures/66666.gif) - -``` -// Example 02 -@Entry -@Component -struct ToolbarBuilderExample { - @State currentIndex: number = 0 - @State Build: Array = [ - { - icon: $r('app.media.ic_public_add'), - icon_after: $r('app.media.ic_public_addcolor'), - text: 'add', - num: 0 - }, - { - icon: $r('app.media.ic_public_app'), - icon_after: $r('app.media.ic_public_appcolor'), - text: 'app', - num: 1 - }, - { - icon: $r('app.media.ic_public_collect'), - icon_after: $r('app.media.ic_public_collectcolor'), - text: 'collect', - num: 2 - } - ] - - @Builder NavigationToolbar() { - Row() { - ForEach(this.Build, item => { - Column() { - Image(this.currentIndex == item.num ? item.icon_after : item.icon) - .width(25) - .height(25) - Text(item.text) - .fontColor(this.currentIndex == item.num ? "#ff7500" : "#000000") - } - .onClick(() => { - this.currentIndex = item.num - }) - .margin({ left: 70 }) - }) - } - } - - build() { - Column() { - Navigation() { - Flex() { - } - } - .toolBar(this.NavigationToolbar) - } - } -} -``` - -![](figures/duande.gif) - diff --git a/en/application-dev/reference/arkui-ts/ts-container-navigator.md b/en/application-dev/reference/arkui-ts/ts-container-navigator.md index a07cec59e74a380fa348d3236dd7954bf97c7c3b..ef7f0b331086ed9506fa083ae76ba32e5c5c89b5 100644 --- a/en/application-dev/reference/arkui-ts/ts-container-navigator.md +++ b/en/application-dev/reference/arkui-ts/ts-container-navigator.md @@ -1,128 +1,54 @@ -# Navigator +# Navigator ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -The **** component provides redirection. +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** +> This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -## Required Permissions + +The **<Navigator>** component provides redirection. + + +## Required Permissions None -## Child Components + +## Child Components This component can contain child components. -## APIs -Navigator\(value?: \{target: string, type?: NavigationType\}\) +## APIs + +Navigator(value?: {target: string, type?: NavigationType}) Creates a navigator. -- Parameters - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

target

-

string

-

Yes

-

-

-

Path of the target page to be redirected to.

-

type

-

NavigationType

-

No

-

Push

-

Navigation type.

-
- -- NavigationType enums - - - - - - - - - - - - - - - - -

Name

-

Description

-

Push

-

Navigates to a specified page in the application.

-

Replace

-

Replaces the current page with another one in the application and destroys the current page.

-

Back

-

Returns to the previous page or a specified page.

-
- - -## Attributes - - - - - - - - - - - - - - - - - - - -

Name

-

Parameters

-

Default Value

-

Description

-

active

-

boolean

-

-

-

Whether the <Navigator> component is activated. If the component is activated, the corresponding navigation takes effect.

-

params

-

Object

-

undefined

-

Data that needs to be passed to the target page during redirection. You can use router.getParams() to obtain the data on the target page.

-
- -## Example +- Parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | target | string | Yes | - | Path of the target page to be redirected to. | + | type | NavigationType | No | NavigationType.Push | Navigation type. | + +- NavigationType enums + | Name | Description | + | -------- | -------- | + | Push | Navigates to a specified page in the application. | + | Replace | Replaces the current page with another one in the application and destroys the current page. | + | Back | Returns to the previous page or a specified page. | + +## Attributes + + | Name | Parameters | Default Value | Description | +| -------- | -------- | -------- | -------- | +| active | boolean | - | Whether the **<Navigator>** component is activated. If the component is activated, the corresponding navigation takes effect. | +| params | Object | undefined | Data that needs to be passed to the target page during redirection. You can use **router.getParams()** to obtain the data on the target page. | + + +## Example + + ``` // Navigator Page @Entry @@ -148,6 +74,7 @@ struct NavigatorExample { } ``` + ``` // Detail Page import router from '@system.router' @@ -171,6 +98,7 @@ struct DetailExample { ``` + ``` // Back Page @Entry @@ -186,5 +114,4 @@ struct BackExample { } ``` -![](figures/navigator.gif) - +![en-us_image_0000001212058486](figures/en-us_image_0000001212058486.gif) diff --git a/en/application-dev/reference/arkui-ts/ts-container-panel.md b/en/application-dev/reference/arkui-ts/ts-container-panel.md index 5c32f0a4cbfb18288990478253d37b58bc0a088a..85416243d108e02d4e90fa7503eaa5acb70b463b 100644 --- a/en/application-dev/reference/arkui-ts/ts-container-panel.md +++ b/en/application-dev/reference/arkui-ts/ts-container-panel.md @@ -1,196 +1,68 @@ -# Panel +# Panel ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -The **** component is a slidable panel that presents lightweight content with flexible sizes. It is a pop-up component. +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** +> This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -## Required Permissions + +The **<Panel>** component is a slidable panel that presents lightweight content with flexible sizes. It is a pop-up component. + + +## Required Permissions None -## Child Components + +## Child Components This component can contain child components. -## APIs - -Panel\(value:\{show:boolean\}\) - -- Parameter - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

show

-

boolean

-

Yes

-

-

-

Whether the panel is shown or hidden.

-
- - -## Attributes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Default Value

-

Description

-

type

-

PanelType

-

Foldable

-

Type of the panel.

-

mode

-

PanelMode

-

-

-

Initial status of the panel.

-

dragBar

-

boolean

-

true

-

Whether to enable a drag bar. The value true means that the drag bar will be displayed, and false means the opposite.

-

fullHeight

-

Length

-

-

-

Panel height in the PanelMode.Full mode.

-

halfHeight

-

Length

-

-

-

Panel height in the PanelMode.Half mode. The default value is half of the screen height.

-

miniHeight

-

Length

-

-

-

Panel height in the PanelMode.Mini mode.

-
- -- PanelType enums - - - - - - - - - - - - - - - - -

Name

-

Description

-

Minibar

-

A minibar panel displays content in the minibar area or a large (fullscreen-like) area.

-

Foldable

-

A foldable panel displays permanent content in a large (fullscreen-like), medium-sized (halfscreen-like), or small area.

-

Temporary

-

A temporary panel displays content in a large (fullscreen-like) or medium-sized (halfscreen-like) area.

-
- - -- PanelMode enums - - - - - - - - - - - - - - - - -

Name

-

Description

-

Mini

-

Displays a minibar or foldable panel in its minimum size. This attribute does not take effect for temporary panels.

-

Half

-

Displays a foldable or temporary panel in a medium-sized (halfscreen-like) area. This attribute does not take effect for minibar panels.

-

Full

-

Displays a panel in a large (fullscreen-like) area.

-
- - -## Events - - - - - - - - - - -

Name

-

Description

-

onChange(callback: (width: number, height: number, mode: PanelMode) => void)

-

Triggered when the status of the panel changes. The returned height value is the height of the content area. When the value of dragbar is true, the height of the panel is the dragbar height plus the height of the content area.

-
- -## Example + +## APIs + +Panel(value:{show:boolean}) + +- Parameter + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | show | boolean | Yes | - | Whether the panel is shown or hidden. | + + +## Attributes + + | Name | Type | Default Value | Description | +| -------- | -------- | -------- | -------- | +| type | PanelType | PanelType.Foldable | Type of the panel. | +| mode | PanelMode | - | Initial status of the panel. | +| dragBar | boolean | true | Whether to enable a drag bar. The value **true** means that the drag bar will be displayed, and **false** means the opposite. | +| fullHeight | Length | - | Panel height in the **PanelMode.Full** mode. | +| halfHeight | Length | - | Panel height in the **PanelMode.Half** mode. The default value is half of the screen height. | +| miniHeight | Length | - | Panel height in the **PanelMode.Mini** mode. | + +- PanelType enums + | Name | Description | + | -------- | -------- | + | Minibar | A minibar panel displays content in the minibar area or a large (fullscreen-like) area. | + | Foldable | A foldable panel displays permanent content in a large (fullscreen-like), medium-sized (halfscreen-like), or small area. | + | Temporary | A temporary panel displays content in a large (fullscreen-like) or medium-sized (halfscreen-like) area. | + +- PanelMode enums + | Name | Description | + | -------- | -------- | + | Mini | Displays a **minibar** or **foldable** panel in its minimum size. This attribute does not take effect for **temporary** panels. | + | Half | Displays a **foldable** or **temporary** panel in a medium-sized (halfscreen-like) area. This attribute does not take effect for **minibar** panels. | + | Full | Displays a panel in a large (fullscreen-like) area. | + + +## Events + + | Name | Description | +| -------- | -------- | +| onChange(callback: (width: number, height: number, mode: PanelMode) => void) | Triggered when the status of the panel changes. The returned height value is the height of the content area. When the value of **dragbar** is **true**, the height of the panel is the dragbar height plus the height of the content area. | + + +## Example + ``` @Entry @@ -224,5 +96,4 @@ struct PanelExample { } ``` -![](figures/panel.gif) - +![en-us_image_0000001256978381](figures/en-us_image_0000001256978381.gif) diff --git a/en/application-dev/reference/arkui-ts/ts-container-rowsplit.md b/en/application-dev/reference/arkui-ts/ts-container-rowsplit.md index cae73207d988b6e6d6f6b82ca5b4cdadc5b0679a..1b034f866a8a95b0a193c8b93d65ee226060d588 100644 --- a/en/application-dev/reference/arkui-ts/ts-container-rowsplit.md +++ b/en/application-dev/reference/arkui-ts/ts-container-rowsplit.md @@ -1,48 +1,41 @@ -# RowSplit +# RowSplit ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -The **** lays out child components horizontally and inserts a vertical divider between every two child components. +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** +> This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -## Required Permissions + +The **<RowSplit>** lays out child components horizontally and inserts a vertical divider between every two child components. + + +## Required Permissions None -## Child Components + +## Child Components This component can contain child components. -## APIs -RowSplit\(\) +## APIs -## Attributes +RowSplit() - - - - - - - - - - - -

Name

-

Type

-

Description

-

resizeable

-

boolean

-

Whether the divider can be dragged. The default value is false.

-
->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->Similar to ****, the divider of **** can be dragged to a position that just fully holds a component. +## Attributes -## Example + | Name | Type | Description | +| -------- | -------- | -------- | +| resizeable | boolean | Whether the divider can be dragged. The default value is **false**. | +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** +> Similar to **<RowSplit>**, the divider of **<RowSplit>** can be dragged to a position that just fully holds a component. + + +## Example + + ``` @Entry @Component @@ -64,5 +57,4 @@ struct RowSplitExample { } ``` -![](figures/rowsplit.gif) - +![en-us_image_0000001212058482](figures/en-us_image_0000001212058482.gif) diff --git a/en/application-dev/reference/arkui-ts/ts-container-scroll.md b/en/application-dev/reference/arkui-ts/ts-container-scroll.md index a52e655865b7dd978c866348be8e77073d6b792f..47880bae2416862adf0e39aa872d53106bdbc75a 100644 --- a/en/application-dev/reference/arkui-ts/ts-container-scroll.md +++ b/en/application-dev/reference/arkui-ts/ts-container-scroll.md @@ -1,341 +1,143 @@ -# Scroll +# Scroll ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -The **** component scrolls the content when the layout size of a component exceeds the viewport of its parent component. +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** +> This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -## Required Permissions + +The **<Scroll>** component scrolls the content when the layout size of a component exceeds the viewport of its parent component. + + +## Required Permissions None -## Child Components + +## Child Components This component supports only one child component. -## APIs - -Scroll\(scroller?: Scroller\) - -## Attributes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Default Value

-

Description

-

scrollable

-

ScrollDirection

-

Vertical

-

Scroll method.

-

scrollBar

-

BarState

-

Auto

-

Scroll bar status.

-

scrollBarColor

-

Color

-

-

-

Color of the scroll bar.

-

scrollBarWidth

-

Length

-

-

-

Width of the scrollbar.

-
- -- ScrollDirection - - - - - - - - - - - - - - - - -

Name

-

Description

-

Horizontal

-

Only horizontal scrolling is supported.

-

Vertical

-

Only vertical scrolling is supported.

-

None

-

Scrolling is disabled.

-
- - -## Scroller - -Controller of the scrollable container component. You can bind this component to the container component and use it to control the scrolling of the container component. Currently, this component can be bound to the **** and **** components. - -### Creating an Object + +## APIs + +Scroll(scroller?: Scroller) + + +## Attributes + +| Name | Type | Default Value | Description | +| -------- | -------- | -------- | -------- | +| scrollable | ScrollDirection | ScrollDirection.Vertical | Scroll method. | +| scrollBar | [BarState](ts-appendix-enums.md#barstate-enums) | Auto | Scroll bar status. | +| scrollBarColor | Color | - | Color of the scroll bar. | +| scrollBarWidth | Length | - | Width of the scrollbar. | + +- ScrollDirection + | Name | Description | + | -------- | -------- | + | Horizontal | Only horizontal scrolling is supported. | + | Vertical | Only vertical scrolling is supported. | + | None | Scrolling is disabled. | + + +## Scroller + +Controller of the scrollable container component. You can bind this component to the container component and use it to control the scrolling of the container component. Currently, this component can be bound to the **<List>** and **<Scroll>** components. + + +### Objects to Import + ``` scroller: Scroller = new Scroller() ``` -### scroller.scrollTo -scrollTo\(value: \{ xOffset: number | string, yOffset: number | string, animation?: \{ duration: number, curve: Curve \} \}\): void +### scroller.scrollTo + +scrollTo(value: { xOffset: number | string, yOffset: number | string, animation?: { duration: number, curve: Curve } }): void + Scrolls to the specified position. -- Parameters - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

xOffset

-

Length

-

Yes

-

-

-

Horizontal scrolling offset.

-

yOffset

-

Length

-

Yes

-

-

-

Vertical scrolling offset.

-

animation

-

{

-

duration: number,

-

curve: Curve | CubicBezier | SpringCurve

-

}

-

No

-

-

-

Animation configuration, which includes the following:

-
  • duration: scrolling duration.
  • curve: scrolling curve.
-
- - -### scroller.scrollEdge - -scrollEdge\(value: Edge\): void + +- Parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | xOffset | Length | Yes | - | Horizontal scrolling offset. | + | yOffset | Length | Yes | - | Vertical scrolling offset. | + | animation | {
duration: number,
curve: Curve \|
CubicBezier \|
SpringCurve
} | No | | Animation configuration, which includes the following:
- **duration**: scrolling duration.
- **curve**: scrolling curve. | + + +### scroller.scrollEdge + +scrollEdge(value: Edge): void + Scrolls to the edge of the container. -- Parameters - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

value

-

Edge

-

Yes

-

-

-

Edge position to scroll to.

-
- - -### scroller.scrollPage - -scrollPage\(value: \{ next: boolean \}\): void + +- Parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | value | Edge | Yes | - | Edge position to scroll to. | + + +### scroller.scrollPage + +scrollPage(value: { next: boolean, direction?: Axis }): void Scrolls to the next or previous page. -- Parameters - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

next

-

boolean

-

Yes

-

-

-

Whether to turn to the next page. The value true means to turn to the next page, and the value false means to turn to the previous page.

-
- - -### scroller.currentOffset - -scroller.currentOffset\(\): Object +- Parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | next | boolean | Yes | - | Whether to turn to the next page. The value **true** means to scroll to the next page, and the value **false** means to scroll to the previous page. | + + +### scroller.currentOffset + +scroller.currentOffset(): Object + Obtains the scrolling offset. -- Return values - - - - - - - - - -

Type

-

Description

-

{

-

xOffset: number,

-

yOffset: number

-

}

-

xOffset: horizontal scrolling offset.

-

yOffset: vertical scrolling offset.

-
+- Return values + | Type | Description | + | -------- | -------- | + | {
xOffset: number,
yOffset: number
} | **xOffset**: horizontal scrolling offset.
**yOffset**: vertical scrolling offset. | + +### scroller.scrollToIndex -### scroller.scrollToIndex +scroller.scrollToIndex(value: number): void -scroller.scrollToIndex\(value: number\): void Scrolls to the specified index. ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->Only the **** component is supported. - -- Parameters - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

value

-

number

-

Yes

-

-

-

Index of the item to be scrolled to in the list.

-
- - -## Events - - - - - - - - - - - - - - - - -

Name

-

Description

-

onScroll(xOffset: number, yOffset: number) => void

-

Invoked to return the horizontal and vertical offsets during scrolling when the specified scroll event occurs.

-

onScrollEdge(side: Edge) => void

-

Invoked when an event of scrolling to the edge occurs.

-

onScrollEnd() => void

-

Invoked when scrolling stops.

-
- -## Example + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** +> Only the **<List>** component is supported. + + +- Parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | value | number | Yes | - | Index of the item to be scrolled to in the list. | + + +## Events + + | Name | Description | +| -------- | -------- | +| onScroll(xOffset: number, yOffset: number) => void | Invoked to return the horizontal and vertical offsets during scrolling when the specified scroll event occurs. | +| onScrollEdge(side: Edge) => void | Callback for the event of scrolling to the edge. | +| onScrollEnd() => void | Invoked when scrolling stops. | + + +## Example + ``` @Entry @@ -388,5 +190,4 @@ struct ScrollExample { } ``` -![](figures/scroll.gif) - +![en-us_image_0000001256978363](figures/en-us_image_0000001256978363.gif) diff --git a/en/application-dev/reference/arkui-ts/ts-container-scrollbar.md b/en/application-dev/reference/arkui-ts/ts-container-scrollbar.md deleted file mode 100644 index 26e9012f59b576416934c0693286ba8f302285c2..0000000000000000000000000000000000000000 --- a/en/application-dev/reference/arkui-ts/ts-container-scrollbar.md +++ /dev/null @@ -1,168 +0,0 @@ -# ScrollBar - ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->This component is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version. - -The **** is used together with the scrollable components, such as ****, ****, and ****. - -## Required Permissions - -None - -## Child Components - -This component can contain a single child component. - -## APIs - -ScrollBar\(value: ScrollBarOption\) - -- ScrollBarOption parameters - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

scroller

-

Scroller

-

Yes

-

-

-

Scrollable component controller, which can be bound to scrollable components.

-

direction

-

ScrollBarDirection

-

No

-

ScrollBarDirection.Vertical

-

Scrollbar direction in which scrollable components scroll.

-

state

-

BarState

-

No

-

BarState.Auto

-

Scroll bar status.

-
- - >![](../../public_sys-resources/icon-note.gif) **NOTE:** - >The **<\ScrollBar>** component defines the behavior style of the scrollable area, and its subnodes define the behavior style of the scrollbar. - >This component is bound to a scrollable component through **scroller**, and can be used to scroll the scrollable component only when their directions are the same. The **<\ScrollBar>** component can be bound to only one scrollable component, and vice versa. - -- ScrollBarDirection enums - - - - - - - - - - - - - -

Name

-

Description

-

Vertical

-

Vertical scrollbar.

-

Horizontal

-

Horizontal scrollbar.

-
- -- BarState enums - - - - - - - - - - - - - - - - -

Name

-

Description

-

On

-

Always displayed.

-

Off

-

Hidden.

-

Auto

-

Displayed on demand (displayed when the user touches the screen and hidden after inactivity of 2s).

-
- - -## Example - -``` -@Entry -@Component -struct ScrollBarExample { - private scroller: Scroller = new Scroller() - private arr: number[] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] - - build() { - Column() { - Stack({ alignContent: Alignment.End }) { - Scroll(this.scroller) { - Flex({ direction: FlexDirection.Column }) { - ForEach(this.arr, (item) => { - Row() { - Text(item.toString()) - .width('90%') - .height(100) - .backgroundColor('#3366CC') - .borderRadius(15) - .fontSize(16) - .textAlign(TextAlign.Center) - .margin({ top: 5 }) - } - }, item => item) - }.margin({ left: 52 }) - } - .scrollBar(BarState.Off) - .scrollable(ScrollDirection.Vertical) - ScrollBar({ scroller: this.scroller, direction: ScrollBarDirection.Vertical,state: BarState.Auto }) { - Text() - .width(30) - .height(100) - .borderRadius(10) - .backgroundColor('#C0C0C0') - }.width(30).backgroundColor('#ededed') - } - } - } -} -``` - -![](figures/f.gif) diff --git a/en/application-dev/reference/arkui-ts/ts-container-stack.md b/en/application-dev/reference/arkui-ts/ts-container-stack.md index acf2675f900b3ab96106a651887c60e30722ebdd..efb1e0276661c1861d2de6d3e9c561d073991b96 100644 --- a/en/application-dev/reference/arkui-ts/ts-container-stack.md +++ b/en/application-dev/reference/arkui-ts/ts-container-stack.md @@ -1,53 +1,35 @@ -# Stack +# Stack ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -The **** component provides a stack container where child components are successively stacked and the latter one overwrites the previous one. +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** +> This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -## Required Permissions + +The **<Stack>** component provides a stack container where child components are successively stacked and the latter one overwrites the previous one. + + +## Required Permissions None -## Child Component - -The **** component can contain child components. - -## APIs - -Stack\(value:\{alignContent?: Alignment\}\) - -- Parameters - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

alignContent

-

Alignment

-

No

-

Center

-

Alignment of child components in the container.

-
- - -## Example + +## Child Component + +The **<Stack>** component can contain child components. + + +## APIs + +Stack(value:{alignContent?: Alignment}) + +- Parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | alignContent | [Alignment](ts-appendix-enums.md#alignment-enums) | No | Center | Alignment of child components in the container. | + + +## Example + ``` @Entry @@ -62,5 +44,4 @@ struct StackExample { } ``` -![](figures/stack.jpg) - +![en-us_image_0000001212378400](figures/en-us_image_0000001212378400.jpg) diff --git a/en/application-dev/reference/arkui-ts/ts-container-stepper.md b/en/application-dev/reference/arkui-ts/ts-container-stepper.md deleted file mode 100644 index 8c0d32d48378e4af273a92ceb6ae5440ebb85a18..0000000000000000000000000000000000000000 --- a/en/application-dev/reference/arkui-ts/ts-container-stepper.md +++ /dev/null @@ -1,184 +0,0 @@ -# Stepper - ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->This component is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version. - -The **** component provides a step navigator. - -## Applicable Devices - - - - - - - - - - - - - - -

Phone

-

Tablet

-

Smart TV

-

Wearable

-

Yes

-

Yes

-

No

-

No

-
- -## Required Permissions - -None - -## Child Components - -Only the child component [StepperItem](ts-container-stepperitem.md) is supported. - -## APIs - -Stepper\(value?: \{ index?: number \}\) - -- Parameters - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

index

-

number

-

No

-

0

-

Index of the <StepperItem> child component that is currently displayed.

-
- - -## Attributes - -None - -## Events - - - - - - - - - - - - - - - - -

Name

-

Description

-

onFinish(callback: () => void)

-

Triggered when the **nextLabel** of the last stepper item in the stepper is clicked.

-

onSkip(callback: () => void)

-

Triggered when the current stepper item is **ItemState.Skip** and the **nextLabel** is clicked.

-

onChange(callback: (prevIndex?: number, index?: number) => void)

-

Triggered when the text button on the left or right is clicked to switch between steps.

-
  • **prevIndex**: index of the step page before the switching.
  • **index**: index of the step page after the switching, that is, index of the previous or next page.
-
- -## Example - -``` -@Entry -@Component -struct StepperExample { - @State currentIndex: number = 0 - @State firstState: ItemState = ItemState.Normal - @State secondState: ItemState = ItemState.Normal - - build() { - Stepper({ - index: this.currentIndex - }) { - StepperItem() { - Text('Page One') - .fontSize(35) - .fontColor(Color.Blue) - .width(200) - .lineHeight(50) - .margin({top:250}) - } - .nextLabel('') - .position({x: '35%', y: 0}) - StepperItem() { - Text('Page Two') - .fontSize(35) - .fontColor(Color.Blue) - .width(200) - .lineHeight(50) - .margin({top:250}) - .onClick(()=>{ - this.firstState = this.firstState === ItemState.Skip ? ItemState.Normal : ItemState.Skip - }) - } - .nextLabel('Next') - .prevLabel('Previous') - .status(this.firstState) - .position({x: '35%', y: 0}) - StepperItem() { - Text('Page Three') - .fontSize(35) - .fontColor(Color.Blue) - .width(200) - .lineHeight(50) - .margin({top:250}) - .onClick(()=>{ - this.secondState = this.secondState === ItemState.Waiting ? ItemState.Normal : ItemState.Waiting - }) - } - .position({x: '35%', y: 0}) - .status(this.secondState) - StepperItem() { - Text('Page four') - .fontSize(35) - .fontColor(Color.Blue) - .width(200) - .lineHeight(50) - .margin({top:250}) - } - .position({x: '35%', y: 0}) - .nextLabel('Finish') - } - .onFinish(() => { - console.log('onFinish') - }) - .onSkip(() => { - console.log('onSkip') - }) - .onChange((prevIndex: number, index: number) => { - this.currentIndex = index - }) - .align(Alignment.Center) - } -} -``` - -![](figures/en-us_image_0000001239788885.gif) diff --git a/en/application-dev/reference/arkui-ts/ts-container-stepperitem.md b/en/application-dev/reference/arkui-ts/ts-container-stepperitem.md deleted file mode 100644 index e1c5f2bf87486c461a1273c0f045dfde4a3b2785..0000000000000000000000000000000000000000 --- a/en/application-dev/reference/arkui-ts/ts-container-stepperitem.md +++ /dev/null @@ -1,123 +0,0 @@ -# StepperItem - ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->This component is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version. - -The **** component provides an element for the **** component. - -## Applicable Devices - - - - - - - - - - - - - - -

Phone

-

Tablet

-

Smart TV

-

Wearable

-

Yes

-

Yes

-

No

-

No

-
- -## Required Permissions - -None - -## Child Components - -This component supports only one child component. - -## APIs - -StepperItem\(\) - -## Attributes - - - - - - - - - - - - - - - - -If the - - - - - - - -

Name

-

Type

-

Default Value

-

Description

-

prevLabel

-

string

-

-

-

When the stepper contains more than one page, the default value for all pages except the first page is **Back**.

-

nextLabel

-

string

-

-

-

When the stepper contains more than one page, the default value for the last page is **Start**, and the default value for other pages is **Next**.

-

status

-

ItemState

-

ItemState.Normal

-

Status of the stepper item.

-
- -- ItemState enums - - - - - - - - - - - - - - - - - - - -

Name

-

Description

-

Normal

-

Normal state, in which the text button on the right is displayed properly and can be clicked to go to the next stepper item.

-

Disabled

-

Disabled state, in which the text button on the right is dimmed and cannot be clicked to go to the next stepper item.

-

Waiting

-

Waiting state, in which a waiting progress bar instead of the text button on the right is displayed. The progress bar cannot be clicked to go to the next stepper item.

-

Skip

-

Skipped state, in which the current step item is skipped and the next step item is performed.

-
- - -## Example - -See [Stepper](ts-container-stepper.md). diff --git a/en/application-dev/reference/arkui-ts/ts-container-swiper.md b/en/application-dev/reference/arkui-ts/ts-container-swiper.md index fea72e9b71f19f6ccf857016ecbe98d5a9c2a9d7..34617b654d5347fa1ec45380191a7723d141e752 100644 --- a/en/application-dev/reference/arkui-ts/ts-container-swiper.md +++ b/en/application-dev/reference/arkui-ts/ts-container-swiper.md @@ -1,200 +1,69 @@ -# Swiper +# Swiper ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -The **** component provides a container that allows users to switch among child components by swiping operations. +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** +> This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -## Required Permissions + +The **<Swiper>** component provides a container that allows users to switch among child components by swiping operations. + + +## Required Permissions None -## Child Components + +## Child Components This component can contain child components. -## APIs - -Swiper\(value:\{controller?: SwiperController\}\) - -- Parameters - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

controller

-

SwiperController

-

No

-

null

-

Controller bound to the component to control the page switching.

-
- - -## Attributes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Default Value

-

Description

-

index

-

number

-

0

-

Index of the child component currently displayed in the container.

-

autoPlay

-

boolean

-

false

-

Whether to enable automatic playback for child component switching. If this attribute is true, the indicator dots do not take effect.

-

interval

-

number

-

3000

-

Interval for automatic playback, in ms.

-

indicator

-

boolean

-

true

-

Whether to enable the navigation dots.

-

loop

-

boolean

-

true

-

Whether to enable loop playback.

-

duration

-

number

-

400

-

Duration of the animation for switching child components, in ms.

-

vertical

-

boolean

-

false

-

Whether vertical swiping is used.

-

itemSpace

-

Length

-

0

-

Space between child components.

-

cachedCount8+

-

number

-

1

-

Number of child components to be cached.

-

disableSwipe8+

-

boolean

-

false

-

Whether to disable the swipe feature.

-
- -### SwiperController - -Controller of the **** component. You can bind this object to the **** component and use it to control page switching. - - - - - - - - - - - - - -

Name

-

Description

-

showNext():void;

-

Turns to the next page.

-

showPrevious():void;

-

Turns to the previous page.

-
- -## Events - - - - - - - - - - -

Name

-

Description

-

onChange( index: number) => void

-

Triggered when the index of the currently displayed component changes.

-
- -## Example + +## APIs + +Swiper(value:{controller?: SwiperController}) + +- Parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | controller | [SwiperController](#swipercontroller) | No | null | Controller bound to the component to control the page switching. | + + +## Attributes + +| Name | Type | Default Value | Description | +| -------- | -------- | -------- | -------- | +| index | number | 0 | Index of the child component currently displayed in the container. | +| autoPlay | boolean | false | Whether to enable automatic playback for child component switching. If this attribute is **true**, the indicator dots do not take effect. | +| interval | number | 3000 | Interval for automatic playback, in ms. | +| indicator | boolean | true | Whether to enable the navigation dots. | +| loop | boolean | true | Whether to enable loop playback. | +| duration | number | 400 | Duration of the animation for switching child components, in ms. | +| vertical | boolean | false | Whether vertical swiping is used. | +| itemSpace | Length | 0 | Space between child components. | +| cachedCount8+ | number | 1 | Number of child components to be cached. | +| disableSwipe8+ | boolean | false | Whether to disable the swipe feature. | +| curve8+ | [Curve](ts-animatorproperty.md) \| Curves | Curve.Ease | Animation curve. The ease-in/ease-out curve is used by default. For details about common curves, see [Curve enums](ts-animatorproperty.md). You can also create custom curves ([interpolation curve objects](ts-interpolation-calculation.md)) by using the API provided by the interpolation calculation module. | + + +### SwiperController + +Controller of the **<Swiper>** component. You can bind this object to the **<Swiper>** component and use it to control page switching. + + | Name | Description | +| -------- | -------- | +| showNext():void | Turns to the next page. | +| showPrevious():void | Turns to the previous page. | + + +## Events + + | Name | Description | +| -------- | -------- | +| onChange( index: number) => void | Triggered when the index of the currently displayed component changes. | + + +## Example + ``` class MyDataSource implements IDataSource { @@ -251,6 +120,7 @@ struct SwiperExample { .duration(1000) .vertical(false) // Horizontal swiping is enabled by default. .itemSpace(0) + .curve(Curve.Linear) // Animation curve .onChange((index: number) => { console.info(index.toString()) }) @@ -270,5 +140,4 @@ struct SwiperExample { } ``` -![](figures/swiper.gif) - +![en-us_image_0000001211898474](figures/en-us_image_0000001211898474.gif) diff --git a/en/application-dev/reference/arkui-ts/ts-container-tabcontent.md b/en/application-dev/reference/arkui-ts/ts-container-tabcontent.md index 0d18789c72139ba1d65d2ffe2a7aab970d188168..7f3af8d922d2bceb26d41a338364bf81bc263516 100644 --- a/en/application-dev/reference/arkui-ts/ts-container-tabcontent.md +++ b/en/application-dev/reference/arkui-ts/ts-container-tabcontent.md @@ -1,61 +1,44 @@ -# TabContent +# TabContent ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -The **** component is used only in the **** component. It corresponds to the content view of a switched tab page. +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** +> This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -## Required Permissions + +The **<TabContent>** component is used only in the **<Tabs>** component. It corresponds to the content view of a switched tab page. + + +## Required Permissions None -## Child Component + +## Child Component This component supports only one child component. -## APIs -TabContent\(\) +## APIs -## Attributes +TabContent() + + +## Attributes Touch target configuration is not supported. - - - - - - - - - - - - - -

Name

-

Type

-

Default Value

-

Description

-

tabBar

-

string | {

-

icon?: string,

-

text?: string

-

}

-

| CustomBuilder8+

-

-

-

Content displayed on the tab bar.

-

CustomBuilder: builder, which can be passed to components (applicable to API 8 or later versions).

-
NOTE:

If an icon uses an SVG image, the width and height attributes of the SVG image must be deleted. Otherwise, the icon size will be determined by the width and height attributes of the SVG image.

-
-
- ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->- The **** component does not support setting of the common width attribute. By default, its width is the same as that of the parent **** component. ->- The **** component does not support setting of the common height attribute. Its height is determined by the height of the parent **** component and the **** component. - -## Example +| Name | Type | Default Value | Description | +| -------- | -------- | -------- | -------- | +| tabBar | string \| {
icon?: string,
text?: string
}
\|[CustomBuilder](../../ui/ts-types.md) | - | Content displayed on the tab bar.
**CustomBuilder**: builder, to which components can be passed (applicable to API version 8 and later versions).
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:**
> If an icon uses an SVG image, the width and height attributes of the SVG image must be deleted. Otherwise, the icon size will be determined by the width and height attributes of the SVG image. | + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** +> - The **<TabContent>** component does not support setting of the common width attribute. By default, its width is the same as that of the parent **<Tabs>** component. +> +> - The **<TabContent>** component does not support setting of the common height attribute. Its height is determined by the height of the parent **<Tabs>** component and the **<TabBar>** component. + + +## Example + ``` @Entry @@ -65,57 +48,15 @@ struct TabContentExample { @State selectedFontColor: string = 'rgba(10, 30, 255, 1)' @State currentIndex: number = 0 private controller: TabsController = new TabsController() - @Builder Tab1Builder() { - Column() { - Image(this.currentIndex === 0 ? '/resources/ic_public_contacts_filled_selected.png' : '/resources/ic_public_contacts_filled.png') - .width(24) - .height(24) - .opacity(this.currentIndex === 0 ? 1 : 0.4) - .objectFit(ImageFit.Contain) - Text("Tab1") - .fontColor(this.currentIndex === 0 ? this.selectedFontColor : this.fontColor) - .fontSize(10) - .margin({top: 2}) - } - } - - @Builder Tab2Builder() { - Column() { - Image(this.currentIndex === 1 ? '/resources/ic_public_contacts_filled_selected.png' : '/resources/ic_public_contacts_filled.png') - .width(24) - .height(24) - .opacity(this.currentIndex === 1 ? 1 : 0.4) - .objectFit(ImageFit.Contain) - Text("Tab2") - .fontColor(this.currentIndex === 1 ? this.selectedFontColor : this.fontColor) - .fontSize(10) - .margin({top: 2}) - } - } - - @Builder Tab3Builder() { - Column() { - Image(this.currentIndex === 3 ? '/resources/ic_public_contacts_filled_selected.png' : '/resources/ic_public_contacts_filled.png') - .width(24) - .height(24) - .opacity(this.currentIndex === 3 ? 1 : 0.4) - .objectFit(ImageFit.Contain) - Text("Tab3") - .fontColor(this.currentIndex === 3 ? this.selectedFontColor : this.fontColor) - .fontSize(10) - .margin({top: 2}) - } - } - - @Builder Tab4Builder() { + @Builder TabBuilder(index: number) { Column() { - Image(this.currentIndex === 4 ? '/resources/ic_public_contacts_filled_selected.png' : '/resources/ic_public_contacts_filled.png') - .width(24) - .height(24) - .opacity(this.currentIndex === 4 ? 1 : 0.4) + Image(this.currentIndex === index ? '/resources/ic_public_contacts_filled_selected.png' : '/resources/ic_public_contacts_filled.png') + .width(10) + .height(10) + .opacity(this.currentIndex === index ? 1 : 0.4) .objectFit(ImageFit.Contain) - Text("Tab4") - .fontColor(this.currentIndex === 4 ? this.selectedFontColor : this.fontColor) + Text(`Tab${(index > 2 ? (index - 1) : index) + 1}`) + .fontColor(this.currentIndex === index ? this.selectedFontColor : this.fontColor) .fontSize(10) .margin({top: 2}) } @@ -134,36 +75,36 @@ struct TabContentExample { build() { Column() { - Tabs({ barPosition: BarPosition.End, index: 0, controller: this.controller }) { + Tabs({ barPosition: BarPosition.End, controller: this.controller }) { TabContent() { Flex({justifyContent: FlexAlign.Center})) { Text('Tab1').fontSize(32) } - }.tabBar(this.Tab1Builder) + }.tabBar(this.TabBuilder(0)) TabContent() { Flex({justifyContent: FlexAlign.Center})) { Text('Tab2').fontSize(32) } - }.tabBar(this.Tab2Builder) + }.tabBar(this.TabBuilder(1)) TabContent() { Flex({justifyContent: FlexAlign.Center})) { Text('Add').fontSize(32) } - }.tabBar(this.AddBuilder) + }.tabBar(this.AddBuilder()) TabContent() { Flex({justifyContent: FlexAlign.Center})) { Text('Tab3').fontSize(32) } - }.tabBar(this.Tab3Builder) + }.tabBar(this.TabBuilder(3)) TabContent() { Flex({justifyContent: FlexAlign.Center})) { Text('Tab4').fontSize(32) } - }.tabBar(this.Tab4Builder) + }.tabBar(this.TabBuilder(4)) } .vertical(false) .barWidth(300).barHeight(56) @@ -176,4 +117,4 @@ struct TabContentExample { } ``` -![](figures/en-us_image_0000001193075122.gif) +![en-us_image_0000001256978331](figures/en-us_image_0000001256978331.gif) diff --git a/en/application-dev/reference/arkui-ts/ts-container-tabs.md b/en/application-dev/reference/arkui-ts/ts-container-tabs.md index e6c394df300683312e582d6d63acf20d9263ace6..8e0fca0e9fa3da2b40a4c2f3eb6199fde96765fc 100644 --- a/en/application-dev/reference/arkui-ts/ts-container-tabs.md +++ b/en/application-dev/reference/arkui-ts/ts-container-tabs.md @@ -1,252 +1,79 @@ -# Tabs - ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. - -The **** component is a container component that allows users to switch between content views through tabs. Each tab page corresponds to a content view. - -## Applicable Devices - - - - - - - - - - - - - - -

Phone

-

Tablet

-

Smart TV

-

Wearable

-

Yes

-

Yes

-

No

-

No

-
- -## Required Permissions +# Tabs + + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** +> This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. + + +The **<Tabs>** component is a container component that allows users to switch between content views through tabs. Each tab page corresponds to a content view. + + +## Required Permissions None -## Child Component - -The **** component can contain [TabContent](ts-container-tabcontent.md) child components. - -## APIs - -Tabs\(value: \{barPosition?: BarPosition, index?: number, controller?: [TabsController](#section104288910399)\}\) - -- Parameters - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

barPosition

-

BarPosition

-

No

-

Start

-

Tab bar position for creating the <Tabs> container component.

-

index

-

number

-

No

-

0

-

Initial tab index.

-

controller

-

TabsController

-

No

-
  

Tab controller.

-
- -- BarPosition enums - - - - - - - - - - - - - -

Name

-

Description

-

Start

-

If the vertical attribute is set to true, the tab is on the left of the container. If the vertical attribute is set to false, the tab is on the top of the container.

-

End

-

If the vertical attribute is set to true, the tab is on the right of the container. If the vertical attribute is set to false, the tab is at the bottom of the container.

-
- - -### TabsController + +## Child Component + +The **<Tabs>** component can contain [TabContent](ts-container-tabcontent.md) child components. + + +## APIs + +Tabs(value: {barPosition?: BarPosition, index?: number, controller?: [TabsController](#tabscontroller)}) + +- Parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | barPosition | BarPosition | No | BarPosition.Start | Tab bar position for creating the **<Tabs>** container component. | + | index | number | No | 0 | Initial tab index. | + | controller | [TabsController](#tabscontroller) | No | - | Tab controller. | + +- BarPosition enums + | Name | Description | + | -------- | -------- | + | Start | If the **vertical** attribute is set to **true**, the tab is on the left of the container. If the **vertical** attribute is set to **false**, the tab is on the top of the container. | + | End | If the **vertical** attribute is set to **true**, the tab is on the right of the container. If the **vertical** attribute is set to **false**, the tab is at the bottom of the container. | + + +### TabsController Defines a tab controller, which is used to control switching of tabs. - - - - - - - - - -

API

-

Description

-

changeIndex(value: number): void

-

Changes the index of a tab. The value starts from 0.

-
- -## Attributes + | API | Description | +| -------- | -------- | +| changeIndex(value: number): void | Changes the index of a tab. The value starts from **0**. | + + +## Attributes Touch target configuration is not supported. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Default Value

-

Description

-

vertical

-

boolean

-

false

-

Whether a tab is a vertical tab.

-

scrollable

-

boolean

-

true

-

Whether page switching can be performed by swiping left or right.

-

barMode

-

BarMode

-

-

-

Tab bar layout mode.

-

barWidth

-

number

-

-

-

Width of the tab bar. If this parameter is not set, the default value in the system theme is used.

-

barHeight

-

number

-

-

-

Height of the tab bar. If this parameter is not set, the default value in the system theme is used.

-

animationDuration

-

number

-

200

-

Animation duration of the tab content.

-
- -- BarMode enums - - - - - - - - - - - - - -

Name

-

Description

-

Scrollable

-

The actual layout width of the tab bar is used. If the actual width exceeds the total length, the tab bar is scrollable.

-

Fixed

-

The widths of all tab bars are evenly allocated.

-
- - -## Events - - - - - - - - - - -

Name

-

Description

-

onChange(callback: (index: number) => void)

-

Event triggered when a tab is switched.

-
- -## Example + | Name | Type | Default Value | Description | +| -------- | -------- | -------- | -------- | +| vertical | boolean | false | Whether a tab is a vertical tab. | +| scrollable | boolean | true | Whether page switching can be performed by swiping left or right. | +| barMode | BarMode | - | Tab bar layout mode. | +| barWidth | number | - | Width of the tab bar. If this parameter is not set, the default value in the system theme is used. | +| barHeight | number | - | Height of the tab bar. If this parameter is not set, the default value in the system theme is used. | +| animationDuration | number | 200 | Animation duration of the tab content. | + +- BarMode enums + | Name | Description | + | -------- | -------- | + | Scrollable | The actual layout width of the tab bar is used. If the actual width exceeds the total length, the tab bar is scrollable. | + | Fixed | The widths of all tab bars are evenly allocated. | + + +## Events + + | Name | Description | +| -------- | -------- | +| onChange(callback: (index: number) => void) | Event triggered when a tab is switched. | + + +## Example + ``` @Entry @@ -256,7 +83,7 @@ struct TabsExample { build() { Column() { - Tabs({ barPosition: BarPosition.Start, index: 1, controller: this.controller }) { + Tabs({ barPosition: BarPosition.Start, controller: this.controller }) { TabContent() { Column().width('100%').height('100%').backgroundColor(Color.Pink) }.tabBar('pink') @@ -284,5 +111,4 @@ struct TabsExample { } ``` -![](figures/tabs.gif) - +![en-us_image_0000001212218430](figures/en-us_image_0000001212218430.gif) diff --git a/en/application-dev/reference/arkui-ts/ts-drawing-components-circle.md b/en/application-dev/reference/arkui-ts/ts-drawing-components-circle.md index 787ebf3396fa7e90eb19ae277d9cbe2649cd0c35..f27d8720103662925dab1c720d4d9da249bb611e 100644 --- a/en/application-dev/reference/arkui-ts/ts-drawing-components-circle.md +++ b/en/application-dev/reference/arkui-ts/ts-drawing-components-circle.md @@ -1,134 +1,50 @@ -# Circle +# Circle ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -The **** component is used to draw a circle. +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** +> This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -## Required Permissions + +The **<Circle>** component is used to draw a circle. + + +## Required Permissions None -## Child Components + +## Child Components None -## APIs - -Circle\(options?: \{width: Length, height: Length\}\) - -- Parameters - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

options

-

Object

-

No

-

-

-

For details, see the options parameters.

-
- -- options parameters - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

width

-

Length

-

Yes

-

-

-

Width.

-

height

-

Length

-

Yes

-

-

-

Height.

-
- - -## Attributes - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Default Value

-

Mandatory

-

Description

-

width

-

Length

-

0

-

No

-

Width of the rectangle where the circle is located.

-

height

-

Length

-

0

-

No

-

Height of the rectangle where the circle is located.

-
- -## Example +## APIs + +Circle(options?: {width: Length, height: Length}) + +- Parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | options | Object | No | - | For details, see the **options** parameters. | + +- options parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | width | Length | Yes | - | Width. | + | height | Length | Yes | - | Height. | + + +## Attributes + + | Name | Type | Default Value | Mandatory | Description | +| -------- | -------- | -------- | -------- | -------- | +| width | Length | 0 | No | Width of the rectangle where the circle is located. | +| height | Length | 0 | No | Height of the rectangle where the circle is located. | + + +## Example + + ``` @Entry @Component @@ -144,5 +60,4 @@ struct CircleExample { } ``` -![](figures/circle.png) - +![en-us_image_0000001256978353](figures/en-us_image_0000001256978353.png) diff --git a/en/application-dev/reference/arkui-ts/ts-drawing-components-ellipse.md b/en/application-dev/reference/arkui-ts/ts-drawing-components-ellipse.md index d36939e06bb7df2bdaf1de30e5f56dad58854707..8c12c8fc6b178006a44b252cc03e5f32ad2af4ce 100644 --- a/en/application-dev/reference/arkui-ts/ts-drawing-components-ellipse.md +++ b/en/application-dev/reference/arkui-ts/ts-drawing-components-ellipse.md @@ -1,134 +1,50 @@ -# Ellipse +# Ellipse ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -The **** component is used to draw an ellipse. +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** +> This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -## Required Permissions + +The **<Ellipse>** component is used to draw an ellipse. + + +## Required Permissions None -## Child Components + +## Child Components None -## APIs - -ellipse\(options?: \{width: Lenght, height: Length\}\) - -- Parameters - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

options

-

Object

-

No

-

-

-

For details, see the options parameters.

-
- -- options parameters - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

width

-

Length

-

Yes

-

-

-

Width.

-

height

-

Length

-

Yes

-

-

-

Height.

-
- - -## Attributes - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Default Value

-

Mandatory

-

Description

-

width

-

Length

-

0

-

No

-

Width of the rectangle where the ellipse is located.

-

height

-

Length

-

0

-

No

-

Height of the rectangle where the ellipse is located.

-
- -## Example +## APIs + +ellipse(options?: {width: Length, height: Length}) + +- Parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | options | Object | No | - | For details, see the **options** parameters. | + +- options parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | width | Length | Yes | - | Width. | + | height | Length | Yes | - | Height. | + + +## Attributes + + | Name | Type | Default Value | Mandatory | Description | +| -------- | -------- | -------- | -------- | -------- | +| width | Length | 0 | No | Width of the rectangle where the ellipse is located. | +| height | Length | 0 | No | Height of the rectangle where the ellipse is located. | + + +## Example + + ``` @Entry @Component @@ -144,5 +60,4 @@ struct EllipseExample { } ``` -![](figures/ellipse.png) - +![en-us_image_0000001212058488](figures/en-us_image_0000001212058488.png) diff --git a/en/application-dev/reference/arkui-ts/ts-drawing-components-line.md b/en/application-dev/reference/arkui-ts/ts-drawing-components-line.md index 00cb05366364d11d4205c94a97f2892c02b73f79..0221bc3737911512a51cd62cd018394ccbb87400 100644 --- a/en/application-dev/reference/arkui-ts/ts-drawing-components-line.md +++ b/en/application-dev/reference/arkui-ts/ts-drawing-components-line.md @@ -1,156 +1,52 @@ -# Line +# Line ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -The **** component is used to draw a straight line. +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** +> This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -## Required Permissions + +The **<Line>** component is used to draw a straight line. + + +## Required Permissions None -## Child Components + +## Child Components None -## APIs - -Line\(options?: \{width: Lenght, height: Length\}\) - -- Parameters - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

options

-

Object

-

No

-

-

-

For details, see the options parameters.

-
- -- options parameters - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

width

-

Length

-

Yes

-

-

-

Width.

-

height

-

Length

-

Yes

-

-

-

Height.

-
- - -## Attributes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Default Value

-

Mandatory

-

Description

-

width

-

Length

-

0

-

No

-

Width of the rectangle where the straight line is located.

-

height

-

Length

-

0

-

No

-

Height of the rectangle where the straight line is located.

-

startPoint

-

Point

-

[0, 0]

-

Yes

-

Coordinate (relative coordinate) of the start point of the straight line.

-

endPoint

-

Point

-

[0, 0]

-

Yes

-

Coordinate (relative coordinate) of the end point of the straight line.

-
- -## Example +## APIs + +Line(options?: {width: Length, height: Length}) + +- Parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | options | Object | No | - | For details, see the **options** parameters. | + +- options parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | width | Length | Yes | - | Width. | + | height | Length | Yes | - | Height. | + + +## Attributes + + | Name | Type | Default Value | Mandatory | Description | +| -------- | -------- | -------- | -------- | -------- | +| width | Length | 0 | No | Width of the rectangle where the straight line is located. | +| height | Length | 0 | No | Height of the rectangle where the straight line is located. | +| startPoint | Point | [0, 0] | Yes | Coordinate (relative coordinate) of the start point of the straight line. | +| endPoint | Point | [0, 0] | Yes | Coordinate (relative coordinate) of the end point of the straight line. | + + +## Example + + ``` @Entry @Component @@ -164,5 +60,4 @@ struct LineExample { } ``` -![](figures/line.jpg) - +![en-us_image_0000001256858387](figures/en-us_image_0000001256858387.jpg) diff --git a/en/application-dev/reference/arkui-ts/ts-drawing-components-path.md b/en/application-dev/reference/arkui-ts/ts-drawing-components-path.md index 3642fd8e7671af6638975d85536c7070cfc824d9..230877976324202f8f0d4c581506c8793d62e37a 100644 --- a/en/application-dev/reference/arkui-ts/ts-drawing-components-path.md +++ b/en/application-dev/reference/arkui-ts/ts-drawing-components-path.md @@ -1,86 +1,62 @@ -# Path +# Path ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -The **** component is used to draw a path. +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** +> This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -## Required Permissions + +The **<Path>** component is used to draw a path. + + +## Required Permissions None -## Child Components + +## Child Components None -## Attributes - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Default Value

-

Mandatory

-

Description

-

width

-

Length

-

0

-

No

-

Width of the rectangle where the path is located.

-

height

-

Length

-

0

-

No

-

Height of the rectangle where the path is located.

-

commands

-

string

-

''

-

Yes

-

Command string for drawing the path.

-
+ +## Attributes + + | Name | Type | Default Value | Mandatory | Description | +| -------- | -------- | -------- | -------- | -------- | +| width | Length | 0 | No | Width of the rectangle where the path is located. | +| height | Length | 0 | No | Height of the rectangle where the path is located. | +| commands | string | '' | Yes | Command string for drawing the path. | + The supported commands are as follows: -- M = moveto -- L = lineto -- H = horizontal lineto -- V = vertical lineto -- C = curveto -- S = smooth curveto -- Q = quadratic Belzier curve -- T = smooth quadratic Belzier curveto -- A = elliptical Arc -- Z = closepath -For example, the command **M0 20 L50 50 L50 100 Z** defines a path that starts from \(0, 20\), reaches \(50, 50\) and then \(50, 100\), and ends at \(0, 20\). +- M = moveto + +- L = lineto + +- H = horizontal lineto + +- V = vertical lineto -## Example +- C = curveto +- S = smooth curveto + +- Q = quadratic Bezier curve + +- T = smooth quadratic Bezier curveto + +- A = elliptical Arc + +- Z = closepath + + +For example, the command **M0 20 L50 50 L50 100 Z** defines a path that starts from (0, 20), reaches (50, 50) and then (50, 100), and ends at (0, 20). + + +## Example + + ``` @Entry @Component @@ -112,5 +88,4 @@ struct PathExample { } ``` -![](figures/path.png) - +![en-us_image_0000001212058492](figures/en-us_image_0000001212058492.png) diff --git a/en/application-dev/reference/arkui-ts/ts-drawing-components-polygon.md b/en/application-dev/reference/arkui-ts/ts-drawing-components-polygon.md index c1eec93f59e1b14d8e61df5e377211b2327a778d..a3a4678f857822de576e7a7b51371d076636021a 100644 --- a/en/application-dev/reference/arkui-ts/ts-drawing-components-polygon.md +++ b/en/application-dev/reference/arkui-ts/ts-drawing-components-polygon.md @@ -1,145 +1,51 @@ -# Polygon +# Polygon ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -The **** component is used to draw a polygon. +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** +> This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -## Required Permissions + +The **<Polygon>** component is used to draw a polygon. + + +## Required Permissions None -## Child Components + +## Child Components None -## APIs - -Polygon\(value:\{options?: \{width: Lenght, height: Length\}\}\) - -- Parameters - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

options

-

Object

-

No

-

-

-

For details, see the options parameters.

-
- -- options parameters - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

width

-

Length

-

Yes

-

-

-

Width.

-

height

-

Length

-

Yes

-

-

-

Height.

-
- - -## Attributes - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Default Value

-

Mandatory

-

Description

-

width

-

Length

-

0

-

No

-

Width of the rectangle where the polygon is located.

-

height

-

Length

-

0

-

No

-

Height of the rectangle where the polygon is located.

-

points

-

Array<Point>

-

-

-

Yes

-

Vertex coordinates of the polygon.

-
- -## Example +## APIs + +Polygon(value:{options?: {width: Length, height: Length}}) + +- Parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | options | Object | No | - | For details, see the **options** parameters. | + +- options parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | width | Length | Yes | - | Width. | + | height | Length | Yes | - | Height. | + + +## Attributes + + | Name | Type | Default Value | Mandatory | Description | +| -------- | -------- | -------- | -------- | -------- | +| width | Length | 0 | No | Width of the rectangle where the polygon is located. | +| height | Length | 0 | No | Height of the rectangle where the polygon is located. | +| points | Array<Point> | - | Yes | Vertex coordinates of the polygon. | + + +## Example + + ``` @Entry @Component @@ -159,5 +65,4 @@ struct PolygonExample { } ``` -![](figures/polygon.gif) - +![en-us_image_0000001212218458](figures/en-us_image_0000001212218458.gif) diff --git a/en/application-dev/reference/arkui-ts/ts-drawing-components-polyline.md b/en/application-dev/reference/arkui-ts/ts-drawing-components-polyline.md index d09da452bc117cb8041936f6c0d43278566a8155..ddffe533def58acca13e346c0a7be8a594c1141e 100644 --- a/en/application-dev/reference/arkui-ts/ts-drawing-components-polyline.md +++ b/en/application-dev/reference/arkui-ts/ts-drawing-components-polyline.md @@ -1,145 +1,51 @@ -# Polyline +# Polyline ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -The **** component is used to draw a polyline. +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** +> This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -## Required Permissions + +The **<Polyline>** component is used to draw a polyline. + + +## Required Permissions None -## Child Components + +## Child Components None -## APIs - -Polyline\(options?: \{width: Lenght, height: Length\}\) - -- Parameters - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

options

-

Object

-

No

-

-

-

For details, see the options parameters.

-
- -- options parameters - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

width

-

Length

-

Yes

-

-

-

Width.

-

height

-

Length

-

Yes

-

-

-

Height.

-
- - -## Attributes - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Default Value

-

Mandatory

-

Description

-

width

-

Length

-

0

-

No

-

Width of the rectangle where the polyline is located.

-

height

-

Length

-

0

-

No

-

Height of the rectangle where the polyline is located.

-

points

-

Array<Point>

-

-

-

Yes

-

List of coordinates that the polyline passes through.

-
- -## Example +## APIs + +Polyline(options?: {width: Length, height: Length}) + +- Parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | options | Object | No | - | For details, see the **options** parameters. | + +- options parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | width | Length | Yes | - | Width. | + | height | Length | Yes | - | Height. | + + +## Attributes + + | Name | Type | Default Value | Mandatory | Description | +| -------- | -------- | -------- | -------- | -------- | +| width | Length | 0 | No | Width of the rectangle where the polyline is located. | +| height | Length | 0 | No | Height of the rectangle where the polyline is located. | +| points | Array<Point> | - | Yes | List of coordinates that the polyline passes through. | + + +## Example + + ``` @Entry @Component @@ -157,5 +63,4 @@ struct PolylineExample { } ``` -![](figures/polyline.gif) - +![en-us_image_0000001212218432](figures/en-us_image_0000001212218432.gif) diff --git a/en/application-dev/reference/arkui-ts/ts-drawing-components-rect.md b/en/application-dev/reference/arkui-ts/ts-drawing-components-rect.md index 7a85738af04b856668d48b98baf6be2443378e92..561cd243b2ef3c64c5eda583de312cdd3e9954c5 100644 --- a/en/application-dev/reference/arkui-ts/ts-drawing-components-rect.md +++ b/en/application-dev/reference/arkui-ts/ts-drawing-components-rect.md @@ -1,200 +1,56 @@ -# Rect +# Rect ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -The **** component is used to draw a rectangle. +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** +> This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -## Required Permissions + +The **<Rect>** component is used to draw a rectangle. + + +## Required Permissions None -## Child Components + +## Child Components None -## APIs - -Rect\(value:\{options?: \{width: Length,height: Length,radius?: Length | Array\} | \{width: Length,height: Length,radiusWidth?: Length,radiusHeight?: Length\}\}\) - -- Parameters - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

options

-

Object

-

No

-

-

-

For details, see the options parameters.

-
- -- options parameters - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

width

-

Length

-

Yes

-

-

-

Width.

-

height

-

Length

-

Yes

-

-

-

Height.

-

radius

-

Length | Array<Length>

-

No

-

0

-

Radius of a rounded corner. You can set the radius of four rounded corners.

-

radiusWidth

-

Length

-

No

-

0

-

Width of the rounded corner.

-

radiusHeight

-

Length

-

No

-

0

-

Height of the rounded corner.

-
- - -## Attributes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Default Value

-

Mandatory

-

Description

-

width

-

Length

-

0

-

No

-

Width.

-

height

-

Length

-

0

-

No

-

Height.

-

radiusWidth

-

Length

-

0

-

No

-

Width of a rounded corner. The width and height are the same when only the width is set.

-

radiusHeight

-

Length

-

0

-

No

-

Height of the rounded corner. The width and height are the same only when the height is set.

-

radius

-

Length | Array<Length>

-

0

-

No

-

Size of the rounded corner.

-
- -## Example +## APIs + +Rect(value:{options?: {width: Length,height: Length,radius?: Length | Array<Length>} | {width: Length,height: Length,radiusWidth?: Length,radiusHeight?: Length}}) + +- Parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | options | Object | No | - | For details, see the **options** parameters. | + +- options parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | width | Length | Yes | - | Width. | + | height | Length | Yes | - | Height. | + | radius | Length \| Array<Length> | No | 0 | Radius of a rounded corner. You can set the radius of four rounded corners. | + | radiusWidth | Length | No | 0 | Width of the rounded corner. | + | radiusHeight | Length | No | 0 | Height of the rounded corner. | + + +## Attributes + + | Name | Type | Default Value | Mandatory | Description | +| -------- | -------- | -------- | -------- | -------- | +| width | Length | 0 | No | Width. | +| height | Length | 0 | No | Height. | +| radiusWidth | Length | 0 | No | Width of a rounded corner. The width and height are the same when only the width is set. | +| radiusHeight | Length | 0 | No | Height of the rounded corner. The width and height are the same only when the height is set. | +| radius | Length \| Array<Length> | 0 | No | Size of the rounded corner. | + + +## Example + + ``` @Entry @Component @@ -217,5 +73,4 @@ struct RectExample { } ``` -![](figures/rect.png) - +![en-us_image_0000001212218454](figures/en-us_image_0000001212218454.png) diff --git a/en/application-dev/reference/arkui-ts/ts-drawing-components-shape.md b/en/application-dev/reference/arkui-ts/ts-drawing-components-shape.md index 18ac993b3063e380357782c72ffceb34d41eceff..41a23559e400e413604e052acfa9497c5bfec812 100644 --- a/en/application-dev/reference/arkui-ts/ts-drawing-components-shape.md +++ b/en/application-dev/reference/arkui-ts/ts-drawing-components-shape.md @@ -1,230 +1,66 @@ -# Shape +# Shape ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -The **** component is the parent component of the drawing components. The attributes described in this topic are universal attributes supported by all the drawing components. +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** +> This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -1. The drawing components use **** as the parent component to implement the effect similar to SVG. -2. The **** component is used independently to draw a specific shape. +The **<Shape>** component is the parent component of the drawing components. The attributes described in this topic are universal attributes supported by all the drawing components. -## Required Permissions + +1. The drawing components use **<Shape>** as the parent component to implement the effect similar to SVG. + + +2. The **<Shape>** component is used independently to draw a specific shape. + + +## Required Permissions None -## Child Components -The **** component can contain child components. +## Child Components -## APIs +The **<Shape>** component can contain child components. -Shape\(value:\{target?: PixelMap\}\) -- Parameters +## APIs - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

target

-

PixelMap

-

No

-

null

-

Shape to draw. You can draw a shape in the specified PixelMap object. If no object is specified, the shape is drawn in the current drawing target.

-
+Shape(value:{target?: PixelMap}) +- Parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | target | PixelMap | No | null | Shape to draw. You can draw a shape in the specified **PixelMap** object. If no object is specified, the shape is drawn in the current drawing target. | -## Attributes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Default Value

-

Mandatory

-

Description

-

viewPort

-

{

-

x: Length,

-

y: Length,

-

width: Length,

-

height: Length

-

}

-

-

-

Yes

-

View port of the shape.

-

fill

-

Color

-

Black

-

No

-

Fill color.

-

stroke

-

Color

-

-

-

No

-

Stroke color.

-

strokeDashArray

-

Array<Length>

-

[]

-

No

-

Stroke dash.

-

strokeDashOffset

-

Length

-

0

-

No

-

Offset of the start point for drawing the stroke.

-

strokeLineCap

-

LineCapStyle

-

Butt

-

No

-

Cap style of the stroke.

-

strokeLineJoin

-

LineJoinStyle

-

Miter

-

No

-

Join style of the stroke.

-

strokeMiterLimit

-

number

-

4

-

No

-

Limit value when the sharp angle is drawn as a miter.

-

strokeOpacity

-

number

-

1

-

No

-

Stroke opacity.

-

strokeWidth

-

Length

-

1

-

No

-

Stroke width.

-

antiAlias

-

boolean

-

true

-

No

-

Whether anti-aliasing is enabled.

-
+## Attributes -- LineJoinStyle enums + | Name | Type | Default Value | Mandatory | Description | +| -------- | -------- | -------- | -------- | -------- | +| viewPort | {
x: Length,
y: Length,
width: Length,
height: Length
} | - | Yes | View port of the shape. | +| fill | Color | Black | No | Fill color. | +| stroke | Color | - | No | Stroke color. | +| strokeDashArray | Array<Length> | [] | No | Stroke dash. | +| strokeDashOffset | Length | 0 | No | Offset of the start point for drawing the stroke. | +| strokeLineCap | LineCapStyle | LineCapStyle.Butt | No | Cap style of the stroke. | +| strokeLineJoin | LineJoinStyle | LineJoinStyle.Miter | No | Join style of the stroke. | +| strokeMiterLimit | number | 4 | No | Limit value when the sharp angle is drawn as a miter. | +| strokeOpacity | number | 1 | No | Stroke opacity. | +| strokeWidth | Length | 1 | No | Stroke width. | +| antiAlias | boolean | true | No | Whether anti-aliasing is enabled. | - - - - - - - - - - - - - - - -

Name

-

Description

-

Bevel

-

Bevel is used to connect paths.

-

Miter

-

Miter is used to connect paths.

-

Round

-

Round is used to connect paths.

-
+- LineJoinStyle enums + | Name | Description | + | -------- | -------- | + | Bevel | Bevel is used to connect paths. | + | Miter | Miter is used to connect paths. | + | Round | Round is used to connect paths. | -## Example +## Example + ``` @Entry @Component @@ -287,5 +123,4 @@ struct ShapeExample { } ``` -![](figures/2-01.png) - +![en-us_image_0000001257058393](figures/en-us_image_0000001257058393.png) diff --git a/en/application-dev/reference/arkui-ts/ts-drawing-components.md b/en/application-dev/reference/arkui-ts/ts-drawing-components.md index 1f1eeac321fc01c4e0024b115b97584fc6dc1c39..853d7b3d98da24c39b5b057c1d254856d7df8352 100644 --- a/en/application-dev/reference/arkui-ts/ts-drawing-components.md +++ b/en/application-dev/reference/arkui-ts/ts-drawing-components.md @@ -1,19 +1,19 @@ -# Drawing Components +# Drawing Components -- **[Circle](ts-drawing-components-circle.md)** -- **[Ellipse](ts-drawing-components-ellipse.md)** -- **[Line](ts-drawing-components-line.md)** +- **[Circle](ts-drawing-components-circle.md)** -- **[Polyline](ts-drawing-components-polyline.md)** +- **[Ellipse](ts-drawing-components-ellipse.md)** -- **[Polygon](ts-drawing-components-polygon.md)** +- **[Line](ts-drawing-components-line.md)** -- **[Path](ts-drawing-components-path.md)** +- **[Polyline](ts-drawing-components-polyline.md)** -- **[Rect](ts-drawing-components-rect.md)** +- **[Polygon](ts-drawing-components-polygon.md)** -- **[Shape](ts-drawing-components-shape.md)** +- **[Path](ts-drawing-components-path.md)** +- **[Rect](ts-drawing-components-rect.md)** +- **[Shape](ts-drawing-components-shape.md)** \ No newline at end of file diff --git a/en/application-dev/reference/arkui-ts/ts-explicit-animation.md b/en/application-dev/reference/arkui-ts/ts-explicit-animation.md index af5ab03d553bae49373b8c023c8d25855ff31da8..aa9f4e4009164f24843748c3eaa7fbdbb0721d86 100644 --- a/en/application-dev/reference/arkui-ts/ts-explicit-animation.md +++ b/en/application-dev/reference/arkui-ts/ts-explicit-animation.md @@ -1,116 +1,35 @@ -# Explicit Animation +# Explicit Animation ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->This animation is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. - - - - - - - - - -

Name

-

Description

-

animateTo(value: AnimationOption, event: ()=> void) : void

-

Provides a transition animation when the status changes due to the closure code.

-

event specifies the closure function that displays the dynamic effect. The system automatically inserts the transition animation if the status changes in the closure function.

-
+> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** +> This animation is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -## AnimationOption Object + | Name | Description | +| -------- | -------- | +| animateTo(value: [AnimationOption](#animationoption-object), event: ()=> void) : void | Provides a transition animation when the status changes due to the closure code.
**event** specifies the closure function that displays the dynamic effect. The system automatically inserts the transition animation if the status changes in the closure function. | -- Attributes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Default Value

-

Description

-

duration

-

number

-

1000

-

Animation duration, in ms.

-

tempo

-

number

-

1.0

-

Animation playback speed. A larger value indicates faster animation playback, and a smaller value indicates slower animation playback. The value 0 means that there is no animation.

-

curve

-

Curve | Curves

-

Linear

-

Animation curve.

-

delay

-

number

-

0

-

Delay of animation playback, in ms. By default, the playback is not delayed.

-

iterations

-

number

-

1

-

Number of times that the animation is played. By default, the animation is played once. The value -1 indicates that the animation is played for an unlimited number of times.

-

playMode

-

PlayMode

-

Normal

-

Animation playback mode. By default, the animation is played from the beginning after the playback is complete.

-
+## AnimationOption Object +- Attributes + | Name | Type | Default Value | Description | + | -------- | -------- | -------- | -------- | + | duration | number | 1000 | Animation duration, in ms. | + | tempo | number | 1.0 | Animation playback speed. A larger value indicates faster animation playback, and a smaller value indicates slower animation playback. The value **0** means that there is no animation. | + | curve | Curve \| Curves | Linear | Animation curve. | + | delay | number | 0 | Delay of animation playback, in ms. By default, the playback is not delayed. | + | iterations | number | 1 | Number of times that the animation is played. By default, the animation is played once. The value **-1** indicates that the animation is played for an unlimited number of times. | + | playMode | PlayMode | Normal | Animation playback mode. By default, the animation is played from the beginning after the playback is complete. | -- APIs - - - - - - - - - -

Name

-

Description

-

onFinish() => void

-

Callback invoked when the animation playback is complete.

-
+- APIs + | Name | Description | + | -------- | -------- | + | onFinish() => void | Callback invoked when the animation playback is complete. | -## Example +## Example + ``` @Entry @@ -165,5 +84,4 @@ struct AnimateToExample { } ``` -![](figures/animateto.gif) - +![en-us_image_0000001256978345](figures/en-us_image_0000001256978345.gif) diff --git a/en/application-dev/reference/arkui-ts/ts-gesture-processing.md b/en/application-dev/reference/arkui-ts/ts-gesture-processing.md index cd8880a63e51c155ee5a9f4b3945fa843d127cd1..e40e024a5d750d9992a1ef7ba60f0d307b6c7d89 100644 --- a/en/application-dev/reference/arkui-ts/ts-gesture-processing.md +++ b/en/application-dev/reference/arkui-ts/ts-gesture-processing.md @@ -1,9 +1,9 @@ -# Gesture Processing +# Gesture Processing -- **[Gesture Binding Methods](ts-gesture-settings.md)** -- **[Basic Gestures](ts-basic-gestures.md)** -- **[Combined Gestures](ts-combined-gestures.md)** +- **[Combined Gestures](ts-combined-gestures.md)** +- **[Gesture Binding Methods](ts-gesture-settings.md)** +- **[Basic Gestures](ts-basic-gestures.md)** \ No newline at end of file diff --git a/en/application-dev/reference/arkui-ts/ts-gesture-settings.md b/en/application-dev/reference/arkui-ts/ts-gesture-settings.md index 40503a4845c5fbbf44d9017ae8d58489e1a7c90f..c467540f76faf3cd350a8dbbd7c96c086b72f1e4 100644 --- a/en/application-dev/reference/arkui-ts/ts-gesture-settings.md +++ b/en/application-dev/reference/arkui-ts/ts-gesture-settings.md @@ -1,190 +1,64 @@ -# Gesture Binding Methods +# Gesture Binding Methods ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->The APIs of this module are supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -## Required Permissions +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** +> This method is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. + + +## Required Permissions None -## Binding Gesture Recognition - -You can use the following attributes to bind gesture recognition to a component. When a gesture is recognized, the event callback is invoked to notify the component. - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Default Value

-

Description

-

gesture

-

gesture: GestureType,

-

mask?: GestureMask

-

gesture: -,

-

mask: GestureMask.Normal

-

Gesture to recognize.

-

gesture specifies the type of the gesture to bind, and mask specifies the event response setting.

-

priorityGesture

-

gesture: GestureType,

-

mask?: GestureMask

-

gesture: -,

-

mask: GestureMask.Normal

-

Gesture to preferentially recognize.

-

gesture specifies the type of the gesture to bind, and mask specifies the event response setting.

-
NOTE:
  • By default, the child component takes precedence over the parent component in gesture recognition. When priorityGesture is configured for the parent component, the parent component takes precedence over the child component in gesture recognition.
-
-

parallelGesture

-

gesture: GestureType,

-

mask?: GestureMask

-

gesture: -,

-

mask: GestureMask.Normal

-

Gesture that can be triggered together with the child component gesture.

-

gesture specifies the type of the gesture to bind, and mask specifies the event response setting.

-
NOTE:
  • The gesture event is not a bubbling event. When parallelGesture is set for the parent component, gesture events that are the same for the parent component and child components can be triggered, thereby implementing a bubbling effect.
-
-
- -- GestureMask enums - - - - - - - - - - - - - -

Name

-

Description

-

Normal

-

The gestures of child components are not masked and are recognized based on the default gesture recognition sequence.

-

IgnoreInternal

-

The gestures of child components are masked. Only the gestures of the current component are recognized.

-
NOTE:

However, the built-in gestures of the child components are not masked. For example, when the child component is a <List> component, the built-in sliding gestures can still be triggered.

-
-
- - -- Gesture types - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Description

-

TapGesture

-

Tap gesture, which can be a single-tap or multi-tap gesture.

-

LongPressGesture

-

Long press gesture.

-

PanGesture

-

Pan gesture.

-

PinchGesture

-

Pinch gesture.

-

RotationGesture

-

Rotation gesture.

-

GestureGroup

-

A group of gestures. Continuous recognition, parallel recognition, and exclusive recognition are supported.

-
- - -## Gesture Response Event - -The component uses the **gesture** method to bind the gesture object and uses the events provided in this object to respond to the gesture operation. For example, the **onAction** event of the **TapGesture** object can be used to respond to a click event. For details about the event definition, see the section of each gesture object. - -- TapGesture events - - - - - - - - - - -

Name

-

Description

-

onAction((event?: GestureEvent) => void)

-

Callback invoked when a tap gesture is recognized.

-
- - -- GestureEvent attributes - - - - - - - - - - - - - - - - -

Name

-

Type

-

Description

-

timestamp

-

number

-

Timestamp of the event.

-

target8+

-

EventTarget

-

Object that triggers the gesture event.

-
- - -## Example + +## Binding Gesture Recognition + + +Use the following attributes to bind gesture recognition to a component. When a gesture is recognized, the event callback is invoked to notify the component. + + + | Name | Type | Default Value | Description | +| -------- | -------- | -------- | -------- | +| gesture | gesture: GestureType,
mask?: GestureMask | gesture: -,
mask: GestureMask.Normal | Gesture to recognize.
**gesture** specifies the type of the gesture to bind, and **mask** specifies the event response setting. | +| priorityGesture | gesture: GestureType,
mask?: GestureMask | gesture: -,
mask: GestureMask.Normal | Gesture to preferentially recognize.
**gesture** specifies the type of the gesture to bind, and **mask** specifies the event response setting.
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:**
> - By default, the child component takes precedence over the parent component in gesture recognition. When **priorityGesture** is configured for the parent component, the parent component takes precedence over the child component in gesture recognition. | +| parallelGesture | gesture: GestureType,
mask?: GestureMask | gesture: -,
mask: GestureMask.Normal | Gesture that can be triggered together with the child component gesture.
**gesture** specifies the type of the gesture to bind, and **mask** specifies the event response setting.
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:**
> - The gesture event is not a bubbling event. When **parallelGesture** is set for the parent component, gesture events that are the same for the parent component and child components can be triggered, thereby implementing a bubbling effect. | + + +- GestureMask enums + | Name | Description | + | -------- | -------- | + | Normal | The gestures of child components are not masked and are recognized based on the default gesture recognition sequence. | + | IgnoreInternal | The gestures of child components are masked. Only the gestures of the current component are recognized.
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:**
> However, the built-in gestures of the child components are not masked. For example, when the child component is a **<List>** component, the built-in sliding gestures can still be triggered. | + + +- Gesture types + | Name | Description | + | -------- | -------- | + | TapGesture | Tap gesture, which can be a single-tap or multi-tap gesture. | + | LongPressGesture | Long press gesture. | + | PanGesture | Pan gesture. | + | PinchGesture | Pinch gesture. | + | RotationGesture | Rotation gesture. | + | GestureGroup | A group of gestures. Continuous recognition, parallel recognition, and exclusive recognition are supported. | + + +## Gesture Response Event + +The component uses the **gesture** method to bind the gesture object and uses the events provided in this object to respond to the gesture operation. For example, the **onAction** event of the **TapGesture** object can be used to respond to a click event. For details about the event definition, see the section of each gesture object. + +- TapGesture events + | Name | Description | + | -------- | -------- | + | onAction((event?: GestureEvent) => void) | Callback invoked when a tap gesture is recognized. | + +- GestureEvent attributes + | Name | Type | Description | + | -------- | -------- | -------- | + | timestamp | number | Timestamp of the event. | + | target8+ | EventTarget | Object that triggers the gesture event. | + + +## Example + ``` @Entry @@ -206,9 +80,9 @@ struct GestureSettingsExample { .priorityGesture( TapGesture() .onAction((event: GestureEvent) => { -this.value = 'priorityGesture onAction' + '\ncomponent globalPos: (' - + event.target.area.globalPos.x + ',' + event.target.area.globalPos.y + ')\nwidth:' - + event.target.area.width + '\nheight:' + event.target.area.height + this.value = 'priorityGesture onAction' + '\ncomponent globalPos:(' + + event.target.area.globalPos.x + ',' + event.target.area.globalPos.y + ')\nwidth:' + + event.target.area.width + '\nheight:' + event.target.area.height }), GestureMask.IgnoreInternal ) }.padding(60) @@ -216,5 +90,4 @@ this.value = 'priorityGesture onAction' + '\ncomponent globalPos: (' } ``` -![](figures/en-us_image_0000001237475107.gif) - +![en-us_image_0000001256858411](figures/en-us_image_0000001256858411.gif) diff --git a/en/application-dev/reference/arkui-ts/ts-global-ui-methods.md b/en/application-dev/reference/arkui-ts/ts-global-ui-methods.md index 7bcfd801bfc0c25f3298744af98ea48c9b8f08cb..a05ce685b9ef70da6dec82b0f3a5300a4bcd9e65 100644 --- a/en/application-dev/reference/arkui-ts/ts-global-ui-methods.md +++ b/en/application-dev/reference/arkui-ts/ts-global-ui-methods.md @@ -1,13 +1,9 @@ -# Global UI Methods +# Global UI Methods -- **[Alert Dialog Box](ts-methods-alert-dialog-box.md)** -- **[Custom Dialog box](ts-methods-custom-dialog-box.md)** -- **[Image Cache](ts-methods-image-cache.md)** - -- **[Media Query](ts-methods-media-query.md)** - -- **[List Selection Dialog Box](ts-methods-custom-actionsheet.md)** +- **[Image Cache](ts-methods-image-cache.md)** +- **[Media Query](ts-methods-media-query.md)** +- **[Pop-up Window](ts-methods-popup-window.md)** \ No newline at end of file diff --git a/en/application-dev/reference/arkui-ts/ts-interpolation-calculation.md b/en/application-dev/reference/arkui-ts/ts-interpolation-calculation.md index c4e369acb641c891c4440217e55aedfd6909f0c7..11443bfc54db26d3fafef85fb3713b7a9457f36d 100644 --- a/en/application-dev/reference/arkui-ts/ts-interpolation-calculation.md +++ b/en/application-dev/reference/arkui-ts/ts-interpolation-calculation.md @@ -1,237 +1,101 @@ -# Interpolation Calculation +# Interpolation Calculation ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->This animation is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -## Modules to Import +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** +> This animation is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. + +## Modules to Import + + ``` import curves from '@ohos.curves' ``` -## Required Permissions + +## Required Permissions None -## curves.init -init\(curve?: Curve\): Object +## curves.init + +init(curve?: Curve): Object + Implements initialization for the interpolation curve, which is used to create an interpolation curve object based on the input parameter. -- Parameters - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

curve

-

Curve

-

No

-

Linear

-

Curve object.

-
- -- Return values - - Curve object. - - -## curves.steps - -steps\(count: number, end: boolean\): Object + +- Parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | curve | Curve | No | Linear | Curve object. | + +- Return values + Curve object. + + +## curves.steps + +steps(count: number, end: boolean): Object + Constructs a step curve object. -- Parameters - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

count

-

number

-

Yes

-

-

-

Number of steps. Must be a positive integer.

-

end

-

boolean

-

No

-

true

-

Step change at the start or end point of each interval. Defaults to true, indicating that the step change occurs at the end point.

-
- -- Return values - - Curve object. - - -## curves.cubicBezier - -cubicBezier\(x1: number, y1: number, x2: number, y2: number\): Object + +- Parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | count | number | Yes | - | Number of steps. Must be a positive integer. | + | end | boolean | No | true | Step change at the start or end point of each interval. Defaults to **true**, indicating that the step change occurs at the end point. | + +- Return values + Curve object. + + +## curves.cubicBezier + +cubicBezier(x1: number, y1: number, x2: number, y2: number): Object + Constructs a third-order Bezier curve object. The curve value must be between 0 and 1. -- Parameters - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

x1

-

number

-

Yes

-

Horizontal coordinate of the first point on the Bezier curve.

-

y1

-

number

-

Yes

-

Vertical coordinate of the first point on the Bezier curve.

-

x2

-

number

-

Yes

-

Horizontal coordinate of the second point on the Bezier curve.

-

y2

-

number

-

Yes

-

Vertical coordinate of the second point on the Bezier curve.

-
- -- Return values - - Curve object. - - -## curves.spring - -spring\(velocity: number, mass: number, stiffness: number, damping: number\): Object + +- Parameters + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | x1 | number | Yes | Horizontal coordinate of the first point on the Bezier curve. | + | y1 | number | Yes | Vertical coordinate of the first point on the Bezier curve. | + | x2 | number | Yes | Horizontal coordinate of the second point on the Bezier curve. | + | y2 | number | Yes | Vertical coordinate of the second point on the Bezier curve. | + +- Return values + Curve object. + + +## curves.spring + +spring(velocity: number, mass: number, stiffness: number, damping: number): Object + Constructs a spring curve object. -- Parameters - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

velocity

-

number

-

Yes

-

Initial velocity.

-

mass

-

number

-

Yes

-

Mass.

-

stiffness

-

number

-

Yes

-

Stiffness.

-

damping

-

number

-

Yes

-

Damping.

-
- -- Return values - - Curve object. - - -## Example +- Parameters + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | velocity | number | Yes | Initial velocity. | + | mass | number | Yes | Mass. | + | stiffness | number | Yes | Stiffness. | + | damping | number | Yes | Damping. | + +- Return values + Curve object. + + +## Example + + ``` import Curves from '@ohos.curves' let curve1 = Curves.init() // Create a default linear interpolation curve. @@ -240,36 +104,25 @@ let curve3 = Curves.spring(100, 1, 228, 30) // Create a spring interpolation cur let curve3 = Curves.cubicBezier(0.1, 0.0, 0.1, 1.0) // Create a third-order Bezier curve. ``` -Curve objects can be created only by the preceding APIs. - - - - - - - - - -

API

-

Description

-

interpolate(time: number): number

-

Calculation function of the interpolation curve. Passing a normalized time parameter to this function returns the current interpolation.

-

time: indicates the current normalized time. The value ranges from 0 to 1.

-

The curve interpolation corresponding to the normalized time point is returned.

-
+ Curve objects can be created only by the preceding APIs. + | API | Description | +| -------- | -------- | +| interpolate(time: number): number | Calculation function of the interpolation curve. Passing a normalized time parameter to this function returns the current interpolation.
**time**: indicates the current normalized time. The value ranges from 0 to 1.
The curve interpolation corresponding to the normalized time point is returned. | -- Example - ``` - import Curves from '@ohos.curves' - let curve = Curves.init(Curve.EaseIn) // Create an interpolation curve which is slow and then fast by default. - let value: number = curve.interpolate(0.5) // Calculate the interpolation for half of the time. - ``` +- Example + + ``` + import Curves from '@ohos.curves' + let curve = Curves.init(Curve.EaseIn) // Create an interpolation curve which is slow and then fast by default. + let value: number = curve.interpolate(0.5) // Calculate the interpolation for half of the time. + ``` -## Example +## Example + ``` import Curves from '@ohos.curves' @Entry @@ -295,5 +148,4 @@ struct ImageComponent { } ``` -![](figures/5.gif) - +![en-us_image_0000001212058456](figures/en-us_image_0000001212058456.gif) diff --git a/en/application-dev/reference/arkui-ts/ts-matrix-transformation.md b/en/application-dev/reference/arkui-ts/ts-matrix-transformation.md index 77a42705ada3f14e5643a702156db3fb87afa7a2..0b441459e0459dc0a6f9466a1f3d16a1531f766c 100644 --- a/en/application-dev/reference/arkui-ts/ts-matrix-transformation.md +++ b/en/application-dev/reference/arkui-ts/ts-matrix-transformation.md @@ -1,860 +1,377 @@ -# Matrix Transformation +# Matrix Transformation ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->This animation is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -## Modules to Import +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** +> This animation is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. + + +## Modules to Import + ``` import matrix4 from '@ohos.matrix4' ``` -## Required Permissions + +## Required Permissions None -## matrix4.init -init\(array: Array\): Object +## matrix4.init + +init(array: Array<number>): Object + Matrix constructor, which is used to create a 4x4 matrix by using the input parameter. Column-major order is used. -- Parameters - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

array

-

Array<number>

-

Yes

-

[1, 0, 0, 0,

-

0, 1, 0, 0,

-

0, 0, 1, 0,

-

0, 0, 0, 1]

-

A number array whose length is 16 (4 x 4). For details, see the parameter description.

-
- -- Return values - - - - - - - - - - -

Type

-

Description

-

Object

-

4x4 matrix object created based on the input parameter.

-
- -- Parameter description - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

m00

-

number

-

Yes

-

Scaling value of the x-axis. Defaults to 1 for the unit matrix.

-

m01

-

number

-

Yes

-

The second value, which is affected by the rotation of the x, y, and z axes.

-

m02

-

number

-

Yes

-

The third value, which is affected by the rotation of the x, y, and z axes.

-

m03

-

number

-

Yes

-

Meaningless.

-

m10

-

number

-

Yes

-

The fifth value, which is affected by the rotation of the x, y, and z axes.

-

m11

-

number

-

Yes

-

Scaling value of the y-axis. Defaults to 1 for the unit matrix.

-

m12

-

number

-

Yes

-

The seventh value, which is affected by the rotation of the x, y, and z axes.

-

m13

-

number

-

Yes

-

Meaningless.

-

m20

-

number

-

Yes

-

The ninth value, which is affected by the rotation of the x, y, and z axes.

-

m21

-

number

-

Yes

-

The tenth value, which is affected by the rotation of the x, y, and z axes.

-

m22

-

number

-

Yes

-

Scaling value of the z-axis. Defaults to 1 for the unit matrix.

-

m23

-

number

-

Yes

-

Meaningless.

-

m30

-

number

-

Yes

-

Translation value of the x-axis, in px. Defaults to 0 for the unit matrix.

-

m31

-

number

-

Yes

-

Translation value of the y-axis, in px. Defaults to 0 for the unit matrix.

-

m32

-

number

-

Yes

-

Translation value of the z-axis, in px. Defaults to 0 for the unit matrix.

-

m33

-

number

-

Yes

-

Valid in homogeneous coordinates, presenting the perspective projection effect.

-
- -- Example - - ``` - import Matrix4 from '@ohos.matrix4' - // Create a 4x4 matrix. - let matrix = Matrix4.init([1.0, 0.0, 0.0, 0.0, - 0.0, 1.0, 0.0, 0.0, - 0.0, 0.0, 1.0, 0.0, - 0.0, 0.0, 0.0, 1.0]) - ``` - - -## matrix4.identity - -identity\(\): Object + +- Parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | array | Array<number> | Yes | [1, 0, 0, 0,
0, 1, 0, 0,
0, 0, 1, 0,
0, 0, 0, 1] | A number array whose length is 16 (4 x 4). For details, see the parameter description. | + +- Return values + | Type | Description | + | -------- | -------- | + | Object | 4x4 matrix object created based on the input parameter. | + +- Parameter description + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | m00 | number | Yes | Scaling value of the x-axis. Defaults to **1** for the unit matrix. | + | m01 | number | Yes | The second value, which is affected by the rotation of the x, y, and z axes. | + | m02 | number | Yes | The third value, which is affected by the rotation of the x, y, and z axes. | + | m03 | number | Yes | Meaningless. | + | m10 | number | Yes | The fifth value, which is affected by the rotation of the x, y, and z axes. | + | m11 | number | Yes | Scaling value of the y-axis. Defaults to **1** for the unit matrix. | + | m12 | number | Yes | The seventh value, which is affected by the rotation of the x, y, and z axes. | + | m13 | number | Yes | Meaningless. | + | m20 | number | Yes | The ninth value, which is affected by the rotation of the x, y, and z axes. | + | m21 | number | Yes | The tenth value, which is affected by the rotation of the x, y, and z axes. | + | m22 | number | Yes | Scaling value of the z-axis. Defaults to **1** for the unit matrix. | + | m23 | number | Yes | Meaningless. | + | m30 | number | Yes | Translation value of the x-axis, in px. Defaults to **0** for the unit matrix. | + | m31 | number | Yes | Translation value of the y-axis, in px. Defaults to **0** for the unit matrix. | + | m32 | number | Yes | Translation value of the z-axis, in px. Defaults to **0** for the unit matrix. | + | m33 | number | Yes | Valid in homogeneous coordinates, presenting the perspective projection effect. | + +- Example + + ``` + import Matrix4 from '@ohos.matrix4' + // Create a 4x4 matrix. + let matrix = Matrix4.init([1.0, 0.0, 0.0, 0.0, + 0.0, 1.0, 0.0, 0.0, + 0.0, 0.0, 1.0, 0.0, + 0.0, 0.0, 0.0, 1.0]) + ``` + + +## matrix4.identity + +identity(): Object + Matrix initialization function. Can return a unit matrix object. -- Return values - - - - - - - - - -

Type

-

Description

-

Object

-

Unit matrix object.

-
+- Return values + | Type | Description | + | -------- | -------- | + | Object | Unit matrix object. | -- Example +- Example + + ``` + // The effect of matrix 1 is the same as that of matrix 2. + import Matrix4 from '@ohos.matrix4' + let matrix = Matrix4.init([1.0, 0.0, 0.0, 0.0, + 0.0, 1.0, 0.0, 0.0, + 0.0, 0.0, 1.0, 0.0, + 0.0, 0.0, 0.0, 1.0]) + let matrix2 = Matrix4.identity() + ``` - ``` - // The effect of matrix 1 is the same as that of matrix 2. - import Matrix4 from '@ohos.matrix4' - let matrix = Matrix4.init([1.0, 0.0, 0.0, 0.0, - 0.0, 1.0, 0.0, 0.0, - 0.0, 0.0, 1.0, 0.0, - 0.0, 0.0, 0.0, 1.0]) - let matrix2 = Matrix4.identity() - ``` +## matrix4.copy -## matrix4.copy +copy(): Object -copy\(\): Object Matrix copy function, which is used to copy the current matrix object. -- Return values - - - - - - - - - - -

Type

-

Description

-

Object

-

Copy object of the current matrix.

-
- -- Example - - ``` - import Matrix4 from '@ohos.matrix4' - @Entry - @Component - struct Test { - private matrix1 = Matrix4.identity().translate({x:100}) - private matrix2 = this.matrix1.copy().scale({x:2}) - build() { - Column() { - Image($r("app.media.bg1")) - .width("40%") - .height(100) - .transform(this.matrix1) - Image($r("app.media.bg2")) - .width("40%") - .height(100) - .margin({top:50}) - .transform(this.matrix2) - } + +- Return values + | Type | Description | + | -------- | -------- | + | Object | Copy object of the current matrix. | + +- Example + + ``` + import Matrix4 from '@ohos.matrix4' + @Entry + @Component + struct Test { + private matrix1 = Matrix4.identity().translate({x:100}) + private matrix2 = this.matrix1.copy().scale({x:2}) + build() { + Column() { + Image($r("app.media.bg1")) + .width("40%") + .height(100) + .transform(this.matrix1) + Image($r("app.media.bg2")) + .width("40%") + .height(100) + .margin({top:50}) + .transform(this.matrix2) } } - ``` + } + ``` - ![](figures/s1.png) + ![en-us_image_0000001256858419](figures/en-us_image_0000001256858419.png) -## Matrix4 +## Matrix4 -### combine -combine\(matrix: Matrix4\): Object +### combine + +combine(matrix: Matrix4): Object + Matrix overlay function, which is used to overlay the effects of two matrices to generate a new matrix object. -- Parameters - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

matrix

-

Matrix4

-

Yes

-

-

-

Matrix object to be overlaid.

-
- -- Return values - - - - - - - - - - -

Type

-

Description

-

Object

-

Object after matrix overlay.

-
- -- Example - - ``` - import Matrix4 from '@ohos.matrix4' - @Entry - @Component - struct Test { - private matrix1 = Matrix4.identity().translate({x:200}).copy() - private matrix2 = Matrix4.identity().scale({x:2}).copy() - build() { - Column() { - // Translate the x-axis by 100 pixels and then scale it up or down by 2x. - Image($r("app.media.bg1")).transform(this.matrix1.combine(this.matrix2)) - .width("40%") - .height(100) - .margin({top:50}) - } + +- Parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | matrix | Matrix4 | Yes | - | Matrix object to be overlaid. | + +- Return values + | Type | Description | + | -------- | -------- | + | Object | Object after matrix overlay. | + +- Example + + ``` + import Matrix4 from '@ohos.matrix4' + @Entry + @Component + struct Test { + private matrix1 = Matrix4.identity().translate({x:200}).copy() + private matrix2 = Matrix4.identity().scale({x:2}).copy() + build() { + Column() { + // Translate the x-axis by 100 pixels and then scale it up or down by 2x. + Image($r("app.media.bg1")).transform(this.matrix1.combine(this.matrix2)) + .width("40%") + .height(100) + .margin({top:50}) } } - ``` + } + ``` - ![](figures/q1.png) + ![en-us_image_0000001212378428](figures/en-us_image_0000001212378428.png) -### invert +### invert + +invert(): Object -invert\(\): Object Matrix inverse function. Can return an inverse matrix of the current matrix object, that is, get an opposite effect. -- Return values - - - - - - - - - -

Type

-

Description

-

Object

-

Inverse matrix object of the current matrix.

-
+- Return values + | Type | Description | + | -------- | -------- | + | Object | Inverse matrix object of the current matrix. | -- Example +- Example + + ``` + import Matrix4 from '@ohos.matrix4' + // The effect of matrix 1 (width scaled up by 2x) is opposite to that of matrix 2 (width scaled down by 2x). + let matrix1 = Matrix4.identity().scale({x:2}) + let matrix2 = matrix1.invert() + ``` - ``` - import Matrix4 from '@ohos.matrix4' - // The effect of matrix 1 (width scaled up by 2x) is opposite to that of matrix 2 (width scaled down by 2x). - let matrix1 = Matrix4.identity().scale({x:2}) - let matrix2 = matrix1.invert() - ``` +### translate -### translate +translate({x?: number, y?: number, z?: number}): Object -translate\(\{x?: number, y?: number, z?: number\}\): Object Matrix translation function, which is used to add the translation effect to the x, y, and z axes of the current matrix. -- Parameters - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

x

-

number

-

No

-

0

-

Translation distance of the x-axis, in px.

-

y

-

number

-

No

-

0

-

Translation distance of the y-axis, in px.

-

z

-

number

-

No

-

0

-

Translation distance of the z-axis, in px.

-
- - -- Return values - - - - - - - - - - -

Type

-

Description

-

Object

-

Matrix object after the translation effect is added.

-
- -- Example - - ``` - import Matrix4 from '@ohos.matrix4' - @Entry - @Component - struct Test { - private matrix1 = Matrix4.identity().translate({x:100, y:200, z:30}) - build() { - Column() { - Image($r("app.media.bg1")).transform(this.matrix1) - .width("40%") - .height(100) - } + +- Parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | x | number | No | 0 | Translation distance of the x-axis, in px. | + | y | number | No | 0 | Translation distance of the y-axis, in px. | + | z | number | No | 0 | Translation distance of the z-axis, in px. | + + +- Return values + | Type | Description | + | -------- | -------- | + | Object | Matrix object after the translation effect is added. | + +- Example + + ``` + import Matrix4 from '@ohos.matrix4' + @Entry + @Component + struct Test { + private matrix1 = Matrix4.identity().translate({x:100, y:200, z:30}) + build() { + Column() { + Image($r("app.media.bg1")).transform(this.matrix1) + .width("40%") + .height(100) } } - ``` + } + ``` + + ![en-us_image_0000001212058494](figures/en-us_image_0000001212058494.png) - ![](figures/s3.png) +### scale -### scale +scale({x?: number, y?: number, z?: number, centerX?: number, centerY?: number}): Object -scale\(\{x?: number, y?: number, z?: number, centerX?: number, centerY?: number\}\): Object Matrix scaling function, which is used to add the scaling effect to the x, y, and z axes of the current matrix. -- Parameters - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

x

-

number

-

No

-

1

-

Scaling multiple of the x-axis.

-

y

-

number

-

No

-

1

-

Scaling multiple of the y-axis.

-

z

-

number

-

No

-

1

-

Scaling multiple of the z-axis.

-

centerX

-

number

-

No

-

0

-

X coordinate of the center point.

-

centerY

-

number

-

No

-

0

-

Y coordinate of the center point.

-
- - -- Return values - - - - - - - - - - -

Type

-

Description

-

Object

-

Matrix object after the scaling effect is added.

-
- -- Example - - ``` - import Matrix4 from '@ohos.matrix4' - @Entry - @Component - struct Test { - private matrix1 = Matrix4.identity().scale({x:2, y:3, z:4, centerX:50, centerY:50}) - build() { - Column() { - Image($r("app.media.bg1")).transform(this.matrix1) - .width("40%") - .height(100) - } + +- Parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | x | number | No | 1 | Scaling multiple of the x-axis. | + | y | number | No | 1 | Scaling multiple of the y-axis. | + | z | number | No | 1 | Scaling multiple of the z-axis. | + | centerX | number | No | 0 | X coordinate of the center point. | + | centerY | number | No | 0 | Y coordinate of the center point. | + + +- Return values + | Type | Description | + | -------- | -------- | + | Object | Matrix object after the scaling effect is added. | + +- Example + + ``` + import Matrix4 from '@ohos.matrix4' + @Entry + @Component + struct Test { + private matrix1 = Matrix4.identity().scale({x:2, y:3, z:4, centerX:50, centerY:50}) + build() { + Column() { + Image($r("app.media.bg1")).transform(this.matrix1) + .width("40%") + .height(100) } } - ``` + } + ``` + + ![en-us_image_0000001256978367](figures/en-us_image_0000001256978367.png) - ![](figures/s4-(1).png) +### rotate -### rotate +rotate({x?: number, y?: number, z?: number, angle?: number, centerX?: Length, centerY?: Length}): Object -rotate\(\{x?: number, y?: number, z?: number, angle?: number, centerX?: Length, centerY?: Length\}\): Object Matrix rotation function, which is used to add the rotation effect to the x, y, and z axes of the current matrix. -- Parameters - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

x

-

number

-

No

-

1

-

X coordinate of the rotation axis vector.

-

y

-

number

-

No

-

1

-

Y coordinate of the rotation axis vector.

-

z

-

number

-

No

-

1

-

Z coordinate of the rotation axis vector.

-

angle

-

number

-

No

-

0

-

Rotation angle.

-

centerX

-

number

-

No

-

0

-

X coordinate of the center point.

-

centerY

-

number

-

No

-

0

-

Y coordinate of the center point.

-
- - -- Return values - - - - - - - - - - -

Type

-

Description

-

Object

-

Matrix object after the rotation effect is added.

-
- -- Example - - ``` - import Matrix4 from '@ohos.matrix4' - @Entry - @Component - struct Test { - private matrix1 = Matrix4.identity().rotate({x:1, y:1, z:2, angle:30}) - build() { - Column() { - Image($r("app.media.bg1")).transform(this.matrix1) - .width("40%") - .height(100) - }.width("100%").margin({top:50}) - } + +- Parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | x | number | No | 1 | X coordinate of the rotation axis vector. | + | y | number | No | 1 | Y coordinate of the rotation axis vector. | + | z | number | No | 1 | Z coordinate of the rotation axis vector. | + | angle | number | No | 0 | Rotation angle. | + | centerX | number | No | 0 | X coordinate of the center point. | + | centerY | number | No | 0 | Y coordinate of the center point. | + + +- Return values + | Type | Description | + | -------- | -------- | + | Object | Matrix object after the rotation effect is added. | + +- Example + + ``` + import Matrix4 from '@ohos.matrix4' + @Entry + @Component + struct Test { + private matrix1 = Matrix4.identity().rotate({x:1, y:1, z:2, angle:30}) + build() { + Column() { + Image($r("app.media.bg1")).transform(this.matrix1) + .width("40%") + .height(100) + }.width("100%").margin({top:50}) } - ``` + } + ``` - ![](figures/1.png) + ![en-us_image_0000001211898504](figures/en-us_image_0000001211898504.png) -### transformPoint +### transformPoint -transformPoint\(point: Point\): Point +transformPoint(point: Point): Point -Matrix point transformation function, which is used to apply the current transformation effect to a coordinate point. -- Parameters - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

point

-

Point

-

Yes

-

-

-

Point to be transformed.

-
- - -- Return values - - - - - - - - - - -

Type

-

Description

-

Point

-

Point object after matrix transformation

-
- -- Example - - ``` - import Matrix4 from '@ohos.matrix4' - import prompt from '@system.prompt' - - @Entry - @Component - struct Test { - private matrix1 = Matrix4.identity().transformPoint([100, 10]) - build() { - Column() { - Button("get Point") - .onClick(() => { - prompt.showToast({message:JSON.stringify(this.matrix1),duration:2000}) - }).backgroundColor(0x2788D9) - }.width("100%").padding(50) - } - } - ``` +Matrix point transformation function, which is used to apply the current transformation effect to a coordinate point. - ![](figures/222.gif) +- Parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | point | Point | Yes | - | Point to be transformed. | + + +- Return values + | Type | Description | + | -------- | -------- | + | Point | Point object after matrix transformation | + +- Example + + ``` + import Matrix4 from '@ohos.matrix4' + import prompt from '@system.prompt' + + @Entry + @Component + struct Test { + private matrix1 = Matrix4.identity().transformPoint([100, 10]) + build() { + Column() { + Button("get Point") + .onClick(() => { + prompt.showToast({message:JSON.stringify(this.matrix1),duration:2000}) + }).backgroundColor(0x2788D9) + }.width("100%").padding(50) + } + } + ``` + ![en-us_image_0000001212218464](figures/en-us_image_0000001212218464.gif) diff --git a/en/application-dev/reference/arkui-ts/ts-media-components-video.md b/en/application-dev/reference/arkui-ts/ts-media-components-video.md new file mode 100644 index 0000000000000000000000000000000000000000..c00ac70de9b3ff1dfd321b41c92655826224b8de --- /dev/null +++ b/en/application-dev/reference/arkui-ts/ts-media-components-video.md @@ -0,0 +1,174 @@ +# Video + + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** +> This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. + + +The **<Video>** component provides a video player. + + +## Child Components + +The **<Video>** component does not support any child component. + + +## APIs + +Video(value: VideoOption) + +- VideoOption attributes + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | src | string | No | - | Path of the video source. | + | currentProgressRate | number \| PlaybackSpeed8+ | No | 1.0 \| PlaybackSpeed.Speed_Forward_1_00_X | Video playback speed.
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:**
> The value of the number type can only be **0.75**, **1.0**, **1.25**, **1.75**, or **2.0**.

>  | + | previewUri | string \| PixelMap8+ \|[Resource](../../ui/ts-types.md) | No | - | Path of the preview image. | + | controller | [VideoController](#videocontroller) | No | - | Controller. | + + +- PlaybackSpeed8+ + | Name | Description | + | -------- | -------- | + | Speed_Forward_0_75_X | 0.75x playback speed. | + | Speed_Forward_1_00_X | 1x playback speed. | + | Speed_Forward_1_25_X | 1.25x playback speed. | + | Speed_Forward_1_75_X | 1.75x playback speed. | + | Speed_Forward_2_00_X | 2x playback speed. | + + +## Attributes + +| Name | Type | Default Value | Description | +| -------- | -------- | -------- | -------- | +| muted | boolean | false | Whether the video is muted. | +| autoPlay | boolean | false | Whether the video is automatically played. | +| controls | boolean | true | Whether the video playback control bar is displayed. | +| objectFit | [ImageFit](ts-basic-components-image.md) | Cover | Video display mode. | +| loop | boolean | false | Whether a single video is played cyclically. | + + +## Events + + | Name | Description | +| -------- | -------- | +| onStart() => void | Triggered when the video is played. | +| onPause() => void | Triggered when the video playback is paused. | +| onFinish() => void | Triggered when the video playback is finished. | +| onError() => void | Triggered when the video playback fails. | +| onPrepared(event?: { duration: number }) => void | Triggered when video preparation is complete. The video duration (in seconds) is obtained from **duration**. | +| onSeeking(event?: { time: number }) => void | Triggered to report the time (in seconds) when the progress bar is being dragged. | +| onSeeked(event?: { time: number }) => void | Triggered to report the playback time (in seconds) when the user finishes dragging the progress bar. | +| onUpdate(event?: { time: number }) => void | Triggered once per 250 ms when the playback progress changes. The unit of the current playback time is second. | + + +### VideoController + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** +> A **VideoController** object can control one or more videos. + + | Name | Description | +| -------- | -------- | +| start() : void | Starts playback. | +| pause() : void | Pauses playback. | +| stop() : void | Stops playback. | +| setCurrentTime(value: number) | Sets the video playback position. | +| setCurrentTime(value: number, seekMode: SeekMode)8+ | Sets the video playback position with the specified seek mode. | + +- SeekMode8+ + | Name | Description | + | -------- | -------- | + | PreviousKeyframe | Seeks to the nearest previous keyframe. | + | NextKeyframe | Seeks to the nearest next keyframe. | + | ClosestKeyframe | Seeks to the nearest keyframe. | + | Accurate | Seeks to a specific frame, regardless of whether the frame is a keyframe. | + + +## Example + + +``` +@Entry +@Component +struct VideoCreateComponent { + @State srcs: string = "/resources/video/video1.mp4"; + @State previewUris: string = "/resources/image/media.JPG"; + @State currentProgressRates: number = 1; + @State autoPlays: boolean = false; + @State controlsss: boolean = true; + myVideoController: VideoController = new VideoController(); + @State startStaus: boolean = true; + build() { + Column() { + Video({ + src: this.srcs, + previewUri: this.previewUris, + currentProgressRate: this.currentProgressRates, + controller: this.myVideoController + }).width(700).height(500) + .autoPlay(this.autoPlays) + .controls(this.controlsss) + .onStart(() => { + console.error('onStart'); + }) + .onPause(() => { + console.error('onPause'); + }) + .onFinish(() => { + console.error('onFinish'); + }) + .onError(() => { + console.error('onFinish'); + }) + .onPrepared((e) => { + console.error('onPrepared is ' + e.duration); + }) + .onSeeking((e) => { + console.error('onSeeking is ' + e.time); + }) + .onSeeked((e) => { + console.error('onSeekedis ' + e.time); + }) + .onUpdate((e) => { + console.error('onUpdateis ' + e.time); + }) + Row() { + Button("src").onClick(() => { + if (this.srcs == "/resources/video/video1.mp4") { + this.srcs = "/resources/video/video2.mp4"; + } else { + this.srcs = "/resources/video/video1.mp4"; + } + }); + Button("previewUri").onClick(() => { + if (this.previewUris == "/resources/image/media.JPG") { + this.previewUris = "/resources/image/sinlin.png"; + } else { + this.previewUris = "/resources/image/media.JPG"; + } + }); + Button("controlsss").onClick(() => { + this.controlsss = !this.controlsss; + }); + } + + Row() { + Button("start").onClick(() => { + this.myVideoController.start(); + }); + Button("pause").onClick(() => { + this.myVideoController.pause(); + }); + Button("stop").onClick(() => { + this.myVideoController.stop(); + }); + } + + Row() { + Button("setCurrentTime").onClick(() => { + this.myVideoController.setCurrentTime(9, SeekMode.Accurate); + }); + } + } + } +} +``` diff --git a/en/application-dev/reference/arkui-ts/ts-media-components.md b/en/application-dev/reference/arkui-ts/ts-media-components.md new file mode 100644 index 0000000000000000000000000000000000000000..51006bbc82a83d001c68a55c5246f8642479027d --- /dev/null +++ b/en/application-dev/reference/arkui-ts/ts-media-components.md @@ -0,0 +1,5 @@ +# Media Components + + + +- **[Video](ts-media-components-video.md)** \ No newline at end of file diff --git a/en/application-dev/reference/arkui-ts/ts-methods-action-sheet.md b/en/application-dev/reference/arkui-ts/ts-methods-action-sheet.md index cce4ea2419a5062a6139d714c5e7c74e8f606bf0..8140b6010e17a2c3e5a271bfbb45778933b3fed2 100644 --- a/en/application-dev/reference/arkui-ts/ts-methods-action-sheet.md +++ b/en/application-dev/reference/arkui-ts/ts-methods-action-sheet.md @@ -1,190 +1,48 @@ -# List Selection Dialog Box +# Action Sheet ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->This component is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version. -List pop-up window. +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** +> This component is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version. -## Required Permissions + +An action sheet is a dialog box that displays actions a user can take. + + +## Required Permissions None -## ActionSheet.show - -show\(options: \{ [paramObject1](#table816913216616)\}\) - -Defines and shows the list popup window. - -- paramObject1 parameters - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

title

-

string

-

No

-

None

-

Title of the dialog box.

-

message

-

string

-

Yes

-

-

-

Content of the dialog box.

-

autoCancel

-

boolean

-

No

-

true

-

Whether to close the dialog box when the overlay is clicked.

-

confirm

-

{

-

value: string,

-

action: () => void

-

}

-

No

-

-

-

Text content of the confirm button and callback upon button clicking.

-

value: button text.

-

action: callback upon button clicking.

-

cancel

-

() => void

-

No

-

-

-

Callback invoked when the dialog box is closed after the overlay is clicked.

-

alignment

-

DialogAlignment

-

No

-

DialogAlignment.Default

-

Alignment mode of the dialog box in the vertical direction.

-

offset

-

{

-

dx: Length,

-

dy: Length

-

}

-

No

-

{

-

dx: 0,

-

dy: 0

-

}

-

Offset of the dialog box relative to the alignment position.

-

sheets

-

Array<SheetInfo>

-

Yes

-

-

-

Options in the dialog box. Each option supports the image, text, and callback.

-
- -- SheetInfo parameters - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

title

-

string

-

Yes

-

-

-

Sheet text.

-

icon

-

string

-

No

-

None

-

Sheet icon.

-

action

-

()=>void

-

Yes

-

-

-

Callback when the sheet is selected.

-
- - -## Example + +## ActionSheet.show + +show(options: { paramObject1}) + +Defines and shows the action sheet. + +- paramObject1 parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | title | string \|[Resource](../../ui/ts-types.md#resource) | No | None | Title of the dialog box. | + | message | string \|[Resource](../../ui/ts-types.md#resource) | | | Content of the dialog box. | + | autoCancel | boolean | No | true | Whether to close the dialog box when the overlay is clicked. | + | confirm | {
value: string \|[Resource](../../ui/ts-types.md#resource),
action: () => void
} | number | string | Text content of the confirm button and callback upon button clicking.
**value**: button text.
**action**: callback upon button clicking. | + | cancel | () => void | No | - | Callback invoked when the dialog box is closed after the overlay is clicked. | + | alignment | DialogAlignment | No | DialogAlignment.Default | Alignment mode of the dialog box in the vertical direction. | + | offset | {
dx: Length\|[Resource](../../ui/ts-types.md#resource)
dy: Length\|[Resource](../../ui/ts-types.md#resource)
} | No | - | Offset of the dialog box relative to the alignment position. | + | sheets | Array<SheetInfo> | Yes | - | Options in the dialog box. Each option supports the image, text, and callback. | + +- SheetInfo parameters + | | | | | | + | -------- | -------- | -------- | -------- | -------- | + | Name | Type | Mandatory | Default Value | Description | + | title | string | Yes | - | Sheet text. | + | icon | string | No | None | Sheet icon. | + | action | ()=>void | Yes | - | Callback when the sheet is selected. | + + +## Example + + ``` @Entry @@ -231,5 +89,6 @@ struct ActionSheetExapmle { } ``` -![](figures/en-us_image_0000001201475612.gif) + +![en-us_image_0000001212058508](figures/en-us_image_0000001212058508.gif) diff --git a/en/application-dev/reference/arkui-ts/ts-methods-alert-dialog-box.md b/en/application-dev/reference/arkui-ts/ts-methods-alert-dialog-box.md index b5ce18d87c65bd9e182c7e127cfce6b653778d9a..fd9f05f595923840ffb8cdc47b398e795919bb65 100644 --- a/en/application-dev/reference/arkui-ts/ts-methods-alert-dialog-box.md +++ b/en/application-dev/reference/arkui-ts/ts-methods-alert-dialog-box.md @@ -1,283 +1,47 @@ -# Alert Dialog Box +# Alert Dialog Box ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->This method is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -You can set the text content and response callback for an alert dialog box. +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** +> This method is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. + -## Attributes +You can set the text content and response callback for an alert dialog box. - - - - - - - - - - - - - -

Name

-

Type

-

Default Value

-

Description

-

show

-

options: { paramObject1| paramObject2}

-

-

-

Defines and displays the <AlertDialog> component.

-
-- paramObject1 parameters +## Attributes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

title

-

string | Resource

-

No

-

-

-

Title of a dialog box.

-

message

-

string | Resource

-

Yes

-

-

-

Content of the dialog box.

-

autoCancel

-

boolean

-

No

-

true

-

Whether to close the dialog box when the overlay is clicked.

-

confirm

-

{

-

value: string | Resource,

-

fontColor?: Color | number | string | Resource,

-

backgroundColor?: Color | number | string | Resource,

-

action: () => void

-

}

-

No

-

-

-

Text content, text color, background color, and click callback of the confirm button.

-

cancel

-

() => void

-

No

-

-

-

Callback invoked when the dialog box is closed after the overlay is clicked.

-

alignment

-

DialogAlignment

-

No

-

DialogAlignment.Default

-

Alignment mode of the dialog box in the vertical direction.

-

offset

-

{

-

dx: Length | Resource,

-

dy: Length | Resource

-

}

-

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.

-
+ | Name | Type | Default Value | Description | +| -------- | -------- | -------- | -------- | +| show | options: { paramObject1\| paramObject2} | - | Defines and displays the **<AlertDialog>** component. | +- paramObject1 parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | title | string \|[Resource](../../ui/ts-types.md#resource) | | | Title of a dialog box. | + | message | string \|[Resource](../../ui/ts-types.md#resource) | | | Content of the dialog box. | + | autoCancel | boolean | No | true | Whether to close the dialog box when the overlay is clicked. | + | confirm | {
value: string \|[Resource](../../ui/ts-types.md#resource),
fontColor?: Color\|number \|string \|[Resource](../../ui/ts-types.md#resource),
backgroundColor?:Color \|number\|string\|[Resource](../../ui/ts-types.md#resource),
action: () => void
}
| | | Text content, text color, background color, and click callback of the confirm button. | + | cancel | () => void | No | - | Callback invoked when the dialog box is closed after the overlay is clicked. | + | alignment | DialogAlignment | No | DialogAlignment.Default | Alignment mode of the dialog box in the vertical direction. | + | offset | {
dx: Length \|[Resource](../../ui/ts-types.md#resource),
dy: Length  \|[Resource](../../ui/ts-types.md#resource)
} | | | 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. | -- paramObject2 parameters +- paramObject2 parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | title | string \|[Resource](../../ui/ts-types.md#resource) | No | - | Title of a dialog box. | + | message | string \|[Resource](../../ui/ts-types.md#resource) | Yes | - | Content of the dialog box. | + | autoCancel | boolean | No | true | Whether to close the dialog box when the overlay is clicked. | + | primaryButton | {
value: string \|[Resource](../../ui/ts-types.md#resource),
fontColor?: Color\|number \|string \|[Resource](../../ui/ts-types.md#resource),
backgroundColor?:Color \|number\|string\|[Resource](../../ui/ts-types.md#resource),
action: () => void
}
| | | Text content, text color, background color, and click callback of the primary button. | + | secondaryButton | {
value: string \|[Resource](../../ui/ts-types.md#resource),
fontColor?: Color\|number \|string \|[Resource](../../ui/ts-types.md#resource),
backgroundColor?:Color \|number\|string\|[Resource](../../ui/ts-types.md#resource),
action: () => void
}
| | | Text content, text color, background color, and click callback of the secondary button. | + | cancel | () => void | No | - | Callback invoked when the dialog box is closed after the overlay is clicked. | + | alignment | DialogAlignment | No | DialogAlignment.Default | Alignment mode of the dialog box in the vertical direction. | + | offset | {
dx: Length \|[Resource](../../ui/ts-types.md#resource),
dy: Length  \|[Resource](../../ui/ts-types.md#resource)
} | | | 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. | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

title

-

string | Resource

-

No

-

-

-

Title of a dialog box.

-

message

-

string | Resource

-

Yes

-

-

-

Content of the dialog box.

-

autoCancel

-

boolean

-

No

-

true

-

Whether to close the dialog box when the overlay is clicked.

-

primaryButton

-

{

-

value: string | Resource,

-

fontColor?: Color | number | string | Resource,

-

backgroundColor?: Color | number | string | Resource,

-

action: () => void;

-

}

-

No

-

-

-

Text content, text color, background color, and click callback of the primary button.

-

secondaryButton

-

-

{

-

value: string | Resource,

-

fontColor?: Color | number | string | Resource,

-

backgroundColor?: Color | number | string | Resource,

-

action: () => void;

-

}

-

No

-

-

-

Text content, text color, background color, and click callback of the secondary button.

-

cancel

-

() => void

-

No

-

-

-

Callback invoked when the dialog box is closed after the overlay is clicked.

-

alignment

-

DialogAlignment

-

No

-

DialogAlignment.Default

-

Alignment mode of the dialog box in the vertical direction.

-

offset

-

{

-

dx: Length | Resource,

-

dy: Length | Resource

-

}

-

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.

-
+## Example -## Example ``` @Entry @@ -333,5 +97,4 @@ struct AlertDialogExample { } ``` -![](figures/alertdialog.gif) - +![en-us_image_0000001256978387](figures/en-us_image_0000001256978387.gif) diff --git a/en/application-dev/reference/arkui-ts/ts-methods-custom-dialog-box.md b/en/application-dev/reference/arkui-ts/ts-methods-custom-dialog-box.md index 67e355e76b1b4e501a3c197ef270026f78ee4203..85d09336c4b500251fc8226a99e1ae7e1bc4f391 100644 --- a/en/application-dev/reference/arkui-ts/ts-methods-custom-dialog-box.md +++ b/en/application-dev/reference/arkui-ts/ts-methods-custom-dialog-box.md @@ -1,151 +1,71 @@ -# Custom Dialog box - ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->This method is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. - -The **CustomDialogController** class is used to display a custom dialog box. - -## APIs - -CustomDialogController\(value:\{builder: CustomDialog, cancel?: \(\) =\> void, autoCancel?: boolean\}\) - -- Parameters - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

builder

-

CustomDialog

-

Yes

-

-

-

Constructor of the custom dialog box content.

-

cancel

-

() => void

-

No

-

-

-

Callback invoked when the dialog box is closed after the overlay exits.

-

autoCancel

-

boolean

-

No

-

true

-

Whether to allow users to click the overlay to exit.

-

alignment

-

DialogAlignment

-

No

-

DialogAlignment.Default

-

Alignment mode of the dialog box in the vertical direction.

-

offset

-

{

-

dx: Length | Resource,

-

dy: Length | Resource

-

}

-

No

-

-

-

Offset of the dialog box relative to the alignment position.

-

customStyle

-

boolean

-

No

-

false

-

Whether the style of the dialog box is customized.

-
- -- DialogAlignment enums - - - - - - - - - - - - - - - - - - - -

Name

-

Description

-

Top

-

Aligns vertically to the top.

-

Center

-

Aligns vertically to the middle.

-

Bottom

-

Aligns vertically to the bottom.

-

Default

-

Default alignment.

-
- - -### CustomDialogController - -Creates an object. +# Custom Dialog Box + + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** +> This method is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. + + +The **CustomDialogController** class is used to display a custom dialog box. + + +## APIs + +CustomDialogController(value:{builder: CustomDialog, cancel?: () => void, autoCancel?: boolean}) + + +- Parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | builder | [CustomDialog](../../ui/ ts-component-based-customdialog.md) | Yes | - | Constructor of the custom dialog box content. | + | cancel | () => void | No | - | Callback invoked when the dialog box is closed after the overlay exits. | + | autoCancel | boolean | No | true | Whether to allow users to click the overlay to exit. | + | alignment | DialogAlignment | No | DialogAlignment.Default | Alignment mode of the dialog box in the vertical direction. | + | offset | {
dx: Length \|[Resource](../../ui/ts-types.md#resource),
dy: Length  \|[Resource](../../ui/ts-types.md#resource)
} | | | Offset of the dialog box relative to the alignment position. | + | customStyle | boolean | No | false | Whether the style of the dialog box is customized. | + +- DialogAlignment enums + | Name | Description | + | -------- | -------- | + | Top | Aligns vertically to the top. | + | Center | Aligns vertically to the middle. | + | Bottom | Aligns vertically to the bottom. | + | Default | Default alignment. | + | TopStart8+ | Top left alignment. | + | TopEnd8+ | Top right alignment. | + | CenterStart8+ | Center left alignment. | + | CenterEnd8+ | Center right alignment. | + | BottomStart8+ | Bottom left alignment. | + | BottomEnd8+ | Bottom right alignment. | + + +### CustomDialogController + + +### Objects to Import + ``` dialogController : CustomDialogController = new CustomDialogController(value:{builder: CustomDialog, cancel?: () => void, autoCancel?: boolean}) ``` -open\(\) + +### dialogController.open + +open(): void + Opens the content of the custom dialog box. If the content has been displayed, this API does not take effect. -close\(\) + +### dialogController.close + +close(): void Closes the custom dialog box. If the dialog box is closed, the setting does not take effect. -## Example + +## Example + ``` @CustomDialog @@ -205,5 +125,4 @@ struct CustomDialogUser { } ``` -![](figures/customdialog.gif) - +![en-us_image_0000001212058470](figures/en-us_image_0000001212058470.gif) diff --git a/en/application-dev/reference/arkui-ts/ts-methods-image-cache.md b/en/application-dev/reference/arkui-ts/ts-methods-image-cache.md index 3075ad66711d30b7768ee95bf8d1357f6e45dbb4..a76ad367d5750f57dc08dfeefec29d0b70b22423 100644 --- a/en/application-dev/reference/arkui-ts/ts-methods-image-cache.md +++ b/en/application-dev/reference/arkui-ts/ts-methods-image-cache.md @@ -1,161 +1,104 @@ -# Image Cache +# Image Cache ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->This method is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -## Modules to Import +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** +> This method is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. + +## Modules to Import + + ``` import app from '@system.app' ``` -## Required Permissions + +## Required Permissions None -## app.setImageCacheCount - -setImageCacheCount\(value: number\): void - -Sets the maximum number of decoded images that can be cached in the memory to speed up the loading of images from the same sources. If the input parameter is not set, the default value **0** is used, indicating that images are not cached. The built-in Least Recently Used \(LRU\) policy is used for caching. After new images are loaded, if the upper limit of the cache is exceeded, the images that have not been updated for the longest time will be replaced. You are advised to set the input parameter based on the application memory requirements. If the number of images is too large, the memory usage may be too high. - -- Parameters - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

value

-

number

-

Yes

-

Number of decoded images that are cached in the memory.

-
- -- Example - - ``` - // app.ets - import app from '@system.app'; - export default { - onCreate() { - app.setImageCacheCount(100) // Set the maximum number of decoded images that can be cached in the memory to 100. - console.info('Application onCreate') - }, - onDestroy() { - console.info('Application onDestroy') - }, - } - ``` - - -## app.setImageRawDataCacheSize - -setImageRawDataCacheSize\(value: number\): void - -Sets the maximum size \(in bytes\) of the image data cached in the memory before decoding to speed up the loading of images from the same sources. If the input parameter is not set, the default value **0** is used, indicating that images are not cached. The LRU policy is used for caching. After new images are loaded, if the upper limit of the cache is exceeded, the images that have not been updated for the longest time will be replaced. You are advised to set the input parameter based on the application memory requirements. If the image cache is too large, the memory usage may be too high. - -- Parameters - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

value

-

number

-

Yes

-

Size of the image data cached before decoding, in bytes.

-
- -- Example - - ``` - // app.ets - import app from '@system.app'; - - export default { - onCreate() { - app.setImageRawDataCacheSize(104,857,600) // Set the upper limit of the memory for caching image data before decoding to 100 MB. - console.info('Application onCreate') - }, - onDestroy() { - console.info('Application onDestroy') - }, - } - ``` - - -## app.setImageFileCacheSize - -setImageFileCacheSize\(value: number\): void - -Sets the maximum size of the image file cache \(in bytes\) to speed up the loading of images from the same sources, especially online image sources and thumbnails. If the input parameter is not set, the default value 100 MB is used. The LRU policy is used for caching. After new images are loaded, if the upper limit of the cache is exceeded, the images that have not been updated for the longest time will be replaced. You are advised to set the input parameter based on the application memory requirements. If the image cache is too large, the disk usage may be too high. - -- Parameters - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

value

-

number

-

Yes

-

Size of the image file cache, in bytes.

-
- -- Example - - ``` - // app.ets - import app from '@system.app'; - - export default { - onCreate() { - app.setImageFileCacheSize(209,715,200) // Set the upper limit of the image file cache to 200 MB. - console.info('Application onCreate') - }, - onDestroy() { - console.info('Application onDestroy') - }, - } - ``` +## app.setImageCacheCount +setImageCacheCount(value: number): void + + Sets the maximum number of decoded images that can be cached in the memory to speed up the loading of images from the same sources. If the input parameter is not set, the default value **0** is used, indicating that images are not cached. The built-in Least Recently Used (LRU) policy is used for caching. After new images are loaded, if the upper limit of the cache is exceeded, the images that have not been updated for the longest time will be replaced. You are advised to set the input parameter based on the application memory requirements. If the number of images is too large, the memory usage may be too high. +- Parameters + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | value | number | Yes | Number of decoded images that are cached in the memory. | + +- Example + + ``` + // app.ets + import app from '@system.app'; + + export default { + onCreate() { + app.setImageCacheCount(100) // Set the maximum number of decoded images that can be cached in the memory to 100. + console.info('Application onCreate') + }, + onDestroy() { + console.info('Application onDestroy') + }, + } + ``` + + +## app.setImageRawDataCacheSize + +setImageRawDataCacheSize(value: number): void + +Sets the maximum size (in bytes) of the image data cached in the memory before decoding to speed up the loading of images from the same sources. If the input parameter is not set, the default value **0** is used, indicating that images are not cached. The LRU policy is used for caching. After new images are loaded, if the upper limit of the cache is exceeded, the images that have not been updated for the longest time will be replaced. You are advised to set the input parameter based on the application memory requirements. If the image cache is too large, the memory usage may be too high. + +- Parameters + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | value | number | Yes | Size of the image data cached before decoding, in bytes. | + +- Example + + ``` + // app.ets + import app from '@system.app'; + + export default { + onCreate() { + app.setImageRawDataCacheSize(104,857,600) // Set the upper limit of the memory for caching image data before decoding to 100 MB. + console.info('Application onCreate') + }, + onDestroy() { + console.info('Application onDestroy') + }, + } + ``` + + +## app.setImageFileCacheSize + +setImageFileCacheSize(value: number): void + +Sets the maximum size of the image file cache (in bytes) to speed up the loading of images from the same sources, especially online image sources and thumbnails. If the input parameter is not set, the default value 100 MB is used. The LRU policy is used for caching. After new images are loaded, if the upper limit of the cache is exceeded, the images that have not been updated for the longest time will be replaced. You are advised to set the input parameter based on the application memory requirements. If the image cache is too large, the disk usage may be too high. + +- Parameters + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | value | number | Yes | Size of the image file cache, in bytes. | + +- Example + + ``` + // app.ets + import app from '@system.app'; + + export default { + onCreate() { + app.setImageFileCacheSize(209,715,200) // Set the upper limit of the image file cache to 200 MB. + console.info('Application onCreate') + }, + onDestroy() { + console.info('Application onDestroy') + }, + } + ``` diff --git a/en/application-dev/reference/arkui-ts/ts-methods-media-query.md b/en/application-dev/reference/arkui-ts/ts-methods-media-query.md index 8437e78f0b688355c630b49033b42ceee5d390e0..1f7e1e91bc03a267030aae252f9045e8841283ab 100644 --- a/en/application-dev/reference/arkui-ts/ts-methods-media-query.md +++ b/en/application-dev/reference/arkui-ts/ts-methods-media-query.md @@ -1,261 +1,115 @@ -# Media Query +# Media Query ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->This method is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -## Modules to Import +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** +> This method is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. + + +## Modules to Import + ``` import mediaquery from '@ohos.mediaquery' ``` -## Required Permissions + +## Required Permissions None -## mediaquery.matchMediaSync -matchMediaSync\(condition: string\): MediaQueryListener +## mediaquery.matchMediaSync + +matchMediaSync(condition: string): MediaQueryListener Sets the media query criteria and returns the corresponding listening handle. -- Parameters - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

condition

-

string

-

Yes

-

Matching condition of a media event. For details about the condition string format, see Media Query.

-
- -- Return values - - - - - - - - - - -

Type

-

Description

-

MediaQueryListener

-

Listening handle to a media event, which is used to register or unregister the listening callback.

-
- -- Example - - ``` - listener = mediaquery.matchMediaSync('(orientation: landscape)'); // Listen to landscape events. - ``` - - -## MediaQueryListener +- Parameters + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | condition | string | Yes | Matching condition of a media event. | + +- Return values + | Type | Description | + | -------- | -------- | + | MediaQueryListener | Listening handle to a media event, which is used to register or unregister the listening callback. | + +- Example + + ``` + listener = mediaquery.matchMediaSync('(orientation: landscape)'); // Listen to landscape events. + ``` + + +## MediaQueryListener Media query handle, including the first query result when the handle is applied for. -### Attributes - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Readable

-

Writable

-

Description

-

matches

-

boolean

-

Yes

-

No

-

Whether the match condition is met.

-

media

-

string

-

Yes

-

No

-

Matching condition of a media event.

-
- -### on - -on\(type: 'change', callback: Callback\): void + +### Attributes + + | Name | Type | Readable | Writable | Description | +| -------- | -------- | -------- | -------- | -------- | +| matches | boolean | Yes | No | Whether the match condition is met. | +| media | string | Yes | No | Matching condition of a media event. | + + +### on + +on(type: 'change', callback: Callback<MediaQueryResult>): void Registers a callback with the corresponding query condition by using the handle. This callback is triggered when the media attributes change. -- Parameters - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

type

-

string

-

Yes

-

Must enter the string change.

-

callback

-

Callback<MediaQueryResult>

-

Yes

-

Callback registered with media query.

-
- -- Example - - For details, see the [off example](#li16426122219256). - - -### off - -off\(type: 'change', callback?: Callback\): void - -Unregisters a callback with the corresponding query condition by using the handle, so that no callback is triggered when the media attributes change. - -- Parameters - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

type

-

boolean

-

Yes

-

Must enter the string change.

-

callback

-

Callback<MediaQueryResult>

-

No

-

Callback to be unregistered. If the default value is used, all callbacks of the handle are unregistered.

-
- -- Example - - ``` - listener = mediaquery.matchMediaSync('(orientation: landscape)'); // Listens to landscape events. - onPortrait(mediaQueryResult) { - if (mediaQueryResult.matches) { - // do something here - } else { - // do something here - } - } - listener.on('change', onPortrait) // Register a callback. - listener.off('change', onPortrait) // Unregister a callback. - ``` - - -## MediaQueryResult - -### Attributes - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Readable

-

Writable

-

Description

-

matches

-

boolean

-

Yes

-

No

-

Whether the match condition is met.

-

media

-

string

-

Yes

-

No

-

Matching condition of a media event.

-
- -### Example +- Parameters + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | type | string | Yes | Must enter the string **change**. | + | callback | Callback<MediaQueryResult> | Yes | Callback registered with media query. | + +- Example + For details, see the [off example](#off). + + +### off + +off(type: 'change', callback?: Callback<MediaQueryResult>): void + + Unregisters a callback with the corresponding query condition by using the handle, so that no callback is triggered when the media attributes change. +- Parameters + | Name | Type | Mandatory | Description | + | -------- | -------- | -------- | -------- | + | type | boolean | Yes | Must enter the string **change**. | + | callback | Callback<MediaQueryResult> | No | Callback to be unregistered. If the default value is used, all callbacks of the handle are unregistered. | + +- Example + + ``` + listener = mediaquery.matchMediaSync('(orientation: landscape)'); // Listens to landscape events. + onPortrait(mediaQueryResult) { + if (mediaQueryResult.matches) { + // do something here + } else { + // do something here + } + } + listener.on('change', onPortrait) // Register a callback. + listener.off('change', onPortrait) // Unregister a callback. + ``` + + +## MediaQueryResult + + +### Attributes + + | Name | Type | Readable | Writable | Description | +| -------- | -------- | -------- | -------- | -------- | +| matches | boolean | Yes | No | Whether the match condition is met. | +| media | string | Yes | No | Matching condition of a media event. | + + +### Example + ``` import mediaquery from '@ohos.mediaquery' @@ -293,5 +147,4 @@ struct MediaQueryExample { } ``` -![](figures/mediaquery.gif) - +![en-us_image_0000001257138369](figures/en-us_image_0000001257138369.gif) diff --git a/en/application-dev/reference/arkui-ts/ts-methods-popup-window.md b/en/application-dev/reference/arkui-ts/ts-methods-popup-window.md new file mode 100644 index 0000000000000000000000000000000000000000..d73efbd8c8d9e8ab1a05d383a8dd2d810df0b486 --- /dev/null +++ b/en/application-dev/reference/arkui-ts/ts-methods-popup-window.md @@ -0,0 +1,9 @@ +# Pop-up Window + + + +- **[Alert Dialog Box](ts-methods-alert-dialog-box.md)** + +- **[Action Sheet](ts-methods-action-sheet.md)** + +- **[Custom Dialog Box](ts-methods-custom-dialog-box.md)** \ No newline at end of file diff --git a/en/application-dev/reference/arkui-ts/ts-motion-path-animation.md b/en/application-dev/reference/arkui-ts/ts-motion-path-animation.md index 56719de12b1bc36a1ebaf620d57898336dae0618..ec0b7d8d9bf3845532644f36ea0ef4af41632816 100644 --- a/en/application-dev/reference/arkui-ts/ts-motion-path-animation.md +++ b/en/application-dev/reference/arkui-ts/ts-motion-path-animation.md @@ -1,51 +1,23 @@ -# Motion Path Animation +# Motion Path Animation + + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** +> This animation is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->This animation is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. The attributes described in this topic are used to set the motion path of the component in a translation animation. -## Attributes - - - - - - - - - - - - - -

Name

-

Type

-

Default Value

-

Description

-

motionPath

-

{

-

path: string,

-

from?: number,

-

to?: number,

-

rotatable?: boolean

-

}

-
NOTE:

In a path, start and end can be used to replace the start point and end point. Example:

-

'Mstart.x start.y L50 50 Lend.x end.y Z'

-
-

{

-

"",

-

0.0,

-

1.0,

-

false

-

}

-

Motion path of the component. The input parameters are described as follows:

-
  • path: motion path of the translation animation. The svg path string is used.
  • from: start point of the motion path. The default value is 0.0.
  • to: end point of the motion path. The default value is 1.0.
  • rotatable: whether to rotate along the path.
-
+## Attributes + + | Name | Type | Default Value | Description | +| -------- | -------- | -------- | -------- | +| motionPath | {
path: string,
from?: number,
to?: number,
rotatable?: boolean
}
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:**
> In a path, **start** and **end** can be used to replace the start point and end point. Example:

> 'Mstart.x start.y L50 50 Lend.x end.y Z' | {
"",
0.0,
1.0,
false
} | Motion path of the component. The input parameters are described as follows:
- **path**: motion path of the translation animation. The **svg** path string is used.
- **from**: start point of the motion path. The default value is **0.0**.
- **to**: end point of the motion path. The default value is **1.0**.
- **rotatable**: whether to rotate along the path. | -## Example +## Example + + ``` @Entry @Component @@ -68,5 +40,4 @@ struct MotionPathExample { } ``` -![](figures/motion.gif) - +![en-us_image_0000001212378420](figures/en-us_image_0000001212378420.gif) diff --git a/en/application-dev/reference/arkui-ts/ts-offscreencanvasrenderingcontext2d.md b/en/application-dev/reference/arkui-ts/ts-offscreencanvasrenderingcontext2d.md index 440b12f304e589a160bb91e74c7856a124b5ccd1..1e133ff6887fc17339b79d54532053c582d5e5ec 100644 --- a/en/application-dev/reference/arkui-ts/ts-offscreencanvasrenderingcontext2d.md +++ b/en/application-dev/reference/arkui-ts/ts-offscreencanvasrenderingcontext2d.md @@ -1,260 +1,54 @@ -# OffscreenCanvasRenderingConxt2D - ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->This component is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version. - -Use **OffscreenCanvasRenderingContext2D** to draw rectangles, images, and text offscreen onto a canvas. Drawing offscreen onto a canvas is a process where content to draw onto the canvas is first drawn in the buffer, and then converted into a picture, and finally the picture is drawn on the canvas. This process increases the drawing efficiency. - -## APIs - -OffscreenCanvasRenderingContext2D\(width: number, height: number, setting: RenderingContextSettings\) - -- Parameters - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

width

-

number

-

Yes

-

-

-

Width of the offscreen canvas.

-

height

-

number

-

Yes

-

-

-

Height of the offscreen canvas.

-

setting

-

RenderingContextSettings

-

Yes

-

-

-

For details, see APIs of RenderingContextSettings.

-
- - -## Attributes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Default Value

-

Description

-

fillStyle

-

<color> | CanvasGradient | CanvasPattern

-

-

-

Style to fill an area.

-
  • When the type is <color>, this parameter indicates the color of the filling area.
  • When the type is CanvasGradient, this parameter indicates a gradient object, which is created using the createLinearGradient method.
  • When the type is CanvasPattern, use the createPattern method to create a pattern.
-

lineWidth

-

number

-

-

-

Line width.

-

strokeStyle

-

<color> | CanvasGradient | CanvasPattern

-

-

-

Stroke style.

-
  • When the type is <color>, this parameter indicates the stroke color.
  • When the type is CanvasGradient, this parameter indicates a gradient object, which is created using the createLinearGradient method.
  • When the type is CanvasPattern, use the createPattern method to create a pattern.
-

lineCap

-

string

-

'butt'

-

Style of the specified line endpoint. The options are as follows:

-
  • 'butt': The endpoints of the line are squared off.
  • 'round': The endpoints of the line are rounded.
  • 'square': The endpoints of the line are squared off, and each endpoint has added a rectangle whose length is the same as the line thickness and whose width is half of the line thickness.
-

lineJoin

-

string

-

'miter'

-

Style of the intersection point between line segments. The options are as follows:

-
  • 'round': The intersection is a sector, whose radius at the rounded corner is equal to the line width.
  • 'bevel': The intersection is a triangle. The rectangular corner of each line is independent.
  • 'miter': The intersection has a miter corner by extending the outside edges of the lines until they meet. You can view the effect of this attribute in miterLimit.
-

miterLimit

-

number

-

10

-

Maximum miter length. The miter length is the distance between the inner corner and the outer corner where two lines meet.

-

font

-

string

-

'normal normal 14px sans-serif'

-

Font style.

-

Syntax: ctx.font='font-size font-family'

-
  • (Optional) font-size: font size and row height. The unit can only be pixels.
  • (Optional) font-family: font family.
-

Syntax: ctx.font='font-style font-weight font-size font-family'

-
  • (Optional) font-style: specifies the font style. Available values are 'normal' and 'italic'.
  • (Optional) font-weight: font weight. Available values are as follows: 'normal', 'bold', 'bolder', 'lighter', 100, 200, 300, 400, 500, 600, 700, 800, 900
  • (Optional) font-size: font size and row height. The unit can only be pixels.
  • (Optional) font-family: font family. Available values are 'sans-serif', 'serif', and 'monospace'.
-

textAlign

-

string

-

'left'

-

Text alignment mode. Available values are as follows:

-
  • 'left': The text is left-aligned.
  • 'right': The text is right-aligned.
  • 'center': The text is center-aligned.
  • 'start': The text is aligned with the start bound.
  • 'end': The text is aligned with the end bound.
-
NOTE:

In the ltr layout mode, the value start equals left. In the rtl layout mode, the value start equals right.

-
-

textBaseline

-

string

-

'alphabetic'

-

Horizontal alignment mode of text. Available values are as follows:

-
  • 'alphabetic': The text baseline is the normal alphabetic baseline.
  • 'top': The text baseline is on the top of the text bounding box.
  • 'hanging': The text baseline is a hanging baseline over the text.
  • 'middle': The text baseline is in the middle of the text bounding box.
  • 'ideographic': The text baseline is the ideographic baseline. If a character exceeds the alphabetic baseline, the ideographic baseline is located at the bottom of the excess character.
  • 'bottom': The text baseline is at the bottom of the text bounding box. Its difference from the ideographic baseline is that the ideographic baseline does not consider letters in the next line.
-

globalAlpha

-

number

-

-

-

Opacity. 0.0: completely transparent; 1.0: completely opaque.

-

lineDashOffset

-

number

-

0.0

-

Offset of the dashed line. The precision is float.

-

globalCompositeOperation

-

string

-

'source-over'

-

Composition operation type. Available values are as follows: 'source-over', 'source-atop', 'source-in', 'source-out', 'destination-over', 'destination-atop', 'destination-in', 'destination-out', 'lighter', 'copy', and 'xor'.

-

shadowBlur

-

number

-

0.0

-

Blur level during shadow drawing. A larger value indicates a more blurred effect. The precision is float.

-

shadowColor

-

<color>

-

-

-

Shadow color.

-

shadowOffsetX

-

number

-

-

-

X-axis shadow offset relative to the original object.

-

shadowOffsetY

-

number

-

-

-

Y-axis shadow offset relative to the original object.

-

imageSmoothingEnabled

-

boolean

-

true

-

Whether to adjust the image smoothness during image drawing. The value true means to enable this feature, and false means the opposite.

-

imageSmoothingQuality

-

string

-

'low'

-

Image smoothness. The value can be 'low', 'medium', or 'high'.

-
- ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->The value of the **** type can be in 'rgb\(255, 255, 255\)', 'rgba\(255, 255, 255, 1.0\)', or '\#FFFFFF' format. - -### fillStyle +# OffscreenCanvasRenderingConxt2D + + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** +> The APIs of this module are supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version. + + +Use **OffscreenCanvasRenderingContext2D** to draw rectangles, images, and text offscreen onto a canvas. Drawing offscreen onto a canvas is a process where content to draw onto the canvas is first drawn in the buffer, and then converted into a picture, and finally the picture is drawn on the canvas. This process increases the drawing efficiency. + + +## APIs + +OffscreenCanvasRenderingContext2D(width: number, height: number, setting: RenderingContextSettings) + +- Parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | width | number | Yes | - | Width of the offscreen canvas. | + | height | number | Yes | - | Height of the offscreen canvas. | + | setting | [RenderingContextSettings](ts-canvasrenderingcontext2d.md#renderingcontextsettings) | Yes | - | See RenderingContextSettings. | + + +## Attributes + +| Name | Type | Default Value | Description | +| -------- | -------- | -------- | -------- | +| [fillStyle](#fillstyle) | <color> \| [CanvasGradient](ts-components-canvas-canvasgradient.md) \| [CanvasPattern](#canvaspattern) | - | Style used to fill an area.
- When the type is **<color>**, this attribute indicates the fill color.
- When the type is **CanvasGradient**, this attribute indicates a gradient object, which is created using the [createLinearGradient](#createlineargradient) method.
- When the type is **CanvasPattern**, this attribute indicates a pattern, which is created using the [createPattern](#createpattern) method. | +| [lineWidth](#linewidth) | number | - | Line width. | +| [strokeStyle](#strokestyle) | <color> \| [CanvasGradient](ts-components-canvas-canvasgradient.md) \| [CanvasPattern](#canvaspattern) | - | Stroke style.
- When the type is **<color>**, this attribute indicates the stroke color.
- When the type is **CanvasGradient**, this attribute indicates a gradient object, which is created using the [createLinearGradient](#createlineargradient) method.
- When the type is **CanvasPattern**, this attribute indicates a pattern, which is created using the [createPattern](#createpattern) method. | +| [lineCap](#linecap) | string | 'butt' | Style of the line endpoints. The options are as follows:
- **'butt'**: The endpoints of the line are squared off.
- **'round'**: The endpoints of the line are rounded.
- **'square'**: The endpoints of the line are squared off by adding a box with an equal width and half the height of the line's thickness. | +| [lineJoin](#linejoin) | string | 'miter' | Style of the shape used to join line segments. The options are as follows:
- **'round'**: The shape used to join line segments is a rounded corner with the radius equal to the line width.
- **'bevel'**: The shape used to join line segments is a beveled corner. The rectangular corner of each line is independent.
- **'miter'**: The shape used to join line segments is a mitered corner. The corner is formed by extending the outside edges of the lines until they meet. You can adjust the effect of this attribute using **miterLimit**. | +| [miterLimit](#miterlimit) | number | 10 | Maximum miter length. The miter length is the distance between the inner corner and the outer corner where two lines meet. | +| [font](#font) | string | 'normal normal 14px sans-serif' | Font style.
Syntax: ctx.font='font-size font-family'
- (Optional) **font-size**: font size and row height. The unit can only be px.
- (Optional) **font-family**: font family.
Syntax: ctx.font='font-style font-weight font-size font-family'
- (Optional) **font-style**: specifies the font style. Available values are **'normal'** and **'italic'**.
- (Optional) **font-weight**: font weight. Available values are as follows: **'normal'**, **'bold'**, **'bolder'**, **'lighter'**, **100**, **200**, **300**, **400**, **500**, **600**, **700**, **800**, **900**
- (Optional) **font-size**: font size and row height. The unit can only be px.
- (Optional) **font-family**: font family. Available values are **'sans-serif'**, **'serif'**, and **'monospace'**. | +| [textAlign](#textalign) | string | 'left' | Text alignment mode. Available values are as follows:
- **'left'**: The text is left-aligned.
- **'right'**: The text is right-aligned.
- **'center'**: The text is center-aligned.
- **'start'**: The text is aligned with the start bound.
- **'end'**: The text is aligned with the end bound.
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:**
> In the **ltr** layout mode, the value **start** equals **left**. In the **rtl** layout mode, the value **start** equals **right**. | +| [textBaseline](#textbaseline) | string | 'alphabetic' | Horizontal alignment mode of text. Available values are as follows:
- **'alphabetic'**: The text baseline is the normal alphabetic baseline.
- **'top'**: The text baseline is on the top of the text bounding box.
- **'hanging'**: The text baseline is a hanging baseline over the text.
- **'middle'**: The text baseline is in the middle of the text bounding box.
- **'ideographic'**: The text baseline is the ideographic baseline. If a character exceeds the alphabetic baseline, the ideographic baseline is located at the bottom of the excess character.
- **'bottom'**: The text baseline is at the bottom of the text bounding box. Its difference from the ideographic baseline is that the ideographic baseline does not consider letters in the next line. | +| [globalAlpha](#globalalpha) | number | - | Opacity. **0.0**: completely transparent; **1.0**: completely opaque. | +| [lineDashOffset](#linedashoffset) | number | 0.0 | Offset of the dashed line. The precision is float. | +| [globalCompositeOperation](#globalcompositeoperation) | string | 'source-over' | Composition operation type. Available values are as follows: **'source-over'**, **'source-atop'**, **'source-in'**, **'source-out'**, **'destination-over'**, **'destination-atop'**, **'destination-in'**, **'destination-out'**, **'lighter'**, **'copy'**, and **'xor'**. | +| [shadowBlur](#shadowblur) | number | 0.0 | Blur level during shadow drawing. A larger value indicates a more blurred effect. The precision is float. | +| [shadowColor](#shadowcolor) | <color> | - | Shadow color. | +| [shadowOffsetX](#shadowoffsetx) | number | - | X-axis shadow offset relative to the original object. | +| [shadowOffsetY](#shadowoffsety) | number | - | Y-axis shadow offset relative to the original object. | +| [imageSmoothingEnabled](#imagesmoothingenabled) | boolean | true | Whether to adjust the image smoothness during image drawing. The value **true** means to enable this feature, and **false** means the opposite. | +| imageSmoothingQuality | string | 'low' | Image smoothness. The value can be **'low'**, **'medium'**, or **'high'**. | + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** +> The value of the **<color>** type can be in 'rgb(255, 255, 255)', 'rgba(255, 255, 255, 1.0)', or '\#FFFFFF' format. + + +### fillStyle + ``` @Entry @@ -283,9 +77,11 @@ struct FillStyleExample { } ``` -![](figures/en-us_image_0000001237555173.png) +![en-us_image_0000001211898510](figures/en-us_image_0000001211898510.png) + + +### lineWidth -### lineWidth ``` @Entry @@ -314,9 +110,11 @@ struct LineWidthExample { } ``` -![](figures/en-us_image_0000001192755194.png) +![en-us_image_0000001257058439](figures/en-us_image_0000001257058439.png) + + +### strokeStyle -### strokeStyle ``` @Entry @@ -346,9 +144,12 @@ struct StrokeStyleExample { } ``` -![](figures/en-us_image_0000001237355135.png) -### lineCap +![en-us_image_0000001257058429](figures/en-us_image_0000001257058429.png) + + +### lineCap + ``` @Entry @@ -381,9 +182,11 @@ struct LineCapExample { } ``` -![](figures/en-us_image_0000001192595232.png) +![en-us_image_0000001256858427](figures/en-us_image_0000001256858427.png) + + +### lineJoin -### lineJoin ``` @Entry @@ -417,9 +220,11 @@ struct LineJoinExample { } ``` -![](figures/en-us_image_0000001237715141.png) +![en-us_image_0000001256858429](figures/en-us_image_0000001256858429.png) + + +### miterLimit -### miterLimit ``` @Entry @@ -453,9 +258,11 @@ struct MiterLimit { } ``` -![](figures/en-us_image_0000001193075178.png) +![en-us_image_0000001212218472](figures/en-us_image_0000001212218472.png) + + +### font -### font ``` @Entry @@ -484,9 +291,11 @@ struct Font { } ``` -![](figures/en-us_image_0000001193075164.png) +![en-us_image_0000001211898508](figures/en-us_image_0000001211898508.png) + + +### textAlign -### textAlign ``` @Entry @@ -530,9 +339,11 @@ struct CanvasExample { } ``` -![](figures/en-us_image_0000001192595234.png) +![en-us_image_0000001257138377](figures/en-us_image_0000001257138377.png) + + +### textBaseline -### textBaseline ``` @Entry @@ -576,9 +387,11 @@ struct TextBaseline { } ``` -![](figures/en-us_image_0000001193075180.png) +![en-us_image_0000001256978375](figures/en-us_image_0000001256978375.png) + + +### globalAlpha -### globalAlpha ``` @Entry @@ -610,9 +423,11 @@ struct GlobalAlpha { } ``` -![](figures/en-us_image_0000001237715165.png) +![en-us_image_0000001211898506](figures/en-us_image_0000001211898506.png) + + +### lineDashOffset -### lineDashOffset ``` @Entry @@ -642,74 +457,25 @@ struct LineDashOffset { } ``` -![](figures/en-us_image_0000001237555181.png) - -### globalCompositeOperation - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Description

-

source-over

-

Displays the new drawing above the existing drawing. This attribute is used by default.

-

source-atop

-

Displays the new drawing on the top of the existing drawing.

-

source-in

-

Displays the new drawing inside the existing drawing.

-

source-out

-

Displays the part of the new drawing that is outside of the existing drawing.

-

destination-over

-

Displays the existing drawing above the new drawing.

-

destination-atop

-

Displays the existing drawing above the new drawing.

-

destination-in

-

Displays the existing drawing inside the new drawing.

-

destination-out

-

Displays the part of the existing drawing that is outside of the new drawing.

-

lighter

-

Displays both the new drawing and the existing drawing.

-

copy

-

Displays the new drawing and neglects the existing drawing.

-

xor

-

Combines the new drawing and existing drawing using the XOR operation.

-
+![en-us_image_0000001212058506](figures/en-us_image_0000001212058506.png) + + +### globalCompositeOperation + + | Name | Description | +| -------- | -------- | +| source-over | Displays the new drawing above the existing drawing. This attribute is used by default. | +| source-atop | Displays the new drawing on the top of the existing drawing. | +| source-in | Displays the new drawing inside the existing drawing. | +| source-out | Displays the part of the new drawing that is outside of the existing drawing. | +| destination-over | Displays the existing drawing above the new drawing. | +| destination-atop | Displays the existing drawing on the top of the new drawing. | +| destination-in | Displays the existing drawing inside the new drawing. | +| destination-out | Displays the part of the existing drawing that is outside of the new drawing. | +| lighter | Displays both the new drawing and the existing drawing. | +| copy | Displays the new drawing and neglects the existing drawing. | +| xor | Combines the new drawing and existing drawing using the XOR operation. | + ``` @Entry @@ -746,9 +512,11 @@ struct GlobalCompositeOperation { } ``` -![](figures/en-us_image_0000001237355137.png) +![en-us_image_0000001212218474](figures/en-us_image_0000001212218474.png) + + +### shadowBlur -### shadowBlur ``` @Entry @@ -779,9 +547,11 @@ struct ShadowBlur { } ``` -![](figures/en-us_image_0000001192755182.png) +![en-us_image_0000001211898514](figures/en-us_image_0000001211898514.png) + + +### shadowColor -### shadowColor ``` @Entry @@ -813,9 +583,11 @@ struct ShadowColor { } ``` -![](figures/en-us_image_0000001237555155.png) +![en-us_image_0000001212058502](figures/en-us_image_0000001212058502.png) + + +### shadowOffsetX -### shadowOffsetX ``` @Entry @@ -847,9 +619,11 @@ struct ShadowOffsetX { } ``` -![](figures/en-us_image_0000001193075168.png) +![en-us_image_0000001257138379](figures/en-us_image_0000001257138379.png) + + +### shadowOffsetY -### shadowOffsetY ``` @Entry @@ -881,9 +655,11 @@ struct ShadowOffsetY { } ``` -![](figures/en-us_image_0000001237475139.png) +![en-us_image_0000001257058427](figures/en-us_image_0000001257058427.png) + + +### imageSmoothingEnabled -### imageSmoothingEnabled ``` @Entry @@ -913,2991 +689,1472 @@ struct ImageSmoothingEnabled { } ``` -![](figures/en-us_image_0000001237355121.png) +![en-us_image_0000001257138385](figures/en-us_image_0000001257138385.png) + -## Methods +## Methods -### fillRect -fillRect\(x: number, y: number, w: number, h: number\): void +### fillRect + +fillRect(x: number, y: number, w: number, h: number): void Fills a rectangle on the canvas. -- Parameters - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

x

-

number

-

Yes

-

0

-

X-coordinate of the upper left corner of the rectangle.

-

y

-

number

-

Yes

-

0

-

Y-coordinate of the upper left corner of the rectangle.

-

width

-

number

-

Yes

-

0

-

Width of the rectangle.

-

height

-

number

-

Yes

-

0

-

Height of the rectangle.

-
- -- Example - - ``` - @Entry - @Component - struct FillRect { - private settings: RenderingContextSettings = new RenderingContextSettings(true) - private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) - private offContext: OffscreenCanvasRenderingContext2D = new OffscreenCanvasRenderingContext2D(600, 600, this.settings) - - build() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Canvas(this.context) - .width('100%') - .height('100%') - .backgroundColor('#ffff00') - .onReady(() =>{ - this.offContext.fillRect(0,30,100,100) - var image = this.offContext.transferToImageBitmap() - this.context.transferFromImageBitmap(image) - }) - } - .width('100%') - .height('100%') - } - } - ``` - - ![](figures/en-us_image_0000001237475123.png) - - -### strokeRect - -strokeRect\(x: number, y: number, w: number, h: number\): void - -Draws a rectangle stroke on the canvas. - -- Parameters - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

x

-

number

-

Yes

-

0

-

X-coordinate of the upper left corner of the rectangle stroke.

-

y

-

number

-

Yes

-

0

-

Y-coordinate of the upper left corner of the rectangle stroke.

-

width

-

number

-

Yes

-

0

-

Width of the rectangle.

-

height

-

number

-

Yes

-

0

-

Height of the rectangle.

-
- - -- Example - - ``` - @Entry - @Component - struct StrokeRect { - private settings: RenderingContextSettings = new RenderingContextSettings(true) - private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) - private offContext: OffscreenCanvasRenderingContext2D = new OffscreenCanvasRenderingContext2D(600, 600, this.settings) - build() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Canvas(this.context) - .width('100%') - .height('100%') - .backgroundColor('#ffff00') - .onReady(() =>{ - this.offContext.strokeRect(30, 30, 200, 150) - var image = this.offContext.transferToImageBitmap() - this.context.transferFromImageBitmap(image) - }) +- Parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | x | number | Yes | 0 | X-coordinate of the upper left corner of the rectangle. | + | y | number | Yes | 0 | Y-coordinate of the upper left corner of the rectangle. | + | width | number | Yes | 0 | Width of the rectangle. | + | height | number | Yes | 0 | Height of the rectangle. | + +- Example + + ``` + @Entry + @Component + struct FillRect { + private settings: RenderingContextSettings = new RenderingContextSettings(true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + private offContext: OffscreenCanvasRenderingContext2D = new OffscreenCanvasRenderingContext2D(600, 600, this.settings) + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.offContext.fillRect(0,30,100,100) + var image = this.offContext.transferToImageBitmap() + this.context.transferFromImageBitmap(image) + }) } - .width('100%') - .height('100%') + .width('100%') + .height('100%') + } + } + ``` + + ![en-us_image_0000001257138375](figures/en-us_image_0000001257138375.png) + + +### strokeRect + +strokeRect(x: number, y: number, w: number, h: number): void + +Draws an outlined rectangle on the canvas. + +- Parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | x | number | Yes | 0 | X-coordinate of the upper left corner of the rectangle. | + | y | number | Yes | 0 | Y-coordinate of the upper left corner of the rectangle. | + | width | number | Yes | 0 | Width of the rectangle. | + | height | number | Yes | 0 | Height of the rectangle. | + +- Example + + ``` + @Entry + @Component + struct StrokeRect { + private settings: RenderingContextSettings = new RenderingContextSettings(true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + private offContext: OffscreenCanvasRenderingContext2D = new OffscreenCanvasRenderingContext2D(600, 600, this.settings) + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.offContext.strokeRect(30, 30, 200, 150) + var image = this.offContext.transferToImageBitmap() + this.context.transferFromImageBitmap(image) + }) } + .width('100%') + .height('100%') } - ``` + } + ``` - ![](figures/en-us_image_0000001192755180.png) + ![en-us_image_0000001212378436](figures/en-us_image_0000001212378436.png) -### clearRect +### clearRect -clearRect\(x: number, y: number, w: number, h: number\): void +clearRect(x: number, y: number, w: number, h: number): void Clears the content in a rectangle on the canvas. -- Parameters - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

x

-

number

-

Yes

-

0

-

X-coordinate of the upper left corner of the rectangle.

-

y

-

number

-

Yes

-

0

-

Y-coordinate of the upper left corner of the rectangle.

-

width

-

number

-

Yes

-

0

-

Width of the rectangle.

-

height

-

number

-

Yes

-

0

-

Height of the rectangle.

-
- - -- Example - - ``` - @Entry - @Component - struct ClearRect { - private settings: RenderingContextSettings = new RenderingContextSettings(true) - private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) - private offContext: OffscreenCanvasRenderingContext2D = new OffscreenCanvasRenderingContext2D(600, 600, this.settings) - build() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Canvas(this.context) - .width('100%') - .height('100%') - .backgroundColor('#ffff00') - .onReady(() =>{ - this.offContext.fillStyle = 'rgb(0,0,255)' - this.offContext.fillRect(0,0,500,500) - this.offContext.clearRect(20,20,150,100) - var image = this.offContext.transferToImageBitmap() - this.context.transferFromImageBitmap(image) - }) - } - .width('100%') - .height('100%') +- Parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | x | number | Yes | 0 | X-coordinate of the upper left corner of the rectangle. | + | y | number | Yes | 0 | Y-coordinate of the upper left corner of the rectangle. | + | width | number | Yes | 0 | Width of the rectangle. | + | height | number | Yes | 0 | Height of the rectangle. | + +- Example + + ``` + @Entry + @Component + struct ClearRect { + private settings: RenderingContextSettings = new RenderingContextSettings(true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + private offContext: OffscreenCanvasRenderingContext2D = new OffscreenCanvasRenderingContext2D(600, 600, this.settings) + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.offContext.fillStyle = 'rgb(0,0,255)' + this.offContext.fillRect(0,0,500,500) + this.offContext.clearRect(20,20,150,100) + var image = this.offContext.transferToImageBitmap() + this.context.transferFromImageBitmap(image) + }) } + .width('100%') + .height('100%') } - ``` + } + ``` - ![](figures/11111-5.png) + ![en-us_image_0000001212058500](figures/en-us_image_0000001212058500.png) -### fillText +### fillText -fillText\(text: string, x: number, y: number\): void +fillText(text: string, x: number, y: number): void Draws filled text on the canvas. -- Parameters - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Parameters

-

Type

-

Mandatory

-

Default Value

-

Description

-

text

-

string

-

Yes

-

""

-

Text to draw.

-

x

-

number

-

Yes

-

0

-

X-coordinate of the lower left corner of the text.

-

y

-

number

-

Yes

-

0

-

Y-coordinate of the lower left corner of the text.

-
- - -- Example - - ``` - @Entry - @Component - struct FillText { - private settings: RenderingContextSettings = new RenderingContextSettings(true) - private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) - private offContext: OffscreenCanvasRenderingContext2D = new OffscreenCanvasRenderingContext2D(600, 600, this.settings) - build() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Canvas(this.context) - .width('100%') - .height('100%') - .backgroundColor('#ffff00') - .onReady(() =>{ - this.offContext.font = '30px sans-serif' - this.offContext.fillText("Hello World!", 20, 100) - var image = this.offContext.transferToImageBitmap() - this.context.transferFromImageBitmap(image) - }) - } - .width('100%') - .height('100%') +- Parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | text | string | Yes | "" | Text to draw. | + | x | number | Yes | 0 | X-coordinate of the lower left corner of the text. | + | y | number | Yes | 0 | Y-coordinate of the lower left corner of the text. | + +- Example + + ``` + @Entry + @Component + struct FillText { + private settings: RenderingContextSettings = new RenderingContextSettings(true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + private offContext: OffscreenCanvasRenderingContext2D = new OffscreenCanvasRenderingContext2D(600, 600, this.settings) + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.offContext.font = '30px sans-serif' + this.offContext.fillText("Hello World!", 20, 100) + var image = this.offContext.transferToImageBitmap() + this.context.transferFromImageBitmap(image) + }) } + .width('100%') + .height('100%') } - ``` + } + ``` - ![](figures/en-us_image_0000001237555165.png) + ![en-us_image_0000001257058437](figures/en-us_image_0000001257058437.png) -### strokeText +### strokeText -strokeText\(text: string, x: number, y: number\): void +strokeText(text: string, x: number, y: number): void Draws a text stroke on the canvas. -- Parameters - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

text

-

string

-

Yes

-

""

-

Text to draw.

-

x

-

number

-

Yes

-

0

-

X-coordinate of the lower left corner of the text.

-

y

-

number

-

Yes

-

0

-

Y-coordinate of the lower left corner of the text.

-
- - -- Example - - ``` - @Entry - @Component - struct StrokeText { - private settings: RenderingContextSettings = new RenderingContextSettings(true) - private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) - private offContext: OffscreenCanvasRenderingContext2D = new OffscreenCanvasRenderingContext2D(600, 600, this.settings) - build() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Canvas(this.context) - .width('100%') - .height('100%') - .backgroundColor('#ffff00') - .onReady(() =>{ - this.offContext.font = '55px sans-serif' - this.offContext.strokeText("Hello World!", 20, 60) - var image = this.offContext.transferToImageBitmap() - this.context.transferFromImageBitmap(image) - }) - } - .width('100%') - .height('100%') +- Parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | text | string | Yes | "" | Text to draw. | + | x | number | Yes | 0 | X-coordinate of the lower left corner of the text. | + | y | number | Yes | 0 | Y-coordinate of the lower left corner of the text. | + +- Example + + ``` + @Entry + @Component + struct StrokeText { + private settings: RenderingContextSettings = new RenderingContextSettings(true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + private offContext: OffscreenCanvasRenderingContext2D = new OffscreenCanvasRenderingContext2D(600, 600, this.settings) + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.offContext.font = '55px sans-serif' + this.offContext.strokeText("Hello World!", 20, 60) + var image = this.offContext.transferToImageBitmap() + this.context.transferFromImageBitmap(image) + }) } + .width('100%') + .height('100%') } - ``` - - ![](figures/en-us_image_0000001237715149.png) - - -### measureText - -measureText\(text: string\): TextMetrics - -Returns a **TextMetrics** object used to obtain the width of specified text. - -- Parameters - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

text

-

string

-

Yes

-

""

-

Text to be measured.

-
- -- Return values - - - - - - - - - - -

Type

-

Description

-

TextMetrics

-

TextMetrics object.

-
- -- **TextMetrics** attributes - - - - - - - - - - - - -

Attribute

-

Type

-

Description

-

width

-

number

-

Width of the text string.

-
- - -- Example - - ``` - @Entry - @Component - struct MeasureText { - private settings: RenderingContextSettings = new RenderingContextSettings(true) - private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) - private offContext: OffscreenCanvasRenderingContext2D = new OffscreenCanvasRenderingContext2D(600, 600, this.settings) - build() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Canvas(this.context) - .width('100%') - .height('100%') - .backgroundColor('#ffff00') - .onReady(() =>{ - this.offContext.font = '50px sans-serif' - this.offContext.fillText("Hello World!", 20, 100) - this.offContext.fillText("width:" + this.context.measureText("Hello World!").width, 20, 200) - var image = this.offContext.transferToImageBitmap() - this.context.transferFromImageBitmap(image) - }) - } - .width('100%') - .height('100%') + } + ``` + + ![en-us_image_0000001212218466](figures/en-us_image_0000001212218466.png) + + +### measureText + +measureText(text: string): TextMetrics + +Returns a **TextMetrics** object used to obtain the width of specified text. + +- Parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | text | string | Yes | "" | Text to be measured. | + +- Return value + | Type | Description | + | -------- | -------- | + | [ERROR:Invalid link:en-us_topic_0000001212218420.xml#en-us_topic_0000001192595178_xref4588645104013,link:#en-us_topic_0000001192595178_li0376175812415](#en-us_topic_0000001192595178_li0376175812415) | **TextMetrics** object. | + +- **TextMetrics** attributes + | Name | Type | Description | + | -------- | -------- | -------- | + | width | number | Width of the text. | + +- Example + + ``` + @Entry + @Component + struct MeasureText { + private settings: RenderingContextSettings = new RenderingContextSettings(true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + private offContext: OffscreenCanvasRenderingContext2D = new OffscreenCanvasRenderingContext2D(600, 600, this.settings) + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.offContext.font = '50px sans-serif' + this.offContext.fillText("Hello World!", 20, 100) + this.offContext.fillText("width:" + this.context.measureText("Hello World!").width, 20, 200) + var image = this.offContext.transferToImageBitmap() + this.context.transferFromImageBitmap(image) + }) } + .width('100%') + .height('100%') } - ``` + } + ``` - ![](figures/en-us_image_0000001193075172.png) + ![en-us_image_0000001256858431](figures/en-us_image_0000001256858431.png) -### stroke +### stroke -stroke\(path?: Path2D\): void +stroke(path?: Path2D): void Strokes a path. -- Parameters - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

path

-

Path2D

-

No

-

null

-

A Path2D path to draw.

-
- - -- Example - - ``` - @Entry - @Component - struct CanvasExample { - private settings: RenderingContextSettings = new RenderingContextSettings(true) - private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) - private offContext: OffscreenCanvasRenderingContext2D = new OffscreenCanvasRenderingContext2D(600, 600, this.settings) - build() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Canvas(this.context) - .width('100%') - .height('100%') - .backgroundColor('#ffff00') - .onReady(() =>{ - this.offContext.moveTo(25, 25) - this.offContext.lineTo(25, 105) - this.offContext.strokeStyle = 'rgb(0,0,255)' - this.offContext.stroke() - var image = this.offContext.transferToImageBitmap() - this.context.transferFromImageBitmap(image) - }) - } - .width('100%') - .height('100%') +- Parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | path | [Path2D](ts-components-canvas-path2d.md) | No | null | A **Path2D** path to draw. | + +- Example + + ``` + @Entry + @Component + struct Stroke { + private settings: RenderingContextSettings = new RenderingContextSettings(true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + private offContext: OffscreenCanvasRenderingContext2D = new OffscreenCanvasRenderingContext2D(600, 600, this.settings) + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.offContext.moveTo(25, 25) + this.offContext.lineTo(25, 105) + this.offContext.strokeStyle = 'rgb(0,0,255)' + this.offContext.stroke() + var image = this.offContext.transferToImageBitmap() + this.context.transferFromImageBitmap(image) + }) } + .width('100%') + .height('100%') } - ``` + } + ``` - ![](figures/en-us_image_0000001192595220.png) + ![en-us_image_0000001257138373](figures/en-us_image_0000001257138373.png) -### beginPath +### beginPath -beginPath\(\): void +beginPath(): void Creates a drawing path. -- Example - - ``` - @Entry - @Component - struct BeginPath { - private settings: RenderingContextSettings = new RenderingContextSettings(true) - private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) - private offContext: OffscreenCanvasRenderingContext2D = new OffscreenCanvasRenderingContext2D(600, 600, this.settings) - build() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Canvas(this.context) - .width('100%') - .height('100%') - .backgroundColor('#ffff00') - .onReady(() =>{ - this.offContext.beginPath() - this.offContext.lineWidth = 6 - this.offContext.strokeStyle = '#0000ff' - this.offContext.moveTo(15, 80) - this.offContext.lineTo(280, 160) - this.offContext.stroke() - var image = this.offContext.transferToImageBitmap() - this.context.transferFromImageBitmap(image) - }) - } - .width('100%') - .height('100%') +- Example + + ``` + @Entry + @Component + struct BeginPath { + private settings: RenderingContextSettings = new RenderingContextSettings(true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + private offContext: OffscreenCanvasRenderingContext2D = new OffscreenCanvasRenderingContext2D(600, 600, this.settings) + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.offContext.beginPath() + this.offContext.lineWidth = 6 + this.offContext.strokeStyle = '#0000ff' + this.offContext.moveTo(15, 80) + this.offContext.lineTo(280, 160) + this.offContext.stroke() + var image = this.offContext.transferToImageBitmap() + this.context.transferFromImageBitmap(image) + }) } + .width('100%') + .height('100%') } - ``` + } + ``` - ![](figures/en-us_image_0000001237555163.png) + ![en-us_image_0000001212378440](figures/en-us_image_0000001212378440.png) -### moveTo +### moveTo -moveTo\(x: number, y: number\): void +moveTo(x: number, y: number): void Moves a drawing path to a target position on the canvas. -- Parameters - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

x

-

number

-

Yes

-

0

-

X-coordinate of the target position.

-

y

-

number

-

Yes

-

0

-

Y-coordinate of the target position.

-
- - -- Example - - ``` - @Entry - @Component - struct MoveTo { - private settings: RenderingContextSettings = new RenderingContextSettings(true) - private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) - private offContext: OffscreenCanvasRenderingContext2D = new OffscreenCanvasRenderingContext2D(600, 600, this.settings) - build() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Canvas(this.context) - .width('100%') - .height('100%') - .backgroundColor('#ffff00') - .onReady(() =>{ - this.offContext.beginPath() - this.offContext.moveTo(10, 10) - this.offContext.lineTo(280, 160) - this.offContext.stroke() - var image = this.offContext.transferToImageBitmap() - this.context.transferFromImageBitmap(image) - }) - } - .width('100%') - .height('100%') +- Parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | x | number | Yes | 0 | X-coordinate of the target position. | + | y | number | Yes | 0 | Y-coordinate of the target position. | + +- Example + + ``` + @Entry + @Component + struct MoveTo { + private settings: RenderingContextSettings = new RenderingContextSettings(true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + private offContext: OffscreenCanvasRenderingContext2D = new OffscreenCanvasRenderingContext2D(600, 600, this.settings) + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.offContext.beginPath() + this.offContext.moveTo(10, 10) + this.offContext.lineTo(280, 160) + this.offContext.stroke() + var image = this.offContext.transferToImageBitmap() + this.context.transferFromImageBitmap(image) + }) } + .width('100%') + .height('100%') } - ``` + } + ``` - ![](figures/en-us_image_0000001192595228.png) + ![en-us_image_0000001212058498](figures/en-us_image_0000001212058498.png) -### lineTo +### lineTo -lineTo\(x: number, y: number\): void +lineTo(x: number, y: number): void Connects the current point to a target position using a straight line. -- Parameters - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

x

-

number

-

Yes

-

0

-

X-coordinate of the target position.

-

y

-

number

-

Yes

-

0

-

Y-coordinate of the target position.

-
- - -- Example - - ``` - @Entry - @Component - struct LineTo { - private settings: RenderingContextSettings = new RenderingContextSettings(true) - private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) - private offContext: OffscreenCanvasRenderingContext2D = new OffscreenCanvasRenderingContext2D(600, 600, this.settings) - build() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Canvas(this.context) - .width('100%') - .height('100%') - .backgroundColor('#ffff00') - .onReady(() =>{ - this.offContext.beginPath() - this.offContext.moveTo(10, 10) - this.offContext.lineTo(280, 160) - this.offContext.stroke() - var image = this.offContext.transferToImageBitmap() - this.context.transferFromImageBitmap(image) - }) - } - .width('100%') - .height('100%') +- Parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | x | number | Yes | 0 | X-coordinate of the target position. | + | y | number | Yes | 0 | Y-coordinate of the target position. | + +- Example + + ``` + @Entry + @Component + struct LineTo { + private settings: RenderingContextSettings = new RenderingContextSettings(true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + private offContext: OffscreenCanvasRenderingContext2D = new OffscreenCanvasRenderingContext2D(600, 600, this.settings) + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.offContext.beginPath() + this.offContext.moveTo(10, 10) + this.offContext.lineTo(280, 160) + this.offContext.stroke() + var image = this.offContext.transferToImageBitmap() + this.context.transferFromImageBitmap(image) + }) } + .width('100%') + .height('100%') } - ``` + } + ``` - ![](figures/en-us_image_0000001237715151.png) + ![en-us_image_0000001257058435](figures/en-us_image_0000001257058435.png) -### closePath +### closePath -closePath\(\): void +closePath(): void Draws a closed path. -- Example - - ``` - @Entry - @Component - struct ClosePath { - private settings: RenderingContextSettings = new RenderingContextSettings(true) - private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) - private offContext: OffscreenCanvasRenderingContext2D = new OffscreenCanvasRenderingContext2D(600, 600, this.settings) - build() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Canvas(this.context) - .width('100%') - .height('100%') - .backgroundColor('#ffff00') - .onReady(() =>{ - this.offContext.beginPath() - this.offContext.moveTo(30, 30) - this.offContext.lineTo(110, 30) - this.offContext.lineTo(70, 90) - this.offContext.closePath() - this.offContext.stroke() - var image = this.offContext.transferToImageBitmap() - this.context.transferFromImageBitmap(image) - }) - } - .width('100%') - .height('100%') +- Example + + ``` + @Entry + @Component + struct ClosePath { + private settings: RenderingContextSettings = new RenderingContextSettings(true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + private offContext: OffscreenCanvasRenderingContext2D = new OffscreenCanvasRenderingContext2D(600, 600, this.settings) + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.offContext.beginPath() + this.offContext.moveTo(30, 30) + this.offContext.lineTo(110, 30) + this.offContext.lineTo(70, 90) + this.offContext.closePath() + this.offContext.stroke() + var image = this.offContext.transferToImageBitmap() + this.context.transferFromImageBitmap(image) + }) } + .width('100%') + .height('100%') } - ``` + } + ``` - ![](figures/en-us_image_0000001192595224.png) + ![en-us_image_0000001257058431](figures/en-us_image_0000001257058431.png) -### createPattern +### createPattern -createPattern\(image: ImageBitmap, repetition: string\): CanvasPattern +createPattern(image: ImageBitmap, repetition: string): CanvasPattern Creates a pattern for image filling based on a specified source image and repetition mode. -- Parameters - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

image

-

ImageBitmap

-

Yes

-

null

-

Source image. For details, see ImageBitmap.

-

repetition

-

string

-

Yes

-

""

-

Repetition mode. The value can be 'repeat', 'repeat-x', 'repeat-y', or 'no-repeat'.

-
- -- Example - - ``` - @Entry - @Component - struct CreatePattern { - private settings: RenderingContextSettings = new RenderingContextSettings(true) - private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) - private img:ImageBitmap = new ImageBitmap("common/images/icon.jpg") - private offContext: OffscreenCanvasRenderingContext2D = new OffscreenCanvasRenderingContext2D(600, 600, this.settings) - build() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Canvas(this.context) - .width('100%') - .height('100%') - .backgroundColor('#ffff00') - .onReady(() =>{ - var pattern = this.offContext.createPattern(this.img, 'repeat') - this.offContext.fillStyle = pattern - this.offContext.fillRect(0, 0, 200, 200) - var image = this.offContext.transferToImageBitmap() - this.context.transferFromImageBitmap(image) - }) - } - .width('100%') - .height('100%') +- Parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | image | [ERROR:Invalid link:en-us_topic_0000001212218420.xml#en-us_topic_0000001192595178_xref1892917323814,link:en-us_topic_0000001192915114.xml](en-us_topic_0000001192915114.xml) | Yes | null | Source image. For details, see [ERROR:Invalid link:en-us_topic_0000001212218420.xml#xref13437192515430,link:en-us_topic_0000001192915114.xml](en-us_topic_0000001192915114.xml). | + | repetition | string | Yes | "" | Repetition mode. The value can be **'repeat'**, **'repeat-x'**, **'repeat-y'**, or **'no-repeat'**. | + +- Example + + ``` + @Entry + @Component + struct CreatePattern { + private settings: RenderingContextSettings = new RenderingContextSettings(true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + private img:ImageBitmap = new ImageBitmap("common/images/icon.jpg") + private offContext: OffscreenCanvasRenderingContext2D = new OffscreenCanvasRenderingContext2D(600, 600, this.settings) + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + var pattern = this.offContext.createPattern(this.img, 'repeat') + this.offContext.fillStyle = pattern + this.offContext.fillRect(0, 0, 200, 200) + var image = this.offContext.transferToImageBitmap() + this.context.transferFromImageBitmap(image) + }) } + .width('100%') + .height('100%') } - ``` + } + ``` - ![](figures/en-us_image_0000001237475133.png) + ![en-us_image_0000001257138387](figures/en-us_image_0000001257138387.png) -### bezierCurveTo +### bezierCurveTo -bezierCurveTo\(cp1x: number, cp1y: number, cp2x: number, cp2y: number, x: number, y: number\): void +bezierCurveTo(cp1x: number, cp1y: number, cp2x: number, cp2y: number, x: number, y: number): void Draws a cubic bezier curve on the canvas. -- Parameters - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

cp1x

-

number

-

Yes

-

0

-

X-coordinate of the first parameter of the bezier curve.

-

cp1y

-

number

-

Yes

-

0

-

Y-coordinate of the first parameter of the bezier curve.

-

cp2x

-

number

-

Yes

-

0

-

X-coordinate of the second parameter of the bezier curve.

-

cp2y

-

number

-

Yes

-

0

-

Y-coordinate of the second parameter of the bezier curve.

-

x

-

number

-

Yes

-

0

-

X-coordinate of the end point on the bezier curve.

-

y

-

number

-

Yes

-

0

-

Y-coordinate of the end point on the bezier curve.

-
- - -- Example - - ``` - @Entry - @Component - struct BezierCurveTo { - private settings: RenderingContextSettings = new RenderingContextSettings(true) - private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) - private offContext: OffscreenCanvasRenderingContext2D = new OffscreenCanvasRenderingContext2D(600, 600, this.settings) - build() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Canvas(this.context) - .width('100%') - .height('100%') - .backgroundColor('#ffff00') - .onReady(() =>{ - this.offContext.beginPath() - this.offContext.moveTo(10, 10) - this.offContext.bezierCurveTo(20, 100, 200, 100, 200, 20) - this.offContext.stroke() - var image = this.offContext.transferToImageBitmap() - this.context.transferFromImageBitmap(image) - }) - } - .width('100%') - .height('100%') +- Name + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | cp1x | number | Yes | 0 | X-coordinate of the first parameter of the bezier curve. | + | cp1y | number | Yes | 0 | Y-coordinate of the first parameter of the bezier curve. | + | cp2x | number | Yes | 0 | X-coordinate of the second parameter of the bezier curve. | + | cp2y | number | Yes | 0 | Y-coordinate of the second parameter of the bezier curve. | + | x | number | Yes | 0 | X-coordinate of the end point on the bezier curve. | + | y | number | Yes | 0 | Y-coordinate of the end point on the bezier curve. | + +- Example + + ``` + @Entry + @Component + struct BezierCurveTo { + private settings: RenderingContextSettings = new RenderingContextSettings(true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + private offContext: OffscreenCanvasRenderingContext2D = new OffscreenCanvasRenderingContext2D(600, 600, this.settings) + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.offContext.beginPath() + this.offContext.moveTo(10, 10) + this.offContext.bezierCurveTo(20, 100, 200, 100, 200, 20) + this.offContext.stroke() + var image = this.offContext.transferToImageBitmap() + this.context.transferFromImageBitmap(image) + }) } + .width('100%') + .height('100%') } - ``` + } + ``` - ![](figures/en-us_image_0000001237715153.png) + ![en-us_image_0000001212378442](figures/en-us_image_0000001212378442.png) -### quadraticCurveTo +### quadraticCurveTo -quadraticCurveTo\(cpx: number, cpy: number, x: number, y: number\): void +quadraticCurveTo(cpx: number, cpy: number, x: number, y: number): void Draws a quadratic curve on the canvas. -- Parameters - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

cpx

-

number

-

Yes

-

0

-

X-coordinate of the bezier curve parameter.

-

cpy

-

number

-

Yes

-

0

-

Y-coordinate of the bezier curve parameter.

-

x

-

number

-

Yes

-

0

-

X-coordinate of the end point on the bezier curve.

-

y

-

number

-

Yes

-

0

-

Y-coordinate of the end point on the bezier curve.

-
- - -- Example - - ``` - @Entry - @Component - struct QuadraticCurveTo { - private settings: RenderingContextSettings = new RenderingContextSettings(true) - private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) - private offContext: OffscreenCanvasRenderingContext2D = new OffscreenCanvasRenderingContext2D(600, 600, this.settings) - build() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Canvas(this.context) - .width('100%') - .height('100%') - .backgroundColor('#ffff00') - .onReady(() =>{ - this.offContext.beginPath(); - this.offContext.moveTo(20, 20); - this.offContext.quadraticCurveTo(100, 100, 200, 20); - this.offContext.stroke(); - var image = this.offContext.transferToImageBitmap() - this.context.transferFromImageBitmap(image) - }) - } - .width('100%') - .height('100%') +- Parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | cpx | number | Yes | 0 | X-coordinate of the bezier curve parameter. | + | cpy | number | Yes | 0 | Y-coordinate of the bezier curve parameter. | + | x | number | Yes | 0 | X-coordinate of the end point on the bezier curve. | + | y | number | Yes | 0 | Y-coordinate of the end point on the bezier curve. | + +- Example + + ``` + @Entry + @Component + struct QuadraticCurveTo { + private settings: RenderingContextSettings = new RenderingContextSettings(true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + private offContext: OffscreenCanvasRenderingContext2D = new OffscreenCanvasRenderingContext2D(600, 600, this.settings) + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.offContext.beginPath(); + this.offContext.moveTo(20, 20); + this.offContext.quadraticCurveTo(100, 100, 200, 20); + this.offContext.stroke(); + var image = this.offContext.transferToImageBitmap() + this.context.transferFromImageBitmap(image) + }) } + .width('100%') + .height('100%') } - ``` + } + ``` - ![](figures/en-us_image_0000001192915184.png) + ![en-us_image_0000001256978383](figures/en-us_image_0000001256978383.png) -### arc +### arc -arc\(x: number, y: number, radius: number, startAngle: number, endAngle: number, anticlockwise?: boolean\): void +arc(x: number, y: number, radius: number, startAngle: number, endAngle: number, anticlockwise?: boolean): void Draws an arc on the canvas. -- Parameters - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

x

-

number

-

Yes

-

0

-

X-coordinate of the center point of the arc.

-

y

-

number

-

Yes

-

0

-

Y-coordinate of the center point of the arc.

-

radius

-

number

-

Yes

-

0

-

Radius of the arc.

-

startAngle

-

number

-

Yes

-

0

-

Start radian of the arc.

-

endAngle

-

number

-

Yes

-

0

-

End radian of the arc.

-

anticlockwise

-

boolean

-

No

-

false

-

Whether to draw the arc counterclockwise.

-
- -- Example - - ``` - @Entry - @Component - struct Arc { - private settings: RenderingContextSettings = new RenderingContextSettings(true) - private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) - private offContext: OffscreenCanvasRenderingContext2D = new OffscreenCanvasRenderingContext2D(600, 600, this.settings) - build() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Canvas(this.context) - .width('100%') - .height('100%') - .backgroundColor('#ffff00') - .onReady(() =>{ - this.offContext.beginPath() - this.offContext.arc(100, 75, 50, 0, 6.28) - this.offContext.stroke() - var image = this.offContext.transferToImageBitmap() - this.context.transferFromImageBitmap(image) - }) - } - .width('100%') - .height('100%') +- Parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | x | number | Yes | 0 | X-coordinate of the center point of the arc. | + | y | number | Yes | 0 | Y-coordinate of the center point of the arc. | + | radius | number | Yes | 0 | Radius of the arc. | + | startAngle | number | Yes | 0 | Start radian of the arc. | + | endAngle | number | Yes | 0 | End radian of the arc. | + | anticlockwise | boolean | No | false | Whether to draw the arc counterclockwise. | + +- Example + + ``` + @Entry + @Component + struct Arc { + private settings: RenderingContextSettings = new RenderingContextSettings(true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + private offContext: OffscreenCanvasRenderingContext2D = new OffscreenCanvasRenderingContext2D(600, 600, this.settings) + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.offContext.beginPath() + this.offContext.arc(100, 75, 50, 0, 6.28) + this.offContext.stroke() + var image = this.offContext.transferToImageBitmap() + this.context.transferFromImageBitmap(image) + }) } + .width('100%') + .height('100%') } - ``` + } + ``` - ![](figures/en-us_image_0000001192595226.png) + ![en-us_image_0000001212378430](figures/en-us_image_0000001212378430.png) -### arcTo +### arcTo -arcTo\(x1: number, y1: number, x2: number, y2: number, radius: number\): void +arcTo(x1: number, y1: number, x2: number, y2: number, radius: number): void Draws an arc based on the radius and points on the arc. -- Parameters - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

x1

-

number

-

Yes

-

0

-

X-coordinate of the first point on the arc.

-

y1

-

number

-

Yes

-

0

-

Y-coordinate of the first point on the arc.

-

x2

-

number

-

Yes

-

0

-

X-coordinate of the second point on the arc.

-

y2

-

number

-

Yes

-

0

-

Y-coordinate of the second point on the arc.

-

radius

-

number

-

Yes

-

0

-

Radius of the arc.

-
- - -- Example - - ``` - @Entry - @Component - struct ArcTo { - private settings: RenderingContextSettings = new RenderingContextSettings(true) - private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) - private offContext: OffscreenCanvasRenderingContext2D = new OffscreenCanvasRenderingContext2D(600, 600, this.settings) - build() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Canvas(this.context) - .width('100%') - .height('100%') - .backgroundColor('#ffff00') - .onReady(() =>{ - this.offContext.moveTo(100, 20); - this.offContext.arcTo(150, 20, 150, 70, 50); - this.offContext.stroke(); - var image = this.offContext.transferToImageBitmap() - this.context.transferFromImageBitmap(image) - }) - } - .width('100%') - .height('100%') +- Parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | x1 | number | Yes | 0 | X-coordinate of the first point on the arc. | + | y1 | number | Yes | 0 | Y-coordinate of the first point on the arc. | + | x2 | number | Yes | 0 | X-coordinate of the second point on the arc. | + | y2 | number | Yes | 0 | Y-coordinate of the second point on the arc. | + | radius | number | Yes | 0 | Radius of the arc. | + +- Example + + ``` + @Entry + @Component + struct ArcTo { + private settings: RenderingContextSettings = new RenderingContextSettings(true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + private offContext: OffscreenCanvasRenderingContext2D = new OffscreenCanvasRenderingContext2D(600, 600, this.settings) + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.offContext.moveTo(100, 20); + this.offContext.arcTo(150, 20, 150, 70, 50); + this.offContext.stroke(); + var image = this.offContext.transferToImageBitmap() + this.context.transferFromImageBitmap(image) + }) } + .width('100%') + .height('100%') } - ``` + } + ``` - ![](figures/en-us_image_0000001237555167.png) + ![en-us_image_0000001257138383](figures/en-us_image_0000001257138383.png) -### ellipse +### ellipse -ellipse\(x: number, y: number, radiusX: number, radiusY: number, rotation: number, startAngle: number, endAngle: number, anticlockwise?: boolean\): void +ellipse(x: number, y: number, radiusX: number, radiusY: number, rotation: number, startAngle: number, endAngle: number, anticlockwise?: boolean): void Draws an ellipse in the specified rectangular region. -- Parameters - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

x

-

number

-

Yes

-

0

-

X-coordinate of the ellipse center.

-

y

-

number

-

Yes

-

0

-

Y-coordinate of the ellipse center.

-

radiusX

-

number

-

Yes

-

0

-

Ellipse radius on the x-axis.

-

radiusY

-

number

-

Yes

-

0

-

Ellipse radius on the y-axis.

-

rotation

-

number

-

Yes

-

0

-

Rotation angle of the ellipse, in radians.

-

startAngle

-

number

-

Yes

-

0

-

Angle of the start point for drawing the ellipse, in radians.

-

endAngle

-

number

-

Yes

-

0

-

Angle of the end point for drawing the ellipse, in radians.

-

anticlockwise

-

boolean

-

No

-

false

-

Whether to draw the ellipse in the counterclockwise direction. The value 0 means to draw the ellipse in the clockwise direction, and 1 means to draw the ellipse in the counterclockwise direction. This parameter is optional. The default value is 0.

-
- - -- Example - - ``` - @Entry - @Component - struct CanvasExample { - private settings: RenderingContextSettings = new RenderingContextSettings(true) - private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) - private offContext: OffscreenCanvasRenderingContext2D = new OffscreenCanvasRenderingContext2D(600, 600, this.settings) - build() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Canvas(this.context) - .width('100%') - .height('100%') - .backgroundColor('#ffff00') - .onReady(() =>{ - this.offContext.beginPath() - this.offContext.ellipse(200, 200, 50, 100, Math.PI * 0.25, Math.PI * 0.5, Math.PI, true) - this.offContext.stroke() - var image = this.offContext.transferToImageBitmap() - this.context.transferFromImageBitmap(image) - }) - } - .width('100%') - .height('100%') +- Parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | x | number | Yes | 0 | X-coordinate of the ellipse center. | + | y | number | Yes | 0 | Y-coordinate of the ellipse center. | + | radiusX | number | Yes | 0 | Ellipse radius on the x-axis. | + | radiusY | number | Yes | 0 | Ellipse radius on the y-axis. | + | rotation | number | Yes | 0 | Rotation angle of the ellipse, in radians. | + | startAngle | number | Yes | 0 | Angle of the start point for drawing the ellipse, in radians. | + | endAngle | number | Yes | 0 | Angle of the end point for drawing the ellipse, in radians. | + | anticlockwise | boolean | No | false | Whether to draw the ellipse in the counterclockwise direction. | + +- Example + + + ``` + @Entry + @Component + struct CanvasExample { + private settings: RenderingContextSettings = new RenderingContextSettings(true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + private offContext: OffscreenCanvasRenderingContext2D = new OffscreenCanvasRenderingContext2D(600, 600, this.settings) + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.offContext.beginPath() + this.offContext.ellipse(200, 200, 50, 100, Math.PI * 0.25, Math.PI * 0.5, Math.PI) + this.offContext.stroke() + var image = this.offContext.transferToImageBitmap() + this.context.transferFromImageBitmap(image) + }) } + .width('100%') + .height('100%') } - ``` + } + ``` - ![](figures/en-us_image_0000001237355131.png) + ![en-us_image_0000001256858423](figures/en-us_image_0000001256858423.png) -### rect +### rect -rect\(x: number, y: number, width: number, height: number\): void +rect(x: number, y: number, width: number, height: number): void Creates a rectangle. -- Parameters - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

x

-

number

-

Yes

-

0

-

X-coordinate of the upper left corner of the rectangle.

-

y

-

number

-

Yes

-

0

-

Y-coordinate of the upper left corner of the rectangle.

-

width

-

number

-

Yes

-

0

-

Width of the rectangle.

-

height

-

number

-

Yes

-

0

-

Height of the rectangle.

-
- - -- Example - - ``` - @Entry - @Component - struct CanvasExample { - private settings: RenderingContextSettings = new RenderingContextSettings(true) - private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) - private offContext: OffscreenCanvasRenderingContext2D = new OffscreenCanvasRenderingContext2D(600, 600, this.settings) - build() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Canvas(this.context) - .width('100%') - .height('100%') - .backgroundColor('#ffff00') - .onReady(() =>{ - this.offContext.rect(20, 20, 100, 100) // Create a 100*100 rectangle at (20, 20) - this.offContext.stroke() - var image = this.offContext.transferToImageBitmap() - this.context.transferFromImageBitmap(image) - }) - } - .width('100%') - .height('100%') +- Parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | x | number | Yes | 0 | X-coordinate of the upper left corner of the rectangle. | + | y | number | Yes | 0 | Y-coordinate of the upper left corner of the rectangle. | + | width | number | Yes | 0 | Width of the rectangle. | + | height | number | Yes | 0 | Height of the rectangle. | + +- Example + + ``` + @Entry + @Component + struct CanvasExample { + private settings: RenderingContextSettings = new RenderingContextSettings(true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + private offContext: OffscreenCanvasRenderingContext2D = new OffscreenCanvasRenderingContext2D(600, 600, this.settings) + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.offContext.rect(20, 20, 100, 100) // Create a 100*100 rectangle at (20, 20) + this.offContext.stroke() + var image = this.offContext.transferToImageBitmap() + this.context.transferFromImageBitmap(image) + }) } + .width('100%') + .height('100%') } - ``` + } + ``` - ![](figures/en-us_image_0000001237715155.png) + ![en-us_image_0000001257138381](figures/en-us_image_0000001257138381.png) -### fill +### fill -fill\(\): void +fill(): void Fills the area inside a closed path. -- Example - - ``` - @Entry - @Component - struct Fill { - private settings: RenderingContextSettings = new RenderingContextSettings(true) - private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) - private offContext: OffscreenCanvasRenderingContext2D = new OffscreenCanvasRenderingContext2D(600, 600, this.settings) - build() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Canvas(this.context) - .width('100%') - .height('100%') - .backgroundColor('#ffff00') - .onReady(() =>{ - this.offContext.rect(20, 20, 100, 100) // Create a 100*100 rectangle at (20, 20) - this.offContext.fill() - var image = this.offContext.transferToImageBitmap() - this.context.transferFromImageBitmap(image) - }) - } - .width('100%') - .height('100%') +- Example + + ``` + @Entry + @Component + struct Fill { + private settings: RenderingContextSettings = new RenderingContextSettings(true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + private offContext: OffscreenCanvasRenderingContext2D = new OffscreenCanvasRenderingContext2D(600, 600, this.settings) + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.offContext.rect(20, 20, 100, 100) // Create a 100*100 rectangle at (20, 20) + this.offContext.fill() + var image = this.offContext.transferToImageBitmap() + this.context.transferFromImageBitmap(image) + }) } + .width('100%') + .height('100%') } - ``` + } + ``` - ![](figures/en-us_image_0000001193075166.png) + ![en-us_image_0000001256858421](figures/en-us_image_0000001256858421.png) -### clip +### clip -clip\(\): void +clip(): void Sets the current path to a clipping path. -- Example - - ``` - @Entry - @Component - struct Clip { - private settings: RenderingContextSettings = new RenderingContextSettings(true) - private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) - private offContext: OffscreenCanvasRenderingContext2D = new OffscreenCanvasRenderingContext2D(600, 600, this.settings) - build() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Canvas(this.context) - .width('100%') - .height('100%') - .backgroundColor('#ffff00') - .onReady(() =>{ - this.offContext.rect(0, 0, 200, 200) - this.offContext.stroke() - this.offContext.clip() - this.offContext.fillStyle = "rgb(255,0,0)" - this.offContext.fillRect(0, 0, 150, 150) - var image = this.offContext.transferToImageBitmap() - this.context.transferFromImageBitmap(image) - }) - } - .width('100%') - .height('100%') +- Example + + ``` + @Entry + @Component + struct Clip { + private settings: RenderingContextSettings = new RenderingContextSettings(true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + private offContext: OffscreenCanvasRenderingContext2D = new OffscreenCanvasRenderingContext2D(600, 600, this.settings) + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.offContext.rect(0, 0, 200, 200) + this.offContext.stroke() + this.offContext.clip() + this.offContext.fillStyle = "rgb(255,0,0)" + this.offContext.fillRect(0, 0, 150, 150) + var image = this.offContext.transferToImageBitmap() + this.context.transferFromImageBitmap(image) + }) } + .width('100%') + .height('100%') } - ``` + } + ``` - ![](figures/en-us_image_0000001192595238.png) + ![en-us_image_0000001257058441](figures/en-us_image_0000001257058441.png) -### rotate +### rotate -rotate\(rotate: number\): void +rotate(rotate: number): void Rotates a canvas clockwise around its coordinate axes. -- Parameters - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

rotate

-

number

-

Yes

-

0

-

Clockwise rotation angle. You can use Math.PI / 180 to convert the angle to a radian.

-
- - -- Example - - ``` - @Entry - @Component - struct Rotate { - private settings: RenderingContextSettings = new RenderingContextSettings(true) - private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) - private offContext: OffscreenCanvasRenderingContext2D = new OffscreenCanvasRenderingContext2D(600, 600, this.settings) - build() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Canvas(this.context) - .width('100%') - .height('100%') - .backgroundColor('#ffff00') - .onReady(() =>{ - this.offContext.rotate(45 * Math.PI / 180) // Rotate the rectangle 45 degrees - this.offContext.fillRect(70, 20, 50, 50) - var image = this.offContext.transferToImageBitmap() - this.context.transferFromImageBitmap(image) - }) - } - .width('100%') - .height('100%') +- Parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | rotate | number | Yes | 0 | Clockwise rotation angle. You can use **Math.PI / 180** to convert the angle to a radian. | + +- Example + + ``` + @Entry + @Component + struct Rotate { + private settings: RenderingContextSettings = new RenderingContextSettings(true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + private offContext: OffscreenCanvasRenderingContext2D = new OffscreenCanvasRenderingContext2D(600, 600, this.settings) + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.offContext.rotate(45 * Math.PI / 180) // Rotate the rectangle 45 degrees + this.offContext.fillRect(70, 20, 50, 50) + var image = this.offContext.transferToImageBitmap() + this.context.transferFromImageBitmap(image) + }) } + .width('100%') + .height('100%') } - ``` - - ![](figures/en-us_image_0000001237355133.png) - - -### scale - -scale\(x: number, y: number\): void - -Scales a canvas based on scaling factors. - -- Parameters - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

x

-

number

-

Yes

-

0

-

Horizontal scale factor.

-

y

-

number

-

Yes

-

0

-

Vertical scale factor.

-
- - -- Example - - ``` - @Entry - @Component - struct Scale { - private settings: RenderingContextSettings = new RenderingContextSettings(true) - private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) - private offContext: OffscreenCanvasRenderingContext2D = new OffscreenCanvasRenderingContext2D(600, 600, this.settings) - build() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Canvas(this.context) - .width('100%') - .height('100%') - .backgroundColor('#ffff00') - .onReady(() =>{ - this.offContext.strokeRect(10, 10, 25, 25) - this.offContext.scale(2, 2) // Scale to 200% - this.offContext.strokeRect(10, 10, 25, 25) - var image = this.offContext.transferToImageBitmap() - this.context.transferFromImageBitmap(image) - }) - } - .width('100%') - .height('100%') + } + ``` + + ![en-us_image_0000001212218478](figures/en-us_image_0000001212218478.png) + + +### scale + +scale(x: number, y: number): void + +Scales a canvas based on scale factors. + +- Parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | x | number | Yes | 0 | Horizontal scale factor. | + | y | number | Yes | 0 | Vertical scale factor. | + +- Example + + ``` + @Entry + @Component + struct Scale { + private settings: RenderingContextSettings = new RenderingContextSettings(true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + private offContext: OffscreenCanvasRenderingContext2D = new OffscreenCanvasRenderingContext2D(600, 600, this.settings) + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.offContext.strokeRect(10, 10, 25, 25) + this.offContext.scale(2, 2) // Scale to 200% + this.offContext.strokeRect(10, 10, 25, 25) + var image = this.offContext.transferToImageBitmap() + this.context.transferFromImageBitmap(image) + }) } + .width('100%') + .height('100%') } - ``` + } + ``` - ![](figures/en-us_image_0000001192755178.png) + ![en-us_image_0000001211898516](figures/en-us_image_0000001211898516.png) -### transform +### transform -transform\(scaleX: number, skewX: number, skewY: number, scaleY: number, translateX: number, translateY: number\): void +transform(scaleX: number, skewX: number, skewY: number, scaleY: number, translateX: number, translateY: number): void Defines a transformation matrix. To transform a graph, you only need to set parameters of the matrix. The coordinates of the graph are multiplied by the matrix values to obtain new coordinates of the transformed graph. You can use the matrix to implement multiple transform effects. ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->The following formulas calculate coordinates of the transformed graph. **x** and **y** represent coordinates before transformation, and **x'** and **y'** represent coordinates after transformation. ->- x' = scaleX \* x + skewY \* y + translateX ->- y' = skewX \* x + scaleY \* y + translateY - -- Parameters - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

scaleX

-

number

-

Yes

-

0

-

X-axis scale.

-

skewX

-

number

-

Yes

-

0

-

X-axis skew.

-

skewY

-

number

-

Yes

-

0

-

Y-axis skew.

-

scaleY

-

number

-

Yes

-

0

-

Y-axis scale.

-

translateX

-

number

-

Yes

-

0

-

X-axis translation.

-

translateY

-

number

-

Yes

-

0

-

Y-axis translation.

-
- -- Example - - ``` - @Entry - @Component - struct Transform { - private settings: RenderingContextSettings = new RenderingContextSettings(true) - private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) - private offContext: OffscreenCanvasRenderingContext2D = new OffscreenCanvasRenderingContext2D(600, 600, this.settings) - build() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Canvas(this.context) - .width('100%') - .height('100%') - .backgroundColor('#ffff00') - .onReady(() =>{ - this.offContext.fillStyle = 'rgb(0,0,0)' - this.offContext.fillRect(0, 0, 100, 100) - this.offContext.transform(1, 0.5, -0.5, 1, 10, 10) - this.offContext.fillStyle = 'rgb(255,0,0)' - this.offContext.fillRect(0, 0, 100, 100) - this.offContext.transform(1, 0.5, -0.5, 1, 10, 10) - this.offContext.fillStyle = 'rgb(0,0,255)' - this.offContext.fillRect(0, 0, 100, 100) - var image = this.offContext.transferToImageBitmap() - this.context.transferFromImageBitmap(image) - }) - } - .width('100%') - .height('100%') +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** +> The following formulas calculate coordinates of the transformed graph. **x** and **y** represent coordinates before transformation, and **x'** and **y'** represent coordinates after transformation. +> +> - x' = scaleX \* x + skewY \* y + translateX +> +> - y' = skewX \* x + scaleY \* y + translateY + +- Parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | scaleX | number | Yes | 0 | X-axis scale. | + | skewX | number | Yes | 0 | X-axis skew. | + | skewY | number | Yes | 0 | Y-axis skew. | + | scaleY | number | Yes | 0 | Y-axis scale. | + | translateX | number | Yes | 0 | X-axis translation. | + | translateY | number | Yes | 0 | Y-axis translation. | + +- Example + + ``` + @Entry + @Component + struct Transform { + private settings: RenderingContextSettings = new RenderingContextSettings(true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + private offContext: OffscreenCanvasRenderingContext2D = new OffscreenCanvasRenderingContext2D(600, 600, this.settings) + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.offContext.fillStyle = 'rgb(0,0,0)' + this.offContext.fillRect(0, 0, 100, 100) + this.offContext.transform(1, 0.5, -0.5, 1, 10, 10) + this.offContext.fillStyle = 'rgb(255,0,0)' + this.offContext.fillRect(0, 0, 100, 100) + this.offContext.transform(1, 0.5, -0.5, 1, 10, 10) + this.offContext.fillStyle = 'rgb(0,0,255)' + this.offContext.fillRect(0, 0, 100, 100) + var image = this.offContext.transferToImageBitmap() + this.context.transferFromImageBitmap(image) + }) } + .width('100%') + .height('100%') } - ``` - - ![](figures/en-us_image_0000001192595230.png) - - -### setTransform - -setTransform\(scaleX: number, skewX: number, skewY: number, scale: number, translateX: number, translateY: number\): void - -Resets the existing transformation matrix and creates a new transformation matrix by using the same parameters as the **transform\(\)** function. - -- Parameters - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

scaleX

-

number

-

Yes

-

0

-

X-axis scale.

-

skewX

-

number

-

Yes

-

0

-

X-axis skew.

-

skewY

-

number

-

Yes

-

0

-

Y-axis skew.

-

scaleY

-

number

-

Yes

-

0

-

Y-axis scale.

-

translateX

-

number

-

Yes

-

0

-

X-axis translation.

-

translateY

-

number

-

Yes

-

0

-

Y-axis translation.

-
- -- Example - - ``` - @Entry - @Component - struct SetTransform { - private settings: RenderingContextSettings = new RenderingContextSettings(true) - private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) - private offContext: OffscreenCanvasRenderingContext2D = new OffscreenCanvasRenderingContext2D(600, 600, this.settings) - build() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Canvas(this.context) - .width('100%') - .height('100%') - .backgroundColor('#ffff00') - .onReady(() =>{ - this.offContext.fillStyle = 'rgb(255,0,0)' - this.offContext.fillRect(0, 0, 100, 100) - this.offContext.setTransform(1,0.5, -0.5, 1, 10, 10) - this.offContext.fillStyle = 'rgb(0,0,255)' - this.offContext.fillRect(0, 0, 100, 100) - var image = this.offContext.transferToImageBitmap() - this.context.transferFromImageBitmap(image) - }) - } - .width('100%') - .height('100%') + } + ``` + + ![en-us_image_0000001212378438](figures/en-us_image_0000001212378438.png) + + +### setTransform + +setTransform(scaleX: number, skewX: number, skewY: number, scale: number, translateX: number, translateY: number): void + +Resets the existing transformation matrix and creates a new transformation matrix by using the same parameters as the **transform()** function. + +- Parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | scaleX | number | Yes | 0 | X-axis scale. | + | skewX | number | Yes | 0 | X-axis skew. | + | skewY | number | Yes | 0 | Y-axis skew. | + | scaleY | number | Yes | 0 | Y-axis scale. | + | translateX | number | Yes | 0 | X-axis translation. | + | translateY | number | Yes | 0 | Y-axis translation. | + +- Example + + ``` + @Entry + @Component + struct SetTransform { + private settings: RenderingContextSettings = new RenderingContextSettings(true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + private offContext: OffscreenCanvasRenderingContext2D = new OffscreenCanvasRenderingContext2D(600, 600, this.settings) + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.offContext.fillStyle = 'rgb(255,0,0)' + this.offContext.fillRect(0, 0, 100, 100) + this.offContext.setTransform(1,0.5, -0.5, 1, 10, 10) + this.offContext.fillStyle = 'rgb(0,0,255)' + this.offContext.fillRect(0, 0, 100, 100) + var image = this.offContext.transferToImageBitmap() + this.context.transferFromImageBitmap(image) + }) } + .width('100%') + .height('100%') } - ``` + } + ``` - ![](figures/en-us_image_0000001237715159.png) + ![en-us_image_0000001211898518](figures/en-us_image_0000001211898518.png) -### translate +### translate -translate\(x: number, y: number\): void +translate(x: number, y: number): void Moves the origin of the coordinate system. -- Parameters - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

x

-

number

-

Yes

-

0

-

X-axis translation

-

y

-

number

-

Yes

-

0

-

Y-axis translation.

-
- -- Example - - ``` - @Entry - @Component - struct Translate { - private settings: RenderingContextSettings = new RenderingContextSettings(true) - private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) - private offContext: OffscreenCanvasRenderingContext2D = new OffscreenCanvasRenderingContext2D(600, 600, this.settings) - build() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Canvas(this.context) - .width('100%') - .height('100%') - .backgroundColor('#ffff00') - .onReady(() =>{ - this.offContext.fillRect(10, 10, 50, 50) - this.offContext.translate(70, 70) - this.offContext.fillRect(10, 10, 50, 50) - var image = this.offContext.transferToImageBitmap() - this.context.transferFromImageBitmap(image) - }) - } +- Parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | x | number | Yes | 0 | X-axis translation. | + | y | number | Yes | 0 | Y-axis translation. | + +- Example + + ``` + @Entry + @Component + struct Translate { + private settings: RenderingContextSettings = new RenderingContextSettings(true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + private offContext: OffscreenCanvasRenderingContext2D = new OffscreenCanvasRenderingContext2D(600, 600, this.settings) + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.offContext.fillRect(10, 10, 50, 50) + this.offContext.translate(70, 70) + this.offContext.fillRect(10, 10, 50, 50) + var image = this.offContext.transferToImageBitmap() + this.context.transferFromImageBitmap(image) + }) + } + .width('100%') + .height('100%') + } + } + ``` + + ![en-us_image_0000001256978373](figures/en-us_image_0000001256978373.png) + + +### drawImage + +drawImage(image: ImageBitmap, dx: number, dy: number): void + +drawImage(image: ImageBitmap, dx: number, dy: number, dWidth: number, dHeight: number): void + +drawImage(image: ImageBitmap, sx: number, sy: number, sWidth: number, sHeight: number, dx: number, dy: number, dWidth: number, dHeight: number):void + +Draws an image. + +- Parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | image | [ERROR:Invalid link:en-us_topic_0000001212218420.xml#en-us_topic_0000001192595178_xref2365443135017,link:en-us_topic_0000001192915114.xml](en-us_topic_0000001192915114.xml) | Yes | null | Image resource. For details, see [ERROR:Invalid link:en-us_topic_0000001212218420.xml#xref10476113612499,link:en-us_topic_0000001192915114.xml](en-us_topic_0000001192915114.xml). | + | sx | number | No | 0 | X-coordinate of the upper left corner of the rectangle used to crop the source image. | + | sy | number | No | 0 | Y-coordinate of the upper left corner of the rectangle used to crop the source image. | + | sWidth | number | No | 0 | Target width to crop the source image. | + | sHeight | number | No | 0 | Target height to crop the source image. | + | dx | number | Yes | 0 | X-coordinate of the upper left corner of the drawing area on the canvas. | + | dy | number | Yes | 0 | Y-coordinate of the upper left corner of the drawing area on the canvas. | + | dWidth | number | No | 0 | Width of the drawing area. | + | dHeight | number | No | 0 | Height of the drawing area. | + + +- Example + + ``` + @Entry + @Component + struct Index { + private settings: RenderingContextSettings = new RenderingContextSettings(true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + private img:ImageBitmap = new ImageBitmap("common/images/icon.jpg") + private offContext: OffscreenCanvasRenderingContext2D = new OffscreenCanvasRenderingContext2D(600, 600, this.settings) + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) .width('100%') .height('100%') + .backgroundColor('#ffff00') + .onReady(() => { + this.offContext.drawImage( this.img,0,0,400,200) + var image = this.offContext.transferToImageBitmap() + this.context.transferFromImageBitmap(image) + }) } + .width('100%') + .height('100%') } - ``` + } + ``` - ![](figures/en-us_image_0000001237475137.png) + ![en-us_image_0000001256978377](figures/en-us_image_0000001256978377.png) -### drawImage +### createImageData -drawImage\(image: ImageBitmap, dx: number, dy: number\): void +createImageData(width: number, height: number): Object -drawImage\(image: ImageBitmap, dx: number, dy: number, dWidth: number, dHeight: number\): void +Creates an **ImageData** object based on the specified width and height. For details, see [ImageData](../reference/arkui-ts/ts-components-canvas-imagebitmap.md). -drawImage\(image: ImageBitmap, sx: number, sy: number, sWidth: number, sHeight: number, dx: number, dy: number, dWidth: number, dHeight: number\):void +- Parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | width | number | Yes | 0 | Width of the **ImageData** object. | + | height | number | Yes | 0 | Height of the **ImageData** object. | -Draws an image. -- Parameters - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

image

-

ImageBitmap

-

Yes

-

null

-

Image resource. For details, see ImageBitmap.

-

sx

-

number

-

No

-

0

-

X-coordinate of the upper left corner of the rectangle used to crop the source image.

-

sy

-

number

-

No

-

0

-

Y-coordinate of the upper left corner of the rectangle used to crop the source image.

-

sWidth

-

number

-

No

-

0

-

Target width to crop the source image.

-

sHeight

-

number

-

No

-

0

-

Target height to crop the source image.

-

dx

-

number

-

Yes

-

0

-

X-coordinate of the upper left corner of the drawing area on the canvas.

-

dy

-

number

-

Yes

-

0

-

Y-coordinate of the upper left corner of the drawing area on the canvas.

-

dWidth

-

number

-

No

-

0

-

Width of the drawing area.

-

dHeight

-

number

-

No

-

0

-

Height of the drawing area.

-
- - -- Example - - ``` - @Entry - @Component - struct Index { - private settings: RenderingContextSettings = new RenderingContextSettings(true) - private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) - private img:ImageBitmap = new ImageBitmap("common/images/icon.jpg") - private offContext: OffscreenCanvasRenderingContext2D = new OffscreenCanvasRenderingContext2D(600, 600, this.settings) - build() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Canvas(this.context) +### createImageData + +createImageData(imageData: ImageData): Object + +Creates an **ImageData** object by copying an existing **ImageData** object. For details, see [ImageData](../reference/arkui-ts/ts-components-canvas-imagebitmap.md). + +- Parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | imagedata | [ImageData](../reference/arkui-ts/ts-components-canvas-imagebitmap.md) | Yes | null | **ImageData** object to copy. | + + +### getImageData + +getImageData(sx: number, sy: number, sw: number, sh: number): Object + +Creates an [ImageData](../reference/arkui-ts/ts-components-canvas-imagebitmap.md) object with pixels in the specified area on the canvas. + +- Parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | sx | number | Yes | 0 | X-coordinate of the upper left corner of the output area. | + | sy | number | Yes | 0 | Y-coordinate of the upper left corner of the output area. | + | sw | number | Yes | 0 | Width of the output area. | + | sh | number | Yes | 0 | Height of the output area. | + + +### putImageData + +putImageData(imageData: Object, dx: number, dy: number, dirtyX?: number, dirtyY?: number, dirtyWidth?: number, dirtyHeight?: number): void + +Puts the [ImageData](../reference/arkui-ts/ts-components-canvas-imagebitmap.md) onto a rectangular area on the canvas. + +- Parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | imagedata | Object | Yes | null | **ImageData** object with pixels to put onto the canvas. | + | dx | number | Yes | 0 | X-axis offset of the rectangular area on the canvas. | + | dy | number | Yes | 0 | Y-axis offset of the rectangular area on the canvas. | + | dirtyX | number | No | 0 | X-axis offset of the upper left corner of the rectangular area relative to that of the source image. | + | dirtyY | number | No | 0 | Y-axis offset of the upper left corner of the rectangular area relative to that of the source image. | + | dirtyWidth | number | No | Width of the **ImageData** object | Width of the rectangular area to crop the source image. | + | dirtyHeight | number | No | Height of the **ImageData** object | Height of the rectangular area to crop the source image. | + +- Example + + ``` + @Entry + @Component + struct PutImageData { + private settings: RenderingContextSettings = new RenderingContextSettings(true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + private offContext: OffscreenCanvasRenderingContext2D = new OffscreenCanvasRenderingContext2D(600, 600, this.settings) + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) .width('100%') .height('100%') .backgroundColor('#ffff00') - .onReady(() => { - this.offContext.drawImage( this.img,0,0,400,200) - var image = this.offContext.transferToImageBitmap() - this.context.transferFromImageBitmap(image) + .onReady(() =>{ + var imageData = this.offContext.createImageData(100, 100) + for (var i = 0; i < imageData.data.length; i += 4) { + imageData.data[i + 0] = 255 + imageData.data[i + 1] = 0 + imageData.data[i + 2] = 255 + imageData.data[i + 3] = 255 + } + this.offContext.putImageData(imageData, 10, 10) + var image = this.offContext.transferToImageBitmap() + this.context.transferFromImageBitmap(image) }) - } - .width('100%') - .height('100%') - } - } - ``` - - ![](figures/en-us_image_0000001192915180.png) - - -### createImageData - -createImageData\(width: number, height: number\): Object - -Creates an **ImageData** object based on the specified width and height. For details, see [ImageData](ts-components-canvas-imagedata.md). - -- Parameters - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default

-

Description

-

width

-

number

-

Yes

-

0

-

Width of the ImageData object.

-

height

-

number

-

Yes

-

0

-

Height of the ImageData object.

-
- - -### createImageData - -createImageData\(imageData: ImageData\): Object - -Creates an **ImageData** object by copying an existing **ImageData** object. For details, see [ImageData](ts-components-canvas-imagedata.md). - -- Parameters - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default

-

Description

-

imagedata

-

ImageData

-

Yes

-

null

-

ImageData object to copy.

-
- - -### getImageData - -getImageData\(sx: number, sy: number, sw: number, sh: number\): Object - -Creates an [ImageData](ts-components-canvas-imagedata.md) object with pixels in the specified area on the canvas. - -- Parameters - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

sx

-

number

-

Yes

-

0

-

X-coordinate of the upper left corner of the output area.

-

sy

-

number

-

Yes

-

0

-

Y-coordinate of the upper left corner of the output area.

-

sw

-

number

-

Yes

-

0

-

Width of the output area.

-

sh

-

number

-

Yes

-

0

-

Height of the output area.

-
- - -### putImageData - -putImageData\(imageData: Object, dx: number, dy: number, dirtyX?: number, dirtyY?: number, dirtyWidth?: number, dirtyHeight?: number\): void - -Puts the [ImageData](ts-components-canvas-imagedata.md) onto a rectangular area on the canvas. - -- Parameters - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

imagedata

-

Object

-

Yes

-

null

-

ImageData object with pixels to put onto the canvas.

-

dx

-

number

-

Yes

-

0

-

X-axis offset of the rectangular area on the canvas.

-

dy

-

number

-

Yes

-

0

-

Y-axis offset of the rectangular area on the canvas.

-

dirtyX

-

number

-

No

-

0

-

X-axis offset of the upper left corner of the rectangular area relative to that of the source image.

-

dirtyY

-

number

-

No

-

0

-

Y-axis offset of the upper left corner of the rectangular area relative to that of the source image.

-

dirtyWidth

-

number

-

No

-

Width of the ImageData object

-

Width of the rectangular area to crop the source image.

-

dirtyHeight

-

number

-

No

-

Height of the ImageData object

-

Height of the rectangular area to crop the source image.

-
- -- Example - - ``` - @Entry - @Component - struct PutImageData { - private settings: RenderingContextSettings = new RenderingContextSettings(true) - private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) - private offContext: OffscreenCanvasRenderingContext2D = new OffscreenCanvasRenderingContext2D(600, 600, this.settings) - build() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Canvas(this.context) - .width('100%') - .height('100%') - .backgroundColor('#ffff00') - .onReady(() =>{ - var imageData = this.offContext.createImageData(100, 100) - for (var i = 0; i < imageData.data.length; i += 4) { - imageData.data[i + 0] = 255 - imageData.data[i + 1] = 0 - imageData.data[i + 2] = 255 - imageData.data[i + 3] = 255 - } - this.offContext.putImageData(imageData, 10, 10) - var image = this.offContext.transferToImageBitmap() - this.context.transferFromImageBitmap(image) - }) - } - .width('100%') - .height('100%') } + .width('100%') + .height('100%') } - ``` + } + ``` - ![](figures/en-us_image_0000001193075170.png) + ![en-us_image_0000001212058496](figures/en-us_image_0000001212058496.png) -### restore +### restore -restore\(\): void +restore(): void Restores the saved drawing context. -- Example - - ``` - @Entry - @Component - struct CanvasExample { - private settings: RenderingContextSettings = new RenderingContextSettings(true) - private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) - private offContext: OffscreenCanvasRenderingContext2D = new OffscreenCanvasRenderingContext2D(600, 600, this.settings) - build() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Canvas(this.context) - .width('100%') - .height('100%') - .backgroundColor('#ffff00') - .onReady(() =>{ - this.offContext.restore() - var image = this.offContext.transferToImageBitmap() - this.context.transferFromImageBitmap(image) - }) - } - .width('100%') - .height('100%') +- Example + + ``` + @Entry + @Component + struct CanvasExample { + private settings: RenderingContextSettings = new RenderingContextSettings(true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + private offContext: OffscreenCanvasRenderingContext2D = new OffscreenCanvasRenderingContext2D(600, 600, this.settings) + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.offContext.restore() + var image = this.offContext.transferToImageBitmap() + this.context.transferFromImageBitmap(image) + }) } + .width('100%') + .height('100%') } - ``` + } + ``` -### save +### save -save\(\): void +save(): void Saves the current drawing context. -- Example - - ``` - @Entry - @Component - struct Restore { - private settings: RenderingContextSettings = new RenderingContextSettings(true) - private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) - private offContext: OffscreenCanvasRenderingContext2D = new OffscreenCanvasRenderingContext2D(600, 600, this.settings) - build() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Canvas(this.context) - .width('100%') - .height('100%') - .backgroundColor('#ffff00') - .onReady(() =>{ - this.offContext.save() - var image = this.offContext.transferToImageBitmap() - this.context.transferFromImageBitmap(image) - }) - } - .width('100%') - .height('100%') +- Example + + ``` + @Entry + @Component + struct CanvasExample { + private settings: RenderingContextSettings = new RenderingContextSettings(true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + private offContext: OffscreenCanvasRenderingContext2D = new OffscreenCanvasRenderingContext2D(600, 600, this.settings) + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.offContext.save() + var image = this.offContext.transferToImageBitmap() + this.context.transferFromImageBitmap(image) + }) } + .width('100%') + .height('100%') } - ``` + } + ``` -### createLinearGradient +### createLinearGradient -createLinearGradient\(x0: number, y0: number, x1: number, y1: number\): void +createLinearGradient(x0: number, y0: number, x1: number, y1: number): void Creates a linear gradient. -- Parameters - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

x0

-

number

-

Yes

-

0

-

X-coordinate of the start point.

-

y0

-

number

-

Yes

-

0

-

Y-coordinate of the start point.

-

x1

-

number

-

Yes

-

0

-

X-coordinate of the end point.

-

y1

-

number

-

Yes

-

0

-

Y-coordinate of the end point.

-
- -- Example - - ``` - @Entry - @Component - struct CreateLinearGradient { - private settings: RenderingContextSettings = new RenderingContextSettings(true) - private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) - private offContext: OffscreenCanvasRenderingContext2D = new OffscreenCanvasRenderingContext2D(600, 600, this.settings) - build() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Canvas(this.context) - .width('100%') - .height('100%') - .backgroundColor('#ffff00') - .onReady(() =>{ - var grad = this.offContext.createLinearGradient(50,0, 300,100) - gra.addColorStop(0.0, 'red') - gra.addColorStop(0.5, 'white') - gra.addColorStop(1.0, 'green') - this.offContext.fillStyle = grad - this.offContext.fillRect(0, 0, 500, 500) - var image = this.offContext.transferToImageBitmap() - this.context.transferFromImageBitmap(image) - }) - } - .width('100%') - .height('100%') +- Parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | x0 | number | Yes | 0 | X-coordinate of the start point. | + | y0 | number | Yes | 0 | Y-coordinate of the start point. | + | x1 | number | Yes | 0 | X-coordinate of the end point. | + | y1 | number | Yes | 0 | Y-coordinate of the end point. | + +- Example + + ``` + @Entry + @Component + struct CreateLinearGradient { + private settings: RenderingContextSettings = new RenderingContextSettings(true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + + private offContext: OffscreenCanvasRenderingContext2D = new OffscreenCanvasRenderingContext2D(600, 600, this.settings) + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + var grad = this.offContext.createLinearGradient(50,0, 300,100) + this.grad.addColorStop(0.0, 'red') + this.grad.addColorStop(0.5, 'white') + this.grad.addColorStop(1.0, 'green') + this.offContext.fillStyle = grad + this.offContext.fillRect(0, 0, 500, 500) + var image = this.offContext.transferToImageBitmap() + this.context.transferFromImageBitmap(image) + }) } + .width('100%') + .height('100%') } - ``` - -![](figures/en-us_image_0000001192915162.png) + } + ``` + + ![en-us_image_0000001212378434](figures/en-us_image_0000001212378434.png) -### createRadialGradient +### createRadialGradient -createRadialGradient\(x0: number, y0: number, r0: number, x1: number, y1: number, r1: number\): void +createRadialGradient(x0: number, y0: number, r0: number, x1: number, y1: number, r1: number): void Creates a linear gradient. -- Parameters - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

x0

-

number

-

Yes

-

0

-

X-coordinate of the center of the start circle.

-

y0

-

number

-

Yes

-

0

-

Y-coordinate of the center of the start circle.

-

r0

-

number

-

Yes

-

0

-

Radius of the start circle, which must be a non-negative finite number.

-

x1

-

number

-

Yes

-

0

-

X-coordinate of the center of the end circle.

-

y1

-

number

-

Yes

-

0

-

Y-coordinate of the center of the end circle.

-

r1

-

number

-

Yes

-

0

-

Radius of the end circle, which must be a non-negative finite number.

-
- -- Example - - ``` - @Entry - @Component - struct CreateRadialGradient { - private settings: RenderingContextSettings = new RenderingContextSettings(true) - private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) - private offContext: OffscreenCanvasRenderingContext2D = new OffscreenCanvasRenderingContext2D(600, 600, this.settings) - build() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - Canvas(this.context) - .width('100%') - .height('100%') - .backgroundColor('#ffff00') - .onReady(() =>{ - var grad = this.offContext.createRadialGradient(200,200,50, 200,200,200) - gra.addColorStop(0.0, 'red') - gra.addColorStop(0.5, 'white') - gra.addColorStop(1.0, 'green') - this.offContext.fillStyle = grad - this.offContext.fillRect(0, 0, 500, 500) - var image = this.offContext.transferToImageBitmap() - this.context.transferFromImageBitmap(image) - }) - } - .width('100%') - .height('100%') +- Parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | x0 | number | Yes | 0 | X-coordinate of the center of the start circle. | + | y0 | number | Yes | 0 | Y-coordinate of the center of the start circle. | + | r0 | number | Yes | 0 | Radius of the start circle, which must be a non-negative finite number. | + | x1 | number | Yes | 0 | X-coordinate of the center of the end circle. | + | y1 | number | Yes | 0 | Y-coordinate of the center of the end circle. | + | r1 | number | Yes | 0 | Radius of the end circle, which must be a non-negative finite number. | + +- Example + + ``` + @Entry + @Component + struct CreateRadialGradient { + private settings: RenderingContextSettings = new RenderingContextSettings(true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + + private offContext: OffscreenCanvasRenderingContext2D = new OffscreenCanvasRenderingContext2D(600, 600, this.settings) + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + var grad = this.offContext.createRadialGradient(200,200,50, 200,200,200) + this.grad.addColorStop(0.0, 'red') + this.grad.addColorStop(0.5, 'white') + this.grad.addColorStop(1.0, 'green') + this.offContext.fillStyle = grad + this.offContext.fillRect(0, 0, 500, 500) + var image = this.offContext.transferToImageBitmap() + this.context.transferFromImageBitmap(image) + }) } + .width('100%') + .height('100%') } - ``` - -![](figures/en-us_image_0000001237555179.png) + } + ``` + ![en-us_image_0000001212218480](figures/en-us_image_0000001212218480.png) -## CanvasPattern -Defines an object created by using the [createPattern](#section660873113512) method. +## CanvasPattern +Defines an object created by using the [createPattern](#createpattern) method. diff --git a/en/application-dev/reference/arkui-ts/ts-page-transition-animation.md b/en/application-dev/reference/arkui-ts/ts-page-transition-animation.md index b1b9c60825e06db19965cf57f494c3b1216076f8..8d3972d2b697cdb68ff25ad1ae031916b729cfb7 100644 --- a/en/application-dev/reference/arkui-ts/ts-page-transition-animation.md +++ b/en/application-dev/reference/arkui-ts/ts-page-transition-animation.md @@ -1,257 +1,70 @@ -# Page Transition - ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->This animation is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. - -Customize the page transition animations by configuring the page entrance and exit components in the global **pageTransition** method. - - - - - - - - - - - - - - - - -

Name

-

Type

-

Description

-

PageTransitionEnter

-

Object

-

Page entrance component, which is used to customize the entrance effect of the current page. For details, see animation parameters.

-

PageTransitionExit

-

Object

-

Page exit component, which is used to customize the exit effect of the current page. For details, see animation parameters.

-
- -- Animation parameters - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Default Value

-

Mandatory

-

Description

-

type

-

RouteType

-

-

-

No

-

If this parameter is not set, the reverse playback effect as pop switches to push is used.

-

duration

-

number

-

1000

-

No

-

Animation duration, in ms.

-

curve

-

Curve | Curves

-

Linear

-

No

-

Animation curve. For details about the valid values, see the description of Curve.

-

delay

-

number

-

0

-

No

-

Animation delay, in ms. Delayed animation is disabled by default.

-
- - -- RouteType enums - - - - - - - - - - - - - -

Name

-

Description

-

Pop

-

When page A jumps to page B, page A is Exit+Push, and page B is Enter+Push.

-

Push

-

When page B returns to page A, page A is Enter+Pop, and page B is Exit+Pop.

-
- - -## Attributes - -The **PageTransitionEnter** and **PageTransitionExit** components support the following attributes: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Default Value

-

Mandatory

-

Description

-

slide

-

SlideEffect

-

Right

-

No

-

Slide effect during page transition. For details about the valid values, see the description of SlideEffect.

-

translate

-

{

-

x? : number,

-

y? : number,

-

z? : number

-

}

-

-

-

No

-

Translation effect during page transition, which is the value of the start point of entrance and the end point of exit. When this parameter is set together with slide, the latter takes effect by default.

-

scale

-

{

-

x? : number,

-

y? : number,

-

z? : number,

-

centerX? : number,

-

centerY? : number

-

}

-

-

-

No

-

Scaling effect during page transition, which is the value of the start point of entrance and the end point of exit.

-

opacity

-

number

-

1

-

No

-

Opacity, which is the opacity value of the start point of entrance or the end point of exit.

-
- -- SlideEffect enums - - - - - - - - - - - - - - - - - - - -

Name

-

Description

-

Left

-

When set to Enter, slides in from the left. When set to Exit, slides out to the left.

-

Right

-

When set to Enter, slides in from the right. When set to Exit, slides out to the right.

-

Top

-

When set to Enter, slides in from the top. When set to Exit, slides out to the top.

-

Bottom

-

When set to Enter, slides in from the bottom. When set to Exit, slides out to the bottom.

-
- - -## Events +# Page Transition + + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** +> This animation is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. + + +Customize the page transition animations by configuring the page entrance and exit components in the global **pageTransition** method. + + + | Name | Parameter | Description | +| -------- | -------- | -------- | +| PageTransitionEnter | Object | Page entrance component, which is used to customize the entrance effect of the current page. For details, see animation parameters. | +| PageTransitionExit | Object | Page exit component, which is used to customize the exit effect of the current page. For details, see animation parameters. | + + +- Animation parameters + | Name | Type | Default Value | Mandatory | Description | + | -------- | -------- | -------- | -------- | -------- | + | type | RouteType | - | No | If this parameter is not set, the reverse playback effect as pop switches to push is used. | + | duration | number | 1000 | No | Animation duration, in ms. | + | curve | Curve \| Curves | Linear | No | Animation curve. For details about the valid values, see **Curve enums**. | + | delay | number | 0 | No | Animation delay, in ms. Delayed animation is disabled by default. | + + +- RouteType enums + | Name | Description | + | -------- | -------- | + | Pop | When page A jumps to page B, page A is Exit+Push, and page B is Enter+Push. | + | Push | When page B returns to page A, page A is Enter+Pop, and page B is Exit+Pop. | + + +## Attributes + +The **PageTransitionEnter** and **PageTransitionExit** components support the following attributes: + + | Name | Type | Default Value | Mandatory | Description | +| -------- | -------- | -------- | -------- | -------- | +| slide | SlideEffect | SlideEffect.Right | No | Slide effect during page transition. For details about the valid values, see the description of [ERROR:Invalid link:en-us_topic_0000001257138309.xml#xref2991922111212,link:#li81331342185820](#li81331342185820). | +| translate | {
x? : number,
y? : number,
z? : number
} | - | No | Translation effect during page transition, which is the value of the start point of entrance and the end point of exit. When this parameter is set together with **slide**, the latter takes effect by default. | +| scale | {
x? : number,
y? : number,
z? : number,
centerX? : number,
centerY? : number
} | - | No | Scaling effect during page transition, which is the value of the start point of entrance and the end point of exit. | +| opacity | number | 1 | No | Opacity, which is the opacity value of the start point of entrance or the end point of exit. | + +- SlideEffect enums + | Name | Description | + | -------- | -------- | + | Left | When set to Enter, slides in from the left. When set to Exit, slides out to the left. | + | Right | When set to Enter, slides in from the right. When set to Exit, slides out to the right. | + | Top | When set to Enter, slides in from the top. When set to Exit, slides out to the top. | + | Bottom | When set to Enter, slides in from the bottom. When set to Exit, slides out to the bottom. | + + +## Events The PageTransitionEnter and PageTransitionExit components support the following events: - - - - - - - - - - - - -

Event

-

Description

-

onEnter(type: RouteType, progress: number) => void

-

The callback input parameter is the normalized progress of the current entrance animation. The value range is 0–1.

-

onExit(type: RouteType, progress: number) => void

-

The callback input parameter is the normalized progress of the current exit animation. The value range is 0–1.

-
- -## Example + | Event | Description | +| -------- | -------- | +| onEnter(type: RouteType, progress: number) => void | The callback input parameter is the normalized progress of the current entrance animation. The value range is 0–1. | +| onExit(type: RouteType, progress: number) => void | The callback input parameter is the normalized progress of the current exit animation. The value range is 0–1. | + + +## Example Customization method 1: The entrance animation of the current page is configured as fade-in, and the exit animation is configured as zoom-out. + ``` // index.ets @Entry @@ -286,6 +99,7 @@ struct PageTransitionExample1 { } ``` + ``` // page1.ets @Entry @@ -317,10 +131,11 @@ struct AExample { } ``` -![](figures/pagetransition1.gif) +![en-us_image_0000001256978335](figures/en-us_image_0000001256978335.gif) Customization method 2: The entrance animation of the current page is configured to slide in from the left, and the exit animation is configured to zoom out with opacity change. + ``` // index.ets @Entry @@ -352,6 +167,7 @@ struct PageTransitionExample { } ``` + ``` // page1.ets @Entry @@ -383,5 +199,4 @@ struct PageTransitionExample1 { } ``` -![](figures/pagetransition2.gif) - +![en-us_image_0000001212058460](figures/en-us_image_0000001212058460.gif) diff --git a/en/application-dev/reference/arkui-ts/ts-transition-animation-component.md b/en/application-dev/reference/arkui-ts/ts-transition-animation-component.md index f6fc3dd221ed86729f59f31edbf46911232b11e0..7524c4fa4c0bdf5322c78c996053f726a8e4d298 100644 --- a/en/application-dev/reference/arkui-ts/ts-transition-animation-component.md +++ b/en/application-dev/reference/arkui-ts/ts-transition-animation-component.md @@ -1,160 +1,41 @@ -# Component Transition +# Component Transition ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->This animation is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -Configure the component transition animations for when a component is inserted or deleted, which improves user experience. This feature takes effect only when **animateTo** is used. The animation duration, curve, and delay are the same as those configured in **animateTo**. +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** +> This animation is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -## Attributes - - - - - - - - - - - - - -

Name

-

Type

-

Default Value

-

Description

-

transition

-

Object

-

-

-

All parameters are optional. For details, see the description of Transition parameters.

-
+Configure the component transition animations for when a component is inserted or deleted, which improves user experience. This feature takes effect only when **animateTo** is used. The animation duration, curve, and delay are the same as those configured in **animateTo**. -- Transition parameters - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Default Value

-

Mandatory

-

Description

-

type

-

TransitionType

-

All

-

No

-

Transition type, which includes component addition and deletion by default.

-
NOTE:

If type is not specified, insertion and deletion use the same transition type.

-
-

opacity

-

number

-

1

-

No

-

Opacity effect during component transition, which is the value of the start point of insertion and the end point of deletion.

-

translate

-

{

-

x? : number,

-

y? : number,

-

z? : number

-

}

-

-

-

No

-

Translation effect during component transition, which is the value of the start point of insertion and the end point of deletion.

-

scale

-

{

-

x? : number,

-

y? : number,

-

z? : number,

-

centerX? : number,

-

centerY? : number

-

}

-

-

-

No

-

Scaling effect during component transition, which is the value of the start point of insertion and the end point of deletion.

-

rotate

-

{

-

x?: number,

-

y?: number,

-

z?: number,

-

angle?: Angle,

-

centerX?: Length,

-

centerY?: Length

-

}

-

-

-

No

-

Rotation effect during component transition, which is the value of the start point of insertion and the end point of deletion.

-
+## Attributes + | Name | Type | Default Value | Description | +| -------- | -------- | -------- | -------- | +| transition | Object | - | All parameters are optional. For details, see **transition** parameters. | -- TransitionType enums +- transition parameters + | Name | Type | Default Value | Mandatory | Description | + | -------- | -------- | -------- | -------- | -------- | + | type | TransitionType | TransitionType.All | No | Transition type, which includes component addition and deletion by default.
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:**
> If **type** is not specified, insertion and deletion use the same transition type. | + | opacity | number | 1 | No | Opacity effect during component transition, which is the value of the start point of insertion and the end point of deletion. | + | translate | {
x? : number,
y? : number,
z? : number
} | - | No | Translation effect during component transition, which is the value of the start point of insertion and the end point of deletion. | + | scale | {
x? : number,
y? : number,
z? : number,
centerX? : number,
centerY? : number
} | - | No | Scaling effect during component transition, which is the value of the start point of insertion and the end point of deletion. | + | rotate | {
x?: number,
y?: number,
z?: number,
angle?: Angle,
centerX?: Length,
centerY?: Length
} | - | No | Rotation effect during component transition, which is the value of the start point of insertion and the end point of deletion. | - - - - - - - - - - - - - - - -

Name

-

Description

-

All

-

The transition takes effect in all scenarios.

-

Insert

-

The transition takes effect when a component is inserted.

-

Delete

-

The transition takes effect when a component is deleted.

-
+- TransitionType enums + | Name | Description | + | -------- | -------- | + | All | The transition takes effect in all scenarios. | + | Insert | The transition takes effect when a component is inserted. | + | Delete | The transition takes effect when a component is deleted. | -## Example +## Example The following example shows how to use a button to control the appearance and disappearance of another button, and how to configure the required transition animations. + ``` @Entry @Component @@ -186,5 +67,4 @@ struct TransitionExample { } ``` -![](figures/transition.gif) - +![en-us_image_0000001211898498](figures/en-us_image_0000001211898498.gif) diff --git a/en/application-dev/reference/arkui-ts/ts-transition-animation-shared-elements.md b/en/application-dev/reference/arkui-ts/ts-transition-animation-shared-elements.md index a73b337b47d8ffa16af12d0a831c538d04467744..41bb952be72928cd57adde58417f3274d4820336 100644 --- a/en/application-dev/reference/arkui-ts/ts-transition-animation-shared-elements.md +++ b/en/application-dev/reference/arkui-ts/ts-transition-animation-shared-elements.md @@ -1,92 +1,32 @@ -# Transition of Shared Elements +# Transition of Shared Elements + + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** +> This animationis supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->This animation is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. Shared element transition can be used for transition between pages, for example, transition from an image on the current page to the next page. -## Type - - - - - - - - - - - - - - -

Name

-

Type

-

Default Value

-

Description

-

sharedTransition

-

id: string,

-

options?: Object

-

-

-

If the same ID is configured for a component on the two pages, this shared component is transited. If this parameter is set to an empty string, no shared elements are transited.

-
- -- options parameters - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Default Value

-

Mandatory

-

Description

-

duration

-

number

-

1000

-

No

-

Animation duration, in ms. The default duration is 1000 ms.

-

curve

-

Curve | Curves

-

Linear

-

No

-

The default curve is linear. For details about the valid values, see Curve enums.

-

delay

-

number

-

0

-

No

-

Delay of animation playback, in ms. By default, the playback is not delayed.

-
- - -## Example + +## Type + + | Name | Type | Default Value | Description | +| -------- | -------- | -------- | -------- | +| sharedTransition | id: string,
options?: Object | - | If the same ID is configured for a component on the two pages, this shared component is transited. If this parameter is set to an empty string, no shared elements are transited. | + +- options parameters + | Name | Type | Default Value | Mandatory | Description | + | -------- | -------- | -------- | -------- | -------- | + | duration | number | 1000 | No | Animation duration, in ms. The default duration is 1000 ms. | + | curve | Curve \| Curves | Linear | No | The default curve is linear. For details about the valid values, see **Curve enums**. | + | delay | number | 0 | No | Delay of animation playback, in ms. By default, the playback is not delayed. | + + +## Example The example shows the transition of a shared element from a page and page B. + ``` @Entry @Component @@ -115,6 +55,7 @@ struct SharedTransitionExample { } ``` + ``` // PageB @Entry @@ -128,5 +69,4 @@ struct BExample { } ``` -![](figures/sharedtransition.gif) - +![en-us_image_0000001211898494](figures/en-us_image_0000001211898494.gif) diff --git a/en/application-dev/reference/arkui-ts/ts-transition-animation.md b/en/application-dev/reference/arkui-ts/ts-transition-animation.md index 590b23e37aa735e0b641bb0d129f09da4972323c..5fd0655ea2f80cadeb2c63392c9602929d96c81d 100644 --- a/en/application-dev/reference/arkui-ts/ts-transition-animation.md +++ b/en/application-dev/reference/arkui-ts/ts-transition-animation.md @@ -1,9 +1,9 @@ -# Transition Animation +# Transition Animation -- **[Page Transition](ts-page-transition-animation.md)** -- **[Component Transition](ts-transition-animation-component.md)** -- **[Transition of Shared Elements](ts-transition-animation-shared-elements.md)** +- **[Page Transition](ts-page-transition-animation.md)** +- **[Component Transition](ts-transition-animation-component.md)** +- **[Transition of Shared Elements](ts-transition-animation-shared-elements.md)** \ No newline at end of file diff --git a/en/application-dev/reference/arkui-ts/ts-universal-attributes-background.md b/en/application-dev/reference/arkui-ts/ts-universal-attributes-background.md index 38ccc9ff5839ffd750bf5e4f5a3673d176d12290..41959f374b15727d0a94c46856b63d25e49c29dc 100644 --- a/en/application-dev/reference/arkui-ts/ts-universal-attributes-background.md +++ b/en/application-dev/reference/arkui-ts/ts-universal-attributes-background.md @@ -1,106 +1,39 @@ -# Background +# Background + + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** +> This attribute is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->This attribute is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. The attributes in this topic are used to set the background color of a component. -## Required Permissions + +## Required Permissions None -## Attributes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Default Value

-

Description

-

backgroundColor

-

Color

-

-

-

Background color of a component.

-

backgroundImage

-

src: string,

-

repeat?: ImageRepeat

-

-

-

src: image address, which can be the address of an Internet or a local image. (SVG images are not supported.)

-

repeat: whether the background image is repeatedly used. By default, the background image is not repeatedly used.

-

backgroundImageSize

-

{

-

width?: Length,

-

height?: Length

-

} | ImageSize

-

Auto

-

Width and height of the background image. When the input is a {width: Length, height: Length} object, if only one attribute is set, the other attribute is the set value multiplied by the original aspect ratio of the image. By default, the original image aspect ratio remains unchanged.

-

backgroundImagePosition

-

{

-

x?: Length,

-

y?: Length

-

} | Alignment

-

{

-

x: 0,

-

y: 0

-

}

-

Position of the background image in the component.

-
- -- ImageSize enums - - - - - - - - - - - - - - - - -

Name

-

Description

-

Cover

-

Default value. The image is scaled with its aspect ratio retained for both sides to be greater than or equal to the display boundaries.

-

Contain

-

The image is scaled with its aspect ratio retained for the content to be completely displayed within the display boundaries.

-

Auto

-

The original image aspect ratio is retained.

-
- - -## Example + +## Attributes + + +| Name | Type | Default Value | Description | +| -------- | -------- | -------- | -------- | +| backgroundColor | Color | - | Background color of a component. | +| backgroundImage | src: string,
repeat?: [ImageRepeat](ts-appendix-enums.md#imagerepeat-enums) | - | **src**: image address, which can be the address of an Internet or a local image. (SVG images are not supported.)
**repeat**: whether the background image is repeatedly used. By default, the background image is not repeatedly used. | +| backgroundImageSize | {
width?: Length,
height?: Length
} \| ImageSize | Auto | Width and height of the background image. When the input is a **{width: Length, height: Length}** object, if only one attribute is set, the other attribute is the set value multiplied by the original aspect ratio of the image. By default, the original image aspect ratio remains unchanged. | +| backgroundImagePosition | {
x?: Length,
y?: Length
} \| [Alignment](ts-appendix-enums.md#alignment-enums) | {
x: 0,
y: 0
} | Position of the background image in the component. | + + +- ImageSize enums + | Name | Description | + | -------- | -------- | + | Cover | Default value. The image is scaled with its aspect ratio retained for both sides to be greater than or equal to the display boundaries. | + | Contain | The image is scaled with its aspect ratio retained for the content to be completely displayed within the display boundaries. | + | Auto | The original image aspect ratio is retained. | + + +## Example + ``` @Entry @@ -166,5 +99,4 @@ struct BackgroundExample { } ``` -![](figures/back.png) - +![en-us_image_0000001211898502](figures/en-us_image_0000001211898502.png) diff --git a/en/application-dev/reference/arkui-ts/ts-universal-attributes-border.md b/en/application-dev/reference/arkui-ts/ts-universal-attributes-border.md index e26571ee07d079fa89ecb48379084e85a5032f00..84561f7671decc24f8d4a8e81d02c705762cc275 100644 --- a/en/application-dev/reference/arkui-ts/ts-universal-attributes-border.md +++ b/en/application-dev/reference/arkui-ts/ts-universal-attributes-border.md @@ -1,110 +1,41 @@ -# Border Configuration +# Border ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->This attribute is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -This section describes the settings of border styles. +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** +> This attribute is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -## Required Permissions + +The attributes described in this topic are used to set border styles. + + +## Required Permissions None -## Attributes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Default Value

-

Description

-

border

-

{

-

width?: Length,

-

color?: Color,

-

radius?: Length,

-

style?: BorderStyle

-

}

-

-

-

Sets a unified border style.

-

borderStyle

-

BorderStyle

-

Solid

-

Sets the border style of an element.

-

borderWidth

-

Length

-

0

-

Sets the border width of an element.

-

borderColor

-

Color

-

-

-

Sets the border color of an element.

-

borderRadius

-

Length

-

0

-

Sets the border radius of an element.

-
- -- BorderStyle enums - - - - - - - - - - - - - - - - -

Name

-

Description

-

Dotted

-

Dotted border. The radius of a dot is half of borderWidth.

-

Dashed

-

Dashed border.

-

Solid

-

Solid border.

-
- - -## Example +## Attributes + + + | Name | Type | Default Value | Description | +| -------- | -------- | -------- | -------- | +| border | {
width?: Length,
color?: Color,
radius?: Length,
style?: BorderStyle
} | - | Sets a unified border style. | +| borderStyle | BorderStyle | BorderStyle.Solid | Sets the border style of an element. | +| borderWidth | Length | 0 | Sets the border width of an element. | +| borderColor | Color | - | Sets the border color of an element. | +| borderRadius | Length | 0 | Sets the border radius of an element. | + + +- BorderStyle enums + | Name | Description | + | -------- | -------- | + | Dotted | Dotted border. The radius of a dot is half of **borderWidth**. | + | Dashed | Dashed border. | + | Solid | Solid border. | + + +## Example + + ``` @Entry @Component @@ -124,5 +55,4 @@ struct BorderExample { } ``` -![](figures/border.gif) - +![en-us_image_0000001211898466](figures/en-us_image_0000001211898466.gif) diff --git a/en/application-dev/reference/arkui-ts/ts-universal-attributes-click.md b/en/application-dev/reference/arkui-ts/ts-universal-attributes-click.md new file mode 100644 index 0000000000000000000000000000000000000000..1679db73148f51450f2c1687d0521b46712f8b5c --- /dev/null +++ b/en/application-dev/reference/arkui-ts/ts-universal-attributes-click.md @@ -0,0 +1,52 @@ +# Click Control + + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** +> This component is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version. + + +## Required Permissions + +None + + +## Attributes + + + | **Name** | **Type** | **Default Value** | **Description** | +| -------- | -------- | -------- | -------- | +| touchable | boolean | true | Whether the current component is touchable. | + + +## Example + + +``` +@Entry +@Component +struct TouchAbleExample { + @State text1: string = '' + @State text2: string = '' + + build() { + Stack() { + Rect() + .fill(Color.Gray).width(150).height(150) + .onClick(() => { + console.info(this.text1 = 'Rect Clicked') + }) + .overlay(this.text1, { align: Alignment.Bottom, offset: { x: 0, y: 20 } }) + Ellipse() + .fill(Color.Pink).width(150).height(80) + .touchable(false) // When the Ellipse area is touched, the message "Ellipse Clicked" is not displayed. + .onClick(() => { + console.info(this.text2 = 'Ellipse Clicked') + }) + .overlay(this.text2, { align: Alignment.Bottom, offset: { x: 0, y: 20 } }) + }.margin(100) + } +} +``` + + +![en-us_image_0000001257138351](figures/en-us_image_0000001257138351.gif) diff --git a/en/application-dev/reference/arkui-ts/ts-universal-attributes-component-id.md b/en/application-dev/reference/arkui-ts/ts-universal-attributes-component-id.md new file mode 100644 index 0000000000000000000000000000000000000000..8fe23854906a4709f817060b8667c3c7131d22ce --- /dev/null +++ b/en/application-dev/reference/arkui-ts/ts-universal-attributes-component-id.md @@ -0,0 +1,104 @@ +# Component ID + + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** +> This component is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version. + + +## Required Permissions + +None + + +## Attributes + + | Name | Type | Default Value | Description | +| -------- | -------- | -------- | -------- | +| id | string | '' | Unique ID of the component. The uniqueness is ensured by the user. | + + +## APIs + + +### getInspectorByKey + +getInspectorByKey(id: string): string + +Obtains all attributes of the component with the specified ID, excluding the information about child components. + +- Parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | id | string | Yes | - | ID of the component whose attributes are to be obtained. | + +- Return value + | Type | Description | + | -------- | -------- | + | string | JSON string of the component attribute list. | + + +### sendEventByKey + +sendEventByKey(id: string, action: number, params: string): boolean + +Sends an event to the component with the specified ID. + +- Parameters + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | id | string | Yes | - | ID of the component for which the event is to be sent. | + | action | number | Yes | - | Type of the event to be sent. The options are as follows:
- Click event: 10.
- LongClick: 11. | + | params | string | Yes | - | Event parameters. If there is no parameter, pass an empty string **""**. | + +- Return value + | Type | Description | + | -------- | -------- | + | boolean | Returns **false** if the component with the specified ID cannot be found; returns **true** otherwise. | + + +## Example + + +``` +@Entry +@Component +struct IdExample { + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Button() { + Text('click') + .fontSize(25) + .fontWeight(FontWeight.Bold) + } + .type(ButtonType.Capsule) + .margin({ + top: 20 + }).onClick(() => { + console.info(getInspectorByKey("click")) + console.info(getInspectorTree()) + setTimeout(() => { + sendEventByKey("longclick", 11, "") + }, 2000) + }).id('click') + + Button() { + Text('longclick') + .fontSize(25) + .fontWeight(FontWeight.Bold) + } + .type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .gesture( + LongPressGesture().onActionEnd(() => { + console.info('long clicked') + })) + .id('longclick') + } + .width('100%') + .height('100%') + } +} +``` diff --git a/en/application-dev/reference/arkui-ts/ts-universal-attributes-enable.md b/en/application-dev/reference/arkui-ts/ts-universal-attributes-enable.md index 9d6b1249786664f03c83e8544e32c860aef8a6a2..1c2ccdfc0895dada913069589f3a27d0c8822ef1 100644 --- a/en/application-dev/reference/arkui-ts/ts-universal-attributes-enable.md +++ b/en/application-dev/reference/arkui-ts/ts-universal-attributes-enable.md @@ -1,39 +1,26 @@ -# Enable/Disable +# Enable/Disable ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->This attribute is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -## Required Permissions +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** +> This attribute is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. + + +## Required Permissions None -## Attributes - - - - - - - - - - - - - - -

Name

-

Type

-

Default Value

-

Description

-

enabled

-

boolean

-

true

-

The value true means that the component is available and can respond to operations such as clicking. The value false means that the component does not respond to operations such as clicking.

-
- -## Example +## Attributes + + + | Name | Type | Default Value | Description | +| -------- | -------- | -------- | -------- | +| enabled | boolean | true | The value **true** means that the component is available and can respond to operations such as clicking. The value **false** means that the component does not respond to operations such as clicking. | + + +## Example + + ``` @Entry @Component @@ -50,5 +37,4 @@ struct EnabledExample { } ``` -![](figures/enabled.gif) - +![en-us_image_0000001212218428](figures/en-us_image_0000001212218428.gif) diff --git a/en/application-dev/reference/arkui-ts/ts-universal-attributes-flex-layout.md b/en/application-dev/reference/arkui-ts/ts-universal-attributes-flex-layout.md index 6423acb80767eded69d695f15723ef1d92660dd5..eaa92f882dfcce0c50c276b907fcb246bc87e4c7 100644 --- a/en/application-dev/reference/arkui-ts/ts-universal-attributes-flex-layout.md +++ b/en/application-dev/reference/arkui-ts/ts-universal-attributes-flex-layout.md @@ -1,66 +1,30 @@ -# Flex Layout +# Flex Layout ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->- This attribute is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. ->- This attribute is valid only when the parent component is a **Flex** component. -## Required Permissions +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** +> - This attribute is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. +> +> - This attribute is valid only when the parent component is a **Flex** component. + + +## Required Permissions None -## Attributes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Default Value

-

Description

-

flexBasis

-

'auto' | Length

-

'auto'

-

Base dimension of a component in the main axis of the Flex layout.

-

flexGrow

-

number

-

0

-

Percentage of the Flex layout's remaining space that is allocated to the component.

-

flexShrink

-

number

-

1

-

Percentage of the Flex layout's shrink size that is allocated to the component.

-

alignSelf

-

ItemAlign

-

Auto

-

Alighment mode, which overwrites the default alignItems configuration in the Flex layout.

-
- -## Example + +## Attributes + + +| Name | Type | Default Value | Description | +| -------- | -------- | -------- | -------- | +| flexBasis | 'auto' \| Length | 'auto' | Base dimension of a component in the main axis of the **Flex** layout. | +| flexGrow | number | 0 | Percentage of the **Flex** layout's remaining space that is allocated to the component. | +| flexShrink | number | 1 | Percentage of the **Flex** layout's shrink size that is allocated to the component. | +| alignSelf | [ItemAlign](ts-appendix-enums.md#itemalign-enums) | Auto | Alignment mode, which overwrites the default **alignItems** configuration in the **Flex** layout. | + + +## Example + ``` @Entry @@ -94,7 +58,7 @@ struct FlexExample { Text('flexShrink').fontSize(9).fontColor(0xCCCCCC).width('90%') // flexShrink() specifies the percentage of the shrink size allocated to the component. - // The ratio of text1 is 0, and the default values of other parameters are 1. If the components cannot be completely displayed, the last two components are shrunk proportionally. The first componented is not shrunk. + // The ratio of text1 is 0, and the default values of other parameters are 1. If the components cannot be completely displayed, the last two components are shrunk proportionally. The first component is not shrunk. Flex({ direction: FlexDirection.Row }) { Text('flexShrink(0)') .flexShrink(0).width('50%').height(100).lineHeight(70) @@ -122,5 +86,4 @@ struct FlexExample { } ``` -![](figures/flex.png) - +![en-us_image_0000001212378394](figures/en-us_image_0000001212378394.png) diff --git a/en/application-dev/reference/arkui-ts/ts-universal-attributes-focus.md b/en/application-dev/reference/arkui-ts/ts-universal-attributes-focus.md new file mode 100644 index 0000000000000000000000000000000000000000..9f3e2481f97d4d40e7f65d106cb245a0a2d68f0f --- /dev/null +++ b/en/application-dev/reference/arkui-ts/ts-universal-attributes-focus.md @@ -0,0 +1,78 @@ +# Focus Control + + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** +> This attribute is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version. + + +## Required Permissions + +None + + +## Attributes + + | **Name** | **Type** | **Default Value** | **Description** | +| -------- | -------- | -------- | -------- | +| focusable | boolean | false | Whether the current component is focusable. | + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** +> The following components support focus control: **<Button>**, **<Text>**, **<Image>**, **<List>**, and **<Grid>**. + + +## Example + + +``` +@Entry +@Component +struct FocusableExample { + @State textOne: string = '' + @State textTwo: string = '' + @State textThree: string = 'The third button cannot be focused' + @State oneButtonColor: string = '#FF0000' + @State twoButtonColor: string = '#FFC0CB' + @State threeButtonColor: string = '#87CEFA' + + build() { + Column({ space:20 }){ + Button(this.textOne) + .backgroundColor(this.oneButtonColor) + .width(300).height(70).fontColor(Color.Black) + .focusable(true) + .onFocus(() => { + this.textOne = 'First Button onFocus' + this.oneButtonColor = '#AFEEEE' + }) + .onBlur(() => { + this.textOne = 'First Button onBlur' + this.oneButtonColor = '#FFC0CB' + }) + Button(this.textTwo) + .backgroundColor(this.twoButtonColor) + .width(300).height(70).fontColor(Color.Black) + .focusable(true) + .onFocus(() => { + this.textTwo = 'Second Button onFocus' + this.twoButtonColor = '#AFEEEE' + }) + .onBlur(() => { + this.textTwo = 'Second Button onBlur' + this.twoButtonColor = '#FFC0CB' + }) + Button(this.textThree) + .backgroundColor(this.threeButtonColor) + .width(300).height(70).fontColor(Color.Black) + .focusable(false) + .onFocus(() => { + this.textThree = 'Third Button onFocus' + this.threeButtonColor = '#AFEEEE' + }) + .onBlur(() => { + this.textThree = 'Third Button onBlur' + this.threeButtonColor = '#FFC0CB' + }) + }.width('100%').margin({ top:20 }) + } +} +``` diff --git a/en/application-dev/reference/arkui-ts/ts-universal-attributes-gradient-color.md b/en/application-dev/reference/arkui-ts/ts-universal-attributes-gradient-color.md index 754e983d7efc929ff9890c9095a61be8784eafc5..dace1744afc31a70ef38060e1c56e514198459c9 100644 --- a/en/application-dev/reference/arkui-ts/ts-universal-attributes-gradient-color.md +++ b/en/application-dev/reference/arkui-ts/ts-universal-attributes-gradient-color.md @@ -1,145 +1,43 @@ -# Gradient Color +# Gradient Color ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->This attribute is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -## Required Permissions +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** +> This attribute is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. + + +## Required Permissions None -## Attributes - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Default Value

-

Description

-

linearGradient

-

{

-

angle?: Angle,

-

direction?:GradientDirection,

-

colors: Array<ColorStop>

-

repeating?: boolean

-

}

-

-

-

Linear gradient.

-

angle: angle of the linear gradient.

-

direction: direction of the linear gradient.

-

colors: description of the gradient colors.

-

repeating: whether the colors are repeated.

-

sweepGradient

-

{

-

center: Point,

-

start?: angle,

-

end?: angle,

-

colors: Array<ColorStop>

-

repeating?: boolean

-

}

-

-

-

Angle gradient.

-

center: center point of the angle gradient.

-

start: start point of the angle gradient.

-

end: end point of the angle gradient.

-

colors: description of the gradient colors.

-

repeating: whether the colors are repeated.

-

radialGradient

-

{

-

center: Point,

-

radius: Length,

-

colors: Array<ColorStop>

-

repeating: boolean

-

}

-

-

-

Radial gradient.

-

center: center point of the radial gradient.

-

radius: radius of the radial gradient.

-

colors: description of the gradient colors.

-

repeating: whether the colors are repeated.

-
- -- GradientDirection enums - - **GradientDirection** is used to describe the gradient direction. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Description

-

Left

-

The gradient direction is from right to left.

-

Top

-

The gradient direction is from bottom to top.

-

Right

-

The gradient direction is from left to right.

-

Bottom

-

The gradient direction is from top to bottom.

-

LeftTop

-

The gradient direction is upper left.

-

LeftBottom

-

The gradient direction is lower left.

-

RightTop

-

The gradient direction is upper right.

-

RightBottom

-

The gradient direction is lower right.

-

None

-

No gradient.

-
- - -## Example + +## Attributes + + +| Name | Type | Default Value | Description | +| -------- | -------- | -------- | -------- | +| linearGradient | {
angle?: [Angle](../../ui/ts-types.md),
direction?:GradientDirection,
colors: Array<[ColorStop](../../ui/ts-types.md)>
repeating?: boolean
} | - | Linear gradient.
**angle**: angle of the linear gradient.
**direction**: direction of the linear gradient.
**colors**: description of the gradient colors.
**repeating**: whether the colors are repeated. | +| sweepGradient | {
center: Point,
start?: angle,
end?: angle,
colors: Array<[ColorStop](../../ui/ts-types.md)>
repeating?: boolean
} | - | Angle gradient.
**center**: center point of the angle gradient.
**start**: start point of the angle gradient.
**end**: end point of the angle gradient.
**colors**: description of the gradient colors.
**repeating**: whether the colors are repeated. | +| radialGradient | {
center: Point,
radius: Length,
colors: Array<[ColorStop](../../ui/ts-types.md)>
repeating: boolean
} | - | Radial gradient.
**center**: center point of the radial gradient.
**radius**: radius of the radial gradient.
**colors**: description of the gradient colors.
**repeating**: whether the colors are repeated. | + + +- GradientDirection enums + **GradientDirection** is used to describe the gradient direction. + + | Name | Description | + | -------- | -------- | + | Left | The gradient direction is from right to left. | + | Top | The gradient direction is from bottom to top. | + | Right | The gradient direction is from left to right. | + | Bottom | The gradient direction is from top to bottom. | + | LeftTop | The gradient direction is upper left. | + | LeftBottom | The gradient direction is lower left. | + | RightTop | The gradient direction is upper right. | + | RightBottom | The gradient direction is lower right. | + | None | No gradient. | + + +## Example + ``` @Entry @@ -182,5 +80,4 @@ struct ColorGradientExample { } ``` -![](figures/colorgradient.png) - +![en-us_image_0000001212218484](figures/en-us_image_0000001212218484.png) diff --git a/en/application-dev/reference/arkui-ts/ts-universal-attributes-grid.md b/en/application-dev/reference/arkui-ts/ts-universal-attributes-grid.md index 941a38b140b9b86cb767935e9895a676dfed1c8e..c62278b652e26902bd50fe1e62723c1cd48a11ae 100644 --- a/en/application-dev/reference/arkui-ts/ts-universal-attributes-grid.md +++ b/en/application-dev/reference/arkui-ts/ts-universal-attributes-grid.md @@ -1,71 +1,29 @@ -# Grid +# Grid ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->- This attribute is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. ->- The column width and column gap in the grid layout are determined by the nearest parent component **GridContainer**. The component tree that uses grid attributes must contain one **GridContainer** or more. -## Required Permissions +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** +> - This attribute is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. +> +> - The column width and column gap in the grid layout are determined by the nearest parent component **GridContainer**. The component tree that uses grid attributes must contain one **GridContainer** or more. + + +## Required Permissions None -## Attributes - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Default Value

-

Description

-

useSizeType

-

{

-

xs?: number | { span: number, offset: number },

-

sm?: number | { span: number, offset: number },

-

md?: number | { span: number, offset: number },

-

lg?: number | { span: number, offset: number }

-

}

-

-

-

Number of occupied columns and offset columns for a specific device width type. span indicates the number of occupied columns, and offset indicates the number of offset columns.

-

If the value is of the number type, only the number of columns can be set. If the value is in the format of {"span": 1, "offset": 0}, both the number of occupied columns and the number of offset columns need to be set.

-
  • xs indicates that the device width type is SizeType.XS.
  • sm indicates that the device width type is SizeType.SM.
-
  • md indicates that the device width type is SizeType.MD.
  • lg indicates that the device width type is SizeType.LG.
-

gridSpan

-

number

-

1

-

Default number of occupied columns, that is, the number of occupied columns when span in useSizeType is not set.

-
NOTE:

If the span attribute is set, the component width is determined by the grid layout.

-
-

gridOffset

-

number

-

0

-

Default number of offset columns, that is, the number of offset columns in the start direction of the parent component (which is also the nth column that the component is in) when offset in useSizeType is not set.

-
NOTE:

1. After this attribute is set, the horizontal layout of the current component does not follow the original layout of the parent component. Instead, it offsets along the start direction of the parent component.

-

2. Offset = (Column width + Gap) x Number of columns

-

3. After this attribute is set, sibling components will be arranged relatively to this component, as in the relative layout.

-
-
- -## Example + +## Attributes + + + | Name | Type | Default Value | Description | +| -------- | -------- | -------- | -------- | +| useSizeType | {
xs?: number \| { span: number, offset: number },
sm?: number \| { span: number, offset: number },
md?: number \| { span: number, offset: number },
lg?: number \| { span: number, offset: number }
} | - | Number of occupied columns and offset columns for a specific device width type. **span** indicates the number of occupied columns, and **offset** indicates the number of offset columns.
If the value is of the number type, only the number of columns can be set. If the value is in the format of {"span": 1, "offset": 0}, both the number of occupied columns and the number of offset columns need to be set.
- **xs** indicates that the device width type is **SizeType.XS**.
- **sm** indicates that the device width type is **SizeType.SM**.
- **md** indicates that the device width type is **SizeType.MD**.
- **lg** indicates that the device width type is **SizeType.LG**. | +| gridSpan | number | 1 | Default number of occupied columns, that is, the number of occupied columns when **span** in **useSizeType** is not set.
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:**
> If the **span** attribute is set, the component width is determined by the grid layout. | +| gridOffset | number | 0 | Default number of offset columns, that is, the number of offset columns in the start direction of the parent component (which is also the nth column that the component is in) when **offset** in **useSizeType** is not set.
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:**
> 1. After this attribute is set, the horizontal layout of the current component does not follow the original layout of the parent component. Instead, it offsets along the start direction of the parent component.

> 2. Offset = (Column width + Gap) x Number of columns

> 3. After this attribute is set, sibling components will be arranged relatively to this component, as in the relative layout. | + + +## Example + ``` @Entry @@ -110,12 +68,11 @@ struct GridContainerExample1 { } ``` -**Figure 1** Device width type SM -![](figures/device-width-type-sm.png "device-width-type-sm") - -**Figure 2** Device width type MD -![](figures/device-width-type-md.png "device-width-type-md") + **Figure1** Device width type SM + ![en-us_image_0000001256858405](figures/en-us_image_0000001256858405.png) -**Figure 3** Device width type LG -![](figures/device-width-type-lg.png "device-width-type-lg") + **Figure2** Device width type MD + ![en-us_image_0000001257058415](figures/en-us_image_0000001257058415.png) + **Figure3** Device width type LG + ![en-us_image_0000001212378416](figures/en-us_image_0000001212378416.png) diff --git a/en/application-dev/reference/arkui-ts/ts-universal-attributes-hover-effect.md b/en/application-dev/reference/arkui-ts/ts-universal-attributes-hover-effect.md new file mode 100644 index 0000000000000000000000000000000000000000..6e47ced759df2a67842ece1c9f67a4b455786df2 --- /dev/null +++ b/en/application-dev/reference/arkui-ts/ts-universal-attributes-hover-effect.md @@ -0,0 +1,69 @@ +# Hover Effect + + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** +> This component is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version. + + +## Required Permissions + +None + + +## Attributes + + | Name | Type | Default Value | Description | +| -------- | -------- | -------- | -------- | +| hoverEffect | HoverEffect | HoverEffect.Auto | Hover effect of the component in hover state. | + +- HoverEffect enums + | Name | Description | + | -------- | -------- | + | Auto | Default hover effect. | + | Scale | Scale effect. | + | Board | Fade-in and fade-out effect. | + | None | No effect. | + + +## Example + + +``` +@Entry +@Component +struct HoverExample { + @State isHoverVal: boolean = false + + build() { + Column({ space: 5 }) { + Column({ space: 5 }) { + Text('Scale').fontSize(20).fontColor(Color.Gray).width('90%').position({ x: 0, y: 80 }) + Column() + .width('80%').height(200).backgroundColor(Color.Gray) + .position({ x: 40, y: 120 }) + .hoverEffect(HoverEffect.Scale) + .onHover((isHover: boolean) => { + console.info('Scale' + isHover) + this.isHoverVal = isHover + }) + + Text('Board').fontSize(20).fontColor(Color.Gray).width('90%').position({ x: 0, y: 380 }) + Column() + .width('80%').height(200).backgroundColor(Color.Gray) + .hoverEffect(HoverEffect.Board) + .position({ x: 40, y: 420 }) + .onHover((isHover: boolean) => { + console.info('HoverEffect.Board') + this.isHoverVal = isHover + }) + } + .hoverEffect(HoverEffect.None) + .width('100%').height('100%').border({ width: 1 }) + .onHover((isHover: boolean) => { + console.info('HoverEffect.None') + this.isHoverVal = isHover + }) + } + } +} +``` diff --git a/en/application-dev/reference/arkui-ts/ts-universal-attributes-image-effect.md b/en/application-dev/reference/arkui-ts/ts-universal-attributes-image-effect.md index a5e0d3e0add09867b6380c00df0b8dc8323c36d3..25e98c6ea8dd47def3c7d1cd7deaf44db3e1f4ee 100644 --- a/en/application-dev/reference/arkui-ts/ts-universal-attributes-image-effect.md +++ b/en/application-dev/reference/arkui-ts/ts-universal-attributes-image-effect.md @@ -1,133 +1,35 @@ -# Image Effect Configuration +# Image Effect Configuration ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->This attribute is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -## Required Permissions +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** +> This attribute is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. + + +## Required Permissions None -## Attributes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Default Value

-

Description

-

blur

-

number

-

-

-

Adds the content blurring for the current component. The input parameter is the blur radius. The larger the radius is, the more blurred the content is. If the value is 0, the content is not blurred.

-

backdropBlur

-

number

-

-

-

Adds the background blur effect for the current component. The input parameter is the blur radius. The larger the radius is, the more blurred the background is. If the value is 0, the background is not blurred.

-

shadow

-

{

-

radius: number,

-

color?: Color,

-

offsetX?: number,

-

offsetY?: number

-

}

-

-

-

Adds the shadow effect to the current component. The input parameters are the fuzzy radius (mandatory), shadow color (optional; gray by default), X-axis offset (optional and 0 by default), and Y-axis offset (optional; 0 by default). The offset unit is px.

-

grayscale

-

number

-

0.0

-

The value indicates the grayscale conversion ratio. If the input value is 1.0, the image is converted into a grayscale image. If the input value is 0.0, the image does not change. If the input value is between 0.0 and 1.0, the effect changes in linear mode. The unit is percentage. The unit is percentage.

-

brightness

-

number

-

1.0

-

Adds a brightness to the current component. The input parameter is a brightness ratio. The value 1 indicates no effects. The value 0 indicates the complete darkness. If the value is less than 1, the brightness decreases. If the value is greater than 1, the brightness increases. A larger value indicates a higher brightness.

-

saturate

-

number

-

1.0

-

Adds the saturation effect to the current component. The saturation is the ratio of the chromatic component to the achromatic component (gray) in a color. When the input value is 1, the source image is displayed. When the input value is greater than 1, a higher percentage of the chromatic component indicates a higher saturation. When the input value is less than 1, a higher percentage of the achromatic component indicates a lower saturation. The unit is percentage.

-

contrast

-

number

-

1.0

-

Adds the contrast effect to the current component. The input parameter is a contrast value. If the value is 1, the source image is displayed. If the value is greater than 1, a larger value indicates a higher contrast and a clearer image. If the value is less than 1, a smaller value indicates a lower contrast is. If the value is 0, the image becomes all gray. The unit is percentage.

-

invert

-

number

-

0

-

Inverts the input image. The input parameter is an image inversion ratio. The value 1 indicates complete inversion. The value 0 indicates that the image does not change. The unit is percentage.

-

colorBlend 8+

-

Color

-

-

-

Adds the color blend effect to the current component. The input parameter is the blended color.

-

sepia

-

number

-

0

-

Converts the image color to sepia. The input parameter is an image inversion ratio. The value 1 indicates the image is completely sepia. The value 0 indicates that the image does not change. The unit is percentage.

-

hueRotate

-

Angle

-

0deg

-

Adds the hue rotation effect to the current component. The input parameter is a rotation angle. If the input value is 0deg, the image does not change (because the default rotation angle is 0deg). The input parameter does not have the maximum value. If the value exceeds 360deg, the image is rotated one ore more circles.

-
- -## Example + +## Attributes + + + | Name | Type | Default Value | Description | +| -------- | -------- | -------- | -------- | +| blur | number | - | Adds the content blurring for the current component. The input parameter is the blur radius. The larger the radius is, the more blurred the content is. If the value is **0**, the content is not blurred. | +| backdropBlur | number | - | Adds the background blur effect for the current component. The input parameter is the blur radius. The larger the radius is, the more blurred the background is. If the value is **0**, the background is not blurred. | +| shadow | {
radius: number,
color?: Color,
offsetX?: number,
offsetY?: number
} | - | Adds the shadow effect to the current component. The input parameters are the fuzzy radius (mandatory), shadow color (optional; gray by default), X-axis offset (optional and 0 by default), and Y-axis offset (optional; 0 by default). The offset unit is px. | +| grayscale | number | 0.0 | The value indicates the grayscale conversion ratio. If the input value is **1.0**, the image is converted into a grayscale image. If the input value is **0.0**, the image does not change. If the input value is between **0.0** and **1.0**, the effect changes in linear mode. The unit is percentage. The unit is percentage. | +| brightness | number | 1.0 | Adds a brightness to the current component. The input parameter is a brightness ratio. The value **1** indicates no effects. The value **0** indicates the complete darkness. If the value is less than **1**, the brightness decreases. If the value is greater than **1**, the brightness increases. A larger value indicates a higher brightness. | +| saturate | number | 1.0 | Adds the saturation effect to the current component. The saturation is the ratio of the chromatic component to the achromatic component (gray) in a color. When the input value is **1**, the source image is displayed. When the input value is greater than **1**, a higher percentage of the chromatic component indicates a higher saturation. When the input value is less than **1**, a higher percentage of the achromatic component indicates a lower saturation. The unit is percentage. | +| contrast | number | 1.0 | Adds the contrast effect to the current component. The input parameter is a contrast value. If the value is **1**, the source image is displayed. If the value is greater than **1**, a larger value indicates a higher contrast and a clearer image. If the value is less than **1**, a smaller value indicates a lower contrast is. If the value is **0**, the image becomes all gray. The unit is percentage. | +| invert | number | 0 | Inverts the input image. The input parameter is an image inversion ratio. The value **1** indicates complete inversion. The value **0** indicates that the image does not change. The unit is percentage. | +| colorBlend 8+ | Color | - | Adds the color blend effect to the current component. The input parameter is the blended color. | +| sepia | number | 0 | Converts the image color to sepia. The input parameter is an image inversion ratio. The value **1** indicates the image is completely sepia. The value **0** indicates that the image does not change. The unit is percentage. | +| hueRotate | Angle | 0deg | Adds the hue rotation effect to the current component. The input parameter is a rotation angle. If the input value is **0deg**, the image does not change (because the default rotation angle is **0deg**). The input parameter does not have the maximum value. If the value exceeds **360deg**, the image is rotated one ore more circles. | + + +## Example + ``` @Entry @@ -172,5 +74,4 @@ Column({space: 10}) { } ``` -![](figures/2222.png) - +![en-us_image_0000001212218448](figures/en-us_image_0000001212218448.png) diff --git a/en/application-dev/reference/arkui-ts/ts-universal-attributes-layout-constraints.md b/en/application-dev/reference/arkui-ts/ts-universal-attributes-layout-constraints.md index cb9ef84f00640333a638c95a2bf1bb7e00cb1179..7b599ad4112cfc8f50c103b232508eaa227bad7d 100644 --- a/en/application-dev/reference/arkui-ts/ts-universal-attributes-layout-constraints.md +++ b/en/application-dev/reference/arkui-ts/ts-universal-attributes-layout-constraints.md @@ -1,49 +1,26 @@ -# Layout Constraints +# Layout Constraints ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->This attribute is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -## Required Permissions +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** +> This attribute is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. + + +## Required Permissions None -## Attributes - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Default Value

-

Description

-

aspectRatio

-

number

-

-

-

Specifies an aspect ratio for the current component.

-

displayPriority

-

number

-

-

-

Sets a display priority for the current component in the layout container. When the space of the parent container is insufficient, the component with a lower priority is hidden.

-
NOTE:

This parameter is valid only for the Row/Column/Flex (single-row) container component.

-
-
- -## Example + +## Attributes + + + | Name | Type | Default Value | Description | +| -------- | -------- | -------- | -------- | +| aspectRatio | number | - | Specifies an aspect ratio for the current component. | +| displayPriority | number | - | Sets a display priority for the current component in the layout container. When the space of the parent container is insufficient, the component with a lower priority is hidden.
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:**
> This parameter is valid only for the Row/Column/Flex (single-row) container component. | + + +## Example + ``` @Entry @@ -93,11 +70,12 @@ struct AspectRatioExample { } ``` -**Figure 1** Portrait display -![](figures/portrait-display.gif "portrait-display") + **Figure1** Portrait display + ![en-us_image_0000001256978379](figures/en-us_image_0000001256978379.gif) + + **Figure2** Landscape display + ![en-us_image_0000001212218476](figures/en-us_image_0000001212218476.gif) -**Figure 2** Landscape display -![](figures/landscape-display.gif "landscape-display") ``` class ContainerInfo { @@ -150,5 +128,4 @@ struct DisplayPriorityExample { ``` -![](figures/displaypriorityexample.gif) - +![en-us_image_0000001212058504](figures/en-us_image_0000001212058504.gif) diff --git a/en/application-dev/reference/arkui-ts/ts-universal-attributes-location.md b/en/application-dev/reference/arkui-ts/ts-universal-attributes-location.md index a3617a10670716c6dfa63416a42f49fede8b21c8..f5154e37c8765f6424c9a856a4b1b733f6c5c9f0 100644 --- a/en/application-dev/reference/arkui-ts/ts-universal-attributes-location.md +++ b/en/application-dev/reference/arkui-ts/ts-universal-attributes-location.md @@ -1,117 +1,37 @@ -# Location +# Location ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->This attribute is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -## Required Permissions +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** +> This attribute is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. + + +## Required Permissions None -## Attributes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Default Value

-

Description

-

align

-

Alignment

-

Center

-

Alignment of the component content. This attribute is valid only when the values of width and height are greater than the size of the component content.

-

direction

-

Direction

-

Auto

-

Horizontal layout of the component. For details about the options, see Direction enums.

-

position

-

{

-

x: Length,

-

y: Length

-

}

-

-

-

Offset of the component anchor point relative to the top start edge of the parent component. The offset is expressed using absolute values. When laying out components, this attribute does not affect the layout of the parent component. It only adjusts the component position during drawing.

-

markAnchor

-

{

-

x: Length,

-

y: Length

-

}

-

{

-

x: 0,

-

y: 0

-

}

-

Anchor point of the component for positioning. The top start edge of the component is used as the reference point for offset.

-

offset

-

{

-

x: Length,

-

y: Length

-

}

-

{

-

x: 0,

-

y: 0

-

}

-

Coordinate offset of the relative layout. This attribute does not affect the layout of the parent component. It only adjusts the component position during drawing.

-
- -- Direction enums - - - - - - - - - - - - - - - - -

Name

-

Description

-

Ltr

-

Components are arranged from left to right.

-

Rtl

-

Components are arranged from right to left.

-

Auto

-

The default layout direction is used.

-
- - -## Example + +## Attributes + + +| Name | Type | Default Value | Description | +| -------- | -------- | -------- | -------- | +| align | [Alignment](ts-appendix-enums.md#alignment-enums) | Center | Alignment of the component content. This attribute is valid only when the values of **width** and **height** are greater than the size of the component content. | +| direction | Direction | Auto | Horizontal layout of the component. For details about the options, see **Direction** enums. | +| position | {
x: Length,
y: Length
} | - | Offset of the component anchor point relative to the top start edge of the parent component. The offset is expressed using absolute values. When laying out components, this attribute does not affect the layout of the parent component. It only adjusts the component position during drawing. | +| markAnchor | {
x: Length,
y: Length
} | {
x: 0,
y: 0
} | Anchor point of the component for positioning. The top start edge of the component is used as the reference point for offset. | +| offset | {
x: Length,
y: Length
} | {
x: 0,
y: 0
} | Coordinate offset of the relative layout. This attribute does not affect the layout of the parent component. It only adjusts the component position during drawing. | + + +- Direction enums + | Name | Description | + | -------- | -------- | + | Ltr | Components are arranged from left to right. | + | Rtl | Components are arranged from right to left. | + | Auto | The default layout direction is used. | + + +## Example + ``` @Entry @@ -144,7 +64,8 @@ struct PositionExample { } ``` -![](figures/position.gif) +![en-us_image_0000001212218456](figures/en-us_image_0000001212218456.gif) + ``` @Entry @@ -197,5 +118,4 @@ struct PositionExample2 { } ``` -![](figures/position2.gif) - +![en-us_image_0000001256858409](figures/en-us_image_0000001256858409.gif) diff --git a/en/application-dev/reference/arkui-ts/ts-universal-attributes-opacity.md b/en/application-dev/reference/arkui-ts/ts-universal-attributes-opacity.md index 1103e964b2be11cae8ab1872dbfeab81838b3c32..c786ef89d6bb43988a3f2039886d3ff8665e5dc9 100644 --- a/en/application-dev/reference/arkui-ts/ts-universal-attributes-opacity.md +++ b/en/application-dev/reference/arkui-ts/ts-universal-attributes-opacity.md @@ -1,41 +1,29 @@ -# Opacity +# Opacity + + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** +> This attribute is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->This attribute is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. The attributes described in this topic are used to set the opacity of a component. -## Required Permissions + +## Required Permissions None -## Attributes - - - - - - - - - - - - - - -

Name

-

Type

-

Default Value

-

Description

-

opacity

-

number

-

1

-

Opacity of a component. The value ranges from 0 to 1. The value 1 means opaque, and 0 means completely transparent.

-
- -## Example +## Attributes + + + | Name | Type | Default Value | Description | +| -------- | -------- | -------- | -------- | +| opacity | number | 1 | Opacity of a component. The value ranges from **0** to **1**. The value **1** means opaque, and **0** means completely transparent. | + + +## Example + + ``` @Entry @Component @@ -55,5 +43,4 @@ struct OpacityExample { } ``` -![](figures/opacity.gif) - +![en-us_image_0000001256858385](figures/en-us_image_0000001256858385.gif) diff --git a/en/application-dev/reference/arkui-ts/ts-universal-attributes-overlay.md b/en/application-dev/reference/arkui-ts/ts-universal-attributes-overlay.md index 005b5faf00fb2dbec0b720fd7e7cbd700617773d..f07ffeb31db4e19ff7af1f79c739e7a2d387378d 100644 --- a/en/application-dev/reference/arkui-ts/ts-universal-attributes-overlay.md +++ b/en/application-dev/reference/arkui-ts/ts-universal-attributes-overlay.md @@ -1,45 +1,25 @@ -# Overlay +# Overlay ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->This attribute is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -## Required Permissions +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** +> This attribute is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. + + +## Required Permissions None -## Attributes - - - - - - - - - - - - - -

Name

-

Type

-

Default Value

-

Description

-

overlay

-

title: string,

-

options: {

-

align?: Alignment,

-

offset?: {x: number, y: number}

-

}

-

{

-

align: Alignment.Center,

-

offset: {0, 0}

-

}

-

Mask added to the component. The mask has the same layout as the component.

-
+## Attributes + + +| Name | Type | Default Value | Description | +| -------- | -------- | -------- | -------- | +| overlay | title: string,
options: {
align?: [Alignment](ts-appendix-enums.md#alignment-enums),
offset?: {x: number, y: number}
} | {
align: Alignment.Center,
offset: {0, 0}
} | Mask added to the component. The mask has the same layout as the component. | + + +## Example -## Example ``` @Entry @@ -61,5 +41,4 @@ struct OverlayExample { } ``` -![](figures/en-us_image_0000001194911566.png) - +![en-us_image_0000001212058472](figures/en-us_image_0000001212058472.png) diff --git a/en/application-dev/reference/arkui-ts/ts-universal-attributes-polymorphic-style.md b/en/application-dev/reference/arkui-ts/ts-universal-attributes-polymorphic-style.md new file mode 100644 index 0000000000000000000000000000000000000000..0baadc21f6c8f99d56770f692e580d74b656154f --- /dev/null +++ b/en/application-dev/reference/arkui-ts/ts-universal-attributes-polymorphic-style.md @@ -0,0 +1,126 @@ +# Polymorphic Style + + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** +> This component is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version. + + +You can set state-specific styles for components. + + +## Required Permissions + +None + + +## Attributes + + | Name | Type | Default Value | Description | +| -------- | -------- | -------- | -------- | +| stateStyle | StateStyles | - | Sets the styles of a component for different states. | + +- StateStyles8+ + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | normal | ()=>void | No | - | Style of the component when stateless. | + | pressed | ()=>void | No | - | Style of the component in the pressed state. | + | disabled | ()=>void | No | - | Style of the component in disabled state. | + + +## Example + + +``` +@Entry +@Component +struct StyleExample { + @State isEnable: boolean = true + + @Styles pressedStyles() { + .backgroundColor("#ED6F21") + .borderRadius(10) + .borderStyle(BorderStyle.Dashed) + .borderWidth(2) + .borderColor("#33000000") + .width(120) + .height(30) + .opacity(1) + } + + @Styles disabledStyles() { + .backgroundColor("#E5E5E5") + .borderRadius(10) + .borderStyle(BorderStyle.Solid) + .borderWidth(2) + .borderColor("#2a4c1919") + .width(90) + .height(25) + .opacity(1) + } + + @Styles normalStyles() { + .backgroundColor("#0A59F7") + .borderRadius(10) + .borderStyle(BorderStyle.Solid) + .borderWidth(2) + .borderColor("#33000000") + .width(100) + .height(25) + .opacity(1) + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center }) { + Text("normal") + .fontSize(14) + .fontColor(Color.White) + .opacity(0.5) + .stateStyles({ + normal: this.normalStyles, + }) + .margin({ bottom: 20 }) + .textAlign(TextAlign.Center) + Text("pressed") + .backgroundColor("#0A59F7") + .borderRadius(20) + .borderStyle(BorderStyle.Dotted) + .borderWidth(2) + .borderColor(Color.Red) + .width(100) + .height(25) + .opacity(1) + .fontSize(14) + .fontColor(Color.White) + .stateStyles({ + pressed: this.pressedStyles, + }) + .margin({ bottom: 20 }) + .textAlign(TextAlign.Center) + Text(this.isEnable == true ? "effective" : "disabled") + .backgroundColor("#0A59F7") + .borderRadius(20) + .borderStyle(BorderStyle.Solid) + .borderWidth(2) + .borderColor(Color.Gray) + .width(100) + .height(25) + .opacity(1) + .fontSize(14) + .fontColor(Color.White) + .enabled(this.isEnable) + .stateStyles({ + disabled: this.disabledStyles, + }) + .textAlign(TextAlign.Center) + Text("control disabled") + .onClick(() => { + this.isEnable = !this.isEnable + console.log(`${this.isEnable}`) + }) + } + .width(350).height(300) + } +} +``` + +![en-us_image_0000001211898512](figures/en-us_image_0000001211898512.gif) diff --git a/en/application-dev/reference/arkui-ts/ts-universal-attributes-popup.md b/en/application-dev/reference/arkui-ts/ts-universal-attributes-popup.md index e0ec8e6def24f08eecdacc1233f563abe4427a43..e3e1aa2400713a3b5a58bb45ede5385ed16b9173 100644 --- a/en/application-dev/reference/arkui-ts/ts-universal-attributes-popup.md +++ b/en/application-dev/reference/arkui-ts/ts-universal-attributes-popup.md @@ -1,272 +1,58 @@ -# Popup Control +# Popup Control ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->This attribute is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -## Required Permissions +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** +> This attribute is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. + + +## Required Permissions None -## Attributes - - - - - - - - - - - - - -

Name

-

Type

-

Default Value

-

Description

-

bindPopup

-

show: boolean,

-

popup: PopupOption | CustomPopupOption

-

-

-

Settings of the popup bound to a component.

-

show: whether to display the popup message on the creation page by default. The default value is false.

-

popup: parameters of the current popup window.

-
+## Attributes -- PopupOption APIs - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

message

-

string

-

Yes

-

-

-

Content of the popup message.

-

placementOnTop

-

boolean

-

No

-

false

-

Whether to display the popup message above the component. The default value is false.

-

primaryButton

-

{

-

value: string,

-

action: () => void

-

}

-

No

-

-

-

The first button.

-

value: text of the primary button in the popup.

-

action: callback function for tapping the primary button.

-

secondaryButton

-

{

-

value: string,

-

action: () => void

-

}

-

No

-

-

-

Second button.

-

value: text of the secondary button in the popup.

-

action: callback function for tapping the secondary button.

-

onStateChange

-

(isVisible: boolean) => void

-

No

-

-

-

Callback for the popup status change event. The parameter isVisible indicates the visibility of the popup.

-
+ | Name | Type | Default Value | Description | +| -------- | -------- | -------- | -------- | +| bindPopup | show: boolean,
popup: PopupOption \| CustomPopupOption | - | Settings of the popup bound to a component.
**show**: whether to display the popup on the creation page by default. The default value is **false**.
**popup**: parameters of the current popup. | -- CustomPopupOption APIs8+ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

builder

-

() => any

-

Yes

-

-

-

Builder of the tooltip content.

-

placement

-

Placement

-

No

-

Placement.Bottom

-

Preferred position of the tooltip component. If the set position is insufficient for holding the component, it will be automatically adjusted.

-

maskColor

-

Color

-

No

-

-

-

Color of the tooltip mask.

-

popupColor

-

Color

-

No

-

-

-

Color of the tooltip.

-

enableArrow

-

boolean

-

No

-

true

-

Whether to display arrows. Arrows are displayed only for tooltips in the up and down directions.

-

autoCancel

-

boolean

-

No

-

true

-

Whether to automatically close the tooltip when an operation is performed on the page.

-

onStateChange

-

(isVisible: boolean) => void

-

No

-

-

-

Callback for the popup status change event. The parameter isVisible indicates the visibility of the popup.

-
+- PopupOption attributes + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | message | string | Yes | - | Content of the popup message. | + | placementOnTop | boolean | No | false | Whether to display the popup above the component. The default value is **false**. | + | primaryButton | {
value: string,
action: () => void
} | No | - | First button.
**value**: text of the primary button in the popup.
**action**: callback function for clicking the primary button. | + | secondaryButton | {
value: string,
action: () => void
} | No | - | Second button.
**value**: text of the secondary button in the popup.
**action**: callback function for clicking the secondary button. | + | onStateChange | (isVisible: boolean) => void | No | - | Callback for the popup status change event. The parameter **isVisible** indicates the visibility of the popup. | -- Placement enums8+ +- CustomPopupOption8+ + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | builder | () => any | Yes | - | Builder of the tooltip content. | + | placement | Placement | No | Placement.Bottom | Preferred position of the tooltip component. If the set position is insufficient for holding the component, it will be automatically adjusted. | + | maskColor | [Color](../../ui/ts-types.md) | No | - | Color of the tooltip mask. | + | popupColor | [Color](../../ui/ts-types.md) | No | - | Color of the tooltip. | + | enableArrow | boolean | No | true | Whether to display arrows. Arrows are displayed only for tooltips in the up and down directions. | + | autoCancel | boolean | No | true | Whether to automatically close the tooltip when an operation is performed on the page. | + | onStateChange | (isVisible: boolean) => void | No | - | Callback for the popup status change event. The parameter **isVisible** indicates the visibility of the popup. | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Description

-

Left

-

The tooltip is on the left of the component.

-

Right

-

The tooltip is on the right of the component.

-

Top

-

The tooltip is on the top of the component.

-

Bottom

-

The tooltip is at the bottom of the component.

-

TopLeft

-

The tooltip is in the upper left corner of the component.

-

TopRight

-

The tooltip is in the upper right corner of the component.

-

BottomLeft

-

The tooltip is in the lower left corner of the component.

-

BottomRight

-

The tooltip is in the lower right corner of the component.

-
+- Placement8+ enums + | Name | Description | + | -------- | -------- | + | Left | The tooltip is on the left of the component. | + | Right | The tooltip is on the right of the component. | + | Top | The tooltip is on the top of the component. | + | Bottom | The tooltip is at the bottom of the component. | + | TopLeft | The tooltip is in the upper left corner of the component. | + | TopRight | The tooltip is in the upper right corner of the component. | + | BottomLeft | The tooltip is in the lower left corner of the component. | + | BottomRight | The tooltip is in the lower right corner of the component. | -## Example +## Example + ``` @Entry @@ -343,5 +129,4 @@ struct PopupExample { } ``` -![](figures/popup.gif) - +![en-us_image_0000001212058458](figures/en-us_image_0000001212058458.gif) diff --git a/en/application-dev/reference/arkui-ts/ts-universal-attributes-response-region.md b/en/application-dev/reference/arkui-ts/ts-universal-attributes-response-region.md deleted file mode 100644 index cf71d324e4ed22f3bee1ef83a1c8b57bb88c1339..0000000000000000000000000000000000000000 --- a/en/application-dev/reference/arkui-ts/ts-universal-attributes-response-region.md +++ /dev/null @@ -1,133 +0,0 @@ -# Touch Target - ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->This attribute is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version. - -You can set the touch target for components that support universal click events, touch events, and gestures. - -## Required Permissions - -None - -## Attributes - - - - - - - - - - - - - - -

Name

-

Type

-

Default Value

-

Description

-

responseRegion

-

Array<Rectangle> | Rectangle

-

{

-

x: 0,

-

y:0,

-

width:'100%',

-

height:'100%'

-

}

-

Indicates one or more touch targets, including their location and size.

-
NOTE:

The percentage is measured relative to the component itself.

-

x and y can be set to a positive or negative percentage value. For example, when x is set to '100%', the touch target is offset from the right edge of the component by the component's width. When x is set to '-100%', the touch target is offset from the left edge of the component by the component's width. When y is set to '100%', the touch target is offset from the bottom edge of the component by the component's height. When y is set to '-100%', the touch target is offset from the top edge of the component by the component's height.

-

width and height can only be set to positive percentage values. For example, when width is set to '100%', the width of the touch target is equal to that of the component; when height is set to '100%', the height of the touch target is equal to that of the component.

-
-
- -- Rectangle object - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

x

-

Length

-

No

-

0vp

-

X coordinate of the touch point relative to the left edge of the component.

-

y

-

Length

-

No

-

0vp

-

Y coordinate of the touch point relative to the left edge of the component.

-

width

-

Length

-

No

-

100%

-

Width of the touch target.

-

height

-

Length

-

No

-

100%

-

Height of the touch target.

-
- - >![](../../public_sys-resources/icon-note.gif) **NOTE:** - >When both **x** and **y** are set to positive values, the entire touch target offsets towards the lower right corner of the component. How much the touch target offsets is subject to the set values. - - -## Example - -``` -@Entry -@Component -struct ResponseRegionExample { - build() { - Column() { - Toggle({ type: ToggleType.Checkbox, isOn: true }) - .selectedColor(0x39a2db) - .backgroundColor(0xAFEEEE) - .responseRegion({ x: 1.0, y: 1.0, width: 400, height: 400 }) - .onChange((isOn: boolean) => { - console.info('Component status:' + isOn) - }) - }.width('100%').margin({ top: 5 }) - } -} -``` - -![](figures/gif1.gif) - diff --git a/en/application-dev/reference/arkui-ts/ts-universal-attributes-sharp-clipping.md b/en/application-dev/reference/arkui-ts/ts-universal-attributes-sharp-clipping.md index 0fb7dd4f8881ad4258e2d887e6a9004d0ce0cd16..eef44b85ca3a83a5d60b78462db9b9b28061c7f8 100644 --- a/en/application-dev/reference/arkui-ts/ts-universal-attributes-sharp-clipping.md +++ b/en/application-dev/reference/arkui-ts/ts-universal-attributes-sharp-clipping.md @@ -1,48 +1,27 @@ -# Shape Clipping +# Shape Clipping ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->This attribute is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -## Required Permissions +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** +> This attribute is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. + + +## Required Permissions None -## Attributes - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Default Value

-

Description

-

clip

-

Shape | boolean

-

false

-

Specifies a clip mode. The value Shape indicates that the current component is cropped based on the specified shape. The value boolean specifies whether to clip the component based on the edge outline.

-

mask

-

Shape

-

-

-

Adds a mask of the specified shape to the current component.

-
- -## Example +## Attributes + + + | Name | Type | Default Value | Description | +| -------- | -------- | -------- | -------- | +| clip | Shape \| boolean | false | Specifies a clip mode. The value **Shape** indicates that the current component is cropped based on the specified shape. The value **boolean** specifies whether to clip the component based on the edge outline. | +| mask | Shape | - | Adds a mask of the specified shape to the current component. | + + +## Example + + ``` @Entry @Component @@ -78,5 +57,4 @@ struct ClipAndMaskExample { } ``` -![](figures/clip.png) - +![en-us_image_0000001212218452](figures/en-us_image_0000001212218452.png) diff --git a/en/application-dev/reference/arkui-ts/ts-universal-attributes-size.md b/en/application-dev/reference/arkui-ts/ts-universal-attributes-size.md index dbac35d7acd691ff16880f42955607a30fb80f8b..f35376f94477923703e61ac33c9e9a6b12a10552 100644 --- a/en/application-dev/reference/arkui-ts/ts-universal-attributes-size.md +++ b/en/application-dev/reference/arkui-ts/ts-universal-attributes-size.md @@ -1,120 +1,30 @@ -# Size +# Size ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->This attribute is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -## Required Permissions +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** +> This attribute is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. + + +## Required Permissions None -## Attributes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Default Value

-

Description

-

width

-

Length

-

-

-

Width of a component. By default, the width required to fully hold the component content is used.

-

height

-

Length

-

-

-

Height of the component. By default, the height required to fully hold the component content is used.

-

size

-

{

-

width?: Length,

-

height?: Length

-

}

-

-

-

Height and width of the component.

-

padding

-

{

-

top?: Length,

-

right?: Length,

-

bottom?: Length,

-

left?: Length

-

} | Length

-

0

-

Padding of the component.

-

When the parameter is of the Length type, the four paddings take effect.

-

margin

-

{

-

top?: Length,

-

right?: Length,

-

bottom?: Length,

-

left?: Length

-

}

-

| Length

-

0

-

Margin of the component.

-

When the parameter is of the Length type, the four margins take effect.

-

constraintSize

-

{

-

minWidth?: Length,

-

maxWidth?: Length,

-

minHeight?: Length,

-

maxHeight?: Lenght

-

}

-

{

-

minWidth: 0,

-

maxWidth: Infinity,

-

minHeight: 0,

-

maxHeight: Infinity

-

}

-

Constraint size of the component, which is used to limit the size range during component layout.

-

layoutWeight

-

number

-

0

-

Weight of the component during layout. When the container size is determined, the layout of the component and sibling components is allocated based on the weight along the main axis. The component size setting is ignored.

-
NOTE:

This attribute is valid only for the Row, Column, and Flex layouts.

-
-
+## Attributes + -## Example + | Name | Type | Default Value | Description | +| -------- | -------- | -------- | -------- | +| width | Length | - | Width of a component. By default, the width required to fully hold the component content is used. | +| height | Length | - | Height of the component. By default, the height required to fully hold the component content is used. | +| size | {
width?: Length,
height?: Length
} | - | Height and width of the component. | +| padding | {
top?: Length,
right?: Length,
bottom?: Length,
left?: Length
} \| Length | 0 | Padding of the component.
When the parameter is of the **Length** type, the four paddings take effect. | +| margin | {
top?: Length,
right?: Length,
bottom?: Length,
left?: Length
}
\| Length | 0 | Margin of the component. 
When the parameter is of the **Length** type, the four margins take effect. | +| constraintSize | {
minWidth?: Length,
maxWidth?: Length,
minHeight?: Length,
maxHeight?: Length
} | {
minWidth: 0,
maxWidth: Infinity,
minHeight: 0,
maxHeight: Infinity
} | Constraint size of the component, which is used to limit the size range during component layout. | +| layoutWeight | number | 0 | Weight of the component during layout. When the container size is determined, the layout of the component and sibling components is allocated based on the weight along the main axis. The component size setting is ignored.
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:**
> This attribute is valid only for the **Row**, **Column**, and **Flex** layouts. | + + +## Example ``` @Entry @@ -137,7 +47,7 @@ struct SizeExample { Text('layoutWeight(1)') .size({ width: '30%', height: 110 }).backgroundColor(0xFFEFD5).textAlign(TextAlign.Center) .layoutWeight(1) - // Weight 0 + // Weight 0 Text('layoutWeight(2)') .size({ width: '30%', height: 110 }).backgroundColor(0xF5DEB3).textAlign(TextAlign.Center) .layoutWeight(2) @@ -146,9 +56,7 @@ struct SizeExample { .size({ width: '30%', height: 110 }).backgroundColor(0xD2B48C).textAlign(TextAlign.Center) }.size({ width: '90%', height: 140 }).backgroundColor(0xAFEEEE) }.width('100%').margin({ top: 5 }) - } -} + }} ``` -![](figures/size.gif) - +![en-us_image_0000001257138367](figures/en-us_image_0000001257138367.gif) diff --git a/en/application-dev/reference/arkui-ts/ts-universal-attributes-text-style.md b/en/application-dev/reference/arkui-ts/ts-universal-attributes-text-style.md index d793202b2815247310b306b50a98b2f835ed1ec5..8cfa736c145a1c1e378a90b34abd9aede4a6a5ea 100644 --- a/en/application-dev/reference/arkui-ts/ts-universal-attributes-text-style.md +++ b/en/application-dev/reference/arkui-ts/ts-universal-attributes-text-style.md @@ -1,144 +1,51 @@ -# Text Style +# Text Style + + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** +> This attribute is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->This attribute is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. The attributes described in this topic are used to set the text style for a component that contains text. -## Required Permissions + +## Required Permissions None -## Attributes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Default Value

-

Description

-

fontColor

-

Color

-

-

-

Text color.

-

fontSize

-

Length

-

-

-

Text size. If the value is of the number type, the unit fp is used.

-

fontStyle

-

FontStyle

-

Normal

-

Font style of the text.

-

fontWeight

-

number | FontWeight

-

Normal

-

Font weight. For the number type, the value ranges from 100 to 900, at an interval of 100. The default value is 400. A larger value indicates a larger font weight.

-

For details on the common enumerated values, see FontWeight enums.

-

fontFamily

-

string

-

-

-

Font family of the text. Use commas (,) to separate multiple fonts. The priority the fonts is the sequence in which they are placed. An example value is Arial, sans-serif.

-
- -- FontStyle enums - - - - - - - - - - - - - -

Name

-

Description

-

Normal

-

Standard font style.

-

Italic

-

Italic font style.

-
- - -- FontWeight enums - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Description

-

Lighter

-

The font weight is lighter.

-

Normal

-

The font weight is normal.

-

Regular

-

The font weight is regular.

-

Medium

-

The font weight is medium.

-

Bold

-

The font weight is bold.

-

Bolder

-

The font weight is bolder.

-
- - -## Example +## Attributes + + + | Name | Type | Default Value | Description | +| -------- | -------- | -------- | -------- | +| fontColor | Color | - | Text color. | +| fontSize | Length | - | Text size. If the value is of the number type, the unit fp is used. | +| fontStyle | FontStyle | FontStyle.Normal | Font style of the text. | +| fontWeight | number \| FontWeight | FontWeight.Normal | Font weight. For the number type, the value ranges from 100 to 900, at an interval of 100. The default value is **400**. A larger value indicates a larger font weight.
For common values of the **FontWeight** type, see **FontWeight** enums. | +| fontFamily | string | - | Font family of the text. Use commas (,) to separate multiple fonts. The priority the fonts is the sequence in which they are placed. An example value is **Arial, sans-serif**. | + + +- FontStyle enums + | Name | Description | + | -------- | -------- | + | Normal | Standard font style. | + | Italic | Italic font style. | + + +- FontWeight enums + | Name | Description | + | -------- | -------- | + | Lighter | The font weight is lighter. | + | Normal | The font weight is normal. | + | Regular | The font weight is regular. | + | Medium | The font weight is medium. | + | Bold | The font weight is bold. | + | Bolder | The font weight is bolder. | + + +## Example + + ``` @Entry @Component @@ -182,5 +89,4 @@ struct TextStyleExample { } ``` -![](figures/textstyle.png) - +![en-us_image_0000001256978333](figures/en-us_image_0000001256978333.png) diff --git a/en/application-dev/reference/arkui-ts/ts-universal-attributes-touch-target.md b/en/application-dev/reference/arkui-ts/ts-universal-attributes-touch-target.md new file mode 100644 index 0000000000000000000000000000000000000000..62fd9db2ddca3e177003555ef8ee806f67c59627 --- /dev/null +++ b/en/application-dev/reference/arkui-ts/ts-universal-attributes-touch-target.md @@ -0,0 +1,57 @@ +# Touch Target + + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** +> This component is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version. + + +You can set the touch target for components that support universal click events, touch events, and gestures. + + +## Required Permissions + +None + + +## Attributes + + + | Name | Type | Default Value | Description | +| -------- | -------- | -------- | -------- | +| responseRegion | Array<Rectangle> \| Rectangle | {
x: 0,
y: 0,
width: '100%',
height: '100%'
} | One or more touch targets, including their location and size.
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:**
> The percentage is measured relative to the component itself.

> **x** and **y** can be set to a positive or negative percentage value. For example, when **x** is set to **'100%'**, the touch target is offset from the right edge of the component by the component's width. When **x** is set to **'-100%'**, the touch target is offset from the left edge of the component by the component's width. When **y** is set to **'100%'**, the touch target is offset from the bottom edge of the component by the component's height. When **y** is set to **'-100%'**, the touch target is offset from the top edge of the component by the component's height.

> **width** and **height** can only be set to positive percentage values. When **width** is set to **'100%'**, the width of the touch target is equal to that of the component; when **height** is set to **'100%'**, the height of the touch target is equal to that of the component. | + + +- Rectangle attributes + | Name | Type | Mandatory | Default Value | Description | + | -------- | -------- | -------- | -------- | -------- | + | x | Length | No | 0vp | X coordinate of the touch point relative to the left edge of the component. | + | y | Length | No | 0vp | Y coordinate of the touch point relative to the left edge of the component. | + | width | Length | No | 100% | Width of the touch target. | + | height | Length | No | 100% | Height of the touch target. | + + > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** + > When both **x** and **y** are set to positive values, the entire touch target offsets towards the lower right corner of the component. How much the touch target offsets is subject to the set values. + + +## Example + + +``` +@Entry +@Component +struct ResponseRegionExample { + build() { + Column() { + Toggle({ type: ToggleType.Checkbox, isOn: true }) + .selectedColor(0x39a2db) + .backgroundColor(0xAFEEEE) + .responseRegion({ x: 1.0, y: 1.0, width: 400, height: 400 }) + .onChange((isOn: boolean) => { + console.info('Component status:' + isOn) + }) + }.width('100%').margin({ top: 5 }) + } +} +``` + +![en-us_image_0000001212218468](figures/en-us_image_0000001212218468.gif) diff --git a/en/application-dev/reference/arkui-ts/ts-universal-attributes-touchable.md b/en/application-dev/reference/arkui-ts/ts-universal-attributes-touchable.md deleted file mode 100644 index b657f8645c805a602937716d43743016ee5fc99b..0000000000000000000000000000000000000000 --- a/en/application-dev/reference/arkui-ts/ts-universal-attributes-touchable.md +++ /dev/null @@ -1,65 +0,0 @@ -# Click Control - ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->This attribute is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version. - -## Required Permissions - -None - -## Attributes - - - - - - - - - - - - - - -

Name

-

Type

-

Default Value

-

Description

-

touchable

-

boolean

-

true

-

Whether the current component is touchable.

-
- -## Example - -``` -@Entry -@Component -struct TouchAbleExample { - @State text1: string = '' - @State text2: string = '' - - build() { - Stack() { - Rect() - .fill(Color.Gray).width(150).height(150) - .onClick(() => { - console.info(this.text1 = 'Rect Clicked') - }) - .overlay(this.text1, { align: Alignment.Bottom, offset: { x: 0, y: 20 } }) - Ellipse() - .fill(Color.Pink).width(150).height(80) - .touchable(false) // When the Ellipse area is touched, the message "Ellipse Clicked" is not displayed. - .onClick(() => { - console.info(this.text2 = 'Ellipse Clicked') - }) - .overlay(this.text2, { align: Alignment.Bottom, offset: { x: 0, y: 20 } }) - }.margin(100) - } -} -``` - -![](figures/gif2.gif) - diff --git a/en/application-dev/reference/arkui-ts/ts-universal-attributes-transformation.md b/en/application-dev/reference/arkui-ts/ts-universal-attributes-transformation.md index 10ced26c5df07aa57727c633231be1d7bbb90f55..9872e09c8ee299860ac42290bd8240284bd48305 100644 --- a/en/application-dev/reference/arkui-ts/ts-universal-attributes-transformation.md +++ b/en/application-dev/reference/arkui-ts/ts-universal-attributes-transformation.md @@ -1,100 +1,29 @@ -# Transformation +# Transformation ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->This attribute is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -## Required Permissions +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** +> This attribute is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. + + +## Required Permissions None -## Attributes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Default Value

-

Description

-

rotate

-

{

-

x?: number,

-

y?: number,

-

z?: number,

-

angle?: Angle,

-

centerX?: Length,

-

centerY?: Length

-

}

-

{

-

x: 0,

-

y: 0,

-

z: 0,

-

angle: 0,

-

centerX: '50%',

-

centerY: '50%'

-

}

-

The vector (x, y, z) specifies a rotation axis. A positive angle indicates a clockwise rotation, and a negative angle indicates a counterclockwise rotation. The default value is 0. centerX and centerY are used to set the rotation center point.

-

translate

-

{

-

x?: Length,

-

y?: Length,

-

z? : Length

-

}

-

{

-

x: 0,

-

y: 0,

-

z: 0

-

}

-

Translation distance along the x-, y-, and z-axis. The translation direction is determined by the positive and negative values. The default value is 0.

-

scale

-

{

-

x?: number,

-

y?: number,

-

z?: number,

-

centerX?: Length,

-

centerY?: Length

-

}

-

{

-

x: 1,

-

y: 1,

-

z: 1,

-

centerX:'50%',

-

centerY:'50%'

-

}

-

Scale ratio of the x-, y-, and z-axis. The default value is 1. centerX and centerY are used to set the scale center point.

-

transform

-

matrix: Matrix4

-

-

-

Transformation matrix of the component.

-
- -## Example +## Attributes + + + | Name | Type | Default Value | Description | +| -------- | -------- | -------- | -------- | +| rotate | {
x?: number,
y?: number,
z?: number,
angle?: Angle,
centerX?: Length,
centerY?: Length
} | {
x: 0,
y: 0,
z: 0,
angle: 0,
centerX: '50%',
centerY: '50%'
} | The vector (x, y, z) specifies a rotation axis. A positive angle indicates a clockwise rotation, and a negative angle indicates a counterclockwise rotation. The default value is **0**. **centerX** and **centerY** are used to set the rotation center point. | +| translate | {
x?: Length,
y?: Length,
z? : Length
} | {
x: 0,
y: 0,
z: 0
} | Translation distance along the x-, y-, and z-axis. The translation direction is determined by the positive and negative values. The default value is **0**. | +| scale | {
x?: number,
y?: number,
z?: number,
centerX?: Length,
centerY?: Length
} | {
x: 1,
y: 1,
z: 1,
centerX:'50%',
centerY:'50%'
} | Scale ratio of the x-, y-, and z-axis. The default value is **1**. **centerX** and **centerY** are used to set the scale center point. | +| transform | matrix: Matrix4 | - | Transformation matrix of the component. | + + +## Example + + ``` import Matrix4 from '@ohos.matrix4' @@ -134,5 +63,4 @@ struct TransformExample { } ``` -![](figures/1111.png) - +![en-us_image_0000001257058401](figures/en-us_image_0000001257058401.png) diff --git a/en/application-dev/reference/arkui-ts/ts-universal-attributes-visibility.md b/en/application-dev/reference/arkui-ts/ts-universal-attributes-visibility.md index 0d1e059339f91505df8d52c44d6e517bffb9f148..0754cd8cc2061dbd136ae8e88e9bc0de84e79592 100644 --- a/en/application-dev/reference/arkui-ts/ts-universal-attributes-visibility.md +++ b/en/application-dev/reference/arkui-ts/ts-universal-attributes-visibility.md @@ -1,67 +1,34 @@ -# Visibility +# Visibility ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->This attribute is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -## Required Permissions +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** +> This attribute is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. + + +## Required Permissions None -## Attributes - - - - - - - - - - - - - - -

Name

-

Type

-

Default Value

-

Description

-

visibility

-

Visibility

-

Visible

-

Whether the component is shown or hidden.

-
- -- Visibility enums - - - - - - - - - - - - - - - - -

Name

-

Description

-

Hidden

-

The component is hidden, and a placeholder is used for it in the layout.

-

Visible

-

The component is shown.

-

None

-

The component is hidden. It is not involved in the layout, and no placeholder is used for it.

-
- - -## Example +## Attributes + + + | Name | Type | Default Value | Description | +| -------- | -------- | -------- | -------- | +| visibility | Visibility | Visibility.Visible | Whether the component is shown or hidden. | + + +- Visibility enums + | Name | Description | + | -------- | -------- | + | Hidden | The component is hidden, and a placeholder is used for it in the layout. | + | Visible | The component is shown. | + | None | The component is hidden. It is not involved in the layout, and no placeholder is used for it. | + + +## Example + + ``` @Entry @Component @@ -85,5 +52,4 @@ struct VisibilityExample { } ``` -![](figures/visibility.gif) - +![en-us_image_0000001257058421](figures/en-us_image_0000001257058421.gif) diff --git a/en/application-dev/reference/arkui-ts/ts-universal-attributes-z-order.md b/en/application-dev/reference/arkui-ts/ts-universal-attributes-z-order.md index 91770cb64ef08cd8209c9ce6d9969d708ebd9f3b..75c12a927c600b0f2a2254f7fa6f4b7e3e414a1f 100644 --- a/en/application-dev/reference/arkui-ts/ts-universal-attributes-z-order.md +++ b/en/application-dev/reference/arkui-ts/ts-universal-attributes-z-order.md @@ -1,39 +1,26 @@ -# Z-order Control +# Z-order Control ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->This attribute is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -## Required Permissions +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** +> This attribute is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. + + +## Required Permissions None -## Attributes - - - - - - - - - - - - - - -

Name

-

Type

-

Default Value

-

Description

-

zIndex

-

number

-

0

-

Hierarchy of sibling components in a container. A larger z-order value indicates a higher display level.

-
- -## Example +## Attributes + + + | Name | Type | Default Value | Description | +| -------- | -------- | -------- | -------- | +| zIndex | number | 0 | Hierarchy of sibling components in a container. A larger z-order value indicates a higher display level. | + + +## Example + + ``` @Entry @Component @@ -57,5 +44,4 @@ struct ZIndexExample { } ``` -![](figures/zindex.png) - +![en-us_image_0000001257058443](figures/en-us_image_0000001257058443.png) diff --git a/en/application-dev/reference/arkui-ts/ts-universal-attributes.md b/en/application-dev/reference/arkui-ts/ts-universal-attributes.md index 2ca2f7ebdbf19b813cdaf4894ab13bb8eb2172f4..b565b5df7a66ceff61d1fe67d004ac9a385dd91b 100644 --- a/en/application-dev/reference/arkui-ts/ts-universal-attributes.md +++ b/en/application-dev/reference/arkui-ts/ts-universal-attributes.md @@ -1,45 +1,53 @@ -# Universal Attributes +# Universal Attributes -- **[Size](ts-universal-attributes-size.md)** -- **[Location](ts-universal-attributes-location.md)** -- **[Layout Constraints](ts-universal-attributes-layout-constraints.md)** +- **[Size](ts-universal-attributes-size.md)** -- **[Flex Layout](ts-universal-attributes-flex-layout.md)** +- **[Location](ts-universal-attributes-location.md)** -- **[Border Configuration](ts-universal-attributes-border.md)** +- **[Layout Constraints](ts-universal-attributes-layout-constraints.md)** -- **[Background](ts-universal-attributes-background.md)** +- **[Flex Layout](ts-universal-attributes-flex-layout.md)** -- **[Opacity](ts-universal-attributes-opacity.md)** +- **[Border](ts-universal-attributes-border.md)** -- **[Visibility](ts-universal-attributes-visibility.md)** +- **[Background](ts-universal-attributes-background.md)** -- **[Enable/Disable](ts-universal-attributes-enable.md)** +- **[Opacity](ts-universal-attributes-opacity.md)** -- **[Overlay](ts-universal-attributes-overlay.md)** +- **[Visibility](ts-universal-attributes-visibility.md)** -- **[Z-order Control](ts-universal-attributes-z-order.md)** +- **[Enable/Disable](ts-universal-attributes-enable.md)** -- **[Transformation](ts-universal-attributes-transformation.md)** +- **[Overlay](ts-universal-attributes-overlay.md)** -- **[Image Effect Configuration](ts-universal-attributes-image-effect.md)** +- **[Z-order Control](ts-universal-attributes-z-order.md)** -- **[Shape Clipping](ts-universal-attributes-sharp-clipping.md)** +- **[Transformation](ts-universal-attributes-transformation.md)** -- **[Text Style](ts-universal-attributes-text-style.md)** +- **[Image Effect Configuration](ts-universal-attributes-image-effect.md)** -- **[Grid](ts-universal-attributes-grid.md)** +- **[Shape Clipping](ts-universal-attributes-sharp-clipping.md)** -- **[Gradient Color](ts-universal-attributes-gradient-color.md)** +- **[Text Style](ts-universal-attributes-text-style.md)** -- **[Popup Control](ts-universal-attributes-popup.md)** +- **[Grid](ts-universal-attributes-grid.md)** -- **[Menu Control](ts-universal-attributes-menu.md)** +- **[Gradient Color](ts-universal-attributes-gradient-color.md)** -- **[Click Control](ts-universal-attributes-touchable.md)** +- **[Popup Control](ts-universal-attributes-popup.md)** -- **[Touch Target](ts-universal-attributes-response-region.md)** +- **[Menu Control](ts-universal-attributes-menu.md)** +- **[Click Control](ts-universal-attributes-click.md)** +- **[Focus Control](ts-universal-attributes-focus.md)** + +- **[Hover Effect](ts-universal-attributes-hover-effect.md)** + +- **[Component ID](ts-universal-attributes-component-id.md)** + +- **[Touch Target](ts-universal-attributes-touch-target.md)** + +- **[Polymorphic Style](ts-universal-attributes-polymorphic-style.md)** \ No newline at end of file diff --git a/en/application-dev/reference/arkui-ts/ts-universal-component-area-change-event.md b/en/application-dev/reference/arkui-ts/ts-universal-component-area-change-event.md new file mode 100644 index 0000000000000000000000000000000000000000..200f994c813dd0768abdb859bbdd92b4c0530ca3 --- /dev/null +++ b/en/application-dev/reference/arkui-ts/ts-universal-component-area-change-event.md @@ -0,0 +1,48 @@ +# Component Area Change Event + + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** +> This component is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version. + + +## Required Permissions + +None + + +## Events + + | Name | Bubble Supported | Description | +| -------- | -------- | -------- | +| onAreaChange(event: (oldValue: Area, newValue: Area) => void) | No | Triggered when the component area changes. For details about the **Area** type, see **Area** attributes. | + + +## Example + + +``` +@Entry +@Component +struct AreaExample { + @State value: string = 'Text' + @State size: string = '' + + build() { + Column() { + Text(this.value) + .backgroundColor(Color.Green).margin(30).fontSize(20) + .onClick(() => { + this.value = this.value + 'Text' + }) + .onAreaChange((oldValue: Area, newValue: Area) => { + console.info(`Ace: on area change, oldValue is ${JSON.stringify(oldValue)} value is ${JSON.stringify(newValue)}`) + this.size = JSON.stringify(newValue) + }) + Text('new area is: \n' + this.size).margin({ right: 30, left: 30 }) + } + .width('100%').height('100%').margin({ top: 30 }) + } +} +``` + +![en-us_image_0000001257058403](figures/en-us_image_0000001257058403.gif) diff --git a/en/application-dev/reference/arkui-ts/ts-universal-components.md b/en/application-dev/reference/arkui-ts/ts-universal-components.md index 3a70c3c421034a7cba1e10b40c8f557ad143f8ce..35d2a841f25a6884ca690a19fdc068d3fad4e1a8 100644 --- a/en/application-dev/reference/arkui-ts/ts-universal-components.md +++ b/en/application-dev/reference/arkui-ts/ts-universal-components.md @@ -1,9 +1,9 @@ -# Universal Components +# Universal Components -- **[Universal Events](ts-universal-events.md)** -- **[Universal Attributes](ts-universal-attributes.md)** -- **[Gesture Processing](ts-gesture-processing.md)** +- **[Universal Events](ts-universal-events.md)** +- **[Universal Attributes](ts-universal-attributes.md)** +- **[Gesture Processing](ts-gesture-processing.md)** \ No newline at end of file diff --git a/en/application-dev/reference/arkui-ts/ts-universal-events-click.md b/en/application-dev/reference/arkui-ts/ts-universal-events-click.md index 8ac56eb6bba732d3e9780113361fe4775b4723cb..0cf31dce9664da5dcc4296f199e613088629bcd1 100644 --- a/en/application-dev/reference/arkui-ts/ts-universal-events-click.md +++ b/en/application-dev/reference/arkui-ts/ts-universal-events-click.md @@ -1,182 +1,36 @@ -# Click Event +# Click Event ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->This event is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -## Required Permissions +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** +> This method is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. + + +## Required Permissions None -## Events - - - - - - - - - - - - -

Name

-

Bubble Supported

-

Description

-

onClick(callback: (event?: ClickEvent) => void)

-

No

-

Called when a click event occurs. For details about the event parameters, see ClickEvent object.

-
- -- ClickEvent object - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Description

-

screenX

-

number

-

X coordinate of the click relative to the left edge of the screen.

-

screenY

-

number

-

Y coordinate of the click relative to the upper edge of the screen.

-

x

-

number

-

X coordinate of the click relative to the left edge of the component being clicked.

-

y

-

number

-

Y coordinate of the click relative to the upper edge of the component being clicked.

-

target8+

-

EventTarget

-

Object of the element that is clicked.

-

timestamp

-

number

-

Timestamp of the event.

-
- -- EventTarget object8+ - - - - - - - - - - - - -

Name

-

Type

-

Description

-

area

-

Area

-

Area information of the target element.

-
- -- Area attributes8+ - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Description

-

width

-

Length

-

Width of the target element.

-

height

-

Length

-

Height of the target element.

-

pos

-

Position

-

Position of the upper left corner of the target element relative to that of the parent element.

-

globalPos

-

Position

-

Position of the upper left corner of the target element relative to that of the page.

-
- -- Position attributes8+ - - - - - - - - - - - - - - - - -

Name

-

Type

-

Description

-

x

-

Length

-

X-coordinate.

-

y

-

Length

-

Y-coordinate.

-
- - -## Example + +## Events + + | Name | Bubble Supported | Description | +| -------- | -------- | -------- | +| onClick(callback: (event?: ClickEvent) => void) | No | Called when a click event occurs. For details about the event parameters, see [ClickEvent](#clickevent). | + + +### ClickEvent + + | Name | Type | Description | +| -------- | -------- | -------- | +| screenX | number | X coordinate of the click relative to the left edge of the screen. | +| screenY | number | Y coordinate of the click relative to the upper edge of the screen. | +| x | number | X coordinate of the click relative to the left edge of the component being clicked. | +| y | number | Y coordinate of the click relative to the upper edge of the component being clicked. | +| target8+ | EventTarget | Target element that is clicked. | +| timestamp | number | Timestamp of the event. | + + +## Example + ``` @Entry @@ -189,9 +43,9 @@ struct ClickExample { Button('Click').backgroundColor(0x2788D9).width(100).height(40) .onClick((event: ClickEvent) => { console.info(this.text = 'Click Point:' + '\n screenX:' + event.screenX + '\n screenY:' + event.screenY - + '\n x :' + event.x + '\n y:' + event.y + '\ntarget:' + '\n component globalPos:(' -+ event.target.area.globalPos.x + ',' + event.target.area.globalPos.y + ')\n width:' - + event.target.area.width + '\n height:' + event.target.area.height) + + '\n x:' + event.x + '\n y:' + event.y + '\ntarget:' + '\n component globalPos:(' + + event.target.area.globalPos.x + ',' + event.target.area.globalPos.y + ')\n width:' + + event.target.area.width + '\n height:' + event.target.area.height) }) Text(this.text).padding(15) }.height(350).width('100%').padding(10) @@ -199,5 +53,5 @@ struct ClickExample { } ``` -![](figures/en-us_image_0000001237355087.gif) +![en-us_image_0000001256858383](figures/en-us_image_0000001256858383.gif) diff --git a/en/application-dev/reference/arkui-ts/ts-universal-events-component-area-change.md b/en/application-dev/reference/arkui-ts/ts-universal-events-component-area-change.md deleted file mode 100644 index 4b79a9ccdd11448dff7c316ee56b10424fa7d796..0000000000000000000000000000000000000000 --- a/en/application-dev/reference/arkui-ts/ts-universal-events-component-area-change.md +++ /dev/null @@ -1,59 +0,0 @@ -# Component Area Change Event - ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->This event is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version. - -## Required Permissions - -None - -## Events - - - - - - - - - - - - -

Name

-

Bubble Supported

-

Description

-

onAreaChange(event: (oldValue: Area, newValue: Area) => void)

-

No

-

Triggered when the component area changes. For details about the Area type, see the description of the Area object.

-
- -## Example - -``` -@Entry -@Component -struct AreaExample { - @State value: string = 'Text' - @State size: string = '' - - build() { - Column() { - Text(this.value) - .backgroundColor(Color.Green).margin(30).fontSize(20) - .onClick(() => { - this.value = this.value + 'Text' - }) - .onAreaChange((oldValue: Area, newValue: Area) => { - console.info(`Ace: on area change, oldValue is ${JSON.stringify(oldValue)} value is ${JSON.stringify(newValue)}`) - this.size = JSON.stringify(newValue) - }) - Text('new area is: \n' + this.size).margin({ right: 30, left: 30 }) - } - .width('100%').height('100%').margin({ top: 30 }) - } -} -``` - -![](figures/gif4.gif) - diff --git a/en/application-dev/reference/arkui-ts/ts-universal-events-drag-drop.md b/en/application-dev/reference/arkui-ts/ts-universal-events-drag-drop.md new file mode 100644 index 0000000000000000000000000000000000000000..b8725c95e27c3d04a9c556eb35ffb6721c99111f --- /dev/null +++ b/en/application-dev/reference/arkui-ts/ts-universal-events-drag-drop.md @@ -0,0 +1,147 @@ +# Drag/Drop Event + + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** +> This component is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version. + + +| Name | Bubble Supported | Description | +| -------- | -------- | -------- | +| onDragStart(callback: (event: [DragEvent](#DragEvent), extraParams?: string) =>\|[Custom Builder](../../ui/ts-types.md)) | No | Triggered when the component bound to the event is dragged for the first time.
-**event**: information about the drag event, including the coordinates of the item that is being dragged.
-**extraParams**: additional information about the drag event. For details, see extraParam.
Return value: object being dragged, which is used for prompts displayed when the object is dragged.
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:**
> - A drag event can be triggered by a 150 ms long press.

> - If the duration of a long-press gesture is set to less than or equal to 150 ms, the callback for the long-press gesture takes precedence. Otherwise, the callback for the drag event takes precedence. | +| onDragEnter(callback: (event: [DragEvent](#DragEvent), extraParams?: string) => void) | No | Triggered when the dragged item enters a valid drop target.
-**event**: information about the drag event, including the coordinates of the item that is being dragged.
-**extraParams**: additional information about the drag event. For details, see extraParam.
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:**
> This event is valid only when the **onDrop** event is listened to. | +| onDragMove(callback: (event: [DragEvent](#DragEvent), extraParams?: string) => void) | No | Triggered when the dragged item moves in a valid drop target.
-**event**: information about the drag event, including the coordinates of the item that is being dragged.
-**extraParams**: additional information about the drag event. For details, see extraParam.
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:**
> This event is valid only when the **onDrop** event is listened to. | +| onDragLeave(callback: (event: [DragEvent](#DragEvent), extraParams?: string) => void) | No | Triggered when the dragged item leaves a valid drop target.
-**event**: information about the drag event, including the coordinates of the item that is being dragged.
-**extraParams**: additional information about the drag event. For details, see extraParam.
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:**
> This event is valid only when the **onDrop** event is listened to. | +| onDrop(callback: (event:[DragEvent](#DragEvent), extraParams?: string) => void) | No | Triggered when the dragged item is dropped on a valid drop target.
-**event**: information about the drag event, including the coordinates of the item that is being dragged.
-**extraParams**: additional information about the drag event. For details, see extraParam. | + + +- extraParam + Returns additional information required for dragging an item. + + **extraParam** is a string converted from a JSON object. You can obtain the following attributes using the JSON object converted from **Json.parse**. + | Name | Type | Description | + | -------- | -------- | -------- | + | selectedIndex | number | Index of the dragged item in the parent container. The value of **selectedindex** starts from **0**.
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:**
> This attribute is valid only in the **ListItem** component. | + | insertIndex | number | Index of the element into which the dragged item is dropped in the **List** component. The value of **insertIndex** starts from **0**.
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:**
> This attribute is valid only in the drag event of the **List** component. | + + +### DragEvent + +- APIs + | Name | Return Value Type | Description | + | -------- | -------- | -------- | + | getX() | number | X-coordinate of the item that is being dragged, in vp. | + | getY() | number | Y-coordinate of the item that is being dragged, in vp. | + + +## Example + + +``` +@Entry +@Component +struct DragExample { + @State numbers: string[] = ['one', 'two', 'three', 'four', 'five', 'six'] + @State text: string = '' + @State bool: boolean = false + @State bool1: boolean = false + @State size: string = '' + @State appleVisible: Visibility = Visibility.Visible + @State orangeVisible: Visibility = Visibility.Visible + @State bananaVisible: Visibility = Visibility.Visible + @State select: number = 0 + @State currentIndex: number = 0 + + @Builder pixelMapBuilder() { + Column() { + Text(this.text) + .width('50%').height(60).fontSize(16).borderRadius(10) + .textAlign(TextAlign.Center).backgroundColor(Color.Yellow) + } + } + + build() { + Column() { + Text('There are three Text elements here') + .fontSize(12).fontColor(0xCCCCCC).width('90%') + .textAlign(TextAlign.Start).margin(5) + Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceAround }) { + Text('apple').width('25%').height(35).fontSize(16) + .textAlign(TextAlign.Center).backgroundColor(0xAFEEEE) + .visibility(this.appleVisible) + .onDragStart(() => { + this.bool = true + this.text = 'apple' + this.appleVisible = Visibility.Hidden + return this.pixelMapBuilder + }) + Text('orange').width('25%').height(35).fontSize(16) + .textAlign(TextAlign.Center).backgroundColor(0xAFEEEE) + .visibility(this.orangeVisible) + .onDragStart(() => { + this.bool = true + this.text = 'orange' + this.orangeVisible = Visibility.Hidden + return this.pixelMapBuilder + }) + Text('banana').width('25%').height(35).fontSize(16) + .textAlign(TextAlign.Center).backgroundColor(0xAFEEEE) + .visibility(this.bananaVisible) + .onDragStart((event: DragEvent, extraParams: string) => { + console.log('Text onDragStarts, ' + extraParams) + this.bool = true + this.text = 'banana' + this.bananaVisible = Visibility.Hidden + return this.pixelMapBuilder + }) + }.border({ width: 1 }).width('90%').padding({ top: 10, bottom: 10 }).margin(10) + + Text('This is a List element').fontSize(12) + .fontColor(0xCCCCCC).width('90%') + .textAlign(TextAlign.Start).margin(15) + List({ space: 20, initialIndex: 0 }) { + ForEach(this.numbers, (item) => { + ListItem() { + Text('' + item) + .width('100%').height(80).fontSize(16).borderRadius(10) + .textAlign(TextAlign.Center).backgroundColor(0xAFEEEE) + } + .onDragStart((event: DragEvent, extraParams: string) => { + console.log('ListItem onDragStarts, ' + extraParams) + var jsonString = JSON.parse(extraParams) + this.bool1 = true + this.text = this.numbers[jsonString.selectedIndex] + this.select = jsonString.selectedIndex + return this.pixelMapBuilder + }) + }, item => item) + } + .editMode(true) + .height('50%').width('90%').border({ width: 1 }) + .divider({ strokeWidth: 2, color: 0xFFFFFF, startMargin: 20, endMargin: 20 }) + .onDragEnter((event: DragEvent, extraParams: string) => { + console.log('List onDragEnter, ' + extraParams) + }) + .onDragMove((event: DragEvent, extraParams: string) => { + console.log('List onDragMove, ' + extraParams) + }) + .onDragLeave((event: DragEvent, extraParams: string) => { + console.log('List onDragLeave, ' + extraParams) + }) + .onDrop((event: DragEvent, extraParams: string) => { + var jsonString = JSON.parse(extraParams) + if (this.bool) { + this.numbers.splice(jsonString.insertIndex, 0, this.text) + this.bool = false + } else if (this.bool1) { + this.numbers.splice(jsonString.selectedIndex, 1) + this.numbers.splice(jsonString.insertIndex, 0, this.text) + this.bool = false + this.bool1 = false + } + }) + }.width('100%').height('100%').padding({ top: 20 }).margin({ top: 20 }) + } +} +``` + +![en-us_image_0000001212218450](figures/en-us_image_0000001212218450.gif) diff --git a/en/application-dev/reference/arkui-ts/ts-universal-events-key.md b/en/application-dev/reference/arkui-ts/ts-universal-events-key.md index 0cbdd5984bd943aa5928259c6becf73df56d07cb..38e1218012c8597c5d2f3022672f88a6ba55a118 100644 --- a/en/application-dev/reference/arkui-ts/ts-universal-events-key.md +++ b/en/application-dev/reference/arkui-ts/ts-universal-events-key.md @@ -1,226 +1,67 @@ -# Key Event +# Key Event ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->This event is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -## Required Permissions +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** +> This method is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. + + +## Required Permissions None -## Events - - - - - - - - - - - - -

Name

-

Bubble Supported

-

Description

-

onKeyEvent(event: (event?: KeyEvent) => void)

-

Yes

-

Called when a key event occurs. For details about the event parameters, see KeyEvent Object.

-
- -## KeyEvent Object - -- Attributes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Description

-

type

-

KeyType

-

Type of a key.

-

keyCode

-

number

-

Key code.

-

keyText

-

string

-

Key value.

-

keySource

-

KeySource

-

Type of the input device that triggers the key event.

-

deviceId

-

number

-

ID of the input device that triggers the key event.

-

metaKey

-

number

-

State of the metakey when the key is pressed. The value 1 means the pressed state, and 0 means the unpressed state.

-

timestamp

-

number

-

Timestamp when the key is pressed.

-
- - -- APIs - - - - - - - - - - -

Name

-

Description

-

stopPropagation(): void

-

Stops the event from bubbling upwards or downwards.

-
- -- KeyType enums - - - - - - - - - - - - - -

Name

-

Description

-

Down

-

The key is pressed.

-

Up

-

The key is released.

-
- - -- KeySource enums - - - - - - - - - - - - - -

Name

-

Description

-

Unknown

-

Unknown input device.

-

Keyboard

-

The input device is a keyboard.

-
- -- Common KeyCode description - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Value

-

Behavior

-

Physical Button

-

19

-

Upward

-

Up button.

-

20

-

Downward

-

Down button.

-

21

-

Leftward

-

Left button.

-

22

-

Rightward

-

Right button.

-

23

-

OK

-

OK key on a remote control.

-

66

-

OK

-

Enter key on a keyboard.

-

160

-

OK

-

Enter button on the numeric keypad.

-
- - -## Example + +## Events + +| Name | Bubble Supported | Description | +| -------- | -------- | -------- | +| onKeyEvent(event: (event?: KeyEvent) => void) | Yes | Called when a key event occurs. For details about the event parameters, see [KeyEvent Object](#KeyEvent Object). | + + +### KeyEvent Object + +- Attributes + | Name | Type | Description | + | -------- | -------- | -------- | + | type | KeyType | Type of a key. | + | keyCode | number | Key code. | + | keyText | string | Key value. | + | keySource | KeySource | Type of the input device that triggers the key event. | + | deviceId | number | ID of the input device that triggers the key event. | + | metaKey | number | State of the metakey when the key is pressed. The value **1** means the pressed state, and **0** means the unpressed state. | + | timestamp | number | Timestamp when the key is pressed. | + +- APIs + | Name | Description | + | -------- | -------- | + | stopPropagation(): void | Stops the event from bubbling upwards or downwards. | + +- KeyType enums + | Name | Description | + | -------- | -------- | + | Down | The key is pressed. | + | Up | The key is released. | + + +- KeySource enums + | Name | Description | + | -------- | -------- | + | Unknown | Unknown input device. | + | Keyboard | The input device is a keyboard. | + +- Common KeyCode description + | Value | Behavior | Physical Button | + | -------- | -------- | -------- | + | 19 | Upward | Up button. | + | 20 | Downward | Down button. | + | 21 | Leftward | Left button. | + | 22 | Rightward | Right button. | + | 23 | OK | **OK** key on a remote control. | + | 66 | OK | **Enter** key on a keyboard. | + | 160 | OK | **Enter** button on the numeric keypad. | + + +## Example + ``` @Entry @@ -247,5 +88,4 @@ struct KeyEventExample { } ``` -![](figures/keyevent.gif) - +![en-us_image_0000001257058433](figures/en-us_image_0000001257058433.gif) diff --git a/en/application-dev/reference/arkui-ts/ts-universal-events-show-hide.md b/en/application-dev/reference/arkui-ts/ts-universal-events-show-hide.md index f2daec1a857375a1126a4894e3cc63b1f81fd721..52a99183757e86f8d1ca0abb41c89a2288dda87b 100644 --- a/en/application-dev/reference/arkui-ts/ts-universal-events-show-hide.md +++ b/en/application-dev/reference/arkui-ts/ts-universal-events-show-hide.md @@ -1,41 +1,25 @@ -# Show/Hide Event +# Show/Hide Event ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->This event is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -## Required Permissions +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** +> This method is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. + + +## Required Permissions None -## Events - - - - - - - - - - - - - - - -

Name

-

Bubble Supported

-

Description

-

onAppear(callback: () => void)

-

No

-

Called when the component is displayed.

-

onDisappear(callback: () => void)

-

No

-

Called when the component disappears.

-
+## Events + + | Name | Bubble Supported | Description | +| -------- | -------- | -------- | +| onAppear(callback: () => void) | No | Called when the component is displayed. | +| onDisappear(callback: () => void) | No | Called when the component disappears. | + + +## Example -## Example ``` import prompt from '@system.prompt' @@ -69,5 +53,4 @@ struct AppearExample { } ``` -![](figures/appear.gif) - +![en-us_image_0000001211898468](figures/en-us_image_0000001211898468.gif) diff --git a/en/application-dev/reference/arkui-ts/ts-universal-events-touch.md b/en/application-dev/reference/arkui-ts/ts-universal-events-touch.md index 5059fd0c0ae60c3653d810120962b6ef0d895dcf..b6945b816e3d27db7e556a0132e709d0698bf60e 100644 --- a/en/application-dev/reference/arkui-ts/ts-universal-events-touch.md +++ b/en/application-dev/reference/arkui-ts/ts-universal-events-touch.md @@ -1,194 +1,61 @@ -# Touch +# Touch Event ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->This event is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -## Required Permissions +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** +> This method is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. + + +## Required Permissions None -## Events - - - - - - - - - - - - -

Name

-

Pop-up

-

Description

-

onTouch(callback: (event?: TouchEvent) => void)

-

Yes

-

Invoked when a touch action is triggered. For details about the event parameters, see TouchEvent.

-
- -## TouchEvent - -- Attributes - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Description

-

type

-

TouchType

-

Type of a touch event.

-

touches

-

Array<TouchObject>

-

All finger information.

-

changedTouches

-

Array<TouchObject>

-

Finger information changed.

-

timestamp

-

number

-

Timestamp of the event.

-

target8+

-

EventTarget

-

Target of the event.

-
- - -- APIs - - - - - - - - - - -

API

-

Description

-

stopPropagation(): void

-

Pop-up of the stop event.

-
- - -- TouchObject - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Description

-

type

-

TouchType

-

Type of a touch event.

-

id

-

number

-

Unique identifier of a finger.

-

screenX

-

number

-

X coordinate of the touch point relative to the left edge of the screen.

-

screenY

-

number

-

Y coordinate of the touch point relative to the upper edge of the device screen.

-

x

-

number

-

X coordinate of the touch point relative to the left edge of the element to touch.

-

y

-

number

-

Y coordinate of the touch point relative to the upper edge of the element to touch.

-
- - -- TouchType - - - - - - - - - - - - - - - - - - - -

Name

-

Description

-

Down

-

Trigger a touch event when a finger is pressed.

-

Up

-

Trigger a touch event when a finger is lifted.

-

Move

-

Trigger a touch event when a finger moves on the screen in pressed state.

-

Cancel

-

Trigger an event when a touch event is canceled.

-
- - -## Example + +## Events + +| Name | Pop-up | Description | +| -------- | -------- | -------- | +| onTouch(callback: (event?: TouchEvent) => void) | Yes | Invoked when a touch action is triggered. For details about the event parameters, see [TouchEvent](#touchevent). | + + +### TouchEvent + +- Attributes + | Name | Type | Description | + | -------- | -------- | -------- | + | type | TouchType | Type of a touch event. | + | touches | Array<TouchObject> | All finger information. | + | changedTouches | Array<TouchObject> | Finger information changed. | + | timestamp | number | Timestamp of the event. | + | target8+ | EventTarget | Target of the event. | + +- APIs + | API | Description | + | -------- | -------- | + | stopPropagation(): void | Pop-up of the stop event. | + + +- TouchObject + | Name | Type | Description | + | -------- | -------- | -------- | + | type | TouchType | Type of a touch event. | + | id | number | Unique identifier of a finger. | + | screenX | number | X coordinate of the touch point relative to the left edge of the screen. | + | screenY | number | Y coordinate of the touch point relative to the upper edge of the device screen. | + | x | number | X coordinate of the touch point relative to the left edge of the element to touch. | + | y | number | Y coordinate of the touch point relative to the upper edge of the element to touch. | + + +- TouchType + | Name | Description | + | -------- | -------- | + | Down | Trigger a touch event when a finger is pressed. | + | Up | Trigger a touch event when a finger is lifted. | + | Move | Trigger a touch event when a finger moves on the screen in pressed state. | + | Cancel | Trigger an event when a touch event is canceled. | + + +## Example + ``` @Entry @@ -211,9 +78,9 @@ struct TouchExample { this.eventType = 'Move' } console.info(this.text = 'TouchType:' + this.eventType + '\nDistance between touch point and touch element:\nx: ' -+ event.touches[0].x + '\n' + 'y: ' + event.touches[0].y + '\ncomponent globalPos: (' - + event.target.area.globalPos.x + ',' + event.target.area.globalPos.y + ')\nwidth:' - + event.target.area.width + '\nheight:' + event.target.area.height) + + event.touches[0].x + '\n' + 'y: ' + event.touches[0].y + '\ncomponent globalPos:(' + + event.target.area.globalPos.x + ',' + event.target.area.globalPos.y + ')\nwidth:' + + event.target.area.width + '\nheight:' + event.target.area.height) }) Text(this.text) }.height(200).width(350).padding({ left: 35, right: 35, top: 35 }) @@ -221,5 +88,4 @@ struct TouchExample { } ``` -![](figures/en-us_image_0000001192915178.gif) - +![en-us_image_0000001212058464](figures/en-us_image_0000001212058464.gif) diff --git a/en/application-dev/reference/arkui-ts/ts-universal-events.md b/en/application-dev/reference/arkui-ts/ts-universal-events.md index 3fd64c2747e5457ef0dbfb6a2dbc8118b98e0c70..fd2340deb9b335116650a2c24ce3b84469143ab3 100644 --- a/en/application-dev/reference/arkui-ts/ts-universal-events.md +++ b/en/application-dev/reference/arkui-ts/ts-universal-events.md @@ -1,13 +1,19 @@ -# Universal Events +# Universal Events -- **[Click Event](ts-universal-events-click.md)** -- **[Touch](ts-universal-events-touch.md)** -- **[Show/Hide Event](ts-universal-events-show-hide.md)** +- **[Click Event](ts-universal-events-click.md)** -- **[Key Event](ts-universal-events-key.md)** +- **[Touch Event](ts-universal-events-touch.md)** -- **[Component Area Change Event](ts-universal-events-component-area-change.md)** +- **[Show/Hide Event](ts-universal-events-show-hide.md)** +- **[Drag/Drop Event](ts-universal-events-drag-drop.md)** +- **[Key Event](ts-universal-events-key.md)** + +- **[Focus Event](ts-universal-focus-event.md)** + +- **[Mouse Event](ts-universal-mouse-key.md)** + +- **[Component Area Change Event](ts-universal-component-area-change-event.md)** \ No newline at end of file diff --git a/en/application-dev/reference/arkui-ts/ts-universal-focus-event.md b/en/application-dev/reference/arkui-ts/ts-universal-focus-event.md new file mode 100644 index 0000000000000000000000000000000000000000..eb5281c52794e2604c06c38be51f76a6e0494d7d --- /dev/null +++ b/en/application-dev/reference/arkui-ts/ts-universal-focus-event.md @@ -0,0 +1,71 @@ +# Focus Event + + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** +> This component is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version. + + +## Required Permissions + +None + + +## Events + + | **Name** | **Bubble Supported** | **Description** | +| -------- | -------- | -------- | +| onFocus(callback: () => void) | No | Triggered when the current component obtains focus. | +| onBlur(callback:() => void) | No | Triggered when the current component loses focus. | + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** +> The following components support focus events: **<Button>**, **<Text>**, **<Image>**, **<List>**, and **<Grid>**. + + +## Example + + +``` +@Entry +@Component +struct FocusEventExample { + @State textOne: string = '' + @State textTwo: string = '' + @State textThree: string = '' + @State oneButtonColor: string = '#FF0000' + @State twoButtonColor: string = '#87CEFA' + @State threeButtonColor: string = '#90EE90' + + build() { + Column({ space:20 }){ + Button(this.textOne) + .backgroundColor(this.oneButtonColor) + .width(260).height(70).fontColor(Color.Black) + .focusable(true) + .onFocus(() => { + this.textOne = 'First Button onFocus' + this.oneButtonColor = '#AFEEEE' + }) + .onBlur(() => { + this.textOne = 'First Button onBlur' + this.oneButtonColor = '#FFC0CB' + }) + Button(this.textTwo) + .backgroundColor(this.twoButtonColor) + .width(260).height(70).fontColor(Color.Black) + .focusable(true) + Button(this.textThree) + .backgroundColor(this.threeButtonColor) + .width(260).height(70).fontColor(Color.Black) + .focusable(true) + .onFocus(() => { + this.textThree = 'Third Button onFocus' + this.threeButtonColor = '#AFEEEE' + }) + .onBlur(() => { + this.textThree = 'Third Button onBlur' + this.threeButtonColor = '#FFC0CB' + }) + }.width('100%').margin({ top:20 }) + } +} +``` diff --git a/en/application-dev/reference/arkui-ts/ts-universal-mouse-key.md b/en/application-dev/reference/arkui-ts/ts-universal-mouse-key.md new file mode 100644 index 0000000000000000000000000000000000000000..c256a22f9f83c094be8a30b736d05609e8d2a486 --- /dev/null +++ b/en/application-dev/reference/arkui-ts/ts-universal-mouse-key.md @@ -0,0 +1,87 @@ +# Mouse Event + + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** +> This component is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version. + + +## Required Permissions + +None + + +## Events + + | Name | Bubble Supported | Description | +| -------- | -------- | -------- | +| onHover(callback: (isHover: boolean) => void) | No | Triggered when the mouse cursor enters or leaves the component.
**isHover**: whether the mouse cursor hovers over the component. The value **true** means that the mouse cursor enters the component, and the value **false** means that the mouse cursor leaves the component. | +| onMouse(callback: (event?: MouseEvent) => void) | Yes | Triggered when the component is clicked by a mouse button or the mouse cursor moves on the component. The **event** parameter indicates the timestamp, mouse button, action, coordinates of the clicked point on the entire screen, and coordinates of the clicked point relative to the component when the event is triggered. | + + +### MouseEvent + +- Attributes + | Name | Type | Description | + | -------- | -------- | -------- | + | timestamp | number | Timestamp when the event is triggered. | + | screenX | number | X-coordinate of the clicked point relative to the upper left corner of the screen. | + | screenY | number | Y-coordinate of the clicked point relative to the upper left corner of the screen. | + | x | number | X-coordinate of the clicked point relative to the upper left corner of the component. | + | y | number | Y-coordinate of the clicked point relative to the upper left corner of the component. | + | button | MouseButton | Mouse button. | + | action | MouseAction | Event action. | + + +- MouseButton attributes + | Name | Type | Description | + | -------- | -------- | -------- | + | Left | number | Left mouse button. | + | Right | number | Right mouse button. | + | Middle | number | Middle mouse button. | + | Back | number | Back button on the left of the mouse. | + | Forward | number | Forward button on the left of the mouse. | + | None | number | No button. | + +- MouseAction attributes + | Name | Type | Description | + | -------- | -------- | -------- | + | Press | number | The mouse button is pressed. | + | Release | number | The mouse button is released. | + | Move | number | The mouse cursor moves. | + + +## Example + + +``` +@Entry +@Component +struct MouseEventExample { + @State hoverText: string = 'no hover' + @State mouseText: string = 'MouseText' + @State color: Color = Color.Blue + + build() { + Column({ space:20 }) { + Button(this.hoverText) + .onHover((isHover: boolean) => { + if (isHover) { + this.hoverText = 'on hover' + this.color = Color.Pink + } else { + this.hoverText = 'no hover' + this.color = Color.Blue + } + }) + .backgroundColor(this.color) + Button('onMouse') + .onMouse((event: MouseEvent) => { + console.log(this.mouseText = 'onMouse:\nButton = ' + event.button + + '\nAction = ' + event.action + '\nlocalXY=(' + event.x + ',' + event.y + ')' + + '\nscreenXY=(' + event.screenX + ',' + event.screenY + ')') + }) + Text(this.mouseText) + }.padding({ top: 20 }).width('100%') + } +} +``` diff --git a/zh-cn/application-dev/Readme-CN.md b/zh-cn/application-dev/Readme-CN.md index 81c318bb63b1bf39f2be220f8587d77a13f61074..29c190d3fc62cba8415a36339d3dcb828f2931d2 100644 --- a/zh-cn/application-dev/Readme-CN.md +++ b/zh-cn/application-dev/Readme-CN.md @@ -3,7 +3,6 @@ - [应用开发导读](application-dev-guide.md) - 了解OpenHarmony - [了解OpenHarmony开源项目](../OpenHarmony-Overview_zh.md) - - [了解OpenHarmony系统](../readme) - [术语](../device-dev/glossary/glossary.md) - [版本说明](../release-notes/Readme.md) - 快速开始 diff --git a/zh-cn/application-dev/ability/ability-assistant-guidelines.md b/zh-cn/application-dev/ability/ability-assistant-guidelines.md index c21e2c78174f9ab5c068e1cff88e89d160a54ce2..2c7ad62bc8b8af6639c9cfe31185ef60eca31dcf 100644 --- a/zh-cn/application-dev/ability/ability-assistant-guidelines.md +++ b/zh-cn/application-dev/ability/ability-assistant-guidelines.md @@ -71,23 +71,23 @@ Ability assistant(Ability助手,简称为aa)是实现应用、原子化服 用于打印Ability的相关信息。 - | 参数 | 二级参数 | 参数说明 | - | ----------------- | -------------------- | ------------------------------------------------------------ | - | -h/--help | - | 帮助信息。 | - | -a/--all | - | 打印所有mission内的Ability。 | - | -l/--mission-list | type(缺省打印全部) | 打印任务栈信息。
type:
NORMAL
DEFAULT_STANDARD
DEFAULT_SINGLE
LAUNCHER | - | -e/--extension | elementName | 打印扩展组件信息。 | - | -u/--userId | UserId | 打印指定UserId的栈信息,需要和其他参数组合使用,例如 aa dump -a -u 100、aa dump -d -u 100、 | - | -d/--data | | 打印Data Ability。 | - | -i/--ability | AbilityRecord ID | 打印指定Ability详细信息 | - | -c/--client | | 打印Ability详细信息,需要和其他参数组合使用,例如 aa dump -a -c、aa dump -i 21 -c、 | - -**使用方法:** - -``` + | 参数 | 参数说明 | + | ---------------------- | -------------------------------------- | + | -h/--help | 帮助信息。 | + | -a/--all | 打印所有mission内的Ability。 | + | -s/--stack \ | 打印指定mission stack内的Ability。 | + | -m/--mission \ | 打印指定mission内的Ability。 | + | -l/--stack-list | 打印每个mission stack内的mission列表。 | + | -u/--ui | 打印system ui Ability。 | + | -e/--serv | 打印Service Ability。 | + | -d/--data | 打印Data Ability。 | + + **使用方法:** + + ``` aa dump -a ``` - + - **force-stop** 通过bundle name强制停止一个进程。 diff --git a/zh-cn/application-dev/ability/fa-brief.md b/zh-cn/application-dev/ability/fa-brief.md index d377c532dbefd29b349be06a239e0f7ce1e6d719..5fcef0a959160ad924f1fe4b5589b094e3837f1a 100644 --- a/zh-cn/application-dev/ability/fa-brief.md +++ b/zh-cn/application-dev/ability/fa-brief.md @@ -1,22 +1 @@ -# FA模型综述 - -## 整体架构 -鸿蒙用户程序的开发本质上就是开发Ability,OpenHarmony系统也是通过调度Ability,通过系统提供的一致性调度契约对Ability进行生命周期管理,从而实现对用户程序的调度。FA模型中Ability分为PageAbility、ServiceAbility和DataAbility三种类型。其中PageAbility具备ArkUI的Ability,是用户具体可见并可以交互的Ability实例;ServiceAbility也是Ability一种,但是没有UI,提供其他Ability调用自定义的服务,在后台运行;DataAbility也是没有UI,提供其他Ability进行数据的增删查服务,在后台运行。 - -## 应用包结构 -**应用包结构如下图所示:** -![fa-package-info](figures/fa-package-info.png) - -## 生命周期 - -**pageAbility生命周期回调如下图所示:** - -![fa-pageAbility-lifecycle](figures/fa-pageAbility-lifecycle.png) - -开发者可以在 app.js/app.ets 中重写生命周期函数,在对应的生命周期函数内处理应用相应逻辑。 - - -## 进程线程模型 -应用独享独立进程,Ability独享独立线程,应用进程在Ability第一次启动时创建,并为启动的Ability创建线程,应用启动后再启动应用内其他Ability,会为每一个Ability创建相应的线程。每个Ability绑定一个独立的JSRuntime实例,因此Ability之间是隔离的。 - -![fa-threading-nodel](figures/fa-threading-model.png) \ No newline at end of file +# FA模型综述 \ No newline at end of file diff --git a/zh-cn/application-dev/ability/fa-pageability.md b/zh-cn/application-dev/ability/fa-pageability.md index 8433c7604ef2fd9250d976c972a0bdaa431c8f2e..ba42ed13dcbd273b82aa6d3bd5b00d19f94a20f1 100644 --- a/zh-cn/application-dev/ability/fa-pageability.md +++ b/zh-cn/application-dev/ability/fa-pageability.md @@ -27,19 +27,19 @@ Page模板(以下简称“Page”)是FA唯一支持的模板,用于提供 **PageAbility类型Ability生命周期回调如下图所示:** -![fa-pageAbility-lifecycle](figures/fa-pageAbility-lifecycle.png) +![PageAbility-Lifecycel-Callbacks](figures/page-ability-lifecycle-callbacks.png) ## 启动本地PageAbility - * 导入模块 + 导入模块 ``` import featureAbility from '@ohos.ability.featureAbility' ``` ``` - featureAbility.startAbility(parameter: StartAbilityParameter, callback: AsyncCallback) + FeatureAbility.startAbility(parameter: StartAbilityParameter, callback: AsyncCallback) ``` * 接口说明 @@ -50,75 +50,61 @@ import featureAbility from '@ohos.ability.featureAbility' ```javascript import featureAbility from '@ohos.ability.featureAbility' -featureAbility.startAbility({ - want: - { - action: "", - entities: [""], - type: "", - options: { - // indicates the grant to perform read operations on the URI - authReadUriPermission: true, - // indicates the grant to perform write operations on the URI - authWriteUriPermission: true, - // support forward intent result to origin ability - abilityForwardResult: true, - // used for marking the ability start-up is triggered by continuation - abilityContinuation: true, - // specifies whether a component does not belong to ohos - notOhosComponent: true, - // specifies whether an ability is started - abilityFormEnabled: true, - // indicates the grant for possible persisting on the URI. - authPersistableUriPermission: true, - // indicates the grant for possible persisting on the URI. - authPrefixUriPermission: true, - // support distributed scheduling system start up multiple devices - abilitySliceMultiDevice: true, - // indicates that an ability using the service template is started regardless of whether the - // host application has been started. - startForegroundAbility: true, - // install the specified ability if it's not installed. - installOnDemand: true, - // return result to origin ability slice - abilitySliceForwardResult: true, - // install the specified ability with background mode if it's not installed. - installWithBackgroundMode: true +featureAbility.startAbility( + { + want: + { + action: "", + entities: [""], + type: "", + options: { + // indicates the grant to perform read operations on the URI + authReadUriPermission: true, + // indicates the grant to perform write operations on the URI + authWriteUriPermission: true, + // support forward intent result to origin ability + abilityForwardResult: true, + // used for marking the ability start-up is triggered by continuation + abilityContinuation: true, + // specifies whether a component does not belong to ohos + notOhosComponent: true, + // specifies whether an ability is started + abilityFormEnabled: true, + // indicates the grant for possible persisting on the URI. + authPersistableUriPermission: true, + // indicates the grant for possible persisting on the URI. + authPrefixUriPermission: true, + // support distributed scheduling system start up multiple devices + abilitySliceMultiDevice: true, + // indicates that an ability using the service template is started regardless of whether the + // host application has been started. + startForegroundAbility: true, + // install the specified ability if it's not installed. + installOnDemand: true, + // return result to origin ability slice + abilitySliceForwardResult: true, + // install the specified ability with background mode if it's not installed. + installWithBackgroundMode: true + }, + deviceId: "", + bundleName: "com.example.startability", + abilityName: "com.example.startability.MainAbility", + uri: "" + }, }, - deviceId: "", - bundleName: "com.example.startability", - abilityName: "com.example.startability.MainAbility", - uri: "" - }, -}, -); -``` -want参数也可以使用parameters参数,使用key-value的方式输入。 -* 示例 -```javascript -import featureAbility from '@ohos.ability.featureAbility' -featureAbility.startAbility({ - want: - { - bundleName: "com.example.startability", - uri: "", - parameters: { - abilityName: "com.example.startability.MainAbility" - } - }, -}, -); + ); +) ``` ## 启动远程PageAbility -* 导入模块 + 导入模块 ``` import featureAbility from '@ohos.ability.featureAbility' ``` ``` -featureAbility.startAbility(parameter: StartAbilityParameter) +FeatureAbility.startAbility(parameter: StartAbilityParameter) ``` * 接口说明 @@ -128,13 +114,14 @@ featureAbility.startAbility(parameter: StartAbilityParameter) * 示例 ```javascript -var promise = await featureAbility.startAbility({ - want: - { - deviceId: this.deviceId, - bundleName: "com.example.test", - abilityName: "com.example.test.MainAbility", - }, -} -); + var promise = await ability.startAbility( + { + want: + { + deviceId: this.deviceId, + bundleName: "com.example.test", + abilityName: "com.example.test.MainAbility", + }, + } + ); ``` \ No newline at end of file diff --git a/zh-cn/application-dev/ability/figures/fa-package-info.png b/zh-cn/application-dev/ability/figures/fa-package-info.png deleted file mode 100755 index 7b660dce47e3873279f9bdf587b1bd290384843b..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/ability/figures/fa-package-info.png and /dev/null differ diff --git a/zh-cn/application-dev/ability/figures/fa-pageAbility-lifecycle.png b/zh-cn/application-dev/ability/figures/fa-pageAbility-lifecycle.png deleted file mode 100755 index 269d06b73dde7c952b56cd76f1842a856dde3c01..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/ability/figures/fa-pageAbility-lifecycle.png and /dev/null differ diff --git a/zh-cn/application-dev/ability/figures/fa-threading-model.png b/zh-cn/application-dev/ability/figures/fa-threading-model.png deleted file mode 100755 index db1102837790330e536bd43062852bf04d505ee1..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/ability/figures/fa-threading-model.png and /dev/null differ diff --git a/zh-cn/application-dev/quick-start/basic-resource-file-categories.md b/zh-cn/application-dev/quick-start/basic-resource-file-categories.md new file mode 100644 index 0000000000000000000000000000000000000000..97cdaa0ab35c5fed21c5b15950530cdca098fedb --- /dev/null +++ b/zh-cn/application-dev/quick-start/basic-resource-file-categories.md @@ -0,0 +1,79 @@ +# 资源文件的分类 + + +## resources目录 + +应用的资源文件(字符串、图片、音频等)统一存放于resources目录下,便于开发者使用和维护。resources目录包括两大类目录,一类为base目录与限定词目录,另一类为rawfile目录,详见resources目录分类。 + + 资源目录示例: + +``` +resources +|---base // 默认存在的目录 +| |---element +| | |---string.json +| |---media +| | |---icon.png +|---en_GB-vertical-car-mdpi // 限定词目录示例,需要开发者自行创建 +| |---element +| | |---string.json +| |---media +| | |---icon.png +|---rawfile // 默认存在的目录 +``` + + **表1** resources目录分类 + +| 分类 | base目录与限定词目录 | rawfile目录 | +| -------- | -------- | -------- | +| 组织形式 | 按照两级目录形式来组织,目录命名必须符合规范,以便根据设备状态去匹配相应目录下的资源文件。
  一级子目录为**base目录**和**限定词目录**。
- base目录是默认存在的目录。当应用的resources资源目录中没有与设备状态匹配的限定词目录时,会自动引用该目录中的资源文件。
- 限定词目录需要开发者自行创建。目录名称由一个或多个表征应用场景或设备特征的限定词组合而成,具体要求参见[限定词目录](#限定词目录)。
二级子目录为**资源目录**,用于存放字符串、颜色、布尔值等基础元素,以及媒体、动画、布局等资源文件,具体要求参见[资源组目录](#资源组目录)。 | 支持创建多层子目录,目录名称可以自定义,文件夹内可以自由放置各类资源文件。
rawfile目录的文件不会根据设备状态去匹配不同的资源。 | +| 编译方式 | 目录中的资源文件会被编译成二进制文件,并赋予资源文件ID。 | 目录中的资源文件会被直接打包进应用,不经过编译,也不会被赋予资源文件ID。 | +| 引用方式 | 通过指定资源类型(type)和资源名称(name)来引用。 | 通过指定文件路径和文件名来引用。 | + + +## 限定词目录 + +限定词目录可以由一个或多个表征应用场景或设备特征的限定词组合而成,包括移动国家码和移动网络码、语言、文字、国家或地区、横竖屏、设备类型、颜色模式和屏幕密度等维度,限定词之间通过下划线(_)或者中划线(-)连接。开发者在创建限定词目录时,需要掌握限定词目录的命名要求,以及限定词目录与设备状态的匹配规则。 + +**限定词目录的命名要求** + +- 限定词的组合顺序:_移动国家码_移动网络码-语言_文字_国家或地区-横竖屏-设备类型-颜色模式-屏幕密度_。开发者可以根据应用的使用场景和设备特征,选择其中的一类或几类限定词组成目录名称。 + +- 限定词的连接方式:语言、文字、国家或地区之间采用下划线(_)连接,移动国家码和移动网络码之间也采用下划线(_)连接,除此之外的其他限定词之间均采用中划线(-)连接。例如:**zh_Hant_CN**、**zh_CN-car-ldpi**。 + +- 限定词的取值范围:每类限定词的取值必须符合限定词取值要求表中的条件,否则,将无法匹配目录中的资源文件。 + **表2** 限定词取值要求 + + | 限定词类型 | 含义与取值说明 | + | -------- | -------- | + | 移动国家码和移动网络码 | 移动国家码(MCC)和移动网络码(MNC)的值取自设备注册的网络。MCC后面可以跟随MNC,使用下划线(_)连接,也可以单独使用。例如:mcc460表示中国,mcc460_mnc00表示中国_中国移动。
详细取值范围,请查阅**ITU-T E.212**(国际电联相关标准)。 | + | 语言 | 表示设备使用的语言类型,由2~3个小写字母组成。例如:zh表示中文,en表示英语,mai表示迈蒂利语。
详细取值范围,请查阅**ISO 639**(ISO制定的语言编码标准)。 | + | 文字 | 表示设备使用的文字类型,由1个大写字母(首字母)和3个小写字母组成。例如:Hans表示简体中文,Hant表示繁体中文。
详细取值范围,请查阅**ISO 15924**(ISO制定的文字编码标准)。 | + | 国家或地区 | 表示用户所在的国家或地区,由2~3个大写字母或者3个数字组成。例如:CN表示中国,GB表示英国。
详细取值范围,请查阅**ISO 3166-1**(ISO制定的国家和地区编码标准)。 | + | 横竖屏 | 表示设备的屏幕方向,取值如下:
- vertical:竖屏
- horizontal:横屏 | + | 设备类型 | 表示设备的类型,取值如下:
- phone:手机
- tablet:平板
- car:车机
- tv:智慧屏
- wearable:智能穿戴 | + | 颜色模式 | 表示设备的颜色模式,取值如下:
- dark:深色模式
- light:浅色模式 | + | 屏幕密度 | 表示设备的屏幕密度(单位为dpi),取值如下:
- sdpi:表示小规模的屏幕密度(Small-scale Dots Per Inch),适用于dpi取值为(0, 120]的设备。
- mdpi:表示中规模的屏幕密度(Medium-scale Dots Per Inch),适用于dpi取值为(120, 160]的设备。
- ldpi:表示大规模的屏幕密度(Large-scale Dots Per Inch),适用于dpi取值为(160, 240]的设备。
- xldpi:表示特大规模的屏幕密度(Extra Large-scale Dots Per Inch),适用于dpi取值为(240, 320]的设备。
- xxldpi:表示超大规模的屏幕密度(Extra Extra Large-scale Dots Per Inch),适用于dpi取值为(320, 480]的设备。
- xxxldpi:表示超特大规模的屏幕密度(Extra Extra Extra Large-scale Dots Per Inch),适用于dpi取值为(480, 640]的设备。 | + +**限定词目录与设备状态的匹配规则** + +- 在为设备匹配对应的资源文件时,限定词目录匹配的优先级从高到低依次为:移动国家码和移动网络码 > 区域(可选组合:语言、语言_文字、语言_国家或地区、语言_文字_国家或地区)> 横竖屏 > 设备类型 > 颜色模式 > 屏幕密度。 + +- 如果限定词目录中包含**移动国家码和移动网络码、语言、文字、横竖屏、设备类型、颜色模式**限定词,则对应限定词的取值必须与当前的设备状态完全一致,该目录才能够参与设备的资源匹配。例如,限定词目录“zh_CN-car-ldpi”不能参与“en_US”设备的资源匹配。 + + +## 资源组目录 + +base目录与限定词目录下面可以创建资源组目录(包括element、media、animation、layout、graphic、profile),用于存放特定类型的资源文件,详见资源组目录说明。 + + + **表3** **资源组目录说明** + +| 资源组目录 | 目录说明 | 资源文件 | +| -------- | -------- | -------- | +| element | 表示元素资源,以下每一类数据都采用相应的JSON文件来表征。
- boolean,布尔型
- color,颜色
- float,浮点型
- intarray,整型数组
- integer,整型
- pattern,样式
- plural,复数形式
- strarray,字符串数组
- string,字符串 | element目录中的文件名称建议与下面的文件名保持一致。每个文件中只能包含同一类型的数据。
- boolean.json
- color.json
- float.json
- intarray.json
- integer.json
- pattern.json
- plural.json
- strarray.json
- string.json | +| media | 表示媒体资源,包括图片、音频、视频等非文本格式的文件。 | 文件名可自定义,例如:icon.png。 | +| animation | 表示动画资源,采用XML文件格式。 | 文件名可自定义,例如:zoom_in.xml。 | +| layout | 表示布局资源,采用XML文件格式。 | 文件名可自定义,例如:home_layout.xml。 | +| graphic | 表示可绘制资源,采用XML文件格式。 | 文件名可自定义,例如:notifications_dark.xml。 | +| profile | 表示其他类型文件,以原始文件形式保存。 | 文件名可自定义。 | diff --git a/zh-cn/application-dev/reference/apis/Readme-CN.md b/zh-cn/application-dev/reference/apis/Readme-CN.md index ff67949950f6b13b004b7be97cb5da316b074f49..698d8fdaeb8b9ab83941265d765b6cf9b7e31b83 100644 --- a/zh-cn/application-dev/reference/apis/Readme-CN.md +++ b/zh-cn/application-dev/reference/apis/Readme-CN.md @@ -25,7 +25,8 @@ - [访问控制](js-apis-abilityAccessCtrl.md) - [通用密钥库系统](js-apis-huks.md) - 数据管理 - - [轻量级存储](js-apis-data-preferences.md) + - [轻量级存储9+](js-apis-data-preferences.md) + - [轻量级存储](js-apis-data-storage.md) - [分布式数据管理](js-apis-distributed-data.md) - [关系型数据库](js-apis-data-rdb.md) - [结果集](js-apis-data-resultset.md) @@ -76,17 +77,15 @@ - [USB管理](js-apis-usb.md) - [位置服务](js-apis-geolocation.md) - 基本功能 - - [应用上下文](js-apis-basic-features-app-context.md) - - [日志打印](js-apis-basic-features-logs.md) - [页面路由](js-apis-basic-features-routes.md) - [弹窗](js-apis-basic-features-pop-up.md) - - [应用配置](js-apis-basic-features-configuration.md) - [定时器](js-apis-basic-features-timer.md) - [锁屏管理](js-apis-screen-lock.md) - [设置系统时间](js-apis-system-time.md) - [壁纸](js-apis-wallpaper.md) - [剪贴板](js-apis-pasteboard.md) - [动画](js-apis-basic-features-animator.md) + - [媒体查询](js-apis-mediaquery.md) - [WebGL](js-apis-webgl.md) - [WebGL2](js-apis-webgl2.md) - [屏幕截图](js-apis-screenshot.md) diff --git a/zh-cn/application-dev/reference/apis/js-apis-ability-context.md b/zh-cn/application-dev/reference/apis/js-apis-ability-context.md index e1ab57aed3064d616732a18fc49d5e6b22670e8a..bf66918245d740b1e39604bb5c7c76d99e043660 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-ability-context.md +++ b/zh-cn/application-dev/reference/apis/js-apis-ability-context.md @@ -10,10 +10,10 @@ Ability的上下文环境,继承自Context。 ## 使用说明 -​在使用AbilityContext的功能前,需要通过Ability子类实例获取。 +在使用AbilityContext的功能前,需要通过Ability子类实例获取。 + - ```js import Ability from '@ohos.application.Ability' class MainAbility extends Ability { @@ -42,10 +42,10 @@ startAbility(want: Want, callback: AsyncCallback<void>): void **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | want | [Want](js-apis-featureAbility.md#Want类型说明) | 是 | 启动Ability的want信息。 | - | callback | AsyncCallback<void> | 是 | callback形式返回启动结果 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| want | [Want](js-apis-featureAbility.md#want) | 是 | 启动Ability的want信息。 | +| callback | AsyncCallback<void> | 是 | callback形式返回启动结果 | **示例:** @@ -71,11 +71,11 @@ startAbility(want: Want, options: StartOptions, callback: AsyncCallback<void& **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | want | [Want](js-apis-featureAbility.md#Want类型说明) | 是 | 启动Ability的want信息。 | - | options | StartOptions | 是 | 启动Ability所携带的参数。 | - | callback | AsyncCallback<void> | 是 | callback形式返回启动结果。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| want | [Want](js-apis-featureAbility.md#want) | 是 | 启动Ability的want信息。 | +| options | StartOptions | 是 | 启动Ability所携带的参数。 | +| callback | AsyncCallback<void> | 是 | callback形式返回启动结果。 | **示例:** @@ -96,7 +96,7 @@ startAbility(want: Want, options: StartOptions, callback: AsyncCallback<void& ## AbilityContext.startAbility -startAbility(want: Want, options: StartOptions): Promise<void>; +startAbility(want: Want, options: StartOptions): Promise<void> 启动Ability。通过Promise返回结果。 @@ -104,10 +104,10 @@ startAbility(want: Want, options: StartOptions): Promise<void>; **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | want | [Want](js-apis-featureAbility.md#Want类型说明) | 是 | 启动Ability的want信息。 | - | options | StartOptions | 是 | 启动Ability所携带的参数。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| want | [Want](js-apis-featureAbility.md#want) | 是 | 启动Ability的want信息。 | +| options | StartOptions | 是 | 启动Ability所携带的参数。 | **返回值:** @@ -145,10 +145,10 @@ startAbilityForResult(want: Want, callback: AsyncCallback<AbilityResult>): **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | want |[Want](js-apis-featureAbility.md#Want类型说明) | 是 | 启动Ability的want信息。 | - | callback | AsyncCallback<[AbilityResult](js-apis-featureAbility.md#abilityresult)> | 是 | 执行结果回调函数。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| want |[Want](js-apis-featureAbility.md#want) | 是 | 启动Ability的want信息。 | +| callback | AsyncCallback<[AbilityResult](js-apis-featureAbility.md#abilityresult)> | 是 | 执行结果回调函数。 | **示例:** @@ -173,11 +173,11 @@ startAbilityForResult(want: Want, options: StartOptions, callback: AsyncCallback **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | want |[Want](js-apis-featureAbility.md#Want类型说明) | 是 | 启动Ability的want信息。 | - | options | StartOptions | 是 | 启动Ability所携带的参数。 | - | callback | AsyncCallback<[AbilityResult](js-apis-featureAbility.md#abilityresult)> | 是 | 执行结果回调函数。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| want |[Want](js-apis-featureAbility.md#want) | 是 | 启动Ability的want信息。 | +| options | StartOptions | 是 | 启动Ability所携带的参数。 | +| callback | AsyncCallback<[AbilityResult](js-apis-featureAbility.md#abilityresult)> | 是 | 执行结果回调函数。 | **示例:** @@ -206,10 +206,10 @@ startAbilityForResult(want: Want, options: StartOptions): Promise<AbilityResu **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | want | [Want](js-apis-featureAbility.md#Want类型说明) | 是 | 启动Ability的want信息。 | - | options | StartOptions | 是 | 启动Ability所携带的参数。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| want | [Want](js-apis-featureAbility.md#want) | 是 | 启动Ability的want信息。 | +| options | StartOptions | 是 | 启动Ability所携带的参数。 | **返回值:** @@ -353,9 +353,9 @@ startAbilityByCall(want: Want): Promise<Caller>; **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | want | [Want](js-apis-featureAbility.md#Want类型说明) | 是 | 传入需要启动的ability的信息,包含ability名称、包名、设备ID,设备ID缺省或为空表示启动本地ability。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| want | [Want](js-apis-featureAbility.md#want) | 是 | 传入需要启动的ability的信息,包含ability名称、包名、设备ID,设备ID缺省或为空表示启动本地ability。 | **返回值:** diff --git a/zh-cn/application-dev/reference/apis/js-apis-basic-features-app-context.md b/zh-cn/application-dev/reference/apis/js-apis-basic-features-app-context.md deleted file mode 100644 index be16b12372a636aa23a991b595c4a800f1c4261f..0000000000000000000000000000000000000000 --- a/zh-cn/application-dev/reference/apis/js-apis-basic-features-app-context.md +++ /dev/null @@ -1,79 +0,0 @@ -# 应用上下文 - - -## 导入模块 - -``` -import app from '@system.app'; -``` - -## 权限列表 - -无 - - -## app.getInfo - -getInfo(): <AppResponse> - -获取当前应用配置文件中声明的信息。 - -- 返回值 - **表1** AppResponse - - | | | | - | -------- | -------- | -------- | - | 参数名 | 类型 | 说明 | - | appID6+ | string | 表示应用的包名,用于标识应用的唯一性。 | - | appName | string | 表示应用的名称。 | - | versionName | string | 表示应用的版本名称。 | - | versionCode | number | 表示应用的版本号。 | - -- 示例 - ``` - export default { - getInfo(){ - var info = app.getInfo(); - console.log(JSON.stringify(info)); - } - } - ``` - - -## app.terminate - -terminate(): void - -退出当前Ability - -> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> 从API Version 7 开始,推荐使用新接口['@ohos.ability.featureAbility'](js-apis-featureAbility.md)。 - -- 示例 - ``` - export default { - terminate(){ - app.terminate(); - }} - ``` - -## app.requestFullWindow - -requestFullWindow(duration: number): void - -请求应用以全窗口运行,FA在某些场景下(如半模态FA)会以非全窗口运行,调用该接口会从非全窗口切换为全窗口运行,如果已经以全窗口运行则该接口调用无效。 - -- 参数 - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | duration | number | 否 | 请求全屏时,设定非全屏到全屏的过渡时间,单位为毫秒,默认时间与非全屏到全屏的距离成正比。 | - -- 示例 - ``` - export default { - requestFullWindow(){ - app.requestFullWindow({ - duration: 200}); - } - } - ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-basic-features-configuration.md b/zh-cn/application-dev/reference/apis/js-apis-basic-features-configuration.md deleted file mode 100644 index d9602902ca3e575a737f08f4edc22f30ef61f06b..0000000000000000000000000000000000000000 --- a/zh-cn/application-dev/reference/apis/js-apis-basic-features-configuration.md +++ /dev/null @@ -1,44 +0,0 @@ -# 应用配置 - - -> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> - 从API Version 7 开始,该接口不再维护,推荐使用新接口['@ohos.i18n'](js-apis-i18n.md)和['@ohos.intl'](js-apis-intl.md)。 -> - - -## 导入模块 - -``` -import configuration from '@system.configuration'; -``` - -## 权限列表 - -无 - - -## configuration.getLocale - -getLocale(): <LocaleResponse> - -获取应用当前的语言和地区。默认与系统的语言和地区同步。 - -- 返回值 - **表1** LocaleResponse - - | 参数名 | 类型 | 说明 | - | -------- | -------- | -------- | - | language | string | 语言。例如:zh。 | - | countryOrRegion | string | 国家或地区。例如:CN。 | - | dir | string | 文字布局方向。取值范围:
- ltr:从左到右;
- rtl:从右到左。 | - | $unicodeSetting^{5+}$ | string | 语言环境定义的Unicode语言环境键集,如果此语言环境没有特定键集,则返回空集。
例如:{"nu":"arab"},表示当前环境下的数字采用阿拉伯语的数字。 | - -- 示例 - ``` - export default { - getLocale() { - const localeInfo = configuration.getLocale(); - console.info(localeInfo.language); - } - } - ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-basic-features-logs.md b/zh-cn/application-dev/reference/apis/js-apis-basic-features-logs.md index 0c6afae60d9aed4e0b2e8873510279255bb25928..00ecf318420eda9d2d11734b638e4518ecef5771 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-basic-features-logs.md +++ b/zh-cn/application-dev/reference/apis/js-apis-basic-features-logs.md @@ -5,10 +5,6 @@ 无需导入。 -## 权限列表 - -无 - ## console.debug diff --git a/zh-cn/application-dev/reference/apis/js-apis-commonEvent.md b/zh-cn/application-dev/reference/apis/js-apis-commonEvent.md index c244934d6de61e238ede1f5b41a98c18574c55a2..8ad8d1f219e7d96340052dd5f0068dfc4329d7aa 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-commonEvent.md +++ b/zh-cn/application-dev/reference/apis/js-apis-commonEvent.md @@ -168,7 +168,7 @@ publish(event: string, callback: AsyncCallback\): void 发布公共事件(callback形式)。 -**系统能力:** SystemCapability.Notification.CommonEvent +**系统能力**:SystemCapability.Notification.CommonEvent **参数:** @@ -201,7 +201,7 @@ publish(event: string, options: CommonEventPublishData, callback: AsyncCallback\ 发布公共事件指定发布信息(callback形式)。 -**系统能力:** SystemCapability.Notification.CommonEvent +**系统能力**:SystemCapability.Notification.CommonEvent **参数:** @@ -243,7 +243,7 @@ publishAsUser(event: string, userId: number, callback: AsyncCallback\): vo 向指定用户发布公共事件(callback形式)。 -**系统能力:** SystemCapability.Notification.CommonEvent +**系统能力**:SystemCapability.Notification.CommonEvent **参数:** @@ -280,7 +280,7 @@ publishAsUser(event: string, userId: number, options: CommonEventPublishData, ca 向指定用户发布公共事件并指定发布信息(callback形式)。 -**系统能力:** SystemCapability.Notification.CommonEvent +**系统能力**:SystemCapability.Notification.CommonEvent **参数:** @@ -325,7 +325,7 @@ createSubscriber(subscribeInfo: CommonEventSubscribeInfo, callback: AsyncCallbac 创建订阅者(callback形式)。 -**系统能力:** SystemCapability.Notification.CommonEvent +**系统能力**:SystemCapability.Notification.CommonEvent **参数:** @@ -367,7 +367,7 @@ createSubscriber(subscribeInfo: CommonEventSubscribeInfo): Promise\): 取消订阅公共事件(callback形式)。 -**系统能力:** SystemCapability.Notification.CommonEvent +**系统能力**:SystemCapability.Notification.CommonEvent **参数:** @@ -517,7 +587,7 @@ CommonEvent.unsubscribe(subscriber, UnsubscribeCallBack); ## CommonEventPublishData -**系统能力:** 以下各项对应的系统能力均为SystemCapability.Notification.CommonEvent +**系统能力:**以下各项对应的系统能力均为SystemCapability.Notification.CommonEvent | 名称 | 读写属性 | 类型 | 必填 | 描述 | | --------------------- | -------- | -------------------- | ---- | ---------------------------- | @@ -530,7 +600,7 @@ CommonEvent.unsubscribe(subscriber, UnsubscribeCallBack); ## CommonEventSubscribeInfo -**系统能力:** 以下各项对应的系统能力均为SystemCapability.Notification.CommonEvent +**系统能力:**以下各项对应的系统能力均为SystemCapability.Notification.CommonEvent | 名称 | 读写属性 | 类型 | 必填 | 描述 | | ------------------- | -------- | -------------- | ---- | ------------------------------------------------------------ | @@ -542,7 +612,7 @@ CommonEvent.unsubscribe(subscriber, UnsubscribeCallBack); ## CommonEventData -**系统能力:** 以下各项对应的系统能力均为SystemCapability.Notification.CommonEvent +**系统能力:**以下各项对应的系统能力均为SystemCapability.Notification.CommonEvent | 名称 | 读写属性 | 类型 | 必填 | 描述 | | ---------- | -------- | -------------------- | ---- | ------------------------------------------------------- | @@ -560,7 +630,7 @@ getCode(callback: AsyncCallback\): void 获取公共事件的结果代码(callback形式)。 -**系统能力:** SystemCapability.Notification.CommonEvent +**系统能力**:SystemCapability.Notification.CommonEvent **参数:** @@ -591,7 +661,7 @@ getCode(): Promise\ 获取公共事件的结果代码(Promise形式)。 -**系统能力:** SystemCapability.Notification.CommonEvent +**系统能力**:SystemCapability.Notification.CommonEvent **返回值:** @@ -617,7 +687,7 @@ setCode(code: number, callback: AsyncCallback\): void 设置公共事件的结果代码(callback形式)。 -**系统能力:** SystemCapability.Notification.CommonEvent +**系统能力**:SystemCapability.Notification.CommonEvent **参数:** @@ -648,7 +718,7 @@ setCode(code: number): Promise\ 设置公共事件的结果代码(Promise形式)。 -**系统能力:** SystemCapability.Notification.CommonEvent +**系统能力**:SystemCapability.Notification.CommonEvent **参数:** @@ -674,7 +744,7 @@ getData(callback: AsyncCallback\): void 获取公共事件的结果数据(callback形式)。 -**系统能力:** SystemCapability.Notification.CommonEvent +**系统能力**:SystemCapability.Notification.CommonEvent **参数:** @@ -704,7 +774,7 @@ getData(): Promise\ 获取公共事件的结果数据(Promise形式)。 -**系统能力:** SystemCapability.Notification.CommonEvent +**系统能力**:SystemCapability.Notification.CommonEvent **返回值:** @@ -730,7 +800,7 @@ setData(data: string, callback: AsyncCallback\): void 设置公共事件的结果数据(callback形式)。 -**系统能力:** SystemCapability.Notification.CommonEvent +**系统能力**:SystemCapability.Notification.CommonEvent **参数:** @@ -761,7 +831,7 @@ setData(data: string): Promise\ 设置公共事件的结果数据(Promise形式)。 -**系统能力:** SystemCapability.Notification.CommonEvent +**系统能力**:SystemCapability.Notification.CommonEvent **参数:** @@ -787,7 +857,7 @@ setCodeAndData(code: number, data: string, callback:AsyncCallback\): void 设置公共事件的结果代码和结果数据(callback形式)。 -**系统能力:** SystemCapability.Notification.CommonEvent +**系统能力**:SystemCapability.Notification.CommonEvent **参数:** @@ -819,7 +889,7 @@ setCodeAndData(code: number, data: string): Promise\ 设置公共事件的结果代码和结果数据(Promise形式)。 -**系统能力:** SystemCapability.Notification.CommonEvent +**系统能力**:SystemCapability.Notification.CommonEvent **参数:** @@ -848,7 +918,7 @@ isOrderedCommonEvent(callback: AsyncCallback\): void 返回true代表是有序公共事件,false代表不是有序公共事件。 -**系统能力:** SystemCapability.Notification.CommonEvent +**系统能力**:SystemCapability.Notification.CommonEvent **参数:** @@ -880,7 +950,7 @@ isOrderedCommonEvent(): Promise\ 返回true代表是有序公共事件,false代表不是有序公共事件。 -**系统能力:** SystemCapability.Notification.CommonEvent +**系统能力**:SystemCapability.Notification.CommonEvent **返回值:** @@ -906,7 +976,7 @@ abortCommonEvent(callback: AsyncCallback\): void 取消当前的公共事件,仅对有序公共事件有效,取消后,公共事件不再向下一个订阅者传递(callback形式)。 -**系统能力:** SystemCapability.Notification.CommonEvent +**系统能力**:SystemCapability.Notification.CommonEvent **参数:** @@ -936,7 +1006,7 @@ abortCommonEvent(): Promise\ 取消当前的公共事件,仅对有序公共事件有效,取消后,公共事件不再向下一个订阅者传递(Promise形式)。 -**系统能力:** SystemCapability.Notification.CommonEvent +**系统能力**:SystemCapability.Notification.CommonEvent **示例:** @@ -956,7 +1026,7 @@ clearAbortCommonEvent(callback: AsyncCallback\): void 清除当前公共事件的取消状态,仅对有序公共事件有效(callback形式)。 -**系统能力:** SystemCapability.Notification.CommonEvent +**系统能力**:SystemCapability.Notification.CommonEvent **参数:** @@ -986,7 +1056,7 @@ clearAbortCommonEvent(): Promise\ 清除当前公共事件的取消状态,仅对有序公共事件有效(Promise形式)。 -**系统能力:** SystemCapability.Notification.CommonEvent +**系统能力**:SystemCapability.Notification.CommonEvent **示例:** @@ -1006,7 +1076,7 @@ getAbortCommonEvent(callback: AsyncCallback\): void 获取当前有序公共事件是否取消的状态(callback形式)。 -**系统能力:** SystemCapability.Notification.CommonEvent +**系统能力**:SystemCapability.Notification.CommonEvent **参数:** @@ -1036,7 +1106,7 @@ getAbortCommonEvent(): Promise\ 获取当前有序公共事件是否取消的状态(Promise形式)。 -**系统能力:** SystemCapability.Notification.CommonEvent +**系统能力**:SystemCapability.Notification.CommonEvent **返回值:** @@ -1062,7 +1132,7 @@ getSubscribeInfo(callback: AsyncCallback\): void 获取订阅者的订阅信息(callback形式)。 -**系统能力:** SystemCapability.Notification.CommonEvent +**系统能力**:SystemCapability.Notification.CommonEvent **参数:** @@ -1092,7 +1162,7 @@ getSubscribeInfo(): Promise\ 获取订阅者的订阅信息(Promise形式)。 -**系统能力:** SystemCapability.Notification.CommonEvent +**系统能力**:SystemCapability.Notification.CommonEvent **返回值:** diff --git a/zh-cn/application-dev/reference/apis/js-apis-fileio.md b/zh-cn/application-dev/reference/apis/js-apis-fileio.md index 1e6def6533c67181588eed4a966acda87a8f4311..b01a673db10bf796345bfd13f374f06bab9e7c34 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-fileio.md +++ b/zh-cn/application-dev/reference/apis/js-apis-fileio.md @@ -1432,7 +1432,7 @@ lstat(path:string, callback:AsyncCallback<Stat>): void ```js fileio.lstat(path, function (err, stat) { // do something - }); + )); ``` @@ -1827,7 +1827,7 @@ chown(path: string, uid: number, gid: number): Promise<void> - 示例: ```js let stat = fileio.statSync(path); - fileio.chown(path, stat.uid, stat.gid).then(function(){ + fileio.chown(path, stat.uid, stat.gid)).then(function(){ console.info("chown successfully"); }).catch(function(err){ console.info("chown failed with error:"+ err); @@ -2127,7 +2127,7 @@ fdopenStream(fd: number, mode: string): Promise<Stream> - 示例: ```js fileio.fdopenStream(fd, mode).then(function(stream){ - console.info("openStream successfully"); + console.info("openStream successfully"+); }).catch(function(err){ console.info("openStream failed with error:"+ err); }); diff --git a/zh-cn/application-dev/reference/apis/js-apis-formprovider.md b/zh-cn/application-dev/reference/apis/js-apis-formprovider.md deleted file mode 100644 index b6f721e33bb056b29d08d0cd45e6d36dd32a4000..0000000000000000000000000000000000000000 --- a/zh-cn/application-dev/reference/apis/js-apis-formprovider.md +++ /dev/null @@ -1,128 +0,0 @@ -# FormProvider - -> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 - -卡片提供方相关接口。 - -## 导入模块 - -``` -import formProvider from '@ohos.application.formProvider'; -``` - -## 权限 - -无 - -## setFormNextRefreshTime - -setFormNextRefreshTime(formId: string, minute: number, callback: AsyncCallback): void; - -设置指定卡片的下一次更新时间。 - -**系统能力:** - -SystemCapability.Ability.Form - -**参数:** - - | 参数名 | 类型 | 必填 | 说明 | - | ------ | ------ | ---- | ------------------------------------- | - | formId | string | 是 | 卡片标识 | - | minute | number | 是 | 指定多久之后更新,单位分钟,大于等于5 | - -**示例:** - - ```js - var formId = "12400633174999288"; - formProvider.setFormNextRefreshTime(formId, 5, (error, data) => { - if (error) { - console.log('formProvider setFormNextRefreshTime, error:' + error.code); - } - }); - ``` - -## setFormNextRefreshTime - -setFormNextRefreshTime(formId: string, minute: number): Promise; - -设置指定卡片的下一次更新时间,以promise方式返回。 - -**系统能力:** - -SystemCapability.Ability.Form - -**参数:** - - | 参数名 | 类型 | 必填 | 说明 | - | ------ | ------ | ---- | ------------------------------------- | - | formId | string | 是 | 卡片标识 | - | minute | number | 是 | 指定多久之后更新,单位分钟,大于等于5 | - -**示例:** - - ```js - var formId = "12400633174999288"; - formProvider.setFormNextRefreshTime(formId, 5).catch((error) => { - console.log('formProvider setFormNextRefreshTime, error:' + JSON.stringify(error)); - }); - ``` - -## updateForm - -updateForm(formId: string, formBindingData: formBindingData.FormBindingData, callback: AsyncCallback): void; - -更新指定的卡片。 - -**系统能力:** - -SystemCapability.Ability.Form - -**参数:** - - | 参数名 | 类型 | 必填 | 说明 | - | ------ | ---------------------------------------------------------------------- | ---- | ---------------- | - | formId | string | 是 | 请求更新的卡片标识 | - | formBindingData | [FormBindingData](js-apis-formbindingdata.md#formbindingdata) | 是 | 用于更新的数据 | - -**示例:** - - ```js - import formBindingData from '@ohos.application.formBindingData'; - var formId = "12400633174999288"; - let obj = formBindingData.createFormBindingData({temperature:"22c", time:"22:00"}); - formProvider.updateForm(formId, obj, (error, data) => { - if (error) { - console.log('formProvider updateForm, error:' + error.code); - } - }); - ``` - -## updateForm - -updateForm(formId: string, formBindingData: formBindingData.FormBindingData): Promise; - -更新指定的卡片,以promise方式返回。 - -**系统能力:** - -SystemCapability.Ability.Form - -**参数:** - - | 参数名 | 类型 | 必填 | 说明 | - | ------ | ---------------------------------------------------------------------- | ---- | ---------------- | - | formId | string | 是 | 请求更新的卡片标识 | - | formBindingData | [FormBindingData](js-apis-formbindingdata.md#formbindingdata) | 是 | 用于更新的数据 | - -**示例:** - - ```js - import formBindingData from '@ohos.application.formBindingData'; - var formId = "12400633174999288"; - let obj = formBindingData.createFormBindingData({temperature:"22c", time:"22:00"}); - formProvider.updateForm(formId, obj).catch((error) => { - console.log('formProvider updateForm, error:' + JSON.stringify(error)); - }); - ``` \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-geolocation.md b/zh-cn/application-dev/reference/apis/js-apis-geolocation.md index 6dd2b097b525559b8820532fe4ab4c97d5e8303b..bbb22b733f8579c06149cd6f9bd32f54a480f306 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-geolocation.md +++ b/zh-cn/application-dev/reference/apis/js-apis-geolocation.md @@ -1,4 +1,4 @@ -# 位置服务(新) +# 位置服务 > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** @@ -7,7 +7,7 @@ ## 导入模块 - + ``` import geolocation from '@ohos.geolocation'; ``` @@ -34,7 +34,7 @@ on(type: 'locationChange', request: LocationRequest, callback: Callback<Locat | callback | Callback<[Location](#location)> | 是 | 接收位置变化状态变化监听。 | - 示例: - + ``` var requestInfo = {'priority': 0x203, 'scenario': 0x300, 'timeInterval': 0, 'distanceInterval': 0, 'maxAccuracy': 0}; var locationChange = (location) => { @@ -57,7 +57,7 @@ off(type: 'locationChange', callback?: Callback<Location>) : void | callback | Callback<[Location](#location)> | 否 | 接收位置变化状态变化监听。 | - 示例: - + ``` var requestInfo = {'priority': 0x203, 'scenario': 0x300, 'timeInterval': 0, 'distanceInterval': 0, 'maxAccuracy': 0}; var locationChange = (location) => { @@ -81,7 +81,7 @@ on(type: 'locationServiceState', callback: Callback<boolean>) : void | callback | Callback<boolean> | 是 | 接收位置服务状态变化监听。 | - 示例: - + ``` var locationServiceState = (state) => { console.log('locationServiceState: ' + state); @@ -103,7 +103,7 @@ off(type: 'locationServiceState', callback?: Callback<boolean>) : void; | callback | Callback<boolean> | 否 | 接收位置服务状态变化监听。 | - 示例: - + ``` var locationServiceState = (state) => { console.log('locationServiceState: state: ' + state); @@ -127,7 +127,7 @@ on(type: 'cachedGnssLocationsReporting', request: CachedGnssLocationsRequest, ca | callback | Callback<boolean> | 是 | 接收GNSS缓存位置上报。 | - 示例: - + ``` var cachedLocationsCb = (locations) => { console.log('cachedGnssLocationsReporting: locations: ' + locations); @@ -150,7 +150,7 @@ off(type: 'cachedGnssLocationsReporting', callback?: Callback<Array<Locati | callback | Callback<boolean> | 否 | 接收GNSS缓存位置上报。 | - 示例: - + ``` var cachedLocationsCb = (locations) => { console.log('cachedGnssLocationsReporting: locations: ' + locations); @@ -174,7 +174,7 @@ on(type: 'gnssStatusChange', callback: Callback<SatelliteStatusInfo>) : vo | callback | Callback<SatelliteStatusInfo> | 是 | 接收GNSS卫星状态信息上报。 | - 示例: - + ``` var gnssStatusCb = (satelliteStatusInfo) => { console.log('gnssStatusChange: ' + satelliteStatusInfo); @@ -196,7 +196,7 @@ off(type: 'gnssStatusChange', callback?: Callback<SatelliteStatusInfo>) : | callback | Callback<SatelliteStatusInfo> | 否 | 接收GNSS卫星状态信息上报。 | - 示例: - + ``` var gnssStatusCb = (satelliteStatusInfo) => { console.log('gnssStatusChange: ' + satelliteStatusInfo); @@ -219,7 +219,7 @@ on(type: 'nmeaMessageChange', callback: Callback<string>) : void; | callback | Callback<string> | 是 | 接收GNSS NMEA信息上报。 | - 示例: - + ``` var nmeaCb = (str) => { console.log('nmeaMessageChange: ' + str); @@ -241,7 +241,7 @@ off(type: 'nmeaMessageChange', callback?: Callback<string>) : void; | callback | Callback<string> | 否 | 接收GNSS NMEA信息上报。 | - 示例: - + ``` var nmeaCb = (str) => { console.log('nmeaMessageChange: ' + str); @@ -265,7 +265,7 @@ on(type: 'fenceStatusChange', request: GeofenceRequest, want: WantAgent) : void; | want | WantAgent | 是 | 用于接收地理围栏事件上报(进出围栏)。 | - 示例: - + ``` import WantAgent from '@ohos.wantAgent'; import { OperationType, WantAgentFlags } from '@ohos.wantagent'; @@ -327,7 +327,7 @@ off(type: 'fenceStatusChange', request: GeofenceRequest, want: WantAgent) : void | want | WantAgent | 是 | 用于接收地理围栏事件上报(进出围栏)。 | - 示例: - + ``` import WantAgent from '@ohos.wantAgent'; import { OperationType, WantAgentFlags } from '@ohos.wantagent'; @@ -391,7 +391,7 @@ getCurrentLocation(request: CurrentLocationRequest, callback: AsyncCallback<L | callback | AsyncCallback<[Location](#location)> | 是 | 用来接收位置信息的回调。 | - 示例: - + ``` var requestInfo = {'priority': 0x203, 'scenario': 0x300,'maxAccuracy': 0}; var locationChange = (err, location) => { @@ -421,7 +421,7 @@ getCurrentLocation(request?: CurrentLocationRequest) : Promise<Location> | Promise<[Location](#location)> | 返回位置信息。 | - 示例: - + ``` var requestInfo = {'priority': 0x203, 'scenario': 0x300,'maxAccuracy': 0}; locationEventListener.getCurrentLocation(requestInfo).then((result) => { @@ -442,7 +442,7 @@ getLastLocation(callback: AsyncCallback<Location>) : void | callback | AsyncCallback<[Location](#location)> | 是 | 用来接收上次位置的回调。 | - 示例: - + ``` geolocation.getLastLocation((err, data) => { console.log('getLastLocation: ' + err + " data: " + JSON.stringify(data)); @@ -462,7 +462,7 @@ getLastLocation() : Promise<Location> | Promise<[Location](#location)> | 返回上次位置信息。 | - 示例: - + ``` geolocation.getLastLocation().then((result) => { console.log('getLastLocation: result: ' + JSON.stringify(result)); @@ -484,7 +484,7 @@ isLocationEnabled(callback: AsyncCallback<boolean>) : void | callback | AsyncCallback<boolean> | 是 | 用来接收位置服务状态的回调。 | - 示例: - + ``` geolocation.isLocationEnabled((err, data) => { console.log('isLocationEnabled: ' + err + " data: " + data); @@ -504,7 +504,7 @@ isLocationEnabled() : Promise<boolean> | Promise<boolean> | 返回位置服务是否可用的状态。 | - 示例: - + ``` geolocation.isLocationEnabled().then((result) => { console.log('promise, isLocationEnabled: ' + result); @@ -526,7 +526,7 @@ requestEnableLocation(callback: AsyncCallback<boolean>) : void | callback | AsyncCallback<boolean> | 是 | 用来接收位置服务状态的回调。 | - 示例: - + ``` geolocation.requestEnableLocation((err, data) => { console.log('requestEnableLocation: ' + err + " data: " + data); @@ -546,7 +546,7 @@ requestEnableLocation() : Promise<boolean> | Promise<boolean> | 返回位置服务是否可用。 | - 示例: - + ``` geolocation.requestEnableLocation().then((result) => { console.log('promise, requestEnableLocation: ' + result); @@ -566,7 +566,7 @@ isGeoServiceAvailable(callback: AsyncCallback<boolean>) : void | callback | AsyncCallback<boolean> | 是 | 用来接收地理编码服务状态的回调。 | - 示例: - + ``` geolocation.isGeoServiceAvailable((err, data) => { console.log('isGeoServiceAvailable: ' + err + " data: " + data); @@ -586,7 +586,7 @@ isGeoServiceAvailable() : Promise<boolean> | Promise<boolean> | 返回地理编码服务是否可用的状态。 | - 示例: - + ``` geolocation.isGeoServiceAvailable().then((result) => { console.log('promise, isGeoServiceAvailable: ' + result); @@ -608,7 +608,7 @@ getAddressesFromLocation(request: ReverseGeoCodeRequest, callback: AsyncCallback | callback | AsyncCallback<Array<[GeoAddress](#geoaddress)>> | 是 | 设置接收逆地理编码请求的回调参数。 | - 示例: - + ``` var reverseGeocodeRequest = {"latitude": 31.12, "longitude": 121.11, "maxItems": 1}; geolocation.getAddressesFromLocation(reverseGeocodeRequest, (err, data) => { @@ -634,7 +634,7 @@ getAddressesFromLocation(request: ReverseGeoCodeRequest) : Promise<Array<G | Promise<Array<[GeoAddress](#geoaddress)>> | 返回地理描述信息。 | - 示例: - + ``` var reverseGeocodeRequest = {"latitude": 31.12, "longitude": 121.11, "maxItems": 1}; geolocation.getAddressesFromLocation(reverseGeocodeRequest).then((data) => { @@ -656,7 +656,7 @@ getAddressesFromLocationName(request: GeoCodeRequest, callback: AsyncCallback< | callback | AsyncCallback<Array<[GeoAddress](#geoaddress)>> | 是 | 设置接收地理编码请求的回调参数。 | - 示例: - + ``` var geocodeRequest = {"description": "上海市浦东新区xx路xx号", "maxItems": 1}; geolocation.getAddressesFromLocationName(geocodeRequest, (err, data) => { @@ -682,7 +682,7 @@ getAddressesFromLocationName(request: GeoCodeRequest) : Promise<Array<GeoA | Promise<Array<[GeoAddress](#geoaddress)>> | 设置接收地理编码请求的回调参数。 | - 示例: - + ``` var geocodeRequest = {"description": "上海市浦东新区xx路xx号", "maxItems": 1}; geolocation.getAddressesFromLocationName(geocodeRequest).then((result) => { @@ -704,7 +704,7 @@ getCachedGnssLocationsSize(callback: AsyncCallback<number>) : void; | callback | AsyncCallback<number> | 是 | 用来接收GNSS芯片缓存位置个数的回调。 | - 示例: - + ``` geolocation.getCachedGnssLocationsSize((err, size) => { console.log('getCachedGnssLocationsSize: err:' + err + " size: " + size); @@ -724,7 +724,7 @@ getCachedGnssLocationsSize() : Promise<number>; | Promise<number> | 返回GNSS缓存位置的个数。 | - 示例: - + ``` geolocation.getCachedGnssLocationsSize().then((result) => { console.log('promise, getCachedGnssLocationsSize: ' + result); @@ -744,7 +744,7 @@ flushCachedGnssLocations(callback: AsyncCallback<boolean>) : void; | callback | AsyncCallback<boolean> | 是 | 用来接收清空GNSS芯片缓存位置操作的结果。 | - 示例: - + ``` geolocation.flushCachedGnssLocations((err, result) => { console.log('flushCachedGnssLocations: err:' + err + " result: " + result); @@ -764,7 +764,7 @@ flushCachedGnssLocations() : Promise<boolean>; | Promise<boolean> | 清空所有GNSS缓存位置是否成功。 | - 示例: - + ``` geolocation.flushCachedGnssLocations().then((result) => { console.log('promise, flushCachedGnssLocations: ' + result); @@ -785,7 +785,7 @@ sendCommand(command: LocationCommand, callback: AsyncCallback<boolean>) : | callback | AsyncCallback<boolean> | 是 | 用来接收命令发送的结果。 | - 示例: - + ``` var requestInfo = {'scenario': 0x301, 'command': "command_1"}; geolocation.sendCommand(requestInfo, (err, result) => { @@ -811,7 +811,7 @@ sendCommand(command: LocationCommand) : Promise<boolean>; | Promise<boolean> | 表示命令发送成功或失败。 | - 示例: - + ``` var requestInfo = {'scenario': 0x301, 'command': "command_1"}; geolocation.sendCommand(requestInfo).then((result) => { @@ -833,7 +833,7 @@ isLocationPrivacyConfirmed(type : LocationPrivacyType, callback: AsyncCallback&l | callback | AsyncCallback<boolean> | 是 | 表示用户是否同意定位服务隐私申明。 | - 示例: - + ``` geolocation.isLocationPrivacyConfirmed(1, (err, result) => { console.log('isLocationPrivacyConfirmed: err:' + err + " result: " + result); @@ -858,7 +858,7 @@ isLocationPrivacyConfirmed(type : LocationPrivacyType,) : Promise<boolean> | Promise<boolean> | 表示用户是否同意定位服务隐私申明。 | - 示例: - + ``` geolocation.isLocationPrivacyConfirmed(1).then((result) => { console.log('promise, isLocationPrivacyConfirmed: ' + result); @@ -880,7 +880,7 @@ setLocationPrivacyConfirmStatus(type : LocationPrivacyType, isConfirmed: boolean | callback | AsyncCallback<boolean> | 是 | 表示操作是否成功。 | - 示例: - + ``` geolocation.setLocationPrivacyConfirmStatus(1, true, (err, result) => { console.log('isLocationPrivacyConfirmed: err:' + err + " result: " + result); @@ -906,7 +906,7 @@ setLocationPrivacyConfirmStatus(type : LocationPrivacyType, isConfirmed : boolea | Promise<boolean> | 表示操作是否成功。 | - 示例: - + ``` geolocation.setLocationPrivacyConfirmStatus(1, true).then((result) => { console.log('promise, setLocationPrivacyConfirmStatus: ' + result); diff --git a/zh-cn/application-dev/reference/apis/js-apis-media.md b/zh-cn/application-dev/reference/apis/js-apis-media.md index 74a1d0b8f40b304115e2cf22f1de6520f76c4a9a..6a4e22478e61f31526cfd26beb260a035ec33e5a 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-media.md +++ b/zh-cn/application-dev/reference/apis/js-apis-media.md @@ -1,5 +1,8 @@ # 媒体服务 +> **说明:** +> 本模块首批接口从API version 6开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 + 媒体子系统为开发者提供一套简单且易于理解的接口,使得开发者能够方便接入系统并使用系统的媒体资源。 媒体子系统包含了音视频相关媒体业务,提供以下常用功能: @@ -23,7 +26,7 @@ createAudioPlayer(): [AudioPlayer](#audioplayer) 同步方式创建音频播放实例。 - +**系统能力:** SystemCapability.Multimedia.Media.AudioPlayer **返回值:** @@ -34,64 +37,7 @@ createAudioPlayer(): [AudioPlayer](#audioplayer) **示例:** ```js -var audioPlayer = media.createAudioPlayer(); -``` - -## media.createAudioPlayerAsync8+ - -createAudioPlayerAsync(callback: AsyncCallback\<[AudioPlayer](#audioplayer)>): void - -异步方式创建音频播放实例。通过注册回调函数获取返回值。 - -**参数:** - -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ------------------------------------------ | ---- | ------------------------------ | -| callback | AsyncCallback<[AudioPlayer](#audioplayer)> | 是 | 异步创建音频播放实例回调方法。 | - -**示例:** - -```js -media.createAudioPlayerAsync((error, audio) => { - if (typeof(audio) != 'undefined') { - audioPlayer = audio; - console.info('audio createAudioPlayerAsync success'); - } else { - console.info(`audio createAudioPlayerAsync fail, error:${error.message}`); - } -}); -``` - -## media.createAudioPlayerAsync8+ - -createAudioPlayerAsync: Promise<[AudioPlayer](#audioplayer)> - -异步方式创建音频播放实例。通过Promise获取返回值。 - -**返回值:** - -| 类型 | 说明 | -| ------------------------------------ | ----------------------------------- | -| Promise<[AudioPlayer](#audioplayer)> | 异步创建音频播放实例Promise返回值。 | - -**示例:** - -```js -function failureCallback(error) { - console.info(`audio failureCallback, error:${error.message}`); -} -function catchCallback(error) { - console.info(`audio catchCallback, error:${error.message}`); -} - -await media.createAudioPlayerAsync.then((audio) => { - if (typeof(audio) != 'undefined') { - audioPlayer = audio; - console.info('audio createAudioPlayerAsync success'); - } else { - console.info('audio createAudioPlayerAsync fail'); - } -}, failureCallback).catch(catchCallback); +let audioPlayer = media.createAudioPlayer(); ``` ## media.createVideoPlayer8+ @@ -100,6 +46,8 @@ createVideoPlayer(callback: AsyncCallback\<[VideoPlayer](#videoplayer8)>): void 异步方式创建视频播放实例,通过注册回调函数获取返回值。 +**系统能力:** SystemCapability.Multimedia.Media.VideoPlayer + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -109,6 +57,8 @@ createVideoPlayer(callback: AsyncCallback\<[VideoPlayer](#videoplayer8)>): void **示例:** ```js +let videoPlayer + media.createVideoPlayer((error, video) => { if (typeof(video) != 'undefined') { videoPlayer = video; @@ -121,10 +71,12 @@ media.createVideoPlayer((error, video) => { ## media.createVideoPlayer8+ -createVideoPlayer: Promise<[VideoPlayer](#videoplayer8)> +createVideoPlayer(): Promise<[VideoPlayer](#videoplayer8)> 异步方式创建视频播放实例,通过Promise获取返回值。 +**系统能力:** SystemCapability.Multimedia.Media.VideoPlayer + **返回值:** | 类型 | 说明 | @@ -134,6 +86,8 @@ createVideoPlayer: Promise<[VideoPlayer](#videoplayer8)> **示例:** ```js +let videoPlayer + function failureCallback(error) { console.info(`video failureCallback, error:${error.message}`); } @@ -157,6 +111,8 @@ createAudioRecorder(): AudioRecorder 创建音频录制的实例来控制音频的录制。 +**系统能力:** SystemCapability.Multimedia.Media.AudioRecorder + **返回值:** | 类型 | 说明 | @@ -169,103 +125,54 @@ createAudioRecorder(): AudioRecorder let audiorecorder = media.createAudioRecorder(); ``` -## media.createAudioRecorderAsync8+ - -createAudioRecorderAsync(callback: AsyncCallback\<[AudioRecorder](#audiorecorder)>): void - -异步方式创建音频录制实例。通过注册回调函数获取返回值。 - -**参数:** +## media.createVideoRecorder8+ -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------------- | ---- | ------------------------------ | -| callback | AsyncCallback<[AudioRecorder](#audiorecorder)> | 是 | 异步创建音频录制实例回调方法。 | - -**示例:** - -```js -media.createAudioRecorderAsync((error, audio) => { - if (typeof(audio) != 'undefined') { - audioRecorder = audio; - console.info('audio createAudioRecorderAsync success'); - } else { - console.info(`audio createAudioRecorderAsync fail, error:${error.message}`); - } -}); -``` - -## media.createAudioRecorderAsync8+ - -createAudioRecorderAsync: Promise<[AudioRecorder](#audiorecorder)> - -异步方式创建音频录制实例。通过Promise获取返回值。 - -**返回值:** - -| 类型 | 说明 | -| ---------------------------------------- | ----------------------------------- | -| Promise<[AudioRecorder](#audiorecorder)> | 异步创建音频录制实例Promise返回值。 | - -**示例:** - -```js -function failureCallback(error) { - console.info(`audio failureCallback, error:${error.message}`); -} -function catchCallback(error) { - console.info(`audio catchCallback, error:${error.message}`); -} - -await media.createAudioRecorderAsync.then((audio) => { - if (typeof(audio) != 'undefined') { - audioRecorder = audio; - console.info('audio createAudioRecorderAsync success'); - } else { - console.info('audio createAudioRecorderAsync fail'); - } -}, failureCallback).catch(catchCallback); -``` - -## media.createVideoRecorderAsync8+ - -createVideoRecorderAsync(callback: AsyncCallback\<[VideoRecorder](#videorecorder8)>): void +createVideoRecorder(callback: AsyncCallback\<[VideoRecorder](#videorecorder8)>): void 异步方式创建视频录制实例。通过注册回调函数获取返回值。 +**系统能力:** SystemCapability.Multimedia.Media.VideoRecorder + **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ----------------------------------------------------------- | ---- | ------------------------------ | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ----------------------------------------------- | ---- | ------------------------------ | | callback | AsyncCallback<[VideoRecorder](#videorecorder8)> | 是 | 异步创建视频录制实例回调方法。 | **示例:** ```js -media.createVideoRecorderAsync((error, video) => { +let videoRecorder + +media.createVideoRecorder((error, video) => { if (typeof(video) != 'undefined') { videoRecorder = video; - console.info('video createVideoRecorderAsync success'); + console.info('video createVideoRecorder success'); } else { - console.info(`video createVideoRecorderAsync fail, error:${error.message}`); + console.info(`video createVideoRecorder fail, error:${error.message}`); } }); ``` -## media.createVideoRecorderAsync8+ +## media.createVideoRecorder8+ -createVideoRecorderAsync: Promise<[VideoRecorder](#videorecorder8)> +createVideoRecorder(): Promise<[VideoRecorder](#videorecorder8)> 异步方式创建视频录制实例。通过Promise获取返回值。 +**系统能力:** SystemCapability.Multimedia.Media.VideoRecorder + **返回值:** -| 类型 | 说明 | -| ----------------------------------------------------- | ----------------------------------- | +| 类型 | 说明 | +| ----------------------------------------- | ----------------------------------- | | Promise<[VideoRecorder](#videorecorder8)> | 异步创建视频录制实例Promise返回值。 | **示例:** ```js +let videoRecorder + function failureCallback(error) { console.info(`video failureCallback, error:${error.message}`); } @@ -273,12 +180,12 @@ function catchCallback(error) { console.info(`video catchCallback, error:${error.message}`); } -await media.createVideoRecorderAsync.then((video) => { +await media.createVideoRecorder.then((video) => { if (typeof(video) != 'undefined') { videoRecorder = video; - console.info('video createVideoRecorderAsync success'); + console.info('video createVideoRecorder success'); } else { - console.info('video createVideoRecorderAsync fail'); + console.info('video createVideoRecorder fail'); } }, failureCallback).catch(catchCallback); ``` @@ -287,7 +194,9 @@ await media.createVideoRecorderAsync.then((video) => { ## MediaErrorCode8+ -媒体服务错误类型枚举 +媒体服务错误类型枚举。 + +**系统能力:** 以下各项对应的系统能力均为 SystemCapability.Multimedia.Media.Core。 | 名称 | 值 | 说明 | | -------------------------- | ---- | -------------------------------------- | @@ -304,29 +213,33 @@ await media.createVideoRecorderAsync.then((video) => { ## MediaType8+ -媒体类型枚举 +媒体类型枚举。 + +**系统能力:** 以下各项对应的系统能力均为 SystemCapability.Multimedia.Media.Core。 -| 名称 | 值 | 说明 | -| ------------------- | ---- | ------------------ | -| MEDIA_TYPE_AUD | 0 | 表示音频。 | -| MEDIA_TYPE_VID | 1 | 表示视频。 | -| MEDIA_TYPE_SUBTITLE | 2 | 表示字幕:开发中。 | +| 名称 | 值 | 说明 | +| -------------- | ---- | ---------- | +| MEDIA_TYPE_AUD | 0 | 表示音频。 | +| MEDIA_TYPE_VID | 1 | 表示视频。 | ## CodecMimeType8+ -Codec MIME类型枚举 +Codec MIME类型枚举。 + +**系统能力:** 以下各项对应的系统能力均为 SystemCapability.Multimedia.Media.Core。 | 名称 | 值 | 说明 | | ------------ | ----------------- | ------------------------ | | VIDEO_MPEG4 | ”video/mp4v-es“ | 表示视频/mpeg4类型。 | -| AUDIO_MPEG | "audio/mpeg" | 表示音频/mpeg类型。 | | AUDIO_AAC | "audio/mp4a-latm" | 表示音频/mp4a-latm类型。 | | AUDIO_VORBIS | "audio/vorbis" | 表示音频/vorbis类型。 | | AUDIO_FLAC | "audio/flac" | 表示音频/flac类型。 | ## MediaDescriptionKey8+ -媒体信息描述枚举 +媒体信息描述枚举。 + +**系统能力:** 以下各项对应的系统能力均为 SystemCapability.Multimedia.Media.Core。 | 名称 | 值 | 说明 | | ------------------------ | --------------- | ------------------------------------------------------------ | @@ -343,7 +256,9 @@ Codec MIME类型枚举 ## BufferingInfoType8+ -缓存事件类型枚举 +缓存事件类型枚举。 + +**系统能力:** 以下各项对应的系统能力均为 SystemCapability.Multimedia.Media.Core。 | 名称 | 值 | 说明 | | ----------------- | ---- | -------------------------- | @@ -354,15 +269,17 @@ Codec MIME类型枚举 ## AudioPlayer -音频播放管理类,用于管理和播放音频媒体。在调用AudioPlayer的方法前,需要先通过[createAudioPlayer()](#media.createaudioplayer)或[createAudioPlayerAsync()](#media.createaudioplayerasync8)构建一个[AudioPlayer](#audioplayer)实例。 +音频播放管理类,用于管理和播放音频媒体。在调用AudioPlayer的方法前,需要先通过[createAudioPlayer()](#mediacreateaudioplayer)构建一个[AudioPlayer](#audioplayer)实例。 音频播放demo可参考:[音频播放开发指导](../../media/audio-playback.md) ### 属性 +**系统能力:** 以下各项对应的系统能力均为 SystemCapability.Multimedia.Media.AudioPlayer。 + | 名称 | 类型 | 可读 | 可写 | 说明 | | ----------- | ------------------------- | ---- | ---- | ------------------------------------------------------------ | -| src | string | 是 | 是 | 音频媒体URI,支持当前主流的音频格式(mp4、aac、mp3、ogg)。
**支持路径示例**:
1、本地绝对路径:file:///data/data/ohos.xxx.xxx/files/test.mp4
![zh-cn_image_0000001164217678](figures/zh-cn_image_0000001164217678.png)
2、http网络播放路径:开发中
3、hls网络播放路径:开发中
4、fd类型播放:开发中
**注意事项**:
媒体素材需至少赋予读权限后,才可正常播放 | +| src | string | 是 | 是 | 音频媒体URI,支持当前主流的音频格式(mp4、aac、mp3、ogg)。
**支持路径示例**:
1. fd类型播放:fd://xxx
![zh-cn_image_0000001164217678](figures/zh-cn_image_url.png)
2. http网络播放路径:开发中
3. hls网络播放路径:开发中
**注意事项**:
使用媒体素材需要获取读权限,否则无法正常播放。 | | loop | boolean | 是 | 是 | 音频循环播放属性,设置为'true'表示循环播放。 | | currentTime | number | 是 | 否 | 音频的当前播放位置。 | | duration | number | 是 | 否 | 音频时长。 | @@ -374,6 +291,8 @@ play(): void 开始播放音频资源,需在[dataLoad](#on('play' | 'pause' | 'stop' | 'reset' | 'dataload' | 'finish' | 'volumechange'))事件成功触发后,才能调用play方法。 +**系统能力:** SystemCapability.Multimedia.Media.AudioPlayer + **示例:** ```js @@ -389,6 +308,8 @@ pause(): void 暂停播放音频资源。 +**系统能力:** SystemCapability.Multimedia.Media.AudioPlayer + **示例:** ```js @@ -404,6 +325,8 @@ stop(): void 停止播放音频资源。 +**系统能力:** SystemCapability.Multimedia.Media.AudioPlayer + **示例:** ```js @@ -419,6 +342,8 @@ reset(): void 切换播放音频资源。 +**系统能力:** SystemCapability.Multimedia.Media.AudioPlayer + **示例:** ```js @@ -434,6 +359,8 @@ seek(timeMs: number): void 跳转到指定播放位置。 +**系统能力:** SystemCapability.Multimedia.Media.AudioPlayer + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -459,6 +386,8 @@ setVolume(vol: number): void 设置音量。 +**系统能力:** SystemCapability.Multimedia.Media.AudioPlayer + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -480,6 +409,8 @@ release(): void 释放音频资源。 +**系统能力:** SystemCapability.Multimedia.Media.AudioPlayer + **示例:** ```js @@ -493,6 +424,8 @@ getTrackDescription(callback: AsyncCallback> 通过Promise方式获取音频轨道信息。 +**系统能力:** SystemCapability.Multimedia.Media.AudioPlayer + **返回值:** | 类型 | 说明 | @@ -568,6 +503,8 @@ on(type: 'bufferingUpdate', callback: (infoType: [BufferingInfoType](#bufferingi 开始订阅音频缓存更新事件。 +**系统能力:** SystemCapability.Multimedia.Media.AudioPlayer + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -590,6 +527,8 @@ on(type: 'play' | 'pause' | 'stop' | 'reset' | 'dataLoad' | 'finish' | 'volumeCh 开始订阅音频播放事件。 +**系统能力:** SystemCapability.Multimedia.Media.AudioPlayer + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -639,7 +578,19 @@ audioPlayer.on('error', (error) => { //设置'error'事件回调 console.info(`audio error called, errCode is ${error.code}`); console.info(`audio error called, errMessage is ${error.message}`); }); -audioPlayer.src = 'file:///data/data/ohos.xxx.xxx/files/test.mp4'; //设置src属性,并触发'dataLoad'事件回调 + +// 用户选择视频设置fd(本地播放) +let fdPath = 'fd://' +let path = 'data/accounts/account_0/appdata/ohos.xxx.xxx.xxx/01.mp3'; +await fileIO.open(path).then(fdNumber) => { + fdPath = fdPath + '' + fdNumber; + console.info('open fd sucess fd is' + fdPath); +}, (err) => { + console.info('open fd failed err is' + err); +}),catch((err) => { + console.info('open fd failed err is' + err); +}); +audioPlayer.src = fdPath; //设置src属性,并触发'dataLoad'事件回调 ``` ### on('timeUpdate') @@ -648,6 +599,8 @@ on(type: 'timeUpdate', callback: Callback\): void 开始订阅音频播放[seek()](#seek)时间更新事件。 +**系统能力:** SystemCapability.Multimedia.Media.AudioPlayer + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -674,6 +627,8 @@ on(type: 'error', callback: ErrorCallback): void 开始订阅音频播放错误事件。 +**系统能力:** SystemCapability.Multimedia.Media.AudioPlayer + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -696,6 +651,8 @@ audioPlayer.setVolume(3); //设置volume为无效值,触发'error'事件 音频播放的状态机。可通过state属性获取当前状态。 +**系统能力:** 以下各项对应的系统能力均为 SystemCapability.Multimedia.Media.AudioPlayer。 + | 名称 | 类型 | 描述 | | ------------------ | ------ | -------------- | | idle | string | 音频播放空闲。 | @@ -710,17 +667,19 @@ audioPlayer.setVolume(3); //设置volume为无效值,触发'error'事件 视频播放demo可参考:[视频播放开发指导](../../media/video-playback.md) -### 属性8+ +### 属性 + +**系统能力:** 以下各项对应的系统能力均为 SystemCapability.Multimedia.Media.VideoPlayer。 -| 名称 | 类型 | 可读 | 可写 | 说明 | -| ----------- | ---------------------------------- | ---- | ---- | ------------------------------------------------------------ | -| url | string | 是 | 是 | 视频媒体URL,支持当前主流的视频格式(mp4、mpeg-ts、webm、mkv)。
**支持路径示例**:
1. 本地绝对路径:file:///data/data/ohos.xxx.xxx/files/test.mp4
![zh-cn_image_0000001164217678](figures/zh-cn_image_0000001164217678.png)
**注意事项**:
媒体素材需至少赋予读权限后,才可正常播放 | -| loop | boolean | 是 | 是 | 视频循环播放属性,设置为'true'表示循环播放。 | -| currentTime | number | 是 | 否 | 视频的当前播放位置。 | -| duration | number | 是 | 否 | 视频时长,返回-1表示直播模式 | -| state | [VideoPlayState](#videoplaystate8) | 是 | 否 | 视频播放的状态。 | -| width | number | 是 | 否 | 视频宽。 | -| height | number | 是 | 否 | 视频高。 | +| 名称 | 类型 | 可读 | 可写 | 说明 | +| ------------------------ | ---------------------------------- | ---- | ---- | ------------------------------------------------------------ | +| url8+ | string | 是 | 是 | 视频媒体URL,支持当前主流的视频格式(mp4、mpeg-ts、webm、mkv)。
**支持路径示例**:
1. fd类型播放:fd://xxx
![zh-cn_image_0000001164217678](figures/zh-cn_image_url.png)
**注意事项**:
使用媒体素材需要获取读权限,否则无法正常播放。 | +| loop8+ | boolean | 是 | 是 | 视频循环播放属性,设置为'true'表示循环播放。 | +| currentTime8+ | number | 是 | 否 | 视频的当前播放位置。 | +| duration8+ | number | 是 | 否 | 视频时长,返回-1表示直播模式。 | +| state8+ | [VideoPlayState](#videoplaystate8) | 是 | 否 | 视频播放的状态。 | +| width8+ | number | 是 | 否 | 视频宽。 | +| height8+ | number | 是 | 否 | 视频高。 | ### setDisplaySurface8+ @@ -728,6 +687,8 @@ setDisplaySurface(surfaceId: string, callback: AsyncCallback\): void 通过回调方式设置SurfaceId。 +**系统能力:** SystemCapability.Multimedia.Media.VideoPlayer + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -753,6 +714,8 @@ setDisplaySurface(surfaceId: string): Promise\ 通过Promise方式设置SurfaceId。 +**系统能力:** SystemCapability.Multimedia.Media.VideoPlayer + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -785,6 +748,8 @@ prepare(callback: AsyncCallback\): void 通过回调方式准备播放视频。 +**系统能力:** SystemCapability.Multimedia.Media.VideoPlayer + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -809,6 +774,8 @@ prepare(): Promise\ 通过Promise方式准备播放视频。 +**系统能力:** SystemCapability.Multimedia.Media.VideoPlayer + **返回值:** | 类型 | 说明 | @@ -835,6 +802,8 @@ play(callback: AsyncCallback\): void; 通过回调方式开始播放视频。 +**系统能力:** SystemCapability.Multimedia.Media.VideoPlayer + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -859,6 +828,8 @@ play(): Promise\; 通过Promise方式开始播放视频。 +**系统能力:** SystemCapability.Multimedia.Media.VideoPlayer + **返回值:** | 类型 | 说明 | @@ -885,6 +856,8 @@ pause(callback: AsyncCallback\): void 通过回调方式暂停播放视频。 +**系统能力:** SystemCapability.Multimedia.Media.VideoPlayer + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -909,6 +882,8 @@ pause(): Promise\ 通过Promise方式暂停播放视频。 +**系统能力:** SystemCapability.Multimedia.Media.VideoPlayer + **返回值:** | 类型 | 说明 | @@ -935,6 +910,8 @@ stop(callback: AsyncCallback\): void 通过回调方式停止播放视频。 +**系统能力:** SystemCapability.Multimedia.Media.VideoPlayer + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -959,6 +936,8 @@ stop(): Promise\ 通过Promise方式停止播放视频。 +**系统能力:** SystemCapability.Multimedia.Media.VideoPlayer + **返回值:** | 类型 | 说明 | @@ -985,6 +964,8 @@ reset(callback: AsyncCallback\): void 通过回调方式切换播放视频。 +**系统能力:** SystemCapability.Multimedia.Media.VideoPlayer + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -1009,6 +990,8 @@ reset(): Promise\ 通过Promise方式切换播放视频。 +**系统能力:** SystemCapability.Multimedia.Media.VideoPlayer + **返回值:** | 类型 | 说明 | @@ -1035,6 +1018,8 @@ seek(timeMs: number, callback: AsyncCallback\): void 通过回调方式跳转到指定播放位置,默认跳转到指定时间点的下一个关键帧。 +**系统能力:** SystemCapability.Multimedia.Media.VideoPlayer + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -1060,6 +1045,8 @@ seek(timeMs: number, mode:SeekMode, callback: AsyncCallback\): void 通过回调方式跳转到指定播放位置。 +**系统能力:** SystemCapability.Multimedia.Media.VideoPlayer + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -1086,6 +1073,8 @@ seek(timeMs: number, mode?:SeekMode): Promise\ 通过Promise方式跳转到指定播放位置,如果没有设置mode则跳转到指定时间点的下一个关键帧。 +**系统能力:** SystemCapability.Multimedia.Media.VideoPlayer + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -1123,6 +1112,8 @@ setVolume(vol: number, callback: AsyncCallback\): void 通过回调方式设置音量。 +**系统能力:** SystemCapability.Multimedia.Media.VideoPlayer + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -1148,6 +1139,8 @@ setVolume(vol: number): Promise\ 通过Promise方式设置音量。 +**系统能力:** SystemCapability.Multimedia.Media.VideoPlayer + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -1180,6 +1173,8 @@ release(callback: AsyncCallback\): void 通过回调方式释放视频资源。 +**系统能力:** SystemCapability.Multimedia.Media.VideoPlayer + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -1204,6 +1199,8 @@ release(): Promise\ 通过Promise方式释放视频资源。 +**系统能力:** SystemCapability.Multimedia.Media.VideoPlayer + **返回值:** | 类型 | 说明 | @@ -1226,10 +1223,12 @@ await videoPlayer.release().then() => { ### getTrackDescription8+ -getTrackDescription(callback: AsyncCallback>)>>): void +getTrackDescription(callback: AsyncCallback>): void 通过回调方式获取视频轨道信息。 +**系统能力:** SystemCapability.Multimedia.Media.VideoPlayer + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -1260,15 +1259,17 @@ videoPlayer.getTrackDescription((error, arrlist) => { ### getTrackDescription8+ -getTrackDescription(): Promise>)>> +getTrackDescription(): Promise> 通过Promise方式获取视频轨道信息。 +**系统能力:** SystemCapability.Multimedia.Media.VideoPlayer + **返回值:** -| 类型 | 说明 | -| -------------------------------------------------------- | ------------------------------- | -| Promise>)>> | 获取视频轨道信息Promise返回值。 | +| 类型 | 说明 | +| ------------------------------------------------------ | ------------------------------- | +| Promise> | 获取视频轨道信息Promise返回值。 | **示例:** @@ -1306,6 +1307,8 @@ setSpeed(speed:number, callback: AsyncCallback\): void 通过回调方式设置播放速度。 +**系统能力:** SystemCapability.Multimedia.Media.VideoPlayer + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -1331,6 +1334,8 @@ setSpeed(speed:number): Promise\ 通过Promise方式设置播放速度。 +**系统能力:** SystemCapability.Multimedia.Media.VideoPlayer + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -1357,6 +1362,8 @@ on(type: 'playbackCompleted', callback: Callback\): void 开始监听视频播放完成事件。 +**系统能力:** SystemCapability.Multimedia.Media.VideoPlayer + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -1378,6 +1385,8 @@ on(type: 'bufferingUpdate', callback: (infoType: BufferingInfoType, value: numbe 开始监听视频缓存更新事件。 +**系统能力:** SystemCapability.Multimedia.Media.VideoPlayer + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -1400,6 +1409,8 @@ on(type: 'startRenderFrame', callback: Callback\): void 开始监听视频播放首帧送显上报事件。 +**系统能力:** SystemCapability.Multimedia.Media.VideoPlayer + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -1421,6 +1432,8 @@ on(type: 'videoSizeChanged', callback: (width: number, height: number) => void): 开始监听视频播放宽高变化事件。 +**系统能力:** SystemCapability.Multimedia.Media.VideoPlayer + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -1443,6 +1456,8 @@ on(type: 'error', callback: ErrorCallback): void 开始监听视频播放错误事件。 +**系统能力:** SystemCapability.Multimedia.Media.VideoPlayer + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -1465,6 +1480,8 @@ videoPlayer.setVolume(3); //设置volume为无效值,触发'error'事件 视频播放的状态机,可通过state属性获取当前状态。 +**系统能力:** 以下各项对应的系统能力均为 SystemCapability.Multimedia.Media.VideoPlayer。 + | 名称 | 类型 | 描述 | | -------- | ------ | -------------- | | idle | string | 视频播放空闲。 | @@ -1478,17 +1495,19 @@ videoPlayer.setVolume(3); //设置volume为无效值,触发'error'事件 视频播放的Seek模式枚举,可通过seek方法作为参数传递下去。 -| 名称 | 值 | 描述 | -| ----------------- | ---- | ------------------------------------------------------------ | -| SEEK_NEXT_SYNC | 0 | 表示跳转到指定时间点的下一个关键帧,建议向后快进的时候用这个枚举值 | -| SEEK_PREV_SYNC | 1 | 表示跳转到指定时间点的上一个关键帧,建议向前快进的时候用这个枚举值 | -| SEEK_CLOSEST_SYNC | 2 | 表示跳转到指定时间点最近的关键帧。 | -| SEEK_CLOSEST | 3 | 表示精确跳转到指定时间点。 | +**系统能力:** 以下各项对应的系统能力均为 SystemCapability.Multimedia.Media.Core。 + +| 名称 | 值 | 描述 | +| -------------- | ---- | ------------------------------------------------------------ | +| SEEK_NEXT_SYNC | 0 | 表示跳转到指定时间点的下一个关键帧,建议向后快进的时候用这个枚举值。 | +| SEEK_PREV_SYNC | 1 | 表示跳转到指定时间点的上一个关键帧,建议向前快进的时候用这个枚举值。 | ## PlaybackSpeed8+ 视频播放的倍速枚举,可通过setSpeed方法作为参数传递下去。 +**系统能力:** 以下各项对应的系统能力均为 SystemCapability.Multimedia.Media.VideoPlayer。 + | 名称 | 值 | 描述 | | -------------------- | ---- | ------------------------------ | | SPEED_FORWARD_0_75_X | 0 | 表示视频播放正常播速的0.75倍。 | @@ -1499,9 +1518,11 @@ videoPlayer.setVolume(3); //设置volume为无效值,触发'error'事件 ## MediaDescription8+ -### [key : string] : any +### [key : string] : Object -通过key-value方式获取媒体信息 +通过key-value方式获取媒体信息。 + +**系统能力:** 以下各项对应的系统能力均为 SystemCapability.Multimedia.Media.Core。 | 名称 | 类型 | 说明 | | ----- | ------ | ------------------------------------------------------------ | @@ -1530,7 +1551,7 @@ audioPlayer.getTrackDescription((error, arrlist) => { ## AudioRecorder -音频录制管理类,用于录制音频媒体。在调用AudioRecorder的方法前,需要先通过[createAudioRecorder()](#media.createaudiorecorder) 或[createAudioRecorderAsync()](#media.createaudiorecorderasync8)构建一个[AudioRecorder](#audiorecorder)实例。 +音频录制管理类,用于录制音频媒体。在调用AudioRecorder的方法前,需要先通过[createAudioRecorder()](#media.createaudiorecorder) 构建一个[AudioRecorder](#audiorecorder)实例。 音频录制demo可参考:[音频录制开发指导](../../media/audio-recorder.md) @@ -1540,6 +1561,10 @@ prepare(config: AudioRecorderConfig): void 录音准备。 +**需要权限:** ohos.permission.MICROPHONE + +**系统能力:** SystemCapability.Multimedia.Media.AudioRecorder + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -1555,7 +1580,7 @@ let audioRecorderConfig = { audioSampleRate : 22050, numberOfChannels : 2, format : media.AudioOutputFormat.AAC_ADTS, - uri : 'file:///data/accounts/account_0/appdata/appdata/recorder/test.m4a', // 文件需先由调用者创建,并给予适当的权限 + uri : 'fd://1', // 文件需先由调用者创建,并给予适当的权限 location : { latitude : 30, longitude : 130}, } audioRecorder.on('prepare', () => { //设置'prepare'事件回调 @@ -1571,6 +1596,8 @@ start(): void 开始录制,需在[prepare](#audiorecorder_on)事件成功触发后,才能调用start方法。 +**系统能力:** SystemCapability.Multimedia.Media.AudioRecorder + **示例:** ```js @@ -1586,6 +1613,8 @@ pause():void 暂停录制,需要在[start](#audiorecorder_on)事件成功触发后,才能调用pause方法。 +**系统能力:** SystemCapability.Multimedia.Media.AudioRecorder + **示例:** ```js @@ -1601,6 +1630,8 @@ resume():void 暂停录制,需要在[pause](#audiorecorder_on)事件成功触发后,才能调用resume方法。 +**系统能力:** SystemCapability.Multimedia.Media.AudioRecorder + **示例:** ```js @@ -1616,6 +1647,8 @@ stop(): void 停止录音。 +**系统能力:** SystemCapability.Multimedia.Media.AudioRecorder + **示例:** ```js @@ -1631,6 +1664,8 @@ release(): void 释放录音资源。 +**系统能力:** SystemCapability.Multimedia.Media.AudioRecorder + **示例:** ```js @@ -1649,6 +1684,8 @@ reset(): void 进行重置录音之前,需要先调用[stop()](#audiorecorder_stop)停止录音。重置录音之后,需要调用[prepare()](#audiorecorder_prepare)设置录音参数项,才能再次进行录音。 +**系统能力:** SystemCapability.Multimedia.Media.AudioRecorder + **示例:** ```js @@ -1664,6 +1701,8 @@ on(type: 'prepare' | 'start' | 'pause' | 'resume' | 'stop' | 'release' | 'reset' 开始订阅音频录制事件。 +**系统能力:** SystemCapability.Multimedia.Media.AudioRecorder + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -1681,7 +1720,7 @@ let audioRecorderConfig = { audioSampleRate : 22050, numberOfChannels : 2, format : media.AudioOutputFormat.AAC_ADTS, - uri : 'file:///data/accounts/account_0/appdata/appdata/recorder/test.m4a', // 文件需先由调用者创建,并给予适当的权限 + uri : 'fd://xx', // 文件需先由调用者创建,并给予适当的权限 location : { latitude : 30, longitude : 130}, } audioRecorder.on('error', (error) => { // 设置'error'事件回调 @@ -1720,6 +1759,8 @@ on(type: 'error', callback: ErrorCallback): void 开始订阅音频录制错误事件。 +**系统能力:** SystemCapability.Multimedia.Media.AudioRecorder + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -1742,6 +1783,8 @@ audioRecorder.prepare(); // prepare不设置参数,触发'error' 表示音频的录音配置。 +**系统能力:** 以下各项对应的系统能力均为 SystemCapability.Multimedia.Media.AudioRecorder。 + | 名称 | 参数类型 | 必填 | 说明 | | --------------------- | --------------------------------------- | ---- | ------------------------------------------------------------ | | audioEncoder | [AudioEncoder](#audioencoder) | 否 | 音频编码格式,默认设置为AAC_LC。 | @@ -1750,52 +1793,60 @@ audioRecorder.prepare(); // prepare不设置参数,触发'error' | numberOfChannels | number | 否 | 音频采集声道数,默认值为2。 | | format | [AudioOutputFormat](#audiooutputformat) | 否 | 音量输出封装格式,默认设置为MPEG_4。 | | location8+ | [Location](#location8) | 否 | 音频采集的地理位置。 | -| uri | string | 是 | 音频输出URI。支持:
1. 文件的绝对路径:file:///data/data/ohos.xxx.xxx/cache/test.mp4![zh-cn_image_0000001164217678](figures/zh-cn_image_0000001164217678.png)
2. 文件的fd路径:file://1 (fd number)
文件需要由调用者创建,并赋予适当的权限。 | +| uri | string | 是 | 视频输出URI:fd://xx (fd number)
![zh-cn_image_0000001164217678](figures/zh-cn_image_url.png)
文件需要由调用者创建,并赋予适当的权限。 | ## AudioEncoder 表示音频编码格式的枚举。 +**系统能力:** 以下各项对应的系统能力均为 SystemCapability.Multimedia.Media.AudioRecorder。 + | 名称 | 默认值 | 说明 | | ------- | ------ | ------------------------------------------------------------ | -| DEFAULT | 0 | Default audio encoding format is AMR_NB。本接口在OpenHarmony 3.1 Release版本仅为接口定义,暂不支持使用。接口将在OpenHarmony 3.1 MR版本中提供使用支持。
**系统能力:**SystemCapability.Multimedia.Media.AudioRecorder | -| AMR_NB | 1 | AMR-NB(Adaptive Multi Rate-Narrow Band Speech Codec) 编码格式。本接口在OpenHarmony 3.1 Release版本仅为接口定义,暂不支持使用。接口将在OpenHarmony 3.1 MR版本中提供使用支持。
**系统能力:**SystemCapability.Multimedia.Media.AudioRecorder | -| AMR_WB | 2 | AMR-WB(Adaptive Multi Rate-Wide Band Speech Codec) 编码格式。本接口在OpenHarmony 3.1 Release版本仅为接口定义,暂不支持使用。接口将在OpenHarmony 3.1 MR版本中提供使用支持。
**系统能力:**SystemCapability.Multimedia.Media.AudioRecorder | -| AAC_LC | 3 | AAC-LC(Advanced Audio Coding Low Complexity)编码格式。
**系统能力:**SystemCapability.Multimedia.Media.AudioRecorder | -| HE_AAC | 4 | HE_AAC(High-Efficiency Advanced Audio Coding)编码格式。本接口在OpenHarmony 3.1 Release版本仅为接口定义,暂不支持使用。接口将在OpenHarmony 3.1 MR版本中提供使用支持。
**系统能力:**SystemCapability.Multimedia.Media.AudioRecorder | +| DEFAULT | 0 | Default audio encoding format is AMR_NB。
本接口在OpenHarmony 3.1 Release版本仅为接口定义,暂不支持使用。接口将在OpenHarmony 3.1 MR版本中提供使用支持。 | +| AMR_NB | 1 | AMR-NB(Adaptive Multi Rate-Narrow Band Speech Codec) 编码格式。
本接口在OpenHarmony 3.1 Release版本仅为接口定义,暂不支持使用。接口将在OpenHarmony 3.1 MR版本中提供使用支持。 | +| AMR_WB | 2 | AMR-WB(Adaptive Multi Rate-Wide Band Speech Codec) 编码格式。
本接口在OpenHarmony 3.1 Release版本仅为接口定义,暂不支持使用。接口将在OpenHarmony 3.1 MR版本中提供使用支持。 | +| AAC_LC | 3 | AAC-LC(Advanced Audio Coding Low Complexity)编码格式。 | +| HE_AAC | 4 | HE_AAC(High-Efficiency Advanced Audio Coding)编码格式。
本接口在OpenHarmony 3.1 Release版本仅为接口定义,暂不支持使用。接口将在OpenHarmony 3.1 MR版本中提供使用支持。 | ## AudioOutputFormat 表示音频封装格式的枚举。 +**系统能力:** 以下各项对应的系统能力均为 SystemCapability.Multimedia.Media.AudioRecorder。 + | 名称 | 默认值 | 说明 | | -------- | ------ | ------------------------------------------------------------ | -| DEFAULT | 0 | 默认封装格式为MPEG-4。本接口在OpenHarmony 3.1 Release版本仅为接口定义,暂不支持使用。接口将在OpenHarmony 3.1 MR版本中提供使用支持。
**系统能力:**SystemCapability.Multimedia.Media.AudioRecorder | -| MPEG_4 | 2 | 封装为MPEG-4格式。
**系统能力:**SystemCapability.Multimedia.Media.AudioRecorder | -| AMR_NB | 3 | 封装为AMR_NB格式。本接口在OpenHarmony 3.1 Release版本仅为接口定义,暂不支持使用。接口将在OpenHarmony 3.1 MR版本中提供使用支持。
**系统能力:**SystemCapability.Multimedia.Media.AudioRecorder | -| AMR_WB | 4 | 封装为AMR_WB格式。本接口在OpenHarmony 3.1 Release版本仅为接口定义,暂不支持使用。接口将在OpenHarmony 3.1 MR版本中提供使用支持。
**系统能力:**SystemCapability.Multimedia.Media.AudioRecorder | -| AAC_ADTS | 6 | 封装为ADTS(Audio Data Transport Stream)格式,是AAC音频的传输流格式。
**系统能力:**SystemCapability.Multimedia.Media.AudioRecorder | +| DEFAULT | 0 | 默认封装格式为MPEG-4。
本接口在OpenHarmony 3.1 Release版本仅为接口定义,暂不支持使用。接口将在OpenHarmony 3.1 MR版本中提供使用支持。 | +| MPEG_4 | 2 | 封装为MPEG-4格式。 | +| AMR_NB | 3 | 封装为AMR_NB格式。
本接口在OpenHarmony 3.1 Release版本仅为接口定义,暂不支持使用。接口将在OpenHarmony 3.1 MR版本中提供使用支持。 | +| AMR_WB | 4 | 封装为AMR_WB格式。
本接口在OpenHarmony 3.1 Release版本仅为接口定义,暂不支持使用。接口将在OpenHarmony 3.1 MR版本中提供使用支持。 | +| AAC_ADTS | 6 | 封装为ADTS(Audio Data Transport Stream)格式,是AAC音频的传输流格式。 | ## VideoRecorder8+ -视频录制管理类,用于录制视频媒体。在调用VideoRecorder的方法前,需要先通过[createVideoRecorderAsync()](#media.createvideorecorderasync8)构建一个[VideoRecorder](#videorecorder8)实例。 +视频录制管理类,用于录制视频媒体。在调用VideoRecorder的方法前,需要先通过[createVideoRecorder()](#media.createvideorecorder8)构建一个[VideoRecorder](#videorecorder8)实例。 视频录制demo可参考:[视频录制开发指导](../../media/video-recorder.md) ### 属性 -| 名称 | 类型 | 可读 | 可写 | 说明 | -| ----- | ------------------------------------- | ---- | ---- | ---------------- | -| state | [VideoRecordState](#videorecordstate) | 是 | 否 | 视频录制的状态。 | +| 名称 | 类型 | 可读 | 可写 | 说明 | +| ------------------ | ------------------------------------- | ---- | ---- | ---------------- | +| state8+ | [VideoRecordState](#videorecordstate) | 是 | 否 | 视频录制的状态。 | -### prepare +### prepare8+ prepare(config: VideoRecorderConfig, callback: AsyncCallback\): void; 异步方式进行视频录制的参数设置。通过注册回调函数获取返回值。 +**需要权限:** ohos.permission.MICROPHONE ohos.permission.CAMERA + +**系统能力:** SystemCapability.Multimedia.Media.VideoRecorder + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -1823,7 +1874,7 @@ let videoConfig = { audioSourceType : 1, videoSourceType : 0, profile : videoProfile, - url : 'file:///data/accounts/account_0/appdata/appdata/recorder/test.mp4', // 文件需先由调用者创建,并给予适当的权限 + url : 'fd://xx', // 文件需先由调用者创建,并给予适当的权限 orientationHint : 0, location : { latitude : 30, longitude : 130 }, } @@ -1854,12 +1905,16 @@ media.createVideoRecorder((err, recorder) => { }); ``` -### prepare +### prepare8+ prepare(config: VideoRecorderConfig): Promise\; 异步方式进行视频录制的参数设置。通过Promise获取返回值。 +**需要权限:** ohos.permission.MICROPHONE ohos.permission.CAMERA + +**系统能力:** SystemCapability.Multimedia.Media.VideoRecorder + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -1892,7 +1947,7 @@ let videoConfig = { audioSourceType : 1, videoSourceType : 0, profile : videoProfile, - url : 'file:///data/accounts/account_0/appdata/appdata/recorder/test.mp4', // 文件需先由调用者创建,并给予适当的权限 + url : 'fd://xx', // 文件需先由调用者创建,并给予适当的权限 orientationHint : 0, location : { latitude : 30, longitude : 130 }, } @@ -1921,7 +1976,7 @@ await videoRecorder.prepare(videoConfig).then(() => { }); ``` -### getInputSurface +### getInputSurface8+ getInputSurface(callback: AsyncCallback\): void; @@ -1931,6 +1986,8 @@ getInputSurface(callback: AsyncCallback\): void; 只能在[prepare()](#videorecorder_prepare1)接口调用后调用。 +**系统能力:** SystemCapability.Multimedia.Media.VideoRecorder + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -1952,7 +2009,7 @@ videoRecorder.getInputSurface((err, surfaceId) => { }); ``` -### getInputSurface +### getInputSurface8+ getInputSurface(): Promise\; @@ -1962,6 +2019,8 @@ getInputSurface(): Promise\; 只能在[prepare()](#videorecorder_prepare1)接口调用后调用。 +**系统能力:** SystemCapability.Multimedia.Media.VideoRecorder + **返回值:** | 类型 | 说明 | @@ -1983,13 +2042,15 @@ await videoRecorder.getInputSurface().then((surfaceId) => { }); ``` -### start +### start8+ start(callback: AsyncCallback\): void; 异步方式开始视频录制。通过注册回调函数获取返回值。 -在[prepare()](#videorecorder_prepare1)和[getInputSurface()](#getinputsurface)后调用,需要依赖数据源先给surface传递数据。 +在[prepare()](#videorecorder_prepare1)和[getInputSurface()](#getinputsurface8)后调用,需要依赖数据源先给surface传递数据。 + +**系统能力:** SystemCapability.Multimedia.Media.VideoRecorder **参数:** @@ -2010,13 +2071,15 @@ videoRecorder.start((err) => { }); ``` -### start +### start8+ start(): Promise\; 异步方式开始视频录制。通过Promise获取返回值。 -在[prepare()](#videorecorder_prepare1)和[getInputSurface()](#getinputsurface)后调用,需要依赖数据源先给surface传递数据。 +在[prepare()](#videorecorder_prepare1)和[getInputSurface()](#getinputsurface8)后调用,需要依赖数据源先给surface传递数据。 + +**系统能力:** SystemCapability.Multimedia.Media.VideoRecorder **返回值:** @@ -2037,7 +2100,7 @@ await videoRecorder.start().then(() => { }); ``` -### pause +### pause8+ pause(callback: AsyncCallback\): void; @@ -2045,6 +2108,8 @@ pause(callback: AsyncCallback\): void; 在[start()](#videorecorder_start1)后调用。可以通过调用[resume()](#videorecorder_resume1)接口来恢复录制。 +**系统能力:** SystemCapability.Multimedia.Media.VideoRecorder + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -2064,7 +2129,7 @@ videoRecorder.pause((err) => { }); ``` -### pause +### pause8+ pause(): Promise\; @@ -2072,6 +2137,8 @@ pause(): Promise\; 在[start()](#videorecorder_start1)后调用。可以通过调用[resume()](#videorecorder_resume1)接口来恢复录制。 +**系统能力:** SystemCapability.Multimedia.Media.VideoRecorder + **返回值:** | 类型 | 说明 | @@ -2091,12 +2158,14 @@ await videoRecorder.pause().then(() => { }); ``` -### resume +### resume8+ resume(callback: AsyncCallback\): void; 异步方式恢复视频录制。通过注册回调函数获取返回值。 +**系统能力:** SystemCapability.Multimedia.Media.VideoRecorder + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -2116,12 +2185,14 @@ videoRecorder.resume((err) => { }); ``` -### resume +### resume8+ resume(): Promise\; 异步方式恢复视频录制。通过Promise获取返回值。 +**系统能力:** SystemCapability.Multimedia.Media.VideoRecorder + **返回值:** | 类型 | 说明 | @@ -2141,13 +2212,15 @@ await videoRecorder.resume().then(() => { }); ``` -### stop +### stop8+ stop(callback: AsyncCallback\): void; 异步方式停止视频录制。通过注册回调函数获取返回值。 -需要重新调用[prepare()](#videorecorder_prepare1)和[getInputSurface()](#getinputsurface)接口才能重新录制。 +需要重新调用[prepare()](#videorecorder_prepare1)和[getInputSurface()](#getinputsurface8)接口才能重新录制。 + +**系统能力:** SystemCapability.Multimedia.Media.VideoRecorder **参数:** @@ -2168,13 +2241,15 @@ videoRecorder.stop((err) => { }); ``` -### stop +### stop8+ stop(): Promise\; 异步方式停止视频录制。通过Promise获取返回值。 -需要重新调用[prepare()](#videorecorder_prepare1)和[getInputSurface()](#getinputsurface)接口才能重新录制。 +需要重新调用[prepare()](#videorecorder_prepare1)和[getInputSurface()](#getinputsurface8)接口才能重新录制。 + +**系统能力:** SystemCapability.Multimedia.Media.VideoRecorder **返回值:** @@ -2195,12 +2270,14 @@ await videoRecorder.stop().then(() => { }); ``` -### release +### release8+ release(callback: AsyncCallback\): void; 异步方式释放视频录制资源。通过注册回调函数获取返回值。 +**系统能力:** SystemCapability.Multimedia.Media.VideoRecorder + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -2220,12 +2297,14 @@ videoRecorder.release((err) => { }); ``` -### release +### release8+ release(): Promise\; 异步方式释放视频录制资源。通过Promise获取返回值。 +**系统能力:** SystemCapability.Multimedia.Media.VideoRecorder + **返回值:** | 类型 | 说明 | @@ -2245,13 +2324,15 @@ await videoRecorder.release().then(() => { }); ``` -### reset +### reset8+ reset(callback: AsyncCallback\): void; 异步方式重置视频录制。通过注册回调函数获取返回值。 -需要重新调用[prepare()](#videorecorder_prepare1)和[getInputSurface()](#getinputsurface)接口才能重新录制。 +需要重新调用[prepare()](#videorecorder_prepare1)和[getInputSurface()](#getinputsurface8)接口才能重新录制。 + +**系统能力:** SystemCapability.Multimedia.Media.VideoRecorder **参数:** @@ -2272,13 +2353,15 @@ videoRecorder.reset((err) => { }); ``` -### reset +### reset8+ reset(): Promise\; 异步方式重置视频录制。通过Promise获取返回值。 -需要重新调用[prepare()](#videorecorder_prepare1)和[getInputSurface()](#getinputsurface)接口才能重新录制。 +需要重新调用[prepare()](#videorecorder_prepare1)和[getInputSurface()](#getinputsurface8)接口才能重新录制。 + +**系统能力:** SystemCapability.Multimedia.Media.VideoRecorder **返回值:** @@ -2299,12 +2382,14 @@ await videoRecorder.reset().then(() => { }); ``` -### on('error') +### on('error')8+ on(type: 'error', callback: ErrorCallback): void 开始订阅视频录制错误事件。 +**系统能力:** SystemCapability.Multimedia.Media.VideoRecorder + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -2327,6 +2412,8 @@ videoRecorder.on('error', (error) => { // 设置'error'事件回调 视频录制的状态机。可通过state属性获取当前状态。 +**系统能力:** 以下各项对应的系统能力均为 SystemCapability.Multimedia.Media.VideoRecorder。 + | 名称 | 类型 | 描述 | | -------- | ------ | ---------------------- | | idle | string | 视频录制空闲。 | @@ -2340,6 +2427,8 @@ videoRecorder.on('error', (error) => { // 设置'error'事件回调 表示视频录制的参数设置。 +**系统能力:** 以下各项对应的系统能力均为 SystemCapability.Multimedia.Media.VideoRecorder。 + | 名称 | 参数类型 | 必填 | 说明 | | --------------- | ---------------------------------------------------------- | ---- | ------------------------------------------------------------ | | audioSourceType | [AudioSourceType](#audiosourcetype8+) | 是 | 视频录制的音频源类型。 | @@ -2347,21 +2436,25 @@ videoRecorder.on('error', (error) => { // 设置'error'事件回调 | profile | [VideoRecorderProfile](#videorecorderprofile8+) | 是 | 视频录制的profile。 | | orientationHint | number | 否 | 录制视频的旋转角度。 | | location | [Location](#location8) | 否 | 录制视频的地理位置。 | -| uri | string | 是 | 视频输出URI。支持:
1. 文件的绝对路径:file:///data/data/ohos.xxx.xxx/cache/test.mp4![zh-cn_image_0000001164217678](figures/zh-cn_image_0000001164217678.png)
2. 文件的fd路径:file://1 (fd number)
文件需要由调用者创建,并赋予适当的权限。 | +| url | string | 是 | 视频输出URL:fd://xx (fd number)
![zh-cn_image_0000001164217678](figures/zh-cn_image_url.png)
文件需要由调用者创建,并赋予适当的权限。 | ## AudioSourceType8+ 表示视频录制中音频源类型的枚举。 -| 名称 | 值 | 说明 | -| -------------------------- | ---- | ---------------------- | -| AUDIO_SOURCE_TYPE_DEFAULT0 | 0 | 默认的音频输入源类型。 | -| AUDIO_SOURCE_TYPE_MIC | 1 | 表示MIC的音频输入源。 | +**系统能力:** 以下各项对应的系统能力均为 SystemCapability.Multimedia.Media.VideoRecorder。 + +| 名称 | 值 | 说明 | +| ------------------------- | ---- | ---------------------- | +| AUDIO_SOURCE_TYPE_DEFAULT | 0 | 默认的音频输入源类型。 | +| AUDIO_SOURCE_TYPE_MIC | 1 | 表示MIC的音频输入源。 | ## VideoSourceType8+ 表示视频录制中视频源类型的枚举。 +**系统能力:** 以下各项对应的系统能力均为 SystemCapability.Multimedia.Media.VideoRecorder。 + | 名称 | 值 | 说明 | | ----------------------------- | ---- | ------------------------------- | | VIDEO_SOURCE_TYPE_SURFACE_YUV | 0 | 输入surface中携带的是raw data。 | @@ -2371,6 +2464,8 @@ videoRecorder.on('error', (error) => { // 设置'error'事件回调 视频录制的配置文件。 +**系统能力:** 以下各项对应的系统能力均为 SystemCapability.Multimedia.Media.VideoRecorder。 + | 名称 | 参数类型 | 必填 | 说明 | | ---------------- | -------------------------------------------- | ---- | ---------------- | | audioBitrate | number | 是 | 音频编码比特率。 | @@ -2386,6 +2481,8 @@ videoRecorder.on('error', (error) => { // 设置'error'事件回调 表示容器格式类型的枚举,缩写为CFT。 +**系统能力:** 以下各项对应的系统能力均为 SystemCapability.Multimedia.Media.Core。 + | 名称 | 值 | 说明 | | ----------- | ----- | --------------------- | | CFT_MPEG_4 | "mp4" | 视频的容器格式,MP4。 | @@ -2395,6 +2492,8 @@ videoRecorder.on('error', (error) => { // 设置'error'事件回调 视频录制的地理位置。 +**系统能力:** 以下各项对应的系统能力均为 SystemCapability.Multimedia.Media.Core。 + | 名称 | 参数类型 | 必填 | 说明 | | --------- | -------- | ---- | ---------------- | | latitude | number | 是 | 地理位置的纬度。 | diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-methods-media-query.md b/zh-cn/application-dev/reference/apis/js-apis-mediaquery.md similarity index 100% rename from zh-cn/application-dev/reference/arkui-ts/ts-methods-media-query.md rename to zh-cn/application-dev/reference/apis/js-apis-mediaquery.md diff --git a/zh-cn/application-dev/reference/apis/js-apis-pasteboard.md b/zh-cn/application-dev/reference/apis/js-apis-pasteboard.md index 169bf06fbf0abf04280616413e06f33a643d633e..1cd00410265aa0edcc88b26d4d335c38c5e8944c 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-pasteboard.md +++ b/zh-cn/application-dev/reference/apis/js-apis-pasteboard.md @@ -86,9 +86,9 @@ createWantData(want:Want): PasteData **系统能力**: SystemCapability.Miscservices.Pasteboard - 参数 - | 参数名 | 类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | - | want | [ERROR:Invalid link:zh-cn_topic_0000001153972080.xml#xref16101652152415,link:zh-cn_topic_0000001153498376.xml#section249133711278](zh-cn_topic_0000001153498376.xml#section249133711278) | 是 | 待保存的Want内容。 | + | want | [Want](js-apis-featureAbility.md#want) | 是 | 待保存的Want内容。 | - 返回值 | 类型 | 说明 | @@ -191,9 +191,9 @@ createWantRecord(want:Want): PasteDataRecord **系统能力**: SystemCapability.Miscservices.Pasteboard - 参数 - | 参数名 | 类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | - | want | [ERROR:Invalid link:zh-cn_topic_0000001153972080.xml#xref1929278214,link:zh-cn_topic_0000001153498376.xml#section249133711278](zh-cn_topic_0000001153498376.xml#section249133711278) | 是 | Want类型数据。 | + | want | [Want](js-apis-featureAbility.md#want) | 是 | Want类型数据。 | - 返回值 | 类型 | 说明 | @@ -263,7 +263,7 @@ createUriRecord(uri:string): PasteDataRecord | 名称 | 参数类型 | 可读 | 可写 | 说明 | | -------- | -------- | -------- | -------- | -------- | | htmlText7+ | string | 是 | 否 | HTML文本内容。 | -| want7+ | [ERROR:Invalid link:zh-cn_topic_0000001153972080.xml#xref97376211378,link:zh-cn_topic_0000001153498376.xml#section249133711278](zh-cn_topic_0000001153498376.xml#section249133711278) | 是 | 否 | Want文本内容。 | +| want7+ | [Want](js-apis-featureAbility.md#want) | 是 | 否 | Want文本内容。 | | mimeType7+ | string | 是 | 否 | 数据类型。 | | plainText7+ | string | 是 | 否 | 文本内容。 | | uri7+ | string | 是 | 否 | URI内容。 | @@ -388,9 +388,9 @@ getPrimaryWant(): Want **系统能力**: SystemCapability.Miscservices.Pasteboard - 返回值 - | 类型 | 说明 | + | 类型 | 说明 | | -------- | -------- | - | [ERROR:Invalid link:zh-cn_topic_0000001153972080.xml#xref731715497254,link:zh-cn_topic_0000001153498376.xml#section249133711278](zh-cn_topic_0000001153498376.xml#section249133711278) | Want对象内容。 | + | [Want](js-apis-featureAbility.md#want) | Want对象内容。 | - 示例 @@ -474,7 +474,7 @@ addHtmlRecord(htmlText: string): void ### addWantRecord7+ -addWantRecord(want: [ERROR:Invalid link:zh-cn_topic_0000001153972080.xml#xref13369155013717,link:zh-cn_topic_0000001153498376.xml#section249133711278](zh-cn_topic_0000001153498376.xml#section249133711278)): void +addWantRecord(want: Want): void 向当前剪贴板内容中添加一条Want条目,并将MIMETYPE_TEXT_INTENT添加到[PasteDataProperty](#pastedataproperty7)的mimeTypes中。入参均不能为空,否则添加失败。 @@ -483,9 +483,9 @@ addWantRecord(want: [ERROR:Invalid link:zh-cn_topic_0000001153972080.xml#xref133 **系统能力**: SystemCapability.Miscservices.Pasteboard - 参数 - | 参数名 | 类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | - | want | [ERROR:Invalid link:zh-cn_topic_0000001153972080.xml#xref179262227253,link:zh-cn_topic_0000001153498376.xml#section249133711278](zh-cn_topic_0000001153498376.xml#section249133711278) | 是 | Want对象内容。 | + | want | [Want](js-apis-featureAbility.md#want) | 是 | Want对象内容。 | - 示例 diff --git a/zh-cn/application-dev/reference/apis/js-apis-request.md b/zh-cn/application-dev/reference/apis/js-apis-request.md index b853b07257218d22fba3b6b2067109942c6b5dc5..4a7f928077f178e713b4b021975780efad122e5f 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-request.md +++ b/zh-cn/application-dev/reference/apis/js-apis-request.md @@ -1,4 +1,4 @@ -# 上传下载(新) +# 上传下载 > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** diff --git a/zh-cn/application-dev/reference/apis/js-apis-system-app.md b/zh-cn/application-dev/reference/apis/js-apis-system-app.md new file mode 100644 index 0000000000000000000000000000000000000000..6ceb384650f9b4c8bd8526fb198bc86788f36474 --- /dev/null +++ b/zh-cn/application-dev/reference/apis/js-apis-system-app.md @@ -0,0 +1,122 @@ +# 应用上下文 + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> - 从API Version 7 开始,该接口不再维护,推荐使用新接口。具体新接口在接口描述中说明。 +> +> - 本模块首批接口从API version 3开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 + + +## 导入模块 + + +``` +import app from '@system.app'; +``` + + +## app.getInfo + +getInfo(): <AppResponse> + +获取当前应用配置文件中声明的信息。 + +**系统能力:** SystemCapability.ArkUI.ArkUI.Lite + +**返回值:** +**表1** AppResponse + +| 参数名 | 类型 | 说明 | +| -------- | -------- | -------- | +| appID6+ | string | 表示应用的包名,用于标识应用的唯一性。 | +| appName | string | 表示应用的名称。 | +| versionName | string | 表示应用的版本名称。 | +| versionCode | number | 表示应用的版本号。 | + +**示例:** + + ``` + export default { + getInfo(){ + var info = app.getInfo(); + console.log(JSON.stringify(info)); + } + } + ``` + +## app.screenOnVisible + +screenOnVisible(Object): void + +应用申请息屏不返回主表盘,再次亮屏依旧显示应用界面。 + +**系统能力:** SystemCapability.ArkUI.ArkUI.Full + +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| visible | boolean | 否 | 是否启动保活,默认值false。 | +| success | Function | 否 | 接口调用成功的回调函数。 | +| fail | Function | 否 | 接口调用失败的回调函数。 | +| complete | Function | 否 | 接口调用结束的回调函数。 | + +**示例:** + + ``` + export default { + screenOnVisible(){ + app.screenOnVisible({ + visible: true, + success() { + console.log('call app.keepVisible success'); + }, + fail(data, code) { + console.log('call app.keepVisible fail'); + }, + }); + } + } + ``` + + +## app.terminate + +terminate(): void + +退出当前Ability。 + +**系统能力:** SystemCapability.ArkUI.ArkUI.Lite + +**示例:** + + ``` + export default { + terminate(){ + app.terminate(); + }} + ``` + +## app.requestFullWindow + +requestFullWindow(duration: number): void + +请求应用以全窗口运行,FA在某些场景下(如半模态FA)会以非全窗口运行,调用该接口会从非全窗口切换为全窗口运行,如果已经以全窗口运行则该接口调用无效。 + +此接口为系统接口,三方应用不支持调用。 + +**系统能力:** SystemCapability.ArkUI.ArkUI.Full + +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| duration | number | 否 | 请求全屏时,设定非全屏到全屏的过渡时间,单位为毫秒,默认时间与非全屏到全屏的距离成正比。 | + +**示例:** + + ``` + export default { + requestFullWindow(){ + app.requestFullWindow({ + duration: 200}); + } + } + ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-system-battery.md b/zh-cn/application-dev/reference/apis/js-apis-system-battery.md new file mode 100644 index 0000000000000000000000000000000000000000..0370a7b99e3d4ca3127f3dcaf2583861da416a58 --- /dev/null +++ b/zh-cn/application-dev/reference/apis/js-apis-system-battery.md @@ -0,0 +1,55 @@ +# 电量信息 + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> - 从API Version 6开始,该接口不再维护,推荐使用新接口['@ohos.batteryInfo'](js-apis-battery-info.md)。 +> +> - 本模块首批接口从API version 3开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 + + +## 导入模块 + + +``` +import battery from '@system.battery'; +``` + + +## battery.getStatus + +getStatus(Object): void + +获取设备当前的充电状态及剩余电量。 + +**系统能力:** SystemCapability.PowerManager.BatteryManager.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| success | Function | 否 | 接口调用成功的回调函数。 | +| fail | Function | 否 | 接口调用失败的回调函数。 | +| complete | Function | 否 | 接口调用结束的回调函数。 | + +success返回值: + +| 参数名 | 类型 | 说明 | +| -------- | -------- | -------- | +| charging | boolean | 当前电池是否在充电中。 | +| level | number | 当前电池的电量,取值范围:0.00 - 1.00 。 | + +**示例:** + +``` +export default { + getStatus() { + battery.getStatus({ + success: function(data) { + console.log('success get battery level:' + data.level); + }, + fail: function(data, code) { + console.log('fail to get battery level code:' + code + ', data: ' + data); + }, + }); + }, +} +``` \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-system-bluetooth.md b/zh-cn/application-dev/reference/apis/js-apis-system-bluetooth.md new file mode 100644 index 0000000000000000000000000000000000000000..78d6b4aaed60883daa60aeb7f9919a2dfb88b062 --- /dev/null +++ b/zh-cn/application-dev/reference/apis/js-apis-system-bluetooth.md @@ -0,0 +1,175 @@ +# 蓝牙 + + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 本模块首批接口从API version 6开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 + + +## 导入模块 + + +``` +import bluetooth from '@system.bluetooth'; +``` + + +## 权限列表 + +ohos.permission.USE_BLUETOOTH + +ohos.permission.DISCOVER_BLUETOOTH + +ohos.permission.MANAGE_BLUETOOTH + + +## bluetooth.startBLEScan(OBJECT) + +开始搜寻附近的低功耗蓝牙外围设备。此操作比较耗费系统资源,请在搜索并连接到设备后调用[bluetooth.stopBLEScan](#bluetoothstopblescanobject)方法停止搜索。 + +**需要权限:** ohos.permission.DISCOVER_BLUETOOTH、ohos.permission.LOCATION + +**系统能力:** SystemCapability.Communication.Bluetooth.Lite + +**参数:** +**表1** StartBLEScanOptions + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| interval | number | 否 | 上报设备的间隔,单位毫秒,默认值为0。0表示找到新设备立即上报,其他数值根据传入的间隔上报。 | +| success | Function | 否 | 接口调用成功的回调函数。 | +| fail | Function | 否 | 接口调用失败的回调函数。 | +| complete | Function | 否 | 接口调用结束的回调函数。 | + +**示例:** + + ``` + bluetooth.startBLEScan({ + success() { + console.log('call bluetooth.startBLEScan success.'); + }, + fail(code, data) { + console.log('call bluetooth.startBLEScan failed, code: ${code}, data: ${data}.`); + }, + complete() { + console.log('call bluetooth.startBLEScan complete.'); + } + }); + ``` + + +## bluetooth.stopBLEScan(OBJECT) + +停止搜寻附近的低功耗蓝牙外围设备。与[bluetooth.startBLEScan(OBJECT)](#bluetoothstartblescanobject)接口配套使用。 + +**需要权限:** ohos.permission.DISCOVER_BLUETOOTH、ohos.permission.LOCATION + +**系统能力:** SystemCapability.Communication.Bluetooth.Lite + +**参数:** +**表2** StopBLEScanOptions + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| success | Function | 否 | 接口调用成功的回调函数。 | +| fail | Function | 否 | 接口调用失败的回调函数。 | +| complete | Function | 否 | 接口调用结束的回调函数。 | + +**示例:** + + ``` + bluetooth.stopBLEScan({ + success() { + console.log('call bluetooth.stopBLEScan success.'); + }, + fail(data, code) { + console.log(`call bluethooth.stopBLEScan fail, code: ${code}, data: ${data}.`); + }, + complete() { + console.log('call bluethooth.stopBLEScan complete.'); + } + }); + ``` + + +## bluetooth.subscribeBLEFound(OBJECT) + +订阅寻找到新设备。再次调用时,会覆盖前一次调用效果,即仅最后一次调用生效。 + +**需要权限:** ohos.permission.DISCOVER_BLUETOOTH、ohos.permission.LOCATION + +**系统能力:** SystemCapability.Communication.Bluetooth.Lite + +**参数:** +**表3** SubscribeBLEFoundOptions + +| 参数 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| success | Function | 是 | 寻找到新设备上报时调用的回调函数。 | +| fail | Function | 否 | 接口调用失败的回调函数。 | + +**表4** success返回值: + +| 参数名 | 类型 | 说明 | +| -------- | -------- | -------- | +| devices | Array<BluetoothDevice> | 新搜索到的设备列表。 | + +**表5** BluethoothDevice + +| 参数名 | 类型 | 说明 | +| -------- | -------- | -------- | +| addrType | string | 设备地址类型,可能值有:
- public: 公共地址
- random: 随机地址 | +| addr | string | 设备MAC地址。 | +| rssi | number | 设备蓝牙的信号强弱指标。 | +| txpower | string | 广播数据中的txpower字段。 | +| data | hex string | 广播数据(包含广播数据和扫描响应数据),十六进制字符串。 | + +**示例:** + + ``` + bluetooth.startaBLEScan({ + success() { + bluetooth.subscribeBLEFound({ + success(data) { + const [device] = data.devices; + if (!!device) { + bluetooth.stopBLEScan(); + } + } + }); + }, + fail(code, data) { + console.log('Failed to start BLE device scan, code: ${code}, data: ${data}`); + } + }); + ``` + + +## bluetooth.unsubscribeBLEFound() + +解除订阅寻找到新设备。 + +**需要权限:** ohos.permission.DISCOVER_BLUETOOTH、ohos.permission.LOCATION + +**系统能力:** SystemCapability.Communication.Bluetooth.Lite + +**示例:** + + ``` + bluetooth.unsubscribeBLEFound(); + ``` + + +## 常见错误码 + +| 错误码 | 说明 | +| -------- | -------- | +| 1100 | 是否处于已连接状态。 | +| 1101 | 当前蓝牙适配器不可用。 | +| 1102 | 没有找到指定设备。 | +| 1103 | 连接失败。 | +| 1104 | 没有找到指定服务。 | +| 1105 | 没有找到指定特征值。 | +| 1106 | 当前连接已断开。 | +| 1107 | 当前特征值不支持此操作。 | +| 1108 | 其余所有系统上报的异常。 | +| 1109 | 系统版本不支持 BLE。 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-system-brightness.md b/zh-cn/application-dev/reference/apis/js-apis-system-brightness.md new file mode 100644 index 0000000000000000000000000000000000000000..eadac91a5945fcedb9cd37bf9b17746f32b21438 --- /dev/null +++ b/zh-cn/application-dev/reference/apis/js-apis-system-brightness.md @@ -0,0 +1,197 @@ +# 屏幕亮度 + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> - 从API Version 7 开始,该接口不再维护,推荐使用新接口['@ohos.brightness'](js-apis-brightness.md)。 +> +> - 本模块首批接口从API version 3开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 + + +## 导入模块 + + +``` +import brightness from '@system.brightness'; +``` + + +## brightness.getValue + +getValue(Object): void + +获得设备当前的屏幕亮度值。 + +**系统能力:** SystemCapability.PowerManager.DisplayPowerManager + +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| success | Function | 否 | 接口调用成功的回调函数。 | +| fail | Function | 否 | 接口调用失败的回调函数。 | +| complete | Function | 否 | 接口调用结束的回调函数。 | + +success返回值: + +| 参数名 | 类型 | 说明 | +| -------- | -------- | -------- | +| value | number | 屏幕亮度,取值为1-255之间的整数。 | + +**示例:** + + ``` + export default { + getValue() { + brightness.getValue({ + success: function(data){ + console.log('success get brightness value:' + data.value); + }, + fail: function(data, code) { + console.log('get brightness fail, code: ' + code + ', data: ' + data); + }, + }); + }, + } + ``` + + +## brightness.setValue + +setValue(Object): void + +设置设备当前的屏幕亮度值。 + +**系统能力:** SystemCapability.PowerManager.DisplayPowerManager + +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| value | number | 是 | 屏幕亮度,值为1-255之间的整数。
- 如果值小于等于0,系统按1处理。
- 如果值大于255,系统按255处理。
- 如果值为小数,系统将处理为整数。例如设置为8.1,系统按8处理。 | +| success | Function | 否 | 接口调用成功的回调函数。 | +| fail | Function | 否 | 接口调用失败的回调函数。 | +| complete | Function | 否 | 接口调用结束的回调函数。 | + +**示例:** + + ``` + export default { + setValue() { + brightness.setValue({ + value: 100, + success: function(){ + console.log('handling set brightness success.'); + }, + fail: function(data, code){ + console.log('handling set brightness value fail, code:' + code + ', data: ' + data); + }, + }); + }, + } + ``` + + +## brightness.getMode + +getMode(Object): void + +获得当前屏幕亮度模式。 + +**系统能力:** SystemCapability.PowerManager.DisplayPowerManager + +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| success | Function | 否 | 接口调用成功的回调函数。 | +| fail | Function | 否 | 接口调用失败的回调函数。 | +| complete | Function | 否 | 接口调用结束的回调函数。 | + + success返回值: + +| 参数名 | 类型 | 说明 | +| -------- | -------- | -------- | +| mode | number | 值为0或1:
- 0为手动调节屏幕亮度模式
- 1为自动调节屏幕亮度模式 | + +**示例:** + + ``` + export default { + getMode() { + brightness.getMode({ + success: function(data){ + console.log('success get mode:' + data.mode); + }, + fail: function(data, code){ + console.log('handling get mode fail, code:' + code + ', data: ' + data); + }, + }); + }, + } + ``` + + +## brightness.setMode + +setMode(Object): void + +设置设备当前的屏幕亮度模式。 + +**系统能力:** SystemCapability.PowerManager.DisplayPowerManager + +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| mode | number | 是 | 值为0或1
- 0为手动调节屏幕亮度
- 1为自动调节屏幕亮度 | +| success | Function | 否 | 接口调用成功的回调函数。 | +| fail | Function | 否 | 接口调用失败的回调函数。 | +| complete | Function | 否 | 接口调用结束的回调函数。 | + +**示例:** + + ``` + export default { + setMode() { + brightness.setMode({ + mode: 1, + success: function(){ + console.log('handling set mode success.'); + }, + fail: function(data, code){ + console.log('handling set mode fail, code:' + code + ', data: ' + data); + }, + }); + }, + } + ``` + + +## brightness.setKeepScreenOn + +setKeepScreenOn(Object): void + +设置屏幕是否保持常亮状态,开启常亮模式推荐在onShow()阶段调用。 + +**系统能力:** SystemCapability.PowerManager.DisplayPowerManager + +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| keepScreenOn | boolean | 是 | 是否保持屏幕常亮。 | +| success | Function | 否 | 接口调用成功的回调函数。 | +| fail | Function | 否 | 接口调用失败的回调函数。 | +| complete | Function | 否 | 接口调用结束的回调函数。 | + +**示例:** + + ``` + export default { + setKeepScreenOn() { + brightness.setKeepScreenOn({ + keepScreenOn: true, + success: function () { + console.log('handling set keep screen on success.') + }, + fail: function (data, code) { + console.log('handling set keep screen on fail, code:' + code + ', data: ' + data); + }, + }); + }, + } + ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-system-cipher.md b/zh-cn/application-dev/reference/apis/js-apis-system-cipher.md new file mode 100644 index 0000000000000000000000000000000000000000..7d434d3c98c0aee4fc813b56899448136a1ad920 --- /dev/null +++ b/zh-cn/application-dev/reference/apis/js-apis-system-cipher.md @@ -0,0 +1,164 @@ +# 加密算法 + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> +> 本模块首批接口从API version 3开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 + + +## 导入模块 + + +``` +import cipher from '@system.cipher' +``` + + +## cipher.rsa + +rsa(Object): void + +RSA 算法加解密。 + +**系统能力:** SystemCapability.Security.Cipher + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| action | string | 是 | 加密类型,可选项有:
1. encrypt 加密
2. decrypt 解密 | +| text | string | 是 | 待加密或解密的文本内容。待加密的文本内容应该是一段普通文本,长度不能超过 keySize / 8 - 66,其中 keySize 是密钥的长度(例如密钥长度为 1024 时,text 不能超过 62 个字节)。待解密的文本内容应该是经过 base64 编码的一段二进制值。base64 编码使用默认风格。 | +| key | string | 是 | 加密的密钥,RSA的密钥。加密时key为公钥,解密时key为私钥 | +| transformation | string | 否 | RSA算法的填充项,默认为RSA/None/OAEPWithSHA256AndMGF1Padding | +| success | Function | 否 | 接口调用成功的回调函数。 | +| fail | Function | 否 | 接口调用失败的回调函数。 | +| complete | Function | 否 | 接口调用结束的回调函数。 | + +**示例:** + +``` +export default { + rsa() { + cipher.rsa({ + //加密 + action: 'encrypt', + //待加密的文本内容 + text: 'hello', + //base64编码后的加密公钥 + key: + 'MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDc7GR2MrfAoefES+wrs1ns2afT\n' + + 'eJXSfIkEHfPXG9fVFjaws1ho4KcZfsxlA0+SXvc83f2SVGCuzULmM2lxxRCtcUN/\n' + + 'h7SoaYEeluhqFimL2AEjfSwINHCLqObJkcjCfoZpE1JCehPiDOJsyT50Auc08h/4\n' + + 'jHQfanyC1nc62LqUCQIDAQAB', + success: function(data) { + console.log('handling success: ${data.text}'); + }, + fail: function(data, code) { + console.log(`### cipher.rsa encrypt fail ### ${code}: ${data}`); + } + }); + cipher.rsa({ + //解密: + action: 'decrypt', + //待解密的内容,是base64编码后的一段二进制值,解密后是文本内容“hello” + text: + 'CUg3tTxTIdpCfreIxIBdws3uhd5qXLwcrVl3XDnQzZFVHyjVVCDHS16rjopaZ4C5xU2Tc8mSDzt7\n' + + 'gp9vBfSwi7bMtSUvXG18DlncsKJFDkJpS5t0PkpS9YrJXrY80Gpe+ME6+6dN9bjgqMljbitDdBRf\n' + + 'S/ZWNI4Q8Q0suNjNkGU=', + //base64编码后的解密私钥 + key: + 'MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBANzsZHYyt8Ch58RL\n' + + '7CuzWezZp9N4ldJ8iQQd89cb19UWNrCzWGjgpxl+zGUDT5Je9zzd/ZJUYK7NQuYz\n' + + 'aXHFEK1xQ3+HtKhpgR6W6GoWKYvYASN9LAg0cIuo5smRyMJ+hmkTUkJ6E+IM4mzJ\n' + + 'PnQC5zTyH/iMdB9qfILWdzrYupQJAgMBAAECgYEAkibhH0DWR13U0gvYJeD08Lfd\n' + + 'Sw1PMHyquEqIcho9Yv7bF3LOXjOg2EEGPx09mvuwXFgP1Kp1e67XPytr6pQQPzK7\n' + + 'XAPcLPx80R/ZjZs8vNFndDOd1HgD3vSVmYQarNzmKi72tOUWMPevsaFXPHo6Xx3X\n' + + '8x0wYb7XuBsQguRctTECQQD7GWX3JUiyo562iVrpTDPOXsrUxmzCrgz2OZildxMd\n' + + 'Pp/PkyDrx7mEXTpk4K/XnQJ3GpJNi2iDSxDuPSAeJ/aPAkEA4Tw4+1Z43S/xH3C3\n' + + 'nfulYBNyB4si6KEUuC0krcC1pDJ21Gd12efKo5VF8SaJI1ZUQOzguV+dqNsB/JUY\n' + + 'OFfX5wJAB1dKv9r7MR3Peg6x9bggm5vx2h6i914XSuuMJupASM6X5X2rrLj+F3yS\n' + + 'RHi9K1SPyeOg+1tkBtKfABgRZFBOyQJAbuTivUSe73AqTKuHjB4ZF0ubqgEkJ9sf\n' + + 'Q2rekzm9dOFvxjZGPQo1qALX09qATMi1ZN376ukby8ZAnSafLSZ64wJBAM2V37go\n' + + 'Sj44HF76ksRow8gecuQm48NCTGAGTicXg8riKog2GC9y8pMNHAezoR9wXJF7kk+k\n' + + 'lz5cHyoMZ9mcd30=', + success: function(data) { + console.log('handling success: ${data.text}'); + }, + fail: function(data, code) { + console.log(`### cipher.rsa decrypt fail ### ${code}: ${data}`); + }, + }); + } +} +``` + + +## cipher.aes + +aes(Object): void + +AES 算法加解密。 + +**系统能力:** SystemCapability.Security.Cipher + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| action | string | 是 | 加密类型,可选项有:
1. encrypt 加密
2. decrypt 解密 | +| text | string | 是 | 待加密或解密的文本内容。待加密的文本内容应该是一段普通文本。待解密的文本内容应该是经过 base64 编码的一段二进制值。base64 编码使用默认风格 | +| key | string | 是 | 加密或解密使用到的密钥,经过 base64 编码后生成的字符串 | +| transformation | string | 否 | AES算法的加密模式和填充项,默认AES/CBC/PKCS5Padding | +| iv | string | 否 | AES加解密的初始向量,经过base64编码后的字符串,默认值为key值 | +| ivOffset | string | 否 | AES加解密的初始向量偏移,默认值0 | +| ivLen | string | 否 | AES加解密的初始向量字节长度,默认值16 | +| success | Function | 否 | 接口调用成功的回调函数。 | +| fail | Function | 否 | 接口调用失败的回调函数。 | +| complete | Function | 否 | 接口调用结束的回调函数。 | + +**示例:** + +``` +export default { + aes() { + cipher.aes({ + //加密 + action: 'encrypt', + //待加密的文本内容 + text: 'hello', + //base64编码后的密钥 + key: 'NDM5Qjk2UjAzMEE0NzVCRjlFMkQwQkVGOFc1NkM1QkQ=', + transformation: 'AES/CBC/PKCS5Padding', + ivOffset: 0, + ivLen: 16, + success: (data) => { + console.log('handling success: ${data.text}'); + }, + fail: (data, code) => { + console.log(`### cipher.aes encrypt fail ### ${code}: ${data}`); + } + }); + cipher.aes({ + //解密: + action: 'decrypt', + //待解密的内容,是base64编码后的一段二进制值 + text: 'CUg3tTxTIdpCfreIxIBdws3uhd5qXLwcrVl3XDnQzZFVHyjVVCDHS16rjopaZ4C5xU2Tc8mSDzt7\n' + + 'gp9vBfSwi7bMtSUvXG18DlncsKJFDkJpS5t0PkpS9YrJXrY80Gpe+ME6+6dN9bjgqMljbitDdBRf\n' + + 'S/ZWNI4Q8Q0suNjNkGU=', + //base64编码后的密钥 + key: 'NDM5Qjk2UjAzMEE0NzVCRjlFMkQwQkVGOFc1NkM1QkQ=', + transformation: 'AES/CBC/PKCS5Padding', + ivOffset: 0, + ivLen: 16, + success: (data) => { + this.dealTxt = data.text; + }, + fail: (data, code) => { + prompt.showToast({ + message: (`### cipher.aes decrypt fail ### code = ${code}: ${data}`) + }) + }, + }); + } +} + +``` \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-system-configuration.md b/zh-cn/application-dev/reference/apis/js-apis-system-configuration.md new file mode 100644 index 0000000000000000000000000000000000000000..d7543663552ae46b61a584e939b6a426253e5795 --- /dev/null +++ b/zh-cn/application-dev/reference/apis/js-apis-system-configuration.md @@ -0,0 +1,45 @@ +# 应用配置 + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> - 从API Version 7 开始,该接口不再维护,推荐使用新接口['@ohos.i18n'](js-apis-i18n.md)和['@ohos.intl'](js-apis-intl.md)。 +> +> +> - 本模块首批接口从API version 3开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 + + +## 导入模块 + + +``` +import configuration from '@system.configuration'; +``` + + +## configuration.getLocale + +getLocale(): <LocaleResponse> + +获取应用当前的语言和地区。默认与系统的语言和地区同步。 + +**系统能力:** SystemCapability.ArkUI.ArkUI.Lite + +**返回值:** +**表1** LocaleResponse + +| 参数名 | 类型 | 说明 | +| -------- | -------- | -------- | +| language | string | 语言。例如:zh。 | +| countryOrRegion | string | 国家或地区。例如:CN。 | +| dir | string | 文字布局方向。取值范围:
- ltr:从左到右;
- rtl:从右到左。 | +| unicodeSetting5+ | string | 语言环境定义的Unicode语言环境键集,如果此语言环境没有特定键集,则返回空集。
例如:{"nu":"arab"},表示当前环境下的数字采用阿拉伯语的数字。 | + +**示例:** + +``` +export default { + getLocale() { + const localeInfo = configuration.getLocale(); + console.info(localeInfo.language); + } +} +``` \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-system-deviceinfo.md b/zh-cn/application-dev/reference/apis/js-apis-system-deviceinfo.md new file mode 100644 index 0000000000000000000000000000000000000000..7deaf91a5aff0bb44547b14ed282159dd7a36697 --- /dev/null +++ b/zh-cn/application-dev/reference/apis/js-apis-system-deviceinfo.md @@ -0,0 +1,75 @@ +# 设备信息 + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> - 从API Version 6开始,该接口不再维护,推荐使用新接口['@ohos.deviceInfo'](js-apis-device-info.md)进行设备信息查询。 +> +> - 本模块首批接口从API version 3开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 + + +## 导入模块 + + +``` +import device from '@system.device'; +``` + + +## device.getInfo + +getInfo(Object): void + +获取当前设备的信息。 + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 在首页的onShow生命周期之前不建议调用device.getInfo接口。 + +**系统能力:** SystemCapability.Startup.SysInfo + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| success | Function | 否 | 接口调用成功的回调函数。 | +| fail | Function | 否 | 接口调用失败的回调函数。 | +| complete | Function | 否 | 接口调用结束的回调函数。 | + +success返回值: + +| 参数名 | 类型 | 说明 | +| -------- | -------- | -------- | +| brand | string | 品牌。 | +| manufacturer | string | 生产商。 | +| model | string | 型号。 | +| product | string | 代号。 | +| language4+ | string | 系统语言。 | +| region4+ | string | 系统地区。 | +| windowWidth | number | 可使用的窗口宽度。 | +| windowHeight | number | 可使用的窗口高度。 | +| screenDensity4+ | number | 屏幕密度。 | +| screenShape4+ | string | 屏幕形状。可取值:
- rect:方形屏;
- circle:圆形屏。 | +| apiVersion4+ | number | 系统API版本号。 | +| releaseType4+ | string | 版本发布类型,值为类型+版本号,如Beta1。
类型可能值有:
- Canary:同一apiVersion下,canary版本之间保持API兼容,beta版本不对canary版本兼容。
- Beta:同一apiVersion下,beta版本之间保持API兼容,release版本不对beta版本兼容。
- Release:release版本会保持5个API版本兼容。 | +| deviceType4+ | string | 设备类型,可能值有:
- phone:智能手机
- tablet:平板
- tv:智慧屏
- wearable:智能穿戴
- liteWearable:轻量级智能穿戴
- ar:增强现实
- vr:虚拟现实
- earphones:耳机
- pc:个人计算机
- speaker:音箱
- smartVision:智能视觉设备
- linkIoT:联接类模组 | + +fail返回错误代码: + +| 错误码 | 说明 | +| -------- | -------- | +| 200 | 返回结果中存在无法获得的信息。 | + +**示例:** + +``` +export default { + getInfo() { + device.getInfo({ + success: function(data) { + console.log('Device information obtained successfully. Device brand:' + data.brand); + }, + fail: function(data, code) { + console.log('Failed to obtain device information. Error code:'+ code + '; Error information: ' + data); + }, + }); + }, +} +``` \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-system-fetch.md b/zh-cn/application-dev/reference/apis/js-apis-system-fetch.md new file mode 100644 index 0000000000000000000000000000000000000000..678ead5ffacc1f0d304197f0256f4ca5e80ff671 --- /dev/null +++ b/zh-cn/application-dev/reference/apis/js-apis-system-fetch.md @@ -0,0 +1,104 @@ +# 数据请求 + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> - 从API Version 6开始,该接口不再维护,推荐使用新接口['@ohos.net.http'](js-apis-http.md)。 +> +> - 本模块首批接口从API version 3开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 + + +## 导入模块 + + +``` +import fetch from '@system.fetch'; +``` + + +## fetch.fetch + +fetch(Object): void + +通过网络获取数据。 + +**需要权限:** ohos.permission.INTERNET + +**系统能力:** SystemCapability.Communication.NetStack + +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| url | string | 是 | 资源地址。 | +| data | string \| Object | 否 | 请求的参数,可选类型是字符串或者json对象。详见表 data与Content-Type关系。 | +| header | Object | 否 | 设置请求的header。 | +| method | string | 否 | 请求方法默认为GET,可选值为:OPTIONS、GET、HEAD、POST、PUT、DELETE、TRACE。 | +| responseType | string | 否 | 默认会根据服务器返回header中的Content-Type确定返回类型,支持文本和json格式。详见success返回值。 | +| success | Function | 否 | 接口调用成功的回调函数。 | +| fail | Function | 否 | 接口调用失败的回调函数。 | +| complete | Function | 否 | 接口调用结束的回调函数。 | + +**表1** data与Content-Type关系 + +| data | Content-Type | 说明 | +| -------- | -------- | -------- | +| string | 不设置 | Content-Type默认为 text/plain,data值作为请求的body。 | +| string | 任意 Type | data值作为请求的body。 | +| Object | 不设置 | Content-Type默认为application/x-www-form-urlencoded,data按照资源地址规则进行encode拼接作为请求的body。 | +| Object | application/x-www-form-urlencoded | data按照资源地址规则进行encode拼接作为请求的body。 | + +success返回值: + +| 参数名 | 类型 | 说明 | +| -------- | -------- | -------- | +| code | number | 表示服务器的状态code。 | +| data | string \| Object | 返回数据类型由responseType确定,详见表 responseType与success中data关系。 | +| headers | Object | 表示服务器response的所有header。 | + +**表2** responseType与success中data关系 + +| responseType | data | 说明 | +| -------- | -------- | -------- | +| 无 | string | 服务器返回的header中的type如果是text/\*或application/json、application/javascript、application/xml,值为文本内容。 | +| text | string | 返回文本内容。 | +| json | Object | 返回json格式的对象。 | + +**示例:** + +``` +export default { + data: { + responseData: 'NA', + url: "test_url", + }, + fetch: function () { + var that = this; + fetch.fetch({ + url: that.url, + success: function(response) { + console.info("fetch success"); + that.responseData = JSON.stringify(response); + }, + fail: function() { + console.info("fetch fail"); + } + }); + } +} +``` + + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 默认支持https,如果要支持http,需要在config.json里增加network标签,属性标识 "cleartextTraffic": true。即: +> +> ``` +> { +> "deviceConfig": { +> "default": { +> "network": { +> "cleartextTraffic": true +> } +> ... +> } +> } +> ... +> } +> ``` \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-system-file.md b/zh-cn/application-dev/reference/apis/js-apis-system-file.md new file mode 100644 index 0000000000000000000000000000000000000000..f43e669498d9835069440988fa646b8560a4d7f2 --- /dev/null +++ b/zh-cn/application-dev/reference/apis/js-apis-system-file.md @@ -0,0 +1,599 @@ +# 文件存储 + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> - 从API Version 6开始,该接口不再维护,推荐使用新接口['@ohos.fileio'](js-apis-fileio.md)。 +> +> - 本模块首批接口从API version 3开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 + + +## 导入模块 + + +``` +import file from '@system.file'; +``` + + +## file.move + +move(Object): void + +将指定文件移动到其他指定位置。 + +**系统能力:** SystemCapability.FileManagement.File.FileIO + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| srcUri | string | 是 | 要移动的文件的uri。字符串最大长度为128,且不能包含“"\*+,:;<=>?[]\|\x7F”等特殊符号。 | +| dstUri | string | 是 | 文件要移动到的位置的uri。字符串最大长度为128,且不能包含“"\*+,:;<=>?[]\|\x7F”等特殊符号。 | +| success | Function | 否 | 接口调用成功的回调函数,返回文件要移动到的位置的uri。 | +| fail | Function | 否 | 接口调用失败的回调函数。 | +| complete | Function | 否 | 接口调用结束的回调函数。 | + +fail返回错误代码: + +| 错误码 | 说明 | +| -------- | -------- | +| 202 | 出现参数错误。 | +| 300 | 出现I/O错误。 | +| 301 | 文件或目录不存在。 | + +**示例:** + +``` +export default { + move() { + file.move({ + srcUri: 'internal://app/myfiles1', + dstUri: 'internal://app/myfiles2', + success: function(uri) { + console.log('call success callback success'); + }, + fail: function(data, code) { + console.error('call fail callback fail, code: ' + code + ', data: ' + data); + }, + }); + } +} +``` + + +## file.copy + +copy(Object): void + +将指定文件拷贝并存储到指定位置。 + +**系统能力:** SystemCapability.FileManagement.File.FileIO + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| srcUri | string | 是 | 要拷贝的文件的uri。 | +| dstUri | string | 是 | 文件要拷贝到的位置的uri。
不支持用应用资源路径或tmp类型的uri。 | +| success | Function | 否 | 接口调用成功的回调函数,返回文件要拷贝到的位置的uri。 | +| fail | Function | 否 | 接口调用失败的回调函数。 | +| complete | Function | 否 | 接口调用结束的回调函数。 | + +fail返回错误代码: + +| 错误码 | 说明 | +| -------- | -------- | +| 202 | 出现参数错误。 | +| 300 | 出现I/O错误。 | +| 301 | 文件或目录不存在。 | + +**示例:** + +``` +export default { + copy() { + file.copy({ + srcUri: 'internal://app/file.txt', + dstUri: 'internal://app/file_copy.txt', + success: function(uri) { + console.log('call success callback success'); + }, + fail: function(data, code) { + console.error('call fail callback fail, code: ' + code + ', data: ' + data); + }, + }); + } +} +``` + + +## file.list + +list(Object): void + +获取指定路径下全部文件的列表。 + +**系统能力:** SystemCapability.FileManagement.File.FileIO + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| uri | string | 是 | 目录uri。字符串最大长度为128,且不能包含“"\*+,:;<=>?[]\|\x7F”等特殊符号。 | +| success | Function | 否 | 接口调用成功的回调函数。 | +| fail | Function | 否 | 接口调用失败的回调函数。 | +| complete | Function | 否 | 接口调用结束的回调函数。 | + +success返回值: + +| 参数名 | 类型 | 说明 | +| -------- | -------- | -------- | +| fileList | Array<FileInfo> | 获取的文件列表,其中每个文件的信息的格式为:
{
uri:'file1',
lastModifiedTime:1589965924479,
length:10240,
type: 'file'
} | + +**表1** FileInfo + +| 参数名 | 类型 | 说明 | +| -------- | -------- | -------- | +| uri | string | 文件的 uri。 | +| lastModifiedTime | number | 文件上一次保存时的时间戳,显示从1970/01/01 00:00:00 GMT到当前时间的毫秒数。 | +| length | number | 文件的大小,单位为字节。 | +| type | string | 文件的类型,可选值为:
- dir:目录;
- file:文件。 | + +fail返回错误代码: + +| 错误码 | 说明 | +| -------- | -------- | +| 202 | 出现参数错误。 | +| 300 | 出现I/O错误。 | +| 301 | 文件或目录不存在。 | + +**示例:** + +``` +export default { + list() { + file.list({ + uri: 'internal://app/pic', + success: function(data) { + console.log(data.fileList); + }, + fail: function(data, code) { + console.error('call fail callback fail, code: ' + code + ', data: ' + data); + }, + }); + } +} +``` + + +## file.get + +get(Object): void + +获取指定本地文件的信息。 + +**系统能力:** SystemCapability.FileManagement.File.FileIO + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| uri | string | 是 | 文件的uri。 | +| recursive | boolean | 否 | 是否进行递归获取子目录文件列表,缺省为false。 | +| success | Function | 否 | 接口调用成功的回调函数。 | +| fail | Function | 否 | 接口调用失败的回调函数。 | +| complete | Function | 否 | 接口调用结束的回调函数。 | + +success返回值: + +| 参数名 | 类型 | 说明 | +| -------- | -------- | -------- | +| uri | string | 文件的uri。 | +| length | number | 文件字节长。 | +| lastModifiedTime | number | 文件保存时的时间戳,从1970/01/01 00:00:00到当前时间的毫秒数。 | +| type | string | 文件类型,可选值为:
- dir:目录;
- file:文件。 | +| subFiles | Array | 文件列表。 | + +fail返回错误代码: + +| 错误码 | 说明 | +| -------- | -------- | +| 202 | 出现参数错误。 | +| 300 | 出现I/O错误。 | +| 301 | 文件或目录不存在。 | + +**示例:** + +``` +export default { + get() { + file.get({ + uri: 'internal://app/file', + success: function(data) { + console.log(data.uri); + }, + fail: function(data, code) { + console.error('call fail callback fail, code: ' + code + ', data: ' + data); + }, + }); + } +} +``` + + +## file.delete + +delete(Object): void + +删除本地文件。 + +**系统能力:** SystemCapability.FileManagement.File.FileIO + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| uri | string | 是 | 删除文件的uri,不能是应用资源路径。 | +| success | Function | 否 | 接口调用成功的回调函数。 | +| fail | Function | 否 | 接口调用失败的回调函数。 | +| complete | Function | 否 | 接口调用结束的回调函数。 | + +fail返回错误代码: + +| 错误码 | 说明 | +| -------- | -------- | +| 202 | 参数错误。 | +| 300 | I/O错误。 | +| 301 | 文件或目录不存在。 | + +**示例:** + +``` +export default { + delete() { + file.delete({ + uri: 'internal://app/my_file', + success: function() { + console.log('call delete success.'); + }, + fail: function(data, code) { + console.error('call fail callback fail, code: ' + code + ', data: ' + data); + }, + }); + } +} +``` + + +## file.writeText + +writeText(Object): void + +写文本内容到指定文件。仅支持文本文档读写。 + +**系统能力:** SystemCapability.FileManagement.File.FileIO + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| uri | string | 是 | 本地文件uri,如果文件不存在会创建文件。 | +| text | string | 是 | 写入的字符串。 | +| encoding | string | 否 | 编码格式,默认为UTF-8。 | +| append | boolean | 否 | 是否追加模式,默认为false。 | +| success | Function | 否 | 接口调用成功的回调函数。 | +| fail | Function | 否 | 接口调用失败的回调函数。 | +| complete | Function | 否 | 接口调用结束的回调函数。 | + +fail返回错误代码: + +| 错误码 | 说明 | +| -------- | -------- | +| 202 | 参数错误。 | +| 300 | I/O错误。 | + +**示例:** + +``` +export default { + writeText() { + file.writeText({ + uri: 'internal://app/test.txt', + text: 'Text that just for test.', + success: function() { + console.log('call writeText success.'); + }, + fail: function(data, code) { + console.error('call fail callback fail, code: ' + code + ', data: ' + data); + }, + }); + } +} +``` + + +## file.writeArrayBuffer + +writeArrayBuffer(Object): void + +写Buffer内容到指定文件。仅支持文本文档读写。 + +**系统能力:** SystemCapability.FileManagement.File.FileIO + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| uri | string | 是 | 本地文件uri,如果文件不存在会创建文件。 | +| buffer | Uint8Array | 是 | 写入的Buffer。 | +| position | number | 否 | 文件开始写入数据的位置的偏移量,默认为0。 | +| append | boolean | 否 | 是否追加模式,默认为false。当设置为true时,position参数无效。 | +| success | Function | 否 | 接口调用成功的回调函数。 | +| fail | Function | 否 | 接口调用失败的回调函数。 | +| complete | Function | 否 | 接口调用结束的回调函数。 | + +fail返回错误代码: + +| 错误码 | 说明 | +| -------- | -------- | +| 202 | 出现参数错误。 | +| 300 | 出现I/O错误。 | + +**示例:** + +``` +export default { + writeArrayBuffer() { + file.writeArrayBuffer({ + uri: 'internal://app/test', + buffer: new Uint8Array(8), //buffer为Uint8Array类型 + success: function() { + console.log('call writeArrayBuffer success.'); + }, + fail: function(data, code) { + console.error('call fail callback fail, code: ' + code + ', data: ' + data); + }, + }); + } +} +``` + + +## file.readText + +readText(Object): void + +从指定文件中读取文本内容。仅支持文本文档读写。 + +**系统能力:** SystemCapability.FileManagement.File.FileIO + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| uri | string | 是 | 本地文件uri。 | +| encoding | string | 否 | 编码格式,缺省为UTF-8。 | +| position | number | 否 | 读取的起始位置,默认值为文件的起始位置。 | +| length | number | 否 | 读取的长度,默认值为4096。 | +| success | Function | 否 | 接口调用成功的回调函数。 | +| fail | Function | 否 | 接口调用失败的回调函数。 | +| complete | Function | 否 | 接口调用结束的回调函数。 | + +success返回值: + +| 参数名 | 类型 | 说明 | +| -------- | -------- | -------- | +| text | string | 读取到的文本内容。 | + +fail返回错误代码: + +| 错误码 | 说明 | +| -------- | -------- | +| 202 | 出现参数错误。 | +| 300 | 出现I/O错误。 | +| 301 | 文件或目录不存在。 | +| 302 | 要读取的文件内容超过4KB。 | + +**示例:** + +``` +export default { + readText() { + file.readText({ + uri: 'internal://app/text.txt', + success: function(data) { + console.log('call readText success: ' + data.text); + }, + fail: function(data, code) { + console.error('call fail callback fail, code: ' + code + ', data: ' + data); + }, + }); + } +} +``` + + +## file.readArrayBuffer + +readArrayBuffer(Object): void + +从指定文件中读取Buffer内容。仅支持文本文档读写。 + +**系统能力:** SystemCapability.FileManagement.File.FileIO + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| uri | string | 是 | 本地文件uri。 | +| position | number | 否 | 读取的起始位置,缺省为文件的起始位置。 | +| length | number | 否 | 需要读取的长度,缺省则读取到文件结尾。 | +| success | Function | 否 | 接口调用成功的回调函数。 | +| fail | Function | 否 | 接口调用失败的回调函数。 | +| complete | Function | 否 | 接口调用结束的回调函数。 | + +success返回值: + +| 参数名 | 类型 | 说明 | +| -------- | -------- | -------- | +| buffer | Uint8Array | 读取到的文件内容。 | + +fail返回错误代码: + +| 错误码 | 说明 | +| -------- | -------- | +| 202 | 出现参数错误。 | +| 300 | 出现I/O错误。 | +| 301 | 文件或目录不存在。 | + +**示例:** + +``` +export default { + readArrayBuffer() { + file.readArrayBuffer({ + uri: 'internal://app/test', + position: 10, + length: 200, + success: function(data) { + console.log('call readArrayBuffer success: ' + data.buffer); + }, + fail: function(data, code) { + console.error('call fail callback fail, code: ' + code + ', data: ' + data); + }, + }); + } +} +``` + + +## file.access + +access(Object): void + +判断指定文件或目录是否存在。 + +**系统能力:** SystemCapability.FileManagement.File.FileIO + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| uri | string | 是 | 目录或文件uri。 | +| success | Function | 否 | 接口调用成功的回调函数。 | +| fail | Function | 否 | 接口调用失败的回调函数。 | +| complete | Function | 否 | 接口调用结束的回调函数。 | + +fail返回错误代码: + +| 错误码 | 说明 | +| -------- | -------- | +| 202 | 出现参数错误。 | +| 300 | 出现I/O 错误。 | +| 301 | 文件或目录不存在。 | + +**示例:** + +``` +export default { + access() { + file.access({ + uri: 'internal://app/test', + success: function() { + console.log('call access success.'); + }, + fail: function(data, code) { + console.error('call fail callback fail, code: ' + code + ', data: ' + data); + }, + }); + } +} +``` + + +## file.mkdir + +mkdir(Object): void + +创建指定目录。 + +**系统能力:** SystemCapability.FileManagement.File.FileIO + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| uri | string | 是 | 目录的uri路径。 | +| recursive | boolean | 否 | 是否递归创建该目录的上级目录,缺省为false。 | +| success | Function | 否 | 接口调用成功的回调函数。 | +| fail | Function | 否 | 接口调用失败的回调函数。 | +| complete | Function | 否 | 接口调用结束的回调函数。 | + +fail返回错误代码: + +| 错误码 | 说明 | +| -------- | -------- | +| 202 | 出现参数错误。 | +| 300 | 出现I/O 错误。 | + +**示例:** + +``` +export default { + mkdir() { + file.mkdir({ + uri: 'internal://app/test_directory', + success: function() { + console.log('call mkdir success.'); + }, + fail: function(data, code) { + console.error('call fail callback fail, code: ' + code + ', data: ' + data); + }, + }); + } +} +``` + + +## file.rmdir + +rmdir(Object): void + +删除指定目录。 + +**系统能力:** SystemCapability.FileManagement.File.FileIO + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| uri | string | 是 | 目录的uri路径。 | +| recursive | boolean | 否 | 是否递归删除子文件和子目录,缺省为false。 | +| success | Function | 否 | 接口调用成功的回调函数。 | +| fail | Function | 否 | 接口调用失败的回调函数。 | +| complete | Function | 否 | 接口调用结束的回调函数。 | + +fail返回错误代码: + +| 错误码 | 说明 | +| -------- | -------- | +| 202 | 出现参数错误。 | +| 300 | 出现I/O 错误。 | +| 301 | 文件或目录不存在。 | + +**示例:** + +``` +export default { + rmdir() { + file.rmdir({ + uri: 'internal://app/test_directory', + success: function() { + console.log('call rmdir success.'); + }, + fail: function(data, code) { + console.error('call fail callback fail, code: ' + code + ', data: ' + data); + }, + }); + } +} +``` \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-system-location.md b/zh-cn/application-dev/reference/apis/js-apis-system-location.md new file mode 100644 index 0000000000000000000000000000000000000000..0c5e8bde4c074f0ad3c43eeb86f53b8cb6286521 --- /dev/null +++ b/zh-cn/application-dev/reference/apis/js-apis-system-location.md @@ -0,0 +1,211 @@ +# 地理位置 + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> - 从API Version 7 开始,该接口不再维护,推荐使用新接口['@ohos.geolocation'](js-apis-geolocation.md)。 +> +> - 本模块首批接口从API version 3开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 + + +## 导入模块 + + +``` +import geolocation from '@system.geolocation'; +``` + + +## 权限列表 + +ohos.permission.LOCATION + + +## geolocation.getLocation + +getLocation(Object): void + +获取设备的地理位置。 + +**系统能力:** SystemCapability.Location.Location.Lite + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| timeout | number | 否 | 超时时间,单位为ms,默认值为30000。
设置超时,是为了防止出现权限被系统拒绝、定位信号弱或者定位设置不当,导致请求阻塞的情况。超时后会使用fail回调函数。
取值范围为32位正整数。如果设置值小于等于0,系统按默认值处理。 | +| coordType | string | 否 | 坐标系的类型,可通过getSupportedCoordTypes获取可选值,缺省值为wgs84。 | +| success | Function | 否 | 接口调用成功的回调函数。 | +| fail | Function | 否 | 接口调用失败的回调函数。 | +| complete | Function | 否 | 接口调用结束的回调函数。 | + +success返回值: + +| 参数名 | 类型 | 说明 | +| -------- | -------- | -------- | +| longitude | number | 设备位置信息:经度。 | +| latitude | number | 设备位置信息:纬度。 | +| altitude | number | 设备位置信息:海拔。 | +| accuracy | number | 设备位置信息:精确度。 | +| time | number | 设备位置信息:时间。 | + +fail返回错误代码: + +| 错误码 | 说明 | +| -------- | -------- | +| 601 | 获取定位权限失败,失败原因:用户拒绝。 | +| 602 | 权限未声明。 | +| 800 | 超时,失败原因:网络状况不佳或GPS不可用。 | +| 801 | 系统位置开关未打开。 | +| 802 | 该次调用结果未返回前接口又被重新调用,该次调用失败返回错误码。 | + +**示例:** + +``` +export default { + getLocation() { + geolocation.getLocation({ + success: function(data) { + console.log('success get location data. latitude:' + data.latitude); + }, + fail: function(data, code) { + console.log('fail to get location. code:' + code + ', data:' + data); + }, + }); + }, +} +``` + + +## geolocation.getLocationType + +getLocationType(Object): void + +获取当前设备支持的定位类型。 + +**系统能力:** SystemCapability.Location.Location.Lite + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| success | Function | 否 | 接口调用成功的回调函数。 | +| fail | Function | 否 | 接口调用失败的回调函数。 | +| complete | Function | 否 | 接口调用结束的回调函数。 | + +success返回值: + +| 参数名 | 类型 | 说明 | +| -------- | -------- | -------- | +| types | Array<string> | 可选的定位类型['gps', 'network']。 | + +**示例:** + +``` +export default { + getLocationType() { + geolocation.getLocationType({ + success: function(data) { + console.log('success get location type:' + data.types[0]); + }, + fail: function(data, code) { + console.log('fail to get location. code:' + code + ', data:' + data); + }, + }); + }, +} +``` + + +## geolocation.subscribe + +subscribe(Object): void + +订阅设备的地理位置信息。多次调用的话,只有最后一次的调用生效。 + +**系统能力:** SystemCapability.Location.Location.Lite + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| coordType | string | 否 | 坐标系的类型,可通过getSupportedCoordTypes获取可选值,默认值为wgs84。 | +| success | Function | 是 | 位置信息发生变化的回调函数。 | +| fail | Function | 否 | 接口调用失败的回调函数。 | + +success返回值: + +| 参数名 | 类型 | 说明 | +| -------- | -------- | -------- | +| longitude | number | 设备位置信息:经度。 | +| latitude | number | 设备位置信息:纬度。 | +| altitude | number | 设备位置信息:海拔。 | +| accuracy | number | 设备位置信息:精确度。 | +| time | number | 设备位置信息:时间。 | + +fail返回错误代码: + +| 错误码 | 说明 | +| -------- | -------- | +| 601 | 获取定位权限失败,失败原因:用户拒绝。 | +| 602 | 权限未声明。 | +| 801 | 系统位置开关未打开。 | + +**示例:** + +``` +export default { + subscribe() { + geolocation.subscribe({ + success: function(data) { + console.log('get location. latitude:' + data.latitude); + }, + fail: function(data, code) { + console.log('fail to get location. code:' + code + ', data:' + data); + }, + }); + }, +} +``` + + +## geolocation.unsubscribe + +unsubscribe(): void + +取消订阅设备的地理位置信息。 + +**系统能力:** SystemCapability.Location.Location.Lite + +**示例:** + +``` +export default { + unsubscribe() { + geolocation.unsubscribe(); + }, +} +``` + + +## geolocation.getSupportedCoordTypes + +getSupportedCoordTypes(): Array<string> + +获取设备支持的坐标系类型。 + +**系统能力:** SystemCapability.Location.Location.Lite + +**返回值:** + +| 类型 | 非空 | 说明 | +| -------- | -------- | -------- | +| Array<string> | 是 | 表示坐标系类型,如[wgs84, gcj02]。 | + +**示例:** + +``` +export default { + getSupportedCoordTypes() { + var types = geolocation.getSupportedCoordTypes(); + }, +} +``` \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-system-mediaquery.md b/zh-cn/application-dev/reference/apis/js-apis-system-mediaquery.md new file mode 100644 index 0000000000000000000000000000000000000000..08ca1c593baa21327cd0ce4bf589c16fe1413025 --- /dev/null +++ b/zh-cn/application-dev/reference/apis/js-apis-system-mediaquery.md @@ -0,0 +1,105 @@ +# 媒体查询 + + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 本模块首批接口从API version 3开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 + + +## 导入模块 + + +``` +import mediaquery from '@system.mediaquery'; +``` + + +## mediaquery.matchMedia + +matchMedia(condition: string): <MediaQueryList> + +根据媒体查询条件,创建MediaQueryList对象。 + +**系统能力:** SystemCapability.ArkUI.ArkUI.Full + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| condition | string | 是 | 用于查询的条件。 | + +**返回值:** +**表1** MediaQueryList + +| 参数名 | 类型 | 说明 | +| -------- | -------- | -------- | +| MediaQueryList | Object | 表示创建MediaQueryList对象的属性,详情见下表 MediaQueryList说明。 | + +**示例:** + +``` +export default { + matchMedia() { + var mMediaQueryList = mediaquery.matchMedia('(max-width: 466)'); + }, +} +``` + + **表2** MediaQueryList说明 + +| 参数名 | 类型 | 说明 | +| -------- | -------- | -------- | +| matches | boolean | 如果查询条件匹配成功则返回true,否则返回值为false。只读。 | +| media | string | 序列化的媒体查询条件,只读。 | +| onchange | Function | matches状态变化时的执行函数。 | + + +## MediaQueryList.addListener + +addListener(Object): void + +给MediaQueryList添加回调函数,回调函数应在onShow生命周期之前添加,即需要在onInit或onReady生命周期里添加。 + +**系统能力:** SystemCapability.ArkUI.ArkUI.Full + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| callback | Function | 是 | 匹配条件发生变化的响应函数。 | + +**示例:** + +``` +export default { + onReady() { + var mMediaQueryList = mediaquery.matchMedia('(max-width: 466)'); + function maxWidthMatch(e) { + if (e.matches) { + // do something + } + } + mMediaQueryList.addListener(maxWidthMatch); + }, +} +``` + + +## MediaQueryList.removeListener + +removeListener(Object): void + +移除MediaQueryList中的回调函数。 + +**系统能力:** SystemCapability.ArkUI.ArkUI.Full + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| callback | Function | 是 | 匹配条件发生变化的响应函数。 | + +**示例:** + +``` +query.removeListener(minWidthMatch); +``` \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-system-network.md b/zh-cn/application-dev/reference/apis/js-apis-system-network.md new file mode 100644 index 0000000000000000000000000000000000000000..fa0b34f7a17543ffc32bbedfb21ac56445a2c113 --- /dev/null +++ b/zh-cn/application-dev/reference/apis/js-apis-system-network.md @@ -0,0 +1,134 @@ +# 网络状态 + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> - 从API Version 7 开始,该接口不再维护,推荐使用新接口['@ohos.telephony.observer'](js-apis-observer.md)。 +> +> - 本模块首批接口从API version 3开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 + + +## 导入模块 + + +``` +import network from '@system.network'; +``` + + +## 权限列表 + +ohos.permission.GET_WIFI_INFO + +ohos.permission.GET_NETWORK_INFO + + +## network.getType + +getType(Object): void + +获取当前设备的网络类型。 + +**系统能力:** SystemCapability.Communication.NetManager.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| success | Function | 否 | 接口调用成功的回调函数。 | +| fail | Function | 否 | 接口调用失败的回调函数。 | +| complete | Function | 否 | 接口调用结束的回调函数。 | + +success返回值: + +| 参数名 | 类型 | 说明 | +| -------- | -------- | -------- | +| metered | boolean | 是否按照流量计费。 | +| type | string | 网络类型,可能的值有2g,3g,4g,5g,wifi,none等。 | + +fail返回值: + +| 错误码 | 说明 | +| -------- | -------- | +| 602 | 当前权限未声明。 | + +**示例:** + +``` +export default { + getType() { + network.getType({ + success: function(data) { + console.log('success get network type:' + data.type); + }, + fail: function(data, code) { + console.log('fail to get network type code:' + code + ', data:' + data); + }, + }); + }, +} +``` + + +## network.subscribe + +subscribe(Object): void + +订阅当前设备的网络连接状态。如果多次调用,会覆盖前一次调用。 + +**系统能力:** SystemCapability.Communication.NetManager.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| success | Function | 否 | 网络发生变化的回调函数。 | +| fail | Function | 否 | 接口调用失败的回调函数。 | + +success返回值: + +| 参数名 | 类型 | 说明 | +| -------- | -------- | -------- | +| metered | boolean | 是否按照流量计费。 | +| type | string | 网络类型,可能的值为2g,3g,4g,5g,wifi,none。 | + +fail返回值: + +| 错误码 | 说明 | +| -------- | -------- | +| 602 | 当前权限未声明。 | +| 200 | 订阅失败。 | + +**示例:** + +``` +export default { + subscribe() { + network.subscribe({ + success: function(data) { + console.log('network type change type:' + data.type); + }, + fail: function(data, code) { + console.log('fail to subscribe network, code:' + code + ', data:' + data); + }, + }); + }, +} +``` + + +## network.unsubscribe + +unsubscribe(): void + +取消订阅设备的网络连接状态。 + +**系统能力:** SystemCapability.Communication.NetManager.Core + +**示例:** + +``` +export default { + unsubscribe() { + network.unsubscribe(); + }, +} +``` \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-system-notification.md b/zh-cn/application-dev/reference/apis/js-apis-system-notification.md new file mode 100644 index 0000000000000000000000000000000000000000..e0fac1ec7e40cf7d7f7256648e9003f05cbefc9a --- /dev/null +++ b/zh-cn/application-dev/reference/apis/js-apis-system-notification.md @@ -0,0 +1,58 @@ +# 通知消息 + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> - 从API Version 7 开始,该接口不再维护,推荐使用新接口['@ohos.notification'](js-apis-notification.md)。 +> +> - 本模块首批接口从API version 3开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 + + +## 导入模块 + + +``` +import notification from '@system.notification'; +``` + + +## notification.show + +show(contentTitle: string, contentText: string, clickAction: ActionInfo): void + +显示通知。 + +**系统能力:** SystemCapability.Notification.Notification + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| contentTitle | string | 否 | 通知标题。 | +| contentText | string | 否 | 通知内容。 | +| clickAction | ActionInfo | 否 | 通知点击后触发的动作。 | + + **表1** ActionInfo + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| bundleName | string | 是 | 点击通知后要跳转到的应用的bundleName | +| abilityName | string | 是 | 点击通知后要跳转到的应用的abilityName | +| uri | string | 是 | 要跳转到的uri,可以是下面的两种格式:
- 页面绝对路径,由配置文件中pages列表提供,例如:
  - pages/index/index
  - pages/detail/detail
- 特殊的,如果uri的值是"/",则跳转到首页。 | + +**示例:** + +``` +export default { + show() { + notification.show({ + contentTitle: 'title info', + contentText: 'text', + clickAction: { + bundleName: 'com.example.testapp', + abilityName: 'notificationDemo', + uri: '/path/to/notification', + }, + }); + }, +} +; +``` \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-system-package.md b/zh-cn/application-dev/reference/apis/js-apis-system-package.md new file mode 100644 index 0000000000000000000000000000000000000000..5572556897c3208026f16fc57c2b8175e67c48e4 --- /dev/null +++ b/zh-cn/application-dev/reference/apis/js-apis-system-package.md @@ -0,0 +1,57 @@ +# 应用管理 + + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 本模块首批接口从API version 3开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 + + +## 导入模块 + + +``` +import pkg from '@system.package'; +``` + + +## package.hasInstalled + +hasInstalled(Object): void + +查询指定应用是否存在,或者原生应用是否安装。 + +**需要权限:** ohos.permission.GET_BUNDLE_INFO + +**系统能力:** SystemCapability.BundleManager.BundleFramework + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| bundleName | string | 是 | 应用包名。 | +| success | Function | 否 | 接口调用成功的回调函数。 | +| fail | Function | 否 | 接口调用失败的回调函数。 | +| complete | Function | 否 | 接口调用结束的回调函数。 | + +success返回值: + +| 参数名 | 类型 | 说明 | +| -------- | -------- | -------- | +| result | boolean | 表示查询的应用是否存在,或者原生应用是否安装。 | + +**示例:** + +``` +export default { + hasInstalled() { + pkg.hasInstalled({ + bundleName: 'com.example.bundlename', + success: function(data) { + console.log('package has installed: ' + data); + }, + fail: function(data, code) { + console.log('query package fail, code: ' + code + ', data: ' + data); + }, + }); + }, +} +``` \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-system-prompt.md b/zh-cn/application-dev/reference/apis/js-apis-system-prompt.md new file mode 100644 index 0000000000000000000000000000000000000000..be6c4bf4cba3de8f1a0ce1b9b87a20fd601d0f42 --- /dev/null +++ b/zh-cn/application-dev/reference/apis/js-apis-system-prompt.md @@ -0,0 +1,144 @@ +# 弹窗 + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 本模块首批接口从API version 3开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 + + +## 导入模块 + + +``` +import prompt from '@system.prompt'; +``` + +## prompt.showToast + +showToast(Object): void + +显示文本弹窗。 + +**系统能力:** SystemCapability.ArkUI.ArkUI.Full + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| message | string | 是 | 显示的文本信息。 | +| duration | number | 否 | 默认值1500ms,建议区间:1500ms-10000ms。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 若小于1500ms则取默认值,最大取值为10000ms。 | +| [bottom]5+ | <length> | 否 | 设置弹窗边框距离屏幕底部的位置。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 仅手机和平板设备支持。 | + +**示例:** + +``` +export default { + showToast() { + prompt.showToast({ + message: 'Message Info', + duration: 2000, + }); + } +} +``` + + +## prompt.showDialog + +showDialog(): void + +在页面内显示对话框。 + +**系统能力:** SystemCapability.ArkUI.ArkUI.Full + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| title | string | 否 | 标题文本。 | +| message | string | 否 | 内容文本。 | +| buttons | Array | 否 | 对话框中按钮的数组,结构为:{text:'button', color: '\#666666'},支持1-3个按钮。其中第一个为positiveButton;第二个为negativeButton;第三个为neutralButton。 | +| success | Function | 否 | 接口调用成功的回调函数,返回值如success返回值所示。 | +| cancel | Function | 否 | 取消调用此接口的回调函数。 | +| complete | Function | 否 | 弹框退出时的回调函数。 | + +success返回值: + +| 参数名 | 类型 | 说明 | +| -------- | -------- | -------- | +| index | number | 选中按钮在buttons数组中的索引。 | + +**示例:** + +``` +export default { + showDialog() { + prompt.showDialog({ + title: 'Title Info', + message: 'Message Info', + buttons: [ + { + text: 'button', + color: '#666666', + }, + ], + success: function(data) { + console.log('dialog success callback,click button : ' + data.index); + }, + cancel: function() { + console.log('dialog cancel callback'); + }, + }); + } +} +``` + +## prompt.showActionMenu6+ + +showActionMenu(Object): void + +显示操作菜单。 + +**系统能力:** SystemCapability.ArkUI.ArkUI.Full + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| title | string | 否 | 标题文本。 | +| buttons | Array | 是 | 对话框中按钮的数组,结构为:{text:'button', color: '\#666666'},支持1-6个按钮。大于6个按钮时弹窗不显示。 | +| success | (data: TapIndex) => void | 否 | 接口调用成功的回调函数。 | +| cancel | () => void | 否 | 接口调用失败的回调函数。 | +| complete | () => void | 否 | 接口调用结束的回调函数。 | + + **表1** TapIndex + +| 参数名 | 类型 | 说明 | +| -------- | -------- | -------- | +| tapIndex | number | 选中按钮在buttons数组中的索引,从0开始。 | + +**示例:** + +``` +export default { + showActionMenu() { + prompt.showActionMenu({ + title: 'Title Info', + buttons: [ + { + text: 'item1', + color: '#666666', + }, + { + text: 'item2', + color: '#000000', + }, + ], + success: function(data) { + console.log('dialog success callback,click button : ' + data.tapIndex); + }, + fail: function(data) { + console.log('dialog fail callback' + data.errMsg); + }, + }); + } +} +``` \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-system-request.md b/zh-cn/application-dev/reference/apis/js-apis-system-request.md new file mode 100644 index 0000000000000000000000000000000000000000..35832ab5a7a476bca68b2394b5e8fbbdc599cee1 --- /dev/null +++ b/zh-cn/application-dev/reference/apis/js-apis-system-request.md @@ -0,0 +1,191 @@ +# 上传下载 + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> - 从API Version 6开始,该接口不再维护,推荐使用新接口['@ohos.request'](https://developer.harmonyos.com/cn/docs/documentation/doc-references/js-apis-request-0000001123753962)。 +> +> - 本模块首批接口从API version 4开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 + + +## 导入模块 + + +``` +import request from '@system.request'; +``` + +## 权限列表 + +ohos.permission.INTERNET。 + + +## request.upload + +upload(Object): void + +上传文件。 + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| url | string | 是 | 上传服务器地址。 | +| header | Object | 否 | 请求头。 | +| method | string | 否 | 请求方法:POST、PUT。缺省POST。 | +| files | Array<File> | 是 | 待上传文件列表。请使用multipart/form-data进行提交。 | +| data | Array<RequestData> | 否 | 请求的表单数据。 | +| success | Function | 否 | 接口调用成功的回调函数。 | +| fail | Function | 否 | 接口调用失败的回调函数。 | +| complete | Function | 否 | 接口调用结束的回调函数。 | + +**表1** File + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| filename | string | 否 | multipart 提交时,请求头中的文件名。 | +| name | string | 否 | multipart 提交时,表单项目的名称,缺省为file。 | +| uri | string | 是 | 文件的本地存储路径。 | +| type | string | 否 | 文件的内容类型,默认根据文件名或路径的后缀获取。 | + +**表2** RequestData + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| name | string | 是 | 表示form 元素的名称。 | +| value | string | 是 | 表示form 元素的值。 | + +success返回值: + +| 参数名 | 类型 | 说明 | +| -------- | -------- | -------- | +| code | number | 服务器返回的HTTP状态码。 | +| data | string | 服务器返回的内容。根据返回头内容中的type决定该值的类型。 | +| headers | Object | 服务器返回的返回头内容。 | + +fail返回值中的data中的code为HTTP状态码。 + +**示例:** + +``` +export default { + upLoad() { + request.upload({ + url: 'http://www.path.com', + files: [ + { + uri: 'internal://cache/path/to/file.txt', + name: 'file', + filename: 'file.txt', + }, + ], + data:[ + { + name: 'name1', + value: 'value', + }, + ], + success: function(data) { + console.log('upload success, code:' + data.code); + }, + fail: function() { + console.log('upload fail'); + }, + }); + } +} +``` + + +## request.download + +download(Object): void + +下载文件。 + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| url | string | 是 | 资源地址。 | +| header | Object | 否 | 请求头。 | +| description | string | 否 | 资源地址的下载描述,默认为文件名称。 | +| filename | string | 否 | 本次下载文件的名称。默认从本次请求或资源地址中获取。 | +| success | Function | 否 | 接口调用成功的回调函数。 | +| fail | Function | 否 | 接口调用失败的回调函数。 | +| complete | Function | 否 | 接口调用结束的回调函数。 | + +success返回值: + +| 参数名 | 类型 | 说明 | +| -------- | -------- | -------- | +| token | string | 表示下载的 token,获取下载状态的依据。 | + +fail返回错误代码: + +| 错误码 | 说明 | +| -------- | -------- | +| 400 | 表示下载任务失败。 | + +**示例:** + +``` +export default { + downLoad() { + request.download({ + url: 'http://www.path.com', + success: function(data) { + console.log('call success callback success: ' + data.token); + }, + fail: function(data, code) { + console.log('handling fail'); + }, + }); + } +} +``` + + +## request.onDownloadComplete + +onDownloadComplete(Object): void + +获取下载任务状态。 + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| token | string | 是 | download 接口返回的结果 token。 | +| success | Function | 否 | 接口调用成功的回调函数。 | +| fail | Function | 否 | 接口调用失败的回调函数。 | +| complete | Function | 否 | 接口调用结束的回调函数。 | + +success返回值: + +| 参数名 | 类型 | 说明 | +| -------- | -------- | -------- | +| uri | string | 表示下载文件的uri。 | + +fail返回错误代码: + +| 错误码 | 说明 | +| -------- | -------- | +| 400 | 表示下载任务失败。 | +| 401 | 表示不存在该下载任务。 | + +**示例:** + +``` +export default { + onDownloadComplete() { + request.onDownloadComplete({ + token: 'token-index', + success: function(data) { + console.log('download success, uri:' + data.uri); + }, + fail: function(data, code) { + console.log('download fail'); + }, + }); + } +} +``` \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-system-router.md b/zh-cn/application-dev/reference/apis/js-apis-system-router.md new file mode 100644 index 0000000000000000000000000000000000000000..a6264dc54e263d4a3f1223736463d624c95d31de --- /dev/null +++ b/zh-cn/application-dev/reference/apis/js-apis-system-router.md @@ -0,0 +1,326 @@ +# 页面路由 + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 本模块首批接口从API version 3开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 + + +## 导入模块 + + +``` +import router from '@system.router'; +``` + +## router.push + +push(Object): void + +跳转到应用内的指定页面。 + +**系统能力:** SystemCapability.ArkUI.ArkUI.Full + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| uri | string | 是 | 表示目标页面的uri,可以用以下两种格式:
- 页面绝对路径,由配置文件中pages列表提供,例如:
  - pages/index/index
  - pages/detail/detail
- 特殊值,如果uri的值是"/",则跳转到首页。 | +| params | Object | 否 | 跳转时要同时传递到目标页面的数据,跳转到目标页面后,参数可以在页面中直接使用,如this.data1(data1为跳转时params参数中的key值)。如果目标页面中已有该字段,则其值会被传入的字段值覆盖。 | + +**示例:** + +``` +// 在当前页面中 +export default { + pushPage() { + router.push({ + uri: 'pages/routerpage2/routerpage2', + params: { + data1: 'message', + data2: { + data3: [123, 456, 789] + }, + }, + }); + } +} +``` + + +``` +// 在routerpage2页面中 +export default { + data: { + data1: 'default', + data2: { + data3: [1, 2, 3] + } + }, + onInit() { + console.info('showData1:' + this.data1); + console.info('showData3:' + this.data2.data3); + } +} +``` + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 页面路由栈支持的最大Page数量为32。 + + +## router.replace + +replace(Object): void + +用应用内的某个页面替换当前页面,并销毁被替换的页面。 + +**系统能力:** SystemCapability.ArkUI.ArkUI.Lite + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| uri | string | 是 | 目标页面的uri,可以是以下的两种格式:
- 页面绝对路径,由配置文件中pages列表提供,例如:
  - pages/index/index
  - pages/detail/detail
- 特殊值,如果uri的值是"/",则跳转到首页。 | +| params | Object | 否 | 跳转时要同时传递到目标页面的数据,跳转到目标页面后,参数可以在页面中直接使用,如this.data1(data1为跳转时params参数中的key值)。如果目标页面中已有该字段,则其值会被传入的字段值覆盖。 | + +**示例:** + +``` +// 在当前页面中 +export default { + replacePage() { + router.replace({ + uri: 'pages/detail/detail', + params: { + data1: 'message', + }, + }); + } +} +``` + + +``` +// 在detail页面中 +export default { + data: { + data1: 'default' + }, + onInit() { + console.info('showData1:' + this.data1) + } +} +``` + +## router.back + +back(Object): void + +返回上一页面或指定的页面。 + +**系统能力:** SystemCapability.ArkUI.ArkUI.Full + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| uri | string | 否 | 返回到指定uri的界面,如果页面栈上没有uri页面,则不响应该情况。如果uri未设置,则返回上一页。 | +| params | Object | 否 | 跳转时要同时传递到目标页面的数据 | + +**示例:** + +``` +// index页面 +export default { + indexPushPage() { + router.push({ + uri: 'pages/detail/detail', + }); + } +} +``` + + +``` +// detail页面 +export default { + detailPushPage() { + router.push({ + uri: 'pages/mall/mall', + }); + } +} +``` + + +``` +// mall页面通过back,将返回detail页面 +export default { + mallBackPage() { + router.back(); + } +} +``` + + +``` +// detail页面通过back,将返回index页面 +export default { + defaultBack() { + router.back(); + } +} +``` + + +``` +// 通过back,返回到detail页面 +export default { + backToDetail() { + router.back({uri:'pages/detail/detail'}); + } +} +``` + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 示例中的uri字段是页面路由,由配置文件中的pages列表指定。 + +## router.clear + +clear(): void + +清空页面栈中的所有历史页面,仅保留当前页面作为栈顶页面。 + +**系统能力:** SystemCapability.ArkUI.ArkUI.Full + +**示例:** + +``` +export default { + clearPage() { + router.clear(); + } +} +``` + +## router.getLength + +getLength(): string + +获取当前在页面栈内的页面数量。 + +**系统能力:** SystemCapability.ArkUI.ArkUI.Full + +**返回值:** + +| 类型 | 说明 | +| -------- | -------- | +| string | 页面数量,页面栈支持最大数值是32。 | + +**示例:** + +``` +export default { + getLength() { + var size = router.getLength(); + console.log('pages stack size = ' + size); + } +} +``` + +## router.getState + +getState(): <RouterState> + +获取当前页面的状态信息。 + +**系统能力:** SystemCapability.ArkUI.ArkUI.Full + +**返回值:** +**表1** RouterState + +| 参数名 | 类型 | 说明 | +| -------- | -------- | -------- | +| index | number | 表示当前页面在页面栈中的索引。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 从栈底到栈顶,index从1开始递增。 | +| name | string | 表示当前页面的名称,即对应文件名。 | +| path | string | 表示当前页面的路径。 | + +**示例:** + +``` +export default { + getState() { + var page = router.getState(); + console.log('current index = ' + page.index); + console.log('current name = ' + page.name); + console.log('current path = ' + page.path); + } +} +``` + +## router.enableAlertBeforeBackPage6+ + +enableAlertBeforeBackPage(Object): void + +开启页面返回询问对话框。 + +**系统能力:** SystemCapability.ArkUI.ArkUI.Full + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| message | string | 是 | 询问对话框内容。 | +| success | () => void | 否 | 接口调用成功的回调函数。 | +| fail | () => void | 否 | 接口调用失败的回调函数。 | +| complete | () => void | 否 | 接口调用结束的回调函数。 | + +**示例:** + +``` +export default { + enableAlertBeforeBackPage() { + router.enableAlertBeforeBackPage({ + message: 'Message Info', + success: function() { + console.log('success'); + }, + fail: function() { + console.log('fail'); + }, + }); + } +} +``` + +## router.disableAlertBeforeBackPage6+ + +disableAlertBeforeBackPage(Object): void + +禁用页面返回询问对话框。 + +**系统能力:** SystemCapability.ArkUI.ArkUI.Full + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| success | () => void | 否 | 接口调用成功的回调函数。 | +| fail | () => void | 否 | 接口调用失败的回调函数。 | +| complete | () => void | 否 | 接口调用结束的回调函数。 | + +**示例:** + +``` +export default { + disableAlertBeforeBackPage() { + router.disableAlertBeforeBackPage({ + success: function() { + console.log('success'); + }, + fail: function() { + console.log('fail'); + }, + }); + } +} +``` + diff --git a/zh-cn/application-dev/reference/apis/js-apis-system-sensor.md b/zh-cn/application-dev/reference/apis/js-apis-system-sensor.md new file mode 100644 index 0000000000000000000000000000000000000000..498ba951ea8b663862f0535392956fa8f02364db --- /dev/null +++ b/zh-cn/application-dev/reference/apis/js-apis-system-sensor.md @@ -0,0 +1,561 @@ +# 传感器 + + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> - 本模块首批接口从API version 4开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 +> - 从API Version 8开始,该接口不再维护,推荐使用新接口[sensor](js-apis-sensor.md)。 +> - 该功能使用需要对应硬件支持,仅支持真机调试。 + + +## 导入模块 + + +``` +import sensor from '@system.sensor'; +``` + + +## 权限列表 + +计步器:ohos.permission.ACTIVITY_MOTION + +心率:ohos.permission.READ_HEALTH_DATA + +加速度:ohos.permission.ACCELEROMETER + +陀螺仪:ohos.permission.GYROSCOPE + + +## 传感器错误码列表 + + | 错误码 | 说明 | +| -------- | -------- | +| 900 | 当前设备不支持相应的传感器。 | + +## sensor.subscribeAccelerometer + +subscribeAccelerometer(Object): void + +观察加速度数据变化。针对同一个应用,多次点击调用时,会覆盖前面的调用效果,即仅最后一次调用生效。 + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| interval | string | 是 | 频率参数,加速度的回调函数执行频率。
默认为normal,可选值有:
- game:极高的回调频率,20ms/次,适用于游戏。
- ui:较高的回调频率,60ms/次,适用于UI更新。
- normal:普通的回调频率,200ms/次,低功耗。 | +| success | Function | 是 | 感应到加速度数据变化后的回调函数。 | +| fail | Function | 否 | 接口调用失败的回调函数。 | + +success返回值: + + | 参数名 | 类型 | 说明 | +| -------- | -------- | -------- | +| x | number | x轴的加速度。 | +| y | number | y轴的加速度。 | +| z | number | z轴的加速度。 | + +**示例:** + +``` +sensor.subscribeAccelerometer({ + interval: 'normal', + success: function(ret) { + console.log('X-axis data: ' + ret.x); + console.log('Y-axis data: ' + ret.y); + console.log('Z-axis data: ' + ret.z); + }, + fail: function(data, code) { + console.error('Subscription failed. Code: ' + code + '; Data: ' + data); + }, +}); +``` + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 建议在页面销毁时,即onDestory回调中,取消数据订阅,避免不必要的性能开销。 + +## sensor.unsubscribeAccelerometer + +unsubscribeAccelerometer(): void + +取消订阅加速度数据。 + +**示例:** + +``` +sensor.unsubscribeAccelerometer(); +``` + +## sensor.subscribeCompass + +subscribeCompass(Object): void + +订阅罗盘数据变化。针对同一个应用,多次点击调用时,会覆盖前面的调用效果,即仅最后一次调用生效。 + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| success | Function | 是 | 罗盘数据改变后触发的回调函数。 | +| fail | Function | 否 | 接口调用失败的回调函数。 | + +success返回值: + + | 参数名 | 类型 | 说明 | +| -------- | -------- | -------- | +| direction | number | 设备面对的方向度数。 | + +**示例:** + +``` +sensor.subscribeCompass({ + success: function(ret) { + console.log('get data direction:' + ret.direction); + }, + fail: function(data, code) { + console.error('Subscription failed. Code: ' + code + '; Data: ' + data); + }, +}); +``` + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 建议在页面销毁时,即onDestory回调中,取消数据订阅,避免不必要的性能开销。 + +## sensor.unsubscribeCompass + +unsubscribeCompass(): void + +取消订阅罗盘。 + +**示例:** + +``` +sensor.unsubscribeCompass(); +``` + +## sensor.subscribeProximity + +subscribeProximity(Object): void + +订阅距离感应数据变化。针对同一个应用,多次点击调用时,会覆盖前面的调用效果,即仅最后一次调用生效。 + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| success | Function | 是 | 距离感应数据改变后调用的回调函数。 | +| fail | Function | 否 | 接口调用失败的回调函数。 | + +success返回值: + + | 参数名 | 类型 | 说明 | +| -------- | -------- | -------- | +| distance | number | 可见物体相对于设备显示屏的接近或远离状态。 | + +**示例:** + +``` +sensor.subscribeProximity({ + success: function(ret) { + console.log('get data distance:' + ret.distance); + }, + fail: function(data, code) { + console.error('Subscription failed. Code: ' + code + '; Data: ' + data); + }, +}); +``` + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 建议在页面销毁时,即onDestory回调中,取消数据订阅,避免不必要的性能开销。 + +## sensor.unsubscribeProximity + +unsubscribeProximity(): void + +取消订阅距离感应。 + +**示例:** + +``` +sensor.unsubscribeProximity(); +``` + +## sensor.subscribeLight + +sensor.subscribeLight(Object): void + +订阅环境光线感应数据变化。再次调用时,会覆盖前一次调用效果,即仅最后一次调用生效。 + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| success | Function | 是 | 光线感应数据改变后的回调函数。 | +| fail | Function | 否 | 接口调用失败的回调函数。 | + +success返回值: + + | 参数名 | 类型 | 说明 | +| -------- | -------- | -------- | +| intensity | number | 光线强度,单位为lux。 | + +**示例:** + +``` +sensor.subscribeLight({ + success: function(ret) { + console.log('get data intensity:' + ret.intensity); + }, + fail: function(data, code) { + console.error('Subscription failed. Code: ' + code + '; Data: ' + data); + }, +}); +``` + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 建议在页面销毁时,即onDestory回调中,取消数据订阅,避免不必要的性能开销。 + +## sensor.unsubscribeLight + +unsubscribeLight(): void + +取消订阅环境光线感应。 + +**示例:** + +``` +sensor.unsubscribeLight(); +``` + +## sensor.subscribeStepCounter + +subscribeStepCounter(Object): void + +订阅计步传感器数据变化。针对同一个应用,多次点击调用时,会覆盖前面的调用效果,即仅最后一次调用生效。 + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| success | Function | 是 | 计步传感器数据改变后的回调函数。 | +| fail | Function | 否 | 接口调用失败的回调函数。 | + +success返回值: + + | 参数名 | 类型 | 说明 | +| -------- | -------- | -------- | +| steps | number | 计步传感器重启后累计记录的步数。
| + +**示例:** + +``` +sensor.subscribeStepCounter({ + success: function(ret) { + console.log('get step value:' + ret.steps); + }, + fail: function(data, code) { + console.log('Subscription failed. Code: ' + code + '; Data: ' + data); + }, +}); +``` + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 建议在页面销毁时,即onDestory回调中,取消数据订阅,避免不必要的性能开销。 + +## sensor.unsubscribeStepCounter + +unsubscribeStepCounter(): void + +取消订阅计步传感器。 + +**示例:** + +``` +sensor.unsubscribeStepCounter(); +``` + + +## sensor.subscribeBarometer + +subcribeBarometer(Object): void + +订阅气压传感器数据变化。针对同一个应用,多次点击调用时,会覆盖前面的调用效果,即仅最后一次调用生效。 + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| success | Function | 是 | 气压传感器数据改变后的回调函数。 | +| fail | Function | 否 | 接口调用失败的回调函数。 | + +success返回值: + + | 参数名 | 类型 | 说明 | +| -------- | -------- | -------- | +| pressure | number | 气压值,单位:帕斯卡。 | + +**示例:** + +``` +sensor.subscribeBarometer({ + success: function(ret) { + console.log('get data value:' + ret.pressure); + }, + fail: function(data, code) { + console.log('Subscription failed. Code: ' + code + '; Data: ' + data); + }, +}); +``` + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 建议在页面销毁时,即onDestory回调中,取消数据订阅,避免不必要的性能开销。 + + +## sensor.unsubscribeBarometer + +unsubscribeBarometer(): void + +取消订阅气压传感器。 + +**示例:** + +``` +sensor.unsubscribeBarometer(); +``` + + +## sensor.subscribeHeartRate + +subscribeHeartRate(Object): void + +订阅心率传感器数据变化。针对同一个应用,多次点击调用时,会覆盖前面的调用效果,即仅最后一次调用生效。 + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| success | Function | 是 | 心率传感器数据改变后的回调函数,默认频率5s/次。 | +| fail | Function | 否 | 接口调用失败的回调函数。 | + +success返回值: + + | 参数名 | 类型 | 说明 | +| -------- | -------- | -------- | +| heartRate | number | 心率值。 | + +**示例:** + +``` +sensor.subscribeHeartRate({ + success: function(ret) { + console.log('get heartrate value:' + ret.heartRate); + }, + fail: function(data, code) { + console.log('Subscription failed. Code: ' + code + '; Data: ' + data); + }, +}); +``` + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 建议在页面销毁时,即onDestory回调中,取消数据订阅,避免不必要的性能开销。 + + +## sensor.unsubscribeHeartRate + +unsubscribeHeartRate(): void + +取消订阅心率。 + +**示例:** + +``` +sensor.unsubscribeHeartRate(); +``` + +## sensor.subscribeOnBodyState + +subscribeOnBodyState(Object): void + +订阅设备佩戴状态。针对同一个应用,多次点击调用时,会覆盖前面的调用效果,即仅最后一次调用生效。 + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| success | Function | 是 | 穿戴状态改变后的回调函数。 | +| fail | Function | 否 | 接口调用失败的回调函数。 | + +success返回值: + + | 参数名 | 类型 | 说明 | +| -------- | -------- | -------- | +| value | boolean | 是否已佩戴。 | + +**示例:** + +``` +sensor.subscribeOnBodyState({ + success: function(ret) { + console.log('get on-body state value:' + ret.value); + }, + fail: function(data, code) { + console.log('Subscription failed. Code: ' + code + '; Data: ' + data); + }, +}); +``` + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 建议在页面销毁时,即onDestory回调中,取消数据订阅,避免不必要的性能开销。 + +## sensor.unsubscribeOnBodyState + +unsubscribeOnBodyState(): void + +取消订阅设备佩戴状态。 + +**示例:** + +``` +sensor.unsubscribeOnBodyState(); +``` + +## sensor.getOnBodyState + +getOnBodyState(Object): void + +获取设备佩戴状态。 + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| success | Function | 否 | 接口调用成功的回调函数。 | +| fail | Function | 否 | 接口调用失败的回调函数。 | +| complete | Function | 否 | 接口调用结束的回调函数。 | + +success返回值: + + | 参数名 | 类型 | 说明 | +| -------- | -------- | -------- | +| value | boolean | 是否已佩戴。 | + +**示例:** + +``` +sensor.getOnBodyState({ + success: function(ret) { + console.log('on body state: ' + ret.value); + }, + fail: function(data, code) { + console.log('Subscription failed. Code: ' + code + '; Data: ' + data); + }, +}); +``` + +## sensor.subscribeDeviceOrientation6+ + +subscribeDeviceOrientation(interval: string, success: (data: DeviceOrientationResponse), fail?: (data: string, code: number)): void + +观察设备方向传感器数据变化。 + +针对同一个应用,多次点击调用时,会覆盖前面的调用效果,即仅最后一次调用生效;针对同一个方法内,不支持多次调用。 + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| interval | string | 是 | 频率参数,设备方向传感器的回调函数执行频率。
默认为normal,可选值有:
- game:极高的回调频率,20ms/次,适用于游戏。
- ui:较高的回调频率,60ms/次,适用于UI更新。
- normal:普通的回调频率,200ms/次,低功耗。 | +| success | Function | 是 | 感应到设备方向传感器数据变化后的回调函数。 | +| fail | Function | 否 | 接口调用失败的回调函数。 | + + success返回值: + | 参数名 | 类型 | 说明 | +| -------- | -------- | -------- | +| alpha | number | 当手机坐标 X/Y 和地球 X/Y 重合时,绕着 Z 轴转动的夹角为 alpha。 | +| beta | number | 当手机坐标 Y/Z 和地球 Y/Z 重合时,绕着 X 轴转动的夹角为 beta。 | +| gamma | number | 当手机 X/Z 和地球 X/Z 重合时,绕着 Y 轴转动的夹角为 gamma。 | + +**示例:** + +``` +sensor.subscribeDeviceOrientation({ + interval: 'normal', + success: function(ret) { + console.log('Alpha data: ' + ret.alpha); + console.log('Beta data: ' + ret.beta); + console.log('Gamma data: ' + ret.gamma); + }, + fail: function(data, code) { + console.error('Subscription failed. Code: ' + code + '; Data: ' + data); + } +}); +``` + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 建议在页面销毁时,即onDestory回调中,取消数据订阅,避免不必要的性能开销。 + +## sensor.unsubscribeDeviceOrientation6+ + +unsubscribeDeviceOrientation(): void + +取消订阅设备方向传感器数据。 + +**示例:** + +``` +sensor.unsubscribeDeviceOrientation(); +``` + +## sensor.subscribeGyroscope6+ + +subscribeGyroscope(interval: string, success: (data: GyroscopeResponse), fail?: (data: string, code: number)): void + +观察陀螺仪数据变化。 + +针对同一个应用,多次点击调用时,会覆盖前面的调用效果,即仅最后一次调用生效;针对同一个方法内,不支持多次调用。 + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| interval | string | 是 | 频率参数,陀螺仪的回调函数执行频率。
默认为normal,可选值有:
- game:极高的回调频率,20ms/次,适用于游戏。
- ui:较高的回调频率,60ms/次,适用于UI更新。
- normal:普通的回调频率,200ms/次,低功耗。 | +| success | Function | 是 | 感应到陀螺仪数据变化后的回调函数。 | +| fail | Function | 否 | 接口调用失败的回调函数。 | + +success返回值: + + | 参数名 | 类型 | 说明 | +| -------- | -------- | -------- | +| x | number | x轴的旋转角速度。 | +| y | number | y轴的旋转角速度。 | +| z | number | z轴的旋转角速度。 | + +**示例:** + +``` +sensor.subscribeGyroscope({ + interval: 'normal', + success: function(ret) { + console.log('X-axis data: ' + ret.x); + console.log('Y-axis data: ' + ret.y); + console.log('Z-axis data: ' + ret.z); + }, + fail: function(data, code) { + console.error('Subscription failed. Code: ' + code + '; data: ' + data); + } +}); +``` + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 建议在页面销毁时,即onDestory回调中,取消数据订阅,避免不必要的性能开销。 + +## sensor.unsubscribeGyroscope6+ + +unsubscribeGyroscope(): void + +取消订阅陀螺仪数据。 + +**示例:** + +``` +sensor.unsubscribeGyroscope(); +``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-system-storage.md b/zh-cn/application-dev/reference/apis/js-apis-system-storage.md new file mode 100644 index 0000000000000000000000000000000000000000..eed952738cdff3a792fe7a86c5f3f94d4f523832 --- /dev/null +++ b/zh-cn/application-dev/reference/apis/js-apis-system-storage.md @@ -0,0 +1,163 @@ +# 数据存储 + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> +> - 从API Version 6开始,该接口不再维护,可以使用接口['@ohos.data.storage'](js-apis-data-storage.md)。在API Version 9后,推荐使用新接口 ['@ohos.data.preferences'](js-apis-data-preferences.md)。 +> +> - 本模块首批接口从API version 3开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 + + +## 导入模块 + + +``` +import storage from '@system.storage'; +``` + + +## storage.get + +get(Object): void + +读取存储的内容。 + +**系统能力:** SystemCapability.DistributedDataManager.Preferences.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| key | string | 是 | 内容索引。 | +| default | string | 否 | key不存在则返回的默认值。 | +| success | Function | 否 | 接口调用成功的回调函数,返回存储的内容。 | +| fail | Function | 否 | 接口调用失败的回调函数。 | +| complete | Function | 否 | 接口调用结束的回调函数。 | + +**示例:** + +``` +export default { + storageGet() { + storage.get({ + key: 'storage_key', + success: function(data) { + console.log('call storage.get success: ' + data); + }, + fail: function(data, code) { + console.log('call storage.get fail, code: ' + code + ', data: ' + data); + }, + complete: function() { + console.log('call complete'); + }, + }); + } +} +``` + + +## storage.set + +set(Object): void + +修改存储的内容。 + +**系统能力:** SystemCapability.DistributedDataManager.Preferences.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| key | string | 是 | 要修改的存储内容的索引。 | +| value | string | 否 | 新值。最大长度128。 | +| success | Function | 否 | 接口调用成功的回调函数。 | +| fail | Function | 否 | 接口调用失败的回调函数。 | +| complete | Function | 否 | 接口调用结束的回调函数。 | + +**示例:** + +``` +export default { + storageSet() { + storage.set({ + key: 'storage_key', + value: 'storage value', + success: function() { + console.log('call storage.set success.'); + }, + fail: function(data, code) { + console.log('call storage.set fail, code: ' + code + ', data: ' + data); + }, + }); + } +} +``` + + +## storage.clear + +clear(Object): void + +清空存储的内容。 + +**系统能力:** SystemCapability.DistributedDataManager.Preferences.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| success | Function | 否 | 接口调用成功的回调函数。 | +| fail | Function | 否 | 接口调用失败的回调函数。 | +| complete | Function | 否 | 接口调用结束的回调函数。 | + +**示例:** + +``` +export default { + storageClear() { + storage.clear({ + success: function() { + console.log('call storage.clear success.'); + }, + fail: function(data, code) { + console.log('call storage.clear fail, code: ' + code + ', data: ' + data); + }, + }); + } +} +``` + + +## storage.delete + +delete(Object): void + +删除存储的内容。 + +**系统能力:** SystemCapability.DistributedDataManager.Preferences.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| key | string | 是 | 内容索引。 | +| success | Function | 否 | 接口调用成功的回调函数。 | +| fail | Function | 否 | 接口调用失败的回调函数。 | +| complete | Function | 否 | 接口调用结束的回调函数。 | + +**示例:** + +``` +export default { + storageDelete() { + storage.delete({ + key: 'Storage1', + success: function() { + console.log('call storage.delete success.'); + }, + fail: function(data, code) { + console.log('call storage.delete fail, code: ' + code + ', data: ' + data); + }, + }); + } +} +``` \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-system-time.md b/zh-cn/application-dev/reference/apis/js-apis-system-time.md index b2389c5b57ddc4471e5c53894b49eb2771fef593..f19a8fb1cfb80abbf91af7a5e1721cc7a7f563f3 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-system-time.md +++ b/zh-cn/application-dev/reference/apis/js-apis-system-time.md @@ -6,7 +6,7 @@ ## 导入模块 - + ``` import systemTime from '@ohos.systemTime'; ``` @@ -29,7 +29,7 @@ setTime(time : number, callback : AsyncCallback<void>) : void | callback | AsyncCallback<void> | 是 | 回调函数,可以在回调函数中处理接口返回值。 | - 示例: - + ``` // time对应的时间为2021-01-20 02:36:25 var time = 1611081385000; @@ -64,7 +64,7 @@ setTime(time : number) : Promise<void> | Promise<void> | 返回的异步回调函数。 | - 示例: - + ``` // time对应的时间为2021-01-20 02:36:25 var time = 1611081385000; @@ -91,7 +91,7 @@ getCurrentTime(isNano?: boolean, callback: AsyncCallback<number>): void | callback | AsyncCallback<number> | 是 | 回调函数,返回自 Unix 纪元以来经过的时间。 | - 示例: - + ``` systemTime.getCurrentTime(true, (error, data) => { if (error) { @@ -122,7 +122,7 @@ getCurrentTime(isNano?: boolean): Promise<number> | Promise<number> | 以Promise形式返回结果,返回自 Unix 纪元以来经过的时间。 | - 示例: - + ``` systemTime.getCurrentTime().then((data) => { console.log(`systemTime.getCurrentTime success data : ` + JSON.stringify(data)); @@ -147,7 +147,7 @@ getRealActiveTime(isNano?: boolean, callback: AsyncCallback<number>): void | callback | AsyncCallback<number> | 是 | 回调函数,返回自系统启动以来但不包括度睡眠时间经过的时间。 | - 示例: - + ``` systemTime.getRealActiveTime(true, (error, data) => { if (error) { @@ -178,7 +178,7 @@ getRealActiveTime(isNano?: boolean): Promise<number> | Promise<number> | 以Promise形式返回结果,返回自系统启动以来但不包括度睡眠时间经过的时间。 | - 示例: - + ``` systemTime.getCurrentTime().then((data) => { console.log(`systemTime.getRealActiveTime success data : ` + JSON.stringify(data)); @@ -203,7 +203,7 @@ getRealTime(callback: AsyncCallback<number>): void | callback | AsyncCallback<number> | 是 | 回调函数,返回自系统启动以来包括深度睡眠时间经过的毫秒数。 | - 示例: - + ``` systemTime.getRealTime(true, (error, data) => { if (error) { @@ -234,7 +234,7 @@ getRealTime(): Promise<number> | Promise<number> | 以Promise形式返回结果,返回自系统启动以来包括深度睡眠时间经过的时间。 | - 示例: - + ``` systemTime.getRealTime().then((data) => { console.log(`systemTime.getRealTime success data: ` + JSON.stringify(data)); @@ -261,7 +261,7 @@ setDate(date: Date, callback: AsyncCallback<void>): void | callback | AsyncCallback<void> | 是 | 回调函数,可以在回调函数中处理接口返回值。 | - 示例: - + ``` var data = new Date("October 13, 2020 11:13:00"); systemTime.setDate(data,(error, data) => { @@ -295,7 +295,7 @@ setDate(date: Date): Promise<void> | Promise<void> | 返回的异步回调函数。 | - 示例: - + ``` var data = new Date("October 13, 2020 11:13:00"); systemTime.setDate(data).then((value) => { @@ -320,7 +320,7 @@ getDate(callback: AsyncCallback<Date>): void | callback | AsyncCallback<Date> | 是 | 回调函数,返回当前系统日期。 | - 示例: - + ``` systemTime.getDate((error, data) => { if (error) { @@ -346,7 +346,7 @@ getDate(): Promise<Date> | Promise<Date> | 以Promise形式返回结果,返回当前系统日期。 | - 示例: - + ``` systemTime.getDate().then((data) => { console.log(`systemTime.getDate success data : ` + JSON.stringify(data)); @@ -373,7 +373,7 @@ setTimezone(timezone: string, callback: AsyncCallback<void>): void | callback | AsyncCallback<void> | 是 | 回调函数,可以在回调函数中处理接口返回值。 | - 示例: - + ``` systemTime.setTimezone('Asia/Shanghai', (error, data) => { if (error) { @@ -406,7 +406,7 @@ setTimezone(timezone: string): Promise<void> | Promise<void> | 返回的异步回调函数。 | - 示例: - + ``` systemTime.setTimezone('Asia/Shanghai').then((data) => { console.log(`systemTime.setTimezone success data : ` + JSON.stringify(data)); @@ -430,7 +430,7 @@ getTimeZone(callback: AsyncCallback<string>): void | callback | AsyncCallback<string> | 是 | 回调函数,返回系统时区。 | - 示例: - + ``` systemTime.getTimeZone((error, data) => { if (error) { @@ -456,7 +456,7 @@ getTimeZone(): Promise<string> | Promise<string> | 以Promise形式返回结果,返回系统时区。 | - 示例: - + ``` systemTime.getDate().then((data) => { console.log(`systemTime.getTimeZone success data : ` + JSON.stringify(data)); diff --git a/zh-cn/application-dev/reference/apis/js-apis-system-vibrate.md b/zh-cn/application-dev/reference/apis/js-apis-system-vibrate.md new file mode 100644 index 0000000000000000000000000000000000000000..b30152d767b1b7216700bd3f11a4811500307512 --- /dev/null +++ b/zh-cn/application-dev/reference/apis/js-apis-system-vibrate.md @@ -0,0 +1,46 @@ +# 振动 + + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> - 本模块首批接口从API version 4开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 +> - 从API Version 8开始,该接口不再维护,推荐使用新接口[vibrator](js-apis-vibrator.md)。 +> - 该功能使用需要对应硬件支持,仅支持真机调试。 + + +## 导入模块 + + +``` +import vibrator from '@system.vibrator'; +``` + + +## vibrator.vibrate + +vibrate(Object): void + +触发设备振动。 + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| mode | string | 否 | 振动的模式,其中long表示长振动,short表示短振动,默认值为long。 | + +**示例:** + +``` +vibrator.vibrate({ + mode: 'short', + success: function(ret) { + console.log('vibrate is successful'); + }, + fail: function(ret) { + console.log('vibrate is failed'); + }, + complete: function(ret) { + console.log('vibrate is completed'); + } +}); +``` + diff --git a/zh-cn/application-dev/reference/apis/js-apis-volumemanager.md b/zh-cn/application-dev/reference/apis/js-apis-volumemanager.md index 55913343e0462c816c5592d07d09cc5b5d78cff5..a11bb17eb929dde989a6f221f364ba9fcbb25e7c 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-volumemanager.md +++ b/zh-cn/application-dev/reference/apis/js-apis-volumemanager.md @@ -174,6 +174,6 @@ unmount(volumeId: string, callback:AsyncCallback<boolean>):void | id9+ | number | 卷id | | uuid9+ | string | 卷uuid | | description9+ | string | 卷相关描述 | -| removable9+ | boolean | 是否为可移动存储设备 | +| removeAble9+ | boolean | 是否为可移动存储设备 | | state9+ | int | 当前卷状态 | | path9+ | string | 卷的挂载地址 | \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-wallpaper.md b/zh-cn/application-dev/reference/apis/js-apis-wallpaper.md index 754db5beae525718482eb88dd5c2950bfcbf8898..212f15f2fe30dbd7c7c6ef209606bf7ec6d2dc0e 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-wallpaper.md +++ b/zh-cn/application-dev/reference/apis/js-apis-wallpaper.md @@ -6,7 +6,7 @@ ## 导入模块 - + ``` import wallpaper from '@ohos.wallpaper'; ``` @@ -39,7 +39,7 @@ getColors(wallpaperType: WallpaperType, callback: AsyncCallback<Array<Rgba | callback | AsyncCallback<Array<[RgbaColor](#rgbacolor)>> | 是 | 回调函数,返回壁纸的主要颜色信息。 | - 示例: - + ``` wallpaper.getColors(wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error, data) => { if (error) { @@ -70,7 +70,7 @@ getColors(wallpaperType: WallpaperType): Promise<Array<RgbaColor>> | Promise<Array<[RgbaColor](#rgbacolor)>> | 返回壁纸的主要颜色信息。 | - 示例: - + ``` wallpaper.getColors(wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => { console.log(`success to getColors.`); @@ -95,7 +95,7 @@ getId(wallpaperType: WallpaperType, callback: AsyncCallback<number>): void | callback | AsyncCallback<number> | 是 | 回调函数,返回壁纸的ID。如果配置了指定类型的壁纸就返回一个大于等于0的数,否则返回-1。取值范围是-1~2^31-1。 | - 示例: - + ``` wallpaper.getId(wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error, data) => { if (error) { @@ -127,7 +127,7 @@ getId(wallpaperType: WallpaperType): Promise<number> | Promise<number> | 壁纸的ID。如果配置了这种壁纸类型的壁纸就返回一个大于等于0的数,否则返回-1。取值范围是-1~2^31-1。 | - 示例: - + ``` wallpaper.getId(wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => { console.log(`success to getId: ` + JSON.stringify(data)); @@ -151,7 +151,7 @@ getMinHeight(callback: AsyncCallback<number>): void | callback | AsyncCallback<number> | 是 | 回调函数,返回壁纸的最小高度值,单位是像素。如果返回值等于0,说明没有设置壁纸,调用者应该使用默认显示的高度值代替。 | - 示例: - + ``` wallpaper.getMinHeight((error, data) => { if (error) { @@ -178,7 +178,7 @@ getMinHeight(): Promise<number> | Promise<number> | 返回壁纸的最小高度值,单位是像素。如果返回值等于0,说明没有设置壁纸,调用者应该使用默认显示的高度值代替。 | - 示例: - + ``` wallpaper.getMinHeight().then((data) => { console.log(`success to getMinHeight: ` + JSON.stringify(data)); @@ -203,7 +203,7 @@ getMinWidth(callback: AsyncCallback<number>): void | callback | AsyncCallback<number> | 是 | 回调函数,壁纸的最小宽度值,单位是像素。如果返回值等于0,说明没有设置壁纸,调用者应该使用默认显示的宽度值代替。 | - 示例: - + ``` wallpaper.getMinWidth((error, data) => { if (error) { @@ -229,7 +229,7 @@ getMinWidth(): Promise<number> | Promise<number> | 壁纸的最小宽度值,单位是像素。如果返回值等于0,说明没有设置壁纸,调用者应该使用默认显示的宽度值代替。 | - 示例: - + ``` wallpaper.getMinWidth().then((data) => { console.log(`success to getMinWidth: ` + JSON.stringify(data)); @@ -253,7 +253,7 @@ isChangePermitted(callback: AsyncCallback<boolean>): void | callback | AsyncCallback<boolean> | 是 | 回调函数,返回是否允许应用改变当前用户的壁纸。如果允许返回true,否则返回false。 | - 示例: - + ``` wallpaper.isChangePermitted((error, data) => { if (error) { @@ -279,7 +279,7 @@ isChangePermitted(): Promise<boolean> | Promise<boolean> | 返回是否允许应用改变当前用户的壁纸。如果允许返回true,否则返回false。 | - 示例: - + ``` wallpaper.isChangePermitted().then((data) => { console.log(`success to isChangePermitted: ` + JSON.stringify(data)); @@ -303,7 +303,7 @@ isOperationAllowed(callback: AsyncCallback<boolean>): void | callback | AsyncCallback<boolean> | 是 | 回调函数,返回是否允许用户设置壁纸。如果允许返回true,否则返回false。 | - 示例: - + ``` wallpaper.isOperationAllowed((error, data) => { if (error) { @@ -329,7 +329,7 @@ isOperationAllowed(): Promise<boolean> | Promise<boolean> | 异步回调函数,返回是否允许用户设置壁纸。如果允许返回true,否则返回false。 | - 示例: - + ``` wallpaper.isOperationAllowed().then((data) => { console.log(`success to isOperationAllowed: ` + JSON.stringify(data)); @@ -356,7 +356,7 @@ reset(wallpaperType: WallpaperType, callback: AsyncCallback<void>): void | callback | AsyncCallback<void> | 是 | 回调函数,调用成功则返回是否移除成功的结果,调用失败则返回error信息。 | - 示例: - + ``` wallpaper.reset((error, data) => { if (error) { @@ -389,7 +389,7 @@ reset(wallpaperType: WallpaperType): Promise<void> | Promise<void> | 调用成功则返回是否移除成功的结果,调用失败则返回error信息。 | - 示例: - + ``` wallpaper.reset(wallpaper.WALLPAPER_SYSTEM).then((data) => { console.log(`success to reset.`); @@ -410,14 +410,14 @@ setWallpaper(uriOrPixelMap: string | image.PixelMap, wallpaperType: WallpaperTyp **系统能力**: SystemCapability.Miscservices.Wallpaper - 参数: - | 参数名 | 类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | - | uriOrPixelMap | string \| [ERROR:Invalid link:zh-cn_topic_0000001154665636.xml#xref134981523104113,link:zh-cn_topic_0000001122977382.xml#section160331714124](zh-cn_topic_0000001122977382.xml#section160331714124) | 是 | JPEG或PNG文件的Uri路径,或者PNG格式文件的位图。 | - | wallpaperType | [WallpaperType](#wallpapertype) | 是 | 壁纸类型。 | - | callback | AsyncCallback<void> | 是 | 回调函数,调用成功则返回是返回设置的结果,调用失败则返回error信息。 | + | uriOrPixelMap | string \|[PixelMap](js-apis-image.md#pixelmap7) | | JPEG或PNG文件的Uri路径,或者PNG格式文件的位图。 | + | wallpaperType | [WallpaperType](#wallpapertype) | 是 | 壁纸类型。 | + | callback | AsyncCallback<void> | 是 | 回调函数,调用成功则返回是返回设置的结果,调用失败则返回error信息。 | - 示例: - + ``` // uriOrPixelMap类型为string let wallpaperPath = "/data/data/ohos.acts.aafwk.plrdtest.form/files/Cup_ic.jpg"; @@ -463,10 +463,10 @@ setWallpaper(uriOrPixelMap: string | image.PixelMap, wallpaperType: WallpaperTyp **系统能力**: SystemCapability.Miscservices.Wallpaper - 参数: - | 参数名 | 类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | - | uriOrPixelMap | string \| [ERROR:Invalid link:zh-cn_topic_0000001154665636.xml#xref2071734616,link:zh-cn_topic_0000001122977382.xml#section160331714124](zh-cn_topic_0000001122977382.xml#section160331714124) | 是 | JPEG或PNG文件的Uri路径,或者PNG格式文件的位图。 | - | wallpaperType | [WallpaperType](#wallpapertype) | 是 | 壁纸类型。 | + | uriOrPixelMap | string \|[PixelMap](js-apis-image.md#pixelmap7) | 是 | JPEG或PNG文件的Uri路径,或者PNG格式文件的位图。 | + | wallpaperType | [WallpaperType](#wallpapertype) | 是 | 壁纸类型。 | - 返回值: | 类型 | 说明 | @@ -474,7 +474,7 @@ setWallpaper(uriOrPixelMap: string | image.PixelMap, wallpaperType: WallpaperTyp | Promise<void> | 调用成功则返回是返回设置的结果,调用失败则返回error信息。 | - 示例: - + ``` // uriOrPixelMap类型为string let wallpaperPath = "/data/data/ohos.acts.aafwk.plrdtest.form/files/Cup_ic.jpg"; @@ -514,13 +514,13 @@ on(type: 'colorChange', callback: (colors: Array<RgbaColor>, wallpaperType **系统能力**: SystemCapability.Miscservices.Wallpaper - 参数: - | 参数名 | 类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | - | type | string | 是 | 取值为'colorChange',表示壁纸颜色变化结果上报事件。 | - | callback | function | 是 | 壁纸颜色变化触发该回调方法,返回壁纸类型和壁纸的主要颜色信息。
- colors
  壁纸的主要颜色信息,其类型见[RgbaColor](#rgbacolor)。
- wallpaperType
  壁纸类型。 | + | type | string | 是 | 取值为'colorChange',表示壁纸颜色变化结果上报事件。 | + | callback | function | 是 | 壁纸颜色变化触发该回调方法,返回壁纸类型和壁纸的主要颜色信息。
- colors
  壁纸的主要颜色信息,其类型见[RgbaColor](#rgbacolor)。
- wallpaperType
  壁纸类型。 | - 示例: - + ``` let listener = (colors, wallpaperType) => { console.log(`wallpaper color changed.`); @@ -544,7 +544,7 @@ off(type: 'colorChange', callback?: (colors: Array<RgbaColor>, wallpaperTy | callback | function | 否 |   表示取消壁纸颜色变化结果上报,不填写该参数则取消订阅该type对应的所有回调。
- colors
  壁纸的主要颜色信息,其类型见[RgbaColor](#rgbacolor)。
- wallpaperType
  壁纸类型。 | - 示例: - + ``` let listener = (colors, wallpaperType) => { console.log(`wallpaper color changed.`); diff --git a/zh-cn/application-dev/reference/apis/js-apis-workScheduler.md b/zh-cn/application-dev/reference/apis/js-apis-workScheduler.md index b2b623dc6f9c8018aeabb4528af605b5fb96730c..8224175b470f7c8538e2975274aa4c2a5a91046a 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-workScheduler.md +++ b/zh-cn/application-dev/reference/apis/js-apis-workScheduler.md @@ -269,6 +269,7 @@ isLastWorkTimeOut(workId: number): Promise\ .catch(err => { console.info('workschedulerLog isLastWorkTimeOut failed, because:' + err.data); }); + }) ``` ## WorkInfo diff --git a/zh-cn/application-dev/reference/arkui-js/figures/transition.gif b/zh-cn/application-dev/reference/arkui-js/figures/transition.gif deleted file mode 100644 index 1b1aacbf3092a0ed946ce477251e60a41b365774..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/reference/arkui-js/figures/transition.gif and /dev/null differ diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-common-transition.md b/zh-cn/application-dev/reference/arkui-js/js-components-common-transition.md index 8aefd3c4353327c655fe5bd0adcfa1ef8b5c32a9..bbf7ca807f64b5a8206a8f865dd8dcdda7bf6b06 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-common-transition.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-common-transition.md @@ -48,8 +48,10 @@ PageA跳转到PageB,跳转的共享元素为image, shareid为“shareImage
- - Click on picture to Jump to ths details +
+ + Click on picture to Jump to ths details +
@@ -235,145 +237,3 @@ export default { b. back场景下:退出页面栈的Page2.js应用transition-enter描述的动画配置,并进行倒播;从页面栈第二位置进入栈顶位置的Page1.js应用transition-exit描述的动画配置,并进行倒播。 ![zh-cn_image_0000001238184345](figures/zh-cn_image_0000001238184345.png) - -### 示例 - -Page1有一个不透明盒子,点击盒子会跳转到Page2,当点击Page2中的盒子,会回退到Page1页面。 - -1. Page1 - - ``` - -
- index -
-
- ``` - - ``` - - import router from '@system.router'; - export default { - data: { - - }, - jump() { - router.push({ - uri:'pages/transition2/transition2' - }) - } - } - ``` - - ``` - - .container { - flex-direction: column; - justify-content: center; - align-items: center; - width: 100%; - height: 100%; - } - .move_page { - width: 100px; - height: 100px; - background-color: #72d3fa; - transition-enter: go_page; - transition-exit: exit_page; - transition-duration: 5s; - transition-timing-function: friction; - } - - @keyframes go_page { - from { - opacity: 0; - transform: translate(0px) rotate(60deg) scale(1.0); - } - - to { - opacity: 1; - transform: translate(100px) rotate(360deg) scale(1.0); - } - } - @keyframes exit_page { - from { - opacity: 1; - transform: translate(200px) rotate(60deg) scale(2); - } - - to { - opacity: 0; - transform: translate(200px) rotate(360deg) scale(2); - } - } - ``` - - - -2. Page2 - - ``` - -
- transition -
-
- import router from '@system.router'; - export default { - data: { - - }, - jumpBack() { - router.back() - } - } - ``` - - ``` - - .container { - flex-direction: column; - justify-content: center; - align-items: center; - width: 100%; - height: 100%; - } - - .move_page { - width: 100px; - height: 100px; - background-color: #f172fa; - transition-enter: go_page; - transition-exit: exit_page; - transition-duration: 5s; - transition-timing-function: ease; - } - - @keyframes go_page { - from { - opacity: 0; - transform:translate(100px) rotate(0deg) scale(1.0); - } - to { - opacity: 1; - transform:translate(100px) rotate(180deg) scale(2.0); - } - } - - @keyframes exit_page { - from { - opacity: 1; - transform: translate(0px) rotate(60deg) scale(1); - } - to { - opacity: 0; - transform: translate(0px) rotate(360deg) scale(1); - } - } - ``` - - ![transition](figures/transition.gif) diff --git a/zh-cn/application-dev/reference/arkui-ts/Readme-CN.md b/zh-cn/application-dev/reference/arkui-ts/Readme-CN.md index fac811e748ba045bd78f38a530618f3aa24c10df..cfd6f34071a5c5a828d3c26f2f358292132103f1 100644 --- a/zh-cn/application-dev/reference/arkui-ts/Readme-CN.md +++ b/zh-cn/application-dev/reference/arkui-ts/Readme-CN.md @@ -132,7 +132,6 @@ - [插值计算](ts-interpolation-calculation.md) - 全局UI方法 - [图片缓存](ts-methods-image-cache.md) - - [媒体查询](ts-methods-media-query.md) - 弹窗 - [警告弹窗](ts-methods-alert-dialog-box.md) - [列表选择弹窗](ts-methods-action-sheet.md) diff --git a/en/application-dev/reference/arkui-ts/figures/gauge.png b/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001174422916.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/gauge.png rename to zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001174422916.png diff --git a/en/application-dev/reference/arkui-ts/figures/gif-1.gif b/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001193499234.gif similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/gif-1.gif rename to zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001193499234.gif diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001239788885.gif b/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001250678457.gif similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/en-us_image_0000001239788885.gif rename to zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001250678457.gif diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-gauge.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-gauge.md new file mode 100644 index 0000000000000000000000000000000000000000..aa5ea7c36ac30a12089ed39f237887c94fbb5f51 --- /dev/null +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-gauge.md @@ -0,0 +1,63 @@ +# Gauge + + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 该组件从API Version 8开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 + + +数据量规图表组件,用于将数据展示为环形图表。 + + +## 权限列表 + +无 + + +## 子组件 + +无 + + +## 接口 + +Gauge(value:{value: number, min?: number, max?: number}) + +- 参数 + | 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | + | -------- | -------- | -------- | -------- | -------- | + | value | number | 是 | - | 当前数据值。 | + | min | number | 否 | 0 | 当前数据段最小值。 | + | max | number | 否 | 100 | 当前数据段最大值。 | + + +## 属性 + + | 名称 | 参数类型 | 默认值 | 描述 | +| -------- | -------- | -------- | -------- | +| value | number | 0 | 设置当前数据图表的值。 | +| startAngle | Angle | -150 | 设置起始角度位置,时钟0点为0度,顺时针方向为正角度。 | +| endAngle | Angle | 150 | 设置终止角度位置,时钟0点为0度,顺时针方向为正角度。 | +| colors | Color \| Array<ColorStop> | - | 设置图表的颜色,支持纯色和分段渐变色设置。 | +| strokeWidth | Length | - | 设置环形图表的环形厚度。 | + + +## 示例 + + +``` +@Entry +@Component +struct GaugeExample { + build() { + Column() { + Gauge({ value: 50, min: 0, max: 100 }) + .startAngle(210).endAngle(150) + .colors([[0x317AF7, 1], [0x5BA854, 1], [0xE08C3A, 1], [0x9C554B, 1], [0xD94838, 1]]) + .strokeWidth(20) + .width(200).height(200) + }.width('100%').margin({ top: 5 }) + } +} +``` + +![zh-cn_image_0000001174422916](figures/zh-cn_image_0000001174422916.png) diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-marquee.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-marquee.md new file mode 100644 index 0000000000000000000000000000000000000000..9ae0bffa885e09a41b855dd084545073432d39af --- /dev/null +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-marquee.md @@ -0,0 +1,95 @@ +# Marquee + + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 该组件从API Version 8开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 + + +跑马灯组件,用于滚动展示一段单行文本。 + + +## 权限列表 + +无 + + +## 子组件 + +无 + + +## 接口 + +Marquee(value: { start: boolean, step?: number, loop?: number, fromStart?: boolean, src: string }) + +- 参数 + | 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | + | -------- | -------- | -------- | -------- | -------- | + | start | boolean | 是 | - | 控制是否进入播放状态。 | + | step | number | 否 | 6 | 滚动动画文本滚动步长。 | + | loop | number | 否 | -1 | 设置重复滚动的次数,小于等于零时无限循环。 | + | fromStart | boolean | 否 | true | 设置文本从头开始滚动或反向滚动。 | + | src | string | 是 | - | 需要滚动的文本。 | + + +## 事件 + + | 名称 | 功能描述 | +| -------- | -------- | +| onStart(callback: () => void) | 开始滚动时触发回调。 | +| onBounce(callback: () => void) | 滚动到底时触发回调。 | +| onFinish(callback: () => void) | 滚动完成时触发回调。 | + + +## 示例 + + +``` +@Entry +@Component +struct MarqueeExample { + @State start: boolean = false + @State fromStart: boolean = true + @State step: number = 50 + @State loop: number = 3 + @State src: string = "Running Marquee starts rolling" + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Marquee({ + start: this.start, + step: this.step, + loop: this.loop, + fromStart: this.fromStart, + src: this.src + }) + .fontColor(Color.White) + .fontSize(50) + .allowScale(false) + .fontWeight(FontWeight.Bold) + .backgroundColor(Color.Black) + .margin({bottom:40}) + .onStart(() => { + console.log('Marquee animation complete onStart') + }) + .onBounce(() => { + console.log('Marquee animation complete onBounce') + }) + .onFinish(() => { + console.log('Marquee animation complete onFinish') + }) + Button('start') + .onClick(() => { + this.start = true + }) + .width(200) + .height(60) + .margin({bottom:20}) + } + .width('100%') + .height('100%') + } +} +``` + +![zh-cn_image_0000001193499234](figures/zh-cn_image_0000001193499234.gif) diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-plugincomponent.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-plugincomponent.md new file mode 100644 index 0000000000000000000000000000000000000000..7707e68d943582a05fe4c4d86183830b5a5a6224 --- /dev/null +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-plugincomponent.md @@ -0,0 +1,318 @@ +# PluginComponent + + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> - 该组件从API Version 8开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 +> +> - 本组件均为系统接口,三方应用不支持调用。 + + +提供外部应用组件嵌入式显示功能,即外部应用提供的UI可在本应用内显示。 + + +## 权限列表 + +无 + + +## 子组件 + +无 + + +## 接口 + +PluginComponent(value: { template: PluginComponentTemplate, data: any }) + +创建插件组件,用于显示外部应用提供的UI。 + +- 参数 + | 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | + | -------- | -------- | -------- | -------- | -------- | + | value | {
template: PluginComponentTemplate,
data: KVObject
} | 是 | - | template:  组件模板,用于跟提供者定义的组件绑定。
data: 传给插件组件提供者使用的数据。 | + +- PluginComponentTemplate类型说明 + | 参数 | 类型 | 描述 | + | -------- | -------- | -------- | + | source | string | 组件模板名。 | + | ability | string | 提供者Ability的abilityname。 | + + +## 事件 + + | 名称 | 功能描述 | +| -------- | -------- | +| onComplete(callback: () => void) | 组件加载完成回调。 | +| onError(callback: (info: { errcode: number, msg: string }) => void) | 组件加载错误回调。
errcode: 错误码。
msg: 错误信息。 | + + +## PluginComponentManager + +提供配套插件组件使用的相关接口,用于给插件组件的使用者请求组件与数据,使用者发送组件模板和数据。 + + +## 导入模块 + + +``` +import pluginComponentManager from '@ohos.plugincomponent' +``` + + +## push + +push(param: PushParameters, callback: AsyncCallback<void>): void + +组件提供者向组件使用者主动发送组件与数据。 + + +- 参数 + | 参数名 | 类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | param | PushParameters | 是 | 组件使用者的详细信息,详见PushParameters参数说明。 | + | callback | AsyncCallback<void> | 是 | 此次接口调用的异步回调。 | + +- PushParameters参数说明 + | 参数名 | 类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | want | Want | 是 | 组件使用者Ability信息。 | + | name | string | 是 | 组件名称。 | + | data | KVObject | 否 | 组件数据值。 | + | extraData | KVObject | 否 | 附加数据值。 | + +- 示例 + 见[组件使用者调用接口](#组件使用者调用接口)示例。 + + +## request + +request(param: RequestParameters, callback: AsyncCallback<RequestCallbackParameters>): void + +组件使用者向组件提供者主动请求组件。 + +- 参数 + | 参数名 | 类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | param | RequestParameters | 是 | 组件模板的详细请求信息,详见RequestParameters参数说明。 | + | callback | AsyncCallback"push”:指组件提供者向使用者主动推送数据。
"request”:指组件使用者向提供者主动请求数据。 | + | callback | OnPushEventCallback \| OnRequestEventCallback | 是 | 见callback事件说明。 | + +- callback事件说明 + | 参数名 | 类型 | 说明 | + | -------- | -------- | -------- | + | OnRequestEventCallback | (source: Want,
name: string,
data: KVObject ) =>RequestEventResult | 数据请求事件的回调。
source: 组件请求方Ability信息。
name: 请求组件名称。
data: 附加数据。
返回值: 请求数据结果。 | + | OnPushEventCallback | (source: Want,
template: PluginComponentTemplate,
data: KVObject,
extraData: KVObject
) => void | 接收提供者主动推送的数据。
source: 组件提供者Ability信息。
template: 组件模板。
data: 组件更新数据。
extraData: 附加数据。 | + +- RequestEventResult类型说明 + | 参数 | 类型 | 说明 | + | -------- | -------- | -------- | + | template | string | 组件名称。 | + | data | KVObject | 组件数据。 | + | extraData | KVObjec | 附加数据。 | + +- 示例 + 见[组件使用者调用接口](#组件使用者调用接口)示例。 + + +## 示例 + + +### 使用PluginComponent组件 + + +``` +import plugin from "../../test/plugin_component.js" +import plugincomponent from '@ohos.plugincomponent' + +@Entry +@Component +struct PluginComponentExample { + @StorageLink("plugincount") plugincount: Object[] = [ + { source: 'plugincomponent1', ability: 'com.example.plugin' }, + { source: 'plugintemplate', ability: 'com.example.myapplication' }, + { source: 'plugintemplate', ability: 'com.example.myapplication' }] + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text('Hello World') + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button('Push') + .fontSize(50) + .width(400) + .height(100) + .onClick(() => { + plugin.Push() + console.log("Button('Push')") + }) + .margin({ top: 20 }) + Button('Request1') + .fontSize(50) + .width(400) + .height(100) + .margin({ top: 20 }) + .onClick(() => { + plugin.Request1() + console.log("Button('Request1')") + }) + Button('Request2') + .fontSize(50) + .width(400) + .height(100) + .margin({ top: 20 }) + .onClick(() => { + plugin.Request2() + console.log("Button('Request2')") + }) + ForEach(this.plugincount, item => { + PluginComponent({ + template: { source: 'plugincomponent1', ability: 'com.example.plugin' }, + data: { 'countDownStartValue': 'new countDownStartValue' } + }).size({ width: 500, height: 100 }) + .onComplete(() => { + console.log("onComplete") + }) + .onError(({errcode, msg}) => { + console.log("onComplete" + errcode + ":" + msg) + }) + }) + } + .width('100%') + .height('100%') +} +``` + + +### 组件使用者调用接口 + + +``` +import pluginComponentManager from '@ohos.plugincomponent' + +function onPushListener(source, template, data, extraData) { + console.log("onPushListener template.source=" + template.source) + var jsonObject = JSON.parse(data.componentTemplate.source) + console.log("request_callback1:source json object" + jsonObject) + var jsonArry = jsonObject.ExternalComponent + for (var i in jsonArry) { + console.log(jsonArry[i]) + } + console.log("onPushListener:source json object" + jsonObject) + console.log("onPushListener:source json string" + JSON.stringify(jsonObject)) + console.log("onPushListener template.ability=" + template.ability) + console.log("onPushListener data=" + JSON.stringify(data)) + console.log("onPushListener extraData=" + JSON.stringify(extraData)) +} + +export default { + //register listener + onListener() { + pluginComponentManager.on("push", onPushListener) + }, + Request() { + // 组件使用者主动发送事件 + pluginComponentManager.request({ + want: { + bundleName: "com.example.myapplication", + abilityName: "com.example.myapplication.MainAbility", + }, + name: "plugintemplate", + data: { + "key_1": "plugin component test", + "key_2": 34234 + }, + jsonPath: "assets/js", + }, + (err, data) => { + console.log("request_callback1: componentTemplate.ability=" + data.componentTemplate.ability) + console.log("request_callback1: componentTemplate.source=" + data.componentTemplate.source) + var jsonObject = JSON.parse(data.componentTemplate.source) + console.log("request_callback1:source json object" + jsonObject) + var jsonArry = jsonObject.ExternalComponent + for (var i in jsonArry) { + console.log(jsonArry[i]) + } + console.log("request_callback1:source json string" + JSON.stringify(jsonObject)) + console.log("request_callback1: data=" + JSON.stringify(data.data)) + console.log("request_callback1: extraData=" + JSON.stringify(data.extraData)) + } + ) + } +} + +// 组件提供者使用接口示例 +import pluginComponentManager from '@ohos.plugincomponent' + +function onRequestListener(source, name, data) { + console.log("onRequestListener name=" + name) + console.log("onRequestListener data=" + JSON.stringify(data)) + return { template: "plugintemplate", data: data } +} + +export default { + //register listener + onListener() { + pluginComponentManager.on("request", onRequestListener) + }, + Push() { + // 组件提供者主动发送事件 + pluginComponentManager.push( + { + want: { + bundleName: "com.example.myapplication", + abilityName: "com.example.myapplication.MainAbility", + }, + name: "plugintemplate", + data: { + "key_1": "plugin component test", + "key_2": 34234 + }, + extraData: { + "extra_str": "this is push event" + }, + jsonPath: "assets/js", + }, + (err, data) => { + console.log("push_callback1: componentTemplate.ability=" + data.componentTemplate.ability) + console.log("push_callback1: componentTemplate.source=" + data.componentTemplate.source) + console.log("push ok!") + } + ) + }, +} +``` diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-stepper.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-stepper.md new file mode 100644 index 0000000000000000000000000000000000000000..9899f76f8d5abdaed32be48cc45a80bed4e3c2c3 --- /dev/null +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-stepper.md @@ -0,0 +1,125 @@ +# Stepper + + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 该组件从API Version 8开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 + + +步骤导航器。 + + +## 权限列表 + +无 + + +## 子组件 + +仅能包含子组件[StepperItem](ts-basic-components-stepperitem.md)。 + + +## 接口 + +Stepper(value?: { index?: number }) + + +- 参数 + | 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | + | -------- | -------- | -------- | -------- | -------- | + | index | number | 否 | 0 | 设置步骤导航器显示第几个StepperItem。 | + + +## 属性 + +无 + + +## 事件 + + | 名称 | 描述 | +| -------- | -------- | +| onFinish(callback: () => void) | 步骤导航器最后一个StepperItem的nextLabel被点击时触发该回调 。 | +| onSkip(callback: () => void) | 当前显示的StepperItem状态为ItemState.Skip时,nextLabel被点击时触发该回调。 | +| onChange(callback: (prevIndex?: number, index?: number) => void) | 点击左边或者右边文本按钮进行步骤切换时触发该事件。
- prevIndex:切换前的步骤页索引值。
- index:切换后的步骤页(前一页或者下一页)索引值。 | + + +## 示例 + +``` +@Entry +@Component +struct StepperExample { + @State currentIndex: number = 0 + @State firstState: ItemState = ItemState.Normal + @State secondState: ItemState = ItemState.Normal + + build() { + Stepper({ + index: this.currentIndex + }) { + StepperItem() { + Text('Page One') + .fontSize(35) + .fontColor(Color.Blue) + .width(200) + .lineHeight(50) + .margin({top:250}) + } + .nextLabel('') + .position({x: '35%', y: 0}) + StepperItem() { + Text('Page Two') + .fontSize(35) + .fontColor(Color.Blue) + .width(200) + .lineHeight(50) + .margin({top:250}) + .onClick(()=>{ + this.firstState = this.firstState === ItemState.Skip ? ItemState.Normal : ItemState.Skip + }) + } + .nextLabel('Next') + .prevLabel('Previous') + .status(this.firstState) + .position({x: '35%', y: 0}) + StepperItem() { + Text('Page Three') + .fontSize(35) + .fontColor(Color.Blue) + .width(200) + .lineHeight(50) + .margin({top:250}) + .onClick(()=>{ + this.secondState = this.secondState === ItemState.Waiting ? ItemState.Normal : ItemState.Waiting + }) + } + .position({x: '35%', y: 0}) + .status(this.secondState) + StepperItem() { + Text('Page four') + .fontSize(35) + .fontColor(Color.Blue) + .width(200) + .lineHeight(50) + .margin({top:250}) + } + .position({x: '35%', y: 0}) + .nextLabel('Finish') + } + .onFinish(() => { + console.log('onFinish') + }) + .onSkip(() => { + console.log('onSkip') + }) + .onChange((prevIndex: number, index: number) => { + this.currentIndex = index + }) + .align(Alignment.Center) + } +} +``` + + +![zh-cn_image_0000001250678457](figures/zh-cn_image_0000001250678457.gif) + diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-stepperitem.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-stepperitem.md new file mode 100644 index 0000000000000000000000000000000000000000..223996522947d688231c451884b81f258f80d0b8 --- /dev/null +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-stepperitem.md @@ -0,0 +1,46 @@ +# StepperItem + + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 该组件从API Version 8开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 + + +步骤导航器元素。 + + +## 权限列表 + +无 + + +## 子组件 + +支持单个子组件。 + + +## 接口 + +StepperItem() + + +## 属性 + +| 参数名 | 参数类型 | 默认值 | 参数描述 | +| -------- | -------- | -------- | -------- | +| prevLabel | string | - | 当步骤导航器大于一页,除第一页默认值都为"返回"。 | +| nextLabel | string | - | 步骤导航器大于一页时,最后一页默认值为"开始",其余页默认值为"下一步"。 | +| status | ItemState | ItemState.Normal | 步骤导航器元素的状态。 | + +- ItemState枚举说明 + | 名称 | 描述 | + | -------- | -------- | + | Normal | 正常状态,右侧文本按钮正常显示,可点击进入下一个StepperItem。 | + | Disabled | 不可用状态,右侧文本按钮灰度显示,不可点击进入下一个StepperItem。 | + | Waiting | 等待状态,右侧文本按钮不显示,使用等待进度条,不可点击进入下一个StepperItem。 | + | Skip | 跳过状态,表示跳过当前步骤, 进入下一个StepperItem。 | + + +## 示例 + +见[Stepper](ts-basic-components-stepper.md)。 + diff --git a/zh-cn/application-dev/ui/ts-application-resource-access.md b/zh-cn/application-dev/ui/ts-application-resource-access.md new file mode 100644 index 0000000000000000000000000000000000000000..61bf3d3a3c0d8f6d6ce913deb80f6987ca78e03e --- /dev/null +++ b/zh-cn/application-dev/ui/ts-application-resource-access.md @@ -0,0 +1,164 @@ +# 访问应用资源 + + +## 资源定义 + +应用资源由开发者在工程的resources目录中定义,resources目录按照两级目录的形式来组织: + +- 一级目录为base目录、限定词目录以及rawfile目录 + - base目录是默认存在的目录。当应用的resources资源目录中没有与设备状态匹配的限定词目录时,会自动引用该目录中的资源文件。 + - 限定词目录需要开发者自行创建,其可以由一个或多个表征应用场景或设备特征的限定词组合而成,包括移动国家码和移动网络码、语言、文字、国家或地区、横竖屏、设备类型、颜色模式和屏幕密度等维度,限定词之间通过下划线(_)或者中划线(-)连接。 + - 在引用rawfile中的资源时,不会根据系统的状态去匹配,rawfile目录中可以直接存放资源文件。 + +- 二级目录为资源目录 + - 用于存放字符串、颜色、浮点数等基础元素,以及媒体等资源文件。 + - 当前支持的文件和资源类型如下: + | 文件名 | 资源类型 | + | -------- | -------- | + | color.json | 颜色资源。 | + | float.json | 间距、圆角、字体等资源。 | + | string.json | 字符串资源。 | + | plural.json | 字符串资源。 | + | media目录 | 图片资源。 | + + +## 资源引用 + +在工程中,通过**“$r('app.type.name')”**的形式引用应用资源。app代表是应用内resources目录中定义的资源;type代表资源类型(或资源的存放位置),可以取“color”、“float”、“string”、“plural”、“media”,name代表资源命名,由开发者定义资源时确定。 + +引用rawfile下资源时使用**“$rawfile('filename')”**的形式**,**当前$rawfile仅支持Image控件引用图片资源,filename需要表示为rawfile目录下的文件相对路径,文件名需要包含后缀,路径开头不可以以"/"开头。 + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 资源描述符不能拼接使用。 + + +## 示例 + +base目录中部分自定义资源如下所示: + + +``` + resources + ├─ base + │ ├─ element + │ │ ├─ color.json + │ │ ├─ string.json + │ │ └─ float.json + │ └─ media + │ └─ my_background_image.png + └─ rawfile + ├─ test.png + └─ newDir + └─ newTest.png +``` + +color.json文件的内容如下: + + +``` +{ + "color": [ + { + "name": "color_hello", + "value": "#ffff0000" + }, + { + "name": "color_world", + "value": "#ff0000ff" + } + ] +} +``` + +float.json文件的内容如下: + + +``` +{ + "float":[ + { + "name":"font_hello", + "value":"28.0fp" + }, + { + "name":"font_world", + "value":"20.0fp" + } + ] +} +``` + +string.json文件的内容如下: + + +``` +{ + "string":[ + { + "name":"string_hello", + "value":"Hello" + }, + { + "name":"string_world", + "value":"World" + }, + { + "name":"message_arrive", + "value":"We will arrive at %s." + } + ] +} +``` + +plural.json文件的内容如下: + + +``` +{ + "plural":[ + { + "name":"eat_apple", + "value":[ + { + "quantity":"one", + "value":"%d apple" + }, + { + "quantity":"other", + "value":"%d apples" + } + ] + } + ] +} +``` + + 在ets文件中,可以使用在resources目录中定义的资源。 + +``` +Text($r('app.string.string_hello')) + .fontColor($r('app.color.color_hello')) + .fontSize($r('app.float.font_hello')) +} + +Text($r('app.string.string_world')) + .fontColor($r('app.color.color_world')) + .fontSize($r('app.float.font_world')) +} + +Text($r('app.string.message_arrive', "five of the clock")) //引用string资源,$r的第二个参数用于替换%s + .fontColor($r('app.color.color_hello')) + .fontSize($r('app.float.font_hello')) +} + +Text($r('app.plural.eat_apple', 5, 5)) //plural$r引用,第一个指定plural资源,第二个参数指定单复数的数量,此处第三个数字为对%d的替换 + .fontColor($r('app.color.color_world')) + .fontSize($r('app.float.font_world')) +} + +Image($r('app.media.my_background_image')) //media资源的$r引用 + +Image($rawfile('test.png')) //rawfile$r引用rawfile目录下图片 + +Image($rawfile('newDir/newTest.png')) //rawfile$r引用rawfile目录下图片 +``` diff --git a/zh-cn/application-dev/ui/ts-system-resource-access.md b/zh-cn/application-dev/ui/ts-system-resource-access.md new file mode 100644 index 0000000000000000000000000000000000000000..f888038883c1530f03c09c342919b9abfec10ef0 --- /dev/null +++ b/zh-cn/application-dev/ui/ts-system-resource-access.md @@ -0,0 +1,20 @@ +# 访问系统资源 + + +系统资源包含色彩、圆角、字体、间距、字符串及图片等。通过使用系统资源,不同的开发者可以开发出具有相同视觉风格的应用。 + + +开发者可以通过**“$r('sys.type.resource_id')”**的形式引用系统资源。sys代表是系统资源;type代表资源类型,可以取“color”、“float”、“string”、“media”;resource_id代表资源id。 + +``` +Text('Hello') + .fontColor($r('sys.color.id_color_emphasize')) + .fontSize($r('sys.float.id_text_size_headline1')) + .fontFamily($r('sys.string.id_text_font_family_medium')) + .backgroundColor($r('sys.color.id_color_palette_aux1')) +Image($r('sys.media.ic_app')) + .border({color: $r('sys.color.id_color_palette_aux1'), radius: $r('sys.float.id_corner_radius_button'), width: 2}) + .margin({top: $r('sys.float.id_elements_margin_horizontal_m'), bottom: $r('sys.float.id_elements_margin_horizontal_l')}) + .height(200) + .width(300) +```