Skip to content

Commit a31c6ba

Browse files
committed
docs: cleanup Progress
1 parent e0c54c8 commit a31c6ba

File tree

5 files changed

+37
-132
lines changed

5 files changed

+37
-132
lines changed
15.8 KB
Loading

content/screenshots/ios/Progress.png

55.8 KB
Loading

content/ui/progress.md

Lines changed: 26 additions & 131 deletions
Original file line numberDiff line numberDiff line change
@@ -1,170 +1,65 @@
11
---
22
title: Progress
3+
description: UI component to indicate the progress of a task.
4+
contributors:
5+
- rigor789
6+
- Ombuweb
37
---
48

59
`<Progress>` is a UI component that shows a bar to indicate the progress of a task.
610

711
See also: [ActivityIndicator](/ui/activity-indicator).
812

9-
---
10-
1113
<DeviceFrame type="ios">
12-
<img src="https://raw.githubusercontent.com/nativescript-vue/nativescript-vue-ui-tests/master/screenshots/ios-simulator103iPhone6/Progress.png"/>
14+
<img src="../screenshots/ios/Progress.png"/>
1315
</DeviceFrame>
1416
<DeviceFrame type="android">
15-
<img src="https://raw.githubusercontent.com/nativescript-vue/nativescript-vue-ui-tests/master/screenshots/android23/Progress.png" />
17+
<img src="../screenshots/android/Progress.png"/>
1618
</DeviceFrame>
1719

18-
### Creating a Progress
19-
20-
<!-- /// flavor plain -->
21-
22-
```xml
23-
<Progress
24-
width="100%"
25-
value="{{ progressValue }}"
26-
maxValue="{{ progressMaxValue }}"
27-
loaded="onProgressLoaded"
28-
/>
29-
```
30-
31-
```ts
32-
import {
33-
Observable,
34-
Page,
35-
Progress,
36-
PropertyChangeData,
37-
} from '@nativescript/core'
38-
39-
export function onNavigatingTo(args) {
40-
const page = args.object as Page
41-
vm.set('progressValue', 10) // Initial value
42-
vm.set('progressMaxValue', 100) // Maximum value
43-
// Forcing progress value change (for demonstration)
44-
setInterval(() => {
45-
const value = vm.get('progressValue')
46-
vm.set('progressValue', value + 2)
47-
}, 300)
48-
page.bindingContext = vm
49-
}
50-
export function onProgressLoaded(args) {
51-
const myProgressBar = args.object as Progress
52-
myProgressBar.on('valueChange', (pargs: PropertyChangeData) => {
53-
// TIP: args (for valueChange of Progress) is extending EventData with oldValue & value parameters
54-
console.log(`Old Value: ${pargs.oldValue}`)
55-
console.log(`New Value: ${pargs.value}`)
56-
})
57-
}
58-
```
59-
60-
<!-- ///
20+
<<< @/../examples/src/ui/Progress/template.xml#example
6121

62-
/// flavor angular
22+
## Example
6323

64-
```xml
65-
<progress value="25" maxValue="100" (valueChanged)="onValueChanged($event)"></progress>
66-
```
67-
68-
```ts
69-
import { Component, OnInit } from '@angular/core'
70-
71-
@Component({
72-
moduleId: module.id,
73-
templateUrl: './styling.component.html',
74-
styleUrls: ['./styling.component.css']
75-
})
76-
export class StylingComponent implements OnInit {
77-
public progressValue: number
78-
79-
ngOnInit() {
80-
this.progressValue = 25
81-
}
82-
}
83-
```
84-
85-
///
24+
### Styling the Progress bar
8625

87-
/// flavor react
26+
To style the Progress bar, set the `backgroundColor` and `color`.
8827

89-
```tsx
90-
function getTaskCompletionPercent() {
91-
// Just a stub method to illustrate the concept.
92-
return 10
93-
}
94-
95-
;<progress value={getTaskCompletionPercent()} maxValue={100} />
96-
```
97-
98-
///
99-
100-
/// flavor vue
28+
The `backgroundColor` will be applied to the track, and the `color` will be applied to the bar itself.
10129

10230
```xml
103-
<progress :value="currentProgress" />
104-
```
105-
106-
///
107-
108-
/// flavor svelte
109-
110-
```xml
111-
<progress value="{currentProgress}" />
112-
```
113-
114-
/// -->
115-
116-
### Styling Progress
117-
118-
Using `backgroundColor` (**CSS**: `background-color`) & color to change the Progress style.
119-
120-
:::tip Note
121-
`backgroundColor` will work only on `iOS`; on `Android` the background will be the color with applied opacity.
122-
:::
123-
124-
```xml
125-
<progress
126-
value="50"
127-
maxValue="100"
128-
backgroundColor="red"
129-
color="green"
130-
></progress>
131-
<!-- Using @nativescript/tailwind to change the Progress style -->
132-
<progress value="25" maxValue="100" class="bg-red-500 text-red-900"></progress>
31+
<Progress
32+
value="75"
33+
backgroundColor="#fff"
34+
color="#000"
35+
/>
13336
```
13437

13538
## Props
13639

13740
### value
13841

139-
```xml
140-
<Progress value="{{ progressValue }}" />
42+
```ts
43+
value: number
14144
```
14245

143-
ets or sets the current value of the progress bar. Must be within the range of 0 to [maxValue](#maxvalue).
46+
Gets or sets the current value of the progress bar.
14447

145-
---
48+
Must be within the range of 0 to [maxValue](#maxValue).
14649

147-
### maxValue
50+
### maxValue {#maxValue}
14851

149-
```xml
150-
<Progress maxValue="{{ progressMaxValue }}" />
52+
```ts
53+
maxValue: number
15154
```
15255

153-
Gets or sets the maximum value of the progress bar. Defaults to: `100`.
56+
Gets or sets the maximum value of the progress bar.
15457

155-
---
58+
Defaults to: `100`.
15659

15760
### ...Inherited
15861

159-
For additional inherited properties, refer to the [API Reference](https://docs.nativescript.org/api-reference/classes/progress)
160-
161-
## Events
162-
163-
### valueChange
164-
165-
Emitted when the `value` property changes.
166-
167-
---
62+
For additional inherited properties, refer to the [API Reference](/api/class/Progress)
16863

16964
## Native Component
17065

examples/flows/screenshots.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@ output.screenshots = [
1010
'Label',
1111
'ListPicker',
1212
'ListView',
13-
'Placeholder'
13+
'Placeholder',
14+
'Progress',
1415
]

examples/src/ui/Progress/template.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<Page>
2+
<GridLayout>
3+
<ContentView verticalAlignment="center">
4+
<!-- #region example -->
5+
<Progress value="75" />
6+
<!-- #endregion example -->
7+
</ContentView>
8+
</GridLayout>
9+
</Page>

0 commit comments

Comments
 (0)