Skip to content

Commit

Permalink
feat(typing-indicator): add indicator to example project
Browse files Browse the repository at this point in the history
  • Loading branch information
shamilovtim authored and xcarpentier committed Dec 30, 2019
1 parent 0899fff commit c172986
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
13 changes: 12 additions & 1 deletion App.tsx
Expand Up @@ -38,6 +38,7 @@ export default class App extends Component {
typingText: null, typingText: null,
isLoadingEarlier: false, isLoadingEarlier: false,
appIsReady: false, appIsReady: false,
isTyping: false,
} }


_isMounted = false _isMounted = false
Expand All @@ -48,6 +49,7 @@ export default class App extends Component {
this.setState({ this.setState({
messages: messagesData, // messagesData.filter(message => message.system), messages: messagesData, // messagesData.filter(message => message.system),
appIsReady: true, appIsReady: true,
isTyping: false,
}) })
} }


Expand Down Expand Up @@ -156,7 +158,15 @@ export default class App extends Component {
this.onSend(messagesToUpload) this.onSend(messagesToUpload)
} }


renderAccessory = () => <AccessoryBar onSend={this.onSendFromUser} /> setIsTyping = () => {
this.setState({
isTyping: !this.state.isTyping,
})
}

renderAccessory = () => (
<AccessoryBar onSend={this.onSendFromUser} isTyping={this.setIsTyping} />
)


renderCustomActions = props => renderCustomActions = props =>
Platform.OS === 'web' ? null : ( Platform.OS === 'web' ? null : (
Expand Down Expand Up @@ -253,6 +263,7 @@ export default class App extends Component {
renderQuickReplySend={this.renderQuickReplySend} renderQuickReplySend={this.renderQuickReplySend}
inverted={Platform.OS !== 'web'} inverted={Platform.OS !== 'web'}
timeTextStyle={{ left: { color: 'red' }, right: { color: 'yellow' } }} timeTextStyle={{ left: { color: 'red' }, right: { color: 'yellow' } }}
isTyping={this.state.isTyping}
/> />
</View> </View>
) )
Expand Down
8 changes: 8 additions & 0 deletions example-expo/AccessoryBar.js
Expand Up @@ -11,11 +11,19 @@ import {
export default class AccessoryBar extends React.Component { export default class AccessoryBar extends React.Component {
render() { render() {
const { onSend } = this.props const { onSend } = this.props
const isTyping = this.props.isTyping

return ( return (
<View style={styles.container}> <View style={styles.container}>
<Button onPress={() => pickImageAsync(onSend)} name='photo' /> <Button onPress={() => pickImageAsync(onSend)} name='photo' />
<Button onPress={() => takePictureAsync(onSend)} name='camera' /> <Button onPress={() => takePictureAsync(onSend)} name='camera' />
<Button onPress={() => getLocationAsync(onSend)} name='my-location' /> <Button onPress={() => getLocationAsync(onSend)} name='my-location' />
<Button
onPress={() => {
isTyping()
}}
name='chat'
/>
</View> </View>
) )
} }
Expand Down

0 comments on commit c172986

Please sign in to comment.