Skip to content

Commit da85168

Browse files
committed
update demo
1 parent d276c12 commit da85168

File tree

12 files changed

+159
-28
lines changed

12 files changed

+159
-28
lines changed

example/app/resource/chat-icon.png

3.62 KB
Loading

example/app/resource/setting.png

2.42 KB
Loading

example/app/resource/user-icon.png

2.88 KB
Loading

example/app/routes/Chat/index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ var themsgid = 1
3434

3535

3636
export default class Chat extends Component {
37+
38+
static navigationOptions = {
39+
title: "Chat",
40+
};
41+
3742
constructor(props) {
3843
super(props);
3944
this.state = { inputViewLayout: {width:window.width, height:86,}};

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

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import React from 'react';
44
import ReactNative from 'react-native';
55
import JMessage from 'jmessage-react-plugin';
66

7-
import FormButton from '../../views/FormButton'
7+
import FormButton from '../../../views/FormButton'
88

99
const {
1010
View,
@@ -15,9 +15,11 @@ const {
1515
Alert,
1616
TextInput,
1717
FlatList,
18+
Image,
1819
} = ReactNative;
1920

2021
class MyListItem extends React.PureComponent {
22+
2123
_onPress = () => {
2224
this.props.onPressItem(this.props.id);
2325
};
@@ -34,9 +36,26 @@ const {
3436
}
3537

3638

37-
var count = 0
39+
const styles = StyleSheet.create({
40+
icon: {
41+
width: 26,
42+
height: 26,
43+
},
44+
});
45+
46+
var count = 0
3847
export default class ConversationList extends React.Component {
39-
48+
static navigationOptions = {
49+
title: "会话",
50+
tabBarLabel: '会话',
51+
tabBarIcon: ({ tintColor }) => (
52+
<Image
53+
source={require('../../../resource/chat-icon.png')}
54+
style={[styles.icon, {tintColor: tintColor}]}
55+
/>
56+
),
57+
};
58+
4059
constructor(props) {
4160
super(props);
4261
this.state = {
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
'use strict';
2+
3+
import React from 'react';
4+
import ReactNative from 'react-native';
5+
import JMessage from 'jmessage-react-plugin';
6+
7+
import Translations from '../../resource/Translations'
8+
9+
const {
10+
View,
11+
Text,
12+
TouchableHighlight,
13+
StyleSheet,
14+
Alert,
15+
} = ReactNative;
16+
17+
export default class Home extends React.Component {
18+
constructor(props) {
19+
super(props);
20+
}
21+
22+
componentWillMount() {
23+
24+
}
25+
26+
render() {
27+
return ( <Text >Home</Text> )
28+
}
29+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
'use strict';
2+
3+
import React from 'react';
4+
import ReactNative from 'react-native';
5+
import JMessage from 'jmessage-react-plugin';
6+
import {
7+
TabNavigator
8+
} from 'react-navigation';
9+
10+
const {
11+
View,
12+
Text,
13+
TouchableHighlight,
14+
StyleSheet,
15+
Button,
16+
Alert,
17+
TextInput,
18+
Image
19+
} = ReactNative;
20+
21+
export default class MyNotificationsScreen extends React.Component {
22+
static navigationOptions = {
23+
title: "我",
24+
tabBarLabel: '我',
25+
tabBarIcon: ({ tintColor }) => (
26+
<Image
27+
source={require('../../../resource/user-icon.png')}
28+
style={[styles.icon, {tintColor: tintColor}]}
29+
/>
30+
),
31+
};
32+
33+
render() {
34+
return (
35+
<Button
36+
onPress={() => this.props.navigation.goBack()}
37+
title="Go back home"
38+
/>
39+
);
40+
}
41+
}
42+
43+
const styles = StyleSheet.create({
44+
icon: {
45+
width: 26,
46+
height: 26,
47+
},
48+
});

example/app/routes/Home/index.js

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,35 @@
33
import React from 'react';
44
import ReactNative from 'react-native';
55
import JMessage from 'jmessage-react-plugin';
6+
import {
7+
TabNavigator
8+
} from 'react-navigation';
69

7-
import Translations from '../../resource/Translations'
10+
import ConversationList from './ConversationList/index.js'
11+
import UserInfo from './UserInfo/index.js'
812

913
const {
1014
View,
1115
Text,
1216
TouchableHighlight,
1317
StyleSheet,
18+
Button,
1419
Alert,
20+
TextInput,
21+
Image
1522
} = ReactNative;
16-
17-
export default class Home extends React.Component {
18-
constructor(props) {
19-
super(props);
20-
}
21-
22-
componentWillMount() {
23-
24-
}
25-
26-
render() {
27-
return ( <Text >Home</Text> )
28-
}
29-
}
23+
24+
const HomePage = TabNavigator({
25+
Conversation: {
26+
screen: ConversationList,
27+
},
28+
UserInfo: {
29+
screen: UserInfo,
30+
},
31+
}, {
32+
tabBarOptions: {
33+
activeTintColor: '#e91e63',
34+
},
35+
});
36+
module.exports = HomePage
37+

example/app/routes/Launch/index.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,12 @@ const {
2929
JMessage.init(params)
3030
JMessage.getMyInfo((myInfo) => {
3131
if (myInfo.username) {
32-
// navigate('Home')
33-
navigate('ConversationList')
32+
navigate('Home')
33+
// navigate('MainPage')
34+
// navigate('ConversationList')
3435
} else {
3536
navigate('Login')
37+
3638
// navigate('Chat')
3739
}
3840
})

example/app/routes/Login/index.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ const {
1717
} = ReactNative;
1818

1919
export default class Login extends React.Component {
20+
static navigationOptions = {
21+
title: "登录"
22+
};
23+
2024
constructor(props) {
2125
super(props);
2226
this.state = {
@@ -31,7 +35,7 @@ const {
3135

3236
JMessage.login({username: this.state.username, password: this.state.password}, () => {
3337
Alert.alert('login success')
34-
navigate('ConversationList')
38+
navigate('Home')
3539
}, (error) => {
3640
Alert.alert('login success', JSON.stringify(error))
3741
})

0 commit comments

Comments
 (0)