diff --git a/en/application-dev/reference/arkui-ts/ts-offscreencanvasrenderingcontext2d.md b/en/application-dev/reference/arkui-ts/ts-offscreencanvasrenderingcontext2d.md index 4c996f22ce50e78e700feef8e334d0961579af7e..f513d46ae5849a33ed8c1eb8c4b7255e4c8403cf 100644 --- a/en/application-dev/reference/arkui-ts/ts-offscreencanvasrenderingcontext2d.md +++ b/en/application-dev/reference/arkui-ts/ts-offscreencanvasrenderingcontext2d.md @@ -2215,7 +2215,7 @@ Since API version 9, this API is supported in ArkTS widgets. **Parameters** -| Parameters | Type | Mandatory | Default Value | Description | +| Name | Type | Mandatory | Default Value | Description | | ---- | ------ | ---- | ---- | ------------- | | sw | number | Yes | 0 | Width of the **ImageData** object.| | sh | number | Yes | 0 | Height of the **ImageData** object.| 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 46af6ad7fc87c0cf7e1a268462d255a8c1337023..feb63e3f4a94158424dc7892e0abc8a7ea747d94 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 @@ -2,7 +2,7 @@ Universal text attributes include text style attributes applicable to text containers. -> **NOTE** +> **NOTE** > > The APIs of this module are supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. diff --git a/en/application-dev/ui/arkts-layout-development-create-looping.md b/en/application-dev/ui/arkts-layout-development-create-looping.md new file mode 100644 index 0000000000000000000000000000000000000000..4845c9dc535a89a990eea9117271d1655d41476b --- /dev/null +++ b/en/application-dev/ui/arkts-layout-development-create-looping.md @@ -0,0 +1,318 @@ +# Creating a Swiper + + +The \<[Swiper](../reference/arkui-ts/ts-container-swiper.md)> component is a container that is able to display child components in looping mode. It is typically used in scenarios such as display of recommended content on the home page. + + +## Layout and Constraints + +The size of the **\** component follows its own size settings (if configured) or adapts based on the size of its child components. + + +## Loop Playback + +The **loop** attribute sets whether to enable loop playback. Its default value is **true**. + +When **loop** is set to **true**, the user can switch to the previous or next page when they are on the first or last page. + + Example of setting **loop** to **true**: + +```ts +... +private swiperController: SwiperController = new SwiperController() +... +Swiper(this.swiperController) { + Text("0") + .width('90%') + .height('100%') + .backgroundColor(Color.Gray) + .textAlign(TextAlign.Center) + .fontSize(30) + + Text("1") + .width('90%') + .height('100%') + .backgroundColor(Color.Green) + .textAlign(TextAlign.Center) + .fontSize(30) + + Text("2") + .width('90%') + .height('100%') + .backgroundColor(Color.Blue) + .textAlign(TextAlign.Center) + .fontSize(30) +} +.loop(true) +``` + +![loop_true](figures/loop_true.gif) + + Example of setting **loop** to **false**: + +```ts +Swiper(this.swiperController) { + Text("0") + .width('90%') + .height('100%') + .backgroundColor(Color.Gray) + .textAlign(TextAlign.Center) + .fontSize(30) + + Text("1") + .width('90%') + .height('100%') + .backgroundColor(Color.Green) + .textAlign(TextAlign.Center) + .fontSize(30) + + Text("2") + .width('90%') + .height('100%') + .backgroundColor(Color.Blue) + .textAlign(TextAlign.Center) + .fontSize(30) +} +.loop(false) +``` + +![loop_false](figures/loop_false.gif) + + +## Automatic Playback + +The **autoPlay** attribute sets whether to enable automatic playback for child component switching. Its default value is **false**. + +When **autoPlay** is set to **true**, automatic playback is enabled for child component switching. The playback interval is specified by the **interval** attribute, which is **3000** by default, in milliseconds. + + Example of setting **autoPlay** to **true**: + +```ts +Swiper(this.swiperController) { + Text("0") + .width('90%') + .height('100%') + .backgroundColor(Color.Gray) + .textAlign(TextAlign.Center) + .fontSize(30) + + Text("1") + .width('90%') + .height('100%') + .backgroundColor(Color.Green) + .textAlign(TextAlign.Center) + .fontSize(30) + + Text("2") + .width('90%') + .height('100%') + .backgroundColor(Color.Pink) + .textAlign(TextAlign.Center) + .fontSize(30) +} +.loop(true) +.autoPlay(true) +.interval(1000) +``` + +![autoPlay](figures/autoPlay.gif) + + +## Navigation Dots Indicator + +The **\** component provides a navigation dots indicator, which is displayed in the bottom center of the component. You can customize the position and style of the navigation dots indicator through the **indicatorStyle **attribute. + +With the **indicatorStyle** attribute, you can set the position of the navigation dots indicator relative to the edges of the **\** component, in addition to the size, color, and mask of each navigation dot as well as the color of the selected navigation dot. + + Example of using the navigation dots indicator in its default style: + +```ts +Swiper(this.swiperController) { + Text("0") + .width('90%') + .height('100%') + .backgroundColor(Color.Gray) + .textAlign(TextAlign.Center) + .fontSize(30) + + Text("1") + .width('90%') + .height('100%') + .backgroundColor(Color.Green) + .textAlign(TextAlign.Center) + .fontSize(30) + + Text("2") + .width('90%') + .height('100%') + .backgroundColor(Color.Pink) + .textAlign(TextAlign.Center) + .fontSize(30) +} +``` + +![indicator](figures/indicator.PNG) + + Example of customizing the style of the navigation dots indicator, with the diameter of 30 vp, left margin of 0, and color of red: + +```ts +Swiper(this.swiperController) { + Text("0") + .width('90%') + .height('100%') + .backgroundColor(Color.Gray) + .textAlign(TextAlign.Center) + .fontSize(30) + + Text("1") + .width('90%') + .height('100%') + .backgroundColor(Color.Green) + .textAlign(TextAlign.Center) + .fontSize(30) + + Text("2") + .width('90%') + .height('100%') + .backgroundColor(Color.Pink) + .textAlign(TextAlign.Center) + .fontSize(30) +} +.indicatorStyle({ + size: 30, + left: 0, + color: Color.Red +}) +``` + +![ind](figures/ind.PNG) + + +## Page Switching Mode + +The **\** component supports three page switching modes: using the swipe gesture, using the navigation dots indicator, and using the controller. + + Switch pages through the controller: + +```ts +@Entry +@Component +struct SwiperDemo { + private swiperController: SwiperController = new SwiperController(); + + build() { + Column({ space: 5 }) { + Swiper(this.swiperController) { + Text("0") + .width(250) + .height(250) + .backgroundColor(Color.Gray) + .textAlign(TextAlign.Center) + .fontSize(30) + Text("1") + .width(250) + .height(250) + .backgroundColor(Color.Green) + .textAlign(TextAlign.Center) + .fontSize(30) + Text("2") + .width(250) + .height(250) + .backgroundColor(Color.Pink) + .textAlign(TextAlign.Center) + .fontSize(30) + } + .indicator(true) + + Row({ space: 12 }) { + Button('showNext') + .onClick(() => { + this.swiperController.showNext(); // Switch to the next page through the controller. + }) + Button('showPrevious') + .onClick(() => { + this.swiperController.showPrevious(); // Switch to the previous page through the controller. + }) + }.margin(5) + }.width('100%') + .margin({ top: 5 }) + } +} +``` + +![controll](figures/controll.gif) + + +## Playback Direction + +You can set the playback direction for the \ component through its **vertical** attribute. + +When **vertical** is set to **true**, vertical swiping is used. The default value of **vertical** is **false**. + + + Example of using horizontal swiping: + +```ts +Swiper(this.swiperController) { + ... +} +.indicator(true) +.vertical(false) +``` + + +![horizontal-swiping](figures/horizontal-swiping.PNG) + + + Example of using vertical swiping: + +```ts +Swiper(this.swiperController) { + ... +} +.indicator(true) +.vertical(true) +``` + + +![vertical-swiping](figures/vertical-swiping.PNG) + + +## Child Components Per Page + +You can set the number of child components per page for the **\** component through its [displayCount](../reference/arkui-ts/ts-container-swiper.md#attributes) attribute. + + To display two child components per page: + +```ts +Swiper(this.swiperController) { + Text("0") + .width(250) + .height(250) + .backgroundColor(Color.Gray) + .textAlign(TextAlign.Center) + .fontSize(30) + Text("1") + .width(250) + .height(250) + .backgroundColor(Color.Green) + .textAlign(TextAlign.Center) + .fontSize(30) + Text("2") + .width(250) + .height(250) + .backgroundColor(Color.Pink) + .textAlign(TextAlign.Center) + .fontSize(30) + Text("3") + .width(250) + .height(250) + .backgroundColor(Color.Blue) + .textAlign(TextAlign.Center) + .fontSize(30) +} +.indicator(true) +.displayCount(2) +``` + +![two](figures/two.PNG) diff --git a/en/application-dev/ui/arkts-popup-and-menu-components-popup.md b/en/application-dev/ui/arkts-popup-and-menu-components-popup.md new file mode 100644 index 0000000000000000000000000000000000000000..2176e02b39dfaf3b7bc59141835578f1ff0c55d9 --- /dev/null +++ b/en/application-dev/ui/arkts-popup-and-menu-components-popup.md @@ -0,0 +1,158 @@ +# Popup + + +You can bind the **Popup** attribute to a component to create a popup, specifying its content and interaction logic, and display state. It is mainly used for screen recording and message notification. + + +Popups can be defined with [PopupOptions](../reference/arkui-ts/ts-universal-attributes-popup.md#popupoptions) or [CustomPopupOptions](../reference/arkui-ts/ts-universal-attributes-popup.md#custompopupoptions8). In **PopupOptions**, you can set **primaryButton** and **secondaryButton** to include buttons in the popup. In **CustomPopupOptions**, you can create a custom popup through the [builder](../quick-start/arkts-builder.md) parameter. + + +## Text Popup + +Text popups are usually used to display text only and do not allow for user interactions. Bind the **Popup** attribute to a component. When the **show** parameter in the **bindPopup** attribute is set to **true**, a popup is displayed. + +If you bind the **Popup** attribute to a **\