question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to customize the accessory height?

See original GitHub issue

Issue Description

I’d like to develop an app like wechat:

image

I tried to custom the accessory height like this:

<GiftedChat
    renderAccessory={()=><View style={{height:300}}/>
/>

But failed.

Steps to Reproduce / Code Snippets

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.

Expected Results

Custom the accessory height and do not cover the message container.

Additional Information

  • Nodejs version: 10.0.0
  • React version: 16.3.1
  • React Native version: 0.55.4
  • react-native-gifted-chat version: 0.4.3
  • Platform(s) (iOS, Android, or both?): [FILL THIS OUT]

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:11 (1 by maintainers)

github_iconTop GitHub Comments

4reactions
Durisvkcommented, Dec 17, 2019

@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

3reactions
madsrodecommented, Apr 26, 2020

This seems to do the job renderInputToolbar={(props) => { return <InputToolbar {...props} accessoryStyle={{ height: showAcc ? 44 : 0 }} />; }}

Read more comments on GitHub >

github_iconTop Results From Across the Web

Dynamic height of accessory view in iOS - Medium
and select xib view and go to attribute inspector and change its size to free form so you may change it's size to...
Read more >
Change height of inputAccessoryView issue - ios
When I change the height of inputAccessoryView in iOS 8, the inputAccessoryView not go to the right origin, but covers the keyboard.
Read more >
Accessory Design Guidelines for Apple Devices
The physical design of band accessories compatible with Apple Watch. ... Continuity Camera Mounts securely hold an iPhone at the optimal height and...
Read more >
How tall can my guest house or accessory dwelling unit be?
It depends on where you are but 18 feet or greater is ideal! The City of Berkeley is currently updating their accessory dwelling...
Read more >
Height-Adjustable Accessory Shelf for Carts and Stands - Black
* Offers subject to change, not combinable with all other offers. Dell may impose a purchase quantity limit (for example, 5 units per...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found