-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.android.js
188 lines (170 loc) · 7.07 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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
import React, { Component } from 'react';
import { AppRegistry, StyleSheet, Text, View, Image,
TouchableNaviteFeedback, TouchableHighlight } from 'react-native';
class Button extends Component {
render() {
return (
<TouchableHighlight onPress={() => this.props.onPress()} underlayColor='white' >
<View style={ [styles.tryme, {backgroundColor: this.props.backColor}] } >
<Text style={{color:'#333', textAlign: 'center'}}>
{this.props.messageToBePrinted}
</Text>
</View>
</TouchableHighlight>
)
}
}
class EdgeChecker extends Component {
componentWillMount() {
this.state = {
isRevese: false,
inResultsStage: false,
lastSuccess: undefined,
index: 0,
streak:0,
score: 0,
total: 0,
words: [
['ОБЕСПЕЧЕНИЕ', 'обеспЕчение', 'обеспечЕние'],
['ХОДАТАЙСТВО', 'ходАтайство', 'ходатАйство'],
['НАЧАЛИ', 'нАчали','началИ'],
['ВКЛЮЧИШЬ','включИшь','вклЮчишь'],
['МОЛЯЩИЙ','молЯщий','мОлящий'],
['БАНТЫ','бАнты','бантЫ'],
['ОБЛЕГЧИТЬ','облегчИть','облЕгчить'],
['БАЛУЯСЬ','балУясь','бАлуясь'],
['БУХГАЛТЕРОВ','бухгАлтеров','бухгалтерОв'],
['ПРИБЫЛ','прИбыл','прибЫл'],
['БАЛОВАННЫЙ','балОванный','бАлованный'],
['ФЕНОГТЯМЕН','фенОмен','феномЕн'],
['БАЛОВАТЬ','баловАть','бАловать'],
['СОГНУТЫЙ','сОгнутый','согнУтый'],
['ДОНЕЛЬЗЯ','донЕльзя','дОнельзя'],
['СВЕКЛА','свЕкла','свеклА'],
['КЛАЛА','клАла','клалА'],
['ЦЕПОЧКА','цепОчка','цЕпочка'],
['КОРЫСТЬ','корЫсть','кОрысть'],
['ТОРТЫ','тОрты','тортЫ'],
['БАЛОВАТЬ','баловАть','бАловать'],
['ОПЛОМБИРОВАТЬ','опломбировАть','опломбИровать'],
['УГЛУБИТЬ','углубИть','углУбить'],
['КОРЫСТЬ','корЫсть','кОрысть'],
['КРЕМЕНЬ','кремЕнь','крЕмень'],
['ПОЗВОНИШЬ','позвонИшь','позвОнишь'],
['НАЧАВШИСЬ','начАвшись','начавшИсь'],
['ВЕРОИСПОВЕДАНИЕ','вероисповЕдание','вероисповедАние'],
['НАМЕРЕНИЕ','намЕрение','намерЕние'],
['НЕФТЕПРОВОД','нефтепровОд','нефтепрОвод'],
['КРАСИВЕЕ','красИвее','красивЕе'],
['ИСЧЕРПАТЬ','исчЕрпать','исчерпАть'],
['ФОРЗАЦ','фОрзац','форзАц'],
['ПРИНЯЛИ','прИняли','принЯли'],
['КРАЛАСЬ','крАлась','кралАсь'],
['ПЛОМБИРОВАТЬ','пломбировАть','пломбИровать'],
['ШАРФЫ','шАрфы','шарфЫ'],
['СРЕДСТВА','срЕдства','средствА',''],
['ПРОСВЕРЛИТ','просверлИт','просвЕрлит'],
['ДОГОВОР','договОр','дОговор'],
['ЩАВЕЛЬ','щавЕль','щАвель'],
['ФЛЁРДОРАНЖ','флёрдорАнж','флёрдОранж'],
['ОКРЕСТИТСЯ','окрЕстится','окрестИтся'],
['НОГТЯ','нОгтя','ногтЯ'],
['ШВАРТУЕТ','швартУет','швАртует',''],
['ЗАМУТНЕЕТ','замутнЕет','зАмутнеет'],
['ЦИКЛОТИМИЯ','циклотимИя','циклотИмия'],
['РАЗВЁРТКИ','развЁртки','рАзвертки'],
['ИЗВИНИШЬСЯ','извинИшься','извИнишься'],
['КЛУБОК','клубОк','клУбок'],
['СМИРИТЕЛЬ','смирИтель','смИритель'],
['ПРЕСВИТЕРСКИЙ','пресвИтерский','пресвитЕрский'],
['ТРЮКА','трЮка','трюкА'],
// {
// word: 'ОБЕСПЕЧЕНИЕ',
// correct: 'обеспЕчение',
// wrong: 'обеспечЕние'
// },
// {
// word: 'ХОДАТАЙСТВО',
// correct: 'ходАтайство',
// wrong: 'ходатАйство'
// }
]
}
}
render() {
const {words, index} = this.state;
const currentQuest = this.state.words[this.state.index];
const question = `Как правильно пишется слово ${currentQuest[0]} ?`;
return (
<View style={styles.fullblue}>
<View style={{}}>
<Text>{question}</Text>
</View>
{this.renderButtons(currentQuest)}
<View>
<Text> Ваш счет: {this.state.score} из {this.state.total}</Text>
</View>
<View>
<Text>{this.state.streak} правильно раз подряд</Text>
</View>
</View>
);
}
renderButtons(currentQuest) {
const defaultColor = 'steelblue';
const {lastSuccess, inResultsStage, isRevese} = this.state
const successBackColor = inResultsStage ? (lastSuccess ? 'green' : defaultColor ) : defaultColor
const failureBackColor = inResultsStage ? (!lastSuccess ? 'red' : defaultColor) : defaultColor
return (
<View style={{ flexDirection: isRevese ? 'row-reverse' : 'row' }}>
<Button onPress={() => this.success()} messageToBePrinted={currentQuest[1]} backColor={successBackColor} />
<Button onPress={() => this.failure()} messageToBePrinted={currentQuest[2]} backColor={failureBackColor} />
</View>
)
}
success() {
this.setState({
score: this.state.score + 1,
total: this.state.total + 1,
streak: this.state.streak + 1,
lastSuccess: true,
inResultsStage: true
})
this.goNext()
}
failure() {
this.setState({
total: this.state.total + 1,
streak: 0,
lastSuccess: false,
inResultsStage: true
})
this.goNext()
}
goNext() {
let nextIndex = this.state.index;
while (nextIndex === this.state.index) {
nextIndex = Math.floor((Math.random() * this.state.words.length) );
}
setTimeout(
() => this.setState({index: nextIndex, isRevese: Math.random() >= .5, inResultsStage: false}),
100
);
}
}
const styles = StyleSheet.create({
tryme:
{
alignItems: 'center',
margin:10,
backgroundColor:'red',
padding: 5
},
fullblue:{
flexDirection: 'column',
alignItems: 'center',
flex: 1,
justifyContent: 'center',
},
});
AppRegistry.registerComponent('mood', () => EdgeChecker);