Skip to content

Commit 9c2bdb3

Browse files
committed
feat: 🎸release v0.0.1
1 parent 3cee457 commit 9c2bdb3

File tree

14 files changed

+48
-42
lines changed

14 files changed

+48
-42
lines changed

.github/CODEOWNERS

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# This is a comment.
2+
# Each line is a file pattern followed by one or more owners.
3+
4+
# These owners will be the default owners for everything in
5+
# the repo. Unless a later match takes precedence,
6+
# @global-owner1 and @global-owner2 will be requested for
7+
# review when someone opens a pull request.
8+
* @botstar-tra @chative-anh @chative-ly @chative-tu

CONTRIBUTING.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ Thank you for your interest in developing ChativeWidget! Below is a detailed gui
66

77
1. Clone the repository to your local machine:
88
```
9-
git clone https://github.com/botstar/chative-react-native-sdk.git
10-
cd chative-react-native-sdk
9+
git clone https://github.com/botstar/chative-react-native-widget.git
10+
cd chative-react-native-widget
1111
```
1212

1313
2. Install dependencies:
@@ -58,7 +58,7 @@ After you've completed your changes and want to test them:
5858
yarn livechat
5959
```
6060
This command will perform the following steps:
61-
- Remove the current version of chative-react-native-sdk
61+
- Remove the current version of chative-react-native-widget
6262
- Clear the yarn cache
6363
- Install the new version from the .tgz file
6464

README.md

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# ChativeWidget for React Native
1+
# Chative Widget for React Native
22

3-
ChativeWidget is a React Native component that provides an easy-to-use chat widget for your mobile applications. It allows you to integrate a customizable chat interface with minimal setup.
3+
Chative Widget is a React Native component that provides an easy-to-use chat widget for your mobile applications. It allows you to integrate a customizable chat interface with minimal setup.
44

55
## Features
66

@@ -10,22 +10,28 @@ ChativeWidget is a React Native component that provides an easy-to-use chat widg
1010
- Adjustable insets for different device sizes
1111
- TypeScript support
1212

13+
## Screenshot
14+
15+
<img src="./screenshot/screenshot.png" alt="screenshot" width="350">
16+
1317
## Installation
1418

1519
```bash
16-
npm install chative-react-native-sdk
20+
npm install chative-react-native-widget
1721
# or
18-
yarn add chative-react-native-sdk
22+
yarn add chative-react-native-widget
1923
```
2024

25+
This library depends on [react-native-webview](https://www.npmjs.com/package/react-native-webview) and [async-storage](https://github.com/react-native-async-storage/async-storage). Please follow the instructions provided in the docs.
26+
2127
## Usage
2228

2329
Here's a basic example of how to use the ChativeWidget in your React Native application:
2430

2531
```jsx
2632
import React, { useRef } from 'react';
2733
import { Button, View } from 'react-native';
28-
import ChativeWidget from 'chative-react-native-sdk';
34+
import ChativeWidget from 'chative-react-native-widget';
2935

