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

rax-listview

v0.6.5

Published

ListView component for Rax.

Downloads

156

Readme

ListView

npm

More complex list, Internal implementation dependent RecyclerView.

Install

$ npm install rax-listview --save

Import

import ListView from 'rax-listview';

Props

| name | type | default | describe | | :-------------------- | :------- | :--- | :------------------------------------ | | renderRow | Function | | template method (necessary) | | dataSource | List | '' | data that needs to be rendered, Use with renderRow (necessary) | | onEndReached | Function | | scroll to bottom trigger event | | onEndReachedThreshold | Number | 500 | distance of bottom place | | onScroll | Function | | event triggered when scrolling | | renderHeader | Function | | render list header | | renderFooter | Function | | render list footer | | renderScrollComponent | Function | | render scroll component in list |

Function

| name | param | return | describe | | :------- | :----- | :--- | :------------------- | | scrollTo | Object | / | param example:{x:0} or {y:100} |

Basic example

Must pass params: renderRow、 dataSource、 onEndReached

  • renderRow: templates for each row
  • dataSource: data that needs to be rendered
  • onEndReached: callback for triggering bottom of list
// demo
import {createElement, Component, render} from 'rax';
import View from 'rax-view';
import Text from 'rax-text';
import Image from 'rax-image';
import Link from 'rax-link';
import TextInput from 'rax-textinput';
import Button from 'rax-button';
import Switch from 'rax-switch';
import Video from 'rax-video';
import ScrollView from 'rax-scrollview';
import ListView from 'rax-listview';
import Touchable from 'rax-touchable';


let listData = [
    {name1: 'tom'}, {name1: 'tom'}, {name1: 'tom'},
    {name1: 'tom'}, {name1: 'tom'}, {name1: 'tom'},
    {name1: 'tom'}, {name1: 'tom'}, {name1: 'tom'},
    {name1: 'tom'}, {name1: 'tom'}, {name1: 'tom'},
    {name1: 'tom'}, {name1: 'tom'}, {name1: 'tom'},
    {name1: 'tom'}, {name1: 'tom'}, {name1: 'tom'},
    {name1: 'tom'}, {name1: 'tom'}, {name1: 'tom'},
    {name1: 'tom'}, {name1: 'tom'}, {name1: 'tom'},
    {name1: 'tom'}, {name1: 'tom'}, {name1: 'tom'},
    {name1: 'tom'}, {name1: 'tom'}, {name1: 'tom'},
    {name1: 'tom'}, {name1: 'tom'}, {name1: 'tom'},
    {name1: 'tom'}, {name1: 'tom'}, {name1: 'tom'},
    {name1: 'tom'}, {name1: 'tom'}, {name1: 'tom'},
    {name1: 'tom'}, {name1: 'tom'}, {name1: 'tom'},
    {name1: 'tom'}, {name1: 'tom'}, {name1: 'tom'},
    {name1: 'tom'}, {name1: 'tom'}, {name1: 'tom'},
];

class ListViewDemo extends Component {

  constructor(props) {
    super(props);
    this.state = {
      index: 0,
      data: listData
    };
  }
  listHeader = () => {
    return (
      <View style={styles.title}>
        <Text style={styles.text}>列表头部</Text>
      </View>
    );
  }
  listLoading = () => {
    if (this.state.index < 4) {
      return (
        <View style={styles.loading}>
          <Text style={styles.text}>loading...</Text>
        </View>
      );
    } else {
      return null;
    }
  }
  listItem = (item, index) => {
    if (index % 2 == 0) {
      return (
        <View style={styles.item1}>
          <Text style={styles.text}>{item.name1}</Text>
        </View>
      );
    } else {
      return (
        <View style={styles.item2}>
          <Text style={styles.text}>{item.name1}</Text>
        </View>
      );
    }
  }
  handleLoadMore = () => {
    setTimeout(() => {
      this.state.index++;
      if (this.state.index < 5) {
        this.state.data.push(
          {name1: 'loadmore 2'},
          {name1: 'loadmore 3'},
          {name1: 'loadmore 4'},
          {name1: 'loadmore 5'},
          {name1: 'loadmore 2'},
          {name1: 'loadmore 3'},
          {name1: 'loadmore 4'},
          {name1: 'loadmore 5'}
        );
      }
      this.setState(this.state);
    }, 1000);
  }

  render() {
    return (
      <View style={styles.container}>
      <ListView
        renderHeader={this.listHeader}
        renderFooter={this.listLoading}
        renderRow={this.listItem}
        dataSource={this.state.data}
        onEndReached={this.handleLoadMore}
      />
      </View>
    );
  }

};

const styles = {
  container: {
    padding: 20,
    borderStyle: 'solid',
    borderColor: '#dddddd',
    borderWidth: 1,
    marginLeft: 20,
    marginRight: 20,
    marginBottom: 10,
    flex: 1
  },
  title: {
    margin: 50
  },
  text: {
    fontSize: 28,
    color: '#000000',
    fontSize: 28,
    padding: 40
  },
  item1: {
    height: 110,
    backgroundColor: '#909090',
    marginBottom: 3
  },
  item2: {
    height: 110,
    backgroundColor: '#e0e0e0',
    marginBottom: 3
  },
  loading: {
    padding: 50,
    textAlign: 'center',
  }
};

render(<ListViewDemo />);

ListView with fixed module

// demo
import {createElement, Component, render} from 'rax';
import ListView from 'rax-listview';
import View from 'rax-view';
import Text from 'rax-text';

class Block extends Component {
  constructor(props) {
    super(props);
    this.state = {
      data: [{key: 'tom'}, {key: 'jeck'}, {key: 'tom'}, {key: 'jeck'}, 
             {key: 'tom'}, {key: 'jeck'}, {key: 'tom'}, {key: 'jeck'}, 
             {key: 'tom'}, {key: 'jeck'}, {key: 'tom'}, {key: 'jeck'}, 
             {key: 'tom'}, {key: 'jeck'}, {key: 'tom'}, {key: 'jeck'}, 
             {key: 'tom'}, {key: 'jeck'}, {key: 'tom'}, {key: 'jeck'}, 
             {key: 'tom'}, {key: 'jeck'}, {key: 'tom'}, {key: 'jeck'}, 
             {key: 'tom'}, {key: 'jeck'}, {key: 'tom'}, {key: 'jeck'}, 
             {key: 'tom'}, {key: 'jeck'}, {key: 'tom'}, {key: 'jeck'}, 
             {key: 'tom'}, {key: 'jeck'}, {key: 'tom'}, {key: 'jeck'}, 
             {key: 'tom'}, {key: 'jeck'}, {key: 'tom'}, {key: 'jeck'}, 
             {key: 'tom'}, {key: 'jeck'}]
    };
  }
  listItem = (item) => {
    return <Text>{item.key}</Text>; 
  }
  handleLoadMore = () => {
    setTimeout(() => {
      this.setState({
        data: [...this.state.data, { key: 'new data' }]
      }); 
    }, 3000);
  }
  render() {
    return <View style={{width: 750, height: 500}}>
      <View style={{backgroundColor: 'red'}}>header module</View>
      <ListView
        renderRow={this.listItem} 
        dataSource={this.state.data}
        onEndReached={this.handleLoadMore}
      ></ListView>
    </View>
  }
}
render(<Block />);