【问题标题】:Custom tolbar with buttons GiftedChat带有按钮的自定义工具栏 天才聊天
【发布时间】:2021-09-13 12:45:39
【问题描述】:

我使用了库 'GiftedChat' 。我想用这个 InputToolBar 做聊天的底部,在容器下面有 5 个按钮,其中一个是发送消息的按钮

如何在组件之间正确分配?

【问题讨论】:

    标签: reactjs react-native chat react-native-gifted-chat


    【解决方案1】:

    如果我理解正确,你想知道如何组织这段代码

    首先,您根本不需要 <View> 来包装您的内容 你应该从库本身导入 GiftedChat,然后你可以使用那里的所有道具

    例如

    import {GiftedChat, InputToolbar} from 'react-native-gifted-chat';
    
     <GiftedChat
              renderInputToolbar={props => {
                return (
                  <InputToolbar
                    {...props}
                    containerStyle={styles.chatWithoutBorder}
                    renderComposer={() => <CustomComposer {...props} />}
                    renderActions={() => {
                      return (
                            <CustomAction />
                          )
                      );
                    }}
                    renderSend={() => <CustomSend {...props} />}
                  />
                );
              }}
            /> 
    

    所有这些自定义组件实际上都是普通组件,您可以自己创建它,您只需要为它发送道具 对于消息框下方的页脚,您将需要此 renderAccessory,如https://github.com/FaridSafi/react-native-gifted-chat 中所述。

    【讨论】:

    • 谢谢,兄弟我会试试这个,如果它有效我关闭了话题:)
    • 好的,如果问题已经解决请标记答案))
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-23
    • 2012-09-05
    • 2021-05-19
    • 2013-04-04
    • 2019-05-05
    相关资源
    最近更新 更多