I'd like to develop an app like wechat:

I tried to custom the accessory height like this:
<GiftedChat
renderAccessory={()=><View style={{height:300}}/>
/>
But failed.
I looked up the lib source code ,and try to change accessoryStyle
<GiftedChat
renderAccessory={()=><View style={{flex:1}}/>
accessoryStyle={{height: 300}}
/>
It works, but the accessory has covered the message container.
Custom the accessory height and do not cover the message container.
@ATShiTou did you manage to fix it?
NO锛孖 give up to use this library and do it myself.
@ATShiTou Can you share your solution, please?
@k1115 @moerabaya @ATShiTou
based on the code in PR #1524 that is not yet merged,
you can still extend the original component class both in pure javascript and typescript,
here's a TypeScript example:
class GiftedChatExtended extends GiftedChat {
componentDidUpdate(prevProps: GiftedChatProps, prevState: any, snapshot?: any) {
super.componentDidUpdate && super.componentDidUpdate(prevProps, prevState, snapshot);
if (prevProps.minInputToolbarHeight !== this.props.minInputToolbarHeight) {
this.setState({
messagesContainerHeight: this.prepareMessagesContainerHeight(
this.getBasicMessagesContainerHeight() - this.getKeyboardHeight()
),
});
}
}
}
and then use GiftedChatExtended however you'd use original GiftedChat component
@Durisvk very clever work, nice job.
why i can't find this.prepareMessagesContainerHeight() in GiftedChat? It isn't here? but I return the value without wrapped with it, the messageContarinerHeight make work yet.
This seems to do the job
renderInputToolbar={(props) => {
return <InputToolbar {...props} accessoryStyle={{
height: showAcc ? 44 : 0
}} />;
}}
Most helpful comment
@k1115 @moerabaya @ATShiTou
based on the code in PR #1524 that is not yet merged,
you can still extend the original component class both in pure javascript and typescript,
here's a TypeScript example:
and then use
GiftedChatExtendedhowever you'd use originalGiftedChatcomponent