stream-chat-react-native icon indicating copy to clipboard operation
stream-chat-react-native copied to clipboard

Cookbook - additions/improvements

Open vishalnarkhede opened this issue 6 years ago • 13 comments

We recently added a cookbook to this react-native sdk, to help users of this library easily get sample codes or examples or rough answers to generic "How to implement x with y component?" questions.

Please check current version here (screenshots coming soon) - https://github.com/GetStream/stream-chat-react-native/blob/master/docs/cookbook.md

Here are some more things that I will add soon:

  • [ ] How to use react-devtools to customise styles?
  • [x] How to add send button or attach button outside input box?
  • [x] How to customise underlying FlatList component of MessageList or ChannelList?
  • [x] How do I disable file picker or image picker functionality?
  • [ ] How do I enable/disable certain message actions (edit, delete, reaction, reply) for messages?
  • [x] How do I override edit, delete, reaction, reply, sendMessage calls? e.g. to track analytics
  • [ ] When some channel in ChannelList receives a new message, it moves by default to top of the list. Is there any way to avoid that?
  • [ ] How can I customise the behaviour of ChannelList when events are received?
  • [x] How do I build this project locally, to be able to change some source code?
  • [ ] How can I create multiple tabs structure using channel list?
  • [ ] How to implement draft message functionality with MessageInput?

If you have more suggestions or use cases of your product, please feel free to add comments. I will try my best to include them in coming releases. Thanks :)

vishalnarkhede avatar Apr 09 '20 07:04 vishalnarkhede

Hello. My issue refers to the groupStyles on messages with attachments. Currently, if a message is in the top/middle/bottom of a message group and it has attachments, it will be considered a 'single' message and thus adding a margin-bottom which I do not want. From what I've seen here, it checks if there are attachments and pushes directly as single message.

Is there any workarounds to keep the layout the same for messages with attachments? (the spacing and the corner radius).

losetchi avatar May 08 '20 13:05 losetchi

Hey @losetchi currently doesn't look like there is NO easy way to do this. But we shall ponder and come-up with some clean way to achieve this

vishalnarkhede avatar May 15 '20 14:05 vishalnarkhede

Hi guys, In my project I'm developing a channel info screen. On that screen like in all other messengers I want to display shared content (attachments): links, files, images. Is there any way how can I grab that data? I see that a workaround could be to loop though all the messages but this is inefficient.

Thanks.

wildvalcom avatar May 20 '20 14:05 wildvalcom

image Hi @vishalnarkhede Thank for your services I am looking for the solution to move the avatar to the top of the messages? Could you give me some suggestions


How can I reduce the distance between the two messages? Sorry, we just change the SDK, I am starting to read the document.

manhncse02926 avatar Jun 09 '20 14:06 manhncse02926

@manhncse02926 Currently you can do it following way:

import { MessageSimple, MessageAvatar, MessageList } from 'stream-chat-react-native';

const CustomAvatar = (props) => {
  return (
    <MessageAvatar
      {...props}
      showAvatar={props.groupStyles[0] === 'single' || props.groupStyles[0] === 'top'}
    />
  )
}

const CustomMessage = props => {
  return (
    <MessageSimple
      {....props}
      MessageAvatar={CustomAvatar}
  )
}


// Use this component in MessageList
<MessageList
  Message={CustomMessage}
  // and other props here
/>

I will soon (next week) add an explicit prop to put avatar at top message instead of bottom message. It seems like a common usecase!!

vishalnarkhede avatar Jun 09 '20 15:06 vishalnarkhede

Hello I have problems with the Cookbook's PushNotification examples The problem others are facing are described here https://github.com/GetStream/stream-chat-js/issues/100

I've tried both of them and can't get it to update the UI after _setupConnection() I can still send messages but no more UI updates are triggered using AppState with wsConnection.disconnect() when it's in the background and _setupConnection() when it gets into foreground.

It disconnects and then reconnects but it never updates the UI. Do I have to force refresh the UI and make it appear and disappear? that is Channel and ChannelList

DobritoiuBogdan747 avatar Jun 10 '20 01:06 DobritoiuBogdan747

Thank you for your reply. I wanna change the position of the avatar to the top of a bubble. Your example seems like only show the avatar of the first message.

I have found the solution on the example already 'message.avatarWrapper.container': 'align-self: flex-start', Thank you


  • I am facing a new problem, I add a header for channel chat then press on the input component, when keyboard dismisses, suddenly my input component also disappear. It happens on my project ( React-native 0.62.2, I phone 11). I tried to copy source code from slack-clone-example but got same the error. Do you know this problem? https://media.giphy.com/media/d8QPefEuvpVfIG9FXU/source.mov I resolved the above problem already. Thank
  • Currently, I'm still hit the warning

backend.js:32 Animated: useNativeDriverwas not specified. This is a required option and must be explicitly set totrueorfalse` When I click upload image or long-press on the message on react-native 0.62.x

manhncse02926 avatar Jun 10 '20 01:06 manhncse02926

Hello I have problems with the Cookbook's PushNotification examples The problem others are facing are described here https://github.com/GetStream/stream-chat-js/issues/100

I've tried both of them and can't get it to update the UI after _setupConnection() I can still send messages but no more UI updates are triggered using AppState with wsConnection.disconnect() when it's in the background and _setupConnection() when it gets into foreground.

It disconnects and then reconnects but it never updates the UI. Do I have to force refresh the UI and make it appear and disappear? that is Channel and ChannelList

@DobritoiuBogdan747 I will need more details regarding this. Maybe use logger and send me logs during the app state transition to [email protected]

vishalnarkhede avatar Jun 12 '20 11:06 vishalnarkhede

Fixed by doing client.queryChannels(). When I do this after reconnect it will update the UI. It appears it needs another request to unblock itself.

DobritoiuBogdan747 avatar Jun 12 '20 16:06 DobritoiuBogdan747

I am building dark mode for my application. How can I config for typing text (TypingIndicator)

manhncse02926 avatar Jun 18 '20 13:06 manhncse02926

@manhncse02926

I am building dark mode for my application. How can I config for typing text (TypingIndicator)

You can style the following keys:

typingIndicator.text
typingIndicator.container

vishalnarkhede avatar Jun 24 '20 09:06 vishalnarkhede

Hey guys any chance to get some steps how to pass a custom Attach/Send button ? Basically i'm looking for changing the icons. Do i need to do something like that ? And then pass it to AttachButton property to MessageInput?

import React from 'react';
import styled from '@stream-io/styled-components';
import * as constants from '../../constants/Constants'

const Container = styled.TouchableOpacity`
  margin-right: 8;
  ${({ theme }) => theme.messageInput.attachButton.css}
`;

const AttachButtonIcon = styled.Image`
  width: 20;
  height: 20;
  ${({ theme }) => theme.messageInput.attachButtonIcon.css}
`;

export const CustomAttachButton = (props) => {     
    return (
    <Container onPress={props.handleOnPress} disabled={props.disabled}>
        <AttachButtonIcon source={MY_CUSTOM_IMAGE_RESOURCE} />
    </Container>
    );
}

plotic avatar Jun 25 '20 20:06 plotic

I am going to close this issue. We created this with the intention of crowdsourcing ideas for cookbook material. But its being used to raise issues and kinda getting hard to keep track of. So please raise the separate tickets for your questions and we will take it from there :)

cc @plotic @manhncse02926

vishalnarkhede avatar Jun 27 '20 05:06 vishalnarkhede