Giter Club home page Giter Club logo

react-native-icons's Introduction

WARNING: This library is discontinued, I highly recommend using https://github.com/oblador/react-native-vector-icons

There's far bigger problems to solve in the open source and React Native communities than competing icon libraries so I'll be focusing on pushing forward other initiatives.

React Native Icons

npm version

Includes 5 different icon fonts and 2,444 icons.

Installation

npm install react-native-icons@latest --save

If you need to support React Native version < 0.12.0-rc use:

npm install [email protected] --save

Note that 0.4.0 does not support Android.

Getting started - iOS

  1. In XCode, in the project navigator right click LibrariesAdd Files to [your project's name]
  2. Go to node_modulesreact-native-iconsios and add ReactNativeIcons.xcodeproj
  3. Add libReactNativeIcons.a (from 'Products' under ReactNativeIcons.xcodeproj) to your project's Build PhasesLink Binary With Libraries phase
  4. Add the font files you want to use into the Copy Bundle Resources build phase of your project (click the '+' and click 'Add Other...' then choose the font files from node_modules/react-native-icons/ios/ReactNativeIcons/Libraries/FontAwesomeKit).
  5. Run your project (Cmd+R)

Getting started - Android

  • In android/setting.gradle
...
include ':react-native-icons'
project(':react-native-icons').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-icons/android')
  • In android/app/build.gradle
...
dependencies {
    ...
    compile project(':react-native-icons')
}
  • register module (in MainActivity.java)
import com.smixx.reactnativeicons.ReactNativeIcons;  // <--- import
import java.util.Arrays; // <--- import this if you want to specify which fonts to load
import com.smixx.reactnativeicons.IconFont; // <--- import this if you want to specify which fonts to load

public class MainActivity extends Activity implements DefaultHardwareBackBtnHandler {
  ......

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mReactRootView = new ReactRootView(this);

    mReactInstanceManager = ReactInstanceManager.builder()
      .setApplication(getApplication())
      .setBundleAssetName("index.android.bundle")
      .setJSMainModuleName("index.android")
      .addPackage(new MainReactPackage())
      .addPackage(new ReactNativeIcons())              // <------ add here
      .setUseDeveloperSupport(BuildConfig.DEBUG)
      .setInitialLifecycleState(LifecycleState.RESUMED)
      .build();

    mReactRootView.startReactApplication(mReactInstanceManager, "example", null);

    setContentView(mReactRootView);
  }

  ......

}
  • Copy the font files and .json files for the fonts you want to use into android/app/src/main/assets from node_modules/react-native-icons/fonts

Not supported on Android yet:

  • Tab Bar
  • Stacked Icons

Custom fonts

iOS

Custom fonts are not yet supported for iOS

Android

1. Copy the font file to your apps assets directory

2. Create a myfontname.json mapping file for the font, this is used to look up the mapping file and is used

Create json file (newiconfont.json) that contains a map of css names to HTML encoded unicode characters., examples in /fonts directory

{
  "alert": "&#xf101",
  "alert-circled": "&#xf100",
  "android-add": "&#xf2c7",
  "android-add-circle": "&#xf359",
...
}

3. Include fonts

  1. Copy font file and .json file to your apps assets directory 3.) In MainActivity.java, add the icon font, first parameter is the prefix you want to use (ex. typicons|globe), second is the filename of the font.
 mReactInstanceManager = ReactInstanceManager.builder()
                .setApplication(getApplication())
                .setBundleAssetName("index.android.bundle")
                .setJSMainModuleName("index.android")
                .addPackage(new MainReactPackage())
                .addPackage(new ReactNativeIcons(Arrays.asList(
                        new IconFont("typicons", "typicons.ttf")
                )))
                .setUseDeveloperSupport(BuildConfig.DEBUG)
                .setInitialLifecycleState(LifecycleState.RESUMED)
                .build();

Notes

  • You only need to include the icon font files you want to use
  • Icon style must set a width and height, or the icon will not be visible
  • You may need to restart your node server for the icon font files to be included.
  • An icon has a name, size, and a color (optional)
  • Color can be provide via the color property or via a style

Example of icons

var { Icon, } = require('react-native-icons');


<Icon
  name='ion|beer'
  size={150}
  color='#887700'
  style={styles.beer}
/>
<Icon
  name='zocial|github'
  size={70}
  color='black'
  style={styles.github}
/>
<Icon
  name='fontawesome|facebook-square'
  size={70}
  color='#3b5998'
  style={styles.facebook}
/>
<Icon
  name='foundation|lightbulb'
  size={30}
  color='#777777'
  style={styles.lightbulb}
/>

<Icon
  name='material|face'
  size={30}
  color='#333333'
  style={styles.face}
