Last active
October 30, 2019 10:07
-
-
Save oflarcade/74b0e3212dd4529466469ebaf5efcae6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
renderItem(item) { | |
const color = item.connected ? 'green' : '#fff'; | |
return ( | |
<TouchableHighlight onPress={() => this.test(item)}> | |
<View style={[styles.row, {backgroundColor: color}]}> | |
<Text | |
style={{ | |
fontSize: 12, | |
textAlign: 'center', | |
color: '#333333', | |
padding: 10, | |
}}> | |
{item.name} | |
</Text> | |
<Text | |
style={{ | |
fontSize: 10, | |
textAlign: 'center', | |
color: '#333333', | |
padding: 2, | |
}}> | |
RSSI: {item.rssi} | |
</Text> | |
<Text | |
style={{ | |
fontSize: 8, | |
textAlign: 'center', | |
color: '#333333', | |
padding: 2, | |
paddingBottom: 20, | |
}}> | |
{item.id} | |
</Text> | |
</View> | |
</TouchableHighlight> | |
); | |
} | |
... | |
render(){ | |
const {peripherlas} = this.state; | |
let list = Array.from(peripherals.values()).sort(el => !el.name) | |
return( | |
... | |
<ScrollView style={styles.scroll}> | |
{list.length == 0 && ( | |
<View style={{flex: 1, margin: 20}}> | |
<Text style={{textAlign: 'center'}}>No peripherals</Text> | |
</View> | |
)} | |
<FlatList | |
data={list} | |
renderItem={({item}) => this.renderItem(item)} | |
keyExtractor={item => item.id} | |
/> | |
</ScrollView> | |
); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment