我有用戶列表,每個用戶都有其列表中的顯示圖像。使用自定義選項卡和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