Skip to content

Commit

Permalink
fix android keyboard
Browse files Browse the repository at this point in the history
  • Loading branch information
FaridSafi committed Jul 30, 2016
1 parent 056f25d commit 79b1964
Show file tree
Hide file tree
Showing 23 changed files with 50 additions and 210 deletions.
3 changes: 3 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"presets": ["react-native"]
}
3 changes: 2 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
}
},
"env": {
"node": true
"node": true,
"jest": true
}
}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
node_modules/
npm-debug.log
TODO.md
__tests__
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@ The most complete chat UI for React Native (formerly known as Gifted Messenger)
## Installation
- `npm install react-native-gifted-chat --save`

## Android installation
- Add `windowSoftInputMode` in your Android Manifest `android/app/src/main/AndroidManifest.xml`
```
<!-- ... -->
android:label="@string/app_name"
android:windowSoftInputMode="adjustResize" // <!-- add this -->
android:configChanges="keyboard|keyboardHidden|orientation|screenSize">
<!-- ... -->
```

## Minimal example
```jsx
import React, { Component } from 'react';
Expand Down Expand Up @@ -88,6 +98,7 @@ See [example project](example/Example.js)
### Send
### Loading


## LICENSE
- [MIT](LICENSE)

Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions example/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:windowSoftInputMode="adjustResize"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
Expand Down
4 changes: 2 additions & 2 deletions example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
"private": true,
"scripts": {
"start": "node_modules/react-native/packager/packager.sh",
"sync": "rm -rf ./node_modules/react-native-gifted-chat; sane '/usr/bin/rsync -v -a --exclude .git --exclude example --exclude node_modules ../ ./node_modules/react-native-gifted-chat/' .. --glob='{**/*.json,**/*.js}'"
"sync": "rm -rf ./node_modules/react-native-gifted-chat; sane '/usr/bin/rsync -v -a --exclude .git --exclude example --exclude __tests__ --exclude node_modules ../ ./node_modules/react-native-gifted-chat/' .. --glob='{**/*.json,**/*.js}'"
},
"dependencies": {
"react": "15.2.1",
"react-native": "^0.30.0",
"react-native-gifted-chat": "file:../"
},
"devDependencies": {
"eslint": "^3.1.1",
"eslint": "^3.2.0",
"eslint-plugin-react": "^5.2.2",
"eslint-plugin-react-native": "^1.2.0",
"sane": "^1.4.0"
Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
"description": "The most complete chat UI for React Native",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"test": "jest"
},
"jest": {
"preset": "jest-react-native"
},
"repository": {
"type": "git",
Expand Down Expand Up @@ -42,7 +45,6 @@
"moment": "^2.13.0",
"react-native-communications": "^2.0.0",
"react-native-dismiss-keyboard": "^1.0.0",
"react-native-gifted-material": "file:./react-native-gifted-material/",
"react-native-invertible-scroll-view": "^1.0.0",
"react-native-parsed-text": "0.0.15"
}
Expand Down
16 changes: 0 additions & 16 deletions react-native-gifted-material/.eslintrc

This file was deleted.

1 change: 0 additions & 1 deletion react-native-gifted-material/.gitignore

This file was deleted.

1 change: 0 additions & 1 deletion react-native-gifted-material/.npmignore

This file was deleted.

55 changes: 0 additions & 55 deletions react-native-gifted-material/components/List.js

This file was deleted.

86 changes: 0 additions & 86 deletions react-native-gifted-material/components/ListRow.js

This file was deleted.

9 changes: 0 additions & 9 deletions react-native-gifted-material/components/index.js

This file was deleted.

1 change: 0 additions & 1 deletion react-native-gifted-material/index.js

This file was deleted.

16 changes: 0 additions & 16 deletions react-native-gifted-material/package.json

This file was deleted.

2 changes: 1 addition & 1 deletion src/Avatar.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
View,
} from 'react-native';

import {Avatar as GiftedAvatar} from 'react-native-gifted-material';
import GiftedAvatar from './GiftedAvatar';

export default class Avatar extends Component {
renderAvatar() {
Expand Down
2 changes: 1 addition & 1 deletion src/Composer.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const styles = StyleSheet.create({
Composer.defaultProps = {
textInputStyle: {},
onChange: () => {},
composerHeight: 33,
composerHeight: 33, // TODO SHARE with GiftedChat.js and tests
text: '',
placeholder: 'Type a message...',
placeholderTextColor: '#b2b2b2',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/*
** This component will be published in a separate package
*/
import React, { Component } from 'react';
import {
Image,
Expand Down
11 changes: 9 additions & 2 deletions src/GiftedChat.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import Time from './Time';

// Min and max heights of ToolbarInput and Composer
// Needed for handling Composer's auto grow and ScrollView animation
// TODO move these values to Constants.js (also with used colors #b2b2b2)
const MIN_COMPOSER_HEIGHT = 33;
const MAX_COMPOSER_HEIGHT = 100;
const MIN_INPUT_TOOLBAR_HEIGHT = 44;
Expand Down Expand Up @@ -242,11 +243,17 @@ class GiftedChat extends Component {
}
}

onKeyboardDidShow() {
onKeyboardDidShow(e) {
if (Platform.OS === 'android') {
this.onKeyboardWillShow(e);
}
this.setIsTypingDisabled(false);
}

onKeyboardDidHide() {
onKeyboardDidHide(e) {
if (Platform.OS === 'android') {
this.onKeyboardWillHide(e);
}
this.setIsTypingDisabled(false);
}

Expand Down
9 changes: 4 additions & 5 deletions src/LoadEarlier.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,17 @@ export default class LoadEarlier extends Component {
const styles = StyleSheet.create({
container: {
alignItems: 'center',
justifyContent: 'center',
marginTop: 5,
marginBottom: 10,
},
wrapper: {
alignItems: 'center',
backgroundColor: '#ccc',
borderRadius: 10,
justifyContent: 'center',
backgroundColor: '#b2b2b2',
borderRadius: 15,
height: 30,
paddingLeft: 10,
paddingRight: 10,
paddingTop: 5,
paddingBottom: 5,
},
text: {
backgroundColor: 'transparent',
Expand Down
4 changes: 0 additions & 4 deletions src/MessageContainer.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import React, { Component, PropTypes } from 'react';
import {

} from 'react-native';

import InvertibleScrollView from 'react-native-invertible-scroll-view';

Expand Down Expand Up @@ -56,7 +53,6 @@ export default class MessageContainer extends Component {
return (
<InvertibleScrollView
{...this.props.invertibleScrollViewProps}

ref={component => this._invertibleScrollViewRef = component}
>
{this.props.messages.map((message, index) => {
Expand Down
Loading

0 comments on commit 79b1964

Please sign in to comment.