4.2.36 • Published 7 months ago

softchatjs-react-native v4.2.36

Weekly downloads
-
License
ISC
Repository
github
Last release
7 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

7 months ago

4.2.35

10 months ago

4.2.34

10 months ago

4.2.33

10 months ago

4.2.32

10 months ago

4.2.31

10 months ago

4.2.30

10 months ago

4.2.29

10 months ago

4.2.28

10 months ago

4.2.27

10 months ago

4.2.26

10 months ago

4.2.25

10 months ago

4.2.24

10 months ago

4.2.23

10 months ago

4.2.22

10 months ago

4.2.21

10 months ago

4.2.2

10 months ago

4.2.12

10 months ago

4.2.11

10 months ago

4.2.1

10 months ago

4.2.0

10 months ago

4.1.9

10 months ago

4.1.80

10 months ago

4.1.79

10 months ago

4.1.78

10 months ago

4.1.77

10 months ago

4.1.76

10 months ago

4.1.75

10 months ago

4.1.74

10 months ago

4.1.73

10 months ago

4.1.72

10 months ago

4.1.71

10 months ago

4.1.70

10 months ago

4.1.68

10 months ago

4.1.66

10 months ago

4.1.65

10 months ago

4.1.64

10 months ago

4.1.63

10 months ago

4.1.62

10 months ago

4.1.61

10 months ago

4.1.59

10 months ago

4.1.58

10 months ago

4.1.57

10 months ago

4.1.56

10 months ago

4.1.55

10 months ago

4.1.54

10 months ago

4.1.52

10 months ago

4.1.51

10 months ago

4.1.5

10 months ago

4.1.4

10 months ago

4.1.3

10 months ago

4.1.2

10 months ago

4.1.1

10 months ago

4.1.0

10 months ago

4.0.9

10 months ago

4.0.7

10 months ago

4.0.6

10 months ago

4.0.5

10 months ago

4.0.2

10 months ago

4.0.1

10 months ago

4.0.0

10 months ago

3.0.9

10 months ago

3.0.8

10 months ago

3.0.7

10 months ago

3.0.6

10 months ago

3.0.5

10 months ago