/>

Stacked icons

<Icon
  name='fontawesome|square'
  size={80}
  color='#55acee'
  style={styles.twitterOutline}>
  <Icon
    name='fontawesome|twitter'
    size={50}
    color='#ffffff'
    style={styles.twitterIcon}/>
</Icon>

With the following styles to center them:

var styles = StyleSheet.create({
  twitterOutline: {
    flexDirection: 'column',
    width: 70,
    height: 70,
    alignItems: 'center'
  },
  twitterIcon: {
    flex: 1,
    width: 40,
    height: 40
  },
});

Custom tab bar

var { TabBarIOS, } = require('react-native-icons');
var TabBarItemIOS = TabBarIOS.Item;

var Example = React.createClass({
  getInitialState: function() {
    return {
      selectedTab: 'home',
      notifCount: 0,
      presses: 0,
    };
  },
  render: function () {
    return (
      <TabBarIOS
        selectedTab={this.state.selectedTab}
        tintColor={'#c1d82f'}
        barTintColor={'#000000'}
        styles={styles.tabBar}>
        <TabBarItemIOS
          name="home"
          iconName={'ion|ios-home-outline'}
          selectedIconName={'ion|ios-home'}
          title={''}
          iconSize={32}
          accessibilityLabel="Home Tab"
          selected={this.state.selectedTab === 'home'}
          onPress={() => {
            this.setState({
              selectedTab: 'home',
            });
          }}>
          {this._renderContent()}
        </TabBarItemIOS>
        <TabBarItemIOS
            name="articles"
            iconName={'ion|ios-paper-outline'}
            selectedIconName={'ion|ios-paper'}
            title={''}
            iconSize={32}
            accessibilityLabel="Articles Tab"
            selected={this.state.selectedTab === 'articles'}
            onPress={() => {
            this.setState({
              selectedTab: 'articles',
            });
          }}>
          {this._renderContent()}
        </TabBarItemIOS>
        <TabBarItemIOS
            name="messages"
            iconName={'ion|chatboxes'}
            title={''}
            iconSize={32}
            accessibilityLabel="Messages Tab"
            selected={this.state.selectedTab === 'messages'}
            onPress={() => {
            this.setState({
              selectedTab: 'messages',
            });
          }}>
          {this._renderContent()}
        </TabBarItemIOS>
        <TabBarItemIOS
            name="settings"
            iconName={'ion|ios-gear-outline'}
            selectedIconName={'ion|ios-gear'}
            title={''}
            iconSize={32}
            accessibilityLabel="Settings Tab"
            selected={this.state.selectedTab === 'settings'}
            onPress={() => {
            this.setState({
              selectedTab: 'settings',
            });
          }}>
          {this._renderContent()}
        </TabBarItemIOS>
      </TabBarIOS>
    );
  }
});

Note: selectedIconName is optional. It defaults to iconName if not set. Also, there's another optional property named selectedIconSize, if you need to change the icon size when the tab is selected.

Included icon fonts

Screenshot

react-native-icons's People

Contributors

admmasters avatar alexkrolick avatar almost avatar andreo avatar auser avatar austinlyons avatar badfortrains avatar brentvatne avatar cieni avatar corymsmith avatar deepure avatar dvdhsu avatar gitter-badger avatar jeffreywescott avatar jonasjonny avatar linghuaj avatar masonicboom avatar michaelgmcd avatar mosch avatar mvayngrib avatar paulgessinger avatar pgmemk avatar skevy avatar skv-headless avatar theoriginalgri avatar zixan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

react-native-icons's Issues

Question: How to change color for "inactive" tab item?

Hello,
I couldn't find a way how to change default text color (gray) to white or anything. Background for active/inactive tab will be nice feature too.
But text is really important because when I will change "barTintColor" then gray looks really bad.
For active tab "tintColor" is working as expected.
Styles are also not working.

Thank you for any help.

Example crashes because of redundant code in FAKZocial.m

https://github.com/corymsmith/react-native-icons/blob/master/iOS/ReactNativeIcons/Libraries/FontAwesomeKit/FAKZocial.m#L9-L16

#ifndef DISABLE_ZOCIAL_AUTO_REGISTRATION
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        NSURL *resourcesBundleUrl = [[NSBundle mainBundle] URLForResource:@"ReactNativeIconsResources" withExtension:@"bundle"];
        NSBundle *bundle = [NSBundle bundleWithURL:resourcesBundleUrl];
        [self registerIconFontWithURL: [[NSBundle mainBundle] URLForResource:@"zocial-regular-webfont" withExtension:@"ttf"]];
    });
#endif

bundle is never used but crashes, because there is no ReactNativeIconsResources.bundle:

