Skip to content

Commit 41c7419

Browse files
author
Uncle Charlie
committed
refactor message cell style
1 parent c76fae0 commit 41c7419

File tree

1 file changed

+24
-14
lines changed

1 file changed

+24
-14
lines changed

js/message/MessageCell.js

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
Image,
77
TouchableOpacity,
88
Dimensions,
9+
StyleSheet,
910
} from 'react-native';
1011

1112
const {width, height} = Dimensions.get('window');
@@ -20,28 +21,37 @@ export default class MessageCell extends React.PureComponent {
2021
const {name, full_name} = this.props.item.item || {};
2122
console.log(`===>message cell props, ${name}, ${full_name}`, this.props.item.item)
2223
return (
23-
<View style={{ alignItems: 'stretch', justifyContent: 'center', backgroundColor: 'white', paddingHorizontal: 10, paddingTop: 10, }}>
24+
<View style={styles.container}>
2425
<TouchableOpacity
2526
onPress={() => console.log('item clicked')}
26-
style={{
27-
backgroundColor: 'yellow', alignItems: 'stretch', justifyContent: 'center',
28-
height: 250,
29-
}}>
30-
<View style={{
31-
flex: 1, justifyContent: 'flex-start', alignItems: 'center',
32-
backgroundColor: 'orange', borderRadius: 10, overflow: 'hidden'
33-
}}>
27+
style={styles.touchable}>
28+
<View style={styles.touchableInside}>
3429
<Image
3530
source={require('./img/graphql_wx.jpg')}
36-
style={{ borderTopLeftRadius: 10, borderTopRightRadius: 10, backgroundColor: 'red', width: SCREEN_WIDTH - 20, height: 150 }}
31+
style={styles.image}
3732
resizeMode={Image.resizeMode.stretch} />
38-
<View style={{ flex: 1, justifyContent: 'space-around', alignSelf: 'stretch', alignItems: 'flex-start', paddingVertical: 20, marginHorizontal: 20 }}>
39-
<Text style={{ textAlign: 'left', backgroundColor: 'yellow' }}>{name}</Text>
40-
<Text style={{ textAlign: 'left', backgroundColor: 'yellow' }}>{full_name}</Text>
33+
<View style={styles.insideView}>
34+
<Text style={styles.insideText}>{name}</Text>
35+
<Text style={styles.insideText}>{full_name}</Text>
4136
</View>
4237
</View>
4338
</TouchableOpacity>
4439
</View>
4540
);
4641
}
47-
}
42+
}
43+
44+
const styles = StyleSheet.create({
45+
container: { alignItems: 'stretch', justifyContent: 'center', backgroundColor: 'white', paddingHorizontal: 10, paddingTop: 10, },
46+
touchable: {
47+
backgroundColor: 'yellow', alignItems: 'stretch', justifyContent: 'center',
48+
height: 250,
49+
},
50+
touchableInside: {
51+
flex: 1, justifyContent: 'flex-start', alignItems: 'center',
52+
backgroundColor: 'orange', borderRadius: 10, overflow: 'hidden'
53+
},
54+
image: { borderTopLeftRadius: 10, borderTopRightRadius: 10, backgroundColor: 'red', width: SCREEN_WIDTH - 20, height: 150 },
55+
insideView: { flex: 1, justifyContent: 'space-around', alignSelf: 'stretch', alignItems: 'flex-start', paddingVertical: 20, marginHorizontal: 20 },
56+
insideText: { textAlign: 'left', backgroundColor: 'yellow' },
57+
});

0 commit comments

Comments
 (0)