diff --git a/en/application-dev/Readme-EN.md b/en/application-dev/Readme-EN.md index 938cada5bbd41bddbc595dffd118198b08a02da9..b79d932947d6eeabe8cdb745573bc8fdc0e68f6b 100644 --- a/en/application-dev/Readme-EN.md +++ b/en/application-dev/Readme-EN.md @@ -8,9 +8,9 @@ - [JavaScript-based Web-like Development Paradigm](ui/ui-arkui-js.md) - [TypeScript-based Declarative Development Paradigm](ui/ui-arkui-ts.md) -- [Audio](media/audio.md) +- [Media](media/Readme-EN.md) - [IPC & RPC](connectivity/ipc-rpc.md) -- [Application Event Logging](application-event-logging/hiappevent.md) +- [DFX](dfx/Readme-EN.md) - [Development References](reference/Readme-EN.md) - [JavaScript-based Web-like Development Paradigm](reference/arkui-js/Readme-EN.md) - [TypeScript-based Declarative Development Paradigm](reference/arkui-ts/Readme-EN.md) diff --git a/en/application-dev/application-event-logging/hiappevent.md b/en/application-dev/application-event-logging/hiappevent.md deleted file mode 100644 index 9f71ed849a4b10d7d0c9389fef7b761dbaf8782c..0000000000000000000000000000000000000000 --- a/en/application-dev/application-event-logging/hiappevent.md +++ /dev/null @@ -1,5 +0,0 @@ -# Application Event Logging - -- [Overview of Application Event Logging](hiappevent-overview.md) -- [Development Guidelines on Application Event Logging](hiappevent-guidelines.md) - diff --git a/en/application-dev/database/Readme-EN.md b/en/application-dev/database/Readme-EN.md new file mode 100644 index 0000000000000000000000000000000000000000..9e68a292b434f94c7711e79aa8452e911590c998 --- /dev/null +++ b/en/application-dev/database/Readme-EN.md @@ -0,0 +1,4 @@ +# Distributed Data Service + +- [Distributed Data Service Overview](database-mdds-overview.md) +- [Distributed Data Service Development](database-mdds-guidelines.md) diff --git a/en/application-dev/database/database-mdds-guidelines.md b/en/application-dev/database/database-mdds-guidelines.md new file mode 100644 index 0000000000000000000000000000000000000000..d0be8af0aa1d82af02f8c21e6ab0113d5fe4e350 --- /dev/null +++ b/en/application-dev/database/database-mdds-guidelines.md @@ -0,0 +1,235 @@ +# Distributed Data Service Development + +## When to Use + +The DDS implements synchronization of application data across user devices. When data is added, deleted, or modified for an application on a device, the same application on another device can obtain the data changes. The DDS applies to the distributed gallery, messages, contacts, and file manager. + +## Available APIs + +The following table describes the APIs provided by the OpenHarmony DDS module. + +**Table 1** APIs provided by the DDS + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Function

+

API

+

Description

+

Creating a distributed database

+

createKVManager(config: KVManagerConfig, callback: AsyncCallback<KVManager>): void

+

createKVManager(config: KVManagerConfig): Promise<KVManager>

+

Creates a KVManager object for database management.

+

getKVStore<T extends KVStore>(storeId: string, options: Options, callback: AsyncCallback<T>): void

+

getKVStore<T extends KVStore>(storeId: string, options: Options): Promise<T>

+

Obtains the KV store with specified Options and storeId.

+

Managing data in a distributed database

+

put(key: string, value: Uint8Array | string | number | boolean, callback: AsyncCallback<void>): void

+

put(key: string, value: Uint8Array | string | number | boolean): Promise<void>

+

Inserts and updates data.

+

delete(key: string, callback: AsyncCallback<void>): void

+

delete(key: string): Promise<void>

+

Deletes data.

+

get(key: string, callback: AsyncCallback<Uint8Array | string | boolean | number>): void

+

get(key: string): Promise<Uint8Array | string | boolean | number>

+

Queries data.

+

Subscribing to changes in the distributed data

+

on(event: 'dataChange', type: SubscribeType, observer: Callback<ChangeNotification>): void

+

on(event: 'syncComplete', syncCallback: Callback<Array<[string, number]>>): void

+

Subscribes to data changes in the database.

+

Synchronizing distributed data

+

sync(deviceIdList: string[], mode: SyncMode, allowedDelayMs?: number): void

+

Triggers database synchronization in manual mode.

+
+ +## How to Develop + +The following uses a single KV store as an example to describe the development procedure. + +1. Import the distributed database module. + + ``` + import distributedData from '@ohos.data.distributedData'; + ``` + +2. Create a **KvManager** instance based on the specified **KvManagerConfig** object. + + 1. Create a **KvManagerConfig** object based on the application context. + 2. Create a **KvManager** instance. + + The sample code is as follows: + + ``` + let kvManager; + try { + const kvManagerConfig = { + bundleName : 'com.example.datamanagertest', + userInfo : { + userId : '0', + userType : distributedData.UserType.SAME_USER_ID + } + } + distributedData.createKVManager(kvManagerConfig, function (err, manager) { + if (err) { + console.log("createKVManager err: " + JSON.stringify(err)); + return; + } + console.log("createKVManager success"); + kvManager = manager; + }); + } catch (e) { + console.log("An unexpected error occurred. Error:" + e); + } + ``` + +3. Create and obtain a single KV store. + + 1. Declare the ID of the single KV store to create. + 2. Create a single KV store. You are advised to disable automatic synchronization \(**autoSync:false**\) and call **sync** if a synchronization is required. + + The sample code is as follows: + + ``` + let kvStore; + try { + const options = { + createIfMissing : true, + encrypt : false, + backup : false, + autoSync : false, + kvStoreType : distributedData.KVStoreType.SINGLE_VERSION, + securityLevel : distributedData.SecurityLevel.S2, + }; + kvManager.getKVStore('storeId', options, function (err, store) { + if (err) { + console.log("getKVStore err: " + JSON.stringify(err)); + return; + } + console.log("getKVStore success"); + kvStore = store; + }); + } catch (e) { + console.log("An unexpected error occurred. Error:" + e); + } + ``` + + >![](../public_sys-resources/icon-note.gif) **NOTE:** + >For data synchronization between networked devices, you are advised to open the distributed database during application startup to obtain the database handle. With this database handle \(**kvStore** in this example\), you can perform operations, such as inserting data into the database, without creating the database repeatedly during the lifecycle of the handle. + +4. Subscribe to changes in the distributed data. + + The following is the sample code for subscribing to the data changes of a single KV store: + + ``` + kvStore.on('dataChange', distributedData.SubscribeType.SUBSCRIBE_TYPE_ALL, function (data) { + console.log("dataChange callback call data: " + JSON.stringify(data)); + }); + ``` + +5. Write data to the single KV store. + + 1. Construct the key and value to be written into the single KV store. + 2. Write key-value pairs into the single KV store. + + The following is the sample code for writing key-value pairs of the string type into the single KV store: + + ``` + const KEY_TEST_STRING_ELEMENT = 'key_test_string'; + const VALUE_TEST_STRING_ELEMENT = 'value-test-string'; + try { + kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT, function (err,data) { + if (err != undefined) { + console.log("put err: " + JSON.stringify(err)); + return; + } + console.log("put success"); + }); + }catch (e) { + console.log("An unexpected error occurred. Error:" + e); + } + ``` + +6. Query data in the single KV store. + + 1. Construct the key to be queried from the single KV store. + 2. Query data from the single KV store. + + The following is the sample code for querying data of the string type from the single KV store: + + ``` + const KEY_TEST_STRING_ELEMENT = 'key_test_string'; + const VALUE_TEST_STRING_ELEMENT = 'value-test-string'; + try { + kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT, function (err,data) { + if (err != undefined) { + console.log("put err: " + JSON.stringify(err)); + return; + } + console.log("put success"); + kvStore.get(KEY_TEST_STRING_ELEMENT, function (err,data) { + console.log("get success data: " + data); + }); + }); + }catch (e) { + console.log("An unexpected error occurred. Error:" + e); + } + ``` + +7. Synchronize data to other devices. + + Select the devices in the same network and the synchronization mode to synchronize data. + + The following is the sample code for data synchronization in a single KV store. **deviceIds** can be obtained by deviceManager by calling **getTrustedDeviceListSync\(\)**, and **1000** indicates that the maximum delay time is 1000 ms. + + ``` + import deviceManager from '@ohos.distributedHardware.deviceManager'; + + let devManager; + // create deviceManager + deviceManager.createDeviceManager("bundleName", (err, value) => { + if (!err) { + devManager = value; + } + }); + + // get deviceIds + let deviceIds = []; + if (devManager != null) { + var deviceList = devManager.getTrustedDeviceListSync(); + for (var i = 0; i < deviceList.length; i++) { + deviceIds[i] = deviceList[i].deviceId; + } + } + kvStore.sync(deviceIds, distributedData.SyncMode.PUSH_ONLY, 1000); + ``` + + diff --git a/en/application-dev/database/database-mdds-overview.md b/en/application-dev/database/database-mdds-overview.md new file mode 100644 index 0000000000000000000000000000000000000000..2262558e38e892854b4de12cf124a88569cabf84 --- /dev/null +++ b/en/application-dev/database/database-mdds-overview.md @@ -0,0 +1,101 @@ +# Distributed Data Service Overview + +The distributed data service \(DDS\) implements distributed database collaboration across devices for applications. Applications save data to distributed databases by calling the DDS APIs. The DDS isolates data of different applications based on a triplet of account, application, and database to ensure secure data access. The DDS synchronizes application data between trusted devices to provide users with consistent data access experience on different devices. + +## Basic Concepts + +- **KV data model** + + The key-value \(KV\) data model allows data to be organized, indexed, and stored in key-value pairs. + + The KV data model is suitable for storing service data that is not related. It provides better read and write performance than the SQL database. The KV data model is widely used in distributed scenarios because it handles database version compatibility issues and data synchronization conflicts easily. The distributed database is based on the KV data model and provides KV-based access interfaces. + +- **Distributed database transactions** + + Distributed database transactions include local transactions \(same as the transactions of traditional databases\) and synchronization transactions. Synchronization transactions allow data to be synchronized between devices by local transaction. Synchronization of a local transaction modification either succeeds or fails on all the devices. + +- **Distributed database consistency** + + In a distributed scenario, cross-device collaboration demands consistent data between the devices in the same network. The data consistency can be classified into the following types: + + - **Strong consistency**: When data is inserted, deleted, or modified on a device, other devices in the same network will obtain the latest data immediately. + - **Weak consistency**: When data is added, deleted, or modified on a device, other devices in the same network may or may not obtain the latest data. The data on these devices may be inconsistent after a certain period of time. + - **Eventual consistency**: When data is added, deleted, or modified on a device, other devices in the same network may not obtain the latest data immediately. However, data on these devices will become consistent after a certain period of time. + + Strong consistency has high requirements on distributed data management and may be used in distributed server deployment. The DDS supports only the eventual consistency because mobile devices are not always online and the network has no center. + +- **Distributed database synchronization** + + After discovering and authenticating a device, the underlying communication component notifies the upper-layer application \(including the DDS\) that the device goes online. The DDS then establishes an encrypted transmission channel to synchronize data between the two devices. + + The DDS provides the following synchronization modes: + + - **Manual synchronization**: Applications call **sync** to trigger a synchronization. The list of devices to be synchronized and the synchronization mode must be specified. The synchronization mode can be **PULL\_ONLY** \(pulling remote data to the local end\), **PUSH\_ONLY** \(pushing local data to the remote end\), or **PUSH\_PULL** \(pushing local data to the remote end and pulling remote data to the local end\). The internal interface supports condition-based synchronization. The data that meets the conditions can be synchronized to the remote end. + - **Automatic synchronization**: includes full synchronization and condition-based subscription synchronization. In full synchronization, the distributed database automatically pushes local data to the remote end and pulls remote data to the local end when a device goes online or application data is updated. Applications do not need to call **sync**. The internal interface supports condition-based subscription synchronization. The data that meets the subscription conditions on the remote end is automatically synchronized to the local end. + +- **Single KV store** + + Data is saved locally in the unit of a single KV entry. Only one entry is saved for each key. Data can be modified only locally and synchronized to remote devices in sequence based on the update time. + +- **Device KV store** + + The device KV store is based on the single KV store. The local device ID is added to the key when KV data is stored in the device KV store. Data can be isolated, managed, and queried by device. However, the data synchronized from remote devices cannot be modified locally. + +- **Conflict resolution** + + A data conflict occurs when multiple devices modify the same data and commit the modification to the database. The last write wins \(LWW\) is the default conflict resolution policy used for data conflicts. Based on the commit timestamps, the data with a later timestamp is used. Currently, customized conflict resolution policies are not supported. + +- **Schema-based database management and data query based on predicates** + + A schema is specified when you create or open a single KV store. Based on the schema, the database detects the value format of key-value pairs and checks the value structure. Based on the fields in the values, the database implements index creation and predicate-based query. + +- **Distributed database backup** + + The DDS provides the database backup capability. You can set **backup** to **true** to enable daily backup. If a distributed database is damaged, the DDS deletes the database and restores the most recent data from the backup database. If no backup database is available, the DDS creates one. The DDS can also back up encrypted databases. + + +## Working Principles + +The DDS supports distributed management of application database data in the OpenHarmony system. Data can be synchronized between multiple devices with the same account, delivering a consistent user experience across devices. The DDS consists of the following: + +- **APIs** + + The DDS provides APIs to create databases, access data, and subscribe to data. The APIs support the KV data model and common data types. They are highly compatible and easy to use, and can be released. + +- **Service component** + + The service component implements management of metadata, permissions, encryption, backup and restore, and multiple users, and completes initialization of the storage component, synchronization component, and communication adaptation layer of the distributed database. + +- **Storage component** + + The storage component implements data access, data reduction, transactions, snapshots, database encryption, data combination, and conflict resolution. + +- **Synchronization component** + + The synchronization component interacts with the storage component and the communication adaptation layer to maintain data consistency between online devices. It synchronizes data generated on the local device to other devices and merges data from other devices into the local device. + +- **Communication adaptation layer** + + The communication adaptation layer calls APIs of the underlying public communication layer to create and connect to communication channels, receive device online and offline messages, update metadata of the connected and disconnected devices, send device online and offline messages to the synchronization component. The synchronization component updates the list of connected devices, and calls the APIs of the communication adaption layer to encapsulate data and send the data to the connected devices. + + +Applications call the DDS APIs to create, access, and subscribe to distributed databases. The APIs store data to the storage component based on the capabilities provided by the service component. The storage component interacts with the synchronization component to synchronize data. The synchronization component uses the communication adaptation layer to synchronize data to remote devices, which update the data in the storage component and provide the data for applications through service APIs. + +**Figure 1** How DDS works + + +![](figures/en-us_image_0000001183386164.png) + +## Constraints + +- The DDS supports the KV data model only. It does not support foreign keys or triggers of the relational database. +- The KV data model specifications supported by the DDS are as follows: + - For each record in a device KV store, the key must be less than or equal to 896 bytes and the value be less than 4 MB. + - For each record in a single KV store, the key must be less than or equal to 1 KB and the value be less than 4 MB. + - An application can open a maximum of 16 KV stores simultaneously. + +- The data that needs to be synchronized between devices should be stored in distributed databases rather than local databases. +- The DDS does not support customized conflict resolution policies. +- The maximum number of access requests to the KvStore API is 1000 per second and 10000 per minute. The maximum number of access requests to the KvManager API is 50 per second and 500 per minute. +- Blocking operations, such as modifying UI components, are not allowed in the distributed database event callback. + diff --git a/en/application-dev/database/figures/en-us_image_0000001183386164.png b/en/application-dev/database/figures/en-us_image_0000001183386164.png new file mode 100644 index 0000000000000000000000000000000000000000..e1fb8747d48c315d0e88504135c0bd388cc81077 Binary files /dev/null and b/en/application-dev/database/figures/en-us_image_0000001183386164.png differ diff --git a/en/application-dev/dfx/Readme-EN.md b/en/application-dev/dfx/Readme-EN.md new file mode 100644 index 0000000000000000000000000000000000000000..88e6d8259de26dc4a8ad5678ecb795e716a65c63 --- /dev/null +++ b/en/application-dev/dfx/Readme-EN.md @@ -0,0 +1,6 @@ +# DFX + +- Application Event Logging + - [Overview of Application Event Logging](hiappevent-overview.md) + - [Development Guidelines on Application Event Logging](hiappevent-guidelines.md) + diff --git a/en/application-dev/application-event-logging/hiappevent-guidelines.md b/en/application-dev/dfx/hiappevent-guidelines.md similarity index 100% rename from en/application-dev/application-event-logging/hiappevent-guidelines.md rename to en/application-dev/dfx/hiappevent-guidelines.md diff --git a/en/application-dev/application-event-logging/hiappevent-overview.md b/en/application-dev/dfx/hiappevent-overview.md similarity index 100% rename from en/application-dev/application-event-logging/hiappevent-overview.md rename to en/application-dev/dfx/hiappevent-overview.md diff --git a/en/application-dev/quick-start/configuring-openharmony-app-signature.md b/en/application-dev/quick-start/configuring-openharmony-app-signature.md index 49abca3fa152bfd836d6be71ede47aa78a77a70b..55ba99b6f63ac78b2c0722c40ae73074d2a68278 100644 --- a/en/application-dev/quick-start/configuring-openharmony-app-signature.md +++ b/en/application-dev/quick-start/configuring-openharmony-app-signature.md @@ -68,7 +68,7 @@ Use the Keytool in the Open JDK to generate a CSR. 3. Run the following command to generate a key store. This example creates a key store named **ide\_demo\_app.p12** and saves it to the root directory of the D drive. ``` - keytool -genkeypair -alias "ide_demo_app" -keyalg EC -sigalg SHA256withECDSA -dname "C=CN,O=HUAWEI,OU=HUAWEI IDE,CN=ide_demo_app" -keystore d:\\idedemokey.p12 -storetype pkcs12 -validity 9125 -storepass 123456Abc -keypass 123456Abc + keytool -genkeypair -alias "ide_demo_app" -keyalg EC -sigalg SHA256withECDSA -dname "C=CN,O=Organization,OU=Unit,CN=ide_demo_app" -keystore d:\\idedemokey.p12 -storetype pkcs12 -validity 9125 -storepass 123456Abc -keypass 123456Abc ``` Parameters in the key store: @@ -80,8 +80,8 @@ Use the Keytool in the Open JDK to generate a CSR. - **sigalg**: signature algorithm, which is automatically set to **SHA256withECDSA** and cannot be changed. - **dname**: - **C**: country/region code, such as **CN**. - - **O**: organization name, such as **HUAWEI**. - - **OU**: organization unit name, such as **HUAWEI IDE**. + - **O**: organization name, such as **Organization**. + - **OU**: organization unit name, such as **Unit**. - **CN**: your first name and last name. Set this parameter to be the same as **alias**. - **validity**: certificate validity period. It is recommended that you set this parameter to **9125** \(25 years\). diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001122862128.png b/en/application-dev/quick-start/figures/en-us_image_0000001122862128.png deleted file mode 100644 index 74b66efabbbbbea4752f0296985486369a0cdc74..0000000000000000000000000000000000000000 Binary files a/en/application-dev/quick-start/figures/en-us_image_0000001122862128.png and /dev/null differ diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001123021842.png b/en/application-dev/quick-start/figures/en-us_image_0000001123021842.png deleted file mode 100644 index 36dc2d05ca4eb23505a73cb0d1606afd3bf844d8..0000000000000000000000000000000000000000 Binary files a/en/application-dev/quick-start/figures/en-us_image_0000001123021842.png and /dev/null differ diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001123021962.png b/en/application-dev/quick-start/figures/en-us_image_0000001123021962.png deleted file mode 100644 index 708b49814e270289c6d1c96520aa6d90ba0edb9c..0000000000000000000000000000000000000000 Binary files a/en/application-dev/quick-start/figures/en-us_image_0000001123021962.png and /dev/null differ diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001123024482.png b/en/application-dev/quick-start/figures/en-us_image_0000001123024482.png deleted file mode 100644 index cedbb0ed07d4249c736f2b358593141f2f4cdc8e..0000000000000000000000000000000000000000 Binary files a/en/application-dev/quick-start/figures/en-us_image_0000001123024482.png and /dev/null differ diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001208210505.png b/en/application-dev/quick-start/figures/en-us_image_0000001208210505.png deleted file mode 100644 index 934b69477b4c10140f0cf8198e4248c53bdb0364..0000000000000000000000000000000000000000 Binary files a/en/application-dev/quick-start/figures/en-us_image_0000001208210505.png and /dev/null differ diff --git a/en/application-dev/reference/apis/Readme-EN.md b/en/application-dev/reference/apis/Readme-EN.md index a8c67d7a907654e92085fc4a20fd56938c5e8f3d..ea1585a4aca4f2addf6631e801f0f4267a50cf05 100644 --- a/en/application-dev/reference/apis/Readme-EN.md +++ b/en/application-dev/reference/apis/Readme-EN.md @@ -16,6 +16,8 @@ - Media - [Audio Management](js-apis-audio.md) - [Media Playback and Recording](js-apis-media.md) +- Security + - [User Authentication](js-apis-useriam-userauth.md) - Data Management - [File Management](js-apis-fileio.md) - [Lightweight Storage](js-apis-data-storage.md) @@ -45,6 +47,7 @@ - [Window](js-apis-window.md) - [Display](js-apis-display.md) - [Update](js-apis-update.md) + - [USB](js-apis-usb.md) - Basic Features - [Application Context](js-apis-basic-features-app-context.md) - [Console Logs](js-apis-basic-features-logs.md) @@ -60,6 +63,6 @@ - Language Base Class Library - [Obtaining Process Information](js-apis-process.md) - [URL String Parsing](js-apis-url.md) - - [String Encoding and Decoding](js-apis-util.md) + - [Util](js-apis-util.md) - [Worker Startup](js-apis-worker.md) diff --git a/en/application-dev/reference/apis/js-apis-account.md b/en/application-dev/reference/apis/js-apis-account.md deleted file mode 100644 index c9544210fb8c7bc53f5a7a39c03615bcca623341..0000000000000000000000000000000000000000 --- a/en/application-dev/reference/apis/js-apis-account.md +++ /dev/null @@ -1,4 +0,0 @@ -# Account Management - -- **[Distributed Account Management](js-apis-distributed-account.md)** -- **[Application Account Management](js-apis-appAccount.md)** diff --git a/en/application-dev/reference/apis/js-apis-appAccount.md b/en/application-dev/reference/apis/js-apis-appAccount.md index bb60e379f614a18c90ce42bb596a1cc0da36260e..b352a63c80420b8266cf4218741f1e0313188b55 100644 --- a/en/application-dev/reference/apis/js-apis-appAccount.md +++ b/en/application-dev/reference/apis/js-apis-appAccount.md @@ -183,7 +183,7 @@ Disables the specified third-party application account from accessing the third- ``` const appAccountManager = account_appAccount.createAppAccountManager(); - appAccountManager.disableAppAccess("ZhangSan", "com.huawei.ohos.accountjsdemo", (err) => { + appAccountManager.disableAppAccess("ZhangSan", "com.example.ohos.accountjsdemo", (err) => { console.log("disableAppAccess err: " + JSON.stringify(err)); }); ``` @@ -211,7 +211,7 @@ Disables the specified third-party application account from accessing the third- ``` const appAccountManager = account_appAccount.createAppAccountManager(); - appAccountManager.disableAppAccess("ZhangSan", "com.huawei.ohos.accountjsdemo").then(() => { + appAccountManager.disableAppAccess("ZhangSan", "com.example.ohos.accountjsdemo").then(() => { console.log('disableAppAccess Success'); }).catch((err) => { console.log("disableAppAccess err: " + JSON.stringify(err)); @@ -236,7 +236,7 @@ Enables the specified third-party application account to access the third-party ``` const appAccountManager = account_appAccount.createAppAccountManager(); - appAccountManager.enableAppAccess("ZhangSan", "com.huawei.ohos.accountjsdemo", (err) => { + appAccountManager.enableAppAccess("ZhangSan", "com.example.ohos.accountjsdemo", (err) => { console.log("enableAppAccess: " + JSON.stringify(err)); }); ``` @@ -263,7 +263,7 @@ Enables the specified third-party application account to access the third-party - Example ``` - app_account_instance.enableAppAccess("ZhangSan", "com.huawei.ohos.accountjsdemo").then(() => { + app_account_instance.enableAppAccess("ZhangSan", "com.example.ohos.accountjsdemo").then(() => { console.log('enableAppAccess Success'); }).catch((err) => { console.log("enableAppAccess err: " + JSON.stringify(err)); diff --git a/en/application-dev/reference/apis/js-apis-data-rdb.md b/en/application-dev/reference/apis/js-apis-data-rdb.md index 50977a3f7b800bc670ecb0ff94e1628daf6ef3fe..50d8dbd904620d5002c285d034651bf65f62a745 100644 --- a/en/application-dev/reference/apis/js-apis-data-rdb.md +++ b/en/application-dev/reference/apis/js-apis-data-rdb.md @@ -1,6 +1,6 @@ -# Relational Database +# Relational Database ->![](../../public_sys-resources/icon-note.gif) **NOTE:** +>**NOTE:** >The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. ## Modules to Import @@ -66,7 +66,7 @@ Obtains a relational database \(RDB\) store. You can set parameters for the RDB ``` import dataRdb from '@ohos.data.rdb' - const STORE_CONFIG = { name: "RdbTest.db" } + const STORE_CONFIG = { name: "RdbTest.db", encryptKey: new Uint8Array([1, 2])} const SQL_CREATE_TABLE = "CREATE TABLE IF NOT EXISTS EMPLOYEE (ID INTEGER PRIMARY KEY AUTOINCREMENT, NAME TEXT NOT NULL, AGE INTEGER, SALARY REAL, CODES BLOB)" dataRdb.getRdbStore(STORE_CONFIG, 1, function (err, rdbStore) { rdbStore.executeSql(SQL_CREATE_TABLE) @@ -972,7 +972,7 @@ Sets the **RdbPredicates** to match the specified string.

Yes

-

Value to match the RdbPredicates.
Wildcards are supported. The asterisk (*) represents zero, one, or more numbers or characters. The question mark (?) represents a single number or character.

+

Value to match the RdbPredicates.

@@ -989,7 +989,7 @@ Sets the **RdbPredicates** to match the specified string.

RdbPredicates

-

RdbPredicates object that matches the specified string.

+

RdbPredicates object that matches the specified field.

@@ -2343,7 +2343,7 @@ Queries data in the database based on specified conditions. This method uses a c

callback

-

AsyncCallback<ResultSet>

+

AsyncCallback<../nottoctopics/en-us_topic_0000001185510506.md#section12882825611>

Yes

@@ -2413,7 +2413,7 @@ Queries data in the database based on specified conditions. This method uses a p -

Promise<ResultSet>

+

Promise<ResultSet>

Promise used to return the result. If the operation is successful, a ResultSet object will be returned.

@@ -2557,6 +2557,114 @@ Runs the SQL statement that contains the specified parameters but does not retur ``` +### changeEncryptKey8+ + +changeEncryptKey\(newEncryptKey:Uint8Array, callback: AsyncCallback\):void + +Changes the encryption key of the RDB store. This method uses a callback to return the result. + +- Parameters + + + + + + + + + + + + + + + + + + + +

Name

+

Type

+

Mandatory

+

Description

+

newEncryptKey

+

Uint8Array

+

Yes

+

New encryption key. This parameter cannot be empty.

+

callback

+

AsyncCallback<number>

+

Yes

+

Callback invoked to return the result.

+
+ + +- Example + + ``` + var newKey = new Uint8Array([1, 2]) + rdbStore.changeEncryptKey(newKey, function (ret) { + console.info(TAG + "result is " + ret)}) + ``` + + +### changeEncryptKey8+ + +changeEncryptKey\(newEncryptKey:Uint8Array\): Promise + +Changes the encryption key of the RDB store. This method uses a promise to return the result. + +- Parameters + + + + + + + + + + + + + + +

Name

+

Type

+

Mandatory

+

Description

+

newEncryptKey

+

Uint8Array

+

Yes

+

New encryption key. This parameter cannot be empty.

+
+ +- Return values + + + + + + + + + + +

Type

+

Description

+

Promise<number>

+

Promise used to return the result.

+
+ +- Example + + ``` + var newKey = new Uint8Array([1, 2]) + let promise = rdbStore.changeEncryptKey(newKey) + promise.then((ret) => { + console.info(TAG + "result is " + ret)}) + ``` + + ## StoreConfig Manages the configuration of an RDB store. @@ -2581,6 +2689,15 @@ Manages the configuration of an RDB store.

Database file name.

+

encryptKey (BETA)8+

+ +

Uint8Array

+ +

No

+ +

Key used to encrypt the RDB store. If a key is added during the creation of an RDB store, the key is required each time you open the RDB store.

+ + @@ -2639,3 +2756,4 @@ Defines a bucket to store key-value pairs. + diff --git a/en/application-dev/reference/apis/js-apis-usb.md b/en/application-dev/reference/apis/js-apis-usb.md new file mode 100644 index 0000000000000000000000000000000000000000..94c9f4a7a53229f888b8afd5bb998c1057822297 --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-usb.md @@ -0,0 +1,1432 @@ +# USB + +>**NOTE:** +>The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. + +## Modules to Import + +``` +import usb from "@ohos.usb"; +``` + +## Required Permissions + +None. + +## usb.getDevices + +usb.getDevices\(\): Array\> + +Obtains the USB device list. + +- Return values + + + + + + + + + + +

Type

+

Description

+

Array<Readonly<USBDevice>>

+

USB device list.

+
+ +- Example + + ``` + let devicesList = usb.getDevices(); + console.log(`devicesList = ${JSON.stringify(devicesList)}`); + // devicesList is a list of USB devices. + // A simple example of devicesList is provided as follows: + [ + { + name: "1-1", + serial: "", + manufacturerName: "", + productName: "", + version: "", + vendorId: 7531, + productId: 2, + clazz: 9, + subclass: 0, + protocol: 1, + devAddress: 1, + busNum: 1, + configs: [ + { + id: 1, + attributes: 224, + isRemoteWakeup: true, + isSelfPowered: true, + maxPower: 0, + name: "1-1", + interfaces: [ + { + id: 0, + protocol: 0, + clazz: 9, + subclass: 0, + alternateSetting: 0, + name: "1-1", + endpoints: [ + { + address: 129, + attributes: 3, + interval: 12, + maxPacketSize: 4, + direction: 128, + number: 1, + type: 3, + interfaceId: 0, + }, + ], + }, + ], + }, + ], + }, + ] + ``` + + +## usb.connectDevice + +usb.connectDevice\(device: USBDevice\): Readonly + +Connects to a USB device. + +Before you do this, call [usb.getDevices](#section1885592111287) to obtain the USB device list, and then call [usb.requestRight](#section1865915394353) to request the device access permission. + +- Parameters + + + + + + + + + + + + + + +

Name

+

Type

+

Mandatory

+

Description

+

device

+

USBDevice

+

Yes

+

USB device information.

+
+ + +- Return values + + + + + + + + + + +

Type

+

Description

+

Readonly<USBDevicePipe>

+

USB device pipe for data transfer.

+
+ +- Example + + ``` + let devicepipe= usb.connectDevice(device); + console.log(`devicepipe = ${JSON.stringify(devicepipe)}`); + ``` + + +## usb.hasRight + +usb.hasRight\(deviceName: string\): boolean + +Checks whether the user has the permission to access the device. + +- Parameters + + + + + + + + + + + + + + +

Name

+

Type

+

Mandatory

+

Description

+

deviceName

+

string

+

Yes

+

Device name.

+
+ +- Return values + + + + + + + + + + +

Type

+

Description

+

boolean

+

Returns true if the user has the permission to access the device; returns false otherwise.

+
+ +- Example + + ``` + let divicesName="1-1"; + let bool = usb.hasRight(divicesName); + console.log(bool); + ``` + + +## usb.requestRight + +usb.requestRight\(deviceName: string\): Promise + +Requests the temporary permission for the application to access the USB device. + +- Parameters + + + + + + + + + + + + + + +

Name

+

Type

+

Mandatory

+

Description

+

deviceName

+

string

+

Yes

+

Device name.

+
+ +- Return values + + + + + + + + + + +

Type

+

Description

+

Promise<boolean>

+

Returns true if the temporary device access permissions are granted; returns false otherwise.

+
+ +- Example + + ``` + let divicesName="1-1"; + usb.requestRight(divicesName).then((ret) => { + console.log(`requestRight = ${JSON.stringify(ret)}`); + }); + ``` + + +## usb.claimInterface + +usb.claimInterface\(pipe: USBDevicePipe, iface: USBInterface, force?: boolean\): number + +Claims a USB interface. + +Before you do this, call [usb.getDevices](#section1885592111287) to obtain the USB device list and USB interfaces, call [usb.requestRight](#section1865915394353) to request the device access permission, and call [usb.connectDevice](#section910254722918) to obtain **devicepipe** as an input parameter. + +- Parameters + + + + + + + + + + + + + + + + + + + + + + + + +

Name

+

Type

+

Mandatory

+

Description

+

pipe

+

USBDevicePipe

+

Yes

+

Device pipe, which is used to determine the bus number and device address.

+

iface

+

USBInterface

+

Yes

+

USB interface, which is used to determine the index of the interface to claim.

+

force

+

boolean

+

No

+

Optional parameter that determines whether to forcibly claim the USB interface. The default value is false, indicating not to forcibly claim the USB interface.

+
+ +- Return values + + + + + + + + + + +

Type

+

Description

+

number

+

Returns 0 if the USB interface is successfully claimed; returns an error code otherwise.

+
+ +- Example + + ``` + let ret = usb.claimInterface(devicepipe, interfaces); + console.log(`claimInterface = ${ret}`); + ``` + + +## usb.releaseInterface + +usb.releaseInterface\(pipe: USBDevicePipe, iface: USBInterface\): number + +Releases a USB interface. + +Before you do this, ensure that you have claimed the interface by calling [usb.claimInterface](#section41056254494). + +- Parameters + + + + + + + + + + + + + + + + + + + +

Name

+

Type

+

Mandatory

+

Description

+

pipe

+

USBDevicePipe

+

Yes

+

Device pipe, which is used to determine the bus number and device address.

+

iface

+

USBInterface

+

Yes

+

USB interface, which is used to determine the index of the interface to release.

+
+ +- Return values + + + + + + + + + + +

Type

+

Description

+

number

+

Returns 0 if the USB interface is successfully released; returns an error code otherwise.

+
+ +- Example + + ``` + let ret = usb.releaseInterface(devicepipe, interfaces); + console.log(`releaseInterface = ${ret}`); + ``` + + +## usb.setConfiguration + +usb.setConfiguration\(pipe: USBDevicePipe, config: USBConfig\): number + +Sets the device configuration. + +Before you do this, call [usb.getDevices](#section1885592111287) to obtain the USB device list and device configuration, call [usb.requestRight](#section1865915394353) to request the device access permission, and call [usb.connectDevice](#section910254722918) to obtain **devicepipe** as an input parameter. + +- Parameters + + + + + + + + + + + + + + + + + + + +

Name

+

Type

+

Mandatory

+

Description

+

pipe

+

USBDevicePipe

+

Yes

+

Device pipe, which is used to determine the bus number and device address.

+

config

+

USBConfig

+

Yes

+

USB configuration to set.

+
+ +- Return values + + + + + + + + + + +

Type

+

Description

+

number

+

Returns 0 if the USB configuration is successfully set; returns an error code otherwise.

+
+ +- Example + + ``` + let ret = usb.setConfiguration(devicepipe, config); + console.log(`setConfiguration = ${ret}`); + ``` + + +## usb.setInterface + +usb.setInterface\(pipe: USBDevicePipe, iface: USBInterface\): number + +Sets a USB interface. + +Before you do this, call [usb.getDevices](#section1885592111287) to obtain the USB device list and interfaces, call [usb.requestRight](#section1865915394353) to request the device access permission, and call [usb.connectDevice](#section910254722918) to obtain **devicepipe** as an input parameter. + +- Parameters + + + + + + + + + + + + + + + + + + + +

Name

+

Type

+

Mandatory

+

Description

+

pipe

+

USBDevicePipe

+

Yes

+

Device pipe, which is used to determine the bus number and device address.

+

iface

+

USBInterface

+

Yes

+

USB interface to set.

+
+ +- Return values + + + + + + + + + + +

Type

+

Description

+

number

+

Returns 0 if the USB interface is successfully set; returns an error code otherwise.

+
+ +- Example + + ``` + let ret = usb.setInterface(devicepipe, interfaces); + console.log(`setInterface = ${ret}`); + ``` + + +## usb.getRawDescriptor + +usb.getRawDescriptor\(pipe: USBDevicePipe\): Uint8Array + +Obtains the raw USB descriptor. + +Before you do this, call [usb.getDevices](#section1885592111287) to obtain the USB device list, call [usb.requestRight](#section1865915394353) to request the device access permission, and call [usb.connectDevice](#section910254722918) to obtain **devicepipe** as an input parameter. + +- Parameters + + + + + + + + + + + + + + +

Name

+

Type

+

Mandatory

+

Description

+

pipe

+

USBDevicePipe

+

Yes

+

Device pipe, which is used to determine the bus number and device address.

+
+ +- Return values + + + + + + + + + + +

Type

+

Description

+

Uint8Array

+

Raw descriptor data.

+
+ +- Example + + ``` + let ret = usb.getRawDescriptor(devicepipe); + ``` + + +## usb.getFileDescriptor + +usb.getFileDescriptor\(pipe: USBDevicePipe\): number + +Obtains the file descriptor. + +Before you do this, call [usb.getDevices](#section1885592111287) to obtain the USB device list, call [usb.requestRight](#section1865915394353) to request the device access permission, and call [usb.connectDevice](#section910254722918) to obtain **devicepipe** as an input parameter. + +- Parameters + + + + + + + + + + + + + + +

Name

+

Type

+

Mandatory

+

Description

+

pipe

+

USBDevicePipe

+

Yes

+

Device pipe, which is used to determine the bus number and device address.

+
+ +- Return values + + + + + + + + + + +

Type

+

Description

+

number

+

File descriptor of the USB device.

+
+ +- Example + + ``` + let ret = usb.getFileDescriptor(devicepipe); + ``` + + +## usb.controlTransfer + +usb.controlTransfer\(pipe: USBDevicePipe, contrlparam: USBControlParams, timeout?: number\): Promise + +Performs control transfer. + +Before you do this, call [usb.getDevices](#section1885592111287) to obtain the USB device list, call [usb.requestRight](#section1865915394353) to request the device access permission, and call [usb.connectDevice](#section910254722918) to obtain **devicepipe** as an input parameter. + +- Parameters + + + + + + + + + + + + + + + + + + + + + + + + +

Name

+

Type

+

Mandatory

+

Description

+

pipe

+

USBDevicePipe

+

Yes

+

USB device pipe, which is used to determine the USB device.

+

contrlparam

+

USBControlParams

+

Yes

+

Control transfer parameters.

+

timeout

+

number

+

No

+

Timeout duration. This parameter is optional. The default value is 0, indicating no timeout.

+
+ +- Return values + + + + + + + + + + +

Type

+

Description

+

Promise<number>

+

Returns the size of the transmitted or received data block if the control transfer is successful; returns -1 if an exception occurs.

+
+ +- Example + + ``` + usb.controlTransfer(devicepipe, USBControlParams).then((ret) => { + console.log(`controlTransfer = ${JSON.stringify(ret)}`); + }) + ``` + + +## usb.bulkTransfer + +usb.bulkTransfer\(pipe: USBDevicePipe, endpoint: USBEndpoint, buffer: Uint8Array, timeout?: number\): Promise + +Performs bulk transfer. + +Before you do this, call [usb.getDevices](#section1885592111287) to obtain the USB device list and endpoints, call [usb.requestRight](#section1865915394353) to request the device access permission, call [usb.connectDevice](#section910254722918) to obtain **devicepipe** as an input parameter, and call [usb.claimInterface](#section41056254494) to claim the USB interface. + +- Parameters + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Name

+

Type

+

Mandatory

+

Description

+

pipe

+

USBDevicePipe

+

Yes

+

USB device pipe, which is used to determine the USB device.

+

endpoint

+

USBEndpoint

+

Yes

+

USB endpoint, which is used to determine the USB port for data transfer.

+

buffer

+

Uint8Array

+

Yes

+

Buffer for writing or reading data.

+

timeout

+

number

+

No

+

Timeout duration. This parameter is optional. The default value is 0, indicating no timeout.

+
+ +- Return values + + + + + + + + + + +

Type

+

Description

+

Promise<number>

+

Returns the size of the transmitted or received data block if the control transfer is successful; returns -1 if an exception occurs.

+
+ +- Example + + ``` + // Call usb.getDevices to obtain a data set. Then, obtain a USB device and its access permission. + // Pass the obtained USB device as a parameter to usb.connectDevice. Then, call usb.connectDevice to connect the USB device. + // Call usb.claimInterface to claim the USB interface. After that, call usb.bulkTransfer to start bulk transfer. + usb.bulkTransfer(devicepipe, endpoint, buffer).then((ret) => { + console.log(`bulkTransfer = ${JSON.stringify(ret)}`); + }); + ``` + + +## usb.closePipe + +usb.closePipe\(pipe: USBDevicePipe\): number + +Closes a USB device pipe. + +Before you do this, call [usb.getDevices](#section1885592111287) to obtain the USB device list, call [usb.requestRight](#section1865915394353) to request the device access permission, and call [usb.connectDevice](#section910254722918) to obtain **devicepipe** as an input parameter. + +- Parameters + + + + + + + + + + + + + + +

Name

+

Type

+

Mandatory

+

Description

+

pipe

+

USBDevicePipe

+

Yes

+

USB device pipe.

+
+ +- Return values + + + + + + + + + + +

Type

+

Description

+

number

+

Returns 0 if the USB device pipe is closed successfully; returns an error code otherwise.

+
+ +- Example + + ``` + let ret = usb.closePipe(devicepipe); + console.log(`closePipe = ${ret}`); + ``` + + +## USBEndpoint + +Represents the USB endpoint from which data is sent or received. You can obtain the USB endpoint through [USBInterface](#section1564414611311). + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Name

+

Type

+

Description

+

address

+

number

+

Endpoint address.

+

attributes

+

number

+

Endpoint attributes.

+

interval

+

number

+

Endpoint interval.

+

maxPacketSize

+

number

+

Maximum size of data packets on the endpoint.

+

direction

+

USBRequestDirection

+

Endpoint direction.

+

number

+

number

+

Endpoint number.

+

type

+

number

+

Endpoint type.

+

interfaceId

+

number

+

Unique ID of the interface to which the endpoint belongs.

+
+ +## USBInterface + +Represents a USB interface. One [USBConfig](#section1172111051715) can contain multiple **USBInterface** instances, each providing a specific function. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Name

+

Type

+

Description

+

id

+

number

+

Unique ID of the USB interface.

+

protocol

+

number

+

Interface protocol.

+

clazz

+

number

+

Device type.

+

subClass

+

number

+

Device subclass.

+

alternateSetting

+

number

+

Settings for alternating between descriptors of the same USB interface.

+

name

+

string

+

Interface name.

+

endpoints

+

Array<USBEndpoint>

+

Endpoints that belong to the USB interface.

+
+ +## USBConfig + +Represents the USB configuration. One [USBDevice](#section14936845182012) can contain multiple **USBConfig** instances. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Name

+

Type

+

Description

+

id

+

number

+

Unique ID of the USB configuration.

+

attributes

+

number

+

Configuration attributes.

+

maxPower

+

number

+

Maximum power consumption, in mA.

+

name

+

string

+

Configuration name, which can be left empty.

+

isRemoteWakeup

+

boolean

+

Support for remote wakeup.

+

isSelfPowered

+

boolean

+

Support for independent power supplies.

+

interfaces

+

Array <USBInterface>

+

Supported interface attributes.

+
+ +## USBDevice + +Represents a USB device. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Name

+

Type

+

Description

+

busNum

+

number

+

Bus address.

+

devAddress

+

number

+

Device address.

+

serial

+

string

+

Device SN.

+

name

+

string

+

Device name.

+

manufacturerName

+

string

+

Device manufacturer.

+

productName

+

string

+

Product name.

+

version

+

string

+

Product version.

+

vendorId

+

number

+

Vendor ID.

+

productId

+

number

+

Product ID.

+

clazz

+

number

+

Device class.

+

subClass

+

number

+

Device subclass.

+

protocol

+

number

+

Device protocol code.

+

configs

+

Array<USBConfig>

+

Device configuration descriptor information.

+
+ +## USBDevicePipe + +Represents a USB device pipe, which is used to determine a USB device. + + + + + + + + + + + + + + + + +

Name

+

Type

+

Description

+

busNum

+

number

+

Bus address.

+

devAddress

+

number

+

Device address.

+
+ +## USBControlParams + +Represents control transfer parameters. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Name

+

Type

+

Description

+

request

+

number

+

Request type.

+

target

+

USBRequestTargetType

+

Request target type.

+

reqType

+

USBControlRequestType

+

Request control type.

+

value

+

number

+

Request parameter value.

+

index

+

number

+

Index of the request parameter value.

+

data

+

Uint8Array

+

Data written to or read from the buffer.

+
+ +## USBRequestTargetType + +Enumerates USB request target types. + + + + + + + + + + + + + + + + + + + + + + + + +

Name

+

Default Value

+

Description

+

USB_REQUEST_TARGET_DEVICE

+

0

+

Device

+

USB_REQUEST_TARGET_INTERFACE

+

1

+

Interface

+

USB_REQUEST_TARGET_ENDPOINT

+

2

+

Endpoint

+

USB_REQUEST_TARGET_OTHER

+

3

+

Others

+
+ +## USBControlRequestType + +Enumerates control request types. + + + + + + + + + + + + + + + + + + + + +

Name

+

Default Value

+

Description

+

USB_REQUEST_TYPE_STANDARD

+

0

+

Standard

+

USB_REQUEST_TYPE_CLASS

+

1

+

Class

+

USB_REQUEST_TYPE_VENDOR

+

2

+

Vendor

+
+ +## USBRequestDirection + +Enumerates request directions. + + + + + + + + + + + + + + + + +

Name

+

Default Value

+

Description

+

USB_REQUEST_TYPE_STANDARD

+

0

+

Request for writing data from the host to the device.

+

USB_REQUEST_TYPE_CLASS

+

0x80

+

Request for reading data from the device to the host.

+
+ + + + + + + + + + + + + + + + + + + + + + + + +

Name

+

Default Value

+

Description

+

NONE

+

0

+

None.

+

ACM

+

1

+

Serial port device

+

ECM

+

2

+

Ethernet port device

+

HDC

+

4

+

HDC device

+
diff --git a/en/application-dev/reference/apis/js-apis-useriam-userauth.md b/en/application-dev/reference/apis/js-apis-useriam-userauth.md new file mode 100644 index 0000000000000000000000000000000000000000..e05a6fdd45fa03a6c9c47e5114b6f728816f3880 --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-useriam-userauth.md @@ -0,0 +1,889 @@ +# User Authentication + +>**NOTE:** +>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. + +## Applicable Devices + + + + + + + + + + + + + + +

Phone

+

Tablet

+

Smart TV

+

Wearable

+

Yes

+

Yes

+

No

+

No

+
+ +## Modules to Import + +``` +import userIAM_userAuth from '@ohos.userIAM.userAuth'; +``` + +## Required Permissions + +ohos.permission.ACCESS\_BIOMETRIC + +## Sample Code + +``` +import userIAM_userAuth from '@ohos.userIAM.userAuth'; + +export default { + startAuth() { + console.info("start auth"); + let tipCallback = (tip)=>{ + console.info("receive tip: errorCode(" + tip.errorCode + ") code(" + tip.tipCode + ") event(" + + tip.tipEvent + ") info(" + tip.tipInfo + ")"); + // Add the logic for displaying the prompt message. + }; + let auth = userIAM_userAuth.getAuthenticator(); + auth.on("tip", tipCallback); + auth.execute("FACE_ONLY", "S2").then((code)=>{ + auth.off("tip", tipCallback); + console.info("auth success"); + // Add the logic for authentication success. + }).catch((code)=>{ + auth.off("tip", tipCallback); + console.error("auth fail, code = " + code); + // Add the logic for authentication failure. + }); + }, + + checkAuthSupport() { + console.info("start check auth support"); + let auth = userIAM_userAuth.getAuthenticator(); + let checkCode = auth.checkAvailability("FACE_ONLY", "S2"); + if (checkCode == userIAM_userAuth.CheckAvailabilityResult.SUPPORTED) { + console.info("check auth support success"); + // Add the logic for the specified authentication type supported. + } else { + console.error("check auth support fail, code = " + checkCode); + // Add the logic for the authentication type that is not supported. + } + }, + + cancelAuth() { + console.info("start cancel auth"); + let auth = userIAM_userAuth.getAuthenticator(); + let cancelCode = auth.cancel(); + if (cancelCode == userIAM_userAuth.Result.SUCCESS) { + console.info("cancel auth success"); + } else { + console.error("cancel auth fail"); + } + } +} +``` + +## userIAM\_userAuth.getAuthenticator + +getAuthenticator\(\): Authenticator + +Obtains an **Authenticator** object for user authentication. 6+ + +Obtains an **Authenticator** object to check the device's capability of user authentication, perform or cancel user authentication, and obtain the tips generated in the authentication process. 7+ + +- Return values + + + + + + + + + + +

Type

+

Description

+

Authenticator

+

Authenticator object obtained.

+
+ +- Example + + ``` + let authenticator = userIAM_userAuth.getAuthenticator(); + ``` + + +## Authenticator + +Provides an **Authenticator** object. + +### execute + +execute\(type: string, level: string, callback: AsyncCallback\): void + +Performs user authentication and returns the authentication result using an asynchronous callback. + +- Parameters + + + + + + + + + + + + + + + + + + + + + + + + +

Name

+

Type

+

Mandatory

+

Description

+

type

+

string

+

Yes

+

Authentication type. Only FACE_ONLY is supported.

+

ALL is reserved and not supported by the current version.

+

level

+

string

+

Yes

+

Security level of the authentication. It can be S1 (lowest), S2, S3, or S4 (highest).

+

Devices capable of 3D facial recognition support S3 and lower-level authentication.

+

Devices capable of 2D facial recognition support S2 and lower-level authentication.

+

callback

+

AsyncCallback<number>

+

No

+

Callback invoked to return the authentication result

+
+ + Callback return values + + + + + + + + + + +

Type

+

Description

+

number

+

Authentication result. See AuthenticationResult.

+
+ +- Example + + ``` + authenticator.execute("FACE_ONLY", "S2", (code)=>{ + if (code == userIAM_userAuth.AuthenticationResult.SUCCESS) { + console.info("auth success"); + return; + } + console.error("auth fail, code = " + code); + }) + ``` + + +### execute + +execute\(type:string, level:string\): Promise + +Performs user authentication and returns the authentication result using a promise. + +- Parameters + + + + + + + + + + + + + + + + + + + +

Name

+

Type

+

Mandatory

+

Description

+

type

+

string

+

Yes

+

Authentication type. Only FACE_ONLY is supported.

+

ALL is reserved and not supported by the current version.

+

level

+

string

+

Yes

+

Security level of the authentication. It can be S1 (lowest), S2, S3, or S4 (highest).

+

Devices capable of 3D facial recognition support S3 and lower-level authentication.

+

Devices capable of 2D facial recognition support S2 and lower-level authentication.

+
+ +- Return values + + + + + + + + + + +

Type

+

Description

+

Promise<number>

+

Promise used to return the authentication result. The number in the promise indicates the authentication result. See AuthenticationResult.

+
+ +- Example + + ``` + let authenticator = userIAM_userAuth.getAuthenticator(); + authenticator.execute("FACE_ONLY", "S2").then((code)=>{ + authenticator.off("tip", tipCallback); + console.info("auth success"); + }).catch((code)=>{ + authenticator.off("tip", tipCallback); + console.error("auth fail, code = " + code); + }); + ``` + + +### cancel7+ + +cancel\(\): number + +Cancels the current authentication. + +- Return values + + + + + + + + + + +

Type

+

Description

+

number

+

Whether the authentication is canceled. For details, see Result.

+
+ +- Example + + ``` + let authenticator = userIAM_userAuth.getAuthenticator(); + let cancelCode = authenticator.cancel(); + if (cancelCode == userIAM_userAuth.Result.SUCCESS) { + console.info("cancel auth success"); + } else { + console.error("cancel auth fail"); + } + ``` + + +### checkAvailability7+ + +checkAvailability\(type: AuthType, level: SecureLevel\): number + +Checks whether the device supports the specified authentication type and security level. + +- Parameters + + + + + + + + + + + + + + + + + + + +

Name

+

Type

+

Mandatory

+

Description

+

type

+

string

+

Yes

+

Authentication type. Only FACE_ONLY is supported.

+

ALL is reserved and not supported by the current version.

+

level

+

string

+

Yes

+

Security level of the authentication. It can be S1 (lowest), S2, S3, or S4 (highest).

+

Devices capable of 3D facial recognition support S3 and lower-level authentication.

+

Devices capable of 2D facial recognition support S2 and lower-level authentication.

+
+ +- Return values + + + + + + + + + + +

Type

+

Description

+

number

+

Check result. For details, see CheckAvailabilityResult.

+
+ +- Example + + ``` + let authenticator = userIAM_userAuth.getAuthenticator(); + let checkCode = authenticator.checkAvailability("FACE_ONLY", "S2"); + if (checkCode == userIAM_userAuth.CheckAvailabilityResult.SUPPORTED) { + console.info("check auth support success"); + } else { + console.error("check auth support fail, code = " + checkCode); + } + ``` + + +### on7+ + +on\(type: "tip", callback: Callback\) : void; + +Subscribes to the events of the specified type. + +- Parameters + + + + + + + + + + + + + + + + + + + +

Name

+

Type

+

Mandatory

+

Description

+

type

+

string

+

Yes

+

Event type. Currently, only tip is supported. An event is triggered when the authentication service sends a message to the caller.

+

callback

+

Callback<Tip>

+

Yes

+

Callback used to report the event of the specified type. Currently, only the tip event is supported.

+
+ + +- Example + + ``` + let authenticator = userIAM_userAuth.getAuthenticator(); + let tipCallback = (tip)=>{ + console.info("receive tip: errorCode(" + tip.errorCode + ") code(" + tip.tipCode +") event(" + + tip.tipEvent + ") info(" + tip.tipInfo + ")"); + }; + authenticator.on("tip", tipCallback); + ``` + + +### off7+ + +off\(type: "tip", callback?: Callback\) : void; + +Unsubscribes from the events of the specified type. + +- Parameters + + + + + + + + + + + + + + + + + + + +

Name

+

Type

+

Mandatory

+

Description

+

type

+

string

+

Yes

+

Event type. Currently, only tip is supported.

+

callback

+

Callback<Tip>

+

No

+

Callback used to report the event of the specified type. Currently, only the tip event is supported. If this parameter is not specified, all callbacks corresponding to type will be canceled.

+
+ + +- Example + + ``` + let authenticator = userIAM_userAuth.getAuthenticator(); + let tipCallback = (tip)=>{ + console.info("receive tip: errorCode(" + tip.errorCode + ") code(" + tip.tipCode + ") event(" + + tip.tipEvent + ") info(" + tip.tipInfo + ")"); + }; + // Unsubscribe from a specified callback. + authenticator.off("tip", tipCallback); + + // Unsubscribe from all callbacks. + authenticator.off("tip"); + ``` + + +## AuthenticationResult + +Enumerates the authentication results. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Name

+

Default Value

+

Description

+

NO_SUPPORT

+

-1

+

The device does not support the current authentication mode.

+

SUCCESS

+

0

+

The authentication is successful.

+

COMPARE_FAILURE

+

1

+

The feature comparison failed.

+

CANCELED

+

2

+

The user cancels the authentication.

+

TIMEOUT

+

3

+

The authentication has timed out.

+

CAMERA_FAIL

+

4

+

The camera failed to start.

+

BUSY

+

5

+

The authentication service is not available. Try again later.

+

INVALID_PARAMETERS

+

6

+

The authentication parameters are invalid.

+

LOCKED

+

7

+

The user account is locked because the number of authentication failures has reached the threshold.

+

NOT_ENROLLED

+

8

+

No authentication credential is registered.

+

GENERAL_ERROR

+

100

+

Other errors.

+
+ +## Tip7+ + +Defines the object of the tip generated during the authentication process. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Name

+

Type

+

Mandatory

+

Description

+

errorCode

+

number

+

Yes

+

Whether the tip is obtained successfully. For details, see Result.

+

tipEvent

+

number

+

Yes

+

Tip event. For details, see TipEvent. Currently, only RESULT and ACQUIRE are supported.

+

tipCode

+

number

+

Yes

+

Tip code.

+
  • If tipEvent is RESULT, the tip code provides the authentication result. For details, see AuthenticationResult.
  • If tipEvent is ACQUIRE, the tip code provides prompt information. For details, see TipCode.
+

tipInfo

+

string

+

Yes

+

Description of the tip code.

+
+ +## Result7+ + +Enumerates the operation results. + + + + + + + + + + + + + + + + +

Name

+

Default Value

+

Description

+

SUCCESS

+

0

+

Successful

+

FAILED

+

1

+

Failed

+
+ +## CheckAvailabilityResult7+ + +Enumerates the device authentication capability check results. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Name

+

Default Value

+

Description

+

SUPPORTED

+

0

+

The device supports the specified authentication type and security level.

+

AUTH_TYPE_NOT_SUPPORT

+

1

+

The device does not support the specified authentication type.

+

SECURE_LEVEL_NOT_SUPPORT

+

2

+

The device does not support the specified authentication security level.

+

DISTRIBUTED_AUTH_NOT_SUPPORT

+

3

+

The device does not support distributed authentication.

+

NOT_ENROLLED

+

4

+

The device does not have the authentication credential.

+

PARAM_NUM_ERROR

+

5

+

The number of parameters is incorrect.

+
+ +## TipEvent7+ + +Enumerates the tip events occurred during the authentication process. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Name

+

Default Value

+

Description

+

RESULT

+

1

+

Credential enrollment result or authentication result.

+

CANCEL

+

2

+

Credential enrollment or authentication canceled.

+

ACQUIRE

+

3

+

Tips generated in the credential enrollment or authentication process.

+

BUSY

+

4

+

Credential enrollment or authentication unavailable.

+

OUT_OF_MEM

+

5

+

Insufficient memory.

+

FACE_ID

+

6

+

Index of a face authentication credential.

+
+ +## TipCode7+ + +Enumerates the tip codes generated during the authentication process. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Name

+

Default Value

+

Description

+

FACE_AUTH_TIP_TOO_BRIGHT

+

1

+

The obtained facial image is too bright due to high illumination.

+

FACE_AUTH_TIP_TOO_DARK

+

2

+

The obtained facial image is too dark due to low illumination.

+

FACE_AUTH_TIP_TOO_CLOSE

+

3

+

The face is too close to the device.

+

FACE_AUTH_TIP_TOO_FAR

+

4

+

The face is too far away from the device.

+

FACE_AUTH_TIP_TOO_HIGH

+

5

+

Only the upper part of the face is captured because the device is angled too high.

+

FACE_AUTH_TIP_TOO_LOW

+

6

+

Only the lower part of the face is captured because the device is angled too low.

+

FACE_AUTH_TIP_TOO_RIGHT

+

7

+

Only the right part of the face is captured because the device is deviated to the right.

+

FACE_AUTH_TIP_TOO_LEFT

+

8

+

Only the left part of the face is captured because the device is deviated to the left.

+

FACE_AUTH_TIP_TOO_MUCH_MOTION

+

9

+

The face moves too fast during facial information collection.

+

FACE_AUTH_TIP_POOR_GAZE

+

10

+

The face is not facing the camera.

+

FACE_AUTH_TIP_NOT_DETECTED

+

11

+

No face is detected.

+
diff --git a/en/application-dev/reference/apis/js-apis-util.md b/en/application-dev/reference/apis/js-apis-util.md index 34e564a8a54a4c9f4c187d00aa5f8c36c3a861c8..6301c943364ab64144197703118e217fe813ff32 100644 --- a/en/application-dev/reference/apis/js-apis-util.md +++ b/en/application-dev/reference/apis/js-apis-util.md @@ -1,8 +1,10 @@ -# String Encoding and Decoding +# util ->![](../../public_sys-resources/icon-note.gif) **NOTE:** +>**NOTE:** >The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. +This module provides common utility functions, such as **TextEncoder** and **TextDecoder** for string encoding and decoding, **RationalNumber** for rational number operations, **LruBuffer** for buffer management, **Scope** for range determination, **Base64** for Base64 encoding and decoding, and **Types** for checks of built-in object types. + ## Modules to Import ``` @@ -11,11 +13,11 @@ import util from '@ohos.util'; ## Required Permissions -None +None. ## util.printf -printf\(format: string, ...args: Object\[\]\): string +printf\(format: string, ...args: Object\[\]\): string Prints the input content in a formatted string. @@ -129,7 +131,7 @@ Obtains detailed information about a system error code. - Example ``` - var errnum = 10; // 10: a system error number + var errnum = 10; // 10 is the system error code. var result = util.getErrorString(errnum); console.log("result = " + result); ``` @@ -137,9 +139,9 @@ Obtains detailed information about a system error code. ## util.callbackWrapper -callbackWrapper\(original: Function\): \(err: Object, value: Object\)=\>void +callbackWrapper\(original: Function\): \(err: Object, value: Object \)=\>void -Calls back an asynchronous function. In the callback, the first parameter indicates the cause of the rejection \(if the promise has been resolved, the value is **null**\), and the second parameter indicates the resolved value. +Calls back an asynchronous function. In the callback, the first parameter indicates the cause of the rejection \(the value is **null** if the promise has been resolved\), and the second parameter indicates the resolved value. - Parameters @@ -160,7 +162,7 @@ Calls back an asynchronous function. In the callback, the first parameter indica

Yes

-

Asynchronous function.

+

Asynchronous function to process.

@@ -177,7 +179,7 @@ Calls back an asynchronous function. In the callback, the first parameter indica

Function

-

Callback, in which the first parameter indicates the cause of the rejection (the value is null if the promise has been resolved) and the second parameter indicates the resolved value.

+

Callback, in which the first parameter indicates the cause of the rejection (the value is null if the promise has been resolved) and the second parameter indicates the resolved value.

@@ -239,7 +241,7 @@ Processes an asynchronous function and returns a promise version.

Function

-

Function in the common error-first style (that is, (err, uses value) =>... is used as the last parameter) and the promise version.

+

Function in the error-first style (that is, (err, value) =>... is called as the last parameter) and the promise version.

@@ -310,7 +312,7 @@ Processes an asynchronous function and returns a promise version.

No

-

Whether to ignore the byte order marker (BOM). The default value is false.

+

Whether to ignore the byte order marker (BOM). The default value is false, which indicates that the result contains the BOM.

@@ -318,9 +320,9 @@ Processes an asynchronous function and returns a promise version. ### constructor -constructor\(encoding?: string, options?: \{ fatal?: boolean; ignoreBOM?: boolean \},\) +constructor\(encoding?:string, options?:\{ fatal?:boolean;ignoreBOM?:boolean \}\) -A constructor used to create a **TextDecoder** instance. +A constructor used to create a **TextDecoder** object. - Parameters @@ -350,7 +352,7 @@ A constructor used to create a **TextDecoder** instance.

No

-

Encoding-related options, which include fatal and ignoreBOM.

+

Encoding-related options, which include fatal and ignoreBOM.

@@ -399,9 +401,9 @@ A constructor used to create a **TextDecoder** instance. ### decode -decode\(input: Uint8Array, options?:\{stream?:false\}\): string +decode\(input: Unit8Array, options?:\{stream?:false\}\):string -Decodes the input parameters and outputs the text. +Decodes the input content. - Parameters @@ -418,11 +420,11 @@ Decodes the input parameters and outputs the text.

input

-

Uint8Array

+

Unit8Array

Yes

-

Uint8Array to decode.

+

Uint8Array to decode.

options

@@ -456,7 +458,7 @@ Decodes the input parameters and outputs the text.

No

-

Whether to allow data blocks in the subsequent decode(). Set this parameter to true if data blocks are processed. If data is not divided into blocks or the last data block is processed, set this parameter to false. The default value is false.

+

Whether to allow data blocks in subsequent decode(). If data is processed in blocks, set this parameter to true. If this is the last data block to process or data is not divided into blocks, set this parameter to false. The default value is false.

@@ -524,7 +526,7 @@ Decodes the input parameters and outputs the text.

No

-

Encoding format. The default value is utf-8.

+

Encoding format. The default format is utf-8.

@@ -534,7 +536,7 @@ Decodes the input parameters and outputs the text. constructor\(\) -A constructor used to create a **TextEncoder** instance. +A constructor used to create a **TextEncoder** object. - Example @@ -545,9 +547,9 @@ A constructor used to create a **TextEncoder** instance. ### encode -encode\(input?: string\): Uint8Array +encode\(input?:string\):Uint8Array -Encodes the input parameter. +Encodes the input content. - Parameters @@ -602,7 +604,7 @@ Encodes the input parameter. ### encodeInto -encodeInto\(input: string, dest: Uint8Array,\):\{ read: number; written: number \} +encodeInto\(input:string, dest:Uint8Array, \):\{ read:number; written:number \} Stores the UTF-8 encoded text. @@ -625,7 +627,7 @@ Stores the UTF-8 encoded text.

Yes

-

String to encode.

+

String to encode.

dest

@@ -634,7 +636,7 @@ Stores the UTF-8 encoded text.

Yes

-

Uint8Array instance used to store the UTF-8 encoded text.

+

Uint8Array object used to hold the UTF-8 encoded text.

@@ -667,3 +669,4509 @@ Stores the UTF-8 encoded text. ``` +## RationalNumber8+ + +### constructor8+ + +constructor\(numerator:number,denominator:number\) + +A constructor used to create a **RationalNumber** object. + +- Parameters + + + + + + + + + + + + + + + + + + + +

Name

+

Type

+

Mandatory

+

Description

+

numerator

+

number

+

Yes

+

Numerator, which is an integer.

+

denominator

+

number

+

Yes

+

Denominator, which is an integer.

+
+ + +- Example + + ``` + var rationalNumber = new util.RationalNumber(1,2); + ``` + + +### createRationalFromString8+ + +static createRationalFromString​\(rationalString:string\):RationalNumber​ + +Creates a **RationalNumber** object using the given string. + +- Parameters + + + + + + + + + + + + + + +

Name

+

Type

+

Mandatory

+

Description

+

rationalString

+

string

+

Yes

+

String used to create the RationalNumber object.

+
+ +- Return values + + + + + + + + + + +

Type

+

Description

+

object

+

RationalNumber object created.

+
+ + +- Example + + ``` + var rationalNumber = new util.RationalNumber(1,2); + var rational = rationalNumer.creatRationalFromString("3/4"); + ``` + + +### compareTo8+ + +compareTo​\(another:RationalNumber\):number​ + +Compares this **RationalNumber** object with a given object. + +- Parameters + + + + + + + + + + + + + + +

Name

+

Type

+

Mandatory

+

Description

+

another

+

RationalNumber

+

Yes

+

Object used to compare with this RationalNumber object.

+
+ +- Return values + + + + + + + + + + +

Type

+

Description

+

number

+

Returns 0 if the two objects are equal; returns 1 if the given object is less than this object; return -1 if the given object is greater than this object.

+
+ + +- Example + + ``` + var rationalNumber = new util.RationalNumber(1,2); + var rational = rationalNumer.creatRationalFromString("3/4"); + var result = rationalNumber.compareTo(rational); + ``` + + +### valueOf8+ + +valueOf\(\):number + +Obtains the value of this **RationalNumber** object as an integer or a floating-point number. + +- Return values + + + + + + + + + + +

Type

+

Description

+

number

+

An integer or a floating-point number.

+
+ + +- Example + + ``` + var rationalNumber = new util.RationalNumber(1,2); + var result = rationalNumber.valueOf(); + ``` + + +### equals8+ + +equals​\(obj:Object\):boolean + +Checks whether this **RationalNumber** object equals the given object. + +- Parameters + + + + + + + + + + + + + + +

Name

+

Type

+

Mandatory

+

Description

+

object

+

Object

+

Yes

+

Object used to compare with this RationalNumber object.

+
+ +- Return values + + + + + + + + + + +

Type

+

Description

+

boolean

+

Returns true if the two objects are equal; returns false otherwise.

+
+ + +- Example + + ``` + var rationalNumber = new util.RationalNumber(1,2); + var rational = rationalNumer.creatRationalFromString("3/4"); + var result = rationalNumber.equals(rational); + ``` + + +### getCommonDivisor8+ + +static getCommonDivisor​\(number1:number,number2:number\):number + +Obtains the greatest common divisor of the two specified integers. + +- Parameters + + + + + + + + + + + + + + + + + + + +

Name

+

Type

+

Mandatory

+

Description

+

number1

+

number

+

Yes

+

The first integer used to get the greatest common divisor.

+

number2

+

number

+

Yes

+

The second integer used to get the greatest common divisor.

+
+ +- Return values + + + + + + + + + + +

Type

+

Description

+

number

+

Greatest common divisor obtained.

+
+ + +- Example + + ``` + var rationalNumber = new util.RationalNumber(1,2); + var result = rationalNumber.getCommonDivisor(4,6); + ``` + + +### getNumerator8+ + +getNumerator​\(\):number + +Obtains the numerator of this **RationalNumber** object. + +- Return values + + + + + + + + + + +

Type

+

Description

+

number

+

Numerator of this RationalNumber object.

+
+ + +- Example + + ``` + var rationalNumber = new util.RationalNumber(1,2); + var result = rationalNumber.getNumerator(); + ``` + + +### getDenominator8+ + +getDenominator​\(\):number + +Obtains the denominator of this **RationalNumber** object. + +- Return values + + + + + + + + + + +

Type

+

Description

+

number

+

Denominator of this RationalNumber object.

+
+ + +- Example + + ``` + var rationalNumber = new util.RationalNumber(1,2); + var result = rationalNumber.getDenominator(); + ``` + + +### isZero8+ + +isZero​\(\):boolean + +Checks whether this **RationalNumber** object is **0**. + +- Return values + + + + + + + + + + +

Type

+

Description

+

boolean

+

Returns true if the value of this RationalNumber object is 0; returns false otherwise.

+
+ + +- Example + + ``` + var rationalNumber = new util.RationalNumber(1,2); + var result = rationalNumber.isZero(); + ``` + + +### isNaN8+ + +isNaN​\(\):boolean + +Checks whether this **RationalNumber** object is a Not a Number \(NaN\). + +- Return values + + + + + + + + + + +

Type

+

Description

+

boolean

+

Returns true if this RationalNumber object is a NaN (the denominator and numerator are both 0); returns false otherwise.

+
+ + +- Example + + ``` + var rationalNumber = new util.RationalNumber(1,2); + var result = rationalNumber.isNaN(); + ``` + + +### isFinite8+ + +isFinite​\(\):boolean + +Checks whether this **RationalNumber** object represents a finite value. + +- Return values + + + + + + + + + + +

Type

+

Description

+

boolean

+

Returns true if this RationalNumber object represents a finite value (the denominator is not 0); returns false otherwise.

+
+ + +- Example + + ``` + var rationalNumber = new util.RationalNumber(1,2); + var result = rationalNumber.isFinite(); + ``` + + +### toString8+ + +toString​\(\):string + +Obtains the string representation of this **RationalNumber** object. + +- Return values + + + + + + + + + + +

Type

+

Description

+

string

+

Returns NaN if the numerator and denominator of this object are both 0; returns a string in Numerator/Denominator format otherwise, for example, 3/5.

+
+ + +- Example + + ``` + var rationalNumber = new util.RationalNumber(1,2); + var result = rationalNumber.toString(); + ``` + + +## LruBuffer8+ + +### Attributes + + + + + + + + + + + + + + + + +

Name

+

Type

+

Readable

+

Writable

+

Description

+

length

+

number

+

Yes

+

No

+

Total number of values in this buffer.

+
+ +- Example + + ``` + var pro = new util.LruBuffer(); + pro.put(2,10); + pro.put(1,8); + var result = pro.length; + ``` + + +### constructor8+ + +constructor\(capacity?:number\) + +A constructor used to create an **LruBuffer** instance. The default capacity of the buffer is 64. + +- Parameters + + + + + + + + + + + + + + +

Name

+

Type

+

Mandatory

+

Description

+

capacity

+

number

+

No

+

Capacity of the LruBuffer to create.

+
+ + +- Example + + ``` + var lrubuffer= new util.LruBuffer(); + ``` + + +### updateCapacity8+ + +updateCapacity\(newCapacity:number\):void + +Changes the **LruBuffer** capacity. If the new capacity is less than or equal to **0**, an exception will be thrown. + +- Parameters + + + + + + + + + + + + + + +

Name

+

Type

+

Mandatory

+

Description

+

newCapacity

+

number

+

Yes

+

New capacity of the buffer.

+
+ +- Example + + ``` + var pro = new util.LruBuffer(); + var result = pro.updateCapacity(100); + ``` + + +### toString8+ + +toString\(\):string + +Obtains the string representation of this **LruBuffer** object. + +- Return values + + + + + + + + + + +

Type

+

Description

+

string

+

String representation of this object.

+
+ + +- Example + + ``` + var pro = new util.LruBuffer(); + pro.put(2,10); + pro.get(2); + pro.remove(20); + var result = pro.toString(); + ``` + + +### getCapacity8+ + +getCapacity\(\):number + +Obtains the capacity of this buffer. + +- Return values + + + + + + + + + + +

Type

+

Description

+

number

+

Capacity of this buffer.

+
+ + +- Example + + ``` + var pro = new util.LruBuffer(); + var result = pro.getCapacity(); + ``` + + +### clear8+ + +clear\(\):void + +Clears key-value pairs from this buffer. The **afterRemoval\(\)** method will be called to perform subsequent operations. + +- Example + + ``` + var pro = new util.LruBuffer(); + pro.put(2,10); + var result = pro.size(); + pro.clear(); + ``` + + +### getCreateCount8+ + +getCreateCount\(\):number + +Obtains the number of return values for **createDefault\(\)**. + +- Return values + + + + + + + + + + +

Type

+

Description

+

number

+

Number of return values for createDefault().

+
+ + +- Example + + ``` + var pro = new util.LruBuffer(); + pro.put(1,8); + var result = pro.getCreateCount(); + ``` + + +### getMissCount8+ + +getMissCount\(\):number + +Obtains the number of times that the queried values are mismatched. + +- Return values + + + + + + + + + + +

Type

+

Description

+

number

+

Number of times that the queried values are mismatched.

+
+ + +- Example + + ``` + var pro = new util.LruBuffer(); + pro.put(2,10); + pro.get(2) + var result = pro.getMissCount(); + ``` + + +### getRemovalCount8+ + +getRemovalCount\(\):number + +Obtains the number of removals from this buffer. + +- Return values + + + + + + + + + + +

Type

+

Description

+

number

+

Number of removals from the buffer.

+
+ + +- Example + + ``` + var pro = new util.LruBuffer(); + pro.put(2,10); + pro.updateCapacity(2); + pro.put(50,22); + var result = pro.getRemovalCount(); + ``` + + +### getMatchCount8+ + +getMatchCount\(\):number + +Obtains the number of times that the queried values are matched. + +- Return values + + + + + + + + + + +

Type

+

Description

+

number

+

Number of times that the queried values are matched.

+
+ + +- Example + + ``` + var pro = new util.LruBuffer(); + pro.put(2,10); + pro.get(2); + var result = pro.getMatchCount(); + ``` + + +### getPutCount8+ + +getPutCount\(\):number + +Obtains the number of additions to this buffer. + +- Return values + + + + + + + + + + +

Type

+

Description

+

number

+

Number of additions to the buffer.

+
+ + +- Example + + ``` + var pro = new util.LruBuffer(); + pro.put(2,10); + var result = pro.getPutCount(); + ``` + + +### isEmpty8+ + +isEmpty\(\):boolean + +Checks whether this buffer is empty. + +- Return values + + + + + + + + + + +

Type

+

Description

+

boolean

+

Returns true if the buffer does not contain any value.

+
+ + +- Example + + ``` + var pro = new util.LruBuffer(); + pro.put(2,10); + var result = pro.isEmpty(); + ``` + + +### get8+ + +get\(key:K\):V | undefined + +Obtains the value of the specified key. + +- Parameters + + + + + + + + + + + + + + +

Name

+

Type

+

Mandatory

+

Description

+

key

+

K

+

Yes

+

Key based on which the value is queried.

+
+ + +- Return values + + + + + + + + + + +

Type

+

Description

+

V | undefind

+

Returns the value of the key if a match is found in the buffer; returns undefined otherwise.

+
+ + +- Example + + ``` + var pro = new util.LruBuffer(); + pro.put(2,10); + var result = pro.get(2); + ``` + + +### put8+ + +put\(key:K,value:V\):V + +Adds a key-value pair to this buffer. + +- Parameters + + + + + + + + + + + + + + + + + + + +

Name

+

Type

+

Mandatory

+

Description

+

key

+

K

+

Yes

+

Key of the key-value pair to add.

+

value

+

V

+

Yes

+

Value of the key-value pair to add.

+
+ + +- Return values + + + + + + + + + + +

Type

+

Description

+

V

+

Returns the existing value if the key already exists; returns the value added otherwise. If the key or value is null, an exception will be thrown.

+
+ + +- Example + + ``` + var pro = new util.LruBuffer(); + var result = pro.put(2,10); + ``` + + +### values8+ + +values\(\):V\[\] + +Obtains all values in this buffer, listed from the most to the least recently accessed. + +- Return values + + + + + + + + + + +

Type

+

Description

+

V []

+

All values in the buffer, listed from the most to the least recently accessed.

+
+ + +- Example + + ``` + var pro = new util.LruBuffer(); + pro.put(2,10); + pro.put(2,"anhu"); + pro.put("afaf","grfb"); + var result = pro.values(); + ``` + + +### keys8+ + +keys\(\):K\[\] + +Obtains all keys in this buffer, listed from the most to the least recently accessed. + +- Return values + + + + + + + + + + +

Type

+

Description

+

K []

+

All keys in the buffer, listed from the most to the least recently accessed.

+
+ + +- Example + + ``` + var pro = new util.LruBuffer(); + pro.put(2,10); + var result = pro.keys(); + ``` + + +### remove8+ + +remove\(key:K\):V | undefined + +Deletes the specified key and its value from this buffer. + +- Parameters + + + + + + + + + + + + + + +

Name

+

Type

+

Mandatory

+

Description

+

key

+

K

+

Yes

+

Key to delete.

+
+ + +- Return values + + + + + + + + + + +

Type

+

Description

+

V | undefind

+

Returns an Optional object containing the deleted key-value pair if the key exists in the buffer; returns an empty Optional object otherwise. If the key is null, an exception will be thrown.

+
+ + +- Example + + ``` + var pro = new util.LruBuffer(); + pro.put(2,10); + var result = pro.remove(20); + ``` + + +### afterRemoval8+ + +afterRemoval\(isEvict:boolean,key:K,value:V,newValue:V\):void + +Performs subsequent operations after a value is deleted. + +- Parameters + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Name

+

Type

+

Mandatory

+

Description

+

isEvict

+

boolean

+

No

+

Whether the buffer capacity is insufficient. If the value is true, this method is called due to insufficient capacity.

+

key

+

K

+

Yes

+

Key deleted.

+

value

+

V

+

Yes

+

Value deleted.

+

newValue

+

V

+

No

+

New value for the key if the put() method is called and the key to be added already exists. In other cases, this parameter is left blank.

+
+ + +- Example + + ``` + var arr = []; + class ChildLruBuffer extends util.LruBuffer + { + constructor() + { + super(); + } + static getInstance() + { + if(this.instance == null) + { + this.instance = new ChildLruBuffer(); + } + return this.instance; + } + afterRemoval(isEvict, key, value, newValue) + { + if (isEvict === false) + { + arr = [key, value, newValue]; + } + } + } + ChildLruBuffer.getInstance().afterRemoval(false,10,30,null); + ``` + + +### contains8+ + +contains\(key:K\):boolean + +Checks whether this buffer contains the specified key. + +- Parameters + + + + + + + + + + + + + + +

Name

+

Type

+

Mandatory

+

Description

+

key

+

K

+

Yes

+

Key to check.

+
+ + +- Return values + + + + + + + + + + +

Type

+

Description

+

boolean

+

Returns true if the buffer contains the specified key; returns false otherwise.

+
+ + +- Example + + ``` + var pro = new util.LruBuffer(); + pro.put(2,10); + var result = pro.contains(20); + ``` + + +### createDefault8+ + +createDefault\(key:K\):V + +Creates a value if the value of the specified key is not available. + +- Parameters + + + + + + + + + + + + + + +

Name

+

Type

+

Mandatory

+

Description

+

key

+

K

+

Yes

+

Key of which the value is missing.

+
+ + +- Return values + + + + + + + + + + +

Type

+

Description

+

V

+

Value of the key.

+
+ + +- Example + + ``` + var pro = new util.LruBuffer(); + var result = pro.createDefault(50); + ``` + + +### entries8+ + +entries\(\):IterableIterator<\[K,V\]\> + +Obtains a new iterator object that contains all key-value pairs in this object. + +- Return values + + + + + + + + + + +

Type

+

Description

+

[K, V]

+

Returns an iterable array.

+
+ + +- Example + + ``` + var pro = new util.LruBuffer(); + pro.put(2,10); + var result = pro.entries(); + ``` + + +### \[Symbol.iterator\]8+ + +\[Symbol.iterator\]\(\): IterableIterator<\[K, V\]\> + +Obtains a two-dimensional array in key-value pairs. + +- Return values + + + + + + + + + + +

Type

+

Description

+

[K, V]

+

A two-dimensional array in key-value pairs.

+
+ + +- Example + + ``` + var pro = new util.LruBuffer(); + pro.put(2,10); + var result = pro[symbol.iterator](); + ``` + + +## Scope8+ + +### ScopeType8+ + +Defines the type of values in a **Scope** object. The value type can be **ScopeComparable** or **number**. + +The values of the **ScopeComparable** type are used to implement the **compareTo** method. Therefore, ensure that the input parameters are comparable. + +``` +interface ScopeComparable{ + compareTo(other:ScopeComparable):boolean; +} +type ScopeType = ScopeComparable | number; +``` + +Create a class to implement the **compareTo** method. In the subsequent sample code, **Temperature** is used as an example of the [ScopeType](#section876116244471) object. + +Example + +``` +class Temperature{ + constructor(value){ + this._temp = value; + } + comapreTo(value){ + return this._temp >= value.getTemp(); + } + getTemp(){ + return this._temp; + } + toString(){ + return this._temp.toString(); + } +} +``` + +### constructor8+ + +constructor\(lowerObj:ScopeType,upperObje:ScopeType\) + +A constructor used to create a **Scope** object with the specified upper and lower limits. + +- Parameters + + + + + + + + + + + + + + + + + + + +

Name

+

Type

+

Mandatory

+

Description

+

lowerObj

+

ScopeType

+

Yes

+

Lower limit of the Scope object.

+

upperObj

+

ScopeType

+

Yes

+

Upper limit of the Scope object.

+
+ +- Example + + ``` + var tempLower = new Temperature(30); + var tempUpper = new Temperature(40); + var range = new util.Scope(tempLower, tempUpper); + ``` + + +### toString8+ + +toString\(\):string + +Obtains a string representation that contains this **Scope**. + +- Return values + + + + + + + + + + +

Type

+

Description

+

string

+

String representation containing the Scope.

+
+ + +- Example + + ``` + var tempLower = new Temperature(30); + var tempUpper = new Temperature(40); + var range = new util.Scope(tempLower, tempUpper); + var result = range.toString(); + ``` + + +### intersect8+ + +intersect\(range:Scope\):Scope + +Obtains the intersection of this **Scope** and the given **Scope**. + +- Parameters + + + + + + + + + + + + + + +

Name

+

Type

+

Mandatory

+

Description

+

range

+

Scope

+

Yes

+

Scope specified.

+
+ + +- Return values + + + + + + + + + + +

Type

+

Description

+

Scope

+

Intersection of this Scope and the given Scope.

+
+ + +- Example + + ``` + var tempLower = new Temperature(30); + var tempUpper = new Temperature(40); + var range = new util.Scope(tempLower, tempUpper); + var tempMiDF = new Temperature(35); + var tempMidS = new Temperature(39); + var rangeFir = new util.Scope(tempMiDF, tempMidS); + range.intersect(rangeFir ); + ``` + + +### intersect8+ + +intersect\(lowerObj:ScopeType,upperObj:ScopeType\):Scope + +Obtains the intersection of this **Scope** and the given lower and upper limits. + +- Parameters + + + + + + + + + + + + + + + + + + + +

Name

+

Type

+

Mandatory

+

Description

+

lowerObj

+

ScopeType

+

Yes

+

Lower limit.

+

upperObj

+

ScopeType

+

Yes

+

Upper limit.

+
+ + +- Return values + + + + + + + + + + +

Type

+

Description

+

Scope

+

Intersection of this Scope and the given lower and upper limits.

+
+ + +- Example + + ``` + var tempLower = new Temperature(30); + var tempUpper = new Temperature(40); + var tempMiDF = new Temperature(35); + var tempMidS = new Temperature(39); + var range = new util.Scope(tempLower, tempUpper); + var result = range.intersect(tempMiDF, tempMidS); + ``` + + +### getUpper8+ + +getUpper\(\):ScopeType + +Obtains the upper limit of this **Scope**. + +- Return values + + + + + + + + + + +

Type

+

Description

+

ScopeType

+

Upper limit of this Scope.

+
+ + +- Example + + ``` + var tempLower = new Temperature(30); + var tempUpper = new Temperature(40); + var range = new util.Scope(tempLower, tempUpper); + var result = range.getUpper(); + ``` + + +### getLower8+ + +getLower\(\):ScopeType + +Obtains the lower limit of this **Scope**. + +- Return values + + + + + + + + + + +

Type

+

Description

+

ScopeType

+

Lower limit of this Scope.

+
+ + +- Example + + ``` + var tempLower = new Temperature(30); + var tempUpper = new Temperature(40); + var range = new util.Scope(tempLower, tempUpper); + var result = range.getLower(); + ``` + + +### expand8+ + +expand\(lowerObj:ScopeType,upperObj:ScopeType\):Scope + +Obtains the union set of this **Scope** and the given lower and upper limits. + +- Parameters + + + + + + + + + + + + + + + + + + + +

Name

+

Type

+

Mandatory

+

Description

+

lowerObj

+

ScopeType

+

Yes

+

Lower limit.

+

upperObj

+

ScopeType

+

Yes

+

Upper limit.

+
+ + +- Return values + + + + + + + + + + +

Type

+

Description

+

Scope

+

Union set of this Scope and the given lower and upper limits.

+
+ + +- Example + + ``` + var tempLower = new Temperature(30); + var tempUpper = new Temperature(40); + var tempMiDF = new Temperature(35); + var tempMidS = new Temperature(39); + var range = new util.Scope(tempLower, tempUpper); + var result = range.expand(tempMiDF, tempMidS); + ``` + + +### expand8+ + +expand\(range:Scope\):Scope + +Obtains the union set of this **Scope** and the given **Scope**. + +- Parameters + + + + + + + + + + + + + + +

Name

+

Type

+

Mandatory

+

Description

+

range

+

Scope

+

Yes

+

Scope specified.

+
+ + +- Return values + + + + + + + + + + +

Type

+

Description

+

Scope

+

Union set of this Scope and the given Scope.

+
+ + +- Example + + ``` + var tempLower = new Temperature(30); + var tempUpper = new Temperature(40); + var tempMiDF = new Temperature(35); + var tempMidS = new Temperature(39); + var range = new util.Scope(tempLower, tempUpper); + var rangeFir = new util.Scope(tempMiDF, tempMidS); + var result = range.expand(rangeFir); + ``` + + +### expand8+ + +expand\(value:ScopeType\):Scope + +Obtains the union set of this **Scope** and the given value. + +- Parameters + + + + + + + + + + + + + + +

Name

+

Type

+

Mandatory

+

Description

+

value

+

ScopeType

+

Yes

+

Value specified.

+
+ + +- Return values + + + + + + + + + + +

Type

+

Description

+

Scope

+

Union set of this Scope and the given value.

+
+ + +- Example + + ``` + var tempLower = new Temperature(30); + var tempUpper = new Temperature(40); + var tempMiDF = new Temperature(35); + var range = new util.Scope(tempLower, tempUpper); + var result = range.expand(tempMiDF); + ``` + + +### contains8+ + +contains\(value:ScopeType\):boolean + +Checks whether a value is within this **Scope**. + +- Parameters + + + + + + + + + + + + + + +

Name

+

Type

+

Mandatory

+

Description

+

value

+

ScopeType

+

Yes

+

Value specified.

+
+ + +- Return values + + + + + + + + + + +

Type

+

Description

+

boolean

+

Returns true if the value is within this Scope; returns false otherwise.

+
+ + +- Example + + ``` + var tempLower = new Temperature(30); + var tempUpper = new Temperature(40); + var tempMiDF = new Temperature(35); + var range = new util.Scope(tempLower, tempUpper); + range.contains(tempMiDF); + ``` + + +### contains8+ + +contains\(range:Scope\):boolean + +Checks whether a range is within this **Scope**. + +- Parameters + + + + + + + + + + + + + + +

Name

+

Type

+

Mandatory

+

Description

+

range

+

Scope

+

Yes

+

Range specified.

+
+ + +- Return values + + + + + + + + + + +

Type

+

Description

+

boolean

+

Returns true if the range is within this Scope; returns false otherwise.

+
+ + +- Example + + ``` + var tempLower = new Temperature(30); + var tempUpper = new Temperature(40); + var range = new util.Scope(tempLower, tempUpper); + var tempLess = new Temperature(20); + var tempMore = new Temperature(45); + var rangeSec = new util.Scope(tempLess, tempMore); + var result = range.contains(rangeSec); + ``` + + +### clamp8+ + +clamp\(value:ScopeType\):ScopeType + +Limits a value to this **Scope**. + +- Parameters + + + + + + + + + + + + + + +

Name

+

Type

+

Mandatory

+

Description

+

value

+

ScopeType

+

Yes

+

Value specified.

+
+ + +- Return values + + + + + + + + + + +

Type

+

Description

+

ScopeType

+

Returns lowerObj if the specified value is less than the lower limit; returns upperObj if the specified value is greater than the upper limit; returns the specified value if it is within this Scope.

+
+ + +- Example + + ``` + var tempLower = new Temperature(30); + var tempUpper = new Temperature(40); + var tempMiDF = new Temperature(35); + var range = new util.Scope(tempLower, tempUpper); + var result = range.clamp(tempMiDF); + ``` + + +## Base648+ + +### constructor8+ + +constructor\(\) + +A constructor used to create a **Base64** object. + +- Example + + ``` + var base64 = new util.Base64(); + ``` + + +### encodeSync8+ + +encodeSync\(src:Uint8Array\):Uint8Array + +Encodes the input content. + +- Parameters + + + + + + + + + + + + + + +

Name

+

Type

+

Mandatory

+

Description

+

src

+

Uint8Array

+

Yes

+

Uint8Array to encode.

+
+ +- Return values + + + + + + + + + + +

Type

+

Description

+

Uint8Array

+

Uint8Array encoded.

+
+ +- Example + + ``` + var that = new util.Base64(); + var array = new Uint8Array([115,49,51]); + var result = that.encodeSync(array); + ``` + + +### encodeToStringSync8+ + +encodeToStringSync\(src:Uint8Array\):string + +Encodes the input content into a string. + +- Parameters + + + + + + + + + + + + + + +

Name

+

Type

+

Mandatory

+

Description

+

src

+

Uint8Array

+

Yes

+

Uint8Array to encode.

+
+ +- Return values + + + + + + + + + + +

Type

+

Description

+

string

+

String encoded from the Uint8Array.

+
+ +- Example + + ``` + var that = new util.Base64(); + var array = new Uint8Array([115,49,51]); + var result = that.encodeToStringSync(array); + ``` + + +### decodeSync8+ + +decodeSync\(src:Uint8Array | string\):Uint8Array + +Decodes the input content. + +- Parameters + + + + + + + + + + + + + + +

Name

+

Type

+

Mandatory

+

Description

+

src

+

Uint8Array | string

+

Yes

+

Uint8Array or string to decode.

+
+ +- Return values + + + + + + + + + + +

Type

+

Description

+

Uint8Array

+

Uint8Array decoded.

+
+ +- Example + + ``` + var that = new util.Base64(); + var buff = 'czEz'; + var result = that.decodeSync(buff); + ``` + + +### encode8+ + +encode\(src:Uint8Array\):Promise + +Encodes the input content asynchronously. + +- Parameters + + + + + + + + + + + + + + +

Name

+

Type

+

Mandatory

+

Description

+

src

+

Uint8Array

+

Yes

+

Uint8Array to encode asynchronously.

+
+ +- Return values + + + + + + + + + + +

Type

+

Description

+

Promise<Uint8Array>

+

Uint8Array obtained after asynchronous encoding.

+
+ +- Example + + ``` + var that = new util.Base64(); + var array = new Uint8Array([115,49,51]); + var rarray = new Uint8Array([99,122,69,122]); + await that.encode(array).then(val=>{ + for (var i = 0; i < rarray.length; i++) { + expect(val[i]).assertEqual(rarray[i]) + } + }) + done(); + ``` + + +### encodeToString8+ + +encodeToString\(src:Uint8Array\):Promise + +Encodes the input content asynchronously into a string. + +- Parameters + + + + + + + + + + + + + + +

Name

+

Type

+

Mandatory

+

Description

+

src

+

Uint8Array

+

Yes

+

Uint8Array to encode asynchronously.

+
+ +- Return values + + + + + + + + + + +

Type

+

Description

+

Promise<string>

+

String obtained after asynchronous encoding.

+
+ +- Example + + ``` + var that = new util.Base64(); + var array = new Uint8Array([115,49,51]); + await that.encodeToString(array).then(val=>{ + expect(val).assertEqual('czEz') + }) + done(); + ``` + + +### decode8+ + +decode\(src:Uint8Array | string\):Promise + +Decodes the input content asynchronously. + +- Parameters + + + + + + + + + + + + + + +

Name

+

Type

+

Mandatory

+

Description

+

src

+

Uint8Array | string

+

Yes

+

Uint8Array or string to decode asynchronously.

+
+ +- Return values + + + + + + + + + + +

Type

+

Description

+

Promise<Uint8Array>

+

Uint8Array obtained after asynchronous decoding.

+
+ +- Example + + ``` + var that = new util.Base64(); + var array = new Uint8Array([99,122,69,122]); + var rarray = new Uint8Array([115,49,51]); + await that.decode(array).then(val=>{ + for (var i = 0; i < rarray.length; i++) { + expect(val[i]).assertEqual(rarray[i]) + } + }) + done(); + ``` + + +## Types8+ + +### constructor8+ + +constructor\(\) + +A constructor used to create a **Types** object. + +- Example + + ``` + var type = new util.Types(); + ``` + + +### isAnyArrayBuffer8+ + +isAnyArrayBuffer\(value: Object\):boolean + +Checks whether the input value is of the **ArrayBuffer** type. + +- Parameters + + + + + + + + + + + + + + +

Name

+

Type

+

Mandatory

+

Description

+

value

+

Object

+

Yes

+

Object to check.

+
+ +- Return values + + + + + + + + + + +

Type

+

Description

+

boolean

+

Returns true if the input value is of the ArrayBuffer type; returns false otherwise.

+
+ +- Example + + ``` + var that = new util.Types(); + var result = that.isAnyArrayBuffer(new ArrayBuffer([])); + ``` + + +### isArrayBufferView8+ + +isArrayBufferView\(value: Object\):boolean + +Checks whether the input value is of the **ArrayBufferView** type. + +**ArrayBufferView** is a helper type representing any of the following: **Int8Array**, **Int16Array**, **Int32Array**, **Uint8Array**, **Uint8ClampedArray**, **Uint32Array**, **Float32Array**, **Float64Array**, and **DataView**. + +- Parameters + + + + + + + + + + + + + + +

Name

+

Type

+

Mandatory

+

Description

+

value

+

Object

+

Yes

+

Object to check.

+
+ + Return values + + + + + + + + + + +

Type

+

Description

+

boolean

+

Returns true if the input value is of the ArrayBufferView type; returns false otherwise.

+
+ +- Example + + ``` + var that = new util.Types(); + var result = that.isArrayBufferView(new Int8Array([])); + ``` + + +### isArgumentsObject8+ + +isArgumentsObject\(value: Object\):boolean + +Checks whether the input value is of the **arguments** type. + +- Parameters + + + + + + + + + + + + + + +

Name

+

Type

+

Mandatory

+

Description

+

value

+

Object

+

Yes

+

Object to check.

+
+ +- Return values + + + + + + + + + + +

Type

+

Description

+

boolean

+

Returns true if the input value is of the arguments type; returns false otherwise.

+
+ +- Example + + ``` + var that = new util.Types(); + function foo() { + var result = that.isArgumentsObject(arguments); + } + var f = foo(); + ``` + + +### isArrayBuffer8+ + +isArrayBuffer\(value: Object\):boolean + +Checks whether the input value is of the **ArrayBuffer** type. + +- Parameters + + + + + + + + + + + + + + +

Name

+

Type

+

Mandatory

+

Description

+

value

+

Object

+

Yes

+

Object to check.

+
+ +- Return values + + + + + + + + + + +

Type

+

Description

+

boolean

+

Returns true if the input value is of the ArrayBuffer type; returns false otherwise.

+
+ +- Example + + ``` + var that = new util.Types(); + var result = that.isArrayBuffer(new ArrayBuffer([])); + ``` + + +### isAsyncFunction8+ + +isAsyncFunction\(value: Object\):boolean + +Checks whether the input value is an asynchronous function. + +- Parameters + + + + + + + + + + + + + + +

Name

+

Type

+

Mandatory

+

Description

+

value

+

Object

+

Yes

+

Object to check.

+
+ +- Return values + + + + + + + + + + +

Type

+

Description

+

boolean

+

Returns true if the input value is an asynchronous function; returns false otherwise.

+
+ +- Example + + ``` + var that = new util.Types(); + var result = that.isAsyncFunction(async function foo() {}); + ``` + + +### isBooleanObject8+ + +isBooleanObject\(value: Object\):boolean + +Checks whether the input value is of the **Boolean** type. + +- Parameters + + + + + + + + + + + + + + +

Name

+

Type

+

Mandatory

+

Description

+

value

+

Object

+

Yes

+

Object to check.

+
+ +- Return values + + + + + + + + + + +

Type

+

Description

+

boolean

+

Returns true if the input value is of the Boolean type; returns false otherwise.

+
+ +- Example + + ``` + var that = new util.Types(); + var result = that.isBooleanObject(new Boolean(true)); + ``` + + +### isBoxedPrimitive8+ + +isBoxedPrimitive\(value: Object\):boolean + +Checks whether the input value is of the **Boolean**, **Number**, **String**, or **Symbol** type. + +- Parameters + + + + + + + + + + + + + + +

Name

+

Type

+

Mandatory

+

Description

+

value

+

Object

+

Yes

+

Object to check.

+
+ +- Return values + + + + + + + + + + +

Type

+

Description

+

boolean

+

Returns true if the input value is of the Boolean, Number, String, or Symbol type; returns false otherwise.

+
+ +- Example + + ``` + var that = new util.Types(); + var result = that.isBoxedPrimitive(new Boolean(false)); + ``` + + +### isDataView8+ + +isDataView\(value: Object\):boolean + +Checks whether the input value is of the **DataView** type. + +- Parameters + + + + + + + + + + + + + + +

Name

+

Type

+

Mandatory

+

Description

+

value

+

Object

+

Yes

+

Object to check.

+
+ +- Return values + + + + + + + + + + +

Type

+

Description

+

boolean

+

Returns true if the input value is of the DataView type; returns false otherwise.

+
+ +- Example + + ``` + var that = new util.Types(); + const ab = new ArrayBuffer(20); + var result = that.isDataView(new DataView(ab)); + ``` + + +### isDate8+ + +isDate\(value: Object\):boolean + +Checks whether the input value is of the **Date** type. + +- Parameters + + + + + + + + + + + + + + +

Name

+

Type

+

Mandatory

+

Description

+

value

+

Object

+

Yes

+

Object to check.

+
+ +- Return values + + + + + + + + + + +

Type

+

Description

+

boolean

+

Returns true if the input value is of the Data type; returns false otherwise.

+
+ +- Example + + ``` + var that = new util.Types(); + var result = that.isDate(new Date()); + ``` + + +### isExternal8+ + +isExternal\(value: Object\):boolean + +Checks whether the input value is of the **native external** type. + +- Parameters + + + + + + + + + + + + + + +

Name

+

Type

+

Mandatory

+

Description

+

value

+

Object

+

Yes

+

Object to check.

+
+ +- Return values + + + + + + + + + + +

Type

+

Description

+

boolean

+

Returns true if the input value is of the native external type; returns false otherwise.

+
+ +- Example + + ``` + var that = new util.Types(); + const data = util.createExternalType(); + var result = that.isExternal(data); + ``` + + +### isFloat32Array8+ + +isFloat32Array\(value: Object\):boolean + +Checks whether the input value is of the **Float32Array** type. + +- Parameters + + + + + + + + + + + + + + +

Name

+

Type

+

Mandatory

+

Description

+

value

+

Object

+

Yes

+

Object to check.

+
+ +- Return values + + + + + + + + + + +

Type

+

Description

+

boolean

+

Returns true if the input value is of the Float32Array type; returns false otherwise.

+
+ +- Example + + ``` + var that = new util.Types(); + var result = that.isFloat32Array(new Float32Array()); + ``` + + +### isFloat64Array8+ + +isFloat64Array\(value: Object\):boolean + +Checks whether the input value is of the **Float64Array** type. + +- Parameters + + + + + + + + + + + + + + +

Name

+

Type

+

Mandatory

+

Description

+

value

+

Object

+

Yes

+

Object to check.

+
+ +- Return values + + + + + + + + + + +

Type

+

Description

+

boolean

+

Returns true if the input value is of the Float64Array type; returns false otherwise.

+
+ +- Example + + ``` + var that = new util.Types(); + var result = that.isFloat64Array(new Float64Array()); + ``` + + +### isGeneratorFunction8+ + +isGeneratorFunction\(value: Object\):boolean + +Checks whether the input value is a generator function. + +- Parameters + + + + + + + + + + + + + + +

Name

+

Type

+

Mandatory

+

Description

+

value

+

Object

+

Yes

+

Object to check.

+
+ +- Return values + + + + + + + + + + +

Type

+

Description

+

boolean

+

Returns true if the input value is a generator function; returns false otherwise.

+
+ +- Example + + ``` + var that = new util.Types(); + var result = that.isGeneratorFunction(function* foo() {}); + ``` + + +### isGeneratorObject8+ + +isGeneratorObject\(value: Object\):boolean + +Checks whether the input value is a generator object. + +- Parameters + + + + + + + + + + + + + + +

Name

+

Type

+

Mandatory

+

Description

+

value

+

Object

+

Yes

+

Object to check.

+
+ +- Return values + + + + + + + + + + +

Type

+

Description

+

boolean

+

Returns true if the input value is a generator object; returns false otherwise.

+
+ +- Example + + ``` + var that = new util.Types(); + function* foo() {} + const generator = foo(); + var result = that.isGeneratorObject(generator); + ``` + + +### isInt8Array8+ + +isInt8Array\(value: Object\):boolean + +Checks whether the input value is of the **Int8Array** type. + +- Parameters + + + + + + + + + + + + + + +

Name

+

Type

+

Mandatory

+

Description

+

value

+

Object

+

Yes

+

Object to check.

+
+ +- Return values + + + + + + + + + + +

Type

+

Description

+

boolean

+

Returns true if the input value is of the Int8Array type; returns false otherwise.

+
+ +- Example + + ``` + var that = new util.Types(); + var result = that.isInt8Array(new Int8Array([])); + ``` + + +### isInt16Array8+ + +isInt16Array\(value: Object\):boolean + +Checks whether the input value is of the **Int16Array** type. + +- Parameters + + + + + + + + + + + + + + +

Name

+

Type

+

Mandatory

+

Description

+

value

+

Object

+

Yes

+

Object to check.

+
+ +- Return values + + + + + + + + + + +

Type

+

Description

+

boolean

+

Returns true if the input value is of the Int16Array type; returns false otherwise.

+
+ +- Example + + ``` + var that = new util.Types(); + var result = that.isInt16Array(new Int16Array([])); + ``` + + +### isInt32Array8+ + +isInt32Array\(value: Object\):boolean + +Checks whether the input value is of the **Int32Array** type. + +- Parameters + + + + + + + + + + + + + + +

Name

+

Type

+

Mandatory

+

Description

+

value

+

Object

+

Yes

+

Object to check.

+
+ +- Return values + + + + + + + + + + +

Type

+

Description

+

boolean

+

Returns true if the input value is of the Int32Array type; returns false otherwise.

+
+ +- Example + + ``` + var that = new util.Types(); + var result = that.isInt32Array(new Int32Array([])); + ``` + + +### isMap8+ + +isMap\(value: Object\):boolean + +Checks whether the input value is of the **Map** type. + +- Parameters + + + + + + + + + + + + + + +

Name

+

Type

+

Mandatory

+

Description

+

value

+

Object

+

Yes

+

Object to check.

+
+ +- Return values + + + + + + + + + + +

Type

+

Description

+

boolean

+

Returns true if the input value is of the Map type; returns false otherwise.

+
+ +- Example + + ``` + var that = new util.Types(); + var result = that.isMap(new Map()); + ``` + + +### isMapIterator8+ + +isMapIterator\(value: Object\):boolean + +Checks whether the input value is of the **MapIterator** type. + +- Parameters + + + + + + + + + + + + + + +

Name

+

Type

+

Mandatory

+

Description

+

value

+

Object

+

Yes

+

Object to check.

+
+ +- Return values + + + + + + + + + + +

Type

+

Description

+

boolean

+

Returns true if the input value is of the MapIterator type; returns false otherwise.

+
+ +- Example + + ``` + var that = new util.Types(); + const map = new Map(); + var result = that.isMapIterator(map.keys()); + ``` + + +### isNativeError8+ + +isNativeError\(value: Object\):boolean + +Checks whether the input value is of the **Error** type. + +- Parameters + + + + + + + + + + + + + + +

Name

+

Type

+

Mandatory

+

Description

+

value

+

Object

+

Yes

+

Object to check.

+
+ +- Return values + + + + + + + + + + +

Type

+

Description

+

boolean

+

Returns true if the input value is of the Error type; returns false otherwise.

+
+ +- Example + + ``` + var that = new util.Types(); + var result = that.isNativeError(new TypeError()); + ``` + + +### isNumberObject8+ + +isNumberObject\(value: Object\):boolean + +Checks whether the input value is a number object. + +- Parameters + + + + + + + + + + + + + + +

Name

+

Type

+

Mandatory

+

Description

+

value

+

Object

+

Yes

+

Object to check.

+
+ +- Return values + + + + + + + + + + +

Type

+

Description

+

boolean

+

Returns true if the input value is a number object; returns false otherwise.

+
+ +- Example + + ``` + var that = new util.Types(); + var result = that.isNumberObject(new Number(0)); + ``` + + +### isPromise8+ + +isPromise\(value: Object\):boolean + +Checks whether the input value is a promise. + +- Parameters + + + + + + + + + + + + + + +

Name

+

Type

+

Mandatory

+

Description

+

value

+

Object

+

Yes

+

Object to check.

+
+ +- Return values + + + + + + + + + + +

Type

+

Description

+

boolean

+

Returns true if the input value is a promise; returns false otherwise.

+
+ +- Example + + ``` + var that = new util.Types(); + var result = that.isPromise(Promise.resolve(1)); + ``` + + +### isProxy8+ + +isProxy\(value: Object\):boolean + +Checks whether the input value is a proxy. + +- Parameters + + + + + + + + + + + + + + +

Name

+

Type

+

Mandatory

+

Description

+

value

+

Object

+

Yes

+

Object to check.

+
+ +- Return values + + + + + + + + + + +

Type

+

Description

+

boolean

+

Returns true if the input value is a proxy; returns false otherwise.

+
+ +- Example + + ``` + var that = new util.Types(); + const target = {}; + const proxy = new Proxy(target, {}); + var result = that.isProxy(proxy); + ``` + + +### isRegExp8+ + +isRegExp\(value: Object\):boolean + +Checks whether the input value is of the **RegExp** type. + +- Parameters + + + + + + + + + + + + + + +

Name

+

Type

+

Mandatory

+

Description

+

value

+

Object

+

Yes

+

Object to check.

+
+ +- Return values + + + + + + + + + + +

Type

+

Description

+

boolean

+

Returns true if the input value is of the RegExp type; returns false otherwise.

+
+ +- Example + + ``` + var that = new util.Types(); + var result = that.isRegExp(new RegExp('abc')); + ``` + + +### isSet8+ + +isSet\(value: Object\):boolean + +Checks whether the input value is of the **Set** type. + +- Parameters + + + + + + + + + + + + + + +

Name

+

Type

+

Mandatory

+

Description

+

value

+

Object

+

Yes

+

Object to check.

+
+ +- Return values + + + + + + + + + + +

Type

+

Description

+

boolean

+

Returns true if the input value is of the Set type; returns false otherwise.

+
+ +- Example + + ``` + var that = new util.Types(); + var result = that.isSet(new Set()); + ``` + + +### isSetIterator8+ + +isSetIterator\(value: Object\):boolean + +Checks whether the input value is of the **SetIterator** type. + +- Parameters + + + + + + + + + + + + + + +

Name

+

Type

+

Mandatory

+

Description

+

value

+

Object

+

Yes

+

Object to check.

+
+ +- Return values + + + + + + + + + + +

Type

+

Description

+

boolean

+

Returns true if the input value is of the SetIterator type; returns false otherwise.

+
+ +- Example + + ``` + var that = new util.Types(); + const set = new Set(); + var result = that.isSetIterator(set.keys()); + ``` + + +### isStringObject8+ + +isStringObject\(value: Object\):boolean + +Checks whether the input value is a string object. + +- Parameters + + + + + + + + + + + + + + +

Name

+

Type

+

Mandatory

+

Description

+

value

+

Object

+

Yes

+

Object to check.

+
+ +- Return values + + + + + + + + + + +

Type

+

Description

+

boolean

+

Returns true if the input value is a string object; returns false otherwise.

+
+ +- Example + + ``` + var that = new util.Types(); + var result = that.isStringObject(new String('foo')); + ``` + + +### isSymbolObjec8+ + +isSymbolObjec\(value: Object\):boolean + +Checks whether the input value is a symbol object. + +- Parameters + + + + + + + + + + + + + + +

Name

+

Type

+

Mandatory

+

Description

+

value

+

Object

+

Yes

+

Object to check.

+
+ +- Return values + + + + + + + + + + +

Type

+

Description

+

boolean

+

Returns true if the input value is a symbol object; returns false otherwise.

+
+ +- Example + + ``` + var that = new util.Types(); + const symbols = Symbol('foo'); + var result = that.isSymbolObject(Object(symbols)); + ``` + + +### isTypedArray8+ + +isTypedArray\(value: Object\):boolean + +Checks whether the input value is of the **TypedArray** type. + +**TypedArray** is a helper type representing any of the following: **Int8Array**, **Int16Array**, **Int32Array**, **Uint8Array**, **Uint8ClampedArray**, **Uint16Array**, **Uint32Array**, **Float32Array**, **Float64Array**, and **DataView**. + +- Parameters + + + + + + + + + + + + + + +

Name

+

Type

+

Mandatory

+

Description

+

value

+

Object

+

Yes

+

Object to check.

+
+ +- Return values + + + + + + + + + + +

Type

+

Description

+

boolean

+

Returns true if the input value is of the TypedArray type; returns false otherwise.

+
+ +- Example + + ``` + var that = new util.Types(); + var result = that.isTypedArray(new Float64Array([])); + ``` + + +### isUint8Array8+ + +isUint8Array\(value: Object\):boolean + +Checks whether the input value is of the **Uint8Array** type. + +- Parameters + + + + + + + + + + + + + + +

Name

+

Type

+

Mandatory

+

Description

+

value

+

Object

+

Yes

+

Object to check.

+
+ +- Return values + + + + + + + + + + +

Type

+

Description

+

boolean

+

Returns true if the input value is of the Uint8Array type; returns false otherwise.

+
+ +- Example + + ``` + var that = new util.Types(); + var result = that.isUint8Array(new Uint8Array([])); + ``` + + +### isUint8ClampedArray8+ + +isUint8ClampedArray\(value: Object\):boolean + +Checks whether the input value is of the **Uint8ClampedArray** type. + +- Parameters + + + + + + + + + + + + + + +

Name

+

Type

+

Mandatory

+

Description

+

value

+

Object

+

Yes

+

Object to check.

+
+ +- Return values + + + + + + + + + + +

Type

+

Description

+

boolean

+

Returns true if the input value is of the Uint8ClampedArray type; returns false otherwise.

+
+ +- Example + + ``` + var that = new util.Types(); + var result = that.isUint8ClampedArray(new Uint8ClampedArray([])); + ``` + + +### isUint16Array8+ + +isUint16Array\(value: Object\):boolean + +Checks whether the input value is of the **Uint16Array** type. + +- Parameters + + + + + + + + + + + + + + +

Name

+

Type

+

Mandatory

+

Description

+

value

+

Object

+

Yes

+

Object to check.

+
+ +- Return values + + + + + + + + + + +

Type

+

Description

+

boolean

+

Returns true if the input value is of the Uint16Array type; returns false otherwise.

+
+ +- Example + + ``` + var that = new util.Types(); + var result = that.isUint16Array(new Uint16Array([])); + ``` + + +### isUint32Array8+ + +isUint32Array\(value: Object\):boolean + +Checks whether the input value is of the **Uint32Array** type. + +- Parameters + + + + + + + + + + + + + + +

Name

+

Type

+

Mandatory

+

Description

+

value

+

Object

+

Yes

+

Object to check.

+
+ +- Return values + + + + + + + + + + +

Type

+

Description

+

boolean

+

Returns true if the input value is of the Uint32Array type; returns false otherwise.

+
+ +- Example + + ``` + var that = new util.Types(); + var result = that.isUint32Array(new Uint32Array([])); + ``` + + +### isWeakMap8+ + +isWeakMap\(value: Object\):boolean + +Checks whether the input value is of the **WeakMap** type. + +- Parameters + + + + + + + + + + + + + + +

Name

+

Type

+

Mandatory

+

Description

+

value

+

Object

+

Yes

+

Object to check.

+
+ +- Return values + + + + + + + + + + +

Type

+

Description

+

boolean

+

Returns true if the input value is of the WeakMap type; returns false otherwise.

+
+ +- Example + + ``` + var that = new util.Types(); + var result = that.isWeakMap(new WeakMap()); + ``` + + +### isWeakSet8+ + +isWeakSet\(value: Object\):boolean + +Checks whether the input value is of the **WeakSet** type. + +- Parameters + + + + + + + + + + + + + + +

Name

+

Type

+

Mandatory

+

Description

+

value

+

Object

+

Yes

+

Object to check.

+
+ +- Return values + + + + + + + + + + +

Type

+

Description

+

boolean

+

Returns true if the input value is of the WeakSet type; returns false otherwise.

+
+ +- Example + + ``` + var that = new util.Types(); + var result = that.isWeakSet(new WeakSet()); + ``` + + diff --git a/en/application-dev/reference/apis/js-apis-wifi.md b/en/application-dev/reference/apis/js-apis-wifi.md index 617d88183d0a304378d2f73efaf709a3f636499b..4cede020064f4a8ad43892a7940715bd49b52679 100644 --- a/en/application-dev/reference/apis/js-apis-wifi.md +++ b/en/application-dev/reference/apis/js-apis-wifi.md @@ -1,124 +1,1409 @@ -# WLAN +# WLAN -> ![icon-note.gif](public_sys-resources/icon-note.gif) **Note:** -> 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. +>**NOTE:** +>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. -## Modules to Import +## Modules to Import ``` -import wifi from '@ohos.wifi_native_js'; +import wifi from '@ohos.wifi'; ``` -## wifi.isWifiActive +## wifi.isWifiActive -isWifiActive(): boolean +isWifiActive\(\): boolean -Checks whether WLAN is activated. +Checks whether the WLAN is activated. -**Return values** +- Return values -| Type| Description| -| -------- | ---------------------------- | -| boolean | Returns **true** if WLAN is activated; returns **false** otherwise.| + + + + + + + + + +

Type

+

Description

+

boolean

+

Returns true if the WLAN is activated; returns false otherwise.

+
-## wifi.getSignalLevel -getSignalLevel(rssi: number, band: number): number +## wifi.scan + +scan\(\): boolean + +Starts a scan for WLAN. + +- Return values + + + + + + + + + + +

Type

+

Description

+

boolean

+

Returns true if the scan is successful; returns false otherwise.

+
+ + +## wifi.getScanInfos + +getScanInfos\(\): Promise\> + +Obtains the scan result. This method uses a promise to return the result. + +- Return values + + + + + + + + + + +

Type

+

Description

+

Promise< Array<WifiScanInfo> >

+

Promise used to return the scan result, which is a list of hotspot information.

+
+ + +## wifi.getScanInfos + +getScanInfos\(callback: AsyncCallback\>\): void + +Obtains the scan result. This method uses an asynchronous callback to return the result. + +- Parameters + + + + + + + + + + + + + + +

Name

+

Type

+

Mandatory

+

Description

+

callback

+

AsyncCallback< Array<WifiScanInfo>>

+

Yes

+

Callback invoked to return the scan result, which is a list of hotspot information.

+
+ + +- Example + + ``` + import wifi from '@ohos.wifi'; + + wifi.getScanInfos(result => { + var len = Object.keys(result).length; + console.log("wifi received scan info call back: " + len); + for (var i = 0; i < len; ++i) { + console.info("ssid: " + result[i].ssid); + console.info("bssid: " + result[i].bssid); + console.info("securityType: " + result[i].securityType); + console.info("rssi: " + result[i].rssi); + console.info("band: " + result[i].band); + console.info("frequency: " + result[i].frequency); + console.info("timestamp: " + result[i].timestamp); + } + }); + + wifi.getScanInfos().then(result => { + var len = Object.keys(result).length; + console.log("wifi received scan info promise: " + len); + for (var i = 0; i < len; ++i) { + console.info("ssid: " + result[i].ssid); + console.info("bssid: " + result[i].bssid); + console.info("securityType: " + result[i].securityType); + console.info("rssi: " + result[i].rssi); + console.info("band: " + result[i].band); + console.info("frequency: " + result[i].frequency); + console.info("timestamp: " + result[i].timestamp); + } + }); + ``` + + +## WifiScanInfo + +Defines the WLAN hotspot information. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Name

+

Type

+

Readable/Writable

+

Description

+

ssid

+

string

+

Read-only

+

Hotspot service set identifier (SSID), in UTF-8 format.

+

bssid

+

string

+

Read-only

+

Basic service set identifier (BSSID) of the hotspot.

+

securityType

+

WifiSecurityType

+

Read-only

+

WLAN encryption type.

+

rssi

+

number

+

Read-only

+

Received Signal Strength Indicator (RSSI) of the hotspot, in dBm.

+

band

+

number

+

Read-only

+

Frequency band of the WLAN access point (AP).

+

frequency

+

number

+

Read-only

+

Frequency of the WLAN AP.

+

timestamp

+

number

+

Read-only

+

Timestamp.

+
+ +## WifiSecurityType + +Enumerates the WLAN encryption types. + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Name

+

Default Value

+

Description

+

WIFI_SEC_TYPE_INVALID

+

0

+

Invalid encryption.

+

WIFI_SEC_TYPE_OPEN

+

1

+

Open encryption.

+

WIFI_SEC_TYPE_WEP

+

2

+

Wired equivalent privacy (WEP) encryption.

+

WIFI_SEC_TYPE_PSK

+

3

+

PSK encryption.

+

WIFI_SEC_TYPE_SAE

+

4

+

Simultaneous authentication of equals (SAE) encryption.

+
+ +## wifi.getSignalLevel + +getSignalLevel\(rssi: number, band: number\): number Obtains the WLAN signal strength. -**Parameters** +- Parameters -| Name| Type| Mandatory| Description| -| ---------- | -------- | -------- | --------------------- | -| rssi | number | Yes| Signal strength (in dBm) of the hotspot.| -| band | number | Yes| Frequency band of the WLAN access point (AP).| + + + + + + + + + + + + + + + + + + +

Name

+

Type

+

Mandatory

+

Description

+

rssi

+

number

+

Yes

+

RSSI of the hotspot, in dBm.

+

band

+

number

+

Yes

+

Frequency band of the WLAN AP.

+
-**Return values** -| Type| Description| -| -------- | ---------------------------- | -| number | Signal strength obtained. The value range is 0 to 4.| +- Return values -## wifi.scan + + + + + + + + + +

Type

+

Description

+

number

+

Signal strength obtained. The value range is 0 to 4.

+
-scan(): boolean -Starts a scan for WLAN. +## wifi.getIpInfo7+ -**Return values** +getIpInfo\(\): IpInfo -| Type| Description| -| -------- | -------------------------------------------- | -| boolean | Returns **true** if the scan is successful; returns **false** otherwise.| +Obtains IP information. -## wifi.getScanInfos +- Return values -getScanInfos(): Promise> + + + + + + + + + +

Type

+

Description

+

IpInfo

+

IP information obtained.

+
-Obtains the scan result. This method uses a promise to return the result. -**Return values** +## IpInfo -| Type| Description| -| ------------------------------------------------ | ---------------------- | -| Promise< Array\<[WifiScanInfo](#wifiscaninfo)> > | Promise used to return the scan result, which is a list of hotspots detected.| +Defines IP information. -## wifi.getScanInfos + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Name

+

Type

+

Readable/Writable

+

Description

+

ipAddress

+

number

+

Read-only

+

IP address.

+

gateway

+

number

+

Read-only

+

Gateway.

+

netmask

+

number

+

Read-only

+

Subnet mask.

+

primaryDns

+

number

+

Read-only

+

IP address of the preferred DNS server.

+

secondDns

+

number

+

Read-only

+

IP address of the alternate DNS server.

+

serverIp

+

number

+

Read-only

+

IP address of the DHCP server.

+

leaseDuration

+

number

+

Read-only

+

Lease duration of the IP address.

+
-getScanInfos(callback: AsyncCallback>): void +## wifi.isConnected7+ -Obtains the scan result. This method uses an asynchronous callback to return the result. +isConnected\(\): boolean -| Name| Type| Mandatory| Description| -| ---------- | ----------------------------------------------------- | -------- | ------------------------------ | -| callback | AsyncCallback< Array\<[WifiScanInfo](#wifiscaninfo)>> | Yes| Callback invoked to return the result, which is a list of hotspots detected.| +Checks whether the WLAN is connected. -**Example** +- Return values -``` -import wifi from '@ohos.wifi_native_js'; - - -wifi.getScanInfos(result => { - var len = Object.keys(result).length; - console.log("received scan info size: " + len); - for (var i = 0; i < len; ++j) { - console.info("ssid: " + result[i].ssid); - console.info("bssid: " + result[i].bssid); - console.info("securityType: " + result[i].securityType); - console.info("rssi: " + result[i].rssi); - console.info("band: " + result[i].band); - console.info("frequency: " + result[i].frequency); - console.info("timestamp: " + result[i].timestamp); - } -}); - -wifi.getScanInfos().then(result => { - var len = Object.keys(result).length; - console.log("received scan info size: " + len); - for (var i = 0; i < len; ++i) { - console.info("ssid: " + result[i].ssid); - console.info("bssid: " + result[i].bssid); - console.info("securityType: " + result[i].securityType); - console.info("rssi: " + result[i].rssi); - console.info("band: " + result[i].band); - console.info("frequency: " + result[i].frequency); - console.info("timestamp: " + result[i].timestamp); + + + + + + + + + +

Type

+

Description

+

boolean

+

Returns true if the WLAN is connected; returns false otherwise.

+
+ + +## wifi.getLinkedInfo7+ + +getLinkedInfo\(\): Promise + +Obtains WLAN connection information. This method uses a promise to return the result. + +- Return values + + + + + + + + + + +

Type

+

Description

+

Promise<WifiLinkedInfo>

+

Promise used to return the WLAN connection information

+
+ + +## wifi.getLinkedInfo7+ + +getLinkedInfo\(callback: AsyncCallback\): void + +Obtains WLAN connection information. This method uses a callback to return the result. + +- Parameters + + + + + + + + + + + + + + +

Name

+

Type

+

Mandatory

+

Description

+

callback

+

AsyncCallback<WifiLinkedInfo>

+

Yes

+

Callback invoked to return the WLAN connection information.

+
+ +- Example + + ``` + import wifi from '@ohos.wifi'; + + wifi.getLinkedInfo(data => { + console.info("get wifi linked info [callback]: " + JSON.stringify(data)); + }); + + wifi.getLinkedInfo().then(data => { + console.info("get wifi linked info [promise]: " + JSON.stringify(data)); + }).catch(error => { + console.info("linked info promise then error"); + }); + ``` + + +## WifiLinkedInfo + +Defines the WLAN connection information. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Name

+

Type

+

Readable/Writable

+

Description

+

ssid

+

string

+

Read-only

+

Hotspot SSID, in UTF-8 format.

+

bssid

+

string

+

Read-only

+

BSSID of the hotspot.

+

rssi

+

number

+

Read-only

+

RSSI of the hotspot, in dBm.

+

band

+

number

+

Read-only

+

Frequency band of the WLAN AP.

+

linkSpeed

+

number

+

Read-only

+

Speed of the WLAN AP.

+

frequency

+

number

+

Read-only

+

Frequency of the WLAN AP.

+

isHidden

+

boolean

+

Read-only

+

Whether the WLAN AP is hidden.

+

isRestricted

+

boolean

+

Read-only

+

Whether data volume is restricted at the WLAN AP.

+

macAddress

+

string

+

Read-only

+

MAC address of the device that sets up the WLAN connection.

+

ipAddress

+

number

+

Read-only

+

IP address of the device that sets up the WLAN connection.

+

connState

+

ConnState

+

Read-only

+

WLAN connection state.

+
+ +## ConnState + +Enumerates the WLAN connection states. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Name

+

Default Value

+

Description

+

SCANNING

+

0

+

The device is scanning for available APs.

+

CONNECTING

+

1

+

A WLAN connection is being established.

+

AUTHENTICATING

+

2

+

An authentication is being performed for a WLAN connection.

+

OBTAINING_IPADDR

+

3

+

The IP address of the WLAN connection is being acquired.

+

CONNECTED

+

4

+

A WLAN connection is established.

+

DISCONNECTING

+

5

+

The WLAN connection is being disconnected.

+

DISCONNECTED

+

6

+

The WLAN connection is disconnected.

+

UNKNOWN

+

7

+

Failed to set up a WLAN connection.

+
+ +## wifi.getCountryCode7+ + +getCountryCode\(\): string + +Obtains the country code. + +- Return values + + + + + + + + + + +

Type

+

Description

+

string

+

Country code obtained.

+
+ + +## wifi.isFeatureSupported7+ + +isFeatureSupported\(featureId: number\): boolean + +Checks whether the device supports the specified WLAN feature. + +- Parameters + + + + + + + + + + + + + + +

Name

+

Type

+

Mandatory

+

Description

+

featureId

+

number

+

Yes

+

Feature ID.

+
+ + +- Return values + + + + + + + + + + +

Type

+

Description

+

boolean

+

Returns true if the feature is supported; returns false otherwise.

+
+ +- Enumerates the WLAN features. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Value

+

Description

+

0x0001

+

WLAN infrastructure mode.

+

0x0002

+

5 GHz bandwidth.

+

0x0004

+

Generic Advertisement Service (GAS)/Access Network Query Protocol (ANQP) feature.

+

0x0008

+

Wi-Fi Direct.

+

0x0010

+

SoftAP.

+

0x0040

+

Wi-Fi AWare.

+

0x8000

+

WLAN AP/STA concurrency

+

0x8000000

+

WPA3 Personal (WPA-3 SAE) feature.

+

0x10000000

+

WPA3 Enterprise Suite B feature.

+

0x20000000

+

Enhanced open feature.

+
+ + +## wifi.on\('wifiStateChange'\)7+ + +on\(type: "wifiStateChange", callback: Callback\): void + +Registers the WLAN state change events. + +- Parameters + + + + + + + + + + + + + + + + + + + +

Name

+

Type

+

Mandatory

+

Description

+

type

+

string

+

Yes

+

Event type. The value is wifiStateChange.

+

callback

+

Callback<number>

+

Yes

+

Callback invoked to return the WLAN state.

+
+ + +- Enumerates the WLAN states. + + + + + + + + + + + + + + + + + + + +

Value

+

Description

+

0

+

Deactivated.

+

1

+

Activated.

+

2

+

Activating.

+

3

+

Deactivating.

+
+ + +## wifi.off\('wifiStateChange'\)7+ + +off\(type: "wifiStateChange", callback?: Callback\): void + +Unregisters the WLAN state change events. + +- Parameters + + + + + + + + + + + + + + + + + + + +

Name

+

Type

+

Mandatory

+

Description

+

type

+

string

+

Yes

+

Event type. The value is wifiStateChange.

+

callback

+

Callback<number>

+

No

+

Callback used to report the WLAN state. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.

+
+ + +- Example + + ``` + import wifi from '@ohos.wifi'; + import { EventListener } from '@ohos.wifi'; + + var WIFI_POWER_STATE = "wifiStateChange"; + var listener = new EventListener(); + + var recvPowerNotifyFunc = result => { + console.info("power state receive event: " + result); } -}); -``` + + // Register event + listener.on(WIFI_POWER_STATE, recvPowerNotifyFunc); + + // Unregister event + listener.off(WIFI_POWER_STATE, recvPowerNotifyFunc); + ``` + + +## wifi.on\('wifiConnectionChange'\)7+ + +on\(type: "wifiConnectionChange", callback: Callback\): void + +Registers the WLAN connection state change events. + +- Parameters + + + + + + + + + + + + + + + + + + + +

Name

+

Type

+

Mandatory

+

Description

+

type

+

string

+

Yes

+

Event type. The value is wifiConnectionChange.

+

callback

+

Callback<number>

+

Yes

+

Callback invoked to return the WLAN connection state.

+
+ + +- Enumerates the WLAN connection states. + + + + + + + + + + + + + +

Value

+

Description

+

0

+

Disconnected.

+

1

+

Connected.

+
+ + +## wifi.off\('wifiConnectionChange'\)7+ + +off\(type: "wifiConnectionChange", callback?: Callback\): void + +Unregisters the WLAN connection state change events. + +- Parameters + + + + + + + + + + + + + + + + + + + +

Name

+

Type

+

Mandatory

+

Description

+

type

+

string

+

Yes

+

Event type. The value is wifiConnectionChange.

+

callback

+

Callback<number>

+

No

+

Callback used to report the WLAN connection state. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.

+
+ + +## wifi.on\('wifiScanStateChange'\)7+ + +on\(type: "wifiScanStateChange", callback: Callback\): void + +Registers the WLAN scan state change events. + +- Parameters + + + + + + + + + + + + + + + + + + + +

Name

+

Type

+

Mandatory

+

Description

+

type

+

string

+

Yes

+

Event type. The value is wifiScanStateChange.

+

callback

+

Callback<number>

+

Yes

+

Callback invoked to return the WLAN scan state.

+
+ + +- Enumerates the WLAN scan states. + + + + + + + + + + + + + +

Value

+

Description

+

0

+

The scan failed.

+

1

+

The scan is successful.

+
+ + +## wifi.off\('wifiScanStateChange'\)7+ + +off\(type: "wifiScanStateChange", callback?: Callback\): void + +Unregisters the WLAN scan state change events. + +- Parameters + + + + + + + + + + + + + + + + + + + +

Name

+

Type

+

Mandatory

+

Description

+

type

+

string

+

Yes

+

Event type. The value is wifiScanStateChange.

+

callback

+

Callback<number>

+

No

+

Callback used to report the WLAN scan state. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.

+
+ +## wifi.on\('wifiRssiChange'\)7+ + +on\(type: "wifiRssiChange", callback: Callback\): void + +Registers the RSSI state change events. + +- Parameters + + + + + + + + + + + + + + + + + + + +

Name

+

Type

+

Mandatory

+

Description

+

type

+

string

+

Yes

+

Event type. The value is wifiRssiChange.

+

callback

+

Callback<number>

+

Yes

+

Callback invoked to return the RSSI, in dBm.

+
+ + +## wifi.off\('wifiRssiChange'\)7+ + +off\(type: "wifiRssiChange", callback?: Callback\): void + +Unregisters the RSSI state change events. + +- Parameters + + + + + + + + + + + + + + + + + + + +

Name

+

Type

+

Mandatory

+

Description

+

type

+

string

+

Yes

+

Event type. The value is wifiRssiChange.

+

callback

+

Callback<number>

+

No

+

Callback used to report the RSSI. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.

+
+ + +## wifi.on\('hotspotStateChange'\)7+ + +on\(type: "hotspotStateChange", callback: Callback\): void + +Registers the hotspot state change events. + +- Parameters + + + + + + + + + + + + + + + + + + + +

Name

+

Type

+

Mandatory

+

Description

+

type

+

string

+

Yes

+

Event type. The value is hotspotStateChange.

+

callback

+

Callback<number>

+

Yes

+

Callback invoked to return the hotspot state.

+
+ + +- Enumerates the hotspot states. + + + + + + + + + + + + + + + + + + + +

Value

+

Description

+

0

+

Deactivated.

+

1

+

Activated.

+

2

+

Activating.

+

3

+

Deactivating.

+
+ + +## wifi.off\('hotspotStateChange'\)7+ + +off\(type: "hotspotStateChange", callback?: Callback\): void + +Unregisters the hotspot state change events. + +- Parameters -## WifiScanInfo + + + + + + + + + + + + + + + + + + +

Name

+

Type

+

Mandatory

+

Description

+

type

+

string

+

Yes

+

Event type. The value is hotspotStateChange.

+

callback

+

Callback<number>

+

No

+

Callback used to report the hotspot state. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.

+
-Defines WLAN hotspot information. -| Name| Type| Readable/Writable| Description| -| ------------ | ---------------- | ------------ | ----------------------------- | -| ssid | string | Read-only| Hotspot service set identifier (SSID), in UTF-8 format.| -| bssid | string | Read-only| Basic service set identifier (BSSID) of the hotspot.| -| securityType | WifiSecurityType | Read-only| WLAN encryption type.| -| rssi | number | Read-only| Signal strength (in dBm) of the hotspot.| -| band | number | Read-only| Frequency band of the WLAN AP.| -| frequency | number | Read-only| Frequency of the WLAN AP.| -| timestamp | number | Read-only| Timestamp.| diff --git a/en/application-dev/reference/arkui-js/Readme-EN.md b/en/application-dev/reference/arkui-js/Readme-EN.md index 7c322dd6bf026387dfbadf215a6638643e3e26d1..d9159c600a7471090dd7d1b510677651bc7c698f 100644 --- a/en/application-dev/reference/arkui-js/Readme-EN.md +++ b/en/application-dev/reference/arkui-js/Readme-EN.md @@ -1,17 +1,4 @@ -# JavaScript-based Web-like Development Paradigm - -- [Framework](js-framework.md) - - [File Organization](js-framework-file.md) - - ["js" Tag](js-framework-js-tag.md) - - [app.js](js-framework-js-file.md) - - [Syntax](js-framework-syntax.md) - - [HML](js-framework-syntax-hml.md) - - [CSS](js-framework-syntax-css.md) - - [JavaScript](js-framework-syntax-js.md) - - - [Lifecycle](js-framework-lifecycle.md) - - [Resource Limitations and Access](js-framework-resource-restriction.md) - - [Multi-Language Capability](js-framework-multiple-languages.md) +# TypeScript-based Declarative Development Paradigm - [Components](js-components.md) - [Common](js-components-common.md) @@ -20,7 +7,7 @@ - [Universal Events](js-components-common-events.md) - [Universal Methods](js-components-common-methods.md) - [Animation Styles](js-components-common-animation.md) - - [Gradient Styles](js-components-common-gradient.md) + - [Gradient Styles](reference/arkui-js/js-components-common-gradient.md) - [Transition Styles](js-components-common-transition.md) - [Media Query](js-components-common-mediaquery.md) - [Custom Font Styles](js-components-common-customizing-font.md) @@ -77,7 +64,7 @@ - [Media Components](js-components-media.md) - [video](js-components-media-video.md) - - [Canvas Components](js-components-canvas.md) + - [Canvas Components ](js-components-canvas.md) - [canvas](js-components-canvas-canvas.md) - [CanvasRenderingContext2D](js-components-canvas-canvasrenderingcontext2d.md) - [Image](js-components-canvas-image.md) @@ -114,10 +101,11 @@ - [Custom Components](js-components-custom.md) - [Basic Usage](js-components-custom-basic-usage.md) - [Custom Events](js-components-custom-events.md) - - [Props](js-components-custom-props.md) + - [props](js-components-custom-props.md) - [Event Parameter](js-components-custom-event-parameter.md) - [slot](js-components-custom-slot.md) - [Lifecycle Definition](js-components-custom-lifecycle.md) - [Appendix](js-appendix.md) - - [Type Attributes](js-appendix-types.md) \ No newline at end of file + - [Type Attributes](js-appendix-types.md) + diff --git a/en/application-dev/reference/arkui-js/figures/001.gif b/en/application-dev/reference/arkui-js/figures/001.gif new file mode 100644 index 0000000000000000000000000000000000000000..1a522da15ad7fd2ef6de0f89e28f7bec087976d8 Binary files /dev/null and b/en/application-dev/reference/arkui-js/figures/001.gif differ diff --git a/en/application-dev/reference/arkui-js/figures/1-33.jpg b/en/application-dev/reference/arkui-js/figures/1-1.jpg similarity index 100% rename from en/application-dev/reference/arkui-js/figures/1-33.jpg rename to en/application-dev/reference/arkui-js/figures/1-1.jpg diff --git a/en/application-dev/reference/arkui-js/figures/1-45.gif b/en/application-dev/reference/arkui-js/figures/1-10.gif similarity index 100% rename from en/application-dev/reference/arkui-js/figures/1-45.gif rename to en/application-dev/reference/arkui-js/figures/1-10.gif diff --git a/en/application-dev/reference/arkui-js/figures/1-34.png b/en/application-dev/reference/arkui-js/figures/1-2.png similarity index 100% rename from en/application-dev/reference/arkui-js/figures/1-34.png rename to en/application-dev/reference/arkui-js/figures/1-2.png diff --git a/en/application-dev/reference/arkui-js/figures/1-36.png b/en/application-dev/reference/arkui-js/figures/1-3.png similarity index 100% rename from en/application-dev/reference/arkui-js/figures/1-36.png rename to en/application-dev/reference/arkui-js/figures/1-3.png diff --git a/en/application-dev/reference/arkui-js/figures/1-38.gif b/en/application-dev/reference/arkui-js/figures/1-38.gif deleted file mode 100644 index 9f4b3be2a876397f9d73f512e22d922fef20eff3..0000000000000000000000000000000000000000 Binary files a/en/application-dev/reference/arkui-js/figures/1-38.gif and /dev/null differ diff --git a/en/application-dev/reference/arkui-js/figures/1-39.png b/en/application-dev/reference/arkui-js/figures/1-6.png similarity index 100% rename from en/application-dev/reference/arkui-js/figures/1-39.png rename to en/application-dev/reference/arkui-js/figures/1-6.png diff --git a/en/application-dev/reference/arkui-js/figures/1-9.png b/en/application-dev/reference/arkui-js/figures/1-9.png new file mode 100644 index 0000000000000000000000000000000000000000..5e7bc3dec11daa00059d3ec93d77ac15ce357a14 Binary files /dev/null and b/en/application-dev/reference/arkui-js/figures/1-9.png differ diff --git a/en/application-dev/reference/arkui-js/figures/1-32.png b/en/application-dev/reference/arkui-js/figures/1.png similarity index 100% rename from en/application-dev/reference/arkui-js/figures/1-32.png rename to en/application-dev/reference/arkui-js/figures/1.png diff --git a/en/application-dev/reference/arkui-js/figures/11-5.gif b/en/application-dev/reference/arkui-js/figures/11-5.gif new file mode 100644 index 0000000000000000000000000000000000000000..7ca939d4de4d330dea962b991362b41ef0aacba9 Binary files /dev/null and b/en/application-dev/reference/arkui-js/figures/11-5.gif differ diff --git a/en/application-dev/reference/arkui-js/figures/11-26.png b/en/application-dev/reference/arkui-js/figures/11.png similarity index 100% rename from en/application-dev/reference/arkui-js/figures/11-26.png rename to en/application-dev/reference/arkui-js/figures/11.png diff --git a/en/application-dev/reference/arkui-js/figures/gradient-from-top-to-bottom-(default).png b/en/application-dev/reference/arkui-js/figures/111.png similarity index 100% rename from en/application-dev/reference/arkui-js/figures/gradient-from-top-to-bottom-(default).png rename to en/application-dev/reference/arkui-js/figures/111.png diff --git a/en/application-dev/reference/arkui-js/figures/12.gif b/en/application-dev/reference/arkui-js/figures/12.gif new file mode 100644 index 0000000000000000000000000000000000000000..561e823f7a9eb432e2aedbbf84637f8be40b0337 Binary files /dev/null and b/en/application-dev/reference/arkui-js/figures/12.gif differ diff --git a/en/application-dev/reference/arkui-js/figures/2-46.gif b/en/application-dev/reference/arkui-js/figures/2-11.gif similarity index 100% rename from en/application-dev/reference/arkui-js/figures/2-46.gif rename to en/application-dev/reference/arkui-js/figures/2-11.gif diff --git a/en/application-dev/reference/arkui-js/figures/2-42.png b/en/application-dev/reference/arkui-js/figures/2.png similarity index 100% rename from en/application-dev/reference/arkui-js/figures/2-42.png rename to en/application-dev/reference/arkui-js/figures/2.png diff --git a/en/application-dev/reference/arkui-js/figures/22-25.png b/en/application-dev/reference/arkui-js/figures/22.png similarity index 100% rename from en/application-dev/reference/arkui-js/figures/22-25.png rename to en/application-dev/reference/arkui-js/figures/22.png diff --git a/en/application-dev/reference/arkui-js/figures/gradient-at-an-angle-of-45.png b/en/application-dev/reference/arkui-js/figures/222.png similarity index 100% rename from en/application-dev/reference/arkui-js/figures/gradient-at-an-angle-of-45.png rename to en/application-dev/reference/arkui-js/figures/222.png diff --git a/en/application-dev/reference/arkui-js/figures/3-41.png b/en/application-dev/reference/arkui-js/figures/3-41.png deleted file mode 100644 index f5796ea1fbe46d66e30db2b1b2e1b382d56d7949..0000000000000000000000000000000000000000 Binary files a/en/application-dev/reference/arkui-js/figures/3-41.png and /dev/null differ diff --git a/en/application-dev/reference/arkui-js/figures/3.png b/en/application-dev/reference/arkui-js/figures/3.png new file mode 100644 index 0000000000000000000000000000000000000000..b370937f36a472829e7a08a4439b4025721b0437 Binary files /dev/null and b/en/application-dev/reference/arkui-js/figures/3.png differ diff --git a/en/application-dev/reference/arkui-js/figures/33-30.png b/en/application-dev/reference/arkui-js/figures/33-30.png deleted file mode 100644 index c000a7acd88692ec455970651f89cd3160052200..0000000000000000000000000000000000000000 Binary files a/en/application-dev/reference/arkui-js/figures/33-30.png and /dev/null differ diff --git a/en/application-dev/reference/arkui-js/figures/gradient-from-left-to-right.png b/en/application-dev/reference/arkui-js/figures/333.png similarity index 100% rename from en/application-dev/reference/arkui-js/figures/gradient-from-left-to-right.png rename to en/application-dev/reference/arkui-js/figures/333.png diff --git a/en/application-dev/reference/arkui-js/figures/4-31.gif b/en/application-dev/reference/arkui-js/figures/4-0.gif similarity index 100% rename from en/application-dev/reference/arkui-js/figures/4-31.gif rename to en/application-dev/reference/arkui-js/figures/4-0.gif diff --git a/en/application-dev/reference/arkui-js/figures/4-24.gif b/en/application-dev/reference/arkui-js/figures/4.gif similarity index 100% rename from en/application-dev/reference/arkui-js/figures/4-24.gif rename to en/application-dev/reference/arkui-js/figures/4.gif diff --git a/en/application-dev/reference/arkui-js/figures/repeating-gradient-from-left-to-right.png b/en/application-dev/reference/arkui-js/figures/444.png similarity index 100% rename from en/application-dev/reference/arkui-js/figures/repeating-gradient-from-left-to-right.png rename to en/application-dev/reference/arkui-js/figures/444.png diff --git a/en/application-dev/reference/arkui-js/figures/5-29.gif b/en/application-dev/reference/arkui-js/figures/5.gif similarity index 100% rename from en/application-dev/reference/arkui-js/figures/5-29.gif rename to en/application-dev/reference/arkui-js/figures/5.gif diff --git a/en/application-dev/reference/arkui-js/figures/6-28.gif b/en/application-dev/reference/arkui-js/figures/6.gif similarity index 100% rename from en/application-dev/reference/arkui-js/figures/6-28.gif rename to en/application-dev/reference/arkui-js/figures/6.gif diff --git a/en/application-dev/reference/arkui-js/figures/9-27.gif b/en/application-dev/reference/arkui-js/figures/9.gif similarity index 100% rename from en/application-dev/reference/arkui-js/figures/9-27.gif rename to en/application-dev/reference/arkui-js/figures/9.gif diff --git a/en/application-dev/reference/arkui-js/figures/en-us_image_0000001173324753.gif b/en/application-dev/reference/arkui-js/figures/animationapi-4.gif similarity index 100% rename from en/application-dev/reference/arkui-js/figures/en-us_image_0000001173324753.gif rename to en/application-dev/reference/arkui-js/figures/animationapi-4.gif diff --git a/en/application-dev/reference/arkui-js/figures/c3.png b/en/application-dev/reference/arkui-js/figures/c3.png new file mode 100644 index 0000000000000000000000000000000000000000..dca96aeb057ba12dc63365e613007e54dd268a40 Binary files /dev/null and b/en/application-dev/reference/arkui-js/figures/c3.png differ diff --git a/en/application-dev/reference/arkui-js/figures/datetime.png b/en/application-dev/reference/arkui-js/figures/datetime.png deleted file mode 100644 index 50c2d2d700960d22c332e33d9fba1b27690e63a4..0000000000000000000000000000000000000000 Binary files a/en/application-dev/reference/arkui-js/figures/datetime.png and /dev/null differ diff --git a/en/application-dev/reference/arkui-js/figures/default-transition-effect-of-shared-elements.png b/en/application-dev/reference/arkui-js/figures/default-transition-effect-of-shared-elements.png index 6f5374132403d7ef4f38fedceee3638c35c44366..70aa78c1973add7bf07ec822d905c1bc98cb47f9 100644 Binary files a/en/application-dev/reference/arkui-js/figures/default-transition-effect-of-shared-elements.png and b/en/application-dev/reference/arkui-js/figures/default-transition-effect-of-shared-elements.png differ diff --git a/en/application-dev/reference/arkui-js/figures/en-us_image_0000001127125202.png b/en/application-dev/reference/arkui-js/figures/en-us_image_0000001127125202.png new file mode 100644 index 0000000000000000000000000000000000000000..6fed31434380106e80629feafdb374c7ba68ee51 Binary files /dev/null and b/en/application-dev/reference/arkui-js/figures/en-us_image_0000001127125202.png differ diff --git a/en/application-dev/reference/arkui-js/figures/en-us_image_0000001127125204.png b/en/application-dev/reference/arkui-js/figures/en-us_image_0000001127125204.png new file mode 100644 index 0000000000000000000000000000000000000000..95770e0a80cd7581b8739c852239dff75b60f655 Binary files /dev/null and b/en/application-dev/reference/arkui-js/figures/en-us_image_0000001127125204.png differ diff --git a/en/application-dev/reference/arkui-js/figures/en-us_image_0000001127125208.png b/en/application-dev/reference/arkui-js/figures/en-us_image_0000001127125208.png new file mode 100644 index 0000000000000000000000000000000000000000..d7d5ebbd57bcdd5e5f77001aa6770ff433654be9 Binary files /dev/null and b/en/application-dev/reference/arkui-js/figures/en-us_image_0000001127125208.png differ diff --git a/en/application-dev/reference/arkui-js/figures/en-us_image_0000001127125212.png b/en/application-dev/reference/arkui-js/figures/en-us_image_0000001127125212.png new file mode 100644 index 0000000000000000000000000000000000000000..bc43e2bfefbb6cc9fb09bc92ff0740a514dd2ff5 Binary files /dev/null and b/en/application-dev/reference/arkui-js/figures/en-us_image_0000001127125212.png differ diff --git a/en/application-dev/reference/arkui-js/figures/en-us_image_0000001127284936.gif b/en/application-dev/reference/arkui-js/figures/en-us_image_0000001127284936.gif deleted file mode 100644 index fa77bb91654623c2de68a19e7f9f95bbd1d029bc..0000000000000000000000000000000000000000 Binary files a/en/application-dev/reference/arkui-js/figures/en-us_image_0000001127284936.gif and /dev/null differ diff --git a/en/application-dev/reference/arkui-js/figures/en-us_image_0000001127285024.png b/en/application-dev/reference/arkui-js/figures/en-us_image_0000001127285024.png new file mode 100644 index 0000000000000000000000000000000000000000..fffc6016e519844a25a096547bc7824f7a3450b0 Binary files /dev/null and b/en/application-dev/reference/arkui-js/figures/en-us_image_0000001127285024.png differ diff --git a/en/application-dev/reference/arkui-js/figures/en-us_image_0000001127285034.gif b/en/application-dev/reference/arkui-js/figures/en-us_image_0000001127285034.gif new file mode 100644 index 0000000000000000000000000000000000000000..17f4ea3f2983fc9a0ad21238b9345e11aa0318c3 Binary files /dev/null and b/en/application-dev/reference/arkui-js/figures/en-us_image_0000001127285034.gif differ diff --git a/en/application-dev/reference/arkui-js/figures/en-us_image_0000001150368628.png b/en/application-dev/reference/arkui-js/figures/en-us_image_0000001150368628.png deleted file mode 100644 index 80ea0c9b9a321e061224884976545e6a9fe04196..0000000000000000000000000000000000000000 Binary files a/en/application-dev/reference/arkui-js/figures/en-us_image_0000001150368628.png and /dev/null differ diff --git a/en/application-dev/reference/arkui-js/figures/en-us_image_0000001152773860.png b/en/application-dev/reference/arkui-js/figures/en-us_image_0000001152773860.png deleted file mode 100644 index e4daaa2ddaeec216adbcd71331494dd38bc67892..0000000000000000000000000000000000000000 Binary files a/en/application-dev/reference/arkui-js/figures/en-us_image_0000001152773860.png and /dev/null differ diff --git a/en/application-dev/reference/arkui-js/figures/en-us_image_0000001152833768.gif b/en/application-dev/reference/arkui-js/figures/en-us_image_0000001152833768.gif new file mode 100644 index 0000000000000000000000000000000000000000..4c7a300f18ca0f9671cacbc68590834f00ee23a1 Binary files /dev/null and b/en/application-dev/reference/arkui-js/figures/en-us_image_0000001152833768.gif differ diff --git a/en/application-dev/reference/arkui-js/figures/en-us_image_0000001169309930.png b/en/application-dev/reference/arkui-js/figures/en-us_image_0000001169309930.png deleted file mode 100644 index 072d846a3cd629316cd0dcf25d5e9e1e1d3e0dc4..0000000000000000000000000000000000000000 Binary files a/en/application-dev/reference/arkui-js/figures/en-us_image_0000001169309930.png and /dev/null differ diff --git a/en/application-dev/reference/arkui-js/figures/en-us_image_0000001173164867.png b/en/application-dev/reference/arkui-js/figures/en-us_image_0000001173164867.png new file mode 100644 index 0000000000000000000000000000000000000000..094d157e55693d0697e407f5f7299c6e2da24f56 Binary files /dev/null and b/en/application-dev/reference/arkui-js/figures/en-us_image_0000001173164867.png differ diff --git a/en/application-dev/reference/arkui-js/figures/en-us_image_0000001173164869.png b/en/application-dev/reference/arkui-js/figures/en-us_image_0000001173164869.png new file mode 100644 index 0000000000000000000000000000000000000000..3866e5677395048de391ed6159a0fe5572f6d91e Binary files /dev/null and b/en/application-dev/reference/arkui-js/figures/en-us_image_0000001173164869.png differ diff --git a/en/application-dev/reference/arkui-js/figures/en-us_image_0000001173164871.png b/en/application-dev/reference/arkui-js/figures/en-us_image_0000001173164871.png new file mode 100644 index 0000000000000000000000000000000000000000..787fe9541b386b83b07e478651637f0f450e99f2 Binary files /dev/null and b/en/application-dev/reference/arkui-js/figures/en-us_image_0000001173164871.png differ diff --git a/en/application-dev/reference/arkui-js/figures/1-35.png b/en/application-dev/reference/arkui-js/figures/en-us_image_0000001173324749.png similarity index 100% rename from en/application-dev/reference/arkui-js/figures/1-35.png rename to en/application-dev/reference/arkui-js/figures/en-us_image_0000001173324749.png diff --git a/en/application-dev/reference/arkui-js/figures/en-us_image_0000001173324783.png b/en/application-dev/reference/arkui-js/figures/en-us_image_0000001173324783.png new file mode 100644 index 0000000000000000000000000000000000000000..e05df70223233ed7162d57f021a167eec9d9686a Binary files /dev/null and b/en/application-dev/reference/arkui-js/figures/en-us_image_0000001173324783.png differ diff --git a/en/application-dev/reference/arkui-js/figures/en-us_image_0000001173324787.png b/en/application-dev/reference/arkui-js/figures/en-us_image_0000001173324787.png new file mode 100644 index 0000000000000000000000000000000000000000..06f1abd77c6c0036539e710f09617c3ef2ce0648 Binary files /dev/null and b/en/application-dev/reference/arkui-js/figures/en-us_image_0000001173324787.png differ diff --git a/en/application-dev/reference/arkui-js/figures/en-us_image_0000001181458721.png b/en/application-dev/reference/arkui-js/figures/en-us_image_0000001178875308.png similarity index 100% rename from en/application-dev/reference/arkui-js/figures/en-us_image_0000001181458721.png rename to en/application-dev/reference/arkui-js/figures/en-us_image_0000001178875308.png diff --git a/en/application-dev/reference/arkui-js/figures/en-us_image_0000001135171488.png b/en/application-dev/reference/arkui-js/figures/en-us_image_0000001179035242.png similarity index 100% rename from en/application-dev/reference/arkui-js/figures/en-us_image_0000001135171488.png rename to en/application-dev/reference/arkui-js/figures/en-us_image_0000001179035242.png diff --git a/en/application-dev/reference/arkui-js/figures/en-us_image_0000001173324847.png b/en/application-dev/reference/arkui-js/figures/en-us_image_0000001193704354.png similarity index 100% rename from en/application-dev/reference/arkui-js/figures/en-us_image_0000001173324847.png rename to en/application-dev/reference/arkui-js/figures/en-us_image_0000001193704354.png diff --git a/en/application-dev/reference/arkui-js/figures/en-us_image_0000001198530395.png b/en/application-dev/reference/arkui-js/figures/en-us_image_0000001198530395.png deleted file mode 100644 index 7a4dbacacb6b1b543a04268afd81a8b8c2f56974..0000000000000000000000000000000000000000 Binary files a/en/application-dev/reference/arkui-js/figures/en-us_image_0000001198530395.png and /dev/null differ diff --git a/en/application-dev/reference/arkui-js/figures/en-us_image_0000001198898293.png b/en/application-dev/reference/arkui-js/figures/en-us_image_0000001198898293.png new file mode 100644 index 0000000000000000000000000000000000000000..3db4286a873ef0bd14e7adeb085239a9941f918b Binary files /dev/null and b/en/application-dev/reference/arkui-js/figures/en-us_image_0000001198898293.png differ diff --git a/en/application-dev/reference/arkui-js/figures/en-us_image_0000001181449919.png b/en/application-dev/reference/arkui-js/figures/en-us_image_0000001224354967.png similarity index 100% rename from en/application-dev/reference/arkui-js/figures/en-us_image_0000001181449919.png rename to en/application-dev/reference/arkui-js/figures/en-us_image_0000001224354967.png diff --git a/en/application-dev/reference/arkui-js/figures/en-us_image_0000001236697937.png b/en/application-dev/reference/arkui-js/figures/en-us_image_0000001236697937.png new file mode 100644 index 0000000000000000000000000000000000000000..8cc5fef8ddb3f1af9d6b231f9183f5094faf5434 Binary files /dev/null and b/en/application-dev/reference/arkui-js/figures/en-us_image_0000001236697937.png differ diff --git a/en/application-dev/reference/arkui-js/figures/en-us_image_0000001127125268.png b/en/application-dev/reference/arkui-js/figures/en-us_image_0000001238184345.png similarity index 100% rename from en/application-dev/reference/arkui-js/figures/en-us_image_0000001127125268.png rename to en/application-dev/reference/arkui-js/figures/en-us_image_0000001238184345.png diff --git a/en/application-dev/reference/arkui-js/figures/figures1.png b/en/application-dev/reference/arkui-js/figures/figures1.png new file mode 100644 index 0000000000000000000000000000000000000000..2ed837e111c3ac1ba1eafb5b28da581ef4de5d22 Binary files /dev/null and b/en/application-dev/reference/arkui-js/figures/figures1.png differ diff --git a/en/application-dev/reference/arkui-js/figures/transition.gif b/en/application-dev/reference/arkui-js/figures/form-transfer.gif similarity index 100% rename from en/application-dev/reference/arkui-js/figures/transition.gif rename to en/application-dev/reference/arkui-js/figures/form-transfer.gif diff --git a/en/application-dev/reference/arkui-js/figures/gif.gif b/en/application-dev/reference/arkui-js/figures/gif.gif new file mode 100644 index 0000000000000000000000000000000000000000..98bf461673a8f11366755e99b8f59baf7cc282e8 Binary files /dev/null and b/en/application-dev/reference/arkui-js/figures/gif.gif differ diff --git a/en/application-dev/reference/arkui-js/figures/grid.gif b/en/application-dev/reference/arkui-js/figures/grid.gif new file mode 100644 index 0000000000000000000000000000000000000000..b6d2387c6db849678ae8897878fe3117170ea42a Binary files /dev/null and b/en/application-dev/reference/arkui-js/figures/grid.gif differ diff --git a/en/application-dev/reference/arkui-js/figures/label.png b/en/application-dev/reference/arkui-js/figures/label.png deleted file mode 100644 index cbe406b48fd77d39b575f506fd6fe48c830e43fa..0000000000000000000000000000000000000000 Binary files a/en/application-dev/reference/arkui-js/figures/label.png and /dev/null differ diff --git a/en/application-dev/reference/arkui-js/figures/lite_bar-37.png b/en/application-dev/reference/arkui-js/figures/lite_bar-4.png similarity index 100% rename from en/application-dev/reference/arkui-js/figures/lite_bar-37.png rename to en/application-dev/reference/arkui-js/figures/lite_bar-4.png diff --git a/en/application-dev/reference/arkui-js/figures/mmmm.gif b/en/application-dev/reference/arkui-js/figures/mmmm.gif new file mode 100644 index 0000000000000000000000000000000000000000..5959ae695322f2e1eda3364d7603ec9d2ca10819 Binary files /dev/null and b/en/application-dev/reference/arkui-js/figures/mmmm.gif differ diff --git a/en/application-dev/reference/arkui-js/figures/multitext.png b/en/application-dev/reference/arkui-js/figures/multitext.png deleted file mode 100644 index fba75110896e178bbfbd9cc309b260b49c83b06d..0000000000000000000000000000000000000000 Binary files a/en/application-dev/reference/arkui-js/figures/multitext.png and /dev/null differ diff --git a/en/application-dev/reference/arkui-js/figures/progress-43.jpg b/en/application-dev/reference/arkui-js/figures/progress-7.jpg similarity index 100% rename from en/application-dev/reference/arkui-js/figures/progress-43.jpg rename to en/application-dev/reference/arkui-js/figures/progress-7.jpg diff --git a/en/application-dev/reference/arkui-js/figures/screenshot-44.png b/en/application-dev/reference/arkui-js/figures/screenshot-8.png similarity index 100% rename from en/application-dev/reference/arkui-js/figures/screenshot-44.png rename to en/application-dev/reference/arkui-js/figures/screenshot-8.png diff --git a/en/application-dev/reference/arkui-js/figures/progress-40.png b/en/application-dev/reference/arkui-js/figures/slider.png similarity index 100% rename from en/application-dev/reference/arkui-js/figures/progress-40.png rename to en/application-dev/reference/arkui-js/figures/slider.png diff --git a/en/application-dev/reference/arkui-js/figures/text.png b/en/application-dev/reference/arkui-js/figures/text.png deleted file mode 100644 index 4a5cbc0c72ee404eb9c8afe605cd862042e98ee3..0000000000000000000000000000000000000000 Binary files a/en/application-dev/reference/arkui-js/figures/text.png and /dev/null differ diff --git a/en/application-dev/reference/arkui-js/figures/time.png b/en/application-dev/reference/arkui-js/figures/time.png deleted file mode 100644 index 484a77f31b70679cb01d8678c93439d4b55c4bcd..0000000000000000000000000000000000000000 Binary files a/en/application-dev/reference/arkui-js/figures/time.png and /dev/null differ diff --git a/en/application-dev/reference/arkui-js/js-appendix-types.md b/en/application-dev/reference/arkui-js/js-appendix-types.md index aa995002fc4d454b1f530010cbea66c8447150e2..83e657a7e233893f13b5b11e0be51b2a3f581e95 100644 --- a/en/application-dev/reference/arkui-js/js-appendix-types.md +++ b/en/application-dev/reference/arkui-js/js-appendix-types.md @@ -118,7 +118,7 @@

#000000

-

+

blanchedalmond

@@ -993,7 +993,7 @@

#708090

-

+

snow

@@ -1096,4 +1096,3 @@ - diff --git a/en/application-dev/reference/arkui-js/js-components-basic-button.md b/en/application-dev/reference/arkui-js/js-components-basic-button.md index 606633ca4b5ed90ad7256ed996d4d8f6608a20ae..0e3cd7fe5e0f3ff9f43ebb0c45dad2676de730d4 100644 --- a/en/application-dev/reference/arkui-js/js-components-basic-button.md +++ b/en/application-dev/reference/arkui-js/js-components-basic-button.md @@ -2,11 +2,11 @@ The **** component includes capsule, circle, text, arc, and download buttons. -## Child Component +## Child Components Not supported -## Attribute +## Attributes In addition to the attributes in [Universal Attributes](js-components-common-attributes.md), the following attributes are supported. @@ -19,7 +19,7 @@ In addition to the attributes in [Universal Attributes](js-components-common-at

Mandatory

-

Triggered when

+

Description

@@ -83,9 +83,9 @@ In addition to the attributes in [Universal Attributes](js-components-common-at -## Style +## Styles -When the button type is not **arc**: +### When the Button Type Is Not **arc** In addition to the styles in [Universal Styles](js-components-common-styles.md), the following styles are supported. @@ -204,7 +204,7 @@ In addition to the styles in [Universal Styles](js-components-common-styles.md)

No

-

Radius of a circle button or fillet radius of a capsule button. For a circle button, this style takes precedence over width and height in the common styles.

+

Button radius. For a circle button, this style takes precedence over width and height in the common styles.

@@ -215,7 +215,7 @@ In addition to the styles in [Universal Styles](js-components-common-styles.md) >- For circle buttons, text-related styles are not supported. >- For text buttons, the text size is automatically adaptive, and **radius**, **width**, and **height** cannot be set. The **background-color** style is not supported when the background is completely transparent. -The following styles are supported when the button type is **arc**. +### When the Button Type Is **arc** In addition to the **background-color**, **opacity**, **display**, **visibility**, **position**, **\[left|top****|right|bottom** styles in [Universal Styles](js-components-common-styles.md), the following styles are supported. @@ -301,11 +301,11 @@ In addition to the **background-color**, **opacity**, **display**, **visibil -## Event +## Events Events in [Universal Events](js-components-common-events.md) are supported. -## Method +## Methods Methods in [Universal Methods](js-components-common-methods.md) are supported. @@ -332,7 +332,7 @@ When the button type is **download**, the following methods are supported. -## Example Code +## Example ``` @@ -393,19 +393,19 @@ When the button type is **download**, the following methods are supported. // xxx.js export default { data: { - progress: 5, + count: 5, downloadText: "Download" }, progress(e) { - this.progress += 10; - this.downloadText = this.progress + "%"; - this.$element('download-btn').setProgress({ progress: this.progress }); - if (this.progress >= 100) { + this.count+= 10; + this.downloadText = this.count+ "%"; + this.$element('download-btn').setProgress({ progress: this.count}); + if (this.count>= 100) { this.downloadText = "Done"; } } } ``` -![](figures/1-32.png) +![](figures/1.png) diff --git a/en/application-dev/reference/arkui-js/js-components-basic-chart.md b/en/application-dev/reference/arkui-js/js-components-basic-chart.md index 200ec57be91c96fcdea6c71f38b4027064d96260..cfb8ae34e6ea898ca580e58a0ac7ebcd7a16569c 100644 --- a/en/application-dev/reference/arkui-js/js-components-basic-chart.md +++ b/en/application-dev/reference/arkui-js/js-components-basic-chart.md @@ -2,7 +2,7 @@ The **** component displays line charts, gauge charts, and bar charts. -## Permission List +## Required Permissions None @@ -10,7 +10,7 @@ None Not supported -## Attribute +## Attributes In addition to the attributes in [Universal Attributes](js-components-common-attributes.md), the following attributes are supported. @@ -797,7 +797,7 @@ For gauge charts, the following attribute is supported. -## Style +## Styles In addition to the styles in [Universal Styles](js-components-common-styles.md), the following styles are supported. @@ -869,7 +869,7 @@ In addition to the styles in [Universal Styles](js-components-common-styles.md)

No

-

Center of the scale bar of the gauge component. This style is supported by the gauge chart only. This style takes precedence over the position style in the common styles, and must be used together with center-x and radius. This style is supported by the gauge chart only.

+

Center of the scale bar of the gauge component. This style is supported by the gauge chart only. This style takes precedence over the position style in the common styles, and must be used together with center-x and radius. This style is supported by the gauge chart only.

radius

@@ -932,11 +932,11 @@ In addition to the styles in [Universal Styles](js-components-common-styles.md) -## Event +## Events Events in [Universal Events](js-components-common-events.md) are supported. -## Method +## Methods In addition to the methods in [Universal Methods](js-components-common-methods.md), the following events are supported. @@ -1156,4 +1156,3 @@ In addition to the methods in [Universal Methods](js-components-common-methods. ![](figures/en-us_image_0000001127125264.png) - diff --git a/en/application-dev/reference/arkui-js/js-components-basic-divider.md b/en/application-dev/reference/arkui-js/js-components-basic-divider.md index 13b19f2471c581d8865972d90050624cc9888e60..c8bb190dbaeacebddbc1325c9ef0ff41b96124d5 100644 --- a/en/application-dev/reference/arkui-js/js-components-basic-divider.md +++ b/en/application-dev/reference/arkui-js/js-components-basic-divider.md @@ -2,15 +2,15 @@ The **** component is used to separate content blocks and content elements. It can be used for the list or UI layout. -## Permission List +## Required Permissions None -## Child Component +## Child Components Not supported -## Attribute +## Attributes In addition to the attributes in [Universal Attributes](js-components-common-attributes.md), the following attributes are supported. @@ -42,9 +42,9 @@ In addition to the attributes in [Universal Attributes](js-components-common-at >![](../../public_sys-resources/icon-note.gif) **NOTE:** ->- The **focusable** and **disabled** attributes are not supported. +>The **focusable** and **disabled** attributes are not supported. -## Style +## Styles Only the following style attributes are supported. @@ -163,7 +163,7 @@ Only the following style attributes are supported.

No

How much a child component will grow. The value specifies allocation of the remaining space on the main axis of the parent component. Size of available space = Container size - Total size of all child components. Value 0 indicates that the child component does not grow.

-
NOTE:

This attribute takes effect only when the parent component is <div>, <list-item>, or <tabs>.

+
NOTE:

This attribute takes effect only when the parent component is <div>, <list-item>, or <tabs>.

@@ -177,7 +177,7 @@ Only the following style attributes are supported.

No

How much a child component will shrink. The shrink occurs only when the sum of default element widths is greater than that of the parent component. Value 0 indicates that the child component does not shrink.

-
NOTE:

This attribute takes effect only when the parent component is <div>, <list-item>, or <tabs>.

+
NOTE:

This attribute takes effect only when the parent component is <div>, <list-item>, or <tabs>.

@@ -198,11 +198,11 @@ Only the following style attributes are supported. -## Event +## Events Not supported -## Method +## Methods Not supported @@ -242,5 +242,5 @@ Not supported } ``` -![](figures/1-33.jpg) +![](figures/1-1.jpg) diff --git a/en/application-dev/reference/arkui-js/js-components-basic-image-animator.md b/en/application-dev/reference/arkui-js/js-components-basic-image-animator.md index d9e66164ffedfce435696f233bca0f32046fe4c5..8dfd02bd6d6090751ae8b212c8762b9deda2a046 100644 --- a/en/application-dev/reference/arkui-js/js-components-basic-image-animator.md +++ b/en/application-dev/reference/arkui-js/js-components-basic-image-animator.md @@ -6,7 +6,7 @@ The **** component is used to provide an image frame animator Not supported -## Attribute +## Attributes In addition to the attributes in [Universal Attributes](js-components-common-attributes.md), the following attributes are supported. @@ -191,11 +191,11 @@ In addition to the attributes in [Universal Attributes](js-components-common-at -## Style +## Styles Styles in [Universal Styles](js-components-common-styles.md) are supported. -## Event +## Events In addition to the events in [Universal Events](js-components-common-events.md), the following events are supported. @@ -239,7 +239,7 @@ In addition to the events in [Universal Events](js-components-common-events.md) -## Method +## Methods In addition to the methods in [Universal Methods](js-components-common-methods.md), the following events are supported. diff --git a/en/application-dev/reference/arkui-js/js-components-basic-image.md b/en/application-dev/reference/arkui-js/js-components-basic-image.md index 6930c23b215667a05ab583aef8a8927d1bacc6d4..a2b12f6effff89978040365e49b0ee16c8084433 100644 --- a/en/application-dev/reference/arkui-js/js-components-basic-image.md +++ b/en/application-dev/reference/arkui-js/js-components-basic-image.md @@ -6,7 +6,7 @@ The **** component is used to render and display images. Not supported -## Attribute +## Attributes In addition to the attributes in [Universal Attributes](js-components-common-attributes.md), the following attributes are supported. @@ -50,7 +50,7 @@ In addition to the attributes in [Universal Attributes](js-components-common-at -## Style +## Styles In addition to the styles in [Universal Styles](js-components-common-styles.md), the following style attributes are supported. @@ -109,7 +109,7 @@ In addition to the styles in [Universal Styles](js-components-common-styles.md)

No

Position of an image in the component.

-

The options are as follows:

+

There are two setting types:

1. Pixels. For example, 15px 15px indicates the moving position along the x-axis or y-axis.

2. Characters. Optional values are as follows:

  • left: The image is displayed on the left of the component.
  • top The image is displayed on the top of the component.
  • right The image is displayed on the right of the component.
  • bottom The image is displayed at the bottom of the component.
@@ -129,7 +129,7 @@ In addition to the styles in [Universal Styles](js-components-common-styles.md)

cover

-

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

+

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

contain

@@ -163,7 +163,7 @@ In addition to the styles in [Universal Styles](js-components-common-styles.md) >1. If the **** component is too small to afford the SVG image, the SVG image is cropped and only its upper left part is displayed in the component. >2. If the **** component is big enough to afford the SVG image, this SVG image is displayed in the upper left corner of the component. -## Event +## Events In addition to the events in [Universal Events](js-components-common-events.md), the following events are supported. @@ -193,7 +193,7 @@ In addition to the events in [Universal Events](js-components-common-events.md) -## Method +## Methods Methods in [Universal Methods](js-components-common-methods.md) are supported. @@ -202,7 +202,7 @@ Methods in [Universal Methods](js-components-common-methods.md) are supported. ```
- + + +
``` @@ -545,6 +548,8 @@ In addition to the methods in [Universal Methods](js-components-common-methods. .content{ width: 100%; height: 200px; + + align-items: center; justify-content: center; } @@ -563,7 +568,7 @@ In addition to the methods in [Universal Methods](js-components-common-methods. } ``` - ![](figures/1-35.png) + ![](figures/en-us_image_0000001173324749.png) 4. Radio button @@ -601,6 +606,5 @@ In addition to the methods in [Universal Methods](js-components-common-methods. } ``` - ![](figures/1-36.png) - + ![](figures/1-3.png) diff --git a/en/application-dev/reference/arkui-js/js-components-basic-label.md b/en/application-dev/reference/arkui-js/js-components-basic-label.md index 6ede9ae8d3e11d7ede0adbe45f10e08658e709af..5e80973d014fa5c07630312c3ab44efbef7dfa00 100644 --- a/en/application-dev/reference/arkui-js/js-components-basic-label.md +++ b/en/application-dev/reference/arkui-js/js-components-basic-label.md @@ -2,7 +2,7 @@ The **** component defines labels for the ****, ****, and **** components. When a label is clicked, the click effect of the component associated with the label will be triggered. -## Permission List +## Required Permissions None @@ -10,7 +10,7 @@ None Not supported -## Attribute +## Attributes In addition to the attributes in [Universal Attributes](js-components-common-attributes.md), the following attributes are supported. @@ -41,7 +41,7 @@ In addition to the attributes in [Universal Attributes](js-components-common-at -## Style +## Styles In addition to the styles in [Universal Styles](js-components-common-styles.md), the following styles are supported. @@ -138,7 +138,7 @@ In addition to the styles in [Universal Styles](js-components-common-styles.md)

No

-

Text modifier. Available values are as follows:

+

Text decoration. Available values are as follows:

  • underline: An underline is used.
  • line-through: A strikethrough is used.
  • none: The standard text is used.
@@ -249,11 +249,11 @@ In addition to the styles in [Universal Styles](js-components-common-styles.md) -## Event +## Events Not supported -## Method +## Methods Not supported diff --git a/en/application-dev/reference/arkui-js/js-components-basic-marquee.md b/en/application-dev/reference/arkui-js/js-components-basic-marquee.md index f5ff2c0c4be5fdb54a5d925802e4b8c666d34670..6f8ba597ae293c90835bc5d867ebcb91eaa733ab 100644 --- a/en/application-dev/reference/arkui-js/js-components-basic-marquee.md +++ b/en/application-dev/reference/arkui-js/js-components-basic-marquee.md @@ -2,7 +2,7 @@ The **** component displays single-line scrolling text. -## Permission List +## Required Permissions None @@ -10,7 +10,7 @@ None Not supported -## Attribute +## Attributes In addition to the attributes in [Universal Attributes](js-components-common-attributes.md), the following attributes are supported. @@ -63,7 +63,7 @@ In addition to the attributes in [Universal Attributes](js-components-common-at -## Style +## Styles In addition to the styles in [Universal Styles](js-components-common-styles.md), the following styles are supported. @@ -140,7 +140,7 @@ In addition to the styles in [Universal Styles](js-components-common-styles.md) -## Event +## Events In addition to the events in [Universal Events](js-components-common-events.md), the following events are supported. @@ -177,7 +177,7 @@ In addition to the events in [Universal Events](js-components-common-events.md) -## Method +## Methods In addition to the methods in [Universal Methods](js-components-common-methods.md), the following events are supported. diff --git a/en/application-dev/reference/arkui-js/js-components-basic-menu.md b/en/application-dev/reference/arkui-js/js-components-basic-menu.md index e07eda729e37f98e21c2e65091a399cdfcfaadfa..df66f67344b190d29efd85f32f0965cbf1d7cf8a 100644 --- a/en/application-dev/reference/arkui-js/js-components-basic-menu.md +++ b/en/application-dev/reference/arkui-js/js-components-basic-menu.md @@ -2,15 +2,15 @@ The **** component provides menus as temporary pop-up windows to display operations that can be performed by users. -## Permission List +## Required Permissions None -## Child Component +## Child Components **[](js-components-basic-option.md)** -## Attribute +## Attributes In addition to the attributes in [Universal Attributes](js-components-common-attributes.md), the following attributes are supported. @@ -65,9 +65,9 @@ In addition to the attributes in [Universal Attributes](js-components-common-at >![](../../public_sys-resources/icon-note.gif) **NOTE:** ->- The **focusable** and **disabled** attributes are not supported. +>The **focusable** and **disabled** attributes are not supported. -## Style +## Styles Only the following style attributes are supported. @@ -166,7 +166,7 @@ Only the following style attributes are supported. -## Event +## Events The following events are supported. @@ -196,7 +196,7 @@ The following events are supported. -## Method +## Methods The following methods are supported. diff --git a/en/application-dev/reference/arkui-js/js-components-basic-option.md b/en/application-dev/reference/arkui-js/js-components-basic-option.md index f91824ecc36f62eb729d00c2a10d1545138c48da..83388a50a23690426b0f36f403900790b4f14d16 100644 --- a/en/application-dev/reference/arkui-js/js-components-basic-option.md +++ b/en/application-dev/reference/arkui-js/js-components-basic-option.md @@ -12,7 +12,7 @@ None None -## Attribute +## Attributes In addition to the attributes in [Universal Attributes](js-components-common-attributes.md), the following attributes are supported. @@ -48,7 +48,7 @@ In addition to the attributes in [Universal Attributes](js-components-common-at

Yes

-

Value of an option, which is used as the returned value of the selected event of the <select>or <menu> parent component.

+

Value of an option, which is used as the return value of the selected event of the <select>or <menu> parent component.

NOTE:

The option value to be displayed on the UI must be put between the start and end tags, for example, <option value="10">October</option>.

@@ -67,7 +67,7 @@ In addition to the attributes in [Universal Attributes](js-components-common-at -## Style +## Styles The following style attributes are supported. @@ -155,11 +155,11 @@ The following style attributes are supported. -## Event +## Events None -## Method +## Methods None diff --git a/en/application-dev/reference/arkui-js/js-components-basic-picker-view.md b/en/application-dev/reference/arkui-js/js-components-basic-picker-view.md index efc1c9f7b3368973322b763d2468d4c1fe750ad9..358309449063dab4098feb7ee2b00d2522d62a8b 100644 --- a/en/application-dev/reference/arkui-js/js-components-basic-picker-view.md +++ b/en/application-dev/reference/arkui-js/js-components-basic-picker-view.md @@ -2,11 +2,11 @@ The **** component provides the view that shows an embedded scrollable selector on the screen. -## Child Component +## Child Components Not supported -## Attribute +## Attributes In addition to the attributes in [Universal Attributes](js-components-common-attributes.md), the following attributes are supported. @@ -62,7 +62,7 @@ Text selector \(**type** is **text**\)

No

Value range of the text selector.

-
NOTE:

Use the data binding mode, for example, range = {{data}}. Declare the corresponding variable data: ["15", "20", "25"] in the JavaScript.

+
NOTE:

Use the data binding mode, for example, range = {{data}}. Declare the corresponding variable data: ["15", "20", "25"] in JavaScript.

@@ -269,7 +269,7 @@ Date and time selector \(**type** is **datetime**\)

No

Time format used by the date and time selector. Available values include:

-
  • 12: displayed in 12-hour format and distinguished by a.m. and p.m.
  • 24: displayed in 24-hour format
    NOTE:

    The default value is the most commonly-used hour format in the current locale. 5+

    +
    • 12: displayed in 12-hour format and distinguished by a.m. and p.m.
    • 24: displayed in 24-hour format
      NOTE:

      The default value is the most commonly-used hour format in the current locale. 5+

    @@ -354,7 +354,7 @@ Multi-column text selector \(**type** is **multi-text**\) -## Style +## Styles In addition to the styles in [Universal Styles](js-components-common-styles.md), the following styles are supported. @@ -449,13 +449,13 @@ In addition to the styles in [Universal Styles](js-components-common-styles.md)

    No

    -

    Font type of an item. Font family, in which fonts are separated by commas (,). Each font is set using a font name or font family name. The first font in the family or the font specified in Custom Font Styles is used for the text

    +

    Font type of an item. Font family, in which fonts are separated by commas (,). Each font is set using a font name or font family name. The first font in the family or the font specified by Custom Font Styles is used for the text

    -## Event +## Events The following events are supported. @@ -565,7 +565,7 @@ Multi-text selector \(**type** is **multi-text**\) -## Method +## Methods Not supported @@ -633,5 +633,5 @@ export default { } ``` -![](figures/lite_bar-37.png) +![](figures/lite_bar-4.png) diff --git a/en/application-dev/reference/arkui-js/js-components-basic-picker.md b/en/application-dev/reference/arkui-js/js-components-basic-picker.md index e4367418b882f971609370677995b3305da313e0..1b161a67e12f80fd51410ad89adebb737ca4db91 100644 --- a/en/application-dev/reference/arkui-js/js-components-basic-picker.md +++ b/en/application-dev/reference/arkui-js/js-components-basic-picker.md @@ -42,7 +42,9 @@ In addition to the attributes in [Universal Attributes](js-components-common-at -Common selector \(type is **text**\) +### Text Selector + +When **type** is set to **text**, a text selector is used.

    Name

    @@ -95,7 +97,9 @@ Common selector \(type is **text**\)
    -Date selector \(type is **date**\) +### Date Selector + +When **type** is set to **date**, a date selector is used.

    Name

    @@ -181,7 +185,9 @@ Date selector \(type is **date**\)
    -Time selector \(**type** is **time**\) +### Time Selector + +When **type** is set to **time**, a time selector is used. -

    Name

    @@ -215,7 +221,7 @@ Time selector \(**type** is **time**\)

    No

    Default value of the time selector, in format of HH:mm. If seconds are contained, the format is HH:mm:ss.

    +

    Default value of the time selector, in the format of HH:mm. If seconds are contained, the format is HH:mm:ss.

    value

    @@ -247,7 +253,9 @@ Time selector \(**type** is **time**\)
    -Date and time selector \(type is **datetime**\) +### Date and Time Selector + +When **type** is set to **datetime**, a date and time selector is used. - @@ -326,7 +336,9 @@ Date and time selector \(type is **datetime**\)

    Name

    @@ -270,7 +278,9 @@ Date and time selector \(type is **datetime**\)

    No

    Default value of the date and time selector. The value can be in the format of MM-DD-HH-mm or YYYY-MM-DD-HH-mm. If the year is not set, the current year is used by default. The value you set is the date selected by default in the pop-up window.

    +

    Default value of the date and time selector. The value can be in either of the following formats:

    +
    • MM-DD-HH-mm
    • YYYY-MM-DD-HH-mm
    +

    If the year is not set, the current year is used by default. The value you set is the date selected by default in the pop-up window.

    value

    @@ -294,7 +304,7 @@ Date and time selector \(type is **datetime**\)

    No

    Time format used by the date and time selector. Available values include:

    -
    • 12: displayed in 12-hour format and distinguished by a.m. and p.m.
    • 24: displayed in 24-hour format
      NOTE:

      The default value is the most commonly-used hour format in the current locale. 5+

      +
      • 12: displayed in 12-hour format and distinguished by a.m. and p.m.
      • 24: displayed in 24-hour format
        NOTE:

        The default value is the most commonly-used hour format in the current locale. 5+

    -Multi-column text selector \(type is **multi-text**\) +### Multi-Column Text Selector + +When **type** is set to **multi-text**, a multi-column text selector is used.

    Name

    @@ -390,7 +402,7 @@ Multi-column text selector \(type is **multi-text**\)
    -## Style +## Styles In addition to the styles in [Universal Styles](js-components-common-styles.md), the following styles are supported. @@ -524,11 +536,11 @@ In addition to the styles in [Universal Styles](js-components-common-styles.md) -## Event +## Events In addition to the events in [Universal Events](js-components-common-events.md), the following events are supported. -Common selector \(type is **text**\) +### Common Selector - @@ -556,7 +568,7 @@ Common selector \(type is **text**\)

    Name

    @@ -541,7 +553,7 @@ Common selector \(type is **text**\)

    change

    { newValue:newValue, newSelected:newSelected }

    +

    { newValue: newValue, newSelected: newSelected }

    Triggered when a value is selected and the OK button is clicked in the displayed pop-up window. newSelected is the index.

    -Date selector \(type is **date**\) +### Date Selector -

    Name

    @@ -569,7 +581,7 @@ Date selector \(type is **date**\)

    change

    { year:year, month:month, day:day }

    +

    { year: year, month: month, day: day }

    Triggered when a value is selected and the OK button is clicked in the displayed pop-up window.

    NOTE:

    The value of month ranges from 0 (January) to 11 (December). 5+

    @@ -586,7 +598,7 @@ Date selector \(type is **date**\)
    -Date and time selector \(type is **datetime**\) +### Date and Time Selector - @@ -614,7 +626,7 @@ Date and time selector \(type is **datetime**\)

    Name

    @@ -599,7 +611,7 @@ Date and time selector \(type is **datetime**\)

    change

    { year:year, month:month, day:day, hour:hour, minute:minute}

    +

    { year: year, month: month, day: day, hour: hour, minute: minute}

    Triggered when a value is selected and the OK button is clicked in the displayed pop-up window.

    -Time selector \(type is **time**\) +### Time Selector - @@ -643,7 +654,7 @@ Time selector \(type is **time**\)

    Name

    @@ -627,8 +639,7 @@ Time selector \(type is **time**\)

    change

    { hour:hour, minute:minute,

    -

    [second:second] }

    +

    { hour: hour, minute: minute, [second: second] }

    Triggered when a value is selected and the OK button is clicked in the displayed pop-up window. If containsecond is set to true, value contains seconds.

    -Multi-column text selector \(type is **multi-text**\) +### Multi-Column Text Selector - - - @@ -680,7 +691,7 @@ Multi-column text selector \(type is **multi-text**\)

    Name

    @@ -656,7 +667,7 @@ Multi-column text selector \(type is **multi-text**\)

    change

    {newValue:[newValue1, newValue2, newValue3, ...], newSelected:[newSelected1, newSelected2, newSelected3, ...]}

    +

    { newValue: [newValue1, newValue2, newValue3, …], newSelected:[newSelected1, newSelected2, newSelected3, …] }

    Triggered when an item is selected and the OK button is clicked in the displayed pop-up window.

    • newValue is an array consisting of the values of the selected items.
    • newSelected is an array consisting of the indexes of the selected items. The lengths of newValue and newSelected are the same as the length of range.
    @@ -664,9 +675,9 @@ Multi-column text selector \(type is **multi-text**\)

    columnchange

    { column:column, newValue:newValue, newSelected:newSelected }

    +

    { column: column, newValue: newValue, newSelected: newSelected }

    Triggered when the value of a column in the multi-column text selector changes.

    +

    Triggered when the value of a column in the multi-column selector changes.

    • column indicates the column whose value has changed.
    • newValue indicates the selected value.
    • newSelected indicates the index of the selected value.
    -## Method +## Methods In addition to the methods in [Universal Methods](js-components-common-methods.md), the following events are supported. @@ -708,20 +719,25 @@ In addition to the methods in [Universal Methods](js-components-common-methods. ```
    - + + - + - + - + - +
    ``` @@ -732,28 +748,23 @@ In addition to the methods in [Universal Methods](js-components-common-methods. justify-content: center; align-items: center; } -.pickertext{ - background-color: red; - width: 300; - height: 400; -} -.pickerdate{ - background-color: #BEFF5B; - width: 200; - height: 200; -} -.pickertime{ - background-color: #B764FF; - width: 500; - height: 200; + picker{ + width:60%; + height:80px; + border-radius:20px; + text-color:white; + font-size:15px; + background-color:#4747e3; + margin-left:20%; } -.pickerdatetime{ - background-color: #FF6387; - width: 100%; - height: 300; -} -.pickermuitl{ - background-color: #71FF31; + select{ + background-color: #efecec; + height: 50px; + width: 60%; + margin-left: 20%; + margin-top: 300px; + margin-bottom: 50px; + font-size: 22px; } ``` @@ -763,6 +774,7 @@ import router from '@system.router'; import prompt from '@system.prompt'; export default { data: { + selectList:["text","data","time","datetime","multitext"], rangetext:['15', "20", "25"], multitext:[["a", "b", "c"], ["e", "f", "g"], ["h", "i"], ["k", "l", "m"]], textvalue:'default textvalue', @@ -777,6 +789,13 @@ export default { dateselect:'2021-3-2', textselect:'2' }, + selectChange(e){ + for(let i = 0;i -![](figures/text.png "text") - -**Figure 2** date - - -![](figures/label.png) - -**Figure 3** time -![](figures/time.png "time") - -**Figure 4** datetime -![](figures/datetime.png "datetime") - -**Figure 5** multitext -![](figures/multitext.png "multitext") +![](figures/mmmm.gif) diff --git a/en/application-dev/reference/arkui-js/js-components-basic-piece.md b/en/application-dev/reference/arkui-js/js-components-basic-piece.md index d494e7ce7d430ae00cf1dbf808073453dfa879a8..a0f82135098fa7d891d164332e8e9670361857f5 100644 --- a/en/application-dev/reference/arkui-js/js-components-basic-piece.md +++ b/en/application-dev/reference/arkui-js/js-components-basic-piece.md @@ -2,14 +2,11 @@ An entrance piece that can contain images and text. It is usually used to display receivers, for example, email recipients or message recipients. ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->This component is supported since API version 5. - ## Child Component None -## Attribute +## Attributes In addition to the attributes in [Universal Attributes](js-components-common-attributes.md), the following attributes are supported. @@ -62,14 +59,14 @@ In addition to the attributes in [Universal Attributes](js-components-common-at -## Style +## Styles Styles in [Universal Styles](js-components-common-styles.md) are supported. >![](../../public_sys-resources/icon-note.gif) **NOTE:** >By default, text and images are placed in the middle of the **** component. -## Event +## Events In addition to the events in [Universal Events](js-components-common-events.md), the following events are supported. @@ -100,12 +97,22 @@ Methods in [Universal Methods](js-components-common-methods.md) are supported. ``` -
    - - +
    + +
    ``` +``` +/* xxx.css */ +.container { + width: 100%; + height: 100%; + align-items: center; + justify-content: center; +} +``` + ``` // xxx.js export default { @@ -119,5 +126,5 @@ export default { } ``` -![](figures/1-38.gif) +![](figures/11-5.gif) diff --git a/en/application-dev/reference/arkui-js/js-components-basic-progress.md b/en/application-dev/reference/arkui-js/js-components-basic-progress.md index 1936578a6c4fcb9bc9ce3fa87c1b080b8956c32c..028d76beac9ed2cb87ecd7a81b6593d6f4bdb4f1 100644 --- a/en/application-dev/reference/arkui-js/js-components-basic-progress.md +++ b/en/application-dev/reference/arkui-js/js-components-basic-progress.md @@ -2,15 +2,15 @@ The **** component is used to provide a progress bar that displays the progress of content loading or operation processing. -## Permission List +## Required Permissions None -## Child Component +## Child Components Not supported -## Attribute +## Attributes In addition to the attributes in [Universal Attributes](js-components-common-attributes.md), the following attributes are supported. @@ -143,7 +143,7 @@ Different types of progress bars support different attributes. -## Style +## Styles In addition to the styles in [Universal Styles](js-components-common-styles.md), the following styles are supported. @@ -475,11 +475,11 @@ type=eclipse5+ -## Event +## Events Events in [Universal Events](js-components-common-events.md) are supported. -## Method +## Methods Methods in [Universal Methods](js-components-common-methods.md) are supported. diff --git a/en/application-dev/reference/arkui-js/js-components-basic-qrcode.md b/en/application-dev/reference/arkui-js/js-components-basic-qrcode.md index 318aa95de379c251f92b71f6c519151857d22567..2c353515b816e544af9948e162a9b18d1aefb815 100644 --- a/en/application-dev/reference/arkui-js/js-components-basic-qrcode.md +++ b/en/application-dev/reference/arkui-js/js-components-basic-qrcode.md @@ -2,18 +2,15 @@ The **** component is used to generate and display a QR code. ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->This component is supported since API version 5. - -## Permission List +## Required Permissions None -## Child Component +## Child Components Not supported -## Attribute +## Attributes In addition to the attributes in [Universal Attributes](js-components-common-attributes.md), the following attributes are supported. @@ -56,7 +53,7 @@ In addition to the attributes in [Universal Attributes](js-components-common-at -## Style +## Styles In addition to the styles in [Universal Styles](js-components-common-styles.md), the following styles are supported. @@ -102,17 +99,82 @@ In addition to the styles in [Universal Styles](js-components-common-styles.md) >- If the values of **width** and **height** are different, the smaller value is used as the length of the QR code. The generated QR code is center displayed. >- If either **width** or **height** is set, the value is used as the length of the QR code. If neither of them is set, the default length is 200 px. -## Event +## Events Events in [Universal Events](js-components-common-events.md) are supported. -## Method +## Methods Methods in [Universal Methods](js-components-common-methods.md) are supported. ## Example ``` - + +
    + + Type + + Color + + Background Color + +
    +``` + +``` +/* xxx.css */ +.container { + width: 100%; + height: 100%; + flex-direction: column; + justify-content: center; + align-items: center; +} +.txt { + margin: 30px; + color: orangered; +} +select{ + margin-top: 40px; + margin-bottom: 40px; +} ``` +``` +/* index.js */ +export default { + data: { + qr_type: 'rect', + qr_size: '300px', + qr_col: '#87ceeb', + col_list: ['#87ceeb','#fa8072','#da70d6','#80ff00ff','#00ff00ff'], + qr_bcol: '#f0ffff', + bcol_list: ['#f0ffff','#ffffe0','#d8bfd8'] + }, + settype(e) { + if (e.checked) { + this.qr_type = 'rect' + } else { + this.qr_type = 'circle' + } + }, + setvalue(e) { + this.qr_value = e.newValue + }, + setcol(e) { + this.qr_col = e.newValue + }, + setbcol(e) { + this.qr_bcol = e.newValue + } +} +``` + +![](figures/12.gif) + diff --git a/en/application-dev/reference/arkui-js/js-components-basic-rating.md b/en/application-dev/reference/arkui-js/js-components-basic-rating.md index 1c86e8a8a6828c6c7f00bb74a7e6db8fa903cf08..35811a0973e287b7a3487b209e0c09a5a0f1c769 100644 --- a/en/application-dev/reference/arkui-js/js-components-basic-rating.md +++ b/en/application-dev/reference/arkui-js/js-components-basic-rating.md @@ -6,11 +6,11 @@ The **** component provides a rating bar used for reviews and ratings None -## Child Component +## Child Components Not supported -## Attribute +## Attributes In addition to the attributes in [Universal Attributes](js-components-common-attributes.md), the following attributes are supported. @@ -76,7 +76,7 @@ In addition to the attributes in [Universal Attributes](js-components-common-at -## Style +## Styles In addition to the styles in [Universal Styles](js-components-common-styles.md), the following styles are supported. @@ -130,8 +130,8 @@ In addition to the styles in [Universal Styles](js-components-common-styles.md)

    <length>|<percentage>

    -

    120px

    -

    60px (cannot be edited)

    +

    120 px

    +

    60 px (cannot be edited)

    No

    @@ -167,7 +167,7 @@ In addition to the styles in [Universal Styles](js-components-common-styles.md) >![](../../public_sys-resources/icon-note.gif) **NOTE:** >You must set **star-background**, **star-secondary**, and **star-foreground**. Otherwise, the rating star is gray, indicating that the image is set incorrectly. -## Event +## Events In addition to the events in [Universal Events](js-components-common-events.md), the following events are supported. @@ -190,7 +190,7 @@ In addition to the events in [Universal Events](js-components-common-events.md) -## Method +## Methods Methods in [Universal Methods](js-components-common-methods.md) are supported. @@ -228,5 +228,5 @@ export default { } ``` -![](figures/1-39.png) +![](figures/1-6.png) diff --git a/en/application-dev/reference/arkui-js/js-components-basic-richtext.md b/en/application-dev/reference/arkui-js/js-components-basic-richtext.md index 612333d4632a71cfd382bce358ccaa8da6c0fb5e..fa545f20b86fae7827cb69bd5634a9495733cb07 100644 --- a/en/application-dev/reference/arkui-js/js-components-basic-richtext.md +++ b/en/application-dev/reference/arkui-js/js-components-basic-richtext.md @@ -3,22 +3,21 @@ The **** component displays rich text information. >![](../../public_sys-resources/icon-note.gif) **NOTE:** ->- This component is supported since API version 6. >- The rich text content must be written in the content area. ## Required Permissions None -## Attribute +## Attributes Only the **id**, **style**, and **class** attributes in [Universal Attributes](js-components-common-attributes.md) are supported. -## Style +## Styles Only the **display** and** visibility** styles in [Universal Styles](js-components-common-styles.md) are supported. -## Event +## Events In addition to the events in [Universal Events](js-components-common-events.md), the following events are supported. @@ -53,8 +52,9 @@ In addition to the events in [Universal Events](js-components-common-events.md) >- Accessibility events are not supported. >- When a page containing **** is returned, the page's transition effect does not apply to the area where the rich text is displayed. >- Make sure the rich text does not go beyond the height of the screen. Otherwise, the excess content will not be displayed. +>- The width cannot be set. By default, the rich text is displayed in full screen. -## Method +## Methods Not supported diff --git a/en/application-dev/reference/arkui-js/js-components-basic-search.md b/en/application-dev/reference/arkui-js/js-components-basic-search.md index 594dcd9eb63a25efae0b4654898286e7157fd9d8..d820d195a41793f22a648b81e1cb9c09346c66eb 100644 --- a/en/application-dev/reference/arkui-js/js-components-basic-search.md +++ b/en/application-dev/reference/arkui-js/js-components-basic-search.md @@ -2,11 +2,11 @@ The **** component provides an input area for users to search. -## Child Component +## Child Components Not supported -## Attribute +## Attributes In addition to the attributes in [Universal Attributes](js-components-common-attributes.md), the following attributes are supported. @@ -84,7 +84,7 @@ In addition to the attributes in [Universal Attributes](js-components-common-at **Table 1** MenuOption5+ -

    Method

    + @@ -109,7 +109,7 @@ In addition to the attributes in [Universal Attributes](js-components-common-at

    Name

    Type

    -## Style +## Styles In addition to the styles in [Universal Styles](js-components-common-styles.md), the following styles are supported. @@ -208,7 +208,7 @@ In addition to the styles in [Universal Styles](js-components-common-styles.md)
    -## Event +## Events In addition to the events in [Universal Events](js-components-common-events.md), the following events are supported. @@ -268,7 +268,7 @@ In addition to the events in [Universal Events](js-components-common-events.md) -## Method +## Methods Methods in [Universal Methods](js-components-common-methods.md) are supported. diff --git a/en/application-dev/reference/arkui-js/js-components-basic-select.md b/en/application-dev/reference/arkui-js/js-components-basic-select.md index d6725e761627bb6f66ebe83f18e31bafed7cb2ee..98b7075a6b76bf36a92f480f5b897bef73f42939 100644 --- a/en/application-dev/reference/arkui-js/js-components-basic-select.md +++ b/en/application-dev/reference/arkui-js/js-components-basic-select.md @@ -2,7 +2,7 @@ The **** component provides a drop-down list that allows users to select among multiple options. -## Permission List +## Required Permissions None @@ -10,11 +10,11 @@ None The **<[option](js-components-basic-option.md)\>** child component is supported. -## Attribute +## Attributes Attributes in [Universal Attributes](js-components-common-attributes.md) are supported. -## Style +## Styles In addition to the styles in [Universal Styles](js-components-common-styles.md), the following styles are supported. @@ -45,7 +45,7 @@ In addition to the styles in [Universal Styles](js-components-common-styles.md) -## Event +## Events In addition to the events in [Universal Events](js-components-common-events.md), the following events are supported. diff --git a/en/application-dev/reference/arkui-js/js-components-basic-slider.md b/en/application-dev/reference/arkui-js/js-components-basic-slider.md index a519857dfe2c13a3e70b9aa83799b52486c89f25..314f192543e46dc0977954acd373b29958721c58 100644 --- a/en/application-dev/reference/arkui-js/js-components-basic-slider.md +++ b/en/application-dev/reference/arkui-js/js-components-basic-slider.md @@ -6,7 +6,7 @@ The **** component is used to quickly adjust settings, such as volume Not supported -## Attribute +## Attributes In addition to the attributes in [Universal Attributes](js-components-common-attributes.md), the following attributes are supported. @@ -110,7 +110,7 @@ In addition to the attributes in [Universal Attributes](js-components-common-at -## Style +## Styles In addition to the styles in [Universal Styles](js-components-common-styles.md), the following styles are supported. @@ -165,7 +165,7 @@ In addition to the styles in [Universal Styles](js-components-common-styles.md) -## Event +## Events In addition to the events in [Universal Events](js-components-common-events.md), the following events are supported. @@ -240,7 +240,7 @@ In addition to the events in [Universal Events](js-components-common-events.md) slider start value is {{startValue}} slider current value is {{currentValue}} slider end value is {{endValue}} - +
    ``` @@ -250,6 +250,8 @@ In addition to the events in [Universal Events](js-components-common-events.md) flex-direction: column; justify-content: center; align-items: center; + + } ``` @@ -277,5 +279,5 @@ export default { } ``` -![](figures/progress-40.png) +![](figures/slider.png) diff --git a/en/application-dev/reference/arkui-js/js-components-basic-span.md b/en/application-dev/reference/arkui-js/js-components-basic-span.md index 9754ac97000fee403b39aea45461085e7d28454b..c33bb40994c5be909bdcd271db9ce3565eb3e393 100644 --- a/en/application-dev/reference/arkui-js/js-components-basic-span.md +++ b/en/application-dev/reference/arkui-js/js-components-basic-span.md @@ -2,22 +2,22 @@ The **** child component of **<[text](js-components-basic-text.md)\>** is used as a text modifier. -## Permission List +## Required Permissions None -## Child Component +## Child Components The **** child component is supported. -## Attribute +## Attributes Attributes in [Universal Attributes](js-components-common-attributes.md) are supported. >![](../../public_sys-resources/icon-note.gif) **NOTE:** ->- The **focusable** and **disabled** attributes are not supported. +>The **focusable** and **disabled** attributes are not supported. -## Style +## Styles Only the following style attributes are supported. @@ -116,7 +116,7 @@ Only the following style attributes are supported. -## Event +## Events Only the click event in [Universal Events](js-components-common-events.md) is supported. diff --git a/en/application-dev/reference/arkui-js/js-components-basic-switch.md b/en/application-dev/reference/arkui-js/js-components-basic-switch.md index 3d8f4a56022e75801e679fdeb7c3e60c6e8b5ac3..4c987aa9bf516b5d735821248f86f8983ba073b4 100644 --- a/en/application-dev/reference/arkui-js/js-components-basic-switch.md +++ b/en/application-dev/reference/arkui-js/js-components-basic-switch.md @@ -2,7 +2,7 @@ The **** component is used to enable or disable a function. -## Permission List +## Required Permissions None @@ -10,7 +10,7 @@ None None -## Attribute +## Attributes In addition to the attributes in [Universal Attributes](js-components-common-attributes.md), the following attributes are supported. @@ -74,7 +74,7 @@ In addition to the attributes in [Universal Attributes](js-components-common-at -## Style +## Styles In addition to the styles in [Universal Styles](js-components-common-styles.md), the following styles are supported. @@ -143,7 +143,7 @@ In addition to the styles in [Universal Styles](js-components-common-styles.md)

    No

    -

    Whether the font size changes following the system's font size settings.

    +

    Whether the font size changes with the system's font size settings.

    NOTE:

    If the config-changes tag of fontSize is configured for abilities in the config.json file, the setting takes effect without application restart.

    @@ -184,7 +184,7 @@ In addition to the styles in [Universal Styles](js-components-common-styles.md) -## Event +## Events In addition to the events in [Universal Events](js-components-common-events.md), the following events are supported. diff --git a/en/application-dev/reference/arkui-js/js-components-basic-text.md b/en/application-dev/reference/arkui-js/js-components-basic-text.md index 1c7e3e0facabba2debb3dc17457f4c2399f93216..683c27d7138bc1e9c0c59251b55dc0bcc68e10b8 100644 --- a/en/application-dev/reference/arkui-js/js-components-basic-text.md +++ b/en/application-dev/reference/arkui-js/js-components-basic-text.md @@ -3,9 +3,9 @@ The **** component is used to display a piece of textual information. >![](../../public_sys-resources/icon-note.gif) **NOTE:** ->The text content must be written in the content area. +>- The text content must be written in the content area. -## Permission List +## Required Permissions None @@ -13,11 +13,11 @@ None **<[span](js-components-basic-span.md)\>** is supported. -## Attribute +## Attributes Attributes in [Universal Attributes](js-components-common-attributes.md) are supported. -## Style +## Styles In addition to the styles in [Universal Styles](js-components-common-styles.md), the following styles are supported. @@ -64,7 +64,7 @@ In addition to the styles in [Universal Styles](js-components-common-styles.md)

    No

    -

    Whether the font size changes following the system's font size settings.

    +

    Whether the font size changes with the system's font size settings.

    NOTE:

    For details about how to make the configuration take effect dynamically, see the config-changes attribute in the config.json file.

    @@ -126,7 +126,7 @@ In addition to the styles in [Universal Styles](js-components-common-styles.md)

    No

    -

    Text modifier. Available values are as follows:

    +

    Text decoration. Available values are as follows:

    • underline: An underline is used.
    • line-through: A strikethrough is used.
    • none: The standard text is used.
    @@ -138,7 +138,7 @@ In addition to the styles in [Universal Styles](js-components-common-styles.md)

    No

    -

    Color of the text modifier.

    +

    Color of the text decoration.

    text-align

    @@ -199,7 +199,7 @@ In addition to the styles in [Universal Styles](js-components-common-styles.md)

    No

    -

    Maximum number of text lines. The value is of the string type. The options are as follows:

    +

    Maximum number of text lines. The string values are as follows:

    • auto7+: The number of text lines adapts to the container height.
    @@ -222,7 +222,7 @@ In addition to the styles in [Universal Styles](js-components-common-styles.md)

    No

    -

    Maximum font size in the text. This style must be used together with min-font-size. The font size can be changed dynamically. After the maximum and minimum font sizes are set, font-size does not take effect.

    +

    Maximum font size in the text. This style must be used together with min-font-size. The font size can be changed dynamically. After the maximum and minimum font sizes are set, font-size does not take effect.

    font-size-step

    @@ -280,7 +280,7 @@ In addition to the styles in [Universal Styles](js-components-common-styles.md)

    No

    Mode for processing blanks in the component. The options are as follows:

    -
    • normal: All spaces, carriage returns, and tabs are combined into one space, and the text is automatically wrapped.
    • nowrap: All spaces, carriage returns, and tabs are combined into one space, and the text is not wrapped.
    • pre: All contents are output as-is without line breaks.
    • pre-wrap: All contents are output as-is with line breaks.
    • pre-line: All spaces and tabs are combined into one space, the carriage return remains unchanged, and the text is wrapped.
    +
    • normal: All spaces, carriage returns, and tabs are combined into one space, and the text is automatically wrapped.
    • nowrap: All spaces, carriage returns, and tabs are combined into one space, and the text is not wrapped.
    • pre: All contents are output as-is.
    • pre-wrap: All contents are output as-is with line breaks.
    • pre-line: All spaces and tabs are combined into one space, the carriage return remains unchanged, and the text is wrapped.

    adapt-height7+

    @@ -307,7 +307,7 @@ In addition to the styles in [Universal Styles](js-components-common-styles.md) >- The **letter-spacing**, **text-align**, **line-height**, **text-overflow**, and **max-lines** styles take effect on text content held by the **** component and its child components \(****\). >- The **** component does not support the coexistence of the text content and **** subcomponents. \(If both of them exist, only the content in **** is displayed.\) -## Event +## Events Events in [Universal Events](js-components-common-events.md) are supported. @@ -362,7 +362,7 @@ export default { } ``` -![](figures/3-41.png) +![](figures/3.png) ``` @@ -401,5 +401,5 @@ export default { } ``` -![](figures/2-42.png) +![](figures/2.png) diff --git a/en/application-dev/reference/arkui-js/js-components-basic-textarea.md b/en/application-dev/reference/arkui-js/js-components-basic-textarea.md index 89341b87ad5cdd49392347b41b3cd6fb5e280f3c..7b872f13e96e9a35eea2717b64a84265f24fa48a 100644 --- a/en/application-dev/reference/arkui-js/js-components-basic-textarea.md +++ b/en/application-dev/reference/arkui-js/js-components-basic-textarea.md @@ -10,7 +10,7 @@ None Not supported -## Attribute +## Attributes In addition to the attributes in [Universal Attributes](js-components-common-attributes.md), the following attributes are supported. @@ -179,7 +179,7 @@ In addition to the attributes in [Universal Attributes](js-components-common-at -## Style +## Styles In addition to the styles in [Universal Styles](js-components-common-styles.md), the following styles are supported. @@ -278,7 +278,7 @@ In addition to the styles in [Universal Styles](js-components-common-styles.md) -## Event +## Events In addition to the events in [Universal Events](js-components-common-events.md), the following events are supported. @@ -361,12 +361,15 @@ Methods in [Universal Methods](js-components-common-methods.md) are supported. ``` // xxx.js +import prompt from '@system.prompt'; +export default { change(e){ prompt.showToast({ message: 'value: ' + e.text + ', lines: ' + e.lines + ', height: ' + e.height, duration: 3000, }); } +} ``` ![](figures/000000.png) diff --git a/en/application-dev/reference/arkui-js/js-components-basic-toggle.md b/en/application-dev/reference/arkui-js/js-components-basic-toggle.md index b1d4dbe2cdea2ffc625a1034ba5ca7025029fc8c..af0237107172cc8e679a96f6fd0793cb48d15919 100644 --- a/en/application-dev/reference/arkui-js/js-components-basic-toggle.md +++ b/en/application-dev/reference/arkui-js/js-components-basic-toggle.md @@ -2,10 +2,7 @@ The **** component allows your user to select from a group of options and may display the selection result in real time. Generally, the option group consists of many toggles. ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->This component is supported since API version 5. - -## Permission List +## Required Permissions None @@ -13,7 +10,7 @@ None Not supported -## Attribute +## Attributes In addition to the attributes in [Universal Attributes](js-components-common-attributes.md), the following attributes are supported. @@ -55,7 +52,7 @@ In addition to the attributes in [Universal Attributes](js-components-common-at -## Style +## Styles In addition to the styles in [Universal Styles](js-components-common-styles.md), the following styles are supported. @@ -72,7 +69,7 @@ In addition to the styles in [Universal Styles](js-components-common-styles.md) -

    color

    +

    text-color

    <color>

    @@ -143,7 +140,7 @@ In addition to the styles in [Universal Styles](js-components-common-styles.md) -## Event +## Events In addition to the events in [Universal Events](js-components-common-events.md), the following events are supported. @@ -166,7 +163,7 @@ In addition to the events in [Universal Events](js-components-common-events.md) -## Method +## Methods Methods in [Universal Methods](js-components-common-methods.md) are supported. diff --git a/en/application-dev/reference/arkui-js/js-components-basic-toolbar-item.md b/en/application-dev/reference/arkui-js/js-components-basic-toolbar-item.md index 3b5c5fa4191b4aec37c21edd120a200c0b5caeae..68a8edeec1fbd54ccc6bdb8d973720079dcedfbb 100644 --- a/en/application-dev/reference/arkui-js/js-components-basic-toolbar-item.md +++ b/en/application-dev/reference/arkui-js/js-components-basic-toolbar-item.md @@ -2,14 +2,11 @@ The **** component is the child component of **** to display an operation option on the toolbar. ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->This component is supported since API version 5. - ## Child Component None -## Attribute +## Attributes In addition to the attributes in [Universal Attributes](js-components-common-attributes.md), the following attributes are supported. @@ -51,7 +48,7 @@ In addition to the attributes in [Universal Attributes](js-components-common-at -## Style +## Styles Only the following style attributes are supported. @@ -132,7 +129,7 @@ Only the following style attributes are supported.

    No

    -

    Text modifier. Available values are as follows:

    +

    Text decoration. Available values are as follows:

    1. underline: An underline is used.
    2. line-through: A strikethrough is used.
    3. none: The standard text is used.
    @@ -191,7 +188,7 @@ Only the following style attributes are supported.

    Background image size.

    • The string values are as follows:
      • contain: Expands the image to the maximum size so that the height and width of the image are applicable to the content area.
      • cover: Extends the background image to a large enough size so that the background image completely covers the background area. Some parts of the image may not be displayed in the background area.
      • auto: The original image width-height ratio is retained.
    • The two <length> values are as follows:

      Width and height of the background image. The first value indicates the width, and the second value indicates the height. If you only set one value, the other value is set to auto by default.

      -
    • The two <percentage> values are as follows:

      Width and height of the background image in percentage of the parent element. The first value indicates the width, and the second value indicates the height. If you only set one value, the other value is set to auto by default.

      +
    • The two <percentage> values are as follows:

      Width and height of the background image in percentage of the parent element. The first value indicates the width, and the second value indicates the height. If you only set one value, the other value is set to auto by default.

    @@ -228,7 +225,7 @@ Only the following style attributes are supported.

    No

    -

    Transparency of an element. The value ranges from 0 to 1. The value 1 means opaque, and 0 means completely transparent.

    +

    Opacity of an element. The value ranges from 0 to 1. The value 1 means opaque, and 0 means completely transparent.

    display

    @@ -262,7 +259,7 @@ Only the following style attributes are supported. -## Event +## Events Events in [Universal Events](js-components-common-events.md) are supported. @@ -273,6 +270,7 @@ Not supported ## Example ``` + @@ -283,5 +281,5 @@ Not supported ``` -![](figures/progress-43.jpg) +![](figures/progress-7.jpg) diff --git a/en/application-dev/reference/arkui-js/js-components-basic-toolbar.md b/en/application-dev/reference/arkui-js/js-components-basic-toolbar.md index e5b019c80be41ff3d67d015b69f73aeb94d79f3a..3f0e8675f69a606e6cbcb145e48bc5cd1591eab1 100644 --- a/en/application-dev/reference/arkui-js/js-components-basic-toolbar.md +++ b/en/application-dev/reference/arkui-js/js-components-basic-toolbar.md @@ -2,10 +2,7 @@ The **** component provides a bar that is usually placed at the bottom of a page to display operation options for the page. ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->This component is supported since API version 5. - -## Permission List +## Required Permissions None @@ -17,18 +14,18 @@ Only the **** component is supported. >A maximum of five **** components can be contained in a **** component. If there are six or more, only the first four are displayed, and the rest items are hidden in the **More** list of the toolbar. Users can click **More** to view the hidden items. >The list is displayed in the default style instead of a customized style set for the **** component. -## Attribute +## Attributes Attributes in [Universal Attributes](js-components-common-attributes.md) are supported. -## Style +## Styles Styles in [Universal Styles](js-components-common-styles.md) are supported. >![](../../public_sys-resources/icon-note.gif) **NOTE:** ->- The **height** style is not supported. The height is fixed at 56px. +>The **height** style is not supported. The height is fixed at 56px. -## Event +## Events None diff --git a/en/application-dev/reference/arkui-js/js-components-canvas-canvas.md b/en/application-dev/reference/arkui-js/js-components-canvas-canvas.md index 54f78a8571f38e3840bc1a485132434984e11758..8a29479f73e396ee3b4d7a591025ce538b70967e 100644 --- a/en/application-dev/reference/arkui-js/js-components-canvas-canvas.md +++ b/en/application-dev/reference/arkui-js/js-components-canvas-canvas.md @@ -2,62 +2,166 @@ The **** component is used for customizing drawings. -## Permission List +## Required Permissions None -## Child Component +## Child Components Not supported -## Attribute +## Attributes Attributes in [Universal Attributes](js-components-common-attributes.md) are supported. -## Style +## Styles Styles in [Universal Styles](js-components-common-styles.md) are supported. -## Event +## Events Events in [Universal Events](js-components-common-events.md) are supported. -## Method +## Methods In addition to the methods in [Universal Methods](js-components-common-methods.md), the following events are supported. - - - - - - - - - - - - - - - -

    Name

    -

    Parameter

    -

    Description

    -

    getContext

    -

    getContext ( type: '2d', attributes6+: { antialias: boolean } ) => CanvasRendering2dContext

    -

    Obtains the canvas drawing context. The invoking methods are as follows6+:

    -

    var ctx = canvas.getContext(contextType);

    -

    var ctx = canvas.getContext(contextType, contextAttributes);

    -

    contextType is mandatory and can be set to 2d. contextAttributes is optional and can be set only to enable or disable the anti-aliasing function. By default, the anti-aliasing function is disabled.

    -

    The contextType objects are as follows:

    -

    2d: The return value is a 2D drawing object that provides specific 2D drawing operations. For details, see section CanvasRenderingContext2D.

    -

    This API cannot be called in onInit or onReady.

    -

    toDataURL6+

    -

    string type, number encoderOptions

    -

    Generate a URL containing the image display.

    -
    • type: specifies the image format. This parameter is optional. The default format is image/png.
    • encoderOptions: When the image format is set to image/jpeg or image/webp, the image quality can be selected from 0 to 1. If the value of this parameter is beyond the value range, the default value 0.92 is used.
    -
    +### getContext + +getContext\(type: '2d', options?: ContextAttrOptions\): CanvasRendering2dContext + +Obtains the canvas drawing context. This API cannot be called in **onInit** or **onReady**. + +- Parameters + + + + + + + + + + + + + + + + + + + +

    Name

    +

    Type

    +

    Mandatory

    +

    Description

    +

    type

    +

    string

    +

    Yes

    +

    The value is set to '2d', indicating that a 2D drawing object is returned. This object can be used to draw rectangles, texts, and images on the canvas component.

    +

    options6+

    +

    ContextAttrOptions

    +

    No

    +

    Whether to enable anti-aliasing. By default, anti-aliasing is disabled.

    +
    + + **Table 1** ContextAttrOptions + + + + + + + + + + + + +

    Name

    +

    Type

    +

    Description

    +

    antialias

    +

    boolean

    +

    Whether to enable anti-aliasing. The default value is false.

    +
    + +- Return values + + + + + + + + + + +

    Type

    +

    Description

    +

    CanvasRenderingContext2D

    +

    2D drawing object, which can be used to draw rectangles, images, and texts on the canvas component.

    +
    + + +### toDataURL6+ + +toDataURL\(type?: string, quality?: number\): string + +Generates a URL containing image display information. + +- Parameters + + + + + + + + + + + + + + + + + + + +

    Name

    +

    Type

    +

    Mandatory

    +

    Description

    +

    type

    +

    string

    +

    No

    +

    Image format. The default value is image/png.

    +

    quality

    +

    number

    +

    No

    +

    Image quality, which ranges from 0 to 1, when the image format is image/jpeg or image/webp. If the set value is beyond the value range, the default value 0.92 is used.

    +
    + +- Return values + + + + + + + + + + +

    Type

    +

    Description

    +

    string

    +

    Image URL.

    +
    + ## Example diff --git a/en/application-dev/reference/arkui-js/js-components-canvas-canvasgradient.md b/en/application-dev/reference/arkui-js/js-components-canvas-canvasgradient.md index 513856ee6f236eb8c74d3219684534acdc430fb4..18e1b0e45a358f9da14418fc611b2b220063f4a9 100644 --- a/en/application-dev/reference/arkui-js/js-components-canvas-canvasgradient.md +++ b/en/application-dev/reference/arkui-js/js-components-canvas-canvasgradient.md @@ -8,10 +8,10 @@ addColorStop\(offset: number, color: string\): void Adds a color stop for the** CanvasGradient** object based on the specified offset and gradient color. -- Parameter +- Parameters -

    Parameter

    + @@ -39,11 +39,25 @@ Adds a color stop for the** CanvasGradient** object based on the specified offs - Example Code ``` - const gradient = ctx.createLinearGradient(0,0,100,0); - gradient.addColorStop(0,'#00ffff'); - gradient.addColorStop(1,'#ffff00'); + +
    + + +
    ``` - ![](figures/en-us_image_0000001152610806.png) + ``` + // xxx.js + export default { + handleClick() { + const el =this.$refs.canvas; + const ctx =el.getContext('2d'); + const gradient = ctx.createLinearGradient(0,0,100,0); + gradient.addColorStop(0,'#00ffff'); + gradient.addColorStop(1,'#ffff00'); + } + } + ``` + ![](figures/en-us_image_0000001152610806.png) diff --git a/en/application-dev/reference/arkui-js/js-components-canvas-canvasrenderingcontext2d.md b/en/application-dev/reference/arkui-js/js-components-canvas-canvasrenderingcontext2d.md index bed0f06aa22212c7e88c6cd93731f9f7c38593e4..e9dc8c57cd6388134b548137b98849640d768e8f 100644 --- a/en/application-dev/reference/arkui-js/js-components-canvas-canvasrenderingcontext2d.md +++ b/en/application-dev/reference/arkui-js/js-components-canvas-canvasrenderingcontext2d.md @@ -1,5 +1,6 @@ # CanvasRenderingContext2D + **CanvasRenderingContext2D** allows you to draw rectangles, text, images, and other objects on a canvas. - Example @@ -40,7 +41,7 @@ - Anti-aliasing enabled - ![](figures/screenshot-44.png) + ![](figures/screenshot-8.png) ## Attributes @@ -133,7 +134,7 @@ @@ -153,7 +154,7 @@ -

    Name

    Type

    Text alignment mode. Available values are as follows:

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

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

    +
    NOTE:

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

    -

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

    +

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

    lineDashOffset

    @@ -225,8 +226,22 @@ ### fillStyle ``` -ctx.fillStyle = '#0000ff'; -ctx.fillRect(20, 20, 150, 100); + +
    + +
    +``` + +``` +//xxx.js +export default { + onShow() { + const el =this.$refs.canvas; + const ctx = el.getContext('2d'); + ctx.fillStyle = '#0000ff'; + ctx.fillRect(20, 20, 150, 100); + } +} ``` ![](figures/en-us_image_0000001166962736.png) @@ -234,8 +249,22 @@ ctx.fillRect(20, 20, 150, 100); ### lineWidth ``` -ctx.lineWidth = 5; -ctx.strokeRect(25, 25, 85, 105); + +
    + +
    +``` + +``` +//xxx.js +export default { + onShow() { + const el =this.$refs.canvas; + const ctx = el.getContext('2d'); + ctx.lineWidth = 5; + ctx.strokeRect(25, 25, 85, 105); + } +} ``` ![](figures/en-us_image_0000001166484430.png) @@ -243,9 +272,23 @@ ctx.strokeRect(25, 25, 85, 105); ### strokeStyle ``` -ctx.lineWidth = 10; -ctx.strokeStyle = '#0000ff'; -ctx.strokeRect(25, 25, 155, 105); + +
    + +
    +``` + +``` +//xxx.js +export default { + onShow() { + const el =this.$refs.canvas; + const ctx = el.getContext('2d'); + ctx.lineWidth = 10; + ctx.strokeStyle = '#0000ff'; + ctx.strokeRect(25, 25, 155, 105); + } +} ``` ![](figures/en-us_image_0000001212124299.png) @@ -253,12 +296,26 @@ ctx.strokeRect(25, 25, 155, 105); ### lineCap ``` -ctx.lineWidth = 8; -ctx.beginPath(); -ctx.lineCap = 'round'; -ctx.moveTo(30, 50); -ctx.lineTo(220, 50); -ctx.stroke(); + +
    + +
    +``` + +``` +//xxx.js +export default { + onShow() { + const el =this.$refs.canvas; + const ctx = el.getContext('2d'); + ctx.lineWidth = 8; + ctx.beginPath(); + ctx.lineCap = 'round'; + ctx.moveTo(30, 50); + ctx.lineTo(220, 50); + ctx.stroke(); + } +} ``` ![](figures/en-us_image_0000001214837127.png) @@ -266,13 +323,27 @@ ctx.stroke(); ### lineJoin ``` -ctx.beginPath(); -ctx.lineWidth = 8; -ctx.lineJoin = 'miter'; -ctx.moveTo(30, 30); -ctx.lineTo(120, 60); -ctx.lineTo(30, 110); -ctx.stroke(); + +
    + +
    +``` + +``` +//xxx.js +export default { + onShow() { + const el =this.$refs.canvas; + const ctx = el.getContext('2d'); + ctx.beginPath(); + ctx.lineWidth = 8; + ctx.lineJoin = 'miter'; + ctx.moveTo(30, 30); + ctx.lineTo(120, 60); + ctx.lineTo(30, 110); + ctx.stroke(); + } +} ``` ![](figures/en-us_image_0000001214717247.png) @@ -280,13 +351,27 @@ ctx.stroke(); ### miterLimit ``` -ctx.lineWidth = 8; -ctx.lineJoin = 'miter'; -ctx.miterLimit = 3; -ctx.moveTo(30, 30); -ctx.lineTo(60, 35); -ctx.lineTo(30, 37); -ctx.stroke(); + +
    + +
    +``` + +``` +//xxx.js +export default { + onShow() { + const el =this.$refs.canvas; + const ctx = el.getContext('2d'); + ctx.lineWidth =14; + ctx.lineJoin = 'miter'; + ctx.miterLimit = 3; + ctx.moveTo(30, 30); + ctx.lineTo(120, 60); + ctx.lineTo(30, 70); + ctx.stroke(); + } +} ``` ![](figures/en-us_image_0000001167001464.png) @@ -294,8 +379,22 @@ ctx.stroke(); ### font ``` -ctx.font = '30px sans-serif'; -ctx.fillText("Hello World", 20, 60); + +
    + +
    +``` + +``` +//xxx.js +export default { + onShow() { + const el =this.$refs.canvas; + const ctx = el.getContext('2d'); + ctx.font = '30px sans-serif'; + ctx.fillText("Hello World", 20, 60); + } +} ``` ![](figures/en-us_image_0000001167046832.png) @@ -303,24 +402,38 @@ ctx.fillText("Hello World", 20, 60); ### textAlign ``` -ctx.strokeStyle = '#0000ff'; -ctx.moveTo(140, 10); -ctx.lineTo(140, 160); -ctx.stroke(); + +
    + +
    +``` -ctx.font = '18px sans-serif'; +``` +//xxx.js +export default { + onShow() { + const el =this.$refs.canvas; + const ctx = el.getContext('2d'); + ctx.strokeStyle = '#0000ff'; + ctx.moveTo(140, 10); + ctx.lineTo(140, 160); + ctx.stroke(); + + ctx.font = '18px sans-serif'; // Show the textAlign values. -ctx.textAlign = 'start'; -ctx.fillText('textAlign=start', 140, 60); -ctx.textAlign = 'end'; -ctx.fillText('textAlign=end', 140, 80); -ctx.textAlign = 'left'; -ctx.fillText('textAlign=left', 140, 100); -ctx.textAlign = 'center'; -ctx.fillText('textAlign=center',140, 120); -ctx.textAlign = 'right'; -ctx.fillText('textAlign=right',140, 140); + ctx.textAlign = 'start'; + ctx.fillText('textAlign=start', 140, 60); + ctx.textAlign = 'end'; + ctx.fillText('textAlign=end', 140, 80); + ctx.textAlign = 'left'; + ctx.fillText('textAlign=left', 140, 100); + ctx.textAlign = 'center'; + ctx.fillText('textAlign=center',140, 120); + ctx.textAlign = 'right'; + ctx.fillText('textAlign=right',140, 140); + } +} ``` ![](figures/en-us_image_0000001167472798.png) @@ -328,23 +441,37 @@ ctx.fillText('textAlign=right',140, 140); ### textBaseline ``` -ctx.strokeStyle = '#0000ff'; -ctx.moveTo(0, 120); -ctx.lineTo(400, 120); -ctx.stroke(); + +
    + +
    +``` -ctx.font = '20px sans-serif'; +``` +//xxx.js +export default { + onShow() { + const el =this.$refs.canvas; + const ctx = el.getContext('2d'); + ctx.strokeStyle = '#0000ff'; + ctx.moveTo(0, 120); + ctx.lineTo(400, 120); + ctx.stroke(); -ctx.textBaseline = 'top'; -ctx.fillText('Top', 10, 120); -ctx.textBaseline = 'bottom'; -ctx.fillText('Bottom', 55, 120); -ctx.textBaseline = 'middle'; -ctx.fillText('Middle', 125, 120); -ctx.textBaseline = 'alphabetic'; -ctx.fillText('Alphabetic', 195, 120); -ctx.textBaseline = 'hanging'; -ctx.fillText('Hanging', 295, 120); + ctx.font = '20px sans-serif'; + + ctx.textBaseline = 'top'; + ctx.fillText('Top', 10, 120); + ctx.textBaseline = 'bottom'; + ctx.fillText('Bottom', 55, 120); + ctx.textBaseline = 'middle'; + ctx.fillText('Middle', 125, 120); + ctx.textBaseline = 'alphabetic'; + ctx.fillText('Alphabetic', 195, 120); + ctx.textBaseline = 'hanging'; + ctx.fillText('Hanging', 295, 120); + } +} ``` ![](figures/en-us_image_0000001169315920.png) @@ -352,11 +479,26 @@ ctx.fillText('Hanging', 295, 120); ### globalAlpha ``` -ctx.fillStyle = 'rgb(255,0,0)'; -ctx.fillRect(0, 0, 50, 50); -ctx.globalAlpha = 0.4; -ctx.fillStyle = 'rgb(0,0,255)'; -ctx.fillRect(50, 50, 50, 50); + +
    + +
    +``` + +``` +//xxx.js +export default { + onShow() { + const el =this.$refs.canvas; + const ctx = el.getContext('2d'); + ctx.fillStyle = 'rgb(255,0,0)'; + ctx.fillRect(0, 0, 50, 50); + ctx.globalAlpha = 0.4; + ctx.fillStyle = 'rgb(0,0,255)'; + ctx.fillRect(50, 50, 50, 50); + + } +} ``` ![](figures/en-us_image_0000001167953648.png) @@ -364,17 +506,31 @@ ctx.fillRect(50, 50, 50, 50); ### lineDashOffset ``` -ctx.arc(100, 75, 50, 0, 6.28); -ctx.setLineDash([10,20]); -ctx.lineDashOffset = 10.0; -ctx.stroke(); + +
    + +
    +``` + +``` +//xxx.js +export default { + onShow() { + const el =this.$refs.canvas; + const ctx = el.getContext('2d'); + ctx.arc(100, 75, 50, 0, 6.28); + ctx.setLineDash([10,20]); + ctx.lineDashOffset = 10.0; + ctx.stroke(); + } +} ``` ![](figures/en-us_image_0000001167950468.png) ### globalCompositeOperation -- Defines a **globalCompositeOperation** object. +- Enumerates the operation types.

    Value

    @@ -445,17 +601,31 @@ ctx.stroke(); - Example ``` - ctx.fillStyle = 'rgb(255,0,0)'; - ctx.fillRect(20, 20, 50, 50); - ctx.globalCompositeOperation = 'source-over'; - ctx.fillStyle = 'rgb(0,0,255)'; - ctx.fillRect(50, 50, 50, 50); - // Start drawing second example - ctx.fillStyle = 'rgb(255,0,0)'; - ctx.fillRect(120, 20, 50, 50); - ctx.globalCompositeOperation = 'destination-over'; - ctx.fillStyle = 'rgb(0,0,255)'; - ctx.fillRect(150, 50, 50, 50); + +
    + +
    + ``` + + ``` + //xxx.js + export default { + onShow() { + const el =this.$refs.canvas; + const ctx = el.getContext('2d'); + ctx.fillStyle = 'rgb(255,0,0)'; + ctx.fillRect(20, 20, 50, 50); + ctx.globalCompositeOperation = 'source-over'; + ctx.fillStyle = 'rgb(0,0,255)'; + ctx.fillRect(50, 50, 50, 50); + // Start drawing second example + ctx.fillStyle = 'rgb(255,0,0)'; + ctx.fillRect(120, 20, 50, 50); + ctx.globalCompositeOperation = 'destination-over'; + ctx.fillStyle = 'rgb(0,0,255)'; + ctx.fillRect(150, 50, 50, 50); + } + } ``` ![](figures/en-us_image_0000001213192781.png) @@ -466,10 +636,24 @@ ctx.stroke(); ### shadowBlur ``` -ctx.shadowBlur = 30; -ctx.shadowColor = 'rgb(0,0,0)'; -ctx.fillStyle = 'rgb(255,0,0)'; -ctx.fillRect(20, 20, 100, 80); + +
    + +
    +``` + +``` +//xxx.js +export default { + onShow() { + const el =this.$refs.canvas; + const ctx = el.getContext('2d'); + ctx.shadowBlur = 30; + ctx.shadowColor = 'rgb(0,0,0)'; + ctx.fillStyle = 'rgb(255,0,0)'; + ctx.fillRect(20, 20, 100, 80); + } +} ``` ![](figures/en-us_image_0000001168111514.png) @@ -477,10 +661,24 @@ ctx.fillRect(20, 20, 100, 80); ### shadowColor ``` -ctx.shadowBlur = 30; -ctx.shadowColor = 'rgb(0,0,255)'; -ctx.fillStyle = 'rgb(255,0,0)'; -ctx.fillRect(30, 30, 100, 100); + +
    + +
    +``` + +``` +//xxx.js +export default { + onShow() { + const el =this.$refs.canvas; + const ctx = el.getContext('2d'); + ctx.shadowBlur = 30; + ctx.shadowColor = 'rgb(0,0,255)'; + ctx.fillStyle = 'rgb(255,0,0)'; + ctx.fillRect(30, 30, 100, 100); + } +} ``` ![](figures/en-us_image_0000001168111610.png) @@ -488,11 +686,25 @@ ctx.fillRect(30, 30, 100, 100); ### shadowOffsetX ``` -ctx.shadowBlur = 10; -ctx.shadowOffsetX = 20; -ctx.shadowColor = 'rgb(0,0,0)'; -ctx.fillStyle = 'rgb(255,0,0)'; -ctx.fillRect(20, 20, 100, 80); + +
    + +
    +``` + +``` +//xxx.js +export default { + onShow() { + const el =this.$refs.canvas; + const ctx = el.getContext('2d'); + ctx.shadowBlur = 10; + ctx.shadowOffsetX = 20; + ctx.shadowColor = 'rgb(0,0,0)'; + ctx.fillStyle = 'rgb(255,0,0)'; + ctx.fillRect(20, 20, 100, 80); + } +} ``` ![](figures/en-us_image_0000001167631876.png) @@ -500,11 +712,25 @@ ctx.fillRect(20, 20, 100, 80); ### shadowOffsetY ``` -ctx.shadowBlur = 10; -ctx.shadowOffsetY = 20; -ctx.shadowColor = 'rgb(0,0,0)'; -ctx.fillStyle = 'rgb(255,0,0)'; -ctx.fillRect(30, 30, 100, 100); + +
    + +
    +``` + +``` +//xxx.js +export default { + onShow() { + const el =this.$refs.canvas; + const ctx = el.getContext('2d'); + ctx.shadowBlur = 10; + ctx.shadowOffsetY = 20; + ctx.shadowColor = 'rgb(0,0,0)'; + ctx.fillStyle = 'rgb(255,0,0)'; + ctx.fillRect(30, 30, 100, 100); + } +} ``` ![](figures/en-us_image_0000001213193285.png) @@ -512,12 +738,26 @@ ctx.fillRect(30, 30, 100, 100); ### imageSmoothingEnabled6+ ``` -var img = new Image(); -img.src = 'common/image/huawei.jpg'; -img.onload = function() { - ctx.imageSmoothingEnabled = false; - ctx.drawImage(img, 0, 0, 400, 200); -}; + +
    + +
    +``` + +``` +//xxx.js +export default { + onShow() { + const el =this.$refs.canvas; + const ctx = el.getContext('2d'); + var img = new Image(); + img.src = 'common/image/example.jpg'; + img.onload = function() { + ctx.imageSmoothingEnabled = false; + ctx.drawImage(img, 0, 0, 400, 200); + }; + } +} ``` ![](figures/smoothoff.png) @@ -530,7 +770,7 @@ fillRect\(x: number, y: number, width:number, height: number\): void Fills a rectangle on the canvas. -- Parameter +- Parameters -

    Name

    @@ -559,7 +799,7 @@ Fills a rectangle on the canvas.

    number

    Width of the rectangle

    +

    Width of the rectangle.

    height

    @@ -575,7 +815,21 @@ Fills a rectangle on the canvas. - Example ``` - ctx.fillRect(20, 20, 200, 150); + +
    + +
    + ``` + + ``` + //xxx.js + export default { + onShow() { + const el =this.$refs.canvas; + const ctx = el.getContext('2d'); + ctx.fillRect(20, 20, 200, 150); + } + } ``` ![](figures/en-us_image_0000001214811029.png) @@ -587,7 +841,7 @@ clearRect\(x: number, y: number, width:number, height: number\): void Clears the content in a rectangle on the canvas. -- Parameter +- Parameters -

    Name

    @@ -616,7 +870,7 @@ Clears the content in a rectangle on the canvas.

    number

    Width of the rectangle

    +

    Width of the rectangle.

    height

    @@ -632,9 +886,23 @@ Clears the content in a rectangle on the canvas. - Example ``` - ctx.fillStyle = 'rgb(0,0,255)'; - ctx.fillRect(0, 0, 400, 200); - ctx.clearRect(20, 20, 150, 100); + +
    + +
    + ``` + + ``` + //xxx.js + export default { + onShow() { + const el =this.$refs.canvas; + const ctx = el.getContext('2d'); + ctx.fillStyle = 'rgb(0,0,255)'; + ctx.fillRect(0, 0, 400, 200); + ctx.clearRect(20, 20, 150, 100); + } + } ``` ![](figures/en-us_image_0000001214619417.png) @@ -646,7 +914,7 @@ strokeRect\(x: number, y: number, width:number, height: number\): void Draws a rectangle stroke on the canvas. -- Parameter +- Parameters -

    Name

    @@ -675,7 +943,7 @@ Draws a rectangle stroke on the canvas.

    number

    Width of the rectangle

    +

    Width of the rectangle.

    height

    @@ -691,7 +959,21 @@ Draws a rectangle stroke on the canvas. - Example ``` - ctx.strokeRect(30, 30, 200, 150); + +
    + +
    + ``` + + ``` + //xxx.js + export default { + onShow() { + const el =this.$refs.canvas; + const ctx = el.getContext('2d'); + ctx.strokeRect(30, 30, 200, 150); + } + } ``` ![](figures/en-us_image_0000001214822091.png) @@ -703,7 +985,7 @@ fillText\(text: string, x: number, y: number\): void Draws filled text on the canvas. -- Parameter +- Parameters

    Name

    @@ -741,8 +1023,22 @@ Draws filled text on the canvas. - Example ``` - ctx.font = '35px sans-serif'; - ctx.fillText("Hello World!", 20, 60); + +
    + +
    + ``` + + ``` + //xxx.js + export default { + onShow() { + const el =this.$refs.canvas; + const ctx = el.getContext('2d'); + ctx.font = '35px sans-serif'; + ctx.fillText("Hello World!", 10, 60); + } + } ``` ![](figures/en-us_image_0000001214469787.png) @@ -754,7 +1050,7 @@ strokeText\(text: string, x: number, y: number\): void Draws a text stroke on the canvas. -- Parameter +- Parameters - - - - - -

    Name

    @@ -792,8 +1088,22 @@ Draws a text stroke on the canvas. - Example ``` - ctx.font = '25px sans-serif'; - ctx.strokeText("Hello World!", 20, 60); + +
    + +
    + ``` + + ``` + //xxx.js + export default { + onShow() { + const el =this.$refs.canvas; + const ctx = el.getContext('2d'); + ctx.font = '25px sans-serif'; + ctx.strokeText("Hello World!", 10, 60); + } + } ``` ![](figures/en-us_image_0000001214460669.png) @@ -805,7 +1115,7 @@ measureText\(text: string\): TextMetrics Returns a **TextMetrics** object used to obtain the width of specified text. -- Parameter +- Parameters

    Name

    @@ -846,10 +1156,24 @@ Returns a **TextMetrics** object used to obtain the width of specified text. - Example ``` - ctx.font = '25px sans-serif'; - var txt = 'Hello World'; - ctx.fillText("width:" + ctx.measureText(txt).width, 20, 60); - ctx.fillText(txt, 20, 110); + +
    + +
    + ``` + + ``` + //xxx.js + export default { + onShow() { + const el =this.$refs.canvas; + const ctx = el.getContext('2d'); + ctx.font = '20px sans-serif'; + var txt = 'Hello World'; + ctx.fillText("width:" + ctx.measureText(txt).width, 20, 60); + ctx.fillText(txt, 20, 110); + } + } ``` ![](figures/en-us_image_0000001169142476.png) @@ -864,13 +1188,28 @@ Draws a stroke. - Example ``` - ctx.moveTo(25, 25); - ctx.lineTo(25, 105); - ctx.strokeStyle = 'rgb(0,0,255)'; - ctx.stroke(); + +
    + +
    + ``` + + ``` + //xxx.js + export default { + onShow() { + const el =this.$refs.canvas; + const ctx = el.getContext('2d'); + ctx.moveTo(25, 25); + ctx.lineTo(25, 250); + ctx.lineWidth = '6'; + ctx.strokeStyle = 'rgb(0,0,255)'; + ctx.stroke(); + } + } ``` - ![](figures/en-us_image_0000001169309930.png) + ![](figures/en-us_image_0000001236697937.png) ### beginPath @@ -882,12 +1221,26 @@ Creates a drawing path. - Example ``` - ctx.beginPath(); - ctx.lineWidth = '6'; - ctx.strokeStyle = '#0000ff'; - ctx.moveTo(15, 80); - ctx.lineTo(280, 160); - ctx.stroke(); + +
    + +
    + ``` + + ``` + //xxx.js + export default { + onShow() { + const el =this.$refs.canvas; + const ctx = el.getContext('2d'); + ctx.beginPath(); + ctx.lineWidth = '6'; + ctx.strokeStyle = '#0000ff'; + ctx.moveTo(15, 80); + ctx.lineTo(280, 80); + ctx.stroke(); + } + } ``` ![](figures/en-us_image_0000001214629745.png) @@ -899,7 +1252,7 @@ moveTo\(x: number, y: number\): void Moves a drawing path to a target position on the canvas. -- Parameter +- Parameters

    Name

    @@ -930,10 +1283,24 @@ Moves a drawing path to a target position on the canvas. - Example ``` - ctx.beginPath(); - ctx.moveTo(10, 10); - ctx.lineTo(280, 160); - ctx.stroke(); + +
    + +
    + ``` + + ``` + //xxx.js + export default { + onShow() { + const el =this.$refs.canvas; + const ctx = el.getContext('2d'); + ctx.beginPath(); + ctx.moveTo(10, 10); + ctx.lineTo(280, 160); + ctx.stroke(); + } + } ``` ![](figures/en-us_image_0000001169309948.png) @@ -945,7 +1312,7 @@ lineTo\(x: number, y: number\): void Connects the current point to a target position using a straight line. -- Parameter +- Parameters

    Name

    @@ -976,10 +1343,24 @@ Connects the current point to a target position using a straight line. - Example ``` - ctx.beginPath(); - ctx.moveTo(10, 10); - ctx.lineTo(280, 160); - ctx.stroke(); + +
    + +
    + ``` + + ``` + //xxx.js + export default { + onShow() { + const el =this.$refs.canvas; + const ctx = el.getContext('2d'); + ctx.beginPath(); + ctx.moveTo(10, 10); + ctx.lineTo(280, 160); + ctx.stroke(); + } + } ``` ![](figures/en-us_image_0000001169469914.png) @@ -994,12 +1375,26 @@ Draws a closed path. - Example ``` - ctx.beginPath(); - ctx.moveTo(30, 30); - ctx.lineTo(110, 30); - ctx.lineTo(70, 90); - ctx.closePath(); - ctx.stroke(); + +
    + +
    + ``` + + ``` + //xxx.js + export default { + onShow() { + const el =this.$refs.canvas; + const ctx = el.getContext('2d'); + ctx.beginPath(); + ctx.moveTo(30, 30); + ctx.lineTo(110, 30); + ctx.lineTo(70, 90); + ctx.closePath(); + ctx.stroke(); + } + } ``` ![](figures/en-us_image_0000001169151508.png) @@ -1011,7 +1406,7 @@ createPattern\(image: Image, repetition: string\): Object Creates a pattern for image filling based on a specified source image and repetition mode. -- Parameter +- Parameters - @@ -193,7 +190,7 @@ In addition to the styles in [Universal Styles](js-components-common-styles.md) >- Height and width styles are not supported. The width of each item is the same as that of its container. The height of each item is the difference between the container height and the bottom button height. >- The **posit** style is not supported. -## Event +## Events In addition to the events in [Universal Events](js-components-common-events.md), the following events are supported. @@ -223,11 +220,11 @@ In addition to the events in [Universal Events](js-components-common-events.md)

    Name

    @@ -1059,9 +1454,25 @@ Creates a pattern for image filling based on a specified source image and repeti - Example ``` - var pat = ctx.createPattern(img, 'repeat'); - ctx.fillStyle = pat; - ctx.fillRect(0, 0, 20, 20); + +
    + +
    + ``` + + ``` + //xxx.js + export default { + onShow() { + const el =this.$refs.canvas; + const ctx = el.getContext('2d'); + var img = new Image(); + img.src = 'common/images/example.jpg'; + var pat = ctx.createPattern(img, 'repeat'); + ctx.fillStyle = pat; + ctx.fillRect(0, 0, 20, 20); + } + } ``` ![](figures/en-us_image_0000001169301188.png) @@ -1073,7 +1484,7 @@ bezierCurveTo\(cp1x: number, cp1y: number, cp2x: number, cp2y: number, x: number Draws a cubic bezier curve on the canvas. -- Parameter +- Parameters

    Name

    @@ -1132,10 +1543,24 @@ Draws a cubic bezier curve on the canvas. - Example ``` - ctx.beginPath(); - ctx.moveTo(10, 10); - ctx.bezierCurveTo(20, 100, 200, 100, 200, 20); - ctx.stroke(); + +
    + +
    + ``` + + ``` + //xxx.js + export default { + onShow() { + const el =this.$refs.canvas; + const ctx = el.getContext('2d'); + ctx.beginPath(); + ctx.moveTo(10, 10); + ctx.bezierCurveTo(20, 100, 200, 100, 200, 20); + ctx.stroke(); + } + } ``` ![](figures/en-us_image_0000001214621177.png) @@ -1147,7 +1572,7 @@ quadraticCurveTo\(cpx: number, cpy: number, x: number, y: number\): void Draws a quadratic curve on the canvas. -- Parameter +- Parameters

    Name

    @@ -1192,10 +1617,24 @@ Draws a quadratic curve on the canvas. - Example ``` - ctx.beginPath(); - ctx.moveTo(20, 20); - ctx.quadraticCurveTo(100, 100, 200, 20); - ctx.stroke(); + +
    + +
    + ``` + + ``` + //xxx.js + export default { + onShow() { + const el =this.$refs.canvas; + const ctx = el.getContext('2d'); + ctx.beginPath(); + ctx.moveTo(20, 20); + ctx.quadraticCurveTo(100, 100, 200, 20); + ctx.stroke(); + } + } ``` ![](figures/en-us_image_0000001169461910.png) @@ -1207,7 +1646,7 @@ arc\(x: number, y: number, radius: number, startAngle: number, endAngle: number, Draws an arc on the canvas. -- Parameter +- Parameters

    Name

    @@ -1266,9 +1705,23 @@ Draws an arc on the canvas. - Example ``` - ctx.beginPath(); - ctx.arc(100, 75, 50, 0, 6.28); - ctx.stroke(); + +
    + +
    + ``` + + ``` + //xxx.js + export default { + onShow() { + const el =this.$refs.canvas; + const ctx = el.getContext('2d'); + ctx.beginPath(); + ctx.arc(100, 75, 50, 0, 6.28); + ctx.stroke(); + } + } ``` ![](figures/en-us_image_0000001169470288.png) @@ -1280,7 +1733,7 @@ arcTo\(x1: number, y1: number, x2: number, y2: number, radius: number\): void Draws an arc based on the radius and points on the arc. -- Parameter +- Parameters

    Name

    @@ -1332,9 +1785,23 @@ Draws an arc based on the radius and points on the arc. - Example ``` - ctx.moveTo(100, 20); + +
    + +
    + ``` + + ``` + //xxx.js + export default { + onShow() { + const el =this.$refs.canvas; + const ctx = el.getContext('2d'); + ctx.moveTo(100, 20); ctx.arcTo(150, 20, 150, 70, 50); // Create an arc. - ctx.stroke(); + ctx.stroke(); + } + } ``` ![](figures/en-us_image_0000001169143586.png) @@ -1346,7 +1813,7 @@ ellipse\(x: number, y: number, radiusX: number, radiusY: number, rotation: numbe Draws an ellipse in the specified rectangular region. -- Parameter +- Parameters - - - -

    Name

    @@ -1361,28 +1828,28 @@ Draws an ellipse in the specified rectangular region.

    number

    X coordinate of the ellipse center

    +

    X-coordinate of the ellipse center

    y

    number

    Y coordinate of the ellipse center

    +

    Y-coordinate of the ellipse center

    radiusX

    number

    Ellipse radius on the x axis

    +

    Ellipse radius on the x-axis.

    radiusY

    number

    Ellipse radius on the y axis

    +

    Ellipse radius on the y-axis.

    rotation

    @@ -1419,9 +1886,23 @@ Draws an ellipse in the specified rectangular region. - Example ``` - ctx.beginPath(); - ctx.ellipse(200, 200, 50, 100, Math.PI * 0.25, Math.PI * 0.5, Math.PI, 1); - ctx.stroke(); + +
    + +
    + ``` + + ``` + //xxx.js + export default { + onShow() { + const el =this.$refs.canvas; + const ctx = el.getContext('2d'); + ctx.beginPath(); + ctx.ellipse(200, 200, 50, 100, Math.PI * 0.25, Math.PI * 0.5, Math.PI, 1); + ctx.stroke(); + } + } ``` ![](figures/ellipse.png) @@ -1433,7 +1914,7 @@ rect\(x: number, y: number, width: number, height: number\): void Creates a rectangle. -- Parameter +- Parameters -

    Name

    @@ -1462,7 +1943,7 @@ Creates a rectangle.

    number

    Width of the rectangle

    +

    Width of the rectangle.

    height

    @@ -1478,8 +1959,22 @@ Creates a rectangle. - Example ``` - ctx.rect(20, 20, 100, 100); // Create a 100*100 rectangle at (20, 20) - ctx.stroke(); // Draw it + +
    + +
    + ``` + + ``` + //xxx.js + export default { + onShow() { + const el =this.$refs.canvas; + const ctx = el.getContext('2d'); + ctx.rect(20, 20, 100, 100); // Create a 100*100 rectangle at (20, 20) + ctx.stroke(); // Draw it + } + } ``` ![](figures/en-us_image_0000001214630783.png) @@ -1494,8 +1989,22 @@ Fills the area inside a closed path. - Example ``` - ctx.rect(20, 20, 100, 100); // Create a 100 x 100 rectangle at (20, 20). + +
    + +
    + ``` + + ``` + //xxx.js + export default { + onShow() { + const el =this.$refs.canvas; + const ctx = el.getContext('2d'); + ctx.rect(20, 20, 100, 100); // Create a 100*100 rectangle at (20, 20). ctx.fill(); // Fill the rectangle using default settings. + } + } ``` ![](figures/en-us_image_0000001214703717.png) @@ -1510,12 +2019,26 @@ Sets the current path to a clipping path. - Example ``` - ctx.rect(0, 0, 200, 200); - ctx.stroke(); - ctx.clip(); + +
    + +
    + ``` + + ``` + //xxx.js + export default { + onShow() { + const el =this.$refs.canvas; + const ctx = el.getContext('2d'); + ctx.rect(0, 0, 200, 200); + ctx.stroke(); + ctx.clip(); // Clip a rectangle and fill it with red paint. - ctx.fillStyle = "rgb(255,0,0)"; - ctx.fillRect(0, 0, 150, 150); + ctx.fillStyle = "rgb(255,0,0)"; + ctx.fillRect(0, 0, 150, 150); + } + } ``` ![](figures/en-us_image_0000001169303414.png) @@ -1527,7 +2050,7 @@ rotate\(rotate: number\): void Rotates a canvas clockwise around its coordinate axes. -- Parameter +- Parameters

    Name

    @@ -1551,8 +2074,22 @@ Rotates a canvas clockwise around its coordinate axes. - Example ``` + +
    + +
    + ``` + + ``` + //xxx.js + export default { + onShow() { + const el =this.$refs.canvas; + const ctx = el.getContext('2d'); ctx.rotate(45 * Math.PI / 180); // Rotate the rectangle 45 degrees. - ctx.fillRect(70, 20, 50, 50); + ctx.fillRect(70, 20, 50, 50); + } + } ``` ![](figures/en-us_image_0000001169463368.png) @@ -1564,7 +2101,7 @@ scale\(x: number, y: number\): void Scales a canvas based on scaling factors. -- Parameter +- Parameters -

    Name

    @@ -1595,9 +2132,23 @@ Scales a canvas based on scaling factors. - Example ``` - ctx.strokeRect(10, 10, 25, 25); + +
    + +
    + ``` + + ``` + //xxx.js + export default { + onShow() { + const el =this.$refs.canvas; + const ctx = el.getContext('2d'); + ctx.strokeRect(10, 10, 25, 25); ctx.scale(2, 2);// Set a 200% scale factor for the rectangle. - ctx.strokeRect(10, 10, 25, 25); + ctx.strokeRect(10, 10, 25, 25); + } + } ``` ![](figures/en-us_image_0000001214463281.png) @@ -1614,7 +2165,7 @@ Defines a transformation matrix. To transform a graph, you only need to set para >- x' = scaleX \* x + skewY \* y + translateX >- y' = skewX \* x + scaleY \* y + translateY -- Parameter +- Parameters - @@ -657,62 +621,3 @@ In addition to the methods in [Universal Methods](js-components-common-methods.

    Name

    @@ -1673,14 +2224,28 @@ Defines a transformation matrix. To transform a graph, you only need to set para - Example ``` - ctx.fillStyle = 'rgb(0,0,0)'; - ctx.fillRect(0, 0, 100, 100) - ctx.transform(1, 0.5, -0.5, 1, 10, 10); - ctx.fillStyle = 'rgb(255,0,0)'; - ctx.fillRect(0, 0, 100, 100); - ctx.transform(1, 0.5, -0.5, 1, 10, 10); - ctx.fillStyle = 'rgb(0,0,255)'; - ctx.fillRect(0, 0, 100, 100); + +
    + +
    + ``` + + ``` + //xxx.js + export default { + onShow() { + const el =this.$refs.canvas; + const ctx = el.getContext('2d'); + ctx.fillStyle = 'rgb(0,0,0)'; + ctx.fillRect(0, 0, 100, 100) + ctx.transform(1, 0.5, -0.5, 1, 10, 10); + ctx.fillStyle = 'rgb(255,0,0)'; + ctx.fillRect(0, 0, 100, 100); + ctx.transform(1, 0.5, -0.5, 1, 10, 10); + ctx.fillStyle = 'rgb(0,0,255)'; + ctx.fillRect(0, 0, 100, 100); + } + } ``` ![](figures/en-us_image_0000001214623227.png) @@ -1751,11 +2316,25 @@ Resets the existing transformation matrix and creates a new transformation matri - Example ``` - ctx.fillStyle = 'rgb(255,0,0)'; - ctx.fillRect(0, 0, 100, 100) - ctx.setTransform(1,0.5, -0.5, 1, 10, 10); - ctx.fillStyle = 'rgb(0,0,255)'; - ctx.fillRect(0, 0, 100, 100); + +
    + +
    + ``` + + ``` + //xxx.js + export default { + onShow() { + const el =this.$refs.canvas; + const ctx = el.getContext('2d'); + ctx.fillStyle = 'rgb(255,0,0)'; + ctx.fillRect(0, 0, 100, 100) + ctx.setTransform(1,0.5, -0.5, 1, 10, 10); + ctx.fillStyle = 'rgb(0,0,255)'; + ctx.fillRect(0, 0, 100, 100); + } + } ``` ![](figures/en-us_image_0000001168984880.png) @@ -1767,7 +2346,7 @@ translate\(x: number, y: number\): void Moves the origin of the coordinate system. -- Parameter +- Parameters

    Name

    @@ -1798,9 +2377,23 @@ Moves the origin of the coordinate system. - Example ``` - ctx.fillRect(10, 10, 50, 50); - ctx.translate(70, 70); - ctx.fillRect(10, 10, 50, 50); + +
    + +
    + ``` + + ``` + //xxx.js + export default { + onShow() { + const el =this.$refs.canvas; + const ctx = el.getContext('2d'); + ctx.fillRect(10, 10, 50, 50); + ctx.translate(70, 70); + ctx.fillRect(10, 10, 50, 50); + } + } ``` ![](figures/en-us_image_0000001169144864.png) @@ -1812,7 +2405,7 @@ createPath2D\(path: Path2D, cmds: string\): Path2D Creates a **Path2D** object. -- Parameter +- Parameters - -

    Name

    @@ -1847,16 +2440,30 @@ Creates a **Path2D** object. - Example ``` - var path1 = ctx.createPath2D(); - path1.moveTo(100, 100); - path1.lineTo(200, 100); - path1.lineTo(100, 200); - path1.closePath(); - ctx.stroke(path1); - var path2 = ctx.createPath2D("M150 150 L50 250 L250 250 Z"); - ctx.stroke(path2); - var path3 = ctx.createPath2D(path2); - ctx.stroke(path3); + +
    + +
    + ``` + + ``` + //xxx.js + export default { + onShow() { + const el =this.$refs.canvas; + const ctx = el.getContext('2d'); + var path1 = ctx.createPath2D(); + path1.moveTo(100, 100); + path1.lineTo(200, 100); + path1.lineTo(100, 200); + path1.closePath(); + ctx.stroke(path1); + var path2 = ctx.createPath2D("M150 150 L50 250 L250 250 Z"); + ctx.stroke(path2); + var path3 = ctx.createPath2D(path2); + ctx.stroke(path3); + } + } ``` ![](figures/en-us_image_0000001214824709.png) @@ -1868,7 +2475,7 @@ drawImage\(image: Image, sx: number, sy: number, sWidth: number, sHeight: number Draws an image. -- Parameter +- Parameters - - - - - - - - - - - - - - - - - - - @@ -250,7 +214,7 @@ In addition to the attributes in [Universal Attributes](js-components-common-at

    Name

    @@ -1948,11 +2555,23 @@ Draws an image. - Example ``` - var test = this.$element('drawImage'); - var ctx = test.getContext('2d'); - var img = new Image(); - img.src = 'common/image/test.jpg'; - ctx.drawImage(img, 50, 80, 80, 80); + +
    + +
    + ``` + + ``` + //xxx.js + export default { + onShow() { + var test = this.$element('drawImage'); + var ctx = test.getContext('2d'); + var img = new Image(); + img.src = 'common/image/test.jpg'; + ctx.drawImage(img, 50, 80, 80, 80); + } + } ``` ![](figures/en-us_image_0000001214704759.png) @@ -1967,7 +2586,21 @@ Restores the saved drawing context. - Example ``` - ctx.restore(); + +
    + +
    + ``` + + ``` + //xxx.js + export default { + onShow() { + const el =this.$refs.canvas; + const ctx = el.getContext('2d'); + ctx.restore(); + } + } ``` @@ -1980,7 +2613,21 @@ Saves the current drawing context. - Example ``` - ctx.save(); + +
    + +
    + ``` + + ``` + //xxx.js + export default { + onShow() { + const el =this.$refs.canvas; + const ctx = el.getContext('2d'); + ctx.save(); + } + } ``` @@ -1990,7 +2637,7 @@ createLinearGradient\(x0: number, y0: number, x1: number, y1: number\): Object Creates a linear gradient. A CanvasGradient object is returned. For details, see [CanvasGradient](js-components-canvas-canvasgradient.md). -- Parameter +- Parameters - - - -

    Name

    @@ -2005,34 +2652,34 @@ Creates a linear gradient. A CanvasGradient object is returned. For details, see

    number

    X coordinate of the start point

    +

    X-coordinate of the start point.

    y0

    number

    Y coordinate of the start point

    +

    Y-coordinate of the start point.

    x1

    number

    X coordinate of the end point

    +

    X-coordinate of the end point.

    y1

    number

    Y coordinate of the end point

    +

    Y-coordinate of the end point.

    -- Return Value +- Return values

    Type

    @@ -2053,8 +2700,10 @@ Creates a linear gradient. A CanvasGradient object is returned. For details, see ``` - - +
    + + +
    ``` ``` @@ -2085,7 +2734,7 @@ createRadialGradient\(x0: number, y0: number, r0: number, x1: number, y1: number Creates a radial gradient and returns a **CanvasGradient** object. -- Parameter +- Parameters - - - - - @@ -2162,8 +2811,10 @@ Creates a radial gradient and returns a **CanvasGradient** object. ``` - - +
    + + +
    ``` ``` @@ -2194,7 +2845,7 @@ createImageData\(width: number, height: number, imageData: Object\): Object Creates an **ImageData** object. For details, see [ImageData](js-components-canvas-imagedata.md). -- Parameter +- Parameters

    Name

    @@ -2100,14 +2749,14 @@ Creates a radial gradient and returns a **CanvasGradient** object.

    number

    X coordinate of the start point

    +

    X-coordinate of the start point.

    y0

    number

    Y coordinate of the center of the start circle

    +

    Y-coordinate of the center of the start circle.

    r0

    @@ -2121,14 +2770,14 @@ Creates a radial gradient and returns a **CanvasGradient** object.

    number

    X coordinate of the center of the end circle

    +

    X-coordinate of the center of the end circle.

    y1

    number

    Y coordinate of the center of the end circle

    +

    Y-coordinate of the center of the end circle.

    r1

    @@ -2152,7 +2801,7 @@ Creates a radial gradient and returns a **CanvasGradient** object.

    Object

    Returns the created CanvasGradient object.

    +

    Returns the created CanvasGradient object.

    Name

    @@ -2249,8 +2900,22 @@ Creates an **ImageData** object. For details, see [ImageData](js-components-c - Example ``` - imageData = ctx.createImageData(50, 100); // Create ImageData with 50px width and 100px height - newImageData = ctx.createImageData(imageData); // Create ImageData using the input imageData + +
    + +
    + ``` + + ``` + //xxx.js + export default { + onShow() { + const el =this.$refs.canvas; + const ctx = el.getContext('2d'); + imageData = ctx.createImageData(50, 100); // Create ImageData with 50px width and 100px height + newImageData = ctx.createImageData(imageData); // Create ImageData using the input imageData + } + } ``` @@ -2260,7 +2925,7 @@ getImageData\(sx: number, sy: number, sw: number, sh: number\): Object Creates an **ImageData** object with pixels in the specified area on the canvas. -- Parameter +- Parameters - - - - - - - - -

    Name

    @@ -2275,14 +2940,14 @@ Creates an **ImageData** object with pixels in the specified area on the canva

    number

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

    +

    X coordinate of the upper left corner of the output area

    sy

    number

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

    +

    Y coordinate of the upper left corner of the output area

    sw

    @@ -2322,9 +2987,21 @@ Creates an **ImageData** object with pixels in the specified area on the canva - Example ``` - var test = this.$element('getImageData'); - var ctx = test.getContext('2d'); - var imageData = ctx.getImageData(0, 0, 280, 300); + +
    + +
    + ``` + + ``` + //xxx.js + export default { + onShow() { + var test = this.$element('getImageData') + var ctx = test.getContext('2d'); + var imageData = ctx.getImageData(0, 0, 280, 300); + } + } ``` @@ -2334,7 +3011,7 @@ putImageData\(imageData: Object, dx: number, dy: number, dirtyX: number, dirtyY: Puts the **ImageData** onto a rectangular area on the canvas. -- Parameter +- Parameters

    Name

    @@ -2400,16 +3077,28 @@ Puts the **ImageData** onto a rectangular area on the canvas. - Example ``` - var test = this.$element('putImageData'); - var ctx = test.getContext('2d'); - var imgData = ctx.createImageData(100, 100); - for (var i = 0; i < imgData.data.length; i += 4) { - imgData.data[i + 0] = 255; - imgData.data[i + 1] = 0; - imgData.data[i + 2] = 0; - imgData.data[i + 3] = 255; + +
    + +
    + ``` + + ``` + //xxx.js + export default { + onShow() { + var test = this.$element('getImageData') + var ctx = test.getContext('2d'); + var imgData = ctx.createImageData(100, 100); + for (var i = 0; i < imgData.data.length; i += 4) { + imgData.data[i + 0] = 255; + imgData.data[i + 1] = 0; + imgData.data[i + 2] = 0; + imgData.data[i + 3] = 255; + } + ctx.putImageData(imgData, 10, 10); + } } - ctx.putImageData(imgData, 10, 10); ``` ![](figures/en-us_image_0000001214463283.png) @@ -2421,7 +3110,7 @@ setLineDash\(segments: Array\): void Sets the dash line style. -- Parameter +- Parameters - @@ -2479,7 +3182,21 @@ Obtains the dash line style. - Example ``` - var info = ctx.getLineDash(); + +
    + +
    + ``` + + ``` + //xxx.js + export default { + onShow() { + const el =this.$refs.canvas; + const ctx = el.getContext('2d'); + var info = ctx.getLineDash(); + } + } ``` @@ -2489,7 +3206,7 @@ transferFromImageBitmap\(bitmap: ImageBitmap\): void Displays the specified **ImageBitmap** object. -- Parameter +- Parameters

    Name

    @@ -2445,9 +3134,23 @@ Sets the dash line style. - Example ``` - ctx.arc(100, 75, 50, 0, 6.28); - ctx.setLineDash([10,20]); - ctx.stroke(); + +
    + +
    + ``` + + ``` + //xxx.js + export default { + onShow() { + const el =this.$refs.canvas; + const ctx = el.getContext('2d'); + ctx.arc(100, 75, 50, 0, 6.28); + ctx.setLineDash([10,20]); + ctx.stroke(); + } + } ``` ![](figures/en-us_image_0000001214623229.png) @@ -2470,7 +3173,7 @@ Obtains the dash line style.

    Array

    Interval of alternate line segments and the length of spacing

    +

    Interval of alternate line segments and the length of spacing.

    - - @@ -35,57 +35,171 @@ Defines a canvas object that can be rendered off the screen. ## Methods - -

    Name

    @@ -2513,15 +3230,28 @@ Displays the specified **ImageBitmap** object. - Example ``` - var canvas = this.$refs.canvasId.getContext('2d'); - var offscreen = new OffscreenCanvas(500,500); - var offscreenCanvasCtx = offscreen.getContext("2d"); - offscreenCanvasCtx.fillRect(0, 0, 200, 200); + +
    + +
    + ``` + + ``` + //xxx.js + export default { + onShow() { + const el =this.$refs.canvas; + const ctx = el.getContext('2d'); + var canvas = this.$refs.canvas.getContext('2d'); + var offscreen = new OffscreenCanvas(500,500); + var offscreenCanvasCtx = offscreen.getContext("2d"); + offscreenCanvasCtx.fillRect(0, 0, 200, 200); - var bitmap = offscreen.transferToImageBitmap(); - canvas.transferFromImageBitmap(bitmap); + var bitmap = offscreen.transferToImageBitmap(); + canvas.transferFromImageBitmap(bitmap); + } + } ``` ![](figures/en-us_image_0000001168984882.png) - diff --git a/en/application-dev/reference/arkui-js/js-components-canvas-image.md b/en/application-dev/reference/arkui-js/js-components-canvas-image.md index 46dce7fc255b8cb8c25d13aafca8807658e6cb74..8ad046dea4f04309fca88e860adf17f3a561d6ad 100644 --- a/en/application-dev/reference/arkui-js/js-components-canvas-image.md +++ b/en/application-dev/reference/arkui-js/js-components-canvas-image.md @@ -2,10 +2,10 @@ **Image** allows you to add an image. -## Attribute +## Attributes -

    Attribute

    + @@ -25,7 +25,7 @@ - - -

    Name

    Type

    Yes

    Image resource path

    +

    Image resource path.

    width

    @@ -36,7 +36,7 @@

    No

    Image width

    +

    Image width.

    height

    @@ -47,7 +47,7 @@

    No

    Image height

    +

    Image height.

    onload

    @@ -78,17 +78,30 @@ ## Example ``` -var ctx = this.$element('drawImage').getContext('2d'); -var img = new Image(); -img.src = 'common/images/huawei.jpg'; -img.onload = function() { - console.log('Image load success'); - ctx.drawImage(img, 0, 0, 360, 250); -}; -img.onerror = function() { - console.log('Image load fail'); -}; + +
    + +
    ``` -![](figures/en-us_image_0000001198530395.png) +``` +//xxx.js +export default { + onShow(){ + const el =this.$refs.canvas + var ctx = this.$element('drawImage').getContext('2d'); + var img = new Image(); + img.src = 'common/images/example.jpg'; + img.onload = function() { + console.log('Image load success'); + ctx.drawImage(img, 0, 0, 360, 250); + }; + img.onerror = function() { + console.log('Image load fail'); + }; + } +} +``` + +![](figures/1-9.png) diff --git a/en/application-dev/reference/arkui-js/js-components-canvas-imagebitmap.md b/en/application-dev/reference/arkui-js/js-components-canvas-imagebitmap.md index 10d8bceff27ac5457b9e2003781b87b27d0dff8f..b8fa0a4cf0f4a21c43b61b6de94bea3191241cd0 100644 --- a/en/application-dev/reference/arkui-js/js-components-canvas-imagebitmap.md +++ b/en/application-dev/reference/arkui-js/js-components-canvas-imagebitmap.md @@ -1,9 +1,9 @@ # ImageBitmap >![](../../public_sys-resources/icon-note.gif) **NOTE:** ->The APIs of this module are supported since API version 7. +>**ImageBitmap** is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -The **ImageBitmap** object is generated by the **transferToImageBitmap\(\)** method of the **OffscreenCanvas** object and stores the pixel data rendered by the offscreen canvas. +The **ImageBitmap** object is generated by the **transferToImageBitmap\(\)** method of the **OffscreenCanvas** and stores the pixel data rendered on the **OffscreenCanvas**. ## Attributes @@ -32,4 +32,3 @@ The **ImageBitmap** object is generated by the **transferToImageBitmap\(\)**
    - diff --git a/en/application-dev/reference/arkui-js/js-components-canvas-imagedata.md b/en/application-dev/reference/arkui-js/js-components-canvas-imagedata.md index ca3d42fa56432c1ca77b46cb32b5da9f3dac665d..5be0cc8d984b5eb433c4fe476d18f83a7b857283 100644 --- a/en/application-dev/reference/arkui-js/js-components-canvas-imagedata.md +++ b/en/application-dev/reference/arkui-js/js-components-canvas-imagedata.md @@ -37,3 +37,29 @@
    +## Example + +``` + +
    + +
    +``` + +``` +//xxx.js +import prompt from '@system.prompt'; +export default { + onShow() { + const el =this.$refs.canvas; + const ctx = el.getContext('2d'); + ctx.fillRect(0,0,200,200) + var imageData = ctx.createImageData(1,1) + prompt.showToast({ + message:imageData, + duration:5000 + }) + } +} +``` + diff --git a/en/application-dev/reference/arkui-js/js-components-canvas-offscreencanvas.md b/en/application-dev/reference/arkui-js/js-components-canvas-offscreencanvas.md index c23d6a59618fc4325cd1d8c62a0bf54743af55dd..ff809fb5f91c182738670f03821508e6de31e301 100644 --- a/en/application-dev/reference/arkui-js/js-components-canvas-offscreencanvas.md +++ b/en/application-dev/reference/arkui-js/js-components-canvas-offscreencanvas.md @@ -1,9 +1,9 @@ # OffscreenCanvas >![](../../public_sys-resources/icon-note.gif) **NOTE:** ->The APIs of this module are supported since API version 7. +>**OffscreenCanvas** is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -Defines a canvas object that can be rendered off the screen. +**OffscreenCanvas** defines a canvas object that can be rendered off the screen. ## Attributes @@ -20,14 +20,14 @@ Defines a canvas object that can be rendered off the screen.

    number

    Width of the offscreen canvas object.

    +

    Width of the OffscreenCanvas object.

    height

    number

    Height of the offscreen canvas object.

    +

    Height of the OffscreenCanvas object.

    - - - - - - - - - - - - - - - - - -

    Name

    -

    Parameter

    -

    Description

    -

    getContext

    -

    contextId: "2d", options?: CanvasRenderingContext2DSettings

    -

    The invoking methods are as follows:

    -

    var ctx = canvas.getContext(contextId);

    -

    var ctx = canvas.getContext(contextId, options);

    -

    The contextId parameter is mandatory. Currently, only the value 2d is supported. The options parameter is optional and is not supported currently.

    -

    Obtains the context for drawing on an offscreen canvas. The parameter can be set only to 2d. The return value is a 2D drawing object that provides specific 2D drawing operations. For details, see OffscreenCanvasRenderingContext2D.

    -

    toDataURL

    -

    type?: string, quality?: number

    -

    Generates a URL containing image display information.

    -
    • type: specifies the image format. This parameter is optional. The default value is image/png.
    • quality: specifies the image quality, which ranges from 0 to 1 when the image format is image/jpeg or image/webp. If the value of this parameter exceeds the value range, the default value 0.92 will be used.
    -

    transferToImageBitmap

    -

    None

    -

    Creates an ImageBitmap object from the most recent image rendered by Offscreen Canvas.

    -
    +### getContext + +getContext\(type: string, options?: CanvasRenderingContext2DSettings\): OffscreenCanvasRenderingContext2D + +Obtains the **OffscreenCanvas** context. This method returns a 2D drawing object. + +- Parameters + + + + + + + + + + + + + + + + + + + +

    Name

    +

    Type

    +

    Mandatory

    +

    Description

    +

    contextId

    +

    string

    +

    Yes

    +

    The value can only be "2d".

    +

    options

    +

    CanvasRenderingContext2DSettings

    +

    No

    +

    2D drawing object, which can be used to draw rectangles, images, and texts, on the OffscreenCanvas.

    +
    + +- Return values + + + + + + + + + + +

    Type

    +

    Description

    +

    OffscreenCanvasRenderingContext2D

    +

    2D drawing object, which can be used to draw rectangles, images, and texts, on the OffscreenCanvas.

    +
    + + +### toDataURL + +toDataURL\(type?: string, quality?:number\): + +Generates a URL containing image display information. + +- Parameters + + + + + + + + + + + + + + + + + + + +

    Name

    +

    Type

    +

    Mandatory

    +

    Description

    +

    type

    +

    string

    +

    No

    +

    Image format. The default value is image/png.

    +

    quality

    +

    number

    +

    No

    +

    Image quality, which ranges from 0 to 1, when the image format is image/jpeg or image/webp. If the set value is beyond the value range, the default value 0.92 is used.

    +
    + +- Return values + + + + + + + + + + +

    Type

    +

    Description

    +

    string

    +

    Image URL.

    +
    + + +### transferToImageBitmap + +transferToImageBitmap\(\): ImageBitmap + +Creates an **ImageBitmap** object on the most recently rendered image of the **OffscreenCanvas**. + +- Return values + + + + + + + + + + +

    Type

    +

    Description

    +

    ImageBitmap

    +

    Pixel data rendered on the OffscreenCanvas.

    +
    + ## Example ``` -var canvas = this.$refs.canvasId.getContext('2d'); -var offscreen = new OffscreenCanvas(500,500); -var offscreenCanvasCtx = offscreen.getContext("2d"); + +
    + +
    +``` + +``` +//xxx.js +export default { + onShow() { + var canvas = this.$refs.canvasId.getContext('2d'); + var offscreen = new OffscreenCanvas(500,500); + var offscreenCanvasCtx = offscreen.getContext("2d"); -// ... some drawing for the canvas using the offscreenCanvasCtx ... + // ... some drawing for the canvas using the offscreenCanvasCtx ... -var dataURL = offscreen.toDataURL(); -console.log(dataURL); //data:image/png;base64,xxxxxx + var dataURL = offscreen.toDataURL(); + console.log(dataURL); //data:image/png;base64,xxxxxx -var bitmap = offscreen.transferToImageBitmap(); -canvas.transferFromImageBitmap(bitmap); + var bitmap = offscreen.transferToImageBitmap(); + canvas.transferFromImageBitmap(bitmap); + } +} ``` diff --git a/en/application-dev/reference/arkui-js/js-components-canvas-path2d.md b/en/application-dev/reference/arkui-js/js-components-canvas-path2d.md index bfbaf4f5b612b052ea3b0ab71ff41b2bfcdc7437..fe67c0ed601ba28ea698ed343546002bdbd50827 100644 --- a/en/application-dev/reference/arkui-js/js-components-canvas-path2d.md +++ b/en/application-dev/reference/arkui-js/js-components-canvas-path2d.md @@ -1,9 +1,6 @@ # Path2D -**** allows you to describe a path through an existing path. This path can be drawn through the **stroke** API of **Canvas**. - ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->This component is supported since API version 6. +**Path2D** allows you to describe a path through an existing path. This path can be drawn through the **stroke** API of **Canvas**. ## addPath @@ -14,7 +11,7 @@ Adds a path to this path. - Parameters -

    Parameter

    + @@ -34,27 +31,40 @@ Adds a path to this path. - Example - ![](figures/en-us_image_0000001173164873.png) + ``` + +
    + +
    + ``` ``` - const ctx = canvas.getContext('2d'); - var path1 = ctx.createPath2D("M250 150 L150 350 L350 350 Z"); - var path2 = ctx.createPath2D(); - path2.addPath(path1); - ctx.stroke(path2); + //xxx.js + export default { + onShow() { + const el =this.$refs.canvas; + const ctx = el.getContext('2d'); + var path1 = ctx.createPath2D("M250 150 L150 350 L350 350 Z"); + var path2 = ctx.createPath2D(); + path2.addPath(path1); + ctx.stroke(path2); + } + } ``` + ![](figures/en-us_image_0000001173164873.png) + ## setTransform setTransform\(scaleX: number, skewX: number, skewY: number, scaleY: number, translateX: number, translateY: number\): void -Draws an arc based on the radius and points on the arc. +Sets the path transformation matrix. - Parameters -

    Name

    Type

    - - - - - - diff --git a/en/application-dev/reference/arkui-js/js-components-common-customizing-font.md b/en/application-dev/reference/arkui-js/js-components-common-customizing-font.md index d70c0865f4a15e85e06bbd35e43f0268b1f013aa..3f32ff3be75cbdb49ea11a54ec761021e7a00576 100644 --- a/en/application-dev/reference/arkui-js/js-components-common-customizing-font.md +++ b/en/application-dev/reference/arkui-js/js-components-common-customizing-font.md @@ -2,10 +2,7 @@ **font-face** is used to define the font style. You can define **font-face** in **style** to specify a font name and resource for your application and then reference this font from **font-family**. -The custom font can be loaded from the font file in a project. - ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->The font format can be .ttf or .otf. +The custom font can be loaded from the font file in a project. The font file must be in .ttf or .otf format. ## Defining @font-face @@ -24,7 +21,7 @@ Customize a font. Supported sources of customized fonts: -- Font file in the project: Specify the path of the font file in the project through **url**. \(You can use absolute paths only. For details, see [Resources and File Access Rules](js-framework-file.md#section6620355202117).\) +- Font file in the project: Specify the path of the font file in the project through **url**. \(You can use absolute paths only. For details, see [Resources and File Access Rules](../../ui/js-framework-file.md#section6620355202117).\) - You can set only one **src** attribute. diff --git a/en/application-dev/reference/arkui-js/js-components-common-events.md b/en/application-dev/reference/arkui-js/js-components-common-events.md index 8424b92f3b3b9735c03d8cc6d7f89f11b5ce64d6..b068eb1672bde489f0cc592fb83eb0df367bb36c 100644 --- a/en/application-dev/reference/arkui-js/js-components-common-events.md +++ b/en/application-dev/reference/arkui-js/js-components-common-events.md @@ -165,7 +165,7 @@ Different from private events, universal events can be bound to most components. - @@ -174,7 +174,7 @@ Different from private events, universal events can be bound to most components. - @@ -183,7 +183,7 @@ Different from private events, universal events can be bound to most components. - @@ -192,7 +192,7 @@ Different from private events, universal events can be bound to most components. - @@ -201,7 +201,7 @@ Different from private events, universal events can be bound to most components. - @@ -210,7 +210,7 @@ Different from private events, universal events can be bound to most components.

    Parameter

    + @@ -109,15 +119,28 @@ Draws an arc based on the radius and points on the arc. - Example - ![](figures/en-us_image_0000001173164873.png) + ``` + +
    + +
    + ``` ``` - const ctx = canvas.getContext('2d'); - var path = ctx.createPath2D("M250 150 L150 350 L350 350 Z"); - path.setTransform(0.8, 0, 0, 0.4, 0, 0); - ctx.stroke(path); + //xxx.js + export default { + onShow() { + const el =this.$refs.canvas; + const ctx = el.getContext('2d'); + var path = ctx.createPath2D("M250 150 L150 350 L350 350 Z"); + path.setTransform(0.8, 0, 0, 0.4, 0, 0); + ctx.stroke(path); + } + } ``` + ![](figures/en-us_image_0000001127125208.png) + ## closePath @@ -127,18 +150,31 @@ Moves the current point of the path back to the start point of the path, and dra - Example - ![](figures/en-us_image_0000001173164873.png) + ``` + +
    + +
    + ``` ``` - const ctx = canvas.getContext('2d'); - var path = ctx.createPath2D(); - path.moveTo(200, 100); - path.lineTo(300, 100); - path.lineTo(200, 200); - path.closePath(); - ctx.stroke(path); + //xxx.js + export default { + onShow() { + const el =this.$refs.canvas; + const ctx = el.getContext('2d'); + var path = ctx.createPath2D(); + path.moveTo(200, 100); + path.lineTo(300, 100); + path.lineTo(200, 200); + path.closePath(); + ctx.stroke(path); + } + } ``` + ![](figures/en-us_image_0000001127125202.png) + ## moveTo @@ -176,18 +212,31 @@ Moves the current coordinate point of the path to the target point, without draw - Example - ![](figures/en-us_image_0000001173164873.png) + ``` + +
    + +
    + ``` ``` - const ctx = canvas.getContext('2d'); - var path = ctx.createPath2D(); - path.moveTo(50, 100); - path.lineTo(250, 100); - path.lineTo(150, 200); - path.closePath(); - ctx.stroke(path); + //xxx.js + export default { + onShow() { + const el =this.$refs.canvas; + const ctx = el.getContext('2d'); + var path = ctx.createPath2D(); + path.moveTo(50, 100); + path.lineTo(250, 100); + path.lineTo(150, 200); + path.closePath(); + ctx.stroke(path); + } + } ``` + ![](figures/en-us_image_0000001173164869.png) + ## lineTo @@ -225,19 +274,32 @@ Draws a straight line from the current point to the target point. - Example - ![](figures/en-us_image_0000001173164873.png) + ``` + +
    + +
    + ``` ``` - const ctx = canvas.getContext('2d'); - var path = ctx.createPath2D(); - path.moveTo(100, 100); - path.lineTo(100, 200); - path.lineTo(200, 200); - path.lineTo(200, 100); - path.closePath(); - ctx.stroke(path); + //xxx.js + export default { + onShow() { + const el =this.$refs.canvas; + const ctx = el.getContext('2d'); + var path = ctx.createPath2D(); + path.moveTo(100, 100); + path.lineTo(100, 200); + path.lineTo(200, 200); + path.lineTo(200, 100); + path.closePath(); + ctx.stroke(path); + } + } ``` + ![](figures/en-us_image_0000001127285024.png) + ## bezierCurveTo @@ -303,20 +365,33 @@ Draws a cubic bezier curve on the canvas. - Example - ![](figures/en-us_image_0000001173164873.png) + ``` + +
    + +
    + ``` ``` - const ctx = canvas.getContext('2d'); - var path = ctx.createPath2D(); - path.moveTo(10, 10); - path.bezierCurveTo(20, 100, 200, 100, 200, 20); - ctx.stroke(path); + //xxx.js + export default { + onShow() { + const el =this.$refs.canvas; + const ctx = el.getContext('2d'); + var path = ctx.createPath2D(); + path.moveTo(10, 10); + path.bezierCurveTo(20, 100, 200, 100, 200, 20); + ctx.stroke(path); + } + } ``` + ![](figures/en-us_image_0000001173324783.png) + ## quadraticCurveTo -quadraticCurveTo\(cpx: number, cpy: number, x: number ,y: number\): void +quadraticCurveTo\(cpx: number, cpy: number, x: number, y: number\): void Draws a quadratic curve on the canvas. @@ -364,16 +439,29 @@ Draws a quadratic curve on the canvas. - Example - ![](figures/en-us_image_0000001173164873.png) + ``` + +
    + +
    + ``` ``` - const ctx = canvas.getContext('2d'); - var path = ctx.createPath2D(); - path.moveTo(10, 10); - path.quadraticCurveTo(100, 100, 200, 20); - ctx.stroke(path); + //xxx.js + export default { + onShow() { + const el =this.$refs.canvas; + const ctx = el.getContext('2d'); + var path = ctx.createPath2D(); + path.moveTo(10, 10); + path.quadraticCurveTo(100, 100, 200, 20); + ctx.stroke(path); + } + } ``` + ![](figures/en-us_image_0000001173164871.png) + ## arc @@ -439,15 +527,28 @@ Draws an arc on the canvas. - Example - ![](figures/en-us_image_0000001173164873.png) + ``` + +
    + +
    + ``` ``` - const ctx = canvas.getContext('2d'); - var path = ctx.createPath2D(); - path.arc(100, 75, 50, 0, 6.28); - ctx.stroke(path); + //xxx.js + export default { + onShow() { + const el =this.$refs.canvas; + const ctx = el.getContext('2d'); + var path = ctx.createPath2D(); + path.arc(100, 75, 50, 0, 6.28); + ctx.stroke(path); + } + } ``` + ![](figures/en-us_image_0000001173164867.png) + ## arcTo @@ -506,15 +607,28 @@ Draws an arc based on the radius and points on the arc. - Example - ![](figures/en-us_image_0000001173164873.png) + ``` + +
    + +
    + ``` ``` - const ctx = canvas.getContext('2d'); - var path = ctx.createPath2D(); - path.arcTo(150, 20, 150, 70, 50); - ctx.stroke(path); + //xxx.js + export default { + onShow() { + const el =this.$refs.canvas; + const ctx = el.getContext('2d'); + var path = ctx.createPath2D(); + path.arcTo(150, 20, 150, 70, 50); + ctx.stroke(path); + } + } ``` + ![](figures/en-us_image_0000001127125204.png) + ## ellipse @@ -537,28 +651,28 @@ Draws an ellipse in the specified rectangular region. - - - - - - - - @@ -654,13 +781,25 @@ Creates a rectangle. - Example - ![](figures/en-us_image_0000001173164873.png) + ``` + +
    + +
    + ``` ``` - const ctx = canvas.getContext('2d'); - var path = ctx.createPath2D(); - path.rect(20, 20, 100, 100); - ctx.stroke(path); + //xxx.js + export default { + onShow() { + const el =this.$refs.canvas; + const ctx = el.getContext('2d'); + var path = ctx.createPath2D(); + path.rect(20, 20, 100, 100); + ctx.stroke(path); + } + } ``` + ![](figures/en-us_image_0000001127125212.png) diff --git a/en/application-dev/reference/arkui-js/js-components-canvas.md b/en/application-dev/reference/arkui-js/js-components-canvas.md index 1c5e8895af23205c04ade64b3c97d1ae5855747b..ffc337dc7eff4415dc24a5ab9212e19ddc792be8 100644 --- a/en/application-dev/reference/arkui-js/js-components-canvas.md +++ b/en/application-dev/reference/arkui-js/js-components-canvas.md @@ -18,4 +18,3 @@ - **[OffscreenCanvasRenderingContext2D](js-offscreencanvasrenderingcontext2d.md)** - diff --git a/en/application-dev/reference/arkui-js/js-components-common-animation.md b/en/application-dev/reference/arkui-js/js-components-common-animation.md index 56c03e6547db8b4484ea2125cb5f766e50cbbace..417c9af4ab1ab4796458a581798352faf31a94b5 100644 --- a/en/application-dev/reference/arkui-js/js-components-common-animation.md +++ b/en/application-dev/reference/arkui-js/js-components-common-animation.md @@ -19,7 +19,7 @@ Components support dynamic rotation, translation, and scaling effects. These eff - - @@ -464,7 +464,7 @@ export default { } ``` -![](figures/en-us_image_0000001173324797.gif) +![](figures/en-us_image_0000001127285034.gif) ``` @@ -522,6 +522,8 @@ export default { } ``` +![](figures/en-us_image_0000001152833768.gif) + >![](../../public_sys-resources/icon-note.gif) **NOTE:** >The @keyframes rule with **from** and **to** defined cannot be dynamically bound to an element. >The following figure shows the meanings of end and start in the steps function. diff --git a/en/application-dev/reference/arkui-js/js-components-common-atomic-layout.md b/en/application-dev/reference/arkui-js/js-components-common-atomic-layout.md index 3b33bc738a6f1b4fc45a6caa80a21a37f7c36637..0e285159f68c1fe6c1be497f37b9a2f745499655 100644 --- a/en/application-dev/reference/arkui-js/js-components-common-atomic-layout.md +++ b/en/application-dev/reference/arkui-js/js-components-common-atomic-layout.md @@ -2,9 +2,6 @@ The atomic layout implements adaptive layout for screens of different sizes and types. Designers can use the atomic layout to define adaptive rules for elements on UIs of different forms. Developers can use the atomic layout to implement the adaptive UI features matching the design effect for a variety of screens. ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->The atomic layout is supported since API version 5. - ## Hiding Components You can set priority flags for a flex layout that does not support cross-row display to define the display priorities for elements in the horizontal or vertical direction. The elements are hidden based on available space of the container. @@ -92,4 +89,3 @@ A component with fixed ratio can be scaled up and down while retaining its aspec

    Name

    Type

    number

    X coordinate of the ellipse center

    +

    X-coordinate of the ellipse center

    y

    number

    Y coordinate of the ellipse center

    +

    Y-coordinate of the ellipse center

    radiusX

    number

    Ellipse radius on the x axis

    +

    Ellipse radius on the x-axis.

    radiusY

    number

    Ellipse radius on the y axis

    +

    Ellipse radius on the y-axis.

    rotation

    @@ -594,15 +708,28 @@ Draws an ellipse in the specified rectangular region. - Example - ![](figures/en-us_image_0000001173164873.png) + ``` + +
    + +
    + ``` ``` - const ctx = canvas.getContext('2d'); - var path = ctx.createPath2D(); - path.ellipse(200, 200, 50, 100, Math.PI * 0.25, Math.PI * 0.5, Math.PI, 1); - ctx.stroke(path); + //xxx.js + export default { + onShow() { + const el =this.$refs.canvas; + const ctx =el.getContext('2d'); + var path = ctx.createPath2D(); + path.ellipse(200, 200, 50, 100, Math.PI * 0.25, Math.PI * 0.5, Math.PI, 1); + ctx.stroke(path); + } + } ``` + ![](figures/en-us_image_0000001173324787.png) + ## rect @@ -625,28 +752,28 @@ Creates a rectangle.

    number

    X-coordinate of the upper left corner of the rectangle

    +

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

    y

    number

    Y-coordinate of the upper left corner of the rectangle

    +

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

    width

    number

    Width of the rectangle

    +

    Width of the rectangle.

    height

    number

    Height of the rectangle

    +

    Height of the rectangle.

    center center

    Origin position of the transformed element. The unit can be px or a percentage (relative to the animation target component). If only one value is specified, the other value is 50%. The available values for the first string are left, center, and right. The available values for the second string are top, center, and bottom.

    +

    Origin position of the transformed element. The unit can be px or a percentage (relative to the animation target component). If only one value is specified, the other one is 50%. The available values for the first string are left, center, and right. The available values for the second string are top, center, and bottom.

    Example:

    transform-origin: 200px 30%

    transform-origin: 100px top

    @@ -369,7 +369,7 @@ Components support dynamic rotation, translation, and scaling effects. These eff

    50% 50%

    Set the background image for a window. The unit can be percentage or px. The first value indicates the horizontal position, and the second value indicates the vertical position. If only one value is specified, the other value is 50%. The available values for the first string are left, center, and right. The available values for the second string are top, center, and bottom.

    +

    Set the background image for a window. The unit can be percentage or px. The first value indicates the horizontal position, and the second value indicates the vertical position. If only one value is specified, the other one is 50%. The available values for the first string are left, center, and right. The available values for the second string are top, center, and bottom.

    Example:

    • background-position: 200px 30%
    • background-position: 100px top
    • background-position: center center
    - diff --git a/en/application-dev/reference/arkui-js/js-components-common-attributes.md b/en/application-dev/reference/arkui-js/js-components-common-attributes.md index ae890a000c7ec4aad8de1c526f66877aef58a40a..7c3db13df60375b2ae5988d747d7c8747da017af 100644 --- a/en/application-dev/reference/arkui-js/js-components-common-attributes.md +++ b/en/application-dev/reference/arkui-js/js-components-common-attributes.md @@ -72,18 +72,21 @@ Common attributes are used to set component identities and appearance.

    Whether a component is disabled. If it is disabled, it cannot respond to user interaction.

    focusable

    +

    data

    boolean

    +

    string

    false

    +

    -

    No

    +

    No

    Whether a component can gain focus. When focusable is set to true, the component can respond to focus events and key events. If a key event or click event is set for the component, this attribute is set to true automatically.

    +

    Attribute set for the component to facilitate data storage and reading. In the JS file:

    +
    • Use e.target.attr.data to read data in the event callback, where e is the input parameter.
    • After a DOM element is obtained by using $element or $refs, it can be accessed through attr.data.
    +
    NOTE:

    It is recommended that you use data-* since API version 6.

    +

    data-*6+

    +

    data-*6+

    string

    DragEvent

    Triggered when dragging is ended.

    +

    Tiggered when dragging is ended.

    No

    DragEvent

    Triggered for entering the component to release.

    +

    Triggered when the dragged component enters a drop target.

    No

    DragEvent

    Triggered for being in the component to release.

    +

    Triggered when the dragged component is being dragged over a drop target.

    No

    DragEvent

    Triggered for exiting the component to release.

    +

    Triggered when the dragged component leaves a drop target.

    No

    DragEvent

    Triggered when the drop operation occurs in the droppable area.

    +

    Triggered when a component is dropped on a drop target.

    No

    >![](../../public_sys-resources/icon-note.gif) **NOTE:** ->- Events not listed in the preceding table are non-bubbling events, such as the [change event](js-components-basic-input.md#section1721512551218). For details, see the specific component. +>Events not listed in the preceding table are non-bubbling events, such as the [change event](js-components-basic-input.md#section1721512551218). For details, see the specific component. **Table 1** Attributes of the BaseEvent object @@ -268,7 +268,7 @@ Different from private events, universal events can be bound to most components.
    -**Table 3** Attributes of the TouchEvent object +**Table 3** TouchInfo - - - - +

    Attribute

    @@ -321,16 +321,9 @@ Different from private events, universal events can be bound to most components.

    Touch force.

    identifier8+

    -

    number

    -

    Unique identifier of a touch point on the screen. The value remains unchanged across the events triggered by finger movement on the screen.

    -
    - **Table 4** Attributes of the SwipeEvent object \(inherited from BaseEvent\) @@ -395,7 +388,7 @@ Different from private events, universal events can be bound to most components.
    -**Table 6** Attributes of the KeyEvent object \(inherited from BaseEvent\)7+\(Rich\) +**Table 6** Attributes of the DragEvent object \(inherited from BaseEvent\)7+

    Attribute

    @@ -481,3 +474,4 @@ export default { } } ``` + diff --git a/en/application-dev/reference/arkui-js/js-components-common-gradient.md b/en/application-dev/reference/arkui-js/js-components-common-gradient.md index f3e2c81c275ea02747579e1f339882c521391a01..e5458a9628650b97d64aac832b8c0a66ba946c74 100644 --- a/en/application-dev/reference/arkui-js/js-components-common-gradient.md +++ b/en/application-dev/reference/arkui-js/js-components-common-gradient.md @@ -1,5 +1,6 @@ # Gradient Styles + Gradient styles are commonly supported and can be set in the **style** attribute or a **.css** file. Gradients enable smooth transition between two or more specified colors. This framework supports two gradient styles: linear gradient and repeating linear gradient. @@ -8,109 +9,113 @@ This framework supports two gradient styles: linear gradient and repeating linea To use the gradient style, you need to specify the transition direction and transition color. -1. Transition direction: specified by **direction** or **angle**. +### Transition Direction - - **direction**: gradient by direction - - **angle**: gradient by angle +The available values are as follows: - ``` - background: linear-gradient(direction/angle, color, color, ...); - background: repeating-linear-gradient(direction/angle, color, color, ...); - ``` +- **direction**: gradient by direction +- **angle**: gradient by angle -2. Transition color: \#ff0000, \#ffff0000, rgb \(255, 0, 0\), and rgba \(255, 0, 0, 1\). At least two colors must be specified. +``` +background: linear-gradient(direction/angle, color, color, ...); +background: repeating-linear-gradient(direction/angle, color, color, ...); +``` -- Parameter +### Transition Color - - - - - - diff --git a/en/application-dev/reference/arkui-js/js-components-common-methods.md b/en/application-dev/reference/arkui-js/js-components-common-methods.md index 2a60d488203a815fd2f37f22380620946f1b6aa5..221a5a9de52b56488cf80ad1de5e4dcbc8961db4 100644 --- a/en/application-dev/reference/arkui-js/js-components-common-methods.md +++ b/en/application-dev/reference/arkui-js/js-components-common-methods.md @@ -2,537 +2,431 @@ After a component is assigned the **id** attribute, you can use the ID to obtain the component objects and call functions. - -

    Name

    +The following four colors are supported: \#ff0000, \#ffff0000, rgb \(255, 0, 0\) and rgba \(255, 0, 0, 1\). At least two colors must be specified. + +- Name + + + - - - - - - - - - - - - - - - - - - -

    Name

    Type

    +

    Type

    Default Value

    +

    Default Value

    Mandatory

    +

    Mandatory

    Description

    +

    Description

    direction

    +

    direction

    to <side-or-corner> <side-or-corner> = [left | right] || [top | bottom]

    +

    to <side-or-corner> <side-or-corner> = [left | right] || [top | bottom]

    to bottom (gradient from top to bottom)

    +

    to bottom (gradient from top to bottom)

    No

    +

    No

    Transition direction. For example, to right (gradient from left to right) or

    -

    to bottom right (from the top left to the bottom right).

    +

    Transition direction. For example, to right (gradient from left to right) or

    +

    to bottom right (from the top left to the bottom right).

    angle

    +

    angle

    <deg>

    +

    <deg>

    180deg

    +

    180deg

    No

    +

    No

    Transition direction. Angle between the gradient line and the y-axis (in the clockwise direction), with the geometric center of the element being the origin of coordinates and the horizontal axis being the x-axis.

    +

    Transition direction. Angle between the gradient line and the y-axis (in the clockwise direction), with the geometric center of the element being the origin of coordinates and the horizontal axis being the x-axis.

    color

    +

    color

    <color> [<length>|<percentage>]

    +

    <color> [<length>|<percentage>]

    -

    +

    -

    Yes

    +

    Yes

    Colors among which smooth transitions are rendered.

    +

    Colors among which smooth transitions are rendered.

    -- Example: +- Example + + 1. Gradient from top to bottom \(default\) ``` #gradient { height: 300px; width: 600px; + /* Gradient starts from red at the top to green at the bottom. */ + background: linear-gradient(red, #00ff00); } ``` - **Figure 1** Gradient from top to bottom \(default\) - ![](figures/gradient-from-top-to-bottom-(default).png "gradient-from-top-to-bottom-(default)") + ![](figures/111.png) - ``` - /* Gradient starts from red at the top to green at the bottom. */ - background: linear-gradient(red, #00ff00); - ``` - - **Figure 2** Gradient at an angle of 45° - ![](figures/gradient-at-an-angle-of-45.png "gradient-at-an-angle-of-45") + 2. Gradient at an angle of 45° ``` /* Gradient at an angle of 45°, changing from red to green */ - background: linear-gradient(45deg, rgb(255,0,0),rgb(0, 255, 0)); + background: linear-gradient(45deg, rgb(255,0,0),rgb(0, 255, 0)); ``` - **Figure 3** Gradient from left to right - ![](figures/gradient-from-left-to-right.png "gradient-from-left-to-right") + ![](figures/222.png) + + 3. Gradient from left to right ``` /* Gradient from left to right, which is available in the 270 px width between the left 90 px and the left 360 px (600*0.6) */ background: linear-gradient(to right, rgb(255,0,0) 90px, rgb(0, 255, 0) 60%); ``` - **Figure 4** Repeating gradient from left to right - ![](figures/repeating-gradient-from-left-to-right.png "repeating-gradient-from-left-to-right") + ![](figures/333.png) + + 4. Repeating gradient ``` - /* Repeating gradient from left to right, the area of which is 30 px (60-30) and the transparency is 0.5 */ + /* Repeating gradient from left to right, the area of which is 30 px (60-30) and the opacity is 0.5 */ background: repeating-linear-gradient(to right, rgba(255, 255, 0, 1) 30px,rgba(0, 0, 255, .5) 60px); ``` + ![](figures/444.png) diff --git a/en/application-dev/reference/arkui-js/js-components-common-mediaquery.md b/en/application-dev/reference/arkui-js/js-components-common-mediaquery.md index 8acaf040924fd9256a1d0458bf1dabdb02641e8a..fd0654a19f27593c4e7a8390c230cdf5eb5e2ec6 100644 --- a/en/application-dev/reference/arkui-js/js-components-common-mediaquery.md +++ b/en/application-dev/reference/arkui-js/js-components-common-mediaquery.md @@ -1,13 +1,13 @@ # Media Query +>![](../../public_sys-resources/icon-note.gif) **NOTE:** +>- The **media** attribute uses the actual size, physical pixel, and screen resolution of the device by default. Do not confuse them with the configuration based on basic screen width 720 px. + Media query is widely used on mobile devices. You may need to frequently modify the application style based on the device type or specific features and device parameters \(such as the screen resolution\). To keep up with your requirements, the media query component provides the following features: 1. Allows you to design different layouts matching the device and application attributes. 2. Synchronously updates the application page layouts when your screen changes dynamically \(for example, in the event of screen splitting or landscape/portrait orientation switching\). ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->The **media** attribute uses the actual size, physical pixel, and screen resolution of the device by default. Do not confuse them with the configuration based on basic screen width 720 px. - ## CSS Syntax Rules Use @media to import query statements. The rules are as follows: @@ -123,22 +123,22 @@ At MediaQuery Level 4, range query is imported so that you can use the operators

    <=

    Less than or equal to, for example, screen and (50 <= height).

    +

    Less than or equal to, for example, screen and (50 <= height).

    >=

    Greater than or equal to, for example, screen and (600 >= height).

    +

    Greater than or equal to, for example, screen and (600 >= height).

    <

    Less than, for example, screen and (50 < height).

    +

    Less than, for example, screen and (50 < height).

    >

    Greater than, for example, screen and (600 > height).

    +

    Greater than, for example, screen and (600 > height).

    - - - - - - - - - - - - - - - - - - - - - - - - - -

    Name

    -

    Parameter

    -

    Mandatory

    -

    Return Value

    -

    Description

    -

    animate

    -

    -

    keyframes: Keyframes, options: Options

    -

    Yes

    -

    -

    -

    Creates and runs an animation shortcut on the component. Specify the keyframes and options required for the animation. This method returns the animation object.

    -

    getBoundingClientRect6+

    -

    -

    -

    -

    -

    Rect

    -

    Obtains the size of the element and its position relative to the window.

    -

    createIntersectionObserver6+

    -

    ObserverParam

    -
      

    Observer

    -

    Adds an Observer, which will be notified of the changes of a component on the current page.

    -
    - -**Table 1** Rect object description 6+ - - - - - - - - - - - - - - - - - - - - - - - - -

    Attribute

    -

    Type

    -

    Description

    -

    width

    -

    number

    -

    Width of an element.

    -

    height

    -

    number

    -

    Height of an element.

    -

    left

    -

    number

    -

    Offset between the left boundary of the element and the window.

    -

    top

    -

    number

    -

    Offset between the upper boundary of the element and the window.

    -
    - -**Table 2** ObserverParam attributes6+ - - - - - - - - - - - - -

    Attribute

    -

    Type

    -

    Description

    -

    ratios

    -

    Array<number>

    -

    When the component is out of the range or is less than the range, the observer callback is triggered.

    -
    - -**Table 3** Methods supported by the Observer object6+ - - - - - - - - - - - - - - - - -

    Name

    -

    Parameter

    -

    Description

    -

    observe

    -

    callback: function

    -

    Subscribes to events of the observed object. The callback method is called when the value is greater than or less than the threshold.

    -

    unobserve

    -
      

    Unsubscribes from events of the observed object.

    -
    - -## this.$element\('_id_'\).animate\(Object, Object\) - -You can use the **animate\(keyframes: Keyframes, options: Options\)** method to obtain an animation object. This object supports properties, methods, and events of the animation component. If **animate** is called for multiple times and the replace policy is used, parameters passed to the last call will take effect. - -**Table 4** Keyframes - - - - - - - - - - - - -

    Parameter

    -

    Type

    -

    Description

    -

    frames

    -

    Array<Style>

    -

    Array of objects used to set animation style attributes. For details about style attributes, see Style attributes.

    -
    - -**Table 5** Style attributes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    Parameter

    -

    Type

    -

    Default Value

    -

    Description

    -

    width

    -

    number

    -

    -

    -

    Width set for the component during playback of the animation.

    -

    height

    -

    number

    -

    -

    -

    Height set for the component during playback of the animation.

    -

    backgroundColor

    -

    <color>

    -

    none

    -

    Background color set for the component during playback of the animation.

    -

    opacity

    -

    number

    -

    1

    -

    Opacity set for the component. The value ranges from 0 to 1.

    -

    backgroundPosition

    -

    string

    -

    -

    -

    The value format is x y, in percentage or pixels.

    -

    The first value indicates the horizontal position, and the second value indicates the vertical position.

    -

    If only one value is specified, the other value is 50% by default.

    -

    transformOrigin

    -

    string

    -

    'center center'

    -

    Origin position of the transformed element.

    -

    The first value indicates the x-axis position. The value can be left, center, right, a length, or a percentage.

    -

    The second value indicates the y-axis position. The value can be top, center, bottom, a length, or a percentage.

    -

    transform

    -

    Transform

    -

    -

    -

    Transformation type set for a transformed element.

    -

    offset

    -

    number

    -

    -

    -
    • The value of offset must be within (0.0,1.0] and sorted in ascending order if it is provided.
    • If there are only two frames, offset can be left empty.
    • If there are more than two frames, offset is mandatory.
    -
    - -**Table 6** Options - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    Parameter

    -

    Type

    -

    Default Value

    -

    Description

    -

    duration

    -

    number

    -

    0

    -

    Duration for playing the animation, in milliseconds.

    -

    easing

    -

    string

    -

    linear

    -

    Time curve of the animation. For details about the supported types, see Available values of the easing attribute.

    -

    delay

    -

    number

    -

    0

    -

    Delay for the animation start. The default value indicates no delay.

    -

    iterations

    -

    number | string

    -

    1

    -

    Number of times the animation will be played. number indicates a fixed number of playback operations, and Infinity indicates an unlimited number of playback operations.

    -

    direction6+

    -

    string

    -

    normal

    -

    Mode of playing the animation.

    -

    normal: Plays the animation in forward loop mode.

    -

    reverse: Plays the animation in reverse loop mode.

    -

    alternate: Plays the animation in alternating loop mode. When the animation is played for an odd number of times, the playback is in forward direction. When the animation is played for an even number of times, the playback is in backward direction.

    -

    alternate-reverse: Plays the animation in reverse-alternating loop mode. When the animation is played for an odd number of times, the playback is in backward direction. When the animation is played for an even number of times, the playback is in forward direction.

    -

    fill

    -

    string

    -

    none

    -

    Start and end styles of the animation.

    -

    none: No style is applied to the target before or after the animation is executed.

    -

    forwards: The target keeps the state at the end of the animation (defined in the last key frame) after the animation is executed.

    -

    backwards6+: The animation uses the value defined in the first key frame during the animation-delay. When animation-direction is set to normal or alternate, the value in the from key frame is used. When animation-direction is set to reverse or alternate-reverse, the value in the to key frame is used..

    -

    both6+: The animation follows the forwards and backwards rules.

    -
    - -**Table 7** Available values of the easing attribute - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    Type

    -

    Description

    -

    linear

    -

    The animation speed keeps unchanged.

    -

    ease-in

    -

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

    -

    ease-out

    -

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

    -

    ease-in-out

    -

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

    -

    friction

    -

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

    -

    extreme-deceleration

    -

    Extreme deceleration curve, cubic-bezier(0.0, 0.0, 0.0, 1.0).

    -

    sharp

    -

    Sharp curve, cubic-bezier(0.33, 0.0, 0.67, 1.0).

    -

    rhythm

    -

    Rhythm curve, cubic-bezier(0.7, 0.0, 0.2, 1.0).

    -

    smooth

    -

    Smooth curve, cubic-bezier(0.4, 0.0, 0.4, 1.0).

    -

    cubic-bezier(x1, y1, x2, y2)

    -

    You can customize an animation speed curve in the cubic-bezier() function. The x and y values of each input parameter must be between 0 and 1.

    -

    steps(number, step-position)6+

    -

    Step curve.

    -

    The number must be set and only an integer is supported.

    -

    step-position is optional. It can be set to start or end. The default value is end.

    -
    +## animate -- Return values +animate\( keyframes: Keyframes, options: Options\): void - Attributes supported by the animation object +- Name - -

    Attribute

    + + + - - - - - + - + - - - +

    Name

    +

    Type

    Type

    +

    Mandatory

    Description

    +

    Description

    finished

    +

    keyframes

    boolean

    +

    keyframes

    Read-only attribute, which indicates whether the animation playback is complete.

    +

    Yes

    +

    Sets the animation style.

    pending

    +

    options

    +

    Options

    boolean

    +

    Yes

    Read-only attribute, which indicates whether the animation is waiting for the completion of other asynchronous operations (for example, start an animation with a delay).

    +

    Array of objects used to set animation attributes. For details, see Options.

    playState

    +
    + + **Table 1** keyframes + + + + + + + + - - - +

    Attribute

    +

    Type

    +

    Description

    +

    frames

    string

    +

    Array<Style>

    Read-write attribute, which indicates the playback status of the animation:

    -
    • idle: The animation is not running (playback ended or not started).
    • running: The animation is running.
    • paused: The animation is paused.
    • finished: Animation playback ends.
    +

    Array of objects used to set animation attributes. For details about style attributes, see Style attributes.

    startTime

    +
    + + **Table 2** Style attributes + + + + + + + + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

    Name

    +

    Type

    +

    Default Value

    +

    Description

    +

    width

    +

    number

    number

    +

    -

    Read-write attribute, which indicates the animation start time. This attribute is similar to delay in the options attribute.

    +

    Width set for the component during playback of the animation.

    +

    height

    +

    number

    +

    -

    +

    Height set for the component during playback of the animation.

    +

    backgroundColor

    +

    <color>

    +

    none

    +

    Background color set for the component during playback of the animation.

    +

    opacity

    +

    number

    +

    1

    +

    Opacity set for the component. The value ranges from 0 to 1.

    +

    backgroundPosition

    +

    string

    +

    -

    +

    The value format is x y, in percentage or pixels.

    +

    The first value indicates the horizontal position, and the second value indicates the vertical position.

    +

    If only one value is specified, the other value is 50% by default.

    +

    transformOrigin

    +

    string

    +

    'center center'

    +

    Origin position of the transformed element.

    +

    The first value indicates the x-axis position. The value can be left, center, right, a length, or a percentage.

    +

    The second value indicates the y-axis position. The value can be top, center, bottom, a length, or a percentage.

    +

    transform

    +

    Transform

    +

    -

    +

    Transformation type set for a transformed element.

    +

    offset

    +

    number

    +

    -

    +
    • The value of offset must be within (0.0,1.0] and sorted in ascending order if it is provided.
    • If there are only two frames, offset can be left empty.
    • If there are more than two frames, offset is mandatory.
    - Methods supported by the animation object + **Table 3** Options description - -

    Method

    + + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

    Name

    +

    Type

    +

    Default Value

    Parameter

    +

    Description

    Description

    +

    duration

    +

    number

    +

    0

    +

    Duration for playing the animation, in milliseconds.

    +

    easing

    +

    string

    +

    linear

    +

    Time curve of the animation. For details about the supported types, see Available values of the easing attribute.

    +

    delay

    +

    number

    +

    0

    +

    Delay for the animation start. The default value indicates no delay.

    +

    iterations

    +

    number | string

    +

    1

    +

    Number of times the animation will be played. number indicates a fixed number of playback operations, and Infinity indicates an unlimited number of playback operations.

    +

    direction6+

    +

    string

    +

    normal

    +

    Mode of playing the animation.

    +

    normal: Plays the animation in forward loop mode.

    +

    reverse: Plays the animation in reverse loop mode.

    +

    alternate: Plays the animation in alternating loop mode. When the animation is played for an odd number of times, the playback is in forward direction. When the animation is played for an even number of times, the playback is in backward direction.

    +

    alternate-reverse: Plays the animation in reverse-alternating loop mode. When the animation is played for an odd number of times, the playback is in backward direction. When the animation is played for an even number of times, the playback is in forward direction.

    +

    fill

    +

    string

    +

    none

    +

    Start and end styles of the animation.

    +

    none: No style is applied to the target before or after the animation is executed.

    +

    forwards: The target keeps the state at the end of the animation (defined in the last key frame) after the animation is executed.

    +

    backwards6+: The animation uses the value defined in the first key frame during the animation-delay. When animation-direction is set to normal or alternate, the value in the from key frame is used. When animation-direction is set to reverse or alternate-reverse, the value in the to key frame is used.

    +

    both6+: The animation follows the forwards and backwards rules.

    +
    + + **Table 4** Available values of the easing attribute + + + + - + + + + + + + + + + + + + + + + + + + + + + + + - - + + + + + + + +

    Type

    +

    Description

    play

    +

    linear

    +

    The animation speed keeps unchanged.

    +

    ease-in

    +

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

    +

    ease-out

    +

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

    +

    ease-in-out

    +

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

    +

    friction

    +

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

    +

    extreme-deceleration

    +

    Extreme deceleration curve, cubic-bezier(0.0, 0.0, 0.0, 1.0).

    +

    sharp

    +

    Sharp curve, cubic-bezier(0.33, 0.0, 0.67, 1.0).

    +

    rhythm

    +

    Rhythm curve, cubic-bezier(0.7, 0.0, 0.2, 1.0).

    +

    smooth

    -

    +

    Smooth curve, cubic-bezier(0.4, 0.0, 0.4, 1.0).

    Plays the animation.

    +

    cubic-bezier(x1, y1, x2, y2)

    +

    You can customize an animation speed curve in the cubic-bezier() function. The x and y values of each input parameter must be between 0 and 1.

    +

    steps(number, step-position)6+

    Step curve.

    +

    The number must be set and only an integer is supported.

    +

    step-position is optional. It can be set to start or end. The default value is end.

    +
    + +- Return values + + The **animation** attributes are as follows. + + + + + - + - - - - - - - - - - -

    Attribute

    +

    Type

    +

    Description

    +

    finish

    +

    finished

    -

    +

    boolean

    Ends the animation.

    +

    Read-only attribute, which indicates whether the animation playback is complete.

    pause

    +

    pending

    -

    +

    boolean

    Pauses the animation.

    +

    Read-only attribute, which indicates whether the animation is waiting for the completion of other asynchronous operations (for example, start an animation with a delay).

    cancel

    +

    playState

    -

    +

    string

    Cancels the animation.

    +

    Read-write attribute, which indicates the playback status of the animation:

    +
    • idle: The animation is not running (playback ended or not started).
    • running: The animation is running.
    • paused: The animation is paused.
    • finished: Animation playback ends.

    reverse

    +

    startTime

    -

    +

    number

    Plays the animation in reverse direction.

    +

    Read-write attribute, which indicates the animation start time. This attribute is similar to delay in the options attribute.

    - Events supported by the animation object + Methods for animation - - - - @@ -325,29 +329,13 @@ You can set component appearance in the **style** attribute or **.css** file

    backdrop-filter: blur(10px)

    - - - - - - - - - -

    Event

    + + - + - + - - - + - + - - - + + + + +

    Method

    Description

    +

    Parameter

    +

    Description

    start6+

    +

    play

    +

    -

    The animation starts.

    +

    Plays the animation.

    cancel

    +

    finish

    The animation is forcibly canceled.

    +

    -

    +

    Ends the animation.

    finish

    +

    pause

    +

    -

    The animation playback is complete.

    +

    Pauses the animation.

    repeat

    +

    cancel

    The animation repeats.

    +

    -

    +

    Cancels the animation.

    +

    reverse

    +

    -

    +

    Plays the animation in reverse.

    + Events for animation -- Example code: + + + + + + + + + + + + + + + + + + +

    Event

    +

    Description

    +

    start6+

    +

    The animation starts.

    +

    cancel

    +

    The animation is forcibly canceled.

    +

    finish

    +

    The animation playback is complete.

    +

    repeat

    +

    The animation repeats.

    +
    + +- Example ``` @@ -628,13 +522,59 @@ You can use the **animate\(keyframes: Keyframes, options: Options\)** method t } ``` - ![](figures/en-us_image_0000001173324753.gif) + ![](figures/animationapi-4.gif) + +## getBoundingClientRect -## this.$element\('_id_'\).getBoundingClientRect\(\)6+ +getBoundingClientRect\(\): [ ](#table1650917111414) Obtains the size of the element and its position relative to the window. +- Return values + + **Table 5** Rect attributes6+ + + + + + + + + + + + + + + + + + + + + + + + + +

    Attribute

    +

    Type

    +

    Description

    +

    width

    +

    number

    +

    Width of an element.

    +

    height

    +

    number

    +

    Height of an element.

    +

    left

    +

    number

    +

    Offset between the left boundary of the element and the window.

    +

    top

    +

    number

    +

    Offset between the upper boundary of the element and the window.

    +
    + - Example ``` @@ -644,10 +584,88 @@ Obtains the size of the element and its position relative to the window. ``` -## this.$element\('_id_'\).createIntersectionObserver\(\)6+ +## createIntersectionObserver + +createIntersectionObserver\(param?: [ObserverParam](#table143341035121917)\):[Observer](#table4506633141711) Gets notified of the visibility of an element on the current page. +- Name + + + + + + + + + + + + + + +

    Name

    +

    Type

    +

    Mandatory

    +

    Description

    +

    param

    +

    ObserverParam

    +

    -

    +

    Obtains the observer callback.

    +
    + + **Table 6** ObserverParam attributes6+ + + + + + + + + + + + + +

    Attribute

    +

    Type

    +

    Description

    +

    ratios

    +

    Array<number>

    +

    When the component is out of the range or is less than the range, the observer callback is triggered.

    +
    + +- Return values + + **Table 7** Methods supported by the Observer object6+ + + + + + + + + + + + + + + + + +

    Name

    +

    Parameter

    +

    Description

    +

    observe

    +

    callback: function

    +

    Subscribes to events of the observed object. The callback method is called when the value is greater than or less than the threshold.

    +

    unobserve

    +

    -

    +

    Unsubscribes from events of the observed object.

    +
    + - Example ``` @@ -663,4 +681,3 @@ Gets notified of the visibility of an element on the current page. observer.unobserve() ``` - diff --git a/en/application-dev/reference/arkui-js/js-components-common-styles.md b/en/application-dev/reference/arkui-js/js-components-common-styles.md index 3d8101ef286e7a4dc9d0ad607da1a3e4b5ce2a61..efa11d67495646d34ef6250230ca4fcdb6497f55 100644 --- a/en/application-dev/reference/arkui-js/js-components-common-styles.md +++ b/en/application-dev/reference/arkui-js/js-components-common-styles.md @@ -150,8 +150,8 @@ You can set component appearance in the **style** attribute or **.css** file

    solid

    Shorthand attribute to set the style for all borders. Available values are as follows:

    -
    • dotted: Dotted border. The radius of a dot is half of border-width.
    • dashed: Dashed border
    -
    • solid: Solid border
    +
    • dotted: dotted border. The radius of a dot is half of border-width.
    • dashed: dashed border.
    +
    • solid: solid border.

    border-[left|top|right|bottom]-style

    @@ -215,6 +215,8 @@ You can set component appearance in the **style** attribute or **.css** file

    -

    Attribute to set the radius of round borders of an element. This attribute cannot be used to set the width, color, or style of a specific border. To set the width or color, you need to set border-width, border-color, or border-style for all the borders at the same time.

    +
    NOTE:

    In the four-value syntax, the values apply to lower-left corner, lower-right corner, upper-left corner, and upper-right corner, respectively.

    +

    border-[top|bottom]-[left|right]-radius

    @@ -223,7 +225,7 @@ You can set component appearance in the **style** attribute or **.css** file

    -

    Attribute to receptively set the radii of upper-left, upper-right, lower-right, and lower-left rounded corners

    +

    Attribute to respectively set the radii of upper-left, upper-right, lower-right, and lower-left rounded corners

    background

    @@ -250,9 +252,11 @@ You can set component appearance in the **style** attribute or **.css** file

    -

    Background image. Currently, this attribute is not compatible with background-color or background. Local and online image resources are supported.

    -

    Example:

    -

    background-image: url("/common/background.png")

    +

    Background image. Currently, this attribute is not compatible with background-color or background. Local image resources are supported.

    +

    Example:

    +
    • background-image: url("/common/background.png")
      NOTE:

      The SVG format is not supported.

      +
      +

    background-size

    @@ -264,7 +268,7 @@ You can set component appearance in the **style** attribute or **.css** file

    Background image size.

    • The string values are as follows:
      • contain: Expands the image to the maximum size so that the height and width of the image are applicable to the content area.
      • cover: Extends the background image to a large enough size so that the background image completely covers the background area. Some parts of the image may not be displayed in the background area.
      • auto: The original image width-height ratio is retained.
    • The two <length> values are as follows:

      Width and height of the background image. The first value indicates the width, and the second value indicates the height. If you only set one value, the other value is set to auto by default.

      -
    • The two <percentage> values are as follows:

      Width and height of the background image in percentage of the parent element. The first value indicates the width, and the second value indicates the height. If you only set one value, the other value is set to auto by default.

      +
    • The two <percentage> values are as follows:

      Width and height of the background image in percentage of the parent element. The first value indicates the width, and the second value indicates the height. If you only set one value, the other value is set to auto by default.

    window-filter5+

    -

    string

    -

    -

    -

    Blur degree and style for windows within the component layout. If this style is not set, the default value 0% (no blur) is used.

    -

    Different blur degrees and styles for multiple blur areas are not supported.

    -

    Available blur styles are as follows: small_light (default value), medium_light, large_light, xlarge_light, small_dark, medium_dark, large_dark, and xlarge_dark.

    -

    Syn tax: window-filter: blur(percent, style5+)

    -

    Example:

    -
    • window-filter: blur(50%)
    • window-filter: blur(10%), large_light
    -
    NOTE:

    This style is only supported on phones and tablets.

    -
    -

    opacity

    number

    1

    Transparency of an element. The value ranges from 0 to 1. The value 1 means opaque, and 0 means completely transparent.

    +

    Opacity of an element. The value ranges from 0 to 1. The value 1 means opaque, and 0 means completely transparent.

    display

    @@ -380,7 +368,7 @@ You can set component appearance in the **style** attribute or **.css** file

    -

    How to divide available space of the parent component for a child component.

    +

    How to divide available space of the parent component for each child component.

    You can set one, two5+, or three5+ values for this style.

    Set one value in either of the following ways:

    • A unitless number to set flex-grow.
    • A valid width value5+ to set flex-basis.
    @@ -524,10 +512,10 @@ You can set component appearance in the **style** attribute or **.css** file

    auto

    Display size of the mask image. The setting is valid only when mask-image is set to an image source.

    -

    The string values are as follows:

    -
    • contain: Expands the image to the maximum size so that the height and width of the image are applicable to the content area.
    • cover: Extends the image to a large enough size so that it completely covers the background area. Some parts of the image may not be displayed in the background area.
    • auto: The original image width-height ratio is retained.
    -

    length indicates the width and height of the image. The first value indicates the width, and the second value indicates the height. If you only set one value, the other value is set to auto by default.

    -

    When you set the width and height with percentage values, the image size is set in relative to the original size. The first value indicates the width, and the second value indicates the height. If you only set one value, the other value is set to auto by default.

    +

    The string values are as follows:

    +
    • contain: Expands the image to the maximum size so that the height and width of the image are applicable to the content area.
    • cover: Extends the image to a large enough size so that it completely covers the background area. Some parts of the image may not be displayed in the background area.
    • auto: The original image width-height ratio is retained.
    +

    length indicates the width and height of the image. The first value indicates the width, and the second value indicates the height. If you only set one value, the other value is set to auto by default.

    +

    When you set the width and height with percentage values, the image size is set in relative to the original size. The first value indicates the width, and the second value indicates the height. If you only set one value, the other value is set to auto by default.

    mask-position6+

    @@ -537,11 +525,11 @@ You can set component appearance in the **style** attribute or **.css** file

    0px 0px

    Display position of the mask image. The setting is valid only when mask-image is set to an image source. Using keywords: If only one keyword is specified, the other value is center by default. The two values define the horizontal position and vertical position, respectively.

    -

    The string values are as follows:

    -
    • left: leftmost in the horizontal direction
    • right: rightmost in the horizontal direction
    • top: top in the vertical direction
    • bottom: bottom in the vertical direction
    • center: center position
    -

    Using <length>: The first value indicates the horizontal position, and the second value indicates the vertical position. 0 0 indicates the upper left corner. The unit is pixel. If only one value is specified, the other one is 50%.

    -

    Using <percentage>: The first value indicates the horizontal position, and the second value indicates the vertical position. 0% 0% indicates the upper left corner. 100% 100% indicates the lower right corner. If only one value is specified, the other one is 50%.

    -

    Using both <percentage> and <length>.

    +

    The string values are as follows:

    +
    • left: leftmost in the horizontal direction
    • right: rightmost in the horizontal direction
    • top: top in the vertical direction
    • bottom: bottom in the vertical direction
    • center: center position
    +

    Using <length>: The first value indicates the horizontal position, and the second value indicates the vertical position. 0 0 indicates the upper left corner. The unit is pixel. If only one value is specified, the other one is 50%.

    +

    Using <percentage>: The first value indicates the horizontal position, and the second value indicates the vertical position. 0% 0% indicates the upper left corner. 100% 100% indicates the lower right corner. If only one value is specified, the other one is 50%.

    +

    Using both <percentage> and <length>.

    border-image-source7+

    @@ -575,7 +563,7 @@ You can set component appearance in the **style** attribute or **.css** file

    0

    Width of the image boundary.

    +

    Width of the border image.

    If you set only one value, it specifies the width for four sides.

    If you set two values, the first value specifies the top and bottom width, and the second value specifies the left and right width.

    If you set three values, the first value specifies the top width, the second value specifies the left and right width, and the third value specifies the bottom width.

    @@ -588,7 +576,7 @@ You can set component appearance in the **style** attribute or **.css** file

    0

    Size of the border image that can exceed the border.

    +

    How far the border image can extend beyond the border box.

    If you set only one value, it specifies the distance of the boarder image beyond the border on four sides.

    If you set two values, the first value specifies the distance of the boarder image's top and bottom sides beyond the boarder, and the second value specifies the distance of the boarder image's left and right sides beyond the boarder.

    If you set three values, the first value specifies the distance of the boarder image's top side beyond the boarder, the second value specifies the distance of the boarder image's left and right sides beyond the boarder, and the third value specifies the distance of the boarder image's bottom side beyond the boarder.

    @@ -601,10 +589,10 @@ You can set component appearance in the **style** attribute or **.css** file

    stretch

    How the image fills the border.

    -

    stretch: stretches the image to fill the border.

    -

    repeat: tiles the image to fill the border.

    -

    round: tiles the image. When the image cannot be tiled for an integer number of times, it can be scaled based on the site requirements.

    +

    How the border image fills the border box.

    +

    stretch: stretches the image to fill the border box.

    +

    repeat: tiles the image to fill the border box.

    +

    round: tiles the image to fill the border box. When the image cannot be tiled for an integer number of times, it can be scaled based on the site requirements.

    border-image7+

    @@ -614,7 +602,7 @@ You can set component appearance in the **style** attribute or **.css** file

    -

    Shorthand attribute. The options are as follows:

    -
    • Attributes of the image border. The parameters include border-image-source, border-image-slice, border-image-width, border-image-outset, and border-image-repeat, respectively meaning the padding, width of the image border, size of the border image that can exceed the border, and how the image fills the border. The default values are used if the parameters are not set.

      Syntax reference: <'border-image-source'> || <'border-image-slice'> [ / <'border-image-width'> | / <'border-image-width'>? / <'border-image-outset'> ]? || <'border-image-repeat'>

      +
      • Gradient color border.

        Example

        border-image: linear-gradient(red, yellow) 10px

        diff --git a/en/application-dev/reference/arkui-js/js-components-common-transition.md b/en/application-dev/reference/arkui-js/js-components-common-transition.md index 55f2c7f3b7a2f8f0b83bfd3a0d89548bc5af7a44..b58d402c1b7120215e371b097ed4f246356dccad 100644 --- a/en/application-dev/reference/arkui-js/js-components-common-transition.md +++ b/en/application-dev/reference/arkui-js/js-components-common-transition.md @@ -1,94 +1,93 @@ # Transition Styles -## Transition of Shared Elements -**Table 1** Transition of shared elements +## Transition of Shared Elements - +### Attributes -

        Name

        + + - - - - - - -

        Name

        Type

        +

        Type

        Default Value

        +

        Default Value

        Description

        +

        Description

        shareid

        +

        shareid

        string

        +

        string

        N/A

        +

        N/A

        Used for the transition of shared elements and takes effect only when it is configured. list-item, image, text, button, label components are supported for the transition of shared elements.

        +

        Used for the transition of shared elements and takes effect only when it is configured. list-item, image, text, button, label components are supported for the transition of shared elements.

        -**Table 2** Transition styles of shared elements +### Styles - - -

        Name

        + + - - - - - - - - - - - - - - -

        Name

        Type

        +

        Type

        Default Value

        +

        Default Value

        Description

        +

        Description

        shared-transition-effect

        +

        shared-transition-effect

        string

        +

        string

        exchange

        +

        exchange

        Entry style of shared elements during the transition, which can be exchange or static.

        -

        During the transition, the style configured on the target page takes effect preferentially.

        -
        • exchange: The source page element is moved to the position of the target page element and is zoomed in or out properly.
        • static: The position of the target page element remains unchanged. You can configure the transparency animation. Currently, only the static effect configured on the target page takes effect.
        +

        Entry style of a shared element during transition.

        +
        • exchange (default): The source page element is moved to the position of the target page element and is zoomed in or out properly.
        • static: The position of the target page element remains unchanged. You can configure the transparency animation. Currently, only the static effect configured on the target page takes effect.

        shared-transition-name

        +

        shared-transition-name

        string

        +

        string

        -

        +

        -

        During the transition, the style configured on the target page takes effect preferentially. This style is used to configure the animation effect of shared elements. The animation effect is an animation sequence defined by @keyframes supporting transform and transparency animations. If the effect of the shared element conflicts with the custom animation, the latter is used.

        +

        During the transition, the style configured on the target page takes effect preferentially. This style is used to configure the animation effect of shared elements. The animation effect is an animation sequence defined by @keyframes supporting transform and transparency animations. If the effect of the shared element conflicts with the custom animation, the latter is used.

        shared-transition-timing-function

        +

        shared-transition-timing-function

        string

        +

        string

        friction

        +

        friction

        During the transition, the style configured on the target page takes effect preferentially. This attribute defines the difference curve during the transition of shared elements. The friction curve is used by default if this parameter is not configured.

        +

        During the transition, the style configured on the target page takes effect preferentially. This property defines the difference curve during the transition of shared elements. If this parameter is not configured, the friction curve is used by default.

        -## Precautions for Shared Elements +### Important Notes 1. If shared element transition style and customized page transition style are both configured, the latter is used. 2. The exchange effect of the shared element is similar to the transition shown in the following figure. -**Figure 1** Default transition effect of shared elements +**Figure 1** Default transition effect of shared elements ![](figures/default-transition-effect-of-shared-elements.png "default-transition-effect-of-shared-elements") 3. The shared element animation does not take effect for the border and background color of the element. 4. During the transition of a shared element, the page element is hidden. Therefore, the animation style and function set for the page element are invalid. -5. During the dynamic change of **shareid**, if the **shareid** value in component A is overwritten by that in component B, the shared element effect of component A becomes ineffective and will not be restored even if the **shareid** value is changed in component B. 5+ +5. During the dynamic change of **shareid**5+, if the **shareid** value in component A is overwritten by that in component B, the shared element effect of component A becomes ineffective and will not be restored even if the **shareid** value is changed in component B. -## Sample Code +### Example Page A jumps to Page B. The shared element is **image**, and the **shareid** is "shareImage". @@ -161,34 +160,36 @@ export default { ## Card Transition - -

        Name

        +>![](../../public_sys-resources/icon-note.gif) **NOTE:** +>Card transitions are not available when other transitions \(including shared element transitions and custom transitions\) are used. + +### Styles + + + - - - - - - -

        Name

        Type

        +

        Type

        Default Value

        +

        Default Value

        Description

        +

        Description

        transition-effect

        +

        transition-effect

        string

        +

        string

        -

        +

        -

        Whether a component on the current page displays the transition effect during a card transition. Available values are as follows:

        -
        • unfold: The component will move upwards by one card height if the component locates above the card tapped by users, or move downwards by one card height if the component locates below the card.
        • none: No transition effect is displayed.
        +

        Whether a component on the current page displays the transition effect during a card transition. Available values are as follows:

        +
        • unfold: The component will move upwards by one card height if the component locates above the card tapped by users, or move downwards by one card height if the component locates below the card.
        • none: No transition effect is displayed.
        ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->Card transitions are not available when other transitions \(including shared element transitions and custom transitions\) are used. - -## Example Code +### Example The **source\_page** has a title area on the top and a card list. Users can tap a card to switch to the **target\_page**. @@ -271,75 +272,74 @@ export default { } ``` -![](figures/transition.gif) +![](figures/form-transfer.gif) ## Page Transition Styles -**Table 3** Page transition styles +### Styles - -

        Name

        + + - - - - - - - - - - - - - - - - - - -

        Name

        Type

        +

        Type

        Default Value

        +

        Default Value

        Description

        +

        Description

        transition-enter

        +

        transition-enter

        string

        +

        string

        -

        +

        -

        Related to @keyframes, which supports transform and transparent animations. For details, see Table 2.

        +

        Related to @keyframes, which supports transform and transparent animations. For details, see Table 2.

        transition-exit

        +

        transition-exit

        string

        +

        string

        -

        +

        -

        Related to @keyframes, which supports transform and transparent animations. For details, see Table 2.

        +

        Related to @keyframes, which supports transform and transparent animations. For details, see Table 2.

        transition-duration

        +

        transition-duration

        string

        +

        string

        Follows the default page transition time of the device.

        +

        Follows the default page transition time of the device.

        The unit can be s or ms. The default unit is ms.

        +

        The unit can be s or ms. The default unit is ms. If no value is specified, the default value is used.

        transition-timing-function

        +

        transition-timing-function

        string

        +

        string

        friction

        +

        friction

        Speed curve of executing transition animation for smoother transition. For details about the parameters, see the description of the valid values of animation-timing-function in Animation Styles.

        +

        Speed curve of executing transition animation for smoother transition. For details about the parameters, see the description of the valid values of animation-timing-function in Animation Styles.

        -## Precautions for Page Transition +### Important Notes 1. When you set a customized transition, set the background color of the page to an opaque color. Otherwise, the transition effect can be harsh. 2. The **transition-enter** and **transition-exit** parameters can be configured separately. The default parameters are used if they are not configured. -3. The default value is used if **transition-duration** is not configured. -4. Notes on the **transition-enter** and **transition-exit** parameters: - 1. In the push scenario, enter the animation described by **transition-enter** of the **Page2.js** application in the page stack; enter the animation described by **transition-exit** of the **Page1.js** application in the second position of the page stack; +3. Notes on the **transition-enter** and **transition-exit** parameters: + 1. In the push scenario, enter the animation described by **transition-enter** of the **Page2.js** application in the page stack; enter the animation described by **transition-exit** of the **Page1.js** application in the second position of the page stack. - ![](figures/en-us_image_0000001173324847.png) + ![](figures/en-us_image_0000001193704354.png) 2. In the back scenario, exit the animation described by **transition-enter** of the **Page2.js** application in the page stack and play the animation in reverse sequence; exit the animation described by **transition-exit** of the Page1.js application in the second position of the page stack and play the animation in reverse sequence. - ![](figures/en-us_image_0000001127125268.png) + ![](figures/en-us_image_0000001238184345.png) diff --git a/en/application-dev/reference/arkui-js/js-components-container-badge.md b/en/application-dev/reference/arkui-js/js-components-container-badge.md index cd1452206f381e97ca8374cedae69b006886db86..b080f605d5ef2f95faa565d505965190f83db9e4 100644 --- a/en/application-dev/reference/arkui-js/js-components-container-badge.md +++ b/en/application-dev/reference/arkui-js/js-components-container-badge.md @@ -2,21 +2,18 @@ The **** component is used to mark new events that require user attention in your application. ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->This component is supported since API version 5. - -## Permission List +## Required Permissions None -## Child Component +## Child Components This component supports only one child component. >![](../../public_sys-resources/icon-note.gif) **NOTE:** >If multiple child components are used, only the first one takes effect by default. -## Attribute +## Attributes In addition to the attributes in [Universal Attributes](js-components-common-attributes.md), the following attributes are supported. @@ -172,31 +169,31 @@ In addition to the attributes in [Universal Attributes](js-components-common-at
        -## Style +## Styles Styles in [Universal Styles](js-components-common-styles.md) are supported. >![](../../public_sys-resources/icon-note.gif) **NOTE:** >The total size of child components must be smaller than or equal to that of the **** component. Otherwise, the child components cannot be displayed. -## Event +## Events Events in [Universal Events](js-components-common-events.md) are supported. -## Method +## Methods Methods in [Universal Methods](js-components-common-methods.md) are supported. -## Example Code +## Example ```
        - huawei + example - huawei + example
        ``` @@ -234,5 +231,5 @@ export default { } ``` -![](figures/en-us_image_0000001150368628.png) +![](figures/figures1.png) diff --git a/en/application-dev/reference/arkui-js/js-components-container-dialog.md b/en/application-dev/reference/arkui-js/js-components-container-dialog.md index 7efcbc9ea9eb68224f0a7b9278c3c13e90ad14e1..3428de3d7aa224dcd711a80019f9309197cb629b 100644 --- a/en/application-dev/reference/arkui-js/js-components-container-dialog.md +++ b/en/application-dev/reference/arkui-js/js-components-container-dialog.md @@ -2,15 +2,15 @@ The **** component is a custom pop-up container. -## Permission List +## Required Permissions None -## Child Component +## Child Components A single child component is supported. -## Attribute +## Attributes In addition to the attributes in [Universal Attributes](js-components-common-attributes.md), the following attributes are supported. @@ -44,11 +44,11 @@ In addition to the attributes in [Universal Attributes](js-components-common-at >![](../../public_sys-resources/icon-note.gif) **NOTE:** >- The **** component does not support the **focusable** and **click-effect** attributes. -## Style +## Styles Only the **width**, **height**, **margin**, **margin-\[left|top|right|bottom\]**, and **margin-\[start|end\]** styles in [Universal Styles](js-components-common-styles.md) are supported. -## Event +## Events Events in [Universal Events](js-components-common-events.md) are not supported. The following table lists the supported event. @@ -85,7 +85,7 @@ Events in [Universal Events](js-components-common-events.md) are not supported
        -## Method +## Methods Methods in [Universal Methods](js-components-common-methods.md) are not supported. The following table lists the supported methods. @@ -221,5 +221,5 @@ export default { } ``` -![](figures/4-24.gif) +![](figures/4.gif) diff --git a/en/application-dev/reference/arkui-js/js-components-container-div.md b/en/application-dev/reference/arkui-js/js-components-container-div.md index ac9af5aa844356f124e545c26f3474037edc2433..d898cc4f90ecdb8bcc6cd70208017d033d05949e 100644 --- a/en/application-dev/reference/arkui-js/js-components-container-div.md +++ b/en/application-dev/reference/arkui-js/js-components-container-div.md @@ -2,19 +2,19 @@ The **** component is a basic container that is used as the root node of the page structure or is used to group the content. -## Permission List +## Required Permissions None -## Child Component +## Child Components Supported -## Attribute +## Attributes Attributes in [Universal Attributes](js-components-common-attributes.md) are supported. -## Style +## Styles In addition to the styles in [Universal Styles](js-components-common-styles.md), the following styles are supported. @@ -64,7 +64,7 @@ In addition to the styles in [Universal Styles](js-components-common-styles.md)

        No

        How items are aligned along the main axis of the current line in a flex container. Available values are as follows:

        -
        • flex-start: Items are packed towards the start line.
        • flex-end: Items are packed towards the end line.
        • center: Items are centered along the line.
        • space-between: Items are positioned with space between the lines.
        • space-around: Items are positioned with space before, between, and after the lines.
        • space-evenly5+: Items are arranged with even space between each two.
        +
        • flex-start: Items are packed towards the start row.
        • flex-end: Items are packed towards the end row.
        • center: Items are centered along the row.
        • space-between: Items are positioned with space between the rows.
        • space-around: Items are positioned with space before, between, and after the rows.
        • space-evenly5+: Items are arranged with even space between each two.

        align-items

        @@ -87,8 +87,8 @@ In addition to the styles in [Universal Styles](js-components-common-styles.md)

        No

        Multi-line alignment mode when there is extra space in the cross axis. Available values are as follows:

        -
        • flex-start: All lines are packed towards the start of the cross axis. The start edge of the cross axis of the first line is aligned with the start edge of the cross axis of the container. All subsequent lines are aligned with the previous line.
        • flex-end: All lines are packed towards the end of the cross axis. The end of the cross axis of the last line is aligned with the end of the cross axis of the container. All subsequent lines are aligned with the previous line.
        • center: All lines are packed towards the center of the container. Lines are close to each other and aligned with the center of the container. The spacing between the start of the container's cross axis and the first line is equal to the spacing between the end of the container's cross axis and the last line.
        • space-between: All lines are evenly distributed in the container. The spacing between two adjacent lines is the same. The start and end edges of the container's cross axis are aligned with the edges of the first and last lines, respectively.
        • space-around: All lines are evenly distributed in the container, and the spacing between two adjacent lines is the same. The spacing between the start edge of the container's cross axis and the first line and that between the end edge and the last line are half of the spacing between two adjacent lines.
        +

        Multi-row alignment mode when there is extra space in the cross axis. Available values are as follows:

        +
        • flex-start: All rows are packed towards the start of the cross axis. The start edge of the cross axis of the first row is aligned with the start edge of the cross axis of the container. All subsequent rows are aligned with the previous row.
        • flex-end: All rows are packed towards the end of the cross axis. The end of the cross axis of the last row is aligned with the end of the cross axis of the container. All subsequent rows are aligned with the previous row.
        • center: All rows are packed towards the center of the container. Rows are close to each other and aligned with the center of the container. The spacing between the start of the container's cross axis and the first row is equal to the spacing between the end of the container's cross axis and the last row.
        • space-between: All rows are evenly distributed in the container. The spacing between two adjacent rows is the same. The start and end edges of the container's cross axis are aligned with the edges of the first and last rows, respectively.
        • space-around: All rows are evenly distributed in the container, and the spacing between two adjacent lines is the same. The spacing between the start edge of the container's cross axis and the first row and that between the end edge and the last row are half of the spacing between two adjacent rows.

        display

        @@ -224,7 +224,7 @@ In addition to the styles in [Universal Styles](js-components-common-styles.md)
        -## Event +## Events In addition to the events in [Universal Events](js-components-common-events.md), the following events are supported. @@ -268,7 +268,7 @@ In addition to the events in [Universal Events](js-components-common-events.md)
        -## Method +## Methods In addition to the methods in [Universal Methods](js-components-common-methods.md), the following events are supported. @@ -371,7 +371,7 @@ In addition to the methods in [Universal Methods](js-components-common-methods.
    -## Example Code +## Example 1. Flex style @@ -466,7 +466,7 @@ In addition to the methods in [Universal Methods](js-components-common-methods. } ``` - ![](figures/22-25.png) + ![](figures/22.png) 3. Grid style @@ -532,7 +532,7 @@ In addition to the methods in [Universal Methods](js-components-common-methods. } ``` - ![](figures/11-26.png) + ![](figures/11.png) 4. Dragging7+ @@ -570,8 +570,8 @@ In addition to the methods in [Universal Methods](js-components-common-methods. }) }, drag(e){ - this.left = e.dragevent.globalX; - this.top = e.dragevent.globalY; + this.left = e.globalX; + this.top = e.globalY; }, dragend(e){ prompt.showToast({ @@ -581,7 +581,7 @@ In addition to the methods in [Universal Methods](js-components-common-methods. } ``` - ![](figures/9-27.gif) + ![](figures/9.gif) ``` @@ -618,8 +618,8 @@ In addition to the methods in [Universal Methods](js-components-common-methods. top:0, }, drag(e){ - this.left = e.dragevent.globalX; - this.top = e.dragevent.globalY; + this.left = e.globalX; + this.top = e.globalY; }, dragenter(e){ prompt.showToast({ @@ -644,7 +644,7 @@ In addition to the methods in [Universal Methods](js-components-common-methods. } ``` - ![](figures/6-28.gif) + ![](figures/6.gif) 5. Pinching7+ @@ -700,6 +700,5 @@ In addition to the methods in [Universal Methods](js-components-common-methods. } ``` - ![](figures/5-29.gif) - + ![](figures/5.gif) diff --git a/en/application-dev/reference/arkui-js/js-components-container-form.md b/en/application-dev/reference/arkui-js/js-components-container-form.md index 7508a85a1ab09f220c05fedda318ae24e444d09d..23d52f34982ef8067457fac1bb81a02b85c471e8 100644 --- a/en/application-dev/reference/arkui-js/js-components-container-form.md +++ b/en/application-dev/reference/arkui-js/js-components-container-form.md @@ -2,9 +2,6 @@ The **** component allows the content in **input** elements to be submitted and reset. ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->This component is supported since API version 6. - ## Required Permissions None @@ -13,15 +10,15 @@ None Supported -## Attribute +## Attributes Attributes in [Universal Attributes](js-components-common-attributes.md) are supported. -## Style +## Styles Styles in [Universal Styles](js-components-common-styles.md) are supported. -## Event +## Events In addition to the events in [Universal Events](js-components-common-events.md), the following events are supported. @@ -72,23 +69,27 @@ In addition to the events in [Universal Events](js-components-common-events.md)
    -## Method +## Methods Methods in [Universal Methods](js-components-common-methods.md) are supported. -## Example: +## Example ```
    +
    - + - - Input text + +
    + Enter text - Submit - Reset +
    + Submit + Reset +
    ``` @@ -105,3 +106,5 @@ export default{ } ``` +![](figures/001.gif) + diff --git a/en/application-dev/reference/arkui-js/js-components-container-list-item-group.md b/en/application-dev/reference/arkui-js/js-components-container-list-item-group.md index 89abe5230ab735f8bf86951bc391d0bf85a130a1..94c1d783105f88d9b17b78737f92d91615633b49 100644 --- a/en/application-dev/reference/arkui-js/js-components-container-list-item-group.md +++ b/en/application-dev/reference/arkui-js/js-components-container-list-item-group.md @@ -2,19 +2,18 @@ **** is a child component of **<[list](js-components-container-list.md)\>** and is used to group items in a list. By default, the width of **** is equal to that of ****. ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->- To use this component, you must set the **columns** attribute of the parent component **** to **1**. Otherwise, **** is not displayed. ->- You can customize the width of each ****. However, if you retain the default value **stretch** of **align-items** for the parent component ****, the width of **** is equal to that of ****. You can set **align-items** to other values rather than **stretch** to make the customized **** width take effect. +- To use this component, you must set the **columns** attribute of the parent component **** to **1**. Otherwise, **** is not displayed. +- You can customize the width of each ****. However, if you retain the default value **stretch** of **align-items** for the parent component ****, the width of **** is equal to that of ****. You can set **align-items** to other values rather than **stretch** to make the customized **** width take effect. -## Permission List +## Required Permissions None -## Child Component +## Child Components Only **<[list-item](js-components-container-list-item.md)\>** are supported. -## Attribute +## Attributes In addition to the attributes in [Universal Attributes](js-components-common-attributes.md), the following attributes are supported. @@ -48,7 +47,7 @@ In addition to the attributes in [Universal Attributes](js-components-common-at >![](../../public_sys-resources/icon-note.gif) **NOTE:** >- **id** in the common attributes is used to identify a group. The input parameters of related functions and event information in the list also use **id** to uniquely identify a group. -## Style +## Styles In addition to the styles in [Universal Styles](js-components-common-styles.md), the following styles are supported. @@ -92,7 +91,7 @@ In addition to the styles in [Universal Styles](js-components-common-styles.md)
    -## Event +## Events In addition to the events in [Universal Events](js-components-common-events.md), the following events are supported. @@ -134,11 +133,11 @@ In addition to the events in [Universal Events](js-components-common-events.md)
    -## Method +## Methods Methods in [Universal Methods](js-components-common-methods.md) are supported. -## Example Code +## Example ``` diff --git a/en/application-dev/reference/arkui-js/js-components-container-list-item.md b/en/application-dev/reference/arkui-js/js-components-container-list-item.md index af8fdffb9e58970b39b71ca345571e36e4bd8db9..1a3f12dfcce31fe4780ff17bed4de809d50915f7 100644 --- a/en/application-dev/reference/arkui-js/js-components-container-list-item.md +++ b/en/application-dev/reference/arkui-js/js-components-container-list-item.md @@ -1,19 +1,16 @@ # list-item -**** is a child component of the **<[list](js-components-container-list.md)\>** component and is used to display items in a list. +**** is a child component of the **<[list](js-components-container-list.md)\>** component and is used to display items in a list. You can customize the width of each ****. However, if you retain the default value **stretch** of **align-items** for the parent component ****, the width of **** is equal to that of ****. You can set **align-items** to other values rather than **stretch** to make the customized **** width take effect. ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->You can customize the width of each ****. However, if you retain the default value **stretch** of **align-items** for the parent component ****, the width of **** is equal to that of ****. You can set **align-items** to other values rather than **stretch** to make the customized **** width take effect. - -## Permission List +## Required Permissions None -## Child Component +## Child Components -Supported +This component supports only one child component. -## Attribute +## Attributes In addition to the attributes in [Universal Attributes](js-components-common-attributes.md), the following attributes are supported. @@ -38,7 +35,7 @@ In addition to the attributes in [Universal Attributes](js-components-common-at

    No

    Type of the list-item. A list can contain multiple list-item types. The same type of list items should have the same view layout after being rendered. If the type is fixed, replace the if attribute with the show attribute to ensure that the view layout remains unchanged.

    +

    Type of the list-item. A list can contain multiple list-item types. The same type of list items should have the same view layout after being rendered. When the type is fixed, replace the if attribute with the show attribute to ensure that the view layout remains unchanged.

    primary

    @@ -75,17 +72,6 @@ In addition to the attributes in [Universal Attributes](js-components-common-at
    • none: The current item does not stick at the top.
    • normal: The current item sticks at the top and disappears with a sliding effect.
    • opacity: The current item sticks at the top and disappears gradually. This option is only supported on wearables.

    stickyradius

    -

    <length>

    -

    1000px

    -

    No

    -

    Radius of the arc for a sticky item on the wearable. If this attribute is not specified, the default radius is used. When sticky is set to none, this attribute setting is invalid.

    -

    clickeffect5+

    boolean

    @@ -101,7 +87,7 @@ In addition to the attributes in [Universal Attributes](js-components-common-at
    -## Style +## Styles In addition to the styles in [Universal Styles](js-components-common-styles.md), the following styles are supported. @@ -132,7 +118,7 @@ In addition to the styles in [Universal Styles](js-components-common-styles.md)
    -## Event +## Events In addition to the events in [Universal Events](js-components-common-events.md), the following events are supported. @@ -158,11 +144,11 @@ In addition to the events in [Universal Events](js-components-common-events.md)
    -## Method +## Methods Methods in [Universal Methods](js-components-common-methods.md) are supported. -## Example Code +## Example For details, see the [list example code](js-components-container-list.md#section24931424488). diff --git a/en/application-dev/reference/arkui-js/js-components-container-list.md b/en/application-dev/reference/arkui-js/js-components-container-list.md index b62c4a0e5548d14f260fceebe34b81d5d5ab8373..54d0630ae2437dc9fe3ce8bd2ec47bb57214e6ba 100644 --- a/en/application-dev/reference/arkui-js/js-components-container-list.md +++ b/en/application-dev/reference/arkui-js/js-components-container-list.md @@ -2,15 +2,15 @@ The **** component provides a list container that presents a series of list items arranged in a column with the same width. Lists support presentations of the same data in a multiple and coherent row style, for example, images and texts. -## Permission List +## Required Permissions N/A -## Child Component +## Child Components <[list-item](js-components-container-list-item-group.md)\> and <[list-item-group](js-components-container-list-item.md)\> -## Attribute +## Attributes In addition to the attributes in [Universal Attributes](js-components-common-attributes.md), the following attributes are supported. @@ -150,30 +150,6 @@ In addition to the attributes in [Universal Attributes](js-components-common-at
    • default: not specified (following the theme)
    • rect: rectangle
    • round: circle

    itemscale

    -

    boolean

    -

    true

    -

    No

    -

    Whether to cancel the zoom-in and zoom-out effects of the focus. This attribute takes effect only on wearables and smart TVs.

    -
    NOTE:

    This attribute takes effect only when columns is set to 1.

    -
    -

    itemcenter

    -

    boolean

    -

    false

    -

    No

    -

    Whether there is always an item at the center of the cross axis of the view for the initialization page and a page after scrolling. This attribute applies only to wearables.

    -

    updateeffect

    boolean

    @@ -200,18 +176,6 @@ In addition to the attributes in [Universal Attributes](js-components-common-at

    scrollvibrate

    -

    boolean

    -

    true

    -

    No

    -

    Whether the device vibrates when the list is scrolled. This attribute takes effect only for wearables.

    -
    • true: The device vibrates when the list is scrolled.
    • false: The device does not vibrate when the list is scrolled.
    -

    initialindex

    number

    @@ -220,8 +184,8 @@ In addition to the attributes in [Universal Attributes](js-components-common-at

    No

    Item to be displayed at the start position of the viewport when the current list is loaded for the first time. The default value is 0, indicating that the first item is displayed.

    -

    The setting does not take effect in any of the following cases:

    +

    Item to be displayed at the start position of the viewport when the current list is loaded for the first time. The default value is 0, indicating that the first item is displayed.

    +

    The setting does not take effect in any of the following cases:

    • The value you set is greater than the index of the last item.
    • The initialoffset attribute is set.
    • indexer or scrollpage is set to true.
    -## Style +## Styles In addition to the styles in [Universal Styles](js-components-common-styles.md), the following styles are supported. @@ -297,7 +261,7 @@ In addition to the styles in [Universal Styles](js-components-common-styles.md)

    No

    Item divider length. If this style is not set, the maximum length is the width of the main axis, and the actual length depends on the divider-origin parameter. This style is valid only when the divider attribute of the list is set to true.

    +

    Item divider length. If this style is not set, the maximum length is the width of the main axis, and the actual length depends on the divider-origin parameter. This style is valid only when the divider attribute of <list> is set to true.

    divider-origin5+

    @@ -308,7 +272,7 @@ In addition to the styles in [Universal Styles](js-components-common-styles.md)

    No

    Item divider offset relative to the start point of the main axis. This style is valid only when the divider attribute of the list is set to true.

    +

    Item divider offset relative to the start point of the main axis. This style is valid only when the divider attribute of <list> is set to true.

    flex-direction

    @@ -410,7 +374,7 @@ In addition to the styles in [Universal Styles](js-components-common-styles.md)
    -## Event +## Events In addition to the events in [Universal Events](js-components-common-events.md), the following events are supported. @@ -487,7 +451,7 @@ In addition to the events in [Universal Events](js-components-common-events.md)
    -## Method +## Methods In addition to the methods in [Universal Methods](js-components-common-methods.md), the following events are supported. @@ -586,7 +550,7 @@ In addition to the methods in [Universal Methods](js-components-common-methods.

    Type

    Mandatory/Optional

    +

    Mandatory

    Default Value

    - -## Example Code - -``` - -
    - - - {{$item.title}} - {{$item.date}} - - -
    -``` - -``` -// index.js -export default { - data: { - todolist: [{ - title: 'Prepare for the interview', - date: 'Dec 31, 2021 10:00:00', - }, { - title: 'Watch the movie', - date: 'Dec 31, 2021 20:00:00', - }], - }, -} -``` - -``` -/* index.css */ -.container { - display: flex; - justify-content: center; - align-items: center; - left: 0px; - top: 0px; - width: 454px; - height: 454px; -} -.todo-wrapper { - width: 454px; - height: 300px; -} -.todo-item { - width: 454px; - height: 80px; - flex-direction: column; -} -.todo-title { - width: 454px; - height: 40px; - text-align: center; -} -``` - -![](figures/33-30.png) - diff --git a/en/application-dev/reference/arkui-js/js-components-container-panel.md b/en/application-dev/reference/arkui-js/js-components-container-panel.md index 049e0d5f647eadec0b2f695da6cbddbb8885474b..6d45f57ae91364b353ffbf8874aee8027b36a297 100644 --- a/en/application-dev/reference/arkui-js/js-components-container-panel.md +++ b/en/application-dev/reference/arkui-js/js-components-container-panel.md @@ -2,14 +2,11 @@ The **** component is a slidable panel. It provides a lightweight content display window with flexible sizes. The **** component pops up when it is displayed. ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->This component is supported since API version 5. - -## Child Component +## Child Components Yes -## Attribute +## Attributes In addition to the attributes in [Universal Attributes](js-components-common-attributes.md), the following attributes are supported. @@ -107,7 +104,7 @@ In addition to the attributes in [Universal Attributes](js-components-common-at >- Rendering attributes, including **for**, **if**, and **show**, are not supported. >- The **focusable** and **disabled** attributes are not supported. -## Style +## Styles Only the following style attributes are supported. @@ -393,13 +390,13 @@ Only the following style attributes are supported.

    No

    Transparency of an element. The value ranges from 0 to 1. The value 1 means opaque, and 0 means completely transparent.

    +

    Opacity of an element. The value ranges from 0 to 1. The value 1 means opaque, and 0 means completely transparent.

    -## Event +## Events The following events are supported. @@ -428,7 +425,7 @@ The following events are supported.
    -## Method +## Methods Only the following methods are supported. @@ -458,7 +455,7 @@ Only the following methods are supported.
    -## Example Code +## Example ``` diff --git a/en/application-dev/reference/arkui-js/js-components-container-popup.md b/en/application-dev/reference/arkui-js/js-components-container-popup.md index 784e9ac5cede7b7f491f0c9ddb5bccb6f45942c1..dc2baeeb728ab71e6662ef5ca87c35b8465a5560 100644 --- a/en/application-dev/reference/arkui-js/js-components-container-popup.md +++ b/en/application-dev/reference/arkui-js/js-components-container-popup.md @@ -2,15 +2,15 @@ The **** component is used to display a pop-up to offer instructions after a user clicks a bound control. -## Permission List +## Required Permissions None -## Child Component +## Child Components All child components are supported. Each **** can have only one child component5+. -## Attribute +## Attributes In addition to the attributes in [Universal Attributes](js-components-common-attributes.md), the following attributes are supported. @@ -91,7 +91,7 @@ In addition to the attributes in [Universal Attributes](js-components-common-at >![](../../public_sys-resources/icon-note.gif) **NOTE:** >- The **focusable** attribute is not supported. -## Style +## Styles In addition to the styles in [Universal Styles](js-components-common-styles.md), the following styles are supported. @@ -125,7 +125,7 @@ In addition to the styles in [Universal Styles](js-components-common-styles.md) >![](../../public_sys-resources/icon-note.gif) **NOTE:** >- Position-related styles are not supported. -## Event +## Events In addition to the events in [Universal Events](js-components-common-events.md), the following events are supported. @@ -148,7 +148,7 @@ In addition to the events in [Universal Events](js-components-common-events.md)
    -## Method +## Methods Only the following methods are supported. diff --git a/en/application-dev/reference/arkui-js/js-components-container-refresh.md b/en/application-dev/reference/arkui-js/js-components-container-refresh.md index 3bba3f740b390b2b45da5f8dfbc4b83f1c3479c3..d428fe32b243f25b76cd92bd7c9e88a221d166bd 100644 --- a/en/application-dev/reference/arkui-js/js-components-container-refresh.md +++ b/en/application-dev/reference/arkui-js/js-components-container-refresh.md @@ -2,15 +2,15 @@ The **** component is used to pull down to refresh the page. -## Permission List +## Required Permissions None -## Child Component +## Child Components Supported -## Attribute +## Attributes In addition to the attributes in [Universal Attributes](js-components-common-attributes.md), the following attributes are supported. @@ -99,7 +99,7 @@ In addition to the attributes in [Universal Attributes](js-components-common-at
    -## Style +## Styles In addition to the styles in [Universal Styles](js-components-common-styles.md), the following styles are supported. @@ -141,7 +141,7 @@ In addition to the styles in [Universal Styles](js-components-common-styles.md)
    -## Event +## Events The following events are supported. @@ -173,7 +173,7 @@ The following events are supported.
    -## Method +## Methods Methods in [Universal Methods](js-components-common-methods.md) are not supported. diff --git a/en/application-dev/reference/arkui-js/js-components-container-stack.md b/en/application-dev/reference/arkui-js/js-components-container-stack.md index 8bce30af1c6222adfa4e09b7b8d0fe9ace958579..af594dff35489a9a490560c71a4cc8097be15209 100644 --- a/en/application-dev/reference/arkui-js/js-components-container-stack.md +++ b/en/application-dev/reference/arkui-js/js-components-container-stack.md @@ -2,31 +2,31 @@ The **** component provides a stack container where child components are successively stacked and the latter one overwrites the previous one. -## Permission List +## Required Permissions None -## Child Component +## Child Components Supported -## Attribute +## Attributes Attributes in [Universal Attributes](js-components-common-attributes.md) are supported. -## Style +## Styles Styles in [Universal Styles](js-components-common-styles.md) are supported. -## Event +## Events Events in [Universal Events](js-components-common-events.md) are supported. -## Method +## Methods Methods in [Universal Methods](js-components-common-methods.md) are supported. -## Example Code +## Example ``` diff --git a/en/application-dev/reference/arkui-js/js-components-container-stepper-item.md b/en/application-dev/reference/arkui-js/js-components-container-stepper-item.md index a00b5fc0ff63b1a93098e705c4919dba5379023a..07fc38fb979720ac7d4193522d15cb7d42e8cef3 100644 --- a/en/application-dev/reference/arkui-js/js-components-container-stepper-item.md +++ b/en/application-dev/reference/arkui-js/js-components-container-stepper-item.md @@ -2,18 +2,15 @@ The **** component displays a step in the step navigator. This component is the child component of ****. ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->This component is supported since API version 5. - -## Permission List +## Required Permissions None -## Child Component +## Child Components Supported -## Attribute +## Attributes In addition to the attributes in [Universal Attributes](js-components-common-attributes.md), the following attributes are supported. @@ -90,7 +87,7 @@ In addition to the attributes in [Universal Attributes](js-components-common-at
    -## Style +## Styles In addition to the styles in [Universal Styles](js-components-common-styles.md), the following styles are supported. @@ -171,7 +168,7 @@ In addition to the styles in [Universal Styles](js-components-common-styles.md)

    No

    Text modifier. Available values are as follows:

    +

    Text decoration. Available values are as follows:

    • underline: An underline is used.
    • line-through: A strikethrough is used.
    • none: The standard text is used.
    -## Method +## Methods Methods in [Universal Methods](js-components-common-methods.md) are not supported. -## Example Code +## Example For details, see the [stepper example code](js-components-container-stepper.md). diff --git a/en/application-dev/reference/arkui-js/js-components-container-stepper.md b/en/application-dev/reference/arkui-js/js-components-container-stepper.md index 0be5a62ac4fbe1a19ca741f2f9bb25a35aaf0b79..1941dfbf7e419f70d16b6869c91c71822aed6b08 100644 --- a/en/application-dev/reference/arkui-js/js-components-container-stepper.md +++ b/en/application-dev/reference/arkui-js/js-components-container-stepper.md @@ -2,21 +2,18 @@ The **** component provides a step navigator. When multiple steps are required to complete a task, you can use the **** component to navigate your users through the whole process. ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->This component is supported since API version 5. - -## Permission List +## Required Permissions None -## Child Component +## Child Components Only the **** component is supported. >![](../../public_sys-resources/icon-note.gif) **NOTE:** >Steps in the **** are sorted according to the sequence of its **** child components. -## Attribute +## Attributes In addition to the attributes in [Universal Attributes](js-components-common-attributes.md), the following attributes are supported. @@ -43,14 +40,14 @@ In addition to the attributes in [Universal Attributes](js-components-common-at
    -## Style +## Styles Styles in [Universal Styles](js-components-common-styles.md) are supported. >![](../../public_sys-resources/icon-note.gif) **NOTE:** >By default, the **** component fills entire space of its container. To optimize user experience, it is recommended that the container should be as large as the application window in size, or should be the root component. -## Event +## Events In addition to the events in [Universal Events](js-components-common-events.md), the following events are supported. @@ -101,7 +98,7 @@ In addition to the events in [Universal Events](js-components-common-events.md)
    -## Method +## Methods In addition to the methods in [Universal Methods](js-components-common-methods.md), the following events are supported. @@ -125,7 +122,7 @@ In addition to the methods in [Universal Methods](js-components-common-methods.
    -## Example Code +## Example ``` diff --git a/en/application-dev/reference/arkui-js/js-components-container-swiper.md b/en/application-dev/reference/arkui-js/js-components-container-swiper.md index 9e965577a4ef1e2b126dd9c43af517811b7a616b..2070bfb323bd72c43c663601c5bf74435565728e 100644 --- a/en/application-dev/reference/arkui-js/js-components-container-swiper.md +++ b/en/application-dev/reference/arkui-js/js-components-container-swiper.md @@ -2,15 +2,15 @@ The **** component provides a container that allows users to switch among child components by swiping operations. -## Permission List +## Required Permissions None -## Child Component +## Child Components All child components except **** are supported. -## Attribute +## Attributes In addition to the attributes in [Universal Attributes](js-components-common-attributes.md), the following attributes are supported. @@ -84,19 +84,6 @@ In addition to the attributes in [Universal Attributes](js-components-common-at

    indicatormask

    -

    boolean

    -

    false

    -

    No

    -

    Whether to use the indicator mask. If this attribute is set to true, the indicator has a gradient mask.

    -
    NOTE:

    This attribute does not take effect for smartphones.5+

    -
    -

    indicatordisabled5+

    boolean

    @@ -169,7 +156,7 @@ In addition to the attributes in [Universal Attributes](js-components-common-at
    -## Style +## Styles In addition to the styles in [Universal Styles](js-components-common-styles.md), the following styles are supported. @@ -255,7 +242,7 @@ In addition to the styles in [Universal Styles](js-components-common-styles.md)
    -## Event +## Events In addition to the events in [Universal Events](js-components-common-events.md), the following events are supported. @@ -292,7 +279,7 @@ In addition to the events in [Universal Events](js-components-common-events.md)
    -## Method +## Methods In addition to the methods in [Universal Methods](js-components-common-methods.md), the following events are supported. @@ -329,7 +316,7 @@ In addition to the methods in [Universal Methods](js-components-common-methods.
    -## Example Code +## Example ``` @@ -414,5 +401,5 @@ export default { } ``` -![](figures/4-31.gif) +![](figures/4-0.gif) diff --git a/en/application-dev/reference/arkui-js/js-components-container-tab-bar.md b/en/application-dev/reference/arkui-js/js-components-container-tab-bar.md index 3abf5f747646e5e81d824ebabaa31cbb005f2f5a..da8e5ce58aedff5c24c26a444fd85a435c45b1ee 100644 --- a/en/application-dev/reference/arkui-js/js-components-container-tab-bar.md +++ b/en/application-dev/reference/arkui-js/js-components-container-tab-bar.md @@ -2,15 +2,15 @@ **** is a child component of **<[tabs](js-components-container-tabs.md)\>** and is used to provide the area to display tab labels. Its child components are horizontally arranged. -## Permission List +## Required Permissions None -## Child Component +## Child Components Supported -## Attribute +## Attributes In addition to the attributes in [Universal Attributes](js-components-common-attributes.md), the following attributes are supported. @@ -42,19 +42,19 @@ In addition to the attributes in [Universal Attributes](js-components-common-at
    -## Style +## Styles Styles in [Universal Styles](js-components-common-styles.md) are supported. -## Event +## Events Events in [Universal Events](js-components-common-events.md) are supported. -## Method +## Methods Methods in [Universal Methods](js-components-common-methods.md) are supported. -## Example Code +## Example For details, see the [tabs example code](js-components-container-tabs.md#section14993155318710). diff --git a/en/application-dev/reference/arkui-js/js-components-container-tab-content.md b/en/application-dev/reference/arkui-js/js-components-container-tab-content.md index 9a91eca94716adc1bafbad61a7068d8ec28dccae..7de7d1f55296d9e1a1358e147d61e9e66d32a137 100644 --- a/en/application-dev/reference/arkui-js/js-components-container-tab-content.md +++ b/en/application-dev/reference/arkui-js/js-components-container-tab-content.md @@ -2,15 +2,15 @@ **** is a child component of [](js-components-container-tabs.md) and is used to provide the area for displaying the tab content. By default, its height is such that all the remaining space of the **** component is filled. The child components are arranged horizontally. When **** is used as a child element in a container, the length on the main axis direction must be specified. Otherwise, the child element cannot be displayed. -## Permission List +## Required Permissions None -## Child Component +## Child Components Supported -## Attribute +## Attributes In addition to the attributes in [Universal Attributes](js-components-common-attributes.md), the following attributes are supported. @@ -41,15 +41,15 @@ In addition to the attributes in [Universal Attributes](js-components-common-at
    -## Style +## Styles Styles in [Universal Styles](js-components-common-styles.md) are supported. -## Event +## Events Events in [Universal Events](js-components-common-events.md) are supported. -## Example Code +## Example For details, see the [tabs example code](js-components-container-tabs.md#section14993155318710). diff --git a/en/application-dev/reference/arkui-js/js-components-container-tabs.md b/en/application-dev/reference/arkui-js/js-components-container-tabs.md index 760b6269a6775dbc020700b3c3db392fed0bfb2f..7e9c8e9a4ef41133cb7889eaf4e36a286145c152 100644 --- a/en/application-dev/reference/arkui-js/js-components-container-tabs.md +++ b/en/application-dev/reference/arkui-js/js-components-container-tabs.md @@ -2,15 +2,15 @@ The **** component provides a tab container. -## Permission List +## Required Permissions None -## Child Component +## Child Components A **** can wrap at most one **<[tab-bar](js-components-container-tab-bar.md)\>** and at most one **<[tab-content](js-components-container-tab-content.md)\>**. -## Attribute +## Attributes In addition to the attributes in [Universal Attributes](js-components-common-attributes.md), the following attributes are supported. @@ -53,11 +53,11 @@ In addition to the attributes in [Universal Attributes](js-components-common-at
    -## Style +## Styles Styles in [Universal Styles](js-components-common-styles.md) are supported. -## Event +## Events In addition to the events in [Universal Events](js-components-common-events.md), the following events are supported. @@ -82,7 +82,7 @@ In addition to the events in [Universal Events](js-components-common-events.md)
    -## Example Code +## Example ``` diff --git a/en/application-dev/reference/arkui-js/js-components-custom-basic-usage.md b/en/application-dev/reference/arkui-js/js-components-custom-basic-usage.md index 0afdff1d1d9fbf7902ae02df9c6d09d47932aebf..8ea11f6fb9fa1026c6e51ff87efddd8779f32d54 100644 --- a/en/application-dev/reference/arkui-js/js-components-custom-basic-usage.md +++ b/en/application-dev/reference/arkui-js/js-components-custom-basic-usage.md @@ -27,37 +27,37 @@ The following is an example of using a custom component with **if-else**: >For child component events that are named in camel case, convert the names to kebab case when binding the events to the parent component. For example, use **@children-event** instead of **childrenEvent**: **@children-event="bindParentVmMethod"**. -## Object +**Table 1** Objects - - - - - -

    Attribute

    + - - - - - - - - - - - diff --git a/en/application-dev/reference/arkui-js/js-components-custom-lifecycle.md b/en/application-dev/reference/arkui-js/js-components-custom-lifecycle.md index ae892a75a546db5133c92591743549cb591fd136..fcadfdd427267b239e3f8660a7eca2b3bece1119 100644 --- a/en/application-dev/reference/arkui-js/js-components-custom-lifecycle.md +++ b/en/application-dev/reference/arkui-js/js-components-custom-lifecycle.md @@ -1,7 +1,7 @@ # Lifecycle Definition >![](../../public_sys-resources/icon-note.gif) **NOTE:** ->This component is supported since API version 5. +>This component is supported since API version 5. Updates will be marked with a superscript to indicate their earliest API version. We provide a range of lifecycle callbacks for custom components, including **onInit**, **onAttached**, **onDetached**, **onLayoutReady**, **onDestroy**, **onPageShow**, and **onPageHide**. You can use these callbacks to manage the internal logic of your custom components. The following describes the times when the lifecycle callbacks are invoked. diff --git a/en/application-dev/reference/arkui-js/js-components-custom-props.md b/en/application-dev/reference/arkui-js/js-components-custom-props.md index 3447328fbb5463cea57ef5c9ed4ebef100595bbe..f2a3a4c4faf87d3230de6d128c9c55ad20548f9d 100644 --- a/en/application-dev/reference/arkui-js/js-components-custom-props.md +++ b/en/application-dev/reference/arkui-js/js-components-custom-props.md @@ -1,4 +1,4 @@ -# Props +# props You can use **props** to declare attributes of a custom component and pass the attributes to the child component. The supported types of **props** include String, Number, Boolean, Array, Object, and Function. Note that a camel case attribute name \(**compProp**\) should be converted to the kebab case format \(**comp-prop**\) when you reference the attribute in an external parent component. You can add **props** to a custom component, and pass the attribute to the child component. diff --git a/en/application-dev/reference/arkui-js/js-components-custom-slot.md b/en/application-dev/reference/arkui-js/js-components-custom-slot.md index 34b14acd701527a60d2f44ac9d3790be7175be4a..b65cfd01d2603195100ed8c0709289dd7b59b692 100644 --- a/en/application-dev/reference/arkui-js/js-components-custom-slot.md +++ b/en/application-dev/reference/arkui-js/js-components-custom-slot.md @@ -1,7 +1,7 @@ # slot >![](../../public_sys-resources/icon-note.gif) **NOTE:** ->The APIs of this module are supported since API version 7. +>The APIs of this module are supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. ## Default Slot diff --git a/en/application-dev/reference/arkui-js/js-components-custom.md b/en/application-dev/reference/arkui-js/js-components-custom.md index d6148b3a87b5fb6a52ea27b35a4dd89d8ffb33a3..496a31fd7ec670877c57c061d6d36e5847e54ce4 100644 --- a/en/application-dev/reference/arkui-js/js-components-custom.md +++ b/en/application-dev/reference/arkui-js/js-components-custom.md @@ -4,7 +4,7 @@ - **[Custom Events](js-components-custom-events.md)** -- **[Props](js-components-custom-props.md)** +- **[props](js-components-custom-props.md)** - **[Event Parameter](js-components-custom-event-parameter.md)** diff --git a/en/application-dev/reference/arkui-js/js-components-grid-basic-concepts.md b/en/application-dev/reference/arkui-js/js-components-grid-basic-concepts.md index fe1a74bd0f9f9611eb4f9e44fcd8802a13c1cf13..892162f087443473485860796fa43f721967c15e 100644 --- a/en/application-dev/reference/arkui-js/js-components-grid-basic-concepts.md +++ b/en/application-dev/reference/arkui-js/js-components-grid-basic-concepts.md @@ -11,9 +11,6 @@ As a layout-auxiliary positioning tool, the grid system plays an essential role 3. Provides a flexible spacing adjustment method for applications to keep up with layout in special scenarios. ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->Grid components are supported since API version 5. - ## Concepts A column system contains of three attributes: margins, gutters, and columns. @@ -44,4 +41,3 @@ A column system contains of three attributes: margins, gutters, and columns. **lg**: 12 columns for 840 ≤ horizontal vp - diff --git a/en/application-dev/reference/arkui-js/js-components-grid-col.md b/en/application-dev/reference/arkui-js/js-components-grid-col.md index 7fdf683b0938e5988008805a36ecfb62772403cd..91bfc7498c4fec9a2e30b7829250766d5f5b080e 100644 --- a/en/application-dev/reference/arkui-js/js-components-grid-col.md +++ b/en/application-dev/reference/arkui-js/js-components-grid-col.md @@ -1,16 +1,16 @@ -# grid-col +# grid-col The **** is the child component of the **** container. -## Permission List +## Required Permissions -None +None. -## Child Component +## Child Components Supported -## Attribute +## Attributes In addition to the attributes in [Universal Attributes](js-components-common-attributes.md), the following attributes are supported. @@ -35,7 +35,7 @@ In addition to the attributes in [Universal Attributes](js-components-common-at - - - - -

    Attribute

    Type

    +

    Type

    Description

    +

    Description

    data

    +

    data

    Object/Function

    +

    Object/Function

    Data model of the page. If the attribute is of the function type, the return value must be of the object type. The attribute name cannot start with the dollar sign ($) or underscore (_). Do not use reserved words (for, if, show, and tid).

    -

    Do not use this attribute and private or public at the same time

    +

    Data model of the page. If the attribute is of the function type, the return value must be of the object type. The attribute name cannot start with a dollar sign ($) or underscore (_). Do not use reserved words (for, if, show, and tid).

    +

    Do not use this attribute and private or public at the same time. (Rich)

    props

    +

    props

    Array/Object

    +

    Array/Object

    Used for communication between components. This attribute can be transferred to components via <tag xxxx='value'>. A props name must be in lowercase and cannot start with dollar sign ($) or underscore (_). Do not use reserved words (for, if, show, and tid). Currently, props does not support functions.

    +

    Used for communication between components. This attribute can be transferred to components via <tag xxxx='value'>. A props name must be in lowercase and cannot start with a dollar sign ($) or underscore (_). Do not use reserved words (for, if, show, and tid). Currently, props does not support functions.

    computed

    +

    computed

    Object

    +

    Object

    Used for pre-processing an expression for reading and setting. The result is cached. The name cannot start with a dollar sign ($) or underscore (_). Do not use reserved words.

    +

    Used for pre-processing an object for reading and setting. The result is cached. The name cannot start with a dollar sign ($) or underscore (_). Do not use reserved words.

    No

    Number of columns occupied by this item and offset columns when sizetype is xs. If you set the value of the number type, you only set the number of occupied columns. You can set a value of the object type for both the number of occupied columns and offset columns, for example, {"span": 1, "offset": 0}.

    +

    Number of columns occupied by this item and offset columns when sizetype is xs. If you set the value of the number type, you only set the number of occupied columns. You can set a value of the object type for both the number of occupied columns and offset columns, for example, {"span": 1, "offset": 0}.

    sm

    @@ -46,7 +46,7 @@ In addition to the attributes in [Universal Attributes](js-components-common-at

    No

    Number of columns occupied by this item and offset columns when sizetype is sm. If you set the value of the number type, you only set the number of occupied columns. You can set a value of the object type for both the number of occupied columns and offset columns, for example, {"span": 1, "offset": 0}.

    +

    Number of columns occupied by this item and offset columns when sizetype is sm. If you set the value of the number type, you only set the number of occupied columns. You can set a value of the object type for both the number of occupied columns and offset columns, for example, {"span": 1, "offset": 0}.

    md

    @@ -57,7 +57,7 @@ In addition to the attributes in [Universal Attributes](js-components-common-at

    No

    Number of columns occupied by this item and offset columns when sizetype is md. If you set the value of the number type, you only set the number of occupied columns. You can set a value of the object type for both the number of occupied columns and offset columns, for example, {"span": 1, "offset": 0}.

    +

    Number of columns occupied by this item and offset columns when sizetype is md. If you set the value of the number type, you only set the number of occupied columns. You can set a value of the object type for both the number of occupied columns and offset columns, for example, {"span": 1, "offset": 0}.

    lg

    @@ -68,7 +68,7 @@ In addition to the attributes in [Universal Attributes](js-components-common-at

    No

    Number of columns occupied by this item and offset columns when sizetype is lg. If you set the value of the number type, you only set the number of occupied columns. You can set a value of the object type for both the number of occupied columns and offset columns, for example, {"span": 1, "offset": 0}.

    +

    Number of columns occupied by this item and offset columns when sizetype is lg. If you set the value of the number type, you only set the number of occupied columns. You can set a value of the object type for both the number of occupied columns and offset columns, for example, {"span": 1, "offset": 0}.

    span

    @@ -90,13 +90,13 @@ In addition to the attributes in [Universal Attributes](js-components-common-at

    No

    Default number of offset columns in the container layout direction when "offset" is not set for a specific sizetype.

    +

    Default number of offset columns in the container layout direction when "offset" is not set for a specific sizetype.

    -## Style +## Styles In addition to the styles in [Universal Styles](js-components-common-styles.md), the following styles are supported. @@ -122,7 +122,7 @@ In addition to the styles in [Universal Styles](js-components-common-styles.md)

    No

    Main axis direction of the container. Available values are as follows:

    -
    • column: Items are placed vertically from top to bottom.
    • row: Items are placed horizontally from left to right.
    +
    • column: Items are placed vertically from top to bottom.
    • row: Items are placed horizontally from left to right.

    flex-wrap

    @@ -134,7 +134,7 @@ In addition to the styles in [Universal Styles](js-components-common-styles.md)

    No

    Whether items in the container are displayed in a single axis or multiple axes. Currently, dynamic modification is not supported. Available values are as follows:

    -
    • nowrap: Items are displayed on a single axis.
    • wrap: Items are displayed on multiple axes.
    +
    • nowrap: Items are displayed on a single axis.
    • wrap: Items are displayed on multiple axes.

    justify-content

    @@ -146,7 +146,7 @@ In addition to the styles in [Universal Styles](js-components-common-styles.md)

    No

    How items are aligned along the main axis of the current row in the container. Available values are as follows:

    -
    • flex-start: Items are packed towards the start row.
    • flex-end: Items are packed towards the end row.
    • center: Items are centered along the row.
    • space-between: Items are positioned with space between the rows.
    • space-around: Items are positioned with space before, between, and after the rows.
    +
    • flex-start: Items are packed towards the start row.
    • flex-end: Items are packed towards the end row.
    • center: Items are centered along the row.
    • space-between: Items are positioned with space between the rows.
    • space-around: Items are positioned with space before, between, and after the rows.

    align-items

    @@ -158,7 +158,7 @@ In addition to the styles in [Universal Styles](js-components-common-styles.md)

    No

    How items are aligned along the cross axis of the current row in the container. Available values are as follows:

    -
    • stretch: Items are stretched to the same height or width as the container in the cross axis direction.
    • flex-start: Items are aligned to the start of the cross axis.
    • flex-end: Items are aligned to the end of the cross axis.
    • center: Items are aligned in the middle of the cross axis.
    +
    • stretch: Items are stretched to the same height or width as the container in the cross axis direction.
    • flex-start: Items are aligned to the start of the cross axis.
    • flex-end: Items are aligned to the end of the cross axis.
    • center: Items are aligned in the middle of the cross axis.

    align-content

    @@ -170,7 +170,7 @@ In addition to the styles in [Universal Styles](js-components-common-styles.md)

    No

    Multi-row alignment mode when there is extra space in the cross axis. Available values are as follows:

    -
    • flex-start: All rows are packed towards the start of the cross axis. The start edge of the cross axis of the first row is aligned with the start edge of the cross axis of the container. All subsequent rows are aligned with the previous row.
    • flex-end: All rows are packed towards the end of the cross axis. The end of the cross axis of the last row is aligned with the end of the cross axis of the container. All subsequent rows are aligned with the previous row.
    • center: All rows are packed towards the center of the container. Rows are close to each other and aligned with the center of the container. The spacing between the start of the container's cross axis and the first row is equal to the spacing between the end of the container's cross axis and the last row.
    • space-between: All rows are evenly distributed in the container. The spacing between two adjacent rows is the same. The start and end edges of the container's cross axis are aligned with the edges of the first and last rows, respectively.
    • space-around: All rows are evenly distributed in the container, and the spacing between two adjacent rows is the same. The spacing between the start edge of the container's cross axis and the first row and that between the end edge and the last row are half of the spacing between two adjacent rows.
    +
    • flex-start: All rows are packed towards the start of the cross axis. The start edge of the cross axis of the first row is aligned with the start edge of the cross axis of the container. All subsequent rows are aligned with the previous row.
    • flex-end: All rows are packed towards the end of the cross axis. The end of the cross axis of the last row is aligned with the end of the cross axis of the container. All subsequent rows are aligned with the previous row.
    • center: All rows are packed towards the center of the container. Rows are close to each other and aligned with the center of the container. The spacing between the start of the container's cross axis and the first row is equal to the spacing between the end of the container's cross axis and the last row.
    • space-between: All rows are evenly distributed in the container. The spacing between two adjacent rows is the same. The start and end edges of the container's cross axis are aligned with the edges of the first and last rows, respectively.
    • space-around: All rows are evenly distributed in the container, and the spacing between two adjacent lines is the same. The spacing between the start edge of the container's cross axis and the first row and that between the end edge and the last row are half of the spacing between two adjacent rows.

    display

    @@ -181,8 +181,8 @@ In addition to the styles in [Universal Styles](js-components-common-styles.md)

    No

    Type of the view box of the element. Currently, dynamic modification is not supported. Text alignment mode. Available values include:

    -
    • flex: flexible layout
    • grid: grid layout
    • none: This item is not rendered.
    +

    Type of the view box of the element. Currently, dynamic modification is not supported. Available values are as follows:

    +
    • flex: flexible layout.
    • grid: grid layout.
    • none: disabled.

    grid-template-[columns|rows]

    @@ -193,13 +193,13 @@ In addition to the styles in [Universal Styles](js-components-common-styles.md)

    No

    Number of rows and columns in the current grid layout. If this attribute is not set, one row and one column are displayed by default. This attribute is valid only when display is set to grid.

    -

    For example, set grid-template-columns to:

    -

    (1) 50px 100px 60px: There are three columns. The first column is 50 px, the second column is 100 px, and the third column is 60 px.

    -

    (2) 1fr 1fr 2fr: There are three columns, and the width allowed by the parent component is divided into four equal shares. The first column occupies one share, the second column occupies one share, and the third column occupies two shares.

    -

    (3) 30% 20% 50%: There are three columns. The first column occupies 30% of the total width allowed by the parent component, the second column occupies 20%, and the third column occupies 50%.

    -

    (4) repeat (2,100px): There are two columns. The first column is 100 px, and the second column is 100 px.

    -

    (5) auto 1fr 1fr: There are three columns. The first column is adaptive to the width required by its child components. The remaining space is divided into two equal shares, one share occupied by each of the two columns.

    +

    Number of rows and columns in the current grid layout. If this attribute is not set, one row and one column are displayed by default. This attribute is valid only when display is set to grid.

    +

    For example, set grid-template-columns to:

    +

    (1) 50px 100px 60px: There are three columns. The first column is 50 px, the second column is 100 px, and the third column is 60 px.

    +

    (2) 1fr 1fr 2fr: There are three columns, and the width allowed by the parent component is divided into four equal shares. The first column occupies one share, the second column occupies one share, and the third column occupies two shares.

    +

    (3) 30% 20% 50%: There are three columns. The first column occupies 30% of the total width allowed by the parent component, the second column occupies 20%, and the third column occupies 50%.

    +

    (4) repeat (2,100px): There are two columns. The first column is 100 px, and the second column is 100 px.

    +

    (5) auto 1fr 1fr: There are three columns. The first column is adaptive to the width required by its child components. The remaining space is divided into two equal shares, one share occupied by each of the two columns.

    grid-[columns|rows]-gap

    @@ -210,7 +210,7 @@ In addition to the styles in [Universal Styles](js-components-common-styles.md)

    No

    Size of the gap between two consecutive rows or columns in a grid layout. You can also use grid-gap to set the same size of the gap between rows and columns. This attribute is valid only when display is set to grid.

    +

    Size of the gap between two consecutive rows or columns in a grid layout. You can also use grid-gap to set the same size of the gap between rows and columns. This attribute is valid only when display is set to grid.

    grid-row-[start|end]

    @@ -221,7 +221,7 @@ In addition to the styles in [Universal Styles](js-components-common-styles.md)

    No

    Start and end row numbers of the current item in the grid layout. This attribute is valid only when display of the parent component is grid. (The display attribute of the parent component can be set to grid only for the <div> container.)

    +

    Start and end row numbers of the current item in the grid layout. This attribute is valid only when display of the parent component is grid. (The display attribute of the parent component can be set to grid only for the <div> container.)

    grid-column-[start|end]

    @@ -232,36 +232,36 @@ In addition to the styles in [Universal Styles](js-components-common-styles.md)

    No

    Start and end column numbers of the current item in the grid layout. This attribute is valid only when display of the parent component is grid. (The display attribute of the parent component can be set to grid only for the <div> container.)

    +

    Start and end column numbers of the current item in the grid layout. This attribute is valid only when display of the parent component is grid. (The display attribute of the parent component can be set to grid only for the <div> container.)

    >![](../../public_sys-resources/icon-note.gif) **NOTE:** ->- Width-related styles are not supported. +>Width-related styles are not supported. -## Event +## Events Events in [Universal Events](js-components-common-events.md) are supported. -## Method +## Methods Methods in [Universal Methods](js-components-common-methods.md) are supported. -## Example Code +## Example ```
    - +
    Element text
    - +
    Element text
    @@ -302,3 +302,5 @@ export default { } ``` +![](figures/grid.gif) + diff --git a/en/application-dev/reference/arkui-js/js-components-grid-container.md b/en/application-dev/reference/arkui-js/js-components-grid-container.md index 8f3d7dfbeabd71c07d1ffc46417c23d469b44a98..9bec017c1a2eb9018b69108c352b300a43055671 100644 --- a/en/application-dev/reference/arkui-js/js-components-grid-container.md +++ b/en/application-dev/reference/arkui-js/js-components-grid-container.md @@ -1,8 +1,8 @@ # grid-container -The **** component is the root container of the grid layout. Within the root container, you can use **** and **** for the grid layout. +The **** component is the root container of the grid layout. Within the root container, you can use **** and **** for the grid layout. -## Permission List +## Required Permissions None @@ -10,7 +10,7 @@ None Only the **** component is supported. -## Attribute +## Attributes In addition to the attributes in [Universal Attributes](js-components-common-attributes.md), the following attributes are supported. @@ -166,9 +166,10 @@ In addition to the attributes in [Universal Attributes](js-components-common-at >![](../../public_sys-resources/icon-note.gif) **NOTE:** +> >- The px unit is applicable when **autoDesignWidth** is set to **true** in the "js" tag. 6+ -## Style +## Styles In addition to the styles in [Universal Styles](js-components-common-styles.md), the following styles are supported. @@ -224,7 +225,7 @@ In addition to the styles in [Universal Styles](js-components-common-styles.md) -## Event +## Events Events in [Universal Events](js-components-common-events.md) are supported. @@ -274,5 +275,5 @@ In addition to the methods in [Universal Methods](js-components-common-methods. ## Example Code -For details, see [grid-col](js-components-grid-col.md#section2021865273710). +For details, see [grid-col](js-components-grid-col.md). diff --git a/en/application-dev/reference/arkui-js/js-components-grid-row.md b/en/application-dev/reference/arkui-js/js-components-grid-row.md index 1c78364c375225442cc8a0496ffd38766a055000..ffb31abdb1fa5fdfad533a54cd47e8a5bc75dae5 100644 --- a/en/application-dev/reference/arkui-js/js-components-grid-row.md +++ b/en/application-dev/reference/arkui-js/js-components-grid-row.md @@ -2,19 +2,19 @@ The **** component is a container used as a child component of ****. Each **** component is arranged horizontally with **flex**-related styles. By default, items in the **** component are packed towards the start row and aligned to the start of the cross axis. You can set the items to be displayed in multiple axes. -## Permission List +## Required Permissions None -## Child Component +## Child Components Only the **** component is supported. -## Attribute +## Attributes Attributes in [Universal Attributes](js-components-common-attributes.md) are supported. -## Style +## Styles In addition to the styles in [Universal Styles](js-components-common-styles.md), the following styles are supported. @@ -83,17 +83,17 @@ In addition to the styles in [Universal Styles](js-components-common-styles.md) >![](../../public_sys-resources/icon-note.gif) **NOTE:** ->- Width-related styles are not supported. +>Width-related styles are not supported. -## Event +## Events Events in [Universal Events](js-components-common-events.md) are supported. -## Method +## Methods Methods in [Universal Methods](js-components-common-methods.md) are supported. ## Example Code -For details, see [grid-col](js-components-grid-col.md#section2021865273710). +For details, see [grid-col](js-components-grid-col.md). diff --git a/en/application-dev/reference/arkui-js/js-components-media-video.md b/en/application-dev/reference/arkui-js/js-components-media-video.md index 220b54e07b4fa6e8e8ad746526bb4841ebf3fe54..1e2b132c923351e37d92eafeea3bf71ef34d3fb1 100644 --- a/en/application-dev/reference/arkui-js/js-components-media-video.md +++ b/en/application-dev/reference/arkui-js/js-components-media-video.md @@ -8,13 +8,13 @@ The **** component provides a video player. > "configChanges": ["orientation"] > ``` -## Permission List +## Required Permissions ## Child Component Not supported -## Attribute +## Attributes In addition to the attributes in [Universal Attributes](js-components-common-attributes.md), the following attributes are supported. @@ -78,7 +78,7 @@ In addition to the attributes in [Universal Attributes](js-components-common-at -## Style +## Styles In addition to the styles in [Universal Styles](js-components-common-styles.md), the following styles are supported. @@ -126,14 +126,14 @@ In addition to the styles in [Universal Styles](js-components-common-styles.md) -## Event +## Events In addition to the events in [Universal Events](js-components-common-events.md), the following events are supported. - @@ -198,14 +198,14 @@ In addition to the events in [Universal Events](js-components-common-events.md)

    Name

    Parameter Type

    +

    Parameter

    Description

    -## Method +## Methods -In addition to the methods in [Universal Methods](js-components-common-methods.md), the following events are supported. +In addition to the methods in [Universal Methods](js-components-common-methods.md), the following methods are supported. - @@ -235,3 +235,6 @@ In addition to the methods in [Universal Methods](js-components-common-methods.

    Name

    Parameter Type

    +

    Type

    Description

    +>![](../../public_sys-resources/icon-note.gif) **NOTE:** +>The methods in the above table can be called after the **attached** callback is invoked. + diff --git a/en/application-dev/reference/arkui-js/js-components-svg-animate.md b/en/application-dev/reference/arkui-js/js-components-svg-animate.md index 24b10e8f27bf7b57f435aa7855e2c694bfe3ea79..751dbe4adb724775bc0cd287b47f29c25cbd2339 100644 --- a/en/application-dev/reference/arkui-js/js-components-svg-animate.md +++ b/en/application-dev/reference/arkui-js/js-components-svg-animate.md @@ -3,9 +3,9 @@ The **** component is used to apply animation to an **** component. >![](../../public_sys-resources/icon-note.gif) **NOTE:** ->The APIs of this module are supported since API version 7. +>This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -## Permission List +## Required Permissions None @@ -221,7 +221,7 @@ Not supported
    ``` -![](figures/1-45.gif) +![](figures/1-10.gif) ``` diff --git a/en/application-dev/reference/arkui-js/js-components-svg-animatemotion.md b/en/application-dev/reference/arkui-js/js-components-svg-animatemotion.md index 8ce363a1cf6fec0975df169d4ec543ed92258bc6..ab8d768fbd7e9333c4876dea209c88da6de576e1 100644 --- a/en/application-dev/reference/arkui-js/js-components-svg-animatemotion.md +++ b/en/application-dev/reference/arkui-js/js-components-svg-animatemotion.md @@ -1,11 +1,11 @@ # animateMotion -The **** component is used to apply the path animation. +The **** component is used to define the animation along a path. >![](../../public_sys-resources/icon-note.gif) **NOTE:** ->The APIs of this module are supported since API version 7. +>This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -## Permission List +## Required Permissions None @@ -90,5 +90,5 @@ The **animate** attributes \(**values** does not take effect\) and the attrib
    ``` -![](figures/2-46.gif) +![](figures/2-11.gif) diff --git a/en/application-dev/reference/arkui-js/js-components-svg-animatetransform.md b/en/application-dev/reference/arkui-js/js-components-svg-animatetransform.md index 6e43e82e616a1af9645cbc1ccc5d3a27a6d73b0c..4b4cf63bcb25cd7e8a7abc010ae91af3bb308ad6 100644 --- a/en/application-dev/reference/arkui-js/js-components-svg-animatetransform.md +++ b/en/application-dev/reference/arkui-js/js-components-svg-animatetransform.md @@ -5,9 +5,9 @@ The **** component is used to apply a transform animation a , , , , , , , >![](../../public_sys-resources/icon-note.gif) **NOTE:** ->The APIs of this module are supported since API version 7. +>This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -## Permission List +## Required Permissions None diff --git a/en/application-dev/reference/arkui-js/js-components-svg-circle.md b/en/application-dev/reference/arkui-js/js-components-svg-circle.md index 2289e069d8cd798c0a03f17e1dfb4737a9a5b708..b83f3c4e8f25a788f4e10c9b5302390df983297a 100644 --- a/en/application-dev/reference/arkui-js/js-components-svg-circle.md +++ b/en/application-dev/reference/arkui-js/js-components-svg-circle.md @@ -3,9 +3,9 @@ The **** component is used to draw circles. >![](../../public_sys-resources/icon-note.gif) **NOTE:** ->The APIs of this module are supported since API version 7. +>This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -## Permission List +## Required Permissions None @@ -15,7 +15,7 @@ None ## Attributes -The universal attributes as well as the attributes listed below are supported. +The [universal attributes](js-components-svg-common-attributes.md) and the attributes listed below are supported. - - - @@ -77,6 +84,44 @@ PinchGesture\(options?: \{ fingers?: number, distance?: number \}\)

    Name

    diff --git a/en/application-dev/reference/arkui-js/js-components-svg-common-attributes.md b/en/application-dev/reference/arkui-js/js-components-svg-common-attributes.md index 8d192ead2f2f1ebcc560f569e1e68591b9bc9768..41708e4000c2be922448df292ce6cb1fad608f69 100644 --- a/en/application-dev/reference/arkui-js/js-components-svg-common-attributes.md +++ b/en/application-dev/reference/arkui-js/js-components-svg-common-attributes.md @@ -1,5 +1,8 @@ # Universal Attributes +>![](../../public_sys-resources/icon-note.gif) **NOTE:** +>Universal attributes are supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. + @@ -32,7 +35,7 @@ - - - - diff --git a/en/application-dev/reference/arkui-js/js-components-svg-ellipse.md b/en/application-dev/reference/arkui-js/js-components-svg-ellipse.md index 703d575f888644cdfff1f4d0a4f7063049a554cf..26e2940fc0d631b63c6713b0e8f162478866081c 100644 --- a/en/application-dev/reference/arkui-js/js-components-svg-ellipse.md +++ b/en/application-dev/reference/arkui-js/js-components-svg-ellipse.md @@ -3,9 +3,9 @@ The **** component is used to draw oval shapes. >![](../../public_sys-resources/icon-note.gif) **NOTE:** ->The APIs of this module are supported since API version 7. +>This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -## Permission List +## Required Permissions None @@ -15,7 +15,7 @@ None ## Attributes -The universal attributes as well as the attributes listed below are supported. +The [universal attributes](js-components-svg-common-attributes.md) and the attributes listed below are supported.

    Name

    No

    Transparency of a fill color. The value ranges from 0 to 1. The value 1 means opaque, and 0 means completely transparent. Attribute animations are supported.

    +

    Opacity of a fill color. The value ranges from 0 to 1. The value 1 means opaque, and 0 means completely transparent. Attribute animations are supported.

    fill-rule

    @@ -43,7 +46,7 @@

    No

    nonzero: non-zero rule; evend: parity rule.

    +

    nonzero: non-zero rule; evenodd: parity rule.

    opacity

    @@ -54,7 +57,7 @@

    No

    Transparency of an element. The value ranges from 0 to 1. The value 1 means opaque, and 0 means completely transparent. Attribute animations are supported.

    +

    Opacity of an element. The value ranges from 0 to 1. The value 1 means opaque, and 0 means completely transparent. Attribute animations are supported.

    stroke

    @@ -137,7 +140,7 @@

    No

    Transparency of the stroke. The value ranges from 0 to 1. The value 1 means opaque, and 0 means completely transparent. Attribute animations are supported.

    +

    Opacity of the stroke. The value ranges from 0 to 1. The value 1 means opaque, and 0 means completely transparent. Attribute animations are supported.

    stroke-width

    @@ -165,7 +168,7 @@

    scale(<x> [<y>]): scales along the x[y]-axis.

    rotate(<a> [<x> <y>]): rotates at an angle of a with (x,y) as the center.

    skewX(<a>): skews at an angle of a along the x-axis.

    -

    skewX(<a>): skews at an angle of a along the y-axis.

    +

    skewY(<a>): skews at an angle of a along the y-axis.

    - - - - - @@ -179,6 +186,37 @@ PanGestureOption\(options?: \{ fingers?: number, direction?: PanDirection, dista

    Name

    diff --git a/en/application-dev/reference/arkui-js/js-components-svg-line.md b/en/application-dev/reference/arkui-js/js-components-svg-line.md index 248eedba9b85be7cb1ec8af29a6617711ce101c8..6ec9f30e742e29c148f4e312afcc31feb6c55bea 100644 --- a/en/application-dev/reference/arkui-js/js-components-svg-line.md +++ b/en/application-dev/reference/arkui-js/js-components-svg-line.md @@ -3,9 +3,9 @@ The **** component is used to draw a line. >![](../../public_sys-resources/icon-note.gif) **NOTE:** ->The APIs of this module are supported since API version 7. +>This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -## Permission List +## Required Permissions None diff --git a/en/application-dev/reference/arkui-js/js-components-svg-path.md b/en/application-dev/reference/arkui-js/js-components-svg-path.md index 1797813f8b1e8ed6ec386dcb72f5b5fb93950399..a6f78eca6161b55eb5fed2fcf4ae624bd8199953 100644 --- a/en/application-dev/reference/arkui-js/js-components-svg-path.md +++ b/en/application-dev/reference/arkui-js/js-components-svg-path.md @@ -3,9 +3,9 @@ The **** component is used to draw a path. >![](../../public_sys-resources/icon-note.gif) **NOTE:** ->The APIs of this module are supported since API version 7. +>This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -## Permission List +## Required Permissions None @@ -15,7 +15,7 @@ None ## Attributes -The universal attributes as well as the attributes listed below are supported. The configured universal attributes are passed to the child components. +The [universal attributes](js-components-svg-common-attributes.md) and the attributes listed below are supported. The configured universal attributes are passed to the child components. - + + + + + +

    Name

    diff --git a/en/application-dev/reference/arkui-js/js-components-svg-polygon.md b/en/application-dev/reference/arkui-js/js-components-svg-polygon.md index 7c63ed5f485e874c116621dffbff91c1504a3fbd..378be8a30a6fa4a0124d113a64b2eead3b19a79a 100644 --- a/en/application-dev/reference/arkui-js/js-components-svg-polygon.md +++ b/en/application-dev/reference/arkui-js/js-components-svg-polygon.md @@ -3,9 +3,9 @@ The **** component is used to draw a polygon. >![](../../public_sys-resources/icon-note.gif) **NOTE:** ->The APIs of this module are supported since API version 7. +>This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -## Permission List +## Required Permissions None @@ -15,7 +15,7 @@ None ## Attributes -The universal attributes as well as the attributes listed below are supported. +The [universal attributes](js-components-svg-common-attributes.md) and the attributes listed below are supported. - @@ -122,6 +125,15 @@ Image\(src: string | PixelMap\) + + + + +

    Name

    diff --git a/en/application-dev/reference/arkui-js/js-components-svg-polyline.md b/en/application-dev/reference/arkui-js/js-components-svg-polyline.md index 7929ec53824520ec869d851a8b071371b1e0c3a5..ddefca98447ae302fa9036bec278c8d1ebc46c85 100644 --- a/en/application-dev/reference/arkui-js/js-components-svg-polyline.md +++ b/en/application-dev/reference/arkui-js/js-components-svg-polyline.md @@ -3,9 +3,9 @@ The **** component is used to draw a polyline. >![](../../public_sys-resources/icon-note.gif) **NOTE:** ->The APIs of this module are supported since API version 7. +>This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -## Permission List +## Required Permissions None diff --git a/en/application-dev/reference/arkui-js/js-components-svg-rect.md b/en/application-dev/reference/arkui-js/js-components-svg-rect.md index d713d24739f398437e9d1411a0d1a9fab70f3e57..1b9ee69bba4ff67d311a08d6910b4d84cf03c472 100644 --- a/en/application-dev/reference/arkui-js/js-components-svg-rect.md +++ b/en/application-dev/reference/arkui-js/js-components-svg-rect.md @@ -3,9 +3,9 @@ The **** component is used to draw rectangles and rounded rectangles. >![](../../public_sys-resources/icon-note.gif) **NOTE:** ->The APIs of this module are supported since API version 7. +>This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -## Permission List +## Required Permissions None @@ -15,7 +15,7 @@ None ## Attributes -The universal attributes as well as the attributes listed below are supported. +The [universal attributes](js-components-svg-common-attributes.md) and the attributes listed below are supported. - - - diff --git a/en/application-dev/reference/arkui-js/js-components-svg-textpath.md b/en/application-dev/reference/arkui-js/js-components-svg-textpath.md index c00f7cb560bbea41ef5331e268492b87d191052b..6ecd8c2df6f5b7917c24f06f5da354a9d597f334 100644 --- a/en/application-dev/reference/arkui-js/js-components-svg-textpath.md +++ b/en/application-dev/reference/arkui-js/js-components-svg-textpath.md @@ -3,11 +3,11 @@ The **** component is used to draw text along the path. >![](../../public_sys-resources/icon-note.gif) **NOTE:** ->- The APIs of this module are supported since API version 7. +>- This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. >- Draws text based on the specified path. The **tspan** child component can be nested for segmenting. >- **** can be nested only by the parent element label **svg**. -## Permission List +## Required Permissions None @@ -89,6 +89,17 @@ The attributes in the following table are supported. + + + + + + - - - @@ -304,7 +315,7 @@ Animation and effect of the combination of **textpath** and **tspan** \(1\) "tspan attribute x|rotate" indicates that the text drawing start point moves from 50 px to 100 px and rotates clockwise by 0 degrees to 360 degrees. -\(2\) "tspan attribute dx|opacity" is drawn after the "tspan static." drawing is complete. The offset moves from 0% to 30%, and the transparency changes from shallow to deep. +\(2\) "tspan attribute dx|opacity" is drawn after the "tspan static." drawing is complete. The offset moves from 0% to 30%, and the opacity changes from shallow to deep. \(3\) **tspan move**: After the previous **tspan** is drawn, the next tspan is drawn with an offset of 5% to show the effect of following the previous **tspan**. @@ -340,7 +351,7 @@ Animation and effect of the combination of **textpath** and **tspan** \(1\) **This is TextPath**.: Draw the first paragraph of text on the path without offset. The size is 30px, and the color is "\#D2691E". -\(2\) The value of **tspan attribute fill|fill-opacity** is 20px offset from the end of the previous text segment. The color is from blue to red, and the transparency is from light to deep. +\(2\) The value of **tspan attribute fill|fill-opacity** is 20px offset from the end of the previous text segment. The color is from blue to red, and the opacity is from light to deep. \(3\) **tspan attribute font-size**: The drawing start point is 20px offset from the end of the previous segment. The start point is static, and the font size ranges from 10px to 50px. The overall length is continuously prolonged. @@ -377,5 +388,5 @@ Animation and effect of the combination of **textpath** and **tspan** \(1\) **tspan attribute stroke**: The stroke color gradually changes from red to green. -\(2\) **tspan attribute stroke-width-opacity**: The contour width is changed from 1px to 5px, and the transparency is changed from shallow to deep. +\(2\) **tspan attribute stroke-width-opacity**: The contour width is changed from 1px to 5px, and the opacity is changed from shallow to deep. diff --git a/en/application-dev/reference/arkui-js/js-components-svg-tspan.md b/en/application-dev/reference/arkui-js/js-components-svg-tspan.md index 173feb122d5e0d6d81eb6c503384bb87961f9ddc..a37f96069f116e394306edf9cbcef2f792f36019 100644 --- a/en/application-dev/reference/arkui-js/js-components-svg-tspan.md +++ b/en/application-dev/reference/arkui-js/js-components-svg-tspan.md @@ -1,11 +1,11 @@ # tspan >![](../../public_sys-resources/icon-note.gif) **NOTE:** ->- The APIs of this module are supported since API version 7. +>- This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. >- The text content must be written in the content area. The **** child component can be nested. >- **** can be nested only by the parent element label **svg**. -## Permission List +## Required Permissions None @@ -124,7 +124,7 @@ The attributes in the following table are supported. - - - diff --git a/en/application-dev/reference/arkui-js/js-components-svg.md b/en/application-dev/reference/arkui-js/js-components-svg.md index b8c870129351d66c777a7b8a4f0b07fefbdacdaa..83fdf3085c0e6268dc313ceaa6d7c26dc0220ac7 100644 --- a/en/application-dev/reference/arkui-js/js-components-svg.md +++ b/en/application-dev/reference/arkui-js/js-components-svg.md @@ -1,12 +1,12 @@ # svg -**** is a basic container, which is used as the root node of the SVG and can be nested in the SVG. +The **** component is a basic container. It can be used as the root node of an SVG document or be used to nest an SVG fragment into an SVG document. >![](../../public_sys-resources/icon-note.gif) **NOTE:** ->The APIs of this module are supported since API version 7. ->Constraints: The width and height must be defined for the **** parent component or **** component. Otherwise, the component is not drawn. +>- This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. +>- The width and height must be defined for the **** parent component or **** component. Otherwise, the component is not drawn. -## Permission List +## Required Permissions None @@ -16,7 +16,7 @@ None ## Attributes -The universal attributes as well as the attributes listed below are supported. The configured universal attributes are passed to the child components. +The [universal attributes](js-components-svg-common-attributes.md) and the attributes listed below are supported. The configured universal attributes are passed to the child components.

    Name

    diff --git a/en/application-dev/reference/arkui-js/js-components-svg-text.md b/en/application-dev/reference/arkui-js/js-components-svg-text.md index 6dee791d248041af39925b9440c1152e1552a86b..4b9887758b264f6c9134537190ed62dae5751d83 100644 --- a/en/application-dev/reference/arkui-js/js-components-svg-text.md +++ b/en/application-dev/reference/arkui-js/js-components-svg-text.md @@ -3,12 +3,12 @@ The **** component is used to display a piece of textual information. >![](../../public_sys-resources/icon-note.gif) **NOTE:** ->- The APIs of this module are supported since API version 7. +>- This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. >- The text content must be written in the content area. The **tspan** sub-element label can be nested to segment the text content. The **textPath** sub-element label can be nested to draw the text content based on the specified path. >- **** can be nested only by the parent element label **svg**. >- Only the default font **sans-serif** is supported. -## Permission List +## Required Permissions None @@ -129,7 +129,7 @@ The attributes in the following table are supported.

    No

    Font fill transparency.

    +

    Font fill opacity.

    opacity

    @@ -140,7 +140,7 @@ The attributes in the following table are supported.

    No

    Transparency of an element. The value ranges from 0 to 1. The value 1 means opaque, and 0 means completely transparent. Attribute animations are supported.

    +

    Opacity of an element. The value ranges from 0 to 1. The value 1 means opaque, and 0 means completely transparent. Attribute animations are supported.

    stroke

    @@ -173,7 +173,7 @@ The attributes in the following table are supported.

    No

    Stroke transparency.

    +

    Stroke opacity.

    Font fill color.

    by

    +

    number

    +

    -

    +

    No

    +

    Attribute offset relative to the specified animation. The default value of from is the original attribute value.

    +

    opacity

    number

    @@ -97,7 +108,7 @@ The attributes in the following table are supported.

    No

    Transparency of an element. The value ranges from 0 to 1. The value 1 means opaque, and 0 means completely transparent. Attribute animations are supported.

    +

    Opacity of an element. The value ranges from 0 to 1. The value 1 means opaque, and 0 means completely transparent. Attribute animations are supported.

    fill-opacity

    @@ -108,7 +119,7 @@ The attributes in the following table are supported.

    No

    Font fill transparency.

    +

    Font fill opacity.

    stroke

    @@ -141,7 +152,7 @@ The attributes in the following table are supported.

    No

    Stroke transparency.

    +

    Stroke opacity.

    No

    Transparency of an element. The value ranges from 0 to 1. The value 1 means opaque, and 0 means completely transparent. Attribute animations are supported.

    +

    Opacity of an element. The value ranges from 0 to 1. The value 1 means opaque, and 0 means completely transparent. Attribute animations are supported.

    fill-opacity

    @@ -135,7 +135,7 @@ The attributes in the following table are supported.

    No

    Font fill transparency.

    +

    Font fill opacity.

    stroke

    @@ -168,7 +168,7 @@ The attributes in the following table are supported.

    No

    Stroke transparency.

    +

    Stroke opacity.

    - - - @@ -29,22 +33,57 @@ DataPanel\(value:\{values: number\[\], max?: number\}\) - - - - - - + + + + + + + + +

    Name

    diff --git a/en/application-dev/reference/arkui-js/js-components.md b/en/application-dev/reference/arkui-js/js-components.md index 775b92b37f0f963d68cb1d87ad7607c6f7a06c76..048e5afb46e3d8765ede56525ebe1de808b6ec48 100644 --- a/en/application-dev/reference/arkui-js/js-components.md +++ b/en/application-dev/reference/arkui-js/js-components.md @@ -8,10 +8,9 @@ - **[Media Components](js-components-media.md)** -- **[Canvas Components \(Rich\)](js-components-canvas.md)** +- **[Canvas Components ](js-components-canvas.md)** - **[Grid](js-components-grid.md)** - **[SVG Components](js-svg.md)** - diff --git a/en/application-dev/reference/arkui-js/js-offscreencanvasrenderingcontext2d.md b/en/application-dev/reference/arkui-js/js-offscreencanvasrenderingcontext2d.md index 524f685ba59c096159811425aedfa3c2a94d5d43..0eaa85d778d22dd9395c16f40d45ec60284bc469 100644 --- a/en/application-dev/reference/arkui-js/js-offscreencanvasrenderingcontext2d.md +++ b/en/application-dev/reference/arkui-js/js-offscreencanvasrenderingcontext2d.md @@ -1,16 +1,17 @@ # OffscreenCanvasRenderingContext2D + >![](../../public_sys-resources/icon-note.gif) **NOTE:** ->The APIs of this module are supported since API version 7. +>**OffscreenCanvasRenderingContext2D** is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -Use **OffscreenCanvasRenderingContext2D** to draw rectangles, images, and texts on the offscreen canvas. +Use **OffscreenCanvasRenderingContext2D** to draw rectangles, images, and texts on an **OffscreenCanvas**. ## Attributes In addition to the attributes that are supported by **CanvasRenderingContext2D**, the following attributes are supported. -

    Attributes

    + @@ -24,7 +25,7 @@ In addition to the attributes that are supported by **CanvasRenderingContext2D* @@ -32,179 +33,306 @@ In addition to the attributes that are supported by **CanvasRenderingContext2D* - Example -``` -var ctx = this.$refs.canvasid.getContext('2d'); -var offscreen = new OffscreenCanvas(360, 500); -var offCanvas2 = offscreen.getContext("2d"); -var img = new Image(); -img.src = 'common/images/flower.jpg'; -offCanvas2.drawImage(img, 0, 0, 100, 100); -offCanvas2.filter = 'blur(5px)'; -offCanvas2.drawImage(img, 100, 0, 100, 100); - -offCanvas2.filter = 'grayscale(50%)'; -offCanvas2.drawImage(img, 200, 0, 100, 100); - -offCanvas2.filter = 'hue-rotate(90deg)'; -offCanvas2.drawImage(img, 0, 100, 100, 100); - -offCanvas2.filter = 'invert(100%)'; -offCanvas2.drawImage(img, 100, 100, 100, 100); + ``` + +
    + +
    + ``` + + ``` + //xxx.js + export default { + onShow(){ + var ctx = this.$refs.canvasId.getContext('2d'); + var offscreen = new OffscreenCanvas(360, 500); + var offCanvas2 = offscreen.getContext("2d"); + var img = new Image(); + img.src = 'common/images/flower.jpg'; + offCanvas2.drawImage(img, 0, 0, 100, 100); + offCanvas2.filter = 'blur(5px)'; + offCanvas2.drawImage(img, 100, 0, 100, 100); + + offCanvas2.filter = 'grayscale(50%)'; + offCanvas2.drawImage(img, 200, 0, 100, 100); + + offCanvas2.filter = 'hue-rotate(90deg)'; + offCanvas2.drawImage(img, 0, 100, 100, 100); + + offCanvas2.filter = 'invert(100%)'; + offCanvas2.drawImage(img, 100, 100, 100, 100); + + offCanvas2.filter = 'drop-shadow(8px 8px 10px green)'; + offCanvas2.drawImage(img, 200, 100, 100, 100); + + offCanvas2.filter = 'brightness(0.4)'; + offCanvas2.drawImage(img, 0, 200, 100, 100); + + offCanvas2.filter = 'opacity(25%)'; + offCanvas2.drawImage(img, 100, 200, 100, 100); + + offCanvas2.filter = 'saturate(30%)'; + offCanvas2.drawImage(img, 200, 200, 100, 100); + + offCanvas2.filter = 'sepia(60%)'; + offCanvas2.drawImage(img, 0, 300, 100, 100); + + offCanvas2.filter = 'contrast(200%)'; + offCanvas2.drawImage(img, 100, 300, 100, 100); + var bitmap = offscreen.transferToImageBitmap(); + ctx.transferFromImageBitmap(bitmap); + } + } + ``` + + ![](figures/c3.png) -offCanvas2.filter = 'drop-shadow(8px 8px 10px green)'; -offCanvas2.drawImage(img, 200, 100, 100, 100); -offCanvas2.filter = 'brightness(0.4)'; -offCanvas2.drawImage(img, 0, 200, 100, 100); - -offCanvas2.filter = 'opacity(25%)'; -offCanvas2.drawImage(img, 100, 200, 100, 100); +## Methods -offCanvas2.filter = 'saturate(30%)'; -offCanvas2.drawImage(img, 200, 200, 100, 100); +In addition to the attributes that are supported by **CanvasRenderingContext2D**, the following attributes are supported. -offCanvas2.filter = 'sepia(60%)'; -offCanvas2.drawImage(img, 0, 300, 100, 100); +### isPointInPath + +isPointInPath\(path?: Path2D, x: number, y: number\): boolean + +Checks whether a specified point is in the path area. + +- Parameters + + +

    Name

    Type

    Image filter.

    Available options are as follows:

    -
    • blur: applies the Gaussian blur for the image.
    • brightness: applies a linear multiplication to the image to make it look brighter or darker.
    • contrast: adjusts the image contrast.
    • drop-shadow: sets a shadow effect for the image.
    • grayscale: converts the image to a grayscale image.
    • hue-rotate: applies hue rotation to the image.
    • invert: inverts the input image.
    • opacity: transparency of the converted image.
    • saturation: saturation of the converted image.
    • sepia: converts the image to dark brown.
    +
    • blur: applies the Gaussian blur for the image.
    • brightness: applies a linear multiplication to the image to make it look brighter or darker.
    • contrast: adjusts the image contrast.
    • drop-shadow: sets a shadow effect for the image.
    • grayscale: converts the image to a grayscale image.
    • hue-rotate: applies hue rotation to the image.
    • invert: inverts the input image.
    • opacity: opacity of the converted image.
    • saturate: saturation of the converted image.
    • sepia: converts the image to dark brown.
    + + + + + + + + + + + + + + + + + + + + + +

    Name

    +

    Type

    +

    Mandatory

    +

    Description

    +

    path

    +

    Path2D

    +

    No

    +

    Path used for checking. If this parameter is not set, the current path is used.

    +

    x

    +

    number

    +

    Yes

    +

    X-coordinate of the point used for checking.

    +

    y

    +

    number

    +

    Yes

    +

    Y-coordinate of the point used for checking.

    +
    + +- Return values + + + + + + + + + + +

    Type

    +

    Description

    +

    boolean

    +

    Whether a specified point is in the path area.

    +
    -offCanvas2.filter = 'contrast(200%)'; -offCanvas2.drawImage(img, 100, 300, 100, 100); -var bitmap = offscreen.transferToImageBitmap(); -ctx.transferFromImageBitmap(bitmap); -``` +- Example -![](figures/en-us_image_0000001152773860.png) + ``` + +
    + In path:{{textValue}} + +
    + ``` + + ``` + // xxx.js + export default { + data: { + textValue: 0 + }, + onShow(){ + var canvas = this.$refs.canvas.getContext('2d'); + var offscreen = new OffscreenCanvas(500,500); + var offscreenCanvasCtx = offscreen.getContext("2d"); + + offscreenCanvasCtx.rect(10, 10, 100, 100); + offscreenCanvasCtx.fill(); + this.textValue = offscreenCanvasCtx.isPointInPath(30, 70); + + var bitmap = offscreen.transferToImageBitmap(); + canvas.transferFromImageBitmap(bitmap); + } + } + ``` + + ![](figures/en-us_image_0000001224354967.png) + + +### isPointInStroke + +isPointInStroke\(path?: Path2D, x: number, y: number\): boolean + +Checks whether a specified point is on the edge line of a path. + +- Parameters + + + + + + + + + + + + + + + + + + + + + + + + +

    Name

    +

    Type

    +

    Mandatory

    +

    Description

    +

    path

    +

    Path2D

    +

    No

    +

    Path used for checking. If this parameter is not set, the current path is used.

    +

    x

    +

    number

    +

    Yes

    +

    X-coordinate of the point used for checking.

    +

    y

    +

    number

    +

    Yes

    +

    Y-coordinate of the point used for checking.

    +
    + +- Return values + + + + + + + + + + +

    Type

    +

    Description

    +

    boolean

    +

    Whether a specified point is in the path area.

    +
    -## Methods +- Example -In addition to the attributes that are supported by **CanvasRenderingContext2D**, the following attributes are supported. + ``` + +
    + In path:{{textValue}} + +
    + ``` + + ``` + // xxx.js + export default { + data: { + textValue: 0 + }, + onShow(){ + var canvas = this.$refs.canvas.getContext('2d'); + var offscreen = new OffscreenCanvas(500,500); + var offscreenCanvasCtx = offscreen.getContext("2d"); + + offscreenCanvasCtx.rect(10, 10, 100, 100); + offscreenCanvasCtx.stroke(); + this.textValue = offscreenCanvasCtx.isPointInStroke(50, 10); + + var bitmap = offscreen.transferToImageBitmap(); + canvas.transferFromImageBitmap(bitmap); + } + } + ``` + + ![](figures/en-us_image_0000001178875308.png) + + +### resetTransform + +resetTransform\(\): void - - - - - - - - - - - - - - - - - - - -

    Name

    -

    Parameter

    -

    Description

    -

    isPointInPath

    -

    -

    path?: Path2D, x: number, y: number

    -

    Checks whether a specified point is in the path area.

    -

    path: optional object, which specifies the path used for checking. If this parameter is not set, the current path is used.

    -

    x: X-coordinate of the point used for checking.

    -

    y: Y-coordinate of the point used for checking.

    -

    isPointInStroke

    -

    path?: Path2D, x: number, y: number

    -

    Checks whether a specified point is on the edge line of a path.

    -

    path: optional object, which specifies the path used for checking. If this parameter is not set, the current path is used.

    -

    x: X-coordinate of the point used for checking.

    -

    y: Y-coordinate of the point used for checking.

    -

    resetTransform

    -

    None

    -

    Resets the current transformation to a unit matrix.

    -
    +- Example -- isPointInPath example - -![](figures/en-us_image_0000001181449919.png) - -``` - -
    - In path:{{textValue}} -
    - -``` - -``` -// xxx.js -export default { - data: { - textValue: 0 - }, - onShow(){ - var canvas = this.$refs.canvas.getContext('2d'); - var offscreen = new OffscreenCanvas(500,500); - var offscreenCanvasCtx = offscreen.getContext("2d"); - - offscreenCanvasCtx.rect(10, 10, 100, 100); - offscreenCanvasCtx.fill(); - this.textValue = offscreenCanvasCtx.isPointInPath(30, 70); - - var bitmap = offscreen.transferToImageBitmap(); - canvas.transferFromImageBitmap(bitmap); - } -} -``` - -- isPointInStroke example - -![](figures/en-us_image_0000001181458721.png) - -``` - -
    - In path:{{textValue}} -
    - -``` - -``` -// xxx.js -export default { - data: { - textValue: 0 - }, - onShow(){ - var canvas = this.$refs.canvas.getContext('2d'); - var offscreen = new OffscreenCanvas(500,500); - var offscreenCanvasCtx = offscreen.getContext("2d"); - - offscreenCanvasCtx.rect(10, 10, 100, 100); - offscreenCanvasCtx.stroke(); - this.textValue = offscreenCanvasCtx.isPointInStroke(50, 10); - - var bitmap = offscreen.transferToImageBitmap(); - canvas.transferFromImageBitmap(bitmap); - } -} -``` - -- resetTransform example - -![](figures/en-us_image_0000001135171488.png) - -``` -var canvas = this.$refs.canvas.getContext('2d'); -var offscreen = new OffscreenCanvas(500,500); -var offscreenCanvasCtx = offscreen.getContext("2d"); - -offscreenCanvasCtx.transform(1, 0, 1.7, 1, 0, 0); -offscreenCanvasCtx.fillStyle = 'gray'; -offscreenCanvasCtx.fillRect(40, 40, 50, 20); -offscreenCanvasCtx.fillRect(40, 90, 50, 20); - -// Non-skewed rectangles -offscreenCanvasCtx.resetTransform(); -offscreenCanvasCtx.fillStyle = 'red'; -offscreenCanvasCtx.fillRect(40, 40, 50, 20); -offscreenCanvasCtx.fillRect(40, 90, 50, 20); - -var bitmap = offscreen.transferToImageBitmap(); -canvas.transferFromImageBitmap(bitmap); -``` + ``` + +
    + In path:{{textValue}} + +
    + ``` + + ``` + //xxx.js + export default { + data:{ + textValue:0 + }, + onShow(){ + var canvas = this.$refs.canvas.getContext('2d'); + var offscreen = new OffscreenCanvas(500,500); + var offscreenCanvasCtx = offscreen.getContext("2d"); + + offscreenCanvasCtx.transform(1, 0, 1.7, 1, 0, 0); + offscreenCanvasCtx.fillStyle = 'gray'; + offscreenCanvasCtx.fillRect(40, 40, 50, 20); + offscreenCanvasCtx.fillRect(40, 90, 50, 20); + + // Non-skewed rectangles + offscreenCanvasCtx.resetTransform(); + offscreenCanvasCtx.fillStyle = 'red'; + offscreenCanvasCtx.fillRect(40, 40, 50, 20); + offscreenCanvasCtx.fillRect(40, 90, 50, 20); + + var bitmap = offscreen.transferToImageBitmap(); + canvas.transferFromImageBitmap(bitmap); + } + } + ``` + + ![](figures/en-us_image_0000001179035242.png) diff --git a/en/application-dev/reference/arkui-js/js-web-development-like.md b/en/application-dev/reference/arkui-js/js-web-development-like.md deleted file mode 100644 index 7e03ff8a6f32e8c64304b9ac13742e61410718a1..0000000000000000000000000000000000000000 --- a/en/application-dev/reference/arkui-js/js-web-development-like.md +++ /dev/null @@ -1,11 +0,0 @@ -# JavaScript-based Web-like Development Paradigm - -- **[Framework](js-framework.md)** - -- **[Components](js-components.md)** - -- **[Custom Components](js-components-custom.md)** - -- **[Appendix](js-appendix.md)** - - diff --git a/en/application-dev/reference/arkui-ts/Readme-EN.md b/en/application-dev/reference/arkui-ts/Readme-EN.md index 2cb89f59542b487fbb09140b152b4e54a4fe5dc9..634f77c8f6ced5b6a05c0e23caf97c342da2ef0f 100644 --- a/en/application-dev/reference/arkui-ts/Readme-EN.md +++ b/en/application-dev/reference/arkui-ts/Readme-EN.md @@ -1,82 +1,13 @@ # TypeScript-based Declarative Development Paradigm -- [Framework Overview](ts-framework-framework.md) - - [File Organization](ts-framework-file.md) - - [Directory Structure](ts-framework-directory.md) - - [Rules for Accessing Application Code Files](ts-framework-file-access-rules.md) - - - ["js" Tag](ts-framework-js-tag.md) - - [Resource Access](ts-resource-access.md) - - [Media Resource Types](ts-media-resource-type.md) - - - [Pixel Units](ts-pixel-units.md) - - [Types](ts-types.md) - -- [Declarative Syntax](ts-declarative-syntax.md) - - [Overview](ts-syntax-intro.md) - - [General UI Description Specifications](ts-general-ui-description-specifications.md) - - [Basic Concepts](ts-general-ui-concepts.md) - - [Declarative UI Description Specifications](ts-declarative-ui-description-specifications.md) - - [Parameterless Configuration](ts-parameterless-configuration.md) - - [Configuration with Mandatory Parameters](ts-configuration-with-mandatory-parameters.md) - - [Attribution Configuration](ts-attribution-configuration.md) - - [Event Configuration](ts-event-configuration.md) - - [Child Component Configuration](ts-child-component-configuration.md) - - - [Component-based](ts-component-based.md) - - [@Component](ts-component-based-component.md) - - [@Entry](ts-component-based-entry.md) - - [@Preview](ts-component-based-preview.md) - - [@Builder](ts-component-based-builder.md) - - [@Extend](ts-component-based-extend.md) - - [@CustomDialog](ts-component-based-customdialog.md) - - - [UI State Management](ts-ui-state-management.md) - - [Basic Concepts](ts-ui-state-mgmt-concepts.md) - - [Managing Component States](ts-managing-component-states.md) - - [@State](ts-component-states-state.md) - - [@Prop](ts-component-states-prop.md) - - [@Link](ts-component-states-link.md) - - - [Managing Application States](ts-managing-application-states.md) - - [APIs](ts-managing-application-states-apis.md) - - [AppStorage](ts-application-states-appstorage.md) - - [PersistentStorage](ts-application-states-apis-persistentstorage.md) - - [Environment](ts-application-states-apis-environment.md) - - - [Synchronization Between AppStorage and Components](ts-application-states-storagelink-storageprop.md) - - - [Managing Other States](ts-managing-other-states.md) - - [@observed and @objectLink](ts-other-states-observed-objectlink.md) - - [@Consume and @Provide](ts-other-states-consume-provide.md) - - [@Watch](ts-other-states-watch.md) - - - [Rendering Control Syntax](ts-rending-control-syntax.md) - - [if/else](ts-rending-control-syntax-if-else.md) - - [ForEach](ts-rending-control-syntax-foreach.md) - - [LazyForEach](ts-rending-control-syntax-lazyforeach.md) - - - [A Deep Dive into @Component](ts-a-deep-dive-into-component.md) - - [build Function](ts-function-build.md) - - [Custom Component Initialization](ts-custom-component-initialization.md) - - [Custom Component Lifecycle Callbacks](ts-custom-component-lifecycle-callbacks.md) - - [Example: Component Creation and Re-Initialization](ts-component-creation-re-initialization.md) - - - [Syntactic Sugar](ts-syntactic-sugar.md) - - [@Decorator](ts-syntactic-sugar-decorator.md) - - [Chaining](ts-syntactic-sugar-chaining.md) - - [struct](ts-syntactic-sugar-struct.md) - - [Instantiating a struct Without the new Keyword](ts-instantiating-a-struct-without-new-keyword.md) - - [Using a Separate Line for New Component](ts-using-a-separate-line-for-new-component.md) - - [Restrictions on Using the TS Language for Generators](ts-restrictions-for-generators.md) - - [Components](ts-components.md) - [Universal Components](ts-universal-components.md) - [Universal Events](ts-universal-events.md) - [Click Event](ts-universal-events-click.md) - - [Touch Event](ts-universal-events-touch.md) + - [Touch](ts-universal-events-touch.md) - [Show/Hide Event](ts-universal-events-show-hide.md) - [Key Event](ts-universal-events-key.md) + - [Component Area Change Event](ts-universal-events-component-area-change.md) - [Universal Attributes](ts-universal-attributes.md) - [Size](ts-universal-attributes-size.md) @@ -98,6 +29,8 @@ - [Gradient Color](ts-universal-attributes-gradient-color.md) - [Popup Control](ts-universal-attributes-popup.md) - [Menu Control](ts-universal-attributes-menu.md) + - [Click Control](ts-universal-attributes-touchable.md) + - [Touch Target](ts-universal-attributes-response-region.md) - [Gesture Processing](ts-gesture-processing.md) - [Gesture Binding Methods](ts-gesture-settings.md) @@ -107,6 +40,7 @@ - [PanGesture](ts-basic-gestures-pangesture.md) - [PinchGesture](ts-basic-gestures-pinchgesture.md) - [RotationGesture](ts-basic-gestures-rotationgesture.md) + - [SwipeGesture](ts-basic-gestures-swipegesture.md) - [Combined Gestures](ts-combined-gestures.md) @@ -115,14 +49,19 @@ - [Button](ts-basic-components-button.md) - [DataPanel](ts-basic-components-datapanel.md) - [Divider](ts-basic-components-divider.md) + - [Gauge](ts-basic-components-gauge.md) - [Image](ts-basic-components-image.md) - [ImageAnimator](ts-basic-components-imageanimator.md) + - [Marquee](ts-basic-components-marquee.md) - [Progress](ts-basic-components-progress.md) - [QRCode](ts-basic-components-qrcode.md) - [Rating](ts-basic-components-rating.md) - [Span](ts-basic-components-span.md) - [Slider](ts-basic-components-slider.md) - [Text](ts-basic-components-text.md) + - [TextArea](ts-basic-components-textarea.md) + - [TextInput](ts-basic-components-textinput.md) + - [Toggle](ts-basic-components-toggle.md) - [Container Components](ts-components-container.md) - [AlphabetIndexer](ts-container-alphabet-indexer.md) @@ -137,14 +76,18 @@ - [List](ts-container-list.md) - [ListItem](ts-container-listitem.md) - [Navigator](ts-container-navigator.md) + - [Navigation](ts-container-navigation.md) - [Panel](ts-container-panel.md) - [Row](ts-container-row.md) - [RowSplit](ts-container-rowsplit.md) - [Scroll](ts-container-scroll.md) + - [ScrollBar](ts-container-scrollbar.md) - [Stack](ts-container-stack.md) - [Swiper](ts-container-swiper.md) - [Tabs](ts-container-tabs.md) - [TabContent](ts-container-tabcontent.md) + - [Stepper](ts-container-stepper.md) + - [StepperItem](ts-container-stepperitem.md) - [Drawing Components](ts-drawing-components.md) - [Circle](ts-drawing-components-circle.md) @@ -156,8 +99,18 @@ - [Rect](ts-drawing-components-rect.md) - [Shape](ts-drawing-components-shape.md) + - [Canvas Components](ts-components-canvas.md) + - [Canvas](ts-components-canvas-canvas.md) + - [CanvasRenderingContext2D](ts-canvasrenderingcontext2d.md) + - [OffscreenCanvasRenderingConxt2D](ts-offscreencanvasrenderingcontext2d.md) + - [Lottie](ts-components-canvas-lottie.md) + - [Path2D](ts-components-canvas-path2d.md) + - [CanvasGradient](ts-components-canvas-canvasgradient.md) + - [ImageBitmap](ts-components-canvas-imagebitmap.md) + - [ImageData](ts-components-canvas-imagedata.md) + - [Animation](ts-animation.md) - - [AnimatorProperty](ts-animatorproperty.md) + - [Attribute Animation](ts-animatorproperty.md) - [Explicit Animation](ts-explicit-animation.md) - [Transition Animation](ts-transition-animation.md) - [Page Transition](ts-page-transition-animation.md) @@ -173,6 +126,7 @@ - [Custom Dialog box](ts-methods-custom-dialog-box.md) - [Image Cache](ts-methods-image-cache.md) - [Media Query](ts-methods-media-query.md) + - [List Selection Dialog Box](ts-methods-custom-actionsheet.md) - [Appendix](ts-appendix.md) - [Built-in Enums](ts-appendix-enums.md) diff --git a/en/application-dev/reference/arkui-ts/figures/1-64.png b/en/application-dev/reference/arkui-ts/figures/1.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/1-64.png rename to en/application-dev/reference/arkui-ts/figures/1.png diff --git a/en/application-dev/reference/arkui-ts/figures/1111-59.png b/en/application-dev/reference/arkui-ts/figures/1111.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/1111-59.png rename to en/application-dev/reference/arkui-ts/figures/1111.png diff --git a/en/application-dev/reference/arkui-ts/figures/11111-5.png b/en/application-dev/reference/arkui-ts/figures/11111-5.png new file mode 100644 index 0000000000000000000000000000000000000000..5da42e3e14d601745274cb62d914c6600620bb25 Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/11111-5.png differ diff --git a/en/application-dev/reference/arkui-ts/figures/11111.png b/en/application-dev/reference/arkui-ts/figures/11111.png new file mode 100644 index 0000000000000000000000000000000000000000..5da42e3e14d601745274cb62d914c6600620bb25 Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/11111.png differ diff --git a/en/application-dev/reference/arkui-ts/figures/2-01.png b/en/application-dev/reference/arkui-ts/figures/2-01.png new file mode 100644 index 0000000000000000000000000000000000000000..e766d36181c3d1fbd96bb0acab1b3eb670e14cd4 Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/2-01.png differ diff --git a/en/application-dev/reference/arkui-ts/figures/5-65.gif b/en/application-dev/reference/arkui-ts/figures/5.gif similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/5-65.gif rename to en/application-dev/reference/arkui-ts/figures/5.gif diff --git a/en/application-dev/reference/arkui-ts/figures/66666.gif b/en/application-dev/reference/arkui-ts/figures/66666.gif new file mode 100644 index 0000000000000000000000000000000000000000..b40f786a2f583af59e9f63d35ab1d503f51525da Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/66666.gif differ diff --git a/en/application-dev/reference/arkui-ts/figures/blank1.gif b/en/application-dev/reference/arkui-ts/figures/blank1.gif new file mode 100644 index 0000000000000000000000000000000000000000..2547cd4af312ee9a2cfc6c3c61b630fdcd7426f9 Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/blank1.gif differ diff --git a/en/application-dev/reference/arkui-ts/figures/blank2.gif b/en/application-dev/reference/arkui-ts/figures/blank2.gif new file mode 100644 index 0000000000000000000000000000000000000000..fe04e9611135b8d8cd4f9ace0acf1d1a5797bf6c Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/blank2.gif differ diff --git a/en/application-dev/reference/arkui-ts/figures/blank_h.gif b/en/application-dev/reference/arkui-ts/figures/blank_h.gif deleted file mode 100644 index 6f3a05c4fa0ac29097cc25d6021fa33f069f6175..0000000000000000000000000000000000000000 Binary files a/en/application-dev/reference/arkui-ts/figures/blank_h.gif and /dev/null differ diff --git a/en/application-dev/reference/arkui-ts/figures/blank_v.gif b/en/application-dev/reference/arkui-ts/figures/blank_v.gif deleted file mode 100644 index 04e09206185deb61233c3bf51a302cc0ccc9c080..0000000000000000000000000000000000000000 Binary files a/en/application-dev/reference/arkui-ts/figures/blank_v.gif and /dev/null differ diff --git a/en/application-dev/reference/arkui-ts/figures/click.gif b/en/application-dev/reference/arkui-ts/figures/click.gif deleted file mode 100644 index 20a61f7c3daa0e4225a7421803948c073fb9fe31..0000000000000000000000000000000000000000 Binary files a/en/application-dev/reference/arkui-ts/figures/click.gif and /dev/null differ diff --git a/en/application-dev/reference/arkui-ts/figures/datapanel.jpg b/en/application-dev/reference/arkui-ts/figures/datapanel.jpg new file mode 100644 index 0000000000000000000000000000000000000000..b12c5fb6563c7ee9d8dfa7e6af1cfe1dcfa1361c Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/datapanel.jpg differ diff --git a/en/application-dev/reference/arkui-ts/figures/datapanel.png b/en/application-dev/reference/arkui-ts/figures/datapanel.png deleted file mode 100644 index 6b8ac87fce6a2b4aebc98304db6ed2fd7d14cb82..0000000000000000000000000000000000000000 Binary files a/en/application-dev/reference/arkui-ts/figures/datapanel.png and /dev/null differ diff --git a/en/application-dev/reference/arkui-ts/figures/divider.png b/en/application-dev/reference/arkui-ts/figures/divider.png deleted file mode 100644 index f2deeb8445fe0f3b66d2b0facbf9e0f0ed9911ca..0000000000000000000000000000000000000000 Binary files a/en/application-dev/reference/arkui-ts/figures/divider.png and /dev/null differ diff --git a/en/application-dev/reference/arkui-ts/figures/duande.gif b/en/application-dev/reference/arkui-ts/figures/duande.gif new file mode 100644 index 0000000000000000000000000000000000000000..7ed4e908925042a11312dd27aa1c28e8c91d8d8c Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/duande.gif differ diff --git a/en/application-dev/reference/arkui-ts/figures/ellipse-63.png b/en/application-dev/reference/arkui-ts/figures/ellipse.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/ellipse-63.png rename to en/application-dev/reference/arkui-ts/figures/ellipse.png diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001182200571.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001182200571.png deleted file mode 100644 index c3d760c6d3f6c1e377ff2e42c0b3fb9e547ac140..0000000000000000000000000000000000000000 Binary files a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001182200571.png and /dev/null differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001192595194.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001192595194.png new file mode 100644 index 0000000000000000000000000000000000000000..348499bc3787a833ab3da5f87500b11c9c93773e Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001192595194.png differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001192595214.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001192595214.png new file mode 100644 index 0000000000000000000000000000000000000000..e544a2958b969018ff6bfe8b44bb8758c2aea61a Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001192595214.png differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001192595216.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001192595216.png new file mode 100644 index 0000000000000000000000000000000000000000..f410f22c1dd0ba7e1c9718eb3995de5f5033c0a6 Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001192595216.png differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001192595220.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001192595220.png new file mode 100644 index 0000000000000000000000000000000000000000..2eed5759714b99dc039faab67acdfe6d67bfc6ac Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001192595220.png differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001192595224.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001192595224.png new file mode 100644 index 0000000000000000000000000000000000000000..72a515c8b425037a4307ef1b16def3e528aab4a0 Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001192595224.png differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001192595226.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001192595226.png new file mode 100644 index 0000000000000000000000000000000000000000..92a309337be0e2f4c49d0484dab0ffd19584b534 Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001192595226.png differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001192595228.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001192595228.png new file mode 100644 index 0000000000000000000000000000000000000000..1f4208ebcf5ffeeda0d1f5c452327c8fd8dcf7ac Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001192595228.png differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001192595230.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001192595230.png new file mode 100644 index 0000000000000000000000000000000000000000..b4fd4aff2fb6b7a32fcb8af41a84fbf57c26d035 Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001192595230.png differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001192595232.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001192595232.png new file mode 100644 index 0000000000000000000000000000000000000000..160278c82fcdf310c796609d5ee29a2a4869af9e Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001192595232.png differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001192595234.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001192595234.png new file mode 100644 index 0000000000000000000000000000000000000000..ec9ddc678b5a74f1e5ae78ba6a9c35618f31a589 Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001192595234.png differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001192595238.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001192595238.png new file mode 100644 index 0000000000000000000000000000000000000000..d3db21e0e3da6d8663f59b2ddabd9e50d6eb1e6a Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001192595238.png differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001192755172.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001192755172.png new file mode 100644 index 0000000000000000000000000000000000000000..5869f7cdc9a81adc7f03d07ab121c6b8433637d9 Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001192755172.png differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001192755174.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001192755174.png new file mode 100644 index 0000000000000000000000000000000000000000..adb4986f7f26047e65e552c570e3f9e62a2037ac Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001192755174.png differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001192755178.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001192755178.png new file mode 100644 index 0000000000000000000000000000000000000000..801bf97495213f41c2b196b2f170af85b156dd5b Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001192755178.png differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001192755180.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001192755180.png new file mode 100644 index 0000000000000000000000000000000000000000..4fb651372a67eca9de3848baa6b66cac0ee9f173 Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001192755180.png differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001192755182.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001192755182.png new file mode 100644 index 0000000000000000000000000000000000000000..0d9cf4d6e06b96da9b93608e7a050af71eaa5032 Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001192755182.png differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001192755188.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001192755188.png new file mode 100644 index 0000000000000000000000000000000000000000..cb250dfc130cc329ae9dc74ddb861e8753d419c3 Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001192755188.png differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001192755194.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001192755194.png new file mode 100644 index 0000000000000000000000000000000000000000..4608132f8e4292a3fe0174a65a9a3f2fc428c0e7 Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001192755194.png differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001192915130.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001192915130.png new file mode 100644 index 0000000000000000000000000000000000000000..1ba89fa119f9a64c74b9353c20ec3d741aaad9be Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001192915130.png differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001192915154.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001192915154.png new file mode 100644 index 0000000000000000000000000000000000000000..f36078d6d832fa757378b72fa0739f66fe781c64 Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001192915154.png differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001192915158.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001192915158.png new file mode 100644 index 0000000000000000000000000000000000000000..d8bdc2d4a59d0b3c5de0f8c020d30ffc5b2ead7a Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001192915158.png differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001192915162.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001192915162.png new file mode 100644 index 0000000000000000000000000000000000000000..1ba89fa119f9a64c74b9353c20ec3d741aaad9be Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001192915162.png differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001192915178.gif b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001192915178.gif new file mode 100644 index 0000000000000000000000000000000000000000..b1808e80a0e4d055d54b886ecca3ddc8efa64b9a Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001192915178.gif differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001192915180.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001192915180.png new file mode 100644 index 0000000000000000000000000000000000000000..7dafd299b8e48ead7d6f783e5a370e31257e341c Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001192915180.png differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001192915184.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001192915184.png new file mode 100644 index 0000000000000000000000000000000000000000..ee1d5493dd38de810cbfe5e41e54d507b839e9c9 Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001192915184.png differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193075122.gif b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193075122.gif new file mode 100644 index 0000000000000000000000000000000000000000..b26dc8bf409987fa624f6dc0cec1c56043e7b37a Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193075122.gif differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193075134.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193075134.png new file mode 100644 index 0000000000000000000000000000000000000000..241fe8546ea2acfdb7baf2c5e66a8af2f0d7b593 Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193075134.png differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193075154.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193075154.png new file mode 100644 index 0000000000000000000000000000000000000000..8c06945a1790bb0a741b330fe0a9170dd2a3a92d Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193075154.png differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193075164.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193075164.png new file mode 100644 index 0000000000000000000000000000000000000000..45be809bdb14e8badfaac2dc8e2486864d29f763 Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193075164.png differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193075166.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193075166.png new file mode 100644 index 0000000000000000000000000000000000000000..fb7fc25c17990998ba263a8525e6a110794c0d87 Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193075166.png differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193075168.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193075168.png new file mode 100644 index 0000000000000000000000000000000000000000..5eecca641660f12e3ad2ba7b97b97eca253a4acf Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193075168.png differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193075170.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193075170.png new file mode 100644 index 0000000000000000000000000000000000000000..241fe8546ea2acfdb7baf2c5e66a8af2f0d7b593 Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193075170.png differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193075172.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193075172.png new file mode 100644 index 0000000000000000000000000000000000000000..5d649492978121a484c2a7a55d4548384c919149 Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193075172.png differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193075178.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193075178.png new file mode 100644 index 0000000000000000000000000000000000000000..4f115a17e671fa21da2d44cd82bf7b0f3c70c0a6 Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193075178.png differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193075180.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193075180.png new file mode 100644 index 0000000000000000000000000000000000000000..7cbe07731306eff949ff7ced4dd7eb4a374c8310 Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193075180.png differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193321136.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193321136.png new file mode 100644 index 0000000000000000000000000000000000000000..72a515c8b425037a4307ef1b16def3e528aab4a0 Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193321136.png differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193321138.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193321138.png new file mode 100644 index 0000000000000000000000000000000000000000..fb7fc25c17990998ba263a8525e6a110794c0d87 Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193321138.png differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193322850.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193322850.png new file mode 100644 index 0000000000000000000000000000000000000000..657eee10e270eb448fc7f7f4b24b18134a42d5dc Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193322850.png differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193322872.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193322872.png new file mode 100644 index 0000000000000000000000000000000000000000..7cbe07731306eff949ff7ced4dd7eb4a374c8310 Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193322872.png differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193322910.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193322910.png new file mode 100644 index 0000000000000000000000000000000000000000..e764c43599592d821c403aac0d3fa40d9edd22e5 Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193322910.png differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193436448.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193436448.png new file mode 100644 index 0000000000000000000000000000000000000000..2eed5759714b99dc039faab67acdfe6d67bfc6ac Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193436448.png differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193481094.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193481094.png new file mode 100644 index 0000000000000000000000000000000000000000..1f4208ebcf5ffeeda0d1f5c452327c8fd8dcf7ac Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193481094.png differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193481096.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193481096.png new file mode 100644 index 0000000000000000000000000000000000000000..138e011909c2d4738f3cd9671a79ea0c37cb5b87 Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193481096.png differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193481098.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193481098.png new file mode 100644 index 0000000000000000000000000000000000000000..defc3c9eb037c06b894ee2e30563facb8c8375ab Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193481098.png differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193482814.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193482814.png new file mode 100644 index 0000000000000000000000000000000000000000..45be809bdb14e8badfaac2dc8e2486864d29f763 Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193482814.png differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193482866.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193482866.png new file mode 100644 index 0000000000000000000000000000000000000000..5eecca641660f12e3ad2ba7b97b97eca253a4acf Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193482866.png differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193641084.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193641084.png new file mode 100644 index 0000000000000000000000000000000000000000..563ce2878d24a7fa46044f201433d759c3fa9001 Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193641084.png differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193641086.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193641086.png new file mode 100644 index 0000000000000000000000000000000000000000..801bf97495213f41c2b196b2f170af85b156dd5b Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193641086.png differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193642802.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193642802.png new file mode 100644 index 0000000000000000000000000000000000000000..160278c82fcdf310c796609d5ee29a2a4869af9e Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193642802.png differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193642848.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193642848.png new file mode 100644 index 0000000000000000000000000000000000000000..83b7a51accdda21d21a39e5e9d917d75811cb496 Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193642848.png differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193737314.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193737314.png new file mode 100644 index 0000000000000000000000000000000000000000..e3b4b42aecaef72ed4a08b3566a895b3f9b12343 Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193737314.png differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193756416.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193756416.png new file mode 100644 index 0000000000000000000000000000000000000000..b0b8bdc7fc7cd417340bbcda6845fd7de0098930 Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193756416.png differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193801070.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193801070.png new file mode 100644 index 0000000000000000000000000000000000000000..92a309337be0e2f4c49d0484dab0ffd19584b534 Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193801070.png differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193801072.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193801072.png new file mode 100644 index 0000000000000000000000000000000000000000..b4fd4aff2fb6b7a32fcb8af41a84fbf57c26d035 Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193801072.png differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193802788.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193802788.png new file mode 100644 index 0000000000000000000000000000000000000000..c1803b711d45a86552a2be4099424206a1561534 Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193802788.png differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193802836.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193802836.png new file mode 100644 index 0000000000000000000000000000000000000000..ad8582f58ed05f9ac3b8962f82d8565d1f580f6c Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001193802836.png differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001194605518.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001194605518.png new file mode 100644 index 0000000000000000000000000000000000000000..085d31e9bf7c5740ac3c46d04c4098e64eb3a544 Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001194605518.png differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001194911566.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001194911566.png new file mode 100644 index 0000000000000000000000000000000000000000..8c8194c14b5ca1ea743782db95027035370ead7e Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001194911566.png differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001194942468.gif b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001194942468.gif new file mode 100644 index 0000000000000000000000000000000000000000..ecbaeb8cc1a3ec9e1ecfd253b605be50836b1f46 Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001194942468.gif differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001196780640.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001196780640.png new file mode 100644 index 0000000000000000000000000000000000000000..857e773f72d0cd7cd9ae13f50aa843a11aae4f97 Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001196780640.png differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001201475612.gif b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001201475612.gif new file mode 100644 index 0000000000000000000000000000000000000000..502888c25bb21b3803858f9c436cca23d9dc29d0 Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001201475612.gif differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237355087.gif b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237355087.gif new file mode 100644 index 0000000000000000000000000000000000000000..38502c83c52aa9229da69d638e4b9b1f5a35009b Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237355087.gif differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237355121.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237355121.png new file mode 100644 index 0000000000000000000000000000000000000000..e764c43599592d821c403aac0d3fa40d9edd22e5 Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237355121.png differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237355131.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237355131.png new file mode 100644 index 0000000000000000000000000000000000000000..138e011909c2d4738f3cd9671a79ea0c37cb5b87 Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237355131.png differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237355133.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237355133.png new file mode 100644 index 0000000000000000000000000000000000000000..088d5a479cc188332bb7295b31aea277897faca8 Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237355133.png differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237355135.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237355135.png new file mode 100644 index 0000000000000000000000000000000000000000..10059591af349daced4bf7abeb009209a3e90f1d Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237355135.png differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237355137.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237355137.png new file mode 100644 index 0000000000000000000000000000000000000000..83b7a51accdda21d21a39e5e9d917d75811cb496 Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237355137.png differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237475107.gif b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237475107.gif new file mode 100644 index 0000000000000000000000000000000000000000..b3966d0abb39044241ee174a126fcf919f402d98 Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237475107.gif differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237475113.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237475113.png new file mode 100644 index 0000000000000000000000000000000000000000..84d835e7feeac31e42c1a53670ef6c999ea4bfe2 Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237475113.png differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237475123.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237475123.png new file mode 100644 index 0000000000000000000000000000000000000000..e3b4b42aecaef72ed4a08b3566a895b3f9b12343 Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237475123.png differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237475133.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237475133.png new file mode 100644 index 0000000000000000000000000000000000000000..f0e245a5c576e92810baacaa09af99f108a010a9 Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237475133.png differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237475137.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237475137.png new file mode 100644 index 0000000000000000000000000000000000000000..defc3c9eb037c06b894ee2e30563facb8c8375ab Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237475137.png differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237475139.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237475139.png new file mode 100644 index 0000000000000000000000000000000000000000..9cb1361bd9aded6d58d51ae771558989977a0608 Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237475139.png differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237555149.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237555149.png new file mode 100644 index 0000000000000000000000000000000000000000..1ba89fa119f9a64c74b9353c20ec3d741aaad9be Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237555149.png differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237555151.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237555151.png new file mode 100644 index 0000000000000000000000000000000000000000..1330e2e2a6395703f9c3747252c1e0a69ae6f4f0 Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237555151.png differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237555155.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237555155.png new file mode 100644 index 0000000000000000000000000000000000000000..071919ed3a638630f33a337f920ae2e60c9c21bc Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237555155.png differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237555163.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237555163.png new file mode 100644 index 0000000000000000000000000000000000000000..26fb5384338291f3eb372abd526f0727ce759bdc Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237555163.png differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237555165.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237555165.png new file mode 100644 index 0000000000000000000000000000000000000000..50726d3e461d7a5dbfec674899fee603aaf41bee Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237555165.png differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237555167.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237555167.png new file mode 100644 index 0000000000000000000000000000000000000000..af02181de0d07d5311b09c8d05c2a018e6e5b4cf Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237555167.png differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237555173.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237555173.png new file mode 100644 index 0000000000000000000000000000000000000000..657eee10e270eb448fc7f7f4b24b18134a42d5dc Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237555173.png differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237555179.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237555179.png new file mode 100644 index 0000000000000000000000000000000000000000..cb250dfc130cc329ae9dc74ddb861e8753d419c3 Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237555179.png differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237555181.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237555181.png new file mode 100644 index 0000000000000000000000000000000000000000..b2728fd1b4e050edddf499398b44a7e3aa634109 Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237555181.png differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237715141.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237715141.png new file mode 100644 index 0000000000000000000000000000000000000000..c1803b711d45a86552a2be4099424206a1561534 Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237715141.png differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237715149.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237715149.png new file mode 100644 index 0000000000000000000000000000000000000000..b0b8bdc7fc7cd417340bbcda6845fd7de0098930 Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237715149.png differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237715151.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237715151.png new file mode 100644 index 0000000000000000000000000000000000000000..1f4208ebcf5ffeeda0d1f5c452327c8fd8dcf7ac Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237715151.png differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237715153.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237715153.png new file mode 100644 index 0000000000000000000000000000000000000000..22e84d1b8951b163748a079b6d1d302148d3b6bb Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237715153.png differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237715155.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237715155.png new file mode 100644 index 0000000000000000000000000000000000000000..945862898489d8e008e94abbcd691aa307b18d06 Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237715155.png differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237715159.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237715159.png new file mode 100644 index 0000000000000000000000000000000000000000..3e7218eb57566d86457a9fbd4a8ed0f0dd490c3f Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237715159.png differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237715165.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237715165.png new file mode 100644 index 0000000000000000000000000000000000000000..f5cd637e5bf9db13e3334ca00413e3a91412c813 Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001237715165.png differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001238281067.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001238281067.png new file mode 100644 index 0000000000000000000000000000000000000000..22e84d1b8951b163748a079b6d1d302148d3b6bb Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001238281067.png differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001238281069.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001238281069.png new file mode 100644 index 0000000000000000000000000000000000000000..088d5a479cc188332bb7295b31aea277897faca8 Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001238281069.png differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001238282783.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001238282783.png new file mode 100644 index 0000000000000000000000000000000000000000..10059591af349daced4bf7abeb009209a3e90f1d Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001238282783.png differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001238282827.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001238282827.png new file mode 100644 index 0000000000000000000000000000000000000000..b2728fd1b4e050edddf499398b44a7e3aa634109 Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001238282827.png differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001238401029.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001238401029.png new file mode 100644 index 0000000000000000000000000000000000000000..d0e446b213816e4db8d67a9898da1afa7b8226ad Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001238401029.png differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001238401031.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001238401031.png new file mode 100644 index 0000000000000000000000000000000000000000..d3db21e0e3da6d8663f59b2ddabd9e50d6eb1e6a Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001238401031.png differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001238402745.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001238402745.png new file mode 100644 index 0000000000000000000000000000000000000000..4608132f8e4292a3fe0174a65a9a3f2fc428c0e7 Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001238402745.png differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001238402777.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001238402777.png new file mode 100644 index 0000000000000000000000000000000000000000..f5cd637e5bf9db13e3334ca00413e3a91412c813 Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001238402777.png differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001238457271.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001238457271.png new file mode 100644 index 0000000000000000000000000000000000000000..4fb651372a67eca9de3848baa6b66cac0ee9f173 Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001238457271.png differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001238476361.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001238476361.png new file mode 100644 index 0000000000000000000000000000000000000000..5d649492978121a484c2a7a55d4548384c919149 Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001238476361.png differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001238521019.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001238521019.png new file mode 100644 index 0000000000000000000000000000000000000000..af02181de0d07d5311b09c8d05c2a018e6e5b4cf Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001238521019.png differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001238521021.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001238521021.png new file mode 100644 index 0000000000000000000000000000000000000000..3e7218eb57566d86457a9fbd4a8ed0f0dd490c3f Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001238521021.png differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001238522733.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001238522733.png new file mode 100644 index 0000000000000000000000000000000000000000..4f115a17e671fa21da2d44cd82bf7b0f3c70c0a6 Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001238522733.png differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001238522783.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001238522783.png new file mode 100644 index 0000000000000000000000000000000000000000..bc093379e122dcac29c4c8d04560d26bfc23d472 Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001238522783.png differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001238537297.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001238537297.png new file mode 100644 index 0000000000000000000000000000000000000000..50726d3e461d7a5dbfec674899fee603aaf41bee Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001238537297.png differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001238556395.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001238556395.png new file mode 100644 index 0000000000000000000000000000000000000000..294b32cf04462b04243afb828199be9b95e6dd17 Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001238556395.png differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001238601051.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001238601051.png new file mode 100644 index 0000000000000000000000000000000000000000..1f4208ebcf5ffeeda0d1f5c452327c8fd8dcf7ac Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001238601051.png differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001238601053.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001238601053.png new file mode 100644 index 0000000000000000000000000000000000000000..945862898489d8e008e94abbcd691aa307b18d06 Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001238601053.png differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001238602771.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001238602771.png new file mode 100644 index 0000000000000000000000000000000000000000..ec9ddc678b5a74f1e5ae78ba6a9c35618f31a589 Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001238602771.png differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001238602821.png b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001238602821.png new file mode 100644 index 0000000000000000000000000000000000000000..9cb1361bd9aded6d58d51ae771558989977a0608 Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001238602821.png differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001239788885.gif b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001239788885.gif new file mode 100644 index 0000000000000000000000000000000000000000..6b44b6a2adc2528e13e95bc10d2a67874226a63b Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001239788885.gif differ diff --git a/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001239925031.gif b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001239925031.gif new file mode 100644 index 0000000000000000000000000000000000000000..05ad0a8aa0ae63ae9193aa1c9b3f943f060220da Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/en-us_image_0000001239925031.gif differ diff --git a/en/application-dev/reference/arkui-ts/figures/f.gif b/en/application-dev/reference/arkui-ts/figures/f.gif new file mode 100644 index 0000000000000000000000000000000000000000..070ae9d042d5211b2ccc6c187ec0f87a90d2c963 Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/f.gif differ diff --git a/en/application-dev/reference/arkui-ts/figures/flex04-61.gif b/en/application-dev/reference/arkui-ts/figures/flex04-2.gif similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/flex04-61.gif rename to en/application-dev/reference/arkui-ts/figures/flex04-2.gif diff --git a/en/application-dev/reference/arkui-ts/figures/gauge.png b/en/application-dev/reference/arkui-ts/figures/gauge.png new file mode 100644 index 0000000000000000000000000000000000000000..2eb96b00f11e597fcc3e3d5ef32701e0a4ef5f5b Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/gauge.png differ diff --git a/en/application-dev/reference/arkui-ts/figures/gesturesetting.gif b/en/application-dev/reference/arkui-ts/figures/gesturesetting.gif deleted file mode 100644 index d8e941ae58c68666c04183756b9549cef9d9d3b0..0000000000000000000000000000000000000000 Binary files a/en/application-dev/reference/arkui-ts/figures/gesturesetting.gif and /dev/null differ diff --git a/en/application-dev/reference/arkui-ts/figures/gif-0.gif b/en/application-dev/reference/arkui-ts/figures/gif-0.gif new file mode 100644 index 0000000000000000000000000000000000000000..23a03cf07feddcb9866e7ab141c212ebf01bf8b2 Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/gif-0.gif differ diff --git a/en/application-dev/reference/arkui-ts/figures/gif-1.gif b/en/application-dev/reference/arkui-ts/figures/gif-1.gif new file mode 100644 index 0000000000000000000000000000000000000000..52fed39eeae057043dbd00abce9ff29d2c35a56a Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/gif-1.gif differ diff --git a/en/application-dev/reference/arkui-ts/figures/gif-4.gif b/en/application-dev/reference/arkui-ts/figures/gif-4.gif new file mode 100644 index 0000000000000000000000000000000000000000..5bcc79b53b227b6bd0484045d20743d9686c8e08 Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/gif-4.gif differ diff --git a/en/application-dev/reference/arkui-ts/figures/gif.gif b/en/application-dev/reference/arkui-ts/figures/gif.gif new file mode 100644 index 0000000000000000000000000000000000000000..8eceb3bf5313485a1fedda5768e70cdb5febc464 Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/gif.gif differ diff --git a/en/application-dev/reference/arkui-ts/figures/gif1.gif b/en/application-dev/reference/arkui-ts/figures/gif1.gif new file mode 100644 index 0000000000000000000000000000000000000000..e97b2a2406059ce3af77ade27bb634845d807726 Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/gif1.gif differ diff --git a/en/application-dev/reference/arkui-ts/figures/gif2.gif b/en/application-dev/reference/arkui-ts/figures/gif2.gif new file mode 100644 index 0000000000000000000000000000000000000000..b0a6fc0df420fa15f8a0e476da5fa8592bbc751b Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/gif2.gif differ diff --git a/en/application-dev/reference/arkui-ts/figures/gif4.gif b/en/application-dev/reference/arkui-ts/figures/gif4.gif new file mode 100644 index 0000000000000000000000000000000000000000..c7532ed87726ac7591901514a7396b617daa10f0 Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/gif4.gif differ diff --git a/en/application-dev/reference/arkui-ts/figures/grid-62.gif b/en/application-dev/reference/arkui-ts/figures/grid-3.gif similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/grid-62.gif rename to en/application-dev/reference/arkui-ts/figures/grid-3.gif diff --git a/en/application-dev/reference/arkui-ts/figures/image1.gif b/en/application-dev/reference/arkui-ts/figures/image1.gif deleted file mode 100644 index 6bc2dfa331eb3b39fc32aa6c1fa131684dff3220..0000000000000000000000000000000000000000 Binary files a/en/application-dev/reference/arkui-ts/figures/image1.gif and /dev/null differ diff --git a/en/application-dev/reference/arkui-ts/figures/image2.gif b/en/application-dev/reference/arkui-ts/figures/image2.gif deleted file mode 100644 index e4ac98cf8925e5ae93206fb663bef01e4d929169..0000000000000000000000000000000000000000 Binary files a/en/application-dev/reference/arkui-ts/figures/image2.gif and /dev/null differ diff --git a/en/application-dev/reference/arkui-ts/figures/image3.gif b/en/application-dev/reference/arkui-ts/figures/image3.gif deleted file mode 100644 index 209112f1e4c14478df3f44390732d4b2c70755f4..0000000000000000000000000000000000000000 Binary files a/en/application-dev/reference/arkui-ts/figures/image3.gif and /dev/null differ diff --git a/en/application-dev/reference/arkui-ts/figures/lottie-ark-2-0-canvas-ui-animate.gif b/en/application-dev/reference/arkui-ts/figures/lottie-ark-2-0-canvas-ui-animate.gif new file mode 100644 index 0000000000000000000000000000000000000000..e22d25b7aa139409766723e4ed0fd6172b85b6cf Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/lottie-ark-2-0-canvas-ui-animate.gif differ diff --git a/en/application-dev/reference/arkui-ts/figures/overlay.gif b/en/application-dev/reference/arkui-ts/figures/overlay.gif deleted file mode 100644 index 4cce6cb6a529cffef01d5b7d1f6ce5f02d63210e..0000000000000000000000000000000000000000 Binary files a/en/application-dev/reference/arkui-ts/figures/overlay.gif and /dev/null differ diff --git a/en/application-dev/reference/arkui-ts/figures/popup.gif b/en/application-dev/reference/arkui-ts/figures/popup.gif index 3bbb23f623eb1163af382d30bc32c1c4cbe524dd..7631bb0d995839d59a9d3876f91fd7e688c35758 100644 Binary files a/en/application-dev/reference/arkui-ts/figures/popup.gif and b/en/application-dev/reference/arkui-ts/figures/popup.gif differ diff --git a/en/application-dev/reference/arkui-ts/figures/progress-60.png b/en/application-dev/reference/arkui-ts/figures/progress.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/progress-60.png rename to en/application-dev/reference/arkui-ts/figures/progress.png diff --git a/en/application-dev/reference/arkui-ts/figures/shape.gif b/en/application-dev/reference/arkui-ts/figures/shape.gif deleted file mode 100644 index 467de1302c615f93709c266f3d5a47ecb941fc53..0000000000000000000000000000000000000000 Binary files a/en/application-dev/reference/arkui-ts/figures/shape.gif and /dev/null differ diff --git a/en/application-dev/reference/arkui-ts/figures/sider.gif b/en/application-dev/reference/arkui-ts/figures/sider.gif deleted file mode 100644 index 733585b5ca3cbb4fdf690e596b622f56393700d0..0000000000000000000000000000000000000000 Binary files a/en/application-dev/reference/arkui-ts/figures/sider.gif and /dev/null differ diff --git a/en/application-dev/reference/arkui-ts/figures/slider.gif b/en/application-dev/reference/arkui-ts/figures/slider.gif new file mode 100644 index 0000000000000000000000000000000000000000..b1724791e4acb31d193a0dce267e42c99288c6bd Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/slider.gif differ diff --git a/en/application-dev/reference/arkui-ts/figures/swiper.gif b/en/application-dev/reference/arkui-ts/figures/swiper.gif index bf8d1335752f51258920d0cfc1b65190e2f53011..5db399f79a02f496aea43ff72e55e29a0bb05a9a 100644 Binary files a/en/application-dev/reference/arkui-ts/figures/swiper.gif and b/en/application-dev/reference/arkui-ts/figures/swiper.gif differ diff --git a/en/application-dev/reference/arkui-ts/figures/textarea1.gif b/en/application-dev/reference/arkui-ts/figures/textarea1.gif new file mode 100644 index 0000000000000000000000000000000000000000..5c888d43eeb0d0d3ab08e0c2922f136ed0b3d142 Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/textarea1.gif differ diff --git a/en/application-dev/reference/arkui-ts/figures/textinput1.gif b/en/application-dev/reference/arkui-ts/figures/textinput1.gif new file mode 100644 index 0000000000000000000000000000000000000000..9fa5c075ecc4f157f1e66316f4b56f28ffa2007d Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/textinput1.gif differ diff --git a/en/application-dev/reference/arkui-ts/figures/toggle.gif b/en/application-dev/reference/arkui-ts/figures/toggle.gif new file mode 100644 index 0000000000000000000000000000000000000000..f6b7ae5ac2bf443574de54cd4df472a8f0cd1aba Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/toggle.gif differ diff --git a/en/application-dev/reference/arkui-ts/figures/touch.gif b/en/application-dev/reference/arkui-ts/figures/touch.gif deleted file mode 100644 index 021c8dfc90ce80c3ee16acbcb4e06c0ddec6e21e..0000000000000000000000000000000000000000 Binary files a/en/application-dev/reference/arkui-ts/figures/touch.gif and /dev/null differ diff --git a/en/application-dev/reference/arkui-ts/figures/unnaming-(3).png b/en/application-dev/reference/arkui-ts/figures/unnaming-(3).png new file mode 100644 index 0000000000000000000000000000000000000000..293ead152f1cde4757f85101d9c8c96bdec4dee7 Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/unnaming-(3).png differ diff --git a/en/application-dev/reference/arkui-ts/figures/unnaming-(4).png b/en/application-dev/reference/arkui-ts/figures/unnaming-(4).png new file mode 100644 index 0000000000000000000000000000000000000000..e2a8cf9cf4fc88e27e7adb0ad9caf2df9ca978c6 Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/unnaming-(4).png differ diff --git a/en/application-dev/reference/arkui-ts/ts-animation.md b/en/application-dev/reference/arkui-ts/ts-animation.md index 1c2ff183affa9a018716b8aa65cfc55d0929ded3..b5406cb67c82d3843280685dfc33bde75a76d689 100644 --- a/en/application-dev/reference/arkui-ts/ts-animation.md +++ b/en/application-dev/reference/arkui-ts/ts-animation.md @@ -1,6 +1,6 @@ -# Animation +# Animation -- **[AnimatorProperty](ts-animatorproperty.md)** +- **[Attribute Animation](ts-animatorproperty.md)** - **[Explicit Animation](ts-explicit-animation.md)** diff --git a/en/application-dev/reference/arkui-ts/ts-animatorproperty.md b/en/application-dev/reference/arkui-ts/ts-animatorproperty.md index 9c80650d15fd63aae30a7092bd68970a4b741cbd..1e78fb758a57f820506df5029e8e3283108e602c 100644 --- a/en/application-dev/reference/arkui-ts/ts-animatorproperty.md +++ b/en/application-dev/reference/arkui-ts/ts-animatorproperty.md @@ -1,4 +1,7 @@ -# AnimatorProperty +# Attribute Animation + +>![](../../public_sys-resources/icon-note.gif) **NOTE:** +>This gesture is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. When the universal attributes of a component change, you can create an **AnimatorProperty** for gradient to improve user experience. diff --git a/en/application-dev/reference/arkui-ts/ts-appendix-enums.md b/en/application-dev/reference/arkui-ts/ts-appendix-enums.md index 0a6b31dde2b2e5e7d0c75a636afea77289e0b04e..0947abd4085bdedcb912f38a114c22cfacc492c1 100644 --- a/en/application-dev/reference/arkui-ts/ts-appendix-enums.md +++ b/en/application-dev/reference/arkui-ts/ts-appendix-enums.md @@ -1,4 +1,4 @@ -# Built-in Enums +# Built-in Enums ## Alignment Enums @@ -57,6 +57,28 @@
    +## Axis enums + + + + + + + + + + + + + +

    Name

    +

    Description

    +

    Vertical

    +

    Vertical direction.

    +

    Horizontal

    +

    Horizontal direction.

    +
    + ## ItemAlign Enums diff --git a/en/application-dev/reference/arkui-ts/ts-appendix.md b/en/application-dev/reference/arkui-ts/ts-appendix.md index 1c5725e47c6723a680d9a391eabd9e8b635aae04..3ba8ba978eabe4cc2cae5d35bcbd82d57ca61141 100644 --- a/en/application-dev/reference/arkui-ts/ts-appendix.md +++ b/en/application-dev/reference/arkui-ts/ts-appendix.md @@ -1,4 +1,4 @@ -# Appendix +# Appendix - **[Built-in Enums](ts-appendix-enums.md)** diff --git a/en/application-dev/reference/arkui-ts/ts-application-states-storagelink-storageprop.md b/en/application-dev/reference/arkui-ts/ts-application-states-storagelink-storageprop.md deleted file mode 100644 index 3d6aab4ec13cf7fa7d0d9aaed7b1575d008ccf94..0000000000000000000000000000000000000000 --- a/en/application-dev/reference/arkui-ts/ts-application-states-storagelink-storageprop.md +++ /dev/null @@ -1,54 +0,0 @@ -# Synchronization Between AppStorage and Components - -In [Managing Component States](ts-component-states-state.md), we have defined how to synchronize the state variables of the component with the **@State** annotated variables in the parent component or ancestor component, including **@Prop**, **@Link**, and **@Consume**. - -This section describes how to synchronize component variables with the **AppStorage** and mainly covers the **@StorageLink** and **@StorageProp** decorators. - -## @StorageLink Decorator - -Components decorated by **@StorageLink\(_key_\)** have bidirectional data binding with the **AppStorage**. **key** is the attribute key value in the **AppStorage**. When a component containing the **@StorageLink** annotated variable is created, the value of the variable is initialized using the value in the **AppStorage**. Changes made to the **@StorageLink** annotated variable in the UI component will be synchronized to the **AppStorage** and from the **AppStorage** to any other binding instance, such as **PersistentStorage** or other bound UI components. - -## @StorageProp Decorator - -Components decorated by **@StorageProp\(_key_\)** have unidirectional data binding with the **AppStorage**. **key** is the attribute key value in the **AppStorage**. When a component containing the **StorageProp** annotated variable is created, the value of the variable is initialized using the value in the **AppStorage**. The change to the attribute value in the **AppStorage** will cause the bound UI component to update the state. - -## Example - -``` -let varA = AppStorage.Link('varA') -let envLang = AppStorage.Prop('languageCode') - -@Entry -@Component -struct ComponentA { - @StorageLink('varA') varA: number = 2 - @StorageProp('languageCode') lang: string = 'en' - private label: string = 'count' - - private aboutToAppear() { - this.label = (this.lang === 'zh') ? 'Number' : 'Count' - } - - build() { - Row({ space: 20 }) { - - Button(`${this.label}: ${this.varA}`) - .onClick(() => { - AppStorage.Set('varA', AppStorage.Get('varA') + 1) - }) - Button(`lang: ${this.lang}`) - .onClick(() => { - if (this.lang === 'zh') { - AppStorage.Set('languageCode', 'en') - } else { - AppStorage.Set('languageCode', 'zh') - } - this.label = (this.lang === 'zh') ? 'Number' : 'Count' - }) - } - } -} -``` - -Each time the user clicks the Count button, the value of **this.varA** increases. This variable is synchronized with **varA** in the **AppStorage**. Each time the user clicks the icon indicating the current language, the value of **languageCode** in the **AppStorage** is changed. The change is synchronized to the **this.lang** variable. - diff --git a/en/application-dev/reference/arkui-ts/ts-basic-components-blank.md b/en/application-dev/reference/arkui-ts/ts-basic-components-blank.md index 311f155eafc0214910546e3ede65e812599c38bd..d005082951b2e5846084878df9a411a3d1fa021b 100644 --- a/en/application-dev/reference/arkui-ts/ts-basic-components-blank.md +++ b/en/application-dev/reference/arkui-ts/ts-basic-components-blank.md @@ -1,9 +1,9 @@ -# Blank - -The **** component supports automatic filling of the empty part of the container along the main axis. +# Blank >![](../../public_sys-resources/icon-note.gif) **NOTE:** ->- This component is valid only when the parent component is **** or ****. +>This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. + +The **** component supports automatic filling of the empty part of the container along the main axis. This component is valid only when the parent component is **** or ****. ## Required Permissions @@ -86,8 +86,8 @@ struct BlankExample { Row() { Text('Bluetooth').fontSize(18) Blank() - Text('on/off').fontSize(18).height(60) - }.width('100%').backgroundColor(0xFFFFFF).borderRadius(15).padding(12) + Toggle({ type: ToggleType.Switch }) + }.width('100%').backgroundColor(0xFFFFFF).borderRadius(15).padding({ left: 12 }) }.backgroundColor(0xEFEFEF).padding(20) } } @@ -95,9 +95,9 @@ struct BlankExample { Portrait mode -![](figures/blank_v.gif) +![](figures/blank1.gif) Landscape mode -![](figures/blank_h.gif) +![](figures/blank2.gif) diff --git a/en/application-dev/reference/arkui-ts/ts-basic-components-button.md b/en/application-dev/reference/arkui-ts/ts-basic-components-button.md index dfe0b0d34742d12314438dc67464308513aa3991..0c017d6aff130f4a59c840646a083283294023cc 100644 --- a/en/application-dev/reference/arkui-ts/ts-basic-components-button.md +++ b/en/application-dev/reference/arkui-ts/ts-basic-components-button.md @@ -1,6 +1,9 @@ -# Button +# Button -Provides the button component. +>![](../../public_sys-resources/icon-note.gif) **NOTE:** +>This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. + +The **** component represents a component that can trigger actions. ## Required Permissions diff --git a/en/application-dev/reference/arkui-ts/ts-basic-components-datapanel.md b/en/application-dev/reference/arkui-ts/ts-basic-components-datapanel.md index 4da875499d18ac85b3312310fe8c27ebdf94f685..2045636c93f2fba167e4c6c4c84aa699b09efe7f 100644 --- a/en/application-dev/reference/arkui-ts/ts-basic-components-datapanel.md +++ b/en/application-dev/reference/arkui-ts/ts-basic-components-datapanel.md @@ -1,6 +1,10 @@ -# DataPanel +# DataPanel -The **** component display proportions in a ring chart. +The **** component displays proportions in a chart. + +## Required Permissions + +None ## Child Components @@ -8,7 +12,7 @@ None ## APIs -DataPanel\(value:\{values: number\[\], max?: number\}\) +DataPanel\(value:\{values: number\[\], max?: number, type?: DataPanelType\}\) - Parameters @@ -17,11 +21,11 @@ DataPanel\(value:\{values: number\[\], max?: number\}\)

    Type

    Mandatory

    +

    Mandatory

    Default Value

    +

    Default Value

    Description

    +

    Description

    number[]

    Yes

    +

    Yes

    -

    +

    -

    Value list. A maximum of nine values are supported.

    +

    Value list. A maximum of nine values are supported.

    max

    number

    No

    +

    No

    100

    +

    100

    Maximum value.

    +

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

    +

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

    +

    type8+

    +

    DataPanelType

    +

    No

    +

    DataPanelType.Circle

    +

    Type of the data panel.

    +
    + + +- DataPanelType enums + + + + + + + + + + + @@ -57,17 +96,19 @@ DataPanel\(value:\{values: number\[\], max?: number\}\) @Entry @Component struct DataPanelExample { - public values1: number[] = [40, 20, 20, 10, 10] + public values1: number[] = [10, 10, 10, 10, 10, 10, 10, 10, 10] build() { Column({ space: 5 }) { - DataPanel({ values: this.values1, max: 100 }) - .width(150) - .height(150) + Text('Circle').fontSize(9).fontColor(0xCCCCCC).margin({ top: 20, right: '80%' }) + DataPanel({ values: this.values1, max: 100, type: DataPanelType.Circle }).width(200).height(200) + + Text('Line').fontSize(9).fontColor(0xCCCCCC).margin({ bottom: 20, right: '80%' }) + DataPanel({ values: this.values1, max: 100, type: DataPanelType.Line }).width(300).height(10) }.width('100%').margin({ top: 5 }) } } ``` -![](figures/datapanel.png) +![](figures/datapanel.jpg) diff --git a/en/application-dev/reference/arkui-ts/ts-basic-components-divider.md b/en/application-dev/reference/arkui-ts/ts-basic-components-divider.md index 582f46904df95794cc01fcfef0e5b7ed28570bb7..975737f94d718f15edb7ea3e3c37cdaf7998e50a 100644 --- a/en/application-dev/reference/arkui-ts/ts-basic-components-divider.md +++ b/en/application-dev/reference/arkui-ts/ts-basic-components-divider.md @@ -1,4 +1,7 @@ -# Divider +# Divider + +>![](../../public_sys-resources/icon-note.gif) **NOTE:** +>This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. The **** component is used to separate content blocks and content elements. @@ -101,5 +104,5 @@ struct DividerExample { } ``` -![](figures/divider.png) +![](figures/en-us_image_0000001196780640.png) diff --git a/en/application-dev/reference/arkui-ts/ts-basic-components-gauge.md b/en/application-dev/reference/arkui-ts/ts-basic-components-gauge.md new file mode 100644 index 0000000000000000000000000000000000000000..1f6b9bc92c5d1508850b1ee64dd90088e8652c1b --- /dev/null +++ b/en/application-dev/reference/arkui-ts/ts-basic-components-gauge.md @@ -0,0 +1,152 @@ +# Gauge + +>![](../../public_sys-resources/icon-note.gif) **NOTE:** +>This component is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version. + +Data gauge chart widget, which is used to display data in a ring chart. + +## Required Permissions + +None + +## Child Component + +N/A + +## APIs + +Gauge\(value:\{value: number, min?: number, max?: number\}\) + +- Parameter + + +

    Name

    +

    Description

    +

    Line

    +

    Line data panel.

    +

    Circle

    +

    Circle data panel.

    + + + + + + + + + + + + + + + + + + + + + + + + + +

    Name

    +

    Type

    +

    Mandatory

    +

    Default Value

    +

    Description

    +

    value

    +

    number

    +

    Yes

    +

    -

    +

    Current data value.

    +

    min

    +

    number

    +

    No

    +

    0

    +

    Minimum value of the current data segment.

    +

    max

    +

    number

    +

    No

    +

    100

    +

    Maximum value of the current data segment.

    +
    + + +## Attributes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

    Name

    +

    Type

    +

    Default Value

    +

    Description

    +

    value

    +

    number

    +

    0

    +

    Sets the value of the current data chart.

    +

    startAngle

    +

    Angle

    +

    -150

    +

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

    +

    endAngle

    +

    Angle

    +

    150

    +

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

    +

    colors

    +

    Color | Array<ColorStop>

    +

    -

    +

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

    +

    strokeWidth

    +

    Length

    +

    -

    +

    Sets the ring thickness of a ring chart.

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

    src

    +

    uri

    string

    syncLoad8+

    +

    boolean

    +

    false

    +

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

    +
    @@ -313,7 +325,7 @@ struct ImageExample1 { } ``` -![](figures/image1.gif) +![](figures/en-us_image_0000001239925031.gif) ``` // Image2 @@ -382,7 +394,7 @@ struct ImageExample2 { } ``` -![](figures/image2.gif) +![](figures/en-us_image_0000001194605518.png) ``` // Image3 @@ -444,5 +456,5 @@ struct ImageExample3 { } ``` -![](figures/image3.gif) +![](figures/en-us_image_0000001194942468.gif) diff --git a/en/application-dev/reference/arkui-ts/ts-basic-components-imageanimator.md b/en/application-dev/reference/arkui-ts/ts-basic-components-imageanimator.md index d2b5813ea5e0ae210640b287a267f96b1bae5b9b..af1a3aaaa8f9297be8efbb28d8455d4c46f5ab5e 100644 --- a/en/application-dev/reference/arkui-ts/ts-basic-components-imageanimator.md +++ b/en/application-dev/reference/arkui-ts/ts-basic-components-imageanimator.md @@ -1,7 +1,14 @@ -# ImageAnimator +# ImageAnimator + +>![](../../public_sys-resources/icon-note.gif) **NOTE:** +>This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. The **** component enables images to be played frame by frame. The list of images to be played can be configured, and the duration of each image can be configured. +## Required Permissions + +None + ## Child Components None diff --git a/en/application-dev/reference/arkui-ts/ts-basic-components-marquee.md b/en/application-dev/reference/arkui-ts/ts-basic-components-marquee.md new file mode 100644 index 0000000000000000000000000000000000000000..5348e4f44d4442d67cc63f1e0491aaa3a0d9976f --- /dev/null +++ b/en/application-dev/reference/arkui-ts/ts-basic-components-marquee.md @@ -0,0 +1,172 @@ +# Marquee + +>![](../../public_sys-resources/icon-note.gif) **NOTE:** +>This component is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version. + +The **** component displays single-line scrolling text. + +## Required Permissions + +None + +## Child Components + +None + +## APIs + +Marquee\(value: \{ start: boolean, step?: number, loop?: number, fromStart?: boolean, src: string \}\) + +- Parameters + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

    Name

    +

    Type

    +

    Mandatory

    +

    Default Value

    +

    Description

    +

    start

    +

    boolean

    +

    Yes

    +

    -

    +

    Whether to set the marquee scroll.

    +

    step

    +

    number

    +

    No

    +

    6

    +

    Scroll step of the marquee text.

    +

    loop

    +

    number

    +

    No

    +

    -1

    +

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

    +

    fromStart

    +

    boolean

    +

    No

    +

    true

    +

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

    +

    src

    +

    string

    +

    Yes

    +

    -

    +

    Text to be scrolled.

    +
    + + +## Events + + + + + + + + + + + + + + + + +

    Name

    +

    Description

    +

    onStart(callback: () => void)

    +

    Invoked when scrolling starts.

    +

    onBounce(callback: () => void)

    +

    Invoked when scrolling reaches the end.

    +

    onFinish(callback: () => void)

    +

    Invoked when scrolling is complete.

    +
    + +## Example + +``` +@Entry +@Component +struct MarqueeExample { + @State start: boolean = false + @State fromStart: boolean = true + @State step: number = 50 + @State loop: number = 3 + @State src: string = "Running Marquee starts rolling" + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Marquee({ + start: this.start, + step: this.step, + loop: this.loop, + fromStart: this.fromStart, + src: this.src + }) + .fontColor(Color.White) + .fontSize(50) + .allowScale(false) + .fontWeight(FontWeight.Bold) + .backgroundColor(Color.Black) + .margin({bottom:40}) + .onStart(() => { + console.log('Marquee animation complete onStart') + }) + .onBounce(() => { + console.log('Marquee animation complete onBounce') + }) + .onFinish(() => { + console.log('Marquee animation complete onFinish') + }) + Button('start') + .onClick(() => { + this.start = true + }) + .width(200) + .height(60) + .margin({bottom:20}) + } + .width('100%') + .height('100%') + } +} +``` + +![](figures/gif-1.gif) + diff --git a/en/application-dev/reference/arkui-ts/ts-basic-components-progress.md b/en/application-dev/reference/arkui-ts/ts-basic-components-progress.md index cab522e012d711153b18d481360f0f17e23d76ba..8652d7554cb1d95285770d158fff4df3aa4b8b0b 100644 --- a/en/application-dev/reference/arkui-ts/ts-basic-components-progress.md +++ b/en/application-dev/reference/arkui-ts/ts-basic-components-progress.md @@ -1,35 +1,13 @@ -# Progress +# Progress + +>![](../../public_sys-resources/icon-note.gif) **NOTE:** +>This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. The **** component is used to provide a progress bar that displays the progress of content loading or an operation. -## Applicable Devices +## Required Permissions - - - - - - - - - - - - - - - -

    Phone

    -

    Tablet

    -

    Head Unit

    -

    Smart TV

    -

    Wearable

    -

    Yes

    -

    Yes

    -

    Yes

    -

    No

    -

    No

    -
    +None ## Child Components @@ -39,7 +17,7 @@ None Progress\(value: \{value: number, total?: number, style?: ProgressStyle\}\) -Creates a progress bar with a clear progress. +Creates a progress bar with a specified progress value. - Parameters @@ -163,5 +141,5 @@ struct ProgressExample { } ``` -![](figures/progress-60.png) +![](figures/progress.png) diff --git a/en/application-dev/reference/arkui-ts/ts-basic-components-qrcode.md b/en/application-dev/reference/arkui-ts/ts-basic-components-qrcode.md index 1cb8387b82656b626a8f4838fc4f2f8b275ca3d2..05e0575e6178ffe6028062fe936635c48ec99605 100644 --- a/en/application-dev/reference/arkui-ts/ts-basic-components-qrcode.md +++ b/en/application-dev/reference/arkui-ts/ts-basic-components-qrcode.md @@ -1,8 +1,11 @@ -# QRCode +# QRCode + +>![](../../public_sys-resources/icon-note.gif) **NOTE:** +>This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. The **** component is used to display QR code information. -## Permissions Required +## Required Permissions None @@ -12,7 +15,7 @@ None ## APIs -QRCode\(value: \{value: string\}\) +QRCode\(value: string\) - Parameters diff --git a/en/application-dev/reference/arkui-ts/ts-basic-components-rating.md b/en/application-dev/reference/arkui-ts/ts-basic-components-rating.md index 03de583d763c8fb1f2f1098da12fee31ebf792db..240dd361951228d2c0202167e6eb3f93218494fc 100644 --- a/en/application-dev/reference/arkui-ts/ts-basic-components-rating.md +++ b/en/application-dev/reference/arkui-ts/ts-basic-components-rating.md @@ -1,7 +1,14 @@ -# Rating +# Rating + +>![](../../public_sys-resources/icon-note.gif) **NOTE:** +>This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. The **** component provides a rating bar. +## Required Permissions + +None + ## Child Components None diff --git a/en/application-dev/reference/arkui-ts/ts-basic-components-slider.md b/en/application-dev/reference/arkui-ts/ts-basic-components-slider.md index 066ff6017ef7a45291da0c9d3289562290483282..009ab92e5a7e8646b6d7ba79b0ce0d34755ac809 100644 --- a/en/application-dev/reference/arkui-ts/ts-basic-components-slider.md +++ b/en/application-dev/reference/arkui-ts/ts-basic-components-slider.md @@ -1,14 +1,21 @@ -# Slider +# Slider + +>![](../../public_sys-resources/icon-note.gif) **NOTE:** +>This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. The **** component is used to quickly adjust settings, such as the volume and brightness. +## Required Permissions + +None + ## Child Components None ## APIs -Slider\(value:\{value?: number, min?: number, max?: number, step?: number, style?: SliderStyle\}\) +Slider\(value:\{value?: number, min?: number, max?: number, step?: number, style?: SliderStyle, direction?: Axis\}\) - Parameters @@ -75,11 +82,22 @@ Slider\(value:\{value?: number, min?: number, max?: number, step?: number, style

    No

    Outset

    +

    SliderStyle.OutSet

    Style of the slider.

    direction8+

    +

    Axis

    +

    No

    +

    Axis.Horizontal

    +

    Whether the slider moves horizontally or vertically.

    +
    @@ -108,6 +126,8 @@ Slider\(value:\{value?: number, min?: number, max?: number, step?: number, style ## Attributes +Touch target configuration is not supported. + @@ -224,6 +244,8 @@ Among all the universal events, only **OnAppear** and **OnDisAppear** are su struct SliderExample { @State outSetValue: number = 40 @State inSetValue: number = 40 + @State outVerticalSetValue: number = 40 + @State inVerticalSetValue: number = 40 build() { Column({ space: 5 }) { @@ -271,10 +293,57 @@ struct SliderExample { Text(this.inSetValue.toFixed(0)).fontSize(16) } .width('80%') + + Row() { + Column() { + Text('slider out direction set').fontSize(9).fontColor(0xCCCCCC).width('50%') + Slider({ + value: this.outVerticalSetValue, + min: 0, + max: 100, + step: 1, + style: SliderStyle.OutSet, + direction: Axis.Vertical + }) + .blockColor(Color.Blue) + .trackColor(Color.Gray) + .selectedColor(Color.Blue) + .showSteps(true) + .showTips(true) + .onChange((value: number, mode: SliderChangeMode) => { + this.outVerticalSetValue = value + console.info('value:' + value + 'mode:' + mode.toString()) + }) + Text(this.outVerticalSetValue.toFixed(0)).fontSize(16) + }.width('50%').height(300) + + Column() { + Text('slider in direction set').fontSize(9).fontColor(0xCCCCCC).width('50%') + Slider({ + value: this.inVerticalSetValue, + min: 0, + max: 100, + step: 1, + style: SliderStyle.InSet, + direction: Axis.Vertical + }) + .blockColor(0xCCCCCC) + .trackColor(Color.Black) + .selectedColor(0xCCCCCC) + .showSteps(false) + .showTips(false) + .onChange((value: number, mode: SliderChangeMode) => { + this.inVerticalSetValue = value + console.info('value:' + value + 'mode:' + mode.toString()) + }) + Text(this.inVerticalSetValue.toFixed(0)).fontSize(16) + }.width('50%').height(300) + } + }.width('100%').margin({ top: 5 }) } } ``` -![](figures/sider.gif) +![](figures/slider.gif) diff --git a/en/application-dev/reference/arkui-ts/ts-basic-components-span.md b/en/application-dev/reference/arkui-ts/ts-basic-components-span.md index 1fee8b43430d37c6553f9a31f8ca0367b3a4576b..5ff2deb2320b6195d66fb3ff38516ff3b59abc3a 100644 --- a/en/application-dev/reference/arkui-ts/ts-basic-components-span.md +++ b/en/application-dev/reference/arkui-ts/ts-basic-components-span.md @@ -1,4 +1,7 @@ -# Span +# Span + +>![](../../public_sys-resources/icon-note.gif) **NOTE:** +>This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. The component is used to display a paragraph of textual information. It can be used only as a child component in the **** component. @@ -46,7 +49,7 @@ Span\(content: string\) ## Attributes -The universal attribute methods support only the common text style. +In addition to the text style attributes, the attributes below are supported.

    Name

    - - @@ -83,6 +90,30 @@ LongPressGesture\(options?: \{ fingers?: number, repeat?: boolean, duration?: nu

    Name

    @@ -89,6 +92,9 @@ The universal attribute methods support only the common text style. Among all the universal events, only the click event is supported. +>![](../../public_sys-resources/icon-note.gif) **NOTE:** +>As the **** component does not have size information, the **target** attribute of the **ClickEvent** object returned by the click event is invalid. + ## Example ``` 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 ce38696b7d0fe7506c483362384624e27d2f81df..6973ed419c06f81dc200b425fa815ae79ec41e22 100644 --- a/en/application-dev/reference/arkui-ts/ts-basic-components-text.md +++ b/en/application-dev/reference/arkui-ts/ts-basic-components-text.md @@ -1,4 +1,7 @@ -# Text +# Text + +>![](../../public_sys-resources/icon-note.gif) **NOTE:** +>This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. The **** component is used to display a paragraph of textual information. diff --git a/en/application-dev/reference/arkui-ts/ts-basic-components-textarea.md b/en/application-dev/reference/arkui-ts/ts-basic-components-textarea.md new file mode 100644 index 0000000000000000000000000000000000000000..8ea07e9d812d3895368a806b700121997598e308 --- /dev/null +++ b/en/application-dev/reference/arkui-ts/ts-basic-components-textarea.md @@ -0,0 +1,186 @@ +# TextArea + +>![](../../public_sys-resources/icon-note.gif) **NOTE:** +>This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. + +Provides the multi-line text input component. + +## Required Permissions + +None + +## Child Component + +N/A + +## APIs + +TextArea\(value?: \{ placeholder?: string \}\) + +- Parameters + + + + + + + + + + + + + + + + +

    Name

    +

    Type

    +

    Mandatory

    +

    Default Value

    +

    Description

    +

    placeholder

    +

    string

    +

    No

    +

    -

    +

    Text displayed when there is no input.

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

    Name

    +

    Type

    +

    Default Value

    +

    Description

    +

    placeholderColor

    +

    Color

    +

    -

    +

    Placeholder text color.

    +

    placeholderFont

    +

    {

    +

    size?: number,

    +

    weight?:number | FontWeight,

    +

    family?: string,

    +

    style?: FontStyle

    +

    }

    +

    -

    +

    Placeholder text style.

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

    textAlign

    +

    TextAlign

    +

    TextAlign.Start

    +

    Sets the text horizontal alignment mode.

    +

    caretColor

    +

    Color

    +

    -

    +

    Sets the color of the cursor in the text box.

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

    Name

    +

    Description

    +

    Start

    +

    Aligns the header horizontally.

    +

    Center

    +

    Horizontal center alignment.

    +

    End

    +

    Align the tail horizontally.

    +
    + + +## Events + + + + + + + + + + +

    Name

    +

    Description

    +

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

    +

    When the input changes, the callback function is triggered.

    +
    + +## Example + +``` +@Entry +@Component +struct TextAreaExample { + @State text: string = '' + + build() { + Column() { + TextArea({ placeholder: 'input your word' }) + .placeholderColor("rgb(0,0,225)") + .placeholderFont({ size: 30, weight: 100, family: 'cursive', style: FontStyle.Italic }) + .textAlign(TextAlign.Center) + .caretColor(Color.Blue) + .height(50) + .fontSize(30) + .fontWeight(FontWeight.Bold) + .fontFamily("sans-serif") + .fontStyle(FontStyle.Normal) + .fontColor(Color.Red) + .onChange((value: string) => { + this.text = value + }) + Text(this.text).width('90%') + } + } +} +``` + +![](figures/textarea1.gif) + diff --git a/en/application-dev/reference/arkui-ts/ts-basic-components-textinput.md b/en/application-dev/reference/arkui-ts/ts-basic-components-textinput.md new file mode 100644 index 0000000000000000000000000000000000000000..c2073e5be95e0abef7bccb498ab11d0d4a014702 --- /dev/null +++ b/en/application-dev/reference/arkui-ts/ts-basic-components-textinput.md @@ -0,0 +1,268 @@ +# TextInput + +>![](../../public_sys-resources/icon-note.gif) **NOTE:** +>This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. + +The **** component provides single-line text input. + +## Required Permissions + +None + +## Child Components + +None + +## APIs + +TextInput\(value?: \{ placeholder?: string \}\) + +- Parameters + + + + + + + + + + + + + + + + +

    Name

    +

    Type

    +

    Mandatory

    +

    Default Value

    +

    Description

    +

    placeholder

    +

    string

    +

    No

    +

    -

    +

    Text displayed when there is no input.

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

    Name

    +

    Type

    +

    Default Value

    +

    Description

    +

    type

    +

    InputType

    +

    InputType.Normal

    +

    Input box type.

    +

    placeholderColor

    +

    Color

    +

    -

    +

    Placeholder color.

    +

    placeholderFont

    +

    {

    +

    size?: Length,

    +

    weight?: number | FontWeight,

    +

    family?: string,

    +

    style?: FontStyle

    +

    }

    +

    -

    +

    Placeholder text style.

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

    enterKeyType

    +

    EnterKeyType

    +

    EnterKeyType.Done

    +

    How the Enter key is labeled.

    +

    caretColor

    +

    Color

    +

    -

    +

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

    +

    maxLength

    +

    number

    +

    -

    +

    Maximum number of characters in the text input.

    +
    + +- EnterKeyType enums + + + + + + + + + + + + + + + + + + + + + + +

    Name

    +

    Description

    +

    Go

    +

    The Enter key is labeled "Go."

    +

    Search

    +

    The Enter key is labeled "Search."

    +

    Send

    +

    The Enter key is labeled "Send."

    +

    Next

    +

    The Enter key is labeled "Next."

    +

    Done

    +

    The Enter key is labeled "Done."

    +
    + + +- InputType enums + + + + + + + + + + + + + + + + + + + +

    Name

    +

    Description

    +

    Normal

    +

    Normal input mode.

    +

    Password

    +

    Password input mode.

    +

    Email

    +

    Email address input mode.

    +

    Number

    +

    Digit input mode.

    +
    + + +## Events + + + + + + + + + + + + + + + + +

    Name

    +

    Description

    +

    onChange(value: string) => void

    +

    Triggered when the input changes.

    +

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

    +

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

    +

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

    +

    Triggered when the input status changes.

    +
    + +## Example + +``` +@Entry +@Component +struct TextInputTest { + @State text: string = '' + @State text1: string = '' + @State text2: string = '' + build() { + Column() { + TextInput({ placeholder: 'input your word' }) + .type(InputType.Normal) + .placeholderColor(Color.Blue) + .placeholderFont({ size: 40, weight: FontWeight.Normal, family: "sans-serif", style: FontStyle.Normal }) + .enterKeyType(EnterKeyType.Next) + .caretColor(Color.Green) + .height(60) + .fontSize(30) + .fontWeight(FontWeight.Bold) + .fontFamily("cursive") + .fontStyle(FontStyle.Italic) + .fontColor(Color.Red) + .maxLength(20) + .onChange((value: string) => { + this.text = value + }) + .onSubmit((enterKey) => { + this.text1 = 'onSubmit' + }) + .onEditChanged((isEditing) => { + this.text2 = 'onEditChanged' + }) + Text(this.text) + Text(this.text1) + Text(this.text2) + } + } +} +``` + +![](figures/textinput1.gif) + diff --git a/en/application-dev/reference/arkui-ts/ts-basic-components-toggle.md b/en/application-dev/reference/arkui-ts/ts-basic-components-toggle.md new file mode 100644 index 0000000000000000000000000000000000000000..2d4f723cbbf7002e12748e661c13ad3f15345026 --- /dev/null +++ b/en/application-dev/reference/arkui-ts/ts-basic-components-toggle.md @@ -0,0 +1,208 @@ +# Toggle + +>![](../../public_sys-resources/icon-note.gif) **NOTE:** +>This component is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version. + +## Required Permissions + +None + +## Child Components + +None + +## APIs + +Toggle\(options: \{ type: ToggleType, isOn?: boolean \}\) + +- Parameters + + + + + + + + + + + + + + + + + + + + + + +

    Name

    +

    Type

    +

    Mandatory

    +

    Default Value

    +

    Description

    +

    type

    +

    ToggleType

    +

    Yes

    +

    -

    +

    Type of the toggle.

    +

    isOn

    +

    boolean

    +

    No

    +

    false

    +

    Initial state of the toggle.

    +
    NOTE:

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

    +
    +
    + + +- ToggleType enums + + + + + + + + + + + + + + + + +

    Name

    +

    Description

    +

    Checkbox

    +

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

    +

    Button

    +

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

    +

    Switch

    +

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

    +
    + + +## Attributes + + + + + + + + + + + + + + + + + + + +

    Name

    +

    Type

    +

    Default Value

    +

    Description

    +

    selectedColor

    +

    Color

    +

    -

    +

    Background color of the toggle when it is enabled.

    +

    switchPointColor

    +

    Color

    +

    -

    +

    Color of the circular slider of the Switch type.

    +
    NOTE:

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

    +
    +
    + +## Events + + + + + + + + + + +

    Name

    +

    Description

    +

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

    +

    Triggered when the switch status changes.

    +
    + +## Example + +``` +@Entry +@Component +struct ToggleExample { + build() { + Column({ space: 10 }) { + Text('type: Switch').fontSize(12).fontColor(0xcccccc).width('90%') + Flex({ justifyContent: FlexAlign.SpaceEvenly, alignItems: ItemAlign.Center }) { + Toggle({ type: ToggleType.Switch, isOn: false }) + .selectedColor(0xed6f21) + .switchPointColor(0xe5ffffff) + .onChange((isOn: boolean) => { + console.info('Component status:' + isOn) + }) + + Toggle({ type: ToggleType.Switch, isOn: true }) + .selectedColor(0x39a2db) + .switchPointColor(0xe5ffffff) + .onChange((isOn: boolean) => { + console.info('Component status:' + isOn) + }) + } + + Text('type: Checkbox').fontSize(12).fontColor(0xcccccc).width('90%') + Flex({ justifyContent: FlexAlign.SpaceEvenly, alignItems: ItemAlign.Center }) { + Toggle({ type: ToggleType.Checkbox, isOn: false }) + .size({ width: 28, height: 28 }) + .selectedColor(0xed6f21) + .onChange((isOn: boolean) => { + console.info('Component status:' + isOn) + }) + + Toggle({ type: ToggleType.Checkbox, isOn: true }) + .size({ width: 28, height: 28 }) + .selectedColor(0x39a2db) + .onChange((isOn: boolean) => { + console.info('Component status:' + isOn) + }) + } + + Text('type: Button').fontSize(12).fontColor(0xcccccc).width('90%') + Flex({ justifyContent: FlexAlign.SpaceEvenly, alignItems: ItemAlign.Center }) { + Toggle({ type: ToggleType.Button, isOn: false }) { + Text('status button').padding({ left: 12, right: 12 }) + } + .selectedColor(0xed6f21) + .onChange((isOn: boolean) => { + console.info('Component status:' + isOn) + }) + + Toggle({ type: ToggleType.Button, isOn: true }) { + Text('status button').padding({ left: 12, right: 12 }) + } + .selectedColor(0x39a2db) + .onChange((isOn: boolean) => { + console.info('Component status:' + isOn) + }) + } + }.width('100%').padding(24) + } +} +``` + +![](figures/toggle.gif) + diff --git a/en/application-dev/reference/arkui-ts/ts-basic-components.md b/en/application-dev/reference/arkui-ts/ts-basic-components.md index 28159001506940dde6005334c6d1d25fb8a11db8..4d256bb16eafa12eaac506f2f931431abc08a772 100644 --- a/en/application-dev/reference/arkui-ts/ts-basic-components.md +++ b/en/application-dev/reference/arkui-ts/ts-basic-components.md @@ -1,4 +1,4 @@ -# Basic Components +# Basic Components - **[Blank](ts-basic-components-blank.md)** @@ -8,10 +8,14 @@ - **[Divider](ts-basic-components-divider.md)** +- **[Gauge](ts-basic-components-gauge.md)** + - **[Image](ts-basic-components-image.md)** - **[ImageAnimator](ts-basic-components-imageanimator.md)** +- **[Marquee](ts-basic-components-marquee.md)** + - **[Progress](ts-basic-components-progress.md)** - **[QRCode](ts-basic-components-qrcode.md)** @@ -24,4 +28,10 @@ - **[Text](ts-basic-components-text.md)** +- **[TextArea](ts-basic-components-textarea.md)** + +- **[TextInput](ts-basic-components-textinput.md)** + +- **[Toggle](ts-basic-components-toggle.md)** + diff --git a/en/application-dev/reference/arkui-ts/ts-basic-gestures-longpressgesture.md b/en/application-dev/reference/arkui-ts/ts-basic-gestures-longpressgesture.md index c3c581ff6554f850dacc2e8bfd946e2d0936ba95..ffef167c0a41c16297c6de534e027ff2418031c2 100644 --- a/en/application-dev/reference/arkui-ts/ts-basic-gestures-longpressgesture.md +++ b/en/application-dev/reference/arkui-ts/ts-basic-gestures-longpressgesture.md @@ -1,4 +1,11 @@ -# LongPressGesture +# LongPressGesture + +>![](../../public_sys-resources/icon-note.gif) **NOTE:** +>This gesture is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. + +## Required Permissions + +None ## APIs @@ -65,12 +72,12 @@ LongPressGesture\(options?: \{ fingers?: number, repeat?: boolean, duration?: nu

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

    +

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

    Callback invoked when a long press gesture is recognized.

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

    +

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

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

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

    Name

    +

    Type

    +

    Description

    +

    repeat

    +

    boolean

    +

    Whether the event is repeated.

    +
    + + ## Example ``` @@ -99,7 +130,7 @@ struct LongPressGestureExample { .gesture( LongPressGesture({ repeat: true }) // Repeatedly triggered when the long press gesture exists. - .onAction((event: GestureEvent) => { + .onAction((event: LongPressGestureEvent) => { if (event.repeat) { this.count++ } }) // Triggered when the long press gesture ends. diff --git a/en/application-dev/reference/arkui-ts/ts-basic-gestures-pangesture.md b/en/application-dev/reference/arkui-ts/ts-basic-gestures-pangesture.md index abfff531623914a9f908a58325ef9eb97bf00e4a..176c52260ab026e9a4d3e41eb7eb2355220170ea 100644 --- a/en/application-dev/reference/arkui-ts/ts-basic-gestures-pangesture.md +++ b/en/application-dev/reference/arkui-ts/ts-basic-gestures-pangesture.md @@ -1,4 +1,11 @@ -# PanGesture +# PanGesture + +>![](../../public_sys-resources/icon-note.gif) **NOTE:** +>This gesture is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. + +## Required Permissions + +None ## APIs @@ -156,22 +163,22 @@ PanGestureOption\(options?: \{ fingers?: number, direction?: PanDirection, dista

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

    +

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

    Callback for the pan gestures reorganization event.

    +

    Callback for the pan gestures recognition event.

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

    +

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

    Callback for the pan gesture movement event.

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

    +

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

    Callback for fingers pick-up.

    onActionCancel(event: () => void)

    +

    onActionCancel(callback: () => void)

    Callback for the touch cancellation event.

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

    Name

    +

    Type

    +

    Description

    +

    offsetX

    +

    number

    +

    Offset of the gesture event, in vp.

    +

    offsetY

    +

    number

    +

    Offset of the gesture event, in vp.

    +
    + + ## Example ``` @@ -196,10 +234,10 @@ struct PanGestureExample { .translate({ x: this.offsetX, y: this.offsetY, z: 5 }) .gesture( PanGesture({}) - .onActionStart((event: GestureEvent) => { + .onActionStart((event: PanGestureEvent) => { console.info('Pan start') }) - .onActionUpdate((event: GestureEvent) => { + .onActionUpdate((event: PanGestureEvent) => { this.offsetX = event.offsetX this.offsetY = event.offsetY }) diff --git a/en/application-dev/reference/arkui-ts/ts-basic-gestures-pinchgesture.md b/en/application-dev/reference/arkui-ts/ts-basic-gestures-pinchgesture.md index 068a834cb4b67c84bc35919d0c1c8bc522962991..0906de7217ea2259a8aad053fcc0f38ddd4e68f6 100644 --- a/en/application-dev/reference/arkui-ts/ts-basic-gestures-pinchgesture.md +++ b/en/application-dev/reference/arkui-ts/ts-basic-gestures-pinchgesture.md @@ -1,4 +1,11 @@ -# PinchGesture +# PinchGesture + +>![](../../public_sys-resources/icon-note.gif) **NOTE:** +>This gesture is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. + +## Required Permissions + +None ## APIs @@ -54,17 +61,17 @@ PinchGesture\(options?: \{ fingers?: number, distance?: number \}\)

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

    +

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

    Callback invoked when a pinch gesture is recognized.

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

    +

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

    Callback invoked during the movement of a pinch gesture.

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

    +

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

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

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

    Name

    +

    Type

    +

    Description

    +

    scale

    +

    number

    +

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

    +

    pinchCenterX

    +

    number

    +

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

    +

    pinchCenterY

    +

    number

    +

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

    +
    + + ## Example ``` @@ -93,10 +138,10 @@ struct PinchGestureExample { .scale({ x: this.scale, y: this.scale, z: this.scale }) .gesture( PinchGesture() - .onActionStart((event: GestureEvent) => { + .onActionStart((event: PinchGestureEvent) => { console.info('Pinch start') }) - .onActionUpdate((event: GestureEvent) => { + .onActionUpdate((event: PinchGestureEvent) => { this.scale = event.scale }) .onActionEnd(() => { diff --git a/en/application-dev/reference/arkui-ts/ts-basic-gestures-rotationgesture.md b/en/application-dev/reference/arkui-ts/ts-basic-gestures-rotationgesture.md index 2e07281bbe86874f3a46b17b1a7ff53ac8791026..a5b02f328549297bea12cb3f00c82afd3c77abfc 100644 --- a/en/application-dev/reference/arkui-ts/ts-basic-gestures-rotationgesture.md +++ b/en/application-dev/reference/arkui-ts/ts-basic-gestures-rotationgesture.md @@ -1,4 +1,11 @@ -# RotationGesture +# RotationGesture + +>![](../../public_sys-resources/icon-note.gif) **NOTE:** +>This gesture is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. + +## Required Permissions + +None ## APIs @@ -54,17 +61,17 @@ RotationGesture\(options?: \{ fingers?: number, angle?: number \}\) -

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

    +

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

    Callback invoked when a rotation gesture is recognized.

    -

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

    +

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

    Callback invoked during the movement of the rotation gesture.

    -

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

    +

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

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

    @@ -77,6 +84,44 @@ RotationGesture\(options?: \{ fingers?: number, angle?: number \}\) +- RotationGestureEvent attributes8+ + + Inherited from [GestureEvent](ts-gesture-settings.md#table290mcpsimp). + + + + + + + + + + + + + + + + + + + + +

    Name

    +

    Type

    +

    Description

    +

    angle

    +

    number

    +

    Rotation angle.

    +

    pinchCenterX

    +

    number

    +

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

    +

    pinchCenterY

    +

    number

    +

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

    +
    + + ## Example ``` @@ -93,10 +138,10 @@ struct RotationGestureExample { .margin(80).rotate({ x:1, y:2, z:3, angle: this.angle }) .gesture( RotationGesture() - .onActionStart((event: GestureEvent) => { + .onActionStart((event: RotationGestureEvent) => { console.log('Rotation start') }) - .onActionUpdate((event: GestureEvent) => { + .onActionUpdate((event: RotationGestureEvent) => { this.angle = event.angle }) .onActionEnd(() => { diff --git a/en/application-dev/reference/arkui-ts/ts-basic-gestures-swipegesture.md b/en/application-dev/reference/arkui-ts/ts-basic-gestures-swipegesture.md new file mode 100644 index 0000000000000000000000000000000000000000..77bb943dc66d8e4a410a25196678f4d914e1ef79 --- /dev/null +++ b/en/application-dev/reference/arkui-ts/ts-basic-gestures-swipegesture.md @@ -0,0 +1,171 @@ +# SwipeGesture + +>![](../../public_sys-resources/icon-note.gif) **NOTE:** +>This attribute is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version. + +## Required Permissions + +None + +## APIs + +SwipeGesture\(value?: \{ fingers?: number; direction?: SwipeDirection; speed?: number \}\) + +- Parameters + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

    Name

    +

    Type

    +

    Mandatory

    +

    Default Value

    +

    Description

    +

    fingers

    +

    number

    +

    No

    +

    1

    +

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

    +

    direction

    +

    SwipeDirection

    +

    No

    +

    SwipeDirection.All

    +

    Swipe direction

    +

    speed

    +

    number

    +

    No

    +

    100

    +

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

    +
    + +- SwipeDirection enums + + + + + + + + + + + + + + + + +

    Name

    +

    Description

    +

    All

    +

    All directions.

    +

    Horizontal

    +

    Horizontal direction.

    +

    Vertical

    +

    Vertical direction.

    +
    + + +## Events + + + + + + + + + + +

    Name

    +

    Description

    +

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

    +

    Callback for the swipe gesture recognition event.

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

    Name

    +

    Type

    +

    Description

    +

    angle

    +

    number

    +

    Angle of the swipe gesture.

    +

    speed

    +

    number

    +

    Speed of the swipe gesture.

    +
    + + +## Example + +``` +@Entry +@Component +struct SwipeGestureExample { + @State rotateAngle : number = 0 + @State speed : number = 1 + + build() { + Column() { + Text("SwipGesture speed : " + this.speed) + Text("SwipGesture angle : " + this.rotateAngle) + } + .position({x: 80, y: 200}) + .border({width:2}) + .width(260).height(260) + .rotate({x: 0, y: 0, z: 1, angle: this.rotateAngle}) + .gesture( + SwipeGesture({fingers: 1, direction:SwipeDirection.Vertical}) + .onAction((event: SwipeGestureEvent) => { + this.speed = event.speed + this.rotateAngle = event.angle + }) + ) + } +} +``` + +![](figures/gif-0.gif) + diff --git a/en/application-dev/reference/arkui-ts/ts-basic-gestures-tapgesture.md b/en/application-dev/reference/arkui-ts/ts-basic-gestures-tapgesture.md index 5b50c3de08dc223ea5a2eea2868bbf988505f66c..79dc179371733d521140bff5f07045ea09372e82 100644 --- a/en/application-dev/reference/arkui-ts/ts-basic-gestures-tapgesture.md +++ b/en/application-dev/reference/arkui-ts/ts-basic-gestures-tapgesture.md @@ -1,4 +1,11 @@ -# TapGesture +# TapGesture + +>![](../../public_sys-resources/icon-note.gif) **NOTE:** +>This gesture is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. + +## Required Permissions + +None ## APIs @@ -59,7 +66,7 @@ TapGesture\(options?: \{ count?: number, fingers?: number \}\) -

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

    +

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

    Callback invoked when a tap gesture is recognized.

    @@ -67,6 +74,11 @@ TapGesture\(options?: \{ count?: number, fingers?: number \}\) +- TapGestureEvent attributes8+ + + Inherited from [GestureEvent](ts-gesture-settings.md#table290mcpsimp). + + ## Example ``` diff --git a/en/application-dev/reference/arkui-ts/ts-basic-gestures.md b/en/application-dev/reference/arkui-ts/ts-basic-gestures.md index 560cd68fb12b8859f1f0d52a4b451b02a2e18b6f..1dca7a6b84f0ef88837ed77e3530986a78a8f139 100644 --- a/en/application-dev/reference/arkui-ts/ts-basic-gestures.md +++ b/en/application-dev/reference/arkui-ts/ts-basic-gestures.md @@ -1,4 +1,4 @@ -# Basic Gestures +# Basic Gestures - **[TapGesture](ts-basic-gestures-tapgesture.md)** @@ -10,4 +10,6 @@ - **[RotationGesture](ts-basic-gestures-rotationgesture.md)** +- **[SwipeGesture](ts-basic-gestures-swipegesture.md)** + diff --git a/en/application-dev/reference/arkui-ts/ts-canvasrenderingcontext2d.md b/en/application-dev/reference/arkui-ts/ts-canvasrenderingcontext2d.md new file mode 100644 index 0000000000000000000000000000000000000000..866df9034fa4f33cfe29801f5a1b691e38413029 --- /dev/null +++ b/en/application-dev/reference/arkui-ts/ts-canvasrenderingcontext2d.md @@ -0,0 +1,3817 @@ +# CanvasRenderingContext2D + +>![](../../public_sys-resources/icon-note.gif) **NOTE:** +>This component is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version. + +Use **RenderingContext** to draw rectangles, text, images, and other objects on a canvas. + +## APIs + +CanvasRenderingContext2D\(setting: RenderingContextSetting\) + +- Parameters + + + + + + + + + + + + + + + + +

    Name

    +

    Type

    +

    Mandatory

    +

    Default Value

    +

    Description

    +

    setting

    +

    RenderingContextSettings

    +

    Yes

    +

    -

    +

    See RenderingContextSettings.

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

    Name

    +

    Type

    +

    Mandatory

    +

    Default Value

    +

    Description

    +

    antialias

    +

    bool

    +

    No

    +

    false

    +

    Whether antialiasing is enabled.

    +

    alpha

    +

    bool

    +

    No

    +

    false

    +

    Whether the canvas contains an alpha channel.

    +
    + + +## Attributes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

    Name

    +

    Type

    +

    Default Value

    +

    Description

    +

    fillStyle

    +

    <color> | CanvasGradient | CanvasPattern

    +

    -

    +

    Style to fill an area.

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

    lineWidth

    +

    number

    +

    -

    +

    Line width.

    +

    strokeStyle

    +

    <color> | CanvasGradient | CanvasPattern

    +

    -

    +

    Stroke style.

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

    lineCap

    +

    string

    +

    'butt'

    +

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

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

    lineJoin

    +

    string

    +

    'miter'

    +

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

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

    miterLimit

    +

    number

    +

    10

    +

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

    +

    font

    +

    string

    +

    'normal normal 14px sans-serif'

    +

    Font style.

    +

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

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

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

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

    textAlign

    +

    string

    +

    'left'

    +

    Text alignment mode. Available values are as follows:

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

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

    +
    +

    textBaseline

    +

    string

    +

    'alphabetic'

    +

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

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

    globalAlpha

    +

    number

    +

    -

    +

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

    +

    lineDashOffset

    +

    number

    +

    0.0

    +

    Offset of the dashed line. The precision is float.

    +

    globalCompositeOperation

    +

    string

    +

    'source-over'

    +

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

    +

    shadowBlur

    +

    number

    +

    0.0

    +

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

    +

    shadowColor

    +

    <color>

    +

    -

    +

    Shadow color.

    +

    shadowOffsetX

    +

    number

    +

    -

    +

    X-axis shadow offset relative to the original object.

    +

    shadowOffsetY

    +

    number

    +

    -

    +

    Y-axis shadow offset relative to the original object.

    +

    imageSmoothingEnabled

    +

    boolean

    +

    true

    +

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

    +

    imageSmoothingQuality

    +

    string

    +

    'low'

    +

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

    +
    + +>![](../../public_sys-resources/icon-note.gif) **NOTE:** +>The value of the **** type can be in 'rgb\(255, 255, 255\)', 'rgba\(255, 255, 255, 1.0\)', or '\#FFFFFF' format. + +### fillStyle + +``` +@Entry +@Component +struct FillStyleExample { + private settings: RenderingContextSettings = new RenderingContextSettings(true,true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.context.fillStyle = '#0000ff' + this.context.fillRect(20, 160, 150, 100) + }) + } + .width('100%') + .height('100%') + } +} +``` + +![](figures/en-us_image_0000001193322850.png) + +### lineWidth + +``` +@Entry +@Component +struct LineWidthExample { + private settings: RenderingContextSettings = new RenderingContextSettings(true,true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.context.lineWidth = 5 + this.context.strokeRect(25, 25, 85, 105) + }) + } + .width('100%') + .height('100%') + } +} +``` + +![](figures/en-us_image_0000001238402745.png) + +### strokeStyle + +``` +@Entry +@Component +struct StrokeStyleExample { + private settings: RenderingContextSettings = new RenderingContextSettings(true,true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.context.lineWidth = 10 + this.context.strokeStyle = '#0000ff' + this.context.strokeRect(25, 25, 155, 105) + }) + } + .width('100%') + .height('100%') + } +} +``` + +![](figures/en-us_image_0000001238282783.png) + +### lineCap + +``` +@Entry +@Component +struct LineCapExample { + private settings: RenderingContextSettings = new RenderingContextSettings(true,true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.context.lineWidth = 8 + this.context.beginPath() + this.context.lineCap = 'round' + this.context.moveTo(30, 50) + this.context.lineTo(220, 50) + this.context.stroke() + }) + } + .width('100%') + .height('100%') + } +} +``` + +![](figures/en-us_image_0000001193642802.png) + +### lineJoin + +``` +@Entry +@Component +struct LineJoinExample { + private settings: RenderingContextSettings = new RenderingContextSettings(true,true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.context.beginPath() + this.context.lineWidth = 8 + this.context.lineJoin = 'miter' + this.context.moveTo(30, 30) + this.context.lineTo(120, 60) + this.context.lineTo(30, 110) + this.context.stroke() + }) + } + .width('100%') + .height('100%') + } +} +``` + +![](figures/en-us_image_0000001193802788.png) + +### miterLimit + +``` +@Entry +@Component +struct MiterLimit { + private settings: RenderingContextSettings = new RenderingContextSettings(true,true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.context.lineWidth = 8 + this.context.lineJoin = 'miter' + this.context.miterLimit = 3 + this.context.moveTo(30, 30) + this.context.lineTo(60, 35) + this.context.lineTo(30, 37) + this.context.stroke() + }) + } + .width('100%') + .height('100%') + } +} +``` + +![](figures/en-us_image_0000001238522733.png) + +### font + +``` +@Entry +@Component +struct Font { + private settings: RenderingContextSettings = new RenderingContextSettings(true,true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.context.font = '30px sans-serif' + this.context.fillText("Hello World", 20, 60) + }) + } + .width('100%') + .height('100%') + } +} +``` + +![](figures/en-us_image_0000001193482814.png) + +### textAlign + +``` +@Entry +@Component +struct TextAlign { + private settings: RenderingContextSettings = new RenderingContextSettings(true,true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.context.strokeStyle = '#0000ff' + this.context.moveTo(140, 10) + this.context.lineTo(140, 160) + this.context.stroke() + + this.context.font = '18px sans-serif' + + this.context.textAlign = 'start' + this.context.fillText('textAlign=start', 140, 60) + this.context.textAlign = 'end' + this.context.fillText('textAlign=end', 140, 80) + this.context.textAlign = 'left' + this.context.fillText('textAlign=left', 140, 100) + this.context.textAlign = 'center' + this.context.fillText('textAlign=center',140, 120) + this.context.textAlign = 'right' + this.context.fillText('textAlign=right',140, 140) + }) + } + .width('100%') + .height('100%') + } +} +``` + +![](figures/en-us_image_0000001238602771.png) + +### textBaseline + +``` +@Entry +@Component +struct TextBaseline { + private settings: RenderingContextSettings = new RenderingContextSettings(true,true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.context.strokeStyle = '#0000ff' + this.context.moveTo(0, 120) + this.context.lineTo(400, 120) + this.context.stroke() + + this.context.font = '20px sans-serif' + + this.context.textBaseline = 'top' + this.context.fillText('Top', 10, 120) + this.context.textBaseline = 'bottom' + this.context.fillText('Bottom', 55, 120) + this.context.textBaseline = 'middle' + this.context.fillText('Middle', 125, 120) + this.context.textBaseline = 'alphabetic' + this.context.fillText('Alphabetic', 195, 120) + this.context.textBaseline = 'hanging' + this.context.fillText('Hanging', 295, 120) + }) + } + .width('100%') + .height('100%') + } +} +``` + +![](figures/en-us_image_0000001193322872.png) + +### globalAlpha + +``` +@Entry +@Component +struct GlobalAlpha { + private settings: RenderingContextSettings = new RenderingContextSettings(true,true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.context.fillStyle = 'rgb(255,0,0)' + this.context.fillRect(0, 0, 50, 50) + this.context.globalAlpha = 0.4 + this.context.fillStyle = 'rgb(0,0,255)' + this.context.fillRect(50, 50, 50, 50) + }) + } + .width('100%') + .height('100%') + } +} +``` + +![](figures/en-us_image_0000001238402777.png) + +### lineDashOffset + +``` +@Entry +@Component +struct LineDashOffset { + private settings: RenderingContextSettings = new RenderingContextSettings(true,true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.context.arc(100, 75, 50, 0, 6.28) + this.context.setLineDash([10,20]) + this.context.stroke(); + }) + } + .width('100%') + .height('100%') + } +} +``` + +![](figures/en-us_image_0000001238282827.png) + +### globalCompositeOperation + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

    Name

    +

    Description

    +

    source-over

    +

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

    +

    source-atop

    +

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

    +

    source-in

    +

    Displays the new drawing inside the existing drawing.

    +

    source-out

    +

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

    +

    destination-over

    +

    Displays the existing drawing above the new drawing.

    +

    destination-atop

    +

    Displays the existing drawing above the new drawing.

    +

    destination-in

    +

    Displays the existing drawing inside the new drawing.

    +

    destination-out

    +

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

    +

    lighter

    +

    Displays both the new drawing and the existing drawing.

    +

    copy

    +

    Displays the new drawing and neglects the existing drawing.

    +

    xor

    +

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

    +
    + +``` +@Entry +@Component +struct GlobalCompositeOperation { + private settings: RenderingContextSettings = new RenderingContextSettings(true,true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.context.fillStyle = 'rgb(255,0,0)' + this.context.fillRect(20, 20, 50, 50) + this.context.globalCompositeOperation = 'source-over' + this.context.fillStyle = 'rgb(0,0,255)' + this.context.fillRect(50, 50, 50, 50) + this.context.fillStyle = 'rgb(255,0,0)' + this.context.fillRect(120, 20, 50, 50) + this.context.globalCompositeOperation = 'destination-over' + this.context.fillStyle = 'rgb(0,0,255)' + this.context.fillRect(150, 50, 50, 50) + }) + } + .width('100%') + .height('100%') + } +} +``` + +![](figures/en-us_image_0000001193642848.png) + +### shadowBlur + +``` +@Entry +@Component +struct ShadowBlur { + private settings: RenderingContextSettings = new RenderingContextSettings(true,true); + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings); + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.context.shadowBlur = 30 + this.context.shadowColor = 'rgb(0,0,0)' + this.context.fillStyle = 'rgb(255,0,0)' + this.context.fillRect(20, 20, 100, 80) + }) + } + .width('100%') + .height('100%') + } +} +``` + +![](figures/en-us_image_0000001193802836.png) + +### shadowColor + +``` +@Entry +@Component +struct ShadowColor { + private settings: RenderingContextSettings = new RenderingContextSettings(true,true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.context.shadowBlur = 30 + this.context.shadowColor = 'rgb(0,0,255)' + this.context.fillStyle = 'rgb(255,0,0)' + this.context.fillRect(30, 30, 100, 100) + }) + } + .width('100%') + .height('100%') + } +} +``` + +![](figures/en-us_image_0000001238522783.png) + +### shadowOffsetX + +``` +@Entry +@Component +struct ShadowOffsetX { + private settings: RenderingContextSettings = new RenderingContextSettings(true,true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.context.shadowBlur = 10 + this.context.shadowOffsetX = 20 + this.context.shadowColor = 'rgb(0,0,0)' + this.context.fillStyle = 'rgb(255,0,0)' + this.context.fillRect(20, 20, 100, 80) + }) + } + .width('100%') + .height('100%') + } +} +``` + +![](figures/en-us_image_0000001193482866.png) + +### shadowOffsetY + +``` +@Entry +@Component +struct ShadowOffsetY { + private settings: RenderingContextSettings = new RenderingContextSettings(true,true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.context.shadowBlur = 10 + this.context.shadowOffsetY = 20 + this.context.shadowColor = 'rgb(0,0,0)' + this.context.fillStyle = 'rgb(255,0,0)' + this.context.fillRect(30, 30, 100, 100) + }) + } + .width('100%') + .height('100%') + } +} +``` + +![](figures/en-us_image_0000001238602821.png) + +### imageSmoothingEnabled + +``` +@Entry +@Component +struct ImageSmoothingEnabled { + private settings: RenderingContextSettings = new RenderingContextSettings(true,true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + private img:ImageBitmap = new ImageBitmap("common/images/icon.jpg") + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.context.imageSmoothingEnabled = false + this.context.drawImage( this.img,0,0,400,200) + }) + } + .width('100%') + .height('100%') + } +} +``` + +![](figures/en-us_image_0000001193322910.png) + +## Methods + +### fillRect + +fillRect\(x: number, y: number, w: number, h: number\): void + +Fills a rectangle on the canvas. + +- Parameters + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

    Name

    +

    Type

    +

    Mandatory

    +

    Default Value

    +

    Description

    +

    x

    +

    number

    +

    Yes

    +

    0

    +

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

    +

    y

    +

    number

    +

    Yes

    +

    0

    +

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

    +

    width

    +

    number

    +

    Yes

    +

    0

    +

    Width of the rectangle.

    +

    height

    +

    number

    +

    Yes

    +

    0

    +

    Height of the rectangle.

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

    Name

    +

    Type

    +

    Mandatory

    +

    Default Value

    +

    Description

    +

    x

    +

    number

    +

    Yes

    +

    0

    +

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

    +

    y

    +

    number

    +

    Yes

    +

    0

    +

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

    +

    width

    +

    number

    +

    Yes

    +

    0

    +

    Width of the rectangle.

    +

    height

    +

    number

    +

    Yes

    +

    0

    +

    Height of the rectangle.

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

    Name

    +

    Type

    +

    Mandatory

    +

    Default Value

    +

    Description

    +

    x

    +

    number

    +

    Yes

    +

    0

    +

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

    +

    y

    +

    number

    +

    Yes

    +

    0

    +

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

    +

    width

    +

    number

    +

    Yes

    +

    0

    +

    Width of the rectangle.

    +

    height

    +

    number

    +

    Yes

    +

    0

    +

    Height of the rectangle.

    +
    + + +- Example + + ``` + @Entry + @Component + struct ClearRect { + private settings: RenderingContextSettings = new RenderingContextSettings(true,true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.context.fillStyle = 'rgb(0,0,255)' + this.context.fillRect(0,0,500,500) + this.context.clearRect(20,20,150,100) + }) + } + .width('100%') + .height('100%') + } + } + ``` + + ![](figures/11111.png) + + +### fillText + +fillText\(text: string, x: number, y: number\): void + +Draws filled text on the canvas. + +- Parameters + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

    Name

    +

    Type

    +

    Mandatory

    +

    Default Value

    +

    Description

    +

    text

    +

    string

    +

    Yes

    +

    ""

    +

    Text to draw.

    +

    x

    +

    number

    +

    Yes

    +

    0

    +

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

    +

    y

    +

    number

    +

    Yes

    +

    0

    +

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

    +
    + + +- Example + + ``` + @Entry + @Component + struct FillText { + private settings: RenderingContextSettings = new RenderingContextSettings(true,true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.context.font = '30px sans-serif' + this.context.fillText("Hello World!", 20, 100) + }) + } + .width('100%') + .height('100%') + } + } + ``` + + ![](figures/en-us_image_0000001238537297.png) + + +### strokeText + +strokeText\(text: string, x: number, y: number\): void + +Draws a text stroke on the canvas. + +- Parameters + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

    Name

    +

    Type

    +

    Mandatory

    +

    Default Value

    +

    Description

    +

    text

    +

    string

    +

    Yes

    +

    ""

    +

    Text to draw.

    +

    x

    +

    number

    +

    Yes

    +

    0

    +

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

    +

    y

    +

    number

    +

    Yes

    +

    0

    +

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

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

    Name

    +

    Type

    +

    Mandatory

    +

    Default Value

    +

    Description

    +

    text

    +

    string

    +

    Yes

    +

    ""

    +

    Text to be measured.

    +
    + + +- Return values + + + + + + + + + + +

    Type

    +

    Description

    +

    TextMetrics

    +

    TextMetrics object.

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

    Attribute

    +

    Type

    +

    Description

    +

    width

    +

    number

    +

    Width of the text string.

    +
    + + +- Example + + ``` + @Entry + @Component + struct MeasureText { + private settings: RenderingContextSettings = new RenderingContextSettings(true,true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.context.font = '50px sans-serif' + this.context.fillText("Hello World!", 20, 100) + this.context.fillText("width:" + this.context.measureText("Hello World!").width, 20, 200) + }) + } + .width('100%') + .height('100%') + } + } + ``` + + ![](figures/en-us_image_0000001238476361.png) + + +### stroke + +stroke\(path?: Path2D\): void + +Strokes a path. + +- Parameters + + + + + + + + + + + + + + + + +

    Name

    +

    Type

    +

    Mandatory

    +

    Default Value

    +

    Description

    +

    path

    +

    Path2D

    +

    No

    +

    null

    +

    A Path2D path to draw.

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

    Name

    +

    Type

    +

    Mandatory

    +

    Default Value

    +

    Description

    +

    x

    +

    number

    +

    Yes

    +

    0

    +

    X-coordinate of the target position.

    +

    y

    +

    number

    +

    Yes

    +

    0

    +

    Y-coordinate of the target position.

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

    Name

    +

    Type

    +

    Mandatory

    +

    Default Value

    +

    Description

    +

    x

    +

    number

    +

    Yes

    +

    0

    +

    X-coordinate of the target position.

    +

    y

    +

    number

    +

    Yes

    +

    0

    +

    Y-coordinate of the target position.

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

    Name

    +

    Type

    +

    Mandatory

    +

    Default Value

    +

    Description

    +

    image

    +

    ImageBitmap

    +

    Yes

    +

    null

    +

    Source image. For details, see ImageBitmap.

    +

    repetition

    +

    string

    +

    Yes

    +

    ""

    +

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

    +
    + +- Example + + ``` + @Entry + @Component + struct CreatePattern { + private settings: RenderingContextSettings = new RenderingContextSettings(true,true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + private img:ImageBitmap = new ImageBitmap("common/images/icon.jpg") + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + var pattern = this.context.createPattern(this.img, 'repeat') + this.context.fillStyle = pattern + this.context.fillRect(0, 0, 200, 200) + }) + } + .width('100%') + .height('100%') + } + } + ``` + + ![](figures/en-us_image_0000001238401029.png) + + +### bezierCurveTo + +bezierCurveTo\(cp1x: number, cp1y: number, cp2x: number, cp2y: number, x: number, y: number\): void + +Draws a cubic bezier curve on the canvas. + +- Parameters + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

    Name

    +

    Type

    +

    Mandatory

    +

    Default Value

    +

    Description

    +

    cp1x

    +

    number

    +

    Yes

    +

    0

    +

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

    +

    cp1y

    +

    number

    +

    Yes

    +

    0

    +

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

    +

    cp2x

    +

    number

    +

    Yes

    +

    0

    +

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

    +

    cp2y

    +

    number

    +

    Yes

    +

    0

    +

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

    +

    x

    +

    number

    +

    Yes

    +

    0

    +

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

    +

    y

    +

    number

    +

    Yes

    +

    0

    +

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

    +
    + + +- Example + + ``` + @Entry + @Component + struct BezierCurveTo { + private settings: RenderingContextSettings = new RenderingContextSettings(true,true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.context.beginPath() + this.context.moveTo(10, 10) + this.context.bezierCurveTo(20, 100, 200, 100, 200, 20) + this.context.stroke() + }) + } + .width('100%') + .height('100%') + } + } + ``` + + ![](figures/en-us_image_0000001238281067.png) + + +### quadraticCurveTo + +quadraticCurveTo\(cpx: number, cpy: number, x: number, y: number\): void + +Draws a quadratic curve on the canvas. + +- Parameters + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

    Name

    +

    Type

    +

    Mandatory

    +

    Default Value

    +

    Description

    +

    cpx

    +

    number

    +

    Yes

    +

    0

    +

    X-coordinate of the bezier curve parameter.

    +

    cpy

    +

    number

    +

    Yes

    +

    0

    +

    Y-coordinate of the bezier curve parameter.

    +

    x

    +

    number

    +

    Yes

    +

    0

    +

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

    +

    y

    +

    number

    +

    Yes

    +

    0

    +

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

    +
    + + +- Example + + ``` + @Entry + @Component + struct QuadraticCurveTo { + private settings: RenderingContextSettings = new RenderingContextSettings(true,true); + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings); + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.context.beginPath(); + this.context.moveTo(20, 20); + this.context.quadraticCurveTo(100, 100, 200, 20); + this.context.stroke(); + }) + } + .width('100%') + .height('100%') + } + } + ``` + + ![](figures/en-us_image_0000001193641084.png) + + +### arc + +arc\(x: number, y: number, radius: number, startAngle: number, endAngle: number, anticlockwise?: boolean\): void + +Draws an arc on the canvas. + +- Parameters + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

    Name

    +

    Type

    +

    Mandatory

    +

    Default Value

    +

    Description

    +

    x

    +

    number

    +

    Yes

    +

    0

    +

    X-coordinate of the center point of the arc.

    +

    y

    +

    number

    +

    Yes

    +

    0

    +

    Y-coordinate of the center point of the arc.

    +

    radius

    +

    number

    +

    Yes

    +

    0

    +

    Radius of the arc.

    +

    startAngle

    +

    number

    +

    Yes

    +

    0

    +

    Start radian of the arc.

    +

    endAngle

    +

    number

    +

    Yes

    +

    0

    +

    End radian of the arc.

    +

    anticlockwise

    +

    boolean

    +

    No

    +

    false

    +

    Whether to draw the arc counterclockwise.

    +
    + + +- Example + + ``` + @Entry + @Component + struct Arc { + private settings: RenderingContextSettings = new RenderingContextSettings(true,true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.context.beginPath() + this.context.arc(100, 75, 50, 0, 6.28) + this.context.stroke() + }) + } + .width('100%') + .height('100%') + } + } + ``` + + ![](figures/en-us_image_0000001193801070.png) + + +### arcTo + +arcTo\(x1: number, y1: number, x2: number, y2: number, radius: number\): void + +Draws an arc based on the radius and points on the arc. + +- Parameters + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

    Name

    +

    Type

    +

    Mandatory

    +

    Default Value

    +

    Description

    +

    x1

    +

    number

    +

    Yes

    +

    0

    +

    X-coordinate of the first point on the arc.

    +

    y1

    +

    number

    +

    Yes

    +

    0

    +

    Y-coordinate of the first point on the arc.

    +

    x2

    +

    number

    +

    Yes

    +

    0

    +

    X-coordinate of the second point on the arc.

    +

    y2

    +

    number

    +

    Yes

    +

    0

    +

    Y-coordinate of the second point on the arc.

    +

    radius

    +

    number

    +

    Yes

    +

    0

    +

    Radius of the arc.

    +
    + + +- Example + + ``` + @Entry + @Component + struct ArcTo { + private settings: RenderingContextSettings = new RenderingContextSettings(true,true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.context.moveTo(100, 20); + this.context.arcTo(150, 20, 150, 70, 50); + this.context.stroke(); + }) + } + .width('100%') + .height('100%') + } + } + ``` + + ![](figures/en-us_image_0000001238521019.png) + + +### ellipse + +ellipse\(x: number, y: number, radiusX: number, radiusY: number, rotation: number, startAngle: number, endAngle: number, anticlockwise?: boolean\): void + +Draws an ellipse in the specified rectangular region. + +- Parameters + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

    Name

    +

    Type

    +

    Mandatory

    +

    Default Value

    +

    Description

    +

    x

    +

    number

    +

    Yes

    +

    0

    +

    X-coordinate of the ellipse center.

    +

    y

    +

    number

    +

    Yes

    +

    0

    +

    Y-coordinate of the ellipse center.

    +

    radiusX

    +

    number

    +

    Yes

    +

    0

    +

    Ellipse radius on the x-axis.

    +

    radiusY

    +

    number

    +

    Yes

    +

    0

    +

    Ellipse radius on the y-axis.

    +

    rotation

    +

    number

    +

    Yes

    +

    0

    +

    Rotation angle of the ellipse, in radians.

    +

    startAngle

    +

    number

    +

    Yes

    +

    0

    +

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

    +

    endAngle

    +

    number

    +

    Yes

    +

    0

    +

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

    +

    anticlockwise

    +

    number

    +

    No

    +

    0

    +

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

    +
    + + +- Example + + ``` + @Entry + @Component + struct Ellipse { + private settings: RenderingContextSettings = new RenderingContextSettings(true,true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.context.beginPath() + this.context.ellipse(200, 200, 50, 100, Math.PI * 0.25, Math.PI * 0.5, Math.PI, true) + this.context.stroke() + }) + Button('back') + .onClick(() => { + router.back() + }) + } + .width('100%') + .height('100%') + } + } + ``` + + ![](figures/en-us_image_0000001193481096.png) + + +### rect + +rect\(x: number, y: number, width: number, height: number\): void + +Creates a rectangle. + +- Parameters + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

    Name

    +

    Type

    +

    Mandatory

    +

    Default Value

    +

    Description

    +

    x

    +

    number

    +

    Yes

    +

    0

    +

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

    +

    y

    +

    number

    +

    Yes

    +

    0

    +

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

    +

    width

    +

    number

    +

    Yes

    +

    0

    +

    Width of the rectangle.

    +

    height

    +

    number

    +

    Yes

    +

    0

    +

    Height of the rectangle.

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

    Name

    +

    Type

    +

    Mandatory

    +

    Default Value

    +

    Description

    +

    rotate

    +

    number

    +

    Yes

    +

    0

    +

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

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

    Name

    +

    Type

    +

    Mandatory

    +

    Default Value

    +

    Description

    +

    x

    +

    number

    +

    Yes

    +

    0

    +

    Horizontal scale factor.

    +

    y

    +

    number

    +

    Yes

    +

    0

    +

    Vertical scale factor.

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

    Name

    +

    Type

    +

    Mandatory

    +

    Default Value

    +

    Description

    +

    scaleX

    +

    number

    +

    Yes

    +

    0

    +

    X-axis scale.

    +

    skewX

    +

    number

    +

    Yes

    +

    0

    +

    X-axis skew.

    +

    skewY

    +

    number

    +

    Yes

    +

    0

    +

    Y-axis skew.

    +

    scaleY

    +

    number

    +

    Yes

    +

    0

    +

    Y-axis scale.

    +

    translateX

    +

    number

    +

    Yes

    +

    0

    +

    X-axis translation.

    +

    translateY

    +

    number

    +

    Yes

    +

    0

    +

    Y-axis translation.

    +
    + +- Example + + ``` + @Entry + @Component + struct Transform { + private settings: RenderingContextSettings = new RenderingContextSettings(true,true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.context.fillStyle = 'rgb(0,0,0)' + this.context.fillRect(0, 0, 100, 100) + this.context.transform(1, 0.5, -0.5, 1, 10, 10) + this.context.fillStyle = 'rgb(255,0,0)' + this.context.fillRect(0, 0, 100, 100) + this.context.transform(1, 0.5, -0.5, 1, 10, 10) + this.context.fillStyle = 'rgb(0,0,255)' + this.context.fillRect(0, 0, 100, 100) + }) + } + .width('100%') + .height('100%') + } + } + ``` + + ![](figures/en-us_image_0000001193801072.png) + + +### setTransform + +setTransform\(scaleX: number, skewX: number, skewY: number, scale: number, translateX: number, translateY: number\): void + +Resets the existing transformation matrix and creates a new transformation matrix by using the same parameters as the **transform\(\)** function. + +- Parameters + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

    Name

    +

    Type

    +

    Mandatory

    +

    Default Value

    +

    Description

    +

    scaleX

    +

    number

    +

    Yes

    +

    0

    +

    X-axis scale.

    +

    skewX

    +

    number

    +

    Yes

    +

    0

    +

    X-axis skew.

    +

    skewY

    +

    number

    +

    Yes

    +

    0

    +

    Y-axis skew.

    +

    scaleY

    +

    number

    +

    Yes

    +

    0

    +

    Y-axis scale.

    +

    translateX

    +

    number

    +

    Yes

    +

    0

    +

    X-axis translation.

    +

    translateY

    +

    number

    +

    Yes

    +

    0

    +

    Y-axis translation.

    +
    + +- Example + + ``` + @Entry + @Component + struct SetTransform { + private settings: RenderingContextSettings = new RenderingContextSettings(true,true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.context.fillStyle = 'rgb(255,0,0)' + this.context.fillRect(0, 0, 100, 100) + this.context.setTransform(1,0.5, -0.5, 1, 10, 10) + this.context.fillStyle = 'rgb(0,0,255)' + this.context.fillRect(0, 0, 100, 100) + }) + } + .width('100%') + .height('100%') + } + } + ``` + + ![](figures/en-us_image_0000001238521021.png) + + +### translate + +translate\(x: number, y: number\): void + +Moves the origin of the coordinate system. + +- Parameters + + + + + + + + + + + + + + + + + + + + + + +

    Name

    +

    Type

    +

    Mandatory

    +

    Default Value

    +

    Description

    +

    x

    +

    number

    +

    Yes

    +

    0

    +

    X-axis translation

    +

    y

    +

    number

    +

    Yes

    +

    0

    +

    Y-axis translation.

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

    Name

    +

    Type

    +

    Mandatory

    +

    Default Value

    +

    Description

    +

    image

    +

    ImageBitmap

    +

    Yes

    +

    null

    +

    Image resource. For details, see ImageBitmap.

    +

    sx

    +

    number

    +

    No

    +

    0

    +

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

    +

    sy

    +

    number

    +

    No

    +

    0

    +

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

    +

    sWidth

    +

    number

    +

    No

    +

    0

    +

    Target width to crop the source image.

    +

    sHeight

    +

    number

    +

    No

    +

    0

    +

    Target height to crop the source image.

    +

    dx

    +

    number

    +

    Yes

    +

    0

    +

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

    +

    dy

    +

    number

    +

    Yes

    +

    0

    +

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

    +

    dWidth

    +

    number

    +

    No

    +

    0

    +

    Width of the drawing area.

    +

    dHeight

    +

    number

    +

    No

    +

    0

    +

    Height of the drawing area.

    +
    + + +- Example + + ``` + @Entry + @Component + struct ImageExample { + private settings: RenderingContextSettings = new RenderingContextSettings(true,true); + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings); + private img:ImageBitmap = new ImageBitmap("common/images/example.jpg"); + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.context.drawImage( this.img,0,0,500,500,0,0,400,200); + }) + } + .width('100%') + .height('100%') + } + } + ``` + + ![](figures/en-us_image_0000001192915154.png) + + +### createImageData + +createImageData\(width: number, height: number\): Object + +Creates an **ImageData** object. For details, see [ImageData](ts-components-canvas-imagedata.md). + +- Parameters + + + + + + + + + + + + + + + + + + + + + + +

    Name

    +

    Type

    +

    Mandatory

    +

    Default

    +

    Description

    +

    width

    +

    number

    +

    Yes

    +

    0

    +

    Width of the ImageData object.

    +

    height

    +

    number

    +

    Yes

    +

    0

    +

    Height of the ImageData object.

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

    Name

    +

    Type

    +

    Mandatory

    +

    Default

    +

    Description

    +

    imagedata

    +

    Object

    +

    Yes

    +

    null

    +

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

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

    Name

    +

    Type

    +

    Mandatory

    +

    Default Value

    +

    Description

    +

    sx

    +

    number

    +

    Yes

    +

    0

    +

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

    +

    sy

    +

    number

    +

    Yes

    +

    0

    +

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

    +

    sw

    +

    number

    +

    Yes

    +

    0

    +

    Width of the output area.

    +

    sh

    +

    number

    +

    Yes

    +

    0

    +

    Height of the output area.

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

    Name

    +

    Type

    +

    Mandatory

    +

    Default Value

    +

    Description

    +

    imagedata

    +

    Object

    +

    Yes

    +

    null

    +

    ImageData object with pixels to put onto the canvas.

    +

    dx

    +

    number

    +

    Yes

    +

    0

    +

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

    +

    dy

    +

    number

    +

    Yes

    +

    0

    +

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

    +

    dirtyX

    +

    number

    +

    No

    +

    0

    +

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

    +

    dirtyY

    +

    number

    +

    No

    +

    0

    +

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

    +

    dirtyWidth

    +

    number

    +

    No

    +

    Width of the ImageData object

    +

    Width of the rectangular area to crop the source image.

    +

    dirtyHeight

    +

    number

    +

    No

    +

    Height of the ImageData object

    +

    Height of the rectangular area to crop the source image.

    +
    + +- Example + + ``` + @Entry + @Component + struct PutImageData { + private settings: RenderingContextSettings = new RenderingContextSettings(true,true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + var imageData = this.context.createImageData(100, 100) + for (var i = 0; i < imageData.data.length; i += 4) { + imageData.data[i + 0] = 255 + imageData.data[i + 1] = 0 + imageData.data[i + 2] = 255 + imageData.data[i + 3] = 255 + } + this.context.putImageData(imageData, 10, 10) + }) + } + .width('100%') + .height('100%') + } + } + ``` + + ![](figures/en-us_image_0000001193075134.png) + + +### restore + +restore\(\): void + +Restores the saved drawing context. + +- Example + + ``` + @Entry + @Component + struct Restore { + private settings: RenderingContextSettings = new RenderingContextSettings(true,true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.controller.restore() + }) + } + .width('100%') + .height('100%') + } + } + ``` + + +### save + +save\(\): void + +Saves the current drawing context. + +- Example + + ``` + @Entry + @Component + struct Restore { + private settings: RenderingContextSettings = new RenderingContextSettings(true,true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.context.save() + }) + } + .width('100%') + .height('100%') + } + } + ``` + + +### createLinearGradient + +createLinearGradient\(x0: number, y0: number, x1: number, y1: number\): void + +Creates a linear gradient. + +- Parameters + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

    Name

    +

    Type

    +

    Mandatory

    +

    Default Value

    +

    Description

    +

    x0

    +

    number

    +

    Yes

    +

    0

    +

    X-coordinate of the start point.

    +

    y0

    +

    number

    +

    Yes

    +

    0

    +

    Y-coordinate of the start point.

    +

    x1

    +

    number

    +

    Yes

    +

    0

    +

    X-coordinate of the end point.

    +

    y1

    +

    number

    +

    Yes

    +

    0

    +

    Y-coordinate of the end point.

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

    Name

    +

    Type

    +

    Mandatory

    +

    Default Value

    +

    Description

    +

    x0

    +

    number

    +

    Yes

    +

    0

    +

    X-coordinate of the center of the start circle.

    +

    y0

    +

    number

    +

    Yes

    +

    0

    +

    Y-coordinate of the center of the start circle.

    +

    r0

    +

    number

    +

    Yes

    +

    0

    +

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

    +

    x1

    +

    number

    +

    Yes

    +

    0

    +

    X-coordinate of the center of the end circle.

    +

    y1

    +

    number

    +

    Yes

    +

    0

    +

    Y-coordinate of the center of the end circle.

    +

    r1

    +

    number

    +

    Yes

    +

    0

    +

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

    +
    + +- Example + + ``` + @Entry + @Component + struct CreateRadialGradient { + private settings: RenderingContextSettings = new RenderingContextSettings(true,true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + private gra:CanvasGradient = new CanvasGradient() + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + var grad = this.context.createRadialGradient(200,200,50, 200,200,200) + this.gra.addColorStop(0.0, 'red') + this.gra.addColorStop(0.5, 'white') + this.gra.addColorStop(1.0, 'green') + this.context.fillStyle = grad + this.context.fillRect(0, 0, 500, 500) + }) + } + .width('100%') + .height('100%') + } + } + ``` + + ![](figures/en-us_image_0000001192755188.png) + + +## CanvasPattern + +Defines an object created by using the [createPattern](#section1643216163371) method. + diff --git a/en/application-dev/reference/arkui-ts/ts-combined-gestures.md b/en/application-dev/reference/arkui-ts/ts-combined-gestures.md index df706686c6cc65d1e492f7fc404ebd97c64871d2..bbcfb02bb9daa3fc81bf01a900c2ad8315238d69 100644 --- a/en/application-dev/reference/arkui-ts/ts-combined-gestures.md +++ b/en/application-dev/reference/arkui-ts/ts-combined-gestures.md @@ -1,4 +1,11 @@ -# Combined Gestures +# Combined Gestures + +>![](../../public_sys-resources/icon-note.gif) **NOTE:** +>This gesture is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. + +## Required Permissions + +None ## APIs diff --git a/en/application-dev/reference/arkui-ts/ts-components-canvas-canvas.md b/en/application-dev/reference/arkui-ts/ts-components-canvas-canvas.md new file mode 100644 index 0000000000000000000000000000000000000000..2a193c594a664d6a902bc4d04648138bee1dba08 --- /dev/null +++ b/en/application-dev/reference/arkui-ts/ts-components-canvas-canvas.md @@ -0,0 +1,101 @@ +# Canvas + +>![](../../public_sys-resources/icon-note.gif) **NOTE:** +>This component is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version. + +The **** component can be used to customize drawings. + +## Required Permissions + +None + +## Child Components + +None + +## APIs + +Canvas\(context: CanvasRenderingContext2D\) + +- Parameters + + + + + + + + + + + + + + + + +

    Name

    +

    Type

    +

    Mandatory

    +

    Default Value

    +

    Description

    +

    context

    +

    CanvasRenderingContext2D

    +

    Yes

    +

    -

    +

    For details, see CanvasRenderingContext2D.

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

    Name

    +

    Parameter

    +

    Description

    +

    onReady(callback: () => void)

    +

    None

    +

    Triggered when .

    +
    + +## Example + +``` +@Entry +@Component +struct CanvasExample { + private settings: RenderingContextSettings = new RenderingContextSettings(true,true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.context.fillRect(0,30,100,100) + }) + } + .width('100%') + .height('100%') + } +} +``` + diff --git a/en/application-dev/reference/arkui-ts/ts-components-canvas-canvasgradient.md b/en/application-dev/reference/arkui-ts/ts-components-canvas-canvasgradient.md new file mode 100644 index 0000000000000000000000000000000000000000..2e1895ded8a48065898a5a8c86c9523157bccce0 --- /dev/null +++ b/en/application-dev/reference/arkui-ts/ts-components-canvas-canvasgradient.md @@ -0,0 +1,87 @@ +# CanvasGradient + +>![](../../public_sys-resources/icon-note.gif) **NOTE:** +>This component is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version. + +**CanvasGradient** provides a gradient object. + +## addColorStop + +addColorStop\(offset: number, color: string\): void + +Adds a color stop for the **CanvasGradient** object based on the specified offset and gradient color. + +- Parameters + + + + + + + + + + + + + + + + + + + + + + +

    Name

    +

    Type

    +

    Mandatory

    +

    Default Value

    +

    Description

    +

    offset

    +

    number

    +

    Yes

    +

    0

    +

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

    +

    color

    +

    string

    +

    Yes

    +

    'ffffff'

    +

    Gradient color to set.

    +
    + +- Example + + ``` + @Entry + @Component + struct Page45 { + private settings: RenderingContextSettings = new RenderingContextSettings(true,true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + private gra:CanvasGradient = new CanvasGradient() + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + var grad = this.context.createLinearGradient(50,0, 300,100) + this.gra.addColorStop(0.0, 'red') + this.gra.addColorStop(0.5, 'white') + this.gra.addColorStop(1.0, 'green') + this.context.fillStyle = grad + this.context.fillRect(0, 0, 500, 500) + }) + } + .width('100%') + .height('100%') + } + } + ``` + + ![](figures/en-us_image_0000001192915130.png) + + diff --git a/en/application-dev/reference/arkui-ts/ts-components-canvas-imagebitmap.md b/en/application-dev/reference/arkui-ts/ts-components-canvas-imagebitmap.md new file mode 100644 index 0000000000000000000000000000000000000000..6c7546ec9f56539adefca6e30cdd3bbbd5075cbc --- /dev/null +++ b/en/application-dev/reference/arkui-ts/ts-components-canvas-imagebitmap.md @@ -0,0 +1,109 @@ +# ImageBitmap + +>![](../../public_sys-resources/icon-note.gif) **NOTE:** +>This component is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version. + +**ImageBitmap** allows you to add an image bitmap. + +## APIs + +ImageBitmap\(src: string\) + +- Parameters + + + + + + + + + + + + + + + + +

    Name

    +

    Type

    +

    Mandatory

    +

    Default Value

    +

    Description

    +

    src

    +

    string

    +

    Yes

    +

    -

    +

    Path of the image bitmap object.

    +
    + + +## Attributes + + + + + + + + + + + + + + + + + + + + + + +

    Attribute

    +

    Type

    +

    Default Value

    +

    Mandatory

    +

    Description

    +

    width

    +

    Length

    +

    0px

    +

    No

    +

    Image width.

    +

    height

    +

    Length

    +

    0px

    +

    No

    +

    Image height.

    +
    + +Example + +``` +@Entry +@Component +struct DrawImageExample { + private settings:RenderingContextSettings = new RenderingContextSettings(true,true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + private img:ImageBitmap = new ImageBitmap("common/images/example.jpg") + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.context.drawImage( this.img,0,0,400,200) + }) + } + .width('100%') + .height('100%') + } +} +``` + +![](figures/en-us_image_0000001192595194.png) + diff --git a/en/application-dev/reference/arkui-ts/ts-components-canvas-imagedata.md b/en/application-dev/reference/arkui-ts/ts-components-canvas-imagedata.md new file mode 100644 index 0000000000000000000000000000000000000000..43aa9147a1cad5c71649bac3f948aa1fc09675b6 --- /dev/null +++ b/en/application-dev/reference/arkui-ts/ts-components-canvas-imagedata.md @@ -0,0 +1,42 @@ +# ImageData + +>![](../../public_sys-resources/icon-note.gif) **NOTE:** +>This component is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version. + +**CanvasImageData** stores pixel data rendered on a canvas. + +## Attributes + + + + + + + + + + + + + + + + + + + + +

    Attribute

    +

    Type

    +

    Description

    +

    width

    +

    number

    +

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

    +

    height

    +

    number

    +

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

    +

    data

    +

    <Uint8ClampedArray>

    +

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

    +
    + diff --git a/en/application-dev/reference/arkui-ts/ts-components-canvas-lottie.md b/en/application-dev/reference/arkui-ts/ts-components-canvas-lottie.md new file mode 100644 index 0000000000000000000000000000000000000000..b2a63e4de072dc9aebade58e2caeec761a522240 --- /dev/null +++ b/en/application-dev/reference/arkui-ts/ts-components-canvas-lottie.md @@ -0,0 +1,1343 @@ +# Lottie + +>![](../../public_sys-resources/icon-note.gif) **NOTE:** +>This component is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version. + +Lottie is a third-party open-source library and depends on **Canvas** and **RenderingContext**. + +## Required Permissions + +None + +## Modules to Import + +``` +import lottie from 'lottie-web' +``` + +>![](../../public_sys-resources/icon-note.gif) **NOTE:** +>**'lottie-web'** is subject to the actual released name. + +## lottie.loadAnimation + +loadAnimation\( + +path: string, container: object, render: string, loop: boolean, autoplay: boolean, name: string \): AnimationItem + +Loads an animation. Before calling this method, declare the **Animator\('\_\_lottie\_ets'\)** object and check that the canvas layout is complete. This method can be used together with a lifecycle callback of the **Canvas** component, for example, **onAppear\(\)** and **onPageShow\(\)**. + +- Parameters + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

    Name

    +

    Type

    +

    Mandatory

    +

    Description

    +

    path

    +

    string

    +

    Yes

    +

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

    +

    container

    +

    object

    +

    Yes

    +

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

    +

    render

    +

    string

    +

    Yes

    +

    Rendering type. Only canvas is supported.

    +

    loop

    +

    boolean | number

    +

    No

    +

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

    +

    autoplay

    +

    boolean

    +

    No

    +

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

    +

    name

    +

    string

    +

    No

    +

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

    +

    initialSegment

    +

    [number, number]

    +

    No

    +

    Start frame and end frame of the animation, respectively.

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

    Name

    +

    Type

    +

    Mandatory

    +

    Description

    +

    name

    +

    string

    +

    Yes

    +

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

    +
    + +- Example + + ``` + import lottie from 'lottie-web' + + @Entry + @Component + struct Index { + private controller: CanvasRenderingContext2D = new CanvasRenderingContext2D() + private animateName: string = "animate" + private animatePath: string = "common/lottie/data.json" + private animateItem: any = null + + private onPageHide(): void { + console.log('onPageHide') + lottie.destroy() + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.controller) + .width('30%') + .height('20%') + .backgroundColor('#0D9FFB') + .onAppear(() => { + console.log('canvas onAppear'); + this.animateItem = lottie.loadAnimation({ + container: this.controller, + renderer: 'canvas', + loop: true, + autoplay: true, + name: this.animateName, + path: this.animatePath, + }) + }) + + Animator('__lottie_ets') // declare Animator('__lottie_ets') when use lottie + Button('load animation') + .onClick(() => { + if (this.animateItem != null) { + this.animateItem.destroy() + this.animateItem = null + } + this.animateItem = lottie.loadAnimation({ + container: this.controller, + renderer: 'canvas', + loop: true, + autoplay: true, + name: this.animateName, + path: this.animatePath, + initialSegment: [10, 50], + }) + }) + + Button('destroy animation') + .onClick(() => { + lottie.destroy(this.animateName) + this.animateItem = null + }) + } + .width('100%') + .height('100%') + } + } + ``` + + ![](figures/lottie-ark-2-0-canvas-ui-animate.gif) + + +## lottie.play + +play\(name: string\): void + +Plays a specified animation. + +- Parameters + + + + + + + + + + + + + + +

    Name

    +

    Type

    +

    Mandatory

    +

    Description

    +

    name

    +

    string

    +

    Yes

    +

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

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

    Name

    +

    Type

    +

    Mandatory

    +

    Description

    +

    name

    +

    string

    +

    Yes

    +

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

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

    Name

    +

    Type

    +

    Mandatory

    +

    Description

    +

    name

    +

    string

    +

    Yes

    +

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

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

    Name

    +

    Type

    +

    Mandatory

    +

    Description

    +

    name

    +

    string

    +

    Yes

    +

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

    +
    + +- Example + + ``` + lottie.stop(this.animateName) + ``` + + +## lottie.setSpeed + +setSpeed\(speed: number, name: string\): void + +Sets the playback speed of the specified animation. + +- Parameters + + + + + + + + + + + + + + + + + + + +

    Name

    +

    Type

    +

    Mandatory

    +

    Description

    +

    speed

    +

    number

    +

    Yes

    +

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

    +

    name

    +

    string

    +

    Yes

    +

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

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

    Name

    +

    Type

    +

    Mandatory

    +

    Description

    +

    direction

    +

    AnimationDirection

    +

    Yes

    +

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

    +

    AnimationDirection: 1 | -1

    +

    name

    +

    string

    +

    Yes

    +

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

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

    Name

    +

    Type

    +

    Description

    +

    name

    +

    string

    +

    Animation name.

    +

    isLoaded

    +

    boolean

    +

    Whether the animation is loaded.

    +

    currentFrame

    +

    number

    +

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

    +

    currentRawFrame

    +

    number

    +

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

    +

    firstFrame

    +

    number

    +

    First frame of the animation segment that is being played.

    +

    totalFrames

    +

    number

    +

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

    +

    frameRate

    +

    number

    +

    Frame rate (frame/s).

    +

    frameMult

    +

    number

    +

    Frame rate (frame/ms).

    +

    playSpeed

    +

    number

    +

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

    +

    playDirection

    +

    number

    +

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

    +

    playCount

    +

    number

    +

    Number of times the animation plays.

    +

    isPaused

    +

    boolean

    +

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

    +

    autoplay

    +

    boolean

    +

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

    +

    loop

    +

    boolean | number

    +

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

    +

    renderer

    +

    any

    +

    Animation rendering object, which depends on the rendering type.

    +

    animationID

    +

    string

    +

    Animation ID.

    +

    timeCompleted

    +

    number

    +

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

    +

    segmentPos

    +

    number

    +

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

    +

    isSubframeEnabled

    +

    boolean

    +

    Whether the precision of currentFrame is a floating point number.

    +

    segments

    +

    AnimationSegment | AnimationSegment[]

    +

    Current segment of the animation.

    +
    + +## AnimationItem.play + +play\(name?: string\): void + +Plays an animation. + +- Parameters + + + + + + + + + + + + + + +

    Name

    +

    Type

    +

    Mandatory

    +

    Description

    +

    name

    +

    string

    +

    No

    +

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

    +
    + +- Example + + ``` + this.anim.play() + ``` + + +## AnimationItem.destroy + +destroy\(name?: string\): void + +Destroys an animation. + +- Parameters + + + + + + + + + + + + + + +

    Name

    +

    Type

    +

    Mandatory

    +

    Description

    +

    name

    +

    string

    +

    No

    +

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

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

    Name

    +

    Type

    +

    Mandatory

    +

    Description

    +

    name

    +

    string

    +

    No

    +

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

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

    Name

    +

    Type

    +

    Mandatory

    +

    Description

    +

    name

    +

    string

    +

    No

    +

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

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

    Name

    +

    Type

    +

    Mandatory

    +

    Description

    +

    name

    +

    string

    +

    No

    +

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

    +
    + +- Example + + ``` + this.anim.stop() + ``` + + +## AnimationItem.setSpeed + +setSpeed\(speed: number\): void + +Sets the playback speed of an animation. + +- Parameters + + + + + + + + + + + + + + +

    Name

    +

    Type

    +

    Mandatory

    +

    Description

    +

    speed

    +

    number

    +

    Yes

    +

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

    +
    + +- Example + + ``` + this.anim.setSpeed(5); + ``` + + +## AnimationItem.setDirection + +setDirection\(direction: AnimationDirection\): void + +Sets the playback direction of an animation. + +- Parameters + + + + + + + + + + + + + + +

    Name

    +

    Type

    +

    Mandatory

    +

    Description

    +

    direction

    +

    AnimationDirection

    +

    Yes

    +

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

    +

    AnimationDirection: 1 | -1.

    +
    + + +- Example + + ``` + this.anim.setDirection(-1) + ``` + + +## AnimationItem.goToAndStop + +goToAndStop\(value: number, isFrame: boolean\): void + +Sets the animation to stop at the specified frame or time. + +- Parameters + + + + + + + + + + + + + + + + + + + + + + + + +

    Name

    +

    Type

    +

    Mandatory

    +

    Description

    +

    value

    +

    number

    +

    Yes

    +

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

    +

    isFrame

    +

    boolean

    +

    No

    +

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

    +

    name

    +

    string

    +

    No

    +

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

    +
    + + +- Example + + ``` + // Set the animation to stop at the specified frame. + this.anim.goToAndStop(25, true) + // Set the animation to stop at the specified time progress. + this.anim.goToAndStop(300, false, this.animateName) + ``` + + +## AnimationItem.goToAndPlay + +goToAndPlay\(value: number, isFrame: boolean\): void + +Sets the animation to start from the specified frame or time progress. + +- Parameters + + + + + + + + + + + + + + + + + + + + + + + + +

    Name

    +

    Type

    +

    Mandatory

    +

    Description

    +

    value

    +

    number

    +

    Yes

    +

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

    +

    isFrame

    +

    boolean

    +

    Yes

    +

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

    +

    name

    +

    string

    +

    No

    +

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

    +
    + + +- Example + + ``` + // Set the animation to start from the specified frame. + this.anim.goToAndPlay(25, true) + // Set the animation to start from the specified time progress. + this.anim.goToAndPlay(300, false, this.animateName) + ``` + + +## AnimationItem.playSegments + +playSegments\(segments: AnimationSegment | AnimationSegment\[\], forceFlag: boolean\): void + +Sets the animation to play only the specified segment. + +- Parameters + + + + + + + + + + + + + + + + + + + +

    Name

    +

    Type

    +

    Mandatory

    +

    Description

    +

    segments

    +

    AnimationSegment = [number, number] | AnimationSegment[]

    +

    Yes

    +

    Segment or segment list.

    +

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

    +

    forceFlag

    +

    boolean

    +

    Yes

    +

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

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

    Name

    +

    Type

    +

    Mandatory

    +

    Description

    +

    forceFlag

    +

    boolean

    +

    Yes

    +

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

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

    Name

    +

    Type

    +

    Mandatory

    +

    Description

    +

    useSubFrames

    +

    boolean

    +

    Yes

    +

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

    +

    true: The currentFrame attribute displays floating-point numbers.

    +

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

    +
    + + +- Example + + ``` + this.anim.setSubframe(false) + ``` + + +## AnimationItem.getDuration + +getDuration\(inFrames?: boolean\): void + +Obtains the duration \(irrelevant to the playback speed\) or number of frames for playing an animation sequence. The settings are related to the input parameter **initialSegment** of the **Lottie.loadAnimation** interface. + +- Parameters + + + + + + + + + + + + + + +

    Name

    +

    Type

    +

    Mandatory

    +

    Description

    +

    inFrames

    +

    boolean

    +

    No

    +

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

    +
    + + +- Example + + ``` + this.anim.setSubframe(true) + ``` + + +## AnimationItem.addEventListener + +addEventListener\(name: AnimationEventName, callback: AnimationEventCallback\): \(\) =\> void + +Adds an event listener. After the event is complete, the specified callback function is triggered. This method returns the function object that can delete the event listener. + +- Parameters + + + + + + + + + + + + + + + + + + + +

    Name

    +

    Type

    +

    Mandatory

    +

    Description

    +

    name

    +

    AnimationEventName

    +

    Yes

    +

    Animation event type. The available options are as follows:

    +

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

    +

    callback

    +

    AnimationEventCallback<T>

    +

    Yes

    +

    Custom callback.

    +
    + + +- Example + + ``` + private callbackItem: any = function() { + console.log("grunt loopComplete") + } + let delFunction = this.animateItem.addEventListener('loopComplete', this.callbackItem) + + // Delete the event listener. + delFunction() + ``` + + +## AnimationItem.removeEventListener + +removeEventListener\(name: AnimationEventName, callback?: AnimationEventCallback\): void + +Deletes an event listener. + +- Parameters + + + + + + + + + + + + + + + + + + + +

    Name

    +

    Type

    +

    Mandatory

    +

    Description

    +

    name

    +

    AnimationEventName

    +

    Yes

    +

    Animation event type. The available options are as follows:

    +

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

    +

    callback

    +

    AnimationEventCallback<T>

    +

    Yes

    +

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

    +
    + + +- Example + + ``` + this.animateItem.removeEventListener('loopComplete', this.callbackItem) + ``` + + +## AnimationItem.triggerEvent + +triggerEvent\(name: AnimationEventName, args: T\): void + +Directly triggers all configured callbacks of a specified event. + +- Parameters + + + + + + + + + + + + + + + + + + + +

    Name

    +

    Type

    +

    Mandatory

    +

    Description

    +

    name

    +

    AnimationEventName

    +

    Yes

    +

    Animation event type.

    +

    +

    args

    +

    any

    +

    Yes

    +

    Custom callback parameters.

    +
    + + +- Example + + ``` + private triggerCallBack: any = function(item) { + console.log("trigger loopComplete, name:" + item.name) + } + + this.animateItem.addEventListener('loopComplete', this.triggerCallBack) + this.animateItem.triggerEvent('loopComplete', this.animateItem) + this.animateItem.removeEventListener('loopComplete', this.triggerCallBack) + ``` + + diff --git a/en/application-dev/reference/arkui-ts/ts-components-canvas-path2d.md b/en/application-dev/reference/arkui-ts/ts-components-canvas-path2d.md new file mode 100644 index 0000000000000000000000000000000000000000..3cf2b4df5c04552bbde5c5d5810162e272fdcd2d --- /dev/null +++ b/en/application-dev/reference/arkui-ts/ts-components-canvas-path2d.md @@ -0,0 +1,959 @@ +# Path2D + +>![](../../public_sys-resources/icon-note.gif) **NOTE:** +>This component is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version. + +**Path2D** allows you to describe a path through an existing path. This path can be drawn through the **stroke** API of **Canvas**. + +## addPath + +addPath\(path: Object\): void + +Adds a path to this path. + +- Parameters + + + + + + + + + + + + + + + + +

    Name

    +

    Type

    +

    Mandatory

    +

    Default Value

    +

    Description

    +

    path

    +

    Object

    +

    Yes

    +

    null

    +

    Path to be added to this path.

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

    Name

    +

    Type

    +

    Mandatory

    +

    Default Value

    +

    Description

    +

    x

    +

    number

    +

    Yes

    +

    0

    +

    X-coordinate of the target point.

    +

    y

    +

    number

    +

    Yes

    +

    0

    +

    Y-coordinate of the target point.

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

    Name

    +

    Type

    +

    Mandatory

    +

    Default Value

    +

    Description

    +

    x

    +

    number

    +

    Yes

    +

    0

    +

    X-coordinate of the target point.

    +

    y

    +

    number

    +

    Yes

    +

    0

    +

    Y-coordinate of the target point.

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

    Name

    +

    Type

    +

    Mandatory

    +

    Default Value

    +

    Description

    +

    cp1x

    +

    number

    +

    Yes

    +

    0

    +

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

    +

    cp1y

    +

    number

    +

    Yes

    +

    0

    +

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

    +

    cp2x

    +

    number

    +

    Yes

    +

    0

    +

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

    +

    cp2y

    +

    number

    +

    Yes

    +

    0

    +

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

    +

    x

    +

    number

    +

    Yes

    +

    0

    +

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

    +

    y

    +

    number

    +

    Yes

    +

    0

    +

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

    +
    + + +- Example + + ``` + @Entry + @Component + struct BezierCurveTo { + private settings: RenderingContextSettings = new RenderingContextSettings(true,true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + private path2Db: Path2D = new Path2D() + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.path2Db.moveTo(10, 10) + this.path2Db.bezierCurveTo(20, 100, 200, 100, 200, 20);this.context.stroke(this.path2Db) + }) + } + .width('100%') + .height('100%') + } + } + ``` + + ![](figures/en-us_image_0000001192915158.png) + + +## quadraticCurveTo + +quadraticCurveTo\(cpx: number, cpy: number, x: number ,y: number\): void + +Draws a quadratic curve on the canvas. + +- Parameters + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

    Name

    +

    Type

    +

    Mandatory

    +

    Default Value

    +

    Description

    +

    cpx

    +

    number

    +

    Yes

    +

    0

    +

    X-coordinate of the bezier curve parameter.

    +

    cpy

    +

    number

    +

    Yes

    +

    0

    +

    Y-coordinate of the bezier curve parameter.

    +

    x

    +

    number

    +

    Yes

    +

    0

    +

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

    +

    y

    +

    number

    +

    Yes

    +

    0

    +

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

    +
    + +- Example + + ``` + @Entry + @Component + struct QuadraticCurveTo { + private settings: RenderingContextSettings = new RenderingContextSettings(true,true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + private path2Db: Path2D = new Path2D() + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.path2Db.moveTo(10, 10) + this.path2Db.quadraticCurveTo(100, 100, 200, 20) + this.context.stroke(this.path2Db) + }) + } + .width('100%') + .height('100%') + } + } + ``` + + ![](figures/en-us_image_0000001237555151.png) + + +## arc + +arc\(x: number, y: number, radius: number, startAngle: number, endAngle: number, anticlockwise?: number\): void + +Draws an arc on the canvas. + +- Parameters + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

    Name

    +

    Type

    +

    Mandatory

    +

    Default Value

    +

    Description

    +

    x

    +

    number

    +

    Yes

    +

    0

    +

    X-coordinate of the center point of the arc.

    +

    y

    +

    number

    +

    Yes

    +

    0

    +

    Y-coordinate of the center point of the arc.

    +

    radius

    +

    number

    +

    Yes

    +

    0

    +

    Radius of the arc.

    +

    startAngle

    +

    number

    +

    Yes

    +

    0

    +

    Start radian of the arc.

    +

    endAngle

    +

    number

    +

    Yes

    +

    0

    +

    End radian of the arc.

    +

    anticlockwise

    +

    boolean

    +

    No

    +

    false

    +

    Whether to draw the arc counterclockwise.

    +
    + +- Example + + ``` + @Entry + @Component + struct Arc { + private settings: RenderingContextSettings = new RenderingContextSettings(true,true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + private path2Db: Path2D = new Path2D() + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.path2Db.arc(100, 75, 50, 0, 6.28);this.context.stroke(this.path2Db) + }) + } + .width('100%') + .height('100%') + } + } + ``` + + ![](figures/en-us_image_0000001192595214.png) + + +## arcTo + +arcTo\(x1: number, y1: number, x2: number, y2: number, radius: number\): void + +Draws an arc based on the radius and points on the arc. + +- Parameters + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

    Name

    +

    Type

    +

    Mandatory

    +

    Default Value

    +

    Description

    +

    x1

    +

    number

    +

    Yes

    +

    0

    +

    X-coordinate of the first point on the arc.

    +

    y1

    +

    number

    +

    Yes

    +

    0

    +

    Y-coordinate of the first point on the arc.

    +

    x2

    +

    number

    +

    Yes

    +

    0

    +

    X-coordinate of the second point on the arc.

    +

    y2

    +

    number

    +

    Yes

    +

    0

    +

    Y-coordinate of the second point on the arc.

    +

    radius

    +

    number

    +

    Yes

    +

    0

    +

    Radius of the arc.

    +
    + +- Example + + ``` + @Entry + @Component + struct ArcTo { + private settings: RenderingContextSettings = new RenderingContextSettings(true,true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + private path2Db: Path2D = new Path2D() + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.path2Db.arcTo(150, 20, 150, 70, 50) + this.context.stroke(this.path2Db) + }) + } + .width('100%') + .height('100%') + } + } + ``` + + ![](figures/en-us_image_0000001192755172.png) + + +## ellipse + +ellipse\(x: number, y: number, radiusX: number, radiusY: number, rotation: number, startAngle: number, endAngle: number, anticlockwise?: number\): void + +Draws an ellipse in the specified rectangular region. + +- Parameters + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

    Name

    +

    Type

    +

    Mandatory

    +

    Default Value

    +

    Description

    +

    x

    +

    number

    +

    Yes

    +

    0

    +

    X-coordinate of the ellipse center.

    +

    y

    +

    number

    +

    Yes

    +

    0

    +

    Y-coordinate of the ellipse center.

    +

    radiusX

    +

    number

    +

    Yes

    +

    0

    +

    Ellipse radius on the x-axis.

    +

    radiusY

    +

    number

    +

    Yes

    +

    0

    +

    Ellipse radius on the y-axis.

    +

    rotation

    +

    number

    +

    Yes

    +

    0

    +

    Rotation angle of the ellipse, in radians.

    +

    startAngle

    +

    number

    +

    Yes

    +

    0

    +

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

    +

    endAngle

    +

    number

    +

    Yes

    +

    0

    +

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

    +

    anticlockwise

    +

    number

    +

    No

    +

    0

    +

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

    +
    + +- Example + + ``` + @Entry + @Component + struct Ellipse { + private settings: RenderingContextSettings = new RenderingContextSettings(true,true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + private path2Db: Path2D = new Path2D() + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.path2Db.ellipse(200, 200, 50, 100, Math.PI * 0.25, Math.PI * 0.5, Math.PI, true) + this.context.stroke(this.path2Db) + }) + } + .width('100%') + .height('100%') + } + } + ``` + + ![](figures/en-us_image_0000001193075154.png) + + +## rect + +rect\(x: number, y: number, width: number, height: number\): void + +Creates a rectangle. + +- Parameters + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

    Name

    +

    Type

    +

    Mandatory

    +

    Default Value

    +

    Description

    +

    x

    +

    number

    +

    Yes

    +

    0

    +

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

    +

    y

    +

    number

    +

    Yes

    +

    0

    +

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

    +

    width

    +

    number

    +

    Yes

    +

    0

    +

    Width of the rectangle.

    +

    height

    +

    number

    +

    Yes

    +

    0

    +

    Height of the rectangle.

    +
    + +- Example + + ``` + @Entry + @Component + struct Rect { + private settings: RenderingContextSettings = new RenderingContextSettings(true,true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + private path2Db: Path2D = new Path2D() + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.path2Db.rect(20, 20, 100, 100);this.context.stroke(this.path2Db) + }) + } + .width('100%') + .height('100%') + } + } + ``` + + ![](figures/en-us_image_0000001192755174.png) + + diff --git a/en/application-dev/reference/arkui-ts/ts-components-canvas.md b/en/application-dev/reference/arkui-ts/ts-components-canvas.md new file mode 100644 index 0000000000000000000000000000000000000000..c28d94e917737bd4625cb335bf388ae50bc7b5f9 --- /dev/null +++ b/en/application-dev/reference/arkui-ts/ts-components-canvas.md @@ -0,0 +1,19 @@ +# Canvas Components + +- **[Canvas](ts-components-canvas-canvas.md)** + +- **[CanvasRenderingContext2D](ts-canvasrenderingcontext2d.md)** + +- **[OffscreenCanvasRenderingConxt2D](ts-offscreencanvasrenderingcontext2d.md)** + +- **[Lottie](ts-components-canvas-lottie.md)** + +- **[Path2D](ts-components-canvas-path2d.md)** + +- **[CanvasGradient](ts-components-canvas-canvasgradient.md)** + +- **[ImageBitmap](ts-components-canvas-imagebitmap.md)** + +- **[ImageData](ts-components-canvas-imagedata.md)** + + diff --git a/en/application-dev/reference/arkui-ts/ts-components-container.md b/en/application-dev/reference/arkui-ts/ts-components-container.md index 4445ee2bd3f38f13d092285a8836600f88a089dd..3350d2b43e33b0334e4f45ae321cc1bce612d93e 100644 --- a/en/application-dev/reference/arkui-ts/ts-components-container.md +++ b/en/application-dev/reference/arkui-ts/ts-components-container.md @@ -1,4 +1,4 @@ -# Container Components +# Container Components - **[AlphabetIndexer](ts-container-alphabet-indexer.md)** @@ -24,6 +24,8 @@ - **[Navigator](ts-container-navigator.md)** +- **[Navigation](ts-container-navigation.md)** + - **[Panel](ts-container-panel.md)** - **[Row](ts-container-row.md)** @@ -32,6 +34,8 @@ - **[Scroll](ts-container-scroll.md)** +- **[ScrollBar](ts-container-scrollbar.md)** + - **[Stack](ts-container-stack.md)** - **[Swiper](ts-container-swiper.md)** @@ -40,4 +44,8 @@ - **[TabContent](ts-container-tabcontent.md)** +- **[Stepper](ts-container-stepper.md)** + +- **[StepperItem](ts-container-stepperitem.md)** + diff --git a/en/application-dev/reference/arkui-ts/ts-components.md b/en/application-dev/reference/arkui-ts/ts-components.md index 8aa235447aa565e0b349feb4559857b588626018..6dd3d6a512fa63959867b3c52e47aba7349f8f06 100644 --- a/en/application-dev/reference/arkui-ts/ts-components.md +++ b/en/application-dev/reference/arkui-ts/ts-components.md @@ -1,4 +1,4 @@ -# Components +# Components - **[Universal Components](ts-universal-components.md)** @@ -8,4 +8,6 @@ - **[Drawing Components](ts-drawing-components.md)** +- **[Canvas Components](ts-components-canvas.md)** + diff --git a/en/application-dev/reference/arkui-ts/ts-container-alphabet-indexer.md b/en/application-dev/reference/arkui-ts/ts-container-alphabet-indexer.md index d1da4616f83919aa329d35cc9e4f332f89c4b32c..4009d2f45471877baaf05483dee27055009169a1 100644 --- a/en/application-dev/reference/arkui-ts/ts-container-alphabet-indexer.md +++ b/en/application-dev/reference/arkui-ts/ts-container-alphabet-indexer.md @@ -1,36 +1,39 @@ -# AlphabetIndexer +# AlphabetIndexer + +>![](../../public_sys-resources/icon-note.gif) **NOTE:** +>This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. The **** component provides an alphabetic index bar. ## Applicable Devices - - - + + + + + + @@ -228,7 +242,7 @@ struct AlphabetIndexerComponent { private value: string[] = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'] build() { - AlphabetIndexer({ ArrayValue: this.value, selected: 0 }) + AlphabetIndexer({ arrayValue: this.value, selected: 0 }) .selectedColor(0xffffff) // Font color of the selected text .popupColor(0xFFFAF0) // Font color of the pop-up text .selectedBackgroundColor(0xCCCCCC) // Background color of the selected text diff --git a/en/application-dev/reference/arkui-ts/ts-container-badge.md b/en/application-dev/reference/arkui-ts/ts-container-badge.md index a53a877249391b25599bd123030518bb17153354..ccb15c953951d277547b7db473e5e642e6cad89f 100644 --- a/en/application-dev/reference/arkui-ts/ts-container-badge.md +++ b/en/application-dev/reference/arkui-ts/ts-container-badge.md @@ -1,7 +1,14 @@ -# Badge +# Badge + +>![](../../public_sys-resources/icon-note.gif) **NOTE:** +>This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. The **** component presents event information on a component. +## Required Permissions + +None + ## Child Components This component supports only one child component. diff --git a/en/application-dev/reference/arkui-ts/ts-container-column.md b/en/application-dev/reference/arkui-ts/ts-container-column.md index 350aac920610e78b2d7d4d1719982aa52ac5568d..5aebfdd7cac87423d8c1494108b354a22bd3c8ae 100644 --- a/en/application-dev/reference/arkui-ts/ts-container-column.md +++ b/en/application-dev/reference/arkui-ts/ts-container-column.md @@ -1,4 +1,7 @@ -# Column +# Column + +>![](../../public_sys-resources/icon-note.gif) **NOTE:** +>This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. The **** component lays out child components vertically. @@ -12,7 +15,7 @@ This component can contain child components. ## APIs -Column\(options?: \{ space?: Length \}\) +Column\(value:\{space?: Length\}\) - Parameters diff --git a/en/application-dev/reference/arkui-ts/ts-container-columnsplit.md b/en/application-dev/reference/arkui-ts/ts-container-columnsplit.md index 4da457e800af742c7b12ff14e795086d9083421a..362c327301ae8d94d92a47637bd08f841557e7ba 100644 --- a/en/application-dev/reference/arkui-ts/ts-container-columnsplit.md +++ b/en/application-dev/reference/arkui-ts/ts-container-columnsplit.md @@ -1,7 +1,14 @@ -# ColumnSplit +# ColumnSplit + +>![](../../public_sys-resources/icon-note.gif) **NOTE:** +>This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. The **** lays out child components vertically and inserts a horizontal divider between every two child components. +## Required Permissions + +None + ## Child Components This component can contain child components. diff --git a/en/application-dev/reference/arkui-ts/ts-container-counter.md b/en/application-dev/reference/arkui-ts/ts-container-counter.md index 618584427ee71bb2c601d6639622245f92662694..5a4c49aa9a83320590730fe01d32949eb2eaa732 100644 --- a/en/application-dev/reference/arkui-ts/ts-container-counter.md +++ b/en/application-dev/reference/arkui-ts/ts-container-counter.md @@ -1,12 +1,19 @@ -# Counter +# Counter + +>![](../../public_sys-resources/icon-note.gif) **NOTE:** +>This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. The **** component provides an operation to increase or decrease the number. +## Required Permissions + +None + ## Child Components This component can contain child components. -## API +## APIs Counter\(\) @@ -21,12 +28,12 @@ Universal events and gestures are not supported. Only the events listed below ar - - diff --git a/en/application-dev/reference/arkui-ts/ts-container-flex.md b/en/application-dev/reference/arkui-ts/ts-container-flex.md index e80339eb43124a7f51805610718a7efc0c2b71e8..e548366843bb3bc04feac69c5050642858b0bc1b 100644 --- a/en/application-dev/reference/arkui-ts/ts-container-flex.md +++ b/en/application-dev/reference/arkui-ts/ts-container-flex.md @@ -1,4 +1,7 @@ -# Flex +# Flex + +>![](../../public_sys-resources/icon-note.gif) **NOTE:** +>This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. The **** component allows for an elastic layout. @@ -12,7 +15,7 @@ This component can contain child components. ## APIs -Flex\(options?: \{ direction?: FlexDirection, wrap?: FlexWrap, justifyContent?: FlexAlign, alignItems?: ItemAlign, alignContent?: FlexAlign \}\) +Flex\(options?: \{ direction?: FlexDirection, wrap?: FlexWrap, justifyContent?: FlexAlign, alignItems?: ItemAlign, alignContent?: FlexAlign \}\) Creates a standard **** component. @@ -402,7 +405,7 @@ struct FlexExample4 { ![](figures/flex04.jpg) -![](figures/flex04-61.gif) +![](figures/flex04-2.gif) ``` // Example 05 diff --git a/en/application-dev/reference/arkui-ts/ts-container-grid.md b/en/application-dev/reference/arkui-ts/ts-container-grid.md index afb863a95afe949110c4c3ca601c314564c8dca0..6d142f9eec1c3bb7a631f05611e7f82806129f3a 100644 --- a/en/application-dev/reference/arkui-ts/ts-container-grid.md +++ b/en/application-dev/reference/arkui-ts/ts-container-grid.md @@ -1,4 +1,7 @@ -# Grid +# Grid + +>![](../../public_sys-resources/icon-note.gif) **NOTE:** +>This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. The **** component is a two-dimensional layout. The component is divided into rows and columns, to form cells. You can specify the cell where an item is located and combine different grids to form various layouts. @@ -69,15 +72,15 @@ Grid\(\) ## Events -

    Phone

    -

    Tablet

    + - - - - - - - -

    Phone

    Head Unit

    +

    Tablet

    Smart TV

    +

    Smart TV

    Wearable

    +

    Wearable

    Yes

    -

    Yes

    +

    Yes

    Yes

    +

    Yes

    No

    +

    No

    No

    +

    No

    +## Required Permissions + +None + ## Child Components None @@ -213,7 +216,18 @@ AlphabetIndexer\(value: \{arrayValue : Array, selected : number\}\)

    onSelected(index: number) => void

    Callback invoked when an item in the alphabetic indexer bar is selected.

    +

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

    +

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

    +

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

    +

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

    +

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

    +

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

    onInc(callback: () => void)

    +

    onInc(event: () => void)

    Event indicating that the number of monitored objects is increased.

    onDec(callback: () => void)

    +

    onDec(event: () => void)

    Event indicating that the number of monitored objects is decreased.

    Name

    + - - - @@ -144,5 +147,5 @@ struct GridExample { } ``` -![](figures/grid-62.gif) +![](figures/grid-3.gif) diff --git a/en/application-dev/reference/arkui-ts/ts-container-gridcontainer.md b/en/application-dev/reference/arkui-ts/ts-container-gridcontainer.md index b4df55cd1a50f0ca0c1e8553fc3e7ef8c6072e50..034b5719ead7182bf945a2640366583a458e4755 100644 --- a/en/application-dev/reference/arkui-ts/ts-container-gridcontainer.md +++ b/en/application-dev/reference/arkui-ts/ts-container-gridcontainer.md @@ -1,14 +1,21 @@ -# GridContainer +# GridContainer + +>![](../../public_sys-resources/icon-note.gif) **NOTE:** +>This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. The **** component lays out components vertically. It is used only in the grid layout. +## Required Permissions + +None + ## Child Components This component can contain child components. ## APIs -GridContainer\(options? :\{ columns?: number | 'auto', sizeType?: SizeType, gutter?: Length, margin?: Length \}\) +GridContainer\(options?: \{ columns?: number | 'auto', sizeType?: SizeType, gutter?: Length, margin?: Length\}\) - Parameter 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 24ef6d0b140293d5615a415342fa1d04ff268a55..a839e1cb6b9b0be44c627a26b873745b20d3c9b2 100644 --- a/en/application-dev/reference/arkui-ts/ts-container-griditem.md +++ b/en/application-dev/reference/arkui-ts/ts-container-griditem.md @@ -1,4 +1,7 @@ -# GridItem +# GridItem + +>![](../../public_sys-resources/icon-note.gif) **NOTE:** +>This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. The **** component provides a single item in a grid. diff --git a/en/application-dev/reference/arkui-ts/ts-container-list.md b/en/application-dev/reference/arkui-ts/ts-container-list.md index efaaaea97b3a4ce2293dc1b32623b2e3e7e92a73..fffebb7e5072c2bbce95200fb5091f265b874e80 100644 --- a/en/application-dev/reference/arkui-ts/ts-container-list.md +++ b/en/application-dev/reference/arkui-ts/ts-container-list.md @@ -1,4 +1,7 @@ -# List +# List + +>![](../../public_sys-resources/icon-note.gif) **NOTE:** +>This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. The **** component provides a list container that presents a series of list items arranged in a column with the same width. It supports presentations of the same type of data in a multiple and coherent row style, for example, images or text. @@ -12,7 +15,7 @@ This component contains the child component [](ts-container-listitem ## APIs -List\(options?: \{ space?: number, initialIndex?: number \}\) +List\(value:\{space?: number, initialIndex?: number\}\) - Parameters @@ -70,7 +73,7 @@ List\(options?: \{ space?: number, initialIndex?: number \}\) - @@ -126,29 +129,6 @@ List\(options?: \{ space?: number, initialIndex?: number \}\)

    Name

    Description

    +

    Description

    onScrollIndex(first: number) => void

    +

    onScrollIndex(first: number) => void

    Triggered when the start item of the grid changes.

    +

    Triggered when the start item of the grid changes.

    listDirection

    Axis

    +

    Axis

    Vertical

    -- Axis enums - - - - - - - - - - - - - -

    Name

    -

    Description

    -

    Vertical

    -

    The list items are vertically arranged.

    -

    Horizontal

    -

    The list items are horizontally arranged.

    -
    - - - EdgeEffect enums @@ -175,20 +155,64 @@ List\(options?: \{ space?: number, initialIndex?: number \}\) ## Events - - - - - - - - @@ -276,7 +273,7 @@ Obtains the scrolling offset. scroller.scrollToIndex\(value: number\): void -Scrolls to the item with the specified index. +Scrolls to the specified index. >![](../../public_sys-resources/icon-note.gif) **NOTE:** >Only the **** component is supported. @@ -332,7 +329,7 @@ Scrolls to the item with the specified index. - diff --git a/en/application-dev/reference/arkui-ts/ts-container-scrollbar.md b/en/application-dev/reference/arkui-ts/ts-container-scrollbar.md new file mode 100644 index 0000000000000000000000000000000000000000..26e9012f59b576416934c0693286ba8f302285c2 --- /dev/null +++ b/en/application-dev/reference/arkui-ts/ts-container-scrollbar.md @@ -0,0 +1,168 @@ +# ScrollBar + +>![](../../public_sys-resources/icon-note.gif) **NOTE:** +>This component is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version. + +The **** is used together with the scrollable components, such as ****, ****, and ****. + +## Required Permissions + +None + +## Child Components + +This component can contain a single child component. + +## APIs + +ScrollBar\(value: ScrollBarOption\) + +- ScrollBarOption parameters + + +

    Name

    + - - - - - + + + + + + + + + + + + + + + @@ -197,8 +221,40 @@ List\(options?: \{ space?: number, initialIndex?: number \}\) >![](../../public_sys-resources/icon-note.gif) **NOTE:** >To enable the editable mode for a list, the following conditions must be met: >- **editMode** is set to **true**. ->- The **onItemDelete** callback is bound, and the value **true** is returned. ->- The **editable** attribute of **** is set to **true**. +>- The list is bound to the **onItemDelete** event and the event returns **true** during event callback. +>- The **editable** attribute of **ListItem** is set to **true**. +>To enable for a list item, the following conditions must be met: +>- **editMode** is set to **true**. +>- The list item is bound to the **onItemDragStart** event and the event returns a floating UI during event callback. + +- ItemDragInfo attributes + + +

    Name

    Description

    +

    Description

    onItemDelete(index: number) => boolean

    +

    onItemDelete(index: number) => boolean

    Triggered when a list item is deleted.

    +

    Triggered when a list item is deleted.

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

    +

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

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

    +

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

    +

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

    +

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

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

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

    +
    +

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

    +

    +

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

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

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

    +
    +

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

    +

    +

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

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

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

    +
    +

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

    +

    +

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

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

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

    +
    +

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

    +

    +

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

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

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

    +
    + + + + + + + + + + + + + +

    Name

    +

    Type

    +

    Description

    +

    x

    +

    number

    +

    X-coordinate of the item that is being dragged.

    +

    y

    +

    number

    +

    Y-coordinate of the item that is being dragged.

    +
    + ## Example @@ -250,3 +306,121 @@ struct ListExample { ![](figures/list.gif) +``` +@Entry +@Component +struct DragListExample { + @State number1: string[] = ['0', '1', '2'] + @State number2: string[] = ['one', 'two', 'three'] + @State text: string = '' + @State bool1: boolean = false + @State bool2: boolean = false + + @Builder pixelMapBuilder() { + Text('-1') + .width('100%').height(100).fontSize(16) + .textAlign(TextAlign.Center).borderRadius(10).backgroundColor(0xFFFFFF) + } + + build() { + Column() { + List() { + ForEach(this.number1, (item) => { + ListItem() { + Text('' + item) + .width('100%').height(100).fontSize(16) + .textAlign(TextAlign.Center).borderRadius(10).backgroundColor(0xF666FF) + } + }, item => item) + } + .editMode(true) + .width('90%').divider({ strokeWidth: 2, color: 0xFFFFFF, startMargin: 20, endMargin: 20 }) + .onItemDelete((index: number) => { + console.info(this.Number1[index] + 'Delete') + this.Number1.splice(index, 1) + console.info(JSON.stringify(this.Number1)) + return true + }) + .onItemDragStart((event: ItemDragInfo, itemIndex: number) => { + this.bool1 = true + this.text = this.number1[itemIndex] + console.log("List1 onItemDragStart, itemIndex:" + itemIndex + ", ItemDragInfo:"+`${JSON.stringify(event)}`) + return this.pixelMapBuilder + }) + .onItemDragEnter((event: ItemDragInfo) => { + console.log("List1 onItemDragEnter") + }) + .onItemDragMove((event: ItemDragInfo, itemIndex: number, insertIndex: number) => { + console.log("List1 onItemDragMove, itemIndex:" + itemIndex + ", insertIndex:" + insertIndex) + }) + .onItemDragLeave((event: ItemDragInfo, itemIndex: number) => { + console.log("List1 onItemDragLeave, itemIndex:" + itemIndex) + }) + .onItemDrop((event: ItemDragInfo, itemIndex: number, insertIndex: number, isSuccess: boolean) => { + if (isSuccess) { + if (this.bool2) { + this.number2.splice(itemIndex, 1) + this.number1.splice(insertIndex, 0, this.text) + this.bool1 = false + this.bool2 = false + } else if (this.bool1) { + this.number1.splice(itemIndex, 1) + this.number1.splice(insertIndex, 0, this.text) + this.bool1 = false + this.bool2 = false + } + } + console.log("List1 onItemDrop, itemIndex:" + itemIndex + ", insertIndex:" + insertIndex + ", isSuccess:" + isSuccess) + }) + Divider().strokeWidth(5).color(0x2788D9).lineCap(LineCapStyle.Round).margin(20) + List() { + ForEach(this.Number2, (item) => { + ListItem() { + Text('' + item) + .width('100%').height(100).fontSize(16) + .textAlign(TextAlign.Center).borderRadius(10).backgroundColor(0xFFF888) + } + }, item => item) + } + .edgeEffect(EdgeEffect.None) + .width('90%') + .editMode(true) + .divider({ strokeWidth: 2, color: 0xFFFFFF, startMargin: 20, endMargin: 20 }) + .onItemDragStart((event: ItemDragInfo, itemIndex: number) => { + this.bool2 = true + this.text = this.number2[itemIndex] + console.log("List2 onItemDragStart, itemIndex:" + itemIndex) + return this.pixelMapBuilder + }) + .onItemDragEnter((event: ItemDragInfo) => { + console.log("List2 onItemDragEnter") + }) + .onItemDragMove((event: ItemDragInfo, itemIndex: number, insertIndex: number) => { + console.log("List2 onItemDragMove, itemIndex:" + itemIndex + ", insertIndex:" + insertIndex) + }) + .onItemDragLeave((event: ItemDragInfo, itemIndex: number) => { + console.log("List2 onItemDragLeave, itemIndex:" + itemIndex) + }) + .onItemDrop((event: ItemDragInfo, itemIndex: number, insertIndex: number, isSuccess: boolean) => { + if (isSuccess) { + if (this.bool1) { + this.number1.splice(itemIndex, 1) + this.number2.splice(insertIndex, 0, this.text) + this.bool1 = false + this.bool2 = false + } else if (this.bool2) { + this.number2.splice(itemIndex, 1) + this.number2.splice(insertIndex, 0, this.text) + this.bool1 = false + this.bool2 = false + } + } + console.log("List2 onItemDrop, itemIndex:" + itemIndex + ", insertIndex:" + insertIndex + ", isSuccess:" + isSuccess) + }) + }.width('100%').height('100%').backgroundColor(0xE600000).padding({ top: 25 }) + } +} +``` + +![](figures/gif-4.gif) + 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 fe496bf9daefc6ede5da40983a130981ed0cf162..e96b60c18f19ce2fb07cde2b64d1790fcb350c1b 100644 --- a/en/application-dev/reference/arkui-ts/ts-container-listitem.md +++ b/en/application-dev/reference/arkui-ts/ts-container-listitem.md @@ -1,4 +1,7 @@ -# ListItem +# ListItem + +>![](../../public_sys-resources/icon-note.gif) **NOTE:** +>This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. The **** component displays specific items in the list. Its width occupies the **** component by default and must be used together with ****. diff --git a/en/application-dev/reference/arkui-ts/ts-container-navigation.md b/en/application-dev/reference/arkui-ts/ts-container-navigation.md new file mode 100644 index 0000000000000000000000000000000000000000..d0b68b8fbfae41d3c239ea93237214a192b4ae1a --- /dev/null +++ b/en/application-dev/reference/arkui-ts/ts-container-navigation.md @@ -0,0 +1,418 @@ +# Navigation + +>![](../../public_sys-resources/icon-note.gif) **NOTE:** +>This component is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version. + +The **** component typically functions as the root container of a page and displays the page title, toolbar, and menu through attribute settings. + +## Required Permissions + +None + +## Child Components + +This component can contain child components. + +## APIs + +Navigation\(\) + +Creates a component that can automatically display the navigation bar, title, and toolbar based on the attribute settings. + +## Attributes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

    Name

    +

    Type

    +

    Default Value

    +

    Description

    +

    title

    +

    string | CustomBuilder

    +

    -

    +

    No title

    +

    subtitle

    +

    string

    +

    -

    +

    Subtitle of the page.

    +

    menus

    +

    Array<NavigationMenuItem> | CustomBuilder

    +

    -

    +

    Menu in the upper right corner of the page.

    +

    +

    titleMode

    +

    NavigationTitleMode

    +

    NavigationTitleMode.Free

    +

    Display mode of the page title bar.

    +

    toolBar

    +

    {

    +

    items:[

    +

    Object

    +

    ] }

    +

    | CustomBuilder

    +

    +

    -

    +

    Content of the toolbar.

    +

    items: all items on the toolbar.

    +

    hideToolBar

    +

    boolean

    +

    false

    +

    Whether the toolbar is shown or hidden.

    +

    true: The toolbar is hidden.

    +

    false: The toolbar is shown.

    +

    hideTitleBar

    +

    boolean

    +

    false

    +

    Whether the title bar is hidden.

    +

    hideBackButton

    +

    boolean

    +

    false

    +

    Whether the back key is hidden.

    +
    + +- NavigationMenuItem parameters + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

    Name

    +

    Type

    +

    Mandatory

    +

    Default Value

    +

    Description

    +

    value

    +

    string

    +

    Yes

    +

    -

    +

    Text of a single option on the menu bar.

    +

    icon

    +

    string

    +

    No

    +

    -

    +

    Icon path of a single option on the menu bar.

    +

    action

    +

    () => void

    +

    No

    +

    -

    +

    Callback invoked when the option is selected.

    +
    + + +- Object attributes + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

    Name

    +

    Type

    +

    Mandatory

    +

    Default Value

    +

    Description

    +

    value

    +

    string

    +

    Yes

    +

    -

    +

    Text of a single option on the toolbar.

    +

    icon

    +

    string

    +

    No

    +

    -

    +

    Icon path of a single option on the toolbar.

    +

    action

    +

    () => void

    +

    No

    +

    -

    +

    Callback invoked when the option is selected.

    +
    + +- NavigationTitleMode enums + + + + + + + + + + + + + + + + +

    Name

    +

    Description

    +

    Free

    +

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

    +

    Mini

    +

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

    +

    Full

    +

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

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

    Name

    +

    Description

    +

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

    +

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

    +
    + +## Example + +``` +/ Example 01 +@Entry +@Component +struct NavigationExample { + private arr: number[] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] + @State hideBar: boolean = true + + @Builder NavigationTitle() { + Column() { + Text('title') + .width(80) + .height(60) + .fontColor(Color.Blue) + .fontSize(30) + } + .onClick(() => { + console.log("title") + }) + } + + @Builder NavigationMenus() { + Row() { + Image('images/add.png') + .width(25) + .height(25) + Image('comment/more.png') + .width(25) + .height(25) + .margin({ left: 30 }) + }.width(100) + } + + build() { + Column() { + Navigation() { + Search({ value: '', placeholder: "" }).width('85%').margin(26) + List({ space: 5, initialIndex: 0 }) { + ForEach(this.arr, (item) => { + ListItem() { + Text('' + item) + .width('90%') + .height(80) + .backgroundColor('#3366CC') + .borderRadius(15) + .fontSize(16) + .textAlign(TextAlign.Center) + }.editable(true) + }, item => item) + } + .listDirection(Axis.Vertical) + .height(300) + .margin({ top: 10, left: 18 }) + .width('100%') + + Button(this.hideBar ? "tool bar" : "hide bar") + .onClick(() => { + this.hideBar = !this.hideBar + }) + .margin({ left: 135, top: 60 }) + } + .title(this.NavigationTitle) + .subTitle('subtitle') + .menus(this.NavigationMenus) + .titleMode(NavigationTitleMode.Free) + .hideTitleBar(false) + .hideBackButton(false) + .onTitleModeChanged((titleModel: NavigationTitleMode) => { + console.log('titleMode') + }) + .toolBar({ items: [ + { value: 'app', icon: 'images/grid.svg', action: () => { + console.log("app") + } }, + { value: 'add', icon: 'images/add.svg', action: () => { + console.log("add") + } }, + { value: 'collect', icon: 'images/collect.svg', action: () => { + console.log("collect") + } }] }) + .hideToolBar(this.hideBar) + } + } +} +``` + +![](figures/66666.gif) + +``` +// Example 02 +@Entry +@Component +struct ToolbarBuilderExample { + @State currentIndex: number = 0 + @State Build: Array = [ + { + icon: $r('app.media.ic_public_add'), + icon_after: $r('app.media.ic_public_addcolor'), + text: 'add', + num: 0 + }, + { + icon: $r('app.media.ic_public_app'), + icon_after: $r('app.media.ic_public_appcolor'), + text: 'app', + num: 1 + }, + { + icon: $r('app.media.ic_public_collect'), + icon_after: $r('app.media.ic_public_collectcolor'), + text: 'collect', + num: 2 + } + ] + + @Builder NavigationToolbar() { + Row() { + ForEach(this.Build, item => { + Column() { + Image(this.currentIndex == item.num ? item.icon_after : item.icon) + .width(25) + .height(25) + Text(item.text) + .fontColor(this.currentIndex == item.num ? "#ff7500" : "#000000") + } + .onClick(() => { + this.currentIndex = item.num + }) + .margin({ left: 70 }) + }) + } + } + + build() { + Column() { + Navigation() { + Flex() { + } + } + .toolBar(this.NavigationToolbar) + } + } +} +``` + +![](figures/duande.gif) + diff --git a/en/application-dev/reference/arkui-ts/ts-container-navigator.md b/en/application-dev/reference/arkui-ts/ts-container-navigator.md index 37711363a1a83fac38d4c498484846a3ea90ea8c..a07cec59e74a380fa348d3236dd7954bf97c7c3b 100644 --- a/en/application-dev/reference/arkui-ts/ts-container-navigator.md +++ b/en/application-dev/reference/arkui-ts/ts-container-navigator.md @@ -1,4 +1,7 @@ -# Navigator +# Navigator + +>![](../../public_sys-resources/icon-note.gif) **NOTE:** +>This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. The **** component provides redirection. diff --git a/en/application-dev/reference/arkui-ts/ts-container-panel.md b/en/application-dev/reference/arkui-ts/ts-container-panel.md index 0fb4cc8f856b33ecc5af3cc09172508f61f3b227..5c32f0a4cbfb18288990478253d37b58bc0a088a 100644 --- a/en/application-dev/reference/arkui-ts/ts-container-panel.md +++ b/en/application-dev/reference/arkui-ts/ts-container-panel.md @@ -1,4 +1,7 @@ -# Panel +# Panel + +>![](../../public_sys-resources/icon-note.gif) **NOTE:** +>This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. The **** component is a slidable panel that presents lightweight content with flexible sizes. It is a pop-up component. diff --git a/en/application-dev/reference/arkui-ts/ts-container-row.md b/en/application-dev/reference/arkui-ts/ts-container-row.md index cb8d022684d28991ea8ea9a197b71c376140b436..e25ea9b861af2897ea301d7e6eb2d6cb5055a639 100644 --- a/en/application-dev/reference/arkui-ts/ts-container-row.md +++ b/en/application-dev/reference/arkui-ts/ts-container-row.md @@ -1,4 +1,7 @@ -# Row +# Row + +>![](../../public_sys-resources/icon-note.gif) **NOTE:** +>This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. The **** component lays out child components horizontally. @@ -12,7 +15,7 @@ This component can contain child components. ## APIs -Row\(options?: \{ space?: Length \}\) +Row\(value:\{space?: Length\}\) - Parameters diff --git a/en/application-dev/reference/arkui-ts/ts-container-rowsplit.md b/en/application-dev/reference/arkui-ts/ts-container-rowsplit.md index 7eb38acadd6c7467406e22f3c87fdadf51e26b39..cae73207d988b6e6d6f6b82ca5b4cdadc5b0679a 100644 --- a/en/application-dev/reference/arkui-ts/ts-container-rowsplit.md +++ b/en/application-dev/reference/arkui-ts/ts-container-rowsplit.md @@ -1,7 +1,14 @@ -# RowSplit +# RowSplit + +>![](../../public_sys-resources/icon-note.gif) **NOTE:** +>This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. The **** lays out child components horizontally and inserts a vertical divider between every two child components. +## Required Permissions + +None + ## Child Components This component can contain child components. diff --git a/en/application-dev/reference/arkui-ts/ts-container-scroll.md b/en/application-dev/reference/arkui-ts/ts-container-scroll.md index 514239cf26b3ae87fd66fb5305a4d71915010fe0..a52e655865b7dd978c866348be8e77073d6b792f 100644 --- a/en/application-dev/reference/arkui-ts/ts-container-scroll.md +++ b/en/application-dev/reference/arkui-ts/ts-container-scroll.md @@ -1,4 +1,7 @@ -# Scroll +# Scroll + +>![](../../public_sys-resources/icon-note.gif) **NOTE:** +>This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. The **** component scrolls the content when the layout size of a component exceeds the viewport of its parent component. @@ -19,9 +22,9 @@ Scroll\(scroller?: Scroller\) - - @@ -29,36 +32,36 @@ Scroll\(scroller?: Scroller\) - - - - - - - - @@ -66,7 +69,7 @@ Scroll\(scroller?: Scroller\)

    Name

    Type

    +

    Type

    Default Value

    +

    Default Value

    Description

    scrollable

    ScrollDirection

    +

    ScrollDirection

    Vertical

    +

    Vertical

    Scroll method.

    scrollBar

    BarState

    +

    BarState

    Auto

    +

    Auto

    Scroll bar status.

    scrollBarColor

    Color

    +

    Color

    -

    +

    -

    Color of the scroll bar.

    scrollBarWidth

    Length

    +

    Length

    -

    +

    -

    Width of the scrollbar.

    -- ScrollDirection enums +- ScrollDirection - + @@ -194,7 +198,8 @@ Scrolls to the edge of the container. - +

    Name

    @@ -98,7 +101,7 @@ Scroll\(scroller?: Scroller\) Controller of the scrollable container component. You can bind this component to the container component and use it to control the scrolling of the container component. Currently, this component can be bound to the **** and **** components. -### Objects to Import +### Creating an Object ``` scroller: Scroller = new Scroller() @@ -156,7 +159,8 @@ Scrolls to the specified position.

    No

      

    -

    +

    Animation configuration, which includes the following:

    • duration: scrolling duration.
    • curve: scrolling curve.

    -

      

    Edge position to scroll to.

    +
    @@ -202,7 +207,9 @@ Scrolls to the edge of the container. ### scroller.scrollPage -scrollPage\(value: \{ next: boolean, direction?: Axis \}\): void +scrollPage\(value: \{ next: boolean \}\): void + +Scrolls to the next or previous page. - Parameters @@ -227,17 +234,7 @@ scrollPage\(value: \{ next: boolean, direction?: Axis \}\): void

    -

    Whether to turn to the next page.

    -

    direction

    -

    Axis

    -

    No

    -
      

    Horizontal or vertical page flipping. If the scrolling direction of the scroll container is determined, this parameter can be omitted.

    +

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

    onScrollEnd() => void

    Invoked when a scrolling stop event occurs.

    +

    Invoked when scrolling stops.

    + + + + + + + + + + + + + + + + + + + + + + + + + +

    Name

    +

    Type

    +

    Mandatory

    +

    Default Value

    +

    Description

    +

    scroller

    +

    Scroller

    +

    Yes

    +

    -

    +

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

    +

    direction

    +

    ScrollBarDirection

    +

    No

    +

    ScrollBarDirection.Vertical

    +

    Scrollbar direction in which scrollable components scroll.

    +

    state

    +

    BarState

    +

    No

    +

    BarState.Auto

    +

    Scroll bar status.

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

    Name

    +

    Description

    +

    Vertical

    +

    Vertical scrollbar.

    +

    Horizontal

    +

    Horizontal scrollbar.

    +
    + +- BarState enums + + + + + + + + + + + + + + + + +

    Name

    +

    Description

    +

    On

    +

    Always displayed.

    +

    Off

    +

    Hidden.

    +

    Auto

    +

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

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

    Phone

    +

    Tablet

    +

    Smart TV

    +

    Wearable

    +

    Yes

    +

    Yes

    +

    No

    +

    No

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

    Name

    +

    Type

    +

    Mandatory

    +

    Default Value

    +

    Description

    +

    index

    +

    number

    +

    No

    +

    0

    +

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

    +
    + + +## Attributes + +None + +## Events + + + + + + + + + + + + + + + + +

    Name

    +

    Description

    +

    onFinish(callback: () => void)

    +

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

    +

    onSkip(callback: () => void)

    +

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

    +

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

    +

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

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

    Phone

    +

    Tablet

    +

    Smart TV

    +

    Wearable

    +

    Yes

    +

    Yes

    +

    No

    +

    No

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

    Name

    +

    Type

    +

    Default Value

    +

    Description

    +

    prevLabel

    +

    string

    +

    -

    +

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

    +

    nextLabel

    +

    string

    +

    -

    +

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

    +

    status

    +

    ItemState

    +

    ItemState.Normal

    +

    Status of the stepper item.

    +
    + +- ItemState enums + + + + + + + + + + + + + + + + + + + +

    Name

    +

    Description

    +

    Normal

    +

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

    +

    Disabled

    +

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

    +

    Waiting

    +

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

    +

    Skip

    +

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

    +
    + + +## Example + +See [Stepper](ts-container-stepper.md). diff --git a/en/application-dev/reference/arkui-ts/ts-container-swiper.md b/en/application-dev/reference/arkui-ts/ts-container-swiper.md index 3f16f010ee5c5e8c18501ed12d01056bfb998c82..fea72e9b71f19f6ccf857016ecbe98d5a9c2a9d7 100644 --- a/en/application-dev/reference/arkui-ts/ts-container-swiper.md +++ b/en/application-dev/reference/arkui-ts/ts-container-swiper.md @@ -1,4 +1,7 @@ -# Swiper +# Swiper + +>![](../../public_sys-resources/icon-note.gif) **NOTE:** +>This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. The **** component provides a container that allows users to switch among child components by swiping operations. @@ -47,9 +50,9 @@ Swiper\(value:\{controller?: SwiperController\}\) ## Attributes -

    Name

    + - @@ -57,78 +60,96 @@ Swiper\(value:\{controller?: SwiperController\}\) - - - - - - - - - - - - - - - - + + + + + + + + + +

    Name

    Type

    +

    Type

    Default Value

    index

    +

    index

    number

    +

    number

    0

    Index of the child component currently displayed in the container.

    autoPlay

    +

    autoPlay

    boolean

    +

    boolean

    false

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

    interval

    +

    interval

    number

    +

    number

    3000

    Interval for automatic playback, in ms.

    indicator

    +

    indicator

    boolean

    +

    boolean

    true

    Whether to enable the navigation dots.

    loop

    +

    loop

    boolean

    +

    boolean

    true

    Whether to enable loop playback.

    duration

    +

    duration

    number

    +

    number

    400

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

    vertical

    +

    vertical

    boolean

    +

    boolean

    false

    Whether vertical swiping is used.

    itemSpace

    +

    itemSpace

    Length

    +

    Length

    0

    Space between child components.

    cachedCount8+

    +

    number

    +

    1

    +

    Number of child components to be cached.

    +

    disableSwipe8+

    +

    boolean

    +

    false

    +

    Whether to disable the swipe feature.

    +
    @@ -176,20 +197,52 @@ Controller of the **** component. You can bind this object to the ** ## Example ``` +class MyDataSource implements IDataSource { + private list: number[] = [] + private listener: DataChangeListener + + constructor(list: number[]) { + this.list = list + } + + totalCount(): number { + return this.list.length + } + + getData(index: number): any { + return this.list[index] + } + + registerDataChangeListener(listener: DataChangeListener): void { + this.listener = listener + } + + unregisterDataChangeListener() { + } +} + @Entry @Component struct SwiperExample { private swiperController: SwiperController = new SwiperController() + private data: MyDataSource = new MyDataSource([]) + + private aboutToAppear(): void { + let list = [] + for (var i = 1; i <= 10; i++) { + list.push(i.toString()); + } + this.data = new MyDataSource(list) + } build() { Column({ space: 5 }) { Swiper(this.swiperController) { - Text('1').width('90%').height(160).backgroundColor(0xAFEEEE).textAlign(TextAlign.Center).fontSize(20) - Text('2').width('90%').height(160).backgroundColor(0xAFEEEE).textAlign(TextAlign.Center).fontSize(20) - Text('3').width('90%').height(160).backgroundColor(0xAFEEEE).textAlign(TextAlign.Center).fontSize(20) - Text('4').width('90%').height(160).backgroundColor(0xAFEEEE).textAlign(TextAlign.Center).fontSize(20) - Text('5').width('90%').height(160).backgroundColor(0xAFEEEE).textAlign(TextAlign.Center).fontSize(20) + LazyForEach(this.data, (item: string) => { + Text(item).width('90%').height(160).backgroundColor(0xAFEEEE).textAlign(TextAlign.Center).fontSize(20) + }, item => item) } + .cachedCount(2) .index(1) .autoPlay(true) .interval(4000) diff --git a/en/application-dev/reference/arkui-ts/ts-container-tabcontent.md b/en/application-dev/reference/arkui-ts/ts-container-tabcontent.md index b5594d313ab3123ba2e449806a6184ffb3f6b8dc..0d18789c72139ba1d65d2ffe2a7aab970d188168 100644 --- a/en/application-dev/reference/arkui-ts/ts-container-tabcontent.md +++ b/en/application-dev/reference/arkui-ts/ts-container-tabcontent.md @@ -1,4 +1,7 @@ -# TabContent +# TabContent + +>![](../../public_sys-resources/icon-note.gif) **NOTE:** +>This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. The **** component is used only in the **** component. It corresponds to the content view of a switched tab page. @@ -16,6 +19,8 @@ TabContent\(\) ## Attributes +Touch target configuration is not supported. + @@ -32,11 +37,13 @@ TabContent\(\) @@ -50,5 +57,123 @@ TabContent\(\) ## Example -See [Tabs](ts-container-tabs.md#section1131255321814). +``` +@Entry +@Component +struct TabContentExample { + @State fontColor: string = 'rgba(0, 0, 0, 0.4)' + @State selectedFontColor: string = 'rgba(10, 30, 255, 1)' + @State currentIndex: number = 0 + private controller: TabsController = new TabsController() + @Builder Tab1Builder() { + Column() { + Image(this.currentIndex === 0 ? '/resources/ic_public_contacts_filled_selected.png' : '/resources/ic_public_contacts_filled.png') + .width(24) + .height(24) + .opacity(this.currentIndex === 0 ? 1 : 0.4) + .objectFit(ImageFit.Contain) + Text("Tab1") + .fontColor(this.currentIndex === 0 ? this.selectedFontColor : this.fontColor) + .fontSize(10) + .margin({top: 2}) + } + } + + @Builder Tab2Builder() { + Column() { + Image(this.currentIndex === 1 ? '/resources/ic_public_contacts_filled_selected.png' : '/resources/ic_public_contacts_filled.png') + .width(24) + .height(24) + .opacity(this.currentIndex === 1 ? 1 : 0.4) + .objectFit(ImageFit.Contain) + Text("Tab2") + .fontColor(this.currentIndex === 1 ? this.selectedFontColor : this.fontColor) + .fontSize(10) + .margin({top: 2}) + } + } + + @Builder Tab3Builder() { + Column() { + Image(this.currentIndex === 3 ? '/resources/ic_public_contacts_filled_selected.png' : '/resources/ic_public_contacts_filled.png') + .width(24) + .height(24) + .opacity(this.currentIndex === 3 ? 1 : 0.4) + .objectFit(ImageFit.Contain) + Text("Tab3") + .fontColor(this.currentIndex === 3 ? this.selectedFontColor : this.fontColor) + .fontSize(10) + .margin({top: 2}) + } + } + + @Builder Tab4Builder() { + Column() { + Image(this.currentIndex === 4 ? '/resources/ic_public_contacts_filled_selected.png' : '/resources/ic_public_contacts_filled.png') + .width(24) + .height(24) + .opacity(this.currentIndex === 4 ? 1 : 0.4) + .objectFit(ImageFit.Contain) + Text("Tab4") + .fontColor(this.currentIndex === 4 ? this.selectedFontColor : this.fontColor) + .fontSize(10) + .margin({top: 2}) + } + } + + @Builder AddBuilder() { + Column() { + Image(this.currentIndex === 2 ? '/resources/ic_public_add_norm_filled_selected.png' : '/resources/ic_public_add_norm_filled.png') + .width(this.currentIndex === 2 ? 26 : 24) + .height(this.currentIndex === 2 ? 26 : 24) + .opacity(this.currentIndex === 2 ? 1 : 0.4) + .objectFit(ImageFit.Contain) + .animation({duration: 200}) + } + } + + build() { + Column() { + Tabs({ barPosition: BarPosition.End, index: 0, controller: this.controller }) { + TabContent() { + Flex({justifyContent: FlexAlign.Center})) { + Text('Tab1').fontSize(32) + } + }.tabBar(this.Tab1Builder) + + TabContent() { + Flex({justifyContent: FlexAlign.Center})) { + Text('Tab2').fontSize(32) + } + }.tabBar(this.Tab2Builder) + + TabContent() { + Flex({justifyContent: FlexAlign.Center})) { + Text('Add').fontSize(32) + } + }.tabBar(this.AddBuilder) + + TabContent() { + Flex({justifyContent: FlexAlign.Center})) { + Text('Tab3').fontSize(32) + } + }.tabBar(this.Tab3Builder) + + TabContent() { + Flex({justifyContent: FlexAlign.Center})) { + Text('Tab4').fontSize(32) + } + }.tabBar(this.Tab4Builder) + } + .vertical(false) + .barWidth(300).barHeight(56) + .onChange((index: number) => { + this.currentIndex = index + }) + .width('90%').backgroundColor('rgba(241, 243, 245, 0.95)') + }.width('100%').height(200).margin({ top: 5 }) + } +} +``` +![](figures/en-us_image_0000001193075122.gif) diff --git a/en/application-dev/reference/arkui-ts/ts-container-tabs.md b/en/application-dev/reference/arkui-ts/ts-container-tabs.md index 450b6211d55f9e0914a1ac31219222b0dc9392c4..e6c394df300683312e582d6d63acf20d9263ace6 100644 --- a/en/application-dev/reference/arkui-ts/ts-container-tabs.md +++ b/en/application-dev/reference/arkui-ts/ts-container-tabs.md @@ -1,4 +1,7 @@ -# Tabs +# Tabs + +>![](../../public_sys-resources/icon-note.gif) **NOTE:** +>This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. The **** component is a container component that allows users to switch between content views through tabs. Each tab page corresponds to a content view. @@ -133,6 +136,8 @@ Defines a tab controller, which is used to control switching of tabs. ## Attributes +Touch target configuration is not supported. +

    Name

    string | {

    icon?: string,

    text?: string

    -

    }

    +

    }

    +

    | CustomBuilder8+

    -

    Content displayed on the tab bar.

    +

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

    NOTE:

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

    diff --git a/en/application-dev/reference/arkui-ts/ts-declarative-syntax.md b/en/application-dev/reference/arkui-ts/ts-declarative-syntax.md deleted file mode 100644 index 65f722e1edadbc670d1f6ef42330f1587714656c..0000000000000000000000000000000000000000 --- a/en/application-dev/reference/arkui-ts/ts-declarative-syntax.md +++ /dev/null @@ -1,15 +0,0 @@ -# Declarative Syntax - -- **[Overview](ts-syntax-intro.md)** - -- **[General UI Description Specifications](ts-general-ui-description-specifications.md)** - -- **[UI State Management](ts-ui-state-management.md)** - -- **[Rendering Control Syntax](ts-rending-control-syntax.md)** - -- **[A Deep Dive into @Component](ts-a-deep-dive-into-component.md)** - -- **[Syntactic Sugar](ts-syntactic-sugar.md)** - - diff --git a/en/application-dev/reference/arkui-ts/ts-declarative.md b/en/application-dev/reference/arkui-ts/ts-declarative.md deleted file mode 100644 index 0b6692ce02417e12633229e6f0e20fdd026a580b..0000000000000000000000000000000000000000 --- a/en/application-dev/reference/arkui-ts/ts-declarative.md +++ /dev/null @@ -1,15 +0,0 @@ -# TypeScript-based Declarative Development Paradigm - -- **[Framework Overview](ts-framework-framework.md)** - -- **[Declarative Syntax](ts-declarative-syntax.md)** - -- **[Components](ts-components.md)** - -- **[Animation](ts-animation.md)** - -- **[Global UI Methods](ts-global-ui-methods.md)** - -- **[Appendix](ts-appendix.md)** - - 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 aea3b4fddd5a3bea925af852a04237756f85c8b8..787ebf3396fa7e90eb19ae277d9cbe2649cd0c35 100644 --- a/en/application-dev/reference/arkui-ts/ts-drawing-components-circle.md +++ b/en/application-dev/reference/arkui-ts/ts-drawing-components-circle.md @@ -1,7 +1,14 @@ -# Circle +# Circle + +>![](../../public_sys-resources/icon-note.gif) **NOTE:** +>This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. The **** component is used to draw a circle. +## Required Permissions + +None + ## Child Components None 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 c5f2d174752f660e81199acc49ba9650550912e0..d36939e06bb7df2bdaf1de30e5f56dad58854707 100644 --- a/en/application-dev/reference/arkui-ts/ts-drawing-components-ellipse.md +++ b/en/application-dev/reference/arkui-ts/ts-drawing-components-ellipse.md @@ -1,14 +1,21 @@ -# Ellipse +# Ellipse + +>![](../../public_sys-resources/icon-note.gif) **NOTE:** +>This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. The **** component is used to draw an ellipse. +## Required Permissions + +None + ## Child Components None ## APIs -ellipse\(options?: \{width: Length, height: Length\}\) +ellipse\(options?: \{width: Lenght, height: Length\}\) - Parameters @@ -137,5 +144,5 @@ struct EllipseExample { } ``` -![](figures/ellipse-63.png) +![](figures/ellipse.png) diff --git a/en/application-dev/reference/arkui-ts/ts-drawing-components-line.md b/en/application-dev/reference/arkui-ts/ts-drawing-components-line.md index 03fae2dad61dced71ac488f8fe77bc44b39de2ca..00cb05366364d11d4205c94a97f2892c02b73f79 100644 --- a/en/application-dev/reference/arkui-ts/ts-drawing-components-line.md +++ b/en/application-dev/reference/arkui-ts/ts-drawing-components-line.md @@ -1,14 +1,21 @@ -# Line +# Line + +>![](../../public_sys-resources/icon-note.gif) **NOTE:** +>This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. The **** component is used to draw a straight line. +## Required Permissions + +None + ## Child Components None ## APIs -Line\(options?: \{width: Length, height: Length\}\) +Line\(options?: \{width: Lenght, height: Length\}\) - Parameters 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 cb4c399e35cab476c14ab3dc3b6e8b5181293d39..3642fd8e7671af6638975d85536c7070cfc824d9 100644 --- a/en/application-dev/reference/arkui-ts/ts-drawing-components-path.md +++ b/en/application-dev/reference/arkui-ts/ts-drawing-components-path.md @@ -1,7 +1,14 @@ -# Path +# Path + +>![](../../public_sys-resources/icon-note.gif) **NOTE:** +>This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. The **** component is used to draw a path. +## Required Permissions + +None + ## Child Components None 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 d7a5b0cd53a8bf5eaf304b8ed6e17ec0ecb1b0ef..c1eec93f59e1b14d8e61df5e377211b2327a778d 100644 --- a/en/application-dev/reference/arkui-ts/ts-drawing-components-polygon.md +++ b/en/application-dev/reference/arkui-ts/ts-drawing-components-polygon.md @@ -1,14 +1,21 @@ -# Polygon +# Polygon + +>![](../../public_sys-resources/icon-note.gif) **NOTE:** +>This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. The **** component is used to draw a polygon. +## Required Permissions + +None + ## Child Components None ## APIs -Polygon\(value:\{options?: \{width: Length, height: Length\}\}\) +Polygon\(value:\{options?: \{width: Lenght, height: Length\}\}\) - Parameters 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 1f0a60df04624328888b1f14693f1132c5fdaadf..d09da452bc117cb8041936f6c0d43278566a8155 100644 --- a/en/application-dev/reference/arkui-ts/ts-drawing-components-polyline.md +++ b/en/application-dev/reference/arkui-ts/ts-drawing-components-polyline.md @@ -1,14 +1,21 @@ -# Polyline +# Polyline + +>![](../../public_sys-resources/icon-note.gif) **NOTE:** +>This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. The **** component is used to draw a polyline. +## Required Permissions + +None + ## Child Components None ## APIs -Polyline\(options?: \{width: Length, height: Length\}\) +Polyline\(options?: \{width: Lenght, height: Length\}\) - Parameters 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 64aee72ab59f9b8a72fa3d57ffc2b58dcaec5eb1..7a85738af04b856668d48b98baf6be2443378e92 100644 --- a/en/application-dev/reference/arkui-ts/ts-drawing-components-rect.md +++ b/en/application-dev/reference/arkui-ts/ts-drawing-components-rect.md @@ -1,7 +1,14 @@ -# Rect +# Rect + +>![](../../public_sys-resources/icon-note.gif) **NOTE:** +>This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. The **** component is used to draw a rectangle. +## Required Permissions + +None + ## Child Components None 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 a9de31541ab38c3be44d6ffac6a621066e27ef61..18ac993b3063e380357782c72ffceb34d41eceff 100644 --- a/en/application-dev/reference/arkui-ts/ts-drawing-components-shape.md +++ b/en/application-dev/reference/arkui-ts/ts-drawing-components-shape.md @@ -1,4 +1,7 @@ -# Shape +# Shape + +>![](../../public_sys-resources/icon-note.gif) **NOTE:** +>This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. The **** component is the parent component of the drawing components. The attributes described in this topic are universal attributes supported by all the drawing components. @@ -6,13 +9,17 @@ The **** component is the parent component of the drawing components. 2. The **** component is used independently to draw a specific shape. +## Required Permissions + +None + ## Child Components The **** component can contain child components. ## APIs -Shape\(target?: PixelMap\) +Shape\(value:\{target?: PixelMap\}\) - Parameters @@ -224,7 +231,7 @@ Shape\(target?: PixelMap\) struct ShapeExample { build() { Column({ space: 5 }) { - Text('basic').fontSize(9).fontColor(0xCCCCCC).width(320) + Text('basic').fontSize(30).fontColor(0xCCCCCC).width(320) // Draw a 300 x 50 rectangle with strokes at (-2, -2). The fill color is 0x317Af7, the stroke color is black, the stroke width is 4, the stroke dash is 20, the offset is 10 to the left, the cap style is rounded, the join style is rounded, and anti-aliasing is enabled (default). // Draw a 300 x 50 ellipse with strokes at (-2, 58). The fill color is 0x317Af7, the stroke color is black, the stroke width is 4, the stroke dash is 20, the offset is 10 to the left, the cap style is rounded, the join style is rounded, and anti-aliasing is enabled (default). // Draw a 300 x 10 path at (-2, 118). The fill color is 0x317Af7, the stroke color is black, the stroke width is 4, the stroke dash is 20, the offset is 10 to the left, the cap style is rounded, and the join style is rounded, and anti-aliasing is enabled (default). @@ -233,7 +240,7 @@ struct ShapeExample { Ellipse().width(300).height(50).offset({ x: 0, y: 60 }) Path().width(300).height(10).commands('M0 0 L900 0').offset({ x: 0, y: 120 }) } - .viewPort({ x: -2, y: -2, width: 304, height: 124 }) + .viewPort({ x: -2, y: -2, width: 304, height: 130 }) .fill(0x317Af7).stroke(Color.Black).strokeWidth(4) .strokeDashArray([20]).strokeDashOffset(10).strokeLineCap(LineCapStyle.Round) .strokeLineJoin(LineJoinStyle.Round).antiAlias(true) @@ -242,32 +249,32 @@ struct ShapeExample { Rect().width(300).height(50) }.viewPort({ x: -1, y: -1, width: 302, height: 52 }).fill(0x317Af7).stroke(Color.Black).strokeWidth(2) - Text('border').fontSize(9).fontColor(0xCCCCCC).width(320) + Text('border').fontSize(30).fontColor(0xCCCCCC).width(320).margin({top:30}) // Draw a 300 x 10 path at (0, -5). The color is 0xEE8443, the stroke width is 10, and the stroke gap is 20. Shape() { Path().width(300).height(10).commands('M0 0 L900 0') - }.viewPort({ x: 0, y: -5, width: 300, height: 10 }).stroke(0xEE8443).strokeWidth(10).strokeDashArray([20]) + }.viewPort({ x: 0, y: -5, width: 300, height: 20 }).stroke(0xEE8443).strokeWidth(10).strokeDashArray([20]) // Draw a 300 x 10 path at (0, -5). The fill color is 0xEE8443, the stroke width is 10, the stroke gap is 20, and the offset is 10 to the left. Shape() { Path().width(300).height(10).commands('M0 0 L900 0') } - .viewPort({ x: 0, y: -5, width: 300, height: 10 }) + .viewPort({ x: 0, y: -5, width: 300, height: 20 }) .stroke(0xEE8443).strokeWidth(10).strokeDashArray([20]).strokeDashOffset(10) // Draw a 300 x 10 path at (0, -5). The fill color is 0xEE8443, the stroke width is 10, and the stroke opacity is 0.5. Shape() { Path().width(300).height(10).commands('M0 0 L900 0') - }.viewPort({ x: 0, y: -5, width: 300, height: 10 }).stroke(0xEE8443).strokeWidth(10).strokeOpacity(0.5) + }.viewPort({ x: 0, y: -5, width: 300, height: 20 }).stroke(0xEE8443).strokeWidth(10).strokeOpacity(0.5) // Draw a 300 x 10 path at (0, -5). The fill color is 0xEE8443, the stroke width is 10, the stroke dash is 20, the offset is 10 to the left, and the cap style is rounded. Shape() { Path().width(300).height(10).commands('M0 0 L900 0') } - .viewPort({ x: 0, y: -5, width: 300, height: 10 }) + .viewPort({ x: 0, y: -5, width: 300, height: 20 }) .stroke(0xEE8443).strokeWidth(10).strokeDashArray([20]).strokeLineCap(LineCapStyle.Round) // Draw a 300 x 50 rectangle with strokes at (-5, -5). The fill color is 0x317Af7, the stroke width is 10, the stroke color is 0xEE8443, and the join style is rounded. Shape() { - Rect().width(300).height(50) + Rect().width(300).height(100) } - .viewPort({ x: -5, y: -5, width: 310, height: 60 }) + .viewPort({ x: -5, y: -5, width: 310, height: 120 }) .fill(0x317Af7).stroke(0xEE8443).strokeWidth(10).strokeLineJoin(LineJoinStyle.Round) Shape() { Path().width(300).height(60).commands('M0 0 L400 0 L400 200 Z') @@ -280,5 +287,5 @@ struct ShapeExample { } ``` -![](figures/shape.gif) +![](figures/2-01.png) diff --git a/en/application-dev/reference/arkui-ts/ts-drawing-components.md b/en/application-dev/reference/arkui-ts/ts-drawing-components.md index 4a02c72060975db39b2142f84b7c95d0901cad87..1f1eeac321fc01c4e0024b115b97584fc6dc1c39 100644 --- a/en/application-dev/reference/arkui-ts/ts-drawing-components.md +++ b/en/application-dev/reference/arkui-ts/ts-drawing-components.md @@ -1,4 +1,4 @@ -# Drawing Components +# Drawing Components - **[Circle](ts-drawing-components-circle.md)** 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 9b93c9cffd76ac518ab281a3f50671c68cb6592d..af5ab03d553bae49373b8c023c8d25855ff31da8 100644 --- a/en/application-dev/reference/arkui-ts/ts-explicit-animation.md +++ b/en/application-dev/reference/arkui-ts/ts-explicit-animation.md @@ -1,4 +1,7 @@ -# Explicit Animation +# Explicit Animation + +>![](../../public_sys-resources/icon-note.gif) **NOTE:** +>This animation is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version.

    Name

    @@ -149,68 +158,26 @@ The component uses the **gesture** method to bind the gesture object and uses - GestureEvent attributes -

    Name

    diff --git a/en/application-dev/reference/arkui-ts/ts-gesture-processing.md b/en/application-dev/reference/arkui-ts/ts-gesture-processing.md index 2e9679997a14217c8c9cd6e866a06f5eac29f6a9..cd8880a63e51c155ee5a9f4b3945fa843d127cd1 100644 --- a/en/application-dev/reference/arkui-ts/ts-gesture-processing.md +++ b/en/application-dev/reference/arkui-ts/ts-gesture-processing.md @@ -1,4 +1,4 @@ -# Gesture Processing +# Gesture Processing - **[Gesture Binding Methods](ts-gesture-settings.md)** 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 8e932fa5193c87c8057c0a114fa0f519a8e3022d..40503a4845c5fbbf44d9017ae8d58489e1a7c90f 100644 --- a/en/application-dev/reference/arkui-ts/ts-gesture-settings.md +++ b/en/application-dev/reference/arkui-ts/ts-gesture-settings.md @@ -1,4 +1,13 @@ -# Gesture Binding Methods +# Gesture Binding Methods + +>![](../../public_sys-resources/icon-note.gif) **NOTE:** +>The APIs of this module are supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. + +## Required Permissions + +None + +## Binding Gesture Recognition You can use the following attributes to bind gesture recognition to a component. When a gesture is recognized, the event callback is invoked to notify the component. @@ -73,7 +82,7 @@ You can use the following attributes to bind gesture recognition to a component.

    IgnoreInternal

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

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

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

    Name

    + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -226,22 +193,28 @@ struct GestureSettingsExample { @State value: string = '' build() { - Column() { - Text('Click\n' + this.value).gesture(TapGesture() - .onAction(() => { - this.value = 'gesture onAction' - })) - }.height(200).width(300).padding(60).border({ width: 1 }).margin(30) + Column(){ + Column() { + Text('Click\n' + this.value) + .gesture( + TapGesture() + .onAction(() => { + this.value = 'gesture onAction' + })) + }.height(200).width(300).padding(60).border({ width: 1 }) // When priorityGesture is specified, the bound gesture is preferentially recognized and the child component gesture is ignored. - .priorityGesture( + .priorityGesture( TapGesture() - .onAction(() => { - this.value = 'priorityGesture onAction' + .onAction((event: GestureEvent) => { +this.value = 'priorityGesture onAction' + '\ncomponent globalPos: (' + + event.target.area.globalPos.x + ',' + event.target.area.globalPos.y + ')\nwidth:' + + event.target.area.width + '\nheight:' + event.target.area.height }), GestureMask.IgnoreInternal - ) + ) + }.padding(60) } } ``` -![](figures/gesturesetting.gif) +![](figures/en-us_image_0000001237475107.gif) diff --git a/en/application-dev/reference/arkui-ts/ts-global-ui-methods.md b/en/application-dev/reference/arkui-ts/ts-global-ui-methods.md index 6233ee97a0d00606d17e12c43f9b0c210b9fb75e..7bcfd801bfc0c25f3298744af98ea48c9b8f08cb 100644 --- a/en/application-dev/reference/arkui-ts/ts-global-ui-methods.md +++ b/en/application-dev/reference/arkui-ts/ts-global-ui-methods.md @@ -1,4 +1,4 @@ -# Global UI Methods +# Global UI Methods - **[Alert Dialog Box](ts-methods-alert-dialog-box.md)** @@ -8,4 +8,6 @@ - **[Media Query](ts-methods-media-query.md)** +- **[List Selection Dialog Box](ts-methods-custom-actionsheet.md)** + diff --git a/en/application-dev/reference/arkui-ts/ts-interpolation-calculation.md b/en/application-dev/reference/arkui-ts/ts-interpolation-calculation.md index 840b6fb7820817d3ecc60e6ec6e043b951958c2a..c4e369acb641c891c4440217e55aedfd6909f0c7 100644 --- a/en/application-dev/reference/arkui-ts/ts-interpolation-calculation.md +++ b/en/application-dev/reference/arkui-ts/ts-interpolation-calculation.md @@ -1,4 +1,7 @@ -# Interpolation Calculation +# Interpolation Calculation + +>![](../../public_sys-resources/icon-note.gif) **NOTE:** +>This animation is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. ## Modules to Import @@ -292,5 +295,5 @@ struct ImageComponent { } ``` -![](figures/5-65.gif) +![](figures/5.gif) diff --git a/en/application-dev/reference/arkui-ts/ts-matrix-transformation.md b/en/application-dev/reference/arkui-ts/ts-matrix-transformation.md index dc0a6f47877cf3b7acc396c4a0a4cccf895bd430..77a42705ada3f14e5643a702156db3fb87afa7a2 100644 --- a/en/application-dev/reference/arkui-ts/ts-matrix-transformation.md +++ b/en/application-dev/reference/arkui-ts/ts-matrix-transformation.md @@ -1,4 +1,7 @@ -# Matrix Transformation +# Matrix Transformation + +>![](../../public_sys-resources/icon-note.gif) **NOTE:** +>This animation is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. ## Modules to Import @@ -775,7 +778,7 @@ Matrix rotation function, which is used to add the rotation effect to the x, y, } ``` - ![](figures/1-64.png) + ![](figures/1.png) ### transformPoint 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 ba0d1786b4d2b65b715ec02ce80bcb4e052e4b4f..b5ce18d87c65bd9e182c7e127cfce6b653778d9a 100644 --- a/en/application-dev/reference/arkui-ts/ts-methods-alert-dialog-box.md +++ b/en/application-dev/reference/arkui-ts/ts-methods-alert-dialog-box.md @@ -1,4 +1,7 @@ -# Alert Dialog Box +# Alert Dialog Box + +>![](../../public_sys-resources/icon-note.gif) **NOTE:** +>This method is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. You can set the text content and response callback for an alert dialog box. @@ -30,110 +33,110 @@ You can set the text content and response callback for an alert dialog box. - paramObject1 parameters -

    Name

    Type

    +

    Type

    Description

    repeat

    -

    boolean

    -

    Whether an event is repeatedly triggered. This attribute is used for the long press gesture.

    -

    offsetX

    -

    number

    -

    Gesture event offset along the x-axis, in vp. This attribute is used for the pan gesture.

    -

    offsetY

    -

    number

    -

    Gesture event offset along the y-axis, in vp. This attribute is used for the pan gesture.

    -

    scale

    -

    number

    -

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

    -

    pinchCenterX

    -

    number

    +

    timestamp

    X-coordinate of the center point of the pinch gesture, in px. This attribute is used for the pinch gesture.

    -

    pinchCenterY

    +

    number

    number

    -

    Y-coordinate of the center point of the pinch gesture, in px. This attribute is used for the pinch gesture.

    -

    angle

    -

    number

    -

    Rotation angle. This attribute is used for the rotation gesture.

    +

    Timestamp of the event.

    timestamp

    +

    target8+

    number

    +

    EventTarget

    Timestamp of the event.

    +

    Object that triggers the gesture event.

    - diff --git a/en/application-dev/reference/arkui-ts/ts-methods-image-cache.md b/en/application-dev/reference/arkui-ts/ts-methods-image-cache.md index f9d698bf1d4224ee26afd8248218f6f578aa6a41..3075ad66711d30b7768ee95bf8d1357f6e45dbb4 100644 --- a/en/application-dev/reference/arkui-ts/ts-methods-image-cache.md +++ b/en/application-dev/reference/arkui-ts/ts-methods-image-cache.md @@ -1,4 +1,7 @@ -# Image Cache +# Image Cache + +>![](../../public_sys-resources/icon-note.gif) **NOTE:** +>This method is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. ## Modules to Import @@ -46,7 +49,6 @@ Sets the maximum number of decoded images that can be cached in the memory to sp ``` // app.ets import app from '@system.app'; - export default { onCreate() { app.setImageCacheCount(100) // Set the maximum number of decoded images that can be cached in the memory to 100. diff --git a/en/application-dev/reference/arkui-ts/ts-methods-media-query.md b/en/application-dev/reference/arkui-ts/ts-methods-media-query.md index d46cb26c2f6c4b70aa90b6d9df1ec157d7cd6f9d..8437e78f0b688355c630b49033b42ceee5d390e0 100644 --- a/en/application-dev/reference/arkui-ts/ts-methods-media-query.md +++ b/en/application-dev/reference/arkui-ts/ts-methods-media-query.md @@ -1,4 +1,7 @@ -# Media Query +# Media Query + +>![](../../public_sys-resources/icon-note.gif) **NOTE:** +>This method is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. ## Modules to Import @@ -130,7 +133,7 @@ Registers a callback with the corresponding query condition by using the handle. - diff --git a/en/application-dev/reference/arkui-ts/ts-motion-path-animation.md b/en/application-dev/reference/arkui-ts/ts-motion-path-animation.md index c555f30713cd69efb5620d89c22d4dd372c9a82d..56719de12b1bc36a1ebaf620d57898336dae0618 100644 --- a/en/application-dev/reference/arkui-ts/ts-motion-path-animation.md +++ b/en/application-dev/reference/arkui-ts/ts-motion-path-animation.md @@ -1,4 +1,7 @@ -# Motion Path Animation +# Motion Path Animation + +>![](../../public_sys-resources/icon-note.gif) **NOTE:** +>This animation is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. The attributes described in this topic are used to set the motion path of the component in a translation animation. diff --git a/en/application-dev/reference/arkui-ts/ts-offscreencanvasrenderingcontext2d.md b/en/application-dev/reference/arkui-ts/ts-offscreencanvasrenderingcontext2d.md new file mode 100644 index 0000000000000000000000000000000000000000..4c985bdfc4751bc968a55bed01ad6474d0d6119e --- /dev/null +++ b/en/application-dev/reference/arkui-ts/ts-offscreencanvasrenderingcontext2d.md @@ -0,0 +1,3905 @@ +# OffscreenCanvasRenderingConxt2D + +>![](../../public_sys-resources/icon-note.gif) **NOTE:** +>This component is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version. + +Use **OffscreenCanvasRenderingContext2D** to draw rectangles, images, and text offscreen onto a canvas. Drawing offscreen onto a canvas is a process where content to draw onto the canvas is first drawn in the buffer, and then converted into a picture, and finally the picture is drawn on the canvas. This process increases the drawing efficiency. + +## APIs + +OffscreenCanvasRenderingContext2D\(width: number, height: number, setting: RenderingContextSettings\) + +- Parameters + + +

    Name

    + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/en/application-dev/reference/arkui-ts/ts-methods-custom-actionsheet.md b/en/application-dev/reference/arkui-ts/ts-methods-custom-actionsheet.md new file mode 100644 index 0000000000000000000000000000000000000000..cce4ea2419a5062a6139d714c5e7c74e8f606bf0 --- /dev/null +++ b/en/application-dev/reference/arkui-ts/ts-methods-custom-actionsheet.md @@ -0,0 +1,235 @@ +# List Selection Dialog Box + +>![](../../public_sys-resources/icon-note.gif) **NOTE:** +>This component is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version. + +List pop-up window. + +## Required Permissions + +None + +## ActionSheet.show + +show\(options: \{ [paramObject1](#table816913216616)\}\) + +Defines and shows the list popup window. + +- paramObject1 parameters + + +

    Name

    Type

    +

    Type

    Mandatory

    +

    Mandatory

    Default Value

    +

    Default Value

    Description

    title

    +

    title

    string | Resource

    +

    string | Resource

    No

    +

    No

    -

    +

    -

    Title of a dialog box.

    message

    +

    message

    string | Resource

    +

    string | Resource

    Yes

    +

    Yes

    -

    +

    -

    Content of the dialog box.

    autoCancel

    +

    autoCancel

    boolean

    +

    boolean

    No

    +

    No

    true

    +

    true

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

    confirm

    +

    confirm

    {

    +

    {

    value: string | Resource,

    fontColor?: Color | number | string | Resource,

    backgroundColor?: Color | number | string | Resource,

    action: () => void

    }

    No

    +

    No

    -

    +

    -

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

    cancel

    +

    cancel

    () => void

    +

    () => void

    No

    +

    No

    -

    +

    -

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

    alignment

    +

    alignment

    DialogAlignment

    +

    DialogAlignment

    No

    +

    No

    DialogAlignment.Default

    +

    DialogAlignment.Default

    Alignment mode of the dialog box in the vertical direction.

    offset

    +

    offset

    {

    +

    {

    dx: Length | Resource,

    dy: Length | Resource

    }

    No

    +

    No

    -

    +

    -

    Offset of the dialog box relative to the alignment position.

    gridCount

    +

    gridCount

    number

    +

    number

    No

    +

    No

    -

    +

    -

    Number of grid columns occupied by the width of the dialog box.

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

    Name

    +

    Type

    +

    Mandatory

    +

    Default Value

    +

    Description

    +

    title

    +

    string

    +

    No

    +

    None

    +

    Title of the dialog box.

    +

    message

    +

    string

    +

    Yes

    +

    -

    +

    Content of the dialog box.

    +

    autoCancel

    +

    boolean

    +

    No

    +

    true

    +

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

    +

    confirm

    +

    {

    +

    value: string,

    +

    action: () => void

    +

    }

    +

    No

    +

    -

    +

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

    +

    value: button text.

    +

    action: callback upon button clicking.

    +

    cancel

    +

    () => void

    +

    No

    +

    -

    +

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

    +

    alignment

    +

    DialogAlignment

    +

    No

    +

    DialogAlignment.Default

    +

    Alignment mode of the dialog box in the vertical direction.

    +

    offset

    +

    {

    +

    dx: Length,

    +

    dy: Length

    +

    }

    +

    No

    +

    {

    +

    dx: 0,

    +

    dy: 0

    +

    }

    +

    Offset of the dialog box relative to the alignment position.

    +

    sheets

    +

    Array<SheetInfo>

    +

    Yes

    +

    -

    +

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

    +
    + +- SheetInfo parameters + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

    Name

    +

    Type

    +

    Mandatory

    +

    Default Value

    +

    Description

    +

    title

    +

    string

    +

    Yes

    +

    -

    +

    Sheet text.

    +

    icon

    +

    string

    +

    No

    +

    None

    +

    Sheet icon.

    +

    action

    +

    ()=>void

    +

    Yes

    +

    -

    +

    Callback when the sheet is selected.

    +
    + + +## Example + +``` +@Entry +@Component +struct ActionSheetExapmle { + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Button('Click to Show ActionSheet') + .onClick(() => { + ActionSheet.show({ + title: 'ActionSheet title', + message: 'message', + confirm: { + value: 'Confirm button', + action: () => { + console.log('Get Alert Dialog handled') + } + }, + sheets: [ + { + title: 'apples', + action: () => { + console.error('apples') + } + }, + { + title: 'bananas', + action: () => { + console.error('bananas') + } + }, + { + title: 'pears', + action: () => { + console.error('pears') + } + } + ] + }) + }) + }.width('100%') + .height('100%') + } +} +``` + +![](figures/en-us_image_0000001201475612.gif) + diff --git a/en/application-dev/reference/arkui-ts/ts-methods-custom-dialog-box.md b/en/application-dev/reference/arkui-ts/ts-methods-custom-dialog-box.md index 856f5f6262cde424712bb05c77eeccde6359eaab..67e355e76b1b4e501a3c197ef270026f78ee4203 100644 --- a/en/application-dev/reference/arkui-ts/ts-methods-custom-dialog-box.md +++ b/en/application-dev/reference/arkui-ts/ts-methods-custom-dialog-box.md @@ -1,4 +1,7 @@ -# Custom Dialog box +# Custom Dialog box + +>![](../../public_sys-resources/icon-note.gif) **NOTE:** +>This method is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. The **CustomDialogController** class is used to display a custom dialog box. @@ -23,7 +26,7 @@ CustomDialogController\(value:\{builder: CustomDialog, cancel?: \(\) =\> void, a

    builder

    CustomDialog

    +

    CustomDialog

    Yes

    type

    boolean

    +

    string

    Yes

    + + + + + + + + + + + + + + + + + + + + + + + + + +

    Name

    +

    Type

    +

    Mandatory

    +

    Default Value

    +

    Description

    +

    width

    +

    number

    +

    Yes

    +

    -

    +

    Width of the offscreen canvas.

    +

    height

    +

    number

    +

    Yes

    +

    -

    +

    Height of the offscreen canvas.

    +

    setting

    +

    RenderingContextSettings

    +

    Yes

    +

    -

    +

    For details, see APIs of RenderingContextSettings.

    +
    + + +## Attributes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

    Name

    +

    Type

    +

    Default Value

    +

    Description

    +

    fillStyle

    +

    <color> | CanvasGradient | CanvasPattern

    +

    -

    +

    Style to fill an area.

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

    lineWidth

    +

    number

    +

    -

    +

    Line width.

    +

    strokeStyle

    +

    <color> | CanvasGradient | CanvasPattern

    +

    -

    +

    Stroke style.

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

    lineCap

    +

    string

    +

    'butt'

    +

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

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

    lineJoin

    +

    string

    +

    'miter'

    +

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

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

    miterLimit

    +

    number

    +

    10

    +

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

    +

    font

    +

    string

    +

    'normal normal 14px sans-serif'

    +

    Font style.

    +

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

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

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

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

    textAlign

    +

    string

    +

    'left'

    +

    Text alignment mode. Available values are as follows:

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

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

    +
    +

    textBaseline

    +

    string

    +

    'alphabetic'

    +

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

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

    globalAlpha

    +

    number

    +

    -

    +

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

    +

    lineDashOffset

    +

    number

    +

    0.0

    +

    Offset of the dashed line. The precision is float.

    +

    globalCompositeOperation

    +

    string

    +

    'source-over'

    +

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

    +

    shadowBlur

    +

    number

    +

    0.0

    +

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

    +

    shadowColor

    +

    <color>

    +

    -

    +

    Shadow color.

    +

    shadowOffsetX

    +

    number

    +

    -

    +

    X-axis shadow offset relative to the original object.

    +

    shadowOffsetY

    +

    number

    +

    -

    +

    Y-axis shadow offset relative to the original object.

    +

    imageSmoothingEnabled

    +

    boolean

    +

    true

    +

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

    +

    imageSmoothingQuality

    +

    string

    +

    'low'

    +

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

    +
    + +>![](../../public_sys-resources/icon-note.gif) **NOTE:** +>The value of the **** type can be in 'rgb\(255, 255, 255\)', 'rgba\(255, 255, 255, 1.0\)', or '\#FFFFFF' format. + +### fillStyle + +``` +@Entry +@Component +struct FillStyleExample { + private settings: RenderingContextSettings = new RenderingContextSettings(true,true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + private offContext: OffscreenCanvasRenderingContext2D = new OffscreenCanvasRenderingContext2D(600, 600, this.settings) + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.offContext.fillStyle = '#0000ff' + this.offContext.fillRect(20, 160, 150, 100) + var image = this.offContext.transferToImageBitmap(); + this.context.transferFromImageBitmap(image); + }) + } + .width('100%') + .height('100%') + } +} +``` + +![](figures/en-us_image_0000001237555173.png) + +### lineWidth + +``` +@Entry +@Component +struct LineWidthExample { + private settings: RenderingContextSettings = new RenderingContextSettings(true,true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + private offContext: OffscreenCanvasRenderingContext2D = new OffscreenCanvasRenderingContext2D(600, 600, this.settings) + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.offContext.lineWidth = 5 + this.offContext.strokeRect(25, 25, 85, 105) + var image = this.offContext.transferToImageBitmap() + this.context.transferFromImageBitmap(image) + }) + } + .width('100%') + .height('100%') + } +} +``` + +![](figures/en-us_image_0000001192755194.png) + +### strokeStyle + +``` +@Entry +@Component +struct StrokeStyleExample { + private settings: RenderingContextSettings = new RenderingContextSettings(true,true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + private offContext: OffscreenCanvasRenderingContext2D = new OffscreenCanvasRenderingContext2D(600, 600, this.settings) + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.offContext.lineWidth = 10 + this.offContext.strokeStyle = '#0000ff' + this.offContext.strokeRect(25, 25, 155, 105) + var image = this.offContext.transferToImageBitmap() + this.context.transferFromImageBitmap(image) + }) + } + .width('100%') + .height('100%') + } +} +``` + +![](figures/en-us_image_0000001237355135.png) + +### lineCap + +``` +@Entry +@Component +struct LineCapExample { + private settings: RenderingContextSettings = new RenderingContextSettings(true,true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + private offContext: OffscreenCanvasRenderingContext2D = new OffscreenCanvasRenderingContext2D(600, 600, this.settings) + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.offContext.lineWidth = 8 + this.offContext.beginPath() + this.offContext.lineCap = 'round' + this.offContext.moveTo(30, 50) + this.offContext.lineTo(220, 50) + this.offContext.stroke() + var image = this.offContext.transferToImageBitmap() + this.context.transferFromImageBitmap(image) + }) + } + .width('100%') + .height('100%') + } +} +``` + +![](figures/en-us_image_0000001192595232.png) + +### lineJoin + +``` +@Entry +@Component +struct LineJoinExample { + private settings: RenderingContextSettings = new RenderingContextSettings(true,true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + private offContext: OffscreenCanvasRenderingContext2D = new OffscreenCanvasRenderingContext2D(600, 600, this.settings) + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.offContext.beginPath() + this.offContext.lineWidth = 8 + this.offContext.lineJoin = 'miter' + this.offContext.moveTo(30, 30) + this.offContext.lineTo(120, 60) + this.offContext.lineTo(30, 110) + this.offContext.stroke() + var image = this.offContext.transferToImageBitmap() + this.context.transferFromImageBitmap(image) + }) + } + .width('100%') + .height('100%') + } +} +``` + +![](figures/en-us_image_0000001237715141.png) + +### miterLimit + +``` +@Entry +@Component +struct MiterLimit { + private settings: RenderingContextSettings = new RenderingContextSettings(true,true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + private offContext: OffscreenCanvasRenderingContext2D = new OffscreenCanvasRenderingContext2D(600, 600, this.settings) + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.offContext.lineWidth = 8 + this.offContext.lineJoin = 'miter' + this.offContext.miterLimit = 3 + this.offContext.moveTo(30, 30) + this.offContext.lineTo(60, 35) + this.offContext.lineTo(30, 37) + this.offContext.stroke() + var image = this.offContext.transferToImageBitmap() + this.context.transferFromImageBitmap(image) + }) + } + .width('100%') + .height('100%') + } +} +``` + +![](figures/en-us_image_0000001193075178.png) + +### font + +``` +@Entry +@Component +struct Font { + private settings: RenderingContextSettings = new RenderingContextSettings(true,true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + private offContext: OffscreenCanvasRenderingContext2D = new OffscreenCanvasRenderingContext2D(600, 600, this.settings) + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.offContext.font = '30px sans-serif' + this.offContext.fillText("Hello World", 20, 60) + var image = this.offContext.transferToImageBitmap() + this.context.transferFromImageBitmap(image) + }) + } + .width('100%') + .height('100%') + } +} +``` + +![](figures/en-us_image_0000001193075164.png) + +### textAlign + +``` +@Entry +@Component +struct TextAlign { + private settings: RenderingContextSettings = new RenderingContextSettings(true,true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + private offContext: OffscreenCanvasRenderingContext2D = new OffscreenCanvasRenderingContext2D(600, 600, this.settings) + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.offContext.strokeStyle = '#0000ff' + this.offContext.moveTo(140, 10) + this.offContext.lineTo(140, 160) + this.offContext.stroke() + + this.offContext.font = '18px sans-serif' + + this.offContext.textAlign = 'start' + this.offContext.fillText('textAlign=start', 140, 60) + this.offContext.textAlign = 'end' + this.offContext.fillText('textAlign=end', 140, 80) + this.offContext.textAlign = 'left' + this.offContext.fillText('textAlign=left', 140, 100) + this.offContext.textAlign = 'center' + this.offContext.fillText('textAlign=center',140, 120) + this.offContext.textAlign = 'right' + this.offContext.fillText('textAlign=right',140, 140) + var image = this.offContext.transferToImageBitmap() + this.context.transferFromImageBitmap(image) + }) + } + .width('100%') + .height('100%') + } +} +``` + +![](figures/en-us_image_0000001192595234.png) + +### textBaseline + +``` +@Entry +@Component +struct TextBaseline { + private settings: RenderingContextSettings = new RenderingContextSettings(true,true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + private offContext: OffscreenCanvasRenderingContext2D = new OffscreenCanvasRenderingContext2D(600, 600, this.settings) + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.offContext.strokeStyle = '#0000ff' + this.offContext.moveTo(0, 120) + this.offContext.lineTo(400, 120) + this.offContext.stroke() + + this.offContext.font = '20px sans-serif' + + this.offContext.textBaseline = 'top' + this.offContext.fillText('Top', 10, 120) + this.offContext.textBaseline = 'bottom' + this.offContext.fillText('Bottom', 55, 120) + this.offContext.textBaseline = 'middle' + this.offContext.fillText('Middle', 125, 120) + this.offContext.textBaseline = 'alphabetic' + this.offContext.fillText('Alphabetic', 195, 120) + this.offContext.textBaseline = 'hanging' + this.offContext.fillText('Hanging', 295, 120) + var image = this.offContext.transferToImageBitmap() + this.context.transferFromImageBitmap(image) + }) + } + .width('100%') + .height('100%') + } +} +``` + +![](figures/en-us_image_0000001193075180.png) + +### globalAlpha + +``` +@Entry +@Component +struct GlobalAlpha { + private settings: RenderingContextSettings = new RenderingContextSettings(true,true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + private offContext: OffscreenCanvasRenderingContext2D = new OffscreenCanvasRenderingContext2D(600, 600, this.settings) + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.offContext.fillStyle = 'rgb(255,0,0)' + this.offContext.fillRect(0, 0, 50, 50) + this.offContext.globalAlpha = 0.4 + this.offContext.fillStyle = 'rgb(0,0,255)' + this.offContext.fillRect(50, 50, 50, 50) + var image = this.offContext.transferToImageBitmap() + this.context.transferFromImageBitmap(image) + }) + } + .width('100%') + .height('100%') + } +} +``` + +![](figures/en-us_image_0000001237715165.png) + +### lineDashOffset + +``` +@Entry +@Component +struct LineDashOffset { + private settings: RenderingContextSettings = new RenderingContextSettings(true,true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + private offContext: OffscreenCanvasRenderingContext2D = new OffscreenCanvasRenderingContext2D(600, 600, this.settings) + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.offContext.arc(100, 75, 50, 0, 6.28) + this.offContext.setLineDash([10,20]) + this.offContext.stroke(); + var image = this.offContext.transferToImageBitmap() + this.context.transferFromImageBitmap(image) + }) + } + .width('100%') + .height('100%') + } +} +``` + +![](figures/en-us_image_0000001237555181.png) + +### globalCompositeOperation + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

    Name

    +

    Description

    +

    source-over

    +

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

    +

    source-atop

    +

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

    +

    source-in

    +

    Displays the new drawing inside the existing drawing.

    +

    source-out

    +

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

    +

    destination-over

    +

    Displays the existing drawing above the new drawing.

    +

    destination-atop

    +

    Displays the existing drawing above the new drawing.

    +

    destination-in

    +

    Displays the existing drawing inside the new drawing.

    +

    destination-out

    +

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

    +

    lighter

    +

    Displays both the new drawing and the existing drawing.

    +

    copy

    +

    Displays the new drawing and neglects the existing drawing.

    +

    xor

    +

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

    +
    + +``` +@Entry +@Component +struct GlobalCompositeOperation { + private settings: RenderingContextSettings = new RenderingContextSettings(true,true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + private offContext: OffscreenCanvasRenderingContext2D = new OffscreenCanvasRenderingContext2D(600, 600, this.settings) + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.offContext.fillStyle = 'rgb(255,0,0)' + this.offContext.fillRect(20, 20, 50, 50) + this.offContext.globalCompositeOperation = 'source-over' + this.offContext.fillStyle = 'rgb(0,0,255)' + this.offContext.fillRect(50, 50, 50, 50) + this.offContext.fillStyle = 'rgb(255,0,0)' + this.offContext.fillRect(120, 20, 50, 50) + this.offContext.globalCompositeOperation = 'destination-over' + this.offContext.fillStyle = 'rgb(0,0,255)' + this.offContext.fillRect(150, 50, 50, 50) + var image = this.offContext.transferToImageBitmap() + this.context.transferFromImageBitmap(image) + }) + } + .width('100%') + .height('100%') + } +} +``` + +![](figures/en-us_image_0000001237355137.png) + +### shadowBlur + +``` +@Entry +@Component +struct ShadowBlur { + private settings: RenderingContextSettings = new RenderingContextSettings(true,true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + private offContext: OffscreenCanvasRenderingContext2D = new OffscreenCanvasRenderingContext2D(600, 600, this.settings) + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.offContext.shadowBlur = 30 + this.offContext.shadowColor = 'rgb(0,0,0)' + this.offContext.fillStyle = 'rgb(255,0,0)' + this.offContext.fillRect(20, 20, 100, 80) + var image = this.offContext.transferToImageBitmap() + this.context.transferFromImageBitmap(image) + }) + } + .width('100%') + .height('100%') + } +} +``` + +![](figures/en-us_image_0000001192755182.png) + +### shadowColor + +``` +@Entry +@Component +struct ShadowColor { + private settings: RenderingContextSettings = new RenderingContextSettings(true,true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + private offContext: OffscreenCanvasRenderingContext2D = new OffscreenCanvasRenderingContext2D(600, 600, this.settings) + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.offContext.shadowBlur = 30 + this.offContext.shadowColor = 'rgb(0,0,255)' + this.offContext.fillStyle = 'rgb(255,0,0)' + this.offContext.fillRect(30, 30, 100, 100) + var image = this.offContext.transferToImageBitmap +() + this.context.transferFromImageBitmap(image) + }) + } + .width('100%') + .height('100%') + } +} +``` + +![](figures/en-us_image_0000001237555155.png) + +### shadowOffsetX + +``` +@Entry +@Component +struct ShadowOffsetX { + private settings: RenderingContextSettings = new RenderingContextSettings(true,true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + private offContext: OffscreenCanvasRenderingContext2D = new OffscreenCanvasRenderingContext2D(600, 600, this.settings) + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.offContext.shadowBlur = 10 + this.offContext.shadowOffsetX = 20 + this.offContext.shadowColor = 'rgb(0,0,0)' + this.offContext.fillStyle = 'rgb(255,0,0)' + this.offContext.fillRect(20, 20, 100, 80) + var image = this.offContext.transferToImageBitmap() + this.context.transferFromImageBitmap(image) + }) + } + .width('100%') + .height('100%') + } +} +``` + +![](figures/en-us_image_0000001193075168.png) + +### shadowOffsetY + +``` +@Entry +@Component +struct ShadowOffsetY { + private settings: RenderingContextSettings = new RenderingContextSettings(true,true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + private offContext: OffscreenCanvasRenderingContext2D = new OffscreenCanvasRenderingContext2D(600, 600, this.settings) + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.offContext.shadowBlur = 10 + this.offContext.shadowOffsetY = 20 + this.offContext.shadowColor = 'rgb(0,0,0)' + this.offContext.fillStyle = 'rgb(255,0,0)' + this.offContext.fillRect(30, 30, 100, 100) + var image = this.offContext.transferToImageBitmap() + this.context.transferFromImageBitmap(image) + }) + } + .width('100%') + .height('100%') + } +} +``` + +![](figures/en-us_image_0000001237475139.png) + +### imageSmoothingEnabled + +``` +@Entry +@Component +struct ImageSmoothingEnabled { + private settings: RenderingContextSettings = new RenderingContextSettings(true,true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + private img:ImageBitmap = new ImageBitmap("common/images/icon.jpg") + private offContext: OffscreenCanvasRenderingContext2D = new OffscreenCanvasRenderingContext2D(600, 600, this.settings) + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.offContext.imageSmoothingEnabled = false + this.offContext.drawImage( this.img,0,0,400,200) + var image = this.offContext.transferToImageBitmap() + this.context.transferFromImageBitmap(image) + }) + } + .width('100%') + .height('100%') + } +} +``` + +![](figures/en-us_image_0000001237355121.png) + +## Methods + +### fillRect + +fillRect\(x: number, y: number, w: number, h: number\): void + +Fills a rectangle on the canvas. + +- Parameters + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

    Name

    +

    Type

    +

    Mandatory

    +

    Default Value

    +

    Description

    +

    x

    +

    number

    +

    Yes

    +

    0

    +

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

    +

    y

    +

    number

    +

    Yes

    +

    0

    +

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

    +

    width

    +

    number

    +

    Yes

    +

    0

    +

    Width of the rectangle.

    +

    height

    +

    number

    +

    Yes

    +

    0

    +

    Height of the rectangle.

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

    Name

    +

    Type

    +

    Mandatory

    +

    Default Value

    +

    Description

    +

    x

    +

    number

    +

    Yes

    +

    0

    +

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

    +

    y

    +

    number

    +

    Yes

    +

    0

    +

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

    +

    width

    +

    number

    +

    Yes

    +

    0

    +

    Width of the rectangle.

    +

    height

    +

    number

    +

    Yes

    +

    0

    +

    Height of the rectangle.

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

    Name

    +

    Type

    +

    Mandatory

    +

    Default Value

    +

    Description

    +

    x

    +

    number

    +

    Yes

    +

    0

    +

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

    +

    y

    +

    number

    +

    Yes

    +

    0

    +

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

    +

    width

    +

    number

    +

    Yes

    +

    0

    +

    Width of the rectangle.

    +

    height

    +

    number

    +

    Yes

    +

    0

    +

    Height of the rectangle.

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

    Parameters

    +

    Type

    +

    Mandatory

    +

    Default Value

    +

    Description

    +

    text

    +

    string

    +

    Yes

    +

    ""

    +

    Text to draw.

    +

    x

    +

    number

    +

    Yes

    +

    0

    +

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

    +

    y

    +

    number

    +

    Yes

    +

    0

    +

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

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

    Name

    +

    Type

    +

    Mandatory

    +

    Default Value

    +

    Description

    +

    text

    +

    string

    +

    Yes

    +

    ""

    +

    Text to draw.

    +

    x

    +

    number

    +

    Yes

    +

    0

    +

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

    +

    y

    +

    number

    +

    Yes

    +

    0

    +

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

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

    Name

    +

    Type

    +

    Mandatory

    +

    Default Value

    +

    Description

    +

    text

    +

    string

    +

    Yes

    +

    ""

    +

    Text to be measured.

    +
    + +- Return values + + + + + + + + + + +

    Type

    +

    Description

    +

    TextMetrics

    +

    TextMetrics object.

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

    Attribute

    +

    Type

    +

    Description

    +

    width

    +

    number

    +

    Width of the text string.

    +
    + + +- Example + + ``` + @Entry + @Component + struct MeasureText { + private settings: RenderingContextSettings = new RenderingContextSettings(true,true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + private offContext: OffscreenCanvasRenderingContext2D = new OffscreenCanvasRenderingContext2D(600, 600, this.settings) + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.offContext.font = '50px sans-serif' + this.offContext.fillText("Hello World!", 20, 100) + this.offContext.fillText("width:" + this.context.measureText("Hello World!").width, 20, 200) + var image = this.offContext.transferToImageBitmap() + this.context.transferFromImageBitmap(image) + }) + } + .width('100%') + .height('100%') + } + } + ``` + + ![](figures/en-us_image_0000001193075172.png) + + +### stroke + +stroke\(path?: Path2D\): void + +Strokes a path. + +- Parameters + + + + + + + + + + + + + + + + +

    Name

    +

    Type

    +

    Mandatory

    +

    Default Value

    +

    Description

    +

    path

    +

    Path2D

    +

    No

    +

    null

    +

    A Path2D path to draw.

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

    Name

    +

    Type

    +

    Mandatory

    +

    Default Value

    +

    Description

    +

    x

    +

    number

    +

    Yes

    +

    0

    +

    X-coordinate of the target position.

    +

    y

    +

    number

    +

    Yes

    +

    0

    +

    Y-coordinate of the target position.

    +
    + + +- Example + + ``` + @Entry + @Component + struct MoveTo { + private settings: RenderingContextSettings = new RenderingContextSettings(true,true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + private offContext: OffscreenCanvasRenderingContext2D = new OffscreenCanvasRenderingContext2D(600, 600, this.settings) + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.offContext.beginPath() + this.offContext.moveTo(10, 10) + this.offContext.lineTo(280, 160) + this.offContext.stroke() + var image = this.offContext.transferToImageBitmap() + this.context.transferFromImageBitmap(image) + }) + } + .width('100%') + .height('100%') + } + } + ``` + + ![](figures/en-us_image_0000001192595228.png) + + +### lineTo + +lineTo\(x: number, y: number\): void + +Connects the current point to a target position using a straight line. + +- Parameters + + + + + + + + + + + + + + + + + + + + + + +

    Name

    +

    Type

    +

    Mandatory

    +

    Default Value

    +

    Description

    +

    x

    +

    number

    +

    Yes

    +

    0

    +

    X-coordinate of the target position.

    +

    y

    +

    number

    +

    Yes

    +

    0

    +

    Y-coordinate of the target position.

    +
    + + +- Example + + ``` + @Entry + @Component + struct LineTo { + private settings: RenderingContextSettings = new RenderingContextSettings(true,true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + private offContext: OffscreenCanvasRenderingContext2D = new OffscreenCanvasRenderingContext2D(600, 600, this.settings) + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.offContext.beginPath() + this.offContext.moveTo(10, 10) + this.offContext.lineTo(280, 160) + this.offContext.stroke() + var image = this.offContext.transferToImageBitmap() + this.context.transferFromImageBitmap(image) + }) + } + .width('100%') + .height('100%') + } + } + ``` + + ![](figures/en-us_image_0000001237715151.png) + + +### closePath + +closePath\(\): void + +Draws a closed path. + +- Example + + ``` + @Entry + @Component + struct ClosePath { + private settings: RenderingContextSettings = new RenderingContextSettings(true,true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + private offContext: OffscreenCanvasRenderingContext2D = new OffscreenCanvasRenderingContext2D(600, 600, this.settings) + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.offContext.beginPath() + this.offContext.moveTo(30, 30) + this.offContext.lineTo(110, 30) + this.offContext.lineTo(70, 90) + this.offContext.closePath() + this.offContext.stroke() + var image = this.offContext.transferToImageBitmap() + this.context.transferFromImageBitmap(image) + }) + } + .width('100%') + .height('100%') + } + } + ``` + + ![](figures/en-us_image_0000001192595224.png) + + +### createPattern + +createPattern\(image: ImageBitmap, repetition: string\): CanvasPattern + +Creates a pattern for image filling based on a specified source image and repetition mode. + +- Parameters + + + + + + + + + + + + + + + + + + + + + + +

    Name

    +

    Type

    +

    Mandatory

    +

    Default Value

    +

    Description

    +

    image

    +

    ImageBitmap

    +

    Yes

    +

    null

    +

    Source image. For details, see ImageBitmap.

    +

    repetition

    +

    string

    +

    Yes

    +

    ""

    +

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

    +
    + +- Example + + ``` + @Entry + @Component + struct CreatePattern { + private settings: RenderingContextSettings = new RenderingContextSettings(true,true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + private img:ImageBitmap = new ImageBitmap("common/images/icon.jpg") + private offContext: OffscreenCanvasRenderingContext2D = new OffscreenCanvasRenderingContext2D(600, 600, this.settings) + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + var pattern = this.offContext.createPattern(this.img, 'repeat') + this.offContext.fillStyle = pattern + this.offContext.fillRect(0, 0, 200, 200) + var image = this.offContext.transferToImageBitmap() + this.context.transferFromImageBitmap(image) + }) + } + .width('100%') + .height('100%') + } + } + ``` + + ![](figures/en-us_image_0000001237475133.png) + + +### bezierCurveTo + +bezierCurveTo\(cp1x: number, cp1y: number, cp2x: number, cp2y: number, x: number, y: number\): void + +Draws a cubic bezier curve on the canvas. + +- Parameters + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

    Name

    +

    Type

    +

    Mandatory

    +

    Default Value

    +

    Description

    +

    cp1x

    +

    number

    +

    Yes

    +

    0

    +

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

    +

    cp1y

    +

    number

    +

    Yes

    +

    0

    +

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

    +

    cp2x

    +

    number

    +

    Yes

    +

    0

    +

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

    +

    cp2y

    +

    number

    +

    Yes

    +

    0

    +

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

    +

    x

    +

    number

    +

    Yes

    +

    0

    +

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

    +

    y

    +

    number

    +

    Yes

    +

    0

    +

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

    +
    + + +- Example + + ``` + @Entry + @Component + struct BezierCurveTo { + private settings: RenderingContextSettings = new RenderingContextSettings(true,true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + private offContext: OffscreenCanvasRenderingContext2D = new OffscreenCanvasRenderingContext2D(600, 600, this.settings) + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.offContext.beginPath() + this.offContext.moveTo(10, 10) + this.offContext.bezierCurveTo(20, 100, 200, 100, 200, 20) + this.offContext.stroke() + var image = this.offContext.transferToImageBitmap() + this.context.transferFromImageBitmap(image) + }) + } + .width('100%') + .height('100%') + } + } + ``` + + ![](figures/en-us_image_0000001237715153.png) + + +### quadraticCurveTo + +quadraticCurveTo\(cpx: number, cpy: number, x: number, y: number\): void + +Draws a quadratic curve on the canvas. + +- Parameters + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

    Name

    +

    Type

    +

    Mandatory

    +

    Default Value

    +

    Description

    +

    cpx

    +

    number

    +

    Yes

    +

    0

    +

    X-coordinate of the bezier curve parameter.

    +

    cpy

    +

    number

    +

    Yes

    +

    0

    +

    Y-coordinate of the bezier curve parameter.

    +

    x

    +

    number

    +

    Yes

    +

    0

    +

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

    +

    y

    +

    number

    +

    Yes

    +

    0

    +

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

    +
    + + +- Example + + ``` + @Entry + @Component + struct QuadraticCurveTo { + private settings: RenderingContextSettings = new RenderingContextSettings(true,true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + private offContext: OffscreenCanvasRenderingContext2D = new OffscreenCanvasRenderingContext2D(600, 600, this.settings) + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.offContext.beginPath(); + this.offContext.moveTo(20, 20); + this.offContext.quadraticCurveTo(100, 100, 200, 20); + this.offContext.stroke(); + var image = this.offContext.transferToImageBitmap() + this.context.transferFromImageBitmap(image) + }) + } + .width('100%') + .height('100%') + } + } + ``` + + ![](figures/en-us_image_0000001192915184.png) + + +### arc + +arc\(x: number, y: number, radius: number, startAngle: number, endAngle: number, anticlockwise?: boolean\): void + +Draws an arc on the canvas. + +- Parameters + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

    Name

    +

    Type

    +

    Mandatory

    +

    Default Value

    +

    Description

    +

    x

    +

    number

    +

    Yes

    +

    0

    +

    X-coordinate of the center point of the arc.

    +

    y

    +

    number

    +

    Yes

    +

    0

    +

    Y-coordinate of the center point of the arc.

    +

    radius

    +

    number

    +

    Yes

    +

    0

    +

    Radius of the arc.

    +

    startAngle

    +

    number

    +

    Yes

    +

    0

    +

    Start radian of the arc.

    +

    endAngle

    +

    number

    +

    Yes

    +

    0

    +

    End radian of the arc.

    +

    anticlockwise

    +

    boolean

    +

    No

    +

    false

    +

    Whether to draw the arc counterclockwise.

    +
    + +- Example + + ``` + @Entry + @Component + struct Arc { + private settings: RenderingContextSettings = new RenderingContextSettings(true,true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + private offContext: OffscreenCanvasRenderingContext2D = new OffscreenCanvasRenderingContext2D(600, 600, this.settings) + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.offContext.beginPath() + this.offContext.arc(100, 75, 50, 0, 6.28) + this.offContext.stroke() + var image = this.offContext.transferToImageBitmap() + this.context.transferFromImageBitmap(image) + }) + } + .width('100%') + .height('100%') + } + } + ``` + + ![](figures/en-us_image_0000001192595226.png) + + +### arcTo + +arcTo\(x1: number, y1: number, x2: number, y2: number, radius: number\): void + +Draws an arc based on the radius and points on the arc. + +- Parameters + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

    Name

    +

    Type

    +

    Mandatory

    +

    Default Value

    +

    Description

    +

    x1

    +

    number

    +

    Yes

    +

    0

    +

    X-coordinate of the first point on the arc.

    +

    y1

    +

    number

    +

    Yes

    +

    0

    +

    Y-coordinate of the first point on the arc.

    +

    x2

    +

    number

    +

    Yes

    +

    0

    +

    X-coordinate of the second point on the arc.

    +

    y2

    +

    number

    +

    Yes

    +

    0

    +

    Y-coordinate of the second point on the arc.

    +

    radius

    +

    number

    +

    Yes

    +

    0

    +

    Radius of the arc.

    +
    + + +- Example + + ``` + @Entry + @Component + struct ArcTo { + private settings: RenderingContextSettings = new RenderingContextSettings(true,true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + private offContext: OffscreenCanvasRenderingContext2D = new OffscreenCanvasRenderingContext2D(600, 600, this.settings) + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.offContext.moveTo(100, 20); + this.offContext.arcTo(150, 20, 150, 70, 50); + this.offContext.stroke(); + var image = this.offContext.transferToImageBitmap() + this.context.transferFromImageBitmap(image) + }) + } + .width('100%') + .height('100%') + } + } + ``` + + ![](figures/en-us_image_0000001237555167.png) + + +### ellipse + +ellipse\(x: number, y: number, radiusX: number, radiusY: number, rotation: number, startAngle: number, endAngle: number, anticlockwise?: boolean\): void + +Draws an ellipse in the specified rectangular region. + +- Parameters + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

    Name

    +

    Type

    +

    Mandatory

    +

    Default Value

    +

    Description

    +

    x

    +

    number

    +

    Yes

    +

    0

    +

    X-coordinate of the ellipse center.

    +

    y

    +

    number

    +

    Yes

    +

    0

    +

    Y-coordinate of the ellipse center.

    +

    radiusX

    +

    number

    +

    Yes

    +

    0

    +

    Ellipse radius on the x-axis.

    +

    radiusY

    +

    number

    +

    Yes

    +

    0

    +

    Ellipse radius on the y-axis.

    +

    rotation

    +

    number

    +

    Yes

    +

    0

    +

    Rotation angle of the ellipse, in radians.

    +

    startAngle

    +

    number

    +

    Yes

    +

    0

    +

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

    +

    endAngle

    +

    number

    +

    Yes

    +

    0

    +

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

    +

    anticlockwise

    +

    boolean

    +

    No

    +

    false

    +

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

    +
    + + +- Example + + ``` + @Entry + @Component + struct Ellipse { + private settings: RenderingContextSettings = new RenderingContextSettings(true,true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + private offContext: OffscreenCanvasRenderingContext2D = new OffscreenCanvasRenderingContext2D(600, 600, this.settings) + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.offContext.beginPath() + this.offContext.ellipse(200, 200, 50, 100, Math.PI * 0.25, Math.PI * 0.5, Math.PI, true) + this.offContext.stroke() + var image = this.offContext.transferToImageBitmap() + this.context.transferFromImageBitmap(image) + }) + } + .width('100%') + .height('100%') + } + } + ``` + + ![](figures/en-us_image_0000001237355131.png) + + +### rect + +rect\(x: number, y: number, width: number, height: number\): void + +Creates a rectangle. + +- Parameters + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

    Name

    +

    Type

    +

    Mandatory

    +

    Default Value

    +

    Description

    +

    x

    +

    number

    +

    Yes

    +

    0

    +

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

    +

    y

    +

    number

    +

    Yes

    +

    0

    +

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

    +

    width

    +

    number

    +

    Yes

    +

    0

    +

    Width of the rectangle.

    +

    height

    +

    number

    +

    Yes

    +

    0

    +

    Height of the rectangle.

    +
    + + +- Example + + ``` + @Entry + @Component + struct Rect { + private settings: RenderingContextSettings = new RenderingContextSettings(true,true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + private offContext: OffscreenCanvasRenderingContext2D = new OffscreenCanvasRenderingContext2D(600, 600, this.settings) + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.offContext.rect(20, 20, 100, 100) // Create a 100*100 rectangle at (20, 20) + this.offContext.stroke() + var image = this.offContext.transferToImageBitmap() + this.context.transferFromImageBitmap(image) + }) + } + .width('100%') + .height('100%') + } + } + ``` + + ![](figures/en-us_image_0000001237715155.png) + + +### fill + +fill\(\): void + +Fills the area inside a closed path. + +- Example + + ``` + @Entry + @Component + struct Fill { + private settings: RenderingContextSettings = new RenderingContextSettings(true,true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + private offContext: OffscreenCanvasRenderingContext2D = new OffscreenCanvasRenderingContext2D(600, 600, this.settings) + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.offContext.rect(20, 20, 100, 100) // Create a 100*100 rectangle at (20, 20) + this.offContext.fill() + var image = this.offContext.transferToImageBitmap() + this.context.transferFromImageBitmap(image) + }) + } + .width('100%') + .height('100%') + } + } + ``` + + ![](figures/en-us_image_0000001193075166.png) + + +### clip + +clip\(\): void + +Sets the current path to a clipping path. + +- Example + + ``` + @Entry + @Component + struct Clip { + private settings: RenderingContextSettings = new RenderingContextSettings(true,true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + private offContext: OffscreenCanvasRenderingContext2D = new OffscreenCanvasRenderingContext2D(600, 600, this.settings) + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.offContext.rect(0, 0, 200, 200) + this.offContext.stroke() + this.offContext.clip() + this.offContext.fillStyle = "rgb(255,0,0)" + this.offContext.fillRect(0, 0, 150, 150) + var image = this.offContext.transferToImageBitmap() + this.context.transferFromImageBitmap(image) + }) + } + .width('100%') + .height('100%') + } + } + ``` + + ![](figures/en-us_image_0000001192595238.png) + + +### rotate + +rotate\(rotate: number\): void + +Rotates a canvas clockwise around its coordinate axes. + +- Parameters + + + + + + + + + + + + + + + + +

    Name

    +

    Type

    +

    Mandatory

    +

    Default Value

    +

    Description

    +

    rotate

    +

    number

    +

    Yes

    +

    0

    +

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

    +
    + + +- Example + + ``` + @Entry + @Component + struct Rotate { + private settings: RenderingContextSettings = new RenderingContextSettings(true,true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + private offContext: OffscreenCanvasRenderingContext2D = new OffscreenCanvasRenderingContext2D(600, 600, this.settings) + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.offContext.rotate(45 * Math.PI / 180) // Rotate the rectangle 45 degrees + this.offContext.fillRect(70, 20, 50, 50) + var image = this.offContext.transferToImageBitmap() + this.context.transferFromImageBitmap(image) + }) + } + .width('100%') + .height('100%') + } + } + ``` + + ![](figures/en-us_image_0000001237355133.png) + + +### scale + +scale\(x: number, y: number\): void + +Scales a canvas based on scaling factors. + +- Parameters + + + + + + + + + + + + + + + + + + + + + + +

    Name

    +

    Type

    +

    Mandatory

    +

    Default Value

    +

    Description

    +

    x

    +

    number

    +

    Yes

    +

    0

    +

    Horizontal scale factor.

    +

    y

    +

    number

    +

    Yes

    +

    0

    +

    Vertical scale factor.

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

    Name

    +

    Type

    +

    Mandatory

    +

    Default Value

    +

    Description

    +

    scaleX

    +

    number

    +

    Yes

    +

    0

    +

    X-axis scale.

    +

    skewX

    +

    number

    +

    Yes

    +

    0

    +

    X-axis skew.

    +

    skewY

    +

    number

    +

    Yes

    +

    0

    +

    Y-axis skew.

    +

    scaleY

    +

    number

    +

    Yes

    +

    0

    +

    Y-axis scale.

    +

    translateX

    +

    number

    +

    Yes

    +

    0

    +

    X-axis translation.

    +

    translateY

    +

    number

    +

    Yes

    +

    0

    +

    Y-axis translation.

    +
    + +- Example + + ``` + @Entry + @Component + struct Transform { + private settings: RenderingContextSettings = new RenderingContextSettings(true,true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + private offContext: OffscreenCanvasRenderingContext2D = new OffscreenCanvasRenderingContext2D(600, 600, this.settings) + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.offContext.fillStyle = 'rgb(0,0,0)' + this.offContext.fillRect(0, 0, 100, 100) + this.offContext.transform(1, 0.5, -0.5, 1, 10, 10) + this.offContext.fillStyle = 'rgb(255,0,0)' + this.offContext.fillRect(0, 0, 100, 100) + this.offContext.transform(1, 0.5, -0.5, 1, 10, 10) + this.offContext.fillStyle = 'rgb(0,0,255)' + this.offContext.fillRect(0, 0, 100, 100) + var image = this.offContext.transferToImageBitmap() + this.context.transferFromImageBitmap(image) + }) + } + .width('100%') + .height('100%') + } + } + ``` + + ![](figures/en-us_image_0000001192595230.png) + + +### setTransform + +setTransform\(scaleX: number, skewX: number, skewY: number, scale: number, translateX: number, translateY: number\): void + +Resets the existing transformation matrix and creates a new transformation matrix by using the same parameters as the **transform\(\)** function. + +- Parameters + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

    Name

    +

    Type

    +

    Mandatory

    +

    Default Value

    +

    Description

    +

    scaleX

    +

    number

    +

    Yes

    +

    0

    +

    X-axis scale.

    +

    skewX

    +

    number

    +

    Yes

    +

    0

    +

    X-axis skew.

    +

    skewY

    +

    number

    +

    Yes

    +

    0

    +

    Y-axis skew.

    +

    scaleY

    +

    number

    +

    Yes

    +

    0

    +

    Y-axis scale.

    +

    translateX

    +

    number

    +

    Yes

    +

    0

    +

    X-axis translation.

    +

    translateY

    +

    number

    +

    Yes

    +

    0

    +

    Y-axis translation.

    +
    + +- Example + + ``` + @Entry + @Component + struct SetTransform { + private settings: RenderingContextSettings = new RenderingContextSettings(true,true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + private offContext: OffscreenCanvasRenderingContext2D = new OffscreenCanvasRenderingContext2D(600, 600, this.settings) + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.offContext.fillStyle = 'rgb(255,0,0)' + this.offContext.fillRect(0, 0, 100, 100) + this.offContext.setTransform(1,0.5, -0.5, 1, 10, 10) + this.offContext.fillStyle = 'rgb(0,0,255)' + this.offContext.fillRect(0, 0, 100, 100) + var image = this.offContext.transferToImageBitmap() + this.context.transferFromImageBitmap(image) + }) + } + .width('100%') + .height('100%') + } + } + ``` + + ![](figures/en-us_image_0000001237715159.png) + + +### translate + +translate\(x: number, y: number\): void + +Moves the origin of the coordinate system. + +- Parameters + + + + + + + + + + + + + + + + + + + + + + +

    Name

    +

    Type

    +

    Mandatory

    +

    Default Value

    +

    Description

    +

    x

    +

    number

    +

    Yes

    +

    0

    +

    X-axis translation

    +

    y

    +

    number

    +

    Yes

    +

    0

    +

    Y-axis translation.

    +
    + +- Example + + ``` + @Entry + @Component + struct Translate { + private settings: RenderingContextSettings = new RenderingContextSettings(true,true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + private offContext: OffscreenCanvasRenderingContext2D = new OffscreenCanvasRenderingContext2D(600, 600, this.settings) + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.offContext.fillRect(10, 10, 50, 50) + this.offContext.translate(70, 70) + this.offContext.fillRect(10, 10, 50, 50) + var image = this.offContext.transferToImageBitmap() + this.context.transferFromImageBitmap(image) + }) + } + .width('100%') + .height('100%') + } + } + ``` + + ![](figures/en-us_image_0000001237475137.png) + + +### drawImage + +drawImage\(image: ImageBitmap, dx: number, dy: number\): void + +drawImage\(image: ImageBitmap, dx: number, dy: number, dWidth: number, dHeight: number\): void + +drawImage\(image: ImageBitmap, sx: number, sy: number, sWidth: number, sHeight: number, dx: number, dy: number, dWidth: number, dHeight: number\):void + +Draws an image. + +- Parameters + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

    Name

    +

    Type

    +

    Mandatory

    +

    Default Value

    +

    Description

    +

    image

    +

    ImageBitmap

    +

    Yes

    +

    null

    +

    Image resource. For details, see ImageBitmap.

    +

    sx

    +

    number

    +

    No

    +

    0

    +

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

    +

    sy

    +

    number

    +

    No

    +

    0

    +

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

    +

    sWidth

    +

    number

    +

    No

    +

    0

    +

    Target width to crop the source image.

    +

    sHeight

    +

    number

    +

    No

    +

    0

    +

    Target height to crop the source image.

    +

    dx

    +

    number

    +

    Yes

    +

    0

    +

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

    +

    dy

    +

    number

    +

    Yes

    +

    0

    +

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

    +

    dWidth

    +

    number

    +

    No

    +

    0

    +

    Width of the drawing area.

    +

    dHeight

    +

    number

    +

    No

    +

    0

    +

    Height of the drawing area.

    +
    + + +- Example + + ``` + @Entry + @Component + struct Index { + private settings: RenderingContextSettings = new RenderingContextSettings(true,true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + private img:ImageBitmap = new ImageBitmap("common/images/icon.jpg") + private offContext: OffscreenCanvasRenderingContext2D = new OffscreenCanvasRenderingContext2D(600, 600, this.settings) + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() => { + this.offContext.drawImage( this.img,0,0,400,200) + var image = this.offContext.transferToImageBitmap() + this.context.transferFromImageBitmap(image) + }) + } + .width('100%') + .height('100%') + } + } + ``` + + ![](figures/en-us_image_0000001192915180.png) + + +### createImageData + +createImageData\(width: number, height: number\): Object + +Creates an **ImageData** object based on the specified width and height. For details, see [ImageData](ts-components-canvas-imagedata.md). + +- Parameters + + + + + + + + + + + + + + + + + + + + + + +

    Name

    +

    Type

    +

    Mandatory

    +

    Default

    +

    Description

    +

    width

    +

    number

    +

    Yes

    +

    0

    +

    Width of the ImageData object.

    +

    height

    +

    number

    +

    Yes

    +

    0

    +

    Height of the ImageData object.

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

    Name

    +

    Type

    +

    Mandatory

    +

    Default

    +

    Description

    +

    imagedata

    +

    ImageData

    +

    Yes

    +

    null

    +

    ImageData object to copy.

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

    Name

    +

    Type

    +

    Mandatory

    +

    Default Value

    +

    Description

    +

    sx

    +

    number

    +

    Yes

    +

    0

    +

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

    +

    sy

    +

    number

    +

    Yes

    +

    0

    +

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

    +

    sw

    +

    number

    +

    Yes

    +

    0

    +

    Width of the output area.

    +

    sh

    +

    number

    +

    Yes

    +

    0

    +

    Height of the output area.

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

    Name

    +

    Type

    +

    Mandatory

    +

    Default Value

    +

    Description

    +

    imagedata

    +

    Object

    +

    Yes

    +

    null

    +

    ImageData object with pixels to put onto the canvas.

    +

    dx

    +

    number

    +

    Yes

    +

    0

    +

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

    +

    dy

    +

    number

    +

    Yes

    +

    0

    +

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

    +

    dirtyX

    +

    number

    +

    No

    +

    0

    +

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

    +

    dirtyY

    +

    number

    +

    No

    +

    0

    +

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

    +

    dirtyWidth

    +

    number

    +

    No

    +

    Width of the ImageData object

    +

    Width of the rectangular area to crop the source image.

    +

    dirtyHeight

    +

    number

    +

    No

    +

    Height of the ImageData object

    +

    Height of the rectangular area to crop the source image.

    +
    + +- Example + + ``` + @Entry + @Component + struct PutImageData { + private settings: RenderingContextSettings = new RenderingContextSettings(true,true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + private offContext: OffscreenCanvasRenderingContext2D = new OffscreenCanvasRenderingContext2D(600, 600, this.settings) + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + var imageData = this.offContext.createImageData(100, 100) + for (var i = 0; i < imageData.data.length; i += 4) { + imageData.data[i + 0] = 255 + imageData.data[i + 1] = 0 + imageData.data[i + 2] = 255 + imageData.data[i + 3] = 255 + } + this.offContext.putImageData(imageData, 10, 10) + var image = this.offContext.transferToImageBitmap() + this.context.transferFromImageBitmap(image) + }) + } + .width('100%') + .height('100%') + } + } + ``` + + ![](figures/en-us_image_0000001193075170.png) + + +### restore + +restore\(\): void + +Restores the saved drawing context. + +- Example + + ``` + @Entry + @Component + struct Restore { + private settings: RenderingContextSettings = new RenderingContextSettings(true,true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + private offContext: OffscreenCanvasRenderingContext2D = new OffscreenCanvasRenderingContext2D(600, 600, this.settings) + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.offContext.restore() + var image = this.offContext.transferToImageBitmap() + this.context.transferFromImageBitmap(image) + }) + } + .width('100%') + .height('100%') + } + } + ``` + + +### save + +save\(\): void + +Saves the current drawing context. + +- Example + + ``` + @Entry + @Component + struct Restore { + private settings: RenderingContextSettings = new RenderingContextSettings(true,true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + private offContext: OffscreenCanvasRenderingContext2D = new OffscreenCanvasRenderingContext2D(600, 600, this.settings) + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + this.offContext.save() + var image = this.offContext.transferToImageBitmap() + this.context.transferFromImageBitmap(image) + }) + } + .width('100%') + .height('100%') + } + } + ``` + + +### createLinearGradient + +createLinearGradient\(x0: number, y0: number, x1: number, y1: number\): void + +Creates a linear gradient. + +- Parameters + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

    Name

    +

    Type

    +

    Mandatory

    +

    Default Value

    +

    Description

    +

    x0

    +

    number

    +

    Yes

    +

    0

    +

    X-coordinate of the start point.

    +

    y0

    +

    number

    +

    Yes

    +

    0

    +

    Y-coordinate of the start point.

    +

    x1

    +

    number

    +

    Yes

    +

    0

    +

    X-coordinate of the end point.

    +

    y1

    +

    number

    +

    Yes

    +

    0

    +

    Y-coordinate of the end point.

    +
    + +- Example + + ``` + @Entry + @Component + struct CreateLinearGradient { + private settings: RenderingContextSettings = new RenderingContextSettings(true,true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + private gra:CanvasGradient = new CanvasGradient() + private offContext: OffscreenCanvasRenderingContext2D = new OffscreenCanvasRenderingContext2D(600, 600, this.settings) + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + var grad = this.offContext.createLinearGradient(50,0, 300,100) + this.gra.addColorStop(0.0, 'red') + this.gra.addColorStop(0.5, 'white') + this.gra.addColorStop(1.0, 'green') + this.offContext.fillStyle = grad + this.offContext.fillRect(0, 0, 500, 500) + var image = this.offContext.transferToImageBitmap() + this.context.transferFromImageBitmap(image) + }) + } + .width('100%') + .height('100%') + } + } + ``` + + ![](figures/en-us_image_0000001192915162.png) + + +### createRadialGradient + +createRadialGradient\(x0: number, y0: number, r0: number, x1: number, y1: number, r1: number\): void + +Creates a linear gradient. + +- Parameters + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

    Name

    +

    Type

    +

    Mandatory

    +

    Default Value

    +

    Description

    +

    x0

    +

    number

    +

    Yes

    +

    0

    +

    X-coordinate of the center of the start circle.

    +

    y0

    +

    number

    +

    Yes

    +

    0

    +

    Y-coordinate of the center of the start circle.

    +

    r0

    +

    number

    +

    Yes

    +

    0

    +

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

    +

    x1

    +

    number

    +

    Yes

    +

    0

    +

    X-coordinate of the center of the end circle.

    +

    y1

    +

    number

    +

    Yes

    +

    0

    +

    Y-coordinate of the center of the end circle.

    +

    r1

    +

    number

    +

    Yes

    +

    0

    +

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

    +
    + +- Example + + ``` + @Entry + @Component + struct CreateRadialGradient { + private settings: RenderingContextSettings = new RenderingContextSettings(true,true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + private gra:CanvasGradient = new CanvasGradient() + private offContext: OffscreenCanvasRenderingContext2D = new OffscreenCanvasRenderingContext2D(600, 600, this.settings) + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() =>{ + var grad = this.offContext.createRadialGradient(200,200,50, 200,200,200) + this.gra.addColorStop(0.0, 'red') + this.gra.addColorStop(0.5, 'white') + this.gra.addColorStop(1.0, 'green') + this.offContext.fillStyle = grad + this.offContext.fillRect(0, 0, 500, 500) + var image = this.offContext.transferToImageBitmap() + this.context.transferFromImageBitmap(image) + }) + } + .width('100%') + .height('100%') + } + } + ``` + + ![](figures/en-us_image_0000001237555179.png) + + +## CanvasPattern + +Defines an object created by using the [createPattern](#section660873113512) method. + diff --git a/en/application-dev/reference/arkui-ts/ts-page-transition-animation.md b/en/application-dev/reference/arkui-ts/ts-page-transition-animation.md index 59d73ec0be1db23323e6899a5fad27840790177d..b1b9c60825e06db19965cf57f494c3b1216076f8 100644 --- a/en/application-dev/reference/arkui-ts/ts-page-transition-animation.md +++ b/en/application-dev/reference/arkui-ts/ts-page-transition-animation.md @@ -1,11 +1,14 @@ -# Page Transition +# Page Transition + +>![](../../public_sys-resources/icon-note.gif) **NOTE:** +>This animation is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. Customize the page transition animations by configuring the page entrance and exit components in the global **pageTransition** method. -

    Component

    + - diff --git a/en/application-dev/reference/arkui-ts/ts-syntax-intro.md b/en/application-dev/reference/arkui-ts/ts-syntax-intro.md deleted file mode 100644 index 637d6dd902e360017b17a733c86751efcd2d0ffa..0000000000000000000000000000000000000000 --- a/en/application-dev/reference/arkui-ts/ts-syntax-intro.md +++ /dev/null @@ -1,11 +0,0 @@ -# Overview - -This section defines the core mechanism and functions of the TypeScript-based declarative development paradigm. It describes declarative UI descriptions, componentization mechanisms, UI state management, rendering control syntax, and syntactic sugar to enhance programming language functionality. - -Follow the provided guidelines for UI development. For details about the components, see [Components](ts-universal-events-click.md). - ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->- All examples use the TypeScript \(TS\) language. If you are using other languages, comply with the syntax requirements of the corresponding language. ->- The components used in the examples are preset in the UI framework and are used only to explain the UI description specifications. ->- Common attribute and event methods generally apply to all components, and the attribute and event methods within a component apply only to the current component. - 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 ba406384d9c21cbbddaf835c24b2c41ece850879..f6fc3dd221ed86729f59f31edbf46911232b11e0 100644 --- a/en/application-dev/reference/arkui-ts/ts-transition-animation-component.md +++ b/en/application-dev/reference/arkui-ts/ts-transition-animation-component.md @@ -1,4 +1,7 @@ -# Component Transition +# Component Transition + +>![](../../public_sys-resources/icon-note.gif) **NOTE:** +>This animation is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. Configure the component transition animations for when a component is inserted or deleted, which improves user experience. This feature takes effect only when **animateTo** is used. The animation duration, curve, and delay are the same as those configured in **animateTo**. 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 d6031abac7c6b10b3fbeb0eaf81f34ab696bba54..a73b337b47d8ffa16af12d0a831c538d04467744 100644 --- a/en/application-dev/reference/arkui-ts/ts-transition-animation-shared-elements.md +++ b/en/application-dev/reference/arkui-ts/ts-transition-animation-shared-elements.md @@ -1,4 +1,7 @@ -# Transition of Shared Elements +# Transition of Shared Elements + +>![](../../public_sys-resources/icon-note.gif) **NOTE:** +>This animation is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. Shared element transition can be used for transition between pages, for example, transition from an image on the current page to the next page. diff --git a/en/application-dev/reference/arkui-ts/ts-transition-animation.md b/en/application-dev/reference/arkui-ts/ts-transition-animation.md index ea0c5b7823bec374697970b4442d467f96134a5b..590b23e37aa735e0b641bb0d129f09da4972323c 100644 --- a/en/application-dev/reference/arkui-ts/ts-transition-animation.md +++ b/en/application-dev/reference/arkui-ts/ts-transition-animation.md @@ -1,4 +1,4 @@ -# Transition Animation +# Transition Animation - **[Page Transition](ts-page-transition-animation.md)** diff --git a/en/application-dev/reference/arkui-ts/ts-ui-state-mgmt-concepts.md b/en/application-dev/reference/arkui-ts/ts-ui-state-mgmt-concepts.md deleted file mode 100644 index 3418214b399b6d08faf0a65e3179bc85ccc7af75..0000000000000000000000000000000000000000 --- a/en/application-dev/reference/arkui-ts/ts-ui-state-mgmt-concepts.md +++ /dev/null @@ -1,22 +0,0 @@ -# Basic Concepts - -In the declarative UI programming paradigm, the UI is a function of an application state, and you update a UI by modifying the current application state. - -The development framework provides various application state management capabilities. - -![](figures/corespec_figures_state-mgmt-overview.png) - -## State Variable Decorators - -- **@State**: state attribute of the component. Each time the **@State** annotated variable changes, the component re-renders and updates the UI. -- **@Link**: The component depends on some state attributes of its parent component. Each time the data in one component is updated, the state of the other component is updated, and the parent and child components are rendered again. -- **@Prop**: The working principle is similar to that of **@Link**. The only difference is that the changes made by a child component are not synchronized to the parent component. - -## Application State Data - -**AppStorage** is the central "database" of the application states used in the entire UI. The UI framework creates a singleton **AppStorage** object for the application and provides the corresponding decorators and APIs for the application. - -- **@StorageLink**: The working principle of **@StorageLink\(_name_\)** is similar to that of **@Consume\(_name_\)**. The difference is that the link object with the specified name is obtained from the **AppStorage**. It establishes bidirectional binding between the UI component and **AppStorage** to synchronize data. -- **@StorageProp**: **@StorageProp\(_name_\)** synchronizes UI component attributes with the **AppStorage** unidirectionally. The value change in the **AppStorage** updates the attribute value in the component, but the UI component cannot change the attribute value in the **AppStorage**. -- The **AppStorage** also provides an API for service logic implementation. The API is used to add, read, modify, and delete the state attributes of applications. The changes made through this API will cause the modified state data to be synchronized to the UI component for UI update. - diff --git a/en/application-dev/reference/arkui-ts/ts-universal-attributes-background.md b/en/application-dev/reference/arkui-ts/ts-universal-attributes-background.md index 105457106373a2ee2bc6a1013e56d53899198621..38ccc9ff5839ffd750bf5e4f5a3673d176d12290 100644 --- a/en/application-dev/reference/arkui-ts/ts-universal-attributes-background.md +++ b/en/application-dev/reference/arkui-ts/ts-universal-attributes-background.md @@ -1,7 +1,16 @@ -# Background +# Background + +>![](../../public_sys-resources/icon-note.gif) **NOTE:** +>This attribute is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. The attributes in this topic are used to set the background color of a component. +## Required Permissions + +None + +## Attributes +

    Name

    Parameter

    +

    Type

    Description

    diff --git a/en/application-dev/reference/arkui-ts/ts-universal-attributes-border.md b/en/application-dev/reference/arkui-ts/ts-universal-attributes-border.md index 06bcb51271a75269aa517bf69205dfb6265d26d7..e26571ee07d079fa89ecb48379084e85a5032f00 100644 --- a/en/application-dev/reference/arkui-ts/ts-universal-attributes-border.md +++ b/en/application-dev/reference/arkui-ts/ts-universal-attributes-border.md @@ -1,7 +1,16 @@ -# Border Configuration +# Border Configuration + +>![](../../public_sys-resources/icon-note.gif) **NOTE:** +>This attribute is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. This section describes the settings of border styles. +## Required Permissions + +None + +## Attributes +

    Name

    diff --git a/en/application-dev/reference/arkui-ts/ts-universal-attributes-enable.md b/en/application-dev/reference/arkui-ts/ts-universal-attributes-enable.md index fa4303a59a41588717a32de3a7b22f8112dfa036..9d6b1249786664f03c83e8544e32c860aef8a6a2 100644 --- a/en/application-dev/reference/arkui-ts/ts-universal-attributes-enable.md +++ b/en/application-dev/reference/arkui-ts/ts-universal-attributes-enable.md @@ -1,11 +1,20 @@ -# Enable/Disable +# Enable/Disable + +>![](../../public_sys-resources/icon-note.gif) **NOTE:** +>This attribute is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. + +## Required Permissions + +None + +## Attributes

    Name

    - - @@ -13,9 +22,9 @@ - - diff --git a/en/application-dev/reference/arkui-ts/ts-universal-attributes-flex-layout.md b/en/application-dev/reference/arkui-ts/ts-universal-attributes-flex-layout.md index 035300f34041f66c5c82735e3b85794b1adbf217..6423acb80767eded69d695f15723ef1d92660dd5 100644 --- a/en/application-dev/reference/arkui-ts/ts-universal-attributes-flex-layout.md +++ b/en/application-dev/reference/arkui-ts/ts-universal-attributes-flex-layout.md @@ -1,7 +1,14 @@ -# Flex Layout +# Flex Layout >![](../../public_sys-resources/icon-note.gif) **NOTE:** ->The attributes described in this topic are valid only when the parent component is **Flex**. +>- This attribute is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. +>- This attribute is valid only when the parent component is a **Flex** component. + +## Required Permissions + +None + +## Attributes

    Name

    Type

    +

    Type

    Default Value

    +

    Default Value

    Description

    enabled

    boolean

    +

    boolean

    true

    +

    true

    The value true means that the component is available and can respond to operations such as clicking. The value false means that the component does not respond to operations such as clicking.

    Name

    diff --git a/en/application-dev/reference/arkui-ts/ts-universal-attributes-gradient-color.md b/en/application-dev/reference/arkui-ts/ts-universal-attributes-gradient-color.md index a3892025437454339092bd2af488934b2016a078..754e983d7efc929ff9890c9095a61be8784eafc5 100644 --- a/en/application-dev/reference/arkui-ts/ts-universal-attributes-gradient-color.md +++ b/en/application-dev/reference/arkui-ts/ts-universal-attributes-gradient-color.md @@ -1,4 +1,13 @@ -# Gradient Color +# Gradient Color + +>![](../../public_sys-resources/icon-note.gif) **NOTE:** +>This attribute is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. + +## Required Permissions + +None + +## Attributes @@ -35,7 +44,7 @@

    center: Point,

    start?: angle,

    end?: angle,

    -

    colors: Array<ColorStop>

    +

    colors: Array<ColorStop>

    repeating?: boolean

    }

    @@ -54,7 +63,7 @@ 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 b14861d3ca54b05dd4ca4d9037b3491941c35d89..941a38b140b9b86cb767935e9895a676dfed1c8e 100644 --- a/en/application-dev/reference/arkui-ts/ts-universal-attributes-grid.md +++ b/en/application-dev/reference/arkui-ts/ts-universal-attributes-grid.md @@ -1,7 +1,14 @@ -# Grid +# Grid >![](../../public_sys-resources/icon-note.gif) **NOTE:** ->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. +>- This attribute is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. +>- The column width and column gap in the grid layout are determined by the nearest parent component **GridContainer**. The component tree that uses grid attributes must contain one **GridContainer** or more. + +## Required Permissions + +None + +## Attributes

    Name

    @@ -14,9 +23,9 @@

    linearGradient

    {

    -

    angle?: Angle,

    +

    angle?: Angle,

    direction?:GradientDirection,

    -

    colors: Array<ColorStop>

    +

    colors: Array<ColorStop>

    repeating?: boolean

    }

    {

    center: Point,

    radius: Length,

    -

    colors: Array<ColorStop>

    +

    colors: Array<ColorStop>

    repeating: boolean

    }

    Name

    diff --git a/en/application-dev/reference/arkui-ts/ts-universal-attributes-image-effect.md b/en/application-dev/reference/arkui-ts/ts-universal-attributes-image-effect.md index 84dad7dcda292a38fdd8329160b092d3024c7aa8..a5e0d3e0add09867b6380c00df0b8dc8323c36d3 100644 --- a/en/application-dev/reference/arkui-ts/ts-universal-attributes-image-effect.md +++ b/en/application-dev/reference/arkui-ts/ts-universal-attributes-image-effect.md @@ -1,4 +1,13 @@ -# Image Effect Configuration +# Image Effect Configuration + +>![](../../public_sys-resources/icon-note.gif) **NOTE:** +>This attribute is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. + +## Required Permissions + +None + +## Attributes + + + + +

    Name

    @@ -88,6 +97,15 @@

    Inverts the input image. The input parameter is an image inversion ratio. The value 1 indicates complete inversion. The value 0 indicates that the image does not change. The unit is percentage.

    colorBlend 8+

    +

    Color

    +

    -

    +

    Adds the color blend effect to the current component. The input parameter is the blended color.

    +

    sepia

    number

    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 9a6499b42e2afbfed033956fe81891d2cf25ff46..cb9ef84f00640333a638c95a2bf1bb7e00cb1179 100644 --- a/en/application-dev/reference/arkui-ts/ts-universal-attributes-layout-constraints.md +++ b/en/application-dev/reference/arkui-ts/ts-universal-attributes-layout-constraints.md @@ -1,4 +1,13 @@ -# Layout Constraints +# Layout Constraints + +>![](../../public_sys-resources/icon-note.gif) **NOTE:** +>This attribute is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. + +## Required Permissions + +None + +## Attributes diff --git a/en/application-dev/reference/arkui-ts/ts-universal-attributes-location.md b/en/application-dev/reference/arkui-ts/ts-universal-attributes-location.md index 21797c3cd9337ae1fddeefebc22a32649c1f0b02..a3617a10670716c6dfa63416a42f49fede8b21c8 100644 --- a/en/application-dev/reference/arkui-ts/ts-universal-attributes-location.md +++ b/en/application-dev/reference/arkui-ts/ts-universal-attributes-location.md @@ -1,4 +1,13 @@ -# Location +# Location + +>![](../../public_sys-resources/icon-note.gif) **NOTE:** +>This attribute is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. + +## Required Permissions + +None + +## Attributes

    Name

    @@ -27,7 +36,7 @@

    -

    Sets a display priority for the current component in the layout container. When the space of the parent container is insufficient, the component with a lower priority is hidden.

    -
    NOTE:
    • This parameter is valid only for the Row/Column/Flex (single-row) container component.
    +
    NOTE:

    This parameter is valid only for the Row/Column/Flex (single-row) container component.

    Name

    diff --git a/en/application-dev/reference/arkui-ts/ts-universal-attributes-menu.md b/en/application-dev/reference/arkui-ts/ts-universal-attributes-menu.md index 77759cd3be9b6ca5a7bde7c9c9830fe4239d8d54..662930943e64d809c4d961b371be83ca95d91a3d 100644 --- a/en/application-dev/reference/arkui-ts/ts-universal-attributes-menu.md +++ b/en/application-dev/reference/arkui-ts/ts-universal-attributes-menu.md @@ -1,4 +1,13 @@ -# Menu Control +# Menu Control + +>![](../../public_sys-resources/icon-note.gif) **NOTE:** +>This attribute is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. + +## Required Permissions + +None + +## Attributes - - @@ -57,7 +66,7 @@ ``` @Entry @Component -struct menuExample { +struct MenuExample { build() { Column() { Text('click for Menu') @@ -84,3 +93,51 @@ struct menuExample { ![](figures/menu.gif) +``` +import router from '@system.router'; + +@Entry +@Component +struct MenuExample { + @Builder MenuBuilder() { + Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) { + Text('text1') + .fontSize(20) + .width(100) + .height(50) + .textAlign(TextAlign.Center) + + Divider().height(10) + + Text('text2') + .fontSize(20) + .width(100) + .height(50) + .textAlign(TextAlign.Center) + + Divider().height(10) + + Button('Next') + .fontSize(20) + .width(100) + .height(50) + .onClick(() => { + router.push({ uri: 'pages/details' }) + }) + + }.width(100) + } + + build() { + Column() { + Text('click for menu') + } + .width('100%') + .margin({ top: 5 }) + .bindMenu(this.MenuBuilder) + } +} +``` + +![](figures/gif.gif) + diff --git a/en/application-dev/reference/arkui-ts/ts-universal-attributes-opacity.md b/en/application-dev/reference/arkui-ts/ts-universal-attributes-opacity.md index 05bb0fddfd3d678cd86c4ca8e8398835a3c7ca0d..1103e964b2be11cae8ab1872dbfeab81838b3c32 100644 --- a/en/application-dev/reference/arkui-ts/ts-universal-attributes-opacity.md +++ b/en/application-dev/reference/arkui-ts/ts-universal-attributes-opacity.md @@ -1,7 +1,16 @@ -# Opacity +# Opacity + +>![](../../public_sys-resources/icon-note.gif) **NOTE:** +>This attribute is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. The attributes described in this topic are used to set the opacity of a component. +## Required Permissions + +None + +## Attributes +

    Name

    @@ -13,11 +22,11 @@

    bindMenu

    Array<MenuItem>

    +

    Array<MenuItem> | CustomBuilder8+

    -

    Binds the menu to a component. If you click a component bound to the menu, the menu is displayed.

    +

    Binds the menu to a component. If you click a component bound to the menu, the menu is displayed. The menu can be in text or custom type.

    diff --git a/en/application-dev/reference/arkui-ts/ts-universal-attributes-overlay.md b/en/application-dev/reference/arkui-ts/ts-universal-attributes-overlay.md index d92cfd65b8bde783914a74e830364ce0db2df4fb..005b5faf00fb2dbec0b720fd7e7cbd700617773d 100644 --- a/en/application-dev/reference/arkui-ts/ts-universal-attributes-overlay.md +++ b/en/application-dev/reference/arkui-ts/ts-universal-attributes-overlay.md @@ -1,4 +1,13 @@ -# Overlay +# Overlay + +>![](../../public_sys-resources/icon-note.gif) **NOTE:** +>This attribute is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. + +## Required Permissions + +None + +## Attributes

    Name

    Name

    @@ -44,7 +53,7 @@ struct OverlayExample { Column() { Image($r('app.media.img')) .width(240).height(240) - .overlay("Don't walk and play with your phone.", { align: Alignment.Bottom, offset: { x: 0, y: -15 } }) + .overlay("Winter is a beautiful season, especially when it snows.", { align: Alignment.Bottom, offset: { x: 0, y: -15 } }) }.border({ color: Color.Black, width: 2 }) }.width('100%') }.padding({ top: 20 }) @@ -52,5 +61,5 @@ struct OverlayExample { } ``` -![](figures/overlay.gif) +![](figures/en-us_image_0000001194911566.png) diff --git a/en/application-dev/reference/arkui-ts/ts-universal-attributes-popup.md b/en/application-dev/reference/arkui-ts/ts-universal-attributes-popup.md index 44fe93b09dfbe3c1d4c380a20ed07d9efcd443e3..e0ec8e6def24f08eecdacc1233f563abe4427a43 100644 --- a/en/application-dev/reference/arkui-ts/ts-universal-attributes-popup.md +++ b/en/application-dev/reference/arkui-ts/ts-universal-attributes-popup.md @@ -1,48 +1,271 @@ -# Popup Control +# Popup Control - -

    Name

    +>![](../../public_sys-resources/icon-note.gif) **NOTE:** +>This attribute is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. + +## Required Permissions + +None + +## Attributes + + + - - - - - - -

    Name

    Type

    +

    Type

    Default Value

    +

    Default Value

    Description

    +

    Description

    bindPopup

    +

    bindPopup

    {

    -

    show: boolean,

    -

    popup: {

    -

    message: string,

    -

    placementOnTop: boolean,

    -

    primaryButton?: {

    -

    value: string,

    -

    action: ()=>void

    -

    },

    -

    secondaryButton?:{

    -

    value: string,

    -

    action: () =>void

    -

    },

    -

    onStateChange?: (isVisible: boolean) => void

    -

    }

    -

    }

    +

    show: boolean,

    +

    popup: PopupOption | CustomPopupOption

    -

    +

    -

    show: whether to display the current popup message. The default value is false.

    -

    message: content of the popup message.

    -

    placementOnTop: whether to display the popup message above the component. The default value is false.

    -

    primaryButton: first button.

    -

    secondaryButton: second button.

    -

    onStateChange: callback for the popup window status change event. The argument is the visibility status of the current popup window.

    +

    Settings of the popup bound to a component.

    +

    show: whether to display the popup message on the creation page by default. The default value is false.

    +

    popup: parameters of the current popup window.

    +- PopupOption APIs + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

    Name

    +

    Type

    +

    Mandatory

    +

    Default Value

    +

    Description

    +

    message

    +

    string

    +

    Yes

    +

    -

    +

    Content of the popup message.

    +

    placementOnTop

    +

    boolean

    +

    No

    +

    false

    +

    Whether to display the popup message above the component. The default value is false.

    +

    primaryButton

    +

    {

    +

    value: string,

    +

    action: () => void

    +

    }

    +

    No

    +

    -

    +

    The first button.

    +

    value: text of the primary button in the popup.

    +

    action: callback function for tapping the primary button.

    +

    secondaryButton

    +

    {

    +

    value: string,

    +

    action: () => void

    +

    }

    +

    No

    +

    -

    +

    Second button.

    +

    value: text of the secondary button in the popup.

    +

    action: callback function for tapping the secondary button.

    +

    onStateChange

    +

    (isVisible: boolean) => void

    +

    No

    +

    -

    +

    Callback for the popup status change event. The parameter isVisible indicates the visibility of the popup.

    +
    + +- CustomPopupOption APIs8+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

    Name

    +

    Type

    +

    Mandatory

    +

    Default Value

    +

    Description

    +

    builder

    +

    () => any

    +

    Yes

    +

    -

    +

    Builder of the tooltip content.

    +

    placement

    +

    Placement

    +

    No

    +

    Placement.Bottom

    +

    Preferred position of the tooltip component. If the set position is insufficient for holding the component, it will be automatically adjusted.

    +

    maskColor

    +

    Color

    +

    No

    +

    -

    +

    Color of the tooltip mask.

    +

    popupColor

    +

    Color

    +

    No

    +

    -

    +

    Color of the tooltip.

    +

    enableArrow

    +

    boolean

    +

    No

    +

    true

    +

    Whether to display arrows. Arrows are displayed only for tooltips in the up and down directions.

    +

    autoCancel

    +

    boolean

    +

    No

    +

    true

    +

    Whether to automatically close the tooltip when an operation is performed on the page.

    +

    onStateChange

    +

    (isVisible: boolean) => void

    +

    No

    +

    -

    +

    Callback for the popup status change event. The parameter isVisible indicates the visibility of the popup.

    +
    + +- Placement enums8+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

    Name

    +

    Description

    +

    Left

    +

    The tooltip is on the left of the component.

    +

    Right

    +

    The tooltip is on the right of the component.

    +

    Top

    +

    The tooltip is on the top of the component.

    +

    Bottom

    +

    The tooltip is at the bottom of the component.

    +

    TopLeft

    +

    The tooltip is in the upper left corner of the component.

    +

    TopRight

    +

    The tooltip is in the upper right corner of the component.

    +

    BottomLeft

    +

    The tooltip is in the lower left corner of the component.

    +

    BottomRight

    +

    The tooltip is in the lower right corner of the component.

    +
    + + ## Example ``` @@ -51,16 +274,23 @@ struct PopupExample { @State noHandlePopup: boolean = false @State handlePopup: boolean = false + @State customPopup: boolean = false + + @Builder popupBuilder() { + Row({ space: 2 }) { + Image('/resource/ic_public_thumbsup.svg').width(24).height(24).margin({ left: -5 }) + Text('Custom Popup').fontSize(12) + }.width(100).height(50).backgroundColor(Color.White) + } build() { - Column({ space: 160 }) { + Flex({ direction: FlexDirection.Column }) { Button('no handle popup') .onClick(() => { this.noHandlePopup = !this.noHandlePopup }) .bindPopup(this.noHandlePopup, { - - message: 'content content content ...', + message: 'content1 content1', placementOnTop: false, onStateChange: (e) => { console.info(e.isVisible.toString()) @@ -68,18 +298,17 @@ struct PopupExample { this.noHandlePopup = false } } - }) + }) + .position({ x: 100, y: 50 }) Button('with handle popup') .onClick(() => { this.handlePopup = !this.handlePopup }) .bindPopup(this.handlePopup, { - - message: 'content content content ...', + message: 'content2 content2', placementOnTop: true, - secondaryButton: { - + primaryButton: { value: 'ok', action: () => { this.handlePopup = !this.handlePopup @@ -90,6 +319,25 @@ struct PopupExample { console.info(e.isVisible.toString()) } }) + .position({ x: 100, y: 200 }) + + Button('custom popup') + .onClick(() => { + this.customPopup = !this.customPopup + }) + .bindPopup(this.customPopup, { + builder: this.popupBuilder, + placement: Placement.Bottom, + maskColor: 0x33000000, + popupColor: Color.White, + enableArrow: true, + onStateChange: (e) => { + if (!e.isVisible) { + this.customPopup = false + } + } + }) + .position({ x: 100, y: 350 }) }.width('100%').padding({ top: 5 }) } } diff --git a/en/application-dev/reference/arkui-ts/ts-universal-attributes-response-region.md b/en/application-dev/reference/arkui-ts/ts-universal-attributes-response-region.md new file mode 100644 index 0000000000000000000000000000000000000000..cf71d324e4ed22f3bee1ef83a1c8b57bb88c1339 --- /dev/null +++ b/en/application-dev/reference/arkui-ts/ts-universal-attributes-response-region.md @@ -0,0 +1,133 @@ +# Touch Target + +>![](../../public_sys-resources/icon-note.gif) **NOTE:** +>This attribute is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version. + +You can set the touch target for components that support universal click events, touch events, and gestures. + +## Required Permissions + +None + +## Attributes + + + + + + + + + + + + + + +

    Name

    +

    Type

    +

    Default Value

    +

    Description

    +

    responseRegion

    +

    Array<Rectangle> | Rectangle

    +

    {

    +

    x: 0,

    +

    y:0,

    +

    width:'100%',

    +

    height:'100%'

    +

    }

    +

    Indicates one or more touch targets, including their location and size.

    +
    NOTE:

    The percentage is measured relative to the component itself.

    +

    x and y can be set to a positive or negative percentage value. For example, when x is set to '100%', the touch target is offset from the right edge of the component by the component's width. When x is set to '-100%', the touch target is offset from the left edge of the component by the component's width. When y is set to '100%', the touch target is offset from the bottom edge of the component by the component's height. When y is set to '-100%', the touch target is offset from the top edge of the component by the component's height.

    +

    width and height can only be set to positive percentage values. For example, when width is set to '100%', the width of the touch target is equal to that of the component; when height is set to '100%', the height of the touch target is equal to that of the component.

    +
    +
    + +- Rectangle object + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

    Name

    +

    Type

    +

    Mandatory

    +

    Default Value

    +

    Description

    +

    x

    +

    Length

    +

    No

    +

    0vp

    +

    X coordinate of the touch point relative to the left edge of the component.

    +

    y

    +

    Length

    +

    No

    +

    0vp

    +

    Y coordinate of the touch point relative to the left edge of the component.

    +

    width

    +

    Length

    +

    No

    +

    100%

    +

    Width of the touch target.

    +

    height

    +

    Length

    +

    No

    +

    100%

    +

    Height of the touch target.

    +
    + + >![](../../public_sys-resources/icon-note.gif) **NOTE:** + >When both **x** and **y** are set to positive values, the entire touch target offsets towards the lower right corner of the component. How much the touch target offsets is subject to the set values. + + +## Example + +``` +@Entry +@Component +struct ResponseRegionExample { + build() { + Column() { + Toggle({ type: ToggleType.Checkbox, isOn: true }) + .selectedColor(0x39a2db) + .backgroundColor(0xAFEEEE) + .responseRegion({ x: 1.0, y: 1.0, width: 400, height: 400 }) + .onChange((isOn: boolean) => { + console.info('Component status:' + isOn) + }) + }.width('100%').margin({ top: 5 }) + } +} +``` + +![](figures/gif1.gif) + diff --git a/en/application-dev/reference/arkui-ts/ts-universal-attributes-sharp-clipping.md b/en/application-dev/reference/arkui-ts/ts-universal-attributes-sharp-clipping.md index c7e6118207a621fa1249937177060ae104533b31..0fb7dd4f8881ad4258e2d887e6a9004d0ce0cd16 100644 --- a/en/application-dev/reference/arkui-ts/ts-universal-attributes-sharp-clipping.md +++ b/en/application-dev/reference/arkui-ts/ts-universal-attributes-sharp-clipping.md @@ -1,4 +1,13 @@ -# Shape Clipping +# Shape Clipping + +>![](../../public_sys-resources/icon-note.gif) **NOTE:** +>This attribute is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. + +## Required Permissions + +None + +## Attributes

    Name

    diff --git a/en/application-dev/reference/arkui-ts/ts-universal-attributes-size.md b/en/application-dev/reference/arkui-ts/ts-universal-attributes-size.md index 74b58e40645efc6af9cdcc881928a341fb902128..dbac35d7acd691ff16880f42955607a30fb80f8b 100644 --- a/en/application-dev/reference/arkui-ts/ts-universal-attributes-size.md +++ b/en/application-dev/reference/arkui-ts/ts-universal-attributes-size.md @@ -1,11 +1,18 @@ -# Size +# Size -This topic describes the attributes used to set the component size. +>![](../../public_sys-resources/icon-note.gif) **NOTE:** +>This attribute is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. + +## Required Permissions + +None + +## Attributes -

    Name

    + - @@ -13,27 +20,27 @@ This topic describes the attributes used to set the component size. - - - - - - - - - - - - - - diff --git a/en/application-dev/reference/arkui-ts/ts-universal-attributes-text-style.md b/en/application-dev/reference/arkui-ts/ts-universal-attributes-text-style.md index 225d274ceb309b91158e2a2e7ef57896e662cbd9..d793202b2815247310b306b50a98b2f835ed1ec5 100644 --- a/en/application-dev/reference/arkui-ts/ts-universal-attributes-text-style.md +++ b/en/application-dev/reference/arkui-ts/ts-universal-attributes-text-style.md @@ -1,7 +1,16 @@ -# Text Style +# Text Style + +>![](../../public_sys-resources/icon-note.gif) **NOTE:** +>This attribute is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. The attributes described in this topic are used to set the text style for a component that contains text. +## Required Permissions + +None + +## Attributes +

    Name

    Type

    +

    Type

    Default Value

    width

    +

    width

    Length

    +

    Length

    -

    Width of a component. By default, the width required to fully hold the component content is used.

    height

    +

    height

    Length

    +

    Length

    -

    Height of the component. By default, the height required to fully hold the component content is used.

    size

    +

    size

    {

    +

    {

    width?: Length,

    height?: Length

    }

    @@ -43,9 +50,9 @@ This topic describes the attributes used to set the component size.

    Height and width of the component.

    padding

    +

    padding

    {

    +

    {

    top?: Length,

    right?: Length,

    bottom?: Length,

    @@ -58,9 +65,9 @@ This topic describes the attributes used to set the component size.

    When the parameter is of the Length type, the four paddings take effect.

    margin

    +

    margin

    {

    +

    {

    top?: Length,

    right?: Length,

    bottom?: Length,

    @@ -74,13 +81,13 @@ This topic describes the attributes used to set the component size.

    When the parameter is of the Length type, the four margins take effect.

    constraintSize

    +

    constraintSize

    {

    +

    {

    minWidth?: Length,

    maxWidth?: Length,

    minHeight?: Length,

    -

    maxHeight?: Length

    +

    maxHeight?: Lenght

    }

    {

    @@ -93,9 +100,9 @@ This topic describes the attributes used to set the component size.

    Constraint size of the component, which is used to limit the size range during component layout.

    layoutWeight

    +

    layoutWeight

    number

    +

    number

    0

    diff --git a/en/application-dev/reference/arkui-ts/ts-universal-attributes-touchable.md b/en/application-dev/reference/arkui-ts/ts-universal-attributes-touchable.md new file mode 100644 index 0000000000000000000000000000000000000000..b657f8645c805a602937716d43743016ee5fc99b --- /dev/null +++ b/en/application-dev/reference/arkui-ts/ts-universal-attributes-touchable.md @@ -0,0 +1,65 @@ +# Click Control + +>![](../../public_sys-resources/icon-note.gif) **NOTE:** +>This attribute is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version. + +## Required Permissions + +None + +## Attributes + + +

    Name

    + + + + + + + + + + + +

    Name

    +

    Type

    +

    Default Value

    +

    Description

    +

    touchable

    +

    boolean

    +

    true

    +

    Whether the current component is touchable.

    +
    + +## Example + +``` +@Entry +@Component +struct TouchAbleExample { + @State text1: string = '' + @State text2: string = '' + + build() { + Stack() { + Rect() + .fill(Color.Gray).width(150).height(150) + .onClick(() => { + console.info(this.text1 = 'Rect Clicked') + }) + .overlay(this.text1, { align: Alignment.Bottom, offset: { x: 0, y: 20 } }) + Ellipse() + .fill(Color.Pink).width(150).height(80) + .touchable(false) // When the Ellipse area is touched, the message "Ellipse Clicked" is not displayed. + .onClick(() => { + console.info(this.text2 = 'Ellipse Clicked') + }) + .overlay(this.text2, { align: Alignment.Bottom, offset: { x: 0, y: 20 } }) + }.margin(100) + } +} +``` + +![](figures/gif2.gif) + diff --git a/en/application-dev/reference/arkui-ts/ts-universal-attributes-transformation.md b/en/application-dev/reference/arkui-ts/ts-universal-attributes-transformation.md index 6f9ba8247b8b3d3a975a9e777471a17c5f1fe985..10ced26c5df07aa57727c633231be1d7bbb90f55 100644 --- a/en/application-dev/reference/arkui-ts/ts-universal-attributes-transformation.md +++ b/en/application-dev/reference/arkui-ts/ts-universal-attributes-transformation.md @@ -1,4 +1,13 @@ -# Transformation +# Transformation + +>![](../../public_sys-resources/icon-note.gif) **NOTE:** +>This attribute is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. + +## Required Permissions + +None + +## Attributes

    Name

    @@ -125,5 +134,5 @@ struct TransformExample { } ``` -![](figures/1111-59.png) +![](figures/1111.png) diff --git a/en/application-dev/reference/arkui-ts/ts-universal-attributes-visibility.md b/en/application-dev/reference/arkui-ts/ts-universal-attributes-visibility.md index 0e5ad66ef588156f5bdb35c8197ad144647eadd7..0d1e059339f91505df8d52c44d6e517bffb9f148 100644 --- a/en/application-dev/reference/arkui-ts/ts-universal-attributes-visibility.md +++ b/en/application-dev/reference/arkui-ts/ts-universal-attributes-visibility.md @@ -1,4 +1,13 @@ -# Visibility +# Visibility + +>![](../../public_sys-resources/icon-note.gif) **NOTE:** +>This attribute is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. + +## Required Permissions + +None + +## Attributes

    Name

    diff --git a/en/application-dev/reference/arkui-ts/ts-universal-attributes-z-order.md b/en/application-dev/reference/arkui-ts/ts-universal-attributes-z-order.md index 5ee46c6c64bb6a072d19f3faac63f84eba13a775..91770cb64ef08cd8209c9ce6d9969d708ebd9f3b 100644 --- a/en/application-dev/reference/arkui-ts/ts-universal-attributes-z-order.md +++ b/en/application-dev/reference/arkui-ts/ts-universal-attributes-z-order.md @@ -1,4 +1,13 @@ -# Z-order Control +# Z-order Control + +>![](../../public_sys-resources/icon-note.gif) **NOTE:** +>This attribute is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. + +## Required Permissions + +None + +## Attributes - diff --git a/en/application-dev/reference/arkui-ts/ts-syntactic-sugar-struct.md b/en/application-dev/ui/ts-syntactic-sugar-struct.md similarity index 65% rename from en/application-dev/reference/arkui-ts/ts-syntactic-sugar-struct.md rename to en/application-dev/ui/ts-syntactic-sugar-struct.md index f91afd6f455c093c85c061d084ab2565dda6b558..3755803f5de09fc94442c2597531366c5d70e964 100644 --- a/en/application-dev/reference/arkui-ts/ts-syntactic-sugar-struct.md +++ b/en/application-dev/ui/ts-syntactic-sugar-struct.md @@ -1,6 +1,6 @@ # struct -Components can be implemented based on **structs**. Components cannot inherit from each other. The **struct** implemented components can be created and destroyed more quickly than **class** implemented components. +Components can be implemented based on **struct**s. Components cannot inherit from each other. The **struct**s implemented components can be created and destroyed more quickly than **class** implemented components. ``` @Component diff --git a/en/application-dev/reference/arkui-ts/ts-syntactic-sugar.md b/en/application-dev/ui/ts-syntactic-sugar.md similarity index 59% rename from en/application-dev/reference/arkui-ts/ts-syntactic-sugar.md rename to en/application-dev/ui/ts-syntactic-sugar.md index b849fcc20b90993b5bc561dfc823832c25dd9958..088e9598c05662fe8f3331c94a4b1980377f432f 100644 --- a/en/application-dev/reference/arkui-ts/ts-syntactic-sugar.md +++ b/en/application-dev/ui/ts-syntactic-sugar.md @@ -1,8 +1,8 @@ -# Syntactic Sugar +# About Syntactic Sugar - **[@Decorator](ts-syntactic-sugar-decorator.md)** -- **[Chaining](ts-syntactic-sugar-chaining.md)** +- **[Chain Call](ts-syntactic-sugar-chaining.md)** - **[struct](ts-syntactic-sugar-struct.md)** @@ -10,6 +10,6 @@ - **[Using a Separate Line for New Component](ts-using-a-separate-line-for-new-component.md)** -- **[Restrictions on Using the TS Language for Generators](ts-restrictions-for-generators.md)** +- **[Restrictions on Using TypeScript for Generators](ts-restrictions-for-generators.md)** diff --git a/en/application-dev/ui/ts-syntax-intro.md b/en/application-dev/ui/ts-syntax-intro.md new file mode 100644 index 0000000000000000000000000000000000000000..87fdf54d31c403eda07675cb8a6d11924a857b94 --- /dev/null +++ b/en/application-dev/ui/ts-syntax-intro.md @@ -0,0 +1,11 @@ +# Overview + +This section defines the core mechanism and functions of the TypeScript-based declarative development paradigm. It acquaints you with the declarative UI descriptions, componentization mechanisms, UI state management, rendering control syntax, and syntactic sugar. + +Follow the provided guidelines for UI development. For details about the components, see [Components](../reference/arkui-js/js-components.md). + +>![](../public_sys-resources/icon-note.gif) **NOTE:** +>- All examples use the TypeScript \(TS\) language. If you are using another language, comply with the syntax requirements for that language. +>- The components used in the examples are preset in the UI framework and are used only to explain the UI description specifications. +>- Universal attribute and event methods generally apply to all components, and the attribute and event methods within a component apply only to this component. + diff --git a/en/application-dev/reference/arkui-ts/ts-types.md b/en/application-dev/ui/ts-types.md similarity index 97% rename from en/application-dev/reference/arkui-ts/ts-types.md rename to en/application-dev/ui/ts-types.md index f1c591f6a7d172ffe916ac256e81471e65824fb0..41b4e8f0a838e1e469834fd97ee057c444f70a0c 100644 --- a/en/application-dev/reference/arkui-ts/ts-types.md +++ b/en/application-dev/ui/ts-types.md @@ -104,70 +104,70 @@ The following colors are supported. - - - - - - - - - - diff --git a/en/application-dev/reference/arkui-ts/ts-ui-state-management.md b/en/application-dev/ui/ts-ui-state-management.md similarity index 79% rename from en/application-dev/reference/arkui-ts/ts-ui-state-management.md rename to en/application-dev/ui/ts-ui-state-management.md index 3e67b9cacbc12d9304a07a387badfa94ab0981cd..fd37d287c456038cc1a9709048a71255d8ab6722 100644 --- a/en/application-dev/reference/arkui-ts/ts-ui-state-management.md +++ b/en/application-dev/ui/ts-ui-state-management.md @@ -1,4 +1,4 @@ -# UI State Management +# About UI State Management - **[Basic Concepts](ts-ui-state-mgmt-concepts.md)** diff --git a/en/application-dev/ui/ts-ui-state-mgmt-concepts.md b/en/application-dev/ui/ts-ui-state-mgmt-concepts.md new file mode 100644 index 0000000000000000000000000000000000000000..d53e914453096d1b2248a372ddf812a7655ca9ae --- /dev/null +++ b/en/application-dev/ui/ts-ui-state-mgmt-concepts.md @@ -0,0 +1,22 @@ +# Basic Concepts + +In the declarative UI programming paradigm, the UI is a function in the specific application state, and you update a UI by modifying the current application state. + +The development framework provides comprehensive application state management capabilities, as shown in the figure below. + +![](figures/corespec_figures_state-mgmt-overview.png) + +## State Variable Decorators + +- **@State**: grants a component the state attribute. Each time the **@State** decorated variable changes, the component re-renders and updates the UI. +- **@Link**: allows a component to depend on some state attributes of its parent component. Each time the data in one component is updated, the state of the other component is updated, and the parent and child components are rendered again. +- **@Prop**: works in a way similar to that of **@Link**. The only difference is that the changes made by a child component are not synchronized to the parent component. + +## Application State Data + +**AppStorage** is the central store of the application states used in the entire UI. The UI framework creates a singleton **AppStorage** object for the application and provides the corresponding decorators and APIs for the application. + +- **@StorageLink**: works in a way similar to that of **@Consume**. The difference is that the link object with the specified name is obtained from the **AppStorage**. It establishes two-way binding between the UI component and **AppStorage** to synchronize data. +- **@StorageProp**: synchronizes UI component attributes with the **AppStorage** unidirectionally. The value change in the **AppStorage** will trigger an update of the attribute value in the UI component, but the attribute value of the UI component will not cause an update of the attribute value in the **AppStorage**. +- Service logic implementation API: adds, reads, modifies, or deletes the state attributes of applications. The changes made by this API will be synchronized to the UI component for UI update. + diff --git a/en/application-dev/reference/arkui-ts/ts-using-a-separate-line-for-new-component.md b/en/application-dev/ui/ts-using-a-separate-line-for-new-component.md similarity index 87% rename from en/application-dev/reference/arkui-ts/ts-using-a-separate-line-for-new-component.md rename to en/application-dev/ui/ts-using-a-separate-line-for-new-component.md index 3a0536d98a93897c6aa601b651e4e33455147b20..9a220f54a95d24d195d3ab1dad5004f12223feb6 100644 --- a/en/application-dev/reference/arkui-ts/ts-using-a-separate-line-for-new-component.md +++ b/en/application-dev/ui/ts-using-a-separate-line-for-new-component.md @@ -18,7 +18,7 @@ Column() { } ``` -**Only one component can be created in each line. The if, else, else if, or ForEach statement is in a separate line.** +**Only one component can be created in a line. An if, else, else if, or ForEach statement must also be in a separate line.** Incorrect: diff --git a/en/application-dev/ui/ui-arkui-js.md b/en/application-dev/ui/ui-arkui-js.md index 9ed2b873bef4c04638941cbf31ad1c0c5d96bee6..f43f305fc3ddc40343a1d3f7d685a7bf394c04aa 100644 --- a/en/application-dev/ui/ui-arkui-js.md +++ b/en/application-dev/ui/ui-arkui-js.md @@ -1,7 +1,9 @@ -# JavaScript-based Web-like Development Paradigm +# JavaScript-based Web-Like Development Paradigm - **[Overview](ui-js-overview.md)** +- **[Framework](js-framework.md)** + - **[Building the UI](ui-js-building-ui.md)** - **[Common Component Development Guidelines](ui-js-common-components.md)** diff --git a/en/application-dev/ui/ui-arkui-ts.md b/en/application-dev/ui/ui-arkui-ts.md index 2e8148cc565fccc9bf3c03604a426717dfe0d7a2..e22bf628a98afc6c86be83f65da7c83492d45e51 100644 --- a/en/application-dev/ui/ui-arkui-ts.md +++ b/en/application-dev/ui/ui-arkui-ts.md @@ -1,10 +1,12 @@ -# TypeScript-based Declarative Development Paradigm +# TypeScript-based Declarative Development Paradigm - **[Overview](ui-ts-overview.md)** -- **[Introduction](ui-ts-developing-intro.md)** +- **[Framework Overview](ts-framework.md)** -- **[Experiencing the Declarative UI](ui-ts-experiencing-declarative--u.md)** +- **[Declarative Syntax](ts-declarative-syntax.md)** + +- **[Experiencing the Declarative UI](ui-ts-experiencing-declarative-ui.md)** - **[Defining Page Layout and Connection](ui-ts-page-layout-connections.md)** diff --git a/en/application-dev/ui/ui-arkui.md b/en/application-dev/ui/ui-arkui.md index 696a0040ac9c753c473cdc4791ab3591601b3997..669dfd6203114becefec73cfbb2914c182036c4c 100644 --- a/en/application-dev/ui/ui-arkui.md +++ b/en/application-dev/ui/ui-arkui.md @@ -1,6 +1,6 @@ -# ArkUI +# ArkUI -- **[JavaScript-based Web-like Development Paradigm](ui-arkui-js.md)** +- **[JavaScript-based Web-Like Development Paradigm](ui-arkui-js.md)** - **[TypeScript-based Declarative Development Paradigm](ui-arkui-ts.md)** diff --git a/en/application-dev/ui/ui-js-animate-attribute-style.md b/en/application-dev/ui/ui-js-animate-attribute-style.md index 9afae8fdce62fe1e89180f004cf64d246dddec8c..7060d95c005843a954ad0850ac8acf4258743cc3 100644 --- a/en/application-dev/ui/ui-js-animate-attribute-style.md +++ b/en/application-dev/ui/ui-js-animate-attribute-style.md @@ -1,6 +1,6 @@ -# Attribute Style Animation +# Defining Attribute Style Animations -In [Keyframes](../reference/arkui-js/js-components-common-methods.md#table1491078445), dynamically set the width and height of the parent component to scale the component. Set the **scale** attribute for child components to scale the parent and child components at the same time. Then, set the **opacity** attribute to display or hide parent and child components. +Keyframes is used to scale a component by dynamically setting the width and height of its parent component. Set the **scale** attribute for child components to scale the child and parent components at the same time. Then, set the **opacity** attribute to display or hide the child and parent components. ``` @@ -56,7 +56,7 @@ text{ opacity: 0; } } -/* Parent component scaling */ +/* Scaling of the parent component */ @keyframes change1{ 0% { width: 20%; @@ -67,7 +67,7 @@ text{ height: 200px; } } -/* Text scaling of child components */ +/* Text scaling of the child component */ @keyframes change2{ 0%{ transform: scale(0); @@ -81,6 +81,6 @@ text{ ![](figures/d1.gif) >![](../public_sys-resources/icon-note.gif) **NOTE:** ->1. The values of animation attributes are not sequenced. The values of **duration** and **delay** are parsed based on the sequence in which they are displayed. +>1. The values of **animation** attributes are not sequenced. However, the values of **duration** and **delay** are parsed based on the sequence in which they are displayed. >2. The **animation-duration** attribute must be set. Otherwise, the duration is 0, which means there is no animation effect. When **animation-fill-mode** is set to **forwards**, the component directly displays the style of the last frame. diff --git a/en/application-dev/ui/ui-js-animate-background-position-style.md b/en/application-dev/ui/ui-js-animate-background-position-style.md index 60d8152b40811a25663a8cbf3a9c125fe2eac370..a0be0d599a8020166cd7dc3fc294ad7781e1608f 100644 --- a/en/application-dev/ui/ui-js-animate-background-position-style.md +++ b/en/application-dev/ui/ui-js-animate-background-position-style.md @@ -1,6 +1,6 @@ # Defining Animations with the background-position Attribute -By changing the **background-position** attribute \(where the first value is the position of the x-axis and the second value is the position on the y-axis\), you move a background image. If the background image goes beyond the respective component boundaries, the excess parts will not be displayed. +By changing the **background-position** attribute \(where the first value is the position on the x-axis and the second value is the position on the y-axis\), you move a background image. If the background image goes beyond the respective component boundaries, the excess parts will not be displayed. ``` @@ -77,5 +77,5 @@ By changing the **background-position** attribute \(where the first value is t ![](figures/q8.gif) >![](../public_sys-resources/icon-note.gif) **NOTE:** ->The **background-position** attribute can only be used to move background images and does not work with **background-color**. +>The **background-position** attribute can only be used to move background images, but not the background color \(**background-color**\). diff --git a/en/application-dev/ui/ui-js-animate-component.md b/en/application-dev/ui/ui-js-animate-component.md index ad980cb95cf1500949a651e67ca8589483c784df..a81efad3851a78467643141a164977281577df5a 100644 --- a/en/application-dev/ui/ui-js-animate-component.md +++ b/en/application-dev/ui/ui-js-animate-component.md @@ -57,15 +57,15 @@ export default { } ``` -![](figures/1-19.gif) +![](figures/1-14.gif) >![](../public_sys-resources/icon-note.gif) **NOTE:** ->- When using the **animate** method, you must pass the [Keyframes](../reference/arkui-js/js-components-common-methods.md#table1491078445) and [Options](../reference/arkui-js/js-components-common-methods.md#table587915341817) parameters. ->- If **animate** is called for multiple times and the replace policy is used, parameters passed to the last call will take effect. +>- When using the **animate** method, you must pass the keyframes and options parameters. +>- If **animate** is called multiple times and the **replace** policy is used, parameters passed to the last call will take effect. ## Setting Animation Parameters -After obtaining an **animation** object, you can set its style working on the component with the [Keyframes](../reference/arkui-js/js-components-common-methods.md#table1491078445) parameter. +After obtaining an **animation** object, you can set its style working on the component by using the keyframes parameter. ``` @@ -134,13 +134,13 @@ export default { } ``` -![](figures/1-20.gif) +![](figures/1-15.gif) >![](../public_sys-resources/icon-note.gif) **NOTE:** >- The sequence of **translate**, **scale**, and **rotate** affects the animation effect. >- **transformOrigin** works only for **scale** and **rotate**. -Set the animation attributes with the [Options](../reference/arkui-js/js-components-common-methods.md#table587915341817) parameter. +Set the animation attributes by using the options parameter. ``` @@ -201,18 +201,18 @@ export default { } ``` -![](figures/3-21.gif) +![](figures/3-16.gif) >![](../public_sys-resources/icon-note.gif) **NOTE:** >**direction**: mode of playing the animation. >**normal**: plays the animation in forward loop mode. >**reverse**: plays the animation in reverse loop mode. >**alternate**: plays the animation in alternating loop mode. When the animation is played for an odd number of times, the playback is in forward direction. When the animation is played for an even number of times, the playback is in reverse direction. ->**alternate-reverse**: plays the animation in reverse-alternating loop mode. When the animation is played for an odd number of times, the playback is in reverse direction. When the animation is played for an even number of times, the playback is in forward direction. +>**alternate-reverse**: plays the animation in reverse alternating loop mode. When the animation is played for an odd number of times, the playback is in reverse direction. When the animation is played for an even number of times, the playback is in forward direction. ## Adding an Event and Calling a Method -Animation objects support animation events and methods. You can achieve the intended animation by adding start and cancel events and calling the play, pause, rewind, and stop methods. +Animation objects support animation events and methods. You can achieve the intended animation by adding **start** and **cancel** events and calling the **play**, **pause**, **rewind**, and **stop** methods. ``` @@ -336,7 +336,7 @@ export default { } ``` -![](figures/111-22.gif) +![](figures/111-17.gif) Change the animation status by changing the **playStat** attribute. diff --git a/en/application-dev/ui/ui-js-animate-css.md b/en/application-dev/ui/ui-js-animate-css.md index b9d00720bcf377158dabd45709fc6f15786b0e62..c5103fa5fe9b0a6f7535fa815be625dd1b6b0af5 100644 --- a/en/application-dev/ui/ui-js-animate-css.md +++ b/en/application-dev/ui/ui-js-animate-css.md @@ -1,5 +1,9 @@ # CSS Animation +- **[Defining Attribute Style Animations](ui-js-animate-attribute-style.md)** + +- **[Defining Animations with the transform Attribute](ui-js-animate-transform.md)** + - **[Defining Animations with the background-position Attribute](ui-js-animate-background-position-style.md)** diff --git a/en/application-dev/ui/ui-js-animate-dynamic-effects.md b/en/application-dev/ui/ui-js-animate-dynamic-effects.md index a80f849b282d1fec713c62bd7347c3d4ac9a6e01..d566b7bee31f6c3a57953b38589861d42e876515 100644 --- a/en/application-dev/ui/ui-js-animate-dynamic-effects.md +++ b/en/application-dev/ui/ui-js-animate-dynamic-effects.md @@ -1,13 +1,13 @@ # Animation Effect -You can set the interpolator to implement the animation effect. For details, see Animation. +You can set the interpolator to implement the animation effect. For details, see [Animation](../reference/apis/js-apis-basic-features-animator.md). >![](../public_sys-resources/icon-note.gif) **NOTE:** >This feature is supported since API version 6. ## Creating an Animation Object -Use **createAnimator** to create an animation object and set the animation attributes with the [options](../reference/arkui-js/js-components-common-methods.md#table587915341817) parameter. +Use **createAnimator** to create an **animation** object and set the **animation** attributes by using the options parameter. ``` @@ -81,7 +81,7 @@ export default { ## Adding Animation Events and Calling Methods -The **animator** supports events and methods, which you can use to customize the animation effect. Events include add frames, cancel, repeat, and finish. Methods include update, play, pause, cancel, reverse, and finish. For details about the supported events and methods, see animator supported events and animator supported APIs. +The **animator** supports events and methods, which you can use to customize the animation effect. Events include **frame**, **cancel**, **repeat**, and **finish**. Methods include **update**, **play**, **pause**, **cancel**, **reverse**, and **finish**. For details about the supported events and methods, see [animator supported events and animator supported APIs](../reference/apis/js-apis-basic-features-animator.md). ``` @@ -230,7 +230,7 @@ export default { } ``` -![](figures/1-23.gif) +![](figures/1-18.gif) >![](../public_sys-resources/icon-note.gif) **NOTE:** >When calling the **update** method, you can use it to update the animation parameters. The input parameters are the same as those of **createAnimator**. diff --git a/en/application-dev/ui/ui-js-animate-frame.md b/en/application-dev/ui/ui-js-animate-frame.md index ad79c111f7cd1e6baab95af9659a90f7cc3528aa..355cc098f746d1271ab6823578ce30f16a1c9b55 100644 --- a/en/application-dev/ui/ui-js-animate-frame.md +++ b/en/application-dev/ui/ui-js-animate-frame.md @@ -96,11 +96,11 @@ export default { ![](figures/3333.gif) >![](../public_sys-resources/icon-note.gif) **NOTE:** ->When invoking the callback, the **requestAnimationFrame** method passes in the timestamp as the first parameter, which indicates the time when **requestAnimationFrame** starts to execute the callback. +>When invoking the callback, the **requestAnimationFrame** method passes the timestamp as the first parameter, which indicates the time when **requestAnimationFrame** starts to execute the callback. ## Canceling an Animation Frame -Use the **cancelAnimationFrame** method to cancel frames on a one-by-one basis. It cancels an animation frame request sent through **requestAnimationFrame**. +Use the **cancelAnimationFrame** method to cancel frames on a one-by-one basis. When this method is called, the animation frame request sent through **requestAnimationFrame** will be canceled. ``` @@ -184,5 +184,5 @@ export default { ![](figures/4444.gif) >![](../public_sys-resources/icon-note.gif) **NOTE:** ->When this method is called, a parameter that indicates an ID must be passed. +>When **cancelAnimationFrame** is called, a parameter that indicates an ID must be passed. diff --git a/en/application-dev/ui/ui-js-animate-transform.md b/en/application-dev/ui/ui-js-animate-transform.md index 6773e18607850375b1984bcb483ab06640098ab1..9ac89180bae2aec0dededa5c0c962fcf0fd8179d 100644 --- a/en/application-dev/ui/ui-js-animate-transform.md +++ b/en/application-dev/ui/ui-js-animate-transform.md @@ -4,7 +4,7 @@ Set the **transform** attribute for component rotation, scaling, translation, ## Designing Static Animation -Create a square and rotate it by 90 degrees to form a rhombus. Cover the lower part of the rhombus with a rectangle below to form a roof. Set the **translate** attribute value of the rectangle to \(150px, -150px\) to determine the coordinate position to form a door, use the **position** attribute to translate the horizontal and vertical lines to the specified coordinates of the parent component \(square\), set the **scale** attribute to scale in the parent and child components together to determine the window size, and use the **skewX** attribute to skew the component and set the coordinate **translate\(200px,-830px\)** to form a chimney. +Create a square and rotate it by 90 degrees to form a rhombus. Cover the lower part of the rhombus with a rectangle to form a roof. Set the **translate** attribute of the rectangle to the coordinate \(150px, -150px\) to form a door, use the **position** attribute to translate the horizontal and vertical axes to the specified coordinates of the parent component \(square\), set the **scale** attribute to scale up the parent and child components together to determine the window size, and use the **skewX** attribute to skew the component and set the coordinate **translate\(200px,-830px\)** to form a chimney. ``` @@ -86,11 +86,11 @@ Create a square and rotate it by 90 degrees to form a rhombus. Cover the lower p } ``` -![](figures/111-18.png) +![](figures/111-13.png) ## Designing Translation Animation -This example implements an animation of a falling ball by changing the ball's y-axis coordinate. Decrease the y-axis coordinate over a time frame to make the ball bounce back. Gradually decrease the bounce height until it drops to 0. An animation where the ball falls is hereby created. +Decrease the y-coordinate over a time frame to make the ball bounce back. Gradually decrease the bounce height until it drops to 0. An animation where the ball falls is hereby created. ``` @@ -166,7 +166,7 @@ This example implements an animation of a falling ball by changing the ball's y- ## Designing Rotation Animation -Set the rotation center around an element in different **transform-origin** positions. Of the **rotate3d** values, the first three values are the rotation vectors of the x-axis, y-axis, and z-axis, respectively; the fourth value is the rotation angle, which can be a negative value to indicate that the rotation is performed anticlockwise. +Set the rotation center around an element in different **transform-origin** positions. Of the **rotate3d** values, the first three values are the rotation vectors of the x-axis, y-axis, and z-axis, respectively; the fourth value is the rotation angle, which can be a negative value to indicate that the rotation is performed counterclockwise. ``` @@ -299,15 +299,7 @@ Set the rotation center around an element in different **transform-origin** po ## Designing Scaling Animation -This example implements a ripple animation with the **scale** attribute. Here is the overall procedure: - -1. Use the positioning function to determine the element's position coordinates. - -2. Create multiple components to achieve the overlapping effect. - -3. Set the **opacity** attribute to hide or display the components. To scale and hide/display a component at the same time, set both the **scale** and **opacity** attributes. - -4. Set different animation durations for different components to achieve the diffusion effect. +This example implements a ripple animation with the **scale** attribute. Here is the overall procedure: First, use the positioning function to determine the coordinates of the element's position. Then, create multiple components to achieve the overlapping effect. After that, set the **opacity** attribute to hide or display the components. To scale and hide/display a component at the same time, set both the **scale** and **opacity** attributes. Finally, set different animation durations for different components to achieve the diffusion effect. Set the scaling values for the x-axis, y-axis, and z-axis in **scale3d** to implement the animation. @@ -417,7 +409,7 @@ text{ ![](figures/d3.gif) >![](../public_sys-resources/icon-note.gif) **NOTE:** ->After the **transform** attributes are set, the child element changes with the parent element. Value changes of other attributes \(such as **height** and **width**\) of the parent element will not affect the child element. +>After the **transform** attributes are set, the child element changes with the parent element. Value changing of other attributes \(such as **height** and **width**\) of the parent element will not affect the child element. ## Setting matrix @@ -463,7 +455,7 @@ The **matrix** attribute defines a transformation matrix with six input parame ## Integrating transform Attributes -You can set multiple **transform** attributes at the same time to apply different transformations to a component. The following example simulatenously applies scaling, translating, and rotating. +You can set multiple **transform** attributes at the same time to apply different transformations to a component. The following example applies the **scale**, **translate**, and **rotate** attributes simultaneously. ``` @@ -570,7 +562,7 @@ You can set multiple **transform** attributes at the same time to apply differ ![](figures/d4.gif) >![](../public_sys-resources/icon-note.gif) **NOTE:** ->1. When multiple transforms are set, the later one overwrites the previous one. To use multiple transform styles at the same time, use the shorthand form to write multiple attribute values in one, for example, **transform: scale\(1\) rotate\(0\) translate\(0,0\)**. ->2. When using the shorthand form, note that the animation effect varies according to the sequence of the attribute values. ->3. The **transform** attributes used when the animation starts must match those when the animation ends. When attributes do not match, the respective animation does not work. Only the animation that has matching values is displayed. +>1. When multiple **transform** attributes are set, the later one overwrites the previous one. To apply multiple transform styles at the same time, use the shorthand notation; that is, write multiple style values in one **transform**, for example, **transform: scale\(1\) rotate\(0\) translate\(0,0\)**. +>2. When using the shorthand notion, note that the animation effect varies according to the sequence of the style values. +>3. The style values in the **transform** attribute used when the animation starts and ends must be in one-to-one mapping. Only the styles that have value mappings are played. diff --git a/en/application-dev/ui/ui-js-animate.md b/en/application-dev/ui/ui-js-animate.md index a68c53927269cb70fcb9d864352514de6ab76f56..0da19180580713ad664d48637de5853d79892002 100644 --- a/en/application-dev/ui/ui-js-animate.md +++ b/en/application-dev/ui/ui-js-animate.md @@ -1,9 +1,5 @@ # Animation Development Guidelines -- **[Attribute Style Animation](ui-js-animate-attribute-style.md)** - -- **[Defining Animations with the transform Attribute](ui-js-animate-transform.md)** - - **[CSS Animation](ui-js-animate-css.md)** - **[JS Animation](ui-js-animate-javascript.md)** diff --git a/en/application-dev/ui/ui-js-building-ui-animation.md b/en/application-dev/ui/ui-js-building-ui-animation.md index 87330f81353fed42f0073ee80ae0a0f13b2e153b..b9c7f025bfb1d4a75ad1aa04c65cd43fd5abaaf9 100644 --- a/en/application-dev/ui/ui-js-building-ui-animation.md +++ b/en/application-dev/ui/ui-js-building-ui-animation.md @@ -60,7 +60,7 @@ The static animation has only the start and end states. To set the transition st The core of a continuous animation is animation attributes, which define the start and end states of the animation and the curve of time and speed. Animation attributes can implement the following effects: -- **animation-name**: Background color, transparency, width, height, and transformation type applied to the element after the animation is executed +- **animation-name**: Background color, opacity, width, height, and transformation type applied to the element after the animation is executed - **animation-delay** and **animation-duration**: Element delay and duration after the animation is executed - **animation-timing-function**: Speed curve of an animation, which makes the animation more fluent - **animation-iteration-count**: Number of animation playback times diff --git a/en/application-dev/ui/ui-js-building-ui-component.md b/en/application-dev/ui/ui-js-building-ui-component.md index 15133af6c3800275ecca27f41c383df14fccd92c..bb5970bd4af8f46805433d2af2626efc8d1a5123 100644 --- a/en/application-dev/ui/ui-js-building-ui-component.md +++ b/en/application-dev/ui/ui-js-building-ui-component.md @@ -47,3 +47,4 @@ Components can be classified into the following types based on their functions.

    Name

    diff --git a/en/application-dev/reference/arkui-ts/ts-universal-attributes.md b/en/application-dev/reference/arkui-ts/ts-universal-attributes.md index 08bf3e67b96e2c69e76085148be87c197f3f15f7..2ca2f7ebdbf19b813cdaf4894ab13bb8eb2172f4 100644 --- a/en/application-dev/reference/arkui-ts/ts-universal-attributes.md +++ b/en/application-dev/reference/arkui-ts/ts-universal-attributes.md @@ -1,4 +1,4 @@ -# Universal Attributes +# Universal Attributes - **[Size](ts-universal-attributes-size.md)** @@ -38,4 +38,8 @@ - **[Menu Control](ts-universal-attributes-menu.md)** +- **[Click Control](ts-universal-attributes-touchable.md)** + +- **[Touch Target](ts-universal-attributes-response-region.md)** + diff --git a/en/application-dev/reference/arkui-ts/ts-universal-components.md b/en/application-dev/reference/arkui-ts/ts-universal-components.md index 7676e5c027a3065f1704b74c2dae162a131f9c07..3a70c3c421034a7cba1e10b40c8f557ad143f8ce 100644 --- a/en/application-dev/reference/arkui-ts/ts-universal-components.md +++ b/en/application-dev/reference/arkui-ts/ts-universal-components.md @@ -1,4 +1,4 @@ -# Universal Components +# Universal Components - **[Universal Events](ts-universal-events.md)** diff --git a/en/application-dev/reference/arkui-ts/ts-universal-events-click.md b/en/application-dev/reference/arkui-ts/ts-universal-events-click.md index 323f9a44069b8e6cb2fe35871b820bfd8b61b5f7..8ac56eb6bba732d3e9780113361fe4775b4723cb 100644 --- a/en/application-dev/reference/arkui-ts/ts-universal-events-click.md +++ b/en/application-dev/reference/arkui-ts/ts-universal-events-click.md @@ -1,4 +1,13 @@ -# Click Event +# Click Event + +>![](../../public_sys-resources/icon-note.gif) **NOTE:** +>This event is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. + +## Required Permissions + +None + +## Events + + + +

    Name

    @@ -58,6 +67,13 @@

    Y coordinate of the click relative to the upper edge of the component being clicked.

    target8+

    +

    EventTarget

    +

    Object of the element that is clicked.

    +

    timestamp

    number

    @@ -68,6 +84,97 @@
    +- EventTarget object8+ + + + + + + + + + + + + +

    Name

    +

    Type

    +

    Description

    +

    area

    +

    Area

    +

    Area information of the target element.

    +
    + +- Area attributes8+ + + + + + + + + + + + + + + + + + + + + + + + + +

    Name

    +

    Type

    +

    Description

    +

    width

    +

    Length

    +

    Width of the target element.

    +

    height

    +

    Length

    +

    Height of the target element.

    +

    pos

    +

    Position

    +

    Position of the upper left corner of the target element relative to that of the parent element.

    +

    globalPos

    +

    Position

    +

    Position of the upper left corner of the target element relative to that of the page.

    +
    + +- Position attributes8+ + + + + + + + + + + + + + + + + +

    Name

    +

    Type

    +

    Description

    +

    x

    +

    Length

    +

    X-coordinate.

    +

    y

    +

    Length

    +

    Y-coordinate.

    +
    + ## Example @@ -79,15 +186,18 @@ struct ClickExample { build() { Column() { - Button('Click').backgroundColor(0x2788D9) + Button('Click').backgroundColor(0x2788D9).width(100).height(40) .onClick((event: ClickEvent) => { - console.info(this.text = 'Button clicked!\n X:' + event.x + '\n' + ' Y:' + event.y) + console.info(this.text = 'Click Point:' + '\n screenX:' + event.screenX + '\n screenY:' + event.screenY + + '\n x :' + event.x + '\n y:' + event.y + '\ntarget:' + '\n component globalPos:(' ++ event.target.area.globalPos.x + ',' + event.target.area.globalPos.y + ')\n width:' + + event.target.area.width + '\n height:' + event.target.area.height) }) Text(this.text).padding(15) - }.height(300).width('100%').padding(35) + }.height(350).width('100%').padding(10) } } ``` -![](figures/click.gif) +![](figures/en-us_image_0000001237355087.gif) diff --git a/en/application-dev/reference/arkui-ts/ts-universal-events-component-area-change.md b/en/application-dev/reference/arkui-ts/ts-universal-events-component-area-change.md new file mode 100644 index 0000000000000000000000000000000000000000..4b79a9ccdd11448dff7c316ee56b10424fa7d796 --- /dev/null +++ b/en/application-dev/reference/arkui-ts/ts-universal-events-component-area-change.md @@ -0,0 +1,59 @@ +# Component Area Change Event + +>![](../../public_sys-resources/icon-note.gif) **NOTE:** +>This event is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version. + +## Required Permissions + +None + +## Events + + + + + + + + + + + + +

    Name

    +

    Bubble Supported

    +

    Description

    +

    onAreaChange(event: (oldValue: Area, newValue: Area) => void)

    +

    No

    +

    Triggered when the component area changes. For details about the Area type, see the description of the Area object.

    +
    + +## Example + +``` +@Entry +@Component +struct AreaExample { + @State value: string = 'Text' + @State size: string = '' + + build() { + Column() { + Text(this.value) + .backgroundColor(Color.Green).margin(30).fontSize(20) + .onClick(() => { + this.value = this.value + 'Text' + }) + .onAreaChange((oldValue: Area, newValue: Area) => { + console.info(`Ace: on area change, oldValue is ${JSON.stringify(oldValue)} value is ${JSON.stringify(newValue)}`) + this.size = JSON.stringify(newValue) + }) + Text('new area is: \n' + this.size).margin({ right: 30, left: 30 }) + } + .width('100%').height('100%').margin({ top: 30 }) + } +} +``` + +![](figures/gif4.gif) + diff --git a/en/application-dev/reference/arkui-ts/ts-universal-events-key.md b/en/application-dev/reference/arkui-ts/ts-universal-events-key.md index 21aad69b43bf00361fd5d6037d17f27f24664d79..0cbdd5984bd943aa5928259c6becf73df56d07cb 100644 --- a/en/application-dev/reference/arkui-ts/ts-universal-events-key.md +++ b/en/application-dev/reference/arkui-ts/ts-universal-events-key.md @@ -1,19 +1,28 @@ -# Key Event +# Key Event - - - @@ -125,21 +141,21 @@ - -

    Name

    +>![](../../public_sys-resources/icon-note.gif) **NOTE:** +>This event is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. + +## Required Permissions + +None + +## Events + + + - - - - - diff --git a/en/application-dev/reference/arkui-ts/ts-universal-events-show-hide.md b/en/application-dev/reference/arkui-ts/ts-universal-events-show-hide.md index f75cc0196e9a97037c9cc8006afb96197f0242c3..f2daec1a857375a1126a4894e3cc63b1f81fd721 100644 --- a/en/application-dev/reference/arkui-ts/ts-universal-events-show-hide.md +++ b/en/application-dev/reference/arkui-ts/ts-universal-events-show-hide.md @@ -1,26 +1,35 @@ -# Show/Hide Event +# Show/Hide Event - -

    Name

    Bubble Supported

    +

    Bubble Supported

    Description

    +

    Description

    onKeyEvent(event: (event?: KeyEvent) => void)

    +

    onKeyEvent(event: (event?: KeyEvent) => void)

    Yes

    +

    Yes

    Called when a key event occurs. For details about the event parameters, see KeyEvent Object.

    +

    Called when a key event occurs. For details about the event parameters, see KeyEvent Object.

    + + + +

    Name

    +>![](../../public_sys-resources/icon-note.gif) **NOTE:** +>This event is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. + +## Required Permissions + +None + +## Events + + + - - - - - - - - diff --git a/en/application-dev/reference/arkui-ts/ts-universal-events-touch.md b/en/application-dev/reference/arkui-ts/ts-universal-events-touch.md index 59f6c6cb6554f4d4d4dca5e323a099045d5c0fbe..5059fd0c0ae60c3653d810120962b6ef0d895dcf 100644 --- a/en/application-dev/reference/arkui-ts/ts-universal-events-touch.md +++ b/en/application-dev/reference/arkui-ts/ts-universal-events-touch.md @@ -1,9 +1,18 @@ -# Touch Event +# Touch + +>![](../../public_sys-resources/icon-note.gif) **NOTE:** +>This event is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. + +## Required Permissions + +None + +## Events

    Name

    Bubble Supported

    +

    Bubble Supported

    Description

    +

    Description

    onAppear(callback: () => void)

    +

    onAppear(callback: () => void)

    No

    +

    No

    Called when the component is displayed.

    +

    Called when the component is displayed.

    onDisappear(callback: () => void)

    +

    onDisappear(callback: () => void)

    No

    +

    No

    Called when the component disappears.

    +

    Called when the component disappears.

    - @@ -13,13 +22,13 @@ -

    Name

    Bubble Supported

    +

    Pop-up

    Description

    Yes

    Called when a touch event occurs. For details about the event parameters, see TouchEvent.

    +

    Invoked when a touch action is triggered. For details about the event parameters, see TouchEvent.

    -## TouchEvent Object +## TouchEvent - Attributes @@ -60,6 +69,13 @@

    Timestamp of the event.

    target8+

    +

    EventTarget

    +

    Target of the event.

    +
    @@ -75,7 +91,7 @@

    stopPropagation(): void

    Stops the event from bubbling upwards or downwards.

    +

    Pop-up of the stop event.

    number

    X coordinate of the touch point relative to the left edge of the element being touched.

    +

    X coordinate of the touch point relative to the left edge of the element to touch.

    y

    number

    Y coordinate of the touch point relative to the upper edge of the element being touched.

    +

    Y coordinate of the touch point relative to the upper edge of the element to touch.

    -- TouchType enums +- TouchType - - - - @@ -183,7 +199,7 @@ struct TouchExample { build() { Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) { - Button('Touch').backgroundColor(0x2788D9) + Button('Touch').backgroundColor(0x2788D9).height(40).width(80) .onTouch((event: TouchEvent) => { if (event.type === TouchType.Down) { this.eventType = 'Down' @@ -194,7 +210,10 @@ struct TouchExample { if (event.type === TouchType.Move) { this.eventType = 'Move' } - console.info(this.text = 'TouchType:' + this.eventType + '\nDistance between touch point and touch element:\nx: ' + event.touches[0].x + '\n' + 'y: ' + event.touches[0].y) + console.info(this.text = 'TouchType:' + this.eventType + '\nDistance between touch point and touch element:\nx: ' ++ event.touches[0].x + '\n' + 'y: ' + event.touches[0].y + '\ncomponent globalPos: (' + + event.target.area.globalPos.x + ',' + event.target.area.globalPos.y + ')\nwidth:' + + event.target.area.width + '\nheight:' + event.target.area.height) }) Text(this.text) }.height(200).width(350).padding({ left: 35, right: 35, top: 35 }) @@ -202,5 +221,5 @@ struct TouchExample { } ``` -![](figures/touch.gif) +![](figures/en-us_image_0000001192915178.gif) diff --git a/en/application-dev/reference/arkui-ts/ts-universal-events.md b/en/application-dev/reference/arkui-ts/ts-universal-events.md index 8f5999c7950cc1a7428fccb824e1e2964b395813..3fd64c2747e5457ef0dbfb6a2dbc8118b98e0c70 100644 --- a/en/application-dev/reference/arkui-ts/ts-universal-events.md +++ b/en/application-dev/reference/arkui-ts/ts-universal-events.md @@ -1,11 +1,13 @@ -# Universal Events +# Universal Events - **[Click Event](ts-universal-events-click.md)** -- **[Touch Event](ts-universal-events-touch.md)** +- **[Touch](ts-universal-events-touch.md)** - **[Show/Hide Event](ts-universal-events-show-hide.md)** - **[Key Event](ts-universal-events-key.md)** +- **[Component Area Change Event](ts-universal-events-component-area-change.md)** + diff --git a/en/application-dev/security/Readme-EN.md b/en/application-dev/security/Readme-EN.md new file mode 100644 index 0000000000000000000000000000000000000000..a9c7d9b828a8576e0db91e99af8282419242bf7b --- /dev/null +++ b/en/application-dev/security/Readme-EN.md @@ -0,0 +1,5 @@ +# Security + +- User Authentication + - [User Authentication Overview](userauth-overview.md) + - [User Authentication Development](userauth-guidelines.md) \ No newline at end of file diff --git a/en/application-dev/security/userauth-guidelines.md b/en/application-dev/security/userauth-guidelines.md new file mode 100644 index 0000000000000000000000000000000000000000..ede673ad7acadde4015c618b567f20ec0d4ddc12 --- /dev/null +++ b/en/application-dev/security/userauth-guidelines.md @@ -0,0 +1,141 @@ +# User Authentication Development + +>**NOTE:** +>This document applies to JS. + +## When to Use + +HarmonyOS supports 2D and 3D facial recognition that can be used for identity authentication during device unlocking, application login, and payment. + +## Available APIs + +The **userIAM\_userAuth** module provides methods for checking the support for biometric authentication, and performing and canceling authentication. You can perform authentication based on biometric features such as facial characteristics. Before performing biometric authentication, check whether your device supports this capability, including the authentication type, security level, and whether local authentication is used. If biometric authentication is not supported, consider using another authentication type. The following table lists methods in the APIs available for biometric authentication. + +**Table 1** Methods available for biometric authentication + + +

    Name

    @@ -150,22 +166,22 @@

    Down

    A finger is pressed.

    +

    Trigger a touch event when a finger is pressed.

    Up

    A finger is lifted.

    +

    Trigger a touch event when a finger is lifted.

    Move

    A finger moves on the screen in pressed state.

    +

    Trigger a touch event when a finger moves on the screen in pressed state.

    Cancel

    A touch event is canceled.

    +

    Trigger an event when a touch event is canceled.

    + + + + + + + + + + + + + + + + + + + + + + + + + +

    Method

    +

    Description

    +

    getAuthenticator(): Authenticator

    +

    Obtains an Authenticator object for user authentication. 6+

    +

    Obtains an Authenticator object to check the device's capability of user authentication, perform or cancel user authentication, and obtain the tips generated in the authentication process. 7+

    +

    checkAvailability(type: AuthType, level: SecureLevel): number

    +

    Checks whether the device supports the specified authentication type and security level.

    +

    execute(type: AuthType, level: SecureLevel, callback: AsyncCallback<number>): void

    +

    Performs user authentication and returns the authentication result using an asynchronous callback.

    +

    execute(type: AuthType, level: SecureLevel): Promise<number>

    +

    Performs user authentication and returns the authentication result using a promise.

    +

    cancel(): void

    +

    Cancels the current authentication.

    +

    on(type: "tip", callback: Callback<Tip>): void

    +

    Subscribes to the events of the specified type.

    +

    off(type: "tip", callback?: Callback<Tip>): void

    +

    Unsubscribes from the events of the specified type.

    +
    + +## How to Develop + +Before starting the development, make the following preparations: + +1. Add the **ohos.permission.ACCESS\_BIOMETRIC** permission declaration to the application permission file. +2. Add **import userIAM\_userAuth from '@ohos.userIAM.userAuth'** to the code file that provides biometric recognition. + +The development procedure is as follows: + +1. Obtain an **Authenticator** singleton object. The sample code is as follows: + + ``` + let auth = userIAM_userAuth.getAuthenticator(); + ``` + +2. Check whether the device provides the authentication capability of the specified level. + + 2D facial recognition supports authentication lower than S2, and 3D facial recognition supports authentication lower than S3. The sample code is as follows: + + ``` + let authenticator = userIAM_userAuth.getAuthenticator(); + let checkCode = authenticator.checkAvailability("FACE_ONLY", "S2"); + if (checkCode == userIAM_userAuth.CheckAvailabilityResult.SUPPORTED) { + console.info("check auth support success"); + } else { + console.error("check auth support fail, code = " + checkCode); + } + ``` + +3. \(Optional\) Subscribe to tip information. The sample code is as follows: + + ``` + let authenticator = userIAM_userAuth.getAuthenticator(); + let tipCallback = (tip)=>{ + console.info("receive tip: errorCode(" + tip.errorCode + ") code(" + tip.tipCode +") event(" + + tip.tipEvent + ") info(" + tip.tipInfo + ")"); + }; + authenticator.on("tip", tipCallback); + ``` + +4. Perform the authentication. The sample code is as follows: + + ``` + let authenticator = userIAM_userAuth.getAuthenticator(); + authenticator.execute("FACE_ONLY", "S2").then((code)=>{ + authenticator.off("tip", tipCallback); + console.info("auth success"); + }).catch((code)=>{ + authenticator.off("tip", tipCallback); + console.error("auth fail, code = " + code); + }); + ``` + +5. \(Optional\) Unsubscribe from tip information if [you have subscribed to tip information](#li109311114115111)you have subscribed to tip information. + + ``` + let authenticator = userIAM_userAuth.getAuthenticator(); + let tipCallback = (tip)=>{ + console.info("receive tip: errorCode(" + tip.errorCode + ") code(" + tip.tipCode + ") event(" + + tip.tipEvent + ") info(" + tip.tipInfo + ")"); + }; + // Unsubscribe from a specified callback. + authenticator.off("tip", tipCallback); + // Unsubscribe from all callbacks. + authenticator.off("tip"); + ``` + +6. Cancel authentication. The sample code is as follows: + + ``` + let authenticator = userIAM_userAuth.getAuthenticator(); + let cancelCode = authenticator.cancel(); + if (cancelCode == userIAM_userAuth.Result.SUCCESS) { + console.info("cancel auth success"); + } else { + console.error("cancel auth fail"); + } + ``` + + diff --git a/en/application-dev/security/userauth-overview.md b/en/application-dev/security/userauth-overview.md new file mode 100644 index 0000000000000000000000000000000000000000..d02a8ec6df859ea48792d5c908665a32fbb0bdae --- /dev/null +++ b/en/application-dev/security/userauth-overview.md @@ -0,0 +1,25 @@ +# User Authentication Overview + +HarmonyOS provides biometric recognition that can be used for identity authentication in device unlocking, application login, and payment. + +HarmonyOS provides both 2D and 3D facial recognition. You can provide either or both of them on your device based on the hardware and technology applied on the device. 3D facial recognition is superior to 2D facial recognition in terms of recognition rate and anti-counterfeiting capability. However, you can use 3D facial recognition only if your device supports capabilities such as 3D structured light and 3D Time of Flight \(TOF\). + +## Basic Concepts + +Biometric recognition \(also known as biometric authentication\) uses optical, acoustical, and biological sensors, as well as the biological statistics mechanism to identify individuals. + +Facial recognition is a biometric recognition technology that identifies individuals based on facial characteristics. A camera is used to collect images or video streams that contain human faces, and automatically detect, track, and recognize the human faces. + +## Working Principles + +Facial recognition establishes a secure channel between a camera and a trusted execution environment \(TEE\). Through this channel, face image data is transmitted to the TEE. This protects against any attack from the rich execution environment \(REE\) as the face image data cannot be obtained from the REE. The face image collection, characteristic extraction, alive human body detection, and characteristic comparison are all completed in the TEE. The TEE implements security isolation based on the trust zone. The external face framework only initiates face authentication and processes authentication results. It does not process the human face data. + +Facial characteristics are stored in the TEE, which uses strong cryptographic algorithms to encrypt and protect the integrity of facial characteristics. The collected and stored facial characteristics will not be transferred out of the TEE without user authorization. This ensures that system or third-party applications cannot obtain facial characteristics, or send or back them up to any external storage medium. + +## Limitations and Constraints + +- HarmonyOS only supports facial recognition and local authentication, and does not support an authentication UI. +- To use biometric recognition, a device must have a camera with a face image pixel greater than 100x100. +- The device must have a TEE, where encrypted facial characteristics are stored. +- Facial recognition may not work for people with similar looks and children whose facial features keep changing. If you are concerned about this, consider using other authentication modes. + diff --git a/en/application-dev/ui/Readme-EN.md b/en/application-dev/ui/Readme-EN.md index be7bf48f1cd4d203b7593b7efba7d8d2eb8a6571..8f16c2a59a777fe617d85df75fca4900a263b630 100755 --- a/en/application-dev/ui/Readme-EN.md +++ b/en/application-dev/ui/Readme-EN.md @@ -1,52 +1,140 @@ # UI -- ArkUI - - JavaScript-based Web-like Development Paradigm - - [Overview](ui-js-overview.md) - - Building the UI - - [Component Overview](ui-js-building-ui-component.md) - - Building the Layout - - [Layout Description](ui-js-building-ui-layout-intro.md) - - [Adding Title and Paragraph Text](ui-js-building-ui-layout-text.md) - - [Adding an Image](ui-js-building-ui-layout-image.md) - - [Adding a Comment](ui-js-building-ui-layout-comment.md) - - [Adding a Container](ui-js-building-ui-layout-external-container.md) - - [Adding Interactions](ui-js-building-ui-interactions.md) - - [Developing Animations](ui-js-building-ui-animation.md) - - [Defining Events](ui-js-building-ui-event.md) - - [Defining Page Routes](ui-js-building-ui-routes.md) - - Common Component Development Guidelines - - [Text](ui-js-components-text.md) - - [Input](ui-js-components-input.md) - - [Button](ui-js-components-button.md) - - [List](ui-js-components-list.md) - - [Picker](ui-js-components-picker.md) - - [Dialog](ui-js-components-dialog.md) - - [Form](ui-js-components-form.md) - - [Stepper](ui-js-components-stepper.md) - - [Tabs](ui-js-component-tabs.md) - - [Image](ui-js-components-images.md) - - Animation Development Guidelines - - CSS Animation - - [Attribute Style Animation](ui-js-animate-attribute-style.md) - - [Defining Animations with the transform Attribute](ui-js-animate-transform.md) - - [Defining Animations with the background-position Attribute](ui-js-animate-background-position-style.md) - - JS Animation - - [Component Animation](ui-js-animate-component.md) - - Interpolator Animation - - [Animation Effect](ui-js-animate-dynamic-effects.md) - - [Animation Frame](ui-js-animate-frame.md) - - - [Custom Components](ui-js-custom-components.md) - - - TypeScript-based Declarative Development Paradigm +- [ ArkUI](ui-arkui.md) + - [JavaScript-based Web-Like Development Paradigm](ui-arkui-js.md) + - [Overview](ui-js-overview.md) + - [Framework](js-framework.md) + - [File Organization](js-framework-file.md) + - ["js" Tag](js-framework-js-tag.md) + - [app.js](js-framework-js-file.md) + - [Syntax](js-framework-syntax.md) + - [HML](js-framework-syntax-hml.md) + - [CSS](js-framework-syntax-css.md) + - [JavaScript](js-framework-syntax-js.md) + + - [Lifecycle](js-framework-lifecycle.md) + - [Resource Limitations and Access](js-framework-resource-restriction.md) + - [Multi-Language Capability](js-framework-multiple-languages.md) + + - [Building the UI](ui-js-building-ui.md) + - [Component Overview](ui-js-building-ui-component.md) + - [Building the Layout](ui-js-building-ui-layout.md) + - [Layout Description](ui-js-building-ui-layout-intro.md) + - [Adding Title and Paragraph Text](ui-js-building-ui-layout-text.md) + - [Adding an Image](ui-js-building-ui-layout-image.md) + - [Adding a Comment](ui-js-building-ui-layout-comment.md) + - [Adding a Container](ui-js-building-ui-layout-external-container.md) + + - [Adding Interactions](ui-js-building-ui-interactions.md) + - [Developing Animations](ui-js-building-ui-animation.md) + - [Defining Events](ui-js-building-ui-event.md) + - [Defining Page Routes](ui-js-building-ui-routes.md) + + - [Common Component Development Guidelines](ui-js-common-components.md) + - [Text](ui-js-components-text.md) + - [Input](ui-js-components-input.md) + - [Button](ui-js-components-button.md) + - [List](ui-js-components-list.md) + - [Picker](ui-js-components-picker.md) + - [Dialog](ui-js-components-dialog.md) + - [Form](ui-js-components-form.md) + - [Stepper](ui-js-components-stepper.md) + - [Tabs](ui-js-component-tabs.md) + - [Image](ui-js-components-images.md) + + - [Animation Development Guidelines](ui-js-animate.md) + - [CSS Animation](ui-js-animate-css.md) + - [Defining Attribute Style Animations](ui-js-animate-attribute-style.md) + - [Defining Animations with the transform Attribute](ui-js-animate-transform.md) + - [Defining Animations with the background-position Attribute](ui-js-animate-background-position-style.md) + + - [JS Animation](ui-js-animate-javascript.md) + - [Component Animation](ui-js-animate-component.md) + - [Interpolator Animation](ui-js-animate-interpolator.md) + - [Animation Effect](ui-js-animate-dynamic-effects.md) + - [Animation Frame](ui-js-animate-frame.md) + + - [Custom Components](ui-js-custom-components.md) + + - [TypeScript-based Declarative Development Paradigm](ui-arkui-ts.md) - [Overview](ui-ts-overview.md) - - [Introduction](ui-ts-developing-intro.md) - - Experiencing the Declarative UI + - [Framework Overview](ts-framework.md) + - [File Organization](ts-framework-file.md) + - [Directory Structure](ts-framework-directory.md) + - [Rules for Accessing Application Code Files](ts-framework-file-access-rules.md) + + - ["js" Tag](ts-framework-js-tag.md) + - [Resource Access](ts-resource-access.md) + - [Accessing Application Resources](ts-application-resource-access.md) + - [Media Resource Types](ts-media-resource-type.md) + + - [Pixel Units](ts-pixel-units.md) + - [Types](ts-types.md) + + - [Declarative Syntax](ts-declarative-syntax.md) + - [Overview](ts-syntax-intro.md) + - [General UI Description Specifications](ts-general-ui-description-specifications.md) + - [Basic Concepts](ts-general-ui-concepts.md) + - [Declarative UI Description Specifications](ts-declarative-ui-description-specifications.md) + - [Parameterless Configuration](ts-parameterless-configuration.md) + - [Configuration with Mandatory Parameters](ts-configuration-with-mandatory-parameters.md) + - [Attribution Configuration](ts-attribution-configuration.md) + - [Event Configuration](ts-event-configuration.md) + - [Child Component Configuration](ts-child-component-configuration.md) + + - [Componentization](ts-component-based.md) + - [@Component](ts-component-based-component.md) + - [@Entry](ts-component-based-entry.md) + - [@Preview](ts-component-based-preview.md) + - [@Builder](ts-component-based-builder.md) + - [@Extend](ts-component-based-extend.md) + - [@CustomDialog](ts-component-based-customdialog.md) + + - [About UI State Management](ts-ui-state-management.md) + - [Basic Concepts](ts-ui-state-mgmt-concepts.md) + - [Managing Component States](ts-managing-component-states.md) + - [@State](ts-component-states-state.md) + - [@Prop](ts-component-states-prop.md) + - [@Link](ts-component-states-link.md) + + - [Managing Application States](ts-managing-application-states.md) + - [APIs](ts-managing-application-states-apis.md) + - [AppStorage](ts-application-states-appstorage.md) + - [PersistentStorage](ts-application-states-apis-persistentstorage.md) + - [Environment](ts-application-states-apis-environment.md) + + - [Synchronization Between AppStorage and Components](ts-application-states-storagelink-storageprop.md) + + - [Managing Other States](ts-managing-other-states.md) + - [@observed and @objectLink](ts-other-states-observed-objectlink.md) + - [@Consume and @Provide](ts-other-states-consume-provide.md) + - [@Watch](ts-other-states-watch.md) + + - [About Rendering Control Syntax](ts-rending-control-syntax.md) + - [if/else](ts-rending-control-syntax-if-else.md) + - [ForEach](ts-rending-control-syntax-foreach.md) + - [LazyForEach](ts-rending-control-syntax-lazyforeach.md) + + - [About @Component](ts-a-deep-dive-into-component.md) + - [build Function](ts-function-build.md) + - [Custom Component Initialization](ts-custom-component-initialization.md) + - [Custom Component Lifecycle Callbacks](ts-custom-component-lifecycle-callbacks.md) + - [Example: Component Creation and Re-Initialization](ts-component-creation-re-initialization.md) + + - [About Syntactic Sugar](ts-syntactic-sugar.md) + - [@Decorator](ts-syntactic-sugar-decorator.md) + - [Chain Call](ts-syntactic-sugar-chaining.md) + - [struct](ts-syntactic-sugar-struct.md) + - [Instantiating a struct Without the new Keyword](ts-instantiating-a-struct-without-new-keyword.md) + - [Using a Separate Line for New Component](ts-using-a-separate-line-for-new-component.md) + - [Restrictions on Using TypeScript for Generators](ts-restrictions-for-generators.md) + + - [Experiencing the Declarative UI](ui-ts-experiencing-declarative-ui.md) - [Creating a Declarative UI Project](ui-ts-creating-project.md) - [Getting to Know Components](ui-ts-components.md) - [Creating a Simple Page](ui-ts-creating-simple-page.md) - - Defining Page Layout and Connection + + - [Defining Page Layout and Connection](ui-ts-page-layout-connections.md) - [Building a Food Data Model](ui-ts-building-data-model.md) - [Building a Food Category List Layout](ui-ts-building-category-list-layout.md) - [Building a Food Category Grid Layout](ui-ts-building-category-grid-layout.md) diff --git a/en/application-dev/ui/figures/000000.png b/en/application-dev/ui/figures/000000.png new file mode 100644 index 0000000000000000000000000000000000000000..58293d5e874f2aa36ecaf7282ca9e4736318092f Binary files /dev/null and b/en/application-dev/ui/figures/000000.png differ diff --git a/en/application-dev/ui/figures/01-2.png b/en/application-dev/ui/figures/01-1.png similarity index 100% rename from en/application-dev/ui/figures/01-2.png rename to en/application-dev/ui/figures/01-1.png diff --git a/en/application-dev/ui/figures/05-6.png b/en/application-dev/ui/figures/05-3.png similarity index 100% rename from en/application-dev/ui/figures/05-6.png rename to en/application-dev/ui/figures/05-3.png diff --git a/en/application-dev/ui/figures/1-19.gif b/en/application-dev/ui/figures/1-14.gif similarity index 100% rename from en/application-dev/ui/figures/1-19.gif rename to en/application-dev/ui/figures/1-14.gif diff --git a/en/application-dev/ui/figures/1-20.gif b/en/application-dev/ui/figures/1-15.gif similarity index 100% rename from en/application-dev/ui/figures/1-20.gif rename to en/application-dev/ui/figures/1-15.gif diff --git a/en/application-dev/ui/figures/1-23.gif b/en/application-dev/ui/figures/1-18.gif similarity index 100% rename from en/application-dev/ui/figures/1-23.gif rename to en/application-dev/ui/figures/1-18.gif diff --git a/en/application-dev/ui/figures/1-3.gif b/en/application-dev/ui/figures/1.gif similarity index 100% rename from en/application-dev/ui/figures/1-3.gif rename to en/application-dev/ui/figures/1.gif diff --git a/en/application-dev/ui/figures/10-15.png b/en/application-dev/ui/figures/10-10.png similarity index 100% rename from en/application-dev/ui/figures/10-15.png rename to en/application-dev/ui/figures/10-10.png diff --git a/en/application-dev/ui/figures/11-12.gif b/en/application-dev/ui/figures/11-8.gif similarity index 100% rename from en/application-dev/ui/figures/11-12.gif rename to en/application-dev/ui/figures/11-8.gif diff --git a/en/application-dev/ui/figures/111-18.png b/en/application-dev/ui/figures/111-13.png similarity index 100% rename from en/application-dev/ui/figures/111-18.png rename to en/application-dev/ui/figures/111-13.png diff --git a/en/application-dev/ui/figures/111-22.gif b/en/application-dev/ui/figures/111-17.gif similarity index 100% rename from en/application-dev/ui/figures/111-22.gif rename to en/application-dev/ui/figures/111-17.gif diff --git a/en/application-dev/ui/figures/2-11.gif b/en/application-dev/ui/figures/2-7.gif similarity index 100% rename from en/application-dev/ui/figures/2-11.gif rename to en/application-dev/ui/figures/2-7.gif diff --git a/en/application-dev/ui/figures/2-8.gif b/en/application-dev/ui/figures/2-8.gif deleted file mode 100644 index b0e9d88f7ccf69a208bdf59ab5bd9a3dee2426f6..0000000000000000000000000000000000000000 Binary files a/en/application-dev/ui/figures/2-8.gif and /dev/null differ diff --git a/en/application-dev/ui/figures/2-4.png b/en/application-dev/ui/figures/2.png similarity index 100% rename from en/application-dev/ui/figures/2-4.png rename to en/application-dev/ui/figures/2.png diff --git a/en/application-dev/ui/figures/20211217-130837(welinkpc).gif b/en/application-dev/ui/figures/20211217-130837(welinkpc).gif new file mode 100644 index 0000000000000000000000000000000000000000..6ba578c8480834de8798cd311444c0499e1f0da5 Binary files /dev/null and b/en/application-dev/ui/figures/20211217-130837(welinkpc).gif differ diff --git a/en/application-dev/ui/figures/3-21.gif b/en/application-dev/ui/figures/3-16.gif similarity index 100% rename from en/application-dev/ui/figures/3-21.gif rename to en/application-dev/ui/figures/3-16.gif diff --git a/en/application-dev/ui/figures/3-5.png b/en/application-dev/ui/figures/3-2.png similarity index 100% rename from en/application-dev/ui/figures/3-5.png rename to en/application-dev/ui/figures/3-2.png diff --git a/en/application-dev/ui/figures/3-13.gif b/en/application-dev/ui/figures/3-9.gif similarity index 100% rename from en/application-dev/ui/figures/3-13.gif rename to en/application-dev/ui/figures/3-9.gif diff --git a/en/application-dev/ui/figures/3-1.png b/en/application-dev/ui/figures/3.png similarity index 100% rename from en/application-dev/ui/figures/3-1.png rename to en/application-dev/ui/figures/3.png diff --git a/en/application-dev/ui/figures/31-14.gif b/en/application-dev/ui/figures/31-14.gif deleted file mode 100644 index d536b946b814de3d5b822611ac5c91c749a9d254..0000000000000000000000000000000000000000 Binary files a/en/application-dev/ui/figures/31-14.gif and /dev/null differ diff --git a/en/application-dev/ui/figures/31.gif b/en/application-dev/ui/figures/31.gif index 7d78a05bdc080bb96dac807a64e7953798261b1e..d536b946b814de3d5b822611ac5c91c749a9d254 100644 Binary files a/en/application-dev/ui/figures/31.gif and b/en/application-dev/ui/figures/31.gif differ diff --git a/en/application-dev/ui/figures/34-17.gif b/en/application-dev/ui/figures/34-12.gif similarity index 100% rename from en/application-dev/ui/figures/34-17.gif rename to en/application-dev/ui/figures/34-12.gif diff --git a/en/application-dev/ui/figures/5-9.gif b/en/application-dev/ui/figures/5-5.gif similarity index 100% rename from en/application-dev/ui/figures/5-9.gif rename to en/application-dev/ui/figures/5-5.gif diff --git a/en/application-dev/ui/figures/7-16.png b/en/application-dev/ui/figures/7-11.png similarity index 100% rename from en/application-dev/ui/figures/7-16.png rename to en/application-dev/ui/figures/7-11.png diff --git a/en/application-dev/ui/figures/8-7.gif b/en/application-dev/ui/figures/8-4.gif similarity index 100% rename from en/application-dev/ui/figures/8-7.gif rename to en/application-dev/ui/figures/8-4.gif diff --git a/en/application-dev/ui/figures/8-10.gif b/en/application-dev/ui/figures/8-6.gif similarity index 100% rename from en/application-dev/ui/figures/8-10.gif rename to en/application-dev/ui/figures/8-6.gif diff --git a/en/application-dev/reference/arkui-ts/figures/corespec_figures_state-mgmt-overview.png b/en/application-dev/ui/figures/corespec_figures_state-mgmt-overview.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/corespec_figures_state-mgmt-overview.png rename to en/application-dev/ui/figures/corespec_figures_state-mgmt-overview.png diff --git a/en/application-dev/reference/arkui-ts/figures/datatype.png b/en/application-dev/ui/figures/datatype.png similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/datatype.png rename to en/application-dev/ui/figures/datatype.png diff --git a/en/application-dev/reference/arkui-js/figures/directory-structure-for-resource-sharing-5+.png b/en/application-dev/ui/figures/directory-structure-for-resource-sharing-5+.png similarity index 100% rename from en/application-dev/reference/arkui-js/figures/directory-structure-for-resource-sharing-5+.png rename to en/application-dev/ui/figures/directory-structure-for-resource-sharing-5+.png diff --git a/en/application-dev/reference/arkui-js/figures/en-us_image_0000001147417424.png b/en/application-dev/ui/figures/en-us_image_0000001147417424.png similarity index 100% rename from en/application-dev/reference/arkui-js/figures/en-us_image_0000001147417424.png rename to en/application-dev/ui/figures/en-us_image_0000001147417424.png diff --git a/en/application-dev/ui/figures/en-us_image_0000001169532276.png b/en/application-dev/ui/figures/en-us_image_0000001169532276.png index 8307c81c6f2e5b05e6e9e1dc127211d683c6737c..35fe49397c017888c8893eef4fcf0ee5cf4f3e26 100644 Binary files a/en/application-dev/ui/figures/en-us_image_0000001169532276.png and b/en/application-dev/ui/figures/en-us_image_0000001169532276.png differ diff --git a/en/application-dev/ui/figures/en-us_image_0000001174035718.png b/en/application-dev/ui/figures/en-us_image_0000001174035718.png deleted file mode 100644 index 85a1028cfd4207a381e35d83dd2544f56b62b57b..0000000000000000000000000000000000000000 Binary files a/en/application-dev/ui/figures/en-us_image_0000001174035718.png and /dev/null differ diff --git a/en/application-dev/ui/figures/en-us_image_0000001251421931.png b/en/application-dev/ui/figures/en-us_image_0000001251421931.png new file mode 100644 index 0000000000000000000000000000000000000000..38283e25da840fcbadf7e08dc27abe1e5df3b946 Binary files /dev/null and b/en/application-dev/ui/figures/en-us_image_0000001251421931.png differ diff --git a/en/application-dev/ui/figures/Figure3.png b/en/application-dev/ui/figures/figures3.png similarity index 100% rename from en/application-dev/ui/figures/Figure3.png rename to en/application-dev/ui/figures/figures3.png diff --git a/en/application-dev/reference/arkui-ts/figures/pixel-units.gif b/en/application-dev/ui/figures/pixel-unit.gif similarity index 100% rename from en/application-dev/reference/arkui-ts/figures/pixel-units.gif rename to en/application-dev/ui/figures/pixel-unit.gif diff --git a/en/application-dev/ui/figures/qqqq.gif b/en/application-dev/ui/figures/qqqq.gif new file mode 100644 index 0000000000000000000000000000000000000000..3482c52e25f1a60d708865d6f40ec444ebcedbfb Binary files /dev/null and b/en/application-dev/ui/figures/qqqq.gif differ diff --git a/en/application-dev/reference/arkui-js/figures/sample_css.png b/en/application-dev/ui/figures/sample_css.png similarity index 100% rename from en/application-dev/reference/arkui-js/figures/sample_css.png rename to en/application-dev/ui/figures/sample_css.png diff --git a/en/application-dev/reference/arkui-js/figures/unnaming-(1).png b/en/application-dev/ui/figures/unnaming-(1).png similarity index 100% rename from en/application-dev/reference/arkui-js/figures/unnaming-(1).png rename to en/application-dev/ui/figures/unnaming-(1).png diff --git a/en/application-dev/reference/arkui-js/js-framework-file.md b/en/application-dev/ui/js-framework-file.md similarity index 50% rename from en/application-dev/reference/arkui-js/js-framework-file.md rename to en/application-dev/ui/js-framework-file.md index 2f5f79964a41a052b389311f8c9cb86a899e8d46..ceb42a24155318b0e174144f1e44c1c823f2f6b1 100644 --- a/en/application-dev/reference/arkui-js/js-framework-file.md +++ b/en/application-dev/ui/js-framework-file.md @@ -26,7 +26,7 @@ Functions of the folders are as follows: - The **resources** directory stores resource configuration files, for example, for multi-resolution loading. For details, see [Resource Limitations and Access](js-framework-resource-restriction.md). - The **share** directory5+ is used to configure resources shared by multiple instances. For example, images and JSON files in this directory can be shared by **default1** and **default2** instances. ->![](../../public_sys-resources/icon-note.gif) **NOTE:** +>![](../public_sys-resources/icon-note.gif) **NOTE:** >- Reserved folders \(**i18n** and **resources**\) cannot be renamed. >- If the same resource name and directory are used under the **share** directory and the instance \(**default**\) directory, the resource in the instance directory will be used when you reference the directory. >- The **share** directory does not support **i18n**. @@ -41,7 +41,7 @@ Application resources can be accessed via an absolute or relative path. In the J - Store code files and resource files in the **common** directory and access the files in a required fashion. - In a **.css** file, use the **url\(\)** function to create a URL, for example, **url\(/common/xxx.png\)**. ->![](../../public_sys-resources/icon-note.gif) **NOTE:** +>![](../public_sys-resources/icon-note.gif) **NOTE:** >When code file A needs to reference code file B: >- If code files A and B are in the same directory, you can use either a relative or absolute path in code file B to reference resource files. >- If code files A and B are in different directories, you must use an absolute path in code file B to reference resource files because the directory of code file B changes during Webpack packaging. @@ -52,47 +52,35 @@ Application resources can be accessed via an absolute or relative path. In the J **Table 1** Supported image formats - - - @@ -53,8 +53,8 @@ As the data provider, **Provide** can update the data of its child nodes and t

    Image Format

    + - - - - - - - - - - - - - - - - - @@ -101,20 +89,16 @@ Application resources can be accessed via an absolute or relative path. In the J **Table 2** Supported video formats -

    Image Format

    API Version

    -

    File Format

    +

    File Format

    BMP

    -

    API Version 3+

    +

    BMP

    .bmp

    +

    .bmp

    GIF

    +

    GIF

    API Version 3+

    -

    .gif

    +

    .gif

    JPEG

    -

    API Version 3+

    +

    JPEG

    .jpg

    +

    .jpg

    PNG

    +

    PNG

    API Version 3+

    -

    .png

    +

    .png

    WebP

    -

    API Version 3+

    +

    WebP

    .webp

    +

    .webp

    - @@ -307,5 +307,5 @@ Multi-language syntax used on application development pages \(including simple f ## Language Acquisition -For details about how to obtain the language, see the Application Configuration section. +For details about how to obtain the language, see the [Application Configuration](../reference/apis/js-apis-basic-features-configuration.md) section. diff --git a/en/application-dev/reference/arkui-js/js-framework-resource-restriction.md b/en/application-dev/ui/js-framework-resource-restriction.md similarity index 67% rename from en/application-dev/reference/arkui-js/js-framework-resource-restriction.md rename to en/application-dev/ui/js-framework-resource-restriction.md index 8f4f462085a030629286e0289e819ba191409bd6..0a9abe9525e8d0c3d964df54d56c93bff302b486 100644 --- a/en/application-dev/reference/arkui-js/js-framework-resource-restriction.md +++ b/en/application-dev/ui/js-framework-resource-restriction.md @@ -1,16 +1,12 @@ # Resource Limitations and Access ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->- Screen density is supported since API version 4. ->- Other qualifiers are supported since API version 6. - ## Resource Qualifiers The name of a resource qualifier consists of one or more qualifiers that represent the application scenarios or device characteristics, covering the screen density, and more. The qualifiers are separated using hyphens \(-\). When creating a qualifiers file under **resources**, you need to understand the file naming conventions and the rules for matching qualifiers files and the device status. ## Naming Conventions for Resource Qualifiers -- Qualifiers are ordered in the following sequence: screen density. You can select one or multiple qualifiers to name your file based on your application scenarios and device characteristics, while following the preceding sequence. The MCC and MNC must exist at the same time. +- Qualifiers are ordered in the following sequence: screen density. You can select one or multiple qualifiers to name your file based on your application scenarios and device characteristics, while following the preceding sequence. - The qualifiers are separated using hyphens \(-\), for example, **res-dark-ldpi.json**. - Value range of qualifiers: The value of each qualifier must meet the requirements specified in the following table. Otherwise, the resource files in the **resources** directory cannot be matched. The qualifiers are case sensitive. - Qualifier prefix: The name of a qualifier file in the **resources** file has the prefix **res**, for example, **res-ldpi.json**. @@ -26,24 +22,7 @@ The name of a resource qualifier consists of one or more qualifiers that represe - - - - - - - - - - - - - @@ -58,7 +58,7 @@ By default, the attributes in the **AppStorage** are changeable, and **AppSto - - -

    Video Formats

    + - - - - - diff --git a/en/application-dev/reference/arkui-js/js-framework-js-file.md b/en/application-dev/ui/js-framework-js-file.md similarity index 96% rename from en/application-dev/reference/arkui-js/js-framework-js-file.md rename to en/application-dev/ui/js-framework-js-file.md index 326478ea6d6b711954f190a8ca604bf4d23d8edb..9cdbf0654d84ab45ee6e1a5092e3cd9ab21b5ed5 100644 --- a/en/application-dev/reference/arkui-js/js-framework-js-file.md +++ b/en/application-dev/ui/js-framework-js-file.md @@ -47,10 +47,10 @@ export default { test: "by getAPP" }, onCreate() { - console.info('AceApplication onCreate'); + console.info('Application onCreate'); }, onDestroy() { - console.info('AceApplication onDestroy'); + console.info('Application onDestroy'); }, }; ``` diff --git a/en/application-dev/reference/arkui-js/js-framework-js-tag.md b/en/application-dev/ui/js-framework-js-tag.md similarity index 98% rename from en/application-dev/reference/arkui-js/js-framework-js-tag.md rename to en/application-dev/ui/js-framework-js-tag.md index c03ec274eeba26f9d430f6866f490a93ee1e9446..16d00b860cd0f3dedebd5745d70ffa03ca473f28 100644 --- a/en/application-dev/reference/arkui-js/js-framework-js-tag.md +++ b/en/application-dev/ui/js-framework-js-tag.md @@ -51,7 +51,7 @@ The "js" tag contains the instance name, window style, and page route informatio

    Video Formats

    API Version

    -

    File Formats

    +

    File Formats

    H.264 AVC

    +

    H.264 AVC

    Baseline Profile (BP)

    API Version 3+

    -

    .3gp

    +

    .3gp

    .mp4

    ->![](../../public_sys-resources/icon-note.gif) **NOTE:** +>![](../public_sys-resources/icon-note.gif) **NOTE:** >The **"name"**, "window", and **"pages"** tags are configured in the **"js"** tag of the config.json file. ## "pages" @@ -69,7 +69,7 @@ The **"pages"** defines the route information of each page. Each page consists } ``` ->![](../../public_sys-resources/icon-note.gif) **NOTE:** +>![](../public_sys-resources/icon-note.gif) **NOTE:** >- The first page in the **pages** list is the home page, also referred to as the entry, of the application. >- The page name should not be a component name, for example, **text.hml** or **button.hml**. @@ -80,7 +80,7 @@ The **"window"** defines window-related configurations. To solve the screen ad - Specify **designWidth**, which is the logical screen width. All size styles, such as **width** and **font-size**, are scaled at the ratio of **designWidth** to the physical screen width. For example, when **designWidth** is 720 px and if you set **width** to 100 px, the actual display width is scaled to 200 physical px on the screen whose physical width is 1440 px. - Set **autoDesignWidth** to **true**, the **designWidth** field will be ignored, and the component and layout will be scaled automatically based on the screen density. The logical screen width is automatically calculated based on the physical screen width and screen density. The logical screen width may vary depending on the device. Use the relative layout to adapt to different devices. For example, on a device with a resolution of 466x466 and 320 DPI \(a screen density of 2x, with 160 DPI as the base\), 1 px is equivalent to 2 physical px. - >![](../../public_sys-resources/icon-note.gif) **NOTE:** + >![](../public_sys-resources/icon-note.gif) **NOTE:** >1. The default **** value in the current style is calculated based on the screen density. For example, if the screen density is x2 \(with 160 DPI as the baseline\) and the default **** value is 1 px, the actual length rendered on the device is 2 physical px. >2. Values of **autoDesignWidth** and **designWidth** do not affect how the default **** value is calculated and the final effect. @@ -141,7 +141,7 @@ The following is a sample code snippet: ``` { "app": { - "bundleName": "com.huawei.player", + "bundleName": "com.example.player", "version": { "code": 1, "name": "1.0" diff --git a/en/application-dev/reference/arkui-js/js-framework-lifecycle.md b/en/application-dev/ui/js-framework-lifecycle.md similarity index 100% rename from en/application-dev/reference/arkui-js/js-framework-lifecycle.md rename to en/application-dev/ui/js-framework-lifecycle.md diff --git a/en/application-dev/reference/arkui-js/js-framework-multiple-languages.md b/en/application-dev/ui/js-framework-multiple-languages.md similarity index 98% rename from en/application-dev/reference/arkui-js/js-framework-multiple-languages.md rename to en/application-dev/ui/js-framework-multiple-languages.md index 3c4e8c1ba06cf4974020993b0975a0038bcf32fb..8e3a2015c59b0be47cbfdafdc92519dfae4f6e59 100644 --- a/en/application-dev/reference/arkui-js/js-framework-multiple-languages.md +++ b/en/application-dev/ui/js-framework-multiple-languages.md @@ -238,7 +238,7 @@ Multi-language syntax used on application development pages \(including simple f

    Function

    See Table 3.

    +

    See Table 5.

    Yes

    MCC and MNC6+

    -

    Indicates the device MCC and SIM card MNC, for example, mcc460-mnc01 and mcc460-mnc02.

    -

    Screen orientation6+

    -

    Indicates the screen orientation of the device. The value can be:

    -
    • vertical: portrait orientation
    • horizontal: landscape orientation
    -

    Device type6+

    -

    Indicates the device type. The value can be:

    -
    • phone: smartphone
    • tablet: tablet
    • tv: smart TV
    • wearable: wearable
    -

    Screen density

    +

    Screen density

    Indicates the screen density of the device, in dpi. The value can be:

    • ldpi: low-density screen (~120 dpi) (0.75 x Reference density)
    • mdpi: medium-density screen (~160 dpi) (reference density)
    • hdpi: high-density screen (~240 dpi) (1.5 x Reference density)
    • xhdpi: extra high-density screen (~320 dpi) (2.0 x Reference density)
    • xxhdpi: extra extra high-density screen (~480 dpi) (3.0 x Reference density)
    • xxxhdpi: extra extra extra high-density screen (~640 dpi) (4.0 x Reference density)
    @@ -54,7 +33,7 @@ The name of a resource qualifier consists of one or more qualifiers that represe ## **Rules for Matching Qualifiers Files and Device Resources** -- Qualifiers are matched with the device resources in the following priorities: MCC and MNC \>screen orientation \> night mode \> device type \> screen density. If no matching resource qualifier file is found, the default resource qualifier file is used. +- Qualifiers are matched with the device resources in the following priorities: MCC and MNC \> screen orientation \> dark mode \> device type \> screen density. If no matching resource qualifier file is found, the default resource qualifier file is used. - If a qualifier file contains resource qualifiers, their values must be consistent with the current device status so that the file can be used for matching the device status. For example, the **res-hdpi.json** qualifier file does not match the device density **xhdpi**. ## Referencing Resources in the JS Module @@ -64,7 +43,7 @@ You can use the $r syntax in the application development files **.hml** and * - @@ -123,6 +102,6 @@ resources/res-defaults.json: ``` ->![](../../public_sys-resources/icon-note.gif) **NOTE:** +>![](../public_sys-resources/icon-note.gif) **NOTE:** >The resource qualifier file does not support color enumeration. diff --git a/en/application-dev/reference/arkui-js/js-framework-syntax-css.md b/en/application-dev/ui/js-framework-syntax-css.md similarity index 99% rename from en/application-dev/reference/arkui-js/js-framework-syntax-css.md rename to en/application-dev/ui/js-framework-syntax-css.md index e4402446b74f866356a750f301a4a0f8051611ec..f03027616e927dd64a75a3ec9216b9d99e30b010 100644 --- a/en/application-dev/reference/arkui-js/js-framework-syntax-css.md +++ b/en/application-dev/ui/js-framework-syntax-css.md @@ -219,7 +219,7 @@ The following is an example for you to use the **:active** pseudo-class to con } ``` ->![](../../public_sys-resources/icon-note.gif) **NOTE:** +>![](../public_sys-resources/icon-note.gif) **NOTE:** >Pseudo-classes are not supported for the **** component and its child components, including, ****, ****, ****, and ****. ## Precompiled Styles @@ -257,7 +257,7 @@ Precompilation is a program that uses specific syntax to generate CSS files. It } ``` - >![](../../public_sys-resources/icon-note.gif) **NOTE:** + >![](../public_sys-resources/icon-note.gif) **NOTE:** >Place precompiled style files in the **common** directory. diff --git a/en/application-dev/reference/arkui-js/js-framework-syntax-hml.md b/en/application-dev/ui/js-framework-syntax-hml.md similarity index 94% rename from en/application-dev/reference/arkui-js/js-framework-syntax-hml.md rename to en/application-dev/ui/js-framework-syntax-hml.md index 28b80c24c71e0126365ad7f23b18c7d67391cb93..e75affdf26dba11ea3888ab93908bc090870c7d3 100644 --- a/en/application-dev/reference/arkui-js/js-framework-syntax-hml.md +++ b/en/application-dev/ui/js-framework-syntax-hml.md @@ -35,7 +35,7 @@ export default { } ``` ->![](../../public_sys-resources/icon-note.gif) **NOTE:** +>![](../public_sys-resources/icon-note.gif) **NOTE:** >- To make the array data modification take effect, use the **splice** method to change array items. >- ECMAScript 6 \(ES6\) syntax is not supported in HML. @@ -66,7 +66,7 @@ Events can be written in the following formats: ``` ``` - /* xxx.js */ + // xxx.js export default { data: { count: 0 @@ -124,13 +124,14 @@ Bubbling event binding covers the following: - Bind an event callback for event bubbling: **on:\{event\}.bubble**. **on:\{event\}** is equivalent to **on:\{event\}.bubble**. - Bind an event callback, but stop the event from bubbling upwards: **grab:\{event\}.bubble**. **grab:\{event\}** is equivalent to **grab:\{event\}.bubble**. - >![](../../public_sys-resources/icon-note.gif) **NOTE:** - >For details about bubbling events, see [Universal Events](js-components-common-events.md). + >![](../public_sys-resources/icon-note.gif) **NOTE:** + >For details about bubbling events, see [Universal Events](../reference/arkui-js/js-components-common-events.md). -- **Example** +- Example ``` +
    @@ -160,8 +161,8 @@ Bubbling event binding covers the following: ``` ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->- Events bound using a traditional statement \(such as **onclick**\) will bubble only when the API version in use is 6 or later. +>![](../public_sys-resources/icon-note.gif) **NOTE:** +>Events bound using a traditional statement \(such as **onclick**\) will bubble only when the API version in use is 6 or later. ## Capturing Event Binding5+ @@ -175,6 +176,7 @@ Event capturing binding includes: - Example ``` +
    @@ -243,7 +245,7 @@ The **for** loop supports the following statements: - for="v in array": **v** is a custom element variable, whose index is **$idx** by default. - for="\(i, v\) in array": **i** indicates the element index, and **v** indicates the element variable. All elements of the array object will be looped through. ->![](../../public_sys-resources/icon-note.gif) **NOTE:** +>![](../public_sys-resources/icon-note.gif) **NOTE:** >- Each element in the array must have the data attribute specified by **tid**. Otherwise, an exception may occur. >- The attribute specified by **tid** in the array must be unique. Otherwise, performance loss occurs. In the above example, only **id** and **name** can be used as **tid** because they are unique fields. >- The **tid** field does not support expressions. @@ -264,7 +266,7 @@ There are two ways to implement conditional rendering: **if-elif-else** or ** ``` ``` -// xxx.css +/* xxx.css */ .container{ flex-direction: column; align-items: center; @@ -303,7 +305,7 @@ In the optimized rendering \(**show**\), if **show** is **true**, the node is ``` ``` -// xxx.css +/* xxx.css */ .container{ flex-direction: column; align-items: center; @@ -327,7 +329,7 @@ export default { } ``` ->![](../../public_sys-resources/icon-note.gif) **NOTE:** +>![](../public_sys-resources/icon-note.gif) **NOTE:** >Do not use **for** and **if** attributes at the same time in an element. ## Logic Control Block @@ -364,7 +366,7 @@ export default { ## Template Reference -HML supports using elements to reference template files. For details, see [Custom Components](js-components-custom-basic-usage.md). +HML supports using elements to reference template files. For details, see [Custom Components](../reference/arkui-js/js-components-custom.md). ``` diff --git a/en/application-dev/reference/arkui-js/js-framework-syntax-js.md b/en/application-dev/ui/js-framework-syntax-js.md similarity index 98% rename from en/application-dev/reference/arkui-js/js-framework-syntax-js.md rename to en/application-dev/ui/js-framework-syntax-js.md index 60f01c968b9a73e2d2f92ae68f5ebc2a374ec95c..9742330e0e9f05f1e15d6f901edceb2937e91cf5 100644 --- a/en/application-dev/reference/arkui-js/js-framework-syntax-js.md +++ b/en/application-dev/ui/js-framework-syntax-js.md @@ -54,10 +54,10 @@ The ES6 syntax is supported. // app.js export default { onCreate() { - console.info('AceApplication onCreate'); + console.info('Application onCreate'); }, onDestroy() { - console.info('AceApplication onDestroy'); + console.info('Application onDestroy'); }, globalData: { appData: 'appData', @@ -134,14 +134,14 @@ The ES6 syntax is supported.
    - - @@ -272,7 +272,7 @@ The ES6 syntax is supported. - @@ -348,7 +348,7 @@ The ES6 syntax is supported. -

    Attribute

    Data Type

    +

    Type

    Description

    Array/Object

    Used for communication between components. This attribute can be transferred to components via <tag xxxx='value'>. A props name must be in lowercase and cannot start with a dollar sign ($) or underscore (_). Do not use reserved words (for, if, show, and tid). Currently, props does not support functions. For details, see Custom Components.

    +

    Used for communication between components. This attribute can be transferred to components via <tag xxxx='value'>. A props name must be in lowercase and cannot start with a dollar sign ($) or underscore (_). Do not use reserved words (for, if, show, and tid). Currently, props does not support functions. For details, see Custom Components.

    computed

    Object

    Used for pre-processing an object for reading and setting. The result is cached. The name cannot start with a dollar sign ($) or underscore (_). Do not use reserved words. For details, see Custom Components.

    +

    Used for pre-processing an object for reading and setting. The result is cached. The name cannot start with a dollar sign ($) or underscore (_). Do not use reserved words. For details, see Custom Components.

    data: string, callback: string | Function

    Listens for attribute changes. If the value of the data attribute changes, the bound event is triggered. For details, see Custom Components.

    +

    Listens for attribute changes. If the value of the data attribute changes, the bound event is triggered. For details, see Custom Components.

    Usage:

    this.$watch('key', callback)

    ease

    Animation curve for scrolling. Available option:

    -

    animation-timing-function

    +

    animation-timing-function

    complete

    diff --git a/en/application-dev/reference/arkui-js/js-framework-syntax.md b/en/application-dev/ui/js-framework-syntax.md similarity index 100% rename from en/application-dev/reference/arkui-js/js-framework-syntax.md rename to en/application-dev/ui/js-framework-syntax.md diff --git a/en/application-dev/reference/arkui-js/js-framework.md b/en/application-dev/ui/js-framework.md similarity index 100% rename from en/application-dev/reference/arkui-js/js-framework.md rename to en/application-dev/ui/js-framework.md diff --git a/en/application-dev/reference/arkui-ts/ts-a-deep-dive-into-component.md b/en/application-dev/ui/ts-a-deep-dive-into-component.md similarity index 82% rename from en/application-dev/reference/arkui-ts/ts-a-deep-dive-into-component.md rename to en/application-dev/ui/ts-a-deep-dive-into-component.md index b29ff6910765035acfaa5d028ea7f799a866d7e5..cc95c1bae6dbfe8e1078c086953e39f85ada01bb 100644 --- a/en/application-dev/reference/arkui-ts/ts-a-deep-dive-into-component.md +++ b/en/application-dev/ui/ts-a-deep-dive-into-component.md @@ -1,4 +1,4 @@ -# A Deep Dive into @Component +# About @Component - **[build Function](ts-function-build.md)** diff --git a/en/application-dev/ui/ts-application-resource-access.md b/en/application-dev/ui/ts-application-resource-access.md new file mode 100644 index 0000000000000000000000000000000000000000..15c34218bba34e782e278969adce902a9996bb7f --- /dev/null +++ b/en/application-dev/ui/ts-application-resource-access.md @@ -0,0 +1,184 @@ +# Accessing Application Resources + +## Resource Definition + +Application resources are defined by in the project's **resources** directory, which is organized as follows: + +- Level-1: **base** sub-directory, qualifiers sub-directories, and **rawfile** sub-directory + - The **base** sub-directory is a default directory. If no qualifiers sub-directories in the **resources** directory of the application match the device status, the resource file in the **base** sub-directory will be automatically referenced. + - You need to create qualifiers sub-directories on your own. The name of a qualifiers sub-directory consists of one or more qualifiers that represent the application scenarios or device characteristics, covering the mobile country code \(MCC\), mobile network code \(MNC\), language, script, country or region, screen orientation, device type, color mode, and screen density. The qualifiers are separated using underscores \(\_\) or hyphens \(-\). + - When the resources in the **rawfile** sub-directory are referenced, resource files will not be matched based on the device status. You can directly store resource files in the **rawfile** sub-directory. + +- Level-2: resource sub-directories + - Resource sub-directories store basic elements such as character strings, colors, and floating point numbers, and resource files such as media files. + - Supported files and resource types are listed in the table below: + + + + + + + + + + + + + + + + + + + + + + +

    File Name

    +

    Resource Type

    +

    color.json

    +

    Color resource.

    +

    float.json

    +

    Resources such as spacing, rounded corners, and fonts.

    +

    string.json

    +

    String resource.

    +

    plural.json

    +

    String resource.

    +

    media directory

    +

    Image resource.

    +
    + + + +## Referencing Resources + +To reference an application resource in a project, use the **"$r\('app.type.name'\)"** format. **app** indicates the resource defined in the **resources** directory of the application. **type** indicates the resource type \(or the location where the resource is stored\). The value can be **color**, **float**, **string**, **plural**, or **media**. **name** indicates the resource name, which you set when defining the resource. + +When referencing resources in the **rawfile** sub-directory, use the **"$rawfile\('filename'\)"** format. Currently, **$rawfile** allows only the **** component to reference image resources. In the format, **filename** indicates the relative path of a file in the **rawfile** directory, and the file name must contain the file name extension. Note that the relative path cannot start with a slash \(/\). + +## Example + +Some custom resources in the **base** sub-directory are as follows: + +``` + resources + ├─ base + │ ├─ element + │ │ ├─ color.json + │ │ ├─ string.json + │ │ └─ float.json + │ └─ media + │ └─ my_background_image.png + └─ rawfile + ├─ test.png + └─ newDir + └─ newTest.png +``` + +The content of the **color.json** file is as follows: + +``` +{ + "color": [ + { + "name": "color_hello", + "value": "#ffff0000" + }, + { + "name": "color_world", + "value": "#ff0000ff" + } + ] +} +``` + +The content of the **float.json** file is as follows: + +``` +{ + "float":[ + { + "name":"font_hello", + "value":"28.0fp" + }, + { + "name":"font_world", + "value":"20.0fp" + } + ] +} +``` + +The content of the **string.json** file is as follows: + +``` +{ + "string":[ + { + "name":"string_hello", + "value":"Hello" + }, + { + "name":"string_world", + "value":"World" + }, + { + "name":"message_arrive", + "value":"We will arrive at %s." + } + ] +} +``` + +The content of the **plural.json** file is as follows: + +``` +{ + "plural":[ + { + "name":"eat_apple", + "value":[ + { + "quantity":"one", + "value":"%d apple" + }, + { + "quantity":"other", + "value":"%d apples" + } + ] + } + ] +} +``` + +In the **ets** file, you can use the resources defined in the **resources** directory. + +``` +Text($r('app.string.string_hello')) + .fontColor($r('app.color.color_hello')) + .fontSize($r('app.float.font_hello')) +} + +Text($r('app.string.string_world')) + .fontColor($r('app.color.color_world')) + .fontSize($r('app.float.font_world')) +} + +Text($r('app.string.message_arrive', "five of the clock")) // Reference string resources. The second parameter of $r is used to replace %s. + .fontColor($r('app.color.color_hello')) + .fontSize($r('app.float.font_hello')) +} + +Text($r('app.plural.eat_apple', 5, 5)) // Reference plural resources. The first parameter specifies the plural resource, and the second parameter specifies the number of plural resources. The third number indicates the substitute of %d. + .fontColor($r('app.color.color_world')) + .fontSize($r('app.float.font_world')) +} + +Image($r(?app.media.my_background_image creation)) // Reference media resources. + +Image($rawfile( Femaletest.png loaded)) // Reference an image in the rawfile directory. + +Image($rawfile(newDir/newTest.png loaded)) // Reference an image in the rawfile directory. +``` + diff --git a/en/application-dev/reference/arkui-ts/ts-application-states-apis-environment.md b/en/application-dev/ui/ts-application-states-apis-environment.md similarity index 92% rename from en/application-dev/reference/arkui-ts/ts-application-states-apis-environment.md rename to en/application-dev/ui/ts-application-states-apis-environment.md index 10de2a33d1fee0a36d172f0cfbd02fce07d54038..69e62557dfa01f19e884799ddfb9d66b39d39ddc 100644 --- a/en/application-dev/reference/arkui-ts/ts-application-states-apis-environment.md +++ b/en/application-dev/ui/ts-application-states-apis-environment.md @@ -1,6 +1,6 @@ # Environment -**Environment** is a singleton object created by the framework when the application is started. It provides the **AppStorage** with a series of environment state attributes required by the application. These attributes describe the device environment where the application runs. **Environment** and its attributes are immutable. All attribute values are of the simple type. +**Environment** is a singleton object created by the framework when the application is started. It provides the **AppStorage** with a series of environment state attributes required by the application. These attributes describe the device environment where the application runs. **Environment** and its attributes are immutable, and all attribute values are of the simple type. The following example shows how to obtain the voice environment from **Environment**: @@ -31,7 +31,7 @@ var enable = AppStorageGet("accessibilityEnabled");

    boolean

    Associates this system item with the Appstorage. You are advised to use this API during application startup. If the attribute already exists in the Appstorage, false is returned. Do not use the variables in the AppStorage. Call this method to associate environment variables.

    +

    Associates this system variable to the Appstorage. You are advised to use this API during application startup. If the attribute already exists in the Appstorage, false is returned. Do not use the variables in the AppStorage. Instead, call this method to bind environment variables.

    EnvProps

    @@ -58,7 +58,7 @@ var enable = AppStorageGet("accessibilityEnabled");
    -## Environment Built-in Environment Variables +## Built-in Environment Variables - -

    key

    diff --git a/en/application-dev/reference/arkui-ts/ts-application-states-apis-persistentstorage.md b/en/application-dev/ui/ts-application-states-apis-persistentstorage.md similarity index 81% rename from en/application-dev/reference/arkui-ts/ts-application-states-apis-persistentstorage.md rename to en/application-dev/ui/ts-application-states-apis-persistentstorage.md index 0b2c48c40b3d7a084a1788728e9c1c5f68446c71..0d4215b5f06b1e85a4e5c4437d15e9167627f2e1 100644 --- a/en/application-dev/reference/arkui-ts/ts-application-states-apis-persistentstorage.md +++ b/en/application-dev/ui/ts-application-states-apis-persistentstorage.md @@ -1,6 +1,6 @@ # PersistentStorage -**PersistentStorage** is used to manage persistent data of applications. This object can link the persistent data of a specific tag to the **AppStorage** and access the persistent data through the **AppStorage** APIs or access the variable of the corresponding key through the **@StorageLink** decorator. +**PersistentStorage** is used to manage persistent data of applications. This object can link the persistent data of a specific flag to the **AppStorage** and access the persistent data through the **AppStorage** APIs or access the variable of the corresponding key through the **@StorageLink** decorator. ## PersistentStorage APIs @@ -22,10 +22,10 @@

    void

    The associated named attribute becomes persistent data in the AppStorage. Value overwriting sequence:

    -

    If the attribute exists in the AppStorage, copy the data in Persistent to the attribute value in the AppStorage.

    +

    Changes associated named attribute to persistent data in the AppStorage. Value overwriting sequence:

    +

    If the attribute exists in the AppStorage, overwrite its value with the attribute value in Persistent.

    If Persistent contains the specified attribute, use the attribute value in Persistent.

    -

    If the preceding conditions are not met, defaultValue is used. The null and undefined values are not supported.

    +

    If the preceding conditions are not met, use defaultValue. The null and undefined values are not supported.

    DeleteProp

    @@ -34,7 +34,7 @@

    void

    Cancels bidirectional data binding. The value of this attribute is deleted from the persistent storage.

    +

    Cancels two-way binding. The value of this attribute will be deleted from the persistent storage.

    PersistProps

    @@ -61,7 +61,7 @@
    ->![](../../public_sys-resources/icon-note.gif) **NOTE:** +>![](../public_sys-resources/icon-note.gif) **NOTE:** >- When using **PersistProp**, ensure that the input key exists in the **Appstorage**. >- **DeleteProp** takes effect only for the data that has been linked during the current startup. diff --git a/en/application-dev/reference/arkui-ts/ts-application-states-appstorage.md b/en/application-dev/ui/ts-application-states-appstorage.md similarity index 75% rename from en/application-dev/reference/arkui-ts/ts-application-states-appstorage.md rename to en/application-dev/ui/ts-application-states-appstorage.md index 1e8d4da37136defa05f89451f62a84dab851b034..9dfac0e2e52fcf1df995cb7e8cb0875d4065d9cb 100644 --- a/en/application-dev/reference/arkui-ts/ts-application-states-appstorage.md +++ b/en/application-dev/ui/ts-application-states-appstorage.md @@ -1,12 +1,12 @@ # AppStorage -**AppStorage** is a singleton object in an application and is created by the UI framework when the application is started. It is designed to provide central storage for variable application state attributes. **AppStorage** contains all the state attributes that need to be accessed throughout the application. The **AppStorage** retains all attributes and their values as long as the application remains running, and the attribute values can be accessed through unique key values. +**AppStorage** is a singleton object in an application and is created by the UI framework when the application is started. It is designed to provide central storage for changing application state attributes. **AppStorage** contains all the state attributes that need to be accessed throughout the application. The **AppStorage** retains all attributes and their values as long as the application remains running, and the attribute values can be accessed through unique key values. -The UI component can synchronize the application state data with the **AppStorage** through the decorators. The implementation of the application service logic can also access the **AppStorage** through APIs. +The UI component can synchronize the application state data with the **AppStorage** through the decorators. The application service logic can also be implemented by accessing the **AppStorage** through APIs. -The selection state property of the **AppStorage** can be synchronized with different data sources or data sinks. These data sources and data sinks can be local or remote on the device and have different functions, such as data persistence. Such data sources and data sinks can be implemented independently of the UI in service logics. +The selection state attribute of the **AppStorage** can be synchronized with different data sources or data sinks. These data sources and data sinks can be local or remote devices and provide different functions, such as data persistence. Such data sources and data sinks can be implemented independently of the UI in the service logic. -By default, the attributes in the **AppStorage** are changeable, and **AppStorage** can also use immutable \(read-only\) attributes. +By default, the attributes in the **AppStorage** are changeable. If needed, **AppStorage** can also use immutable \(read-only\) attributes. ## AppStorage APIs @@ -27,7 +27,7 @@ By default, the attributes in the **AppStorage** are changeable, and **AppSto

    @Link

    Returns a bidirectional data binding to this attribute if there is data with a given key, meaning that changes made to the data by a variable or component will be synchronized to the AppStorage, and changes made to the data by the AppStorage will be synchronized to the variable or component. If the attribute with this key does not exist or is read-only, undefined is returned.

    +

    Returns the two-way binding to this attribute if there is data with a given key. This means that changes made to the data by a variable or component will be synchronized to the AppStorage, and changes made to the data by the AppStorage will be synchronized to the variable or component. If the attribute with this key does not exist or is read-only, undefined is returned.

    SetAndLink

    @@ -37,7 +37,7 @@ By default, the attributes in the **AppStorage** are changeable, and **AppSto

    @Link

    Similar to the Link API. If the current key is stored in the AppStorage, the value corresponding to the key is returned. If the key has not been created, a Link instance corresponding to the default value is created and returned.

    +

    Works in a way similar to the Link API. If the current key is stored in the AppStorage, the value corresponding to the key is returned. If the key has not been created, a Link instance corresponding to the default value is created and returned.

    Prop

    @@ -46,8 +46,8 @@ By default, the attributes in the **AppStorage** are changeable, and **AppSto

    @Prop

    Returns a one-way data binding to an attribute with a given key if the attribute exists. This one-way binding means that changes to the attribute can only be synchronized to variables or components through AppStorage. The variable returned by this method is an immutable variable, which is applicable to the variable and immutable state attributes. If the attribute with this key does not exist, undefined is returned.

    -
    NOTE:

    The attribute value type corresponding to the prop method is of a simple type.

    +

    Returns one-way binding to an attribute with a given key if the attribute exists. This one-way binding means that changes to the attribute can only be synchronized to variables or components through AppStorage. The variable returned by this method is an immutable one, which is applicable both to the variable and immutable state attributes. If the attribute with this key does not exist, undefined is returned.

    +
    NOTE:

    The attribute value type used in the prop method must be of a simple type.

    @Prop

    Similar to the Prop API. If the current key is stored in the AppStorage, the value corresponding to the key is returned. If the key has not been created, a Prop instance corresponding to the default value is created and returned.

    +

    Works in a way similar to the Prop API. If the current key is stored in the AppStorage, the value corresponding to the key is returned. If the key has not been created, a Prop instance corresponding to the default value is created and returned.

    Has

    @@ -103,8 +103,8 @@ By default, the attributes in the **AppStorage** are changeable, and **AppSto

    boolean

    If an attribute with the same name exists: returns true if the attribute can be modified, and false otherwise.

    -

    If the attribute with the same name does not exist: Create the first attribute whose value is the defaultValue. The null and undefined values are not supported.

    +

    Returns true if an attribute with the same name exists and the attribute can be modified; returns false otherwise.

    +

    If the attribute with the same name does not exist: the first attribute whose value is the defaultValue is created and returned. The null and undefined values are not supported.

    Delete

    @@ -122,7 +122,7 @@ By default, the attributes in the **AppStorage** are changeable, and **AppSto

    boolean

    Deletes all attributes. If a state variable still references any of the attributes, false is returned.

    +

    Deletes all attributes. If any of the attributes is being referenced by a state variable, false is returned.

    IsMutable

    @@ -136,7 +136,7 @@ By default, the attributes in the **AppStorage** are changeable, and **AppSto
    ->![](../../public_sys-resources/icon-note.gif) **NOTE:** +>![](../public_sys-resources/icon-note.gif) **NOTE:** >Currently, the API can process only basic data and cannot modify a value in an object. ## Example diff --git a/en/application-dev/ui/ts-application-states-storagelink-storageprop.md b/en/application-dev/ui/ts-application-states-storagelink-storageprop.md new file mode 100644 index 0000000000000000000000000000000000000000..c2c4f351939e0e85e419bd666c4c781c5e4d28b3 --- /dev/null +++ b/en/application-dev/ui/ts-application-states-storagelink-storageprop.md @@ -0,0 +1,54 @@ +# Synchronization Between AppStorage and Components + +In [Managing Component States](ts-component-states-state.md), we have defined how to synchronize the state variables of the child components with the **@State** decorated variables in the parent component or ancestor component, including **@Prop**, **@Link**, and **@Consume**. + +In this section, we'll describe how to synchronize component variables with the **AppStorage** through the **@StorageLink** and **@StorageProp** decorators. + +## @StorageLink Decorator + +Two-way data binding can be established between components and the **AppStorage** through state variables decorated by **@StorageLink\(_key_\)**. Wherein, **key** is the attribute key value in the **AppStorage**. When a component containing the **@StorageLink** decorated variable is created, the variable is initialized using the value in the **AppStorage**. Changes made to this variable in the component will be first synchronized to the **AppStorage**, and then to other bound instances, such as **PersistentStorage** or other bound UI components. + +## @StorageProp Decorator + +One-way data binding can be established between components and the **AppStorage** through state variables decorated by **@StorageProp\(_key_\)**. Wherein, **key** is the attribute key value in the **AppStorage**. When a component containing the **StorageProp** decorated variable is created, the variable is initialized using the value in the **AppStorage**. The change to the attribute value in the **AppStorage** will cause the bound UI component to update the state. + +## Example + +``` +let varA = AppStorage.Link('varA') +let envLang = AppStorage.Prop('languageCode') + +@Entry +@Component +struct ComponentA { + @StorageLink('varA') varA: number = 2 + @StorageProp('languageCode') lang: string = 'en' + private label: string = 'count' + + private aboutToAppear() { + this.label = (this.lang === 'en') ? 'Number' : 'Count' + } + + build() { + Row({ space: 20 }) { + + Button(`${this.label}: ${this.varA}`) + .onClick(() => { + AppStorage.Set('varA', AppStorage.Get('varA') + 1) + }) + Button(`lang: ${this.lang}`) + .onClick(() => { + if (this.lang === 'zh') { + AppStorage.Set('languageCode', 'en') + } else { + AppStorage.Set('languageCode', 'en') + } + this.label = (this.lang === 'en') ? 'Number' : 'Count' + }) + } + } +} +``` + +Each time the user clicks the **Count** button, the value of **this.varA** will increase by 1. This variable is synchronized with **varA** in the **AppStorage**. Each time the user clicks the language icon, the value of **languageCode** in the **AppStorage** will be changed, and the change will be synchronized to the **this.lang** variable. + diff --git a/en/application-dev/reference/arkui-ts/ts-attribution-configuration.md b/en/application-dev/ui/ts-attribution-configuration.md similarity index 63% rename from en/application-dev/reference/arkui-ts/ts-attribution-configuration.md rename to en/application-dev/ui/ts-attribution-configuration.md index e7db9c1e38d47352905de894148073a52fee80a4..f1ff930d90b2cd8574526fad963ab8085e4e02a7 100644 --- a/en/application-dev/reference/arkui-ts/ts-attribution-configuration.md +++ b/en/application-dev/ui/ts-attribution-configuration.md @@ -9,9 +9,9 @@ Text('123') .fontSize(12) ``` -You can also use the "**.**" operation to implement method chaining and configure multiple attributes of the component at the same time. +You can also use the "**.**" operation to implement chain call to configure multiple attributes at the same time. -Below is the sample code for configuring multiple attributes of the **** component at the same time: +Below is the sample code for configuring the **width** and **height** attributes of the **** component at the same time: ``` Image('a.jpg') @@ -20,7 +20,7 @@ Image('a.jpg') .height(100) ``` -In addition to constants, you can also pass variables or expressions, as shown in the following: +In addition to constants, you can also pass variables or expressions, as shown below: ``` // Size, count, and offset are private variables defined in the component. @@ -31,9 +31,9 @@ Image('a.jpg') .height(this.offset + 100) ``` -For attributes of preset components, the framework also predefines some enumeration types, which you can call to pass enums. +For attributes of preset components, the framework also provides some predefined enumeration types, which you can pass as parameters to methods. -Enumeration types must meet the parameter type requirements, with details on the definition of enumeration types for specific attributes. +Enumeration types must meet the parameter type requirements on the enumeration type definitions for specific attributes. You can configure the font color and weight attributes of the **** component as follows: diff --git a/en/application-dev/reference/arkui-ts/ts-child-component-configuration.md b/en/application-dev/ui/ts-child-component-configuration.md similarity index 71% rename from en/application-dev/reference/arkui-ts/ts-child-component-configuration.md rename to en/application-dev/ui/ts-child-component-configuration.md index 83eedca2c17ba1f17b8c16e737a43ec501289b44..4d8d82427410ae6c037445446eecdbff94cc9d47 100644 --- a/en/application-dev/reference/arkui-ts/ts-child-component-configuration.md +++ b/en/application-dev/ui/ts-child-component-configuration.md @@ -1,6 +1,6 @@ # Child Component Configuration -For a component that supports child component configuration, for example, a container component, add the UI descriptions of the child components inside "**\{ ... \}**". The ****, ****, ****, ****, ****, and **** components are container components. +For a component that supports child components, for example, a container component, add the UI descriptions of the child components inside "**\{ ... \}**". The ****, ****, ****, ****, ****, and **** components are container components. The following is a simple example of the **** component: @@ -15,7 +15,7 @@ Column() { } ``` -Multiple child components can be nested. +Multiple child components can be nested in the **** component, as shown below: ``` Column() { diff --git a/en/application-dev/reference/arkui-ts/ts-component-based-builder.md b/en/application-dev/ui/ts-component-based-builder.md similarity index 82% rename from en/application-dev/reference/arkui-ts/ts-component-based-builder.md rename to en/application-dev/ui/ts-component-based-builder.md index 7f6a9d32cb4a416da1bf6f3b6c8d7ba5f3f44157..ca33d875afd237420c4856665c2bcd4736828f4d 100644 --- a/en/application-dev/reference/arkui-ts/ts-component-based-builder.md +++ b/en/application-dev/ui/ts-component-based-builder.md @@ -1,6 +1,6 @@ # @Builder -The **@Builder** decorator defines a method for rendering custom components. It provides a method to work in a manner similar to the [build](ts-function-build.md) function. The syntax of the **@Builder** decorator is the same as that of the **build** function. +The **@Builder** decorator defines a method for rendering custom components It allows a method to work in the same way as the [build](ts-function-build.md) function. The syntax of methods decorated by **@Builder** is the same as that of the **build** function. You can use the **@Builder** decorator to quickly generate multiple layouts within a custom component. diff --git a/en/application-dev/reference/arkui-ts/ts-component-based-component.md b/en/application-dev/ui/ts-component-based-component.md similarity index 55% rename from en/application-dev/reference/arkui-ts/ts-component-based-component.md rename to en/application-dev/ui/ts-component-based-component.md index 2609e792b5897277ef08b292808252617cb4e31a..49854681fd5fa42f8975aa1ab684b738ea4810f7 100644 --- a/en/application-dev/reference/arkui-ts/ts-component-based-component.md +++ b/en/application-dev/ui/ts-component-based-component.md @@ -1,8 +1,8 @@ # @Component -A struct annotated by **@Component** has the component-based capability and can function an independent component. This type of component is also called a custom component. +A struct decorated by **@Component** has the component-based capability and can serve as an independent component. This type of component is also called a custom component. -This component can be combined with other components. It describes the UI structure by implementing the **build** method, which must comply with the API constraints of **Builder**. The API definition is as follows: +This component can be combined with other components. It describes the UI structure by implementing the **build** method, which must comply with the **Builder** API constraints. The API definition is as follows: ``` interface Builder { @@ -12,20 +12,20 @@ interface Builder { Custom components have the following features: -- **Composable:** can be combined with preset or other components, as well as common attributes and methods. -- **Reusable:** can be reused by other components and used as different instances in different parent components or containers. -- **With a lifecycle:** provide lifecycle callbacks in the component for service logic processing. -- **Data-driven update:** enable the UI to be automatically updated based on the status data. +- **Composability:** Custom components can be used with preset or other components, as well as common attributes and methods. +- **Reusable:** Custom components can be reused by other components and used as different instances in different parent components or containers. +- **Lifecycle:** Custom components provide callbacks for service logic processing throughout the lifecycle. +- **Data-driven update:** The UI of custom components can be automatically updated based on the status data. -The component lifecycle mainly includes the **aboutToAppear** and **aboutToDisappear** callbacks. For details, see [Custom Component Lifecycle Callbacks](ts-custom-component-lifecycle-callbacks.md). +The component lifecycle mainly involves two callbacks, **aboutToAppear** and **aboutToDisappear** . For details, see [Custom Component Lifecycle Callbacks](ts-custom-component-lifecycle-callbacks.md). ->![](../../public_sys-resources/icon-note.gif) **NOTE:** +>![](../public_sys-resources/icon-note.gif) **NOTE:** >- Components must comply with the preceding **Builder** API constraints. Other components are combined in declarative mode in the internal **build** method. The **build** method is called when a component is created or updated for the first time. ->- Do not customize constructors for components. +>- Custom constructors are prohibited for components. ## Example -The following code defines the **MyComponent** component: +The following code illustrates how to create a custom component named **MyComponent**: ``` @Component @@ -39,9 +39,9 @@ struct MyComponent { } ``` -The **build** method of **MyComponent** is executed during initial rendering. In addition, when the component status changes, the **build** method is executed again. +The **build** method of **MyComponent** is executed during initial rendering. When the component status changes, the **build** method will be executed again. -The following code uses the **MyComponent** component: +The following code illustrates how to use **MyComponent**: ``` @Component @@ -56,7 +56,7 @@ struct ParentComponent { } ``` -**MyComponent** can be embedded multiple times into different components for reuse. +**MyComponent** can be embedded multiple times and can be nested in different components, as shown in the code below: ``` @Component diff --git a/en/application-dev/reference/arkui-ts/ts-component-based-customdialog.md b/en/application-dev/ui/ts-component-based-customdialog.md similarity index 100% rename from en/application-dev/reference/arkui-ts/ts-component-based-customdialog.md rename to en/application-dev/ui/ts-component-based-customdialog.md diff --git a/en/application-dev/reference/arkui-ts/ts-component-based-entry.md b/en/application-dev/ui/ts-component-based-entry.md similarity index 90% rename from en/application-dev/reference/arkui-ts/ts-component-based-entry.md rename to en/application-dev/ui/ts-component-based-entry.md index 6dba072779b062cab2fd50b97f509bf570e0a6ca..a058f034fdb32a4658bf3de8336850f2893f149c 100644 --- a/en/application-dev/reference/arkui-ts/ts-component-based-entry.md +++ b/en/application-dev/ui/ts-component-based-entry.md @@ -2,12 +2,12 @@ The custom component decorated by **@Entry** functions as the default entry component of the respective page. When the page is loaded, the custom component decorated by **@Entry** is created and displayed first. ->![](../../public_sys-resources/icon-note.gif) **NOTE:** +>![](../public_sys-resources/icon-note.gif) **NOTE:** >A source file can contain at most one custom component decorated by **@Entry**. ## Example -Sample code for using **@Entry**: +Example of using **@Entry**: ``` // Only MyComponent decorated by @Entry is rendered and displayed. "hello world" is displayed, but "goodbye" is not displayed. diff --git a/en/application-dev/reference/arkui-ts/ts-component-based-extend.md b/en/application-dev/ui/ts-component-based-extend.md similarity index 63% rename from en/application-dev/reference/arkui-ts/ts-component-based-extend.md rename to en/application-dev/ui/ts-component-based-extend.md index e210c69634d9b08b94ef6369ea2a75ee45869b4d..729893c2ee6368fdba48ead9635bd540351da1d7 100644 --- a/en/application-dev/reference/arkui-ts/ts-component-based-extend.md +++ b/en/application-dev/ui/ts-component-based-extend.md @@ -1,11 +1,11 @@ # @Extend -The **@Extend** decorator adds new attribute functions to preset components, such as ****, ****, and ****. You can use the **@Extend** decorator to quickly define and reuse the custom style of a component. +The **@Extend** decorator adds new attribute functions to preset components, such as ****, ****, and ****. You can use the **@Extend** decorator to quickly define and reuse the custom styles of a component. ``` -@Extend(Text) function fancy(color: number) { - .fontColor(color) - .fontSize(24) +@Extend(Text) function fancy(fontSize: number) { + .fontColor(Color.Red) + .fontSize(fontSize) .fontStyle(FontStyle.Italic) } @@ -15,14 +15,14 @@ struct FancyUse { build() { Row({ space: 10 }) { Text("Fancy") - .fancy(Color.Blue) + .fancy(16) Text("Fancy") - .fancy(Color.Red) + .fancy(24) } } } ``` ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->The **@Extend** decorator cannot be used in the struct definition box of a custom component. +>![](../public_sys-resources/icon-note.gif) **NOTE:** +>The **@Extend** decorator cannot be used in the struct definition of a custom component. diff --git a/en/application-dev/reference/arkui-ts/ts-component-based-preview.md b/en/application-dev/ui/ts-component-based-preview.md similarity index 87% rename from en/application-dev/reference/arkui-ts/ts-component-based-preview.md rename to en/application-dev/ui/ts-component-based-preview.md index c11bf9e779d56ee1026c2beef33e1c356d34782f..c58898c2e41841f5b93b50ed7c0ab79b98e73324 100644 --- a/en/application-dev/reference/arkui-ts/ts-component-based-preview.md +++ b/en/application-dev/ui/ts-component-based-preview.md @@ -2,12 +2,12 @@ Custom components decorated by **@Preview** can be previewed in the Previewer of DevEco Studio. When the page is loaded, the custom components decorated by **@Preview** are created and displayed. ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->A source file can contain at most one custom component decorated by **@Preview**. +>![](../public_sys-resources/icon-note.gif) **NOTE:** +>In a source file, at most one custom component can be decorated by **@Preview**. ## Example -Sample code for using **@Preview**: +Example of using **@Preview**: ``` // Display only Hello Component1 on the PC preview. The content under MyComponent is displayed on the real device. diff --git a/en/application-dev/reference/arkui-ts/ts-component-based.md b/en/application-dev/ui/ts-component-based.md similarity index 84% rename from en/application-dev/reference/arkui-ts/ts-component-based.md rename to en/application-dev/ui/ts-component-based.md index e2fe7e8346df8e5da5198e878494e37bebc47abd..2ebfc47886dd60ed5586c20d718e6904a4a46cee 100644 --- a/en/application-dev/reference/arkui-ts/ts-component-based.md +++ b/en/application-dev/ui/ts-component-based.md @@ -1,4 +1,4 @@ -# Component-based +# Componentization - **[@Component](ts-component-based-component.md)** diff --git a/en/application-dev/reference/arkui-ts/ts-component-creation-re-initialization.md b/en/application-dev/ui/ts-component-creation-re-initialization.md similarity index 82% rename from en/application-dev/reference/arkui-ts/ts-component-creation-re-initialization.md rename to en/application-dev/ui/ts-component-creation-re-initialization.md index 085f420b05aa18351c023e1bb83ee9edef2b4ee7..ad98aedda691eeed622fe2cf5c7e70afc3a099a5 100644 --- a/en/application-dev/reference/arkui-ts/ts-component-creation-re-initialization.md +++ b/en/application-dev/ui/ts-component-creation-re-initialization.md @@ -54,9 +54,9 @@ struct TimerComponent { 3. Execute the **build** function of **ParentComp**. 4. Create a preset **** component. 1. Create a preset **** component, set the text content to be displayed, and add the **** component instance to the **** component. - 2. The component on the **true** branch is created based on the **if** condition. + 2. Create the component on the **true** branch based on the **if** condition. 1. Create a preset **** component and set the image source address. - 2. Creates a **TimerComponent** using the given constructor. + 2. Create a **TimerComponent** using the given constructor. 1. Create a **TimerComponent** object. 2. Initialize the values of member variables locally. 3. Use the parameters provided by the **TimerComponent** constructor to update the values of member variables. @@ -74,17 +74,17 @@ When a user clicks a button: 2. The **build** function of **ParentComp** is executed. 3. The preset **** component is reused by the framework and reinitialized. 4. The child components of **** reuse and reinitialize the objects in the memory. - 1. The preset **** component is reused, but the new text content will be used for re-initialization. - 2. The component on the **false** branch is created based on the **if** condition. - 1. The components on the original **true** branch are not used and will be destroyed. + 1. Reuse the preset **** component after re-initializing the component using new text content. + 2. Reuse the component on the **false** branch based on the **if** condition. + 1. Destroy the components on the original **true** branch as these components are no longer used. 1. Destroy the created preset **** component instance. - 2. The **TimerComponent** component instance is destroyed, and the **aboutToDisappear** function is called. + 2. Destroy the **TimerComponent** component instance, and call the **aboutToDisappear** function. 2. Create components on the **false** branch. 1. Create a preset **** component and set the image source address. 2. Create a **TimerComponent** again using the given constructor. 3. Initialize the newly created **TimerComponent** and call the **aboutToAppear** and **build** functions. - 3. The preset **** component will be reused, with the new image source address. + 3. Reuse the preset **** component, with the new image source address. diff --git a/en/application-dev/reference/arkui-ts/ts-component-states-link.md b/en/application-dev/ui/ts-component-states-link.md similarity index 57% rename from en/application-dev/reference/arkui-ts/ts-component-states-link.md rename to en/application-dev/ui/ts-component-states-link.md index 1a35937fadbbc8632f0abb0eada9b3e7642f5533..16ffb392a2baeab7b77fc6f0aa7b01577724ff52 100644 --- a/en/application-dev/reference/arkui-ts/ts-component-states-link.md +++ b/en/application-dev/ui/ts-component-states-link.md @@ -1,15 +1,15 @@ # @Link -Bidirectional data binding can be established between the **@Link** annotated variable and the **@State** annotated variable of the parent component. +Two-way binding can be established between the **@Link** decorated variable and the **@State** decorated variable of the parent component. The **@Link** data has the following features: -- **Support for multiple types**: The value of the **@Link** annotated variable is the same as that of the **@State** annotated variable, that is, class, number, string, boolean, or arrays of these types. +- **Support for multiple types**: The value of the **@Link** decorated variable can be of the same type as the **@State** decorated variable; that is, the value can be of the following types: **class**, **number**, **string**, **boolean**, or arrays of these types. - **Private**: Data is accessed only within the component. -- **Single data source**: The variable of the parent component for initializing the **@Link** annotated variable must be the **@State** annotated variable. -- **Bidirectional communication**: When a child component changes the **@Link** annotated variable, the **@State** annotated variable of its parent component is also changed. -- **Requiring the variable reference to the @Link annotated variable**: When creating a new instance of the component, you must use the naming parameter to initialize all **@Link** annotated variables. The **@Link** annotated variable can be initialized by using the reference of the **@State** or **@Link** annotated variable. The **@State** annotated variable can be referenced using the '**$**' operator. +- **Single data source**: The variable of the parent component for initializing the **@Link** decorated variable must be the **@State** decorated variable. +- **Two-way binding**: When a child component changes the **@Link** decorated variable, the **@State** decorated variable of its parent component is also changed. +- **Support for initialization with the variable reference passed to the @Link decorated variable**: When creating a new instance of the component, you must use the naming parameter to initialize all **@Link** decorated variables. The **@Link** decorated variable can be initialized by using the reference of the **@State** or **@Link** decorated variable. Wherein, the **@State** decorated variable can be referenced using the '**$**' operator. ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->The **@Link** annotated variable cannot be initialized within the component. +>![](../public_sys-resources/icon-note.gif) **NOTE:** +>The **@Link** decorated variable cannot be initialized within the component. ## Simple Type Example @@ -41,7 +41,7 @@ struct PlayButton { } ``` -The **@Link** semantics are derived from the '**$**' operator. In other words, **$isPlaying** is a bidirectional data binding of the internal state of **this.isPlaying**. When you click **PlayButton**, the **** and **** components of **PlayButton** are refreshed at the same time. +The **@Link** semantics are derived from the '**$**' operator. In other words, **$isPlaying** is the two-way binding of the internal state **this.isPlaying**. When you click **PlayButton**, the **** and **** components of **PlayButton** are refreshed at the same time. ## Complex Type Example @@ -80,7 +80,7 @@ struct Child { } ``` -In the example above, click **Button 1** and **Button 2** to change the list of text items displayed in the parent component. +In the example above, click **Button1** and **Button2** to change the list of text items displayed in the parent component. ## Example of Using @Link, @State, and @Prop Together @@ -118,8 +118,8 @@ struct ChildB { } ``` -In the preceding example, **ParentView** contains two child components: **ChildA** and **ChildB**. The state variable counter of **ParentView** initializes **ChildA** and **ChildB**. +In the preceding example, **ParentView** contains two child components: **ChildA** and **ChildB**. They are initialized by the state variable **counter** of **ParentView**. -- **ChildB** uses **@Link** to establish bidirectional binding. When the value of the **counterRef** state variable is changed in **ChildB**, the change is synchronized to **ParentView** and **ChildA**. -- **ChildA** uses **@Prop** to establish a unidirectional state binding from **ParentView** to itself. When **ChildA** changes the state, it is re-rendered, but the change is not communicated to **ParentView** or **ChildB**. +- **ChildB** uses **@Link** to establish two-way state binding. When the value of the **counterRef** state variable is changed in **ChildB**, the change is synchronized to **ParentView** and **ChildA**. +- **ChildA** uses **@Prop** to establish one-way state binding from **ParentView** to itself. When **ChildA** changes the state, it is re-rendered, but the change is not updated to **ParentView** or **ChildB**. diff --git a/en/application-dev/reference/arkui-ts/ts-component-states-prop.md b/en/application-dev/ui/ts-component-states-prop.md similarity index 62% rename from en/application-dev/reference/arkui-ts/ts-component-states-prop.md rename to en/application-dev/ui/ts-component-states-prop.md index 84244e6076494bf15ba2ee13ddacb7a4cf636a33..06e195c25108ec681807542b30511c40a19b1f66 100644 --- a/en/application-dev/reference/arkui-ts/ts-component-states-prop.md +++ b/en/application-dev/ui/ts-component-states-prop.md @@ -1,13 +1,13 @@ # @Prop -**@Prop** and **@State** have the same semantics but different initialization modes. Variables decorated by **@Prop** must be initialized using the **@State** annotated variable provided by their parent components. The **@Prop** annotated variable can be modified in the component, but the modification is not notified to the parent component. That is, **@Prop** is unidirectional data binding. +**@Prop** and **@State** have the same semantics but different initialization modes. Variables decorated by **@Prop** must be initialized using the **@State** decorated variable provided by their parent components. The **@Prop** decorated variable can be modified in the component, but the modification is not updated to the parent component; that is, **@Prop** uses unidirectional data binding. -The **@Prop** data has the following features: +The **@Prop** state data has the following features: -- **Support for simple types**: Only the following simple types are supported: number, string, and boolean. +- **Support for simple types**: Only the following simple types are supported: **number**, **string**, and **boolean**. - **Private**: Data is accessed only within the component. - **Support for multiple instances**: A component can have multiple attributes decorated by **@Prop**. -- **Requiring a value for the @Prop annotated variable for initialization**: When a new instance of the component is created, all **@Prop** annotated variables must be initialized. Initialization inside the component is not supported. +- **Support for initialization with a value passed to the @Prop decorated variable**: When a new instance of the component is created, all **@Prop** decorated variables must be initialized. Initialization inside the component is not supported. ## Example @@ -32,7 +32,7 @@ struct ParentComponent { // when creatng ChildComponent, the initial value of its @Prop variable must be supplied // in a named constructor parameter - // also regular costOfOneAttempt (non-Prop) variable is initialized + // also regular costOfOneAttempt (non-Prop) variable is initialied CountDownComponent({ count: this.countDownStartValue, costOfOneAttempt: 2}) } } @@ -61,8 +61,8 @@ struct CountDownComponent { } ``` -In the preceding example, when you press **+1** or **-1**, the status of the parent component changes and the **build** method is executed again. In this case, a new **CountDownComponent** is created. The **countDownStartValue** property of the parent component is used to initialize the **@Prop** annotated variable of the child component. When you click the **Try again** button of the child component, the value of the **@Prop** annotated **count**variable is changed. As a result, the **CountDownComponent** is rendered again. However, changes to the **count** value do not affect the **countDownStartValue** value of the parent component. +In the preceding example, when you press **+1** or **-1**, the status of the parent component changes and the **build** method is executed again. In this case, a new **CountDownComponent** is created. The **countDownStartValue** property of the parent component is used to initialize the **@Prop** decorated variable of the child component. When you touch the **Try again** button of the child component, the value of the **count** variable decorated by **@Prop** is changed. As a result, the **CountDownComponent** is rendered again. However, the change of the **count** value does not affect the **countDownStartValue** value of the parent component. ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->When a new component instance is created, all its **@Prop** annotated variables must be initialized. +>![](../public_sys-resources/icon-note.gif) **NOTE:** +>When a new component instance is created, all its **@Prop** decorated variables must be initialized. diff --git a/en/application-dev/reference/arkui-ts/ts-component-states-state.md b/en/application-dev/ui/ts-component-states-state.md similarity index 52% rename from en/application-dev/reference/arkui-ts/ts-component-states-state.md rename to en/application-dev/ui/ts-component-states-state.md index 76dedc2f35ad0102953d568b5e329d0cb7cd588a..fa1704e770f7c06b1cb112ed040f97a0313ea1f7 100644 --- a/en/application-dev/reference/arkui-ts/ts-component-states-state.md +++ b/en/application-dev/ui/ts-component-states-state.md @@ -1,16 +1,16 @@ # @State -The **@State** annotated variable is the internal state data of the component. When the state data is modified, the** build** method of the component is called to refresh the UI. +The **@State** decorated variable is the internal state data of the component. When the state data is modified, the** build** method of the component is called to refresh the UI. The **@State** data has the following features: -- **Support for multiple types**: The following strong types by value and by reference are supported: **class**, **number**, **boolean**, **string**, and arrays of these types, that is,** Array**, **Array**, **Array**, and **Array**. **object** and **any** are not allowed. -- **Support for multi-instance**: The internal state data of different instances of a component is independent. -- **Internal private**: Attributes marked with **@State** cannot be directly modified outside the component. Its lifecycle depends on the component where it is located. -- **Local initialization required**: Initial values must be allocated to all **@State** annotated variables. Otherwise, they may become undefined in the framework. -- **Can be used to set initial values for custom components**: When creating a component instance, you can explicitly specify the initial value of the **@State** annotated attribute based on the variable name. +- **Support for multiple types**: The following types are supported: strong types by value and by reference, including **class**, **number**, **boolean**, **string**, as well as arrays of these types, that is, **Array**, **Array**, **Array**, and **Array**. **object** and **any** are not allowed. +- **Support for multiple instances**: Multiple instances can coexist in a component. The internal state data of different instances is independent. +- **Internal private**: An attribute marked with **@State** cannot be directly modified outside the component. Its lifecycle depends on the component where it is located. +- **Local initialization required**: Initial values must be allocated to all **@State** decorated variables through the initialization process. Otherwise, they may become undefined in the framework. +- **Support for setting of initial attribute values based on the state variable name**: When creating a component instance, you can explicitly specify the initial value of the **@State** decorated attribute based on the variable name. -## Simple Example of @State Annotated Attribute +## Simple Example of @State Decorated Attribute ``` @Entry @@ -33,7 +33,7 @@ struct MyComponent { } ``` -## Complex Example of @State Annotated Variable +## Complex Example of @State Decorated Variable ``` // Customize the status data class. @@ -64,15 +64,15 @@ struct MyComponent { build() { Column() { - Text(`${this.title.value}`) + Text(`${this.title.value}`).fontSize(30) Button() { - Text(`Click to change title`).fontSize(10) + Text(`Click to change title`).fontSize(20).fontColor(Color.White) }.onClick(() => { - this.title.value = this.toggle ? 'Hello World' : 'Hello UI' + this.title.value = (this.toggle == this.title.value) ? 'Hello World' : 'Hello UI' }) // Modify the internal state of MyComponent using the anonymous method. Button() { - Text(`Click to increase count=${this.count}`).fontSize(10) + Text(`Click to increase count=${this.count}`).fontSize(20).fontColor(Color.White) }.onClick(() => { this.count += this.increaseBy }) // Modify the internal state of MyComponent using the anonymous method. @@ -83,9 +83,9 @@ struct MyComponent { In the preceding example: -- The custom component **MyComponent** defines the **@State** annotated variables **count** and **title**. If the value of **count** or **title** changes, the **build** method of **MyComponent** is called to render the component again. +- Two **@State** decorated variables, **count** and **title**, have been defined for **MyComponent**. If the value of **count** or **title** changes, the **build** method of **MyComponent** needs to be called to render the component again. - The **EntryComponent** has multiple **MyComponent** instances. The internal status change of the first **MyComponent** does not affect the second **MyComponent**. -- When creating a **MyComponent** instance, use the variable name to initialize the variables in the component. For example: +- When creating a **MyComponent** instance, initialize the variables in the component based on the variable name. For example: ``` MyComponent({title: {value: 'Hello, World 2'}, count: 7}) diff --git a/en/application-dev/reference/arkui-ts/ts-configuration-with-mandatory-parameters.md b/en/application-dev/ui/ts-configuration-with-mandatory-parameters.md similarity index 100% rename from en/application-dev/reference/arkui-ts/ts-configuration-with-mandatory-parameters.md rename to en/application-dev/ui/ts-configuration-with-mandatory-parameters.md diff --git a/en/application-dev/reference/arkui-ts/ts-custom-component-initialization.md b/en/application-dev/ui/ts-custom-component-initialization.md similarity index 85% rename from en/application-dev/reference/arkui-ts/ts-custom-component-initialization.md rename to en/application-dev/ui/ts-custom-component-initialization.md index da5931159c97ec5a5eeb28c798266f389059c225..48cc0ce5c0e4c6bd312daa25ae4647609d02589b 100644 --- a/en/application-dev/reference/arkui-ts/ts-custom-component-initialization.md +++ b/en/application-dev/ui/ts-custom-component-initialization.md @@ -1,48 +1,48 @@ # Custom Component Initialization -This topic describes the rules for initializing component state variables. +This section describes the rules for initializing component state variables. The member variables of a component can be initialized in either of the following ways: - Local initialization. For example: ``` - @State counter: Counterr = new Counter() + @State counter: Counter = new Counter() ``` -- Using constructor parameters for initialization. For example: +- Initialization using constructor parameters. For example: ``` MyComponent(counter: $myCounter) ``` -The allowed method depends on the decorator of the state variable. +The allowed method depends on the decorator of the state variable, as shown in the following table. - - - - @@ -94,17 +94,17 @@ The allowed method depends on the decorator of the state variable.

    Decorator Type

    Local Initialization

    Using Constructor Parameters for Initialization

    +

    Initialization Using Constructor Parameters

    @State

    +

    @State

    Mandatory

    Optional

    @Prop

    +

    @Prop

    Forbidden

    Mandatory

    @Link

    +

    @Link

    Forbidden

    -In the preceding table: +As indicated by the preceding table: -- The **@State** annotated variable needs to be initialized locally. The initial value can be overwritten by the constructor parameter. -- The **@Prop** and **@Link** annotated variables must be initialized only by constructor parameters. +- The **@State** decorated variable needs to be initialized locally. The initial value can be overwritten by the constructor parameter. +- The **@Prop** and **@Link** decorated variables must be initialized only by constructor parameters. Comply with the following rules when using constructors to initialize member variables: - - - - - @@ -72,9 +72,9 @@ struct CountDownTimerComponent { } ``` -The example above shows that lifecycle functions are critical to allowing **CountDownTimerComponent** to manage its timer resources. Similar functions include loading resources asynchronously from the network. +The example above shows that lifecycle functions are critical for **CountDownTimerComponent** to manage its timer resources. Similar functions include loading resources asynchronously from the network. ->![](../../public_sys-resources/icon-note.gif) **NOTE:** +>![](../public_sys-resources/icon-note.gif) **NOTE:** >- Promise and asynchronous callback functions can be used in lifecycle functions, for example, network resource getters and timer setters. >- Do not use **async await** in lifecycle functions. diff --git a/en/application-dev/ui/ts-declarative-syntax.md b/en/application-dev/ui/ts-declarative-syntax.md new file mode 100644 index 0000000000000000000000000000000000000000..806cf1f72eabbe021f18487f711384494c801503 --- /dev/null +++ b/en/application-dev/ui/ts-declarative-syntax.md @@ -0,0 +1,15 @@ +# Declarative Syntax + +- **[Overview](ts-syntax-intro.md)** + +- **[General UI Description Specifications](ts-general-ui-description-specifications.md)** + +- **[About UI State Management](ts-ui-state-management.md)** + +- **[About Rendering Control Syntax](ts-rending-control-syntax.md)** + +- **[About @Component](ts-a-deep-dive-into-component.md)** + +- **[About Syntactic Sugar](ts-syntactic-sugar.md)** + + diff --git a/en/application-dev/reference/arkui-ts/ts-declarative-ui-description-specifications.md b/en/application-dev/ui/ts-declarative-ui-description-specifications.md similarity index 100% rename from en/application-dev/reference/arkui-ts/ts-declarative-ui-description-specifications.md rename to en/application-dev/ui/ts-declarative-ui-description-specifications.md diff --git a/en/application-dev/reference/arkui-ts/ts-event-configuration.md b/en/application-dev/ui/ts-event-configuration.md similarity index 61% rename from en/application-dev/reference/arkui-ts/ts-event-configuration.md rename to en/application-dev/ui/ts-event-configuration.md index efbc6888685b5663388980735b9eb62c3213e708..fbaaca289df7e1b8d49101eb10e4ac172c1b5d4a 100644 --- a/en/application-dev/reference/arkui-ts/ts-event-configuration.md +++ b/en/application-dev/ui/ts-event-configuration.md @@ -2,7 +2,7 @@ You can use event methods to configure events supported by components. -- Sample code for using a lambda expression to configure the event method of a component: +- Example of using a lambda expression to configure the event of a component: ``` // Counter is a private data variable defined in the component. @@ -13,9 +13,9 @@ You can use event methods to configure events supported by components. ``` -- Sample code for using an anonymous function expression to configure the event method of a component: +- Example of using an anonymous function expression to configure the event of a component: - In this case, **bind** must be used to ensure that **this** in the function body references the contained component. + In this case, **bind** must be used to ensure that the contained components are referenced by **this** in the function body. ``` // Counter is a private data variable defined in the component. @@ -26,7 +26,7 @@ You can use event methods to configure events supported by components. ``` -- Sample code for using a component's member function to configure the event method of the component: +- Example of using a component's member function to configure the event of the component: ``` myClickHandler(): void { diff --git a/en/application-dev/reference/arkui-ts/ts-framework-directory.md b/en/application-dev/ui/ts-framework-directory.md similarity index 80% rename from en/application-dev/reference/arkui-ts/ts-framework-directory.md rename to en/application-dev/ui/ts-framework-directory.md index ec0776b5d59b08416347343300f7061083cdc14b..75bf3b9fea9cf4341d98b9c423bbc8cea9427955 100644 --- a/en/application-dev/reference/arkui-ts/ts-framework-directory.md +++ b/en/application-dev/ui/ts-framework-directory.md @@ -1,8 +1,8 @@ # Directory Structure -The following figure shows the typical directory structure of the **ets** module \(**entry/src/main**\) for an application with feature abilities \(FAs\). +The following figure shows the typical directory structure of the **eTS** module \(**entry/src/main**\) for an application with feature abilities \(FAs\). -![](figures/en-us_image_0000001182200571.png) +![](figures/en-us_image_0000001251421931.png) Functions of the files are as follows: @@ -14,6 +14,6 @@ Functions of the folders and files are as follows: - The **pages** directory stores all component pages. - The **common** directory stores common code files, such as custom components and public methods. ->![](../../public_sys-resources/icon-note.gif) **NOTE:** +>![](../public_sys-resources/icon-note.gif) **NOTE:** >- TypeScript and JavaScript files can be imported as page files. diff --git a/en/application-dev/reference/arkui-ts/ts-framework-file-access-rules.md b/en/application-dev/ui/ts-framework-file-access-rules.md similarity index 100% rename from en/application-dev/reference/arkui-ts/ts-framework-file-access-rules.md rename to en/application-dev/ui/ts-framework-file-access-rules.md diff --git a/en/application-dev/reference/arkui-ts/ts-framework-file.md b/en/application-dev/ui/ts-framework-file.md similarity index 100% rename from en/application-dev/reference/arkui-ts/ts-framework-file.md rename to en/application-dev/ui/ts-framework-file.md diff --git a/en/application-dev/reference/arkui-ts/ts-framework-js-tag.md b/en/application-dev/ui/ts-framework-js-tag.md similarity index 97% rename from en/application-dev/reference/arkui-ts/ts-framework-js-tag.md rename to en/application-dev/ui/ts-framework-js-tag.md index 83588feb070b1a1045ba427033dac223b178a9cd..5f7e115ad2d69803312591f23b2f28f7aee593c5 100644 --- a/en/application-dev/reference/arkui-ts/ts-framework-js-tag.md +++ b/en/application-dev/ui/ts-framework-js-tag.md @@ -23,7 +23,7 @@ Configure the **"js"** tag in the [config.json](https://developer.harmonyos.c -

    From the Variable in Parent Component (Below) to the Variable in Child Component (Right)

    + - @@ -116,7 +116,7 @@ Comply with the following rules when using constructors to initialize member var - @@ -183,13 +183,13 @@ Comply with the following rules when using constructors to initialize member var

    From the Variable in the Parent Component (Below) to the Variable in the Child Component (Right)

    @state

    +

    @State

    @Link

    @State

    Allowed

    +

    Not allowed

    Allowed

    -In the preceding table: +As indicated by the preceding table: -- The normal variable of the parent component can be used to initialize the **@State** annotated variable of the child component, but cannot be used to initialize the **@Link** or **@Prop** annotated variable. -- The **@State** annotated variable of the parent component can initialize the **@Prop**, **@Link** \(using **$**\), or normal variables of the child component, but cannot initialize the **@State** annotated variable of the child component. -- The **@Link** annotated variable of the parent component can initialize the **@Link** annotated or common variables of the child component. However, it is a syntax error to initialize the **@State** annotated member of the child component. In addition, initializing the **@Prop** annotated variable is not recommended. -- The **@Prop** annotated variable of the parent component can initialize the normal variables or **@Prop** annotated variables of its child components, but cannot initialize the **@State** or **@Link** annotated variables. -- **@StorageLink** and **@StorageProp** cannot be passed from the parent component to its child components. +- The normal variable of the parent component can be used to initialize the **@State** decorated variable of the child component, but not the **@Link** or **@Prop** decorated variable. +- The **@State** decorated variable of the parent component can be used to initialize the **@Prop**, **@Link** \(using **$**\), or normal variables of the child component, but cannot initialize the **@State** decorated variable of the child component. +- The **@Link** decorated variable of the parent component can initialize the **@Link** decorated or normal variables of the child component. However, initializing the **@State** decorated member of the child component can result in a syntax error. In addition, initializing the **@Prop** decorated variable is not recommended. +- The **@Prop** decorated variable of the parent component can be used to initialize the normal variables or **@Prop** decorated variables of the child component, but not the **@State** or **@Link** decorated variables. +- Passing **@StorageLink** and **@StorageProp** from the parent component to the child component is prohibited. - In addition to the preceding rules, the TypeScript strong type rules need to be followed. ## Example @@ -218,7 +218,7 @@ struct CompA { Row() { CompB({bLink: $aLink, // valid init a @Link with reference of another @Link, bProp: this.aState}) // valid init a @Prop with value of a @State - CompB({aLink: $aState, // invalid: type mismatch expected ref to ClassA, provided reference to boolean + CompB({aLink: $aState, // invalid: type missmatch expected ref to ClassA, provided reference to boolean bProp: false}) // valid init a @Prop by constants value } } diff --git a/en/application-dev/reference/arkui-ts/ts-custom-component-lifecycle-callbacks.md b/en/application-dev/ui/ts-custom-component-lifecycle-callbacks.md similarity index 73% rename from en/application-dev/reference/arkui-ts/ts-custom-component-lifecycle-callbacks.md rename to en/application-dev/ui/ts-custom-component-lifecycle-callbacks.md index 870c18baa7f0d62de9b1a0b6a81a6c020f0897b8..3fbf56db7d03632f4aff64f276234d24ebba8f3f 100644 --- a/en/application-dev/reference/arkui-ts/ts-custom-component-lifecycle-callbacks.md +++ b/en/application-dev/ui/ts-custom-component-lifecycle-callbacks.md @@ -1,6 +1,6 @@ # Custom Component Lifecycle Callbacks -The lifecycle callbacks of a custom component are used to notify users of the lifecycle of the component. These callbacks are private and are invoked by the development framework at a specified time during running. They cannot be manually invoked from applications. +The lifecycle callbacks of a custom component are used to notify users of the lifecycle of the component. These callbacks are private and are invoked by the development framework at a specified time at runtime. They cannot be manually invoked from applications. ## Lifecycle Callback Definition @@ -13,30 +13,30 @@ The lifecycle callbacks of a custom component are used to notify users of the li

    aboutToAppear

    Executed after a new instance of the custom component is created and before its build function is executed.

    -

    You can change state variables in the aboutToAppear function, which will take effect when you execute the build function later.

    +

    Invoked after a new instance of the custom component is created and before its build function is executed.

    +

    You can change state variables in the aboutToAppear function. The change will take effect when you execute the build function next time.

    aboutToDisappear

    Executed before the destructor of the custom component is consumed.

    -

    Do not change state variables in the aboutToDisappear function. Especially, the modification of the @Link annotated variable may cause unstable application behavior.

    +

    Invoked before the destructor of the custom component is consumed.

    +

    Do not change state variables in the aboutToDisappear function as doing this can cause unexpected errors. For example, the modification of the @Link decorated variable may cause unstable application running.

    onPageShow

    Invoked when the page is displayed. The scenarios include the routing process and scenarios where the application is switched to the foreground or background. Only the custom components decorated by @Entry take effect.

    +

    Invoked when a page is displayed. This callback is used in the routing process or scenarios where the application is switched to the foreground or background. Only the custom components decorated by @Entry take effect.

    onPageHide

    Invoked when the page is hidden. The scenarios include the routing process and scenarios where the application is switched to the foreground or background. Only the custom components decorated by @Entry take effect.

    +

    Invoked when a page is hidden. This callback is used in the routing process or scenarios where the application is switched to the foreground or background. Only the custom components decorated by @Entry take effect.

    onBackPress

    Invoked when a user clicks the back button. Only the custom components decorated by @Entry take effect.

    -
    • The value true is returned if the page processes the return logic and does not route the page.
    • false is returned if the default return logic is used.
    • If no value is returned, the default return logic is used.
    +
    • The value true is returned if the page processes the return logic instead of performing page routing.
    • The value false is returned if the default return logic is used.
    • If no value is returned, the default return logic is used.

    Yes

    Name of the ETS instance.

    +

    Name of the eTS instance.

    pages

    @@ -75,7 +75,7 @@ The **"pages"** defines the route information of each page's entry component. } ``` ->![](../../public_sys-resources/icon-note.gif) **NOTE:** +>![](../public_sys-resources/icon-note.gif) **NOTE:** >- The first page in the **"pages"** list is the home page of the application. >- The page name must not be a component name, for example, **Text.ets** or **Button.ets**. >- Each page file must contain the [page entry component](ts-component-based-entry.md) \(with the @Entry decoration\). @@ -145,8 +145,8 @@ The **"mode"** configures the running type and syntax style of a JS component.
    ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->- If **type** is set to **form**, **syntax** cannot be **ets**. +>![](../public_sys-resources/icon-note.gif) **NOTE:** +>If **type** is set to **form**, **syntax** cannot be **ets**. ## Example diff --git a/en/application-dev/reference/arkui-ts/ts-framework-framework.md b/en/application-dev/ui/ts-framework.md similarity index 100% rename from en/application-dev/reference/arkui-ts/ts-framework-framework.md rename to en/application-dev/ui/ts-framework.md diff --git a/en/application-dev/reference/arkui-ts/ts-function-build.md b/en/application-dev/ui/ts-function-build.md similarity index 69% rename from en/application-dev/reference/arkui-ts/ts-function-build.md rename to en/application-dev/ui/ts-function-build.md index 0a8584a918e21a053e2d9e911c36a872a1e7a029..5415112733ba0a915822ddc2f94073cca2ada01e 100644 --- a/en/application-dev/reference/arkui-ts/ts-function-build.md +++ b/en/application-dev/ui/ts-function-build.md @@ -1,6 +1,6 @@ # build Function -The **build** function meets the definition of the **Builder** API and is used to define the declarative UI description of the components. +The **build** function meets the definition of the **Builder** API and is used to define the declarative UI description of components. ``` interface Builder { diff --git a/en/application-dev/reference/arkui-ts/ts-general-ui-concepts.md b/en/application-dev/ui/ts-general-ui-concepts.md similarity index 50% rename from en/application-dev/reference/arkui-ts/ts-general-ui-concepts.md rename to en/application-dev/ui/ts-general-ui-concepts.md index bfd0e9c574f556fea4562472a57a0ae4b43cf3b4..fd834881baf8524e1f8c7834031c98dcc4f19a38 100644 --- a/en/application-dev/reference/arkui-ts/ts-general-ui-concepts.md +++ b/en/application-dev/ui/ts-general-ui-concepts.md @@ -1,6 +1,6 @@ # Basic Concepts -The TypeScript-based declarative development paradigm provides a wide array of basic components, which can be combined and extended in a declarative manner to describe the UI of an application. It also provides basic data binding and event processing mechanisms to help you implement application interaction logic. +The TypeScript-based declarative development paradigm provides a wide array of basic components, which can be combined and extended in a declarative manner to describe the UI of an application. It also provides basic data binding and event processing mechanisms to help you implement the application interaction logic. ## HelloWorld Example @@ -32,12 +32,12 @@ struct Hello { ## Basic Concepts -The preceding sample code shows the structure of a simple page and illustrates the following basic concepts: +The preceding sample code shows the structure of a simple page. It involves the following basic concepts: -- **Decorator**: applies to classes, structures, methods, and variables, and assigns special meanings to them. In the sample code, **@Entry**, **@Component**, and **@State** are decorators. -- **Custom component**: reusable UI unit, which can be combined with other components. In the sample code, **struct Hello** annotated by **@Component** is a custom component. +- **Decorator**: a special kind of declaration that can be applied to classes, structures, methods, and variables, and assigns special meanings to them. In the sample code, **@Entry**, **@Component**, and **@State** are decorators. +- **Custom component**: a reusable UI unit, which can be combined with other components. In the sample code, **struct Hello** decorated by **@Component** is a custom component. - **UI description**: declaratively describes the UI structure. In the sample code, the block of code in the **build\(\)** method provides the UI description. -- **Built-in component**: default basic or layout component preset in the framework. You can directly invoke these components, such as ****, ****, ****, and **** components in the sample code. -- **Attribute method**: used to configure component attributes, such as **fontSize\(\)**, **width\(\)**, **height\(\)**, and **color\(\)**. -- **Event method**: used to add the component response logic to an event. The logic is set through an event method, such as **onClick\(\)** for a button. +- **Built-in component**: the default basic or layout component preset in the framework. You can directly invoke these components, such as ****, ****, ****, and **** components in the sample code. +- **Attribute method**: a method used to configure component attributes, such as **fontSize\(\)**, **width\(\)**, **height\(\)**, and **color\(\)**. +- **Event method**: a method used to add the component response logic to an event. The logic is set through an event method, such as **onClick\(\)** for a button. diff --git a/en/application-dev/reference/arkui-ts/ts-general-ui-description-specifications.md b/en/application-dev/ui/ts-general-ui-description-specifications.md similarity index 82% rename from en/application-dev/reference/arkui-ts/ts-general-ui-description-specifications.md rename to en/application-dev/ui/ts-general-ui-description-specifications.md index d1678c1138a082a443b1d07426eba6a6becaf39d..209c5856b1e8cddf865efe8a72d59b7272ed6af3 100644 --- a/en/application-dev/reference/arkui-ts/ts-general-ui-description-specifications.md +++ b/en/application-dev/ui/ts-general-ui-description-specifications.md @@ -4,6 +4,6 @@ - **[Declarative UI Description Specifications](ts-declarative-ui-description-specifications.md)** -- **[Component-based](ts-component-based.md)** +- **[Componentization](ts-component-based.md)** diff --git a/en/application-dev/reference/arkui-ts/ts-instantiating-a-struct-without-new-keyword.md b/en/application-dev/ui/ts-instantiating-a-struct-without-new-keyword.md similarity index 77% rename from en/application-dev/reference/arkui-ts/ts-instantiating-a-struct-without-new-keyword.md rename to en/application-dev/ui/ts-instantiating-a-struct-without-new-keyword.md index effb1b6d89cb4793d3da35fc23511c5a101d6c0a..d4510ca475164a5806c958570e86f28a64351bed 100644 --- a/en/application-dev/reference/arkui-ts/ts-instantiating-a-struct-without-new-keyword.md +++ b/en/application-dev/ui/ts-instantiating-a-struct-without-new-keyword.md @@ -1,6 +1,6 @@ # Instantiating a struct Without the new Keyword -For the instantiation of **struct**, the **new** keyword can be omitted. +You can omit the **new** keyword when instantiating a **struct**. ``` // Definition diff --git a/en/application-dev/reference/arkui-ts/ts-managing-application-states-apis.md b/en/application-dev/ui/ts-managing-application-states-apis.md similarity index 100% rename from en/application-dev/reference/arkui-ts/ts-managing-application-states-apis.md rename to en/application-dev/ui/ts-managing-application-states-apis.md diff --git a/en/application-dev/reference/arkui-ts/ts-managing-application-states.md b/en/application-dev/ui/ts-managing-application-states.md similarity index 100% rename from en/application-dev/reference/arkui-ts/ts-managing-application-states.md rename to en/application-dev/ui/ts-managing-application-states.md diff --git a/en/application-dev/reference/arkui-ts/ts-managing-component-states.md b/en/application-dev/ui/ts-managing-component-states.md similarity index 100% rename from en/application-dev/reference/arkui-ts/ts-managing-component-states.md rename to en/application-dev/ui/ts-managing-component-states.md diff --git a/en/application-dev/reference/arkui-ts/ts-managing-other-states.md b/en/application-dev/ui/ts-managing-other-states.md similarity index 100% rename from en/application-dev/reference/arkui-ts/ts-managing-other-states.md rename to en/application-dev/ui/ts-managing-other-states.md diff --git a/en/application-dev/reference/arkui-ts/ts-media-resource-type.md b/en/application-dev/ui/ts-media-resource-type.md similarity index 100% rename from en/application-dev/reference/arkui-ts/ts-media-resource-type.md rename to en/application-dev/ui/ts-media-resource-type.md diff --git a/en/application-dev/reference/arkui-ts/ts-other-states-consume-provide.md b/en/application-dev/ui/ts-other-states-consume-provide.md similarity index 80% rename from en/application-dev/reference/arkui-ts/ts-other-states-consume-provide.md rename to en/application-dev/ui/ts-other-states-consume-provide.md index 24775d653786804a00d55e3c5206aec317557984..51a3624a69b9349b10a0294ccc0cb056cc2834c4 100644 --- a/en/application-dev/reference/arkui-ts/ts-other-states-consume-provide.md +++ b/en/application-dev/ui/ts-other-states-consume-provide.md @@ -1,6 +1,6 @@ # @Consume and @Provide -As the data provider, **Provide** can update the data of its child nodes and trigger page rendering. After **Consume** detects that the **Provide** data is updated, the current view is re-rendered. +As the data provider, **Provide** can update the data of child nodes and trigger page rendering. After **Consume** detects that the **Provide** data is updated, it will initiate re-rendering of the current view. **Table 1** @Provide @@ -13,12 +13,12 @@ As the data provider, **Provide** can update the data of its child nodes and t

    Decorator parameters

    Alias: a constant of the string type. If an alias is specified, implement the data update with this alias. If there is no alias, use the variable name as the alias. @Provide("alias") is recommended.

    +

    Alias: a constant of the string type. If an alias is specified, implement the data update for this alias. If there is no alias, use the variable name as the alias. @Provide("alias") is recommended.

    Synchronization mechanism

    The @Provide annotated variable is similar to the @state variable. You can modify the variable to re-render the page. You can also modify the @Consume annotated variable to modify the @State annotated variable reversely.

    +

    The @Provide decorated variable is similar to the @state variable. You can modify the variable to re-render the page. You can also modify the @Consume decorated variable to modify the @State decorated variable reversely.

    Initial value

    @@ -29,7 +29,7 @@ As the data provider, **Provide** can update the data of its child nodes and t

    Page re-rendering scenarios

    1. Primitive types: boolean, string, and number

    -

    2. @observed annotated class: Modify the attributes of the class.

    +

    2. @observed: used to modify the attributes of the @observed decorated class.

    3. Array: Add, delete, or update elements in an array.

    ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->When using **@Provide** and **@Consume**, take measures to avoid infinite loops caused by circular reference. +>![](../public_sys-resources/icon-note.gif) **NOTE:** +>To avoid infinite loops caused by circular reference, exercise caution when using **@Provide** and **@Consume**. The description of other attributes is the same as that of **@Provide**. diff --git a/en/application-dev/reference/arkui-ts/ts-other-states-observed-objectlink.md b/en/application-dev/ui/ts-other-states-observed-objectlink.md similarity index 96% rename from en/application-dev/reference/arkui-ts/ts-other-states-observed-objectlink.md rename to en/application-dev/ui/ts-other-states-observed-objectlink.md index 3e54d663ef2e40533b311120b825d4294720d5f3..b62e6a13e4a7b5dac72ae829bb400cfdca13b9ca 100644 --- a/en/application-dev/reference/arkui-ts/ts-other-states-observed-objectlink.md +++ b/en/application-dev/ui/ts-other-states-observed-objectlink.md @@ -66,6 +66,6 @@ struct ViewB { } ``` ->![](../../public_sys-resources/icon-note.gif) **NOTE:** +>![](../public_sys-resources/icon-note.gif) **NOTE:** >**@ObjectLink** is used to decorate variables and cannot be initialized. **@Observed** is used to decorate a class. diff --git a/en/application-dev/reference/arkui-ts/ts-other-states-watch.md b/en/application-dev/ui/ts-other-states-watch.md similarity index 70% rename from en/application-dev/reference/arkui-ts/ts-other-states-watch.md rename to en/application-dev/ui/ts-other-states-watch.md index 34b090256874b5d02f77296c3a0d816705c0e43f..5e5c10722f6079f2b4e4d313eadadd1bf3485845 100644 --- a/en/application-dev/reference/arkui-ts/ts-other-states-watch.md +++ b/en/application-dev/ui/ts-other-states-watch.md @@ -1,6 +1,6 @@ # @Watch -The application can register a callback. This callback is triggered when a variable decorated by any of the following decorators changes: **@State**, **@Prop**, **@Link**, **@ObjectLink**, **@Provide**, **@Consume**, **@StorageProp**, and **@StorageLink**. The variables in **@Watch** must be enclosed in **""**. +The application can register a callback through **@Watch**. This callback is triggered when a variable decorated by any of the following decorators changes: **@State**, **@Prop**, **@Link**, **@ObjectLink**, **@Provide**, **@Consume**, **@StorageProp**, and **@StorageLink**. The variables in **@Watch** must be enclosed in **""**. ``` @Entry diff --git a/en/application-dev/reference/arkui-ts/ts-parameterless-configuration.md b/en/application-dev/ui/ts-parameterless-configuration.md similarity index 100% rename from en/application-dev/reference/arkui-ts/ts-parameterless-configuration.md rename to en/application-dev/ui/ts-parameterless-configuration.md diff --git a/en/application-dev/reference/arkui-ts/ts-pixel-units.md b/en/application-dev/ui/ts-pixel-units.md similarity index 99% rename from en/application-dev/reference/arkui-ts/ts-pixel-units.md rename to en/application-dev/ui/ts-pixel-units.md index bf2e33a832aa658c8c632d58265f198cb5fcc6cb..30c64a9b078610a68bea9e2f9ff8d20360fabd74 100644 --- a/en/application-dev/reference/arkui-ts/ts-pixel-units.md +++ b/en/application-dev/ui/ts-pixel-units.md @@ -121,5 +121,5 @@ struct Example { } ``` -![](figures/pixel-units.gif) +![](figures/pixel-unit.gif) diff --git a/en/application-dev/reference/arkui-ts/ts-rending-control-syntax-foreach.md b/en/application-dev/ui/ts-rending-control-syntax-foreach.md similarity index 63% rename from en/application-dev/reference/arkui-ts/ts-rending-control-syntax-foreach.md rename to en/application-dev/ui/ts-rending-control-syntax-foreach.md index 4515c322b56d516e1ac51e5fef4e000d7e8553a7..58714c0b13c4291c47b2ba80136161406650a5e3 100644 --- a/en/application-dev/reference/arkui-ts/ts-rending-control-syntax-foreach.md +++ b/en/application-dev/ui/ts-rending-control-syntax-foreach.md @@ -1,27 +1,27 @@ # ForEach -The development framework provides the **ForEach** component to iterate arrays and create components for each array item. **ForEach** is defined as follows: +The development framework provides **ForEach** to iterate arrays and create components for each array item. **ForEach** is defined as follows: ``` ForEach( arr: any[], // Array to be iterated - itemGenerator: (item: any) => void, // child component generator - keyGenerator?: (item: any) => string // (optional) Unique key generator, which is recommended. + itemGenerator: (item: any, index?: number) => void, // child component generator + keyGenerator?: (item: any, index?: number) => string // (optional) Unique key generator, which is recommended. ) ``` ->![](../../public_sys-resources/icon-note.gif) **NOTE:** +>![](../public_sys-resources/icon-note.gif) **NOTE:** >- Loop rendering uses **ForEach** to automatically generate child components from the provided array. >- **ForEach** must be used in container components. ->- The first parameter must be an array. An empty array is allowed. In the empty array scenario, no child component is created. You can set functions whose return values are of the array type, for example, **arr.slice \(1, 3\)**. The set functions cannot change any state variables including the array itself, such as **Array.splice**, **Array.sort**, and **Array.reverse**. +>- The first parameter must be an array. An empty array is allowed. If an array is empty, no child component is created. You can set the functions whose return values are of the array type, for example, **arr.slice \(1, 3\)**. The set functions cannot change any state variables including the array itself, such as **Array.splice**, **Array.sort**, and **Array.reverse**. >- The second parameter is used to generate the lambda function of the child components. It generates one or more child components for a given array item. A single component and its child component list must be contained in the braces \(\{...\}\). ->- The optional third parameter is an anonymous function for key value generation. It generates a unique and stable key value for a given array item. When the position of a subitem in the array is changed, the key value of the subitem cannot be changed. When a subitem in the array is replaced with a new item, the key value of the current item must be different from the key value of the new item. The key-value generator is optional. However, for performance reasons, it is strongly recommended that this be provided, which enables the development framework to better identify array changes. If you click to reverse the array and no key-value generator is provided, all nodes in **ForEach** will be rebuilt. ->- The generated child components must be allowed in the parent container component of **ForEach**. The child component generator function can contain **if/else** conditional rendering. In addition, **ForEach** can be contained in the **if/else** conditional rendering statement. ->- The calling sequence of the subitem generator function may be different from that of the data items in the array. During the development, do not assume whether the subitem generator and key value generator functions are executed and the execution sequence. The following example may not work properly: +>- The third parameter is optional and used as an anonymous function for key value generation. It generates a unique and stable key value for a given array item. When the position of a subitem in the array is changed, the key value of the subitem cannot be changed. When a subitem in the array is replaced with a new item, the key value of the current item must be different from the key value of the new item. The key-value generator is optional. However, for performance reasons, it is strongly recommended that the generator be provided, so that the development framework can better identify array changes. If the array is reversed while no key-value generator is provided, all nodes in **ForEach** will be rebuilt. +>- The generated child components must be allowed in the parent container component of **ForEach**. The child component generator function can contain the **if/else** conditional statement. In addition, **ForEach** can be contained in the **if/else** conditional statement. +>- The calling sequence of subitem generator functions may be different from that of the data items in the array. During the development, do not assume whether the subitem generator and key value generator functions are executed and the execution sequence. The following is an example of incorrect usage: > ``` > ForEach(anArray, item => {Text(`${++counter}. item.label`)}) > ``` -> Below is sample code that works: +> Below is an example of correct usage: > ``` > ForEach(anArray.map((item1, index1) => { return { i: index1 + 1, data: item1 }; }), > item => Text(`${item.i}. item.data.label`), diff --git a/en/application-dev/reference/arkui-ts/ts-rending-control-syntax-if-else.md b/en/application-dev/ui/ts-rending-control-syntax-if-else.md similarity index 72% rename from en/application-dev/reference/arkui-ts/ts-rending-control-syntax-if-else.md rename to en/application-dev/ui/ts-rending-control-syntax-if-else.md index 0e3569adb1702b106ec4408a50c469d75803a7e4..22af60153a56496b6f5cfd3dc9b7fd72ef0208d2 100644 --- a/en/application-dev/reference/arkui-ts/ts-rending-control-syntax-if-else.md +++ b/en/application-dev/ui/ts-rending-control-syntax-if-else.md @@ -2,15 +2,15 @@ Use **if/else** for conditional rendering. ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->- The **if** conditional statement can use state variables. ->- You can use **if** to make the rendering of a child component depend on the conditional statement. +>![](../public_sys-resources/icon-note.gif) **NOTE:** +>- State variables can be used in the **if** conditional statement. +>- You can use the **if** conditional statement to implement rendering of child components. >- The **if** conditional statement must be used in container components. >- Some container components limit the type or number of child components. When **if** is placed in these components, the limitation applies to components created in **if** and **else** statements. For example, when **if** is used in the **** component, only the **** component can be used in the **if** conditional statement, and only the **** component can be used in the **** component. ## Example -Sample code for using the **if** conditional statement: +Example of using the **if** conditional statement: ``` Column() { @@ -20,7 +20,7 @@ Column() { } ``` -Sample code for using the **if**, **else if**, and **else** conditional statements: +Example of using the **if**, **else if**, and **else** conditional statements: ``` Column() { diff --git a/en/application-dev/reference/arkui-ts/ts-rending-control-syntax-lazyforeach.md b/en/application-dev/ui/ts-rending-control-syntax-lazyforeach.md similarity index 82% rename from en/application-dev/reference/arkui-ts/ts-rending-control-syntax-lazyforeach.md rename to en/application-dev/ui/ts-rending-control-syntax-lazyforeach.md index b20c42383cf23a94761968e3a4c719f07f8acc93..095ff605e8f14fe9fba9d0d09d585d9c55afa127 100644 --- a/en/application-dev/reference/arkui-ts/ts-rending-control-syntax-lazyforeach.md +++ b/en/application-dev/ui/ts-rending-control-syntax-lazyforeach.md @@ -23,22 +23,22 @@ LazyForEach( ): void ``` ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->- When data is updated through **onDataChanged** of **LazyForEach**, if **itemGenerator** contains a fully static view \(the view does not contain state variables\), the view will not be updated. +>![](../public_sys-resources/icon-note.gif) **NOTE:** +>- When data is updated through **onDataChanged** of **LazyForEach**, if **itemGenerator** contains a fully static view \(that is, the view does not contain state variables\), the view will not be updated. >- **LazyForEach** is used to automatically generate child components from the provided data source. ->- **LazyForEach** must be used in the container component. Only the ****, ****, and **** components support on-demand data loading \(that is, only the visible part and a small amount of data before and after the visible part are loaded for buffering\). For other components, all data is loaded at a time. +>- **LazyForEach** must be used in the container component. Only the ****, ****, and **** components support on-demand data loading \(that is, only the visible part and a small amount of data before and after the visible part are loaded for caching\). For other components, all data is loaded at a time. >- The first parameter must be an object inherited from **IDataSource**. You need to implement related APIs. >- The second parameter is used to generate the lambda function of the child components. It generates one or more child components for a given array item. A single component and its child component list must be contained in the braces \(\{...\}\). ->- The optional third parameter is an anonymous function for key value generation. It generates a unique and stable key value for a given array item. When the position of a subitem in the array is changed, the key value of the subitem cannot be changed. When a subitem in the array is replaced with a new item, the key value of the current item must be different from the key value of the new item. The key-value generator is optional. However, for performance reasons, it is strongly recommended that this be provided, which enables the development framework to better identify array changes. If you click to reverse the array and no key-value generator is provided, all nodes in **ForEach** will be rebuilt. ->- The generated child component must be allowed in the parent container component of **LazyForEach**, enabling **LazyForEach** to be included in the **if/else** conditional rendering statement. +>- The third parameter is optional and used as an anonymous function for key value generation. It generates a unique and stable key value for a given array item. When the position of a subitem in the array is changed, the key value of the subitem cannot be changed. When a subitem in the array is replaced with a new item, the key value of the current item must be different from the key value of the new item. The key-value generator is optional. However, for performance reasons, it is strongly recommended that the generator be provided, so that the development framework can better identify array changes. If the array is reversed while no key-value generator is provided, all nodes in **ForEach** will be rebuilt. +>- The generated child component must be allowed in the parent container component of **LazyForEach**, so that **LazyForEach** can be included in the **if/else** conditional statement. >- **LazyForEach** must create one and only one child component in each iteration. >- **ForEach** cannot be used as a child component of **LazyForEach**, and **LazyForEach** does not support nesting. ->- The **if/else** conditional rendering statement is not allowed in **LazyForEach**. ->- The calling sequence of the subitem generator function may be different from that of the data items in the data source. During the development, do not assume whether the subitem generator and key value generator functions are executed and the execution sequence. The following example may not work properly: +>- The **if/else** conditional statement is not allowed in **LazyForEach**. +>- The calling sequence of the subitem generator function may be different from that of the data items in the data source. During the development, do not assume whether the subitem generator and key value generator functions are executed and the execution sequence. The following is an example of incorrect usage: > ``` > ForEach(dataSource, item => {Text(`${++counter}. item.label`)}) > ``` -> Below is sample code that works: +> Below is an example of correct usage: > ``` > ForEach(dataSource, > item => Text(`${item.i}. item.data.label`)), diff --git a/en/application-dev/reference/arkui-ts/ts-rending-control-syntax.md b/en/application-dev/ui/ts-rending-control-syntax.md similarity index 71% rename from en/application-dev/reference/arkui-ts/ts-rending-control-syntax.md rename to en/application-dev/ui/ts-rending-control-syntax.md index ce196b3167666ad0fd712accaef2253948add52c..e8626c1a4acc4e4881c7648e973fb9555164f4af 100644 --- a/en/application-dev/reference/arkui-ts/ts-rending-control-syntax.md +++ b/en/application-dev/ui/ts-rending-control-syntax.md @@ -1,4 +1,4 @@ -# Rendering Control Syntax +# About Rendering Control Syntax - **[if/else](ts-rending-control-syntax-if-else.md)** diff --git a/en/application-dev/reference/arkui-ts/ts-resource-access.md b/en/application-dev/ui/ts-resource-access.md similarity index 60% rename from en/application-dev/reference/arkui-ts/ts-resource-access.md rename to en/application-dev/ui/ts-resource-access.md index b68fa14a170b126ab9f86117cab39a489c1a3a0c..3294e7f68de3f762505efa0d18117ae6a35e9e1b 100644 --- a/en/application-dev/reference/arkui-ts/ts-resource-access.md +++ b/en/application-dev/ui/ts-resource-access.md @@ -1,5 +1,7 @@ # Resource Access +- **[Accessing Application Resources](ts-application-resource-access.md)** + - **[Media Resource Types](ts-media-resource-type.md)** diff --git a/en/application-dev/reference/arkui-ts/ts-restrictions-for-generators.md b/en/application-dev/ui/ts-restrictions-for-generators.md similarity index 62% rename from en/application-dev/reference/arkui-ts/ts-restrictions-for-generators.md rename to en/application-dev/ui/ts-restrictions-for-generators.md index eb4392ba884da2d18dba7781dfdfd31f005f8336..03e708ccc7e83178c1c39b1f55b49c279b36eb2f 100644 --- a/en/application-dev/reference/arkui-ts/ts-restrictions-for-generators.md +++ b/en/application-dev/ui/ts-restrictions-for-generators.md @@ -1,10 +1,10 @@ -# Restrictions on Using the TS Language for Generators +# Restrictions on Using TypeScript for Generators -The TypeScript programming language has the following restrictions on generators: +TypeScript has the following restrictions on generators: - Expressions can be used only in character strings \($\{expression\}\), **if** conditions, **ForEach** parameters, and component parameters. -- None of these expressions can cause any application state variables \(**@State**, **@Link**, and **@Prop**\) to change. Otherwise, undefined and potentially unstable framework behavior may occur. -- You can use **console.log** in the first line of the generator function body so that you can more easily track component re-rendering. Expressions in the log character strings also comply with the preceding restrictions. +- No expressions should cause any application state variables \(**@State**, **@Link**, and **@Prop**\) to change. Otherwise, undefined and potentially unstable framework behavior may occur. +- You can use **console.log** in the first line of the generator function body so that you can track component re-rendering more easily. Expressions in the log character strings also comply with the preceding restrictions. - The generator function cannot contain local variables. None of the above restrictions apply to anonymous function implementations of event-handling functions \(such as **onClick**\) and to the rest of the UI component description. @@ -17,7 +17,7 @@ build() { console.log(`a: ${a}`) // invalid: console.log only allowed in first line of build Column() { Text('Hello ${this.myName.toUpperCase()}') // ok. - ForEach(this.arr.reverse(), ..., ...) // invalid: Array.reverse modifies the @State array variable in place + ForEach(this.arr.reverse(), ..., ...) // invalid: Array.reverse modifies the @State array varible in place } buildSpecial() // invalid: no function calls Text(this.calcTextValue()) // this function call is ok. diff --git a/en/application-dev/reference/arkui-ts/ts-syntactic-sugar-chaining.md b/en/application-dev/ui/ts-syntactic-sugar-chaining.md similarity index 58% rename from en/application-dev/reference/arkui-ts/ts-syntactic-sugar-chaining.md rename to en/application-dev/ui/ts-syntactic-sugar-chaining.md index 5fd89481545297fabe4afbf9a84be38ae6e35f2a..6cccebeeead49fad7eba642fd668b7b902c7f2e4 100644 --- a/en/application-dev/reference/arkui-ts/ts-syntactic-sugar-chaining.md +++ b/en/application-dev/ui/ts-syntactic-sugar-chaining.md @@ -1,6 +1,6 @@ -# Chaining +# Chain Call -You can configure the UI structure and its attributes and events using method chaining: calling the methods by separating them with a \(dot.\) +You can configure the UI structure and its attributes and events and separate them with a dot\(.\) to implement chain call. ``` Column() { diff --git a/en/application-dev/reference/arkui-ts/ts-syntactic-sugar-decorator.md b/en/application-dev/ui/ts-syntactic-sugar-decorator.md similarity index 94% rename from en/application-dev/reference/arkui-ts/ts-syntactic-sugar-decorator.md rename to en/application-dev/ui/ts-syntactic-sugar-decorator.md index db69bce438092196e3375eff84ddd94bcef88f47..d2bc0707dcab41db9ba908d8c69905e0d15e85b8 100644 --- a/en/application-dev/reference/arkui-ts/ts-syntactic-sugar-decorator.md +++ b/en/application-dev/ui/ts-syntactic-sugar-decorator.md @@ -4,7 +4,7 @@ Multiple decorator implementations can be superimposed on the target element and written on the same line or multiple lines. It is recommended that the implementation be written on multiple lines. -In the example below, the elements decorated by **@Component** take on the form of a component, and the variables decorated by **@State** have the meaning of the state data. +In the example below, the elements decorated by **@Component** take on the form of a component, and the variables decorated by **@State** have the meaning of state data. ``` @Component @@ -72,7 +72,7 @@ struct MyComponent {

    Primitive types, classes, and arrays

    This decorator is used for bidirectional data binding between parent and child components. The internal state data of the parent component is used as the data source. Any changes made to one component will be reflected to the other.

    +

    This decorator is used for two-way binding between the parent component and the child component. The internal state data of the parent component is used as the data source. Any changes made to one component will be reflected to the other.

    0x000000

    +

    Blue

    0x0000ff

    +

    Brown

    0xa52a2a

    +

    Gray

    0x808080

    +

    Green

    0x008000

    +

    Orange

    0xffa500

    +

    Pink

    0xffc0cb

    +

    Red

    0xff0000

    +

    White

    0xffffff

    +

    Yellow

    0xffff00

    +

    + diff --git a/en/application-dev/ui/ui-js-building-ui-interactions.md b/en/application-dev/ui/ui-js-building-ui-interactions.md index 410818fa36db2e91c508459983bbb0ad92c7d8bf..87cd80eb5a7fbba63ddf2675bbcf4b99f6ce11e4 100644 --- a/en/application-dev/ui/ui-js-building-ui-interactions.md +++ b/en/application-dev/ui/ui-js-building-ui-interactions.md @@ -71,5 +71,5 @@ export default { } ``` -The ArkUI also provides many form components, such as switches, tags, and pickers, for you to flexibly lay out pages and improve their interactions with users. For details, see [Container Components](../reference/arkui-js/js-components-container-badge.md). + ArkUI also provides many form components, such as switches, tags, and pickers, for you to flexibly lay out pages and improve their interactions with users. For details, see [Container Components](../reference/arkui-js/js-components-container.md). diff --git a/en/application-dev/ui/ui-js-building-ui-layout-image.md b/en/application-dev/ui/ui-js-building-ui-layout-image.md index eab97b67a10ff937a1de06971b07a055cfd3b184..8c9026d467b0dc746ff6fd51c7b62cf5a0caccee 100644 --- a/en/application-dev/ui/ui-js-building-ui-layout-image.md +++ b/en/application-dev/ui/ui-js-building-ui-layout-image.md @@ -1,8 +1,8 @@ # Adding an Image -Generally, the [](../reference/arkui-js/js-components-basic-image.md) component is used to add images on a page. The method of using this component is similar to that of using the **** component. +Generally, the [****](../reference/arkui-js/js-components-basic-image.md) component is used to add images on a page. The method of using this component is similar to that of using the **** component. -To reference images via the **** component, you must create the **common** directory under **js** \> **default**, and then store the image files in the **common** directory. For details about the directory structure, see [Directory Structure](../reference/arkui-js/js-framework-file.md#section119431650182015). The following sample code shows you how to add an image and set its style. +To reference images via the **** component, you must create the **common** directory under **js** \> **default**, and then store the image files in the **common** directory. For details about the directory structure, see [Directory Structure](js-framework-file.md). The following sample code shows you how to add an image and set its style. ``` diff --git a/en/application-dev/ui/ui-js-building-ui-layout-intro.md b/en/application-dev/ui/ui-js-building-ui-layout-intro.md index 468bb242e2aaa7a7dc57526edf1e5c082aa3b5c6..7ee7f04d95087af0266e0d896ed0c2e9698b0c30 100644 --- a/en/application-dev/ui/ui-js-building-ui-layout-intro.md +++ b/en/application-dev/ui/ui-js-building-ui-layout-intro.md @@ -1,14 +1,12 @@ # Layout Description -The baseline width for page design is 720 logical px. The display width of a page element depends on the ratio of the screen width to the baseline width. +The baseline width for page design is 720 logical pixels. The display width of a page element depends on the ratio of the screen width to the baseline width. For example, when the width of a component is 100 px, its display width is converted as follows: -- On a screen with the width of 720 physical px, the display width is 100 physical px. +On a screen with the width of 720 physical pixels, the display width is 100 physical pixels. On a screen with the width of 1440 physical pixels, the display width is 200 physical pixels. -- On a screen with the width of 1440 physical px, the display width is 200 physical px. - -Basic elements on the page include title, text, and image areas. Each basic element may contain multiple sub-elements. You can add components, such as buttons, switches, and progress bars, to these elements and sub-elements as required. When setting the layout, you need to consider the following for each basic element: +Basic page elements include title, text, and image areas. Each basic element may contain multiple sub-elements. You can add components, such as buttons, switches, and progress bars, to these elements and sub-elements as required. When setting the layout, you need to consider the following for each basic element: - Size and arrangement - Overlapping with other elements @@ -24,5 +22,5 @@ You can disassemble elements on the page first and then implement them in sequen **Figure 2** Layout of the comment area -![](figures/Figure3.png) +![](figures/figures3.png) diff --git a/en/application-dev/ui/ui-js-component-tabs.md b/en/application-dev/ui/ui-js-component-tabs.md index e8e364c975df5d198811cd9b4a381026250cfb32..d29186ddca5ea240ad27dd237e0cc7c605324894 100644 --- a/en/application-dev/ui/ui-js-component-tabs.md +++ b/en/application-dev/ui/ui-js-component-tabs.md @@ -42,7 +42,7 @@ Create a **** component in the **.hml** file under **pages/index**. } ``` -![](figures/3-13.gif) +![](figures/3-9.gif) ## Setting the Tabs Orientation @@ -146,7 +146,7 @@ Set the background color, border, and tab-content layout of the **** co } ``` -![](figures/31-14.gif) +![](figures/31.gif) ## Displaying the Tab Index @@ -187,6 +187,7 @@ export default { ![](figures/32.gif) >![](../public_sys-resources/icon-note.gif) **NOTE:** +> >- A **** can wrap at most one [****](../reference/arkui-js/js-components-container-tab-bar.md) and at most one [****](../reference/arkui-js/js-components-container-tab-content.md). ## Example Scenario diff --git a/en/application-dev/ui/ui-js-components-button.md b/en/application-dev/ui/ui-js-components-button.md index 4ec1d0d841be8318cfab3f924c239c2054174965..7910632641df5d614ea8409a818507b72ece5eca 100644 --- a/en/application-dev/ui/ui-js-components-button.md +++ b/en/application-dev/ui/ui-js-components-button.md @@ -23,7 +23,7 @@ Create a **** component in the **.hml** file under **pages/index** } ``` -![](figures/3-5.png) +![](figures/3-2.png) ## Setting the Button Type @@ -61,7 +61,7 @@ Set the **type** attribute of the **** component to **button**, ** } ``` -![](figures/05-6.png) +![](figures/05-3.png) >![](../public_sys-resources/icon-note.gif) **NOTE:** >- For capsule buttons, border-related styles are not supported. @@ -157,6 +157,7 @@ export default { ![](figures/34.gif) >![](../public_sys-resources/icon-note.gif) **NOTE:** +> >- The **setProgress** method supports only buttons of the download type. ## Example Scenario diff --git a/en/application-dev/ui/ui-js-components-dialog.md b/en/application-dev/ui/ui-js-components-dialog.md index 429fa0bf422791cbc60e38f671cf2e1fe649e444..eecd6e02fa0141e82aedbee04009a15181aae0d8 100644 --- a/en/application-dev/ui/ui-js-components-dialog.md +++ b/en/application-dev/ui/ui-js-components-dialog.md @@ -59,7 +59,7 @@ export default { } ``` -![](figures/5-9.gif) +![](figures/5-5.gif) ## Setting Dialog Box Response diff --git a/en/application-dev/ui/ui-js-components-form.md b/en/application-dev/ui/ui-js-components-form.md index 2fe7fbf2b74d6e20abfa40fb70148dcf529553da..19c05e7189c0c438173966e138b541694da3fff3 100644 --- a/en/application-dev/ui/ui-js-components-form.md +++ b/en/application-dev/ui/ui-js-components-form.md @@ -105,7 +105,7 @@ export default{ } ``` -![](figures/8-10.gif) +![](figures/8-6.gif) ## Example Scenario diff --git a/en/application-dev/ui/ui-js-components-images.md b/en/application-dev/ui/ui-js-components-images.md index 4c6aebcee11b1eb3c012b2c5c085128552e6e7d1..a74db3749a3673fd691a013822ff71096792c1e6 100644 --- a/en/application-dev/ui/ui-js-components-images.md +++ b/en/application-dev/ui/ui-js-components-images.md @@ -23,7 +23,7 @@ Create an **** component in the **.hml** file under **pages/index** } ``` -![](figures/10-15.png) +![](figures/10-10.png) ## Setting the Image Style @@ -55,11 +55,11 @@ image{ } ``` -![](figures/7-16.png) +![](figures/7-11.png) ## Display Multiple Images -Define a **for** loop to display multiple images cyclically. Set **option** to specify the image scale style. For details about the scale styles, see the description of [object-fit](../reference/arkui-js/js-components-basic-image.md#table175851535113711). +Define a **for** loop to display multiple images cyclically. Set **option** to specify the image scale style. For details about the scale styles, see the description of object-fit. ``` @@ -129,7 +129,7 @@ export default { } ``` -![](figures/34-17.gif) +![](figures/34-12.gif) ## Loading Images diff --git a/en/application-dev/ui/ui-js-components-input.md b/en/application-dev/ui/ui-js-components-input.md index 8e32743e5b2d2c4b9955f4556d5753d0dc198371..f98b669ebe7560b969e287548b9567451ef25985 100644 --- a/en/application-dev/ui/ui-js-components-input.md +++ b/en/application-dev/ui/ui-js-components-input.md @@ -25,7 +25,7 @@ Create an **** component in the **.hml** file under **pages/index** } ``` -![](figures/2-4.png) +![](figures/2.png) ## Setting the Input Type @@ -222,6 +222,7 @@ import prompt from '@system.prompt' ![](figures/19.gif) >![](../public_sys-resources/icon-note.gif) **NOTE:** +> >- This method is available when the input type is set to **text**, **email**, **date**, **time**, **number**, or **password**. ## Example Scenario diff --git a/en/application-dev/ui/ui-js-components-list.md b/en/application-dev/ui/ui-js-components-list.md index b44533731e1ead6269a22e90d6272cac33f99134..6e45758d530697b6793bfbfe18c9fe5dde6a2120 100644 --- a/en/application-dev/ui/ui-js-components-list.md +++ b/en/application-dev/ui/ui-js-components-list.md @@ -183,9 +183,10 @@ export default { } ``` -![](figures/8-7.gif) +![](figures/8-4.gif) >![](../public_sys-resources/icon-note.gif) **NOTE:** +> >- The **groupcollapse** and **groupexpand** events can be used only by the **list-item-group** component. ## Example Scenario diff --git a/en/application-dev/ui/ui-js-components-picker.md b/en/application-dev/ui/ui-js-components-picker.md index e20f83233225504bf70bf58d5616767dcd713298..6d4f4131e62832db16054273b3d7052ada0ad5be 100644 --- a/en/application-dev/ui/ui-js-components-picker.md +++ b/en/application-dev/ui/ui-js-components-picker.md @@ -48,7 +48,7 @@ Set the **type** attribute of the **** component. For example, set background-color: #F1F3F5; } .pickertext{ - margin-bottom: 30px; + margin-bottom: 30px; } ``` @@ -63,7 +63,7 @@ export default { } ``` -![](figures/2-8.gif) +![](figures/20211217-130837(welinkpc).gif) >![](../public_sys-resources/icon-note.gif) **NOTE:** >- When setting the value range of a common selector, you must use the data binding mode. @@ -181,7 +181,7 @@ Implement a health check-in application by using the **** component.
    - +
    ``` @@ -263,11 +263,9 @@ export default { this.build = e.newValue }, dateonchange(e) { + e.month=e.month+1; this.datevalue = e.year + "-" + e.month + "-" + e.day; - pmt.showToast({ message:"date:"+e.year+"-"+e.month+"-"+e.day }) }, - datetimeonchange(e) { - this.datetimevalue=e.year+"-"+e.month+"-"+e.day+" "+e.hour+":"+e.minute; - pmt.showToast({ message:"Time:"+e.month+"-"+e.day+" "+e.hour+":"+e.minute }) + pmt.showToast({ message:"date:"+e.year+"-"+e.month+"-"+e.day }) }, showtoast() { pmt.showToast({ @@ -279,5 +277,5 @@ export default { } ``` -![](figures/31.gif) +![](figures/qqqq.gif) diff --git a/en/application-dev/ui/ui-js-components-stepper.md b/en/application-dev/ui/ui-js-components-stepper.md index ac7f0b51b15f6805f0118d879797d52ae12c9d08..cab1e9ae62f36ef4570d294f9a64f0cd1f231f62 100644 --- a/en/application-dev/ui/ui-js-components-stepper.md +++ b/en/application-dev/ui/ui-js-components-stepper.md @@ -38,7 +38,7 @@ text{ } ``` -![](figures/2-11.gif) +![](figures/2-7.gif) ## Setting the Index @@ -76,7 +76,7 @@ text{ ![](figures/10.gif) -Set the **label** attribute to customize the button text for the **** . +Set the **label** attribute to customize the button text for the ****. ``` @@ -133,7 +133,7 @@ export default { } ``` -![](figures/11-12.gif) +![](figures/11-8.gif) ## Setting the Style diff --git a/en/application-dev/ui/ui-js-components-text.md b/en/application-dev/ui/ui-js-components-text.md index c2b8d17fc69fdc67e0046004663040de2243d7ec..99942a3c164a191a8dff423bce1965e22bd49c93 100644 --- a/en/application-dev/ui/ui-js-components-text.md +++ b/en/application-dev/ui/ui-js-components-text.md @@ -46,7 +46,7 @@ Set the **color**, **font-size**, and **allow-scale** attributes. - Adding a text modifier -Set the **text-decoration** attribute to add an underline, overline, line-through, or a combination of lines to selected text. For values of **text-decoration**, see [Text Styles](../reference/arkui-js/js-components-basic-text.md#section5775351116). +Set the **text-decoration** attribute to add an underline, overline, line-through, or a combination of lines to selected text. For values of **text-decoration**, see [Text Style](../reference/arkui-js/js-components-basic-text.md). ``` @@ -72,7 +72,7 @@ text{ } ``` -![](figures/3-1.png) +![](figures/3.png) - Hiding text content @@ -110,7 +110,7 @@ Set the **text-overflow** attribute to **ellipsis** so that overflowed text - Setting the text line breaking mode -Set the **word-break** attribute to specify how to break lines of text. For values of **word-break**, see [Text Styles](../reference/arkui-js/js-components-basic-text.md#section5775351116). +Set the **word-break** attribute to specify how to break lines of text. For values of **word-break**, see [Text Styles](../reference/arkui-js/js-components-basic-text.md). ``` @@ -181,11 +181,11 @@ Set the **word-break** attribute to specify how to break lines of text. For va ``` -![](figures/01-2.png) +![](figures/01-1.png) >![](../public_sys-resources/icon-note.gif) **NOTE:** ->- When the **** child component is used to form a text paragraph, incorrect settings of the **** attributes \(for example, **font-weight** set to **1000**\) will result in abnormal display of the text paragraph. ->- When the **** child component is being used, do not include any text you want to show in the **** component, as such text will not be displayed. +>- When the **** child component is used to form a text paragraph, incorrect **** attribute settings \(for example, setting of **font-weight** to **1000**\) will result in abnormal display of the text paragraph. +>- When the **** child component is being used, do not include any text you want to show in the **** component, as such text will not be displayed if you do so. ## Example Scenario @@ -240,5 +240,5 @@ export default { } ``` -![](figures/1-3.gif) +![](figures/1.gif) diff --git a/en/application-dev/ui/ui-js-overview.md b/en/application-dev/ui/ui-js-overview.md index e4d7eee788b9aea5ac6d591961f99b833f0e4ccc..7d9da6ca4f2bb6ff1edde7c22e8f4616febaa06e 100644 --- a/en/application-dev/ui/ui-js-overview.md +++ b/en/application-dev/ui/ui-js-overview.md @@ -1,20 +1,18 @@ # Overview -The ArkUI provides basic, container, and canvas UI components and standard CSS animation capabilities. It supports the web-development-like programming paradigm. + ArkUI with the JavaScript-based web-like development paradigm provides UI components \(basic, container, canvas, and more\) and standard CSS animation capabilities. ## Basic Capabilities - **Web-like development paradigm** - The ArkUI supports languages that are similar to those for web development, such as HTML and CSS. You can use them to describe the page layout and style, and use JavaScript \(conforming to the ECMAScript specification\) for page behavior. The ArkUI allows you to avoid code for UI state switching. The view configuration information is intuitive. + ArkUI supports languages that are similar to those for web development, such as HTML and CSS. You can use them to describe the page layout and style, and use JavaScript \(conforming to the ECMAScript specification\) for page behavior. With ArkUI, you can configure the UI in an intuitive manner, eliminating the need to code for UI state switching. ## Overall Structure - ArkUI provides two development paradigms: JavaScript-based web-like development paradigm and TypeScript-based declarative development paradigm. - -The ArkUI that uses the JavaScript-based web-like development paradigm consists of the following layers:, application layer, frontend framework layer, engine layer, and porting layer. + ArkUI with the JavaScript-based web-like development paradigm consists of the following layers: application layer, frontend framework layer, engine layer, and porting layer. ![](figures/zh-cn_image_0000001077953992.png) diff --git a/en/application-dev/ui/ui-ts-building-category-grid-layout.md b/en/application-dev/ui/ui-ts-building-category-grid-layout.md index 4d77a9088a7e6ab632ed3043d07ef5b77dfc9634..534482f62ed38279b90570e1e32bcba6b1849173 100644 --- a/en/application-dev/ui/ui-ts-building-category-grid-layout.md +++ b/en/application-dev/ui/ui-ts-building-category-grid-layout.md @@ -2,7 +2,7 @@ The diet application allows food on the home page to display in list or grid mode. You can implement switching between food categories through tabs in grid mode. -1. Add the **Category** enumeration type to the **FoodCategoryList** page. +1. Import the **Category** enumeration type to the **FoodCategoryList** page. ``` import { Category, FoodData } from '../model/FoodData' @@ -86,7 +86,7 @@ The diet application allows food on the home page to display in list or grid mod } ``` -5. Add the **@State** decorator. After you click the switch tab in the upper right corner, the page does not change. This is because the **showList** does not have state data and its change does not trigger the page refresh. You need to add the **@State** decorator to make it state data. The change of the **@State** decorator will cause the component where the decorator is located to be re-rendered. +5. Add the **@State** decorator. After you click the switch tab in the upper right corner, the page does not change. This is because the **showList** does not have state data and its change does not trigger the page refresh. You need to add the **@State** decorator to make it state data. The change of the **@State** decorator will cause re-rendering of the component where the decorator is located. ``` @Entry @@ -247,7 +247,7 @@ The diet application allows food on the home page to display in list or grid mod ![](figures/video_2021-10-21_105602.gif) -10. Create the **Category.Vegetable**, **Category.Fruit**, **Category.Nut**, **Category.SeaFood**, and **Category.Desert** tabs. +10. Create the **Category.Vegetable**, **Category.Fruit**, **Category.Nut**, **Category.SeaFood**, and **Category.Dessert** tabs. ``` @Component diff --git a/en/application-dev/ui/ui-ts-building-category-list-layout.md b/en/application-dev/ui/ui-ts-building-category-list-layout.md index f1ed59a97a5407e43827f472e6e215fae862ef7a..7aff7b7bbffbc5386d82886a410b0cdd3715471d 100644 --- a/en/application-dev/ui/ui-ts-building-category-list-layout.md +++ b/en/application-dev/ui/ui-ts-building-category-list-layout.md @@ -1,8 +1,8 @@ # Building a Food Category List Layout -Use the **List** component and **ForEach** loop rendering to build the food category list layout. +Use the **List** component and **ForEach** loop to build the food category list layout. -1. Create the **FoodCategoryList.ets** page in the **pages** directory, change the name of the **index.ets** file to **FoodDetail.ets**, and add the **index.ets** file to the **"pages"** tag in the **config.json** file. The page in the first position is the home page. +1. Create a page file named **FoodCategoryList.ets** in the **pages** directory, rename the **index.ets** file **FoodDetail.ets**, and add the renamed file to the **"pages"** tag in the **config.json** file. The first page under the tag is the home page. ``` "js": [ @@ -14,7 +14,7 @@ Use the **List** component and **ForEach** loop rendering to build the food ] ``` -2. Create the **FoodList** component as the page entry component. The **FoodListItem** component is a child component of the **FoodList** component. The **** component is used to display repeated data of the same type. Its child component** ** is used to display specific items in the list. +2. Create a **List** component named **FoodList** as the page entry point. Then, add a **ListItem** component named **FoodListItem** as its child component. The **List** component is used to display data of the same type. Its child component **** is used to display specific items in the list. ``` @Component @@ -42,7 +42,7 @@ Use the **List** component and **ForEach** loop rendering to build the food import { initializeOnStartup } from '../model/FoodDataModels' ``` -4. Configure **FoodList** and **FoodListItem** components to pass values between each other. Create the member variable **foodItems** of the **FoodData\[\]** type in the **FoodList** component and invoke the **initializeOnStartup** method to assign a value to the variable. Create a member variable **foodItem** of the **FoodData** type in the **FoodListItem** component. Pass the **foodItems\[0\]** of the first element in the **foodItems** array of the parent component to **FoodListItem** as a parameter. +4. Configure the **FoodList** and **FoodListItem** components to pass values. Create a member variable named **foodItems** of the **FoodData\[\]** type in the **FoodList** component and invoke the **initializeOnStartup** method to assign a value to the variable. Create a member variable **foodItem** of the **FoodData** type in the **FoodListItem** component. Pass the **foodItems\[0\]** of the first element in the parent **foodItems** array as a parameter to **FoodListItem**. ``` import { FoodData } from '../model/FoodData' @@ -68,7 +68,7 @@ Use the **List** component and **ForEach** loop rendering to build the food } ``` -5. Declare the UI layout of the **FoodListItem** child component. Create the **Flex** component, including the thumbnail of the food image, food name, and calories corresponding to the food. +5. Declare the UI layout of the **FoodListItem** child component. Create a **Flex** component, including the food image thumbnail, food name, and calories in the food. ``` import { FoodData } from '../model/FoodData' @@ -112,7 +112,7 @@ Use the **List** component and **ForEach** loop rendering to build the food ![](figures/en-us_image_0000001204776353.png) -6. Create two **FoodListItem** objects. Create two **FoodListItem** objects in the **** component and pass the first element **this.foodItems\[0\]** and the second element **foodItem: this.foodItems\[1\]** to the **FoodListItem**. +6. Create two **FoodListItem** objects. Create two **FoodListItem** objects in the **List** component and pass the first element **this.foodItems\[0\]** and the second element **foodItem: this.foodItems\[1\]** to the **FoodListItem**. ``` import { FoodData } from '../model/FoodData' @@ -159,7 +159,7 @@ Use the **List** component and **ForEach** loop rendering to build the food ![](figures/en-us_image_0000001204537865.png) -7. Import **ForEach** to avoid creating **FoodListItem** objects one by one. +7. Import **ForEach** so that you do not need to create **FoodListItem** objects one by one. ``` ForEach( @@ -169,9 +169,9 @@ Use the **List** component and **ForEach** loop rendering to build the food ) ``` - The **ForEach** group has three parameters. The first parameter is the array to be traversed, the second parameter is the lambda function for generating child components, and the third parameter is the key value generator. The third parameter is optional. However, for performance reasons, it is strongly recommended that you provide it. **keyGenerator** enables the development framework to better recognize array changes without having to rebuild all nodes due to item changes. + The **ForEach** group has three parameters. The first parameter is the array to be traversed, the second parameter is the lambda function for generating child components, and the third parameter is the key value generator. The third parameter is optional. Yet, for performance reasons, it is strongly recommended that you provide it. **keyGenerator** enables the development framework to better recognize array changes without having to rebuild all nodes after item changes. - Traverse the **foodItems** array to cyclically create the **ListItem** component. Each item in **foodItems** is passed as a parameter to the **FoodListItem** component. + Traverse the **foodItems** array to cyclically create the **ListItem** component. Pass each item in **foodItems** as a parameter to the **FoodListItem** component. ``` ForEach(this.foodItems, item => { diff --git a/en/application-dev/ui/ui-ts-building-data-model.md b/en/application-dev/ui/ui-ts-building-data-model.md index 5e47f0bec306b281c8ad6ac2119d0b180024aabc..2068f1e12080202c598480f2fedae47462ad4baf 100644 --- a/en/application-dev/ui/ui-ts-building-data-model.md +++ b/en/application-dev/ui/ui-ts-building-data-model.md @@ -1,14 +1,14 @@ # Building a Food Data Model -In the created page, we use various items to describe food, such as food names, calories, proteins, fats, carbohydrates, and vitamin C. This form of coding is impractical in actual development. Therefore, you need to create food data models to store and manage data in a unified manner. +On the created page, we use various items to describe food, such as food names, calories, proteins, fats, carbohydrates, and vitamin C. This form of coding is impractical in actual development. Therefore, you need to create food data models to store and manage data in a unified manner. ![](figures/en-us_image_0000001215433095.png) -1. Create a **model** folder and create the **FoodData.ets** file in the **model** folder. +1. Create a folder named **model** and create a file named **FoodData.ets** therein. ![](figures/en-us_image_0000001195119619.png) -2. Define the food data storage model **FoodData** and the enumerated variable **Category**. The **FoodData** class contains the food ID, name, category, image, calories, protein, fat, carbohydrates, and vitamin C attributes. +2. Define a food data storage model, **FoodData**, and an enum variable, **Category**. The **FoodData** class contains the food ID, name, category, image, calories, protein, fat, carbohydrates, and vitamin C attributes. The eTS programming language is an extension of the TS language and also supports the TS syntax. @@ -47,13 +47,13 @@ In the created page, we use various items to describe food, such as food names, } ``` -3. Store food image resources in the **resources** \> **phone** \> **media** directory. The image name is the food name. +3. Store food image resources in the **resources** \> **phone** \> **media** directory. Use food names as the image names. ![](figures/en-us_image_0000001195117633.png) -4. Create food resource data. Create **FoodDataModels.ets** in the **model** folder and declare the food composition array **FoodComposition** on the page. +4. Create food resource data. Create **FoodDataModels.ets** in the **model** folder and declare a food composition array, **FoodComposition** on the page. - In this example, 12 pieces of food data are used. In actual development, you can customize more data resources. When there are a large number of food resources, it is recommended that **LazyForEach** be used to load data. The following nutritional data is sourced from the Internet. + In this example, 12 pieces of food data are used. You can customize more data resources when needed. Use **LazyForEach** to load data if a large amount of food data is involved. The following nutritional data is sourced from the Internet. ``` const FoodComposition: any[] = [ @@ -72,7 +72,7 @@ In the created page, we use various items to describe food, such as food names, ] ``` -5. Create the **initializeOnStartUp** method to initialize the **FoodData** array. In **FoodDataModels.ets**, the **FoodData** and **Category** defined in **FoodData.ets** are used. Therefore, you need to use **export** for **FoodData** class in **FoodData.ets**, and use **import** for the **FoodData** and **Category** in **FoodDataModels.ets**. +5. Create the **initializeOnStartUp** method to initialize the **FoodData** array. Export the **FoodData** class from **FoodData.ets**, and import **FoodData** and **Category** in **FoodDataModels.ets**. ``` // FoodData.ets diff --git a/en/application-dev/ui/ui-ts-components.md b/en/application-dev/ui/ui-ts-components.md index a0058e6c7411b8b11662f1732e988bf72f79eb52..a72ec12ada141779b6a31af7d978836f0a6ee2e4 100644 --- a/en/application-dev/ui/ui-ts-components.md +++ b/en/application-dev/ui/ui-ts-components.md @@ -4,7 +4,7 @@ Before customizing a component, get to know what the [component and decorator]( ## Components and Decorators -In a declarative UI, all pages are composed of components. The data structure of the component is **struct**, and the decorator [@Component](../reference/arkui-ts/ts-component-based-component.md) is the component-based flag. The struct decorated by **@Component** indicates that the struct has the component capability. +In a declarative UI, all pages are composed of components. The data structure of the component is **struct**, and the decorator [@Component](ts-component-based-component.md) is the component-based flag. The struct decorated by **@Component** indicates that the struct has the component capability. The method for declaring a custom component is as follows: @@ -21,7 +21,7 @@ interface Builder { } ``` -The component decorated by [@Entry](../reference/arkui-ts/ts-component-based-entry.md) indicates that the component is the main entry of the page and can also be considered as the root node of the page. Note that a page must have one and only one **@Entry**. Only the **@Entry** decorated component and its child components are displayed on the page. +The component decorated by [@Entry](ts-component-based-entry.md) indicates that the component is the main entry of the page and can also be considered as the root node of the page. Note that a page must have one and only one **@Entry**. Only the **@Entry** decorated component and its child components are displayed on the page. **@Component** and **@Entry** are basic and important decorators. To put it simply, a decorator assigns a capability to an object to be decorated. For example, **@Entry** assigns the capability of the page entry, and **@Component** assigns the component capability. @@ -76,3 +76,4 @@ When you create a system component, the default style is used. You can change th ![](figures/en-us_image_0000001168888224.png) + diff --git a/en/application-dev/ui/ui-ts-creating-project.md b/en/application-dev/ui/ui-ts-creating-project.md index 5d28cec40a7cc757e7fdfae6775561cb933cea87..57482cce585951a02a62e25b765a38d2eac2de57 100644 --- a/en/application-dev/ui/ui-ts-creating-project.md +++ b/en/application-dev/ui/ui-ts-creating-project.md @@ -2,7 +2,7 @@ Before creating a project, you need to install DevEco Studio. For details, see [HUAWEI DevEco Studio User Guide](https://developer.harmonyos.com/en/docs/documentation/doc-guides/tools_overview-0000001053582387). -1. Open DevEco Studio and click **Create Project**. If a project exists, choose **File** \> **New** \> **New project**. +1. Open DevEco Studio and click **Create Project**. If there is already a project, choose **File** \> **New** \> **New project**. ![](figures/en-us_image_0000001168956332.png) @@ -14,13 +14,13 @@ Before creating a project, you need to install DevEco Studio. For details, see ![](figures/en-us_image_0000001213462329.png) -4. On the project configuration page, change the project name to **HealthyDiet**, set **Project Type** to **Application**, **Device Type** to **Phone**, **Language** to **eTS**, and enable compatibility with API version 7. By default, DevEco Studio saves the project to drive C. To change the save path, click the folder icon for **Save Location** and specify a path. After completing configuration, click **Finish**. +4. On the project configuration page, set Project Name to **HealthyDiet**, **Project Type** to **Application**, **Device Type** to **Phone**, **Language** to **eTS**, and **Compatible API Version** to **SDK: API Version 7**. By default, DevEco Studio saves the project to drive C. You can change the save path by setting **Save Location**. When you are done, click **Finish**. ![](figures/en-us_image_0000001167746622.png) 5. After the project is created, open the **app.ets** file. - The **app.ets** file provides the **onCreate** and **onDestroy** methods for the application lifecycle. These methods are called when an application is created and when an application is destroyed, respectively. Global variables can be declared in **app.ets**, and the declared data and methods are shared by the entire application. + The **app.ets** file provides the **onCreate** and **onDestroy** methods for the application lifecycle. **onCreate** is called when an application is created, and **onDestroy** is called when an application is destroyed. Global variables can be declared in the **app.ets** file, wherein the declared data and methods are shared by the entire application. ``` export default { diff --git a/en/application-dev/ui/ui-ts-creating-simple-page.md b/en/application-dev/ui/ui-ts-creating-simple-page.md index a5f7f2492a14a3c7fe0911f517c5f9924d166376..ca6be86def635a49f870cbf0a3d653f093e60774 100644 --- a/en/application-dev/ui/ui-ts-creating-simple-page.md +++ b/en/application-dev/ui/ui-ts-creating-simple-page.md @@ -1,12 +1,12 @@ # Creating a Simple Page -In this section, we will start the development of the food details page and learn how to build custom components through the container components **** and **** as well as basic components **** and **** to complete the food introduction with pictures and texts. +In this section, we will develop an infographic food details page, by building custom components through the container components **** and **** as well as basic components **** and ****. ## Building the Stack Layout 1. Create a food name. - Delete the code of the **build** method of the project template, create the **** component, and place the **** component in the braces of the **** component so that the **** component becomes a child component of the **** component. A **** component consists of one or more child components. The latter child component overwrites the former child component. + Delete the code of the **build** method in the project template, create a **** component, and place the **** component in the braces of the **** component so that the **** component becomes a child component of the **** component. A **** component consists of one or more child components. The latter child component overwrites the former one. ``` @Entry @@ -26,7 +26,7 @@ In this section, we will start the development of the food details page and lear 2. Display food pictures. - Create an **** component and specify the URL for the component. The **** and **** components are mandatory. To display the **** component above the **** component, you need to declare the **** component first. Image resources are stored in the **rawfile** folder in **resources**. When referencing the resources in the **rawfile** folder, use the **$rawfile\('_filename_ loaded\)** format, where **filename** indicates the relative path of the file in the **rawfile** folder. Currently, **$rawfile** only allows the **** component to reference image resources. + Create an **** component and specify a URL for it. The **** and **** components are mandatory. To display the **** component above the **** component, you need to declare the **** component first. Image resources are stored in the **rawfile** folder in **resources**. When referencing the resources in the **rawfile** folder, use the **$rawfile\('_filename_ loaded\)** format, where **filename** indicates the relative path of the file in the **rawfile** folder. Currently, **$rawfile** only allows the **** component to reference image resources. ``` @Entry @@ -249,7 +249,7 @@ You can use the **Flex** layout to build a food composition table. In this way 2. Create a **Flex** component to display two food composition categories in the tomato: Calories and Nutrition. - **Calories** contains information about calories. **Nutrition** contains protein, fat, carbohydrates, and vitamin C. + **Calories** contains information about calories. **Nutrition** contains information about protein, fat, carbohydrates, and vitamin C. Create the Calories class. Create a **Flex** component and set its height to **280**, and the top, right, and left margins to **30**. The **Flex** component contains three **Text** child components, which represent the category name \(**Calories**\), content name \(**Calories**\), and contain value \(**17 kcal**\), respectively. By default, child components in the **Flex** component are arranged horizontally. @@ -546,5 +546,14 @@ You can use the **Flex** layout to build a food composition table. In this way ![](figures/en-us_image_0000001215199399.png) -You've learned how to build a simple food details page. Read on to define page layout and connection. +You've learned how to build a simple food details page. Read on to learn how to define the page layout and connection. + +## Samples + +The following sample is provided to help you better understand how to use build a simple page: + +- [eTSBuildCommonView](https://gitee.com/openharmony/app_samples/tree/master/ETSUI/eTSBuildCommonView) + + This sample shows how to build a common view to display the picture of tomatoes and nutrition information, with the stack layout and flex layout. + diff --git a/en/application-dev/ui/ui-ts-developing-intro.md b/en/application-dev/ui/ui-ts-developing-intro.md deleted file mode 100644 index eeebf0cedc91fb18cc1333005bea2562d6c908ac..0000000000000000000000000000000000000000 --- a/en/application-dev/ui/ui-ts-developing-intro.md +++ /dev/null @@ -1,11 +0,0 @@ -# Introduction - -This guide aims to build a diet application that allows you to view nutritional information about food. The details are as follows: - -1. **Food Detail**: [Build a food basic information page](ui-ts-creating-simple-page.md). -2. **Food Category/List**: [Build food list and category pages](ui-ts-building-data-model.md). - -You will be able to design and develop applications on your own after learning about components, layouts, animations, and data state management from project creation and common view construction. Development has never so easy. - -![](figures/en-us_image_0000001174035718.png) - diff --git a/en/application-dev/ui/ui-ts-experiencing-declarative--u.md b/en/application-dev/ui/ui-ts-experiencing-declarative-ui.md similarity index 100% rename from en/application-dev/ui/ui-ts-experiencing-declarative--u.md rename to en/application-dev/ui/ui-ts-experiencing-declarative-ui.md diff --git a/en/application-dev/ui/ui-ts-overview.md b/en/application-dev/ui/ui-ts-overview.md index c86f7f50be7634106ea74bb90bc2904bdbf6f712..cc1ab7d987b871b9b46f53fa4f7244786491682e 100644 --- a/en/application-dev/ui/ui-ts-overview.md +++ b/en/application-dev/ui/ui-ts-overview.md @@ -1,10 +1,10 @@ # Overview -The TypeScript-based declarative development paradigm of ArkUI is a simplified, high-performance UI development framework for cross-device applications. +The TypeScript-based declarative development paradigm of ArkUI is a simplified, high-performance UI development framework for cross-device applications on OpenHarmony. ## Basic Capabilities -In ArkUI that uses the TypeScript-based declarative development paradigm, the programming mode is closer to natural semantics. You can intuitively describe the UI without caring about how the framework implements UI drawing and rendering, leading to simplified and efficient development. The UI capabilities are provided from three dimensions: component, animation, and state management. It also provides system capability APIs to allow for effortless invocation of system capabilities. +In ArkUI that uses the TypeScript-based declarative development paradigm, the programming mode is closer to natural semantics. You can intuitively describe the UI without caring about how the framework implements UI drawing and rendering, leading to simplified and efficient development. The UI capabilities are provided from three dimensions: component, animation, and state management. System capability APIs are also provided to allow for effortless invocation of system capabilities. - **Out-of-the-box components** @@ -23,7 +23,7 @@ In ArkUI that uses the TypeScript-based declarative development paradigm, the pr - **System capability APIs** - Development is never so easy, with a diverse array of encapsulated system capability APIs, from UI design to system capability invoking. + Development has never been so easy, with a diverse array of encapsulated system capability APIs, from UI design to system capability invoking. ## Overall Architecture diff --git a/en/application-dev/ui/ui-ts-page-redirection-data-transmission.md b/en/application-dev/ui/ui-ts-page-redirection-data-transmission.md index 21b5a1a9bd7428b04f66b40862d81e263bf94b5f..e1ef96fc52a31ee3659ae19d48cce27d80641153 100644 --- a/en/application-dev/ui/ui-ts-page-redirection-data-transmission.md +++ b/en/application-dev/ui/ui-ts-page-redirection-data-transmission.md @@ -1,6 +1,6 @@ # Implementing Page Redirection and Data Transmission -This section describes how to implement page redirection and data transmission: +This section describes how to implement page redirection and data transmission between pages: 1. Page redirection: Click a food item on the food list page to go to the food details page. Click the back button on the food details page to go back to the food list page. 2. Data transmission between pages: After you click a food item, **FoodDetail** receives data from the previous page and renders the corresponding food details page. @@ -44,7 +44,7 @@ The procedure below uses these two mechanisms for redirection between the page l ![](figures/listrouter.gif) -2. Click **FoodGridItem**. The **FoodDetail** page is displayed. Call the **push** API of the **router** module to push the **FoodDetail** page to the route stack to implement page redirection. To use the router APIs, you need to import **router**. +2. Click **FoodGridItem**. The **FoodDetail** page is displayed. Import the **router** module, and then call the **push** API of this module to push the **FoodDetail** page to the route stack to implement page redirection. ``` import router from '@system.router' @@ -118,7 +118,7 @@ The procedure below uses these two mechanisms for redirection between the page l ## Data Transmission Between Pages -We have implemented the redirection and going back of the **FoodCategoryList** and **FoodDetail** pages. However, the tomato details page is displayed no matter which **FoodListItem**/**FoodGridItem** is clicked. This is because the data transmission between pages is not configured and the routing with parameters is required. +We have implemented the redirection and going back of the **FoodCategoryList** and **FoodDetail** pages. At this point, the tomato details page is displayed no matter which **FoodListItem**/**FoodGridItem** is clicked. This is because the data transmission between pages is not yet configured. To configure data transmission between pages, set the routing with parameters as follows: 1. Set the **params** attribute in the **Navigator** of the **FoodListItem** component. The **params** attribute accepts the key-value object. @@ -161,7 +161,7 @@ We have implemented the redirection and going back of the **FoodCategoryList** } ``` -3. Obtain the value of **foodData**. Call **router.getParams\(\).foodData** to obtain the data corresponding to **foodDate** carried when the **FoodCategoryList** page is displayed. +3. Obtain the value of **foodData**. Call **router.getParams\(\).foodData** to obtain the data corresponding to **foodData** carried when the **FoodCategoryList** page is displayed. ``` @Entry @@ -268,3 +268,12 @@ We have implemented the redirection and going back of the **FoodCategoryList** ``` +## Samples + +The following sample is provided to help you better understand how to define the page layout and connection: + +- [eTSDefiningPageLayoutAndConnection](https://gitee.com/openharmony/app_samples/tree/master/ETSUI/eTSDefiningPageLayoutAndConnection) + + This sample exemplifies the basic usage of the list layout, grid layout, and page routing, by building the food list page and food details page. + + diff --git a/en/application-dev/usb/Readme-EN.md b/en/application-dev/usb/Readme-EN.md new file mode 100644 index 0000000000000000000000000000000000000000..7ff9009a986f880c8b06123ba716e18c5a3722da --- /dev/null +++ b/en/application-dev/usb/Readme-EN.md @@ -0,0 +1,4 @@ +# USB Service + +- [USB Service Overview](usb-overview.md) +- [USB Service Development](usb-guidelines.md) diff --git a/en/application-dev/usb/figures/en-us_image_0000001237821727.png b/en/application-dev/usb/figures/en-us_image_0000001237821727.png new file mode 100644 index 0000000000000000000000000000000000000000..4a139c4e6e93a0b161563e87f8e0903d2b64a299 Binary files /dev/null and b/en/application-dev/usb/figures/en-us_image_0000001237821727.png differ diff --git a/en/application-dev/usb/public_sys-resources/icon-caution.gif b/en/application-dev/usb/public_sys-resources/icon-caution.gif new file mode 100644 index 0000000000000000000000000000000000000000..6e90d7cfc2193e39e10bb58c38d01a23f045d571 Binary files /dev/null and b/en/application-dev/usb/public_sys-resources/icon-caution.gif differ diff --git a/en/application-dev/usb/public_sys-resources/icon-danger.gif b/en/application-dev/usb/public_sys-resources/icon-danger.gif new file mode 100644 index 0000000000000000000000000000000000000000..6e90d7cfc2193e39e10bb58c38d01a23f045d571 Binary files /dev/null and b/en/application-dev/usb/public_sys-resources/icon-danger.gif differ diff --git a/en/application-dev/usb/public_sys-resources/icon-note.gif b/en/application-dev/usb/public_sys-resources/icon-note.gif new file mode 100644 index 0000000000000000000000000000000000000000..6314297e45c1de184204098efd4814d6dc8b1cda Binary files /dev/null and b/en/application-dev/usb/public_sys-resources/icon-note.gif differ diff --git a/en/application-dev/usb/public_sys-resources/icon-notice.gif b/en/application-dev/usb/public_sys-resources/icon-notice.gif new file mode 100644 index 0000000000000000000000000000000000000000..86024f61b691400bea99e5b1f506d9d9aef36e27 Binary files /dev/null and b/en/application-dev/usb/public_sys-resources/icon-notice.gif differ diff --git a/en/application-dev/usb/public_sys-resources/icon-tip.gif b/en/application-dev/usb/public_sys-resources/icon-tip.gif new file mode 100644 index 0000000000000000000000000000000000000000..93aa72053b510e456b149f36a0972703ea9999b7 Binary files /dev/null and b/en/application-dev/usb/public_sys-resources/icon-tip.gif differ diff --git a/en/application-dev/usb/public_sys-resources/icon-warning.gif b/en/application-dev/usb/public_sys-resources/icon-warning.gif new file mode 100644 index 0000000000000000000000000000000000000000..6e90d7cfc2193e39e10bb58c38d01a23f045d571 Binary files /dev/null and b/en/application-dev/usb/public_sys-resources/icon-warning.gif differ diff --git a/en/application-dev/usb/usb-guidelines.md b/en/application-dev/usb/usb-guidelines.md new file mode 100644 index 0000000000000000000000000000000000000000..caa2c920c7417ffd723dac3acfc43cc80430a2e8 --- /dev/null +++ b/en/application-dev/usb/usb-guidelines.md @@ -0,0 +1,216 @@ +# USB Service Development + +## When to Use + +In Host mode, you can obtain the list of connected devices, enable or disable the devices, manage device access permissions, and perform data transfer or control transfer. + +## APIs + +The OpenHarmony USB service provides the following functions: query of USB device list, bulk data transfer, control transfer, and access permission management. + +The following table lists the USB APIs currently available. For details, see the _API Reference_. + +**Table 1** Open USB APIs + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

    API

    +

    Description

    +

    hasRight(deviceName: string): boolean

    +

    Checks whether the user, for example, the application or system, has the device access permissions. The value true is returned if the user has the device access permissions; the value false is returned otherwise.

    +

    requestRight(deviceName: string): Promise<boolean>

    +

    Requests the temporary permission for a given application to access the USB device.

    +

    connectDevice(device: USBDevice): Readonly<USBDevicePipe>

    +

    Connects to the USB device based on the device information returned by getDevices().

    +

    getDevices(): Array<Readonly<USBDevice>>

    +

    Obtains the USB device list.

    +

    setConfiguration(pipe: USBDevicePipe, config: USBConfig): number

    +

    Sets the USB device configuration.

    +

    setInterface(pipe: USBDevicePipe, iface: USBInterface): number

    +

    Sets a USB interface.

    +

    claimInterface(pipe: USBDevicePipe, iface: USBInterface, force?: boolean): number

    +

    Claims a USB interface

    +

    function bulkTransfer(pipe: USBDevicePipe, endpoint: USBEndpoint, buffer: Uint8Array, timeout?: number): Promise<number>

    +

    Performs bulk transfer.

    +

    closePipe(pipe: USBDevicePipe): number

    +

    Closes a USB device pipe.

    +

    releaseInterface(pipe: USBDevicePipe, iface: USBInterface): number

    +

    Releases a USB interface.

    +

    getFileDescriptor(pipe: USBDevicePipe): number

    +

    Obtains the file descriptor.

    +

    getRawDescriptor(pipe: USBDevicePipe): Uint8Array

    +

    Obtains the raw USB descriptor.

    +

    controlTransfer(pipe: USBDevicePipe, contrlparam: USBControlParams, timeout?: number): Promise<number>

    +

    Performs control transfer.

    +
    + +## How to Develop + +You can set a USB device as a host to connect to a device for data transfer. The development procedure is as follows: + +1. Obtain the USB device list. + + ``` + // Import the USB API package. + import usb from '@ohos.usb'; + // Obtain the USB device list. + var deviceList = usb.getDevices(); + /* + Example deviceList structure + [ + { + name: "1-1", + serial: "", + manufacturerName: "", + productName: "", + version: "", + vendorId: 7531, + productId: 2, + clazz: 9, + subclass: 0, + protocol: 1, + devAddress: 1, + busNum: 1, + configs: [ + { + id: 1, + attributes: 224, + isRemoteWakeup: true, + isSelfPowered: true, + maxPower: 0, + name: "1-1", + interfaces: [ + { + id: 0, + protocol: 0, + clazz: 9, + subclass: 0, + alternateSetting: 0, + name: "1-1", + endpoints: [ + { + address: 129, + attributes: 3, + interval: 12, + maxPacketSize: 4, + direction: 128, + number: 1, + type: 3, + interfaceId: 0, + }, + ], + }, + ], + }, + ], + }, + ], + */ + ``` + +2. Obtain the device operation permissions. + + ``` + var deviceName = deviceList[0].name; + // Request the permissions to operate a specified device. + usb.requestRight(deviceName).then(hasRight => { + console.info("usb device request right result: " + hasRight); + }).catch(error => { + console.info("usb device request right failed : " + error); + }); + ``` + +3. Open the device. + + ``` + // Open the device, and obtain the USB device pipe for data transfer. + var pipe = usb.connectDevice(deviceList[0]); + /* + Claim the corresponding interface from deviceList. + interface must be one present in the device configuration. + */ + usb.claimInterface(pipe , interface, true); + ``` + +4. Perform data transfer. + + ``` + /* + Read data. Select the corresponding RX endpoint from deviceList for data transfer. + (endpoint.direction == 0x80); dataUint8Array indicates the data to read. The data type is Uint8Array. + */ + + usb.bulkTransfer(pipe, inEndpoint, dataUint8Array, 15000).then(dataLength => { + if (dataLength >= 0) { + console.info("usb readData result Length : " + dataLength); + var resultStr = this.ab2str(dataUint8Array); // Convert uint8 data into a string. + console.info("usb readData buffer : " + resultStr); + } else { + console.info("usb readData failed : " + dataLength); + } + }).catch(error => { + console.info("usb readData error : " + JSON.stringify(error)); + }); + // Send data. Select the corresponding TX endpoint from deviceList for data transfer. (endpoint.direction == 0) + usb.bulkTransfer(pipe, endpoint, dataUint8Array, 15000).then(dataLength => { + if (dataLength >= 0) { + console.info("usb writeData result write length : " + dataLength); + } else { + console.info("writeData failed"); + } + }).catch(error => { + console.info("usb writeData error : " + JSON.stringify(error)); + }); + ``` + +5. Release the USB interface, and close the USB device. + + ``` + usb.releaseInterface(pipe, interface); + usb.closePipe(pipe); + ``` + + diff --git a/en/application-dev/usb/usb-overview.md b/en/application-dev/usb/usb-overview.md new file mode 100644 index 0000000000000000000000000000000000000000..f2304ed3b7d07d67642a49622a8769c8c9565e09 --- /dev/null +++ b/en/application-dev/usb/usb-overview.md @@ -0,0 +1,20 @@ +# USB Service Overview + +## Basic Concepts + +The USB service in OpenHarmony is an abstraction of underlying hardware-based USB devices. Your application can access the USB devices via the USB service. With the APIs provided by the USB service, you can obtain the list of connected USB devices, manage device access permissions, and perform data transfer or control transfer between the host and connected devices. + +## Working Principles + +The USB subsystem consists of three parts: USB API, USB Service, and USB HAL. The following figure shows how the USB service is implemented. + +**Figure 1** Implementation of the USB service + + +![](figures/en-us_image_0000001237821727.png) + +- USB API: provides USB APIs that implement various basic functions, for example, query of the USB device list, bulk data transfer, control transfer, and right management. +- USB Service: receives, parses, and distributes Hardware Abstraction Layer \(HAL\) data, manages and controls foreground and background policies, and manages devices. + +- USB HAL: provides driver capability APIs that can be directly called in user mode. + diff --git a/en/device-dev/driver/Readme-EN.md b/en/device-dev/driver/Readme-EN.md index 2c0d763aeefc102df40371b779547d8cad78ead0..310db48cfb1623552eb51cd2c5b7211dbb528808 100644 --- a/en/device-dev/driver/Readme-EN.md +++ b/en/device-dev/driver/Readme-EN.md @@ -37,4 +37,5 @@ - [Sensor](driver-peripherals-sensor-des.md) - [WLAN](driver-peripherals-external-des.md) - [Audio](driver-peripherals-audio-des.md) - - [USB](driver-peripherals-usb-des.md) \ No newline at end of file + - [USB](driver-peripherals-usb-des.md) + - [CAMERA](driver-peripherals-camera-des.md) \ No newline at end of file diff --git a/en/device-dev/driver/driver-peripherals-camera-des.md b/en/device-dev/driver/driver-peripherals-camera-des.md new file mode 100644 index 0000000000000000000000000000000000000000..24cf34f94b702f7c3fe7439adf8ae6df0bc04e38 --- /dev/null +++ b/en/device-dev/driver/driver-peripherals-camera-des.md @@ -0,0 +1,677 @@ +# Camera + +- [Introduction](#section353860995163604) +- [Development Guidelines](#section1291233039163604) + - [Available APIs](#section1192025723163604) + - [How to Develop](#section1407626053163604) + +- [Development Example](#section605457993163604) + +## Introduction + +The OpenHarmony camera driver model implements the camera hardware driver interface \(HDI\) and the camera pipeline model to manage camera devices. + +The camera driver model consists of the following layers: + +- HDI implementation layer: implements standard southbound interfaces of OpenHarmony cameras. + +- Framework layer: connects to the HDI implementation layer for control instruction and stream transfer, establishes data channels, and manages camera devices. + +- Adaptation layer: shields the differences between bottom-layer chips and OSs for multi-platform adaptation. + + +**Figure 1** Architecture of the camera driver model +![](figures/architecture-of-the-camera-driver-model.png "architecture-of-the-camera-driver-model") + +1. The CameraDeviceHost process is created during system startup. The process enumerates underlying devices, creates a **DeviceManager** instance that manages the device tree, an object for each underlying device, and a **CameraHost** instance, and registers the **CameraHost** instance with the UHDF service. Through this service, the upper layer can obtain the CameraDeviceHost process at the bottom layer to operate the underlying devices. Note that the **DeviceManager** instance can also be created by using the configuration table. + +2. The Camera Service obtains the **CameraHost** instance through the CameraDeviceHost service. The **CameraHost** instance can be used to obtain the bottom-layer camera capabilities, turn on the flashlight, call the **Open\(\)** interface to start the camera and create a connection, create a **DeviceManager** instance \(powering on the bottom-layer hardware modules\), and create a **CameraDevice** instance \(providing the device control interface for the upper layer\). When the **CameraDevice** instance is created, each submodule of PipelineCore is instantiated. Among the submodules, StreamPiplineCore is responsible for creating pipelines, and MetaQueueManager is responsible for reporting metadata. + +3. The Camera Service configures the stream and creates a **Stream** instance through the **CameraDevice** instance at the bottom layer. The StreamPipelineStrategy module creates the node connection mode of the corresponding stream by using the mode issued by the upper layer and querying the configuration table. The StreamPipelineBuilder module creates a node and returns the pipeline to the StreamPipelineDispatcher module through the connection. The StreamPipelineDispatcher module provides unified pipeline invoking management. + +4. The Camera Service controls the stream operations through the **Stream** instance. The **AttachBufferQueue\(\)** interface is used to deliver the buffer queue requested from the display module to the bottom layer. The CameraDeviceDriverModel manages the buffer. After the **Capture\(\)** interface is called to deliver commands, the bottom layer transfers the buffer to the upper layer. The Image Signal Processor \(ISP\) node obtains a specified number of buffers from the buffer queue and delivers the buffers to the bottom-layer ISP hardware. After filling the buffers, the ISP hardware transfers the buffers to the CameraDeviceDriverModel. The CameraDeviceDriverModel fills the created pipeline with the received buffers by using a loop thread. Each node processes the pipeline data and transfers the data to the upper layer by using a callback. At the same time, the buffers are freed for reuse. + +5. The Camera Service delivers the photographing command through the **Capture\(\)** interface. The **ChangeToOfflineStream\(\)** interface is used to query the position of the photographing buffer. If the ISP hardware has output an image and sent the image data to the IPP node, the common photographing streams can be converted into offline streams. Otherwise, the close process is executed. The **ChangeToOfflineStream\(\)** interface transfers **StreamInfo** to enable the offline stream to obtain the stream information of the common stream, confirms the node connection mode of the offline stream based on the configuration table, and creates the node connection of the offline stream. If the node connection has been created, the interface releases the node required by the non-offline stream through **CloseCamera\(\)**. It then waits for the buffer to return from the bottom-layer pipeline to the upper layer and then releases the pipeline resources. + +6. The Camera Service sends the **CaptureSetting** parameter to the CameraDeviceDriverModel through the **UpdateSettings\(\)** interface of the **CameraDevice** instance. The CameraDeviceDriverModel forwards the parameter to each node through the StreamPipelineDispatcher module. The **CaptureSetting** parameter carried in the **StartStreamingCapture\(\)** and **Capture\(\)** interfaces is forwarded to the node to which the stream belongs through the StreamPipelineDispatcher module. + +7. The Camera Service controls underlying metadata reporting through the **EnableResult\(\)** and **DisableResult\(\)** interfaces. If the bottom-layer metadata needs to be reported, the pipeline creates a buffer queue in the CameraDeviceDriverModel to collect and transfer metadata, queries the configuration table based on the StreamPipelineStrategy module, and creates and connects to the specified node through the StreamPipelineBuilder module. The MetaQueueManager module delivers the buffer to the bottom layer, and the bottom-layer node fills in data. The MetaQueueManager module then invokes the upper-layer callback to transfer the data to the upper layer. + +8. The Camera Service calls the **Close\(\)** interface of the **CameraDevice** class, and the **CameraDevice** instance calls the corresponding DeviceManager module to power off each hardware. If an offline stream exists in the subpipeline of the IPP node, the offline stream must be reserved until the execution is complete. + +9. To implement dynamic frame control, a CollectBuffer thread is started in the StreamOperator. The CollectBuffer thread obtains a buffer from the buffer queue of each stream. If the frame rate of a stream needs to be controlled \(1/n of the sensor output frame rate\), the CollectBuffer thread can control the buffer packaging of each frame as required, and determine whether to collect the buffer of the stream. For example, if the output frame rate of the sensor is 120 fps and the preview stream frame rate is 30 fps, the CollectBuffer thread collects the buffer of the preview stream every 4 fps. + + +## Development Guidelines + +### Available APIs + +For details about the HDI functionalities and the function passing rules, see "Available APIs" in [Camera](https://gitee.com/openharmony/drivers_peripheral/blob/master/camera/README_zh.md). + +### How to Develop + +The following describes the main APIs of the camera driver model, including the APIs for registering and detecting cameras, creating, capturing, and destroying streams, and enabling and disabling devices. \(To clearly describe the implementation of main functionalities, some error judgment and log source code are not described here.\) + +1. Register a **CameraHost**. + + Define the **HdfDriverEntry** structure to define the method for initializing a **CameraHost**. + + ``` + struct HdfDriverEntry g_cameraHostDriverEntry = { + .moduleVersion = 1, + .moduleName = "camera_service", + .Bind = HdfCameraHostDriverBind, + .Init = HdfCameraHostDriverInit, + .Release = HdfCameraHostDriverRelease, + }; + HDF_INIT(g_cameraHostDriverEntry); // Register the HdfDriverEntry structure with the HDF. + ``` + +2. Initialize the **CameraHost**. + + **HdfCameraHostDriverBind** defined in the **HdfDriverEntry** structure provides the registration of **CameraServiceDispatch\(\)** and **CameraHostStubInstance\(\)**. **CameraServiceDispatch\(\)** is used to remotely call a method of the **CameraHost**, such as **OpenCamera\(\)** and **SetFlashlight\(\)**. **CameraHostStubInstance\(\)** is used to initialize the camera device, which is called during system startup. + + ``` + int HdfCameraHostDriverBind(HdfDeviceObject *deviceObject) + { + HDF_LOGI("HdfCameraHostDriverBind enter!"); + if (deviceObject == nullptr) { + HDF_LOGE("HdfCameraHostDriverBind: HdfDeviceObject is NULL !"); + return HDF_FAILURE; + } + HdfCameraService *hdfCameraService = reinterpret_cast(OsalMemAlloc(sizeof(HdfCameraService))); + if (hdfCameraService == nullptr) { + HDF_LOGE("HdfCameraHostDriverBind OsalMemAlloc HdfCameraService failed!"); + return HDF_FAILURE; + } + hdfCameraService->ioservice.Dispatch = CameraServiceDispatch; // Used to call methods of the CameraHost. + hdfCameraService->ioservice.Open = nullptr; + hdfCameraService->ioservice.Release = nullptr; + hdfCameraService->instance = CameraHostStubInstance(); // Initialize the camera device. + deviceObject->service = &hdfCameraService->ioservice; + return HDF_SUCCESS; + } + ``` + + The following functions are the implementation of the methods of the **CameraHost**: + + ``` + int32_t CameraHostStub::CameraHostServiceStubOnRemoteRequest(int cmdId, MessageParcel &data, + MessageParcel &reply, MessageOption &option) + { + switch(cmdId) { + case CMD_CAMERA_HOST_SET_CALLBACK: { + return CameraHostStubSetCallback(data, reply, option); + } + case CMD_CAMERA_HOST_GET_CAMERAID: { + return CameraHostStubGetCameraIds(data, reply, option); + } + case CMD_CAMERA_HOST_GET_CAMERA_ABILITY: { + return CameraHostStubGetCameraAbility(data, reply, option); + } + case CMD_CAMERA_HOST_OPEN_CAMERA: { + return CameraHostStubOpenCamera(data, reply, option); + } + case CMD_CAMERA_HOST_SET_FLASH_LIGHT: { + return CameraHostStubSetFlashlight(data, reply, option); + } + default: { + HDF_LOGE("%s: not support cmd %d", __func__, cmdId); + return HDF_ERR_INVALID_PARAM; + } + } + return HDF_SUCCESS; + } + ``` + + **CameraHostStubInstance\(\)** finally calls **CameraHostImpl::Init\(\)** to obtain the physical camera and initialize the DeviceManager and PipelineCore modules. + +3. Obtain the **CamerHost**. + + Call the **Get\(\)** interface to obtain the **CameraHost** from the **CameraService**. The **Get\(\)** interface is as follows: + + ``` + sptr ICameraHost::Get(const char *serviceName) + { + do { + using namespace OHOS::HDI::ServiceManager::V1_0; + auto servMgr = IServiceManager::Get(); + if (servMgr == nullptr) { + HDF_LOGE("%s: IServiceManager failed!", __func__); + break; + } + auto remote = servMgr->GetService(serviceName); // Obtain the CameraHost based on serviceName. + if (remote != nullptr) { + sptr hostSptr = iface_cast(remote); // Return the CameraHostProxy object that contains methods such as OpenCamera() to the caller. + return hostSptr; + } + HDF_LOGE("%s: GetService failed! serviceName = %s", __func__, serviceName); + } while(false); + HDF_LOGE("%s: get %s failed!", __func__, serviceName); + return nullptr; + } + ``` + +4. Implement the **OpenCamera\(\)** interface. + + The **CameraHostProxy** class provides five interfaces: **SetCallback\(\)**, **GetCameraIds\(\)**, **GetCameraAbility\(\)**, **OpenCamera\(\)**, and **SetFlashlight\(\)**. The following describes **OpenCamera\(\)**. + + The **OpenCamera\(\)** interface calls the remote **CameraHostStubOpenCamera\(\)** interface through the CMD\_CAMERA\_HOST\_OPEN\_CAMERA to obtain an **ICameraDevice** object. + + ``` + CamRetCode CameraHostProxy::OpenCamera(const std::string &cameraId, const OHOS::sptr &callback, OHOS::sptr &pDevice) + { + int32_t ret = Remote()->SendRequest(CMD_CAMERA_HOST_REMOTE_OPEN_CAMERA, data, reply, option); + if (ret != HDF_SUCCESS) { + HDF_LOGE("%{public}s: SendRequest failed, error code is %{public}d", __func__, ret); + return INVALID_ARGUMENT; + } + CamRetCode retCode = static_cast(reply.ReadInt32()); + bool flag = reply.ReadBool(); + if (flag) { + sptr remoteCameraDevice = reply.ReadRemoteObject(); + if (remoteCameraDevice == nullptr) { + HDF_LOGE("%{public}s: CameraHostProxy remoteCameraDevice is null", __func__); + } + pDevice = OHOS::iface_cast(remoteCameraDevice); + } + return retCode; + } + ``` + + **Remote\(\)-\>SendRequest** calls **CameraHostServiceStubOnRemoteRequest\(\)**, enters the **CameraHostStubOpenCamera\(\)** interface based on **cmdId**, and finally calls **CameraHostImpl::OpenCamera\(\)** to obtain a **CameraDevice** and power on the camera hardware. + + ``` + CamRetCode CameraHostImpl::OpenCamera(const std::string &cameraId, const OHOS::sptr &callback, OHOS::sptr &device) + { + std::shared_ptr cameraDevice = std::static_pointer_cast(itr->second); + if (cameraDevice == nullptr) { + CAMERA_LOGE("camera device is null."); + return INSUFFICIENT_RESOURCES; + } + CamRetCode ret = cameraDevice->SetCallback(callback); + if (ret != NO_ERROR) { + CAMERA_LOGW("set camera device callback faild."); + return ret; + } + CameraHostConfig *config = CameraHostConfig::GetInstance(); + if (config == nullptr) { + return INVALID_ARGUMENT; + } + std::vector phyCameraIds; + RetCode rc = config->GetPhysicCameraIds(cameraId, phyCameraIds); + if (rc != RC_OK) { + CAMERA_LOGE("get physic cameraId failed."); + return DEVICE_ERROR; + } + if (CameraPowerUp(cameraId, phyCameraIds) != RC_OK) { // Power on the camera hardware. + CAMERA_LOGE("camera powerup failed."); + CameraPowerDown(phyCameraIds); + return DEVICE_ERROR; + } + + auto sptrDevice = deviceBackup_.find(cameraId); + if (sptrDevice == deviceBackup_.end()) { + deviceBackup_[cameraId] = cameraDevice.get(); + } + device = deviceBackup_[cameraId]; + cameraDevice->SetStatus(true); + return NO_ERROR; + } + ``` + +5. Implement the **GetStreamOperator\(\)** interface. + + **CameraDeviceImpl** defines interfaces such as **GetStreamOperator\(\)**, **UpdateSettings\(\)**, **SetResultMode\(\)**, and **GetEnabledResult\(\)**. The following is an example of implementing the **GetStreamOperator\(\)** interface: + + ``` + CamRetCode CameraDeviceImpl::GetStreamOperator(const OHOS::sptr &callback, + OHOS::sptr &streamOperator) + { + if (callback == nullptr) { + CAMERA_LOGW("input callback is null."); + return INVALID_ARGUMENT; + } + spCameraDeciceCallback_ = callback; + if (spStreamOperator_ == nullptr) { + // Here, an spStreamOperator object is created and passed to the caller for stream operations. + spStreamOperator_ = new(std::nothrow) StreamOperatorImpl(spCameraDeciceCallback_, shared_from_this()); + if (spStreamOperator_ == nullptr) { + CAMERA_LOGW("create stream operator failed."); + return DEVICE_ERROR; + } + ismOperator_ = spStreamOperator_; + } + streamOperator = ismOperator_; + + spStreamOperator_->SetRequestCallback([this](){ + cameraDeciceCallback_->OnError(REQUEST_TIMEOUT, 0); + }); + } + ``` + +6. Create a stream. + + Fill in the **StreamInfo** structure before creating a stream by calling **CreateStreams\(\)**. + + ``` + using StreamInfo = struct _StreamInfo { + int streamId_; + int width_; // Stream width + int height_; // Stream height + int format_; // Stream format, for example, PIXEL_FMT_YCRCB_420_SP + int datasapce_; + StreamIntent intent_; // StreamIntent, for example, PREVIEW + bool tunneledMode_; + OHOS::sptr bufferQueue_; // The stream buffer queue can be created by using the streamCustomer->CreateProducer() interface. + int minFrameDuration_; + EncodeType encodeType_; + }; + ``` + + The **CreateStreams\(\)** interface in the **StreamOperatorImpl** class is used to create a **StreamBase** instance, which can then be used to initialize operations such as **CreateBufferPool\(\)** by using the **init\(\)** method. + + ``` + RetCode StreamOperatorImpl::CreateStream(const std::shared_ptr& streamInfo) + { + static std::map typeMap = { + {PREVIEW, "PREVIEW"}, + {VIDEO, "VIDEO"}, + {STILL_CAPTURE, "STILL_CAPTURE"}, + {POST_VIEW, "POST_VIEW"}, {ANALYZE, "ANALYZE"}, + {CUSTOM, "CUSTOM"} + }; + + auto itr = typeMap.find(streamInfo->intent_); + if (itr == typeMap.end()) { + CAMERA_LOGE("do not support stream type. [type = %{public}d]", streamInfo->intent_); + return RC_ERROR; + } + std::shared_ptr stream = StreamFactory::Instance().CreateShared(itr->second); // Create a StreamBase instance. + RetCode rc = stream->Init(streamInfo); + return RC_OK; + } + ``` + +7. Configure the stream. + + Use the **CommitStreams\(\)** method to configure the stream, including PipelineCore initialization and creation. It must be called after the stream is created. + + ``` + CamRetCode StreamOperatorImpl::CommitStreams(OperationMode mode, const std::shared_ptr& modeSetting) + { + auto cameraDevice = cameraDevice_.lock(); + if (cameraDevice == nullptr) { + CAMERA_LOGE("camera device closed."); + return CAMERA_CLOSED; + } + std::shared_ptr PipelineCore = + std::static_pointer_cast(cameraDevice)->GetPipelineCore(); + if (PipelineCore == nullptr) { + CAMERA_LOGE("Failed to obtain PipelineCore."); + return CAMERA_CLOSED; + } + + streamPipeCore_ = PipelineCore->GetStreamPipelineCore(); + if (streamPipeCore_ == nullptr) { + CAMERA_LOGE("Failed to obtain the stream PipelineCore."); + return DEVICE_ERROR; + } + + RetCode rc = streamPipeCore_->Init(); // Initialize the PipelineCore. + if (rc != RC_OK) { + CAMERA_LOGE("Failed to initialize the stream PipelineCore."); + return DEVICE_ERROR; + } + rc = streamPipeCore_->CreatePipeline(mode); // Create a pipeline. + if (rc != RC_OK) { + CAMERA_LOGE("Failed to create pipeline."); + return INVALID_ARGUMENT; + } + return NO_ERROR; + } + ``` + +8. Capture images. + + Fill in the **CaptureInfo** structure before calling the **Capture\(\)** method. + + ``` + using CaptureInfo = struct _CaptureInfo { + std::vector streamIds_; // IDs of streams to be captured + std::shared_ptr captureSetting_; // Camera ability can be obtained through the GetCameraAbility() interface of CameraHost. + bool enableShutterCallback_; + }; + ``` + + Use the **Capture\(\)** interface in **StreamOperatorImpl** to call the **CreateCapture\(\)** interface to capture streams. + + ``` + CamRetCode StreamOperatorImpl::Capture(int captureId, const std::shared_ptr& captureInfo, bool isStreaming) + { + if (!ValidCaptureInfo(captureId, captureInfo)) { + CAMERA_LOGE("capture streamIds is empty. [captureId = %d]", captureId); + return INVALID_ARGUMENT; + } + std::shared_ptr cameraCapture = nullptr; + RetCode rc = CreateCapture(captureId, captureInfo, isStreaming, cameraCapture); + if (rc != RC_OK) { + CAMERA_LOGE("create capture is failed."); + return DEVICE_ERROR; + } + + { + std::unique_lock lock(captureMutex_); + camerCaptureMap_.insert(std::make_pair(captureId, cameraCapture)); + } + + rc = StartThread(); + if (rc != RC_OK) { + CAMERA_LOGE("preview start failed."); + return DEVICE_ERROR; + } + return NO_ERROR; + } + ``` + +9. Cancel the capture and release the offline stream. + + Use the **CancelCapture\(\)** interface in the **StreamOperatorImpl** class to cancel the stream capture based on **captureId**. + + ``` + CamRetCode StreamOperatorImpl::CancelCapture(int captureId) + { + auto itr = camerCaptureMap_.find(captureId); // Search for the CameraCapture object in the Map based on the captureId. + RetCode rc = itr->second->Cancel(); // Call the Cancel() interface in CameraCapture to cancel the stream capture. + std::unique_lock lock(captureMutex_); + camerCaptureMap_.erase(itr); // Erase the CameraCapture object. + return NO_ERROR; + } + ``` + + Use the **ReleaseStreams\(\)** interface in the **StreamOperatorImpl** class t release the streams created by using **CreateStream\(\)** and **CommitStreams\(\)** and destroy the pipeline. + + ``` + CamRetCode StreamOperatorImpl::ReleaseStreams(const std::vector& streamIds) + { + RetCode rc = DestroyStreamPipeline(streamIds); // Destroy the pipeline based on streamIds. + rc = DestroyHostStreamMgr(streamIds); + rc = DestroyStreams(streamIds); // Destroy the stream specified by streamIds. + return NO_ERROR; + } + ``` + +10. Close the camera device. + + Use the **Close\(\)** interface in the **CameraDeviceImpl** class to close the camera device. This interface calls **PowerDown\(\)** in the **DeviceManager** to power off the device. + + +## Development Example + +There is a camera demo in the **/drivers/peripheral/camera/hal/init** directory. After system startup, the executable file **ohos\_camera\_demo** is generated in the **/system/bin** directory. This demo can implement basic camera capabilities such as preview and photographing. The following uses the demo as an example to describe how to use the HDI to implement the **PreviewOn\(\)** and **CaptureON\(\)** interfaces. + +1. Construct a Hos3516Demo object in the **main** function. This object contains methods for initializing the camera and starting, stopping, and releasing streams. The **mainDemo-\>InitSensors\(\)** function is used to initialize the **CameraHost**, and the **mainDemo-\>InitCameraDevice\(\)** function is used to initialize the **CameraDevice**. + + ``` + int main(int argc, char** argv) + { + RetCode rc = RC_OK; + auto mainDemo = std::make_shared(); + rc = mainDemo->InitSensors(); // Initialize the CameraHost. + if (rc == RC_ERROR) { + CAMERA_LOGE("main test: mainDemo->InitSensors() error\n"); + return -1; + } + + rc = mainDemo->InitCameraDevice(); // Initialize the CameraDevice. + if (rc == RC_ERROR) { + CAMERA_LOGE("main test: mainDemo->InitCameraDevice() error\n"); + return -1; + } + + rc = PreviewOn(0, mainDemo); // Configure and enable streams. + if (rc != RC_OK) { + CAMERA_LOGE("main test: PreviewOn() error demo exit"); + return -1; + } + + ManuList(mainDemo, argc, argv); // Print the menu to the console. + + return RC_OK; + } + ``` + + The function used to initialize the **CameraHost** is implemented as follows, where the HDI **ICameraHost::Get\(\)** is called to obtain the **demoCameraHost** and set the callback: + + ``` + RetCode Hos3516Demo::InitSensors() + { + demoCameraHost_ = ICameraHost::Get(DEMO_SERVICE_NAME); + if (demoCameraHost_ == nullptr) { + CAMERA_LOGE("demo test: ICameraHost::Get error"); + return RC_ERROR; + } + + hostCallback_ = new CameraHostCallback(); + rc = demoCameraHost_->SetCallback(hostCallback_); + return RC_OK; + } + ``` + + The implementation of the function for initializing the **CameraDevice** is as follows, where the **GetCameraIds\(cameraIds\_\)**, **GetCameraAbility\(cameraId, ability\_\)**, and **OpenCamera\(cameraIds\_.front\(\), callback, demoCameraDevice\_\)** interfaces are called to obtain the **demoCameraHost**. + + ``` + RetCode Hos3516Demo::InitCameraDevice() + { + (void)demoCameraHost_->GetCameraIds(cameraIds_); + const std::string cameraId = cameraIds_.front(); + demoCameraHost_->GetCameraAbility(cameraId, ability_); + + sptr callback = new CameraDeviceCallback(); + rc = demoCameraHost_->OpenCamera(cameraIds_.front(), callback, demoCameraDevice_); + return RC_OK; + } + ``` + +2. Implement the **PreviewOn\(\)** interface to configure streams, enable preview streams, and start stream capture. After this interface is called, the camera preview channel starts running. Two streams are enabled: preview stream and capture or video stream. Only the preview stream will be captured. + + ``` + static RetCode PreviewOn(int mode, const std::shared_ptr& mainDemo) + { + rc = mainDemo->StartPreviewStream(); // Configure the preview stream. + if (mode == 0) { + rc = mainDemo->StartCaptureStream(); // Configure the capture stream. + } else { + rc = mainDemo->StartVideoStream(); // Configure the video stream. + } + + rc = mainDemo->CaptureON(STREAM_ID_PREVIEW, CAPTURE_ID_PREVIEW, CAPTURE_PREVIEW); // Capture the preview stream. + return RC_OK; + } + ``` + + The **StartCaptureStream\(\)**, **StartVideoStream\(\)**, and **StartPreviewStream\(\)** interfaces call the **CreateStream\(\)** interface with different input parameters. + + ``` + RetCode Hos3516Demo::StartVideoStream() + { + RetCode rc = RC_OK; + if (isVideoOn_ == 0) { + isVideoOn_ = 1; + rc = CreateStream(STREAM_ID_VIDEO, streamCustomerVideo_, VIDEO); // To enable the preview stream or capture stream, change the input parameters. + } + return RC_OK; + } + ``` + + The **CreateStream\(\)** interface calls the HDI to configure and create a stream. Specifically, the interface first calls the HDI to obtain a **StreamOperation** object and then creates a **StreamInfo** object. Call **CreateStreams\(\)** and **CommitStreams\(\)** to create and configure a stream. + + ``` + RetCode Hos3516Demo::CreateStreams(const int streamIdSecond, StreamIntent intent) + { + std::vector> streamInfos; + std::vector>().swap(streamInfos); + GetStreamOpt(); // Obtain a StreamOperator object. + std::shared_ptr previewStreamInfo = std::make_shared(); + SetStreamInfo(previewStreamInfo, streamCustomerPreview_, STREAM_ID_PREVIEW, PREVIEW); // Fill in the StreamInfo. + if (previewStreamInfo->bufferQueue_ == nullptr) { + CAMERA_LOGE("demo test: CreateStream CreateProducer(); is nullptr\n"); + return RC_ERROR; + } + streamInfos.push_back(previewStreamInfo); + + std::shared_ptr secondStreamInfo = std::make_shared(); + if (streamIdSecond == STREAM_ID_CAPTURE) { + SetStreamInfo(secondStreamInfo, streamCustomerCapture_, STREAM_ID_CAPTURE, intent); + } else { + SetStreamInfo(secondStreamInfo, streamCustomerVideo_, STREAM_ID_VIDEO, intent); + } + + if (secondStreamInfo->bufferQueue_ == nullptr) { + CAMERA_LOGE("demo test: CreateStreams CreateProducer() secondStreamInfo is nullptr\n"); + return RC_ERROR; + } + streamInfos.push_back(secondStreamInfo); + + rc = streamOperator_->CreateStreams(streamInfos); // Create a stream. + if (rc != Camera::NO_ERROR) { + CAMERA_LOGE("demo test: CreateStream CreateStreams error\n"); + return RC_ERROR; + } + + rc = streamOperator_->CommitStreams(Camera::NORMAL, ability_); // Commit the stream. + if (rc != Camera::NO_ERROR) { + CAMERA_LOGE("demo test: CreateStream CommitStreams error\n"); + std::vector streamIds = {STREAM_ID_PREVIEW, streamIdSecond}; + streamOperator_->ReleaseStreams(streamIds); + return RC_ERROR; + } + return RC_OK; + } + ``` + + The **CaptureON\(\)** interface calls the **Capture\(\)** method of **StreamOperator** to obtain camera data, rotate the buffer, and start a thread to receive data of the corresponding type. + + ``` + RetCode Hos3516Demo::CaptureON(const int streamId, const int captureId, CaptureMode mode) + { + The std::shared_ptr captureInfo = std::make_shared(); // Create and fill in CaptureInfo. + captureInfo->streamIds_ = {streamId}; + captureInfo->captureSetting_ = ability_; + captureInfo->enableShutterCallback_ = false; + + The int rc = streamOperator_->Capture(captureId, captureInfo, true); // The stream capture starts, and buffer recycling starts. + if (mode == CAPTURE_PREVIEW) { + streamCustomerPreview_->ReceiveFrameOn(nullptr); // Create a preview thread to receive the passed buffers. + } else if (mode == CAPTURE_SNAPSHOT) { + The streamCustomerCapture_->ReceiveFrameOn([this](void* addr, const uint32_t size) { // Create a capture thread to receive the passed buffers through the StoreImage callback. + StoreImage(addr, size); + }); + } else if (mode == CAPTURE_VIDEO) { + OpenVideoFile(); + streamCustomerVideo_->ReceiveFrameOn([this](void* addr, const uint32_t size) {// Create a video thread to receive the passed buffer by calling the StoreVideo callback. + StoreVideo(addr, size); + }); + } + return RC_OK; + } + ``` + +3. Implement the **ManuList\(\)** function to obtain characters from the console through the **fgets\(\)** interface. Different characters correspond to different capabilities provided by the demo, and the functionality menu is printed. + + ``` + static void ManuList(const std::shared_ptr& mainDemo, + const int argc, char** argv) + { + int idx, c; + int awb = 1; + constexpr char shortOptions[] = "h:cwvaqof:"; + c = getopt_long(argc, argv, shortOptions, longOptions, &idx); + while(1) { + switch (c) { + case 'h': + c = PutMenuAndGetChr(); // Print the menu. + break; + + case 'f': + FlashLightTest(mainDemo); // Test the flashlight capability. + c = PutMenuAndGetChr(); + break; + case 'o': + OfflineTest(mainDemo); // Test the offline capability. + c = PutMenuAndGetChr(); + break; + case 'c': + CaptureTest(mainDemo); // Test the capture capability. + c = PutMenuAndGetChr(); + break; + case 'w': // Test the AWB capability. + if (awb) { + mainDemo->SetAwbMode(OHOS_CAMERA_AWB_MODE_INCANDESCENT); + } else { + mainDemo->SetAwbMode(OHOS_CAMERA_AWB_MODE_OFF); + } + awb = !awb; + c = PutMenuAndGetChr(); + break; + case 'a': // Test the AE capability. + mainDemo->SetAeExpo(); + c = PutMenuAndGetChr(); + break; + case 'v': // Test the video capability. + VideoTest(mainDemo); + c = PutMenuAndGetChr(); + break; + case 'q': // Exit the demo. + PreviewOff(mainDemo); + mainDemo->QuitDemo(); + exit(EXIT_SUCCESS); + + default: + CAMERA_LOGE("main test: command error please retry input command"); + c = PutMenuAndGetChr(); + break; + } + } + } + ``` + + The **PutMenuAndGetChr\(\)** interface prints the menu of the demo and calls **fgets\(\)** to wait for commands from the console. + + ``` + static int PutMenuAndGetChr(void) + { + constexpr uint32_t inputCount = 50; + int c = 0; + char strs[inputCount]; + Usage(stdout); + CAMERA_LOGD("pls input command(input -q exit this app)\n"); + fgets(strs, inputCount, stdin); + + for (int i = 0; i < inputCount; i++) { + if (strs[i] != '-') { + c = strs[i]; + break; + } + } + return c; + } + ``` + + The console outputs the menu details as follows: + + ``` + "Options:\n" + "-h | --help Print this message\n" + "-o | --offline stream offline test\n" + "-c | --capture capture one picture\n" + "-w | --set WB Set white balance Cloudy\n" + "-v | --video capture Viedeo of 10s\n" + "-a | --Set AE Set Auto exposure\n" + "-f | --Set Flashlight Set flashlight ON 5s OFF\n" + "-q | --quit stop preview and quit this app\n"); + ``` + + Other capabilities in the demo are implemented by calling different HDIs, which are similar to **PreviewOn\(\)**. For details, see [ohos\_camera\_demo](https://gitee.com/openharmony/drivers_peripheral/tree/master/camera/hal/init). + + diff --git a/zh-cn/application-dev/Readme-CN.md b/zh-cn/application-dev/Readme-CN.md index f9052ad08cd2e400bb6b926d1d67036516c1fbd8..da4e7d1ccf044c6c683143eeaaa9385840bb0c11 100644 --- a/zh-cn/application-dev/Readme-CN.md +++ b/zh-cn/application-dev/Readme-CN.md @@ -8,11 +8,11 @@ - 方舟开发框架(ArkUI) - [基于JS扩展的类Web开发范式](ui/ui-arkui-js.md) - [基于TS扩展的声明式开发范式](ui/ui-arkui-ts.md) -- [音频](media/audio.md) -- [用户认证](security/Readme-CN.md) +- [媒体](media/Readme-CN.md) +- [安全](security/Readme-CN.md) - [IPC与RPC通信](connectivity/ipc-rpc.md) - [分布式数据服务](database/Readme-CN.md) - [USB服务](usb/Readme-CN.md) -- [应用事件打点](application-event-logging/Readme-CN.md) +- [DFX](dfx/Readme-CN.md) - [开发参考](reference/Readme-CN.md) diff --git a/zh-cn/application-dev/application-event-logging/Readme-CN.md b/zh-cn/application-dev/application-event-logging/Readme-CN.md deleted file mode 100644 index e79ac250ded24889ab768c23a594a4b8ad4e258c..0000000000000000000000000000000000000000 --- a/zh-cn/application-dev/application-event-logging/Readme-CN.md +++ /dev/null @@ -1,5 +0,0 @@ -# 应用事件打点 - -- [应用事件打点概述](hiappevent-overview.md) -- [应用事件打点开发指导](hiappevent-guidelines.md) - diff --git a/zh-cn/application-dev/background-agent-scheduled-reminder/background-agent-scheduled-reminder-guide.md b/zh-cn/application-dev/background-agent-scheduled-reminder/background-agent-scheduled-reminder-guide.md index aa954f0be42d7539feb938120db7f9cf9e0a3dce..e1b2b4c62a663e7e916e67baf3245ca4240f48a8 100644 --- a/zh-cn/application-dev/background-agent-scheduled-reminder/background-agent-scheduled-reminder-guide.md +++ b/zh-cn/application-dev/background-agent-scheduled-reminder/background-agent-scheduled-reminder-guide.md @@ -150,12 +150,12 @@ interface LocalDateTime:时间信息实例 } ], wantAgent: { - pkgName: "com.huawei.phone", - abilityName: "com.huawei.phone.MainAbility" + pkgName: "com.example.phone", + abilityName: "com.example.phone.MainAbility" }, maxScreenWantAgent: { - pkgName: "com.huawei.phone", - abilityName: "com.huawei.phone.MainAbility" + pkgName: "com.example.phone", + abilityName: "com.example.phone.MainAbility" }, title: "this is title", content: "this is content", @@ -209,12 +209,12 @@ calendar: { }, ], wantAgent: { - pkgName: "com.huawei.phone", - abilityName: "com.huawei.phone.MainAbility" + pkgName: "com.example.phone", + abilityName: "com.example.phone.MainAbility" }, maxScreenWantAgent: { - pkgName: "com.huawei.phone", - abilityName: "com.huawei.phone.MainAbility" + pkgName: "com.example.phone", + abilityName: "com.example.phone.MainAbility" }, ringDuration: 5, snoozeTimes: 2, @@ -247,12 +247,12 @@ alarm: { }, ], wantAgent: { - pkgName: "com.huawei.phone", - abilityName: "com.huawei.phone.MainAbility" + pkgName: "com.example.phone", + abilityName: "com.example.phone.MainAbility" }, maxScreenWantAgent: { - pkgName: "com.huawei.phone", - abilityName: "com.huawei.phone.MainAbility" + pkgName: "com.example.phone", + abilityName: "com.example.phone.MainAbility" }, ringDuration: 5, snoozeTimes: 2, diff --git a/zh-cn/application-dev/dfx/Readme-CN.md b/zh-cn/application-dev/dfx/Readme-CN.md new file mode 100644 index 0000000000000000000000000000000000000000..4962e5b9907be3cf6a11db0b10aa6fccb5c4858a --- /dev/null +++ b/zh-cn/application-dev/dfx/Readme-CN.md @@ -0,0 +1,6 @@ +# DFX + +- 应用事件打点 + - [应用事件打点概述](hiappevent-overview.md) + - [应用事件打点开发指导](hiappevent-guidelines.md) + diff --git a/zh-cn/application-dev/application-event-logging/hiappevent-guidelines.md b/zh-cn/application-dev/dfx/hiappevent-guidelines.md similarity index 100% rename from zh-cn/application-dev/application-event-logging/hiappevent-guidelines.md rename to zh-cn/application-dev/dfx/hiappevent-guidelines.md diff --git a/zh-cn/application-dev/application-event-logging/hiappevent-overview.md b/zh-cn/application-dev/dfx/hiappevent-overview.md similarity index 100% rename from zh-cn/application-dev/application-event-logging/hiappevent-overview.md rename to zh-cn/application-dev/dfx/hiappevent-overview.md diff --git a/zh-cn/application-dev/media/figures/zh-cn_image_0000001182608857.png b/zh-cn/application-dev/media/figures/zh-cn_image_0000001182608857.png deleted file mode 100755 index e0777e28838f6d2455233f2068339f8548f50c67..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/media/figures/zh-cn_image_0000001182608857.png and /dev/null differ diff --git a/zh-cn/application-dev/quick-start/configuring-openharmony-app-signature.md b/zh-cn/application-dev/quick-start/configuring-openharmony-app-signature.md index af4feaca7f9210449bcaa99a4c6b5b87a3a731d3..1af132ca75010a9a7644ca89e12515ed9de8ac98 100644 --- a/zh-cn/application-dev/quick-start/configuring-openharmony-app-signature.md +++ b/zh-cn/application-dev/quick-start/configuring-openharmony-app-signature.md @@ -62,7 +62,7 @@ OpenHarmony应用通过数字证书(.cer文件)和Profile文件(.p7b文件 3. 执行如下命令,生成公私钥文件。例如,生成的密钥库名称为ide_demo_app.p12,存储到D盘根目录下。 ``` - keytool -genkeypair -alias "ide_demo_app" -keyalg EC -sigalg SHA256withECDSA -dname "C=CN,O=HUAWEI,OU=HUAWEI IDE,CN=ide_demo_app" -keystore d:\\idedemokey.p12 -storetype pkcs12 -validity 9125 -storepass 123456Abc -keypass 123456Abc + keytool -genkeypair -alias "ide_demo_app" -keyalg EC -sigalg SHA256withECDSA -dname "C=CN,O=Organization,OU=Unit IDE,CN=ide_demo_app" -keystore d:\\idedemokey.p12 -storetype pkcs12 -validity 9125 -storepass 123456Abc -keypass 123456Abc ``` 生成公私钥文件的参数说明如下: @@ -74,8 +74,8 @@ OpenHarmony应用通过数字证书(.cer文件)和Profile文件(.p7b文件 - **sigalg**:签名算法,固定为**SHA256withECDSA**。 - **dname**:按照操作界面提示进行输入。 - C:国家/地区代码,如CN。 - - O:组织名称,如HUAWEI。 - - OU:组织单位名称,如HUAWEI IDE。 + - O:组织名称,如Organization。 + - OU:组织单位名称,如Unit。 - CN:名字与姓氏,建议与别名一致。 - **validity**:证书有效期,建议设置为9125(25年)。 - **storepass**:设置密钥库密码,必须由大写字母、小写字母、数字和特殊符号中的两种以上字符的组合,长度至少为8位。请记住该密码,后续签名配置需要使用。 diff --git a/zh-cn/application-dev/reference/apis/js-apis-Bundle.md b/zh-cn/application-dev/reference/apis/js-apis-Bundle.md index 22414a8baf90fe29b0466ebcd6853046e91726e0..a76231d2c5d6d2ead5abc11a76069e95246ef195 100755 --- a/zh-cn/application-dev/reference/apis/js-apis-Bundle.md +++ b/zh-cn/application-dev/reference/apis/js-apis-Bundle.md @@ -1048,7 +1048,7 @@ install(bundleFilePaths: Array\, param: InstallParam, callback: AsyncCal | --------------- | ---------------------------------------------- | ---- | ------------------------------------------------------------ | | bundleFilePaths | Array\ | 是 | 安装用包路径 | | param | InstallParam | 是 | userId:用户ID
    installFlag:安装标识。
    NORMAL:安装/卸载
    REPLACE_EXISTING:更新
    isKeepData:卸载时是否保留运行时数据 | -| callback | AsyncCallback<[InstallStatus](#Installstatus)> | 是 | 回调方法 | +| callback | AsyncCallback<[InstallStatus](#installstatus)> | 是 | 回调方法 | **示例:** @@ -1081,7 +1081,7 @@ uninstall(bundleName: string, param: InstallParam, callback: AsyncCallback\installFlag:安装标识。
    NORMAL:安装/卸载
    REPLACE_EXISTING:更新
    isKeepData:卸载时是否保留运行时数据 | -| callback | AsyncCallback<[InstallStatus](#Installstatus)> | 是 | 回调方法 | +| callback | AsyncCallback<[InstallStatus](#installstatus)> | 是 | 回调方法 | **示例:** diff --git a/zh-cn/application-dev/reference/apis/js-apis-appAccount.md b/zh-cn/application-dev/reference/apis/js-apis-appAccount.md index e67440bc153e0f9a17b40978d28708166c1aff01..537dc263d18ec8b7359b849a063d4f133774a305 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-appAccount.md +++ b/zh-cn/application-dev/reference/apis/js-apis-appAccount.md @@ -183,7 +183,7 @@ disableAppAccess(name: string, bundleName: string, callback: AsyncCallback<vo ``` const appAccountManager = account_appAccount.createAppAccountManager(); - appAccountManager.disableAppAccess("ZhangSan", "com.huawei.ohos.accountjsdemo", (err) => { + appAccountManager.disableAppAccess("ZhangSan", "com.example.ohos.accountjsdemo", (err) => { console.log("disableAppAccess err: " + JSON.stringify(err)); }); ``` @@ -211,7 +211,7 @@ disableAppAccess(name: string, bundleName: string): Promise<void>; ``` const appAccountManager = account_appAccount.createAppAccountManager(); - appAccountManager.disableAppAccess("ZhangSan", "com.huawei.ohos.accountjsdemo").then(() => { + appAccountManager.disableAppAccess("ZhangSan", "com.example.ohos.accountjsdemo").then(() => { console.log('disableAppAccess Success'); }).catch((err) => { console.log("disableAppAccess err: " + JSON.stringify(err)); @@ -236,7 +236,7 @@ enableAppAccess(name: string, bundleName: string, callback: AsyncCallback<voi ``` const appAccountManager = account_appAccount.createAppAccountManager(); - appAccountManager.enableAppAccess("ZhangSan", "com.huawei.ohos.accountjsdemo", (err) => { + appAccountManager.enableAppAccess("ZhangSan", "com.example.ohos.accountjsdemo", (err) => { console.log("enableAppAccess: " + JSON.stringify(err)); }); ``` @@ -263,7 +263,7 @@ enableAppAccess(name: string, bundleName: string): Promise<void>; - 示例: ``` - app_account_instance.enableAppAccess("ZhangSan", "com.huawei.ohos.accountjsdemo").then(() => { + app_account_instance.enableAppAccess("ZhangSan", "com.example.ohos.accountjsdemo").then(() => { console.log('enableAppAccess Success'); }).catch((err) => { console.log("enableAppAccess err: " + JSON.stringify(err)); diff --git a/zh-cn/application-dev/reference/apis/js-apis-basic-features-routes.md b/zh-cn/application-dev/reference/apis/js-apis-basic-features-routes.md index 105beaef3114128c854d0e484dce779a2d31542f..42cc91031a704c0d758e01591a272f956ca25024 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-basic-features-routes.md +++ b/zh-cn/application-dev/reference/apis/js-apis-basic-features-routes.md @@ -289,35 +289,3 @@ disableAlertBeforeBackPage(Object): void } } ``` - -## router.getParams7+ - -getParams(): Object - -获取发起跳转的页面往当前页传入的参数。 - -- 返回值 - | 类型 | 说明 | - | -------- | -------- | - | Object | 发起跳转的页面往当前页传入的参数。 | - -- 示例 - ``` - // 在当前页面中 - export default { - pushPage() { - router.push({ - uri: 'pages/detail/detail', - params: { - data1: 'message', - }, - }); - } - } - // 在detail页面中 - export default { - onInit() { - console.info('showData1:' + router.getParams().data1); - } - } - ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-bytrace.md b/zh-cn/application-dev/reference/apis/js-apis-bytrace.md index 39b89054b0aaa58f87f962e655bf33abf1b88407..0e8a5058d6676b86af07a94468772622750e6ae6 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-bytrace.md +++ b/zh-cn/application-dev/reference/apis/js-apis-bytrace.md @@ -64,22 +64,22 @@ finishTrace(name: string, taskId: number): void ``` //追踪并行执行的同名任务 bytrace.startTrace("myTestFunc", 1); - ...... //业务流程 + //业务流程...... bytrace.startTrace("myTestFunc", 2); //第二个追踪的任务开始,同时第一个追踪的同名任务还没结束,出现了并行执行,对应接口的taskId需要不同。 - ...... //业务流程 + //业务流程...... bytrace.finishTrace("myTestFunc", 1); - ...... //业务流程 + //业务流程...... bytrace.finishTrace("myTestFunc", 2); ``` ``` //追踪串行执行的同名任务 bytrace.startTrace("myTestFunc", 1); - ...... //业务流程 + //业务流程...... bytrace.finishTrace("myTestFunc", 1); //第一个追踪的任务结束 - ...... //业务流程 + //业务流程...... bytrace.startTrace("myTestFunc", 1); //第二个追踪的同名任务开始,同名的待追踪任务串行执行。 - ...... //业务流程 + //业务流程...... bytrace.finishTrace("myTestFunc", 1); ``` @@ -101,7 +101,7 @@ traceByValue(name: string, value: number): void ``` let traceCount = 3; bytrace.traceByValue("myTestCount", traceCount); - ...... - traceCount = 5; + traceCount = 4; bytrace.traceByValue("myTestCount", traceCount); + //业务流程...... ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-dataAbilityHelper.md b/zh-cn/application-dev/reference/apis/js-apis-dataAbilityHelper.md index 2434d3505b9cfb72172e3b0f0883c1ea94715fa4..faacbf73949124197205b3cf50bf22e81e840dca 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-dataAbilityHelper.md +++ b/zh-cn/application-dev/reference/apis/js-apis-dataAbilityHelper.md @@ -1,35 +1,6 @@ -### DataAbilityHelper模块(JS端SDK接口) - -#### 支持设备 - -| API | 手机 | 平板 | 智慧屏 | 智能穿戴 | 轻量级智能穿戴 | 智慧视觉设备 | -| ------------------------------------------------------------ | ---- | ---- | ------ | -------- | -------------- | ------------ | -| DataAbilityHelper.openFile(uri: string, mode: string, callback: AsyncCallback\) | 支持 | 支持 | 支持 | 支持 | 不支持 | 不支持 | -| DataAbilityHelper.openFile(uri: string, mode: string) | 支持 | 支持 | 支持 | 支持 | 不支持 | 不支持 | -| DataAbilityHelper.on(type: 'dataChange', uri: string, callback: AsyncCallback\) | 支持 | 支持 | 支持 | 支持 | 不支持 | 不支持 | -| DataAbilityHelper.off(type: 'dataChange', uri: string, callback?: AsyncCallback\) | 支持 | 支持 | 支持 | 支持 | 不支持 | 不支持 | -| DataAbilityHelper.getFileTypes(uri: string, mimeTypeFilter: string, callback: AsyncCallback>) | 支持 | 支持 | 支持 | 支持 | 不支持 | 不支持 | -| DataAbilityHelper.getFileTypes(uri: string, mimeTypeFilter: string) | 支持 | 支持 | 支持 | 支持 | 不支持 | 不支持 | -| DataAbilityHelper.getType(uri: string, callback: AsyncCallback\) | 支持 | 支持 | 支持 | 支持 | 不支持 | 不支持 | -| DataAbilityHelper.getType(uri: string) | 支持 | 支持 | 支持 | 支持 | 不支持 | 不支持 | -| DataAbilityHelper.normalizeUri(uri: string, callback: AsyncCallback\) | 支持 | 支持 | 支持 | 支持 | 不支持 | 不支持 | -| DataAbilityHelper.normalizeUri(uri: string) | 支持 | 支持 | 支持 | 支持 | 不支持 | 不支持 | -| DataAbilityHelper.denormalizeUri(uri: string, callback: AsyncCallback\) | 支持 | 支持 | 支持 | 支持 | 不支持 | 不支持 | -| DataAbilityHelper.denormalizeUri(uri: string) | 支持 | 支持 | 支持 | 支持 | 不支持 | 不支持 | -| DataAbilityHelper.notifyChange(uri: string, callback: AsyncCallback\) | 支持 | 支持 | 支持 | 支持 | 不支持 | 不支持 | -| DataAbilityHelper.notifyChange(uri: string) | 支持 | 支持 | 支持 | 支持 | 不支持 | 不支持 | -| DataAbilityHelper.insert(uri: string, valuesBucket: rdb.ValuesBucket, callback: AsyncCallback\) | 支持 | 支持 | 支持 | 支持 | 不支持 | 不支持 | -| DataAbilityHelper.insert(uri: string, valuesBucket: rdb.ValuesBucket) | 支持 | 支持 | 支持 | 支持 | 不支持 | 不支持 | -| DataAbilityHelper.batchInsert(uri: string, valuesBuckets: Array, callback: AsyncCallback\) | 支持 | 支持 | 支持 | 支持 | 不支持 | 不支持 | -| DataAbilityHelper.batchInsert(uri: string, valuesBuckets: Array) | 支持 | 支持 | 支持 | 支持 | 不支持 | 不支持 | -| DataAbilityHelper.delete(uri: string, predicates: dataAbility.DataAbilityPredicates, callback: AsyncCallback\) | 支持 | 支持 | 支持 | 支持 | 不支持 | 不支持 | -| DataAbilityHelper.delete(uri: string, predicates: dataAbility.DataAbilityPredicates) | 支持 | 支持 | 支持 | 支持 | 不支持 | 不支持 | -| DataAbilityHelper.update(uri: string, valuesBucket: rdb.ValuesBucket, predicates: dataAbility.DataAbilityPredicates, callback: AsyncCallback\) | 支持 | 支持 | 支持 | 支持 | 不支持 | 不支持 | -| DataAbilityHelper.update(uri: string, valuesBucket: rdb.ValuesBucket, predicates: dataAbility.DataAbilityPredicates) | 支持 | 支持 | 支持 | 支持 | 不支持 | 不支持 | -| DataAbilityHelper.query(uri: string, columns: Array\, predicates: dataAbility.DataAbilityPredicates, callback: AsyncCallback\) | 支持 | 支持 | 支持 | 支持 | 不支持 | 不支持 | -| DataAbilityHelper.query(uri: string, columns: Array\, predicates: dataAbility.DataAbilityPredicates) | 支持 | 支持 | 支持 | 支持 | 不支持 | 不支持 | - -#### 导入模块 +# DataAbilityHelper模块(JS端SDK接口) + +## 导入模块 ``` import featureAbility from '@ohos.ability.featureAbility' @@ -37,26 +8,23 @@ import ohos_data_ability from '@ohos.data.dataability' import ohos_data_rdb from '@ohos.data.rdb' ``` -#### DataAbilityHelper.openFile(uri: string, mode: string, callback: AsyncCallback\) - -- 接口说明 - - 在指定的远程路径中打开文件(callback形式) +## DataAbilityHelper +### openFile -* 参数描述 +openFile(uri: string, mode: string, callback: AsyncCallback\): void - | 名称 | 读写属性 | 类型 | 必填 | 描述 | - | -------- | -------- | -------------------- | ---- | ------------------------ | - | uri | 只读 | string | 是 | 指示要打开的文件的路径。 | - | mode | 只读 | string | 是 | 指示文件打开模式‘rwt’。 | - | callback | 只读 | AsyncCallback\ | 是 | 被指定的回调方法 | +在指定的远程路径中打开文件(callback形式)。 -* 返回值 +**参数:** - 返回文件描述符。 +| 名称 | 类型 | 必填 | 描述 | +| -------- | ---------------------- | ---- | ---------------------------------- | +| uri | string | 是 | 指示要打开的文件的路径。 | +| mode | string | 是 | 指示文件打开模式‘rwt’。 | +| callback | AsyncCallback\ | 是 | 被指定的回调方法,返回文件描述符。 | -* 示例 +**示例:** ```javascript import featureAbility from '@ohos.ability.featureAbility' @@ -72,24 +40,23 @@ DAHelper.openFile( }); ``` -#### DataAbilityHelper.openFile(uri: string, mode: string) - -- 接口说明 - - 在指定的远程路径中打开文件(Promise形式) +### openFile -* 参数描述 +openFile(uri: string, mode: string): Promise\ - | 名称 | 读写属性 | 类型 | 必填 | 描述 | - | ---- | -------- | ------ | ---- | ------------------------ | - | uri | 只读 | string | 是 | 指示要打开的文件的路径。 | - | mode | 只读 | string | 是 | 指示文件打开模式‘rwt’。 | +**参数:** -* 返回值 +| 名称 | 类型 | 必填 | 描述 | +| ---- | ------ | ---- | ------------------------ | +| uri | string | 是 | 指示要打开的文件的路径。 | +| mode | string | 是 | 指示文件打开模式‘rwt’。 | - 返回文件描述符。 +**返回值:** +| 类型 | 说明 | +| ---------------- | ---------------- | +| Promise\ | 返回文件描述符。 | -* 示例 +**示例:** ```javascript import featureAbility from '@ohos.ability.featureAbility' @@ -104,25 +71,21 @@ DAHelper.openFile( }); ``` -#### DataAbilityHelper.on(type: 'dataChange', uri: string, callback: AsyncCallback\) +### on('dataChange') -- 接口说明 +on(type: 'dataChange', uri: string, callback: AsyncCallback\): void - 注册观察者以观察给定uri指定的数据callback通知 +注册观察者以观察给定uri指定的数据callback通知。 -- 参数描述 +**参数:** - | 名称 | 读写属性 | 类型 | 必填 | 描述 | - | -------- | -------- | -------------------- | ---- | ------------------------ | - | type | 只读 | string | 是 | 数据更改。 | - | uri | 只读 | string | 是 | 指示要操作的数据的路径。 | - | callback | 只读 | AsyncCallback\ | 是 | 指示数据更改时的回调。 | +| 名称 | 类型 | 必填 | 描述 | +| -------- | -------------------- | ---- | ------------------------ | +| type | string | 是 | 数据更改。 | +| uri | string | 是 | 指示要操作的数据的路径。 | +| callback | AsyncCallback\ | 是 | 指示数据更改时的回调。 | -- 返回值 - - void - -- 示例 +**示例:** ```js import featureAbility from '@ohos.ability.featureAbility' @@ -139,25 +102,21 @@ helper.on( ) ``` -#### DataAbilityHelper.off(type: 'dataChange', uri: string, callback?: AsyncCallback\) - -- 接口说明 +### off('dataChange') - 注消观察者以停止观察给定uri指定的数据callback通知 +off(type: 'dataChange', uri: string, callback?: AsyncCallback\): void -- 参数描述 +注消观察者以停止观察给定uri指定的数据callback通知。 - | 名称 | 读写属性 | 类型 | 必填 | 描述 | - | -------- | -------- | -------------------- | ---- | ------------------------ | - | type | 只读 | string | 是 | 数据更改。 | - | uri | 只读 | string | 是 | 指示要操作的数据的路径。 | - | callback | 只读 | AsyncCallback\ | 否 | 指示已注册的回调。 | +**参数:** -- 返回值 +| 名称 | 类型 | 必填 | 描述 | +| -------- | -------------------- | ---- | ------------------------ | +| type | string | 是 | 数据更改。 | +| uri | string | 是 | 指示要操作的数据的路径。 | +| callback | AsyncCallback\ | 否 | 指示已注册的回调。 | - void - -- 示例 +**示例:** ```js import featureAbility from '@ohos.ability.featureAbility' @@ -178,24 +137,20 @@ helper.off( ) ``` -#### DataAbilityHelper.getType(uri: string, callback: AsyncCallback\) - -- 接口说明 +### getType - 获取给定URI指定数据的MIME类型(callback形式) +getType(uri: string, callback: AsyncCallback\): void -- 参数描述 +获取给定URI指定数据的MIME类型(callback形式)。 - | 名称 | 读写属性 | 类型 | 必填 | 描述 | - | -------- | -------- | ---------------------- | ---- | ------------------------ | - | uri | 只读 | string | 是 | 指示要操作的数据的路径。 | - | callback | 只读 | AsyncCallback\ | 是 | 回调方法 | +**参数:** -- 返回值 +| 名称 | 类型 | 必填 | 描述 | +| -------- | ---------------------- | ---- | --------------------------------------------- | +| uri | string | 是 | 指示要操作的数据的路径。 | +| callback | AsyncCallback\ | 是 | 回调方法,返回与uri指定的数据匹配的MIME类型。 | - 返回与uri指定的数据匹配的MIME类型。 - -- 示例 +**示例:** ```js import featureAbility from '@ohos.ability.featureAbility' @@ -209,23 +164,24 @@ DAHelper.getType( }); ``` -#### DataAbilityHelper.getType(uri: string) - -- 接口说明 +### getType - 获取给定URI指定数据的MIME类型(Promise形式) +getType(uri: string): Promise\ -- 参数描述 +获取给定URI指定数据的MIME类型(Promise形式)。 - | 名称 | 读写属性 | 类型 | 必填 | 描述 | - | ---- | -------- | ------ | ---- | ------------------------ | - | uri | 只读 | string | 是 | 指示要操作的数据的路径。 | +**参数:** -- 返回值 +| 名称 | 类型 | 必填 | 描述 | +| ---- | ------ | ---- | ------------------------ | +| uri | string | 是 | 指示要操作的数据的路径。 | - 返回与uri指定的数据匹配的MIME类型。 +**返回值:** +| 类型 | 说明 | +| ---------------- | ----------------------------------- | +| Promise\ | 返回与uri指定的数据匹配的MIME类型。 | -- 示例 +**示例:** ```js import featureAbility from '@ohos.ability.featureAbility' @@ -239,25 +195,21 @@ DAHelper.getType( }); ``` -#### DataAbilityHelper.getFileTypes(uri: string, mimeTypeFilter: string, callback: AsyncCallback>) - -- 接口说明 +### getFileTypes - 获取支持的文件的MIME类型(callback形式) +getFileTypes(uri: string, mimeTypeFilter: string, callback: AsyncCallback>): void -- 参数描述 +获取支持的文件的MIME类型(callback形式)。 - | 名称 | 读写属性 | 类型 | 必填 | 描述 | - | -------------- | -------- | ------------------------------ | ---- | ---------------------------- | - | uri | 只读 | string | 是 | 指示要获取的文件的路径。 | - | mimeTypeFilter | 只读 | string | 是 | 指示要获取的文件的MIME类型。 | - | callback | 只读 | AsyncCallback\> | 是 | 回调方法 | +**参数:** -- 返回值 +| 名称 | 类型 | 必填 | 描述 | +| -------------- | ------------------------------ | ---- | ---------------------------------- | +| uri | string | 是 | 指示要获取的文件的路径。 | +| mimeTypeFilter | string | 是 | 指示要获取的文件的MIME类型。 | +| callback | AsyncCallback\> | 是 | 回调方法,返回匹配的MIME类型数组。 | - 返回匹配的MIME类型数组。 - -- 示例 +**示例:** ```js import featureAbility from '@ohos.ability.featureAbility' @@ -272,24 +224,27 @@ DAHelper.getFileTypes( }); ``` -#### DataAbilityHelper.getFileTypes(uri: string, mimeTypeFilter: string) -- 接口说明 - 获取支持的文件的MIME类型(Promise形式) +### getFileTypes + +getFileTypes(uri: string, mimeTypeFilter: string): Promise\> -- 参数描述 +获取支持的文件的MIME类型(Promise形式)。 - | 名称 | 读写属性 | 类型 | 必填 | 描述 | - | -------------- | -------- | ------ | ---- | ---------------------------- | - | uri | 只读 | string | 是 | 指示要获取的文件的路径。 | - | mimeTypeFilter | 只读 | string | 是 | 指示要获取的文件的MIME类型。 | +**参数:** -- 返回值 +| 名称 | 类型 | 必填 | 描述 | +| -------------- | ------ | ---- | ---------------------------- | +| uri | string | 是 | 指示要获取的文件的路径。 | +| mimeTypeFilter | string | 是 | 指示要获取的文件的MIME类型。 | - 返回匹配的MIME类型数组。 +**返回值:** +| 类型 | 说明 | +| ------------------------ | ------------------------ | +| Promise\> | 返回匹配的MIME类型数组。 | -- 示例 +**示例:** ```js import featureAbility from '@ohos.ability.featureAbility' @@ -304,24 +259,20 @@ DAHelper.getFileTypes( }); ``` -#### DataAbilityHelper.normalizeUri(uri: string, callback: AsyncCallback\) +### normalizeUri -- 接口说明 +normalizeUri(uri: string, callback: AsyncCallback\): void - 将引用数据功能的给定uri转换为规范化uri(callback形式) +将引用数据功能的给定uri转换为规范化uri(callback形式)。 -- 参数描述 +**参数:** - | 名称 | 读写属性 | 类型 | 必填 | 描述 | - | -------- | -------- | ---------------------- | ---- | ----------------------- | - | uri | 只读 | string | 是 | 指示要规范化的uri对象。 | - | callback | 只读 | AsyncCallback\ | 是 | 回调方法 | +| 名称 | 类型 | 必填 | 描述 | +| -------- | ---------------------- | ---- | ------------------------------------------------------------ | +| uri | string | 是 | 指示要规范化的uri对象。 | +| callback | AsyncCallback\ | 是 | 回调方法。如果数据功能支持uri规范化或null,则返回规范化uri对象。 | -- 返回值 - - 如果数据功能支持uri规范化或null,则返回规范化uri对象。 - -- 示例 +**示例:** ```js import featureAbility from '@ohos.ability.featureAbility' @@ -335,23 +286,24 @@ DAHelper.normalizeUri( }); ``` -#### DataAbilityHelper.normalizeUri(uri: string) - -- 接口说明 +### normalizeUri - 将引用数据功能的给定uri转换为规范化uri(Promise形式) +normalizeUri(uri: string): Promise\ -- 参数描述 +将引用数据功能的给定uri转换为规范化uri(Promise形式)。 - | 名称 | 读写属性 | 类型 | 必填 | 描述 | - | ---- | -------- | ------ | ---- | ----------------------- | - | uri | 只读 | string | 是 | 指示要规范化的uri对象。 | +**参数:** -- 返回值 +| 名称 | 类型 | 必填 | 描述 | +| ---- | ------ | ---- | ----------------------- | +| uri | string | 是 | 指示要规范化的uri对象。 | - 如果数据功能支持uri规范化或null,则返回规范化uri对象。 +**返回值:** +| 类型 | 说明 | +| ---------------- | ------------------------------------------------------ | +| Promise\ | 如果数据功能支持uri规范化或null,则返回规范化uri对象。 | -- 示例 +**示例:** ```js import featureAbility from '@ohos.ability.featureAbility' @@ -365,24 +317,20 @@ DAHelper.normalizeUri( }); ``` -#### DataAbilityHelper.denormalizeUri(uri: string, callback: AsyncCallback\) - -- 接口说明 - - 将由normalizeUri(uri)生成的给定规范化uri转换为非规范化uri(callback形式) +### denormalizeUri -- 参数描述 +denormalizeUri(uri: string, callback: AsyncCallback\): void - | 名称 | 读写属性 | 类型 | 必填 | 描述 | - | -------- | -------- | ---------------------- | ---- | ----------------------- | - | uri | 只读 | string | 是 | 指示要规范化的uri对象。 | - | callback | 只读 | AsyncCallback\ | 是 | 回调方法 | +将由normalizeUri(uri)生成的给定规范化uri转换为非规范化uri(callback形式)。 -- 返回值 +**参数:** - 如果反规范化成功,则返回反规范化uri对象。 +| 名称 | 类型 | 必填 | 描述 | +| -------- | ---------------------- | ---- | --------------------------------------------------- | +| uri | string | 是 | 指示要规范化的uri对象。 | +| callback | AsyncCallback\ | 是 | 回调方法。如果反规范化成功,则返回反规范化uri对象。 | -- 示例 +**示例:** ```js import featureAbility from '@ohos.ability.featureAbility' @@ -396,23 +344,26 @@ DAHelper.denormalizeUri( }); ``` -#### DataAbilityHelper.denormalizeUri(uri: string) -- 接口说明 - 将由normalizeUri(uri)生成的给定规范化uri转换为非规范化uri(Promise形式) +### denormalizeUri -- 参数描述 +denormalizeUri(uri: string): Promise\ - | 名称 | 读写属性 | 类型 | 必填 | 描述 | - | ---- | -------- | ------ | ---- | ----------------------- | - | uri | 只读 | string | 是 | 指示要规范化的uri对象。 | +将由normalizeUri(uri)生成的给定规范化uri转换为非规范化uri(Promise形式)。 -- 返回值 +**参数:** - 如果反规范化成功,则返回反规范化uri对象。 +| 名称 | 类型 | 必填 | 描述 | +| ---- | ------ | ---- | ----------------------- | +| uri | string | 是 | 指示要规范化的uri对象。 | -- 示例 +**返回值:** +| 类型 | 说明 | +| ---------------- | ----------------------------------------- | +| Promise\ | 如果反规范化成功,则返回反规范化uri对象。 | + +**示例:** ```js import featureAbility from '@ohos.ability.featureAbility' @@ -426,24 +377,20 @@ DAHelper.denormalizeUri( }); ``` -#### DataAbilityHelper.notifyChange(uri: string, callback: AsyncCallback\) - -- 接口说明 - - 通知已注册的观察者uri指定的数据资源的更改(callback形式) +### notifyChange -- 参数描述 +notifyChange(uri: string, callback: AsyncCallback\): void - | 名称 | 读写属性 | 类型 | 必填 | 描述 | - | -------- | -------- | -------------------- | ---- | ------------------------ | - | uri | 只读 | string | 是 | 指示要操作的数据的路径。 | - | callback | 只读 | AsyncCallback\ | 是 | 回调方法 | +通知已注册的观察者uri指定的数据资源的更改(callback形式)。 -- 返回值 +**参数:** - void +| 名称 | 类型 | 必填 | 描述 | +| -------- | -------------------- | ---- | ------------------------ | +| uri | string | 是 | 指示要操作的数据的路径。 | +| callback | AsyncCallback\ | 是 | 回调方法。 | -- 示例 +**示例:** ```js import featureAbility from '@ohos.ability.featureAbility' @@ -457,23 +404,24 @@ helper.notifyChange( }); ``` -#### DataAbilityHelper.notifyChange(uri: string) +### notifyChange -- 接口说明 +notifyChange(uri: string): Promise\ - 通知已注册的观察者uri指定的数据资源的更改(Promise形式) +通知已注册的观察者uri指定的数据资源的更改(Promise形式)。 -- 参数描述 +**参数:** - | 名称 | 读写属性 | 类型 | 必填 | 描述 | - | ---- | -------- | ------ | ---- | ------------------------ | - | uri | 只读 | string | 是 | 指示要操作的数据的路径。 | +| 名称 | 类型 | 必填 | 描述 | +| ---- | ------ | ---- | ------------------------ | +| uri | string | 是 | 指示要操作的数据的路径。 | -- 返回值 +**返回值:** +| 类型 | 说明 | +| -------------- | --------------------- | +| Promise\ | 返回值为Promise对象。 | - void - -- 示例 +**示例:** ```js import featureAbility from '@ohos.ability.featureAbility' @@ -487,25 +435,21 @@ DAHelper.notifyChange( }); ``` -#### DataAbilityHelper.insert(uri: string, valuesBucket: rdb.ValuesBucket, callback: AsyncCallback\) - -- 接口说明 +### insert - 将单个数据记录插入数据库(callback形式) +insert(uri: string, valuesBucket: rdb.ValuesBucket, callback: AsyncCallback\): void -- 参数描述 +将单个数据记录插入数据库(callback形式)。 - | 名称 | 读写属性 | 类型 | 必填 | 描述 | - | ------------ | -------- | ---------------------- | ---- | ------------------------------------------------------ | - | uri | 只读 | string | 是 | 指示要插入的数据的路径。 | - | valuesBucket | 只读 | rdb.ValuesBucket | 是 | 指示要插入的数据记录。如果此参数为空,将插入一个空行。 | - | callback | 只读 | AsyncCallback\ | 是 | 回调方法 | +**参数:** -- 返回值 +| 名称 | 类型 | 必填 | 描述 | +| ------------ | ---------------------- | ---- | ------------------------------------------------------ | +| uri | string | 是 | 指示要插入的数据的路径。 | +| valuesBucket | rdb.ValuesBucket | 是 | 指示要插入的数据记录。如果此参数为空,将插入一个空行。 | +| callback | AsyncCallback\ | 是 | 回调方法,返回插入数据记录的索引。 | - 返回插入数据记录的索引。 - -- 示例 +**示例:** ```js import featureAbility from '@ohos.ability.featureAbility' @@ -526,24 +470,25 @@ DAHelper.insert( }); ``` -#### DataAbilityHelper.insert(uri: string, valuesBucket: rdb.ValuesBucket) - -- 接口说明 +### insert - 将单个数据记录插入数据库(Promise形式) +insert(uri: string, valuesBucket: rdb.ValuesBucket): Promise\ -- 参数描述 +将单个数据记录插入数据库(Promise形式)。 - | 名称 | 读写属性 | 类型 | 必填 | 描述 | - | ------------ | -------- | ---------------- | ---- | ------------------------------------------------------ | - | uri | 只读 | string | 是 | 指示要插入的数据的路径。 | - | valuesBucket | 只读 | rdb.ValuesBucket | 是 | 指示要插入的数据记录。如果此参数为空,将插入一个空行。 | +**参数:** -- 返回值 +| 名称 | 类型 | 必填 | 描述 | +| ------------ | ---------------- | ---- | ------------------------------------------------------ | +| uri | string | 是 | 指示要插入的数据的路径。 | +| valuesBucket | rdb.ValuesBucket | 是 | 指示要插入的数据记录。如果此参数为空,将插入一个空行。 | - 返回插入数据记录的索引。 +**返回值:** +| 类型 | 说明 | +| ---------------- | ------------------------ | +| Promise\ | 返回插入数据记录的索引。 | -- 示例 +**示例:** ```js import featureAbility from '@ohos.ability.featureAbility' @@ -564,25 +509,21 @@ DAHelper.insert( }); ``` -#### DataAbilityHelper.batchInsert(uri: string, valuesBuckets: Array, callback: AsyncCallback\) - -- 接口说明 +### batchInsert - 将多个数据记录插入数据库(callback形式) +batchInsert(uri: string, valuesBuckets: Array, callback: AsyncCallback\): void -- 参数描述 +插入数据库(callback形式)。 - | 名称 | 读写属性 | 类型 | 必填 | 描述 | - | ------------ | -------- | ----------------------- | ---- | ------------------------ | - | uri | 只读 | string | 是 | 指示要插入的数据的路径。 | - | valuesBucket | 只读 | Array | 是 | 指示要插入的数据记录。 | - | callback | 只读 | AsyncCallback\ | 是 | 回调方法 | +**参数:** -- 返回值 +| 名称 | 类型 | 必填 | 描述 | +| ------------ | ----------------------- | ---- | -------------------------------- | +| uri | string | 是 | 指示要插入的数据的路径。 | +| valuesBucket | Array | 是 | 指示要插入的数据记录。 | +| callback | AsyncCallback\ | 是 | 回调方法。返回插入的数据记录数。 | - 返回插入的数据记录数。 - -- 示例 +**示例:** ```js import featureAbility from '@ohos.ability.featureAbility' @@ -600,24 +541,25 @@ DAHelper.batchInsert( }); ``` -#### DataAbilityHelper.batchInsert(uri: string, valuesBuckets: Array) - -- 接口说明 +### batchInsert - 将多个数据记录插入数据库(Promise形式) +batchInsert(uri: string, valuesBuckets: Array): Promise\ -- 参数描述 +将多个数据记录插入数据库(Promise形式)。 - | 名称 | 读写属性 | 类型 | 必填 | 描述 | - | ------------ | -------- | ----------------------- | ---- | ------------------------ | - | uri | 只读 | string | 是 | 指示要插入的数据的路径。 | - | valuesBucket | 只读 | Array | 是 | 指示要插入的数据记录。 | +**参数:** -- 返回值 +| 名称 | 类型 | 必填 | 描述 | +| ------------ | ----------------------- | ---- | ------------------------ | +| uri | string | 是 | 指示要插入的数据的路径。 | +| valuesBucket | Array | 是 | 指示要插入的数据记录。 | - 返回插入的数据记录数。 +**返回值:** +| 类型 | 说明 | +| ---------------- | ---------------------- | +| Promise\ | 返回插入的数据记录数。 | -- 示例 +**示例:** ```js import featureAbility from '@ohos.ability.featureAbility' @@ -635,25 +577,21 @@ DAHelper.batchInsert( }); ``` -#### DataAbilityHelper.delete(uri: string, predicates: dataAbility.DataAbilityPredicates, callback: AsyncCallback\) +### delete -- 接口说明 +delete(uri: string, predicates: dataAbility.DataAbilityPredicates, callback: AsyncCallback\): void - 从数据库中删除一个或多个数据记录(callback形式) +从数据库中删除一个或多个数据记录(callback形式)。 -- 参数描述 +**参数:** - | 名称 | 读写属性 | 类型 | 必填 | 描述 | - | ------------ | -------- | --------------------------------- | ---- | ------------------------------------------------ | - | uri | 只读 | string | 是 | 指示要删除的数据的路径。 | - | valuesBucket | 只读 | dataAbility.DataAbilityPredicates | 是 | 指示筛选条件。当此参数为null时,应定义处理逻辑。 | - | callback | 只读 | AsyncCallback\ | 是 | 回调方法 | +| 名称 | 类型 | 必填 | 描述 | +| ------------ | --------------------------------- | ---- | ------------------------------------------------ | +| uri | string | 是 | 指示要删除的数据的路径。 | +| valuesBucket | dataAbility.DataAbilityPredicates | 是 | 指示筛选条件。当此参数为null时,应定义处理逻辑。 | +| callback | AsyncCallback\ | 是 | 回调方法。返回已删除的数据记录数。 | -- 返回值 - - 返回已删除的数据记录数。 - -- 示例 +**示例:** ```js import featureAbility from '@ohos.ability.featureAbility' @@ -670,24 +608,25 @@ DAHelper.delete( }); ``` -#### DataAbilityHelper.delete(uri: string, predicates: dataAbility.DataAbilityPredicates) - -- 接口说明 +### delete - 从数据库中删除一个或多个数据记录(Promise形式) +delete(uri: string, predicates: dataAbility.DataAbilityPredicates): Promise\ -- 参数描述 +从数据库中删除一个或多个数据记录(Promise形式)。 - | 名称 | 读写属性 | 类型 | 必填 | 描述 | - | ------------ | -------- | --------------------------------- | ---- | ------------------------------------------------ | - | uri | 只读 | string | 是 | 指示要删除的数据的路径。 | - | valuesBucket | 只读 | dataAbility.DataAbilityPredicates | 是 | 指示筛选条件。当此参数为null时,应定义处理逻辑。 | +**参数:** -- 返回值 +| 名称 | 类型 | 必填 | 描述 | +| ------------ | --------------------------------- | ---- | ------------------------------------------------ | +| uri | string | 是 | 指示要删除的数据的路径。 | +| valuesBucket | dataAbility.DataAbilityPredicates | 是 | 指示筛选条件。当此参数为null时,应定义处理逻辑。 | - 返回已删除的数据记录数。 +**返回值:** +| 类型 | 说明 | +| ---------------- | ------------------------ | +| Promise\ | 返回已删除的数据记录数。 | -- 示例 +**示例:** ```js import featureAbility from '@ohos.ability.featureAbility' @@ -703,26 +642,22 @@ DAHelper.delete( }); ``` -#### DataAbilityHelper.update(uri: string, valuesBucket: rdb.ValuesBucket, predicates: dataAbility.DataAbilityPredicates, callback: AsyncCallback\) - -- 接口说明 - - 更新数据库中的数据记录(callback形式) +### update -- 参数描述 +update(uri: string, valuesBucket: rdb.ValuesBucket, predicates: dataAbility.DataAbilityPredicates, callback: AsyncCallback\): void - | 名称 | 读写属性 | 类型 | 必填 | 描述 | - | ------------ | -------- | --------------------------------- | ---- | ------------------------------------------------ | - | uri | 只读 | string | 是 | 指示要更新的数据的路径。 | - | valuesBucket | 只读 | rdb.ValuesBucket | 是 | 指示要更新的数据。 | - | predicates | 只读 | dataAbility.DataAbilityPredicates | 是 | 指示筛选条件。当此参数为null时,应定义处理逻辑。 | - | callback | 只读 | AsyncCallback\ | 是 | 回调方法 | +更新数据库中的数据记录(callback形式)。 -- 返回值 +**参数:** - 返回更新的数据记录数。 +| 名称 | 类型 | 必填 | 描述 | +| ------------ | --------------------------------- | ---- | ------------------------------------------------ | +| uri | string | 是 | 指示要更新的数据的路径。 | +| valuesBucket | rdb.ValuesBucket | 是 | 指示要更新的数据。 | +| predicates | dataAbility.DataAbilityPredicates | 是 | 指示筛选条件。当此参数为null时,应定义处理逻辑。 | +| callback | AsyncCallback\ | 是 | 回调方法,返回更新的数据记录数。 | -- 示例 +**示例:** ```js import featureAbility from '@ohos.ability.featureAbility' @@ -746,25 +681,26 @@ DAHelper.update( }); ``` -#### DataAbilityHelper.update(uri: string, valuesBucket: rdb.ValuesBucket, predicates: dataAbility.DataAbilityPredicates) +### update -- 接口说明 +update(uri: string, valuesBucket: rdb.ValuesBucket, predicates: dataAbility.DataAbilityPredicates): Promise\ - 更新数据库中的数据记录(Promise形式) +更新数据库中的数据记录(Promise形式)。 -- 参数描述 +**参数:** - | 名称 | 读写属性 | 类型 | 必填 | 描述 | - | ------------ | -------- | --------------------------------- | ---- | ------------------------------------------------ | - | uri | 只读 | string | 是 | 指示要更新的数据的路径。 | - | valuesBucket | 只读 | rdb.ValuesBucket | 是 | 指示要更新的数据。 | - | predicates | 只读 | dataAbility.DataAbilityPredicates | 是 | 指示筛选条件。当此参数为null时,应定义处理逻辑。 | +| 名称 | 类型 | 必填 | 描述 | +| ------------ | --------------------------------- | ---- | ------------------------------------------------ | +| uri | string | 是 | 指示要更新的数据的路径。 | +| valuesBucket | rdb.ValuesBucket | 是 | 指示要更新的数据。 | +| predicates | dataAbility.DataAbilityPredicates | 是 | 指示筛选条件。当此参数为null时,应定义处理逻辑。 | -- 返回值 +**返回值:** +| 类型 | 说明 | +| ---------------- | -------------------------------------------- | +| Promise\ | 返回值为Promise对象,Promise中包含应用信息。 | - 返回更新的数据记录数。 - -- 示例 +**示例:** ```js import featureAbility from '@ohos.ability.featureAbility' @@ -788,26 +724,22 @@ DAHelper.update( }); ``` -#### DataAbilityHelper.query(uri: string, columns: Array\, predicates: dataAbility.DataAbilityPredicates, callback: AsyncCallback\) - -- 接口说明 +### query - 查询数据库中的数据(callback形式) +query(uri: string, columns: Array\, predicates: dataAbility.DataAbilityPredicates, callback: AsyncCallback\): void -- 参数描述 +查询数据库中的数据(callback形式)。 - | 名称 | 读写属性 | 类型 | 必填 | 描述 | - | ---------- | -------- | --------------------------------- | ---- | ------------------------------------------------ | - | uri | 只读 | string | 是 | 指示要查询的数据的路径。 | - | columns | 只读 | rdb.ValuesBucket | 是 | 指示要查询的列。如果此参数为空,则查询所有列。 | - | predicates | 只读 | dataAbility.DataAbilityPredicates | 是 | 指示筛选条件。当此参数为null时,应定义处理逻辑。 | - | callback | 只读 | AsyncCallback\ | 是 | 回调方法 | +**参数:** -- 返回值 +| 名称 | 类型 | 必填 | 描述 | +| ---------- | --------------------------------- | ---- | ------------------------------------------------ | +| uri | string | 是 | 指示要查询的数据的路径。 | +| columns | rdb.ValuesBucket | 是 | 指示要查询的列。如果此参数为空,则查询所有列。 | +| predicates | dataAbility.DataAbilityPredicates | 是 | 指示筛选条件。当此参数为null时,应定义处理逻辑。 | +| callback | AsyncCallback\ | 是 | 回调方法,返回查询结果。 | - 返回查询结果 - -- 示例 +**示例:** ```js import featureAbility from '@ohos.ability.featureAbility' @@ -828,25 +760,26 @@ DAHelper.query( -#### DataAbilityHelper.query(uri: string, columns: Array\, predicates: dataAbility.DataAbilityPredicates) - -- 接口说明 +### query - 查询数据库中的数据(Promise形式) +query(uri: string, columns: Array\, predicates: dataAbility.DataAbilityPredicates): Promise\ -- 参数描述 +查询数据库中的数据(Promise形式)。 - | 名称 | 读写属性 | 类型 | 必填 | 描述 | - | ---------- | -------- | --------------------------------- | ---- | ------------------------------------------------ | - | uri | 读写 | string | 是 | 指示要查询的数据的路径。 | - | columns | 读写 | rdb.ValuesBucket | 是 | 指示要查询的列。如果此参数为空,则查询所有列。 | - | predicates | 读写 | dataAbility.DataAbilityPredicates | 是 | 指示筛选条件。当此参数为null时,应定义处理逻辑。 | +**参数:** -- 返回值 +| 名称 | 类型 | 必填 | 描述 | +| ---------- | --------------------------------- | ---- | ------------------------------------------------ | +| uri | string | 是 | 指示要查询的数据的路径。 | +| columns | rdb.ValuesBucket | 是 | 指示要查询的列。如果此参数为空,则查询所有列。 | +| predicates | dataAbility.DataAbilityPredicates | 是 | 指示筛选条件。当此参数为null时,应定义处理逻辑。 | - 返回查询结果 +**返回值:** +| 类型 | 说明 | +| ------------------- | -------------- | +| Promise\ | 返回查询结果。 | -- 示例 +**示例:** ```js import featureAbility from '@ohos.ability.featureAbility' diff --git a/zh-cn/application-dev/reference/apis/js-apis-fileio.md b/zh-cn/application-dev/reference/apis/js-apis-fileio.md index 6045ecd2e205fbe56bc27aee8a0321aa4901585b..f868fc0ef78fb7bc0034a9e49a0f73b864603e8b 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-fileio.md +++ b/zh-cn/application-dev/reference/apis/js-apis-fileio.md @@ -2031,14 +2031,14 @@ lchownSync(path: string, uid: number, gid: number): void createWatcher(filename: string, events: number, callback: AsyncCallback<number>): Watcher -以异步方法监控文件或者目录的变化,使用callback形式返回结果。 +以异步方法监听文件或者目录的变化,使用callback形式返回结果。 - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | filename | string | 是 | 待监视文件的绝对路径。 | - | events | Number | 是 | - 1: 监控文件或者目录是否发生重命名。
    - 2:监控文件或者目录内容的是否修改。
    - 3:两者都有。 | - | callback | AsyncCallback<number > | 是 | 每监控发生变化一次,调用一次此函数。 | + | events | Number | 是 | - 1: 监听文件或者目录是否发生重命名。
    - 2:监听文件或者目录内容的是否修改。
    - 3:两者都有。 | + | callback | AsyncCallback<number > | 是 | 每发生变化一次,调用一次此函数。 | - 返回值: | 参数名 | 说明 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-intl.md b/zh-cn/application-dev/reference/apis/js-apis-intl.md index 3bd8821cb190423c1ac5ec8c4cd4cd23b308a973..acc6e97ba97a8415fa81580c2ea9a2aae6c96f79 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-intl.md +++ b/zh-cn/application-dev/reference/apis/js-apis-intl.md @@ -51,7 +51,7 @@ constructor(locale: string, options?: options) - 示例: ``` - var locale = new Intl.Locale("zh-CN", { numeric: true }); + var locale = new Intl.Locale("zh-CN"); ``` @@ -405,7 +405,7 @@ compare(first: string, second: string): number - 示例: ``` - var collator = new intl.Collator("zh-Hans"); + var collator = new Intl.Collator("zh-Hans"); collator.compare("first", "second"); ``` @@ -423,7 +423,7 @@ resolvedOptions(): CollatorOptions - 示例: ``` - var collator = new intl.Collator("zh-Hans"); + var collator = new Intl.Collator("zh-Hans"); var options = collator.resolvedOptions(); ``` @@ -494,7 +494,7 @@ select(n: number): string - 示例: ``` - var pluralRules = new intl.PluralRules("zh-Hans"); + var pluralRules = new Intl.PluralRules("zh-Hans"); pluralRules.select(1); ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-update.md b/zh-cn/application-dev/reference/apis/js-apis-update.md index c1845759c88716b69468ffac22f6233e98e2c521..5feefbea31a92d598e99f36abbce3a2e3c7f7fd7 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-update.md +++ b/zh-cn/application-dev/reference/apis/js-apis-update.md @@ -10,13 +10,104 @@ ## 导入模块 ```js -import client from '@ohos.update' +import update from '@ohos.update' ``` ## 权限列表 无 +## 获取升级对象Updater + +### update.getUpdater + +getUpdater(upgradeFile: string, updateType?: UpdateTypes): Updater + +获取本地升级Updater。 + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ----------- | --------------------------- | ---- | -------- | +| upgradeFile | string | 是 | 升级文件 | +| updateType | [UpdateTypes](#updatetypes) | 是 | 升级类型 | + +**返回值:** + +| 类型 | 说明 | +| ------------------- | -------- | +| [Updater](#updater) | 升级对象 | + +**示例:** + +``` +try { + let updater = update.getUpdater('/data/updater/updater.zip', 'OTA'); +} catch(error) { + console.error(" Fail to get updater error: " + error); +} +``` + +### update.getUpdaterForOther + +getUpdaterForOther(upgradeFile: string, device: string, updateType?: UpdateTypes): Updater + +获取升级对象给待升级设备。 + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ----------- | --------------------------- | ---- | ---------- | +| upgradeFile | string | 是 | 升级文件 | +| device | string | 是 | 待升级设备 | +| updateType | [UpdateTypes](#updatetypes) | 是 | 升级类型 | + +**返回值:** + +| 类型 | 说明 | +| ------------------- | -------- | +| [Updater](#updater) | 升级对象 | + +**示例:** + +``` +try { + let updater = update.getUpdaterForOther('/data/updater/updater.zip', '1234567890', 'OTA'); +} catch(error) { + console.error(" Fail to get updater error: " + error); +} +``` + +### update.getUpdaterFromOther + +getUpdaterFromOther(upgradeFile: string, device: string, updateType?: UpdateTypes): Updater + +获取其它设备为本设备升级的Updater。 + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ----------- | --------------------------- | ---- | ---------- | +| upgradeFile | string | 是 | 升级文件 | +| device | string | 是 | 待升级设备 | +| updateType | [UpdateTypes](#updatetypes) | 是 | 升级类型 | + +**返回值:** + +| 类型 | 说明 | +| ------------------- | -------- | +| [Updater](#updater) | 升级对象 | + +**示例:** + +``` +try { + let updater = update.getUpdaterFromOther('/data/updater/updater.zip', '1234567890', 'OTA'); +} catch(error) { + console.error(" Fail to get updater error: " + error); +} +``` + ## Updater ### getNewVersionInfo @@ -34,12 +125,12 @@ getNewVersionInfo(callback: AsyncCallback\): void **示例:** ``` -updater.getNewVersionInfo(info => { +update.getNewVersionInfo(info => { console.log("getNewVersionInfo success " + info.status); console.log(`info versionName = ` + info.result[0].versionName); console.log(`info versionCode = ` + info.result[0].versionCode); console.log(`info verifyInfo = ` + info.result[0].verifyInfo); -)}; +}); ``` ### getNewVersionInfo @@ -57,14 +148,13 @@ getNewVersionInfo(): Promise\ **示例:** ``` -var p = updater.getNewVersionInfo(); -p.then(function (value) { +updater.getNewVersionInfo().then(value => { console.log(`info versionName = ` + value.result[0].versionName); console.log(`info versionCode = ` + value.result[0].versionCode); console.log(`info verifyInfo = ` + value.result[0].verifyInfo); -}).catch(function (err) { +}).catch(err => { console.log("getNewVersionInfo promise error: " + err.code); -)}; +}); ``` ### checkNewVersion @@ -82,12 +172,12 @@ checkNewVersion(callback: AsyncCallback\): void **示例:** ``` -updater.checkNewVersion(info => { +update.checkNewVersion(info => { console.log("checkNewVersion success " + info.status); console.log(`info versionName = ` + info.result[0].versionName); console.log(`info versionCode = ` + info.result[0].versionCode); console.log(`info verifyInfo = ` + info.result[0].verifyInfo); -)}; +}); ``` ### checkNewVersion @@ -105,14 +195,13 @@ checkNewVersion(): Promise\ **示例:** ``` -var p = updater.checkNewVersion(); -p.then(function (value) { +update.checkNewVersion().then(value => { console.log(`info versionName = ` + value.result[0].versionName); console.log(`info versionCode = ` + value.result[0].versionCode); console.log(`info verifyInfo = ` + value.result[0].verifyInfo); -}).catch(function (err) { +}).catch(err => { console.log("checkNewVersion promise error: " + err.code); -)}; +}); ``` ### verifyUpdatePackage @@ -131,12 +220,10 @@ verifyUpdatePackage(upgradeFile: string, certsFile: string): void **示例:** ``` -var getVar = update.getUpdater(); -getVar.on("verifyProgress", function (callback){ - console.info('on verifyProgress ' + callback.percent); +update.on("verifyProgress", callback => { + console.info('on verifyProgress ' + callback.percent); }); -getVar.verifyUpdatePackage("XXX", "XXX"); -getVar.off("verifyProgress"); +update.verifyUpdatePackage("XXX", "XXX"); ``` ### rebootAndCleanUserData @@ -154,12 +241,10 @@ rebootAndCleanUserData(): Promise\ **示例:** ``` -var getVar = update.getUpdater(); -p = getVar.rebootAndCleanUserData(); -p.then(function (value) { - console.info("rebootAndCleanUserData promise success: " + value); -}).catch(function (err) { - console.info("rebootAndCleanUserData promise error: " + err.code); +update.rebootAndCleanUserData().then(result => { + console.log("rebootAndCleanUserData " + result); +}).catch(err => { + console.info("rebootAndCleanUserData promise error: " + err.code); }); ``` @@ -178,13 +263,8 @@ rebootAndCleanUserData(callback: AsyncCallback\): void **示例:** ``` -var getVar = update.getUpdater(); -getVar.rebootAndCleanUserData(function (err, data) { - if (err.code == 0) { - console.info("rebootAndCleanUserData callback success:" + data) - } else { - console.info("rebootAndCleanUserData callback err:" + err.code) - } +update.rebootAndCleanUserData(result => { + console.log("rebootAndCleanUserData ", result) }); ``` @@ -203,10 +283,9 @@ applyNewVersion(): Promise\ **示例:** ``` -var getVar = update.getUpdater(); -p.then(function (value) { - console.info("applyNewVersion promise success: " + value); -}).catch(function (err) { +update.applyNewVersion().then(result => { + console.log("appVewVersion ", result) +}).catch(err => { console.info("applyNewVersion promise error: " + err.code); }); ``` @@ -226,13 +305,8 @@ applyNewVersion(callback: AsyncCallback\): void **示例:** ``` -var getVar = update.getUpdater(); -getVar.applyNewVersion(function (err, data) { - if (err.code == 0) { - console.info("applyNewVersion callback success:" + data) - } else { - console.info("applyNewVersion callback err:" + err.code) - } +update.applyNewVersion(result => { + console.log("applyNewVersion ", result) }); ``` @@ -249,7 +323,7 @@ updater.on("downloadProgress", progress => { console.log("downloadProgress on" + progress); console.log(`downloadProgress status: ` + progress.status); console.log(`downloadProgress percent: ` + progress.percent); -)}; +}); updater.download(); ``` @@ -266,7 +340,7 @@ updater.on("upgradeProgress", progress => { console.log("upgradeProgress on" + progress); console.log(`upgradeProgress status: ` + progress.status); console.log(`upgradeProgress percent: ` + progress.percent); -)}; +}); updater.upgrade(); ``` @@ -288,14 +362,15 @@ setUpdatePolicy(policy: UpdatePolicy, callback: AsyncCallback\): void ``` // 设置策略 let policy = { -autoDownload: false, -autoDownloadNet: true, -mode: 2, -autoUpgradeInterval: [ 2, 3 ], -autoUpgradeCondition: 2 + autoDownload: false, + autoDownloadNet: true, + mode: 2, + autoUpgradeInterval: [ 2, 3 ], + autoUpgradeCondition: 2 } -updater.setUpdatePolicy(policy, function(result) { -console.log("setUpdatePolicy ", result)}); +update.setUpdatePolicy(policy, result => { + console.log("setUpdatePolicy ", result) +}); ``` ### setUpdatePolicy @@ -320,16 +395,17 @@ setUpdatePolicy(policy: UpdatePolicy): Promise\ ``` let policy = { -autoDownload: false, -autoDownloadNet: true, -mode: 2, -autoUpgradeInterval: [ 2, 3 ], -autoUpgradeCondition: 2 + autoDownload: false, + autoDownloadNet: true, + mode: 2, + autoUpgradeInterval: [ 2, 3 ], + autoUpgradeCondition: 2 } -updater.setUpdatePolicy(policy) -.then(data=> -console.log('set policy success') -) +update.setUpdatePolicy(policy).then(result => + console.log("setUpdatePolicy ", result) +).catch(err => { + console.log("setUpdatePolicy promise error: " + err.code); +}); ``` ### getUpdatePolicy @@ -347,12 +423,12 @@ getUpdatePolicy(callback: AsyncCallback\): void **示例:** ``` -updater.getUpdatePolicy(policy => { +update.getUpdatePolicy(policy => { console.log("getUpdatePolicy success"); console.log(`policy autoDownload = ` + policy.autoDownload); console.log(`policy autoDownloadNet = ` + policy.autoDownloadNet); console.log(`policy mode = ` + policy.mode); -)}; +}); ``` ### getUpdatePolicy @@ -370,103 +446,13 @@ getUpdatePolicy(): Promise\ **示例:** ``` -p = updater.getUpdatePolicy(); -p.then(function (value) { +update.getUpdatePolicy().then(value => { console.log(`info autoDownload = ` + value.autoDownload); console.log(`info autoDownloadNet = ` + value.autoDownloadNet); console.log(`info mode = ` + value.mode); -}).catch(function (err) { +}).catch(err => { console.log("getUpdatePolicy promise error: " + err.code); -)}; -``` - -## update.getUpdater - -getUpdater(upgradeFile: string, updateType?: UpdateTypes): Updater - -获取本地升级Updater。 - -**参数:** - -| 参数名 | 类型 | 必填 | 说明 | -| ----------- | --------------------------- | ---- | -------- | -| upgradeFile | string | 是 | 升级文件 | -| updateType | [UpdateTypes](#updatetypes) | 是 | 升级类型 | - -**返回值:** - -| 类型 | 说明 | -| ------------------- | -------- | -| [Updater](#updater) | 升级对象 | - -**示例:** - -``` -try { - page.data.updater = update.getUpdater('/data/updater/updater.zip', 'OTA'); -} catch(error) { - console.error(" Fail to get updater error: " + error); -} -``` - -## update.getUpdaterForOther - -getUpdaterForOther(upgradeFile: string, device: string, updateType?: UpdateTypes): Updater - -获取升级对象给待升级设备。 - -**参数:** - -| 参数名 | 类型 | 必填 | 说明 | -| ----------- | --------------------------- | ---- | ---------- | -| upgradeFile | string | 是 | 升级文件 | -| device | string | 是 | 待升级设备 | -| updateType | [UpdateTypes](#updatetypes) | 是 | 升级类型 | - -**返回值:** - -| 类型 | 说明 | -| ------------------- | -------- | -| [Updater](#updater) | 升级对象 | - -**示例:** - -``` -try { - page.data.updater = update.getUpdaterForOther('/data/updater/updater.zip', '1234567890', 'OTA'); -} catch(error) { - console.error(" Fail to get updater error: " + error); -} -``` - -## update.getUpdaterFromOther - -getUpdaterFromOther(upgradeFile: string, device: string, updateType?: UpdateTypes): Updater - -获取其它设备为本设备升级的Updater。 - -**参数:** - -| 参数名 | 类型 | 必填 | 说明 | -| ----------- | --------------------------- | ---- | ---------- | -| upgradeFile | string | 是 | 升级文件 | -| device | string | 是 | 待升级设备 | -| updateType | [UpdateTypes](#updatetypes) | 是 | 升级类型 | - -**返回值:** - -| 类型 | 说明 | -| ------------------- | -------- | -| [Updater](#updater) | 升级对象 | - -**示例:** - -``` -try { - page.data.updater = update.getUpdaterFromOther('/data/updater/updater.zip', '1234567890', 'OTA'); -} catch(error) { - console.error(" Fail to get updater error: " + error); -} +}); ``` ## UpdateTypes diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-common-transition.md b/zh-cn/application-dev/reference/arkui-js/js-components-common-transition.md index 79e69a10709c3e76fb8e710b944060e5504f5f87..d7582ada79c53a9f195112517f7559d58a2f1a77 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-common-transition.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-common-transition.md @@ -92,12 +92,14 @@ PageA跳转到PageB,跳转的共享元素为image, shareid为“shareImage
    - - - - Click on picture to Jump to ths details - - + + +
    + + Click on picture to Jump to ths details +
    +
    +
    ``` diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-matrix-transformation.md b/zh-cn/application-dev/reference/arkui-ts/ts-matrix-transformation.md index ed935c811ddf45b854ad2dcdade70c34231d5682..0e22e0f7fc73f6bc3ac331f6961497ba89175f39 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-matrix-transformation.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-matrix-transformation.md @@ -6,7 +6,7 @@ ## 导入模块 ``` -import matrix4 from '@ohos.matrix4' +import Matrix4 from '@ohos.matrix4' ``` ## 权限列表 @@ -228,7 +228,6 @@ Matrix的构造函数,可以通过传入的参数创建一个四阶矩阵, - 示例 ``` - import Matrix4 from '@ohos.matrix4' // 创建一个四阶矩阵 let matrix = Matrix4.init([1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, @@ -263,8 +262,7 @@ Matrix的初始化函数,可以返回一个单位矩阵对象。 ``` // matrix1 和 matrix2 效果一致 - import Matrix4 from '@ohos.matrix4' - let matrix = Matrix4.init([1.0, 0.0, 0.0, 0.0, + let matrix1 = Matrix4.init([1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0]) @@ -297,7 +295,6 @@ Matrix的拷贝函数,可以拷贝一份当前的矩阵对象。 - 示例 ``` - import Matrix4 from '@ohos.matrix4' @Entry @Component struct Test { @@ -318,8 +315,8 @@ Matrix的拷贝函数,可以拷贝一份当前的矩阵对象。 } } ``` - - ![](figures/s1.png) + +![](figures/s1.png) ## Matrix4 @@ -377,7 +374,6 @@ Matrix的叠加函数,可以将两个矩阵的效果叠加起来生成一个 - 示例 ``` - import Matrix4 from '@ohos.matrix4' @Entry @Component struct Test { @@ -394,8 +390,8 @@ Matrix的叠加函数,可以将两个矩阵的效果叠加起来生成一个 } } ``` - - ![](figures/q1.png) + +![](figures/q1.png) ### invert @@ -423,7 +419,6 @@ Matrix的逆函数,可以返回一个当前矩阵对象的逆矩阵,即效 - 示例 ``` - import Matrix4 from '@ohos.matrix4' // matrix1(宽放大2倍) 和 matrix2(宽缩小2倍) 效果相反 let matrix1 = Matrix4.identity().scale({x:2}) let matrix2 = matrix1.invert() @@ -506,7 +501,6 @@ Matrix的平移函数,可以为当前矩阵增加x轴/Y轴/Z轴平移效果。 - 示例 ``` - import Matrix4 from '@ohos.matrix4' @Entry @Component struct Test { @@ -520,8 +514,8 @@ Matrix的平移函数,可以为当前矩阵增加x轴/Y轴/Z轴平移效果。 } } ``` - - ![](figures/s3.png) + +![](figures/s3.png) ### scale @@ -622,7 +616,6 @@ Matrix的缩放函数,可以为当前矩阵增加x轴/Y轴/Z轴缩放效果。 - 示例 ``` - import Matrix4 from '@ohos.matrix4' @Entry @Component struct Test { @@ -636,8 +629,8 @@ Matrix的缩放函数,可以为当前矩阵增加x轴/Y轴/Z轴缩放效果。 } } ``` - - ![](figures/s4-(1).png) + +![](figures/s4-(1).png) ### rotate @@ -749,7 +742,6 @@ Matrix的旋转函数,可以为当前矩阵增加x轴/Y轴/Z轴旋转效果。 - 示例 ``` - import Matrix4 from '@ohos.matrix4' @Entry @Component struct Test { @@ -763,8 +755,8 @@ Matrix的旋转函数,可以为当前矩阵增加x轴/Y轴/Z轴旋转效果。 } } ``` - - ![](figures/1.png) + +![](figures/1.png) ### transformPoint @@ -821,7 +813,6 @@ Matrix的坐标点转换函数,可以将当前的变换效果作用到一个 - 示例 ``` - import Matrix4 from '@ohos.matrix4' import prompt from '@system.prompt' @Entry @@ -838,7 +829,6 @@ Matrix的坐标点转换函数,可以将当前的变换效果作用到一个 } } ``` - - ![](figures/222.gif) - + +![](figures/222.gif) diff --git a/zh-cn/application-dev/ui/Readme-CN.md b/zh-cn/application-dev/ui/Readme-CN.md index c1686c318ea05527f66e614c8ecf6c987afea460..046740653d8b7b921f1d0527455555e88e5e8d42 100755 --- a/zh-cn/application-dev/ui/Readme-CN.md +++ b/zh-cn/application-dev/ui/Readme-CN.md @@ -84,11 +84,9 @@ - [@Prop](ts-component-states-prop.md) - [@Link](ts-component-states-link.md) - 管理应用程序的状态 - - 接口 - - [应用程序的数据存储](ts-application-states-appstorage.md) - - [持久化数据管理](ts-application-states-apis-persistentstorage.md) - - [环境变量](ts-application-states-apis-environment.md) - - [AppStorage与组件同步](ts-application-states-storagelink-storageprop.md) + - [应用程序的数据存储](ts-application-states-appstorage.md) + - [持久化数据管理](ts-application-states-apis-persistentstorage.md) + - [环境变量](ts-application-states-apis-environment.md) - 其他类目的状态管理 - [Observed和ObjectLink数据管理](ts-other-states-observed-objectlink.md) - [@Consume和@Provide数据管理](ts-other-states-consume-provide.md) @@ -102,13 +100,7 @@ - [自定义组件初始化](ts-custom-component-initialization.md) - [自定义组件生命周期回调函数](ts-custom-component-lifecycle-callbacks.md) - [组件创建和重新初始化示例](ts-component-creation-re-initialization.md) - - 语法糖 - - [装饰器](ts-syntactic-sugar-decorator.md) - - [链式调用](ts-syntactic-sugar-chaining.md) - - [struct对象](ts-syntactic-sugar-struct.md) - - [在实例化过程中省略"new"](ts-instantiating-a-struct-without-new-keyword.md) - - [组件创建使用独立一行](ts-using-a-separate-line-for-new-component.md) - - [生成器函数内使用TS语言的限制](ts-restrictions-for-generators.md) + - [语法糖](ts-syntactic-sugar.md) - 体验声明式UI - [创建声明式UI工程](ui-ts-creating-project.md) - [初识Component](ui-ts-components.md) diff --git a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001214948035.png b/zh-cn/application-dev/ui/figures/CoreSpec_figures_state-mgmt-overview.png similarity index 100% rename from zh-cn/application-dev/ui/figures/zh-cn_image_0000001214948035.png rename to zh-cn/application-dev/ui/figures/CoreSpec_figures_state-mgmt-overview.png diff --git a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001206450834.png b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001206450834.png new file mode 100644 index 0000000000000000000000000000000000000000..d2e430e8d79689719c884bdab96c0da4e0be2a4d Binary files /dev/null and b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001206450834.png differ diff --git a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001251090821.png b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001251090821.png new file mode 100644 index 0000000000000000000000000000000000000000..44f42f4dea3de06ad2252079616d61595dd5674e Binary files /dev/null and b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001251090821.png differ diff --git a/zh-cn/application-dev/ui/js-framework-syntax-js.md b/zh-cn/application-dev/ui/js-framework-syntax-js.md index e2e07bd29a6c7564765f8e98b0523a3f809b2fd9..ed3b8c30913e680cb7898fb360c76c9a516dfaab 100644 --- a/zh-cn/application-dev/ui/js-framework-syntax-js.md +++ b/zh-cn/application-dev/ui/js-framework-syntax-js.md @@ -35,10 +35,10 @@ JS文件用来定义HML页面的业务逻辑,支持ECMA规范的JavaScript语 // app.js export default { onCreate() { - console.info('AceApplication onCreate'); + console.info('Application onCreate'); }, onDestroy() { - console.info('AceApplication onDestroy'); + console.info('Application onDestroy'); }, globalData: { appData: 'appData', diff --git a/zh-cn/application-dev/ui/ts-a-deep-dive-into-component.md b/zh-cn/application-dev/ui/ts-a-deep-dive-into-component.md index 960cd294dff35dd8802e79a0a68826b619e4278d..da2f9bf87f951ed5f7601ab5842aab6b2e5109ac 100644 --- a/zh-cn/application-dev/ui/ts-a-deep-dive-into-component.md +++ b/zh-cn/application-dev/ui/ts-a-deep-dive-into-component.md @@ -1,11 +1,11 @@ -# 深入理解组件化 +# 深入理解组件化 +- **[build函数](ts-function-build.md)** +- **[自定义组件成员变量初始化](ts-custom-component-initialization.md)** -- **[build函数](ts-function-build.md)** +- **[自定义组件生命周期回调函数](ts-custom-component-lifecycle-callbacks.md)** -- **[自定义组件初始化](ts-custom-component-initialization.md)** +- **[组件创建和重新初始化示例](ts-component-creation-re-initialization.md)** -- **[自定义组件生命周期回调函数](ts-custom-component-lifecycle-callbacks.md)** -- **[组件创建和重新初始化示例](ts-component-creation-re-initialization.md)** \ No newline at end of file diff --git a/zh-cn/application-dev/ui/ts-application-states-apis-environment.md b/zh-cn/application-dev/ui/ts-application-states-apis-environment.md index 8ca4c6c2b6ae81587582899c90865012ac92b31a..a1c08ac5a070d3c30f498f990e754a0f8e3d5075 100644 --- a/zh-cn/application-dev/ui/ts-application-states-apis-environment.md +++ b/zh-cn/application-dev/ui/ts-application-states-apis-environment.md @@ -1,36 +1,115 @@ -# 环境变量 - -**Environment**是框架在应用程序启动时创建的单例对象,它为**AppStorage**提供了一系列应用程序需要的环境状态属性,这些属性描述了应用程序运行的设备环境。**Environment**及其属性是不可变的,所有属性值类型均为简单类型。 - - -如下示例展示了从**Environment**获取语音环境: +# 环境变量 +**Environment**是框架在应用程序启动时创建的单例对象,它为**AppStorage**提供了一系列应用程序需要的环境状态属性,这些属性描述了应用程序运行的设备环境。**Environment**及其属性是不可变的,所有属性值类型均为简单类型。如下示例展示了从**Environment**获取语音环境: ``` Environment.EnvProp("accessibilityEnabled", "default"); var enable = AppStorageGet("accessibilityEnabled"); ``` +**accessibilityEnabled**是**Environment**提供默认系统变量识别符。首先需要将对应系统属性绑定到**Appstorage**中,再通过AppStorage中的方法或者装饰器访问对应系统的属性数据。 -**accessibilityEnabled**是**Environment**提供默认系统变量识别符。首先需要将对应系统属性绑定到**Appstorage**中,后可以通过AppStorage中的方法或者装饰器,访问对应系统属性数据。 - - -## Environment接口 - -| **key** | 参数 | 返回值 | **说明** | -| -------- | -------- | -------- | -------- | -| EnvProp | key : string
    defaultValue: any | boolean | 关联此系统项到Appstorage中。建议在app启动时使用此Api。如果此属性在Appstorage已经存在则返回false。请勿使用AppStorage中的变量,在调用此方法关联环境变量。 | -| EnvProps | keys: {
    key: string,
    defaultValue: any
    }[] | void | 关联此系统项数组到Appstorage中。 | -| Keys | Array<string> | number | 返回关联的系统项。 | +## Environment接口 + + + + + + + + + + + + + + + + + + + + + + + +

    key

    +

    参数

    +

    返回值

    +

    说明

    +

    EnvProp

    +

    key: string,

    +

    defaultValue: any

    +

    boolean

    +

    关联此系统项到Appstorage中,建议在app启动时使用此接口。如果该属性在Appstorage已存在,返回false。请勿使用AppStorage中的变量,在调用此方法关联环境变量。

    +

    EnvProps

    +

    keys: {

    +

    key: string,

    +

    defaultValue: any

    +

    }[]

    +

    void

    +

    关联此系统项数组到Appstorage中。

    +

    Keys

    +

    Array<string>

    +

    number

    +

    返回关联的系统项。

    +
    -## Environment内置的环境变量 +## Environment内置的环境变量 -| **key** | **类型** | **说明** | -| -------- | -------- | -------- | -| accessibilityEnabled | boolean | 无障碍屏幕朗读是否启用。 | -| colorMode | ColorMode | 深浅色模式,选项值为:
    - ColorMode.LIGHT:浅色模式;
    - ColorMode.DARK:深色模式。 | -| fontScale | number | 字体大小比例,范围为:[0.85, 1.45]。 | -| fontWeightScale | number | 字体权重比例,取值范围:[0.6, 1.6]。 | -| layoutDirection | LayoutDirection | 布局方向类型,可选值为:
    - LayoutDirection.LTR:从左到右;
    - LayoutDirection.RTL:从右到左。 | -| languageCode | string | 当前系统语言值,小写字母,例如zh。 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

    key

    +

    类型

    +

    说明

    +

    accessibilityEnabled

    +

    boolean

    +

    无障碍屏幕朗读是否启用。

    +

    colorMode

    +

    ColorMode

    +

    深浅色模式,可选值为:

    +
    • ColorMode.LIGHT:浅色模式;
    • ColorMode.DARK:深色模式。
    +

    fontScale

    +

    number

    +

    字体大小比例,取值范围为[0.85, 1.45]。

    +

    fontWeightScale

    +

    number

    +

    字体权重比例,取值范围为[0.6, 1.6]。

    +

    layoutDirection

    +

    LayoutDirection

    +

    布局方向类型,可选值为:

    +
    • LayoutDirection.LTR:从左到右;
    • LayoutDirection.RTL:从右到左。
    +

    languageCode

    +

    string

    +

    设置当前系统的语言,小写字母,例如zh。

    +
    diff --git a/zh-cn/application-dev/ui/ts-application-states-apis-persistentstorage.md b/zh-cn/application-dev/ui/ts-application-states-apis-persistentstorage.md index 70a6771bff6cde0146cb0221d983acf8e4d5f856..3e5d3a64da050e39696fb23b3eb39f5ce34ec041 100644 --- a/zh-cn/application-dev/ui/ts-application-states-apis-persistentstorage.md +++ b/zh-cn/application-dev/ui/ts-application-states-apis-persistentstorage.md @@ -1,22 +1,66 @@ -# 持久化数据管理 +# 持久化数据管理 -**PersistentStorage**用于管理应用持久化数据。此对象可以将特定标记的持久化数据链接到AppStorage中,并由AppStorage接口访问对应持久化数据,或者通过@StorageLink修饰器来访问对应key的变量。 +方舟开发框架通过**PersistentStorage**类提供了一些静态方法用来管理应用持久化数据,可以将特定标记的持久化数据链接到AppStorage中,并由AppStorage接口访问对应持久化数据,或者通过@StorageLink装饰器来访问对应key的变量。 + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

    方法

    +

    参数说明

    +

    返回值

    +

    定义

    +

    PersistProp

    +

    key : string

    +

    defaultValue: T

    +

    void

    +

    关联命名的属性在AppStorage变为持久化数据,赋值覆盖顺序如下:

    +
    • 首先,如果该属性存在于AppStorage,将Persistent中的数据复写为AppStorage中的属性值。
    • 其次,Persistent中有此命名的属性,使用Persistent中的属性值。
    +
    • 最后,以上条件均不满足,则使用defaultValue,不支持null和undefined。
    +

    DeleteProp

    +

    key: string

    +

    void

    +

    取消双向数据绑定,该属性值将从持久存储中删除。

    +

    PersistProps

    +

    keys: {

    +

    key: string,

    +

    defaultValue: any

    +

    }[]

    +

    void

    +

    关联多个命名的属性绑定。

    +

    Keys

    +

    void

    +

    Array<string>

    +

    返回所有持久化属性的标记。

    +
    -## PersistentStorage接口 - -| 方法 | 参数说明 | 返回值 | 定义 | -| -------- | -------- | -------- | -------- | -| PersistProp | key : string
    defaultValue: T | void | 关联命名的属性在AppStorage变为持久化数据。赋值覆盖顺序
    首先 如果此属性在AppStorage中存在,并且将Persistent中的数据复写为AppStorage中的属性值。
    其次Persistent中有此命名的属性,使用Persistent中的属性值。
    最后 以上条件不满足使用defaultValue,不支持null和undefined。 | -| DeleteProp | key: string | void | 取消双向数据绑定,该属性值将从持久存储中删除。 | -| PersistProps | keys: {
    key: string,
    defaultValue: any
    }[] | void | 关联多个命名的属性绑定。 | -| Keys | void | Array<string> | 返回所有持久化属性的标记。 | - -> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> - PersistProp接口使用时,需要保证输入对应的key应当在Appstorage存在。 -> -> - DeleteProp接口使用时,只能对本次启动已经link过的数据生效。 - +>![](../../public_sys-resources/icon-note.gif) **说明:** +>- PersistProp接口使用时,需要保证输入对应的key应当在Appstorage存在。 +>- DeleteProp接口使用时,只能对本次启动已经link过的数据生效。 ``` PersistentStorage.PersistProp("highScore", "0"); @@ -44,3 +88,4 @@ struct PersistentComponent { } } ``` + diff --git a/zh-cn/application-dev/ui/ts-application-states-appstorage.md b/zh-cn/application-dev/ui/ts-application-states-appstorage.md index bc818d03e8f74c17e12c00ae5eb74527f6eb980d..2f7c5a200c9b34c55d13001e88591ad36369e418 100644 --- a/zh-cn/application-dev/ui/ts-application-states-appstorage.md +++ b/zh-cn/application-dev/ui/ts-application-states-appstorage.md @@ -1,44 +1,198 @@ -# 应用程序的数据存储 +# 应用程序的数据存储 -**AppStorage**是应用程序中的单例对象,由UI框架在应用程序启动时创建。它的目的是为可变应用程序状态属性提供中央存储。**AppStorage**包含整个应用程序中需要访问的所有状态属性。只要应用程序保持运行,**AppStorage**存储就会保留所有属性及其值,属性值可以通过唯一的键值进行访问。 +**AppStorage**是应用程序中的单例对象,由UI框架在应用程序启动时创建,在应用程序退出退出时销毁,为应用程序范围内的可变状态属性提供中央存储。**AppStorage**包含整个应用程序中需要访问的所有状态属性,只要应用程序保持运行,**AppStorage**就会保存所有属性及属性值,属性值可以通过唯一的键值进行访问。 +UI组件可以通过装饰器将应用程序状态数据与**AppStorage**进行同步,应用业务逻辑的实现也可以通过接口访问**AppStorage**。 -UI组件可以通过装饰器将应用程序状态数据与**AppStorage**进行同步。应用业务逻辑的实现也可以通过接口访问**AppStorage**。 +**AppStorage**的选择状态属性可以与不同的数据源或数据接收器同步,这些数据源和接收器可以是设备上的本地或远程,并具有不同的功能,如数据持久性。这样的数据源和接收器可以独立于UI在业务逻辑中实现。 +默认情况下,**AppStorage**中的属性是可变的,**AppStorage**还可使用不可变(只读)属性。 -AppStorage的选择状态属性可以与不同的数据源或数据接收器同步。这些数据源和接收器可以是设备上的本地或远程,并具有不同的功能,如数据持久性。这样的数据源和接收器可以独立于UI在业务逻辑中实现。 +## AppStorage接口 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

    方法

    +

    参数说明

    +

    返回值

    +

    定义

    +

    SetAndLink

    +

    key: string,

    +

    defaultValue: T

    +

    @Link

    +

    与Link接口类似,如果当前的key保存于AppStorage,则返回该key对应的value。如果该key未被创建,则创建一个对应default值的Link返回。

    +

    Set

    +

    key: string,

    +

    newValue: T

    +

    void

    +

    对已保存的key值,替换其value值。

    +

    Link

    +

    key: string

    +

    @Link

    +

    如果存在具有给定键的数据,则返回到此属性的双向数据绑定,该双向绑定意味着变量或者组件对数据的更改将同步到AppStorage,通过AppStorage对数据的修改将同步到变量或者组件。如果具有此键的属性不存在或属性为只读,则返回undefined

    +

    SetAndProp

    +

    propName: string,

    +

    defaultValue: S

    +

    @Prop

    +

    与Prop接口类似,如果当前的key保存于AppStorage,则返回该key对应的value。如果该key未被创建,则创建一个对应default值的Prop返回。

    +

    Prop

    +

    key: string

    +

    @Prop

    +

    如果存在具有给定键的属性,则返回此属性的单向数据绑定。该单向绑定意味着只能通过AppStorage将属性的更改同步到变量或者组件。该方法返回的变量为不可变变量,适用于可变和不可变的状态属性,如果具有此键的属性不存在则返回undefined

    +
    说明:

    prop方法对应的属性值类型为简单类型。

    +
    +

    SetOrCreate

    +

    key: string,

    +

    newValue: T

    +

    boolean

    +

    如果相同名字的属性存在:如果此属性可以被更改返回true,否则返回false。

    +

    如果相同名字的属性不存在:创建第一个赋值为defaultValue的属性,不支持null和undefined。

    +

    Get

    +

    key: string

    +

    T或undefined

    +

    通过此接口获取对应key值的value。

    +

    Has

    +

    propName: string

    +

    boolean

    +

    判断对应键值的属性是否存在

    +

    Keys

    +

    void

    +

    array<string>

    +

    返回包含所有键的字符串数组。

    +

    Delete

    +

    key: string

    +

    boolean

    +

    删除key指定的键值对,如果存在且删除成功返回true,不存在或删除失败返回false。

    +

    Clear

    +

    void

    +

    boolean

    +

    删除所有的属性,如果当前有状态变量依旧引用此属性,则返回false。

    +

    IsMutable

    +

    key: string

    +

    boolean

    +

    返回此属性是否存在并且是否可以改变。

    +
    -默认情况下,**AppStorage**中的属性是可变的,**AppStorage**还可使用不可变(只读)属性。 +>![](../../public_sys-resources/icon-note.gif) **说明:** +>当前接口当前仅可以处理基础类型数据,对于修改object中某一个值尚未支持。 + +## AppStorage与组件同步 +在[管理组件拥有的状态](ts-component-states-state.md)中,已经定义了如何将组件的状态变量与父组件或祖先组件中的**@State**装饰的状态变量同步,主要包括**@Prop**、**@Link**、**@Consume**。 -## AppStorage接口说明 +本章节将定义如何将组件变量与**AppStorage**同步,主要提供**@StorageLink**和**@StorageProp**装饰器。 -| 方法 | 参数说明 | 返回值 | 定义 | -| -------- | -------- | -------- | -------- | -| Link | key: string | \@Link | 如果存在具有给定键的数据,则返回到此属性的双向数据绑定,该双向绑定意味着变量或者组件对数据的更改将同步到**AppStorage**,通过**AppStorage**对数据的修改将同步到变量或者组件。如果具有此键的属性不存在或属性为只读,则返回**undefined**。 | -| SetAndLink | key : String
    defaultValue: T | \@Link | 与Link接口类似。如果当前的key在AppStorage有保存,则返回此key对应的value。如果此key未被创建,则创建一个对应default值的Link返回。 | -| Prop | key: string | \@Prop | 如果存在具有给定键的属性,则返回到此属性的单向数据绑定。该单向绑定意味着只能通过**AppStorage**将属性的更改同步到变量或者组件。该方法返回的变量为不可变变量,适用于可变和不可变的状态属性,如果具有此键的属性不存在则返回**undefined**。
    > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
    > prop方法对应的属性值类型为简单类型。 | -| SetAndProp | key : string
    defaultValue: S | \@Prop | 与Prop接口类似。如果当前的key在AppStorage有保存,则返回此key对应的value。如果此key未被创建,则创建一个对应default值的Prop返回。 | -| Has | key: string | boolean | 判断对应键值的属性是否存在。 | -| Keys | void | array<string> | 返回包含所有键的字符串数组。 | -| Get | string | T或undefined | 通过此接口获取对应此key值的value | -| Set | string,  newValue :T | void | 对已保存的key值,替换其value值。 | -| SetOrCreate | string,  newValue :T | boolean | 如果相同名字的属性存在:如果此属性可以被更改返回true,否则返回false
    如果相同名字的属性不存在:创建第一个赋值为defaultValue的属性,不支持null和undefined | -| Delete | key : string | boolean | 删除属性,如果存在返回true,不存在返回false | -| Clear | none | boolean | 删除所有的属性,如果当前有状态变量依旧引用此属性,则返回false | -| IsMutable | key: string | | 返回此属性是否存在并且是否可以改变。 | +### @StorageLink装饰器 -> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> 当前接口当前仅可以处理基础类型数据,对于修改object中某一个值尚未支持。 +组件通过使用**@StorageLink\(key\)**装饰的状态变量,与**AppStorage**建立双向数据绑定,**key**为**AppStorage**中的属性键值。当创建包含**@StorageLink**的状态变量的组件时,该状态变量的值将使用**AppStorage**中的值进行初始化。在UI组件中对**@StorageLink**的状态变量所做的更改将同步到**AppStorage**,并从**AppStorage**同步到任何其他绑定实例中,如**PersistentStorage**或其他绑定的UI组件。 +### @StorageProp装饰器 -## 示例 +组件通过使用**@StorageProp\(key\)**装饰的状态变量,将与**AppStorage**建立单向数据绑定,**key**标识AppStorage中的属性键值。当创建包含**@StoageProp**的状态变量的组件时,该状态变量的值将使用**AppStorage**中的值进行初始化。**AppStorage**中的属性值的更改会导致绑定的UI组件进行状态更新。 + +## 示例 ``` -let link1 = AppStorage.Link('PropA')let link2 = AppStorage.Link('PropA')let prop = AppStorage.Prop('PropA') +let varA = AppStorage.Link('varA') +let envLang = AppStorage.Prop('languageCode') + +@Entry +@Component +struct ComponentA { + @StorageLink('varA') varA: number = 2 + @StorageProp('languageCode') lang: string = 'en' + private label: string = 'count' -link1 = 47 // causes link1 == link2 == prop == 47 -link2 = link1 + prop // causes link1 == link2 == prop == 94 -prop = 1 // error, prop is immutable + private aboutToAppear() { + this.label = (this.lang === 'zh') ? '数' : 'Count' + } + + build() { + Row({ space: 20 }) { + + Button(`${this.label}: ${this.varA}`) + .onClick(() => { + AppStorage.Set('varA', AppStorage.Get('varA') + 1) + }) + Button(`lang: ${this.lang}`) + .onClick(() => { + if (this.lang === 'zh') { + AppStorage.Set('languageCode', 'en') + } else { + AppStorage.Set('languageCode', 'zh') + } + this.label = (this.lang === 'zh') ? '数' : 'Count' + }) + } + } +} ``` + +每次开发者单击Count按钮时,this.varA变量值都会增加,此变量与AppStorage中的varA同步。每次用户单击当前语言按钮时,修改AppStorage中的languageCode,此修改会同步给this.lang变量。 + diff --git a/zh-cn/application-dev/ui/ts-attribution-configuration.md b/zh-cn/application-dev/ui/ts-attribution-configuration.md index 1a7bd99b60c95f75c2f524305c079d9cf472eaae..0f7546ecaeeea2e7c2e03ae33eff8c1d65aaed4d 100644 --- a/zh-cn/application-dev/ui/ts-attribution-configuration.md +++ b/zh-cn/application-dev/ui/ts-attribution-configuration.md @@ -1,55 +1,44 @@ -# 属性配置 +# 属性配置 +使用属性方法配置组件的属性,属性方法紧随组件,并用“**.**”运算符连接。 +- 配置**Text**组件的字体大小属性: -使用属性方法配置组件的属性。属性方法紧随组件,并用“**.**”运算符连接。 + ``` + Text('123') + .fontSize(12) + ``` -配置**Text**组件的字体大小属性示例: +- 使用“**.**”操作进行链式调用并同时配置组件的多个属性,如下所示: + ``` + Image('a.jpg') + .alt('error.jpg') + .width(100) + .height(100) + ``` -``` -Text('123') - .fontSize(12) -``` +- 除了直接传递常量参数外,还可以传递变量或表达式,如下所示: -此外,您还可以使用“**.**”操作进行链式调用并同时配置组件的多个属性。 + ``` + // Size, count, and offset are private variables defined in the component. + Text('hello') + .fontSize(this.size) + Image('a.jpg') + .width(this.count % 2 === 0 ? 100 : 200) + .height(this.offset + 100) + ``` -您可以同时配置**Image**组件的多个属性,如下所示: +- 对于内置组件,框架还为其属性预定义了一些枚举类型,供开发人员调用,枚举值可以作为参数传递。枚举类型必须满足参数类型要求,有关特定属性的枚举类型定义的详细信息。可以按以下方式配置**Text**组件的颜色和字重属性: + ``` + Text('hello') + .fontSize(20) + .fontColor(Color.Red) + .fontWeight(FontWeight.Bold) + ``` -``` -Image('a.jpg') - .alt('error.jpg') .width(100) .height(100) -``` - -除了直接传递常量参数外,还可以传递变量或表达式,如下所示: - - -``` -// Size, count, and offset are private variables defined in the component. -Text('hello') - .fontSize(this.size) -Image('a.jpg') - .width(this.count % 2 === 0 ? 100 : 200) .height(this.offset + 100) -``` - - -对于内置组件,框架还为其属性预定义了一些枚举类型,供开发人员调用,枚举值可以作为参数传递。 - - -枚举类型必须满足参数类型要求,有关特定属性的枚举类型定义的详细信息。 - - -您可以按以下方式配置**Text**组件的颜色和字重属性: - - -``` -Text('hello') - .fontSize(20) - .fontColor(Color.Red) - .fontWeight(FontWeight.Bold) -``` diff --git a/zh-cn/application-dev/ui/ts-child-component-configuration.md b/zh-cn/application-dev/ui/ts-child-component-configuration.md index 8a55c4c5da317ae980f563dfa1675bab6b72520f..22fd3f45d2aa3eac98fe0abf0fb1841dffdef84f 100644 --- a/zh-cn/application-dev/ui/ts-child-component-configuration.md +++ b/zh-cn/application-dev/ui/ts-child-component-configuration.md @@ -1,13 +1,9 @@ -# 子组件配置 - - - -对于支持子组件配置的组件,例如容器组件,在“**{ ... }**”里为组件添加子组件的UI描述。**Column**、**Row**、**Stack**、**Button**、**Grid**和**List**组件都是容器组件。 +# 子组件配置 +对于支持子组件配置的组件,例如容器组件,在“**\{ ... \}**”里为组件添加子组件的UI描述。**Column**、**Row**、**Stack**、**Button**、**Grid**和**List**组件都是容器组件。 以下是简单的**Column**示例: - ``` Column() { Text('Hello') @@ -19,10 +15,8 @@ Column() { } ``` - 可以嵌套多个子组件: - ``` Column() { Column() { @@ -50,3 +44,4 @@ Column() { } }.alignItems(HorizontalAlign.Center) // center align components inside Column ``` + diff --git a/zh-cn/application-dev/ui/ts-component-based-builder.md b/zh-cn/application-dev/ui/ts-component-based-builder.md index 13eda212ad9e38a8f362518c3cf50d8356ee2d06..5c0b80f3017cf44c64459a7c231bdb4727cf8dfb 100644 --- a/zh-cn/application-dev/ui/ts-component-based-builder.md +++ b/zh-cn/application-dev/ui/ts-component-based-builder.md @@ -1,12 +1,6 @@ -# @Builder - - - -@Builder装饰器定义了一个如何渲染自定义组件的方法。此装饰器提供了一个修饰方法,其目的是和[build函数](../ui/ts-function-build.md)一致。@Builder装饰器装饰的方法的语法规范与build函数也保持一致。 - - -通过@Builder装饰器可以在一个自定义组件内快速生成多个布局内容。 +# @Builder +@Builder装饰的方法用于定义组件的声明式UI描述,在一个自定义组件内快速生成多个布局内容。@Builder装饰方法的功能和语法规范与[build函数](ts-function-build.md)相同。 ``` @Entry @@ -45,3 +39,4 @@ struct CompA { } } ``` + diff --git a/zh-cn/application-dev/ui/ts-component-based-component.md b/zh-cn/application-dev/ui/ts-component-based-component.md index 5c61df4dc74f5d83edf238b3046025b7c96bd601..e16660280a497526d3e2eb6c672938abd1a71a82 100644 --- a/zh-cn/application-dev/ui/ts-component-based-component.md +++ b/zh-cn/application-dev/ui/ts-component-based-component.md @@ -1,40 +1,19 @@ -# @Component +# @Component -**@Component** 装饰的**struct**表示该结构体具有组件化能力,能够成为一个独立的组件,这种类型的组件也称为自定义组件。 +**@Component**装饰的**struct**表示该结构体具有组件化能力,能够成为一个独立的组件,这种类型的组件也称为自定义组件,在**build**方法里描述UI结构。自定义组件具有以下特点: +- **可组合:**允许开发人员组合使用内置组件、其他组件、公共属性和方法; +- **可重用:**自定义组件可以被其他组件重用,并作为不同的实例在不同的父组件或容器中使用; +- **生命周期:**生命周期的回调方法可以在组件中配置,用于业务逻辑处理; +- **数据驱动更新:**由状态变量的数据驱动,实现UI自动更新。 -该组件可以组合其他组件,它通过实现**build**方法来描述UI结构,其必须符合**Builder**的接口约束,该接口定义如下: +对组件化的深入描述,请参考[深入理解组件化](ts-a-deep-dive-into-component.md)。 +>![](../../public_sys-resources/icon-note.gif) **说明:** +>- 自定义组件必须定义build方法。 +>- 自定义组件禁止自定义构造函数。 -``` -interface Builder { - build: () => void -} -``` - - -用户定义的组件具有以下特点: - - -- **可组合**:允许开发人员组合使用内置组件和其他组件,以及公共属性和方法; - -- **可重用**:可以被其他组件重用,并作为不同的实例在不同的父组件或容器中使用; - -- **有生命周期**:生命周期的回调方法可以在组件中配置,用于业务逻辑处理; - -- **数据驱动更新**:可以由状态数据驱动,实现UI自动更新。 - - -组件生命周期主要包括**aboutToAppear**和**aboutToDisappear**回调函数,有关规范,请参见“[组件生命周期回调函数](../ui/ts-custom-component-lifecycle-callbacks.md)”章节。 - - -> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> - 组件必须遵循上述**Builder**接口约束,其他组件在内部的**build**方法中以声明式方式进行组合,在组件的第一次创建和更新场景中都会调用**build**方法。 -> -> - 组件禁止自定义构造函数。 - - -## 示例 +## 示例 如下代码定义了**MyComponent**组件**:** @@ -67,7 +46,7 @@ struct ParentComponent { } ``` -可以多次嵌入**MyComponent**,并嵌入到不同的组件中进行重用: +可以多次使用**MyComponent**,并在不同的组件中进行重用: ``` @Component @@ -96,3 +75,4 @@ struct ParentComponent { } } ``` + diff --git a/zh-cn/application-dev/ui/ts-component-based-customdialog.md b/zh-cn/application-dev/ui/ts-component-based-customdialog.md index 29047e1ad759ffca2b18954484d845ad3eb29635..7cefbc4f80f1b40cf3e8a713c316f40afc80e2ba 100644 --- a/zh-cn/application-dev/ui/ts-component-based-customdialog.md +++ b/zh-cn/application-dev/ui/ts-component-based-customdialog.md @@ -1,9 +1,6 @@ -# @CustomDialog - - - -**@CustomDialog** 装饰器用于装饰自定义弹窗。 +# @CustomDialog +**@CustomDialog**装饰器用于装饰自定义弹窗。 ``` // custom-dialog-demo.ets @@ -49,3 +46,4 @@ struct CustomDialogUser { } } ``` + diff --git a/zh-cn/application-dev/ui/ts-component-based-entry.md b/zh-cn/application-dev/ui/ts-component-based-entry.md index 42a59ec1b7e82e71035c6987623a0665fce5bd22..b84dd545b39605e2d3e9df53d018592d6243d5e1 100644 --- a/zh-cn/application-dev/ui/ts-component-based-entry.md +++ b/zh-cn/application-dev/ui/ts-component-based-entry.md @@ -1,15 +1,13 @@ -# @Entry +# @Entry -用 **@Entry** 装饰的自定义组件用作页面的默认入口组件,加载页面时,将首先创建并呈现 **@Entry** 装饰的自定义组件。 +用**@Entry**装饰的自定义组件用作页面的默认入口组件,加载页面时,将首先创建并呈现**@Entry**装饰的自定义组件。 +>![](../../public_sys-resources/icon-note.gif) **说明:** +>在单个源文件中,最多可以使用**@Entry**装饰一个自定义组件。 -> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> 在单个源文件中,最多可以使用 **@Entry** 装饰一个自定义组件。 +## 示例 - -## 示例 - -**@Entry** 的用法如下: +**@Entry**的用法如下: ``` // Only MyComponent decorated by @Entry is rendered and displayed. "hello world" is displayed, but "goodbye" is not displayed. @@ -34,3 +32,4 @@ struct HideComponent { } } ``` + diff --git a/zh-cn/application-dev/ui/ts-component-based-extend.md b/zh-cn/application-dev/ui/ts-component-based-extend.md index 5475ffc379a9c34aa143a8ffb76934ba35b472d9..3470ec317be64ad8c259738abf92648ff6df2ff1 100644 --- a/zh-cn/application-dev/ui/ts-component-based-extend.md +++ b/zh-cn/application-dev/ui/ts-component-based-extend.md @@ -1,9 +1,6 @@ -# @Extend - - - -**@Extend** 装饰器将新的属性函数添加到内置组件上,如**Text**、**Column**、**Button**等。通过 **@Extend** 装饰器可以快速定义并复用组件的自定义样式。 +# @Extend +**@Extend**装饰器将新的属性函数添加到内置组件上,如**Text**、**Column**、**Button**等。通过**@Extend**装饰器可以快速定义并复用组件的自定义样式。 ``` @Extend(Text) function fancy(fontSize: number) { @@ -26,6 +23,6 @@ struct FancyUse { } ``` +>![](../../public_sys-resources/icon-note.gif) **说明:** +>@Extend装饰器不能用在自定义组件struct定义框内。 -> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> @Extend装饰器不能用在自定义组件struct定义框内。 diff --git a/zh-cn/application-dev/ui/ts-component-based-preview.md b/zh-cn/application-dev/ui/ts-component-based-preview.md index 5a1fa133e891d95339ec424fcb6746beecea1b05..694cbbed6b5e4d03c0ad4c0c9aa704b801956342 100644 --- a/zh-cn/application-dev/ui/ts-component-based-preview.md +++ b/zh-cn/application-dev/ui/ts-component-based-preview.md @@ -1,17 +1,14 @@ -# @Preview +# @Preview -用 **@Preview** 装饰的自定义组件可以在DevEco的PC预览上进行单组件预览,加载页面时,将创建并呈现 **@Preview** 装饰的自定义组件。 +用**@Preview**装饰的自定义组件可以在DevEco Studio的预览器上进行预览,加载页面时,将创建并呈现**@Preview**装饰的自定义组件。 +>![](../../public_sys-resources/icon-note.gif) **说明:** +>在单个源文件中,最多可以使用**@Preview**装饰一个自定义组件。 -> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> 在单个源文件中,最多可以使用 **@Preview** 装饰一个自定义组件。 - - -## 示例 +## 示例 **@Preview**的用法如下: - ``` // Display only Hello Component1 on the PC preview. The content under MyComponent is displayed on the real device. @Entry @@ -60,3 +57,4 @@ struct Component2 { } } ``` + diff --git a/zh-cn/application-dev/ui/ts-component-based.md b/zh-cn/application-dev/ui/ts-component-based.md index debff48ae78c7632f4f98474fa89e239911574fb..fec4b7a92e43a9840e697c2aeccd0e25374ad3df 100644 --- a/zh-cn/application-dev/ui/ts-component-based.md +++ b/zh-cn/application-dev/ui/ts-component-based.md @@ -1,15 +1,15 @@ -# 组件化 +# 组件化 +- **[@Component](ts-component-based-component.md)** +- **[@Entry](ts-component-based-entry.md)** -- **[\@Component](ts-component-based-component.md)** +- **[@Preview](ts-component-based-preview.md)** -- **[\@Entry](ts-component-based-entry.md)** +- **[@Builder](ts-component-based-builder.md)** -- **[\@Preview](ts-component-based-preview.md)** +- **[@Extend](ts-component-based-extend.md)** -- **[\@Builder](ts-component-based-builder.md)** +- **[@CustomDialog](ts-component-based-customdialog.md)** -- **[\@Extend](ts-component-based-extend.md)** -- **[\@CustomDialog](ts-component-based-customdialog.md)** \ No newline at end of file diff --git a/zh-cn/application-dev/ui/ts-component-creation-re-initialization.md b/zh-cn/application-dev/ui/ts-component-creation-re-initialization.md index 11f03699d12f2f4b06a493912e881dfbf2fe64ab..fb5b88da9ff1b8ae34c610903e740bf784f11a25 100644 --- a/zh-cn/application-dev/ui/ts-component-creation-re-initialization.md +++ b/zh-cn/application-dev/ui/ts-component-creation-re-initialization.md @@ -1,4 +1,4 @@ -# 组件创建和重新初始化示例 +# 组件创建和重新初始化示例 ``` @Entry @@ -47,46 +47,43 @@ struct TimerComponent { } ``` +## 初始创建和渲染 -## 初始创建和渲染 +1. 创建父组件**ParentComp**; +2. 本地初始化**ParentComp**的状态变量**isCountDown**; +3. 执行**ParentComp**的**build**函数; +4. 创建**Column**内置组件; + 1. 创建**Text**内置组件,设置其文本展示内容,并将**Text**组件实例添加到**Column**中; + 2. 判断if条件,创建**true**分支上的组件; + 1. 创建**Image**内置组件,并设置其图片源地址; + 2. 使用给定的构造函数创建**TimerComponent**; + 1. 创建**TimerComponent**对象; + 2. 本地初始化成员变量初始值; + 3. 使用**TimerComponent**构造函数提供的参数更新成员变量的值; + 4. 执行**TimerComponent**的**aboutToAppear**函数; + 5. 执行**TimerComponent**的**build**函数,创建相应的UI描述结构; -1. 创建父组件**ParentComp**; + 3. 创建**Button**内置组件,设置相应的内容。 -2. 本地初始化**ParentComp**的状态变量**isCountDown**; -3. 执行**ParentComp**的**build**函数; - -4. 创建**Column**内置组件; - 1. 创建**Text**内置组件,设置其文本展示内容,并将**Text**组件实例添加到**Column**中; - 2. 判断if条件,创建**true**分支上的组件; - 1. 创建**Image**内置组件,并设置其图片源地址; - 2. 使用给定的构造函数创建**TimerComponent**; - 1. 创建**TimerComponent**对象; - 2. 本地初始化成员变量初始值; - 3. 使用**TimerComponent**构造函数提供的参数更新成员变量的值; - 4. 执行**TimerComponent**的**aboutToAppear**函数; - 5. 执行**TimerComponent**的**build**函数,创建相应的UI描述结构; - 3. 创建**Button**内置组件,设置相应的内容。 - - -## 状态更新 +## 状态更新 用户单击按钮时: -1. **ParentComp**的**isCountDown**状态变量的值更改为false; +1. **ParentComp**的**isCountDown**状态变量的值更改为false; +2. 执行**ParentComp**的**build**函数; +3. **Column**内置组件会被框架重用并执行重新初始化; +4. **Column**的子组件会重用内存中的对象,但会进行重新初始化; + 1. **Text**内置组件会被重用,但使用新的文本内容进行重新初始化; + 2. 判断if条件,使用false分支上的组件; + 1. 原来true分支上的组件不在使用,这些组件会进行销毁; + 1. 创建的**Image**内置组件实例进行销毁; + 2. **TimerComponent**组件实例进行销毁,**aboutToDisappear**函数被调用; -2. 执行**ParentComp**的**build**函数; + 2. 创建false分支上的组件; + 1. 创建**Image**内置组件,并设置其图片源地址; + 2. 使用给定的构造函数重新创建**TimerComponent**; + 3. 新创建的**TimerComponent**进行初始化,并调用**aboutToAppear**函数和**build**函数。 -3. **Column**内置组件会被框架重用并执行重新初始化; + 3. **Button**内置组件会被重用,但使用新的图片源地址。 -4. **Column**的子组件会重用内存中的对象,但会进行重新初始化; - 1. **Text**内置组件会被重用,但使用新的文本内容进行重新初始化; - 2. 判断if条件,使用false分支上的组件; - 1. 原来true分支上的组件不在使用,这些组件会进行销毁; - 1. 创建的**Image**内置组件实例进行销毁; - 2. **TimerComponent**组件实例进行销毁,**aboutToDisappear**函数被调用; - 2. 创建false分支上的组件; - 1. 创建**Image**内置组件,并设置其图片源地址; - 2. 使用给定的构造函数重新创建**TimerComponent**; - 3. 新创建的**TimerComponent**进行初始化,并调用**aboutToAppear**函数和**build**函数。 - 3. **Button**内置组件会被重用,但使用新的图片源地址。 diff --git a/zh-cn/application-dev/ui/ts-component-states-link.md b/zh-cn/application-dev/ui/ts-component-states-link.md index 2eda79be5106c0bd1e40061b38f51456addee142..300a785d1a08fe958bd0ed32fdd765bf04e941c2 100644 --- a/zh-cn/application-dev/ui/ts-component-states-link.md +++ b/zh-cn/application-dev/ui/ts-component-states-link.md @@ -1,24 +1,17 @@ -# @Link +# @Link -**@Link**装饰的变量可以和父组件的 **@State** 变量建立双向数据绑定: +**@Link**装饰的变量可以和父组件的**@State**变量建立双向数据绑定: +- **支持多种类型:@Link**变量的值与**@State**变量的类型相同,即class、number、string、boolean或这些类型的数组; +- **私有:**仅在组件内访问; +- **单个数据源:**初始化**@Link**变量的父组件的变量必须是**@State**变量; +- **双向通信:**子组件对**@Link**变量的更改将同步修改父组件的**@State**变量; +- **创建自定义组件时需要将变量的引用传递给@Link变量:**在创建组件的新实例时,必须使用命名参数初始化所有**@Link**变量。**@Link**变量可以使用**@State**变量或**@Link**变量的引用进行初始化,**@State**变量可以通过'**$**'操作符创建引用。 -- **支持多种类型:@Link**变量的值与 **@State** 变量的类型相同,即class、number、string、boolean或这些类型的数组; +>![](../../public_sys-resources/icon-note.gif) **说明:** +>**@Link**变量不能在组件内部进行初始化。 -- **私有:** 仅在组件内访问; - -- **单个数据源:** 初始化 **@Link** 变量的父组件的变量必须是 **@State** 变量; - -- **双向通信:** 子组件对 **@Link** 变量的更改将同步修改父组件的 **@State** 变量; - -- **创建自定义组件时需要将变量的引用传递给@Link变量:** 在创建组件的新实例时,必须使用命名参数初始化所有 **@Link** 变量。 **@Link** 变量可以使用 **@State** 变量或 **@Link** 变量的引用进行初始化。 **@State** 变量可以通过' **$** '操作符创建引用。 - - -> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> **@Link**变量不能在组件内部进行初始化。 - - -## 简单类型示例 +## 简单类型示例 ``` @Entry @@ -48,10 +41,9 @@ struct PlayButton { } ``` -**@Link**语义是从' **$** '操作符引出,即 **$isPlaying** 是**this.isPlaying**内部状态的双向数据绑定。当您单击**PlayButton**时,PlayButton 的**Image**组件和**Text**组件将同时进行刷新。 +**@Link**语义是从'**$**'操作符引出,即**$isPlaying**是**this.isPlaying**内部状态的双向数据绑定。当您单击**PlayButton**时,PlayButton 的**Image**组件和**Text**组件将同时进行刷新。 - -## 复杂类型示例 +## 复杂类型示例 ``` @Entry @@ -88,10 +80,9 @@ struct Child { } ``` -在上面的示例中,点击**Button1**和**Button2**以更改父组件中显示的文本项目列表。 - +在上面的示例中,点击**Button1**和**Button2**更改父组件中显示的文本项目列表。 -## @Link和@State、@Prop结合使用示例 +## @Link和@State、@Prop结合使用示例 ``` @Entry @@ -127,8 +118,8 @@ struct ChildB { } ``` -上述示例中,ParentView包含ChildA和ChildB两个子组件,ParentView的状态变量**counter**分别初始化ChildA和ChildB: +上述示例中,ParentView包含ChildA和ChildB两个子组件,ParentView的状态变量**counter**分别初始化ChildA和ChildB。 -- ChildB使用 **@Link** 建立双向状态绑定。当**ChildB**修改**counterRef**状态变量值时,该更改将同步到**ParentView**和**ChildA**共享; +- ChildB使用**@Link**建立双向状态绑定。当**ChildB**修改**counterRef**状态变量值时,该更改将同步到**ParentView**和**ChildA**共享; +- ChildA使用**@Prop**建立从**ParentView**到自身的单向状态绑定。当**ChildA**修改状态时,**ChildA**将重新渲染,但该更改不会传达给**ParentView**和**ChildB。** -- ChildA使用**@Prop**建立从**ParentView**到自身的单向状态绑定。当**ChildA**修改状态时,**ChildA**将重新渲染,但该更改不会传达给**ParentView**和**ChildB。** diff --git a/zh-cn/application-dev/ui/ts-component-states-prop.md b/zh-cn/application-dev/ui/ts-component-states-prop.md index 2a50aa808b5b5ac644ca00c11e292511da884986..e5f4612a05ad1062adc6946ee72494bbf21df01c 100644 --- a/zh-cn/application-dev/ui/ts-component-states-prop.md +++ b/zh-cn/application-dev/ui/ts-component-states-prop.md @@ -1,20 +1,15 @@ -# @Prop +# @Prop -**@Prop** 具有与 **@State** 相同的语义,但初始化方式不同。 **@Prop** 装饰的变量必须使用其父组件提供的 **@State** 变量进行初始化,允许组件内部修改 **@Prop** 变量,但上述更改不会通知给父组件,即 **@Prop** 属于单向数据绑定。 +**@Prop与@State**有相同的语义,但初始化方式不同。**@Prop**装饰的变量必须使用其父组件提供的**@State**变量进行初始化,允许组件内部修改**@Prop**变量,但更改不会通知给父组件,即**@Prop**属于单向数据绑定。 -**@Prop** 状态数据具有以下特征: +**@Prop**状态数据具有以下特征: +- **支持简单类型:**仅支持number、string、boolean简单类型; +- **私有:**仅在组件内访问; +- **支持多个实例:**一个组件中可以定义多个标有**@Prop**的属性; +- **创建自定义组件时将值传递给@Prop变量进行初始化:**在创建组件的新实例时,必须初始化所有@Prop变量,不支持在组件内部进行初始化。 -- **支持简单类型:** 仅支持简单类型:number、string、boolean; - -- **私有:** 仅在组件内访问; - -- **支持多个实例:** 一个组件中可以定义多个标有 **@Prop** 的属性; - -- **创建自定义组件时将值传递给 @Prop 变量进行初始化:** 在创建组件的新实例时,必须初始化所有 **@Prop** 变量,不支持在组件内部进行初始化。 - - -## 示例 +## 示例 ``` @Entry @@ -66,7 +61,8 @@ struct CountDownComponent { } ``` -在上述示例中,当按“+1”或“-1”按钮时,父组件状态发生变化,重新执行**build**方法,此时将创建一个新的**CountDownComponent**组件。父组件的**countDownStartValue**状态属性被用于初始化子组件的 **@Prop** 变量。当按下子组件的“Try again”按钮时,其 **@Prop** 变量**count**将被更改,这将导致**CountDownComponent**重新渲染。但是,**count**值的更改不会影响父组件的**countDownStartValue**值。 +在上述示例中,当按“+1”或“-1”按钮时,父组件状态发生变化,重新执行**build**方法,此时将创建一个新的**CountDownComponent**组件。父组件的**countDownStartValue**状态属性被用于初始化子组件的**@Prop**变量,当按下子组件的“Try again”按钮时,其**@Prop**变量**count**将被更改,**CountDownComponent**重新渲染。但是**count**值的更改不会影响父组件的**countDownStartValue**值。 + +>![](../../public_sys-resources/icon-note.gif) **说明:** +>创建新组件实例时,必须初始化其所有**@Prop**变量。 -> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> 创建新组件实例时,必须初始化其所有 **@Prop** 变量。 diff --git a/zh-cn/application-dev/ui/ts-component-states-state.md b/zh-cn/application-dev/ui/ts-component-states-state.md index 7373d886fdde057a72322947f265711995223e33..0bb15182030d2521ad80647d13320a30813db0f7 100644 --- a/zh-cn/application-dev/ui/ts-component-states-state.md +++ b/zh-cn/application-dev/ui/ts-component-states-state.md @@ -1,22 +1,16 @@ -# @State +# @State -**@State** 装饰的变量是组件内部的状态数据,当这些状态数据被修改时,将会调用所在组件的**build**方法进行UI刷新。 +**@State**装饰的变量是组件内部的状态数据,当这些状态数据被修改时,将会调用所在组件的**build**方法进行UI刷新。 -**@State** 状态数据具有以下特征: +**@State**状态数据具有以下特征: +- **支持多种类型:**允许**class**、**number**、**boolean**、**string**强类型的按值和按引用类型。允许这些强类型构成的数组,即**Array**、**Array**、**Array**、**Array。**不允许**object**和**any。** +- **支持多实例:**组件不同实例的内部状态数据独立。 +- **内部私有:**标记为**@State**的属性是私有变量,只能在组件内访问。 +- **需要本地初始化:**必须为所有**@State**变量分配初始值,将变量保持未初始化可能导致框架行为未定义。 +- **创建自定义组件时支持通过状态变量名设置初始值:**在创建组件实例时,可以通过变量名显式指定**@State**状态属性的初始值**。** -- **支持多种类型:** 允许如下强类型的按值和按引用类型:**class**、**number**、**boolean**、**string**,以及这些类型的数组,即 **Array<class>**、**Array<string>**、**Array<boolean>**、**Array<number>** 。不允许**object**和**any。** - -- **支持多实例:** 组件不同实例的内部状态数据独立。 - -- **内部私有:** 标记为 **@State** 的属性不能直接在组件外部修改。它的生命周期取决于它所在的组件。 - -- **需要本地初始化:** 必须为所有 **@State** 变量分配初始值,将变量保持未初始化可能导致框架行为未定义。 - -- **创建自定义组件时支持通过状态变量名设置初始值:** 在创建组件实例时,可以通过变量名显式指定 **@State** 状态属性的初始值**。** - - -## 简单类型的状态属性示例 +## 简单类型的状态属性示例 ``` @Entry @@ -39,8 +33,7 @@ struct MyComponent { } ``` - -## 复杂类型的状态变量示例 +## 复杂类型的状态变量示例 ``` // Customize the status data class. @@ -56,7 +49,8 @@ class Model { struct EntryComponent { build() { Column() { - MyComponent({count: 1, increaseBy: 2}) // MyComponent1 in this document MyComponent({title: {value: 'Hello, World 2'}, count: 7}) //MyComponent2 in this document + MyComponent({count: 1, increaseBy: 2}) // MyComponent1 in this document + MyComponent({title: {value: 'Hello, World 2'}, count: 7}) //MyComponent2 in this document } } } @@ -87,15 +81,13 @@ struct MyComponent { } ``` - 在上述示例中: +- 用户定义的组件**MyComponent**定义了**@State**状态变量**count**和**title**。如果**count**或**title**的值发生变化,则执行**MyComponent**的**build**方法来重新渲染组件; +- **EntryComponent**中有多个**MyComponent**组件实例,第一个**MyComponent**内部状态的更改不会影响第二个**MyComponent**; +- 创建**MyComponent**实例时通过变量名给组件内的变量进行初始化,如: -- 用户定义的组件**MyComponent**定义了 **@State** 状态变量**count**和**title**。如果**count**或**title**的值发生变化,则执行**MyComponent**的**build**方法来重新渲染组件; - -- **EntryComponent**中有多个**MyComponent**组件实例,第一个**MyComponent**内部状态的更改不会影响第二个**MyComponent**; + ``` + MyComponent({title: {value: 'Hello, World 2'}, count: 7}) + ``` -- 创建**MyComponent**实例时通过变量名给组件内的变量进行初始化,如: - ``` - MyComponent({title: {value: 'Hello, World 2'}, count: 7}) - ``` diff --git a/zh-cn/application-dev/ui/ts-configuration-with-mandatory-parameters.md b/zh-cn/application-dev/ui/ts-configuration-with-mandatory-parameters.md index 9f6fa98b97cca45e9ad7663f96ba101da99617fc..d53a20f232036cad839708255e1823f31f079ff0 100644 --- a/zh-cn/application-dev/ui/ts-configuration-with-mandatory-parameters.md +++ b/zh-cn/application-dev/ui/ts-configuration-with-mandatory-parameters.md @@ -1,34 +1,24 @@ -# 必选参数构造配置 - - - -如果组件的接口定义中包含必选构造参数,则在组件后面的“**()**”中必须配置参数。参数可以使用常量进行赋值。 +# 必选参数构造配置 +如果组件的接口定义中包含必选构造参数,则在组件后面的“**\(\)**”中必须配置参数,参数可以使用常量进行赋值。 例如: +- **Image**组件的必选参数**src**: -**Image**组件的必选参数**src**: - - -``` -Image('http://xyz/a.jpg') -``` - - -**Text**组件的必选参数**content**: + ``` + Image('http://xyz/a.jpg') + ``` -``` -Text('123') -``` +- **Text**组件的必选参数**content**: + ``` + Text('123') + ``` -变量或表达式也可以用于参数赋值,其中表达式返回的结果类型必须满足参数类型要求。 - - -传递变量或表达式来构造**Image**和**Text**组件的参数示例如下: +变量或表达式也可以用于参数赋值,其中表达式返回的结果类型必须满足参数类型要求。例如,传递变量或表达式来构造**Image**和**Text**组件的参数: ``` // imagePath, where imageUrl is a private data variable defined in the component. @@ -39,3 +29,4 @@ Image('http://' + this.imageUrl) // features of the corresponding language. This specification is not limited. Text(`count: ${this.count}`) ``` + diff --git a/zh-cn/application-dev/ui/ts-custom-component-initialization.md b/zh-cn/application-dev/ui/ts-custom-component-initialization.md index 9fbaa15db85b5f81d72b13b641dc53ba4f3b4f2c..f636d44f4312fa6e8a4598ad6dc5a4f2d78add5c 100644 --- a/zh-cn/application-dev/ui/ts-custom-component-initialization.md +++ b/zh-cn/application-dev/ui/ts-custom-component-initialization.md @@ -1,76 +1,196 @@ -# 自定义组件初始化 - -本节介绍自定义组件状态变量的初始化规则。 - +# 自定义组件成员变量初始化 组件的成员变量可以通过两种方式初始化: +- 本地初始化,例如: -- 本地初始化,例如: - ``` - @State counter: Counter = new Counter() - ``` - -- 在构造组件时通过构造参数初始化,例如: - ``` - MyComponent(counter: $myCounter) - ``` - - -具体允许哪种方式取决于状态变量的装饰器: - - -| 装饰器类型 | 本地初始化 | 通过构造函数参数初始化 | -| -------- | -------- | -------- | -| @State | 必须 | 可选 | -| @Prop | 禁止 | 必须 | -| @Link | 禁止 | 必须 | -| @StorageLink | 必须 | 禁止 | -| @StorageProp | 必须 | 禁止 | -| @Provide | 必须 | 可选 | -| @Consume | 禁止 | 禁止 | -| @ObjectLink | 禁止 | 必须 | -| 常规成员变量 | 推荐 | 可选 | - + ``` + @State counter: Counter = new Counter() + ``` -从上表中: +- 在构造组件时通过构造参数初始化,例如: + ``` + MyComponent(counter: $myCounter) + ``` -- **@State**变量需要本地初始化,初始化的值可以被构造参数覆盖; -- **@Prop**和**@Link**变量必须且仅通过构造函数参数进行初始化。 +具体允许哪种方式取决于状态变量的装饰器: + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

    装饰器类型

    +

    本地初始化

    +

    通过构造函数参数初始化

    +

    @State

    +

    必须

    +

    可选

    +

    @Prop

    +

    禁止

    +

    必须

    +

    @Link

    +

    禁止

    +

    必须

    +

    @StorageLink

    +

    必须

    +

    禁止

    +

    @StorageProp

    +

    必须

    +

    禁止

    +

    @Provide

    +

    必须

    +

    可选

    +

    @Consume

    +

    禁止

    +

    禁止

    +

    @ObjectLink

    +

    禁止

    +

    必须

    +

    常规成员变量

    +

    推荐

    +

    可选

    +
    + +从上表中可以看出: + +- **@State**变量需要本地初始化,初始化的值可以被构造参数覆盖; +- **@Prop**和**@Link**变量必须且仅通过构造函数参数进行初始化。 通过构造函数方法初始化成员变量,需要遵循如下规则: - -| 从父组件中的变量(下)到子组件中的变量(右) | @State | @Link | @Prop | 常规变量 | -| -------- | -------- | -------- | -------- | -------- | -| @State | 不允许 | 允许 | 允许 | 允许 | -| @Link | 不允许 | 允许 | 不推荐 | 允许 | -| @Prop | 不允许 | 不允许 | 允许 | 允许 | -| @StorageLink | 不允许 | 允许 | 不允许 | 允许 | -| @StorageProp | 不允许 | 不允许 | 不允许 | 允许 | -| 常规变量 | 允许 | 不允许 | 不允许 | 允许 | - - -从上表中: - - -- 父组件的常规变量可以用于初始化子组件的**@State**变量,但不能用于初始化**@Link**或**@Prop**变量; - -- 父组件的**@State**变量可以初始化子组件的**@Prop**、**@Link(通过$)**或常规变量,但不能初始化子组件的**@State**变量; - -- 父组件的**@Link**变量可以初始化子组件的@Link或常规变量。但是初始化子组件的**@State**成员是语法错误,此外不建议初始化**@prop;** - -- 父组件的**@Prop**变量可以初始化子组件的常规变量或**@Prop**变量,但不能初始化子组件的**@State**或**@Link**变量。 - -- @StorageLink和@StorageProp不允许由父组件中传递到子组件。 - -- 除了上述规则外,还需要遵循TS的强类型规则。 - - -## 示例 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

    从父组件中的变量(下)到子组件中的变量(右)

    +

    @State

    +

    @Link

    +

    @Prop

    +

    常规变量

    +

    @State

    +

    不允许

    +

    允许

    +

    允许

    +

    允许

    +

    @Link

    +

    不允许

    +

    允许

    +

    不推荐

    +

    允许

    +

    @Prop

    +

    不允许

    +

    不允许

    +

    允许

    +

    允许

    +

    @StorageLink

    +

    不允许

    +

    允许

    +

    不允许

    +

    允许

    +

    @StorageProp

    +

    不允许

    +

    不允许

    +

    不允许

    +

    允许

    +

    常规变量

    +

    允许

    +

    不允许

    +

    不允许

    +

    允许

    +
    + +从上表中可以看出: + +- 父组件的常规变量可以用于初始化子组件的**@State**变量,但不能用于初始化**@Link**或**@Prop**变量; +- 父组件的**@State**变量可以初始化子组件的**@Prop**、**@Link(通过$)**或常规变量,但不能初始化子组件的**@State**变量; +- 父组件的**@Link**变量可以初始化子组件的@Link或常规变量。但是初始化子组件的**@State**成员是语法错误,此外不建议初始化**@prop;** +- 父组件的**@Prop**变量可以初始化子组件的常规变量或**@Prop**变量,但不能初始化子组件的**@State**或**@Link**变量。 +- @StorageLink和@StorageProp不允许由父组件中传递到子组件。 +- 除了上述规则外,还需要遵循TS的强类型规则。 + +## 示例 ``` @Entry @@ -112,3 +232,4 @@ struct CompB { } } ``` + diff --git a/zh-cn/application-dev/ui/ts-custom-component-lifecycle-callbacks.md b/zh-cn/application-dev/ui/ts-custom-component-lifecycle-callbacks.md index 20f7c9108bea49e21b21ec6eba83a7b74375bb86..4bc7a37020be6a1778d56bbe509dc92b7d33a527 100644 --- a/zh-cn/application-dev/ui/ts-custom-component-lifecycle-callbacks.md +++ b/zh-cn/application-dev/ui/ts-custom-component-lifecycle-callbacks.md @@ -1,20 +1,46 @@ -# 自定义组件生命周期回调函数 +# 自定义组件生命周期回调函数 自定义组件的生命周期回调函数用于通知用户该自定义组件的生命周期,这些回调函数是私有的,在运行时由开发框架在特定的时间进行调用,不能从应用程序中手动调用这些回调函数。 +## 生命周期回调函数定义 -## 生命周期回调函数定义 + + + + + + + + + + + + + + + + + + + + + +

    函数名

    +

    描述

    +

    aboutToAppear

    +

    函数在创建自定义组件的新实例后,在执行其build函数之前执行。允许在aboutToAppear函数中改变状态变量,更改将在后续执行build函数中生效。

    +

    aboutToDisappear

    +

    函数在自定义组件析构消耗之前执行。不允许在aboutToDisappear函数中改变状态变量,特别是@Link变量的修改可能会导致应用程序行为不稳定。

    +

    onPageShow

    +

    页面显示时触发一次,包括路由过程、应用进入前后台等场景,仅@Entry修饰的自定义组件生效。

    +

    onPageHide

    +

    页面消失时触发一次,包括路由过程、应用进入前后台等场景,仅@Entry修饰的自定义组件生效。

    +

    onBackPress

    +

    当用户点击返回按钮时触发,仅@Entry修饰的自定义组件生效。

    +
    • 返回true表示页面自己处理返回逻辑, 不进行页面路由。
    • 返回false表示使用默认的返回逻辑。
    • 不返回值会作为false处理。
    +
    -| 函数名 | 描述 | -| -------- | -------- | -| aboutToAppear | 函数在创建自定义组件的新实例后,在执行其**build**函数之前执行。
    允许在**aboutToAppear**函数中改变状态变量,这些更改将在后续执行build函数中生效。 | -| aboutToDisappear | 函数在自定义组件析构消耗之前执行。
    不允许在**aboutToDisappear**函数中改变状态变量,特别是**@Link**变量的修改可能会导致应用程序行为不稳定。 | -| onPageShow | 当此页面显示时触发一次。包括路由过程、应用进入前后台等场景,仅@Entry修饰的自定义组件生效。 | -| onPageHide | 当此页面消失时触发一次。包括路由过程、应用进入前后台等场景,仅@Entry修饰的自定义组件生效。 | -| onBackPress | 当用户点击返回按钮时触发,,仅@Entry修饰的自定义组件生效。
    - 返回true表示页面自己处理返回逻辑, 不进行页面路由。
    - 返回false表示使用默认的返回逻辑。
    - 不返回值会作为false处理。 | - - -## 示例 +## 示例 ``` @Component @@ -46,8 +72,7 @@ struct CountDownTimerComponent { 上述示例表明,生命周期函数对于允许CountDownTimerComponent管理其计时器资源至关重要,类似的函数也包括异步从网络请求加载资源。 +>![](../../public_sys-resources/icon-note.gif) **说明:** +>- 允许在生命周期函数中使用**Promise**和异步回调函数,比如网络资源获取,定时器设置等; +>- 不允许在生命周期函数中使用**async await**。 -> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> - 允许在生命周期函数中使用**Promise**和异步回调函数,比如网络资源获取,定时器设置等; -> -> - 不允许在生命周期函数中使用**async await**。 diff --git a/zh-cn/application-dev/ui/ts-declarative-ui-description-specifications.md b/zh-cn/application-dev/ui/ts-declarative-ui-description-specifications.md index e72a1ffb9628fd58dee9e7dbb9968f2e741e2a69..ecb6cdf8fa38ff10f34844541fbd2372240db307 100644 --- a/zh-cn/application-dev/ui/ts-declarative-ui-description-specifications.md +++ b/zh-cn/application-dev/ui/ts-declarative-ui-description-specifications.md @@ -1,13 +1,13 @@ -# 声明式UI描述规范 +# 声明式UI描述规范 +- **[无构造参数配置](ts-parameterless-configuration.md)** +- **[必选参数构造配置](ts-configuration-with-mandatory-parameters.md)** -- **[无构造参数配置](ts-parameterless-configuration.md)** +- **[属性配置](ts-attribution-configuration.md)** -- **[必选参数构造配置](ts-configuration-with-mandatory-parameters.md)** +- **[事件配置](ts-event-configuration.md)** -- **[属性配置](ts-attribution-configuration.md)** +- **[子组件配置](ts-child-component-configuration.md)** -- **[事件配置](ts-event-configuration.md)** -- **[子组件配置](ts-child-component-configuration.md)** \ No newline at end of file diff --git a/zh-cn/application-dev/ui/ts-event-configuration.md b/zh-cn/application-dev/ui/ts-event-configuration.md index 35afd40ceac94edbf8aaaf4ce9df04ff491e993b..ba25d7c8151b3730a98a31a09979c3fd5c923d0f 100644 --- a/zh-cn/application-dev/ui/ts-event-configuration.md +++ b/zh-cn/application-dev/ui/ts-event-configuration.md @@ -1,39 +1,40 @@ -# 事件配置 +# 事件配置 +通过事件方法可以配置组件支持的事件。 +- 使用lambda表达式配置组件的事件方法: -通过事件方法可以配置组件支持的事件。 + ``` + // Counter is a private data variable defined in the component. + Button('add counter') + .onClick(() => { + this.counter += 2 + }) + ``` + + +- 使用匿名函数表达式配置组件的事件方法,要求使用**bind**,以确保函数体中的this引用包含的组件。 + + ``` + // Counter is a private data variable defined in the component. + Button('add counter') + .onClick(function () { + this.counter += 2 + }.bind(this)) + ``` + + +- 使用组件的成员函数配置组件的事件方法: + + ``` + myClickHandler(): void { + // do something + } + + ... + + Button('add counter') + .onClick(this.myClickHandler) + ``` -- 使用lambda表达式配置组件的事件方法: - ``` - // Counter is a private data variable defined in the component. - Button('add counter') - .onClick(() => { - this.counter += 2 - }) - ``` - - -- 使用匿名函数表达式配置组件的事件方法: - 此时要求我们使用**bind**,以确保函数体中的this引用包含的组件。 - ``` - // Counter is a private data variable defined in the component. - Button('add counter') - .onClick(function () { - this.counter += 2 - }.bind(this)) - ``` - - -- 使用组件的成员函数配置组件的事件方法: - ``` - myClickHandler(): void { - // do something - } - - ... - - Button('add counter') - .onClick(this.myClickHandler) - ``` diff --git a/zh-cn/application-dev/ui/ts-function-build.md b/zh-cn/application-dev/ui/ts-function-build.md index 7d6f0572fd6ad08c3414d8b53061d664a4a2ce0b..f2a5985099e7725cd6f1c172ce2bbed9ec7beb33 100644 --- a/zh-cn/application-dev/ui/ts-function-build.md +++ b/zh-cn/application-dev/ui/ts-function-build.md @@ -1,12 +1,13 @@ -# build函数 - - - -**build**函数满足**Builder**构造器接口定义,用于定义组件的声明式UI描述。 +# build函数 +**build**函数满足**Builder**构造器接口定义,用于定义组件的声明式UI描述。必须遵循上述**Builder**接口约束,在**build**方法中以声明式方式进行组合自定义组件或系统内置组件,在组件的第一次创建和更新场景中都会调用**build**方法。 ``` interface Builder { build: () => void } ``` + +>![](../../public_sys-resources/icon-note.gif) **说明:** +>build方法仅支持组合组件,使用渲染控制语法。 + diff --git a/zh-cn/application-dev/ui/ts-general-ui-concepts.md b/zh-cn/application-dev/ui/ts-general-ui-concepts.md index e3d73e432318c6256a714762cef6267ee8583e46..dbb942e3db100536f4c3dfcbe764c85c5cd61dd1 100644 --- a/zh-cn/application-dev/ui/ts-general-ui-concepts.md +++ b/zh-cn/application-dev/ui/ts-general-ui-concepts.md @@ -1,9 +1,8 @@ -# 基本概念 +# 基本概念 基于TS扩展的声明式开发范式提供了一系列基本组件,这些组件以声明方式进行组合和扩展来描述应用程序的UI界面,并且还提供了基本的数据绑定和事件处理机制,帮助开发者实现应用交互逻辑。 - -## HelloWorld基本示例 +## HelloWorld基本示例 ``` // An example of displaying Hello World. After you click the button, Hello UI is displayed. @@ -31,19 +30,14 @@ struct Hello { } ``` - -## 基本概念描述 +## 基本概念描述 上述示例代码描述了简单页面的结构,并介绍了以下基本概念: -- **装饰器**:装饰类、结构、方法和变量,并为它们赋予特殊含义。例如,上例中的 **@Entry**、 **@Component** 和 **@State** 都是装饰器; - -- **自定义组件**:可重用的UI单元,可以与其他组件组合,如 **@Component** 装饰的**struct Hello**; - -- **UI描述**:声明性描述UI结构,例如 **build()** 方法中的代码块; - -- **内置组件**:框架中默认内置的基本组件和布局组件,开发者可以直接调用,如**Column**、**Text**、**Divider**、**Button**等; - -- **属性方法**:用于配置组件属性,如 **fontSize()**、**width()**、**height()**、**color()** 等; +- **装饰器:**方舟开发框架定义了一些具有特殊含义的装饰器,用于装饰类、结构、方法和变量。例如,上例中的**@Entry**、**@Component**和**@State**都是装饰器; +- **自定义组件:**可重用的UI单元,可以与其他组件组合,如**@Component**装饰的**struct Hello**; +- **UI描述:**声明性描述UI结构,例如**build\(\)**方法中的代码块; +- **内置组件:**框架中默认内置的基本组件和布局组件,开发者可以直接调用,如**Column**、**Text**、**Divider**、**Button**等; +- **属性方法:**用于配置组件属性,如**fontSize\(\)**、**width\(\)**、**height\(\)**、**color\(\)**等; +- **事件方法:**在事件方法的回调中添加组件响应逻辑。例如,为Button组件添加onClick方法,在onClick方法的回调中添加点击响应逻辑。 -- **事件方法**:用于将组件响应逻辑添加到事件中。逻辑是通过事件方法设置的。例如,按钮后面的 **onClick()** 。 diff --git a/zh-cn/application-dev/ui/ts-general-ui-description-specifications.md b/zh-cn/application-dev/ui/ts-general-ui-description-specifications.md index fbc8a013dbadc01ad18e97422dd6a9a2768a2774..664bd7b5c75d5b53f19436a29e5e116b6dbd3008 100644 --- a/zh-cn/application-dev/ui/ts-general-ui-description-specifications.md +++ b/zh-cn/application-dev/ui/ts-general-ui-description-specifications.md @@ -1,9 +1,9 @@ -# 通用UI描述规范 +# 通用UI描述规范 +- **[基本概念](ts-general-ui-concepts.md)** +- **[声明式UI描述规范](ts-declarative-ui-description-specifications.md)** -- **[基本概念](ts-general-ui-concepts.md)** +- **[组件化](ts-component-based.md)** -- **[声明式UI描述规范](ts-declarative-ui-description-specifications.md)** -- **[组件化](ts-component-based.md)** \ No newline at end of file diff --git a/zh-cn/application-dev/ui/ts-managing-application-states.md b/zh-cn/application-dev/ui/ts-managing-application-states.md index b2d8ac3c0d7f3fdeed79d5611f42b351c755a775..73502ac9402555a26100924e606512726e3ae488 100644 --- a/zh-cn/application-dev/ui/ts-managing-application-states.md +++ b/zh-cn/application-dev/ui/ts-managing-application-states.md @@ -1,7 +1,9 @@ -# 管理应用程序的状态 +# 管理应用程序的状态 +- **[应用程序的数据存储](ts-application-states-appstorage.md)** +- **[持久化数据管理](ts-application-states-apis-persistentstorage.md)** + +- **[环境变量](ts-application-states-apis-environment.md)** -- **[接口](ts-managing-application-states-apis.md)** -- **[AppStorage与组件同步](ts-application-states-storagelink-storageprop.md)** \ No newline at end of file diff --git a/zh-cn/application-dev/ui/ts-managing-component-states.md b/zh-cn/application-dev/ui/ts-managing-component-states.md index 8311895b4e2373db2e3794af7016727f9c38032b..3432c79f2d34fe7dda48e8bb9cb83000fd90060e 100644 --- a/zh-cn/application-dev/ui/ts-managing-component-states.md +++ b/zh-cn/application-dev/ui/ts-managing-component-states.md @@ -1,9 +1,9 @@ -# 管理组件拥有的状态 +# 管理组件拥有的状态 +- **[@State](ts-component-states-state.md)** +- **[@Prop](ts-component-states-prop.md)** -- **[\@State](ts-component-states-state.md)** +- **[@Link](ts-component-states-link.md)** -- **[\@Prop](ts-component-states-prop.md)** -- **[\@Link](ts-component-states-link.md)** \ No newline at end of file diff --git a/zh-cn/application-dev/ui/ts-managing-other-states.md b/zh-cn/application-dev/ui/ts-managing-other-states.md index 2a458b8be8d0f6a803049c747f78c0c3fbd257c9..a3a2768f1e056fb67ef7b8f3b688a0fd67322c6d 100644 --- a/zh-cn/application-dev/ui/ts-managing-other-states.md +++ b/zh-cn/application-dev/ui/ts-managing-other-states.md @@ -1,9 +1,9 @@ -# 其他类目的状态管理 +# 其他类目的状态管理 +- **[Observed和ObjectLink数据管理](ts-other-states-observed-objectlink.md)** +- **[@Consume和@Provide数据管理](ts-other-states-consume-provide.md)** -- **[Observed和ObjectLink数据管理](ts-other-states-observed-objectlink.md)** +- **[@Watch](ts-other-states-watch.md)** -- **[\@Consume和\@Provide数据管理](ts-other-states-consume-provide.md)** -- **[\@Watch](ts-other-states-watch.md)** \ No newline at end of file diff --git a/zh-cn/application-dev/ui/ts-other-states-consume-provide.md b/zh-cn/application-dev/ui/ts-other-states-consume-provide.md index 0a3ff849b79b386bbe8080bedb9b5bf3b9f89072..df22ac16ab55df83b656ce6d37dcbbd0e2b773c0 100644 --- a/zh-cn/application-dev/ui/ts-other-states-consume-provide.md +++ b/zh-cn/application-dev/ui/ts-other-states-consume-provide.md @@ -1,34 +1,62 @@ -# @Consume和@Provide数据管理 - - +# @Consume和@Provide数据管理 Provide作为数据的提供方,可以更新其子孙节点的数据,并触发页面渲染。Consume在感知到Provide数据的更新后,会触发当前view的重新渲染。 - -**表1** @Provide - -| 类型 | 说明 | -| -------- | -------- | -| 装饰器参数 | 别名:是一个string类型的常量。如果规定别名,则提供对应别名的数据更新。如果没有,则使用变量名作为别名。推荐使用@Provide("alias")这种形式。 | -| 同步机制 | @Provide的变量类似@state,可以修改对应变量进行页面重新渲染。也可以修改@Consume装饰的变量,反向修改@State变量。 | -| 初始值 | 必须制定初始值 | -| 页面重渲染场景 | 1. 基础类型 boolean,string,number
    2. observed class,修改其中的属性
    3. Array:添加,删除,更新数组中的元素 | - - -**表2** @Consume - -| 类型 | 说明 | -| -------- | -------- | -| 初始值 | 不可设置默认值 | - - -> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> 使用@Provide 和@Consume时避免循环引用导致死循环。 - +**表 1** @Provide + + + + + + + + + + + + + + + + + + + +

    名称

    +

    说明

    +

    装饰器参数

    +

    是一个string类型的常量,用于给装饰的变量起别名。如果规定别名,则提供对应别名的数据更新。如果没有,则使用变量名作为别名。推荐使用@Provide("alias")这种形式。

    +

    同步机制

    +

    @Provide的变量类似@state,可以修改对应变量进行页面重新渲染。也可以修改@Consume装饰的变量,反向修改@State变量。

    +

    初始值

    +

    必须制定初始值。

    +

    页面重渲染场景

    +

    触发页面渲染的修改:

    +
    • 基础类型(boolean,string,number)的改变;
    • @Observed class类型变量及其属性的修改;
    • 添加,删除,更新数组中的元素。
    +
    + +**表 2** @Consume + + + + + + + + + + +

    类型

    +

    说明

    +

    初始值

    +

    不可设置默认值。

    +
    + +>![](../../public_sys-resources/icon-note.gif) **说明:** +>使用@Provide 和@Consume时避免循环引用导致死循环。 其他属性说明与Provide一致。 - ``` @Entry @Component @@ -74,3 +102,4 @@ struct CompC { } } ``` + diff --git a/zh-cn/application-dev/ui/ts-other-states-observed-objectlink.md b/zh-cn/application-dev/ui/ts-other-states-observed-objectlink.md index 183d66647240ad8d8d5d136702d56c7b2699bcc3..3a654775f8a367741763d8785dd125d2ed8ef8cf 100644 --- a/zh-cn/application-dev/ui/ts-other-states-observed-objectlink.md +++ b/zh-cn/application-dev/ui/ts-other-states-observed-objectlink.md @@ -1,73 +1,172 @@ -# Observed和ObjectLink数据管理 +# Observed和ObjectLink数据管理 -@observed是用来class的修饰器,表示此对象中的数据变更将被UI页面管理。@objectLink用来修饰被@observed装饰的变量。 +本章将引入两个新的装饰符@Observed和@ObjectLink: + +- @Observed应用于类,表示该类中的数据变更被UI页面管理,例如:@Observed class ClassA \{\}。 +- @ObjectLink应用于被@Observed所装饰类的对象,例如:@ObjectLink a: ClassA。 + +## 引入动机 + +当开发者需要在子组件中针对父组件的一个变量(parent\_a)设置双向同步时,开发者可以在父组件中使用@State装饰变量(parsent\_a),并在子组件中使用@Link装饰相应的变量(child\_a)。这样的话,不仅可以实现父组件与单个子组件之间的数据同步,也可以实现父组件与多个子组件之间的数据同步。如下图所示,可以看到,父子组件针对ClassA类型的变量设置了双向同步,那么当子组件1中变量的属性c的值变化时,会通知父组件同步变化,而当父组件中属性c的值变化时,会通知所有子组件同步变化。 + +![](figures/zh-cn_image_0000001251090821.png) + +然而,上述例子是针对某个数据对象进行的整体同步,而当开发者只想针对父组件中某个数据对象的部分信息进行同步时,使用@Link就不能满足要求。如果这些部分信息是一个类对象,就可以使用@ObjectLink配合@Observed来实现,如下图所示。 + +![](figures/zh-cn_image_0000001206450834.png) + +## 设置要求 + +- @Observed 用于类,@ObjectLink 用于变量。 +- @ObjectLink装饰的变量类型必须为类(class type)。 + - 类要被@Observed装饰器所装饰。 + - 不支持简单类型参数,可以使用@Prop进行单向同步。 + +- @ObjectLink装饰的变量是不可变的(immutable)。 + - 属性的改动是被允许的,当改动发生时,如果同一个对象被多个@ObjectLink变量所引用,那么所有拥有这些变量的自定义组件都会被通知去重新渲染。 + +- @ObjectLink装饰的变量不可设置默认值。 + - 必须让父组件中有一个由@State、@Link、@StorageLink、@Provide或@Consume所装饰变量参与的TS表达式进行初始化。 + +- @ObjectLink装饰的变量是私有变量,只能在组件内访问。 + +## 示例 + +### 案例1 ``` -// 需要监听的对象 -@Observed class ClassA { - static nextID : number = 0; - public id : number; - public c: number; - - constructor(c: number) { - this.id = ClassA.nextID++; - this.c = c; +@Observed +class ClassA { + public name : string; + public c: number; + constructor(c: number, name: string = 'OK') { + this.name = name; + this.c = c; + } +} + +class ClassB { + public a: ClassA; + constructor(a: ClassA) { + this.a = a; + } +} + +@Component +struct ViewA { + label : string = "ep1"; + @ObjectLink a : ClassA; + build() { + Column() { + Text(`ViewA [${this.label}]: a.c=${this.a.c}`) + .fontSize(20) + Button(`+1`) + .width(100) + .margin(2) + .onClick(() => { + this.a.c += 1; + }) + Button(`reset`) + .width(100) + .margin(2) + .onClick(() => { + this.a = new ClassA(0); // ERROR, this.a is immutable + }) } + } } -@Observed class ClassB { - public a: ClassA; +@Entry +@Component +struct ViewB { + @State b : ClassB = new ClassB(new ClassA(10)); + build() { + Flex({direction: FlexDirection.Column, alignItems: ItemAlign.Center}) { + ViewA({label: "ViewA #1", a: this.b.a}) + ViewA({label: "ViewA #2", a: this.b.a}) - constructor(a: ClassA) { - this.a = a; + Button(`ViewB: this.b.a.c += 1` ) + .width(320) + .margin(4) + .onClick(() => { + this.b.a.c += 1; + }) + Button(`ViewB: this.b.a = new ClassA(0)`) + .width(240) + .margin(4) + .onClick(() => { + this.b.a = new ClassA(0); + }) + Button(`ViewB: this.b = new ClassB(ClassA(0))`) + .width(240) + .margin(4) + .onClick(() => { + this.b = new ClassB(new ClassA(0)); + }) } + } } ``` +### 案例2 ``` +var nextID: number = 0; +@Observed +class ClassA { + public name : string; + public c: number; + public id : number; + constructor(c: number, name: string = 'OK') { + this.name = name; + this.c = c; + this.id = nextID++; + } +} + @Component struct ViewA { - @ObjectLink a : ClassA; label : string = "ViewA1"; + @ObjectLink a: ClassA; build() { - Row() { - Button(`ViewA [${this.label}] this.a.c=${this.a.c} +1`) - .onClick(() => { - this.a.c += 1; - }) - Button(`ViewA [${this.label}] reset this.a =new ClassA(0)`) + Row() { + Button(`ViewA [${this.label}] this.a.c= ${this.a.c} +1`) .onClick(() => { - this.a = new ClassA(0); // ERROR, this.a is immutable + this.a.c += 1; }) - } + } } } @Entry -@Component +@Component struct ViewB { - @State b : ClassB = new ClassB(new ClassA(0)); - + @State arrA : ClassA[] = [ new ClassA(0), new ClassA(0) ]; build() { - Column() { - ViewA({label: "ViewA #1", a: this.b.a}) - ViewA({label: "ViewA #2", a: this.b.a}) + Column() { + ForEach (this.arrA, (item) => { + ViewA({label: `#${item.id}`, a: item}) + }, + (item) => item.id.toString() + ) + ViewA({label: `ViewA this.arrA[first]`, a: this.arrA[0]}) + ViewA({label: `ViewA this.arrA[last]`, a: this.arrA[this.arrA.length-1]}) - Button(`ViewB: this.b.a = new ClassA(0)`) + Button(`ViewB: reset array`) .onClick(() => { - this.b.a = new ClassA(0); - }) - Button(`ViewB: this.b = new ClassB(ClassA(0))`) + this.arrA = [ new ClassA(0), new ClassA(0) ]; + }) + Button(`ViewB: push`) + .onClick(() => { + this.arrA.push(new ClassA(0)) + }) + Button(`ViewB: shift`) .onClick(() => { - this.b = new ClassB(new ClassA(0)); - }) + this.arrA.shift() + }) } - } + } } ``` - -> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> @ObjectLink用于修饰变量,并且不可以初始化。@Observed用于修饰类。 diff --git a/zh-cn/application-dev/ui/ts-other-states-watch.md b/zh-cn/application-dev/ui/ts-other-states-watch.md index b8f72ac88f48cb2a4e9f7998ccd99f391ddb95fd..cc89576b6449f5c6a488d4a5878370ad391cc5c1 100644 --- a/zh-cn/application-dev/ui/ts-other-states-watch.md +++ b/zh-cn/application-dev/ui/ts-other-states-watch.md @@ -1,9 +1,14 @@ -# @Watch +# @Watch +@Watch用于监听状态变量的变化,语法结构为: +``` +@State @Watch("onChanged") count : number = 0 +``` -应用可以注册回调方法。当一个被@State, @Prop, @Link, @ObjectLink, @Provide, @Consume, @StorageProp, 以及 @StorageLink中任意一个装饰器修饰的变量改变时,均可触发此回调。@Watch中的变量一定要使用(“”)进行包装。 +如上给状态变量增加一个@Watch装饰器,通过@Watch注册一个回调方法onChanged, 当状态变量count被改变时, 触发onChanged回调。 +装饰器@State, @Prop, @Link, @ObjectLink, @Provide, @Consume, @StorageProp以及 @StorageLink装饰的变量可以监听其变化。 ``` @Entry @@ -34,3 +39,4 @@ struct CompA { } } ``` + diff --git a/zh-cn/application-dev/ui/ts-parameterless-configuration.md b/zh-cn/application-dev/ui/ts-parameterless-configuration.md index 6e076173605de168772cb75ee74a43f37a2e9a49..d1f30e5e6186706be091aff25e06ec23b57aaef0 100644 --- a/zh-cn/application-dev/ui/ts-parameterless-configuration.md +++ b/zh-cn/application-dev/ui/ts-parameterless-configuration.md @@ -1,12 +1,6 @@ -# 无构造参数配置 - - - -组件的接口定义不包含必选构造参数,组件后面的“**()**”中不需要配置任何内容。 - - -例如,以下**Divider**组件不包含构造参数: +# 无构造参数配置 +组件的接口定义不包含必选构造参数,组件后面的“**\(\)**”中不需要配置任何内容。例如,**Divider**组件不包含构造参数: ``` Column() { @@ -15,3 +9,4 @@ Column() { Text('item 2') } ``` + diff --git a/zh-cn/application-dev/ui/ts-rending-control-syntax-foreach.md b/zh-cn/application-dev/ui/ts-rending-control-syntax-foreach.md index be58e040cc7b598426e222711d99c903a539b43c..9c6db483554f0af4e1ba0f70fcb1ee3c46eb6ec9 100644 --- a/zh-cn/application-dev/ui/ts-rending-control-syntax-foreach.md +++ b/zh-cn/application-dev/ui/ts-rending-control-syntax-foreach.md @@ -1,7 +1,6 @@ -# 循环渲染 - -开发框架提供**ForEach**组件来迭代数组,并为每个数组项创建相应的组件。**ForEach**定义如下: +# 循环渲染 +开发框架提供**循环渲染(**ForEach组件)来迭代数组,并为每个数组项创建相应的组件。**ForEach**定义如下: ``` ForEach( @@ -11,35 +10,76 @@ ForEach( ) ``` +## ForEach + +ForEach\(arr: any\[\],itemGenerator: \(item: any, index?: number\) =\> void, keyGenerator?: \(item: any, index?: number\) =\> string\):void + +**表 1** 参数说明 + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

    参数名

    +

    参数类型

    +

    必填

    +

    默认值

    +

    参数描述

    +

    arr

    +

    any[]

    +

    +

    -

    +

    必须是数组,允许空数组,空数组场景下不会创建子组件。同时允许设置返回值为数组类型的函数,例如arr.slice(1, 3),设置的函数不得改变包括数组本身在内的任何状态变量,如Array.spliceArray.sortArray.reverse这些改变原数组的函数。

    +

    itemGenerator

    +

    (item: any, index?: number) => void

    +

    +

    -

    +

    生成子组件的lambda函数,为给定数组项生成一个或多个子组件,单个组件和子组件列表必须括在大括号“{....}”中。

    +

    keyGenerator

    +

    (item: any, index?: number) => string

    +

    +

    -

    +

    匿名参数,用于给定数组项生成唯一且稳定的键值。当子项在数组中的位置更改时,子项的键值不得更改,当数组中的子项被新项替换时,被替换项的键值和新项的键值必须不同。键值生成器的功能是可选的,但是,为了使开发框架能够更好地识别数组更改,提高性能,建议提供。如将数组反向时,如果没有提供键值生成器,则ForEach中的所有节点都将重建

    +
    -> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> - 循环渲染使用ForEach从提供的数组中自动生成子组件; -> -> - 必须在容器组件内使用; -> -> - 第一个参数必须是数组:允许空数组,空数组场景下不会创建子组件。同时允许设置返回值为数组类型的函数,例如**arr.slice(1, 3)**,设置的函数不得改变包括数组本身在内的任何状态变量,如**Array.splice**、**Array.sort**或**Array.reverse**这些原地修改数组的函数; -> -> - 第二个参数用于生成子组件的lambda函数。它为给定数组项生成一个或多个子组件。单个组件和子组件列表必须括在大括号“**{....}**”中; -> -> - 可选的第三个参数是用于键值生成的匿名函数。它为给定数组项生成唯一且稳定的键值。当子项在数组中的位置更改时,子项的键值不得更改,当数组中的子项被新项替换时,被替换项的键值和新项的键值必须不同。键值生成器的功能是可选的。但是,出于性能原因,强烈建议提供,这使开发框架能够更好地识别数组更改。如单击进行数组反向时,如果没有提供键值生成器,则ForEach中的所有节点都将重建。 -> -> - 生成的子组件必须允许在**ForEach**的父容器组件中,允许子组件生成器函数中包含**if/else**条件渲染,同时也允许**ForEach**包含在**if/else**条件渲染语句中。 -> -> - 子项生成器函数的调用顺序不一定和数组中的数据项相同,在开发过程中不要假设子项生成器和键值生成器函数是否执行以及执行顺序。如下示例可能无法正常工作: -> ``` -> ForEach(anArray, item => {Text(`${++counter}. item.label`)}) -> ``` -> -> 正确的示例如下: -> -> ``` -> ForEach(anArray.map((item1, index1) => { return { i: index1 + 1, data: item1 }; }), -> item => Text(`${item.i}. item.data.label`), -> item => item.data.id.toString()) -> ``` - - -## 示例 +>![](../../public_sys-resources/icon-note.gif) **说明:** +>- 必须在容器组件内使用; +>- 生成的子组件允许在**ForEach**的父容器组件中,允许子组件生成器函数中包含**if/else**条件渲染,同时也允许**ForEach**包含在**if/else**条件渲染语句中; +>- 子项生成器函数的调用顺序不一定和数组中的数据项相同,在开发过程中不要假设子项生成器和键值生成器函数是否执行以及执行顺序。如下示例可能无法正常工作: +> ``` +> ForEach(anArray, item => {Text(`${++counter}. item.label`)}) +> ``` +> 正确的示例如下: +> ``` +> ForEach(anArray.map((item1, index1) => { return { i: index1 + 1, data: item1 }; }), +> item => Text(`${item.i}. item.data.label`), +> item => item.data.id.toString()) +> ``` + +## 示例 简单类型数组示例: @@ -69,6 +109,7 @@ struct MyComponent { ``` 复杂类型数组示例: + ``` class Month { year: number @@ -131,3 +172,4 @@ struct Calendar1 { } } ``` + diff --git a/zh-cn/application-dev/ui/ts-rending-control-syntax-if-else.md b/zh-cn/application-dev/ui/ts-rending-control-syntax-if-else.md index 5596373025c013c8b2c49cf7e152fa3989dc24ee..357b53ce20cc726540e1e6010a842551e35eb22e 100644 --- a/zh-cn/application-dev/ui/ts-rending-control-syntax-if-else.md +++ b/zh-cn/application-dev/ui/ts-rending-control-syntax-if-else.md @@ -1,19 +1,14 @@ -# 条件渲染 +# 条件渲染 使用**if/else**进行条件渲染。 +>![](../../public_sys-resources/icon-note.gif) **说明:** +>- if条件语句可以使用状态变量。 +>- 使用if可以使子组件的渲染依赖条件语句。 +>- 必须在容器组件内使用。 +>- 某些容器组件限制子组件的类型或数量。将if放置在这些组件内时,这些限制将应用于if和else语句内创建的组件。例如,Grid组件的子组件仅支持GridItem组件,在Grid组件内使用if时,则if条件语句内仅允许使用GridItem组件。 -> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> - if条件语句可以使用状态变量; -> -> - 使用if可以使子组件的渲染依赖条件语句; -> -> - 必须在容器组件内使用。 -> -> - 某些容器组件限制子组件的类型或数量。当将if放置在这些组件内时,这些限制将应用于if和else语句内创建的组件:如当在Grid组件内使用if时,则仅允许if条件语句内使用GridItem组件,而在List组件内则仅允许ListItem组件。 - - -## 示例 +## 示例 使用if条件语句: @@ -25,10 +20,8 @@ Column() { } ``` - 使用if、else if、else条件语句: - ``` Column() { if (this.count < 0) { @@ -42,3 +35,4 @@ Column() { } } ``` + diff --git a/zh-cn/application-dev/ui/ts-rending-control-syntax-lazyforeach.md b/zh-cn/application-dev/ui/ts-rending-control-syntax-lazyforeach.md index a752fc701fc3204cf67f99f27d9d85378245a229..698a239ceb583fdee9655e440ac9d4dfcfc79bd4 100644 --- a/zh-cn/application-dev/ui/ts-rending-control-syntax-lazyforeach.md +++ b/zh-cn/application-dev/ui/ts-rending-control-syntax-lazyforeach.md @@ -1,9 +1,21 @@ -# 数据懒加载 - -开发框架提供**LazyForEach**组件按需迭代数据,并在每次迭代过程中创建相应的组件。**LazyForEach**定义如下: +# 数据懒加载 +开发框架提供**数据懒加载**(LazyForEach组件)从提供的数据源中按需迭代数据,并在每次迭代过程中创建相应的组件。**LazyForEach**定义如下: ``` +LazyForEach( + dataSource: IDataSource, // Data source to be iterated + itemGenerator: (item: any) => void, // child component generator + keyGenerator?: (item: any) => string // (optional) Unique key generator, which is recommended. +): void + +interface IDataSource { + totalCount(): number; // Get total count of data + getData(index: number): any; // Get single data by index + registerDataChangeListener(listener: DataChangeListener): void; // Register listener to listening data changes + unregisterDataChangeListener(listener: DataChangeListener): void; // Unregister listener +} + interface DataChangeListener { onDataReloaded(): void; // Called while data reloaded onDataAdded(index: number): void; // Called while single data added @@ -11,56 +23,152 @@ interface DataChangeListener { onDataDeleted(index: number): void; // Called while single data deleted onDataChanged(index: number): void; // Called while single data changed } -interface IDataSource { - totalCount(): number; // Get total count of data - getData(index: number): any; // Get single data by index - registerDataChangeListener(listener: DataChangeListener): void; // Register listener to listening data changes - unregisterDataChangeListener(listener: DataChangeListener): void; // Unregister listener -} -LazyForEach( - dataSource: IDataSource, // Data source to be iterated - itemGenerator: (item: any) => void, // child component generator - keyGenerator?: (item: any) => string // (optional) Unique key generator, which is recommended. -): void ``` +## 接口 + +### LazyForEach + +LazyForEach\(dataSource: IDataSource, itemGenerator: \(item: any\) =\> void, keyGenerator?: \(item: any\) =\> string\):void -> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> - 通过LazyForEach的onDataChanged更新数据时,如果itemGenerator里面包含一个全静态(此view中不包含状态变量)的view,此view将不会更新 -> -> - 数据懒加载组件使用LazyForEach从提供的数据源中自动生成子组件; -> -> - 必须在容器组件内使用,且仅有List、Grid以及Swiper组件支持数据的按需加载(即只加载可视部分以及其前后少量数据用于缓冲),其他组件仍然是一次加载所有数据; -> -> - 第一个参数必须是继承自IDataSource的对象,需要开发者实现相关接口; -> -> - 第二个参数用于生成子组件的lambda函数。它为给定数组项生成一个或多个子组件。单个组件和子组件列表必须括在大括号“**{....}**”中; -> -> - 可选的第三个参数是用于键值生成的匿名函数。它为给定数组项生成唯一且稳定的键值。当子项在数组中的位置更改时,子项的键值不得更改,当数组中的子项被新项替换时,被替换项的键值和新项的键值必须不同。键值生成器的功能是可选的。但是,出于性能原因,强烈建议提供,这使开发框架能够更好地识别数组更改。如单击进行数组反向时,如果没有提供键值生成器,则ForEach中的所有节点都将重建。 -> -> - 生成的子组件必须允许在**LazyForEach**的父容器组件中,允许**LazyForEach**包含在**if/else**条件渲染语句中。 -> -> - **LazyForEach**在每次迭代中,必须创建一个且只允许创建一个子组件。 -> -> - **ForEach**不允许作为**LazyForEach**的子组件,**LazyForEach**也不支持嵌套。 -> -> - **LazyForEach**中不允许出现**if/else**条件渲染语句。 -> -> - 子项生成器函数的调用顺序不一定和数据源中的数据项相同,在开发过程中不要假设子项生成器和键值生成器函数是否执行以及执行顺序。如下示例可能无法正常工作: -> ``` -> ForEach(dataSource, item => {Text(`${++counter}. item.label`)}) -> ``` -> -> 正确的示例如下: -> -> ``` -> ForEach(dataSource, -> item => Text(`${item.i}. item.data.label`)), -> item => item.data.id.toString()) -> ``` - - -## 示例 +**表 1** 参数说明 + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

    参数名

    +

    参数类型

    +

    必填

    +

    默认值

    +

    参数描述

    +

    dataSource

    +

    IDataSource

    +

    +

    -

    +

    实现IDataSource接口的对象,需要开发者实现相关接口。

    +

    itemGenerator

    +

    (item: any) => void

    +

    +

    -

    +

    生成子组件的lambda函数,为给定数组项生成一个或多个子组件,单个组件和子组件列表必须括在大括号“{....}”中。

    +

    keyGenerator

    +

    (item: any) => string

    +

    +

    -

    +

    匿名函数,用于键值生成,为给定数组项生成唯一且稳定的键值。当子项在数组中的位置更改时,子项的键值不得更改,当数组中的子项被新项替换时,被替换项的键值和新项的键值必须不同。键值生成器的功能是可选的,但是,为了使开发框架能够更好地识别数组更改,提高性能,建议提供。如将数组反向时,如果没有提供键值生成器,则LazyForEach中的所有节点都将重建。

    +
    + +**表 2** IDataSource类型说明 + + + + + + + + + + + + + + + + + + + +

    名称

    +

    描述

    +

    totalCount(): number

    +

    获取数据总数。

    +

    getData(index: number): any

    +

    获取索引对应的数据。

    +

    registerDataChangeListener(listener: DataChangeListener): void

    +

    注册改变数据的控制器。

    +

    unregisterDataChangeListener(listener: DataChangeListener): void

    +

    注销改变数据的控制器。

    +
    + +**表 3** DataChangeListener类型说明 + + + + + + + + + + + + + + + + + + + + + + +

    名称

    +

    描述

    +

    onDataReloaded(): void

    +

    重新加载所有数据。

    +

    onDataAdded(index: number): void

    +

    通知组件index的位置有数据添加。

    +

    onDataMoved(from: number, to: number): void

    +

    通知组件数据从from的位置移到to的位置。

    +

    onDataDeleted(index: number): void

    +

    通知组件index的位置有数据删除。

    +

    onDataChanged(index: number): void

    +

    通知组件index的位置有数据变化。

    +
    + +>![](../../public_sys-resources/icon-note.gif) **说明:** +>- 数据懒加载必须在容器组件内使用,且仅有List、Grid以及Swiper组件支持数据的懒加载(即只加载可视部分以及其前后少量数据用于缓冲),其他组件仍然是一次加载所有的数据; +>- **LazyForEach**在每次迭代中,必须且只允许创建一个子组件; +>- 生成的子组件必须允许在**LazyForEach**的父容器组件中; +>- 允许**LazyForEach**包含在**if/else**条件渲染语句中,不允许**LazyForEach**中出现**if/else**条件渲染语句; +>- 为了高性能渲染,通过DataChangeListener对象的onDataChanged方法来更新UI时,仅itemGenerator中的UI描述的组件内使用了状态变量时,才会触发组件刷新; +>- 子项生成器函数的调用顺序不一定和数据源中的数据项相同,在开发过程中不要假设子项生成器和键值生成器函数是否执行以及执行顺序。如下示例可能无法正常工作: +> ``` +> LazyForEach(dataSource, item => {Text(`${++counter}. item.label`)}) +> ``` +> 正确的示例如下: +> ``` +> LazyForEach(dataSource, +> item => Text(`${item.i}. item.data.label`)), +> item => item.data.id.toString()) +> ``` + +## 示例 ``` // Basic implementation of IDataSource to handle data listener @@ -156,3 +264,4 @@ struct MyComponent { } } ``` + diff --git a/zh-cn/application-dev/ui/ts-rending-control-syntax.md b/zh-cn/application-dev/ui/ts-rending-control-syntax.md index 7dfa08a42eea73e7ecabf9e02c0a6a5ee49768a4..f054d5dbb18d9b4ecd8dfb21ce93c1993d8b8163 100644 --- a/zh-cn/application-dev/ui/ts-rending-control-syntax.md +++ b/zh-cn/application-dev/ui/ts-rending-control-syntax.md @@ -1,9 +1,9 @@ -# 渲染控制语法 +# 渲染控制语法 +- **[条件渲染](ts-rending-control-syntax-if-else.md)** +- **[循环渲染](ts-rending-control-syntax-foreach.md)** -- **[条件渲染](ts-rending-control-syntax-if-else.md)** +- **[数据懒加载](ts-rending-control-syntax-lazyforeach.md)** -- **[循环渲染](ts-rending-control-syntax-foreach.md)** -- **[数据懒加载](ts-rending-control-syntax-lazyforeach.md)** \ No newline at end of file diff --git a/zh-cn/application-dev/ui/ts-syntactic-sugar.md b/zh-cn/application-dev/ui/ts-syntactic-sugar.md index 43a67c3b9947f594c358ce8bc4c053044f17f800..8247ffe1eb2d47b57736612a7d4b07f1c1f2de32 100644 --- a/zh-cn/application-dev/ui/ts-syntactic-sugar.md +++ b/zh-cn/application-dev/ui/ts-syntactic-sugar.md @@ -1,15 +1,217 @@ -# 语法糖 +# 语法糖 +## 装饰器 +装饰器**@Decorator**不仅可以装饰类或结构体,还可以装饰类的属性。多个装饰器可以叠加到目标元素,定义在同一行上或者在多行上,推荐定义在多行上。 -- **[装饰器](ts-syntactic-sugar-decorator.md)** +如下示例为**@Component**和**@State**的使用,被**@Component**装饰的元素具备了组件化的含义,使用**@State**装饰的变量具备了状态数据的含义。 -- **[链式调用](ts-syntactic-sugar-chaining.md)** +``` +@Component +struct MyComponent { + @State count: number = 0 +} +``` -- **[struct对象](ts-syntactic-sugar-struct.md)** +装饰器定义在同一行上的描述如下: -- **[在实例化过程中省略"new"](ts-instantiating-a-struct-without-new-keyword.md)** +``` +@Entry @Component struct MyComponent { +} +``` -- **[组件创建使用独立一行](ts-using-a-separate-line-for-new-component.md)** +但更推荐定义在多行上: + +``` +@Entry +@Component +struct MyComponent { +} +``` + +### 支持的装饰器列表 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

    装饰器

    +

    装饰内容

    +

    说明

    +

    @Component

    +

    struct

    +

    结构体在装饰后具有基于组件的能力,需要实现build方法来更新UI。

    +

    @Entry

    +

    struct

    +

    组件被装饰后作为页面的入口,页面加载时将被渲染显示。

    +

    @Preview

    +

    struct

    +

    用@Preview装饰的自定义组件可以在DevEco Studio的预览器上进行预览,加载页面时,将创建并呈现@Preview装饰的自定义组件。

    +

    @Builder

    +

    方法

    +

    @Builder装饰的方法用于定义组件的声明式UI描述,在一个自定义组件内快速生成多个布局内容。

    +

    @Extend

    +

    方法

    +

    @Extend装饰器将新的属性函数添加到内置组件上,通过@Extend装饰器可以快速定义并复用组件的自定义样式。

    +

    @CustomDialog

    +

    struct

    +

    @CustomDialog装饰器用于装饰自定义弹窗。

    +

    @State

    +

    基本数据类型,类,数组

    +

    修饰的状态数据被修改时会触发组件的build方法进行UI界面更新。

    +

    @Prop

    +

    基本数据类型

    +

    修改后的状态数据用于在父组件和子组件之间建立单向数据依赖关系。修改父组件关联数据时,更新当前组件的UI。

    +

    @Link

    +

    基本数据类型,类,数组

    +

    父子组件之间的双向数据绑定,父组件的内部状态数据作为数据源,任何一方所做的修改都会反映给另一方。

    +

    @Observed

    +

    +

    @Observed应用于类,表示该类中的数据变更被UI页面管理。

    +

    @ObjectLink

    +

    被@Observed所装饰类的对象

    +

    @ObjectLink应用于被@Observed所装饰类的对象。

    +

    @Consume

    +

    基本数据类型,类,数组

    +

    Provide作为数据的提供方,可以更新其子孙节点的数据,并触发页面渲染。

    +

    @Provide

    +

    基本数据类型,类,数组

    +

    Consume在感知到Provide数据的更新后,会触发当前view的重新渲染。

    +

    @Watch

    +

    被@State, @Prop, @Link, @ObjectLink, @Provide, @Consume, @StorageProp, @StorageLink中任意一个装饰的变量

    +

    @Watch用于监听状态变量的变化,应用可以注册回调方法。

    +
    + +## 链式调用 + +允许开发者以“.”链式调用的方式配置UI结构及其属性、事件等。 + +``` +Column() { + Image('1.jpg') + .alt('error.jpg') + .width(100) + .height(100) +}.padding(10) +``` + +## struct对象 + +组件可以基于**struct**实现,组件不能有继承关系,**struct**可以比**class**更加快速的创建和销毁。 + +``` +@Component +struct MyComponent { + @State data: string = '' + + build() { + } +} +``` + +## 在实例化过程中省略"new" + +对于**struct**的实例化,可以省略**new**。 + +``` +// 定义 +@Component +struct MyComponent { + build() { + } +} + +// 使用 +Column() { + MyComponent() +} + +// 等价于 +new Column() { + new MyComponent() +} +``` + +## 生成器函数内使用TS语言的限制 + +TS语言的使用在生成器函数中存在一定的限制: + +- 表达式仅允许在字符串\($\{expression\}\)、if条件、ForEach的参数和组件的参数中使用; +- 这些表达式中的任何一个都不能导致任何应用程序状态变量(@State、@Link、@Prop)的改变,否则会导致未定义和潜在不稳定的框架行为; +- 生成器函数内部不能有局部变量。 + +上述限制都不适用于事件处理函数(例如**onClick**)的匿名函数实现,它们也不适用于UI组件描述外的其余部分。 + +非法示例: + +``` +build() { + let a: number = 1 // invalid: variable declaration not allowed + Column() { + Text('Hello ${this.myName.toUpperCase()}') // ok. + ForEach(this.arr.reverse(), ..., ...) // invalid: Array.reverse modifies the @State array varible in place + } + buildSpecial() // invalid: no function calls + Text(this.calcTextValue()) // this function call is ok. +} +``` -- **[生成器函数内使用TS语言的限制](ts-restrictions-for-generators.md)** \ No newline at end of file diff --git a/zh-cn/application-dev/ui/ts-syntax-intro.md b/zh-cn/application-dev/ui/ts-syntax-intro.md index 7dafc7216f36671bdaa48766f8f1f0acf50c1ac0..90348c240af10b24c92091e228f25725e65268e9 100644 --- a/zh-cn/application-dev/ui/ts-syntax-intro.md +++ b/zh-cn/application-dev/ui/ts-syntax-intro.md @@ -1,16 +1,12 @@ -# 描述规范使用说明 - - +# 描述规范使用说明 本节定义了基于TS扩展的声明式开发范式的核心机制和功能。讲述了声明式UI描述、组件化机制、UI状态管理、渲染控制语法和语法糖。 +本节为应用开发人员开发UI提供了参考规范。有关组件的详细信息,请参考[组件说明](../reference/arkui-ts/ts-components.md)。 -本节为应用开发人员开发UI提供了参考规范。有关组件的详细信息,请参考[组件说明](../reference/arkui-ts/ts-universal-events-click.md)。 - +>**说明:** +> +>- 所有示例都以TypeScript \(TS\)语言为例,请遵循相应语言的语法要求。 +>- 示例中的**Image**、**Button**、**Text**、**Divider**、**Row**和**Column**等组件是UI框架中预置的组件控件,仅用于解释UI描述规范。 +>- 通用属性方法和事件方法通常支持所有组件,而组件内的属性方法和事件方法仅对当前组件有效。 -> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> - 所有示例都以TypeScript (TS)语言为例,请遵循相应语言的语法要求。 -> -> - 示例中的**Image**、**Button**、**Text**、**Divider**、**Row**和**Column**等组件是UI框架中预置的组件控件,仅用于解释UI描述规范。 -> -> - 通用属性方法和事件方法通常支持所有组件,而组件内的属性方法和事件方法仅对当前组件有效。 diff --git a/zh-cn/application-dev/ui/ts-ui-state-management.md b/zh-cn/application-dev/ui/ts-ui-state-management.md index 6c1a8a94433196bcf632a7c3423b0ba87bb29489..98a1b5c20488ebd827e533abbd43df7c3e1115d3 100644 --- a/zh-cn/application-dev/ui/ts-ui-state-management.md +++ b/zh-cn/application-dev/ui/ts-ui-state-management.md @@ -1,11 +1,11 @@ -# UI状态管理 +# UI状态管理 +- **[基本概念](ts-ui-state-mgmt-concepts.md)** +- **[管理组件拥有的状态](ts-managing-component-states.md)** -- **[基本概念](ts-ui-state-mgmt-concepts.md)** +- **[管理应用程序的状态](ts-managing-application-states.md)** -- **[管理组件拥有的状态](ts-managing-component-states.md)** +- **[其他类目的状态管理](ts-managing-other-states.md)** -- **[管理应用程序的状态](ts-managing-application-states.md)** -- **[其他类目的状态管理](ts-managing-other-states.md)** \ No newline at end of file diff --git a/zh-cn/application-dev/ui/ts-ui-state-mgmt-concepts.md b/zh-cn/application-dev/ui/ts-ui-state-mgmt-concepts.md index 81815307c91cade50d72047f83c4d4e45fb2ebc2..ef4d716d46f58c8813907beb92de44b21e3d1b0f 100644 --- a/zh-cn/application-dev/ui/ts-ui-state-mgmt-concepts.md +++ b/zh-cn/application-dev/ui/ts-ui-state-mgmt-concepts.md @@ -1,29 +1,20 @@ -# 基本概念 +# 基本概念 -在声明式UI编程范式中,UI是应用程序状态的函数,开发人员通过修改当前应用程序状态来更新相应的UI界面。 +在声明式UI编程范式中,UI是应用程序状态的函数,开发人员通过修改当前应用程序状态来更新相应的UI界面。开发框架提供了多种应用程序状态管理的能力。 +![](figures/CoreSpec_figures_state-mgmt-overview.png) -开发框架提供了多种应用程序状态管理的能力。 +## 状态变量装饰器 +- **@State:**组件拥有的状态属性,当**@State**装饰的变量更改时,组件会重新渲染更新UI。 +- **@Link:**组件依赖于其父组件拥有的某些状态属性,当任何一个组件中的数据更新时,另一个组件的状态都会更新,父子组件重新渲染。 +- **@Prop:**原理类似**@Link**,但是子组件所做的更改不会同步到父组件上,属于单向传递。 -![zh-cn_image_0000001214948035](figures/zh-cn_image_0000001214948035.png) +## 应用程序状态数据 +**AppStorage**是整个UI应用程序状态的中心“数据库”,UI框架会针对应用程序创建单例**AppStorage**对象,并提供相应的装饰器和接口供应用程序使用。 -## 状态变量装饰器 +- **@StorageLink:@StorageLink\(name\)**的原理类似于**@Consume\(name\)**,不同的是,该给定名称的链接对象是从**AppStorage**中获得的,在**UI组件**和**AppStorage**之间建立双向绑定同步数据。 +- **@StorageProp:@StorageProp\(name\)**将UI组件属性与**AppStorage**进行单向同步,**AppStorage**中值的更改会更新组件中的属性,但UI组件无法更改**AppStorage**中的属性值。 +- **AppStorage**还提供用于业务逻辑实现的API,用于添加、读取、修改和删除应用程序的状态属性,此API所做的更改会导致修改的状态数据同步到UI组件上进行UI更新。 -- **\@State:**组件拥有的状态属性。每当**\@State**装饰的变量更改时,组件会重新渲染更新UI。 - -- **\@Link:**组件依赖于其父组件拥有的某些状态属性。每当任何一个组件中的数据更新时,另一个组件的状态都会更新,父子组件都会进行重新渲染。 - -- **\@Prop:**工作原理类似**\@Link**,只是子组件所做的更改不会同步到父组件上,属于单向传递。 - - -## 应用程序状态数据 - -**AppStorage**是整个UI中使用的应用程序状态的中心“数据库”,UI框架会针对应用程序创建单例**AppStorage**对象,并提供相应的装饰器和接口供应用程序使用。 - -- **\@StorageLink:\@StorageLink(name)**的工作原理类似于**\@Consume(name)**,不同的是,该给定名称的链接对象是从**AppStorage**中获得的,它在**UI组件**和**AppStorage**之间建立双向绑定同步数据。 - -- **\@StorageProp:\@StorageProp(name)**将UI组件属性与**AppStorage**进行单向同步。**AppStorage**中的值更改会更新组件中的属性,但UI组件无法更改**AppStorage**中的属性值。 - -- **AppStorage**还提供用于业务逻辑实现的API,用于添加、读取、修改和删除应用程序的状态属性,通过此API所做的更改会导致修改的状态数据同步到UI组件上进行UI更新。 diff --git a/zh-cn/application-dev/ui/ui-js-component-tabs.md b/zh-cn/application-dev/ui/ui-js-component-tabs.md index 8d653761d56920aaa47b42a7628ee101fb69d5ea..621f642ac8297164c0c3a56aa65f7539bb8bb002 100644 --- a/zh-cn/application-dev/ui/ui-js-component-tabs.md +++ b/zh-cn/application-dev/ui/ui-js-component-tabs.md @@ -189,7 +189,8 @@ export default { > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> - tabs子组件仅支持一个[](../reference/arkui-js/js-components-container-tab-bar.md)和一个[](../reference/arkui-js/js-components-container-tab-content.md)。 +> +> - tabs子组件仅支持一个[\](../reference/arkui-js/js-components-container-tab-bar.md)和一个\[](../reference/arkui-js/js-components-container-tab-content.md)。 ## 场景示例 diff --git a/zh-cn/readme.md b/zh-cn/readme.md index ebb61b142a0ada7a9189c2402ea280ad024207c6..60ec60dc2e6e65aae9eb619034a404af5c0b0b54 100644 --- a/zh-cn/readme.md +++ b/zh-cn/readme.md @@ -67,7 +67,7 @@ - connectivity:[网络与连接](application-dev/connectivity/Readme-CN.md) - database:[分布式数据服务](application-dev/database/Readme-CN.md) - usb:[USB服务](application-dev//usb/Readme-CN.md) - - application-event-logging:[应用事件打点](application-dev/application-event-logging/Readme-CN.md) + - dfx:[DFX](application-dev/dfx/Readme-CN.md) - reference:[开发参考](application-dev/reference/Readme-CN.md) - 许可证及版权信息检查工具:[开源合规审查工具](https://gitee.com/openharmony-sig/tools_oat) - glossary:[术语](device-dev/glossary/glossary.md) diff --git a/zh-cn/website-directory.md b/zh-cn/website-directory.md index f844163b63e741077b0d0ebb7de712b33c8d3e5d..67cc8979d830c6f55db5fc17ae361d8554d1ec33 100644 --- a/zh-cn/website-directory.md +++ b/zh-cn/website-directory.md @@ -1254,15 +1254,17 @@ ——>——>——>——>——>——> [页面跳转与数据传递](application-dev/ui/ui-ts-page-redirection-data-transmission.md) -——>——>——> 音频 +——>——>——> 媒体 -——>——>——>——> [音频开发概述](application-dev/media/audio-overview.md) +——>——>——>——> 音频 -——>——>——>——> [音频播放开发指导](application-dev/media/audio-playback.md) +——>——>——>——>——> [音频开发概述](application-dev/media/audio-overview.md) -——>——>——>——> [音频管理开发指导](application-dev/media/audio-management.md) +——>——>——>——>——> [音频播放开发指导](application-dev/media/audio-playback.md) -——>——>——>——> [音频录制开发指导](application-dev/media/audio-recorder.md) +——>——>——>——>——> [音频管理开发指导](application-dev/media/audio-management.md) + +——>——>——>——>——> [音频录制开发指导](application-dev/media/audio-recorder.md) ——>——>——> 用户认证 @@ -1290,11 +1292,11 @@ ——>——>——>——> [USB服务开发指导](application-dev/usb/usb-guidelines.md) -——>——>——> 应用事件打点 +——>——>——> DFX -——>——>——>——> [应用事件打点概述](application-dev/application-event-logging/hiappevent-overview.md) +——>——>——>——> [应用事件打点概述](application-dev/dfx/hiappevent-overview.md) -——>——>——>——> [应用事件开发指导](application-dev/application-event-logging/hiappevent-guidelines.md) +——>——>——>——> [应用事件开发指导](application-dev/dfx/hiappevent-guidelines.md) ——>——>——> [DevEco Studio(OpenHarmony)使用指南](application-dev/quick-start/deveco-studio-user-guide-for-openharmony.md)