Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support icon type #41

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

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.

None yet

1 participant