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

Add 'onPressActionButton' prop #333

Merged
merged 1 commit into from
Jan 10, 2017
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ See [example/App.js](example/App.js)
- **`renderComposer`** _(Function)_ - render the text input message composer
- **`renderSend`** _(Function)_ - render the send button
- **`renderAccessory`** _(Function)_ - renders a second line of actions below the message composer
- **`onPressActionButton`** _(Function)_ - callback to perform custom logic when the Action button is pressed (the default `actionSheet` will not be used)
- **`bottomOffset`** _(Integer)_ - distance of the chat from the bottom of the screen, useful if you display a tab bar


Expand Down
3 changes: 2 additions & 1 deletion src/Actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export default class Actions extends React.Component {
return (
<TouchableOpacity
style={[styles.container, this.props.containerStyle]}
onPress={this.onActionsPress}
onPress={this.props.onPressActionButton || this.onActionsPress}
>
{this.renderIcon()}
</TouchableOpacity>
Expand Down Expand Up @@ -103,6 +103,7 @@ Actions.propTypes = {
options: React.PropTypes.object,
optionTintColor: React.PropTypes.string,
icon: React.PropTypes.func,
onPressActionButton: React.PropTypes.func,
containerStyle: View.propTypes.style,
iconTextStyle: Text.propTypes.style,
};
4 changes: 4 additions & 0 deletions src/InputToolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@ import {

import Composer from './Composer';
import Send from './Send';
import Actions from './Actions';

export default class InputToolbar extends React.Component {
renderActions() {
if (this.props.renderActions) {
return this.props.renderActions(this.props);
} else if (this.props.onPressActionButton) {
return <Actions {...this.props} />;
}
return null;
}
Expand Down Expand Up @@ -89,6 +92,7 @@ InputToolbar.propTypes = {
renderActions: React.PropTypes.func,
renderSend: React.PropTypes.func,
renderComposer: React.PropTypes.func,
onPressActionButton: React.PropTypes.func,
containerStyle: View.propTypes.style,
primaryStyle: View.propTypes.style,
accessoryStyle: View.propTypes.style,
Expand Down