RateBar.js
3.4 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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
import React,{ useState } from 'react';
import { Surface, Text ,HelperText} from 'react-native-paper';
import { StyleSheet,View } from 'react-native';
import { StackedBarChart } from 'react-native-svg-charts';
import PromptSearchRate from '../PromptSearch/PromptSearchRate';
export default RateBar = (props) => {
const [ click,setClick ] = useState(0);
return (
<Surface style={styles.surface}>
{props.score.msg ?
<>
<View style={styles.container}>
<Text style={styles.Text}>총 점수 : {props.score.full}</Text>
<View style={styles.colorContainer}>
<View style={styles.textContainer}>
<View style={styles.colorA}></View><Text>키워드 점수</Text>
</View>
<View style={styles.textContainer}>
<View style={styles.colorB}></View><Text>맞춤법 점수</Text>
</View>
</View>
</View>
<StackedBarChart
data={ [{
keyword: {
value: props.score.key,
svg: {
onPressIn: () => {setClick(1)},
onPressOut: ()=>{setClick(0)}
},
},
korean: {
value: props.score.fix,
svg: {
onPressIn: () => {setClick(2)},
onPressOut: ()=>{setClick(0)}
},
},
rest: {
value: (100-(props.score.key+props.score.fix)),
}
}]}
style={{height:50, width:'90%'}}
keys={['keyword','korean','rest']}
colors={['#ffaa5a','#2cc3c2','#ffffff']}
showGrid={ false }
horizontal={ true }
contentInset={ { top: 10 } }
valueAccessor={({ item, key }) => item[key].value}
/>
<View style={styles.infoContainer}>
<HelperText type={'info'} visible={click==1} style={{fontSize:20}}>키워드 : {props.score.key}</HelperText>
<HelperText type={'info'} visible={click==2} style={{fontSize:20}}>맞춤법 : {props.score.fix}</HelperText>
</View>
<Text>눌러서 각각의 점수를 알아보세요!</Text>
</>
: <PromptSearchRate />}
</Surface>
);
}
const styles = StyleSheet.create({
container:{
width: '100%',
flexDirection:'row',
justifyContent:'center',
},
colorContainer:{
position:"absolute",
right:0,
},
colorA:{
backgroundColor:'#ffaa5a',
height: 7,
width: 7,
marginRight: 5,
},
colorB:{
backgroundColor:'#2cc3c2',
height: 7,
width: 7,
marginRight: 5,
},
textContainer:{
flexDirection:'row',
justifyContent:'center',
alignItems:'center'
},
infoContainer:{
flexDirection:'row',
justifyContent:'center',
alignItems:'center',
width: '100%'
},
surface: {
padding: 8,
flex: 0.3,
width: '95%',
alignItems: 'center',
justifyContent: 'center',
elevation: 2,
marginTop: 10
},
Text:{
fontSize: 25,
},
});