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

Z
zengyawen 已提交
3

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

Z
zengyawen 已提交
8

E
ester.zhou 已提交
9
The **\<Progress>** component is used to provide a progress bar that displays the progress of content loading or an operation.
Z
zengyawen 已提交
10 11 12


## Required Permissions
Z
zengyawen 已提交
13

Z
zengyawen 已提交
14
None
Z
zengyawen 已提交
15

Z
zengyawen 已提交
16 17

## Child Components
Z
zengyawen 已提交
18

E
ester.zhou 已提交
19
Not supported
Z
zengyawen 已提交
20 21


Z
zengyawen 已提交
22 23
## APIs

E
ester.zhou 已提交
24
Progress(value: {value: number, total?: number, type?: ProgressType})
Z
zengyawen 已提交
25 26 27 28

Creates a progress bar.

- Parameters
E
ester.zhou 已提交
29
  | Name | Type | Mandatory | Default Value | Description |
Z
zengyawen 已提交
30
  | -------- | -------- | -------- | -------- | -------- |
E
esterzhou 已提交
31 32 33
  | value | number | Yes | - | Current progress. |
  | total | number | No | 100 | Total progress. |
  | type | ProgressType | No | ProgressType.Linear | Type of the progress bar. |
Z
zengyawen 已提交
34 35


E
esterzhou 已提交
36
- ProgressType enums
E
ester.zhou 已提交
37
  | Name | Description |
Z
zengyawen 已提交
38
  | -------- | -------- |
E
esterzhou 已提交
39 40 41 42 43
  | Linear | Linear type. |
  | Ring<sup>8+</sup> | Ring type without scale. 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<sup>8+</sup> | Ring type with scale, which is similar to the clock scale style. |
  | Capsule<sup>8+</sup> | Capsule type. At both ends, the progress bar changes from an arc to a straight line and from a straight line to an arc. In the middle part of the capsule, the progress bar moves to the right. |
Z
zengyawen 已提交
44 45 46 47


## Attributes

E
esterzhou 已提交
48
| Name | Type | Default Value | Description |
Z
zengyawen 已提交
49
| -------- | -------- | -------- | -------- |
E
esterzhou 已提交
50 51 52
| value | number | - | Current progress. |
| color | Color | - | Background color of the progress bar. |
| style<sup>8+</sup> | {<br/>strokeWidth? : Length,<br/>scaleCount? : number,<br/>scaleWidth? : Length<br/>} | - | Component style.<br/>- **strokeWidth**: width of the progress bar.<br/>- **scaleCount**: scale count of the circular progress bar.<br/>- **scaleWidth**: scale width of the circular progress bar.<br/>If the scale thickness is greater than the progress bar width, the default scale thickness is used. |
Z
zengyawen 已提交
53 54 55 56


## Example

E
esterzhou 已提交
57

E
ester.zhou 已提交
58 59
```ts
// xxx.ets
Z
zengyawen 已提交
60 61 62 63
@Entry
@Component
struct ProgressExample {
  build() {
Z
zengyawen 已提交
64
    Column({ space: 15 }) {
Z
zengyawen 已提交
65
      Text('Linear Progress').fontSize(9).fontColor(0xCCCCCC).width('90%')
E
esterzhou 已提交
66 67
      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 已提交
68 69 70

      Text('Eclipse Progress').fontSize(9).fontColor(0xCCCCCC).width('90%')
      Row({ space: 40 }) {
E
esterzhou 已提交
71 72
        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 已提交
73 74 75 76
      }

      Text('ScaleRing Progress').fontSize(9).fontColor(0xCCCCCC).width('90%')
      Row({ space: 40 }) {
E
esterzhou 已提交
77 78
        Progress({ value: 10, type: ProgressType.ScaleRing }).width(100)
        Progress({ value: 20, total: 150, type: ProgressType.ScaleRing })
Z
zengyawen 已提交
79 80 81 82 83 84
          .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 已提交
85 86
        Progress({ value: 10, type: ProgressType.Ring }).width(100)
        Progress({ value: 20, total: 150, type: ProgressType.Ring })
Z
zengyawen 已提交
87 88 89 90 91 92
          .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 已提交
93 94
        Progress({ value: 10, type: ProgressType.Capsule }).width(100).height(50)
        Progress({ value: 20, total: 150, type: ProgressType.Capsule }).color(Color.Grey).value(50).width(100).height(50)
Z
zengyawen 已提交
95 96
      }
    }.width('100%').margin({ top: 30 })
Z
zengyawen 已提交
97 98 99 100
  }
}
```

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