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-flat-chat

v0.1.1

Published

An agnostic and fully customizable React Native chat

Downloads

11

Readme

Flat Chat GitHub version

A powerfull React Native chat component without external dependencies.

N.B: FlatChat is still under development and it's not ready for production yet. Feel free to test it and contribute.

Why choose FlatChat

  • Easy to use: only need few lines to get started
  • No dependencies: no third part component conflicts
  • Rich documentation: no struggle trying to make it works
  • Elegant, clean and modern design: no more old style chat, FlatChat uses a fresh design
  • :iphone: Native animations: FlatChat mimics a real native chat using smooth animations
  • :rocket: High performance: significant performance improvement with FlatList rather than ScrollView or ListView
  • Fully customizable: easy customize FlatChat with your requirements
  • Use case examples: useful examples to find the perfect configuration

Other features:

  • Keyboard avoiding
  • Avoid navigation bar height
  • Multiline text input
  • Messages filters: regex messages to avoid black-list words, spam, etc

Installation

  • Using npm: npm i -S react-native-flat-chat

Usage

  1. Import FlatChat component:
import { FlatChat } from 'react-native-flat-chat';
  1. Use it in your render() method providing properties. To make it works you need to pass two basic properties:
  • data (Array): chat messages data from your state. You can simply pass an empty array to make it starts with no messages or provide loaded messages
  • onSend (function): callback called every time user sends a new message.

Basic example

Here's a simple example of how your app scene should look like:

import React, { Component } from 'react';
import { FlatChat } from 'react-native-flat-chat';

export default class MyChatScene extends Component {
  state = {
    data: [] // chat messages data
  };

  // push new message into data
  sendMessage(message) {
    // enable the following line to test both bubbles
    //message.owner = message.key % 2 === 0 ? 'me' : 'stranger';

    this.setState({ data: [...this.state.data, message] });
  }

  render() {
    <View style={{ flex: 1 }}>

      // my awesome FlatChat component
      <FlatChat
        data={this.state.data}
        // assign a callback which will be called every time user sends a new message
        onSend={() => this.sendMessage()}   
      />

    </View>
  }
}

Other examples

Need more customization? You can find other useful examples here.

FlatList data Array

According to official documentation a FlatList (which is implemented inside FlatChat) takes items from a data array. A data item is an Object with the following properties:

{
  key: (Number),    // item UNIQUE key
                    // e.g 10

  owner: (String)   // the message owner
                    // e.g "me" or "stranger"

  text: (String)    // the message text
                    // e.g "Hey, what's up?"
}

N.B: FlatChat manages new messages with key data.length to make a unique key. If you provide loaded messages inside state.data make sure they have progressive keys starting from 0.

API

Read the API documentation here