4.2.36 • Published 2 months ago

softchatjs-react-native v4.2.36

Weekly downloads
-
License
ISC
Repository
github
Last release
2 months ago

softchatjs-react-native

React native UI SDK for softchatjs-core. Create a free account at: https://www.softchatjs.com

Installation

npm install softchatjs-core softchatjs-react-native

Install the peer dependecies

npm install expo-av expo-camera expo-file-system expo-image expo-image-picker @shopify/flash-list expo-video

Usage

import React, { useEffect } from 'react';
import { ChatProvider, Conversations } from "softchatjs-react-native";
import ChatClient from "softchatjs-core"

const client = ChatClient.getInstance({ subId: 'xxxx', projectId: 'xxxx' });

var chatUser = {
    uid: '1234',
    username: 'abc-123',
    firstname: "John",
    lastname: "Doe",
    profileUrl: "",
    custom: { "anything": "anything" },
}

function App() {

    const [ currentConversation, setCurrentConversation ] = useState(null)

    useEffect(() => {
        if (client) {
            client.initializeUser(chatUser);
        }
    }, [client]);

  return (
    <ChatProvider
        client={client}
    >
        {currentConversation? (
            <Chat
                activeConversation={currentConversation}
            />
        ):(
            <Conversations
                user={chatUser}
                onOpen={({ activeConversation }) => {
                    setCurrentConversation(activeConversation)
                }}
            />
        )}
        
    </ChatProvider>
  );
}

export default App;

Guide

<Conversations /> Component API

Props

ParameterTypeDefaultDescription
userUserMetaRequired. chat user
onOpenFunctionRequired. Function that returns the selected conversation
renderItemFunctionRender a custom conversation item
renderHeaderFunctionRender a custom conversation header
renderPlaceHolderFunctionRender a custom placeholder
usersUserMeta[]list of users a conversation can be initiated with
storeConversationListMetaLocally stored conversation map

<Chat /> Component API

Props

ParameterTypeDefaultDescription
activeConversationConversationListItemRequired. Selected conversation
renderChatBubbleFunctionRender a custom chat item
renderHeaderFunctionRender chat header
placeholderJSX.ElementRender placeholder
renderHeaderFunctionRender custom chat input
keyboardOffsetnumberValue passed to adjust how the keyboard adjusts the input field when it's open

<BroadcastLists /> Component API

Props

ParameterTypeDefaultDescription
clientChatClientRequired. Selected conversation
onOpenFunctionRequired Function that returns the selected broadcast list
renderItemFunctionRender a custom broadacast list item

Customizing the UI

var fontFamily = "Giest"

var darkModeTheme: ReactTheme = {
  background: {
    primary: "#1b1d21", // White for the primary background
    secondary: "#202326", // Light grey for secondary background
    disabled: "#E0E0E0", // Very light grey for disabled background
  },
  text: {
    primary: "white", // Black text for high contrast
    secondary: "#4A4A4A", // Dark grey for secondary text
    disabled: "#9E9E9E", // Light grey for disabled text
  },
  action: {
    primary: "#007AFF", // Bright blue for primary action buttons
    secondary: "#5AA3FF", // Light blue for secondary action buttons
  },
  chatBubble: {
    left: {
      bgColor: "#343434", // Light grey for incoming message background
      messageColor: "white", // Dark grey for incoming message text
      messageTimeColor: "#6D6D6D", // Medium grey for message time
      replyBorderColor: "#D1D1D6", // Slightly darker grey for reply border
    },
    right: {
      bgColor: "#343434", // Light blue for outgoing message background
      messageColor: "white", // Black for outgoing message text
      messageTimeColor: "#6D6D6D", // Medium grey for message time
      replyBorderColor: "#A3D1FF", // Medium blue for reply border
    },
  },
  icon: "white", // Dark grey for icons
  divider: "rgba(128, 128, 128, 0.136)", // Light grey for dividers
  hideDivider: false,
  input: {
    bgColor: "#1b1d21", // Light grey for input background
    textColor: "white", // Black for input text
    emojiPickerTheme: "dark", // Light theme for emoji picker
  },
};

<ChatProvider
    client={client}
    theme={darkModeTheme}
    fontFamily={fontFamily}
>
    {children}
</ChatProvider>
4.2.36

2 months ago

4.2.35

5 months ago

4.2.34

5 months ago

4.2.33

5 months ago

4.2.32

5 months ago

4.2.31

5 months ago

4.2.30

5 months ago

4.2.29

5 months ago

4.2.28

5 months ago

4.2.27

5 months ago

4.2.26

5 months ago

4.2.25

5 months ago

4.2.24

5 months ago

4.2.23

5 months ago

4.2.22

5 months ago

4.2.21

5 months ago

4.2.2

5 months ago

4.2.12

5 months ago

4.2.11

5 months ago

4.2.1

5 months ago

4.2.0

5 months ago

4.1.9

5 months ago

4.1.80

6 months ago

4.1.79

6 months ago

4.1.78

6 months ago

4.1.77

6 months ago

4.1.76

6 months ago

4.1.75

6 months ago

4.1.74

6 months ago

4.1.73

6 months ago

4.1.72

6 months ago

4.1.71

6 months ago

4.1.70

6 months ago

4.1.68

6 months ago

4.1.66

6 months ago

4.1.65

6 months ago

4.1.64

6 months ago

4.1.63

6 months ago

4.1.62

6 months ago

4.1.61

6 months ago

4.1.59

6 months ago

4.1.58

6 months ago

4.1.57

6 months ago

4.1.56

6 months ago

4.1.55

6 months ago

4.1.54

6 months ago

4.1.52

6 months ago

4.1.51

6 months ago

4.1.5

6 months ago

4.1.4

6 months ago

4.1.3

6 months ago

4.1.2

6 months ago

4.1.1

6 months ago

4.1.0

6 months ago

4.0.9

6 months ago

4.0.7

6 months ago

4.0.6

6 months ago

4.0.5

6 months ago

4.0.2

6 months ago

4.0.1

6 months ago

4.0.0

6 months ago

3.0.9

6 months ago

3.0.8

6 months ago

3.0.7

6 months ago

3.0.6

6 months ago

3.0.5

6 months ago