提交 7ae6a963 authored 作者: 吴强's avatar 吴强

添加了个人中心的页面导航

上级 75e662c6
...@@ -8,5 +8,5 @@ ...@@ -8,5 +8,5 @@
# For customization when using a Version Control System, please read the # For customization when using a Version Control System, please read the
# header note. # header note.
#Fri Oct 27 18:29:04 CST 2017 #Fri Oct 27 18:29:04 CST 2017
sdk.dir=D\:\\AppData\\Local\\Android\\sdk1 #sdk.dir=D\:\\AppData\\Local\\Android\\sdk1
# sdk.dir=D\:\\Android\\sdk sdk.dir=D\:\\Android\\sdk
import { fetchDomains, switchDomain, currentDomain } from '../services/domain';
import { getDomain, setDomain } from '../utils/auth';
export default {
namespace: 'domain',
state: {
init: undefined,
list: [],
},
subscriptions: {
setup({ dispatch }) { // eslint-disable-line
},
},
effects: {
*fetch(ignored, { put, call }) {
const domain = yield call(getDomain);
const init = domain ? domain.path : undefined;
const list = yield call(fetchDomains, '/', true);
yield put({ type: 'queryInit', payload: init });
yield put({ type: 'queryList', payload: list });
},
*switch({ payload: domainPath }, { put, call }) {
yield call(switchDomain, domainPath);
const { path, name } = yield call(currentDomain);
yield call(setDomain, name, path);
yield put({ type: 'queryInit', payload: path });
},
},
reducers: {
queryInit(state, { payload: init }) {
return {
...state,
init,
};
},
queryList(state, { payload: list }) {
return {
...state,
list,
};
},
},
};
import { NavigationActions } from 'react-navigation';
import { getData, getMeta } from '../../utils/DataTemplate';
export default {
namespace: 'userInfo',
state: {
userName: undefined,
currentJiDiName: undefined,
jidiList: [],
},
subscriptions: {
setup({ dispatch }) { // eslint-disable-line
},
},
reducers: {
setUserName(state, { payload: userName }) {
return {
...state,
userName,
};
},
setJiDiList(state, { payload: jidiList }) {
return {
...state,
jidiList,
};
},
setCurrentJiDi(state, { payload: currentJiDiName }) {
return {
...state,
currentJiDiName,
};
},
},
effects: {
},
};
import React, { Component } from 'react'; import React, { Component } from 'react';
import { View, Text, Image, StyleSheet } from 'react-native'; import { View, Text, Image, StyleSheet } from 'react-native';
import { TabNavigator } from 'react-navigation'; import { TabNavigator } from 'react-navigation';
import userInfoPageScreen from './userinfopage'; import userInfoPageScreen from './userinfo/index';
import fwInfo from './fwInfo'; import fwInfo from './fwInfo';
import chatsIcon from '../../../image/chats-icon.png'; import chatsIcon from '../../../image/chats-icon.png';
import Empty from '../empty'; import Empty from '../empty';
......
import React, { PureComponent } from 'react';
import { View, StyleSheet, RefreshControl, Dimensions, ScrollView, Text } from 'react-native';
const width = Dimensions.get('window').width;
const height = Dimensions.get('window').height;
// create a component
class UserInfoHomeScreen extends PureComponent {
renderHeader=() => {
return (
<View style={styles.header}>
<View style={styles.userContainer}>
<Text style={styles.avatar} />
<View>
<View style={{ flexDirection: 'row' }}>
<Text style={{ color: 'white' }}>素敌</Text>
<Text style={{ marginLeft: 4 }} />
</View>
<Text style={{ color: 'white', marginTop: 4 }}>个人信息</Text>
</View>
</View>
</View>
);
};
render() {
return (
<View style={{ flex: 1, backgroundColor: '#06C1AE'}}>
<View style={{ position: 'absolute', width, height, backgroundColor: '#06C1AE' }} />
<ScrollView
refreshControl={
<RefreshControl
refreshing={this.state.isRefreshing}
onRefresh={() => this.onHeaderRefresh()}
tintColor="gray"
/>
}
>
{this.renderHeader}
</ScrollView>
</View>
);
}
}
const styles = StyleSheet.create({
header: {
backgroundColor: '#06C1AE',
paddingBottom: 20,
},
icon: {
width: 27,
height: 27,
},
userContainer: {
flexDirection: 'row',
alignItems: 'center',
margin: 10,
},
avatar: {
width: 50,
height: 50,
marginRight: 10,
borderRadius: 25,
borderWidth: 2,
borderColor: '#51D3C6',
},
});
export default UserInfoHomeScreen;
import { StackNavigator } from 'react-navigation';
import UserInfoHomeScreen from './UserInfoHomeScreen';
const userInfoPageScreen = StackNavigator(
{
UserInfoHome: {
screen: UserInfoHomeScreen,
},
},
{
headerMode: 'none',
navigationOptions: {
gesturesEnabled: false,
},
},
);
export default userInfoPageScreen;
import React, { Component } from 'react';
import { Button } from 'react-native';
class userInfoPageScreen extends Component {
render() {
return (
<Button
onPress={() => this.props.navigation.goBack()}
title="Go back home"
/>
);
}
}
export default userInfoPageScreen;
...@@ -6,7 +6,7 @@ import { getDomain } from '../utils/auth'; ...@@ -6,7 +6,7 @@ import { getDomain } from '../utils/auth';
export async function fetchDomains(basePath, withRoot = false) { export async function fetchDomains(basePath, withRoot = false) {
if (!basePath) { if (!basePath) {
const domain = await getDomain(); const domain = await getDomain(); // 从内存中拿到domain
if (!domain) { if (!domain) {
throw new Error('Not set domain yet!'); throw new Error('Not set domain yet!');
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论