-
Notifications
You must be signed in to change notification settings - Fork 1
/
clueScreen.js
76 lines (71 loc) · 2.2 KB
/
clueScreen.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
import React, { Component } from 'react';
import { Text, View, ActivityIndicator, Alert, ScrollView, TouchableHighlight } from 'react-native';
import callClueAPI from './clueAPI'
import { styles } from './styles'
export default class ClueScreen extends Component {
state = {
loading: true,
clueObjectList: []
}
async componentDidMount() {
try {
let clueObjectList = await callClueAPI(
this.props.navigation.getParam('wordObjectList', []),
this.props.navigation.getParam('team', '')
)
if ('err' in clueObjectList) {
Alert.alert(clueObjectList.err)
} else {
this.setState({ clueObjectList })
}
} catch (err) {
console.log('in here')
Alert.alert('Server Request Failed')
} finally {
this.setState({ loading: false })
}
}
render() {
if (this.state.loading) {
return (
<View style={{ flex: 1, justifyContent: 'center' }}>
<ActivityIndicator size="large" color="#393D46" />
</View>
);
}
return (
<ScrollView>
{
this.state.clueObjectList.map((clueObject, index) => {
return (
<TouchableHighlight
key={index}
underlayColor='white'
onPress={() => {
Alert.alert(
'"' + clueObject.clue + '" hints at:',
clueObject.wordsHintedAt.join('\n')
)
}}>
<View style={styles.clueView}>
<View flex={0.8} justifyContent='center'>
<Text style={styles.clueText}>
{clueObject.clue}
</Text>
</View>
<View flex={0.2} style={{ alignItems: 'flex-end', justifyContent: 'center' }}>
<Text style={[styles.clueText, { color: 'white', fontSize: 27 }]}>
{clueObject.wordsHintedAt.length}
</Text>
</View>
</View>
</TouchableHighlight>
)
})
}
<View style={{ height: 8 }} />
{/* for extra padding at bottom */}
</ScrollView>
)
}
}