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

v1.0.0

Published

"chat bubble for react-native"

Downloads

332

Readme

React Native Chat Bubble

React Native Chat bubble is a simple lightweight component for your React Native Applications which uses react-native-svg and react-native-size-matters to create a highly customizable chat bubble for you with curved tail or without.

Installation

react-native-chat-bubble has two peer dependencies:

react-native-svg and react-native-size-matters

You must install these alongside react-native-chat-bubble.

Install the package using npm or yarn:

npm install react-native-chat-bubble react-native-svg react-native-size-matters
yarn add react-native-chat-bubble react-native-svg react-native-size-matters

If you're using Expo, make sure to use the expo install command to install these packages to ensure compatibility with your Expo SDK version:

expo install react-native-chat-bubble
expo install react-native-svg
expo install react-native-size-matters

Usage


import ChatBubble from 'react-native-chat-bubble';

<ChatBubble
  isOwnMessage={true}
  bubbleColor='#1084ff'
  tailColor='#1084ff'
  withTail={true}
  onPress={() => console.log("Bubble Pressed!")}
>
  <Text>Your message content</Text>
</ChatBubble>

Check the example

Props

The SwipeableFlatList component accepts the following props:

ViewProps:

If you don't pass onPress function, the chat bubble wrapper will be a View from react-native and you can also pass the rest of the ViewProps, which you can check here

PressableProps

If you pass the onPress function, the package will wrap the ChatBubble in Pressable from react-native to call your function when the user presses the message, so you can also pass the rest of the PressableProps, which you can check here

isOwnMessage: boolean

Prop to identify the message and therefore the alignment.

children: ReactNode

The message content.

bubbleColor: string

Color of your chat bubble. Defaults to #1084ff for own messages and grey for others.

tailColor: string

Color of the tail of the chat bubble. If you pass a bubbleColor prop and your tail and the bubble are the same color, you don't need to use this prop, they'll match automatically.

withTail: boolean

Prop which defines if the tail is displayed with your message. Defaults to true.

withTail: boolean

Prop which defines if the tail is displayed with your message. Defaults to true.

hitSlop:({top: number, bottom: number, left: number, right: number})

increase the touchable area of the chat bubble.

maxWidth:number

Maximum width of your chat bubble. When adjusting maxWidth this prop should be used instead of a style override, in order to use moderateScale. Defaults to 250

style: StyleProp<ViewStyle>

Additional styles or style overrides for the chat bubble.

License

This project is licensed under the MIT License.

Dependencies

react-native-chat-bubble has a peer dependency on react-native-svg and react-native-size-matters. It will be installed automatically when you install this package. However, please ensure that your project meets the requirements for both of these libraries.

example


import React from 'react';
import { Alert, Image, StyleSheet, Text, View } from 'react-native';
import ChatBubble from "react-native-chat-bubble";

const App: React.FC = () => {

  return (
    <View style={styles.container}>
      <ChatBubble
        isOwnMessage={true}
        bubbleColor="#1084ff"
        tailColor="#1084ff"
        withTail={true}
        style={styles.chatBubble}
      >
        <Text style={styles.textOwn}>Lorem ipsum dolor sit amet consectetur adipisicing elit. Quas atque repudiandae alias nisi aut? Ut perferendis similique non vel! Blanditiis nihil enim culpa ex numquam commodi saepe? Non, ex recusandae.</Text>
      </ChatBubble>
      <ChatBubble
       onPress={() => Alert.alert("Hi", "This is alert")}
        isOwnMessage={false}
        bubbleColor="lightgrey"
        withTail={true}
        style={styles.chatBubble}
      >
        <Text style={styles.text}>hi.</Text>
      </ChatBubble>
      <ChatBubble
        isOwnMessage={true}
        bubbleColor="#1084ff"
        tailColor="#1084ff"
        withTail={true}
        style={styles.chatBubble}
      >
        <Text  style={styles.textOwn}>Lorem ipsum dolor sit amet consectetur adipisicing elit. Quas atque repudiandae alias nisi aut? Ut perferendis similique non vel! Blanditiis nihil enim culpa ex numquam commodi saepe? Non, ex recusandae.</Text>
      </ChatBubble>
      <ChatBubble
        isOwnMessage={true}
        bubbleColor="#1084ff"
        tailColor="#1084ff"
        withTail={true}
        style={styles.chatBubble}
      >
        <Image style={{height:100, width:100}} 
        resizeMode="contain" 
        resizeMethod="resize"  
        source={{uri: "https://raw.githubusercontent.com/GFean/rn-gesture-swipeable-flatlist-example/main/assets/favicon.png"}}/>
      </ChatBubble>
    </View>
  );
};

const styles = StyleSheet.create({
  container: {
   marginTop:100,
    flex: 1,
   paddingHorizontal:10
  },
  chatBubble: {
    padding: 10,
  },
  text: {
    color: 'black',
  },
  textOwn: {
   color: 'white',
 },
});

export default App