Skip to content

Commit

Permalink
add wrapInSafeArea prop & fix allow overwrite input toolbar position (#…
Browse files Browse the repository at this point in the history
…1572)

* Add optionTitles on MessageText

* Add messagesContainerStyle

* Fix remove react-dom peer dependecy

* add custom action sheet

* fix allow overwrite input toolbar position

* add useSafeArea prop

* Revert "add useSafeArea prop"

This reverts commit 5adb6e7.

* add wrapInSafeArea prop
  • Loading branch information
Alejandro authored and xcarpentier committed Jan 2, 2020
1 parent 3ec8c5c commit 3900884
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
11 changes: 9 additions & 2 deletions src/GiftedChat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ export interface GiftedChatProps<TMessage extends IMessage = IMessage> {
text?: string
/* Controls whether or not the message bubbles appear at the top of the chat */
alignTop?: boolean
/* Determine whether is wrapped in a SafeAreaView */
wrapInSafeArea?: boolean
/* enables the scrollToBottom Component */
scrollToBottom?: boolean
/* Scroll to bottom wrapper style */
Expand Down Expand Up @@ -281,6 +283,7 @@ class GiftedChat<TMessage extends IMessage = IMessage> extends React.Component<
extraData: null,
minComposerHeight: MIN_COMPOSER_HEIGHT,
maxComposerHeight: MAX_COMPOSER_HEIGHT,
wrapInSafeArea: true,
}

static propTypes = {
Expand Down Expand Up @@ -347,6 +350,7 @@ class GiftedChat<TMessage extends IMessage = IMessage> extends React.Component<
minComposerHeight: PropTypes.number,
maxComposerHeight: PropTypes.number,
alignTop: PropTypes.bool,
wrapInSafeArea: PropTypes.bool,
}

static append<TMessage extends IMessage>(
Expand Down Expand Up @@ -831,8 +835,11 @@ class GiftedChat<TMessage extends IMessage = IMessage> extends React.Component<

render() {
if (this.state.isInitialized === true) {
const { wrapInSafeArea } = this.props
const Wrapper = wrapInSafeArea ? SafeAreaView : View

return (
<SafeAreaView style={styles.safeArea}>
<Wrapper style={styles.safeArea}>
<ActionSheetProvider
ref={(component: any) => (this._actionSheetRef = component)}
>
Expand All @@ -841,7 +848,7 @@ class GiftedChat<TMessage extends IMessage = IMessage> extends React.Component<
{this.renderInputToolbar()}
</View>
</ActionSheetProvider>
</SafeAreaView>
</Wrapper>
)
}
return (
Expand Down
2 changes: 1 addition & 1 deletion src/InputToolbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,8 @@ export default class InputToolbar extends React.Component<
style={
[
styles.container,
this.props.containerStyle,
{ position: this.state.position },
this.props.containerStyle,
] as ViewStyle
}
>
Expand Down

0 comments on commit 3900884

Please sign in to comment.