Position the text alongside the thumbnail rather than in the center

In the current setup, my username text is positioned in the center of the view. I want to reconfigure it so that it displays directly to the right of the thumbnail. However, removing the alignItems: 'center', property from the item disrupts the entire style. Are there any alternative solutions to address this issue?

import { StyleSheet, Alert } from 'react-native';
import { View, Text, Button, Thumbnail } from 'native-base';
import Icon from 'react-native-vector-icons/FontAwesome';
import { moderateScale } from 'react-native-size-matters';
import { TouchableOpacity } from 'react-native-gesture-handler';

 return (
    <View style={styles.item}>
      <TouchableOpacity>
        <Thumbnail
          style={styles.thumbnail}
          source={{
            uri:
              'https://cdn4.iconfinder.com/data/icons/avatars-xmas-giveaway/128/afro_woman_female_person-512.png',
          }}
        />
      </TouchableOpacity>
      <View style={styles.nameContainer}>
        <Text style={styles.userName}>USER NAME</Text>
      </View>
      <Button
        rounded
        style={styles.deleteButton}>
        <Icon name="trash-o" size={moderateScale(20)} color="black" />
      </Button>
    </View>
  );
};

const styles = StyleSheet.create({
  item: {
    backgroundColor: 'pink',
    borderRadius: moderateScale(20),
    padding: moderateScale(20),
    marginVertical: moderateScale(8),
    marginHorizontal: 16,
    height: moderateScale(70),
    justifyContent: 'space-between',
    flexDirection: 'row',
    alignItems: 'center',
  },
  thumbnail: {
    height: 70,
    width: 70,
    position: 'relative',
  },
  nameContainer: {
    //flex: 1,
    // alignItems: 'center',
    // textAlign: 'center',
  },
  userName: {
    paddingRight: moderateScale(55),
    paddingLeft: moderateScale(20),
    //textAlign: 'center',
    color: 'white',
    fontWeight: '900'
  },
  deleteButton: {
    backgroundColor: '#31C283',
    width: moderateScale(45),
    justifyContent: 'center',
  },
  horizontalLine: {
    marginTop: moderateScale(30),
    width: '87%',
    height: moderateScale(1),
    backgroundColor: 'grey',
    alignSelf: 'center',
  },
});

I attempted to create a snack expo project but encountered difficulties using native base within it.

https://i.sstatic.net/Js1s3.png

Answer №1

You've introduced unnecessary padding. Update the styles as shown below to align the text beside the Thumbnail.

  fullNameBox: {
    display: 'inline-block',
  },
  userFullName: {
    color: '#FFFFFF',
    fontStyle: 'bold'
  },

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Directing users to a specific section on another webpage can be accomplished using HTML, JavaScript, or

<nav> <div class='container-fluid'> <h1 class='logo'>Logo</h1> <ul class='list-unstyled naving'> <li><a href='index.html'>Home</a></li> ...

Adjust the alignment of the text to match the orientation of the image

When creating a layout with text and an image, I want them to be contained within a parent element that has a specified height, such as 100px. The text should adjust to the content, whether it's a short phrase or a lengthy paragraph, without a fixed ...

Mastering the art of implementing dynamic template variables in TinyMCE

After exploring the 'full' example and conducting research on the Wiki and moxie forums, I have yet to find a solution. I am attempting to implement what the wiki states is possible, but encountered an issue when replacing the 'staffid' ...

Introducing a fresh parameter to initiate and end Server Sent Events

Assistance needed. I have implemented Server Sent Events to dynamically update a website using data from a database. Now, I aim to send a new parameter ('abc.php/?lastID=xxx') back to the PHP script based on information received in the previous ...

Angular BreakPointObserver is a powerful tool that allows developers

Hey there! I've been working with the BreakpointObserver and have run into an issue while trying to define breakpoints for mobile and tablet devices. It seems that my code is functioning properly for tablets, but not for mobile devices. Upon further i ...