screen shot 2015-05-21 at 12 28 47 pm

No manager class found for view with module name "FAKIconImage"

Hello,

after integrating everything in my app, I get the following error in XCODE:

[tid:com.facebook.ReactKit.ShadowQueue][RCTUIManager.m:746] No manager class found for view with module name "FAKIconImage"

Do you know the background of this error?

Regards
Philipp

not work

it's not work. my app crashed.

#ifdef __BLOCKS__
__OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_4_0)
DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW
void
dispatch_once(dispatch_once_t *predicate, dispatch_block_t block);

DISPATCH_INLINE DISPATCH_ALWAYS_INLINE DISPATCH_NONNULL_ALL DISPATCH_NOTHROW
void
_dispatch_once(dispatch_once_t *predicate, dispatch_block_t block)
{
    if (DISPATCH_EXPECT(*predicate, ~0l) != ~0l) {
        dispatch_once(predicate, block); // crashed here
    }
}
#undef dispatch_once
#define dispatch_once _dispatch_once
#endif

Push and pop breaks SMXTabBarIOS

Much like #37, but occurs with just the library, and no views.

To replicate, just make a SMXTabBarIOS, then in one of the tabs, attempt to push another view on top. When that top view is popped, the tab bar (which is on the bottom) is entirely broken.

ios simulator screen shot jun 16 2015 3 15 47 am

Icons being clipped

The zocial Twitter icon (and many of their other ones) is being clipped.

<FAKIconImage name={'zocial|twitter'} size={50} style={{width:50, height: 50}} color='white' />

Image of clipping

I've tried messing with the both the size prop, and what I pass to width and height, but it keeps clipping.

Cannot install react-native-icons in my existing project

Hello guys, I've tried to setup react-native-icons following the installation guide on github, however my build fails with some errors like (RCTRootView.h , RCTViewManager.h not found)
I've also tried to clone the example and run it on my device but still errors appear when I try to build in xCode.

Any ideas?

Thanks in advance !

Requiring internal react-native modules will stop working

react-native uses a module format that is specific to Facebook that relies on a global namespace. We're trying to isolate it from the outside world and use the standard CommonJS and node modules instead. Therefore in the latest react-native version 0.7.0-rc.2 requiring any of the internal modules using their name will be warning and in the future will be an error.

For example require('NativeModules') is now a warning:

Unable to resolve module NativeModules from [project_path]/node_modules/react-native-icons/FAKIconImage.ios.js

To depend on NativeModules please use the exported react-native node module:

require('react-native').NativeModules

This issue was originally reported here: facebook/react-native#1808

Icons aren't showing after upgrade to 0.0.3

Hi,
after upgrade to react-native 0.3.11 and icons to 0.0.3 icons aren't displaying. I am also using SMXTabBar in project and in console I can see warning: [tid:com.facebook.ReactKit.ShadowQueue][RCTUIManager.m:738] No manager class found for view with module name "SMXTabBar". TabBar is not displaying at all too.
Maybe I made mistake in step 7, witch files should be added? Only *.ttf | *.otf ?

'User Search Paths' not in Xcode

I'm stuck on point 6. There are a number of similar labels in Build Settings but none which are exactly 'User Search Paths'. The photo shows my available option

search paths

Ionic icons not working

When I try to reference an ionic icon (ionic ios icons work fine) like so:

<Icon
    name='ion|mic-a'
    size={50}
    color={'#f7f5ff'}
    style={styles.audioCreateIcon}
     >
</Icon>

Ios icons work fine but with normal ionic icons I get an error EXC Bad Instruction.

Cannot update icon props

Hi,
First of all many thanks for this great component!
I don't seem to be able to change icon props once it's been drawn :

<Icon
    size={ 20 }
    name="ion|beer"
    color={ (this.state.selected && 'red') || 'blue' }
    style={ {height: 20, width: 20} }
/>

The icon is correctly drawn on first render, but the color doesn't change on state update. Am I doing something wrong ?

Many thanks

Adding project to package.json and npm installing breaks the app

@corymsmith This is probably something else I am missing but I narrowed it down to the following

Step 1 - 'react-native init TestProject' // using react-native 0.4

After adding react-native-icons to package.json
Step 2 - npm install

Run app, and it just hangs after the splash screen. If I remove the react-native-icons from the node_modules folder and re run the app, it loads just fine, have you encountered this?

Thanks

Jose

Icons as image assets

Hi, it would be great to have a way to get icons as image assets as well, so to be used wherever react native allows for an Image.propTypes.source. Make sense? Is it a dream? :)

Font Icons Not Showing

I followed through Getting Started instructions and I'm using the code from Example/index.ios.js.

