React Native Smartassets Save

smart load react native image resource both from apk(ipa) and jsbundle Dir.

Project README

react-native-smartassets

Getting started

Smartassets change the react native image load logic by hook defaultAsset method.

Smartassets let your app can load image form apk(ipa in iOS case) and filesystem with smart choose.

before after

$ npm install --save react-native-smartassets

Mostly automatic installation

$ react-native link react-native-smartassets

Manual installation

iOS

  1. In XCode, in the project navigator, right click LibrariesAdd Files to [your project's name]
  2. Go to node_modulesreact-native-smartassets and add RNSmartassets.xcodeproj
  3. In XCode, in the project navigator, select your project. Add libRNSmartassets.a to your project's Build PhasesLink Binary With Libraries
  4. Run your project (Cmd+R)<

Android

  1. Open up android/app/src/main/java/[...]/MainActivity.java
  • Add import com.smallnew.smartassets.RNSmartassetsPackage; to the imports at the top of the file
  • Add new RNSmartassetsPackage() to the list returned by the getPackages() method
  1. Append the following lines to android/settings.gradle:
    include ':react-native-smartassets'
    project(':react-native-smartassets').projectDir = new File(rootProject.projectDir, 	'../node_modules/react-native-smartassets/android')
    
  2. Insert the following lines inside the dependencies block in android/app/build.gradle:
      compile project(':react-native-smartassets')
    

Usage

import {SmartAssets} from 'react-native-smartassets';
SmartAssets.initSmartAssets();
SmartAssets.setiOSRelateMainBundlePath(youOriginJsBundlePath);//optional

Open Source Agenda is not affiliated with "React Native Smartassets" Project. README Source: smallnew/react-native-smartassets
Stars
26
Open Issues
1
Last Commit
3 years ago
License
MIT

Open Source Agenda Badge

Open Source Agenda Rating