Ways to dynamically update the navbar tabs based on the changing URL

Just starting out with React. I've created a React component called Navbar.js that will appear on 3 different pages: Landing, Login, and Home. However, the tabs displayed in each page are different. For instance, on the landing page it will show a lo ...

What causes the Bootstrap navbar dropdown to be partially obscured in IE8?

While working on a specific project, I have encountered an issue where everything seems to function properly in newer browsers except for IE8 during testing. The dropdown menu is functional, however, it appears hidden behind the main content area labeled ...

Accessing composable variables in Vue 3 without having to redefine refs from within a function

Currently, I am implementing a parent companyList component along with a reusable Table component and an useFetch composable in vue 3.2. Prior to integrating the Table component, my code looked like this: companyList <script setup> import { com ...

Guide on Sending a POST Request via HTTPS in Websites

I am developing a browser extension for Chrome that requires sending a post request to a server using standard HTTP. However, this is causing a mixed content error when I'm on a website that uses HTTPS, and the browser refuses to process my request. ...

Ways to improve the feedback for Typescript when dealing with the potential existence of a nested method

Recently encountered a critical bug that I believe could have been identified with the right TypeScript setup. Struggling to come up with a suitable title, so please bear with me. While initializing a widget app, similar to a chat app loaded by a parent a ...

empty area located on the right side of my HTML/CSS website

I'm struggling to figure out why a small white space appears next to my webpage. Inspecting the element shows that the body ends before the space begins, indicating the border is where it should be. As a beginner in HTML and CSS, I hope this issue wil ...

Issue with JavaScript variables (I presume) - there seems to be a conflict when one variable is used alongside another

I am attempting to conduct a test that requires displaying the number of attempts (each time the button is pressed) alongside the percentage of successful attempts, updating each time the button is clicked. However, I've encountered an issue where onl ...

Error: Unable to execute $(...).stellar since it is not a recognized function

Having some trouble implementing the stellar plugin. I've included all the necessary js, but keep getting an error in the dev tools console: 'Uncaught TypeError: $(...).stellar is not a function'. Here's what I have in the head tags: ...

Endless cycle of NGRX dispatching

I tried creating a simple ngrx project to test the store, but I encountered an infinite loop issue. Even after attempting to mimic other examples that do not have this problem. To begin with, I defined 2 class models as shown below: export interface IBookR ...

Combine arrays of objects by comparing two attributes in Typescript

Suppose I have an array in TypeScript that looks like this: const array = [ { id_m: "123", period: "Q1/22", amount: 1000 }, { id_m: "123", period: "Q1/22", amount: 500 }, { id_m: "123&q ...

Efficient method for a component to work seamlessly with both React 17 and the latest version React 18

With the introduction of React 18, there is a new method for manually rendering a component. Instead of using import ReactDOM from 'react-dom'; ReactDOM.render(component, container) it is now required to use import { createRoot } from 'reac ...

Issue with Next.js and snapscroll: Scroll does not reach the top of the page after changing routes

When using Snapscroll and setting the height to 100vh together, I encountered an issue where changing pages would not display the first element. Instead, it seemed like the elements were being affected by the previous page's position. Since I am util ...

``The importance of properly formatting a text string before encoding it into

Currently in the process of converting an XML document to JSON via a PHP backend and then sending it back to the frontend using AJAX. This is achieved through the following code snippet: print_r(json_encode($result_xml)); If you want to view the response ...

Class does not have the capability to deserialize an array

I encountered this issue with my code (see image): https://i.sstatic.net/QxI0f.png Here is the snippet of my code: function CheckLoginData() { var user = []; user.Email = $("#tbEmail").val(); user.Password = $("#tbPassword").val(); $.ajax({ type ...

Manifest file: Error detected at the beginning of line 1 and column 1 while using Chrome browser

After building my React app using npm run build, I encountered an issue where GET and POST requests from the front-end to back-end were returning a status of 200. However, there was a strange error causing all the images from my files not to appear on loca ...