Skip to content

Commit ce22781

Browse files
committed
1.udpate example add userinfo Page 2.fix logout bug
1 parent da85168 commit ce22781

File tree

10 files changed

+156
-32
lines changed

10 files changed

+156
-32
lines changed
5.14 KB
Loading
2.07 KB
Loading
2.52 KB
Loading
2.78 KB
Loading
5.08 KB
Loading

example/app/routes/Chat/index.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,6 @@ export default class Chat extends Component {
166166
}
167167

168168
componentWillUnmount() {
169-
Alert.alert("Component", "will unmount")
170169
JMessage.removeReceiveMessageListener(this.receiveMessageCallBack)
171170
AuroraIController.removeMessageListDidLoadListener(this.messageListDidLoadCallback)
172171
}

example/app/routes/Home/ConversationList/index.js

Lines changed: 45 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const {
1515
Alert,
1616
TextInput,
1717
FlatList,
18-
Image,
18+
Image
1919
} = ReactNative;
2020

2121
class MyListItem extends React.PureComponent {
@@ -41,6 +41,21 @@ const styles = StyleSheet.create({
4141
width: 26,
4242
height: 26,
4343
},
44+
conversationContent: {
45+
borderBottomWidth: 1,
46+
borderColor: "#cccccc",
47+
height: 60,
48+
},
49+
conversationItem: {
50+
flexDirection:'row',
51+
margin: 10,
52+
alignItems: 'center',
53+
},
54+
conversationAvatar: {
55+
width: 45,
56+
height: 45,
57+
marginRight: 10,
58+
},
4459
});
4560

