Skip to content

Conversation

@ballad89
Copy link

Native base now supports icon type

Icon.propTypes = {
  ...IconNB.propTypes,
  style: PropTypes.oneOfType([
    PropTypes.object,
    PropTypes.number,
    PropTypes.array
  ]),
  name: PropTypes.string,
  ios: PropTypes.string,
  android: PropTypes.string,
  active: PropTypes.bool,
  type: PropTypes.string
};

which can be set to one of

setIcon(iconType) {
    if (iconType === undefined && this.context.theme) {
      // eslint-disable-next-line
      iconType = this.context.theme['@@shoutem.theme/themeStyle'].variables
        .iconFamily;
    }
    switch (iconType) {
    case 'AntDesign':
      this.Icon = AntDesign;
      break;
    case 'Entypo':
      this.Icon = Entypo;
      break;
    case 'EvilIcons':
      this.Icon = EvilIcons;
      break;
    case 'Feather':
      this.Icon = Feather;
      break;
    case 'FontAwesome':
      this.Icon = FontAwesome;
      break;
    case 'FontAwesome5':
      this.Icon = FontAwesome5;
      break;
    case 'Foundation':
      this.Icon = Foundation;
      break;
    case 'Ionicons':
      this.Icon = Ionicons;
      break;
    case 'MaterialCommunityIcons':
      this.Icon = MaterialCommunityIcons;
      break;
    case 'MaterialIcons':
      this.Icon = MaterialIcons;
      break;
    case 'Octicons':
      this.Icon = Octicons;
      break;
    case 'SimpleLineIcons':
      this.Icon = SimpleLineIcons;
      break;
    case 'Zocial':
      this.Icon = Zocial;
      break;
    default:
      this.Icon = Ionicons;
    }
  }

and used like this

<Icon name="exchange" type="FontAwesome" />

native-base already checks for iconType === undefined and also has a default in the switch

default:
      this.Icon = Ionicons;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant