Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate GiftedChat to TypeScript #1190

Merged
merged 19 commits into from
Apr 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .babelrc

This file was deleted.

55 changes: 55 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
version: 2

test: &test
docker:
- image: circleci/node:11.10.1
steps:
- checkout

- restore_cache:
keys:
- v1-dependencies-{{ .Branch }}-{{ checksum "yarn.lock" }}
- v1-dependencies-

- run:
name: Installing codecov
command: sudo yarn global add codecov

- run:
name: Installing dependencies
command: yarn install

- run:
name: Check typescript
command: yarn tsc

- run:
name: Check tslint
command: yarn lint

- run:
name: Check tests
command: yarn test:coverage

- run:
name: codecov
command: codecov

- save_cache:
paths:
- node_modules
- ~/.cache/yarn
key: v1-dependencies-{{ .Branch }}-{{ checksum "yarn.lock" }}

jobs:
test:
<<: *test

workflows:
version: 2
watchdog_system:
jobs:
- test:
filters:
branches:
only: /^feature\/.*$|^release\/.*$|^hotfix\/.*$/
1 change: 0 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@ android
ios
example
example-slack-message
example-pusher-chatkit
example-expo
22 changes: 0 additions & 22 deletions .eslintrc

This file was deleted.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ TODO.md
.vscode
Exponent-*.app
*.log
lib/
2 changes: 1 addition & 1 deletion .npmignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
example/
example-expo/
example-slack-message/
example-pusher-chatkit/
TODO.md
screenshots/
.babelrc
Expand All @@ -10,3 +9,4 @@ README.md
ISSUE_TEMPLATE.md
circle.yml
codecov.yml
media/
11 changes: 11 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"trailingComma": "all",
"semi": false,
"singleQuote": true,
"tabWidth": 2,
"useTabs": false,
"bracketSpacing": true,
"jsxBracketSameLine": false,
"jsxSingleQuote": true,
"printWidth": 80
}
10 changes: 0 additions & 10 deletions .travis.yml

This file was deleted.

77 changes: 49 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
💬 Gifted Chat
</h3>
<p align="center">
The most complete chat UI for React Native <br/>
<small>formerly known as Gifted Messenger</small>
The most complete chat UI for React Native
</p>
<p align="center">
<a href="https://www.npmjs.com/package/react-native-gifted-chat">
Expand All @@ -34,6 +33,24 @@
<a href="https://snack.expo.io/@xcarpentier/gifted-chat" target="_blank"><i>demo</i></a>
</p>

## Sponsor

<p align="center">
<br/>
<a href="https://www.lereacteur.io" target="_blank">
<img src="https://github.com/raw/FaridSafi/react-native-gifted-chat/sponsor-lereacteur/media/logo_sponsor.png">
</a>
<br>
<p align="center">
Coding Bootcamp in Paris co-founded by Farid Safi
</p>
<a href="https://www.lereacteur.io" target="_blank">
<p align="center">
Click to learn more
</p>
</a>
</p>

## Features

- Fully customizable components
Expand All @@ -47,6 +64,7 @@
- InputToolbar avoiding keyboard
- Redux support
- System message
- Write with TypeScript [soon](https://github.com/FaridSafi/react-native-gifted-chat/pull/1190)

## Dependency

Expand All @@ -69,35 +87,35 @@
## Example

```jsx
import React from 'react'
import { GiftedChat } from 'react-native-gifted-chat'
import React from "react";
import { GiftedChat } from "react-native-gifted-chat";

class Example extends React.Component {
state = {
messages: [],
}
messages: []
};

componentWillMount() {
this.setState({
messages: [
{
_id: 1,
text: 'Hello developer',
text: "Hello developer",
createdAt: new Date(),
user: {
_id: 2,
name: 'React Native',
avatar: 'https://placeimg.com/140/140/any',
},
},
],
})
name: "React Native",
avatar: "https://placeimg.com/140/140/any"
}
}
]
});
}

onSend(messages = []) {
this.setState(previousState => ({
messages: GiftedChat.append(previousState.messages, messages),
}))
messages: GiftedChat.append(previousState.messages, messages)
}));
}

render() {
Expand All @@ -106,10 +124,10 @@ class Example extends React.Component {
messages={this.state.messages}
onSend={messages => this.onSend(messages)}
user={{
_id: 1,
_id: 1
}}
/>
)
);
}
}
```
Expand Down Expand Up @@ -208,20 +226,23 @@ e.g. System Message
- **`onInputTextChanged`** _(Function)_ - Callback when the input text changes
- **`maxInputLength`** _(Integer)_ - Max message composer TextInput length
- **`parsePatterns`** _(Function)_ - Custom parse patterns for [react-native-parsed-text](https://github.com/taskrabbit/react-native-parsed-text) used to linkify message content (like URLs and phone numbers), e.g.:
```js
<GiftedChat
parsePatterns={(linkStyle) => [
{ type: 'phone', style: linkStyle, onPress: this.onPressPhoneNumber },
{ pattern: /#(\w+)/, style: { ...linkStyle, styles.hashtag }, onPress: this.onPressHashtag },
]}
/>
```

```js
<GiftedChat
parsePatterns={(linkStyle) => [
{ type: 'phone', style: linkStyle, onPress: this.onPressPhoneNumber },
{ pattern: /#(\w+)/, style: { ...linkStyle, styles.hashtag }, onPress: this.onPressHashtag },
]}
/>
```

- **`extraData`** _(Object)_ - Extra props for re-rendering FlatList on demand. This will be useful for rendering footer etc.
- **`minComposerHeight`** _(Object)_ - Custom min height of the composer.
- **`maxComposerHeight`** _(Object)_ - Custom max height of the composer.
* **`scrollToBottom`** _(Bool)_ - Enables the scrollToBottom Component (Default is false)
* **`scrollToBottomComponent`** _(Function)_ - Custom Scroll To Bottom Component container
* **`scrollToBottomOffset`** _(Integer)_ - Custom Height Offset upon which to begin showing Scroll To Bottom Component (Default is 200)

* **`scrollToBottom`** _(Bool)_ - Enables the scrollToBottom Component (Default is false)
* **`scrollToBottomComponent`** _(Function)_ - Custom Scroll To Bottom Component container
* **`scrollToBottomOffset`** _(Integer)_ - Custom Height Offset upon which to begin showing Scroll To Bottom Component (Default is 200)
* **`alignTop`** _(Boolean)_ Controls whether or not the message bubbles appear at the top of the chat (Default is false - bubbles align to bottom)

## Imperative methods
Expand Down
9 changes: 9 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module.exports = function(api) {
api.cache(true)
return {
presets: [
'module:metro-react-native-babel-preset',
'@babel/preset-typescript',
],
}
}
35 changes: 0 additions & 35 deletions circle.yml

This file was deleted.

Loading