-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHistory.js
59 lines (53 loc) · 1.38 KB
/
History.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
import React, { Component } from 'react'
import { StyleSheet, Text, View, TouchableOpacity } from 'react-native'
import moment from 'moment'
import dbLayer from './dbLayer'
import { ScrollView } from 'react-native-gesture-handler'
export class History extends Component {
seedData(count) {
for (let i = 0; i < count; i++) {
dbLayer.createEntry(
{
scannedAt: new Date(),
content: `${i}`,
type: 'T',
},
null,
this.refreshData(),
)
}
}
render() {
const { entries, onDeleteEntry } = this.props
return (
<View style={{ flex: 1 }}>
<ScrollView style={styles.container}>
{entries.map(({ id, scannedAt, content, type }) => (
<TouchableOpacity key={id} onPress={() => onDeleteEntry(id)}>
<View style={styles.entryContainer}>
<Text>
Scanned:
{moment()
.startOf(scannedAt)
.fromNow()}
</Text>
<Text>Content: {content}</Text>
<Text>Type: {type}</Text>
</View>
</TouchableOpacity>
))}
</ScrollView>
</View>
)
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
marginHorizontal: 50,
},
entryContainer: {
marginVertical: 10,
},
})
export default History