npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-native-web-image

v0.0.6

Published

An image component for react-native with persistent disk and memory caching

Downloads

20

Readme

React Native WebImage

An image component for react-native with persistent disk and memory caching.

It is mostly a wrapper around native libraries which actually do the hard work. On Android it uses Glide, on iOS – SDWebImage.

:warning: The package is currently in alpha stage of development. If you find a bug or missing functionality, please feel free to report, but better fix or implement what you want and send a pull request to GitHub repository.

Installation

npm install --save react-native-web-image
react-native link

| version | react-native | | ------------- | ------------ | | 0.0.5 - 0.0.6 | >=0.47.0 | | 0.0.3 - 0.0.4 | >=0.40.0 | | <=0.0.2 | <0.40.0 (tested with 0.37.0) |

Usage

import React, { Component } from 'react'
import { StyleSheet, Text, View } from 'react-native'
import WebImage from 'react-native-web-image'

export default class App extends Component {
  render() {
    const imageUri = 'https://placeholdit.imgix.net/~text?txtsize=33&txt=200x150&w=200&h=150'
    return (
      <View style={styles.container}>
        <Text style={styles.welcome}>Sample image</Text>
        <View style={styles.imgContainer}>
          <WebImage style={styles.img} source={{uri:imageUri}}/>
        </View>
      </View>
    )
  }
}

const white = '#FFFFFF'
const blue = 'rgb(0,0,255)'
const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: white,
  },
  welcome: {
    fontSize: 20,
    textAlign: 'center',
    margin: 10,
  },
  img: {
    flex: 1,
  },
  imgContainer: {
    flexDirection: 'row',
    flex: 1,
    borderWidth: 1,
    borderColor: blue,
  }
})

API

WebImage element

<WebImage source={source}/>

| Attribute | Type | Description | | ---------- | -------- | ----------- | | source | Object | Describes image source (mimics original Image element) | | source.uri | String | (Required) URL of the image | | resizeMode | Enum{'cover','contain','stretch','center'} | Determine resize mode for image. Default: 'contain' | | onError | Function | Will be called on error |

Resize modes

  • contain - Scale the image uniformly (maintain the image's aspect ratio) so that both dimensions (width and height) of the image will be equal to or less than the corresponding dimension of the view (minus padding).
  • cover - Scale the image uniformly so that both dimensions (width and height) of the image will be equal to or larger than the corresponding dimension of the view (minus padding).
  • stretch - Scale width and height independently, aspect ration will not be preserved.
  • center - Scale the image down so that it is completely visible, if bigger than the area of the view. The image will not be scaled up. The image will be placed at the center of the view.

onError(event)

  • event.error - String representation of error (platform dependent)
  • event.uri - URI which leads to error

Author

Vladimir Timofeev

Contributors

License

  • Main source code is licensed under the MIT License.
  • SDWebImage (embedded in project) is licensed under the MIT License.
  • Glide (included via gradle) is licensed under Apache 2.0 License.