我有用户列表,每个用户都有其列表中的显示图像。使用自定义选项卡和StackNavigator?
我想要的是每当用户按下显示图像,通过stackNavigation重定向到他/她的个人资料。
CustomTabView:
const CustomTabView = ({ router, navigation }) => {
const { routes, index } = navigation.state;
const ActiveScreen = router.getComponentForState(navigation.state);
const routeNav = addNavigationHelpers({
...navigation,
state: routes[index],
});
const routeOptions = router.getScreenOptions(routeNav, 'tabBar');
return (
<View style={styles.container}>
<CustomTabBar
navigation={navigation}
activeRouteName={routes[index].routeName}
icon={routeOptions.tabBarIcon}
/>
<ActiveScreen
navigation={addNavigationHelpers({
...navigation,
state: routes[index]
})}
/>
</View>
);
};
StackNavigator: // // goToProfile.js也尝试将在index.anndroid.js但没有找到一种方法来导出
const goToProfile = StackNavigator({
Profile: {
screen: Profile,
navigationOptions: ({ navigation }) => ({
title: `${navigation.state.params.person.name.first} ${navigation.state.params.person.name.last}`
})
},
})
定制标签: //index.android.js
const CustomTabRouter = TabRouter(
{
Chat: {
screen: Chats,
path: ""
},
Status: {
screen: Contacts,
path: "notifications"
},
Camera: {
screen: Camera,
path: "settings"
}
},
{
initialRouteName: "Chat",
},
);
const CustomTabs = createNavigationContainer(
createNavigator(CustomTabRouter)(CustomTabView)
);
也是我的组件:
<TouchableOpacity
onPress = {() => this.props.navigation.navigate('Profile', { item }) } >
<Avatar
source={{ uri: item.picture.thumbnail }}
/>
</TouchableOpacity>
问题是什么? – Cruiser
@Cruiser如何在我的聊天屏幕中使用stacknavigator来实现 –
SO不是代码写入服务。我建议你做一个尝试,并提出一个问题,当你卡住,出现错误,或以其他方式遇到问题 – Cruiser