-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.android.js
164 lines (161 loc) · 4.05 KB
/
index.android.js
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
/**
* Created by TinySymphony on 2016-12-26.
* Android Examples
*/
import React, {Component} from 'react';
import {
AppRegistry,
StyleSheet,
View,
Text,
ScrollView
} from 'react-native';
import Grading from './Grading';
export default class grading extends Component {
constructor(props) {
super(props);
this.state = {
board: {
num: 124,
score: 4.5
},
arcs: {
score: 8.4
},
stars: {
score: 6.0
},
smiles: {
isLike: true
}
};
this.changeBoardScore = this.changeBoardScore.bind(this);
this.changeStarScore = this.changeStarScore.bind(this);
this.changeArcScore = this.changeArcScore.bind(this);
this.changeSmileScore = this.changeSmileScore.bind(this);
}
changeBoardScore(newScore) {
const {num, score} = this.state.board;
this.setState({
board: {
num: num + 1,
score: (score * num + newScore) / (num + 1)
}
});
}
changeStarScore(score) {
this.setState({
stars: {score: score}
});
}
changeArcScore(score) {
console.log(score);
this.setState({
arcs: {score: score}
});
}
changeSmileScore(score) {
this.setState({
smiles: {isLike: score}
});
}
render() {
return (
<ScrollView style={styles.container}>
<Text style={styles.welcome}>Examples about react-native-grading</Text>
<View style={styles.boardGrading}>
<Grading
score={this.state.board.score}
num={this.state.board.num}
defaultColor="#9ce0d6"
onGrading={this.changeBoardScore}
/>
<Grading score={4.0} num={72346} fontColor="#552da6" readOnly={true}/>
<Grading score={2.45} num={712338} activeColor="#2bb8aa" enable={false}/>
<Grading
score={4.9}
num={234234523478}
readOnly={true}
fontColor="#3c77b5"
/>
</View>
<View style={styles.starsGrading}>
<Grading
mode="stars"
scale={2.4}
score={this.state.stars.score}
scoreBase={10}
activeColor="#eb5461"
onGrading={this.changeStarScore}/>
<Grading
mode="stars"
scale={2}
scoreBase={8}
defaultColor="#dad9b8"
score={5}
enable={false}/>
<Grading mode="stars" score={4.45} readOnly={true}/>
</View>
<View style={styles.arcsGrading}>
<Grading mode="arcs" score={this.state.arcs.score} scoreBase={10} name="Design" onGrading={this.changeArcScore}/>
<Grading
mode="arcs"
score={4.7}
scoreBase={10}
activeColor="#2bb8aa"
scale={1.2}
name="Creativity"
readOnly={true}
/>
<Grading
mode="arcs"
score={45}
scale={1.6}
isPercentage={true}
name="Usability"
enable={false}
/>
</View>
<View style={styles.simlesGrading}>
<Grading
mode="smiles"
isLike={this.state.smiles.isLike}
onGrading={this.changeSmileScore}/>
<Grading mode="smiles" scale={1.2} activeColor="#d23f2b" isLike={false} readOnly={true}/>
<Grading mode="smiles" scale={1.4} activeColor="#f2558d" isLike={true} enable={false}/>
</View>
</ScrollView>
);
}
}
const styles = StyleSheet.create({
container: {
backgroundColor: '#F5FCFF'
},
welcome: {
marginTop: 30,
fontSize: 20,
textAlign: 'center',
margin: 10,
color: '#333333'
},
boardGrading: {
flexDirection: 'row',
justifyContent: 'space-around',
flexWrap: 'wrap'
},
starsGrading: {
flex: 1,
marginTop: 20,
justifyContent: 'space-around'
},
arcsGrading: {
marginTop: 20,
justifyContent: 'space-around'
},
simlesGrading: {
marginTop: 20,
alignItems: 'center'
}
});
AppRegistry.registerComponent('ranking', () => grading);