From f43c14dd5d083ffd9ae92e3a823520f160e458fb Mon Sep 17 00:00:00 2001 From: Deven Joshi Date: Mon, 28 Jun 2021 16:48:58 +0530 Subject: [PATCH] feat: Added new docs --- .../stream_chat_flutter/message_list_view.mdx | 37 +++++++++++++ .../channel_list_core.mdx | 49 +++++++++++++++++ .../message_list_core.mdx | 53 ++++++++++++++++++- .../message_search_list_core.mdx | 29 +++++++++- 4 files changed, 166 insertions(+), 2 deletions(-) diff --git a/docusaurus/docs/Flutter/stream_chat_flutter/message_list_view.mdx b/docusaurus/docs/Flutter/stream_chat_flutter/message_list_view.mdx index c68c9bcb..36cf7e39 100644 --- a/docusaurus/docs/Flutter/stream_chat_flutter/message_list_view.mdx +++ b/docusaurus/docs/Flutter/stream_chat_flutter/message_list_view.mdx @@ -4,3 +4,40 @@ sidebar_position: 5 title: MessageListView --- +The MessageListView shows the list of messages of the current channel. + +```dart +class ChannelPage extends StatelessWidget { + const ChannelPage({ + Key key, + }) : super(key: key); + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: ChannelHeader(), + body: Column( + children: [ + Expanded( + child: MessageListView( + threadBuilder: (_, parentMessage) { + return ThreadPage( + parent: parentMessage, + ); + }, + ), + ), + MessageInput(), + ], + ), + ); + } +} +``` + +Make sure to have a [StreamChannel] ancestor in order to +provide the information about the channels. +The widget uses a [ListView.custom] to render the list of channels. + +The widget components render the ui based on the first +ancestor of type [StreamChatTheme]. \ No newline at end of file diff --git a/docusaurus/docs/Flutter/stream_chat_flutter_core/channel_list_core.mdx b/docusaurus/docs/Flutter/stream_chat_flutter_core/channel_list_core.mdx index 1133dcd5..7200def2 100644 --- a/docusaurus/docs/Flutter/stream_chat_flutter_core/channel_list_core.mdx +++ b/docusaurus/docs/Flutter/stream_chat_flutter_core/channel_list_core.mdx @@ -4,3 +4,52 @@ sidebar_position: 4 title: ChannelListCore --- +`ChannelListCore` is a simplified class that allows fetching a list of +channels while exposing UI builders. + +This allows you to construct your own UI while not having to +worry about the specific logic of fetching channels in your app. + +A `ChannelListController` is used to reload and paginate data. + +```dart +class ChannelListPage extends StatelessWidget { + @override + Widget build(BuildContext context) { + return Scaffold( + body: ChannelListCore( + filter: { + 'members': { + '\$in': [StreamChat.of(context).user.id], + } + }, + sort: [SortOption('last_message_at')], + pagination: PaginationParams( + limit: 20, + ), + errorBuilder: (err) { + return Center( + child: Text('An error has occured'), + ); + }, + emptyBuilder: (context) { + return Center( + child: Text('Nothing here...'), + ); + }, + emptyBuilder: (context) { + return Center( + child: CircularProgressIndicator(), + ); + }, + listBuilder: (context, list) { + return ChannelPage(list); + } + ), + ); + } +} +``` + +Make sure to have a `StreamChatCore` ancestor in order to provide the +information about the channels. \ No newline at end of file diff --git a/docusaurus/docs/Flutter/stream_chat_flutter_core/message_list_core.mdx b/docusaurus/docs/Flutter/stream_chat_flutter_core/message_list_core.mdx index 08c8ddbb..b77f2002 100644 --- a/docusaurus/docs/Flutter/stream_chat_flutter_core/message_list_core.mdx +++ b/docusaurus/docs/Flutter/stream_chat_flutter_core/message_list_core.mdx @@ -2,4 +2,55 @@ id: message_list_core sidebar_position: 5 title: MessageListCore ---- \ No newline at end of file +--- + +`MessageListCore` is a simplified class that allows fetching a list of +messages while exposing UI builders. + +This allows you to construct your own UI while not having to +worry about the specific logic of fetching messages in a channel. + +A `MessageListController` is used to paginate data. + +```dart +class ChannelPage extends StatelessWidget { + const ChannelPage({ + Key key, + }) : super(key: key); + + @override + Widget build(BuildContext context) { + return Scaffold( + body: Column( + children: [ + Expanded( + child: MessageListCore( + emptyBuilder: (context) { + return Center( + child: Text('Nothing here...'), + ); + }, + loadingBuilder: (context) { + return Center( + child: CircularProgressIndicator(), + ); + }, + messageListBuilder: (context, list) { + return MessagesPage(list); + }, + errorWidgetBuilder: (context, err) { + return Center( + child: Text('Error'), + ); + }, + ), + ), + ], + ), + ); + } +} +``` + +Make sure to have a `StreamChannel` ancestor in order to provide the +information about the channels. \ No newline at end of file diff --git a/docusaurus/docs/Flutter/stream_chat_flutter_core/message_search_list_core.mdx b/docusaurus/docs/Flutter/stream_chat_flutter_core/message_search_list_core.mdx index 95d6c8b4..b9c42bd0 100644 --- a/docusaurus/docs/Flutter/stream_chat_flutter_core/message_search_list_core.mdx +++ b/docusaurus/docs/Flutter/stream_chat_flutter_core/message_search_list_core.mdx @@ -2,4 +2,31 @@ id: message_search_list_core sidebar_position: 6 title: MessageSearchListCore ---- \ No newline at end of file +--- + + +`MessageSearchListCore` is a simplified class that allows searching for + messages across channels while exposing UI builders. + A `MessageSearchListController` is used to load and paginate data. + +```dart +class MessageSearchPage extends StatelessWidget { + @override + Widget build(BuildContext context) { + return Scaffold( + body: MessageSearchListCore( + messageQuery: _channelQuery, + filters: { + 'members': { + r'$in': [user.id] + } + }, + paginationParams: PaginationParams(limit: 20), + ), + ); + } +} +``` + +Make sure to have a `MessageSearchBloc` ancestor in order to provide the +information about the messages. \ No newline at end of file