React-native-gifted-chat: InputToolBar spacing on iPhoneX

Created on 26 May 2018  路  9Comments  路  Source: FaridSafi/react-native-gifted-chat

Issue Description

There is an issue with iPhoneX where you either have the message that you are typing overlap with the bottom bar and can't see all of your text, or if you add a marginBottom you overlap with the avatar from the most recent message.

Here is some text entered into the text box:
simulator screen shot - iphone x - 2018-05-26 at 14 33 07

If you add one more character you get this strange artifact:
simulator screen shot - iphone x - 2018-05-26 at 14 33 09

If you style the input toolbar then it overlaps the Initials Avatar of the last message:
simulator screen shot - iphone x - 2018-05-26 at 14 33 55

Steps to Reproduce / Code Snippets

Default inputToolbar code:

  renderInputToolbar(props) {
    return <InputToolbar {...props} containerStyle={styles.inputToolbarStyle} />;
  }

Here is the styling:

inputToolbarStyle: {
    marginLeft: 15,
    marginRight: 15,
    marginBottom: 10,
    borderWidth: StyleSheet.hairlineWidth,
    borderColor: CommonStyles.colors.middleGrey,
    borderRadius: 25
  },

Expected Results

Should be able to add some padding below the avatar or at least line up the bottom of the avatar with the bottom of the last message

Additional Information

  • Nodejs version: 9.3.0
  • React version: 16.3.1
  • React Native version: Expo version 27
  • react-native-gifted-chat version: 0.4.3
  • Platform(s) (iOS, Android, or both?): Both

Most helpful comment

@ewal and what to do when you have it inside of SafeAreaView? it created some nasty bottom spacing when the keyboard is open :(

OK, i found out you can use bottomOffset and offset the chat by the height of bottom safeArea.. nice :)

All 9 comments

I was able to fix the overlap by adding marginBottom: 5 to Avatar.js styles.left.container on line 73. I don't know if other people are having this problem as well.

@MeKyleH, just out of curiosity, do you wrap GiftedChat in a SafeAreaView?

@ewal I wasn't wrapping it in a SafeAreaView. However, after adding that it resolved the strange artifact with the text not displaying correctly when typing. Thanks so much!

Awesomeness 馃槃

@ewal and what to do when you have it inside of SafeAreaView? it created some nasty bottom spacing when the keyboard is open :(

OK, i found out you can use bottomOffset and offset the chat by the height of bottom safeArea.. nice :)

@anceque can you show me what bottomOffset you put? didn't get the "by the height of bottom safeArea" part.

This library gives you a nice interface to get the right value for bottomOffset on iPhoneX and no offset on other phones https://github.com/ptelad/react-native-iphone-x-helper

@msqar

Solved it by setting bottomOffset and react-native-iphone-x-helper.getBottomSpace

like this:

import {getBottomSpace} from 'react-native-iphone-x-helper';

<View style={paddingBottom: getBottomSpace()}>
...
  <GiftedChat
    messages={this.state.messages}
    bottomOffset={getBottomSpace()}
    onSend={messages => this.onSend(messages)}
    user={{
      _id: 1,
    }}
  />
</View>

bottomOffset working perfect.
Thanks @diamont1001 you saved my time

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jasonwcfan picture jasonwcfan  路  3Comments

redwind picture redwind  路  3Comments

luisar picture luisar  路  3Comments

inceptivetech picture inceptivetech  路  3Comments

arayaryoma picture arayaryoma  路  3Comments