Closed mrcodefrost closed 1 week ago
Screen recording of the bug
This issue is stale because it has been open for 20 days with no activity.
This issue was closed because it has been inactive for 7 days since being marked as stale.
Hey @mrcodefrost 👋
Since we do not know what your chat screen implementation looks like, we cannot make any assumptions in the media widget as to how we can show messages or add replies - so it is up to you to do this.
Having said that, it is relatively straightforward. Assuming you have a StreamMessageListView
and StreamMessageInput
on the screen, here is a simple implementation for this based on your code:
class ChatScreen extends StatefulWidget {
const ChatScreen({super.key});
@override
State<ChatScreen> createState() => _ChatScreenState();
}
class _ChatScreenState extends State<ChatScreen> {
late final messageInputController = StreamMessageInputController();
final focusNode = FocusNode();
@override
Widget build(BuildContext context) {
return SafeArea(
child: Scaffold(
appBar: const StreamChannelHeader(),
body: Column(
children: <Widget>[
Expanded(
child: StreamMessageListView(
markReadWhenAtTheBottom: true,
messageBuilder: (context, details, messageList, defaultImpl) {
return defaultImpl.copyWith(
onReplyTap: reply,
onShowMessage: showMessage,
);
},
),
),
StreamMessageInput(
onQuotedMessageCleared: messageInputController.clearQuotedMessage,
focusNode: focusNode,
messageInputController: messageInputController,
),
],
),
),
);
}
void reply(Message message) {
messageInputController.quotedMessage = message;
WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
focusNode.requestFocus();
});
}
void showMessage(Message message, Channel c) async {
final client = StreamChat.of(context).client;
final channel = client.channel(
c.type,
id: c.id,
);
if (channel.state == null) {
await channel.watch();
}
/// Now navigate to a new page and add a new `StreamChannel` with an initialMessageId:
// StreamChannel(
// initialMessageId: YOUR_MESSAGE_ID,
// child: YourChatScreen(),
// ...
// )
}
}
Hope this helps, I'll try to see if we can add more docs around this soon.
Thanks!
Which packages are you using?
stream_chat_flutter
On what platforms did you experience the issue?
iOS, Android
What version are you using?
stream_chat_flutter: 7.2.0-hotfix.1 connectivity_plus: 5.0.2
What happened?
Expected Behavior : 1) tapping 'reply' should tag the attachment file (photo, video etc) and revert to it with a new message. Basically do what reply means. 2) tapping 'show in chat' should show the message in the chat screen.
Actual Behavior : Nothing happens on tapping either reply or show in chat.
Steps to reproduce
Supporting info to reproduce
Relevant log output
Flutter analyze output
Flutter doctor output
Code of Conduct