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-custom-chat-module

v0.3.0

Published

Chat Module

Downloads

2

Readme

react-native-custom-chat-module

A Simple React Native Chat Module

Installation

yarn add react-native-custom-chat-module

Second step(Plugins Installation):

run this command

yarn add react-native-vector-icons uuid react-native-random-values

Add types for react-native-vector-icons

yarn add -D @types/react-native-vector-icons

Setup IOS

make sure you have installe dth epods by running the following command

cd ios && pod install

Also make sure you have imported react-native-get-random-value on the begeniing of App.js or App.tsx

// App.tsx
import * as React from 'react';
import 'react-native-get-random-values';

// rest of the component

Usage

import ChatList from 'react-native-custom-chat-module';

// ...

<ChatList
  tintColor="#fff"
  headerTitleStyle={{ color: '#fff' }}
  headerStyle={{ backgroundColor: '#1A1F16' }}
  title="Message Title"
  onBackPress={() => {
    // do someting on back press
  }}
  inputPlaceholderTextColor="#ccc"
  chatInputStyle={{ color: '#fff' }}
  onSendMessage={(newMessage) => {
    // api call or store in state
  }}
  data={messages}
/>;

props

export type IMessageType = {
  /**
   * id of the string unique
   */
  id: string;
  /**
   * message string
   */
  message: string;
  /**
   * sent or recived date of the message
   */
  date: string;
  /**
   * to identify weather message is sent or recived
   */
  sent: boolean;
};

export type IChatListProps = Omit<ViewProps, 'style'> & {
  /**
   * style of the component
   * @default {flex: 1}
   */
  style?: StyleProp<ViewStyle>;
  /**
   * Name or Title of the chat
   */
  title: string;
  /**
   * function which will be called when cross icon on the header is pressed
   * @returns void
   */
  onBackPress?: () => void;
  /**
   * function which will be called when send icon is pressed in the input
   * @param message Message object created by the input text
   * @returns void
   *
   *
   * ```js
   * Eg:
   * <ChatList
   *    onSendMessage={(newMessage) => {
   *        // call the api or store in state
   *    }}
   * />
   *
   * ```
   */
  onSendMessage?: (message: IMessageType) => void;

  /**
   * data array of messages
   *
   * ```js
   * Eg:
   *
   * const items = [{
   *    id: "1",
   *    message: "New Message",
   *    date: new Date().toString()
   * }];
   *
   * return (
   *    <ChatList
   *        data={items}
   *    />
   * )
   *
   * ```
   */
  data: IMessageType[];
  /**
   * header style
   * use this to se the header height and backgroud coloe of the header
   */
  headerStyle?: StyleProp<Omit<ViewStyle, 'justifyContent' | 'alignItems'>>;
  /**
   * header title text style
   * user this to set the style for the header title text
   */
  headerTitleStyle?: StyleProp<TextStyle>;

  /**
   * chat input style
   * use this to change the style for the chat inpput component
   * ie: font size, color, family etc
   */
  chatInputStyle?: StyleProp<TextStyle>;
  /**
   * use this to change the style of the chat input container
   */
  chatInputContainerStyle?: StyleProp<ViewStyle>;
  /**
   * These styles will be applied to the scroll view content container which
   * wraps all of the child views. Example:
   *
   *   return (
   *     <ChatList listContentContainerStyle={styles.contentContainer} />
   *   );
   *   ...
   *   const styles = StyleSheet.create({
   *     contentContainer: {
   *       paddingVertical: 20
   *     }
   *   });
   */
  listContentContainerStyle?: StyleProp<ViewStyle>;
  /**
   * titne color changes the the color of the header title and the back button
   */
  tintColor?: ColorValue;
  /**
   * The text color of the placeholder string
   */
  inputPlaceholderTextColor?: ColorValue;
};

export type IChatHeaderProps = Pick<
  IChatListProps,
  'title' | 'onBackPress' | 'headerStyle' | 'headerTitleStyle' | 'tintColor'
> & {};

export type IChatInputProps = Pick<
  IChatListProps,
  | 'onSendMessage'
  | 'chatInputStyle'
  | 'chatInputContainerStyle'
  | 'inputPlaceholderTextColor'
> & {};

export type IListComponentProps = Pick<
  IChatListProps,
  'data' | 'listContentContainerStyle'
>;

export type IMessageItemProps = {
  item: IMessageType;
};

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT


Made with create-react-native-library