diff --git a/.gitattributes b/.gitattributes index e723e1197d0db7c523e27d00cc64d13e847318fb..f17b2bee513f3dc8a111965f4c58346eaede9b0b 100644 --- a/.gitattributes +++ b/.gitattributes @@ -16,3 +16,4 @@ OpenHarmony_Icons.zip filter=lfs diff=lfs merge=lfs -text zip filter=lfs diff=lfs merge=lfs -text figures/OpenHarmony_Icons.zip filter=lfs diff=lfs merge=lfs -text +figures/OpenHarmony应用图标模版.zip filter=lfs diff=lfs merge=lfs -text diff --git a/en/application-dev/application-models/arkts-ui-widget-configuration.md b/en/application-dev/application-models/arkts-ui-widget-configuration.md index 7c27d434cbcc0c73cd05c96509b704131d5fd093..f0f003e608c995461ad1e84c65ed2a09b87febb7 100644 --- a/en/application-dev/application-models/arkts-ui-widget-configuration.md +++ b/en/application-dev/application-models/arkts-ui-widget-configuration.md @@ -8,7 +8,7 @@ Widget-related configuration includes **FormExtensionAbility** configuration and Example configuration: - + ```json { "module": { @@ -53,10 +53,12 @@ Widget-related configuration includes **FormExtensionAbility** configuration and | formConfigAbility | Link to a specific page of the application. The value is a URI.| String| Yes (initial value: left empty)| | formVisibleNotify | Whether the widget is allowed to use the widget visibility notification.| String| Yes (initial value: left empty)| | metadata | Metadata of the widget. This field contains the array of the **customizeData** field.| Object| Yes (initial value: left empty)| + | dataProxyEnabled | Whether the widget supports the [update-through-proxy](./arkts-ui-widget-update-by-proxy.md) feature.
- **true**: The widget supports the update-through-proxy feature.
- **false**: The widget does not support the update-through-proxy feature.
If this tag is set to **true**, the settings for the scheduled update time will still take effect, but the settings for the update interval and next update time will not.| Boolean| Yes (initial value: **false**)| + | isDynamic | Whether the widget is a dynamic widget. This tag only applies to ArkTS widgets.
- **true**: The widget is a dynamic widget.
- **false**: The widget is a static widget. In this case, the widget is displayed as a static image after being added.| Boolean| Yes (initial value: **true**)| Example configuration: - + ```json { "forms": [ diff --git a/en/application-dev/application-models/arkts-ui-widget-page-custom-drawing.md b/en/application-dev/application-models/arkts-ui-widget-page-custom-drawing.md index a55cb9cd17cda67cc2989e5916db19c5cf36cc47..3fb83498972a425ef11821c3292a74bbdb81016d 100644 --- a/en/application-dev/application-models/arkts-ui-widget-page-custom-drawing.md +++ b/en/application-dev/application-models/arkts-ui-widget-page-custom-drawing.md @@ -1,12 +1,12 @@ # Applying Custom Drawing in the Widget -You can apply custom drawing in your ArkTS widget to create a more vibrant experience. Use the [Canvas](../reference/arkui-ts/ts-components-canvas-canvas.md) component to create a canvas on the widget, and then use the [CanvasRenderingContext2D](../reference/arkui-ts/ts-canvasrenderingcontext2d.md) object to draw custom graphics on the canvas. The following code snippet draws a smiling face in the center of a canvas. +You can apply custom drawing in your ArkTS widget to create a more vibrant experience. Use the [\](../reference/arkui-ts/ts-components-canvas-canvas.md) component to create a canvas on the widget, and then use the [CanvasRenderingContext2D](../reference/arkui-ts/ts-canvasrenderingcontext2d.md) object to draw custom graphics on the canvas. The following code snippet draws a smiling face in the center of a canvas. ```ts @Entry @Component -struct Card { +struct WidgetCard { private canvasWidth: number = 0; private canvasHeight: number = 0; // Initialize CanvasRenderingContext2D and RenderingContextSettings. @@ -26,9 +26,9 @@ struct Card { this.canvasWidth = this.context.width; this.canvasHeight = this.context.height; // Draw the background of the canvas. - this.context.fillStyle = 'rgba(203, 154, 126, 1.00)'; + this.context.fillStyle = '#EEF0FF'; this.context.fillRect(0, 0, this.canvasWidth, this.canvasHeight); - // Draw a red circle in the center of the canvas. + // Draw a circle in the center of the canvas. this.context.beginPath(); let radius = this.context.width / 3; let circleX = this.context.width / 2; @@ -36,35 +36,48 @@ struct Card { this.context.moveTo(circleX - radius, circleY); this.context.arc(circleX, circleY, radius, 2 * Math.PI, 0, true); this.context.closePath(); - this.context.fillStyle = 'red'; + this.context.fillStyle = '#5A5FFF'; this.context.fill(); // Draw the left eye of the smiling face. - let leftR = radius / 4; - let leftX = circleX - (radius / 2); - let leftY = circleY - (radius / 3.5); + let leftR = radius / 13; + let leftX = circleX - (radius / 2.3); + let leftY = circleY - (radius / 4.5); this.context.beginPath(); - this.context.arc(leftX, leftY, leftR, 0, Math.PI, true); - this.context.strokeStyle = '#ffff00'; - this.context.lineWidth = 10; + this.context.arc(leftX, leftY, leftR, 0, 2 * Math.PI, true); + this.context.strokeStyle = '#FFFFFF'; + this.context.lineWidth = 15; this.context.stroke(); // Draw the right eye of the smiling face. - let rightR = radius / 4; - let rightX = circleX + (radius / 2); - let rightY = circleY - (radius / 3.5); + let rightR = radius / 13; + let rightX = circleX + (radius / 2.3); + let rightY = circleY - (radius / 4.5); this.context.beginPath(); - this.context.arc(rightX, rightY, rightR, 0, Math.PI, true); - this.context.strokeStyle = '#ffff00'; - this.context.lineWidth = 10; + this.context.arc(rightX, rightY, rightR, 0, 2 * Math.PI, true); + this.context.strokeStyle = '#FFFFFF'; + this.context.lineWidth = 15; + this.context.stroke(); + // Draw the nose of the smiling face. + let startX = circleX; + let startY = circleY - 20; + this.context.beginPath(); + this.context.moveTo(startX, startY); + this.context.lineTo(startX - 8, startY + 40); + this.context.lineTo(startX + 8, startY + 40); + this.context.strokeStyle = '#FFFFFF'; + this.context.lineWidth = 15; + this.context.lineCap = 'round' + this.context.lineJoin = 'round' this.context.stroke(); // Draw the mouth of the smiling face. - let mouthR = radius / 2.5; + let mouthR = radius / 2; let mouthX = circleX; - let mouthY = circleY + (radius / 3); + let mouthY = circleY + 10; this.context.beginPath(); - this.context.arc(mouthX, mouthY, mouthR, Math.PI, 0, true); - this.context.strokeStyle = '#ffff00'; - this.context.lineWidth = 10; + this.context.arc(mouthX, mouthY, mouthR, Math.PI / 1.4, Math.PI / 3.4, true); + this.context.strokeStyle = '#FFFFFF'; + this.context.lineWidth = 15; this.context.stroke(); + this.context.closePath(); }) } }.height('100%').width('100%') @@ -74,4 +87,4 @@ struct Card { The figure below shows the effect. -![WidgetCanvasDemo](figures/WidgetCanvasDemo.png) \ No newline at end of file +![WidgetCanvasDemo](figures/WidgetCanvasDemo.jpeg) \ No newline at end of file diff --git a/en/application-dev/application-models/arkts-ui-widget-update-by-proxy.md b/en/application-dev/application-models/arkts-ui-widget-update-by-proxy.md index e93a1c25dc36358ee8068210dfb7bb1bb0aa035a..c655582af7834992c42025823b94ecab71eaa4ab 100644 --- a/en/application-dev/application-models/arkts-ui-widget-update-by-proxy.md +++ b/en/application-dev/application-models/arkts-ui-widget-update-by-proxy.md @@ -22,7 +22,7 @@ Processing flow of the widget provider (indicated by the blue arrows in the figu 2. In the [onAddForm](../reference/apis/js-apis-app-form-formExtensionAbility.md#onaddform) callback, the widget provider returns the **key** + **subscriberId** combination defined by the data provider to the Widget Manager. -3. Widget Manager parses the subscription information of the widget provider and registers a subscription instance with the data management service. +3. The Widget Manager parses the subscription information of the widget provider and registers a subscription instance with the data management service. Processing flow of the widget update proxy (indicated by the red arrows in the figure): @@ -67,13 +67,13 @@ The update-through-proxy configuration varies by the type of shared data. } ``` -- Configure the subscription information [proxies](../reference/apis/js-apis-app-form-formBindingData.md#proxydata) in the [onAddForm](../reference/apis/js-apis-app-form-formExtensionAbility.md#onaddform) callback and return the information to the Widget Manager through [formBinding](../reference/apis/js-apis-app-form-formBindingData.md#formbindingdata). In this example, **key** is set to **detail** and **subscriberId** is set to **11**. +- Configure the subscription information [proxyData](../reference/apis/js-apis-app-form-formBindingData.md#proxydata10) in the [onAddForm](../reference/apis/js-apis-app-form-formExtensionAbility.md#onaddform) callback and return the information to the Widget Manager through [formBinding](../reference/apis/js-apis-app-form-formBindingData.md#formbindingdata). In this example, **key** is set to **detail** and **subscriberId** is set to **11**. > **NOTE** > > The value of **key** can be a URI or a simple string. The default value of **subscriberId** is the value of **formId**. The actual value depends on the definition of the data provider. ```ts import formBindingData from '@ohos.app.form.formBindingData'; - + let dataShareHelper; onAddForm(want) { let formData = {}; @@ -89,14 +89,14 @@ The update-through-proxy configuration varies by the type of shared data. } ``` -- In the widget page code file **widgets.abc**, use the variable in LocalStorage to obtain the subscribed data. In this example, the subscribed data is obtained through **'detail'** and displayed in the **\** component. +- In the widget page code file **widgets.abc**, use the variable in LocalStorage to obtain the subscribed data. The variable in LocalStorage is bound to a string and updates the subscribed data in the key:value pair format. The key must be the same as that subscribed to by the widget provider. In this example, the subscribed data is obtained through **'detail'** and displayed in the **\** component. ```ts let storage = new LocalStorage(); @Entry(storage) @Component struct Index { @LocalStorageProp('detail') detail: string = 'Loading...'; - + build() { Row() { Column() { @@ -139,7 +139,7 @@ The update-through-proxy configuration varies by the type of shared data. } ``` -- Add a subscription template ([addTemplate]([../reference/apis/js-apis-data-dataShare.md#addtemplate10)) to the [onAddForm](../reference/apis/js-apis-app-form-formExtensionAbility.md#onaddform) callback and use the template predicates to notify the database of the subscribed data conditions. Then, configure the subscription information [proxies](../reference/apis/js-apis-app-form-formBindingData.md#proxydata) and return it to the Widget Manager through [formBinding](../reference/apis/js-apis-app-form-formBindingData.md#formbindingdata). In the example, the predicate is set to **"list": "select type from TBL00 limit 0,1"**, indicating that the first data record in the **type** column is obtained from the **TBL00** database. The data is returned to the widget page code file **widgets.abc** in {"list":[{"type":"value0"}]} format. +- Add a subscription template ([addTemplate](../reference/apis/js-apis-data-dataShare.md#addtemplate10)) to the [onAddForm](../reference/apis/js-apis-app-form-formExtensionAbility.md#onaddform) callback and use the template predicates to notify the database of the subscribed data conditions. Then, configure the subscription information [proxyData](../reference/apis/js-apis-app-form-formBindingData.md#proxydata10) and return it to the Widget Manager through [formBinding](../reference/apis/js-apis-app-form-formBindingData.md#formbindingdata). In the example, the predicate is set to **"list": "select type from TBL00 limit 0,1"**, indicating that the first data record in the **type** column is obtained from the **TBL00** database. The data is returned to the widget page code file **widgets.abc** in {"list":[{"type":"value0"}]} format. > **NOTE** > @@ -178,7 +178,7 @@ The update-through-proxy configuration varies by the type of shared data. } ``` -- In the widget page code file **widgets.abc**, use the variable in LocalStorage to obtain the subscribed data. In the example, the subscribed data is obtained through **'list'**, and the value of the first element is displayed on the **\** component. +- In the widget page code file (generally the .ets file in the **pages** folder under the widget directory of the project), use the variable in LocalStorage to obtain the subscribed data. The variable in LocalStorage is bound to a string and updates the subscribed data in the key:value pair format. The key must be the same as that subscribed to by the widget provider. In the example, the subscribed data is obtained through **'list'**, and the value of the first element is displayed on the **\** component. ```ts let storage = new LocalStorage(); @Entry(storage) @@ -190,7 +190,7 @@ The update-through-proxy configuration varies by the type of shared data. readonly FULL_WIDTH_PERCENT: string = '100%'; readonly FULL_HEIGHT_PERCENT: string = '100%'; @LocalStorageProp('list') list: Array = [{"type": "a"}]; - + build() { Row() { Column() { @@ -216,4 +216,3 @@ The update-through-proxy configuration varies by the type of shared data. ## Data Provider Development For details, see [Data Management](../database/data-mgmt-overview.md). - \ No newline at end of file diff --git a/en/application-dev/application-models/arkts-ui-widget-update-by-time.md b/en/application-dev/application-models/arkts-ui-widget-update-by-time.md index 1e70db6ef0126b42ee2f4b3a7280fd2a7cbaa5a1..c3fcf45f3b95e88ca1a0f2bc13aefa94100873c0 100644 --- a/en/application-dev/application-models/arkts-ui-widget-update-by-time.md +++ b/en/application-dev/application-models/arkts-ui-widget-update-by-time.md @@ -95,3 +95,4 @@ When periodic update is triggered, the system calls the [onUpdateForm()](../refe > - Each widget can be updated at the specified interval for a maximum of 50 times every day, including updates triggered by setting [updateDuration](arkts-ui-widget-configuration.md) or calling [setFormNextRefreshTime()](../reference/apis/js-apis-app-form-formProvider.md#setformnextrefreshtime). When the limit is reached, the widget cannot be updated in this mode again. The number of update times is reset at 00:00 every day. >- A single timer is used for timing updates at the specified interval. Therefore, if a widget is configured to update at scheduled intervals, the first scheduled update may have a maximum deviation of 30 minutes. For example, if widget A (updated every half an hour) is added at 03:20 and widget B (also updated every half an hour) is added at 03:40, the first update of widget B has a deviation of 10 minutes to the expected time: The timer starts at 03:20 when widget A is added, triggers an update for widget A at 03:50, and triggers another update for widget B at 04:20 (instead of 04:10 as expected). > - Updates at the specified interval and updates at the scheduled time are triggered only when the screen is on. The update action is merely recorded when the screen is off and is performed once the screen is on. +>- If the [update-through-proxy](./arkts-ui-widget-update-by-proxy.md) feature is enabled, the settings for the update interval and next update time will not take effect. diff --git a/en/application-dev/application-models/driverextensionability.md b/en/application-dev/application-models/driverextensionability.md new file mode 100644 index 0000000000000000000000000000000000000000..c8063abf88ab3e48c551dd8e28e3eda2db56c664 --- /dev/null +++ b/en/application-dev/application-models/driverextensionability.md @@ -0,0 +1,129 @@ +# DriverExtensionAbility + +[DriverExtensionAbility](../reference/apis/js-apis-app-ability-driverExtensionAbility.md) is an ExtensionAbility of the driver type that provides driver-related extension framework. If the capabilities of a device can be expanded by inserting an external hardware module, you can install the driver of the hardware module through an application. DriverExtensionAbility can be used to develop such applications. + + +The [DriverExtensionAbility](../reference/apis/js-apis-app-ability-driverExtensionAbility.md) can be bound to an application through the DriverExtensionManager and process related transactions in the background based on the application request information. +Each type of ExtensionAbility has its own context. The DriverExtensionAbility provides related capabilities through the [DriverExtensionContext](../reference/apis/js-apis-inner-application-driverExtensionContext.md). + +This topic describes how to use DriverExtensionAbility in the following scenarios: + +- [DriverExtensionAbility](#driverextensionability) + - [How to Develop](#how-to-develop) + +## How to Develop + +To implement a driver, create a DriverExtensionAbility in the DevEco Studio project. The procedure is as follows: + +1. In the **ets** directory of a module in the project, right-click and choose **New > Directory** to create a directory named **driverextability**. + +2. In the **driverextability** directory, right-click and choose **New > TypeScript File** to create a file named **DriverExtAbility.ts**. + +3. Open the **DriverExtAbility.ts** file, import the [RPC module](../reference/apis/js-apis-rpc.md), and overload the **onRemoteMessageRequest()** method to receive messages from the application and return the processing result to the application. **REQUEST_VALUE** is used to verify the service request code sent by the application. + + ```ts + import rpc from '@ohos.rpc'; + + const REQUEST_CODE = 99; + + class StubTest extends rpc.RemoteObject { + constructor(des) { + super(des); + } + + // Receive the message sent from the application and return the processing result to the application. + onRemoteMessageRequest(code, data, reply, option) { + if (code === REQUEST_CODE) { + // Receive the data sent from the application. + // When the application calls data.writeInt() multiple times to write data, the driver can receive the corresponding data by calling data.readInt() for multiple times. + let optFir = data.readInt(); + let optSec = data.readInt(); + // The driver returns the data processing result to the application. + // In the example, two pieces of data are received, and the sum of the two pieces of data is returned to the application. + reply.writeInt(optFir + optSec); + } + return true; + } + } + ``` + + +4. In the **DriverExtAbility.ts** file, import the dependency package [DriverExtensionAbility](../reference/apis/js-apis-app-ability-driverExtensionAbility.md), which provides the **onInit()**, **onRelease()**, **onConnect()**, and **onDisconnect()** lifecycle callbacks. Then, customize a class to inherit from [DriverExtensionAbility](../reference/apis/js-apis-app-ability-driverExtensionAbility.md) and override the lifecycle callbacks as required. + + ```ts + import DriverExtensionAbility from '@ohos.app.ability.DriverExtensionAbility'; + import rpc from '@ohos.rpc'; + + const TAG: string = '[Example].[Entry].[DriverExtAbility]'; + const REQUEST_CODE = 99; + + class StubTest extends rpc.RemoteObject { + // ... + } + + export default class DriverExtAbility extends DriverExtensionAbility { + onInit(want) { + console.info(TAG, `onInit, want: ${want.abilityName}`); + } + + onRelease() { + console.info(TAG, `onRelease, want: ${want.abilityName}`); + } + + onConnect(want) { + console.info(TAG, `onConnect, want: ${want.abilityName}`); + return new StubTest("test"); + } + + onDisconnect(want) { + console.info(TAG, `onDisconnect, want: ${want.abilityName}`); + } + + onDump() { + console.info(TAG, `onDump, params:` + JSON.stringify(params)); + return ['params']; + } + } + ``` + +5. Register the DriverExtensionAbility in the [**module.json5** file](../quick-start/module-configuration-file.md) of the module in the project. Set **type** to **service** and **srcEntry** to the code path of the DriverExtensionAbility component. + + ```json + { + "module": { + // ... + "extensionAbilities": [ + { + "name": "DriverExtAbility", + "icon": "$media:icon", + "description": "driver", + "type": "driver", + "exported": true, + "srcEntry": "./ets/driverextability/DriverExtAbility.ts", + "metadata": [ + { + "name": "bus", // The bus is mandatory. + "value": "USB", + }, + { + "name": "desc", // Description of the driver, which is mandatory. + "value": "the sample of driverExtensionAbility", + }, + { + "name": "vendor", // Driver vendor name, which is mandatory. + "value": "string", + }, + { + "name": "vid", // List of supported USB vendor IDs, separated by commas (,). The value cannot be empty. + "value": "string, string", + }, + { + "name": "pid", // List of supported USB product IDs, separated by commas (,). The value cannot be empty. + "value": "string, string", + } + ] + } + ] + } + } + ``` diff --git a/en/application-dev/application-models/figures/WidgetCanvasDemo.jpeg b/en/application-dev/application-models/figures/WidgetCanvasDemo.jpeg new file mode 100644 index 0000000000000000000000000000000000000000..3961eba1947c74229e43af53d1ad525af414028f Binary files /dev/null and b/en/application-dev/application-models/figures/WidgetCanvasDemo.jpeg differ diff --git a/en/application-dev/application-models/figures/WidgetCanvasDemo.png b/en/application-dev/application-models/figures/WidgetCanvasDemo.png deleted file mode 100644 index c09c82dd88cf002020990b5b8327701c445eeaaf..0000000000000000000000000000000000000000 Binary files a/en/application-dev/application-models/figures/WidgetCanvasDemo.png and /dev/null differ diff --git a/en/application-dev/quick-start/app-configuration-file.md b/en/application-dev/quick-start/app-configuration-file.md index 6977c5c7cc53085d66e38ec8edd33bddb0623ff7..0d317685bef83223088752ac44a47bd0373cb9df 100644 --- a/en/application-dev/quick-start/app-configuration-file.md +++ b/en/application-dev/quick-start/app-configuration-file.md @@ -35,7 +35,7 @@ As shown above, the **app.json5** file contains several tags. | Name| Description| Data Type| Initial Value Allowed| | -------- | -------- | -------- | -------- | | bundleName | Bundle name, which uniquely identifies an application. The value must comply with the following rules:
- Consists of letters, digits, underscores (_), and periods (.).
- Starts with a letter.
- Contains 7 to 127 bytes.
You are advised to use the reverse domain name notation, for example, *com.example.demo*, where the first part is the domain suffix **com**, the second part is the vendor/individual name, and the third part is the application name, which can be of multiple levels.
If an application is built with the system source code, you are advised to name it in *com.ohos.demo* notation, where **ohos** signifies that the application is an OpenHarmony system application.| String| No| -| bundleType| Bundle type, which is used to distinguish applications and atomic services.
- **app**: The bundle is a common application.
- **atomicService**: The bundle is an atomic service.
- **shared**: The bundle is a shared object application.| String| Yes (initial value: **"app"**)| +| bundleType| Bundle type, which is used to distinguish applications and atomic services.
- **app**: The bundle is a common application.
- **atomicService**: The bundle is an atomic service.
- **shared**: The bundle is a shared object application.| String| Yes (initial value: **"app"**)| | debug | Whether the application can be debugged. This tag is generated during compilation and building in DevEco Studio.
- **true**: The application can be debugged.
- **false**: The application cannot be debugged.| Boolean| Yes (initial value: **false**)| | icon | [Icon of the application](../application-models/application-component-configuration-stage.md). The value is an icon resource index.| String| No| | label | [Name of the application](../application-models/application-component-configuration-stage.md). The value is a string resource index.| String| No| diff --git a/en/application-dev/quick-start/arkts-appstorage.md b/en/application-dev/quick-start/arkts-appstorage.md index 2f11d6b826d0a0e280c3efdc00905e509fb0e9f6..50cbcf6aa0854fc901eb6bbf80b41da7c990eaa1 100644 --- a/en/application-dev/quick-start/arkts-appstorage.md +++ b/en/application-dev/quick-start/arkts-appstorage.md @@ -12,7 +12,7 @@ This topic describes only the AppStorage application scenarios and related decor ## Overview -AppStorage is a singleton LocalStorage object that is created by the UI framework at application startup. Its purpose is to provide the central storage for mutable application UI state attributes. AppStorage retains all those attributes and their values as long as the application remains running. Attributes are accessed using a unique key string value. +AppStorage is a singleton object that is created at application startup. Its purpose is to provide the central storage for mutable application UI state attributes. AppStorage retains all those attributes and their values as long as the application remains running. Attributes are accessed using a unique key string value. UI components synchronize application state attributes with the AppStorage. Implementation of application business logic can access AppStorage as well. @@ -21,7 +21,7 @@ Selected state attributes of AppStorage can be synced with different data source ## \@StorageProp -As mentioned above, if you want to establish a binding between AppStorage and a custom component, you need to use the \@StorageProp and \@StorageLink decorators. Use \@StorageProp(key) or \@StorageLink(key) to decorate variables in the component. **key** identifies the attribute in AppStorage. +As mentioned above, if you want to establish a binding between AppStorage and a custom component, you'll need the \@StorageProp and \@StorageLink decorators. Use \@StorageProp(key) or \@StorageLink(key) to decorate variables in the component, where **key** identifies the attribute in AppStorage. When a custom component is initialized, the \@StorageProp(key)/\@StorageLink(key) decorated variable is initialized with the value of the attribute with the given key in AppStorage. Local initialization is mandatory. If an attribute with the given key is missing from AppStorage, it will be added with the stated initializing value. (Whether the attribute with the given key exists in AppStorage depends on the application logic.) @@ -34,7 +34,7 @@ By decorating a variable with \@StorageProp(key), a one-way data synchronization | \@StorageProp Decorator| Description | | ------------------ | ---------------------------------------- | | Decorator parameters | **key**: constant string, mandatory (note, the string is quoted) | -| Allowed variable types | Object, class, string, number, Boolean, enum, and array of these types. For details about the scenarios of nested objects, see [Observed Changes and Behavior](#observed-changes-and-behavior).
The type must be specified and must be the same as the corresponding attribute in LocalStorage. **any** is not supported. The **undefined** and **null** values are not allowed.| +| Allowed variable types | Object, class, string, number, Boolean, enum, and array of these types. For details about the scenarios of nested objects, see [Observed Changes and Behavior](#observed-changes-and-behavior).
The type must be specified. Whenever possible, use the same type as that of the corresponding attribute in AppStorage. Otherwise, implicit type conversion occurs, causing application behavior exceptions. **any** is not supported. The **undefined** and **null** values are not allowed.| | Synchronization type | One-way: from the attribute in AppStorage to the component variable.
The component variable can be changed locally, but an update from AppStorage will overwrite local changes.| | Initial value for the decorated variable | Mandatory. It is used as the default value for initialization if the attribute does not exist in AppStorage.| @@ -44,7 +44,7 @@ By decorating a variable with \@StorageProp(key), a one-way data synchronization | Transfer/Access | Description | | ---------- | ---------------------------------------- | | Initialization and update from the parent component| Forbidden.| -| Subnode initialization | Supported; can be used to initialize a n \@State, \@Link, \@Prop, or \@Provide decorated variable in the child component.| +| Subnode initialization | Supported; can be used to initialize an \@State, \@Link, \@Prop, or \@Provide decorated variable in the child component.| | Access | None. | @@ -92,7 +92,7 @@ By decorating a variable with \@StorageProp(key), a one-way data synchronization | \@StorageLink Decorator| Description | | ------------------ | ---------------------------------------- | | Decorator parameters | **key**: constant string, mandatory (note, the string is quoted) | -| Allowed variable types | Object, class, string, number, Boolean, enum, and array of these types. For details about the scenarios of nested objects, see [Observed Changes and Behavior](#observed-changes-and-behavior).
The type must be specified and must be the same as the corresponding attribute in AppStorage. **any** is not supported. The **undefined** and **null** values are not allowed.| +| Allowed variable types | Object, class, string, number, Boolean, enum, and array of these types. For details about the scenarios of nested objects, see [Observed Changes and Behavior](#observed-changes-and-behavior).
The type must be specified. Whenever possible, use the same type as that of the corresponding attribute in AppStorage. Otherwise, implicit type conversion occurs, causing application behavior exceptions. **any** is not supported. The **undefined** and **null** values are not allowed.| | Synchronization type | Two-way: from the attribute in AppStorage to the custom component variable and back| | Initial value for the decorated variable | Mandatory. It is used as the default value for initialization if the attribute does not exist in AppStorage.| @@ -193,6 +193,181 @@ struct CompA { } ``` +### Persistent Subscription and Callback + +The persistent subscription and callback can help reduce overhead and enhance code readability. + + +```ts +// xxx.ets +import emitter from '@ohos.events.emitter'; + +let NextID: number = 0; + +class ViewData { + title: string; + uri: Resource; + color: Color = Color.Black; + id: number; + + constructor(title: string, uri: Resource) { + this.title = title; + this.uri = uri + this.id = NextID++; + } +} + +@Entry +@Component +struct Gallery2 { + dataList: Array = [new ViewData('flower', $r('app.media.icon')), new ViewData('OMG', $r('app.media.icon')), new ViewData('OMG', $r('app.media.icon'))] + scroller: Scroller = new Scroller() + private preIndex: number = -1 + + build() { + Column() { + Grid(this.scroller) { + ForEach(this.dataList, (item: ViewData) => { + GridItem() { + TapImage({ + uri: item.uri, + index: item.id + }) + }.aspectRatio(1) + .onClick(() => { + if (this.preIndex === item.id) { + return + } + var innerEvent = { eventId: item.id } + // Selected: from black to red + var eventData = { + data: { + "colorTag": 1 + } + } + emitter.emit(innerEvent, eventData) + + if (this.preIndex != -1) { + console.info(`preIndex: ${this.preIndex}, index: ${item.id}, black`) + var innerEvent = { eventId: this.preIndex } + // Deselected: from red to black + var eventData = { + data: { + "colorTag": 0 + } + } + emitter.emit(innerEvent, eventData) + } + this.preIndex = item.id + }) + + }, (item: ViewData) => JSON.stringify(item)) + }.columnsTemplate('1fr 1fr') + } + + } +} + +@Component +export struct TapImage { + @State tapColor: Color = Color.Black; + private index: number; + private uri: Resource; + + onTapIndexChange(colorTag: emitter.EventData) { + this.tapColor = colorTag.data.colorTag ? Color.Red : Color.Black + } + + aboutToAppear() { + // Define the event ID. + var innerEvent = { eventId: this.index } + emitter.on(innerEvent, this.onTapIndexChange.bind(this)) + } + + build() { + Column() { + Image(this.uri) + .objectFit(ImageFit.Cover) + .border({ width: 5, style: BorderStyle.Dotted, color: this.tapColor }) + } + } +} +``` + +The following example uses the message mechanism to subscribe to events. Because this mechanism can result in a large number of nodes to listen for and a long implementation time, it is not recommended. + + +```ts +// xxx.ets +class ViewData { + title: string; + uri: Resource; + color: Color = Color.Black; + + constructor(title: string, uri: Resource) { + this.title = title; + this.uri = uri + } +} + +@Entry +@Component +struct Gallery2 { + dataList: Array = [new ViewData('flower', $r('app.media.icon')), new ViewData('OMG', $r('app.media.icon')), new ViewData('OMG', $r('app.media.icon'))] + scroller: Scroller = new Scroller() + + build() { + Column() { + Grid(this.scroller) { + ForEach(this.dataList, (item: ViewData, index?: number) => { + GridItem() { + TapImage({ + uri: item.uri, + index: index + }) + }.aspectRatio(1) + + }, (item: ViewData, index?: number) => { + return JSON.stringify(item) + index; + }) + }.columnsTemplate('1fr 1fr') + } + + } +} + +@Component +export struct TapImage { + @StorageLink('tapIndex') @Watch('onTapIndexChange') tapIndex: number = -1; + @State tapColor: Color = Color.Black; + private index: number; + private uri: Resource; + + // Check whether the component is selected. + onTapIndexChange() { + if (this.tapIndex >= 0 && this.index === this.tapIndex) { + console.info(`tapindex: ${this.tapIndex}, index: ${this.index}, red`) + this.tapColor = Color.Red; + } else { + console.info(`tapindex: ${this.tapIndex}, index: ${this.index}, black`) + this.tapColor = Color.Black; + } + } + + build() { + Column() { + Image(this.uri) + .objectFit(ImageFit.Cover) + .onClick(() => { + this.tapIndex = this.index; + }) + .border({ width: 5, style: BorderStyle.Dotted, color: this.tapColor }) + } + + } +} +``` + ## Restrictions @@ -201,4 +376,6 @@ When using AppStorage together with [PersistentStorage](arkts-persiststorage.md) - A call to **PersistentStorage.PersistProp()** after creating the attribute in AppStorage uses the type and value in AppStorage and overwrites any attribute with the same name in PersistentStorage. In light of this, the opposite order of calls is recommended. For an example of incorrect usage, see [Accessing Attribute in AppStorage Before PersistentStorage](arkts-persiststorage.md#accessing-attribute-in-appstorage-before-persistentstorage). - A call to **Environment.EnvProp()** after creating the attribute in AppStorage will fail. This is because AppStorage already has an attribute with the same name, and the environment variable will not be written into AppStorage. Therefore, you are advised not to use the preset environment variable name in AppStorage. + +- Changes to the variables decorated by state decorators will cause UI re-render. If the changes are for message communication, rather than for UI re-render, the emitter mode is recommended. For the example, see [Persistent Subscription and Callback](#persistent-subscription-and-callback). diff --git a/en/application-dev/quick-start/arkts-link.md b/en/application-dev/quick-start/arkts-link.md index 81db9ef3e2f4ce2df8cec8a1c793712ca79374d8..0fcfa8142ad3bca5a46f03aa7b5ff2d550d7c495 100644 --- a/en/application-dev/quick-start/arkts-link.md +++ b/en/application-dev/quick-start/arkts-link.md @@ -20,7 +20,7 @@ An \@Link decorated variable in a child component shares the same value with a v | ----------- | ---------------------------------------- | | Decorator parameters | None. | | Synchronization type | Two-way:
from an \@State, \@StorageLink, or \@Link decorated variable in the parent component to this variable; and the other way around.| -| Allowed variable types | Object, class, string, number, Boolean, enum, and array of these types. For details about the scenarios of nested types, see [Observed Changes](#observed-changes).
The type must be specified and must be the same as that of the counterpart variable of the parent component.
**any** is not supported. A combination of simple and complex types is not supported. The **undefined** and **null** values are not allowed.
**NOTE**
The Length, ResourceStr, and ResourceColor types are a combination of simple and complex types and therefore not supported.| +| Allowed variable types | Object, class, string, number, Boolean, enum, and array of these types.
Date type. For details about the scenarios of supported types, see [Observed Changes](#observed-changes).
The type must be specified and must be the same as that of the counterpart variable of the parent component.
**any** is not supported. A combination of simple and complex types is not supported. The **undefined** and **null** values are not allowed.
**NOTE**
The Length, ResourceStr, and ResourceColor types are a combination of simple and complex types and therefore not supported.| | Initial value for the decorated variable | Forbidden. | @@ -28,7 +28,7 @@ An \@Link decorated variable in a child component shares the same value with a v | Transfer/Access | Description | | ---------- | ---------------------------------------- | -| Initialization and update from the parent component| Mandatory. A two-way synchronization relationship can be established with the @State, @StorageLink, or \@Link decorated variable in the parent component. An \@Link decorated variable can be initialized from an \@State, \@Link, \@Prop, \@Provide, \@Consume, \@ObjectLink, \@StorageLink, \@StorageProp, \@LocalStorageLink, or \@LocalStorageProp decorated variable in the parent component.
Since API version 9, the syntax is **Comp({ aLink: this.aState })** for initializing an \@Link decorated variable in the child component from an @State decorated variable in its parent component. The **Comp({aLink: $aState})** syntax is also supported| +| Initialization and update from the parent component| Mandatory. A two-way synchronization relationship can be established with the @State, @StorageLink, or \@Link decorated variable in the parent component. An \@Link decorated variable can be initialized from an \@State, \@Link, \@Prop, \@Provide, \@Consume, \@ObjectLink, \@StorageLink, \@StorageProp, \@LocalStorageLink, or \@LocalStorageProp decorated variable in the parent component.
Since API version 9, the syntax is **Comp({ aLink: this.aState })** for initializing an \@Link decorated variable in the child component from an @State decorated variable in its parent component. The **Comp({aLink: $aState})** syntax is also supported.| | Subnode initialization | Supported; can be used to initialize a regular variable or \@State, \@Link, \@Prop, or \@Provide decorated variable in the child component.| | Access | Private, accessible only within the component. | @@ -48,6 +48,61 @@ An \@Link decorated variable in a child component shares the same value with a v - When the decorated variable is of the array type, the addition, deletion, and updates of array items can be observed. For details, see [Array Type \@Link](#array-type-link). +- When the decorated variable is of the Date type, the overall value assignment of the Date object can be observed, and the following APIs can be called to update Date attributes: **setFullYear**, **setMonth**, **setDate**, **setHours**, **setMinutes**, **setSeconds**, **setMilliseconds**, **setTime**, **setUTCFullYear**, **setUTCMonth**, **setUTCDate**, **setUTCHours**, **setUTCMinutes**, **setUTCSeconds**, and **setUTCMilliseconds**. + +```ts +@Component +struct DateComponent { + @Link selectedDate: Date; + + build() { + Column() { + Button(`child increase the year by 1`).onClick(() => { + this.selectedDate.setFullYear(this.selectedDate.getFullYear() + 1) + }) + Button('child update the new date') + .margin(10) + .onClick(() => { + this.selectedDate = new Date('2023-09-09') + }) + DatePicker({ + start: new Date('1970-1-1'), + end: new Date('2100-1-1'), + selected: this.selectedDate + }) + } + + } +} + +@Entry +@Component +struct ParentComponent { + @State parentSelectedDate: Date = new Date('2021-08-08'); + + build() { + Column() { + Button('parent increase the month by 1') + .margin(10) + .onClick(() => { + this.parentSelectedDate.setMonth(this.parentSelectedDate.getMonth() + 1) + }) + Button('parent update the new date') + .margin(10) + .onClick(() => { + this.parentSelectedDate = new Date('2023-07-07') + }) + DatePicker({ + start: new Date('1970-1-1'), + end: new Date('2100-1-1'), + selected: this.parentSelectedDate + }) + + DateComponent({selectedDate:this.parentSelectedDate}) + } + } +} +``` ### Framework Behavior @@ -184,4 +239,5 @@ struct Parent { As described above, the ArkUI framework can observe the addition, deletion, and replacement of array items. It should be noted that, in the preceding example, the type of the \@Link and \@State decorated variables is the same: number[]. It is not allowed to define the \@Link decorated variable in the child component as type number (**\@Link item: number**), and create child components for each array item in the \@State decorated array in the parent component. [\@Prop](arkts-prop.md) or \@Observed should be used depending on application semantics. + diff --git a/en/application-dev/quick-start/arkts-localstorage.md b/en/application-dev/quick-start/arkts-localstorage.md index 6be9a62d0c84043783c75d29e4af3e7d252829c0..0116d2e18f9023d5769b6b0b67b561b41bb0e149 100644 --- a/en/application-dev/quick-start/arkts-localstorage.md +++ b/en/application-dev/quick-start/arkts-localstorage.md @@ -60,7 +60,7 @@ By decorating a variable with \@LocalStorageProp(key), a one-way data synchroniz | \@LocalStorageProp Decorator| Description | | ----------------------- | ---------------------------------------- | | Decorator parameters | **key**: constant string, mandatory (note, the string is quoted) | -| Allowed variable types | Object, class, string, number, Boolean, enum, and array of these types. For details about the scenarios of nested objects, see [Observed Changes and Behavior](#observed-changes-and-behavior).
The type must be specified and must be the same as the corresponding attribute in LocalStorage. **any** is not supported. The **undefined** and **null** values are not allowed.| +| Allowed variable types | Object, class, string, number, Boolean, enum, and array of these types. For details about the scenarios of nested objects, see [Observed Changes and Behavior](#observed-changes-and-behavior).
The type must be specified. Whenever possible, use the same type as that of the corresponding attribute in LocalStorage. Otherwise, implicit type conversion occurs, causing application behavior exceptions. **any** is not supported. The **undefined** and **null** values are not allowed.| | Synchronization type | One-way: from the attribute in LocalStorage to the component variable. The component variable can be changed locally, but an update from LocalStorage will overwrite local changes.| | Initial value for the decorated variable | Mandatory. It is used as the default value for initialization if the attribute does not exist in LocalStorage.| @@ -118,7 +118,7 @@ By decorating a variable with \@LocalStorageProp(key), a one-way data synchroniz | \@LocalStorageLink Decorator| Description | | ----------------------- | ---------------------------------------- | | Decorator parameters | **key**: constant string, mandatory (note, the string is quoted) | -| Allowed variable types | Object, class, string, number, Boolean, enum, and array of these types. For details about the scenarios of nested objects, see [Observed Changes and Behavior](#observed-changes-and-behavior).
The type must be specified and must be the same as the corresponding attribute in LocalStorage. **any** is not supported. The **undefined** and **null** values are not allowed.| +| Allowed variable types | Object, class, string, number, Boolean, enum, and array of these types. For details about the scenarios of nested objects, see [Observed Changes and Behavior](#observed-changes-and-behavior).
The type must be specified. Whenever possible, use the same type as that of the corresponding attribute in LocalStorage. Otherwise, implicit type conversion occurs, causing application behavior exceptions. **any** is not supported. The **undefined** and **null** values are not allowed.| | Synchronization type | Two-way: from the attribute in LocalStorage to the custom component variable and back| | Initial value for the decorated variable | Mandatory. It is used as the default value for initialization if the attribute does not exist in LocalStorage.| @@ -292,7 +292,7 @@ struct CompA { .onClick(() => this.storLink += 1) - // You are not advised to use the global variable linkToPropA.get() in the component because errors may occur due to different life cycles. + // Avoid using the global variable linkToPropA.get() in the component. Doing so may cause errors due to different lifecycles. Text(`@LocalStorageLink: ${this.storLink} - linkToPropA: ${linkToPropA.get()}`) } } @@ -306,7 +306,7 @@ This example shows how to use \@LocalStorageLink to create a two-way synchroniza Check the changes in the **Parent** custom component. -1. Clicking **countStorage ${this.playCount} incr by 1** decreases the value of **this.playCount** by 1. This change is synchronized to LocalStorage and to the components bound to **playCountLink** in the **Child** component. +1. Clicking **playCount ${this.playCount} dec by 1** decreases the value of **this.playCount** by 1. This change is synchronized to LocalStorage and to the components bound to **playCountLink** in the **Child** component. 2. Click **countStorage ${this.playCount} incr by 1** to call the **set** API in LocalStorage to update the attributes corresponding to **countStorage** in LocalStorage. The components bound to** playCountLink** in the **Child** component are updated synchronously. @@ -379,7 +379,7 @@ Changes in the **Child** custom component: ### Sharing a LocalStorage Instance from UIAbility to One or More Pages -In the preceding examples, the LocalStorage instance is shared only in an \@Entry decorated component and its owning child component (a page). To enable a LocalStorage instance to be shared across pages, you can create a LocalStorage instance in the owning UIAbility and call windowStage.[loadContent](https://gitee.com/openharmony/docs/blob/master/en/application-dev/reference/apis/js-apis-window.md#loadcontent9). +In the preceding examples, the LocalStorage instance is shared only in an \@Entry decorated component and its owning child component (a page). To enable a LocalStorage instance to be shared across pages, you can create a LocalStorage instance in the owning UIAbility and call windowStage.[loadContent](../reference/apis/js-apis-window.md#loadcontent9). ```ts @@ -420,7 +420,6 @@ struct CompA { } ``` - > **NOTE** > > It is good practice to always create a LocalStorage instance with meaningful default values, which serve as a backup when execution exceptions occur and are also useful for unit testing of pages. diff --git a/en/application-dev/quick-start/arkts-observed-and-objectlink.md b/en/application-dev/quick-start/arkts-observed-and-objectlink.md index 808e522540be970004aab0a2bcd2009af3916df0..61f1bd8ae476f5984405eed97fb127161bb131e2 100644 --- a/en/application-dev/quick-start/arkts-observed-and-objectlink.md +++ b/en/application-dev/quick-start/arkts-observed-and-objectlink.md @@ -15,7 +15,7 @@ The decorators described above can observe only the changes of the first layer. - Regarding classes decorated by \@Observed, the attribute changes can be observed. -- The \@ObjectLink decorated state variable in the child component is used to accept the instance of the \@Observed decorated class and establish two-way data binding with the corresponding state variable in the parent component. The instance can be an \@Observed decorated item in the array or an \@Observeddecorated attribute in the class object. +- The \@ObjectLink decorated state variable in the child component is used to accept the instance of the \@Observed decorated class and establish two-way data binding with the corresponding state variable in the parent component. The instance can be an \@Observed decorated item in the array or an \@Observed decorated attribute in the class object. - Using \@Observed alone has no effect. Combined use with \@ObjectLink for two-way synchronization or with [\@Prop](arkts-prop.md) for one-way synchronization is required. @@ -54,7 +54,7 @@ this.objLink= ... > > - \@Prop creates a one-way synchronization from the data source to the decorated variable. It takes a copy of its source tp enable changes to remain local. When \@Prop observes a change to its source, the local value of the \@Prop decorated variable is overwritten. > -> - \@ObjectLink creates a two-way synchronization between the data source and the decorated variable. An \@ObjectLink decorated variable can be considered as a pointer to the source object inside the parent component. If value assignment of an \@ObjectLink decorated variable occurs, the synchronization chain is interrupted. +> - \@ObjectLink creates a two-way synchronization between the data source and the decorated variable. An \@ObjectLink decorated variable can be considered as a pointer to the source object inside the parent component. Do not assign values to \@ObjectLink decorated variables, as doing so will interrupt the synchronization chain. \@ObjectLink decorated variables are initialized through data source (Object) references. Assigning a value to them is equivalent to updating the array item or class attribute in the parent component, which is not supported in TypeScript/JavaScript and will result in a runtime error. ## Variable Transfer/Access Rules @@ -216,13 +216,13 @@ Event handlers in **ViewB**: - this.b.a = new ClassA(0) and this.b = new ClassB(new ClassA(0)): Change to the \@State decorated variable **b** and its attributes. -- this.b.a.c = ... : Second change. [@State](arkts-state.md#observed-changes) cannot observe the change of the second layer, but ClassA is decorated by \@Observed, and therefore the change of its attribute c can be observed by \@ObjectLink. +- this.b.a.c = ... : Change at the second layer. Though [@State](arkts-state.md#observed-changes) cannot observe the change at the second layer, the change of an attribute of \@Observed decorated ClassA, which is attribute **c** in this example, can be observed by \@ObjectLink. Event handlers in **ViewA**: -- this.a.c += 1: Changes to the \@ObjectLink decorated variable which cause the button label to be updated. Unlike \@Prop, \@ObjectLink does not have a copy of its source. Instead, \@ObjectLink creates a reference to its source. +- this.a.c += 1: Changes to the \@ObjectLink decorated variable cause the button label to be updated. Unlike \@Prop, \@ObjectLink does not have a copy of its source. Instead, \@ObjectLink creates a reference to its source. - The \@ObjectLink decorated variable is read-only. Assigning **this.a = new ClassA(...)** is not allowed. Once value assignment occurs, the reference to the data source is reset and the synchronization is interrupted. @@ -300,7 +300,7 @@ struct ViewB { 1. ForEach: The newly added Class A object is unknown to the **ForEach** [itemGenerator](arkts-rendering-control-foreach.md#api-description). The item builder of **ForEach** will be executed to create a **View A** component instance. 2. ViewA({ label: ViewA this.arrA[last], a: this.arrA[this.arrA.length-1] }): The last item of the array is changed. As a result, the second **View A** component instance is changed. For **ViewA({ label: ViewA this.arrA[first], a: this.arrA[0] })**, a change to the array does not trigger a change to the array item, so the first **View A** component instance is not refreshed. -- this.arrA[Math.floor (this.arrA.length/2)].c: [@State](arkts-state.md#observed-changes) cannot observe changes in the second layer. However, as **ClassA** is decorated by \@Observed, the change of its attributes will be observed by \@ObjectLink. +- this.arrA[Math.floor (this.arrA.length/2)].c: [@State](arkts-state.md#observed-changes) cannot observe changes at the second layer. However, as **ClassA** is decorated by \@Observed, the change of its attributes will be observed by \@ObjectLink. ### Two-Dimensional Array diff --git a/en/application-dev/quick-start/arkts-prop.md b/en/application-dev/quick-start/arkts-prop.md index 1e962f469695d8d942847469dbebec1fcbf30ade..968673943256251a8d35a842663d2976ee5b5019 100644 --- a/en/application-dev/quick-start/arkts-prop.md +++ b/en/application-dev/quick-start/arkts-prop.md @@ -20,12 +20,12 @@ For an \@Prop decorated variable, the value synchronization is uni-directional f ## Rules of Use -| \@Prop Decorator | Description | -| ------------------ | ------------------------------------------------------------ | -| Decorator parameters | None. | -| Synchronization type | One-way: from the data source provided by the parent component to the @Prop decorated variable. For details about the scenarios of nested types, see [Observed Changes](#observed-changes).| -| Allowed variable types| Object, class, string, number, Boolean, enum, and array of these types.
**any** is not supported. A combination of simple and complex types is not supported. The **undefined** and **null** values are not allowed.
The type must be specified.
**NOTE**
The Length, ResourceStr, and ResourceColor types are a combination of simple and complex types and therefore not supported.
Negative examples:
CompA ({ aProp: undefined })
CompA ({ aProp: null })
The type must be the same as that of the [data source](arkts-state-management-overview.md#basic-concepts). There are three cases:
- Synchronizing the \@Prop decorated variable from an \@State or other decorated variable. Example: [Simple Type @Prop Synced from @State in Parent Component](#simple-type-prop-synced-from-state-in-parent-component).
- Synchronizing the \@Prop decorated variable from the item of an \@State or other decorated array. Example: [Simple Type @Prop Synced from @State Array Item in Parent Component](#simple-type-prop-synced-from-state-array-item-in-parent-component).
- Synchronizing the \@Prop decorated variable from a state attribute of the Object or class type in the parent component. Example: [Class Object Type @Prop Synced from @State Class Object Attribute in Parent Component](#class-object-type-prop-synced-from-state-class-object-attribute-in-parent-component).| -| Initial value for the decorated variable| Local initialization is allowed. | +| \@Prop Decorator| Description | +| ----------- | ---------------------------------------- | +| Decorator parameters | None. | +| Synchronization type | One-way: from the data source provided by the parent component to the @Prop decorated variable. For details about the scenarios of nested types, see [Observed Changes](#observed-changes).| +| Allowed variable types | Object, class, string, number, Boolean, enum, and array of these types.
**any** is not supported. A combination of simple and complex types is not supported. The **undefined** and **null** values are not allowed.
Date type.
For details about the scenarios of supported types, see [Observed Changes](#observed-changes).
The type must be specified.
**NOTE**
The Length, ResourceStr, and ResourceColor types are a combination of simple and complex types and therefore not supported.
Negative examples:
CompA ({ aProp: undefined })
CompA ({ aProp: null })
The type must be the same as that of the [data source](arkts-state-management-overview.md#basic-concepts). There are three cases:
- Synchronizing the \@Prop decorated variable from an \@State or other decorated variable. Example: [Simple Type @Prop Synced from @State in Parent Component](#simple-type-prop-synced-from-state-in-parent-component).
- Synchronizing the \@Prop decorated variable from the item of an \@State or other decorated array. Example: [Simple Type @Prop Synced from @State Array Item in Parent Component](#simple-type-prop-synced-from-state-array-item-in-parent-component).
- Synchronizing the \@Prop decorated variable from a state attribute of the Object or class type in the parent component. Example: [Class Object Type @Prop Synced from @State Class Object Attribute in Parent Component](#class-object-type-prop-synced-from-state-class-object-attribute-in-parent-component).| +| Initial value for the decorated variable | Local initialization is allowed. | ## Variable Transfer/Access Rules @@ -134,6 +134,61 @@ For synchronization between \@State and \@Prop decorated variables: - In addition to \@State, the source can also be decorated with \@Link or \@Prop, where the mechanisms for syncing the \@Prop would be the same. - The source and \@Prop decorated variable must be of the same type. The \@Prop decorated variable can be of simple and class types. +- When the decorated variable is of the Date type, the overall value assignment of the Date object can be observed, and the following APIs can be called to update Date attributes: **setFullYear**, **setMonth**, **setDate**, **setHours**, **setMinutes**, **setSeconds**, **setMilliseconds**, **setTime**, **setUTCFullYear**, **setUTCMonth**, **setUTCDate**, **setUTCHours**, **setUTCMinutes**, **setUTCSeconds**, and **setUTCMilliseconds**. + +```ts +@Component +struct DateComponent { + @Prop selectedDate: Date; + + build() { + Column() { + Button('child update the new date') + .margin(10) + .onClick(() => { + this.selectedDate = new Date('2023-09-09') + }) + Button(`child increase the year by 1`).onClick(() => { + this.selectedDate.setFullYear(this.selectedDate.getFullYear() + 1) + }) + DatePicker({ + start: new Date('1970-1-1'), + end: new Date('2100-1-1'), + selected: this.selectedDate + }) + } + } +} + +@Entry +@Component +struct ParentComponent { + @State parentSelectedDate: Date = new Date('2021-08-08'); + + build() { + Column() { + Button('parent update the new date') + .margin(10) + .onClick(() => { + this.parentSelectedDate = new Date('2023-07-07') + }) + Button('parent increase the day by 1') + .margin(10) + .onClick(() => { + this.parentSelectedDate.setDate(this.parentSelectedDate.getDate() + 1) + }) + DatePicker({ + start: new Date('1970-1-1'), + end: new Date('2100-1-1'), + selected: this.parentSelectedDate + }) + + DateComponent({selectedDate:this.parentSelectedDate}) + } + + } +} +``` ### Framework Behavior diff --git a/en/application-dev/quick-start/arkts-provide-and-consume.md b/en/application-dev/quick-start/arkts-provide-and-consume.md index 427e2f79d0d2f04b62c8d31f7633f10ab449d8eb..dcaa7b70e708fdda54dd35d04595bfc03fc5cc91 100644 --- a/en/application-dev/quick-start/arkts-provide-and-consume.md +++ b/en/application-dev/quick-start/arkts-provide-and-consume.md @@ -18,9 +18,9 @@ An \@Provide decorated state variable exists in the ancestor component and is sa - An \@Provide decorated state variable becomes available to all descendent components of the providing component automatically. The variable is said to be "provided" to other components. This means that you do not need to pass a variable from component to component multiple times. -- A descendent component gains access to the provided state variable by decorating a variable with \@Consume. This establishes a two-way data synchronization between the provided and the consumed variable. This synchronization works the same as a combination of \@State and \@Link does. The only difference is that the former allows transfer across multiple levels of the UI parent-child hierarchy. +- A descendent component gains access to the provided state variable by decorating a variable with \@Consume. This establishes a two-way data synchronization between the provided and the consumed variable. This synchronization works in the same manner as a combination of \@State and \@Link does. The only difference is that the former allows transfer across multiple levels of the UI parent-child hierarchy. -- \@Provide and \@Consume can be bound using the same variable name or variable alias. The variable types must be the same. +- \@Provide and \@Consume can be bound using the same variable name or variable alias. Whenever possible, use the same variable types to prevent implicit type conversion and consequently application behavior exceptions. ```ts @@ -34,7 +34,7 @@ An \@Provide decorated state variable exists in the ancestor component and is sa ``` -When \@Provide and \@Consume are bound through the same variable name or variable alias, the variables decorated by \@Provide and \@Consume are in a one-to-many relationship. A custom component, including its child components, cannot contain multiple \@Provide decorated variables under the same name or alias. +When \@Provide and \@Consume are bound through the same variable name or variable alias, the variables decorated by \@Provide and \@Consume are in a one-to-many relationship. A custom component, including its child components, cannot contain multiple \@Provide decorated variables under the same name or alias. Otherwise, a runtime error will occur. ## Decorator Description @@ -45,14 +45,14 @@ The rules of \@State also apply to \@Provide. The difference is that \@Provide a | -------------- | ---------------------------------------- | | Decorator parameters | Alias: constant string, optional.
If the alias is specified, the variable is provided under the alias name only. If the alias is not specified, the variable is provided under the variable name.| | Synchronization type | Two-way:
from the \@Provide decorated variable to all \@Consume decorated variables; and the other way around. The two-way synchronization behaviour is the same as that of the combination of \@State and \@Link.| -| Allowed variable types | Object, class, string, number, Boolean, enum, and array of these types. For details about the scenarios of nested types, see [Observed Changes](#observed-changes).
**any** is not supported. A combination of simple and complex types is not supported. The **undefined** and **null** values are not allowed.
The type must be specified. The type of the provided and the consumed variables must be the same.
**NOTE**
The Length, ResourceStr, and ResourceColor types are a combination of simple and complex types and therefore not supported.| +| Allowed variable types | Object, class, string, number, Boolean, enum, and array of these types.
Date type.
For details about the scenarios of supported types, see [Observed Changes](#observed-changes).
**any** is not supported. A combination of simple and complex types is not supported. The **undefined** and **null** values are not allowed.
The type must be specified. The type of the provided and the consumed variables must be the same.
**NOTE**
The Length, ResourceStr, and ResourceColor types are a combination of simple and complex types and therefore not supported.| | Initial value for the decorated variable | Mandatory. | | \@Consume Decorator| Description | | -------------- | ---------------------------------------- | | Decorator parameters | Alias: constant string, optional.
If the alias is specified, the alias name is used for matching with the \@Provide decorated variable. Otherwise, the variable name is used.| | Synchronization type | from the \@Provide decorated variable to all \@Consume decorated variables; and the other way around. The two-way synchronization behaviour is the same as that of the combination of \@State and \@Link.| -| Allowed variable types | Object, class, string, number, Boolean, enum, and array of these types. For details about the scenarios of nested types, see [Observed Changes](#observed-changes).
**any** is not supported. The **undefined** and **null** values are not allowed.
The type must be specified. The type of the provided and the consumed variables must be the same.
**NOTE**
An \@Consume decorated variable must have a matching \@Provide decorated variable with the corresponding attribute and alias on its parent or ancestor node.| +| Allowed variable types | Object, class, string, number, Boolean, enum, and array of these types.
Date type.
For details about the scenarios of supported types, see [Observed Changes](#observed-changes).
**any** is not supported. The **undefined** and **null** values are not allowed.
The type must be specified. The type of the provided and the consumed variables must be the same.
**NOTE**
An \@Consume decorated variable must have a matching \@Provide decorated variable with the corresponding attribute and alias on its parent or ancestor node.| | Initial value for the decorated variable | Forbidden. | @@ -99,6 +99,62 @@ The rules of \@State also apply to \@Provide. The difference is that \@Provide a - When the decorated variable is of the array type, the addition, deletion, and updates of array items can be observed. +- When the decorated variable is of the Date type, the overall value assignment of the Date object can be observed, and the following APIs can be called to update Date attributes: **setFullYear**, **setMonth**, **setDate**, **setHours**, **setMinutes**, **setSeconds**, **setMilliseconds**, **setTime**, **setUTCFullYear**, **setUTCMonth**, **setUTCDate**, **setUTCHours**, **setUTCMinutes**, **setUTCSeconds**, and **setUTCMilliseconds**. + +```ts +@Component +struct CompD { + + @Consume selectedDate: Date; + + build() { + Column() { + Button(`child increase the day by 1`) + .onClick(() => { + this.selectedDate.setDate(this.selectedDate.getDate() + 1) + }) + Button('child update the new date') + .margin(10) + .onClick(() => { + this.selectedDate = new Date('2023-09-09') + }) + DatePicker({ + start: new Date('1970-1-1'), + end: new Date('2100-1-1'), + selected: this.selectedDate + }) + } + } +} + +@Entry +@Component +struct CompA { + + @Provide selectedDate: Date = new Date('2021-08-08') + + build() { + Column() { + Button('parent increase the day by 1') + .margin(10) + .onClick(() => { + this.selectedDate.setDate(this.selectedDate.getDate() + 1) + }) + Button('parent update the new date') + .margin(10) + .onClick(() => { + this.selectedDate = new Date('2023-07-07') + }) + DatePicker({ + start: new Date('1970-1-1'), + end: new Date('2100-1-1'), + selected: this.selectedDate + }) + CompD() + } + } +} +``` ### Framework Behavior diff --git a/en/application-dev/quick-start/arkts-statestyles.md b/en/application-dev/quick-start/arkts-statestyles.md index c712d74e8bacdda40235efe0798e6092df03ec63..7b5b0eaf74310050edacfbd230a66cb961f7fdd3 100644 --- a/en/application-dev/quick-start/arkts-statestyles.md +++ b/en/application-dev/quick-start/arkts-statestyles.md @@ -1,4 +1,4 @@ -# stateStyles Decorator: Polymorphic Style +# stateStyles: Polymorphic Style Unlike \@Styles and \@Extend, which are used to reuse styles only on static pages, stateStyles enables you to set state-specific styles. @@ -16,6 +16,8 @@ stateStyles is an attribute method that sets the style based on the internal sta - disabled +- selected10+ + ## Application Scenarios diff --git a/en/application-dev/quick-start/arkts-watch.md b/en/application-dev/quick-start/arkts-watch.md index 6a566f0a6ba720ad967bb54c86649edb6e817f77..08ae0631beda39cd2d511fd05f4d800952c26de1 100644 --- a/en/application-dev/quick-start/arkts-watch.md +++ b/en/application-dev/quick-start/arkts-watch.md @@ -1,4 +1,4 @@ -# \@Watch: Getting Notified of State Variable Changes +# \@Watch Decorator: Getting Notified of State Variable Changes \@Watch is used to listen for state variables. If your application needs watch for value changes of a state variable, you can decorate the variable with \@Watch. @@ -27,7 +27,7 @@ An application can request to be notified whenever the value of the \@Watch deco | Type | Description | | ---------------------------------------- | ---------------------------------------- | -| (changedPropertyName? : string) => void | This function is a member function of the custom component. **changedPropertyName** indicates the name of the watched attribute.
It is useful when you use the same function as a callback to several watched attributes.
It takes the attribute name as a string input parameter and returns nothing.| +| (changedPropertyName? : string) => void | This function is a member function of the custom component. **changedPropertyName** indicates the name of the watched attribute.
It is useful when you use the same function as a callback to several watched attributes.
It takes the attribute name as a string input parameter and returns nothing.| ## Observed Changes and Behavior @@ -131,7 +131,7 @@ The processing procedure is as follows: ### \@Watch and Custom Component Update -This example is used to clarify the processing steps of custom component updates and \@Watch. Note that **count** is @State decorated in both components. +This example is used to clarify the processing steps of custom component updates and \@Watch. **count** is decorated by \@State in **CountModifier** and \@Prop in **TotalView**. ```ts diff --git a/en/application-dev/quick-start/in-app-hsp.md b/en/application-dev/quick-start/in-app-hsp.md index cb31cbc5b703c3caec5c34b4e0702657b56d26f5..f9e6926bc7dcc284cceaa26729cf822aa933cb57 100644 --- a/en/application-dev/quick-start/in-app-hsp.md +++ b/en/application-dev/quick-start/in-app-hsp.md @@ -146,7 +146,7 @@ struct Index { } ``` -### Redirecting to a Page in Another Bundle +### Redirecting to a Page If you want to add a button in the **entry** module to jump to the menu page (**library/src/main/ets/pages/menu.ets**) in the **library** module, you can write the following code in the **entry/src/main/ets/MainAbility/Index.ets** file of the **entry** module: ```ts diff --git a/en/application-dev/reference/apis/js-apis-animator.md b/en/application-dev/reference/apis/js-apis-animator.md index ca8c254cc2920df317a9c9b5d5cce55f3efa852d..1818bfc13dd6859894cf122f96b2171d0ce70e47 100644 --- a/en/application-dev/reference/apis/js-apis-animator.md +++ b/en/application-dev/reference/apis/js-apis-animator.md @@ -6,7 +6,7 @@ The **Animator** module provides APIs for applying animation effects, including > > The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version. > -> This module can be used only after a component instance is created, and it cannot be used in the [UIAbility](./js-apis-app-ability-uiAbility.md). +> This module cannot be used in the file declaration of the [UIAbility](./js-apis-app-ability-uiAbility.md). In other words, the APIs of this module can be used only after a component instance is created; they cannot be called in the lifecycle of the UIAbility. > > The functionality of this module depends on UI context. This means that the APIs of this module cannot be used where the UI context is unclear. For details, see [UIContext](./js-apis-arkui-UIContext.md#uicontext). > @@ -40,17 +40,19 @@ Creates an **Animator** object. **Example** ```js - let options = { - duration: 1500, - easing: "friction", - delay: 0, - fill: "forwards", - direction: "normal", - iterations: 3, - begin: 200.0, - end: 400.0 - }; - animator.create(options); +import animator, { AnimatorOptions } from '@ohos.animator'; + +let options: AnimatorOptions = { // The explicit type AnimatorOptions does not need to be emphasized in the xxx.js file. + duration: 1500, + easing: "friction", + delay: 0, + fill: "forwards", + direction: "normal", + iterations: 3, + begin: 200.0, + end: 400.0 +}; +animator.create(options); ``` ## AnimatorResult @@ -83,7 +85,7 @@ For details about the error codes, see [Animator Error Codes](../errorcodes/erro **Example** ```js -let options = { +let options: AnimatorOptions = { // The explicit type AnimatorOptions does not need to be emphasized in the xxx.js file. duration: 1500, easing: "friction", delay: 0, @@ -516,7 +518,7 @@ This API is deprecated since API version 9. You are advised to use [create9 **Example** ```js -let options = { +let options: AnimatorOptions = { // The explicit type AnimatorOptions does not need to be emphasized in the xxx.js file. duration: 1500, easing: "friction", delay: 0, diff --git a/en/application-dev/reference/apis/js-apis-app-ability-driverExtensionAbility.md b/en/application-dev/reference/apis/js-apis-app-ability-driverExtensionAbility.md new file mode 100644 index 0000000000000000000000000000000000000000..769c14e71f4fc11339c36aa848a60d1a719a9624 --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-app-ability-driverExtensionAbility.md @@ -0,0 +1,207 @@ +# @ohos.app.ability.DriverExtensionAbility (DriverExtensionAbility) + +The **DriverExtensionAbility** module provides the ExtensionAbility related to drivers. It provides lifecycle callbacks to be invoked when a driver is created, destroyed, connected, or disconnected. + +> **NOTE** +> +> The initial APIs of this module are supported since API version 10. Newly added APIs will be marked with a superscript to indicate their earliest API version. +> The APIs of this module can be used only in the stage model. + +## Modules to Import + +```ts +import DriverExtension from '@ohos.app.ability.DriverExtensionAbility'; +``` + +## Required Permissions + +None. + +## Attributes + +**System capability**: SystemCapability.Driver.ExternalDevice + +**System API**: This is a system API and cannot be called by third-party applications. + +| Name| Type| Readable| Writable| Description| +| -------- | -------- | -------- | -------- | -------- | +| context | [DriverExtensionContext](js-apis-inner-application-driverExtensionContext.md) | Yes| No| Context of the **DriverExtension**. This context is inherited from **ExtensionContext**.| + + +## DriverExtensionAbility.onInit + +onInit(want: Want): void; + +Called when a DriverExtensionAbility is created to initialize the service logic. + +**System capability**: SystemCapability.Driver.ExternalDevice + +**System API**: This is a system API and cannot be called by third-party applications. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| want | [Want](js-apis-app-ability-want.md) | Yes| Want information related to this DriverExtensionAbility, including the ability name and bundle name.| + +**Example** + + ```ts + class DriverExt extends DriverExtension { + onInit(want) { + console.log('onInit, want: ${want.abilityName}'); + } + } + ``` + + +## DriverExtensionAbility.onRelease + +onRelease(): void; + +Called when this DriverExtensionAbility is destroyed to clear resources. + +**System capability**: SystemCapability.Driver.ExternalDevice + +**System API**: This is a system API and cannot be called by third-party applications. + +**Example** + + ```ts + class DriverExt extends DriverExtension { + onRelease() { + console.log('onRelease'); + } + } + ``` + + +## DriverExtensionAbility.onConnect + +onConnect(want: Want): rpc.RemoteObject | Promise; + +Called following **onCreate()** when a DriverExtensionAbility is started by calling **connectAbility()**. A **RemoteObject** object is returned for communication between the server and client. + +**System capability**: SystemCapability.Driver.ExternalDevice + +**System API**: This is a system API and cannot be called by third-party applications. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| want | [Want](js-apis-app-ability-want.md)| Yes| Want information related to this DriverExtensionAbility, including the ability name and bundle name.| + +**Return value** + +| Type| Description| +| -------- | -------- | +| rpc.RemoteObject | A **RemoteObject** object used for communication between the server and client.| + +**Example** + + ```ts + import rpc from '@ohos.rpc'; + class StubTest extends rpc.RemoteObject{ + constructor(des) { + super(des); + } + onRemoteRequest(code, data, reply, option) { + } + } + class DriverExt extends DriverExtension { + onConnect(want) { + console.log('onConnect , want: ${want.abilityName}'); + return new StubTest('test'); + } + } + ``` + +If the returned **RemoteObject** object depends on an asynchronous API, you can use the asynchronous lifecycle. + + ```ts +import rpc from '@ohos.rpc'; +class StubTest extends rpc.RemoteObject{ + constructor(des) { + super(des); + } + onRemoteRequest(code, data, reply, option) { + } +} +async function getDescriptor() { + // Call the asynchronous function. + return "asyncTest" +} +class DriverExt extends DriverExtension { + async onConnect(want) { + console.log(`onConnect , want: ${want.abilityName}`); + let descriptor = await getDescriptor(); + return new StubTest(descriptor); + } +} + ``` + +## DriverExtensionAbility.onDisconnect + +onDisconnect(want: Want): void | Promise\; + +Called when a client is disconnected from this DriverExtensionAbility. + +**System capability**: SystemCapability.Driver.ExternalDevice + +**System API**: This is a system API and cannot be called by third-party applications. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| want |[Want](js-apis-app-ability-want.md)| Yes| Want information related to this DriverExtensionAbility, including the ability name and bundle name.| + +**Example** + + ```ts + class DriverExt extends DriverExtension { + onDisconnect(want) { + console.log('onDisconnect, want: ${want.abilityName}'); + } + } + ``` + +After the **onDisconnect** lifecycle callback is executed, the application may exit. As a result, the asynchronous function in **onDisconnect** may fail to be executed correctly, for example, asynchronously writing data to the database. The asynchronous lifecycle can be used to ensure that the subsequent lifecycle continues after the asynchronous **onDisconnect** is complete. + + ```ts +class DriverExt extends DriverExtension { + async onDisconnect(want) { + console.log('onDisconnect, want: ${want.abilityName}'); + // Call the asynchronous function. + } +} + ``` + + +## DriverExtensionAbility.onDump + +onDump(params: Array\): Array\; + +Dumps client information. + +**System capability**: SystemCapability.Driver.ExternalDevice + +**System API**: This is a system API and cannot be called by third-party applications. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| params | Array\ | Yes| Parameters in the form of a command.| + +**Example** + + ```ts + class DriverExt extends DriverExtension { + onDump(params) { + console.log('dump, params: ${JSON.stringify(params)}'); + return ['params']; + } + } + ``` diff --git a/en/application-dev/reference/apis/js-apis-inner-application-driverExtensionContext.md b/en/application-dev/reference/apis/js-apis-inner-application-driverExtensionContext.md new file mode 100644 index 0000000000000000000000000000000000000000..0d45758d096a0c1eb556fe996e9cfa70bb17c542 --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-inner-application-driverExtensionContext.md @@ -0,0 +1,45 @@ +# DriverExtensionContext + +The **DriverExtensionContext** module provides the context of **DriverExtensionAbility**. It inherits from **ExtensionContext**. + +The **DriverExtensionContext** module provides the operations that need to be actively initiated in the **DriverExtensionAbility** implementation. + +> **NOTE** +> +> - The initial APIs of this module are supported since API version 10. Newly added APIs will be marked with a superscript to indicate their earliest API version. +> - The APIs of this module can be used only in the stage model. + +## Modules to Import + +```ts +import common from '@ohos.app.ability.common'; +``` + +## How to Use + +Before using **DriverExtensionContext**, you need to obtain it through a **DriverExtensionAbility** child class instance. + +```ts + import DriverExtensionAbility from '@ohos.app.ability.DriverExtensionAbility'; + + let context; + class EntryAbility extends DriverExtensionAbility { + onInit() { + context = this.context; // Obtain DriverExtensionContext. + } + } +``` + +## DriverExtensionContext.updateDriverState + +updateDriverState(): void; + +Updates the driver state. This interface is reserved and does not provide specific functionality currently. + +**System capability**: SystemCapability.Driver.ExternalDevice + +**Example** + + ```ts + this.context.updateDriverState() ; + ``` diff --git a/en/application-dev/reference/apis/js-apis-mediaquery.md b/en/application-dev/reference/apis/js-apis-mediaquery.md index 29f319addaadfc093be1d7da8e5eb6aecc40f98d..30c09eec9457d04d4892bbed8cfbdbfd4ffbb071 100644 --- a/en/application-dev/reference/apis/js-apis-mediaquery.md +++ b/en/application-dev/reference/apis/js-apis-mediaquery.md @@ -6,7 +6,7 @@ The **mediaquery** module provides different styles for different media types. > > The APIs of this module are supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. > -> This module can be used only after a component instance is created, and it cannot be used in the [UIAbility](./js-apis-app-ability-uiAbility.md). +> This module cannot be used in the file declaration of the [UIAbility](./js-apis-app-ability-uiAbility.md). In other words, the APIs of this module can be used only after a component instance is created; they cannot be called in the lifecycle of the UIAbility. > > The functionality of this module depends on UI context. This means that the APIs of this module cannot be used where the UI context is unclear. For details, see [UIContext](./js-apis-arkui-UIContext.md#uicontext). > diff --git a/en/application-dev/reference/apis/js-apis-promptAction.md b/en/application-dev/reference/apis/js-apis-promptAction.md index 1624fd511a1f1fd99fb75e4aa93b3dc2a2872bd9..b5cda219aca77e3aefb888c1793f7f9e7b2d3f0a 100644 --- a/en/application-dev/reference/apis/js-apis-promptAction.md +++ b/en/application-dev/reference/apis/js-apis-promptAction.md @@ -6,7 +6,7 @@ The **PromptAction** module provides APIs for creating and showing toasts, dialo > > The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. > -> This module can be used only after a component instance is created, and it cannot be used in the [UIAbility](./js-apis-app-ability-uiAbility.md). +> This module cannot be used in the file declaration of the [UIAbility](./js-apis-app-ability-uiAbility.md). In other words, the APIs of this module can be used only after a component instance is created; they cannot be called in the lifecycle of the UIAbility. > > The functionality of this module depends on UI context. This means that the APIs of this module cannot be used where the UI context is unclear. For details, see [UIContext](./js-apis-arkui-UIContext.md#uicontext). > diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001252667389.gif b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001252667389.gif deleted file mode 100644 index 198227c0282462bfb34f5363a7996a6817e1bb83..0000000000000000000000000000000000000000 Binary files a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001252667389.gif and /dev/null differ diff --git a/en/application-dev/reference/arkui-ts/figures/text_3.gif b/en/application-dev/reference/arkui-ts/figures/text_3.gif new file mode 100644 index 0000000000000000000000000000000000000000..f29a8c19fae069e2c16fdcd93a6a1007d1e1d85d Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/text_3.gif differ diff --git a/en/application-dev/reference/arkui-ts/figures/transitionComponent1.gif b/en/application-dev/reference/arkui-ts/figures/transitionComponent1.gif deleted file mode 100644 index 6b5dd0f0ca7d09218af2641e4ae2900eb394623d..0000000000000000000000000000000000000000 Binary files a/en/application-dev/reference/arkui-ts/figures/transitionComponent1.gif and /dev/null differ diff --git a/en/application-dev/reference/arkui-ts/ts-animatorproperty.md b/en/application-dev/reference/arkui-ts/ts-animatorproperty.md index 403bce55ad683f76315967c1c563c044d324631b..00095beb0f5a5739de8a9ab62da63a1807e475c5 100644 --- a/en/application-dev/reference/arkui-ts/ts-animatorproperty.md +++ b/en/application-dev/reference/arkui-ts/ts-animatorproperty.md @@ -14,14 +14,18 @@ Since API version 9, this API is supported in ArkTS widgets. | Name | Type | Mandatory | Description | | ---------- | ------------------------------------------| ---- | ------------------------------------------------------------ | -| duration | number | No | Animation duration, in ms.
Default value: **1000**
Unit: ms
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
- The maximum animation duration on an ArkTS widget is 1000 ms.
- A value less than 1 evaluates to the value **0**.
- If the value is of the floating point type, the value is rounded down. If the value is 1.2, the value **1** is used.| -| tempo | number | No | Animation playback speed. A larger value indicates a higher animation playback speed.
The value **0** indicates that no animation is applied.
Default value: **1**
**NOTE**
A value less than 1 evaluates to the value **1**.| +| duration | number | No | Animation duration, in ms.
Default value: **1000**
Unit: ms
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
- The maximum animation duration on an ArkTS widget is 1000 ms.
- A value less than 0 evaluates to the value **0**.
- Floating-point values will be rounded down to integers. For example, if the value set is 1.2, **1** will be used.| +| tempo | number | No | Animation playback speed. A larger value indicates a higher animation playback speed.
The value **0** indicates that no animation is applied.
Default value: **1**
**NOTE**
A value less than 0 evaluates to the value **1**.| | curve | string \| [Curve](ts-appendix-enums.md#curve) \| [ICurve](../apis/js-apis-curve.md#icurve)9+ | No | Animation curve. The default curve is linear.
Default value: **Curve.Linear**
Since API version 9, this API is supported in ArkTS widgets.| -| delay | number | No | Delay of animation playback, in ms. The value **0** indicates that the playback is not delayed.
Default value: **0**
Value range: [0, +∞)
**NOTE**
A value less than 1 evaluates to the value **0**. If the value is of the floating point type, the value is rounded down. If the value is 1.2, the value **1** is used.| +| delay | number | No | Delay of animation playback, in ms. The value **0** indicates that the playback is not delayed.
Default value: **0**
Value range: [0, +∞)
**NOTE**
- A value less than 0 evaluates to the value **0**.
- Floating-point values will be rounded down to integers. For example, if the value set is 1.2, **1** will be used.| | iterations | number | No | Number of times that the animation is played.
Default value: **1**
Value range: [-1, +∞)
**NOTE**
The value **-1** indicates that the animation is played for an unlimited number of times. The value **0** indicates that no animation is applied.| -| playMode | [PlayMode](ts-appendix-enums.md#playmode) | No | Animation playback mode. By default, the animation is played from the beginning after the playback is complete.
Default value: **PlayMode.Normal**
Since API version 9, this API is supported in ArkTS widgets.| +| playMode | [PlayMode](ts-appendix-enums.md#playmode) | No | Animation playback mode. By default, the animation is played from the beginning after the playback is complete.
Default value: **PlayMode.Normal**
Since API version 9, this API is supported in ArkTS widgets.
For details about the restrictions, see **Notes about PlayMode**.| | onFinish | () => void | No | Callback invoked when the animation playback is complete.
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
This callback is not invoked when **iterations** is set to **-1**.| +> **Notes about PlayMode**: +> - **PlayMode.Normal** and **PlayMode.Alternate** are recommended. Under these settings, the first round of the animation is played forwards. If **PlayMode.Reverse** or **PlayMode.AlternateReverse** is used, the first round of the animation is played backwards. In this case, the animation jumps to the end state and then starts from there. +> - When using **PlayMode.Alternate** or **PlayMode.AlternateReverse**, make sure the final state of the animation is the same as the value of the state variable. In other words, make sure the last round of the animation is played forwards. When **PlayMode.Alternate** is used, **iterations** must be set to an odd number. When **PlayMode.AlternateReverse** is used, **iterations** must be set to an even number. +> - **PlayMode.Reverse** is not recommended. Under this setting, the animation jumps to the end state at the beginning, and its final state will be different from the value of the state variable. ## Example 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 834d98d902de5e5bc0244201cae0b2455ccbcb15..fc6d76af6ee7276c2d6de2d4660af8e2211cd5a1 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 @@ -88,6 +88,7 @@ struct SelectExample { .optionFont({ size: 16, weight: 400 }) .space(this.space) .arrowPosition(this.arrowPosition) + .menuAlign(MenuAlignType.START, {dx:0, dy:0}) .onSelect((index:number, text: string)=>{ console.info('Select:' + index) this.index = index; 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 0b559a3c66a086b77036b3d9f60a2adb7d61f92c..bbfc708b4f22509f4499260143aa8977f2e7c2e4 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 @@ -40,8 +40,8 @@ In addition to the [universal attributes](ts-universal-attributes-size.md) and [ | minFontSize | number \| string \| [Resource](ts-types.md#resource) | Minimum font size.
For the setting to take effect, this attribute must be used together with **maxFontSize**, **maxLines**, or layout constraint settings.
Since API version 9, this API is supported in ArkTS widgets. | | maxFontSize | number \| string \| [Resource](ts-types.md#resource) | Maximum font size.
For the setting to take effect, this attribute must be used together with **minFontSize**, **maxLines**, or layout constraint settings.
Since API version 9, this API is supported in ArkTS widgets. | | textCase | [TextCase](ts-appendix-enums.md#textcase) | Text case.
Default value: **TextCase.Normal**
Since API version 9, this API is supported in ArkTS widgets.| -| copyOption9+ | [CopyOptions](ts-appendix-enums.md#copyoptions9) | Whether copy and paste is allowed.
Default value: **CopyOptions.None**
This API is supported in ArkTS widgets.| -| draggable(deprecated) | boolean | Drag effect of the selected text.
This attribute cannot be used with the [onDragStart](ts-universal-events-drag-drop.md) event.
It must be used with **copyOption** to enable the selected text to be dragged and copied.
Default value: **false**
**NOTE**
This API is supported since API version 8 and deprecated since API version 10. You are advised to use the universal attribute [draggable](ts-universal-events-drag-drop.md) instead. | +| copyOption9+ | [CopyOptions](ts-appendix-enums.md#copyoptions9) | Whether copy and paste is allowed.
Default value: **CopyOptions.None**
This API is supported in ArkTS widgets.
**NOTE**
When this attribute is set to **CopyOptions.InApp** or **CopyOptions.LocalDevice**, a long press on the text will display a context menu that offers the copy and select-all options.| +| draggable(deprecated) | boolean | Drag effect of the selected text.
This attribute cannot be used with the [onDragStart](ts-universal-events-drag-drop.md) event.
It must be used together with **copyOption**. When it is set to **true** and **copyOptions** is set to **CopyOptions.InApp** or **CopyOptions.LocalDevice**, the selected text can be dragged and copied to the text box.
Default value: **false**
**NOTE**
This API is supported since API version 8 and deprecated since API version 10. You are advised to use the universal attribute [draggable](ts-universal-events-drag-drop.md) instead.| | textShadow10+ | [ShadowOptions](ts-universal-attributes-image-effect.md#shadowoptions) | Text shadow.| | heightAdaptivePolicy10+ | [TextHeightAdaptivePolicy](ts-appendix-enums.md#textheightadaptivepolicy10) | How the adaptive height is determined for the text.
Default value: **TextHeightAdaptivePolicy.MAX_LINES_FIRST**
**NOTE**
When this attribute is set to **TextHeightAdaptivePolicy.MAX_LINES_FIRST**, the **maxLines** attribute takes precedence for adjusting the text height. If the **maxLines** setting results in a layout beyond the layout constraints, the text will shrink to a font size between `minFontSize` and `maxFontSize` to allow for more content to be shown.
When this attribute is set to **TextHeightAdaptivePolicy.MIN_FONT_SIZE_FIRST**, the **minFontSize** attribute takes precedence for adjusting the text height. If the text can fit in one line with the **minFontSize** setting, the text will enlarge to the largest possible font size between **minFontSize** and **maxFontSize**.
When this attribute is set to **TextHeightAdaptivePolicy.LAYOUT_CONSTRAINT_FIRST**, the layout constraints take precedence for adjusting the text height. If the resultant layout is beyond the layout constraints, the text will shrink to a font size between **minFontSize** and **maxFontSize** to respect the layout constraints. If the layout still exceeds the layout constraints after the font size is reduced to **minFontSize**, the lines that exceed the layout constraints are deleted. | | textIndent10+ | number \| string | Indentation of the first line.
Default value: **0**| @@ -250,3 +250,64 @@ struct TextExample2 { } ``` ![textExp1](figures/textExp2.png) + +### Example 3 + +Example of using **textShadow**, **heightAdaptivePolicy**, and **TextOverflow.MARQUEE**: + +```ts +@Entry +@Component +struct TextExample { + build() { + Column({ space: 8 }) { + Text('textShadow').fontSize(9).fontColor(0xCCCCCC).margin(15).width('90%') + Text('textShadow') + .width('80%') + .height(55) + .fontSize(40) + .lineHeight(55) + .textAlign(TextAlign.Center) + .textShadow({ radius: 10, color: Color.Black, offsetX: 0, offsetY: 0 }) + .borderWidth(1) + Divider() + Text('heightAdaptivePolicy').fontSize(9).fontColor(0xCCCCCC).margin(15).width('90%') + Text('This is the text with the height adaptive policy set') + .width('80%') + .height(90) + .borderWidth(1) + .minFontSize(10) + .maxFontSize(30) + .maxLines(3) + .textOverflow({ overflow: TextOverflow.Ellipsis }) + .heightAdaptivePolicy(TextHeightAdaptivePolicy.MAX_LINES_FIRST) + Text('This is the text with the height adaptive policy set') + .width('80%') + .height(90) + .borderWidth(1) + .minFontSize(10) + .maxFontSize(30) + .maxLines(3) + .textOverflow({ overflow: TextOverflow.Ellipsis }) + .heightAdaptivePolicy(TextHeightAdaptivePolicy.MIN_FONT_SIZE_FIRST) + Text('This is the text with the height adaptive policy set') + .width('80%') + .height(90) + .borderWidth(1) + .minFontSize(10) + .maxFontSize(30) + .maxLines(3) + .textOverflow({ overflow: TextOverflow.Ellipsis }) + .heightAdaptivePolicy(TextHeightAdaptivePolicy.LAYOUT_CONSTRAINT_FIRST) + Divider() + Text('marquee').fontSize(9).fontColor(0xCCCCCC).margin(15).width('90%') + Text('This is the text with the text overflow set marquee') + .width(300) + .borderWidth(1) + .textOverflow({ overflow: TextOverflow.MARQUEE }) + } + } +} +``` + +![](figures/text_3.gif) diff --git a/en/application-dev/reference/arkui-ts/ts-components-canvas-matrix2d.md b/en/application-dev/reference/arkui-ts/ts-components-canvas-matrix2d.md index 4099142bfb7494bdc335036322eb67f7bb3127a7..5912fcd55b27220debbf5e5346f0a275a983c839 100644 --- a/en/application-dev/reference/arkui-ts/ts-components-canvas-matrix2d.md +++ b/en/application-dev/reference/arkui-ts/ts-components-canvas-matrix2d.md @@ -413,6 +413,70 @@ struct Matrix2DMultiply { } ``` +### rotate(deprecated) + +rotate(rx?: number, ry?: number): Matrix2D + +Performs a rotation operation on this matrix. + +Since API version 9, this API is supported in ArkTS widgets. This API is a null API. + +This API is deprecated since API version 10. You are advised to use [rotate](#rotate10) instead. + +**Parameters** + +| Parameter| Type | Mandatory| Default Value| Description | +| ---- | ------ | ---- | ------ | -------------------------------- | +| rx | number | No | 0 | Horizontal coordinate (in vp) of the rotation point.| +| ry | number | No | 0 | Vertical coordinate (in vp) of the rotation point.| + +**Return value** + +| Type | Description | +| --------------------- | -------------------- | +| [Matrix2D](#matrix2d) | Matrix of the rotation result.| + +**Example** + +```ts +// xxx.ets +@Entry +@Component +struct Matrix2DRotate { + @State message: string = 'Matrix2D Rotate' + + printMatrix(title, matrix) { + console.log(title) + console.log("Matrix [scaleX = " + matrix.scaleX + ", scaleY = " + matrix.scaleY + + ", rotateX = " + matrix.rotateX + ", rotateY = " + matrix.rotateY + + ", translateX = " + matrix.translateX + ", translateY = " + matrix.translateY + "]") + } + build() { + Row() { + Column() { + Text(this.message) + .fontSize(20) + .fontWeight(FontWeight.Bold) + Button("matrix rotate") + .onClick(() => { + var matrix : Matrix2D = new Matrix2D() + matrix.scaleX = 1 + matrix.scaleY = 1 + matrix.rotateX = 0 + matrix.rotateY = 0 + matrix.translateX = 0 + matrix.translateY = 0 + matrix.rotate(10, 10) + this.printMatrix(this.message, matrix) + }) + } + .width('100%') + } + .height('100%') + } +} +``` + ### rotate10+ rotate(degree: number, rx?: number, ry?: number): Matrix2D 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 f47c0319907873b5b140e9c17b143a94965a4573..632660059028c78bb8c25e46c8acbfe1f4f1c78f 100644 --- a/en/application-dev/reference/arkui-ts/ts-container-griditem.md +++ b/en/application-dev/reference/arkui-ts/ts-container-griditem.md @@ -26,20 +26,26 @@ GridItem() | columnStart | number | Start column number of the component.| | columnEnd | number | End column number of the component.| | forceRebuild(deprecated) | boolean | Whether to re-create the component when it is being built.
This API is deprecated since API version 9. Whether to re-create the component is automatically determined based on the component attributes and child component changes. No manual configuration is required.
Default value: **false**| -| selectable8+ | boolean | Whether the current grid item is selectable by the mouse.
**NOTE**
This attribute takes effect only when mouse frame selection is enabled for the parent **\** container.
Default value: **true** | +| selectable8+ | boolean | Whether the grid item is selectable by the mouse.
**NOTE**
This attribute takes effect only when mouse frame selection is enabled for the parent **\** container.
Default value: **true** | +| selected10+ | boolean | Whether the grid item is selected. This attribute supports [$$](../../quick-start/arkts-two-way-sync.md) for two-way binding of variables.
**NOTE**
This attribute must be used before the [style for the selected state](./ts-universal-attributes-polymorphic-style.md) is set. Otherwise, the style settings will not take effect.
Default value: **false**| > **NOTE** > > Rules for setting **rowStart**, **rowEnd**, **columnStart**, and **columnEnd**: > -> - The valid value range of **rowStart** and **rowEnd** is 0 to the total number of rows minus 1. The valid value range of **columnStart** and **columnEnd** is 0 to the total number of columns minus 1. +> The valid value range of **rowStart** and **rowEnd** is 0 to the total number of rows minus 1. The valid value range of **columnStart** and **columnEnd** is 0 to the total number of columns minus 1. > -> - Settings outside of the valid ranges do not take effect. +> Settings outside of the valid ranges do not take effect. > -> - In the grid that has both **columnTemplate** and **rowTemplate** set, a grid item takes up the specified number of rows (rowEnd – rowStart + 1) or columns (columnEnd – columnStart + 1), depending on whether **rowStart**/**rowEnd** or **columnStart**/**columnEnd** is set. ->- In the grid that has only **columnTemplate** set, a grid item takes up the specified number of columns. -> - In the grid that has only **rowTemplate** set, a grid item takes up the specified number of rows. ->- In the grid that has neither **columnTemplate** nor **rowTemplate** set, the row and column number attributes do not work. +> In the grid that has both **columnTemplate** and **rowTemplate** set, grid items that have **rowStart**/**rowEnd** or **columnStart**/**columnEnd** set are laid out in a row-by-row then column-by-column manner. +> +> In the grid that has only **columnTemplate** set, grid items that have **columnStart**/**columnEnd** set are laid out in the specific columns. If there are already grid items in those columns, the grid items will be laid out in another row. +> +> In the grid that has only **rowTemplate** set, grid items that have **rowStart**/**rowEnd** set are laid out in the specific rows. If there are already grid items in those rows, the grid items will be laid out in another column. +> +> In the grid that has only **columnTemplate** set, grid items whose row or column number settings are invalid are laid out in a row-by-row then column-by-column manner. +> +> In the grid that has neither **columnTemplate** nor **rowTemplate** set, the row and column number attributes do not work. ## Events 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 c54b6e0ee78b9ee062639e1ba966e75566bda5e8..cd8ef63993cdbfdc654453e9d647bd2fdb5ac7d1 100644 --- a/en/application-dev/reference/arkui-ts/ts-container-listitem.md +++ b/en/application-dev/reference/arkui-ts/ts-container-listitem.md @@ -42,7 +42,8 @@ In addition to the [universal attributes](ts-universal-attributes-size.md), the | sticky(deprecated) | [Sticky](#stickydeprecated) | Sticky effect of the list item.
Default value: **Sticky.None**
This API is deprecated since API version 9. You are advised to use **sticky** of the [\](ts-container-list.md#attributes) component.| | editable(deprecated) | boolean \| [EditMode](#editmodedeprecated) | Whether to enter editing mode, where the list item can be deleted or moved.
This API is deprecated since API version 9.
Default value: **false**| | selectable8+ | boolean | Whether the current list item is selectable by mouse drag.
**NOTE**
This attribute takes effect only when mouse frame selection is enabled for the parent **\** container.
Default value: **true**| -| swipeAction9+ | {
start?: CustomBuilder \| [SwipeActionItem](#swipeactionitem10),
end?:CustomBuilder \| [SwipeActionItem](#swipeactionitem10),
edgeEffect?: [SwipeEdgeEffect](#swipeedgeeffect9),
} | Swipe action displayed when the list item is swiped out from the screen edge.
- **start**: swipe action displayed on the left of the list item when the item is swiped right (in vertical list layout) or above the list item when the item is swiped down (in horizontal list layout).
- **end**: swipe action displayed on the right of the list item when the item is swiped left (in vertical list layout) or below the list item when the item is swiped up (in horizontal list layout).
- **edgeEffect**: scroll effect.
**NOTE**
- The top level of the **@builder** function corresponding to **start** and **end** must be a single component and cannot be an **if/else**, **ForEach**, or **LazyForEach** statement.
- The swipe gesture works only in the list item area. If a swipe causes a child component to extend beyond the list item area, the portion outside the area does not respond to the swipe. In light of this, avoid setting **swipeAction** to a component too wide in a multi-column list. | +| selected10+ | boolean | Whether the list item is selected. This attribute supports [$$](../../quick-start/arkts-two-way-sync.md) for two-way binding of variables.
**NOTE**
This attribute must be used before the [style for the selected state](./ts-universal-attributes-polymorphic-style.md) is set. Otherwise, the style settings will not take effect.
Default value: **false**| +| swipeAction9+ | {
start?: CustomBuilder \| [SwipeActionItem](#swipeactionitem10),
end?:CustomBuilder \| [SwipeActionItem](#swipeactionitem10),
edgeEffect?: [SwipeEdgeEffect](#swipeedgeeffect9),
} | Swipe action displayed when the list item is swiped out from the screen edge.
- **start**: swipe action displayed on the left of the list item when the item is swiped right (in vertical list layout) or above the list item when the item is swiped down (in horizontal list layout).
- **end**: swipe action displayed on the right of the list item when the item is swiped left (in vertical list layout) or below the list item when the item is swiped up (in horizontal list layout).
- **edgeEffect**: scroll effect.
**NOTE**
- The top level of the **@builder** function corresponding to **start** and **end** must be a single component and cannot be an **if/else**, **ForEach**, or **LazyForEach** statement.
- The swipe gesture works only in the list item area. If a swipe causes a child component to extend beyond the list item area, the portion outside the area does not respond to the swipe. In light of this, avoid setting **swipeAction** to a component too wide in a multi-column list.| ## Sticky(deprecated) This API is deprecated since API version 9. You are advised to use [stickyStyle](ts-container-list.md#stickystyle9) of the **\** component. diff --git a/en/application-dev/reference/arkui-ts/ts-container-sidebarcontainer.md b/en/application-dev/reference/arkui-ts/ts-container-sidebarcontainer.md index 9b195d49a0ed0a36bdf1675820d7fb2b8cadcbd9..da83e2257a34430922c41df0ed57fc91aa8a137e 100644 --- a/en/application-dev/reference/arkui-ts/ts-container-sidebarcontainer.md +++ b/en/application-dev/reference/arkui-ts/ts-container-sidebarcontainer.md @@ -34,7 +34,7 @@ SideBarContainer( type?: SideBarContainerType ) | -------- | -------- | | Embed | The sidebar is embedded in the component and displayed side by side with the content area.| | Overlay | The sidebar is displayed overlaid on the content area.| -| AUTO | The sidebar is displayed in Embed mode when the component size is greater than or equal to the sum of **minSideBarWidth** and **minContentWidth**
and in Overlay mode otherwise.| +| AUTO | The sidebar is displayed in Embed mode when the component size is greater than or equal to the sum of **minSideBarWidth** and **minContentWidth**
and in Overlay mode otherwise.
If **minSideBarWidth** or **minContentWidth** is not set, the default value will be used for calculation. If the calculation result is less than 600 vp, 600 vp will be used as the breakpoint value for mode switching.| ## Attributes @@ -45,22 +45,22 @@ In addition to the [universal attributes](ts-universal-attributes-size.md), the | showSideBar | boolean | Whether to display the sidebar.
Default value: **true**
Since API version 10, this attribute supports [$$](../../quick-start/arkts-two-way-sync.md) for two-way binding of variables.| | controlButton | [ButtonStyle](#buttonstyle) | Attributes of the sidebar control button.| | showControlButton | boolean | Whether to display the sidebar control button.
Default value: **true**| -| sideBarWidth | number \| [Length](ts-types.md#length)9+ | Width of the sidebar.
Default value: **200**
Unit: vp
**NOTE**
A value less than 0 evaluates to the default value.
The value must comply with the width constraints. If it is not within the valid range, the value closest to the set one is used.
The width of the sidebar, whether it is specified or kept at the default, takes precedence over that of the sidebar child components.| -| minSideBarWidth | number \| [Length](ts-types.md#length)9+ | Minimum width of the sidebar.
Default value: **200**, in vp
**NOTE**
A value less than 0 evaluates to the default value.
The value cannot exceed the width of the sidebar container itself. Otherwise, the width of the sidebar container itself is used.
When set, the minimum width of the sidebar takes precedence over that of the sidebar child components. If it is not set, however, the minimum width of the sidebar child component takes precedence.| -| maxSideBarWidth | number \| [Length](ts-types.md#length)9+ | Maximum width of the sidebar.
Default value: **280**, in vp
**NOTE**
A value less than 0 evaluates to the default value.
The value cannot exceed the width of the sidebar container itself. Otherwise, the width of the sidebar container itself is used.
When set, the maximum width of the sidebar takes precedence over that of the sidebar child components. If it is not set, however, the maximum width of the sidebar child component takes precedence.| +| sideBarWidth | number \| [Length](ts-types.md#length)9+ | Width of the sidebar.
Default value: **240vp**
Unit: vp
**NOTE**
In API version 9 and earlier versions, the default value is **200vp**. In API version 10, the default value is **240vp**.
A value less than 0 evaluates to the default value.
The value must comply with the width constraints. If it is not within the valid range, the value closest to the set one is used.
The width of the sidebar, whether it is specified or kept at the default, takes precedence over that of the sidebar child components.| +| minSideBarWidth | number \| [Length](ts-types.md#length)9+ | Minimum width of the sidebar.
Default value: **240vp**
Unit: vp
**NOTE**
In API version 9 and earlier versions, the default value is **200vp**. In API version 10, the default value is **240vp**.
A value less than 0 evaluates to the default value.
The value cannot exceed the width of the sidebar container itself. Otherwise, the width of the sidebar container itself is used.
When set, the minimum width of the sidebar takes precedence over that of the sidebar child components. If it is not set, however, the minimum width of the sidebar child component takes precedence.| +| maxSideBarWidth | number \| [Length](ts-types.md#length)9+ | Maximum width of the sidebar.
Default value: **280vp**
Unit: vp
**NOTE**
A value less than 0 evaluates to the default value.
The value cannot exceed the width of the sidebar container itself. Otherwise, the width of the sidebar container itself is used.
When set, the maximum width of the sidebar takes precedence over that of the sidebar child components. If it is not set, however, the maximum width of the sidebar child component takes precedence.| | autoHide9+ | boolean | Whether to automatically hide the sidebar when it is dragged to be smaller than the minimum width.
Default value: **true**
**NOTE**
The value is subject to the **minSideBarWidth** attribute method. If it is not set in **minSideBarWidth**, the default value is used.
Whether the sidebar should be hidden is determined when it is being dragged. When its width is less than the minimum width, the damping effect is required to trigger hiding (a distance out of range).| | sideBarPosition9+ | [SideBarPosition](#sidebarposition9) | Position of the sidebar.
Default value: **SideBarPosition.Start**| | divider10+ | [DividerStyle](#dividerstyle10) \| null | Divider style.
- **DividerStyle** (default): The divider is displayed.
- **null**: The divider is not displayed.| -| minContentWidth10+ | Dimension | Minimum width of the content area of the sidebar container.
Default value: **360**
Unit: vp| +| minContentWidth10+ | [Dimension](ts-types.md#dimension10) | Minimum width of the content area of the sidebar container.
Default value: **360vp**
Unit: vp
**NOTE**
A value less than 0 evaluates to the default value.
In Embed mode, when the component size is increased, only the content area is enlarged; when the component size is decreased, the content area is shrunk until its width reaches the value defined by **minContentWidth**, and then the sidebar is shrunk until its width reaches the value defined by **minSideBarWidth**; if the component size is further decreased, while respecting the minimum width of the sidebar, the content area is further shrunk until it is 0 vp large.
minContentWidth takes precedence over maxSideBarWidth and sideBarWidth of the sidebar. If minContentWidth is not set, the priority of the default value is lower than that of minSideBarWidth and maxSideBarWidth.| ## ButtonStyle | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| left | number | No| Spacing between the sidebar control button and the left of the container.
Default value: **16**
Unit: vp| -| top | number | No| Spacing between the sidebar control button and the top of the container.
Default value: **48**
Unit: vp| -| width | number | No| Width of the sidebar control button.
Default value: **32**
Unit: vp| -| height | number | No| Height of the sidebar control button.
Default value: **32**
Unit: vp| +| left | number | No| Spacing between the sidebar control button and the left of the container.
Default value: **16vp**
Unit: vp| +| top | number | No| Spacing between the sidebar control button and the top of the container.
Default value: **48vp**
Unit: vp| +| width | number | No| Width of the sidebar control button.
Default value:
API version 9 and earlier versions: **32vp**
API version 10 and later versions: **24vp**
Unit: vp| +| height | number | No| Height of the sidebar control button.
Default value:
API version 9 and earlier versions: **32vp**
API version 10 and later versions: **24vp**
Unit: vp| | icons | {
shown: string \| PixelMap \| [Resource](ts-types.md) ,
hidden: string \| PixelMap \| [Resource](ts-types.md) ,
switching?: string \| PixelMap \| [Resource](ts-types.md)
} | No| Icons of the sidebar control button.

- **shown**: icon of the control button when the sidebar is shown.
**NOTE**
When an error occurs during resource obtaining, the default icon is used.
- **hidden**: icon of the control button when the sidebar is hidden.
- **switching**: icon of the control button when the sidebar is switching between the shown and hidden states.| ## SideBarPosition9+ @@ -74,21 +74,19 @@ In addition to the [universal attributes](ts-universal-attributes-size.md), the | Name | Type | Mandatory| Description | | ----------- | ------------- | ---- | ---------------------------------------- | -| strokeWidth | [Length](ts-types.md#length) | Yes | Stroke width of the divider.
Default value: **1**
Unit: vp| +| strokeWidth | [Length](ts-types.md#length) | Yes | Stroke width of the divider.
Default value: **1vp**
Unit: vp| | color | [ResourceColor](ts-types.md#resourcecolor) | No | Color of the divider.
Default value: **#000000, 3%** | | startMargin | [Length](ts-types.md#length) | No | Distance between the divider and the top of the sidebar.
Default value: **0**| | endMargin | [Length](ts-types.md#length) | No | Distance between the divider and the bottom of the sidebar.
Default value: **0**| > **NOTE** > -> When the universal attributes [width and height](ts-universal-attributes-size.md) are set for the sidebar, the **width** setting takes effect only when the sidebar container width is not set, and the **height** settings does not take effect. -> The settings of the universal attributes **width** and **height** do not take effect for the sidebar content area. By default, sidebar content area takes up the remaining space of the sidebar container. +> The settings of the [universal size attributes](ts-universal-attributes-size.md) **width** and **height** do not take effect for the sidebar child component. +> The settings do not take effect for the sidebar content area either. By default, the sidebar content area takes up the remaining space of the sidebar container. > > If the attribute method is not used, the sidebar is displayed depending on the size. > > - If the size is less than 520 vp, the sidebar is not displayed by default. > - If the size is greater than or equal to 520 vp, the sidebar is displayed by default. -> - -> - ## Events 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 0bfa204dd223123bd5a1ef98cfc45eb1136b42b8..fb8b772e1eaaa265d15b9a38140ff77e7d629577 100644 --- a/en/application-dev/reference/arkui-ts/ts-container-stack.md +++ b/en/application-dev/reference/arkui-ts/ts-container-stack.md @@ -30,7 +30,7 @@ In addition to the [universal attributes](ts-universal-attributes-size.md), the | Name | Type | Description | | ------------ | ------------------------------------------- | ------------------------------------------------------------ | -| alignContent | [Alignment](ts-appendix-enums.md#alignment) | Alignment of child components in the container.
Default value: **Alignment.Center**
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
When this attribute and the universal attribute [align](ts-universal-attributes-location.md) are both set, only the **align** setting takes effect.| +| alignContent | [Alignment](ts-appendix-enums.md#alignment) | Alignment of child components in the container.
Default value: **Alignment.Center**
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
When both this attribute and the universal attribute [align](ts-universal-attributes-location.md) are set, whichever is set last takes effect.| ## Example 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 47c8c41f78db5961fb831835c0b73fd8b91e129e..9adcb73285ee60ea5ab75832b6c7e404e8e523e2 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 @@ -22,8 +22,8 @@ Since API version 9, this API is supported in ArkTS widgets. | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| width | string \| number | No| Width of the circle.
Default value: **0**| -| height | string \| number | No| Height of the circle.
Default value: **0**| +| width | string \| number | No| Width of the circle.
Default value: **0**
**NOTE**
An invalid value is handled as the default value.| +| height | string \| number | No| Height of the circle.
Default value: **0**
**NOTE**
An invalid value is handled as the default value.| ## Attributes @@ -31,19 +31,20 @@ In addition to the [universal attributes](ts-universal-attributes-size.md), the | Name| Type| Description| | -------- | -------- | -------- | -| fill | [ResourceColor](ts-types.md) | Color of the fill area.
Default value: **Color.Black**
Since API version 9, this API is supported in ArkTS widgets.| -| fillOpacity | number \| string \| [Resource](ts-types.md#resource)| Opacity of the fill area.
Default value: **1**
Since API version 9, this API is supported in ArkTS widgets.| -| stroke | [ResourceColor](ts-types.md) | Stroke color. If this attribute is not set, the component does not have any stroke.
Since API version 9, this API is supported in ArkTS widgets.| -| strokeDashArray | Array<Length> | Stroke dashes.
Default value: **[]**
Since API version 9, this API is supported in ArkTS widgets.| -| strokeDashOffset | number \| string | Offset of the start point for drawing the stroke.
Default value: **0**
Since API version 9, this API is supported in ArkTS widgets.| +| fill | [ResourceColor](ts-types.md) | Color of the fill area.
Default value: **Color.Black**
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
An invalid value is handled as the default value.| +| fillOpacity | number \| string \| [Resource](ts-types.md#resource)| Opacity of the fill area.
Default value: **1**
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
An invalid value is handled as the default value.| +| stroke | [ResourceColor](ts-types.md) | Stroke color. If this attribute is not set, the component does not have any stroke.
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
If the value is invalid, no stroke will be drawn.| +| strokeDashArray | Array<Length> | Stroke dashes.
Default value: **[]**
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
An invalid value is handled as the default value.| +| strokeDashOffset | number \| string | Offset of the start point for drawing the stroke.
Default value: **0**
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
An invalid value is handled as the default value.| | strokeLineCap | [LineCapStyle](ts-appendix-enums.md#linecapstyle) | Cap style of the stroke.
Default value: **LineCapStyle.Butt**
Since API version 9, this API is supported in ArkTS widgets.| -| strokeLineJoin | [LineJoinStyle](ts-appendix-enums.md#linejoinstyle) | Join style of the stroke.
Default value: **LineJoinStyle.Miter**
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
This attribute does not work for the **\** component, which does not have corners.| +| strokeLineJoin | [LineJoinStyle](ts-appendix-enums.md#linejoinstyle) | Join style of the stroke.
Default value: **LineJoinStyle.Miter**
Since API version 9, this API is supported in ArkTS widgets.| | strokeMiterLimit | number \| string | Limit on the ratio of the miter length to the value of **strokeWidth** used to draw a miter join.
Default value: **4**
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
This attribute does not take effect for the **\** component, because it does not have a miter join.| -| strokeOpacity | number \| string \| [Resource](ts-types.md#resource)| Stroke opacity.
Default value: **1**
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
The value range is [0.0, 1.0]. If the set value is less than 0.0, **0.0** will be used. If the set value is greater than 1.0, **1.0** will be used.| -| strokeWidth | Length | Stroke width.
Default value: **1**
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
The value cannot be a percentage.| +| strokeOpacity | number \| string \| [Resource](ts-types.md#resource)| Stroke opacity.
Default value: **1**
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
The value range is [0.0, 1.0]. A value less than 0.0 evaluates to the value **0.0**. A value greater than 1.0 evaluates to the value **1.0**. Any other value evaluates to the value **1.0**.| +| strokeWidth | Length | Stroke width.
Default value: **1**
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
The value cannot be a percentage.
An invalid value is handled as the default value.| | antiAlias | boolean | Whether anti-aliasing is enabled.
Default value: **true**
Since API version 9, this API is supported in ArkTS widgets.| + ## Example ```ts 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 95d6e04adb6cdac5a36d57cc6013c3eb98434491..210728ef5116708567ce98e41db1d08ae228d88e 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 @@ -22,8 +22,10 @@ Since API version 9, this API is supported in ArkTS widgets. | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| width | string \| number | No| Width.
Default value: **0**| -| height | string \| number | No| Height.
Default value: **0**| +| width | string \| number | No| Width.
Default value: **0**
**NOTE**
An invalid value is handled as the default value.| +| height | string \| number | No| Height.
Default value: **0**
**NOTE**
An invalid value is handled as the default value.| + + ## Attributes @@ -31,19 +33,20 @@ In addition to the [universal attributes](ts-universal-attributes-size.md), the | Name| Type| Default Value| Description| | -------- | -------- | -------- | -------- | -| fill | [ResourceColor](ts-types.md) | Color.Black | Color of the fill area.
Since API version 9, this API is supported in ArkTS widgets.| -| fillOpacity | number \| string \| [Resource](ts-types.md#resource)| 1 | Opacity of the fill area.
Since API version 9, this API is supported in ArkTS widgets.| -| stroke | [ResourceColor](ts-types.md) | - |Stroke color. If this attribute is not set, the component does not have any stroke.
Since API version 9, this API is supported in ArkTS widgets.| -| strokeDashArray | Array<Length> | [] | Stroke dashes.
Since API version 9, this API is supported in ArkTS widgets.| -| strokeDashOffset | number \| string | 0 | Offset of the start point for drawing the stroke.
Since API version 9, this API is supported in ArkTS widgets.| +| fill | [ResourceColor](ts-types.md) | Color.Black | Color of the fill area.
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
An invalid value is handled as the default value.| +| fillOpacity | number \| string \| [Resource](ts-types.md#resource)| 1 | Opacity of the fill area.
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
An invalid value is handled as the default value.| +| stroke | [ResourceColor](ts-types.md) | - |Stroke color. If this attribute is not set, the component does not have any stroke.
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
If the value is invalid, no stroke will be drawn.| +| strokeDashArray | Array<Length> | [] | Stroke dashes.
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
An invalid value is handled as the default value.| +| strokeDashOffset | number \| string | 0 | Offset of the start point for drawing the stroke.
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
An invalid value is handled as the default value.| | strokeLineCap | [LineCapStyle](ts-appendix-enums.md#linecapstyle) | LineCapStyle.Butt | Cap style of the stroke.
Since API version 9, this API is supported in ArkTS widgets.| | strokeLineJoin | [LineJoinStyle](ts-appendix-enums.md#linejoinstyle) | LineJoinStyle.Miter | Join style of the stroke.
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
This attribute does not work for the **\** component, which does not have corners.| | strokeMiterLimit | number \| string | 4 | Limit on the ratio of the miter length to the value of **strokeWidth** used to draw a miter join.
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
This attribute does not take effect for the **\** component, because it does not have a miter join.| -| strokeOpacity | number \| string \| [Resource](ts-types.md#resource)| 1 | Stroke opacity.
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
The value range is [0.0, 1.0]. If the set value is less than 0.0, **0.0** will be used. If the set value is greater than 1.0, **1.0** will be used.| -| strokeWidth | Length | 1 | Stroke width.
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
The value cannot be a percentage.| +| strokeOpacity | number \| string \| [Resource](ts-types.md#resource)| 1 | Stroke opacity.
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
The value range is [0.0, 1.0]. A value less than 0.0 evaluates to the value **0.0**. A value greater than 1.0 evaluates to the value **1.0**. Any other value evaluates to the value **1.0**.| +| strokeWidth | Length | 1 | Stroke width.
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
The value cannot be a percentage.
An invalid value is handled as the default value.| | antiAlias | boolean | true | Whether anti-aliasing is enabled.
Since API version 9, this API is supported in ArkTS widgets.| + ## Example ```ts 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 f17d6856796e158066f4cbe1e20e046fa8d562ff..258fafdf9b7bbb003be35567cbf4aefbfd30f27d 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 @@ -21,8 +21,9 @@ Since API version 9, this API is supported in ArkTS widgets. | Name| Type| Mandatory| Default Value| Description| | -------- | -------- | -------- | -------- | -------- | -| width | string \| number | No| 0 | Width.| -| height | string \| number | No| 0 | Height.| +| width | string \| number | No| 0 | Width.
**NOTE**
An invalid value is handled as the default value.| +| height | string \| number | No| 0 | Height.
**NOTE**
An invalid value is handled as the default value.| + ## Attributes @@ -31,20 +32,22 @@ In addition to the [universal attributes](ts-universal-attributes-size.md), the | Name| Type| Default Value| Description| | -------- | -------- | -------- | -------- | -| startPoint | Array<Length> | [0, 0] | Coordinates (relative coordinates) of the start point of the line, in vp.
Since API version 9, this API is supported in ArkTS widgets.| -| endPoint | Array<Length> | [0, 0] | Coordinates (relative coordinates) of the end point of the line, in vp.
Since API version 9, this API is supported in ArkTS widgets.| +| startPoint | Array<Length> | [0, 0] | Coordinates (relative coordinates) of the start point of the line, in vp.
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
An invalid value is handled as the default value.| +| endPoint | Array<Length> | [0, 0] | Coordinates (relative coordinates) of the end point of the line, in vp.
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
An invalid value is handled as the default value.| | fill | [ResourceColor](ts-types.md#resourcecolor) | Color.Black | Color of the fill area.
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
This attribute does not take effect because the **\** component cannot be used to draw a closed shape.| | fillOpacity | number \| string \| [Resource](ts-types.md#resource)| 1 | Opacity of the fill area.
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
This attribute does not take effect because the **\** component cannot be used to draw a closed shape.| -| stroke | [ResourceColor](ts-types.md) | - | Stroke color. If this attribute is not set, the component does not have any stroke.
Since API version 9, this API is supported in ArkTS widgets.| -| strokeDashArray | Array<Length> | [] | Stroke dashes.
Since API version 9, this API is supported in ArkTS widgets.| -| strokeDashOffset | number \| string | 0 | Offset of the start point for drawing the stroke.
Since API version 9, this API is supported in ArkTS widgets.| +| stroke | [ResourceColor](ts-types.md) | - | Stroke color. If this attribute is not set, the component does not have any stroke.
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
If the value is invalid, no stroke will be drawn.| +| strokeDashArray | Array<Length> | [] | Stroke dashes.
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
An invalid value is handled as the default value.| +| strokeDashOffset | number \| string | 0 | Offset of the start point for drawing the stroke.
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
An invalid value is handled as the default value.| | strokeLineCap | [LineCapStyle](ts-appendix-enums.md#linecapstyle) | LineCapStyle.Butt | Cap style of the stroke.
Since API version 9, this API is supported in ArkTS widgets.| | strokeLineJoin | [LineJoinStyle](ts-appendix-enums.md#linejoinstyle) | LineJoinStyle.Miter | Join style of the stroke.
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
This attribute does not work for the **\** component, which does not have corners.| | strokeMiterLimit | number \| string | 4 | Limit value when the sharp angle is drawn as a miter.
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
This attribute does not take effect because the **\** component cannot be used to draw a shape with a sharp angle.| -| strokeOpacity | number \| string \| [Resource](ts-types.md#resource)| 1 | Stroke opacity.
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
The value range is [0.0, 1.0]. If the set value is less than 0.0, **0.0** will be used. If the set value is greater than 1.0, **1.0** will be used.| -| strokeWidth | Length | 1 | Stroke width.
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
The value cannot be a percentage.| +| strokeOpacity | number \| string \| [Resource](ts-types.md#resource)| 1 | Stroke opacity.
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
The value range is [0.0, 1.0]. A value less than 0.0 evaluates to the value **0.0**. A value greater than 1.0 evaluates to the value **1.0**. Any other value evaluates to the value **1.0**.| +| strokeWidth | Length | 1 | Stroke width.
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
The value cannot be a percentage.
An invalid value is handled as the default value.| | antiAlias | boolean | true | Whether anti-aliasing is enabled.
Since API version 9, this API is supported in ArkTS widgets.| + + ## Example ### Example 1 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 25ba06a014b013ed97219d21cca40cca8f8e90c3..5cb272b6f3d39ac9394ff3e60384a9c41f8a50fc 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 @@ -19,11 +19,13 @@ Since API version 9, this API is supported in ArkTS widgets. **Parameters** -| Name | Type | Mandatory| Description | -| -------- | ---------------- | ---- | ----------------------------------- | -| width | number \| string | No | Width of the rectangle where the path is located.
Default value: **0** | -| height | number \| string | No | Height of the rectangle where the path is located.
Default value: **0** | -| commands | string | No | Command for drawing the path.
Default value: **''**| +| Name | Type | Mandatory| Description | +| -------- | ---------------- | ---- | ------------------------------------------------------------ | +| width | number \| string | No | Width of the rectangle where the path is located.
Default value: **0**
**NOTE**
An invalid value is handled as the default value.| +| height | number \| string | No | Height of the rectangle where the path is located.
Default value: **0**
**NOTE**
An invalid value is handled as the default value.| +| commands | string | No | Command for drawing the path.
Default value: **''**
**NOTE**
An invalid value is handled as the default value.| + + ## Attributes @@ -31,17 +33,17 @@ In addition to the [universal attributes](ts-universal-attributes-size.md), the | Name | Type | Default Value | Description | | -------- | ----------------------------------- | ---- | ---------------------------------------- | -| commands | string | '' | Command for drawing the path. The unit is px. For details about how to convert pixel units, see [Pixel Units](ts-pixel-units.md).
Since API version 9, this API is supported in ArkTS widgets.| -| fill | [ResourceColor](ts-types.md) | Color.Black | Color of the fill area.
Since API version 9, this API is supported in ArkTS widgets.| -| fillOpacity | number \| string \| [Resource](ts-types.md#resource)| 1 | Opacity of the fill area.
Since API version 9, this API is supported in ArkTS widgets.| -| stroke | [ResourceColor](ts-types.md) | - |Stroke color. If this attribute is not set, the component does not have any stroke.
Since API version 9, this API is supported in ArkTS widgets.| -| strokeDashArray | Array<Length> | [] | Stroke dashes.
Since API version 9, this API is supported in ArkTS widgets.| -| strokeDashOffset | number \| string | 0 | Offset of the start point for drawing the stroke.
Since API version 9, this API is supported in ArkTS widgets.| +| commands | string | '' | Command for drawing the path. The unit is px. For details about how to convert pixel units, see [Pixel Units](ts-pixel-units.md).
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
An invalid value is handled as the default value.| +| fill | [ResourceColor](ts-types.md) | Color.Black | Color of the fill area.
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
An invalid value is handled as the default value.| +| fillOpacity | number \| string \| [Resource](ts-types.md#resource)| 1 | Opacity of the fill area.
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
An invalid value is handled as the default value.| +| stroke | [ResourceColor](ts-types.md) | - |Stroke color. If this attribute is not set, the component does not have any stroke.
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
If the value is invalid, no stroke will be drawn.| +| strokeDashArray | Array<Length> | [] | Stroke dashes.
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
An invalid value is handled as the default value.| +| strokeDashOffset | number \| string | 0 | Offset of the start point for drawing the stroke.
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
An invalid value is handled as the default value.| | strokeLineCap | [LineCapStyle](ts-appendix-enums.md#linecapstyle) | LineCapStyle.Butt | Cap style of the stroke.
Since API version 9, this API is supported in ArkTS widgets.| | strokeLineJoin | [LineJoinStyle](ts-appendix-enums.md#linejoinstyle) | LineJoinStyle.Miter | Join style of the stroke.
Since API version 9, this API is supported in ArkTS widgets.| -| strokeMiterLimit | number \| string | 4 | Limit on the ratio of the miter length to the value of **strokeWidth** used to draw a miter join. The miter length indicates the distance from the outer tip to the inner corner of the miter.
**NOTE**
This attribute must be set to a value greater than or equal to 1 and takes effect when **strokeLineJoin** is set to **LineJoinStyle.Miter**.
Since API version 9, this API is supported in ArkTS widgets.| -| strokeOpacity | number \| string \| [Resource](ts-types.md#resource)| 1 | Opacity of the stroke.
**NOTE**
The value range is [0.0, 1.0]. If the set value is less than 0.0, **0.0** will be used. If the set value is greater than 1.0, **1.0** will be used.
Since API version 9, this API is supported in ArkTS widgets.| -| strokeWidth | Length | 1 | Width of the stroke.
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
The value cannot be a percentage.| +| strokeMiterLimit | number \| string | 4 | Limit on the ratio of the miter length to the value of **strokeWidth** used to draw a miter join. The miter length indicates the distance from the outer tip to the inner corner of the miter.
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
This attribute works only when **strokeLineJoin** is set to **LineJoinStyle.Miter**.
The value must be greater than or equal to 1.0. If the value is in the [0, 1) range, the value **1.0** will be used. In other cases, the default value will be used.| +| strokeOpacity | number \| string \| [Resource](ts-types.md#resource)| 1 | Opacity of the stroke.
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
The value range is [0.0, 1.0]. A value less than 0.0 evaluates to the value **0.0**. A value greater than 1.0 evaluates to the value **1.0**. Any other value evaluates to the value **1.0**.| +| strokeWidth | Length | 1 | Width of the stroke.
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
The value cannot be a percentage.
An invalid value is handled as the default value.| | antiAlias | boolean | true | Whether anti-aliasing is enabled.
Since API version 9, this API is supported in ArkTS widgets.| The supported commands are as follows: 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 8a0450ff17a692d98170a9dca96d7acb65250660..eda62dee5b2e3e5e5d50ddc2e42d1ae2944b8b93 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 @@ -22,8 +22,9 @@ Since API version 9, this API is supported in ArkTS widgets. | Name| Type| Mandatory| Default Value| Description| | -------- | -------- | -------- | -------- | -------- | -| width | string \| number | No| 0 | Width.| -| height | string \| number | No| 0 | Height.| +| width | string \| number | No| 0 | Width.
**NOTE**
An invalid value is handled as the default value.| +| height | string \| number | No| 0 | Height.
**NOTE**
An invalid value is handled as the default value.| + ## Attributes @@ -32,17 +33,17 @@ In addition to the [universal attributes](ts-universal-attributes-size.md), the | Name| Type| Default Value| Description| | -------- | -------- | -------- | -------- | -| points | Array<Point> | [] | Vertex coordinates of the polygon.
Since API version 9, this API is supported in ArkTS widgets.| -| fill | [ResourceColor](ts-types.md) | Color.Black | Color of the fill area.
Since API version 9, this API is supported in ArkTS widgets.| -| fillOpacity | number \| string \| [Resource](ts-types.md#resource)| 1 | Opacity of the fill area.
Since API version 9, this API is supported in ArkTS widgets.| -| stroke | [ResourceColor](ts-types.md) | - | Stroke color. If this attribute is not set, the component does not have any stroke.
Since API version 9, this API is supported in ArkTS widgets.| -| strokeDashArray | Array<Length> | [] | Stroke dashes.
Since API version 9, this API is supported in ArkTS widgets.| -| strokeDashOffset | number \| string | 0 | Offset of the start point for drawing the stroke.
Since API version 9, this API is supported in ArkTS widgets.| +| points | Array<Point> | [] | Vertex coordinates of the polygon.
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
An invalid value is handled as the default value.| +| fill | [ResourceColor](ts-types.md) | Color.Black | Color of the fill area.
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
An invalid value is handled as the default value.| +| fillOpacity | number \| string \| [Resource](ts-types.md#resource)| 1 | Opacity of the fill area.
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
An invalid value is handled as the default value.| +| stroke | [ResourceColor](ts-types.md) | - | Stroke color. If this attribute is not set, the component does not have any stroke.
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
If the value is invalid, no stroke will be drawn.| +| strokeDashArray | Array<Length> | [] | Stroke dashes.
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
An invalid value is handled as the default value.| +| strokeDashOffset | number \| string | 0 | Offset of the start point for drawing the stroke.
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
An invalid value is handled as the default value.| | strokeLineCap | [LineCapStyle](ts-appendix-enums.md#linecapstyle) | LineCapStyle.Butt | Cap style of the stroke.
Since API version 9, this API is supported in ArkTS widgets.| | strokeLineJoin | [LineJoinStyle](ts-appendix-enums.md#linejoinstyle) | LineJoinStyle.Miter | Join style of the stroke.
Since API version 9, this API is supported in ArkTS widgets.| -| strokeMiterLimit | number \| string | 4 | Limit on the ratio of the miter length to the value of **strokeWidth** used to draw a miter join. The miter length indicates the distance from the outer tip to the inner corner of the miter.
**NOTE**
This attribute must be set to a value greater than or equal to 1 and takes effect when **strokeLineJoin** is set to **LineJoinStyle.Miter**.
Since API version 9, this API is supported in ArkTS widgets.| -| strokeOpacity | number \| string \| [Resource](ts-types.md#resource)| 1 | Stroke opacity.
**NOTE**
The value range is [0.0, 1.0]. If the set value is less than 0.0, **0.0** will be used. If the set value is greater than 1.0, **1.0** will be used.
Since API version 9, this API is supported in ArkTS widgets.| -| strokeWidth | Length | 1 | Stroke width.
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
The value cannot be a percentage.| +| strokeMiterLimit | number \| string | 4 | Limit on the ratio of the miter length to the value of **strokeWidth** used to draw a miter join. The miter length indicates the distance from the outer tip to the inner corner of the miter.
**NOTE**
This attribute works only when **strokeLineJoin** is set to **LineJoinStyle.Miter**.
The value must be greater than or equal to 1.0. If the value is in the [0, 1) range, the value **1.0** will be used. In other cases, the default value will be used.
Since API version 9, this API is supported in ArkTS widgets.| +| strokeOpacity | number \| string \| [Resource](ts-types.md#resource)| 1 | Stroke opacity.
**NOTE**
The value range is [0.0, 1.0]. A value less than 0.0 evaluates to the value **0.0**. A value greater than 1.0 evaluates to the value **1.0**. Any other value evaluates to the value **1.0**.
Since API version 9, this API is supported in ArkTS widgets.| +| strokeWidth | Length | 1 | Stroke width.
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
The value cannot be a percentage.
An invalid value is handled as the default value.| | antiAlias | boolean | true | Whether anti-aliasing is enabled.
Since API version 9, this API is supported in ArkTS widgets.| ## Point 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 6681e790aeb02e3bcfb706cf0162e9c0376e7906..a8cf8ca7ccfef77b5a17e7e4326fabfc49ba1506 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 @@ -22,8 +22,9 @@ Since API version 9, this API is supported in ArkTS widgets. | Name| Type| Mandatory| Default Value| Description| | -------- | -------- | -------- | -------- | -------- | -| width | string \| number | No| 0 | Width.| -| height | string \| number | No| 0 | Height.| +| width | string \| number | No| 0 | Width.
**NOTE**
An invalid value is handled as the default value.| +| height | string \| number | No| 0 | Height.
**NOTE**
An invalid value is handled as the default value.| + ## Attributes @@ -32,18 +33,20 @@ In addition to the [universal attributes](ts-universal-attributes-size.md), the | Name| Type| Default Value| Description| | -------- | -------- | -------- | -------- | -| points | Array<Point> | [] | List of coordinates that the polyline passes through.
Since API version 9, this API is supported in ArkTS widgets.| -| fill | [ResourceColor](ts-types.md) | Color.Black | Color of the fill area.
Since API version 9, this API is supported in ArkTS widgets.| -| fillOpacity | number \| string \| [Resource](ts-types.md#resource)| 1 | Opacity of the fill area.
Since API version 9, this API is supported in ArkTS widgets.| -| stroke | [ResourceColor](ts-types.md) | - | Stroke color. If this attribute is not set, the component does not have any stroke.
Since API version 9, this API is supported in ArkTS widgets.| -| strokeDashArray | Array<Length> | [] | Stroke dashes.
Since API version 9, this API is supported in ArkTS widgets.| -| strokeDashOffset | number \| string | 0 | Offset of the start point for drawing the stroke.
Since API version 9, this API is supported in ArkTS widgets.| +| points | Array<Point> | [] | List of coordinates that the polyline passes through.
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
An invalid value is handled as the default value.| +| fill | [ResourceColor](ts-types.md) | Color.Black | Color of the fill area.
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
An invalid value is handled as the default value.| +| fillOpacity | number \| string \| [Resource](ts-types.md#resource)| 1 | Opacity of the fill area.
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
An invalid value is handled as the default value.| +| stroke | [ResourceColor](ts-types.md) | - | Stroke color. If this attribute is not set, the component does not have any stroke.
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
If the value is invalid, no stroke will be drawn.| +| strokeDashArray | Array<Length> | [] | Stroke dashes.
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
An invalid value is handled as the default value.| +| strokeDashOffset | number \| string | 0 | Offset of the start point for drawing the stroke.
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
An invalid value is handled as the default value.| | strokeLineCap | [LineCapStyle](ts-appendix-enums.md#linecapstyle) | LineCapStyle.Butt | Cap style of the stroke.
Since API version 9, this API is supported in ArkTS widgets.| | strokeLineJoin | [LineJoinStyle](ts-appendix-enums.md#linejoinstyle) | LineJoinStyle.Miter | Join style of the stroke.
Since API version 9, this API is supported in ArkTS widgets.| -| strokeMiterLimit | number \| string | 4 | Limit on the ratio of the miter length to the value of **strokeWidth** used to draw a miter join. The miter length indicates the distance from the outer tip to the inner corner of the miter.
**NOTE**
This attribute must be set to a value greater than or equal to 1 and takes effect when **strokeLineJoin** is set to **LineJoinStyle.Miter**.
Since API version 9, this API is supported in ArkTS widgets.| -| strokeOpacity | number \| string \| [Resource](ts-types.md#resource)| 1 | Stroke opacity.
**NOTE**
The value range is [0.0, 1.0]. If the set value is less than 0.0, **0.0** will be used. If the set value is greater than 1.0, **1.0** will be used.
Since API version 9, this API is supported in ArkTS widgets.| -| strokeWidth | Length | 1 | Stroke width.
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
The value cannot be a percentage.| -| antiAlias | boolean | true | Whether anti-aliasing is enabled.
Since API version 9, this API is supported in ArkTS widgets.| +| strokeMiterLimit | number \| string | 4 | Limit on the ratio of the miter length to the value of **strokeWidth** used to draw a miter join. The miter length indicates the distance from the outer tip to the inner corner of the miter.
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
This attribute works only when **strokeLineJoin** is set to **LineJoinStyle.Miter**.
The value must be greater than or equal to 1.0. If the value is in the [0, 1) range, the value **1.0** will be used. In other cases, the default value will be used.
Since API version 9, this API is supported in ArkTS widgets.| +| strokeOpacity | number \| string \| [Resource](ts-types.md#resource)| 1 | Stroke opacity.
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
The value range is [0.0, 1.0]. A value less than 0.0 evaluates to the value **0.0**. A value greater than 1.0 evaluates to the value **1.0**. Any other value evaluates to the value **1.0**.| +| strokeWidth | Length | 1 | Stroke width.
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
The value cannot be a percentage.
An invalid value is handled as the default value.| +| antiAlias | boolean | true | Whether anti-aliasing is enabled.
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
An invalid value is handled as the default value.| + + ## Point 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 c7fac4fa35067c4e9be6e6e7aca05f0d7e25bdb1..879805a6635cb0decefa842036bae5b2c88ba896 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 @@ -23,12 +23,11 @@ Since API version 9, this API is supported in ArkTS widgets. | Name| Type| Mandatory| Default Value| Description| | -------- | -------- | -------- | -------- | -------- | -| width | string \| number | No| 0 | Width.| -| height | string \| number | No| 0 | Height.| -| radius | string \| number \| Array<string \| number> | No| 0 | Radius of the rounded corner. You can set separate radiuses for four rounded corners.| -| radiusWidth | string \| number | No| 0 | Width of the rounded corner.| -| radiusHeight | string \| number | No| 0 | Height of the rounded corner.| - +| width | string \| number | No| 0 | Width.
**NOTE**
An invalid value is handled as the default value.| +| height | string \| number | No| 0 | Height.
**NOTE**
An invalid value is handled as the default value.| +| radius | string \| number \| Array<string \| number> | No| 0 | Radius of the rounded corner. You can set separate radiuses for four rounded corners.
This attribute works in a similar manner as **radiusWidth**/**radiusHeight**. When they are used together, it takes precedence over **radiusWidth**/**radiusHeight**.
**NOTE**
An invalid value is handled as the default value.| +| radiusWidth | string \| number | No| 0 | Width of the rounded corner.
**NOTE**
An invalid value is handled as the default value.| +| radiusHeight | string \| number | No| 0 | Height of the rounded corner.
**NOTE**
An invalid value is handled as the default value.| ## Attributes @@ -36,21 +35,20 @@ In addition to the [universal attributes](ts-universal-attributes-size.md), the | Name| Type| Default Value| Description| | -------- | -------- | -------- | -------- | -| radiusWidth | string \| number | 0 | Width of the rounded corner. The width and height are the same when only the width is set.
Since API version 9, this API is supported in ArkTS widgets.| -| radiusHeight | string \| number | 0 | Height of the rounded corner. The width and height are the same only when the height is set.
Since API version 9, this API is supported in ArkTS widgets.| -| radius | string \| number \| Array<string \| number> | 0 | Radius of the rounded corner. You can set separate radiuses for four rounded corners.
Since API version 9, this API is supported in ArkTS widgets.| -| fill | [ResourceColor](ts-types.md) | Color.Black | Color of the fill area.
Since API version 9, this API is supported in ArkTS widgets.| -| fillOpacity | number \| string \| [Resource](ts-types.md#resource)| 1 | Opacity of the fill area.
Since API version 9, this API is supported in ArkTS widgets.| -| stroke | [ResourceColor](ts-types.md) | - | Stroke color. If this attribute is not set, the component does not have any stroke.
Since API version 9, this API is supported in ArkTS widgets.| -| strokeDashArray | Array<Length> | [] | Stroke dashes.
Since API version 9, this API is supported in ArkTS widgets.| -| strokeDashOffset | number \| string | 0 | Offset of the start point for drawing the stroke.
Since API version 9, this API is supported in ArkTS widgets.| +| radiusWidth | string \| number | 0 | Width of the rounded corner. The width and height are the same when only the width is set.
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
An invalid value is handled as the default value.| +| radiusHeight | string \| number | 0 | Height of the rounded corner. The width and height are the same only when the height is set.
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
An invalid value is handled as the default value.| +| radius | string \| number \| Array<string \| number> | 0 | Radius of the rounded corner. You can set separate radiuses for four rounded corners.
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
An invalid value is handled as the default value.| +| fill | [ResourceColor](ts-types.md) | Color.Black | Color of the fill area.
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
An invalid value is handled as the default value.| +| fillOpacity | number \| string \| [Resource](ts-types.md#resource)| 1 | Opacity of the fill area.
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
An invalid value is handled as the default value.| +| stroke | [ResourceColor](ts-types.md) | - | Stroke color. If this attribute is not set, the component does not have any stroke.
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
If the value is invalid, no stroke will be drawn.| +| strokeDashArray | Array<Length> | [] | Stroke dashes.
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
An invalid value is handled as the default value.| +| strokeDashOffset | number \| string | 0 | Offset of the start point for drawing the stroke.
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
An invalid value is handled as the default value.| | strokeLineCap | [LineCapStyle](ts-appendix-enums.md#linecapstyle) | LineCapStyle.Butt | Cap style of the stroke.
Since API version 9, this API is supported in ArkTS widgets.| | strokeLineJoin | [LineJoinStyle](ts-appendix-enums.md#linejoinstyle) | LineJoinStyle.Miter | Join style of the stroke.
Since API version 9, this API is supported in ArkTS widgets.| -| strokeMiterLimit | number \| string | 4 | Limit on the ratio of the miter length to the value of **strokeWidth** used to draw a miter join. The miter length indicates the distance from the outer tip to the inner corner of the miter.
**NOTE**
This attribute must be set to a value greater than or equal to 1 and takes effect when **strokeLineJoin** is set to **LineJoinStyle.Miter**.
Since API version 9, this API is supported in ArkTS widgets.| -| strokeOpacity | number \| string \| [Resource](ts-types.md#resource)| 1 | Stroke opacity.
**NOTE**
The value range is [0.0, 1.0]. If the set value is less than 0.0, **0.0** will be used. If the set value is greater than 1.0, **1.0** will be used.
Since API version 9, this API is supported in ArkTS widgets.| -| strokeWidth | Length | 1 | Stroke width.
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
The value cannot be a percentage.| -| antiAlias | boolean | true | Whether anti-aliasing is enabled.
Since API version 9, this API is supported in ArkTS widgets.| - +| strokeMiterLimit | number \| string | 4 | Limit on the ratio of the miter length to the value of **strokeWidth** used to draw a miter join. The miter length indicates the distance from the outer tip to the inner corner of the miter.
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
This attribute works only when **strokeLineJoin** is set to **LineJoinStyle.Miter**.
The value must be greater than or equal to 1.0. If the value is in the [0, 1) range, the value **1.0** will be used. In other cases, the default value will be used.| +| strokeOpacity | number \| string \| [Resource](ts-types.md#resource)| 1 | Stroke opacity.
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
The value range is [0.0, 1.0]. A value less than 0.0 evaluates to the value **0.0**. A value greater than 1.0 evaluates to the value **1.0**. Any other value evaluates to the value **1.0**.| +| strokeWidth | Length | 1 | Stroke width.
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
The value cannot be a percentage.
An invalid value is handled as the default value.| +| antiAlias | boolean | true | Whether anti-aliasing is enabled.
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
An invalid value is handled as the default value.| ## Example 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 e3f57037af5c78d001a79831ebe65819706bf460..c9506bbbf823f263f8675fc0329eb5d51f5f2f0c 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 @@ -2,7 +2,6 @@ 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. - 1. Drawing components use **\** as their parent to implement the effect similar to SVG. 2. The **\** component is used independently to draw a specific shape. @@ -36,17 +35,17 @@ In addition to the [universal attributes](ts-universal-attributes-size.md), the | Name| Type| Default Value| Description| | -------- | -------- | -------- | -------- | -| viewPort | {
x?: number \| string,
y?: number \| string,
width?: number \| string,
height?: number \| string
} | { x:0, y:0, width:0, height:0 } | Viewport of the shape.
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
If of the string type, the value cannot be a percentage.| -| fill | [ResourceColor](ts-types.md) | Color.Black | Color of the fill area.
Since API version 9, this API is supported in ArkTS widgets.| -| fillOpacity | number \| string \| [Resource](ts-types.md#resource)| 1 | Opacity of the fill area.
Since API version 9, this API is supported in ArkTS widgets.| -| stroke | [ResourceColor](ts-types.md) | - | Stroke color. If this attribute is not set, the component does not have any stroke.
Since API version 9, this API is supported in ArkTS widgets.| -| strokeDashArray | Array<Length> | [] | Stroke dashes.
Since API version 9, this API is supported in ArkTS widgets.| -| strokeDashOffset | number \| string | 0 | Offset of the start point for drawing the stroke.
Since API version 9, this API is supported in ArkTS widgets.| +| viewPort | {
x?: number \| string,
y?: number \| string,
width?: number \| string,
height?: number \| string
} | { x:0, y:0, width:0, height:0 } | View port of the shape.
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
If of the string type, the value cannot be a percentage.
An invalid value is handled as the default value.| +| fill | [ResourceColor](ts-types.md) | Color.Black | Color of the fill area.
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
An invalid value is handled as the default value.| +| fillOpacity | number \| string \| [Resource](ts-types.md#resource)| 1 | Opacity of the fill area.
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
An invalid value is handled as the default value.| +| stroke | [ResourceColor](ts-types.md) | - | Stroke color. If this attribute is not set, the component does not have any stroke.
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
If the value is invalid, no stroke will be drawn.| +| strokeDashArray | Array<Length> | [] | Stroke dashes.
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
An invalid value is handled as the default value.| +| strokeDashOffset | number \| string | 0 | Offset of the start point for drawing the stroke.
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
An invalid value is handled as the default value.| | strokeLineCap | [LineCapStyle](ts-appendix-enums.md#linecapstyle) | LineCapStyle.Butt | Cap style of the stroke.
Since API version 9, this API is supported in ArkTS widgets.| | strokeLineJoin | [LineJoinStyle](ts-appendix-enums.md#linejoinstyle) | LineJoinStyle.Miter | Join style of the stroke.
Since API version 9, this API is supported in ArkTS widgets.| -| strokeMiterLimit | number \| string | 4 | Limit on the ratio of the miter length to the value of **strokeWidth** used to draw a miter join. The miter length indicates the distance from the outer tip to the inner corner of the miter.
**NOTE**
This attribute must be set to a value greater than or equal to 1 and takes effect when **strokeLineJoin** is set to **LineJoinStyle.Miter**.
Since API version 9, this API is supported in ArkTS widgets.| -| strokeOpacity | number \| string \| [Resource](ts-types.md#resource)| 1 | Stroke opacity.
**NOTE**
The value range is [0.0, 1.0]. If the set value is less than 0.0, **0.0** will be used. If the set value is greater than 1.0, **1.0** will be used.
Since API version 9, this API is supported in ArkTS widgets.| -| strokeWidth | number \| string | 1 | Stroke width.
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
If of the string type, the value cannot be a percentage.| +| strokeMiterLimit | number \| string | 4 | Limit on the ratio of the miter length to the value of **strokeWidth** used to draw a miter join. The miter length indicates the distance from the outer tip to the inner corner of the miter.
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
This attribute works only when **strokeLineJoin** is set to **LineJoinStyle.Miter**. The value must be greater than or equal to 1.0. If the value is in the [0, 1) range, the value **1.0** will be used. In other cases, the default value will be used.| +| strokeOpacity | number \| string \| [Resource](ts-types.md#resource)| 1 | Stroke opacity.
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
The value range is [0.0, 1.0]. A value less than 0.0 evaluates to the value **0.0**. A value greater than 1.0 evaluates to the value **1.0**. Any other value evaluates to the value **1.0**.| +| strokeWidth | number \| string | 1 | Stroke width.
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
If of the string type, the value cannot be a percentage.
An invalid value is handled as the default value.| | antiAlias | boolean | true | Whether anti-aliasing is enabled.
Since API version 9, this API is supported in ArkTS widgets.| | mesh8+ | Array<number>,number,number | [],0,0 | Mesh effect. The first parameter is an array of lengths (column + 1) * (row + 1) * 2, which records the position of each vertex of the distorted bitmap. The second parameter is the number of columns in the mesh matrix. The third parameter is the number of rows in the mesh matrix.
Since API version 9, this API is supported in ArkTS widgets.| 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 3e756f519e74b7f851b3af2401e7272eb133a4a9..93b2912e0d4105efc88fb8ce4189095d75a04422 100644 --- a/en/application-dev/reference/arkui-ts/ts-explicit-animation.md +++ b/en/application-dev/reference/arkui-ts/ts-explicit-animation.md @@ -5,6 +5,10 @@ You can create explicit animation with your custom settings. > **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. +> +> The functionality of this module depends on UI context. This means that the APIs of this module cannot be used where the UI context is unclear. For details, see [UIContext](../apis/js-apis-arkui-UIContext.md#uicontext). +> +> Since API version 10, you can use the [animateTo](../apis/js-apis-arkui-UIContext.md#animateto) API in [UIContext](../apis/js-apis-arkui-UIContext.md#uicontext) to obtain the UI context. animateTo(value: AnimateParam, event: () => void): void @@ -19,14 +23,18 @@ Since API version 9, this API is supported in ArkTS widgets. | Name| Type| Description| | -------- | -------- | -------- | -| duration | number | Animation duration, in ms.
Default value: **1000**
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
- The maximum animation duration on an ArkTS widget is 1000 ms. If the set value exceeds the limit, the value **1000** will be used.| -| tempo | number | 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.
Default value: **1.0**| +| duration | number | Animation duration, in ms.
Default value: **1000**
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
- The maximum animation duration on an ArkTS widget is 1000 ms. If the set value exceeds the limit, the value **1000** will be used.
- A value less than 0 evaluates to the value **0**.
- Floating-point values will be rounded down to integers. For example, if the value set is 1.2, **1** will be used.| +| tempo | number | 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.
Default value: **1.0**
**NOTE**
A value less than 0 evaluates to the value **1**.| | curve | [Curve](ts-appendix-enums.md#curve) \| [ICurve](../apis/js-apis-curve.md#icurve) \| string | Animation curve.
Default value: **Curve.Linear**
Since API version 9, this API is supported in ArkTS widgets.| -| delay | number | Delay of animation playback, in ms. By default, the playback is not delayed.
Default value: **0**| +| delay | number | Delay of animation playback, in ms. By default, the playback is not delayed.
Default value: **0**
**NOTE**
- A value less than 0 evaluates to the value **0**.
- Floating-point values will be rounded down to integers. For example, if the value set is 1.2, **1** will be used.| | iterations | number | 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.
Default value: **1**| -| playMode | [PlayMode](ts-appendix-enums.md#playmode) | Animation playback mode. By default, the animation is played from the beginning after the playback is complete.
Default value: **PlayMode.Normal**
Since API version 9, this API is supported in ArkTS widgets.| +| playMode | [PlayMode](ts-appendix-enums.md#playmode) | Animation playback mode. By default, the animation is played from the beginning after the playback is complete.
Default value: **PlayMode.Normal**
Since API version 9, this API is supported in ArkTS widgets.
For details about the restrictions, see **Notes about PlayMode**.| | onFinish | () => void | Callback invoked when the animation playback is complete.
Since API version 9, this API is supported in ArkTS widgets.| +> **Notes about PlayMode**: +> - **PlayMode.Normal** and **PlayMode.Alternate** are recommended. Under these settings, the first round of the animation is played forwards. If **PlayMode.Reverse** or **PlayMode.AlternateReverse** is used, the first round of the animation is played backwards. In this case, the animation jumps to the end state and then starts from there. +> - When using **PlayMode.Alternate** or **PlayMode.AlternateReverse**, make sure the final state of the animation is the same as the value of the state variable. In other words, make sure the last round of the animation is played forwards. When **PlayMode.Alternate** is used, **iterations** must be set to an odd number. When **PlayMode.AlternateReverse** is used, **iterations** must be set to an even number. +> - **PlayMode.Reverse** is not recommended. Under this setting, the animation jumps to the end state at the beginning, and its final state will be different from the value of the state variable. ## Example 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 6b37f324306957502522eddda9c14be98bee3797..8761afbe8aa8bfaeb3c80de85d2ebdb5b8161a97 100644 --- a/en/application-dev/reference/arkui-ts/ts-gesture-settings.md +++ b/en/application-dev/reference/arkui-ts/ts-gesture-settings.md @@ -2,9 +2,9 @@ Bind different types of gesture events to components and set response methods for them. -> **NOTE** +> **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. +> The APIs of this module are supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. ## Binding Gesture Recognition @@ -65,6 +65,9 @@ The component binds gesture objects of different **GestureType**s through gestur | tiltX9+ | number | Angle between the projection of the stylus on the device plane and the x-axis.| | tiltY9+ | number | Angle between the projection of the stylus on the device plane and the y-axis.| | sourceTool9+ | [SourceTool](#sourcetool) | Event input source.| +| velocityX10+ | number | Velocity along the x-axis. This parameter is used in [PanGesture](ts-basic-gestures-pangesture.md). The origin of the coordinate axis is the upper left corner of the screen. The velocity is positive if the movement is from left to right, and it is negative if the movement is from right to left.| +| velocityY10+ | number | Velocity along the y-axis. This parameter is used in [PanGesture](ts-basic-gestures-pangesture.md). The origin of the coordinate axis is the upper left corner of the screen. The velocity is positive if the movement is from top to bottom, and it is negative if the movement is from bottom to top.| +| velocity10+ | number | Velocity along the main axis. This parameter is used in [PanGesture](ts-basic-gestures-pangesture.md). The value is the arithmetic square root of the sum of squares of the velocity along the x- and y-axis.| ## SourceType | Name| Description| 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 20b98309f386de5f891f49955adb97a9c879be79..23371f6c72aba355a27702582aea203ebaa42698 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 @@ -8,7 +8,7 @@ You can set the text content and response callback for an alert dialog box. > > The functionality of this module depends on UI context. This means that the APIs of this module cannot be used where the UI context is unclear. For details, see [UIContext](../apis/js-apis-arkui-UIContext.md#uicontext). > -> Since API version 10, you can use the[showAlertDialog](../apis/js-apis-arkui-UIContext.md#showalertdialog) API in [UIContext](../apis/js-apis-arkui-UIContext.md#uicontext) to obtain the UI context. +> Since API version 10, you can use the [showAlertDialog](../apis/js-apis-arkui-UIContext.md#showalertdialog) API in [UIContext](../apis/js-apis-arkui-UIContext.md#uicontext) to obtain the UI context. ## Attributes 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 8018ee5d626d0fcb04dd36f3d70e2081736b189d..abf39f4dc607abdb37dedea6ed2407e22fb9f94c 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 @@ -12,23 +12,8 @@ You can configure the component transition animations through the **transition** | Name| Type| Description| | -------- | -------- | -------- | -| transition | TransitionOptions \| TransitionEffect10+ | Transition effects when the component is inserted, displayed, deleted, or hidden.
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
For details, see the description of **TransitionOptions** and **TransitionEffect**.| +| transition | TransitionOptions(deprecated) \| TransitionEffect10+ | Transition effects when the component is inserted, displayed, deleted, or hidden.
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
For details, see the descriptions of **TransitionOptions** and **TransitionEffect**.| -## TransitionOptions -Defines the transition effect by setting parameters in the struct. -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| type | [TransitionType](ts-appendix-enums.md#transitiontype) | No| Transition type.
Default value: **TransitionType.All**
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
If **type** is not specified, the default value **TransitionType.All** is used, which means that the transition effect works for both component addition and deletion.| -| opacity | number | No| Opacity of the component during transition, which is the value of the start point of insertion and the end point of deletion.
Value range: [0, 1]
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
A value less than 0 or greater than 1 evaluates to the value **1**.| -| translate | {
x? : number \| string,
y? : number \| string,
z? : number \| string
} | No| Translation of the component during transition, which is the value of the start point of insertion and the end point of deletion.
-**x**: distance to translate along the x-axis.
-**y**: distance to translate along the y-axis.
-**z**: distance to translate along the z-axis.
Since API version 9, this API is supported in ArkTS widgets.| -| scale | {
x? : number,
y? : number,
z? : number,
centerX? : number \| string,
centerY? : number \| string
} | No| Scaling of the component during transition, which is the value of the start point of insertion and the end point of deletion.
- **x**: scale factor along the x-axis.
- **y**: scale factor along the y-axis.
- **z**: scale factor along the z-axis.
- **centerX** and **centerY**: scale center point. The default values are both **"50%"**, indicating that the center point of the page.
- If the center point is (0, 0), it refers to the upper left corner of the component.
Since API version 9, this API is supported in ArkTS widgets.| -| rotate | {
x?: number,
y?: number,
z?: number,
angle: number \| string,
centerX?: number \| string,
centerY?: number \| string
} | No| Rotation of the component during transition, which is the value of the start point of insertion and the end point of deletion.
- **x**: X-component of the rotation vector.
- **y**: Y-component of the rotation vector.
- **z**: Z-component of the rotation vector.
- **centerX** and **centerY**: rotation center point. The default values are both **"50%"**, indicating that the center point of the page.
- If the center point is (0, 0), it refers to the upper left corner of the component.
Since API version 9, this API is supported in ArkTS widgets.| - -> **NOTE** -> -> 1. When set to a value of the **TransitionOptions** type, the **transition** attribute must work with [animateTo](ts-explicit-animation.md). The animation duration, curve, and delay follow the settings in **animateTo**. -> 2. If the value of the **TransitionOptions** type has only **type** specified, the transition effect will take on the default opacity. For example, **{type: TransitionType.Insert}** produces the same effect as **{type: TransitionType.Insert, opacity: 0}**. If a specific style is specified, the transition effect will not take on the default opacity. -> 3. For details about the scale and rotate effects, see [Transformation](ts-universal-attributes-transformation.md). ## TransitionEffect10+ Defines the transition effect by using the provided APIs, as listed below. @@ -37,7 +22,7 @@ Defines the transition effect by using the provided APIs, as listed below. | opacity | number | Yes| Opacity of the component during transition, which is the value of the start point of insertion and the end point of deletion.
Value range: [0, 1]
**NOTE**
A value less than 0 or greater than 1 evaluates to the value **1**.| | translate | {
x? : number \| string,
y? : number \| string,
z? : number \| string
} | Yes| Translation of the component during transition, which is the value of the start point of insertion and the end point of deletion.
-**x**: distance to translate along the x-axis.
-**y**: distance to translate along the y-axis.
-**z**: distance to translate along the z-axis.| | scale | {
x? : number,
y? : number,
z? : number,
centerX? : number \| string,
centerY? : number \| string
} | Yes| Scaling of the component during transition, which is the value of the start point of insertion and the end point of deletion.
- **x**: scale factor along the x-axis.
- **y**: scale factor along the y-axis.
- **z**: scale factor along the z-axis.
- **centerX** and **centerY**: scale center point. The default values are both **"50%"**, indicating that the center point of the page.
- If the center point is (0, 0), it refers to the upper left corner of the component.| -| rotate | {
x?: number,
y?: number,
z?: number,
angle: number \| string,
centerX?: number \| string,
centerY?: number \| string
} | Yes| Rotation of the component during transition, which is the value of the start point of insertion and the end point of deletion.
- **x**: rotation vector along the x-axis.
- **y**: Y-component of the rotation vector.
- **z**: Z-component of the rotation vector.
- **centerX** and **centerY**: rotation center point. The default values are both **"50%"**, indicating that the center point of the page.
- If the center point is (0, 0), it refers to the upper left corner of the component.| +| rotate | {
x?: number,
y?: number,
z?: number,
angle: number \| string,
centerX?: number \| string,
centerY?: number \| string
} | Yes| Rotation of the component during transition, which is the value of the start point of insertion and the end point of deletion.
- **x**: X-component of the rotation vector.
- **y**: Y-component of the rotation vector.
- **z**: Z-component of the rotation vector.
- **centerX** and **centerY**: rotation center point. The default values are both **"50%"**, indicating that the center point of the page.
- If the center point is (0, 0), it refers to the upper left corner of the component.| | move | [TransitionEdge](ts-appendix-enums.md#transitionedge10) | Yes| Slide-in and slide-out of the component from the screen edge during transition. It is essentially a translation effect, which is the value of the start point of insertion and the end point of deletion.| | asymmetric | appear: TransitionEffect,
disappear: TransitionEffect
| Yes| Asymmetric transition effect.
The first parameter indicates the transition effect for appearance, and the second parameter indicates the transition effect for disappearance.
If the **asymmetric** function is not used for **TransitionEffect**, the transition effect takes effect for both appearance and disappearance of the component.| | combine | TransitionEffect | No| Combination of transition effects.| @@ -49,7 +34,7 @@ The static functions listed in the preceding table are used to create a **Transi | -------- | -------- | | IDENTITY | Disables the transition effect.| | OPACITY | Applies a transition effect with the opacity of 0. It is equivalent to **TransitionEffect.opacity(0)**.| -| SLIDE | Applies a transition effect of sliding in from the left when the component appears and sliding out from the right when the component disappears. It is equivalent to **TransitionEffect.asymmetric(TransitionEffect.START, TrasitionEffect.END)**.| +| SLIDE | Applies a transition effect of sliding in from the left when the component appears and sliding out from the right when the component disappears. It is equivalent to **TransitionEffect.asymmetric(TransitionEffect.move(TransitionEdge.START), TransitionEffect.move(TransitionEdge.END))**.| > **NOTE** > @@ -57,47 +42,26 @@ The static functions listed in the preceding table are used to create a **Transi > 2. The animation settings take effect in the following sequence: animation settings specified in the current **TransitionEffect** > animation settings specified in the previous **TransitionEffect** > animation settings specified in **animateTo** that triggers the component to appear and disappear. > 3. If **animateTo** is not used and **TransitionEffect** does not have the **animation** parameter specified, the component will appear or disappear without any transition animation. > 4. If the value of an attribute specified in **TransitionEffect** is the same as the default value, no transition animation is applied for the attribute. For example, with **TransitionEffect.opacity(1).animation({duration:1000})**, because the default value of **opacity** is also **1**, no opacity animation will be applied, and the component appears or disappears without any transition animation. +> 5. For details about the scale and rotate effects, see [Transformation](ts-universal-attributes-transformation.md). -## Example -The following is an example of using **TransitionOptions** for appearance and disappearance of the component. -```ts -// xxx.ets -@Entry -@Component -struct TransitionExample { - @State flag: boolean = true - @State show: string = 'show' +## TransitionOptions(deprecated) +Defines the transition effect by setting parameters in the struct. - build() { - Column() { - Button(this.show).width(80).height(30).margin(30) - .onClick(() => { - // Click the button to show or hide the image. - if (this.flag) { - this.show = 'hide'; - } else { - this.show = 'show'; - } - // When set to a value of the TransitionOptions type, the transition attribute must work with animateTo. - animateTo({ duration: 1000 }, () => { - this.flag = !this.flag - }) - }) - if (this.flag) { - // Apply different transition effects to the appearance and disappearance of the image. - // When the image appears, it changes from the state where the scale factor is 0 along the x-axis and 1 along the y-axis to the state where the scale factor is both 1 along x-axis and y-axis. - // When the image disappears, it rotates from 0° to 180° clockwise around the z-axis. - Image($r('app.media.testImg')).width(200).height(200) - .transition({ type: TransitionType.Insert, scale: { x: 0, y: 1.0 } }) - .transition({ type: TransitionType.Delete, rotate: { z: 1, angle: 180 } }) - } - }.width('100%') - } -} -``` +This API is deprecated since API version 10. You are advised to use [TransitionEffect](#transitioneffect10) instead. +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| type | [TransitionType](ts-appendix-enums.md#transitiontype) | No| Transition type.
Default value: **TransitionType.All**
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
If **type** is not specified, the default value **TransitionType.All** is used, which means that the transition effect works for both component addition and deletion.| +| opacity | number | No| Opacity of the component during transition, which is the value of the start point of insertion and the end point of deletion.
Value range: [0, 1]
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
A value less than 0 or greater than 1 evaluates to the value **1**.| +| translate | {
x? : number \| string,
y? : number \| string,
z? : number \| string
} | No| Translation of the component during transition, which is the value of the start point of insertion and the end point of deletion.
-**x**: distance to translate along the x-axis.
-**y**: distance to translate along the y-axis.
-**z**: distance to translate along the z-axis.
Since API version 9, this API is supported in ArkTS widgets.| +| scale | {
x? : number,
y? : number,
z? : number,
centerX? : number \| string,
centerY? : number \| string
} | No| Scaling of the component during transition, which is the value of the start point of insertion and the end point of deletion.
- **x**: scale factor along the x-axis.
- **y**: scale factor along the y-axis.
- **z**: scale factor along the z-axis.
- **centerX** and **centerY**: scale center point. The default values are both **"50%"**, indicating that the center point of the page.
- If the center point is (0, 0), it refers to the upper left corner of the component.
Since API version 9, this API is supported in ArkTS widgets.| +| rotate | {
x?: number,
y?: number,
z?: number,
angle: number \| string,
centerX?: number \| string,
centerY?: number \| string
} | No| Rotation of the component during transition, which is the value of the start point of insertion and the end point of deletion.
- **x**: X-component of the rotation vector.
- **y**: Y-component of the rotation vector.
- **z**: Z-component of the rotation vector.
- **centerX** and **centerY**: rotation center point. The default values are both **"50%"**, indicating that the center point of the page.
- If the center point is (0, 0), it refers to the upper left corner of the component.
Since API version 9, this API is supported in ArkTS widgets.| -Below you can see the example in action.
-![transitionComponent1](figures/transitionComponent1.gif) +> **NOTE** +> +> 1. When set to a value of the **TransitionOptions** type, the **transition** attribute must work with [animateTo](ts-explicit-animation.md). The animation duration, curve, and delay follow the settings in **animateTo**. +> 2. If the value of the **TransitionOptions** type has only **type** specified, the transition effect will take on the default opacity. For example, **{type: TransitionType.Insert}** produces the same effect as **{type: TransitionType.Insert, opacity: 0}**. If a specific style is specified, the transition effect will not take on the default opacity. + +## Example The following is an example of using the same transition effect for the appearance and disappearance (which are inverse processes) of the component. ```ts 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 2fcbfe67f010ea80ca278932bf4210074d438878..c741d2973743543c25e430e7575c8162053780bf 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 @@ -12,7 +12,7 @@ A shared element transition is a transition animation applied to a component tha | Name | Parameter | Description | | ---------------- | ------------------------------------------------------------ | ------------------------------------------------------------ | -| sharedTransition | id: string,
{
duration?: number,
curve?: Curve \| string,
delay?: number,
motionPath?:
{
path: string,
form?: number,
to?: number,
rotatable?: boolean
},
zIndex?: number,
type?: [SharedTransitionEffectType](ts-appendix-enums.md#sharedtransitioneffecttype)
} | Transition of the shared element. If the same **id** value is configured for a component on the two pages, this component is considered as a shared element of the pages. If the **id** value is an empty string, no transition will be applied to the component.
- **id**: component ID.
- **duration**: animation duration.
Default value: **1000**
Unit: ms
Value range: [0, +∞)
The value **0** indicates that no animation is applied. A value less than 0 evaluates to the value **0**.
- **curve**: animation curve. The default curve is **Linear**. For details about the valid values, see [Curve](ts-animatorproperty.md).
- **delay**: animation delay.
Default value: **0**
Unit: ms
Value range: [0, +∞)
A value less than 0 evaluates to the value **0**.
- **motionPath**: motion path information. For details, see [Motion Path Animation](ts-motion-path-animation.md).
- **path**: path.
- **from**: start value.
- **to**: end value.
- **rotatable**: whether to rotate.
- **zIndex**: z-axis.
- **type**: animation type.| +| sharedTransition | id: string,
{
duration?: number,
curve?: Curve \| string,
delay?: number,
motionPath?:
{
path: string,
form?: number,
to?: number,
rotatable?: boolean
},
zIndex?: number,
type?: [SharedTransitionEffectType](ts-appendix-enums.md#sharedtransitioneffecttype)
} | Transition of the shared element. If the same **id** value is configured for a component on the two pages, this component is considered as a shared element of the pages. If the **id** value is an empty string, no transition will be applied to the component.
- **id**: component ID.
- **duration**: animation duration.
Default value: **1000**
Unit: ms
Value range: [0, +∞)
The value **0** indicates that no animation is applied. A value less than 0 evaluates to the default value **1000**.
- **curve**: animation curve. The default curve is **Linear**. For details about the valid values, see [Curve](ts-animatorproperty.md).
- **delay**: animation delay.
Default value: **0**
Unit: ms
Value range: [0, +∞)
A value less than 0 evaluates to the value **0**.
- **motionPath**: motion path information. For details, see [Motion Path Animation](ts-motion-path-animation.md).
- **path**: path.
- **from**: start value.
- **to**: end value.
- **rotatable**: whether to rotate.
- **zIndex**: z-axis.
- **type**: animation type.| ## Example diff --git a/en/application-dev/reference/arkui-ts/ts-types.md b/en/application-dev/reference/arkui-ts/ts-types.md index 1b3f4797c639b3e566b5beccff527ab4b83c21d8..00799c76b97e399281f1593d182fea925bee3c23 100644 --- a/en/application-dev/reference/arkui-ts/ts-types.md +++ b/en/application-dev/reference/arkui-ts/ts-types.md @@ -228,7 +228,7 @@ The **CustomBuilder** type is used to define custom UI descriptions in component | Name | Type | Description | | ------------- | ---------------------- | ---------------------------------------- | -| CustomBuilder | () => any | Must be decorated by **@Builder**. For details, see [@Builder](../../quick-start/arkts-builder.md).| +| CustomBuilder | () => any | Builder for creating a custom component; must be used with @Builder. For details, see [@Builder](../../quick-start/arkts-builder.md).| ## PixelStretchEffectOptions10+ @@ -321,3 +321,23 @@ Describes the animation information of the \ component. | currentOffset | number | Offset of the currently displayed element relative to the start position of the **\** along the main axis. Unit: vp
Default value: **0**| | targetOffset | number | Offset of the target element relative to the start position of the **\** along the main axis. Unit: vp
Default value: **0**| | velocity | number | Hands-off velocity at the beginning of the animation. Unit: vp/s
Default value: **0**| +## SafeAreaType10+ + +The **SafeAreaType** type is used to describe the types of expanded safe areas. + +| Name | Description | +| -------- | ------------------------------------------ | +| SYSTEM | Default non-safe area of the system, including the status bar and navigation bar. | +| CUTOUT | Non-safe area of the device, for example, the notch area.| +| KEYBOARD | Soft keyboard area. | + +## SafeAreaEdge10+ + +The **SafeAreaEdge** type is used to define the edge for expanding the safe area. + +| Name | Description | +| ------ | ---------- | +| TOP | Top edge.| +| BOTTOM | Bottom edge.| +| START | Start edge.| +| END | End edge.| 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 d5273a2bf095ea4fa4f34e2e7306f7b467ff72db..9685a333244c3b756fa4e4eb5f5f101a3f142f61 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 @@ -4,15 +4,16 @@ > > - The APIs of this module are 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. +> - The column width and column gap in the grid layout are determined by the nearest parent component **\**. The component tree that uses grid attributes must contain one **\** component or more. +> - To call the **gridSpan** or **gridOffset** attribute, its parent or ancestor component must be **\**. ## Attributes | Name | Type | Description | | ----------- | ------------------------------------------------------------ | ------------------------------------------------------------ | -| useSizeType(deprecated) | {
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**.
This attribute is deprecated since API version 9. You are advised to use [GridCol](ts-container-gridcol.md) and [GridRow](ts-container-gridrow.md) instead. | +| useSizeType(deprecated) | {
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**.
This attribute is deprecated since API version 9. You are advised to use [GridCol](ts-container-gridcol.md) and [GridRow](ts-container-gridrow.md) instead.| | gridSpan | number | 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.
Default value: **1**| | gridOffset | number | 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**
- 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.
- Offset = (Column width + Gap) \* Number of columns.
- After this attribute is set, sibling components will be arranged relatively to this component, as in the relative layout.
Default value: **0**| @@ -110,6 +111,6 @@ struct GridContainerExample1 { ![en-us_image_0000001212378416](figures/en-us_image_0000001212378416.png) -**Figure 4** Setting gridSpan and gridOffset separately has the same effect as using SizeType for a specific device width type +**Figure 4** Setting gridSpan and gridOffset separately has the same effect as useSizeType for a specific device width type ![gridSpan](figures/gridSpan.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 76855375443264f0e2552db2b0df1fd339d8a53b..3ed88228f7e2ab9f68b61479f027f03b6b26c4cd 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 @@ -55,7 +55,7 @@ struct AspectRatioExample { Text(item) .backgroundColor(0xbbb2cb) .fontSize(40) - .height(160) + .width('100%') .aspectRatio(1.5) } }, item => item) @@ -70,10 +70,12 @@ struct AspectRatioExample { } ``` -**Figure 1** Portrait display
+**Figure 1** Portrait display + ![en-us_image_0000001256978379](figures/en-us_image_0000001256978379.gif) -**Figure 2** Landscape display
+**Figure 2** Landscape display + ![en-us_image_0000001212218476](figures/en-us_image_0000001212218476.gif) ```ts @@ -133,4 +135,6 @@ struct DisplayPriorityExample { ``` +Landscape display in containers of different sizes + ![en-us_image_0000001212058504](figures/en-us_image_0000001212058504.gif) 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 index f0698f179b985dff0628d8d963b736ad51d7d16e..a65cf6360f920e72c90a094a2191a210155834fa 100644 --- 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 @@ -9,7 +9,7 @@ You can set state-specific styles for components. ## Attributes -| Style| Type| Description| +| Name| Type| Description| | -------- | -------- | -------- | | stateStyles | StateStyles | Styles of the component for different states.
Since API version 9, this API is supported in ArkTS widgets.| @@ -21,9 +21,10 @@ Since API version 9, this API is supported in ArkTS widgets. | -------- | -------- | -------- | -------- | | normal | ()=>void | No| Style of the component when being stateless.| | pressed | ()=>void | No| Style of the component in the pressed state.| -| disabled | ()=>void | No| Style of the component in disabled state.| -| focused | ()=>void | No| Style of the component in focused state.| -| clicked | ()=>void | No| Style of the component in clicked state.| +| disabled | ()=>void | No| Style of the component in the disabled state.| +| focused | ()=>void | No| Style of the component in the focused state.| +| clicked | ()=>void | No| Style of the component in the clicked state.| +| selected10+ | ()=>void | No| Style of the component in the selected state.| ## Example 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 index 891a32648e566f5c2bb4de1aa0ea231ab86d6c18..930672fb147052dc00382a014c3ccfcc57e44641 100644 --- 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 @@ -5,19 +5,14 @@ A drag event is triggered when a component is dragged. > **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. +> +> The following components provide the drag effect by default: [\](../arkui-ts/ts-basic-components-image.md), [\](../arkui-ts/ts-basic-components-text.md), [\