-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdemo.js
156 lines (139 loc) · 3.31 KB
/
demo.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
/**
* Sample React Native App
* https://github.com/facebook/react-native
*
* @format
* @flow
*/
import React, { Component } from 'react';
import { Platform, StyleSheet, Text, View, TouchableOpacity, Image } from 'react-native';
import Swipeout from 'react-native-swipeout'
export default class App extends Component {
constructor(props) {
super(props);
this.state = {
Rightbuttons: [
{
backgroundColor: 'red',
color: 'white',
text: 'Rbutton1',
onPress: () => { this.aaaa() }
},
{
backgroundColor: 'blue',
color: 'white',
text: 'Rbutton2',
onPress: () => { this.aaaa() }
},
{
backgroundColor: 'green',
color: 'white',
text: 'Rbutton3',
onPress: () => { this.aaaa() }
},
],
Leftbuttons: [
{
backgroundColor: 'red',
color: 'white',
text: 'Lbutton1',
onPress: () => { this.aaaa() }
},
{
backgroundColor: 'blue',
color: 'white',
text: 'Lbutton2',
onPress: () => { this.aaaa() }
},
{
backgroundColor: 'green',
color: 'white',
text: 'Lbutton3',
onPress: () => { this.aaaa() }
},
]
}
this.aaaa = this.aaaa.bind(this);
}
aaaa() {
console.log('123');
}
_childView = () => {
let view = (<TouchableOpacity onPress={()=>{
console.log('detail')
}}>
<View style={styles.containerItem}>
<Image style={styles.itemImg} source={{ uri: 'https://ss1.bdstatic.com/70cFvXSh_Q1YnxGkpoWK1HF6hhy/it/u=1391206089,2029672096&fm=26&gp=0.jpg' }} />
<View style={styles.itemRightContent}>
<Text style={styles.title}>{'hahhahah'}</Text>
<View style={styles.itemRightBottom}>
<Text style={styles.userName}>{'南山'}</Text>
<Text style={styles.userName}>{'2019-09'}</Text>
</View>
</View>
</View>
</TouchableOpacity>)
return view
}
render() {
let views = this._childView()
return (
<View style={styles.container}>
<Swipeout right={this.state.Rightbuttons}>
{views}
</Swipeout>
<Swipeout left={this.state.Leftbuttons}>
{views}
</Swipeout>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
},
welcome: {
flex: 1
},
instructions: {
textAlign: 'center',
color: '#333333',
marginBottom: 5,
},
containerItem: {
flexDirection: 'row',
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#fcfcfc',
padding: 10,
borderBottomColor: '#ddd',
borderBottomWidth: 1
},
title: {
fontSize: 18,
textAlign: 'left',
color: 'black'
},
itemImg: {
width: 88,
height: 66,
marginRight: 10
},
itemRightContent: {
flex: 1,
flexDirection: 'column'
},
itemRightBottom: {
flex: 1,
flexDirection: 'row',
alignItems: 'center'
},
userName: {
flex: 1,
fontSize: 14,
color: '#87CEFA',
marginTop: 5,
marginRight: 5
}
});