3036
export default function App() {
3137
const widgetRef = useRef(null);
@@ -35,7 +41,7 @@ export default function App() {
3541
};
3642

3743
const handleCloseChat = () => {
38-
widgetRef.current?.hide();
44+
// widgetRef.current?.hide();
3945
};
4046

4147
return (
@@ -44,7 +50,7 @@ export default function App() {
4450
<ChativeWidget
4551
ref={widgetRef}
4652
channelId="your-channel-id"
47-
onClosed={handleCloseChat}
53+
onClosed={() => console.log('Widget closed')}
4854
onLoaded={() => console.log('Widget loaded')}
4955
onNewMessage={(message) => console.log('New message:', message)}
5056
/>
@@ -64,15 +70,14 @@ export default function App() {
6470
| insetBottom | number | No | Bottom inset (default: 50 for iOS, 20 for Android) |
6571
| onClosed | () => void | No | Callback when the widget is closed |
6672
| onLoaded | () => void | No | Callback when the widget is loaded |
67-
| onNewMessage | (message: any) => void | No | Callback when a new message is received |
73+
| onNewMessage | () => void | No | Callback when a new message is received |
6874
6975
## Methods
7076
7177
The following methods are available via the ref:
7278
7379
- `show()`: Display the chat widget
7480
- `hide()`: Hide the chat widget
75-
- `injectJavaScript(script: string)`: Inject custom JavaScript into the widget
7681
- `reload()`: Reload the widget
7782
7883
## Customization
@@ -93,7 +98,7 @@ You can customize the appearance of the widget by providing a custom header comp
9398
This module includes TypeScript declarations. You can import types like this:
9499
95100
```typescript
96-
import ChativeWidget, { ChativeWidgetRef } from 'chative-react-native-sdk';
101+
import ChativeWidget, { ChativeWidgetRef } from 'chative-react-native-widget';
97102
```
98103
99104
## License

examples/App.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
1-
import ChativeWidget from 'chative-react-native-sdk';
1+
import ChativeWidget from 'chative-react-native-widget';
22
import React, { useRef } from 'react';
33
import { Button, SafeAreaView, StyleSheet, View } from 'react-native';
44

55
export default function App() {
66
const chativeWidgetRef = useRef(null);
7+
const channelId = 's49f3a621-2f07-45a4-8019-92663014b998'; // Replace with your channel id
78

89
const handleOpenModal = () => {
910
chativeWidgetRef.current.show();
1011
};
1112

1213
const handleCloseModal = () => {
13-
chativeWidgetRef.current.hide();
14+
// chativeWidgetRef.current.hide();
1415
};
1516

1617
const onLoaded = () => {
@@ -28,7 +29,7 @@ export default function App() {
2829
</View>
2930
<ChativeWidget
3031
ref={chativeWidgetRef}
31-
channelId="sacfa6e20-cf0a-11ee-a51c-59f486eae982"
32+
channelId={channelId}
3233
onLoaded={onLoaded}
3334
onClosed={handleCloseModal}
3435
onNewMessage={onNewMessage}

examples/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
"android": "expo start --android",
88
"ios": "expo start --ios",
99
"web": "expo start --web",
10-
"livechat": "yarn remove chative-react-native-sdk && yarn cache clean && yarn add ../chative-react-native-sdk-v0.0.1.tgz"
10+
"livechat": "yarn remove chative-react-native-widget && yarn cache clean && yarn add ../chative-react-native-widget-v0.0.1.tgz"
1111
},
1212
"dependencies": {
1313
"@react-native-async-storage/async-storage": "^1.23.1",
14-
"chative-react-native-sdk": "../chative-react-native-sdk-v0.0.1.tgz",
14+
"chative-react-native-widget": "../chative-react-native-widget-v0.0.1.tgz",
1515
"expo": "~51.0.20",
1616
"expo-status-bar": "~1.12.1",
1717
"react": "18.2.0",

examples/yarn.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2263,9 +2263,9 @@ charenc@0.0.2, charenc@~0.0.1:
22632263
resolved "https://registry.yarnpkg.com/charenc/-/charenc-0.0.2.tgz#c0a1d2f3a7092e03774bfa83f14c0fc5790a8667"
22642264
integrity sha512-yrLQ/yVUFXkzg7EDQsPieE/53+0RlaWTs+wBrvW36cyilJ2SaDWfl4Yj7MtLTXleV9uEKefbAGUPv2/iWSooRA==
22652265

2266-
chative-react-native-sdk@../chative-react-native-sdk-v0.0.1.tgz:
2266+
chative-react-native-widget@../chative-react-native-widget-v0.0.1.tgz:
22672267
version "0.0.1"
2268-
resolved "../chative-react-native-sdk-v0.0.1.tgz#5b120f83c65105c86599bbac74461433b215afa2"
2268+
resolved "../chative-react-native-widget-v0.0.1.tgz#6b64d0e39773d3160899c53c54fe01236f1e76e2"
22692269

22702270
chownr@^2.0.0:
22712271
version "2.0.0"

index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import { ReactElement } from 'react';
44
import { ViewStyle } from 'react-native';
55

6-
declare module 'chative-react-native-sdk' {
6+
declare module 'chative-react-native-widget' {
77
export interface ChativeWidgetProps {
88
channelId: string;
99
headerComponent?: ReactElement;

package.json

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "chative-react-native-sdk",
2+
"name": "chative-react-native-widget",
33
"version": "0.0.1",
44
"description": "React Native SDK for Chative",
55
"main": "index.js",
@@ -9,7 +9,7 @@
99
},
1010
"repository": {
1111
"type": "git",
12-
"url": "git+https://github.com/botstar/chative-react-native-sdk.git"
12+
"url": "git+https://github.com/botstar/chative-react-native-widget.git"
1313
},
1414
"dependencies": {},
1515
"peerDependencies": {
@@ -46,12 +46,14 @@
4646
"react",
4747
"native",
4848
"chative",
49-
"widget"
49+
"widget",
50+
"chat",
51+
"customer-support"
5052
],
5153
"author": "chative",
5254
"license": "MIT",
5355
"bugs": {
54-
"url": "https://github.com/botstar/chative-react-native-sdk/issues"
56+
"url": "https://github.com/botstar/chative-react-native-widget/issues"
5557
},
56-
"homepage": "https://github.com/botstar/chative-react-native-sdk#readme"
58+
"homepage": "https://github.com/botstar/chative-react-native-widget#readme"
5759
}

screenshot/screenshot.png

496 KB
Loading

src/ChativeWidget.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ import PropTypes from 'prop-types';
22
import React, { forwardRef, useImperativeHandle, useRef, useState } from 'react';
33
import { Platform, SafeAreaView, StyleSheet, View } from 'react-native';
44
import WebViewComponent from './WebView';
5-
import { WidgetApi } from './helper';
5+
import { INDEX_HIDE, INDEX_SHOW } from './constants';
6+
import { WidgetApi } from './utils';
67

78
const propTypes = {
89
channelId: PropTypes.string.isRequired,
@@ -29,7 +30,7 @@ const ChativeWidget = forwardRef(({
2930
const webViewRef = useRef(null);
3031

3132
const modalStyleDynamic = {
32-
zIndex: isModalVisible ? 999 : -1,
33+
zIndex: isModalVisible ? INDEX_SHOW : INDEX_HIDE,
3334
opacity: isModalVisible ? 1 : 0,
3435
};
3536

@@ -41,6 +42,7 @@ const ChativeWidget = forwardRef(({
4142
const handleClose = () => {
4243
setIsModalVisible(false);
4344
onClosed && onClosed();
45+
webViewRef.current?.injectJavaScript(WidgetApi('openChatWindow'));
4446
};
4547

4648
useImperativeHandle(ref, () => ({
@@ -50,7 +52,6 @@ const ChativeWidget = forwardRef(({
5052
},
5153
hide: () => {
5254
setIsModalVisible(false);
53-
webViewRef.current?.injectJavaScript(WidgetApi('openChatWindow'));
5455
},
5556
injectJavaScript: (script) => {
5657
webViewRef.current?.injectJavaScript(script);

0 commit comments

Comments
 (0)