-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsmsview.js
80 lines (73 loc) · 2.08 KB
/
smsview.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
import React, { Component, } from 'react'
import { View,
StyleSheet,
TouchableOpacity,
Dimensions,
Text,
ListView,
} from 'react-native'
var deviceWidth = Dimensions.get('window').width;
import SQLite from 'react-native-sqlite-storage';
import {Actions} from 'react-native-router-flux';
var DanhMuc = [];
class Smsview extends Component {
static propTypes = {}
static defaultProps = {}
constructor(props) {
super(props)
var ds = new ListView.DataSource({rowHasChanged: (r1, r2) => r1 !== r2});
this.state = {
id: '',
Name: '',
data : [],
dataSource: ds.cloneWithRows(DanhMuc),
}
var db = SQLite.openDatabase({name: "dbChucTet2017.db", createFromLocation : "~dbChucTet2017.db" });
db.transaction((tx) => {
tx.executeSql('SELECT * FROM DanhMuc', [], (tx,results) =>{
DanhMuc.splice(0, DanhMuc.length);
var len = results.rows.length;
for (let i = 0; i < len ; i++) {
DanhMuc.push({'id': results.rows.item(i).ids, 'Name': results.rows.item(i).Name});
}
this.setState({
dataSource: ds.cloneWithRows(DanhMuc),
})
});
});
}
_renderView (data,sectionID,rowId) {
return (
<TouchableOpacity style = {styles.TouView} onPress = {() => Actions.Content({data: data.id , title : data.Name})} >
<Text style = {styles.TouText}>{data.Name}</Text>
</TouchableOpacity>
);
}
render() {
return (
<View style = {styles.container}>
<ListView style = {{marginTop : 60}} dataSource={this.state.dataSource} renderRow={this._renderView}
enableEmptySections = {true} />
</View>
)
}
}
const styles = StyleSheet.create({
container: {
flex :1 ,
backgroundColor: 'white',
},
TouView: {
height : 50,
justifyContent: 'center',
alignItems: 'center',
backgroundColor : '#f2f2f2',
margin : 10,
},
TouText : {
fontSize: 20,
textAlign: 'center',
margin: 10,
},
});
export default Smsview