@@ -5,7 +5,6 @@ import Immutable from 'seamless-immutable';
55import PropTypes from 'prop-types' ;
66import uniq from 'lodash/uniq' ;
77import styled from '@stream-io/styled-components' ;
8- import { ActionSheetCustom as ActionSheet } from 'react-native-actionsheet' ;
98
109import { logChatPromiseExecution } from 'stream-chat' ;
1110
@@ -21,14 +20,13 @@ import { pickImage, pickDocument } from '../../native';
2120import { FileState , ACITriggerSettings } from '../../utils' ;
2221import { themed } from '../../styles/theme' ;
2322
23+ import ActionSheet from './ActionSheet' ;
2424import SendButton from './SendButton' ;
2525import AttachButton from './AttachButton' ;
2626import ImageUploadPreview from './ImageUploadPreview' ;
2727import FileUploadPreview from './FileUploadPreview' ;
2828import { AutoCompleteInput } from '../AutoCompleteInput' ;
2929
30- import iconGallery from '../../images/icons/icon_attach-media.png' ;
31- import iconFolder from '../../images/icons/icon_folder.png' ;
3230import iconClose from '../../images/icons/icon_close.png' ;
3331
3432// https://stackoverflow.com/a/6860916/2570866
@@ -87,35 +85,6 @@ const InputBoxContainer = styled.View`
8785 ${ ( { theme } ) => theme . messageInput . inputBoxContainer . css }
8886` ;
8987
90- const ActionSheetTitleContainer = styled . View `
91- flex-direction: row;
92- justify-content: space-between;
93- align-items: center;
94- width: 100%;
95- height: 100%;
96- padding-left: 20;
97- padding-right: 20;
98- ${ ( { theme } ) => theme . messageInput . actionSheet . titleContainer . css } ;
99- ` ;
100-
101- const ActionSheetTitleText = styled . Text `
102- font-weight: bold;
103- ${ ( { theme } ) => theme . messageInput . actionSheet . titleText . css } ;
104- ` ;
105-
106- const ActionSheetButtonContainer = styled . View `
107- flex-direction: row;
108- align-items: center;
109- justify-content: flex-start;
110- width: 100%;
111- padding-left: 20;
112- ${ ( { theme } ) => theme . messageInput . actionSheet . buttonContainer . css } ;
113- ` ;
114-
115- const ActionSheetButtonText = styled . Text `
116- ${ ( { theme } ) => theme . messageInput . actionSheet . buttonText . css } ;
117- ` ;
118-
11988/**
12089 * UI Component for message input
12190 * Its a consumer of [Channel Context](https://getstream.github.io/stream-chat-react-native/#channelcontext)
@@ -210,6 +179,12 @@ class MessageInput extends PureComponent {
210179 * Defaults to and accepts same props as: [AttachButton](https://getstream.github.io/stream-chat-react-native/#attachbutton)
211180 * */
212181 AttachButton : PropTypes . oneOfType ( [ PropTypes . node , PropTypes . elementType ] ) ,
182+ /**
183+ * Custom UI component for ActionSheet.
184+ *
185+ * Defaults to and accepts same props as: [ActionSheet](https://getstream.github.io/stream-chat-react-native/#actionsheet)
186+ * */
187+ ActionSheet : PropTypes . oneOfType ( [ PropTypes . node , PropTypes . elementType ] ) ,
213188 /**
214189 * Additional props for underlying TextInput component. These props will be forwarded as it is to TextInput component.
215190 *
@@ -238,12 +213,13 @@ class MessageInput extends PureComponent {
238213 } ;
239214
240215 static defaultProps = {
241- hasImagePicker : true ,
242- hasFilePicker : true ,
216+ ActionSheet ,
217+ AttachButton ,
243218 disabled : false ,
244- sendImageAsync : false ,
219+ hasFilePicker : true ,
220+ hasImagePicker : true ,
245221 SendButton,
246- AttachButton ,
222+ sendImageAsync : false ,
247223 } ;
248224
249225 getMessageDetailsForState = ( message , initialValue ) => {
@@ -840,7 +816,8 @@ class MessageInput extends PureComponent {
840816 text : this . state . text + text ,
841817 } ) ;
842818 } ;
843- setInputBoxRef = ( o ) => ( this . inputBox = o ) ;
819+
820+ setInputBoxRef = ( o ) => ( this . attachActionSheet = o ) ;
844821
845822 closeAttachActionSheet = ( ) => {
846823 this . attachActionSheet . hide ( ) ;
@@ -893,42 +870,10 @@ class MessageInput extends PureComponent {
893870 */ }
894871
895872 < ActionSheet
896- ref = { ( o ) => ( this . attachActionSheet = o ) }
897- title = {
898- < ActionSheetTitleContainer >
899- < ActionSheetTitleText > { t ( 'Add a file' ) } </ ActionSheetTitleText >
900- < IconSquare
901- icon = { iconClose }
902- onPress = { this . closeAttachActionSheet }
903- />
904- </ ActionSheetTitleContainer >
905- }
906- options = { [
907- /* eslint-disable */
908- < AttachmentActionSheetItem
909- icon = { iconGallery }
910- text = { t ( 'Upload a photo' ) }
911- /> ,
912- < AttachmentActionSheetItem
913- icon = { iconFolder }
914- text = { t ( 'Upload a file' ) }
915- /> ,
916- /* eslint-enable */
917- ] }
918- onPress = { ( index ) => {
919- // https://github.com/beefe/react-native-actionsheet/issues/36
920- setTimeout ( ( ) => {
921- switch ( index ) {
922- case 0 :
923- this . _pickImage ( ) ;
924- break ;
925- case 1 :
926- this . _pickFile ( ) ;
927- break ;
928- default :
929- }
930- } , 201 ) ; // 201ms to fire after the animation is complete https://github.com/beefe/react-native-actionsheet/blob/master/lib/ActionSheetCustom.js#L78
931- } }
873+ setAttachActionSheetRef = { this . setInputBoxRef }
874+ closeAttachActionSheet = { this . closeAttachActionSheet }
875+ pickFile = { this . _pickFile }
876+ pickImage = { this . _pickImage }
932877 styles = { this . props . actionSheetStyles }
933878 />
934879 < InputBoxContainer ref = { this . props . setInputBoxContainerRef } >
@@ -1044,10 +989,3 @@ export default withTranslationContext(
1044989 withSuggestionsContext ( withChannelContext ( themed ( MessageInput ) ) ) ,
1045990 ) ,
1046991) ;
1047-
1048- const AttachmentActionSheetItem = ( { icon, text } ) => (
1049- < ActionSheetButtonContainer >
1050- < IconSquare icon = { icon } />
1051- < ActionSheetButtonText > { text } </ ActionSheetButtonText >
1052- </ ActionSheetButtonContainer >
1053- ) ;
0 commit comments