skip to Main Content

I have a JS class

    import React from 'react';
    import { StyleSheet, View } from 'react-native';
    import { Avatar, Accessory } from 'react-native-elements';
    import PropTypes from 'prop-types';
    import MenuButton from './MenuButton';
    import AppStyles from '../AppStyles';
    import Api from '../Api';
    
    export default class DrawerContainer extends React.Component {
      render() {
        const { navigation, onLogout } = this.props;
        return (
          <View style={styles.content}>
            <Avatar size={100}
      rounded
      source={{
        uri:
          'https://s3.amazonaws.com/uifaces/faces/twitter/ladylexy/128.jpg',
      }}
    />
            <View style={styles.container}>
    
              <MenuButton
                title="Home"
                source={AppStyles.iconSet.home}
                onPress={() => {
                  navigation.navigate('Home');
                }}
              />
              <MenuButton
                title="Logout"
                source={AppStyles.iconSet.logout}
                onPress={() => {
                  onLogout();
                  Api.logout();
                }}
              />
            </View>
          </View>
        );
      }
    }
    
    const styles = StyleSheet.create({
      content: {
        flex: 1,
        flexDirection: 'column',
        alignItems: 'center',
        justifyContent: 'center',
        paddingTop: 75
      },
      container: {
        flex: 1,
        alignItems: 'center',
        paddingHorizontal: 20,
        alignItems: 'flex-end'
      },
    });
    
    DrawerContainer.propTypes = {
      navigation: PropTypes.object,
      onLogout: PropTypes.func,
    };

Here is the output generated from the same.

enter image description here

What I want to achieve is to have a gap between the image and the icons displayed. I tried using padding but the text overflows with the same. Can anyone suggest as to what wrong am I doing here?

2

Answers


  1. Try to reate a margin-top for .container

    Login or Signup to reply.
  2.  container: {
            flex: 1,
            alignItems: 'center',
            paddingHorizontal: 20,
            alignItems: 'flex-end'
            margin-top: 10%;
          },
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search