My issue is that I don't see any of the font icons rendering on the simulator.

ios simulator screen shot jun 15 2015 9 46 12 pm

I don't see any error messages on React Packager responses on Terminal, but I see some error messages displaying on chrome console.

screen shot 2015-06-15 at 9 45 45 pm

Can someone point me in the right direction to resolve this issue?

Cannot find module 'FAKIconImage'

I'm getting the following error after following the 6 steps in the readme getting started.

screen shot 2015-07-05 at 1 58 58 pm

The project builds fine, it just breaks on this require in my app when it runs.

Icon  = require('FAKIconImage')

I'm using react-native-webpack-server so wondering whether the issue may be related to that.

Any help would be much appreciated!

Icon not showing

Hi! I followed the instructions in other issues and successfully set the search path.
search-path

I also linked the library and exported the font:
linked-libraries

However, the icon is not showing.
icon-not-showing

My code is

var Icon = require('FAKIconImage');

// ......

        <Text>Blah 1</Text>
        <Icon
          name='foundation|lightbulb'
          size={30}
          color='#777777'
          style={styles.lightbulb}
        />
        <Text>Blah 2</Text>

As you can see, only the surrounding text is showing up.

Upgrading to react-native 0.6.0 causes Error

Hello,
After upgrading to 0.6.0, I'm getting these errors.

[error][tid:main][RCTModuleData.m:119] SMXTabBarManager is returning nil for it's methodQueue, 
which is not permitted. You must either return a pre-initialized queue, or @synthesize the 
methodQueue to let the bridge create a queue for you.

any idea?

Missing from NPM

Step 1 fails, as it doesn't looks like this package is available via npm?

react 0.60 breaking react-native-icon

Hi Im getting the error of

EXC_BAD_INSTRUCTIONS at FAKIconImageManager.m Line 49

SEL selector = NSSelectorFromString([NSString stringWithFormat:@"%@IconWithSize:",[self camelcase:iconIdentifier]]);

My console is logging
registerForRemoteNotificationTypes: is not supported in iOS 8.0 and later.

It is fine if I debug in phone though

Trouble upgrading to react-native 0.3.10

Hi,

After upgrading react-native to 0.3.10 (from 0.3.4) the project build fails with the following : Did you forget to use RCT_EXPORT_MODULE() ? (see attachments). Downgrading back to 0.3.4 solves the issue.

Thank you.

capture d ecran 2015-04-09 a 18 57 56
capture d ecran 2015-04-09 a 18 40 59

Push then Pop breaks SMXTabBarIOS

I have SMXTabBarIOS and Navigator set up, when you push something ontop of the tabs, then pop that scene, the scene with the tabs is broken.

[Bug? Using Icon] Invariant Violation: Expected a component class, got undefined.

Thanks for the plugin. Potentially a great help :)
However, I have successfully added the icons to a custom tab bar but attempting to use an icon in a regular view causes this error. Any ideas?

Invariant Violation: Expected a component class, got undefined.
<unknown>
ReactNativeDefaultInjection.js:101

getComponentClassForElement
ReactNativeComponent.js:59

React-Native v0.4.4
React-Native-Icons v0.0.9

does not work with the newest react-native 0.4.4

I would love to use your component in our react-native chat app.
I can see several cases where I want to use it instead of Images

BUT!!!

When building the project Xcode complains that it could not find node_modules/react-native/Libraries/ReactIOS/ReactIOSViewAttributes. And in fact this source is not there anymore (or anywhere for that matter).

Could you please take a look.

React-Native dependency

Hey,
Why the 0.4.x is no longer supported with the latest release?
Is it possible to add 0.6 support as well?

got an error

Class SMXTabBarManager was not exported, Did you forget to use RCT_EXPORT_MODULE()?

and can not display icons.

any help, thanks

Subspec to include different font icons

Would you be open to the idea of having multiple subspecs for different font icons? This would allow the ease of using pods, but without adding each and every font to the app.

As a new XCode User, I'm unable to complete Step 4 of Getting Started

Step 4 states:

Add libReactNativeIcons.a (from 'Products' under ReactNativeIcons.xcodeproj) to your project's Build PhasesLink Binary With Libraries phase.

First, I'm unable to find a Products item under ReactNativeIcons.xcodeproj. When I Show package contents, these are the only items I see:

project.pbxproj
project.xcworkspace
xcuserdata

Second, I found the Link Binary With Libraries phase action in XCode, however, its grayed out.

Upgrade to FontAwesome 4.3

Hey guys! Great library. It's been very convenient.

Are there any plans to upgrade to FontAwesome 4.3? I'm trying to use venus-mars, and it's not included in the current version.

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.