Code Monkey home page Code Monkey logo

Comments (2)

pcofilada avatar pcofilada commented on August 17, 2024 2

You can do this by moving <View name="plan" style={styles.tabButtons}><Icon size={25} name="dot-circle-o"/><Text>Plan</Text></View> to a new component, maybe you could call it as TabBarItem then use it like <TabBarItem name='plan' selectedStyle={{ color: 'red' }} />. After that, on your TabBarItem component you can get the selectedStyle on your props.

Here is my sample code:

import React from 'React'
import { View, Text } from 'react-native'
import Icon from 'react-native-vector-icons/Ionicons';

const TabBarItem = ({ name, selectedItem, selectedStyle, text, icon }) => {
  const {
    iconTextWrapperStyle,
    iconStyle,
    textStyle
  } = styles

  return (
    <View style={iconTextWrapperStyle}>
      <Icon name={icon} style={[iconStyle, selectedItem === name ? selectedStyle : {}]}/>
      <Text style={[textStyle, selectedItem === name ? selectedStyle : {}]}>{text}</Text>
    </View>
  )
}

const styles = {
  iconTextWrapperStyle: {
    flexDirection: 'column',
    alignItems: 'center',
    justifyContent: 'center'
  },
  iconStyle: {
    fontSize: 25,
    color: 'grey'
  },
  textStyle: {
    fontSize: 10,
    color: 'grey'
  }
}

export default TabBarItem

from react-native-tabs.

vongohren avatar vongohren commented on August 17, 2024

Closing for good answer

from react-native-tabs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.