Repository navigation
Expand file tree
/
Copy pathProgressView.web.js
More file actions
94 lines (78 loc) · 2.34 KB
/
Copy pathProgressView.web.js
File metadata and controls
94 lines (78 loc) · 2.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/**
* Copyright (c) 2015-present, Alibaba Group Holding Limited.
* All rights reserved.
*
* @providesModule ReactProgressView
*/
'use strict';
import React, { Component } from 'react';
import View from 'ReactView';
import StyleSheet from 'ReactStyleSheet';
import { Mixin as NativeMethodsMixin } from 'NativeMethodsMixin';
import mixin from 'react-mixin';
import autobind from 'autobind-decorator';
class ProgressView extends Component {
render() {
let specificStyle = {
progressTint: {},
progressTrack: {},
};
if ( this.props.trackImage ) {
specificStyle.progressTrack.background = 'url(' + this.props.trackImage.uri + ') no-repeat 0 0';
specificStyle.progressTrack.backgroundSize = '100% 100%';
}
if ( this.props.trackTintColor ) {
specificStyle.progressTrack.background = this.props.trackTintColor;
}
if ( this.props.progressViewStyle == 'bar' ) {
specificStyle.progressTrack.background = 'transparent';
}
if ( this.props.progressImage ) {
specificStyle.progressTint.background = 'url(' + this.props.progressImage.uri + ') no-repeat 0 0';
specificStyle.progressTint.backgroundSize = '100% 100%';
}
if ( this.props.progressTintColor ) {
specificStyle.progressTint.background = this.props.progressTintColor;
}
// process progress
let progress = this.props.progress;
if ( progress >= 1 ) {
progress = 1;
} else if ( progress <= 0 ) {
progress = 0;
}
specificStyle.progressTint.width = 100 * progress + '%';
specificStyle = StyleSheet.create(specificStyle);
return (
<View style={[styles.progressView, this.props.style]}>
<View style={[styles.progressTrack, specificStyle.progressTrack]}>
<View style={[styles.progressTint, specificStyle.progressTint]} />
</View>
</View>
);
}
};
let styles = StyleSheet.create({
progressView: {
display: 'block',
height: '2px',
width: '100%',
},
progressTint: {
position: 'absolute',
left: 0,
width: 0,
height: '100%',
background: '#0079fe',
},
progressTrack: {
position: 'relative',
width: '100%',
height: '100%',
background: '#b4b4b4',
}
});
mixin.onClass(ProgressView, NativeMethodsMixin);
autobind(ProgressView);
ProgressView.isReactNativeComponent = true;
export default ProgressView;