当用户登录系统时,我想更改用户个人资料图片。材质选项卡导航器左侧角落的用户头像。当用户登录系统时,我将图像 url 存储在 AsyncStorage 中作为profilePic。
我想访问 AsyncStorage 并在此处获取个人资料图片。
<Image
source={{
uri:
'https://cdn.apparelconnects.com/users_2_a34456c8-6d69-4b80-98f2-d184ff9f504d_img.png',
}}
我尝试了很多方法。但我不能这样做。在这里,我附上了我的代码。任何人都知道这里的访问 AsyncStorage,请帮助我..
const TabNavigator = createMaterialTopTabNavigator(
{
Profile: {
screen: Logout,
navigationOptions: {
title: 'Home',
tabBarIcon: ({tintColor}) => (
<Image
source={{
uri:
'https://cdn.apparelconnects.com/users_2_a34456c8-6d69-4b80-98f2-d184ff9f504d_img.png',
}}
style={{
width: tabBarConfiguration.icon_size,
height: tabBarConfiguration.icon_size,
borderRadius: 40 / 2,
overflow: 'hidden',
borderWidth: tintColor == colors.orange ? 2 : 0,
borderColor: tintColor,
}}
/>
),
},
},
Home: {
screen: Home,
navigationOptions: {
title: 'Home',
tabBarIcon: ({tintColor}) => (
<Image
source={require('../asserts/images/home_icon.png')}
style={{
width: tabBarConfiguration.icon_size,
height: tabBarConfiguration.icon_size,
tintColor: tintColor,
}}
/>
),
},
},
{
initialRouteName: 'Home',
activeColor: '#f0edf6',
inactiveColor: '#3e2465',
barStyle: {backgroundColor: '#694fad'},
tabBarPosition: 'top',
swipeEnabled: true,
lazy: true,
tabBarOptions: {
showIcon: true,
showLabel: false,
activeTintColor: colors.orange,
inactiveTintColor: '#a1a1a1',
style: {
backgroundColor: '#ffffff',
height: hp('10%'),
},
labelStyle: {
textAlign: 'center',
fontWeight: 'bold',
},
indicatorStyle: {
backgroundColor: 'transparent',
},
},
defaultNavigationOptions: ({navigation}) => ({
tabBarOnPress: ({navigation, defaultHandler}) => {
if (
navigation.state.routeName === 'Profile' ||
navigation.state.routeName === 'More'
) {
return null;
}
defaultHandler();
},
}),
},
);
export default createAppContainer(TabNavigator);