diff --git a/en/application-dev/Readme-EN.md b/en/application-dev/Readme-EN.md index d854b82e015d4bbf670b773670fd41ed1b856d03..95504e593a1ae40a3f8853ca28f3067c71729315 100644 --- a/en/application-dev/Readme-EN.md +++ b/en/application-dev/Readme-EN.md @@ -41,18 +41,46 @@ - [Resource Categories and Access](quick-start/resource-categories-and-access.md) - Learning ArkTS - [Getting Started with ArkTS](quick-start/arkts-get-started.md) - - ArkTS Syntax (Declarative UI) - - [Basic UI Description](quick-start/arkts-basic-ui-description.md) - - State Management - - [Basic Concepts](quick-start/arkts-state-mgmt-concepts.md) - - [State Management with Page-level Variables](quick-start/arkts-state-mgmt-page-level.md) - - [State Management with Application-level Variables](quick-start/arkts-state-mgmt-application-level.md) - - [Dynamic UI Element Building](quick-start/arkts-dynamic-ui-elememt-building.md) - - [Rendering Control](quick-start/arkts-rendering-control.md) - - [Restrictions and Extensions](quick-start/arkts-restrictions-and-extensions.md) + - Basic Syntax + - [Basic Syntax Overview](quick-start/arkts-basic-syntax-overview.md) + - [Declarative UI Description](quick-start/arkts-declarative-ui-description.md) + - Custom Component + - [Creating a Custom Component](quick-start/arkts-create-custom-components.md) + - [Page and Custom Component Lifecycle](quick-start/arkts-page-custom-components-lifecycle.md) + - [\@Builder: Custom Builder Function](quick-start/arkts-builder.md) + - [\@BuilderParam: @Builder Function Reference](quick-start/arkts-builderparam.md) + - [\@Styles: Definition of Resusable Styles](quick-start/arkts-style.md) + - [\@Extend: Extension of Built-in Components](quick-start/arkts-extend.md) + - [stateStyles: Polymorphic Style](quick-start/arkts-statestyles.md) + - State Management + - [State Management Overview](quick-start/arkts-state-management-overview.md) + - Component State Management + - [\@State: State Owned by Component](quick-start/arkts-state.md) + - [\@Prop: One-Way Synchronization from Parent to Child Components](quick-start/arkts-prop.md) + - [\@Link: Two-Way Synchronization Between Parent and Child Components](quick-start/arkts-link.md) + - [\@Provide and \@Consume: Two-Way Synchronization with Descendant Components](quick-start/arkts-provide-and-consume.md) + - [\@Observed and \@ObjectLink: Observing Attribute Changes in Nested Class Objects](quick-start/arkts-observed-and-objectlink.md) + - Application State Management + - [Application State Management Overview](quick-start/arkts-application-state-management-overview.md) + - [LocalStorage: UI State Storage](quick-start/arkts-localstorage.md) + - [AppStorage: Application-wide UI State Storage](quick-start/arkts-appstorage.md) + - [PersistentStorage: Application State Persistence](quick-start/arkts-persiststorage.md) + - [Environment: Device Environment Query](quick-start/arkts-environment.md) + - Other State Management Features + - [Overview of Other State Management Features](quick-start/arkts-other-state-mgmt-functions-overview.md) + - [\@Watch: Getting Notified of State Variable Changes](quick-start/arkts-watch.md) + - [$$ Syntax: Two-Way Synchronization of Built-in Components](quick-start/arkts-two-way-sync.md) + - Rendering Control + - [Rendering Control Overview](quick-start/arkts-rendering-control-overview.md) + - [if/else: Conditional Rendering](quick-start/arkts-rendering-control-ifelse.md) + - [ForEach: Rendering of Repeated Content](quick-start/arkts-rendering-control-foreach.md) + - [LazyForEach: Lazy Data Loading](quick-start/arkts-rendering-control-lazyforeach.md) + + - Development - [Application Models](application-models/Readme-EN.md) - [UI Development](ui/Readme-EN.md) + - [Web](web/Readme-EN.md) - [Notification](notification/Readme-EN.md) - [Window Manager](windowmanager/Readme-EN.md) - [WebGL](webgl/Readme-EN.md) @@ -86,6 +114,7 @@ - [ArkTS and JS APIs](reference/apis/Readme-EN.md) - [Error Codes](reference/errorcodes/Readme-EN.md) - Native APIs + - [Native APIs](reference/native-apis/Readme-EN.md) - [Standard Libraries](reference/native-lib/third_party_libc/musl.md) - [Node_API](reference/native-lib/third_party_napi/napi.md) - [FAQs](faqs/Readme-EN.md) diff --git a/en/application-dev/database/Readme-EN.md b/en/application-dev/database/Readme-EN.md index b397b5b38682c9910724ea70e4759fe9a9aaf06e..77e1d8f9738d949ce9b0f0396bf66f99b9bf924e 100644 --- a/en/application-dev/database/Readme-EN.md +++ b/en/application-dev/database/Readme-EN.md @@ -5,7 +5,7 @@ - [Overview of Application Data Persistence](app-data-persistence-overview.md) - [Persisting Preferences Data](data-persistence-by-preferences.md) - [Persisting KV Store Data](data-persistence-by-kv-store.md) - - [Persisting RDB Store Data] (data-persistence-by-rdb-store.md) + - [Persisting RDB Store Data](data-persistence-by-rdb-store.md) - Distributed Application Data Synchronization - [Distributed Application Data Synchronization Overview](sync-app-data-across-devices-overview.md) - [Cross-Device Synchronization of KV Stores](data-sync-of-kv-store.md) @@ -16,7 +16,7 @@ - [Database Backup and Restoration](data-backup-and-restore.md) - [Database Encryption](data-encryption.md) - [Access Control by Device and Data Level](access-control-by-device-and-data-level.md) -- Cross-Application Data Sharing (Available Only for System Applications) +- Cross-Application Data Sharing (for System Applications Only) - [Cross-Application Data Sharing Overview](share-device-data-across-apps-overview.md) - [Sharing Data Using DataShareExtensionAbility](share-data-by-datashareextensionability.md) - [Sharing Data in Silent Access](share-data-by-silent-access.md) diff --git a/en/application-dev/file-management/Readme-EN.md b/en/application-dev/file-management/Readme-EN.md index 1e644dbac0ff2cf0e9f9deb205d234abc716ac08..bdc1bc7c1b00195bc24c71396f4fed78b93de15a 100644 --- a/en/application-dev/file-management/Readme-EN.md +++ b/en/application-dev/file-management/Readme-EN.md @@ -1,4 +1,4 @@ -# File +# File Management - [File Management Overview](file-management-overview.md) - Application File @@ -20,4 +20,4 @@ - Distributed File System - [Distributed File System Overview](distributed-fs-overview.md) - [Setting the Security Level of a Distributed File](set-security-label.md) - - [Access Files Across Devices](file-access-across-devices.md) + - [Accessing Files Across Devices](file-access-across-devices.md) diff --git a/en/application-dev/file-management/file-access-across-devices.md b/en/application-dev/file-management/file-access-across-devices.md index 434af1a2920a9f9144dfa6e29bcf57edbd57bd93..840078f5f982d55a9d9a3713fafa49d632d352f8 100644 --- a/en/application-dev/file-management/file-access-across-devices.md +++ b/en/application-dev/file-management/file-access-across-devices.md @@ -1,4 +1,4 @@ -# Access Files Across Devices +# Accessing Files Across Devices The distributed file system provides cross-device file access capabilities for applications. For the same application installed on multiple devices, you can implement read and write of the files in the application's distributed directory (**/data/storage/el2/distributedfiles/**) across devices by using [ohos.file.fs](app-file-access.md). For example, device A and device B are installed with the same application. After device A and device B are connected to form a Virtual Device, the application on device A can access the files of the same application on Device B. What you need to do is place the files to the distributed directory. diff --git a/en/application-dev/media/Readme-EN.md b/en/application-dev/media/Readme-EN.md index f3a233ca129527db112459ab5110df49b8e1052d..efc78832291fda395506dc0864af4fae0f068621 100755 --- a/en/application-dev/media/Readme-EN.md +++ b/en/application-dev/media/Readme-EN.md @@ -45,11 +45,11 @@ - [Session Management](camera-session-management.md) - [Camera Preview](camera-preview.md) - [Camera Photographing](camera-shooting.md) - - [Video Recording](camera-recording.md) + - [Camera Recording](camera-recording.md) - [Camera Metadata](camera-metadata.md) - Best Practices - [Camera Photographing Sample](camera-shooting-case.md) - - [Video Recording Sample](camera-recording-case.md) + - [Camera Recording Sample](camera-recording-case.md) - Image - [Image Overview](image-overview.md) - [Image Decoding](image-decoding.md) diff --git a/en/application-dev/media/camera-recording-case.md b/en/application-dev/media/camera-recording-case.md index 4d284f7e675fe0693240bbb678391147926652e7..7aedbf5688812c47542ee627329b137325f17bbc 100644 --- a/en/application-dev/media/camera-recording-case.md +++ b/en/application-dev/media/camera-recording-case.md @@ -1,4 +1,4 @@ -# Video Recording Sample +# Camera Recording Sample ## Development Process diff --git a/en/application-dev/media/camera-recording.md b/en/application-dev/media/camera-recording.md index 421ff990bf45b372dd39cd3346e29b636f292762..208b0664204ef2f74bb1160702053bde61fdf316 100644 --- a/en/application-dev/media/camera-recording.md +++ b/en/application-dev/media/camera-recording.md @@ -1,4 +1,4 @@ -# Video Recording +# Camera Recording Video recording is also an important function of the camera application. Video recording is the process of cyclic capturing of frames. To smooth videos, you can follow step 4 in [Camera Photographing](camera-shooting.md) to set the resolution, flash, focal length, photo quality, and rotation angle. diff --git a/en/application-dev/quick-start/Readme-EN.md b/en/application-dev/quick-start/Readme-EN.md index a60e0f7ef7b15e9b6a32f066a6c3eecbc32f6528..b7d98534c97fbf95b23ff1fb53ba67319696ef40 100644 --- a/en/application-dev/quick-start/Readme-EN.md +++ b/en/application-dev/quick-start/Readme-EN.md @@ -39,17 +39,37 @@ - [Resource Categories and Access](resource-categories-and-access.md) - Learning ArkTS - [Getting Started with ArkTS](arkts-get-started.md) - - ArkTS Syntax (Declarative UI) - - [Basic UI Description](arkts-basic-ui-description.md) - - State Management - - [Basic Concepts](arkts-state-mgmt-concepts.md) - - [State Management with Page-level Variables](arkts-state-mgmt-page-level.md) - - [State Management with Application-level Variables](arkts-state-mgmt-application-level.md) - - [Dynamic UI Element Building](arkts-dynamic-ui-elememt-building.md) - - [Rendering Control](arkts-rendering-control.md) - - [Restrictions and Extensions](arkts-restrictions-and-extensions.md) -- FAQs - - [Full SDK Compilation Guide](full-sdk-compile-guide.md) - - [Guide to Switching to Full SDK](full-sdk-switch-guide.md) -- Tools - - [DevEco Studio (OpenHarmony) User Guide](deveco-studio-user-guide-for-openharmony.md) \ No newline at end of file + - Basic Syntax + - [Basic Syntax Overview](arkts-basic-syntax-overview.md) + - [Declarative UI Description](arkts-declarative-ui-description.md) + - Custom Component + - [Creating a Custom Component](arkts-create-custom-components.md) + - [Page and Custom Component Lifecycle](arkts-page-custom-components-lifecycle.md) + - [\@Builder: Custom Builder Function](arkts-builder.md) + - [\@BuilderParam: @Builder Function Reference](arkts-builderparam.md) + - [\@Styles: Definition of Resusable Styles](arkts-style.md) + - [\@Extend: Extension of Built-in Components](arkts-extend.md) + - [stateStyles: Polymorphic Style](arkts-statestyles.md) + - State Management + - [State Management Overview](arkts-state-management-overview.md) + - Component State Management + - [\@State: State Owned by Component](arkts-state.md) + - [\@Prop: One-Way Synchronization from Parent to Child Components](arkts-prop.md) + - [\@Link: Two-Way Synchronization Between Parent and Child Components](arkts-link.md) + - [\@Provide and \@Consume: Two-Way Synchronization with Descendant Components](arkts-provide-and-consume.md) + - [\@Observed and \@ObjectLink: Observing Attribute Changes in Nested Class Objects](arkts-observed-and-objectlink.md) + - Application State Management + - [Application State Management Overview](arkts-application-state-management-overview.md) + - [LocalStorage: UI State Storage](arkts-localstorage.md) + - [AppStorage: Application-wide UI State Storage](arkts-appstorage.md) + - [PersistentStorage: Application State Persistence](arkts-persiststorage.md) + - [Environment: Device Environment Query](arkts-environment.md) + - Other State Management Features + - [Overview of Other State Management Features](arkts-other-state-mgmt-functions-overview.md) + - [\@Watch: Getting Notified of State Variable Changes](arkts-watch.md) + - [$$ Syntax: Two-Way Synchronization of Built-in Components](arkts-two-way-sync.md) + - Rendering Control + - [Rendering Control Overview](arkts-rendering-control-overview.md) + - [if/else: Conditional Rendering](arkts-rendering-control-ifelse.md) + - [ForEach: Rendering of Repeated Content](arkts-rendering-control-foreach.md) + - [LazyForEach: Lazy Data Loading](arkts-rendering-control-lazyforeach.md) diff --git a/en/application-dev/quick-start/arkts-application-state-management-overview.md b/en/application-dev/quick-start/arkts-application-state-management-overview.md new file mode 100644 index 0000000000000000000000000000000000000000..b481f79298e585c00a8a6e5c80f1c6a5cc092949 --- /dev/null +++ b/en/application-dev/quick-start/arkts-application-state-management-overview.md @@ -0,0 +1,13 @@ +# Application State Management Overview + + +The decorators described in the previous topics are used to share state variables within a page, that is, within a component tree. If you want to share state data at the application level or across multiple pages, you would need to apply application-level state management. ArkTS provides a wide variety of application state management capabilities: + + +- [LocalStorage](arkts-localstorage.md): API for storing the UI state, usually used for state sharing within a [UIAbility](https://gitee.com/openharmony/docs/blob/master/en/application-dev/reference/apis/js-apis-app-ability-uiAbility.md) or between pages. + +- [AppStorage](arkts-appstorage.md): special, singleton LocalStorage object within the application, which is created by the UI framework at application startup and provides the central storage for application UI state attributes. + +- [PersistentStorage](arkts-persiststorage.md): API for persisting application attributes. It is usually used together with AppStorage to persist selected AppStorage attributes to the disk so that their values are the same upon application re-start as they were when the application was closed. + +- [Environment](arkts-environment.md): a range of environment parameters regarding the device where the application runs. The environment parameters are synchronized to the AppStorage and can be used together with the AppStorage. diff --git a/en/application-dev/quick-start/arkts-appstorage.md b/en/application-dev/quick-start/arkts-appstorage.md new file mode 100644 index 0000000000000000000000000000000000000000..c5f6196fc66ceaeb8630342b4256d7350e5fd2a0 --- /dev/null +++ b/en/application-dev/quick-start/arkts-appstorage.md @@ -0,0 +1,203 @@ +# AppStorage: Application-wide UI State Storage + + +AppStorage provides the central storage for mutable application UI state attributes. It is bound to the application process and is created by the UI framework at application startup. + + +Unlike LocalStorage, which is usually used for page-level state sharing, AppStorage enables application-wide UI state sharing. AppStorage is equivalent to the hub of the entire application. [PersistentStorage](arkts-persiststorage.md) and [Environment](arkts-environment.md) data is passed first to AppStorage and then from AppStorage to the UI component. + + +This topic describes only the AppStorage application scenarios and related decorators: \@StorageProp and \@StorageLink. + + +## Overview + +AppStorage is a singleton LocalStorage object that is created by the UI framework at application startup. Its purpose is to provide the central storage for mutable application UI state attributes. AppStorage retains all those attributes and their values as long as the application remains running. Attributes are accessed using a unique key string value. + +UI components synchronize application state attributes with the AppStorage. Implementation of application business logic can access AppStorage as well. + +Selected state attributes of AppStorage can be synched with different data sources or data sinks. Those data sources and sinks can be on a local or remote device, and have different capabilities, such as data persistence (see [PersistentStorage](arkts-persiststorage.md)). These data sources and sinks are implemented in the business logic, separate from the UI. Link those AppStorage attributes to [@StorageProp](#storageprop) and [@StorageLink](#storagelink) whose values should be kept until application re-start. + + +## \@StorageProp + +As mentioned above, if you want to establish a binding between AppStorage and a custom component, you need to use the \@StorageProp and \@StorageLink decorators. Use \@StorageProp(key) or \@StorageLink(key) to decorate variables in the component. **key** identifies the attribute in AppStorage. + +When a custom component is initialized, the \@StorageProp(key)/\@StorageLink(key) decorated variable is initialized with the value of the attribute with the given key in AppStorage. Local initialization is mandatory. If an attribute with the given key is missing from AppStorage, it will be added with the stated initializing value. (Whether the attribute with the given key exists in AppStorage depends on the application logic.) + + +By decorating a variable with \@StorageProp(key), a one-way data synchronization is established with the attribute with the given key in AppStorage. A local change can be made, but it will not be synchronized to AppStorage. An update to the attribute with the given key in AppStorage will overwrite local changes. + + +### Rules of Use + +| \@StorageProp Decorator| Description | +| ------------------ | ---------------------------------------- | +| Decorator parameters | **key**: constant string, mandatory (note, the string is quoted) | +| Allowed variable types | Object, class, string, number, Boolean, enum, and array of these types. For details about the scenarios of nested objects, see [Observed Changes and Behavior](#observed-changes-and-behavior).
The type must be specified and must be the same as the corresponding attribute in LocalStorage. **any** is not supported. The **undefined** and **null** values are not allowed.| +| Synchronization type | One-way: from the attribute in AppStorage to the component variable.
The component variable can be changed locally, but an update from AppStorage will overwrite local changes.| +| Initial value for the decorated variable | Mandatory. It is used as the default value for initialization if the attribute does not exist in AppStorage.| + + +### Variable Transfer/Access Rules + +| Transfer/Access | Description | +| ---------- | ---------------------------------------- | +| Initialization and update from the parent component| Forbidden.| +| Subnode initialization | Supported; can be used to initialize a n \@State, \@Link, \@Prop, or \@Provide decorated variable in the child component.| +| Access | None. | + + + **Figure 1** \@StorageProp initialization rule + + +![en-us_image_0000001552978157](figures/en-us_image_0000001552978157.png) + + +### Observed Changes and Behavior + +**Observed Changes** + + +- When the decorated variable is of the Boolean, string, or number type, its value change can be observed. + +- When the decorated variable is of the class or Object type, its value change and value changes of all its attributes, that is, the attributes that **Object.keys(observedObject)** returns. + +- When the decorated variable is of the array type, the addition, deletion, and updates of array items can be observed. + + +**Framework Behavior** + + +- When the value change of the \@StorageProp(key) decorated variable is observed, the change is not synchronized to the attribute with the give key value in AppStorage. + +- The value change of the \@StorageProp(key) decorated variable only applies to the private member variables of the current component, but not other variables bound to the key. + +- When the data decorated by \@StorageProp(key) is a state variable, the change of the data is not synchronized to AppStorage, but the owning custom component is re-rendered. + +- When the attribute with the given key in AppStorage is updated, the change is synchronized to all the \@StorageProp(key) decorated data, and the local changes of the data are overwritten. + + +## \@StorageLink + +\@StorageLink(key) creates a two-way data synchronization with the attribute with the given key in AppStorage. + +1. If a local change occurs, it is synchronized to AppStorage. + +2. Changes in AppStorage are synchronized to all attributes with the given key, including one-way bound variables (\@StorageProp decorated variables and one-way bound variables created through \@Prop), two-way bound variables (\@StorageLink decorated variables and two-way bound variables created through \@Link), and other instances (such as PersistentStorage). + + +### Rules of Use + +| \@StorageLink Decorator| Description | +| ------------------ | ---------------------------------------- | +| Decorator parameters | **key**: constant string, mandatory (note, the string is quoted) | +| Allowed variable types | Object, class, string, number, Boolean, enum, and array of these types. For details about the scenarios of nested objects, see [Observed Changes and Behavior](#observed-changes-and-behavior).
The type must be specified and must be the same as the corresponding attribute in AppStorage. **any** is not supported. The **undefined** and **null** values are not allowed.| +| Synchronization type | Two-way: from the attribute in AppStorage to the custom component variable and back| +| Initial value for the decorated variable | Mandatory. It is used as the default value for initialization if the attribute does not exist in AppStorage.| + + +### Variable Transfer/Access Rules + +| Transfer/Access | Description | +| ---------- | ---------------------------------------- | +| Initialization and update from the parent component| Forbidden. | +| Subnode initialization | Supported; can be used to initialize a regular variable or \@State, \@Link, \@Prop, or \@Provide decorated variable in the child component.| +| Access | None. | + + + **Figure 2** \@StorageLink initialization rule + + +![en-us_image_0000001501938718](figures/en-us_image_0000001501938718.png) + + +### Observed Changes and Behavior + +**Observed Changes** + + +- When the decorated variable is of the Boolean, string, or number type, its value change can be observed. + +- When the decorated variable is of the class or Object type, its value change and value changes of all its attributes, that is, the attributes that **Object.keys(observedObject)** returns. + +- When the decorated variable is of the array type, the addition, deletion, and updates of array items can be observed. + + +**Framework Behavior** + + +1. When the value change of the \@StorageLink(key) decorated variable is observed, the change is synchronized to the attribute with the give key value in AppStorage. + +2. Once the attribute with the given key in AppStorage is updated, all the data (including \@StorageLink and \@StorageProp decorated variables) bound to the attribute key is changed synchronously. + +3. When the data decorated by \@StorageLink(key) is a state variable, the change of the data is synchronized to AppStorage, and the owning custom component is re-rendered. + + +## Application Scenarios + + +### Example of Using AppStorage and LocalStorage from Application Logic + +Since AppStorage is a singleton, its APIs are all static ones. How these APIs work resembles the non-static APIs of LocalStorage. + + +```ts +AppStorage.SetOrCreate('PropA', 47); + +let storage: LocalStorage = new LocalStorage({ 'PropA': 17 }); +let propA: number = AppStorage.Get('PropA') // propA in AppStorage == 47, propA in LocalStorage == 17 +var link1: SubscribedAbstractProperty = AppStorage.Link('PropA'); // link1.get() == 47 +var link2: SubscribedAbstractProperty = AppStorage.Link('PropA'); // link2.get() == 47 +var prop: SubscribedAbstractProperty = AppStorage.Prop('PropA'); // prop.get() = 47 + +link1.set(48); // two-way sync: link1.get() == link2.get() == prop.get() == 48 +prop.set(1); // one-way sync: prop.get()=1; but link1.get() == link2.get() == 48 +link1.set(49); // two-way sync: link1.get() == link2.get() == prop.get() == 49 + +storage.get('PropA') // == 17 +storage.set('PropA', 101); +storage.get('PropA') // == 101 + +AppStorage.Get('PropA') // == 49 +link1.get() // == 49 +link2.get() // == 49 +prop.get() // == 49 +``` + + +### Example of Using AppStorage and LocalStorage from Inside the UI + +\@StorageLink works together with the AppStorage in the same way as \@LocalStorageLink works together with LocalStorage. It creates two-way data synchronization with an attribute in AppStorage. + + +```ts +AppStorage.SetOrCreate('PropA', 47); +let storage = new LocalStorage({ 'PropA': 48 }); + +@Entry(storage) +@Component +struct CompA { + @StorageLink('PropA') storLink: number = 1; + @LocalStorageLink('PropA') localStorLink: number = 1; + + build() { + Column({ space: 20 }) { + Text(`From AppStorage ${this.storLink}`) + .onClick(() => this.storLink += 1) + + Text(`From LocalStorage ${this.localStorLink}`) + .onClick(() => this.localStorLink += 1) + } + } +} +``` + + +## Restrictions + +When using AppStorage together with [PersistentStorage](arkts-persiststorage.md) and [Environment](arkts-environment.md), pay attention to the following: + +- A call to **PersistentStorage.PersistProp()** after creating the attribute in AppStorage uses the type and value in AppStorage and overwrites any attribute with the same name in PersistentStorage. In light of this, the opposite order of calls is recommended. For an example of incorrect usage, see [Accessing Attribute in AppStorage Before PersistentStorage](arkts-persiststorage.md#accessing-attribute-in-appstorage-before-persistentstorage). + +- A call to **Environment.EnvProp()** after creating the attribute in AppStorage will fail. This is because AppStorage already has an attribute with the same name, and the environment variable will not be written into AppStorage. Therefore, you are advised not to use the preset environment variable name in AppStorage. diff --git a/en/application-dev/quick-start/arkts-basic-syntax-overview.md b/en/application-dev/quick-start/arkts-basic-syntax-overview.md new file mode 100644 index 0000000000000000000000000000000000000000..59dd8e9e0ebb02f4f76b59985fe45e2e6b1f4cdd --- /dev/null +++ b/en/application-dev/quick-start/arkts-basic-syntax-overview.md @@ -0,0 +1,40 @@ +# Basic Syntax Overview + + +With a basic understanding of the ArkTS language, let's look into the basic composition of ArkTS through an example. As shown below, when the user clicks the button, the text content changes from **Hello World** to **Hello ArkUI**. + + + **Figure 1** Example effect drawing + +![Video_2023-03-06_152548](figures/Video_2023-03-06_152548.gif) + + +In this example, the basic composition of ArkTS is as follows. + + + **Figure 2** Basic composition of ArkTS + +![arkts-basic-grammar](figures/arkts-basic-grammar.png) + + +- Decorator: design pattern used to decorate classes, structures, methods, and variables to assign special meanings to them. In the preceding sample code, \@Entry, \@Component, and \@State are decorators. \@Component indicates a custom component, \@Entry indicates that the custom component is an entry component, and \@State indicates a state variable in the component, whose change will trigger the UI to re-render. + +- [UI description](arkts-declarative-ui-description.md): declarative description of the UI structure, such as the code block of the **build()** method. + +- [Custom component](arkts-create-custom-components.md): reusable UI unit, which can be combined with other components, such as the struct **Hello** decorated by @Component. + +- Built-in component: default basic or container component preset in ArkTS, which can be directly invoked, such as** \**,** \**, **\**, and **\