@@ -18,11 +18,11 @@ import uniq from 'lodash/uniq';
1818import styled from '@stream-io/styled-components' ;
1919import { themed } from '../styles/theme' ;
2020import { SendButton } from './SendButton' ;
21+ import { AttachButton } from './AttachButton' ;
2122
2223import { ActionSheetCustom as ActionSheet } from 'react-native-actionsheet' ;
2324// import iconMedia from '../images/icons/icon_attach-media.png';
2425
25- import iconAddAttachment from '../images/icons/plus-outline.png' ;
2626import iconGallery from '../images/icons/icon_attach-media.png' ;
2727import iconFolder from '../images/icons/icon_folder.png' ;
2828import iconClose from '../images/icons/icon_close.png' ;
@@ -61,17 +61,6 @@ const InputBoxContainer = styled.View`
6161 ${ ( { theme } ) => theme . messageInput . inputBoxContainer . css }
6262` ;
6363
64- const AttachButton = styled . TouchableOpacity `
65- margin-right: 8;
66- ${ ( { theme } ) => theme . messageInput . attachButton . css }
67- ` ;
68-
69- const AttachButtonIcon = styled . Image `
70- width: 15;
71- height: 15;
72- ${ ( { theme } ) => theme . messageInput . attachButtonIcon . css }
73- ` ;
74-
7564const ActionSheetTitleContainer = styled . View `
7665 flex-direction: row;
7766 justify-content: space-between;
@@ -180,6 +169,15 @@ const MessageInput = withKeyboardContext(
180169 PropTypes . node ,
181170 PropTypes . elementType ,
182171 ] ) ,
172+ /**
173+ * Custom UI component for attach button.
174+ *
175+ * Defaults to and accepts same props as: [AttachButton](https://getstream.github.io/stream-chat-react-native/#attachbutton)
176+ * */
177+ AttachButton : PropTypes . oneOfType ( [
178+ PropTypes . node ,
179+ PropTypes . elementType ,
180+ ] ) ,
183181 /**
184182 * Additional props for underlying TextInput component. These props will be forwarded as it is to TextInput component.
185183 *
@@ -205,6 +203,7 @@ const MessageInput = withKeyboardContext(
205203 hasImagePicker : true ,
206204 hasFilePicker : true ,
207205 SendButton,
206+ AttachButton,
208207 } ;
209208
210209 getMessageDetailsForState = ( message ) => {
@@ -690,7 +689,12 @@ const MessageInput = withKeyboardContext(
690689 this . attachActionSheet . hide ( ) ;
691690 } ;
692691 render ( ) {
693- const { hasImagePicker, hasFilePicker, SendButton } = this . props ;
692+ const {
693+ hasImagePicker,
694+ hasFilePicker,
695+ SendButton,
696+ AttachButton,
697+ } = this . props ;
694698 let editingBoxStyles = { } ;
695699 if ( this . props . editing ) {
696700 editingBoxStyles = {
@@ -749,7 +753,7 @@ const MessageInput = withKeyboardContext(
749753 ) }
750754 < InputBoxContainer ref = { this . props . setInputBoxContainerRef } >
751755 < AttachButton
752- onPress = { async ( ) => {
756+ handleOnPress = { async ( ) => {
753757 if ( hasImagePicker && hasFilePicker ) {
754758 await this . props . dismissKeyboard ( ) ;
755759 this . attachActionSheet . show ( ) ;
@@ -758,9 +762,7 @@ const MessageInput = withKeyboardContext(
758762 else if ( ! hasImagePicker && hasFilePicker )
759763 this . _pickFile ( ) ;
760764 } }
761- >
762- < AttachButtonIcon source = { iconAddAttachment } />
763- </ AttachButton >
765+ />
764766 { /**
765767 TODO: Use custom action sheet to show icon with titles of button. But it doesn't
766768 work well with async onPress operations. So find a solution.
0 commit comments