ts-basic-components-progress.md 4.8 KB
Newer Older
Z
zengyawen 已提交
1
# Progress
Z
zengyawen 已提交
2

E
ester.zhou 已提交
3
The **\<Progress>** component is used to provide a progress indicator that displays the progress of content loading or an operation.
Z
zengyawen 已提交
4

5
>  **NOTE**
E
ester.zhou 已提交
6
>
7
>  This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version.
Z
zengyawen 已提交
8 9 10


## Child Components
Z
zengyawen 已提交
11

E
ester.zhou 已提交
12
Not supported
Z
zengyawen 已提交
13 14


Z
zengyawen 已提交
15 16
## APIs

E
ester.zhou 已提交
17
Progress(options: {value: number, total?: number, type?: ProgressType})
Z
zengyawen 已提交
18

E
ester.zhou 已提交
19
Creates a progress indicator.
Z
zengyawen 已提交
20

E
ester.zhou 已提交
21
**Parameters**
Z
zengyawen 已提交
22

E
ester.zhou 已提交
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| value | number | Yes| Current progress.|
| total | number | No| Total progress.<br>Default value: **100**|
| type<sup>8+</sup> | ProgressType | No| Type of the progress indicator.<br>Default value: **ProgressType.Linear**|
| style<sup>deprecated</sup> | ProgressStyle | No| Style the progress indicator.<br>This parameter is deprecated since API version 8. You are advised to use **type** instead.<br>Default value: **ProgressStyle.Linear**|

## ProgressType

| Name| Description|
| -------- | -------- |
| Linear | Linear type.|
| Ring<sup>8+</sup> | Indeterminate ring type. The ring fills up as the progress increases.|
| Eclipse<sup>8+</sup> | Eclipse type, which visualizes the progress in a way similar to the moon waxing from new to full.|
| ScaleRing<sup>8+</sup> | Determinate ring type, which is similar to the clock scale.|
| Capsule<sup>8+</sup> | Capsule type. At both ends, the progress indicator works in a same manner as the eclipse type. In the middle part of the capsule, the progress indicator works in a same manner as the linear type.|

##  ProgressStyle

| Name     | Description                                                        |
| --------- | ------------------------------------------------------------ |
| Linear    | Linear type.                                                  |
| Ring      | Indeterminate ring type. The ring fills up as the progress increases.            |
| Eclipse   | Eclipse type, which visualizes the progress in a way similar to the moon waxing from new to full.|
| ScaleRing | Determinate ring type, which is similar to the clock scale.        |
| Capsule   | Capsule type. At both ends, the progress indicator works in a same manner as the eclipse type. In the middle part of the capsule, the progress indicator works in a same manner as the linear type.|
Z
zengyawen 已提交
49 50 51

## Attributes

E
ester.zhou 已提交
52 53 54 55 56
| Name| Type| Description|
| -------- | -------- | -------- |
| value | number | Current progress.|
| color | [ResourceColor](ts-types.md#resourcecolor) | Background color of the progress indicator.|
| style<sup>8+</sup> | {<br>strokeWidth?: [Length](ts-types.md#length),<br>scaleCount?: number,<br>scaleWidth?: [Length](ts-types.md#length)<br>} | Component style.<br>- **strokeWidth**: stroke width of the progress indicator.<br>- **scaleCount**: number of divisions on the determinate ring-type process indicator.<br>- **scaleWidth**: scale bar width of the determinate ring-type process indicator. If it is greater than the progress indicator width, the default value is used instead.|
Z
zengyawen 已提交
57 58 59 60


## Example

E
ester.zhou 已提交
61 62
```ts
// xxx.ets
Z
zengyawen 已提交
63 64 65 66
@Entry
@Component
struct ProgressExample {
  build() {
Z
zengyawen 已提交
67
    Column({ space: 15 }) {
Z
zengyawen 已提交
68
      Text('Linear Progress').fontSize(9).fontColor(0xCCCCCC).width('90%')
E
esterzhou 已提交
69 70
      Progress({ value: 10, type: ProgressType.Linear }).width(200)
      Progress({ value: 20, total: 150, type: ProgressType.Linear }).color(Color.Grey).value(50).width(200)
Z
zengyawen 已提交
71 72 73

      Text('Eclipse Progress').fontSize(9).fontColor(0xCCCCCC).width('90%')
      Row({ space: 40 }) {
E
esterzhou 已提交
74 75
        Progress({ value: 10, type: ProgressType.Eclipse }).width(100)
        Progress({ value: 20, total: 150, type: ProgressType.Eclipse }).color(Color.Grey).value(50).width(100)
Z
zengyawen 已提交
76 77 78 79
      }

      Text('ScaleRing Progress').fontSize(9).fontColor(0xCCCCCC).width('90%')
      Row({ space: 40 }) {
E
esterzhou 已提交
80 81
        Progress({ value: 10, type: ProgressType.ScaleRing }).width(100)
        Progress({ value: 20, total: 150, type: ProgressType.ScaleRing })
Z
zengyawen 已提交
82 83 84 85 86 87
          .color(Color.Grey).value(50).width(100)
          .style({ strokeWidth: 15, scaleCount: 15, scaleWidth: 5 })
      }

      Text('Ring Progress').fontSize(9).fontColor(0xCCCCCC).width('90%')
      Row({ space: 40 }) {
E
esterzhou 已提交
88 89
        Progress({ value: 10, type: ProgressType.Ring }).width(100)
        Progress({ value: 20, total: 150, type: ProgressType.Ring })
Z
zengyawen 已提交
90 91 92 93 94 95
          .color(Color.Grey).value(50).width(100)
          .style({ strokeWidth: 20, scaleCount: 30, scaleWidth: 20 })
      }

      Text('Capsule Progress').fontSize(9).fontColor(0xCCCCCC).width('90%')
      Row({ space: 40 }) {
E
ester.zhou 已提交
96
        Progress({ value: 10, type: ProgressType.Capsule }).width(100).height(50)
E
ester.zhou 已提交
97 98 99 100 101
        Progress({ value: 20, total: 150, type: ProgressType.Capsule })
          .color(Color.Grey)
          .value(50)
          .width(100)
          .height(50)
Z
zengyawen 已提交
102 103
      }
    }.width('100%').margin({ top: 30 })
Z
zengyawen 已提交
104 105 106 107
  }
}
```

Z
zengyawen 已提交
108
![en-us_image_0000001212378432](figures/en-us_image_0000001212378432.gif)