4661
var count = 0
@@ -67,37 +82,40 @@ const styles = StyleSheet.create({
6782
componentWillMount() {
6883
JMessage.getConversations((result) => {
6984

70-
var data = result.map((conversaion) =>
85+
var data = result.map((conversation, index) =>
7186
{
72-
var item
73-
if (conversaion.conversationType === 'single') {
74-
item = {key: conversaion.target.username}
87+
var item = {}
88+
item.key = index
89+
item.conversation = conversation
90+
if (conversation.conversationType === 'single') {
91+
item = {key: conversation.target.username}
7592
item.conversationType = 'single'
93+
item.displayName = conversation.target.nickname
7694
} else {
77-
item = {key: conversaion.target.id}
95+
item = {key: conversation.target.id}
7896
item.conversationType = 'group'
79-
Alert.alert('conversaion', JSON.stringify(conversaion))
97+
item.displayName = conversation.target.name
8098
}
8199

82-
if (conversaion.latestMessage === undefined) {
100+
if (conversation.latestMessage === undefined) {
83101
item.latestMessageString = ""
84102
return item
85103
}
86104

87-
item.conversationType = conversaion.conversationType
88-
if (conversaion.latestMessage.type === 'text') {
89-
item.latestMessageString = conversaion.latestMessage.text
105+
item.conversationType = conversation.conversationType
106+
if (conversation.latestMessage.type === 'text') {
107+
item.latestMessageString = conversation.latestMessage.text
90108
}
91109

92-
if (conversaion.latestMessage.type === 'image') {
110+
if (conversation.latestMessage.type === 'image') {
93111
item.latestMessageString = '[图片]'
94112
}
95113

96-
if (conversaion.latestMessage.type === 'voice') {
114+
if (conversation.latestMessage.type === 'voice') {
97115
item.latestMessageString = '[语言]'
98116
}
99117

100-
if (conversaion.latestMessage.type === 'file') {
118+
if (conversation.latestMessage.type === 'file') {
101119
item.latestMessageString = '[文件]'
102120
}
103121

@@ -133,10 +151,22 @@ const styles = StyleSheet.create({
133151
renderItem = { ({item}) => (
134152
<View>
135153
<TouchableHighlight
154+
style={[styles.conversationContent]}
155+
underlayColor = '#dddddd'
136156
onPress={ () => {
137157
this.props.navigation.navigate('Chat', {conversation: item})
138158
}}>
139-
<Text>{item.key}</Text>
159+
<View style={ [styles.conversationItem]}>
160+
<Image
161+
source={require('../../../resource/group-icon.png')}
162+
style={[styles.conversationAvatar]}>
163+
</Image>
164+
<View>
165+
<Text>{ item.displayName }</Text>
166+
<Text>{ item.latestMessageString }</Text>
167+
</View>
168+
</View>
169+
140170

141171
</TouchableHighlight>
142172
</View>

example/app/routes/Home/UserInfo/index.js

Lines changed: 108 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,42 @@ const {
1818
Image
1919
} = ReactNative;
2020

21+
const styles = StyleSheet.create({
22+
header: {
23+
justifyContent: 'center',
24+
alignItems: 'center',
25+
marginTop: 20,
26+
borderBottomWidth: 1,
27+
borderColor: "#cccccc",
28+
},
29+
icon: {
30+
width: 26,
31+
height: 26,
32+
},
33+
username: {
34+
marginTop: 10,
35+
marginBottom: 20,
36+
justifyContent: 'center',
37+
alignItems: 'center',
38+
textAlign: 'center',
39+
40+
},
41+
listContent: {
42+
borderBottomWidth: 1,
43+
borderColor: "#cccccc",
44+
},
45+
listItem: {
46+
flexDirection:'row',
47+
alignItems: 'center',
48+
margin: 10,
49+
},
50+
itemIcon: {
51+
width: 26,
52+
height: 26,
53+
marginRight: 10,
54+
},
55+
});
56+
2157
export default class MyNotificationsScreen extends React.Component {
2258
static navigationOptions = {
2359
title: "我",
@@ -29,20 +65,79 @@ export default class MyNotificationsScreen extends React.Component {
2965
/>
3066
),
3167
};
32-
68+
constructor(props) {
69+
super(props)
70+
this.state = {
71+
myInfo: {}
72+
}
73+
}
74+
componentWillMount() {
75+
JMessage.getMyInfo((user) => {
76+
// this.sta = myInfo
77+
this.setState({myInfo: user})
78+
})
79+
}
3380
render() {
3481
return (
35-
<Button
36-
onPress={() => this.props.navigation.goBack()}
37-
title="Go back home"
38-
/>
82+
<View>
83+
<View
84+
style={[styles.header]}>
85+
<Image
86+
source={require('../../../resource/group-icon.png')}
87+
style={[styles.header]}>
88+
</Image>
89+
<Text
90+
style={[styles.username]}>
91+
{ this.state.myInfo.nickname}
92+
</Text>
93+
</View>
94+
<TouchableHighlight
95+
underlayColor = '#dddddd'
96+
style={[styles.listContent]}
97+
onPress={ () => {
98+
}}
99+
>
100+
<View
101+
style={[styles.listItem]}>
102+
<Image
103+
source={require('../../../resource/myinfo-icon.png')}
104+
style={[styles.itemIcon]}>
105+
</Image>
106+
<Text>{this.state.myInfo.username}</Text>
107+
</View>
108+
</TouchableHighlight>
109+
<TouchableHighlight
110+
underlayColor = '#dddddd'
111+
style={[styles.listContent]}
112+
onPress={ () => {
113+
}}
114+
>
115+
<View
116+
style={[styles.listItem]}>
117+
<Image
118+
source={require('../../../resource/setting-icon.png')}
119+
style={[styles.itemIcon]}>
120+
</Image>
121+
<Text>{ "设置" }</Text>
122+
</View>
123+
</TouchableHighlight>
124+
<TouchableHighlight
125+
style={[styles.listContent]}
126+
underlayColor = '#dddddd'
127+
onPress={() => {
128+
JMessage.logout()
129+
this.props.navigation.navigate('Login')
130+
}}>
131+
<View
132+
style={[styles.listItem]}>
133+
<Image
134+
source={require('../../../resource/logout-icon.png')}
135+
style={[styles.itemIcon]}>
136+
</Image>
137+
<Text>{ "登出" }</Text>
138+
</View>
139+
</TouchableHighlight>
140+
</View>
39141
);
40142
}
41-
}
42-
43-
const styles = StyleSheet.create({
44-
icon: {
45-
width: 26,
46-
height: 26,
47-
},
48-
});
143+
}

example/index.ios.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ const ReactJChat = StackNavigator({
4343
},{
4444
// mode:'modal',
4545
headerMode: 'screen',
46-
transitionConfig:()=>({
46+
transitionConfig:() => ({
4747
screenInterpolator:CardStackStyleInterpolator.forInitial,
4848
})
4949
});
5050

51-
AppRegistry.registerComponent('ReactJChat', () => ReactJChat);
51+
AppRegistry.registerComponent('ReactJChat', () => ReactJChat);

ios/RCTJMessageModule/RCTJMessageModule.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ - (void)didReceiveJMessageMessage:(NSNotification *)notification {
212212
}];
213213
}
214214

215-
RCT_EXPORT_METHOD(logout:(NSDictionary *)param) {
215+
RCT_EXPORT_METHOD(logout) {
216216
[JMSGUser logout:^(id resultObject, NSError *error) {}];
217217
}
218218

0 commit comments

Comments
 (0)