Skip to content

Commit

Permalink
Adds AlignTop Property (FaridSafi#1124)
Browse files Browse the repository at this point in the history
* Adds AlignTop Property

* Update linting errors
  • Loading branch information
Matt Van authored and xcarpentier committed Feb 12, 2019
1 parent 6aac68d commit 281902c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ e.g. System Message
* **`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
1 change: 1 addition & 0 deletions src/GiftedChat.js
Original file line number Diff line number Diff line change
Expand Up @@ -624,6 +624,7 @@ GiftedChat.propTypes = {
extraData: PropTypes.object,
minComposerHeight: PropTypes.number,
maxComposerHeight: PropTypes.number,
alignTop: PropTypes.bool,
};

export {
Expand Down
8 changes: 7 additions & 1 deletion src/MessageContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ export default class MessageContainer extends React.PureComponent {
return <View style={styles.container} />;
}
return (
<View style={styles.container}>
<View style={this.props.alignTop ? styles.containerAlignTop : styles.container}>
{this.state.showScrollBottom && this.props.scrollToBottom ? this.renderScrollToBottomWrapper() : null}
<FlatList
ref={(ref) => (this.flatListRef = ref)}
Expand Down Expand Up @@ -184,6 +184,10 @@ const styles = StyleSheet.create({
container: {
flex: 1,
},
containerAlignTop: {
flexDirection: 'row',
alignItems: 'flex-start',
},
contentContainerStyle: {
justifyContent: 'flex-end',
},
Expand Down Expand Up @@ -227,6 +231,7 @@ MessageContainer.defaultProps = {
extraData: null,
scrollToBottom: false,
scrollToBottomOffset: 200,
alignTop: false,
};

MessageContainer.propTypes = {
Expand All @@ -244,4 +249,5 @@ MessageContainer.propTypes = {
scrollToBottom: PropTypes.bool,
scrollToBottomOffset: PropTypes.number,
scrollToBottomComponent: PropTypes.func,
alignTop: PropTypes.bool,
};

0 comments on commit 281902c

Please sign in to comment.