From 3edbfc944776b758f2fc89f29ed4957804598684 Mon Sep 17 00:00:00 2001 From: Deven Joshi Date: Thu, 6 Jan 2022 18:34:50 +0530 Subject: [PATCH 1/9] added mip changes, capabilities changes --- packages/stream_chat_v1/lib/channel_page.dart | 11 +-- .../stream_chat_v1/lib/group_info_screen.dart | 90 ++++++++++--------- packages/stream_chat_v1/lib/thread_page.dart | 18 ++-- packages/stream_chat_v1/pubspec.yaml | 8 +- 4 files changed, 66 insertions(+), 61 deletions(-) diff --git a/packages/stream_chat_v1/lib/channel_page.dart b/packages/stream_chat_v1/lib/channel_page.dart index 6ed2398..19aa3a3 100644 --- a/packages/stream_chat_v1/lib/channel_page.dart +++ b/packages/stream_chat_v1/lib/channel_page.dart @@ -34,8 +34,8 @@ class ChannelPage extends StatefulWidget { } class _ChannelPageState extends State { - Message? _quotedMessage; FocusNode? _focusNode; + MessageInputController _messageInputController = MessageInputController(); @override void initState() { @@ -50,7 +50,7 @@ class _ChannelPageState extends State { } void _reply(Message message) { - setState(() => _quotedMessage = message); + _messageInputController.quotedMessage = message; WidgetsBinding.instance!.addPostFrameCallback((timeStamp) { _focusNode!.requestFocus(); }); @@ -144,7 +144,6 @@ class _ChannelPageState extends State { threadBuilder: (_, parentMessage) { return ThreadPage(parent: parentMessage!); }, - pinPermissions: ['owner', 'admin', 'member'], ), Positioned( bottom: 0, @@ -177,11 +176,7 @@ class _ChannelPageState extends State { ), MessageInput( focusNode: _focusNode, - quotedMessage: _quotedMessage, - onQuotedMessageCleared: () { - setState(() => _quotedMessage = null); - _focusNode!.unfocus(); - }, + messageInputController: _messageInputController, ), ], ), diff --git a/packages/stream_chat_v1/lib/group_info_screen.dart b/packages/stream_chat_v1/lib/group_info_screen.dart index 6a06e1e..66c8306 100644 --- a/packages/stream_chat_v1/lib/group_info_screen.dart +++ b/packages/stream_chat_v1/lib/group_info_screen.dart @@ -150,7 +150,10 @@ class _GroupInfoScreenState extends State { ), centerTitle: true, actions: [ - if (!channel.channel.isDistinct && isOwner) + if (!channel.channel.isDistinct && + isOwner && + channel.channel.ownCapabilities + .contains(PermissionType.updateChannelMembers)) StreamNeumorphicButton( child: InkWell( onTap: () { @@ -365,6 +368,8 @@ class _GroupInfoScreenState extends State { ), Expanded( child: TextField( + enabled: channel.ownCapabilities + .contains(PermissionType.updateChannel), focusNode: _focusNode, controller: _nameController, cursorColor: @@ -449,47 +454,50 @@ class _GroupInfoScreenState extends State { // ), // onTap: () {}, // ), - StreamBuilder( - stream: StreamChannel.of(context).channel.isMutedStream, - builder: (context, snapshot) { - mutedBool.value = snapshot.data; + if (channel.channel.ownCapabilities + .contains(PermissionType.muteChannel)) + StreamBuilder( + stream: StreamChannel.of(context).channel.isMutedStream, + builder: (context, snapshot) { + mutedBool.value = snapshot.data; - return OptionListTile( - tileColor: StreamChatTheme.of(context).colorTheme.appBg, - separatorColor: StreamChatTheme.of(context).colorTheme.disabled, - title: AppLocalizations.of(context).muteGroup, - titleTextStyle: StreamChatTheme.of(context).textTheme.body, - leading: Padding( - padding: const EdgeInsets.symmetric(horizontal: 16.0), - child: StreamSvgIcon.mute( - size: 24.0, - color: StreamChatTheme.of(context) - .colorTheme - .textHighEmphasis - .withOpacity(0.5), + return OptionListTile( + tileColor: StreamChatTheme.of(context).colorTheme.appBg, + separatorColor: + StreamChatTheme.of(context).colorTheme.disabled, + title: AppLocalizations.of(context).muteGroup, + titleTextStyle: StreamChatTheme.of(context).textTheme.body, + leading: Padding( + padding: const EdgeInsets.symmetric(horizontal: 16.0), + child: StreamSvgIcon.mute( + size: 24.0, + color: StreamChatTheme.of(context) + .colorTheme + .textHighEmphasis + .withOpacity(0.5), + ), ), - ), - trailing: snapshot.data == null - ? CircularProgressIndicator() - : ValueListenableBuilder( - valueListenable: mutedBool, - builder: (context, value, _) { - return CupertinoSwitch( - value: value!, - onChanged: (val) { - mutedBool.value = val; + trailing: snapshot.data == null + ? CircularProgressIndicator() + : ValueListenableBuilder( + valueListenable: mutedBool, + builder: (context, value, _) { + return CupertinoSwitch( + value: value!, + onChanged: (val) { + mutedBool.value = val; - if (snapshot.data!) { - channel.channel.unmute(); - } else { - channel.channel.mute(); - } - }, - ); - }), - onTap: () {}, - ); - }), + if (snapshot.data!) { + channel.channel.unmute(); + } else { + channel.channel.mute(); + } + }, + ); + }), + onTap: () {}, + ); + }), OptionListTile( title: AppLocalizations.of(context).pinnedMessages, tileColor: StreamChatTheme.of(context).colorTheme.appBg, @@ -654,7 +662,9 @@ class _GroupInfoScreenState extends State { ); }, ), - if (!channel.channel.isDistinct) + if (!channel.channel.isDistinct && + channel.channel.ownCapabilities + .contains(PermissionType.leaveChannel)) OptionListTile( tileColor: StreamChatTheme.of(context).colorTheme.appBg, separatorColor: StreamChatTheme.of(context).colorTheme.disabled, diff --git a/packages/stream_chat_v1/lib/thread_page.dart b/packages/stream_chat_v1/lib/thread_page.dart index ca8d67c..f61130c 100644 --- a/packages/stream_chat_v1/lib/thread_page.dart +++ b/packages/stream_chat_v1/lib/thread_page.dart @@ -18,8 +18,14 @@ class ThreadPage extends StatefulWidget { } class _ThreadPageState extends State { - Message? _quotedMessage; FocusNode _focusNode = FocusNode(); + late MessageInputController _messageInputController; + + @override + void initState() { + super.initState(); + _messageInputController = MessageInputController(message: widget.parent); + } @override void dispose() { @@ -28,7 +34,7 @@ class _ThreadPageState extends State { } void _reply(Message message) { - setState(() => _quotedMessage = message); + _messageInputController.quotedMessage = message; WidgetsBinding.instance!.addPostFrameCallback((timeStamp) { _focusNode.requestFocus(); }); @@ -60,18 +66,12 @@ class _ThreadPageState extends State { }, ); }, - pinPermissions: ['owner', 'admin', 'member'], ), ), if (widget.parent.type != 'deleted') MessageInput( - parentMessage: widget.parent, focusNode: _focusNode, - quotedMessage: _quotedMessage, - onQuotedMessageCleared: () { - setState(() => _quotedMessage = null); - _focusNode.unfocus(); - }, + messageInputController: _messageInputController, ), ], ), diff --git a/packages/stream_chat_v1/pubspec.yaml b/packages/stream_chat_v1/pubspec.yaml index 9043349..d2190d0 100644 --- a/packages/stream_chat_v1/pubspec.yaml +++ b/packages/stream_chat_v1/pubspec.yaml @@ -23,7 +23,7 @@ dependencies: stream_chat_localizations: git: url: https://github.com/GetStream/stream-chat-flutter.git - ref: develop + ref: feat/capabilities path: packages/stream_chat_localizations flutter_local_notifications: ^9.0.0 flutter_svg: ^0.23.0 @@ -42,17 +42,17 @@ dependency_overrides: stream_chat: git: url: https://github.com/GetStream/stream-chat-flutter.git - ref: develop + ref: feat/capabilities path: packages/stream_chat stream_chat_flutter_core: git: url: https://github.com/GetStream/stream-chat-flutter.git - ref: develop + ref: feat/capabilities path: packages/stream_chat_flutter_core stream_chat_flutter: git: url: https://github.com/GetStream/stream-chat-flutter.git - ref: develop + ref: feat/capabilities path: packages/stream_chat_flutter flutter: From 6ffec8007ef1875e866fd956a44bed25a0e6c1c0 Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Tue, 25 Jan 2022 15:29:22 +0100 Subject: [PATCH 2/9] remove role check --- .../ios/Runner.xcodeproj/project.pbxproj | 33 ++++++++++++------- .../xcshareddata/xcschemes/Runner.xcscheme | 2 +- .../stream_chat_v1/lib/group_info_screen.dart | 15 +++------ 3 files changed, 27 insertions(+), 23 deletions(-) diff --git a/packages/stream_chat_v1/ios/Runner.xcodeproj/project.pbxproj b/packages/stream_chat_v1/ios/Runner.xcodeproj/project.pbxproj index 3b333d0..fe295e0 100644 --- a/packages/stream_chat_v1/ios/Runner.xcodeproj/project.pbxproj +++ b/packages/stream_chat_v1/ios/Runner.xcodeproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 46; + objectVersion = 50; objects = { /* Begin PBXBuildFile section */ @@ -177,7 +177,7 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 1140; - LastUpgradeCheck = 1020; + LastUpgradeCheck = 1300; ORGANIZATIONNAME = "The Chromium Authors"; TargetAttributes = { 97C146ED1CF9000F007C117D = { @@ -245,7 +245,7 @@ "${BUILT_PRODUCTS_DIR}/DKImagePickerController/DKImagePickerController.framework", "${BUILT_PRODUCTS_DIR}/DKPhotoGallery/DKPhotoGallery.framework", "${BUILT_PRODUCTS_DIR}/FMDB/FMDB.framework", - "${BUILT_PRODUCTS_DIR}/Reachability/Reachability.framework", + "${BUILT_PRODUCTS_DIR}/ReachabilitySwift/Reachability.framework", "${BUILT_PRODUCTS_DIR}/SDWebImage/SDWebImage.framework", "${BUILT_PRODUCTS_DIR}/SwiftyGif/SwiftyGif.framework", "${BUILT_PRODUCTS_DIR}/connectivity_plus/connectivity_plus.framework", @@ -256,14 +256,14 @@ "${BUILT_PRODUCTS_DIR}/image_gallery_saver/image_gallery_saver.framework", "${BUILT_PRODUCTS_DIR}/image_picker/image_picker.framework", "${BUILT_PRODUCTS_DIR}/libwebp/libwebp.framework", - "${BUILT_PRODUCTS_DIR}/path_provider/path_provider.framework", + "${BUILT_PRODUCTS_DIR}/path_provider_ios/path_provider_ios.framework", "${BUILT_PRODUCTS_DIR}/photo_manager/photo_manager.framework", "${BUILT_PRODUCTS_DIR}/share_plus/share_plus.framework", - "${BUILT_PRODUCTS_DIR}/shared_preferences/shared_preferences.framework", + "${BUILT_PRODUCTS_DIR}/shared_preferences_ios/shared_preferences_ios.framework", "${BUILT_PRODUCTS_DIR}/sqflite/sqflite.framework", "${BUILT_PRODUCTS_DIR}/sqlite3/sqlite3.framework", "${BUILT_PRODUCTS_DIR}/sqlite3_flutter_libs/sqlite3_flutter_libs.framework", - "${BUILT_PRODUCTS_DIR}/url_launcher/url_launcher.framework", + "${BUILT_PRODUCTS_DIR}/url_launcher_ios/url_launcher_ios.framework", "${BUILT_PRODUCTS_DIR}/video_compress/video_compress.framework", "${BUILT_PRODUCTS_DIR}/video_player/video_player.framework", "${BUILT_PRODUCTS_DIR}/video_thumbnail/video_thumbnail.framework", @@ -285,14 +285,14 @@ "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/image_gallery_saver.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/image_picker.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/libwebp.framework", - "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/path_provider.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/path_provider_ios.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/photo_manager.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/share_plus.framework", - "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/shared_preferences.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/shared_preferences_ios.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/sqflite.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/sqlite3.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/sqlite3_flutter_libs.framework", - "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/url_launcher.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/url_launcher_ios.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/video_compress.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/video_player.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/video_thumbnail.framework", @@ -442,7 +442,10 @@ ); INFOPLIST_FILE = Runner/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 11.0; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); LIBRARY_SEARCH_PATHS = ( "$(inherited)", "$(PROJECT_DIR)/Flutter", @@ -581,7 +584,10 @@ ); INFOPLIST_FILE = Runner/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 11.0; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); LIBRARY_SEARCH_PATHS = ( "$(inherited)", "$(PROJECT_DIR)/Flutter", @@ -615,7 +621,10 @@ ); INFOPLIST_FILE = Runner/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 11.0; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); LIBRARY_SEARCH_PATHS = ( "$(inherited)", "$(PROJECT_DIR)/Flutter", diff --git a/packages/stream_chat_v1/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/packages/stream_chat_v1/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme index fb2dffc..c87d15a 100644 --- a/packages/stream_chat_v1/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +++ b/packages/stream_chat_v1/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -1,6 +1,6 @@ { ); } - var userMember = snapshot.data!.firstWhereOrNull( - (e) => e.user!.id == StreamChat.of(context).currentUser!.id, - ); - var isOwner = userMember?.role == 'owner'; - return Scaffold( backgroundColor: StreamChatTheme.of(context).colorTheme.appBg, appBar: AppBar( @@ -150,10 +145,8 @@ class _GroupInfoScreenState extends State { ), centerTitle: true, actions: [ - if (!channel.channel.isDistinct && - isOwner && - channel.channel.ownCapabilities - .contains(PermissionType.updateChannelMembers)) + if (channel.channel.ownCapabilities + .contains(PermissionType.updateChannelMembers)) StreamNeumorphicButton( child: InkWell( onTap: () { @@ -177,7 +170,9 @@ class _GroupInfoScreenState extends State { height: 8.0, color: StreamChatTheme.of(context).colorTheme.disabled, ), - if (isOwner) _buildNameTile(), + if (channel.channel.ownCapabilities + .contains(PermissionType.updateChannel)) + _buildNameTile(), _buildOptionListTiles(), ], ), From 420028da2eae94006e86d38f7b50a2a71b226036 Mon Sep 17 00:00:00 2001 From: Sahil Kumar Date: Mon, 21 Mar 2022 16:12:28 +0530 Subject: [PATCH 3/9] feat(sample-app): Migrate sample app to v4 Signed-off-by: xsahil03x --- .../lib/ui/common/my_channel_preview.dart | 3 - packages/imessage/lib/message_page.dart | 1 - .../stream_chat_v1/android/app/build.gradle | 2 +- .../lib/advanced_options_page.dart | 1 - .../lib/channel_file_display_screen.dart | 2 +- packages/stream_chat_v1/lib/channel_list.dart | 195 +++++++++++++----- .../stream_chat_v1/lib/channel_list_page.dart | 12 +- .../lib/channel_media_display_screen.dart | 6 +- packages/stream_chat_v1/lib/channel_page.dart | 11 +- .../stream_chat_v1/lib/chat_info_screen.dart | 30 +-- .../stream_chat_v1/lib/choose_user_page.dart | 2 +- .../lib/group_chat_details_screen.dart | 7 +- .../stream_chat_v1/lib/group_info_screen.dart | 19 +- packages/stream_chat_v1/lib/home_page.dart | 1 - packages/stream_chat_v1/lib/main.dart | 1 - .../stream_chat_v1/lib/new_chat_screen.dart | 12 +- .../lib/new_group_chat_screen.dart | 8 +- .../lib/pinned_messages_screen.dart | 4 +- .../stream_chat_v1/lib/splash_screen.dart | 1 - packages/stream_chat_v1/lib/thread_page.dart | 8 +- .../lib/user_mentions_page.dart | 2 +- 21 files changed, 200 insertions(+), 128 deletions(-) diff --git a/packages/chatty/lib/ui/common/my_channel_preview.dart b/packages/chatty/lib/ui/common/my_channel_preview.dart index 9156d83..9d54a9b 100644 --- a/packages/chatty/lib/ui/common/my_channel_preview.dart +++ b/packages/chatty/lib/ui/common/my_channel_preview.dart @@ -1,9 +1,6 @@ import 'package:collection/collection.dart' show IterableExtension; import 'package:flutter/material.dart'; -import 'package:flutter/widgets.dart'; -import 'package:jiffy/jiffy.dart'; import 'package:stream_chat_flutter/stream_chat_flutter.dart'; -import 'package:stream_chat_flutter_core/stream_chat_flutter_core.dart'; /*Navigator.push( context, diff --git a/packages/imessage/lib/message_page.dart b/packages/imessage/lib/message_page.dart index 23d15df..497e19c 100644 --- a/packages/imessage/lib/message_page.dart +++ b/packages/imessage/lib/message_page.dart @@ -1,5 +1,4 @@ import 'package:flutter/cupertino.dart'; -import 'package:flutter/material.dart'; import 'package:imessage/message_list_view.dart'; import 'package:stream_chat_flutter_core/stream_chat_flutter_core.dart' show diff --git a/packages/stream_chat_v1/android/app/build.gradle b/packages/stream_chat_v1/android/app/build.gradle index ce7eeee..147d607 100644 --- a/packages/stream_chat_v1/android/app/build.gradle +++ b/packages/stream_chat_v1/android/app/build.gradle @@ -26,7 +26,7 @@ apply plugin: 'kotlin-android' apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" android { - compileSdkVersion 30 + compileSdkVersion 31 ndkVersion '21.4.7075529' sourceSets { diff --git a/packages/stream_chat_v1/lib/advanced_options_page.dart b/packages/stream_chat_v1/lib/advanced_options_page.dart index a42f200..2645e19 100644 --- a/packages/stream_chat_v1/lib/advanced_options_page.dart +++ b/packages/stream_chat_v1/lib/advanced_options_page.dart @@ -3,7 +3,6 @@ import 'package:example/localizations.dart'; import 'package:example/routes/routes.dart'; import 'package:example/stream_version.dart'; import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; import 'package:flutter_secure_storage/flutter_secure_storage.dart'; import 'package:stream_chat_flutter/stream_chat_flutter.dart'; diff --git a/packages/stream_chat_v1/lib/channel_file_display_screen.dart b/packages/stream_chat_v1/lib/channel_file_display_screen.dart index 4f4a806..743b3eb 100644 --- a/packages/stream_chat_v1/lib/channel_file_display_screen.dart +++ b/packages/stream_chat_v1/lib/channel_file_display_screen.dart @@ -160,7 +160,7 @@ class _ChannelFileDisplayScreenState extends State { padding: const EdgeInsets.all(1.0), child: Padding( padding: const EdgeInsets.all(8.0), - child: FileAttachment( + child: StreamFileAttachment( message: media.values.toList()[position], attachment: media.keys.toList()[position], ), diff --git a/packages/stream_chat_v1/lib/channel_list.dart b/packages/stream_chat_v1/lib/channel_list.dart index d13e830..25813f0 100644 --- a/packages/stream_chat_v1/lib/channel_list.dart +++ b/packages/stream_chat_v1/lib/channel_list.dart @@ -6,6 +6,7 @@ import 'package:example/search_text_field.dart'; import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; import 'package:stream_chat_flutter/stream_chat_flutter.dart'; +import 'package:flutter_slidable/flutter_slidable.dart'; import 'channel_page.dart'; import 'chat_info_screen.dart'; @@ -39,6 +40,16 @@ class _ChannelList extends State { }); } + late final _channelListController = StreamChannelListController( + client: StreamChat.of(context).client, + filter: Filter.in_( + 'members', + [StreamChat.of(context).currentUser!.id], + ), + presence: true, + limit: 30, + ); + @override void initState() { super.initState(); @@ -86,7 +97,7 @@ class _ChannelList extends State { ), ], body: _isSearchActive - ? MessageSearchListView( + ? StreamMessageSearchListView( showErrorTile: true, messageQuery: _channelQuery, filters: Filter.in_('members', [user!.id]), @@ -149,59 +160,141 @@ class _ChannelList extends State { ); }, ) - : ChannelListView( - onChannelTap: (channel, _) { - Navigator.pushNamed( - context, - Routes.CHANNEL_PAGE, - arguments: ChannelPageArgs( - channel: channel, - ), - ); - }, - onStartChatPressed: () { - Navigator.pushNamed(context, Routes.NEW_CHAT); - }, - swipeToAction: true, - filter: Filter.in_('members', [user!.id]), - presence: true, - limit: 30, - onViewInfoTap: (channel) { - Navigator.pop(context); - if (channel.memberCount == 2 && channel.isDistinct) { - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => StreamChannel( + : SlidableAutoCloseBehavior( + closeWhenOpened: true, + child: RefreshIndicator( + onRefresh: _channelListController.refresh, + child: StreamChannelListView( + controller: _channelListController, + itemBuilder: (context, channel, tile) { + final chatTheme = StreamChatTheme.of(context); + final backgroundColor = chatTheme.colorTheme.inputBg; + final canDeleteChannel = channel.ownCapabilities + .contains(PermissionType.deleteChannel); + return Slidable( + groupTag: 'channels-actions', + endActionPane: ActionPane( + extentRatio: canDeleteChannel ? 0.40 : 0.20, + motion: const BehindMotion(), + children: [ + CustomSlidableAction( + child: Icon(Icons.more_horiz), + backgroundColor: backgroundColor, + onPressed: (_) { + showChannelInfoModalBottomSheet( + context: context, + channel: channel, + onViewInfoTap: () { + Navigator.pop(context); + Navigator.push( + context, + MaterialPageRoute( + builder: (context) { + final isOneToOne = + channel.memberCount == 2 && + channel.isDistinct; + return StreamChannel( + channel: channel, + child: isOneToOne + ? ChatInfoScreen( + messageTheme: chatTheme + .ownMessageTheme, + user: channel + .state!.members + .where((m) => + m.userId != + channel + .client + .state + .currentUser! + .id) + .first + .user, + ) + : GroupInfoScreen( + messageTheme: chatTheme + .ownMessageTheme, + ), + ); + }, + ), + ); + }, + ); + }, + ), + if (canDeleteChannel) + CustomSlidableAction( + backgroundColor: backgroundColor, + child: StreamSvgIcon.delete( + color: chatTheme.colorTheme.accentError, + ), + onPressed: (_) async { + final res = await showConfirmationDialog( + context, + title: 'Delete Conversation', + question: + 'Are you sure you want to delete this conversation?', + okText: 'Delete', + cancelText: 'Cancel', + icon: StreamSvgIcon.delete( + color: chatTheme.colorTheme.accentError, + ), + ); + if (res == true) { + await _channelListController + .deleteChannel(channel); + } + }, + ), + ], + ), + child: tile, + ); + }, + onChannelTap: (channel) { + Navigator.pushNamed( + context, + Routes.CHANNEL_PAGE, + arguments: ChannelPageArgs( channel: channel, - child: ChatInfoScreen( - messageTheme: - StreamChatTheme.of(context).ownMessageTheme, - user: channel.state!.members - .where((m) => - m.userId != - channel.client.state.currentUser!.id) - .first - .user, + ), + ); + }, + emptyBuilder: (_) { + return Center( + child: Padding( + padding: EdgeInsets.all(8), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Expanded(child: StreamChannelListEmptyWidget()), + TextButton( + onPressed: () { + Navigator.pushNamed( + context, + Routes.NEW_CHAT, + ); + }, + child: Text( + 'Start a chat', + style: StreamChatTheme.of(context) + .textTheme + .bodyBold + .copyWith( + color: StreamChatTheme.of(context) + .colorTheme + .accentPrimary, + ), + ), + ), + ], ), ), - ), - ); - } else { - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => StreamChannel( - channel: channel, - child: GroupInfoScreen( - messageTheme: - StreamChatTheme.of(context).ownMessageTheme, - ), - ), - ), - ); - } - }, + ); + }, + ), + ), ), ), ), diff --git a/packages/stream_chat_v1/lib/channel_list_page.dart b/packages/stream_chat_v1/lib/channel_list_page.dart index be43bd6..af45104 100644 --- a/packages/stream_chat_v1/lib/channel_list_page.dart +++ b/packages/stream_chat_v1/lib/channel_list_page.dart @@ -40,7 +40,7 @@ class _ChannelListPageState extends State { Positioned( top: -3, right: -16, - child: UnreadIndicator(), + child: StreamUnreadIndicator(), ), ], ), @@ -70,7 +70,7 @@ class _ChannelListPageState extends State { } return Scaffold( backgroundColor: StreamChatTheme.of(context).colorTheme.appBg, - appBar: ChannelListHeader( + appBar: StreamChannelListHeader( onNewChatButtonTap: () { Navigator.pushNamed(context, Routes.NEW_CHAT); }, @@ -100,10 +100,8 @@ class _ChannelListPageState extends State { body: IndexedStack( index: _currentIndex, children: [ - ChannelsBloc( - child: MessageSearchBloc( - child: ChannelList(), - ), + MessageSearchBloc( + child: ChannelList(), ), UserMentionsPage(), ], @@ -165,7 +163,7 @@ class LeftDrawer extends StatelessWidget { ), child: Row( children: [ - UserAvatar( + StreamUserAvatar( user: user, showOnlineStatus: false, constraints: BoxConstraints.tight(Size.fromRadius(20)), diff --git a/packages/stream_chat_v1/lib/channel_media_display_screen.dart b/packages/stream_chat_v1/lib/channel_media_display_screen.dart index ee23293..5ccd92c 100644 --- a/packages/stream_chat_v1/lib/channel_media_display_screen.dart +++ b/packages/stream_chat_v1/lib/channel_media_display_screen.dart @@ -21,7 +21,7 @@ class ChannelMediaDisplayScreen extends StatefulWidget { final ShowMessageCallback? onShowMessage; - final MessageThemeData messageTheme; + final StreamMessageThemeData messageTheme; const ChannelMediaDisplayScreen({ required this.messageTheme, @@ -180,7 +180,7 @@ class _ChannelMediaDisplayScreenState extends State { MaterialPageRoute( builder: (context) => StreamChannel( channel: channel, - child: FullScreenMedia( + child: StreamFullScreenMedia( mediaAttachments: media.map((e) => e.attachment).toList(), startIndex: position, @@ -194,7 +194,7 @@ class _ChannelMediaDisplayScreenState extends State { }, child: media[position].attachment.type == 'image' ? IgnorePointer( - child: ImageAttachment( + child: StreamImageAttachment( attachment: media[position].attachment, message: media[position].message, showTitle: false, diff --git a/packages/stream_chat_v1/lib/channel_page.dart b/packages/stream_chat_v1/lib/channel_page.dart index 19aa3a3..6cf60e5 100644 --- a/packages/stream_chat_v1/lib/channel_page.dart +++ b/packages/stream_chat_v1/lib/channel_page.dart @@ -60,7 +60,7 @@ class _ChannelPageState extends State { Widget build(BuildContext context) { return Scaffold( backgroundColor: StreamChatTheme.of(context).colorTheme.appBg, - appBar: ChannelHeader( + appBar: StreamChannelHeader( showTypingIndicator: false, onImageTap: () async { var channel = StreamChannel.of(context).channel; @@ -108,7 +108,7 @@ class _ChannelPageState extends State { Expanded( child: Stack( children: [ - MessageListView( + StreamMessageListView( initialScrollIndex: widget.initialScrollIndex, initialAlignment: widget.initialAlignment, highlightInitialMessage: widget.highlightInitialMessage, @@ -137,7 +137,7 @@ class _ChannelPageState extends State { ); }, deletedBottomRowBuilder: (context, message) { - return const VisibleFootnote(); + return const StreamVisibleFootnote(); }, ); }, @@ -155,8 +155,7 @@ class _ChannelPageState extends State { .colorTheme .appBg .withOpacity(.9), - child: TypingIndicator( - alignment: Alignment.centerLeft, + child: StreamTypingIndicator( padding: const EdgeInsets.symmetric( horizontal: 8, vertical: 4, @@ -174,7 +173,7 @@ class _ChannelPageState extends State { ], ), ), - MessageInput( + StreamMessageInput( focusNode: _focusNode, messageInputController: _messageInputController, ), diff --git a/packages/stream_chat_v1/lib/chat_info_screen.dart b/packages/stream_chat_v1/lib/chat_info_screen.dart index 2ba0789..9556840 100644 --- a/packages/stream_chat_v1/lib/chat_info_screen.dart +++ b/packages/stream_chat_v1/lib/chat_info_screen.dart @@ -1,8 +1,6 @@ -import 'package:collection/collection.dart' show IterableExtension; import 'package:example/localizations.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -import 'package:jiffy/jiffy.dart'; import 'package:stream_chat_flutter/stream_chat_flutter.dart'; import 'channel_file_display_screen.dart'; @@ -16,7 +14,7 @@ class ChatInfoScreen extends StatefulWidget { /// User in consideration final User? user; - final MessageThemeData messageTheme; + final StreamMessageThemeData messageTheme; const ChatInfoScreen({ Key? key, @@ -54,13 +52,7 @@ class _ChatInfoScreenState extends State { height: 8.0, color: StreamChatTheme.of(context).colorTheme.disabled, ), - if ([ - 'admin', - 'owner', - ].contains(channel.state!.members - .firstWhereOrNull( - (m) => m.userId == channel.client.state.currentUser!.id) - ?.role)) + if (channel.ownCapabilities.contains(PermissionType.deleteChannel)) _buildDeleteListTile(), ], ), @@ -78,7 +70,7 @@ class _ChatInfoScreenState extends State { children: [ Padding( padding: const EdgeInsets.all(16.0), - child: UserAvatar( + child: StreamUserAvatar( user: widget.user!, constraints: BoxConstraints.tightFor( width: 72.0, @@ -95,7 +87,7 @@ class _ChatInfoScreenState extends State { SizedBox(height: 7.0), _buildConnectedTitleState(), SizedBox(height: 15.0), - OptionListTile( + StreamOptionListTile( title: '@${widget.user!.id}', tileColor: StreamChatTheme.of(context).colorTheme.appBg, trailing: Padding( @@ -148,7 +140,7 @@ class _ChatInfoScreenState extends State { builder: (context, snapshot) { mutedBool.value = snapshot.data; - return OptionListTile( + return StreamOptionListTile( tileColor: StreamChatTheme.of(context).colorTheme.appBg, title: AppLocalizations.of(context).muteUser, titleTextStyle: StreamChatTheme.of(context).textTheme.body, @@ -201,7 +193,7 @@ class _ChatInfoScreenState extends State { // ), // onTap: () {}, // ), - OptionListTile( + StreamOptionListTile( title: AppLocalizations.of(context).pinnedMessages, tileColor: StreamChatTheme.of(context).colorTheme.appBg, titleTextStyle: StreamChatTheme.of(context).textTheme.body, @@ -261,7 +253,7 @@ class _ChatInfoScreenState extends State { ); }, ), - OptionListTile( + StreamOptionListTile( title: AppLocalizations.of(context).photosAndVideos, tileColor: StreamChatTheme.of(context).colorTheme.appBg, titleTextStyle: StreamChatTheme.of(context).textTheme.body, @@ -321,7 +313,7 @@ class _ChatInfoScreenState extends State { ); }, ), - OptionListTile( + StreamOptionListTile( title: AppLocalizations.of(context).files, tileColor: StreamChatTheme.of(context).colorTheme.appBg, titleTextStyle: StreamChatTheme.of(context).textTheme.body, @@ -361,7 +353,7 @@ class _ChatInfoScreenState extends State { ); }, ), - OptionListTile( + StreamOptionListTile( title: AppLocalizations.of(context).sharedGroups, tileColor: StreamChatTheme.of(context).colorTheme.appBg, titleTextStyle: StreamChatTheme.of(context).textTheme.body, @@ -391,7 +383,7 @@ class _ChatInfoScreenState extends State { } Widget _buildDeleteListTile() { - return OptionListTile( + return StreamOptionListTile( title: 'Delete Conversation', tileColor: StreamChatTheme.of(context).colorTheme.appBg, titleTextStyle: StreamChatTheme.of(context).textTheme.body.copyWith( @@ -632,7 +624,7 @@ class __SharedGroupsScreenState extends State<_SharedGroupsScreen> { children: [ Padding( padding: const EdgeInsets.all(8.0), - child: ChannelAvatar( + child: StreamChannelAvatar( channel: channel, constraints: BoxConstraints(maxWidth: 40.0, maxHeight: 40.0), diff --git a/packages/stream_chat_v1/lib/choose_user_page.dart b/packages/stream_chat_v1/lib/choose_user_page.dart index 7d3ce51..611804c 100644 --- a/packages/stream_chat_v1/lib/choose_user_page.dart +++ b/packages/stream_chat_v1/lib/choose_user_page.dart @@ -124,7 +124,7 @@ class ChooseUserPage extends StatelessWidget { arguments: HomePageArgs(client), ); }, - leading: UserAvatar( + leading: StreamUserAvatar( user: user, constraints: BoxConstraints.tight( Size.fromRadius(20), diff --git a/packages/stream_chat_v1/lib/group_chat_details_screen.dart b/packages/stream_chat_v1/lib/group_chat_details_screen.dart index df40cc5..cd75681 100644 --- a/packages/stream_chat_v1/lib/group_chat_details_screen.dart +++ b/packages/stream_chat_v1/lib/group_chat_details_screen.dart @@ -1,7 +1,6 @@ import 'package:example/localizations.dart'; import 'package:flutter/material.dart'; import 'package:stream_chat_flutter/stream_chat_flutter.dart'; -import 'package:uuid/uuid.dart'; import 'channel_page.dart'; import 'routes/routes.dart'; @@ -155,7 +154,7 @@ class _GroupChatDetailsScreenState extends State { ), ], ), - body: ConnectionStatusBuilder( + body: StreamConnectionStatusBuilder( statusBuilder: (context, status) { String statusString = ''; bool showStatus = true; @@ -172,7 +171,7 @@ class _GroupChatDetailsScreenState extends State { statusString = AppLocalizations.of(context).disconnected; break; } - return InfoTile( + return StreamInfoTile( showMessage: showStatus, tileAnchor: Alignment.topCenter, childAnchor: Alignment.topCenter, @@ -222,7 +221,7 @@ class _GroupChatDetailsScreenState extends State { final user = _selectedUsers[index]; return ListTile( key: ObjectKey(user), - leading: UserAvatar( + leading: StreamUserAvatar( user: user, constraints: BoxConstraints.tightFor( width: 40, diff --git a/packages/stream_chat_v1/lib/group_info_screen.dart b/packages/stream_chat_v1/lib/group_info_screen.dart index 9609249..ba70916 100644 --- a/packages/stream_chat_v1/lib/group_info_screen.dart +++ b/packages/stream_chat_v1/lib/group_info_screen.dart @@ -4,7 +4,6 @@ import 'package:collection/collection.dart' show IterableExtension; import 'package:example/localizations.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -import 'package:jiffy/jiffy.dart'; import 'package:stream_chat_flutter/stream_chat_flutter.dart'; import 'channel_file_display_screen.dart'; @@ -15,7 +14,7 @@ import 'pinned_messages_screen.dart'; import 'routes/routes.dart'; class GroupInfoScreen extends StatefulWidget { - final MessageThemeData messageTheme; + final StreamMessageThemeData messageTheme; const GroupInfoScreen({ Key? key, @@ -222,7 +221,7 @@ class _GroupInfoScreenState extends State { horizontal: 8.0, vertical: 12.0, ), - child: UserAvatar( + child: StreamUserAvatar( user: member.user!, constraints: BoxConstraints.tightFor( height: 40.0, @@ -456,7 +455,7 @@ class _GroupInfoScreenState extends State { builder: (context, snapshot) { mutedBool.value = snapshot.data; - return OptionListTile( + return StreamOptionListTile( tileColor: StreamChatTheme.of(context).colorTheme.appBg, separatorColor: StreamChatTheme.of(context).colorTheme.disabled, @@ -493,7 +492,7 @@ class _GroupInfoScreenState extends State { onTap: () {}, ); }), - OptionListTile( + StreamOptionListTile( title: AppLocalizations.of(context).pinnedMessages, tileColor: StreamChatTheme.of(context).colorTheme.appBg, titleTextStyle: StreamChatTheme.of(context).textTheme.body, @@ -553,7 +552,7 @@ class _GroupInfoScreenState extends State { ); }, ), - OptionListTile( + StreamOptionListTile( tileColor: StreamChatTheme.of(context).colorTheme.appBg, separatorColor: StreamChatTheme.of(context).colorTheme.disabled, title: AppLocalizations.of(context).photosAndVideos, @@ -615,7 +614,7 @@ class _GroupInfoScreenState extends State { ); }, ), - OptionListTile( + StreamOptionListTile( tileColor: StreamChatTheme.of(context).colorTheme.appBg, separatorColor: StreamChatTheme.of(context).colorTheme.disabled, title: AppLocalizations.of(context).files, @@ -660,7 +659,7 @@ class _GroupInfoScreenState extends State { if (!channel.channel.isDistinct && channel.channel.ownCapabilities .contains(PermissionType.leaveChannel)) - OptionListTile( + StreamOptionListTile( tileColor: StreamChatTheme.of(context).colorTheme.appBg, separatorColor: StreamChatTheme.of(context).colorTheme.disabled, title: AppLocalizations.of(context).leaveGroup, @@ -730,7 +729,7 @@ class _GroupInfoScreenState extends State { child: _buildTextInputSection(modalSetState), ), Expanded( - child: UserListView( + child: StreamUserListView( selectedUsers: {}, onUserTap: (user, _) async { _searchController!.clear(); @@ -900,7 +899,7 @@ class _GroupInfoScreenState extends State { Center( child: Padding( padding: const EdgeInsets.all(16.0), - child: UserAvatar( + child: StreamUserAvatar( user: user, constraints: BoxConstraints.tightFor( height: 64.0, diff --git a/packages/stream_chat_v1/lib/home_page.dart b/packages/stream_chat_v1/lib/home_page.dart index a53dd2c..e37b862 100644 --- a/packages/stream_chat_v1/lib/home_page.dart +++ b/packages/stream_chat_v1/lib/home_page.dart @@ -4,7 +4,6 @@ import 'package:example/channel_page.dart'; import 'package:example/notifications_service.dart'; import 'package:example/routes/app_routes.dart'; import 'package:example/routes/routes.dart'; -import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:stream_chat_flutter/stream_chat_flutter.dart'; diff --git a/packages/stream_chat_v1/lib/main.dart b/packages/stream_chat_v1/lib/main.dart index fc4ed9b..31717ca 100644 --- a/packages/stream_chat_v1/lib/main.dart +++ b/packages/stream_chat_v1/lib/main.dart @@ -4,7 +4,6 @@ import 'package:example/choose_user_page.dart'; import 'package:example/home_page.dart'; import 'package:example/localizations.dart'; import 'package:example/splash_screen.dart'; -import 'package:flutter/cupertino.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter/scheduler.dart'; diff --git a/packages/stream_chat_v1/lib/new_chat_screen.dart b/packages/stream_chat_v1/lib/new_chat_screen.dart index eb247c3..ffd9554 100644 --- a/packages/stream_chat_v1/lib/new_chat_screen.dart +++ b/packages/stream_chat_v1/lib/new_chat_screen.dart @@ -130,7 +130,7 @@ class _NewChatScreenState extends State { ), centerTitle: true, ), - body: ConnectionStatusBuilder( + body: StreamConnectionStatusBuilder( statusBuilder: (context, status) { String statusString = ''; bool showStatus = true; @@ -147,7 +147,7 @@ class _NewChatScreenState extends State { statusString = AppLocalizations.of(context).disconnected; break; } - return InfoTile( + return StreamInfoTile( showMessage: showStatus, tileAnchor: Alignment.topCenter, childAnchor: Alignment.topCenter, @@ -200,7 +200,7 @@ class _NewChatScreenState extends State { .overlay, shape: BoxShape.circle, ), - child: UserAvatar( + child: StreamUserAvatar( showOnlineStatus: false, user: user, constraints: BoxConstraints.tightFor( @@ -288,7 +288,7 @@ class _NewChatScreenState extends State { behavior: HitTestBehavior.opaque, onPanDown: (_) => FocusScope.of(context).unfocus(), child: UsersBloc( - child: UserListView( + child: StreamUserListView( selectedUsers: _selectedUsers, groupAlphabetically: _isSearchActive ? false : true, @@ -366,7 +366,7 @@ class _NewChatScreenState extends State { future: channel!.initialized, builder: (context, snapshot) { if (snapshot.data == true) { - return MessageListView(); + return StreamMessageListView(); } return Center( @@ -384,7 +384,7 @@ class _NewChatScreenState extends State { }, ), ), - MessageInput( + StreamMessageInput( focusNode: _messageInputFocusNode, preMessageSending: (message) async { await channel!.watch(); diff --git a/packages/stream_chat_v1/lib/new_group_chat_screen.dart b/packages/stream_chat_v1/lib/new_group_chat_screen.dart index 2d0842a..a2a2ec5 100644 --- a/packages/stream_chat_v1/lib/new_group_chat_screen.dart +++ b/packages/stream_chat_v1/lib/new_group_chat_screen.dart @@ -88,7 +88,7 @@ class _NewGroupChatScreenState extends State { ) ], ), - body: ConnectionStatusBuilder( + body: StreamConnectionStatusBuilder( statusBuilder: (context, status) { String statusString = ''; bool showStatus = true; @@ -105,7 +105,7 @@ class _NewGroupChatScreenState extends State { statusString = AppLocalizations.of(context).disconnected; break; } - return InfoTile( + return StreamInfoTile( showMessage: showStatus, tileAnchor: Alignment.topCenter, childAnchor: Alignment.topCenter, @@ -136,7 +136,7 @@ class _NewGroupChatScreenState extends State { children: [ Stack( children: [ - UserAvatar( + StreamUserAvatar( onlineIndicatorAlignment: Alignment(0.9, 0.9), user: user, @@ -229,7 +229,7 @@ class _NewGroupChatScreenState extends State { behavior: HitTestBehavior.opaque, onPanDown: (_) => FocusScope.of(context).unfocus(), child: UsersBloc( - child: UserListView( + child: StreamUserListView( selectedUsers: _selectedUsers, pullToRefresh: false, groupAlphabetically: _isSearchActive ? false : true, diff --git a/packages/stream_chat_v1/lib/pinned_messages_screen.dart b/packages/stream_chat_v1/lib/pinned_messages_screen.dart index a3470bd..6c2eaec 100644 --- a/packages/stream_chat_v1/lib/pinned_messages_screen.dart +++ b/packages/stream_chat_v1/lib/pinned_messages_screen.dart @@ -21,7 +21,7 @@ class PinnedMessagesScreen extends StatefulWidget { final ShowMessageCallback? onShowMessage; - final MessageThemeData messageTheme; + final StreamMessageThemeData messageTheme; const PinnedMessagesScreen({ required this.messageTheme, @@ -166,7 +166,7 @@ class _PinnedMessagesScreenState extends State { var text = data[position].message.text ?? ''; return ListTile( - leading: UserAvatar( + leading: StreamUserAvatar( user: user, constraints: BoxConstraints.tightFor( width: 40.0, diff --git a/packages/stream_chat_v1/lib/splash_screen.dart b/packages/stream_chat_v1/lib/splash_screen.dart index 2c89228..9e72572 100644 --- a/packages/stream_chat_v1/lib/splash_screen.dart +++ b/packages/stream_chat_v1/lib/splash_screen.dart @@ -1,5 +1,4 @@ import 'package:flutter/material.dart'; -import 'package:flutter/scheduler.dart'; import 'package:lottie/lottie.dart'; mixin SplashScreenStateMixin on State diff --git a/packages/stream_chat_v1/lib/thread_page.dart b/packages/stream_chat_v1/lib/thread_page.dart index f61130c..6ffd5e3 100644 --- a/packages/stream_chat_v1/lib/thread_page.dart +++ b/packages/stream_chat_v1/lib/thread_page.dart @@ -44,13 +44,13 @@ class _ThreadPageState extends State { Widget build(BuildContext context) { return Scaffold( backgroundColor: StreamChatTheme.of(context).colorTheme.appBg, - appBar: ThreadHeader( + appBar: StreamThreadHeader( parent: widget.parent, ), body: Column( children: [ Expanded( - child: MessageListView( + child: StreamMessageListView( parentMessage: widget.parent, initialScrollIndex: widget.initialScrollIndex, initialAlignment: widget.initialAlignment, @@ -62,14 +62,14 @@ class _ThreadPageState extends State { return defaultMessage.copyWith( onReplyTap: _reply, deletedBottomRowBuilder: (context, message) { - return const VisibleFootnote(); + return const StreamVisibleFootnote(); }, ); }, ), ), if (widget.parent.type != 'deleted') - MessageInput( + StreamMessageInput( focusNode: _focusNode, messageInputController: _messageInputController, ), diff --git a/packages/stream_chat_v1/lib/user_mentions_page.dart b/packages/stream_chat_v1/lib/user_mentions_page.dart index fa2d834..4d266a1 100644 --- a/packages/stream_chat_v1/lib/user_mentions_page.dart +++ b/packages/stream_chat_v1/lib/user_mentions_page.dart @@ -10,7 +10,7 @@ class UserMentionsPage extends StatelessWidget { Widget build(BuildContext context) { final user = StreamChat.of(context).currentUser!; return MessageSearchBloc( - child: MessageSearchListView( + child: StreamMessageSearchListView( filters: Filter.in_('members', [user.id]), messageFilters: Filter.custom( operator: r'$contains', From 928221099b8e6796ceb347159b32ad26e6ffae6a Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Tue, 22 Mar 2022 10:29:43 +0100 Subject: [PATCH 4/9] update deps --- .../ios/Runner.xcodeproj/project.pbxproj | 6 ++---- packages/stream_chat_v1/pubspec.yaml | 14 +++++++------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/packages/stream_chat_v1/ios/Runner.xcodeproj/project.pbxproj b/packages/stream_chat_v1/ios/Runner.xcodeproj/project.pbxproj index fe295e0..925a689 100644 --- a/packages/stream_chat_v1/ios/Runner.xcodeproj/project.pbxproj +++ b/packages/stream_chat_v1/ios/Runner.xcodeproj/project.pbxproj @@ -264,8 +264,7 @@ "${BUILT_PRODUCTS_DIR}/sqlite3/sqlite3.framework", "${BUILT_PRODUCTS_DIR}/sqlite3_flutter_libs/sqlite3_flutter_libs.framework", "${BUILT_PRODUCTS_DIR}/url_launcher_ios/url_launcher_ios.framework", - "${BUILT_PRODUCTS_DIR}/video_compress/video_compress.framework", - "${BUILT_PRODUCTS_DIR}/video_player/video_player.framework", + "${BUILT_PRODUCTS_DIR}/video_player_avfoundation/video_player_avfoundation.framework", "${BUILT_PRODUCTS_DIR}/video_thumbnail/video_thumbnail.framework", "${BUILT_PRODUCTS_DIR}/wakelock/wakelock.framework", ); @@ -293,8 +292,7 @@ "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/sqlite3.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/sqlite3_flutter_libs.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/url_launcher_ios.framework", - "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/video_compress.framework", - "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/video_player.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/video_player_avfoundation.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/video_thumbnail.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/wakelock.framework", ); diff --git a/packages/stream_chat_v1/pubspec.yaml b/packages/stream_chat_v1/pubspec.yaml index d2190d0..ae257d6 100644 --- a/packages/stream_chat_v1/pubspec.yaml +++ b/packages/stream_chat_v1/pubspec.yaml @@ -13,20 +13,20 @@ dependencies: stream_chat_flutter: git: url: https://github.com/GetStream/stream-chat-flutter.git - ref: develop + ref: v4 path: packages/stream_chat_flutter stream_chat_persistence: git: url: https://github.com/GetStream/stream-chat-flutter.git - ref: develop + ref: v4 path: packages/stream_chat_persistence stream_chat_localizations: git: url: https://github.com/GetStream/stream-chat-flutter.git - ref: feat/capabilities + ref: v4 path: packages/stream_chat_localizations flutter_local_notifications: ^9.0.0 - flutter_svg: ^0.23.0 + flutter_svg: ^1.0.1 flutter_secure_storage: ^4.2.1 yaml: ^3.1.0 uuid: ^3.0.5 @@ -42,17 +42,17 @@ dependency_overrides: stream_chat: git: url: https://github.com/GetStream/stream-chat-flutter.git - ref: feat/capabilities + ref: v4 path: packages/stream_chat stream_chat_flutter_core: git: url: https://github.com/GetStream/stream-chat-flutter.git - ref: feat/capabilities + ref: v4 path: packages/stream_chat_flutter_core stream_chat_flutter: git: url: https://github.com/GetStream/stream-chat-flutter.git - ref: feat/capabilities + ref: v4 path: packages/stream_chat_flutter flutter: From 56b8f894791abea2eed927adb2429eab662e7684 Mon Sep 17 00:00:00 2001 From: Ayush Shekhar Date: Wed, 13 Apr 2022 18:46:39 +0530 Subject: [PATCH 5/9] Migrated most of the code from deprecated widgets to v4 widgets, and changed data being supplied for full screen implementation --- .../stream_chat_v1/android/app/build.gradle | 2 +- .../ios/Runner.xcodeproj/project.pbxproj | 6 ++---- .../lib/advanced_options_page.dart | 1 - .../lib/channel_file_display_screen.dart | 2 +- packages/stream_chat_v1/lib/channel_list.dart | 2 +- .../stream_chat_v1/lib/channel_list_page.dart | 6 +++--- .../lib/channel_media_display_screen.dart | 17 +++++++++------ packages/stream_chat_v1/lib/channel_page.dart | 11 +++++----- .../stream_chat_v1/lib/chat_info_screen.dart | 21 +++++++++---------- .../stream_chat_v1/lib/choose_user_page.dart | 2 +- .../lib/group_chat_details_screen.dart | 7 +++---- .../stream_chat_v1/lib/group_info_screen.dart | 19 ++++++++--------- packages/stream_chat_v1/lib/home_page.dart | 1 - packages/stream_chat_v1/lib/main.dart | 1 - .../stream_chat_v1/lib/new_chat_screen.dart | 12 +++++------ .../lib/new_group_chat_screen.dart | 8 +++---- .../lib/pinned_messages_screen.dart | 4 ++-- .../stream_chat_v1/lib/splash_screen.dart | 1 - packages/stream_chat_v1/lib/thread_page.dart | 8 +++---- .../lib/user_mentions_page.dart | 2 +- packages/stream_chat_v1/pubspec.yaml | 8 +++---- 21 files changed, 68 insertions(+), 73 deletions(-) diff --git a/packages/stream_chat_v1/android/app/build.gradle b/packages/stream_chat_v1/android/app/build.gradle index ce7eeee..147d607 100644 --- a/packages/stream_chat_v1/android/app/build.gradle +++ b/packages/stream_chat_v1/android/app/build.gradle @@ -26,7 +26,7 @@ apply plugin: 'kotlin-android' apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" android { - compileSdkVersion 30 + compileSdkVersion 31 ndkVersion '21.4.7075529' sourceSets { diff --git a/packages/stream_chat_v1/ios/Runner.xcodeproj/project.pbxproj b/packages/stream_chat_v1/ios/Runner.xcodeproj/project.pbxproj index fe295e0..925a689 100644 --- a/packages/stream_chat_v1/ios/Runner.xcodeproj/project.pbxproj +++ b/packages/stream_chat_v1/ios/Runner.xcodeproj/project.pbxproj @@ -264,8 +264,7 @@ "${BUILT_PRODUCTS_DIR}/sqlite3/sqlite3.framework", "${BUILT_PRODUCTS_DIR}/sqlite3_flutter_libs/sqlite3_flutter_libs.framework", "${BUILT_PRODUCTS_DIR}/url_launcher_ios/url_launcher_ios.framework", - "${BUILT_PRODUCTS_DIR}/video_compress/video_compress.framework", - "${BUILT_PRODUCTS_DIR}/video_player/video_player.framework", + "${BUILT_PRODUCTS_DIR}/video_player_avfoundation/video_player_avfoundation.framework", "${BUILT_PRODUCTS_DIR}/video_thumbnail/video_thumbnail.framework", "${BUILT_PRODUCTS_DIR}/wakelock/wakelock.framework", ); @@ -293,8 +292,7 @@ "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/sqlite3.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/sqlite3_flutter_libs.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/url_launcher_ios.framework", - "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/video_compress.framework", - "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/video_player.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/video_player_avfoundation.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/video_thumbnail.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/wakelock.framework", ); diff --git a/packages/stream_chat_v1/lib/advanced_options_page.dart b/packages/stream_chat_v1/lib/advanced_options_page.dart index a42f200..2645e19 100644 --- a/packages/stream_chat_v1/lib/advanced_options_page.dart +++ b/packages/stream_chat_v1/lib/advanced_options_page.dart @@ -3,7 +3,6 @@ import 'package:example/localizations.dart'; import 'package:example/routes/routes.dart'; import 'package:example/stream_version.dart'; import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; import 'package:flutter_secure_storage/flutter_secure_storage.dart'; import 'package:stream_chat_flutter/stream_chat_flutter.dart'; diff --git a/packages/stream_chat_v1/lib/channel_file_display_screen.dart b/packages/stream_chat_v1/lib/channel_file_display_screen.dart index 4f4a806..743b3eb 100644 --- a/packages/stream_chat_v1/lib/channel_file_display_screen.dart +++ b/packages/stream_chat_v1/lib/channel_file_display_screen.dart @@ -160,7 +160,7 @@ class _ChannelFileDisplayScreenState extends State { padding: const EdgeInsets.all(1.0), child: Padding( padding: const EdgeInsets.all(8.0), - child: FileAttachment( + child: StreamFileAttachment( message: media.values.toList()[position], attachment: media.keys.toList()[position], ), diff --git a/packages/stream_chat_v1/lib/channel_list.dart b/packages/stream_chat_v1/lib/channel_list.dart index d13e830..3ebe2a5 100644 --- a/packages/stream_chat_v1/lib/channel_list.dart +++ b/packages/stream_chat_v1/lib/channel_list.dart @@ -86,7 +86,7 @@ class _ChannelList extends State { ), ], body: _isSearchActive - ? MessageSearchListView( + ? StreamMessageSearchListView( showErrorTile: true, messageQuery: _channelQuery, filters: Filter.in_('members', [user!.id]), diff --git a/packages/stream_chat_v1/lib/channel_list_page.dart b/packages/stream_chat_v1/lib/channel_list_page.dart index be43bd6..f2f70eb 100644 --- a/packages/stream_chat_v1/lib/channel_list_page.dart +++ b/packages/stream_chat_v1/lib/channel_list_page.dart @@ -40,7 +40,7 @@ class _ChannelListPageState extends State { Positioned( top: -3, right: -16, - child: UnreadIndicator(), + child: StreamUnreadIndicator(), ), ], ), @@ -70,7 +70,7 @@ class _ChannelListPageState extends State { } return Scaffold( backgroundColor: StreamChatTheme.of(context).colorTheme.appBg, - appBar: ChannelListHeader( + appBar: StreamChannelListHeader( onNewChatButtonTap: () { Navigator.pushNamed(context, Routes.NEW_CHAT); }, @@ -165,7 +165,7 @@ class LeftDrawer extends StatelessWidget { ), child: Row( children: [ - UserAvatar( + StreamUserAvatar( user: user, showOnlineStatus: false, constraints: BoxConstraints.tight(Size.fromRadius(20)), diff --git a/packages/stream_chat_v1/lib/channel_media_display_screen.dart b/packages/stream_chat_v1/lib/channel_media_display_screen.dart index ee23293..0cfdde6 100644 --- a/packages/stream_chat_v1/lib/channel_media_display_screen.dart +++ b/packages/stream_chat_v1/lib/channel_media_display_screen.dart @@ -21,7 +21,7 @@ class ChannelMediaDisplayScreen extends StatefulWidget { final ShowMessageCallback? onShowMessage; - final MessageThemeData messageTheme; + final StreamMessageThemeData messageTheme; const ChannelMediaDisplayScreen({ required this.messageTheme, @@ -180,11 +180,16 @@ class _ChannelMediaDisplayScreenState extends State { MaterialPageRoute( builder: (context) => StreamChannel( channel: channel, - child: FullScreenMedia( - mediaAttachments: - media.map((e) => e.attachment).toList(), + child: StreamFullScreenMedia( + mediaAttachmentPackages: media + .map( + (e) => StreamAttachmentPackage( + attachment: e.attachment, + message: e.message, + ), + ) + .toList(), startIndex: position, - message: media[position].message, userName: media[position].message.user!.name, onShowMessage: widget.onShowMessage, ), @@ -194,7 +199,7 @@ class _ChannelMediaDisplayScreenState extends State { }, child: media[position].attachment.type == 'image' ? IgnorePointer( - child: ImageAttachment( + child: StreamImageAttachment( attachment: media[position].attachment, message: media[position].message, showTitle: false, diff --git a/packages/stream_chat_v1/lib/channel_page.dart b/packages/stream_chat_v1/lib/channel_page.dart index 19aa3a3..6cf60e5 100644 --- a/packages/stream_chat_v1/lib/channel_page.dart +++ b/packages/stream_chat_v1/lib/channel_page.dart @@ -60,7 +60,7 @@ class _ChannelPageState extends State { Widget build(BuildContext context) { return Scaffold( backgroundColor: StreamChatTheme.of(context).colorTheme.appBg, - appBar: ChannelHeader( + appBar: StreamChannelHeader( showTypingIndicator: false, onImageTap: () async { var channel = StreamChannel.of(context).channel; @@ -108,7 +108,7 @@ class _ChannelPageState extends State { Expanded( child: Stack( children: [ - MessageListView( + StreamMessageListView( initialScrollIndex: widget.initialScrollIndex, initialAlignment: widget.initialAlignment, highlightInitialMessage: widget.highlightInitialMessage, @@ -137,7 +137,7 @@ class _ChannelPageState extends State { ); }, deletedBottomRowBuilder: (context, message) { - return const VisibleFootnote(); + return const StreamVisibleFootnote(); }, ); }, @@ -155,8 +155,7 @@ class _ChannelPageState extends State { .colorTheme .appBg .withOpacity(.9), - child: TypingIndicator( - alignment: Alignment.centerLeft, + child: StreamTypingIndicator( padding: const EdgeInsets.symmetric( horizontal: 8, vertical: 4, @@ -174,7 +173,7 @@ class _ChannelPageState extends State { ], ), ), - MessageInput( + StreamMessageInput( focusNode: _focusNode, messageInputController: _messageInputController, ), diff --git a/packages/stream_chat_v1/lib/chat_info_screen.dart b/packages/stream_chat_v1/lib/chat_info_screen.dart index 2ba0789..297106e 100644 --- a/packages/stream_chat_v1/lib/chat_info_screen.dart +++ b/packages/stream_chat_v1/lib/chat_info_screen.dart @@ -2,7 +2,6 @@ import 'package:collection/collection.dart' show IterableExtension; import 'package:example/localizations.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -import 'package:jiffy/jiffy.dart'; import 'package:stream_chat_flutter/stream_chat_flutter.dart'; import 'channel_file_display_screen.dart'; @@ -16,7 +15,7 @@ class ChatInfoScreen extends StatefulWidget { /// User in consideration final User? user; - final MessageThemeData messageTheme; + final StreamMessageThemeData messageTheme; const ChatInfoScreen({ Key? key, @@ -78,7 +77,7 @@ class _ChatInfoScreenState extends State { children: [ Padding( padding: const EdgeInsets.all(16.0), - child: UserAvatar( + child: StreamUserAvatar( user: widget.user!, constraints: BoxConstraints.tightFor( width: 72.0, @@ -95,7 +94,7 @@ class _ChatInfoScreenState extends State { SizedBox(height: 7.0), _buildConnectedTitleState(), SizedBox(height: 15.0), - OptionListTile( + StreamOptionListTile( title: '@${widget.user!.id}', tileColor: StreamChatTheme.of(context).colorTheme.appBg, trailing: Padding( @@ -148,7 +147,7 @@ class _ChatInfoScreenState extends State { builder: (context, snapshot) { mutedBool.value = snapshot.data; - return OptionListTile( + return StreamOptionListTile( tileColor: StreamChatTheme.of(context).colorTheme.appBg, title: AppLocalizations.of(context).muteUser, titleTextStyle: StreamChatTheme.of(context).textTheme.body, @@ -201,7 +200,7 @@ class _ChatInfoScreenState extends State { // ), // onTap: () {}, // ), - OptionListTile( + StreamOptionListTile( title: AppLocalizations.of(context).pinnedMessages, tileColor: StreamChatTheme.of(context).colorTheme.appBg, titleTextStyle: StreamChatTheme.of(context).textTheme.body, @@ -261,7 +260,7 @@ class _ChatInfoScreenState extends State { ); }, ), - OptionListTile( + StreamOptionListTile( title: AppLocalizations.of(context).photosAndVideos, tileColor: StreamChatTheme.of(context).colorTheme.appBg, titleTextStyle: StreamChatTheme.of(context).textTheme.body, @@ -321,7 +320,7 @@ class _ChatInfoScreenState extends State { ); }, ), - OptionListTile( + StreamOptionListTile( title: AppLocalizations.of(context).files, tileColor: StreamChatTheme.of(context).colorTheme.appBg, titleTextStyle: StreamChatTheme.of(context).textTheme.body, @@ -361,7 +360,7 @@ class _ChatInfoScreenState extends State { ); }, ), - OptionListTile( + StreamOptionListTile( title: AppLocalizations.of(context).sharedGroups, tileColor: StreamChatTheme.of(context).colorTheme.appBg, titleTextStyle: StreamChatTheme.of(context).textTheme.body, @@ -391,7 +390,7 @@ class _ChatInfoScreenState extends State { } Widget _buildDeleteListTile() { - return OptionListTile( + return StreamOptionListTile( title: 'Delete Conversation', tileColor: StreamChatTheme.of(context).colorTheme.appBg, titleTextStyle: StreamChatTheme.of(context).textTheme.body.copyWith( @@ -632,7 +631,7 @@ class __SharedGroupsScreenState extends State<_SharedGroupsScreen> { children: [ Padding( padding: const EdgeInsets.all(8.0), - child: ChannelAvatar( + child: StreamChannelAvatar( channel: channel, constraints: BoxConstraints(maxWidth: 40.0, maxHeight: 40.0), diff --git a/packages/stream_chat_v1/lib/choose_user_page.dart b/packages/stream_chat_v1/lib/choose_user_page.dart index 7d3ce51..611804c 100644 --- a/packages/stream_chat_v1/lib/choose_user_page.dart +++ b/packages/stream_chat_v1/lib/choose_user_page.dart @@ -124,7 +124,7 @@ class ChooseUserPage extends StatelessWidget { arguments: HomePageArgs(client), ); }, - leading: UserAvatar( + leading: StreamUserAvatar( user: user, constraints: BoxConstraints.tight( Size.fromRadius(20), diff --git a/packages/stream_chat_v1/lib/group_chat_details_screen.dart b/packages/stream_chat_v1/lib/group_chat_details_screen.dart index df40cc5..cd75681 100644 --- a/packages/stream_chat_v1/lib/group_chat_details_screen.dart +++ b/packages/stream_chat_v1/lib/group_chat_details_screen.dart @@ -1,7 +1,6 @@ import 'package:example/localizations.dart'; import 'package:flutter/material.dart'; import 'package:stream_chat_flutter/stream_chat_flutter.dart'; -import 'package:uuid/uuid.dart'; import 'channel_page.dart'; import 'routes/routes.dart'; @@ -155,7 +154,7 @@ class _GroupChatDetailsScreenState extends State { ), ], ), - body: ConnectionStatusBuilder( + body: StreamConnectionStatusBuilder( statusBuilder: (context, status) { String statusString = ''; bool showStatus = true; @@ -172,7 +171,7 @@ class _GroupChatDetailsScreenState extends State { statusString = AppLocalizations.of(context).disconnected; break; } - return InfoTile( + return StreamInfoTile( showMessage: showStatus, tileAnchor: Alignment.topCenter, childAnchor: Alignment.topCenter, @@ -222,7 +221,7 @@ class _GroupChatDetailsScreenState extends State { final user = _selectedUsers[index]; return ListTile( key: ObjectKey(user), - leading: UserAvatar( + leading: StreamUserAvatar( user: user, constraints: BoxConstraints.tightFor( width: 40, diff --git a/packages/stream_chat_v1/lib/group_info_screen.dart b/packages/stream_chat_v1/lib/group_info_screen.dart index 9609249..ba70916 100644 --- a/packages/stream_chat_v1/lib/group_info_screen.dart +++ b/packages/stream_chat_v1/lib/group_info_screen.dart @@ -4,7 +4,6 @@ import 'package:collection/collection.dart' show IterableExtension; import 'package:example/localizations.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -import 'package:jiffy/jiffy.dart'; import 'package:stream_chat_flutter/stream_chat_flutter.dart'; import 'channel_file_display_screen.dart'; @@ -15,7 +14,7 @@ import 'pinned_messages_screen.dart'; import 'routes/routes.dart'; class GroupInfoScreen extends StatefulWidget { - final MessageThemeData messageTheme; + final StreamMessageThemeData messageTheme; const GroupInfoScreen({ Key? key, @@ -222,7 +221,7 @@ class _GroupInfoScreenState extends State { horizontal: 8.0, vertical: 12.0, ), - child: UserAvatar( + child: StreamUserAvatar( user: member.user!, constraints: BoxConstraints.tightFor( height: 40.0, @@ -456,7 +455,7 @@ class _GroupInfoScreenState extends State { builder: (context, snapshot) { mutedBool.value = snapshot.data; - return OptionListTile( + return StreamOptionListTile( tileColor: StreamChatTheme.of(context).colorTheme.appBg, separatorColor: StreamChatTheme.of(context).colorTheme.disabled, @@ -493,7 +492,7 @@ class _GroupInfoScreenState extends State { onTap: () {}, ); }), - OptionListTile( + StreamOptionListTile( title: AppLocalizations.of(context).pinnedMessages, tileColor: StreamChatTheme.of(context).colorTheme.appBg, titleTextStyle: StreamChatTheme.of(context).textTheme.body, @@ -553,7 +552,7 @@ class _GroupInfoScreenState extends State { ); }, ), - OptionListTile( + StreamOptionListTile( tileColor: StreamChatTheme.of(context).colorTheme.appBg, separatorColor: StreamChatTheme.of(context).colorTheme.disabled, title: AppLocalizations.of(context).photosAndVideos, @@ -615,7 +614,7 @@ class _GroupInfoScreenState extends State { ); }, ), - OptionListTile( + StreamOptionListTile( tileColor: StreamChatTheme.of(context).colorTheme.appBg, separatorColor: StreamChatTheme.of(context).colorTheme.disabled, title: AppLocalizations.of(context).files, @@ -660,7 +659,7 @@ class _GroupInfoScreenState extends State { if (!channel.channel.isDistinct && channel.channel.ownCapabilities .contains(PermissionType.leaveChannel)) - OptionListTile( + StreamOptionListTile( tileColor: StreamChatTheme.of(context).colorTheme.appBg, separatorColor: StreamChatTheme.of(context).colorTheme.disabled, title: AppLocalizations.of(context).leaveGroup, @@ -730,7 +729,7 @@ class _GroupInfoScreenState extends State { child: _buildTextInputSection(modalSetState), ), Expanded( - child: UserListView( + child: StreamUserListView( selectedUsers: {}, onUserTap: (user, _) async { _searchController!.clear(); @@ -900,7 +899,7 @@ class _GroupInfoScreenState extends State { Center( child: Padding( padding: const EdgeInsets.all(16.0), - child: UserAvatar( + child: StreamUserAvatar( user: user, constraints: BoxConstraints.tightFor( height: 64.0, diff --git a/packages/stream_chat_v1/lib/home_page.dart b/packages/stream_chat_v1/lib/home_page.dart index a53dd2c..e37b862 100644 --- a/packages/stream_chat_v1/lib/home_page.dart +++ b/packages/stream_chat_v1/lib/home_page.dart @@ -4,7 +4,6 @@ import 'package:example/channel_page.dart'; import 'package:example/notifications_service.dart'; import 'package:example/routes/app_routes.dart'; import 'package:example/routes/routes.dart'; -import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:stream_chat_flutter/stream_chat_flutter.dart'; diff --git a/packages/stream_chat_v1/lib/main.dart b/packages/stream_chat_v1/lib/main.dart index fc4ed9b..31717ca 100644 --- a/packages/stream_chat_v1/lib/main.dart +++ b/packages/stream_chat_v1/lib/main.dart @@ -4,7 +4,6 @@ import 'package:example/choose_user_page.dart'; import 'package:example/home_page.dart'; import 'package:example/localizations.dart'; import 'package:example/splash_screen.dart'; -import 'package:flutter/cupertino.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter/scheduler.dart'; diff --git a/packages/stream_chat_v1/lib/new_chat_screen.dart b/packages/stream_chat_v1/lib/new_chat_screen.dart index eb247c3..ffd9554 100644 --- a/packages/stream_chat_v1/lib/new_chat_screen.dart +++ b/packages/stream_chat_v1/lib/new_chat_screen.dart @@ -130,7 +130,7 @@ class _NewChatScreenState extends State { ), centerTitle: true, ), - body: ConnectionStatusBuilder( + body: StreamConnectionStatusBuilder( statusBuilder: (context, status) { String statusString = ''; bool showStatus = true; @@ -147,7 +147,7 @@ class _NewChatScreenState extends State { statusString = AppLocalizations.of(context).disconnected; break; } - return InfoTile( + return StreamInfoTile( showMessage: showStatus, tileAnchor: Alignment.topCenter, childAnchor: Alignment.topCenter, @@ -200,7 +200,7 @@ class _NewChatScreenState extends State { .overlay, shape: BoxShape.circle, ), - child: UserAvatar( + child: StreamUserAvatar( showOnlineStatus: false, user: user, constraints: BoxConstraints.tightFor( @@ -288,7 +288,7 @@ class _NewChatScreenState extends State { behavior: HitTestBehavior.opaque, onPanDown: (_) => FocusScope.of(context).unfocus(), child: UsersBloc( - child: UserListView( + child: StreamUserListView( selectedUsers: _selectedUsers, groupAlphabetically: _isSearchActive ? false : true, @@ -366,7 +366,7 @@ class _NewChatScreenState extends State { future: channel!.initialized, builder: (context, snapshot) { if (snapshot.data == true) { - return MessageListView(); + return StreamMessageListView(); } return Center( @@ -384,7 +384,7 @@ class _NewChatScreenState extends State { }, ), ), - MessageInput( + StreamMessageInput( focusNode: _messageInputFocusNode, preMessageSending: (message) async { await channel!.watch(); diff --git a/packages/stream_chat_v1/lib/new_group_chat_screen.dart b/packages/stream_chat_v1/lib/new_group_chat_screen.dart index 2d0842a..a2a2ec5 100644 --- a/packages/stream_chat_v1/lib/new_group_chat_screen.dart +++ b/packages/stream_chat_v1/lib/new_group_chat_screen.dart @@ -88,7 +88,7 @@ class _NewGroupChatScreenState extends State { ) ], ), - body: ConnectionStatusBuilder( + body: StreamConnectionStatusBuilder( statusBuilder: (context, status) { String statusString = ''; bool showStatus = true; @@ -105,7 +105,7 @@ class _NewGroupChatScreenState extends State { statusString = AppLocalizations.of(context).disconnected; break; } - return InfoTile( + return StreamInfoTile( showMessage: showStatus, tileAnchor: Alignment.topCenter, childAnchor: Alignment.topCenter, @@ -136,7 +136,7 @@ class _NewGroupChatScreenState extends State { children: [ Stack( children: [ - UserAvatar( + StreamUserAvatar( onlineIndicatorAlignment: Alignment(0.9, 0.9), user: user, @@ -229,7 +229,7 @@ class _NewGroupChatScreenState extends State { behavior: HitTestBehavior.opaque, onPanDown: (_) => FocusScope.of(context).unfocus(), child: UsersBloc( - child: UserListView( + child: StreamUserListView( selectedUsers: _selectedUsers, pullToRefresh: false, groupAlphabetically: _isSearchActive ? false : true, diff --git a/packages/stream_chat_v1/lib/pinned_messages_screen.dart b/packages/stream_chat_v1/lib/pinned_messages_screen.dart index a3470bd..6c2eaec 100644 --- a/packages/stream_chat_v1/lib/pinned_messages_screen.dart +++ b/packages/stream_chat_v1/lib/pinned_messages_screen.dart @@ -21,7 +21,7 @@ class PinnedMessagesScreen extends StatefulWidget { final ShowMessageCallback? onShowMessage; - final MessageThemeData messageTheme; + final StreamMessageThemeData messageTheme; const PinnedMessagesScreen({ required this.messageTheme, @@ -166,7 +166,7 @@ class _PinnedMessagesScreenState extends State { var text = data[position].message.text ?? ''; return ListTile( - leading: UserAvatar( + leading: StreamUserAvatar( user: user, constraints: BoxConstraints.tightFor( width: 40.0, diff --git a/packages/stream_chat_v1/lib/splash_screen.dart b/packages/stream_chat_v1/lib/splash_screen.dart index 2c89228..9e72572 100644 --- a/packages/stream_chat_v1/lib/splash_screen.dart +++ b/packages/stream_chat_v1/lib/splash_screen.dart @@ -1,5 +1,4 @@ import 'package:flutter/material.dart'; -import 'package:flutter/scheduler.dart'; import 'package:lottie/lottie.dart'; mixin SplashScreenStateMixin on State diff --git a/packages/stream_chat_v1/lib/thread_page.dart b/packages/stream_chat_v1/lib/thread_page.dart index f61130c..6ffd5e3 100644 --- a/packages/stream_chat_v1/lib/thread_page.dart +++ b/packages/stream_chat_v1/lib/thread_page.dart @@ -44,13 +44,13 @@ class _ThreadPageState extends State { Widget build(BuildContext context) { return Scaffold( backgroundColor: StreamChatTheme.of(context).colorTheme.appBg, - appBar: ThreadHeader( + appBar: StreamThreadHeader( parent: widget.parent, ), body: Column( children: [ Expanded( - child: MessageListView( + child: StreamMessageListView( parentMessage: widget.parent, initialScrollIndex: widget.initialScrollIndex, initialAlignment: widget.initialAlignment, @@ -62,14 +62,14 @@ class _ThreadPageState extends State { return defaultMessage.copyWith( onReplyTap: _reply, deletedBottomRowBuilder: (context, message) { - return const VisibleFootnote(); + return const StreamVisibleFootnote(); }, ); }, ), ), if (widget.parent.type != 'deleted') - MessageInput( + StreamMessageInput( focusNode: _focusNode, messageInputController: _messageInputController, ), diff --git a/packages/stream_chat_v1/lib/user_mentions_page.dart b/packages/stream_chat_v1/lib/user_mentions_page.dart index fa2d834..4d266a1 100644 --- a/packages/stream_chat_v1/lib/user_mentions_page.dart +++ b/packages/stream_chat_v1/lib/user_mentions_page.dart @@ -10,7 +10,7 @@ class UserMentionsPage extends StatelessWidget { Widget build(BuildContext context) { final user = StreamChat.of(context).currentUser!; return MessageSearchBloc( - child: MessageSearchListView( + child: StreamMessageSearchListView( filters: Filter.in_('members', [user.id]), messageFilters: Filter.custom( operator: r'$contains', diff --git a/packages/stream_chat_v1/pubspec.yaml b/packages/stream_chat_v1/pubspec.yaml index d2190d0..d730fa3 100644 --- a/packages/stream_chat_v1/pubspec.yaml +++ b/packages/stream_chat_v1/pubspec.yaml @@ -26,7 +26,7 @@ dependencies: ref: feat/capabilities path: packages/stream_chat_localizations flutter_local_notifications: ^9.0.0 - flutter_svg: ^0.23.0 + flutter_svg: flutter_secure_storage: ^4.2.1 yaml: ^3.1.0 uuid: ^3.0.5 @@ -42,17 +42,17 @@ dependency_overrides: stream_chat: git: url: https://github.com/GetStream/stream-chat-flutter.git - ref: feat/capabilities + ref: 5587622587e1fb31e1935d4209189db0434ef09b path: packages/stream_chat stream_chat_flutter_core: git: url: https://github.com/GetStream/stream-chat-flutter.git - ref: feat/capabilities + ref: 5587622587e1fb31e1935d4209189db0434ef09b path: packages/stream_chat_flutter_core stream_chat_flutter: git: url: https://github.com/GetStream/stream-chat-flutter.git - ref: feat/capabilities + ref: 5587622587e1fb31e1935d4209189db0434ef09b path: packages/stream_chat_flutter flutter: From 18e69cd4bd7ba415d7ab52be504adb597f98318d Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Thu, 28 Apr 2022 14:53:00 +0200 Subject: [PATCH 6/9] update lists --- .../ios/Runner.xcodeproj/project.pbxproj | 2 + packages/stream_chat_v1/lib/channel_list.dart | 86 ++++++---- .../stream_chat_v1/lib/group_info_screen.dart | 136 +++++++-------- .../stream_chat_v1/lib/new_chat_screen.dart | 53 ++++-- .../lib/new_group_chat_screen.dart | 146 ++++++++-------- .../lib/user_mentions_page.dart | 157 +++++++++--------- 6 files changed, 317 insertions(+), 263 deletions(-) diff --git a/packages/stream_chat_v1/ios/Runner.xcodeproj/project.pbxproj b/packages/stream_chat_v1/ios/Runner.xcodeproj/project.pbxproj index 925a689..5b28f53 100644 --- a/packages/stream_chat_v1/ios/Runner.xcodeproj/project.pbxproj +++ b/packages/stream_chat_v1/ios/Runner.xcodeproj/project.pbxproj @@ -264,6 +264,7 @@ "${BUILT_PRODUCTS_DIR}/sqlite3/sqlite3.framework", "${BUILT_PRODUCTS_DIR}/sqlite3_flutter_libs/sqlite3_flutter_libs.framework", "${BUILT_PRODUCTS_DIR}/url_launcher_ios/url_launcher_ios.framework", + "${BUILT_PRODUCTS_DIR}/video_compress/video_compress.framework", "${BUILT_PRODUCTS_DIR}/video_player_avfoundation/video_player_avfoundation.framework", "${BUILT_PRODUCTS_DIR}/video_thumbnail/video_thumbnail.framework", "${BUILT_PRODUCTS_DIR}/wakelock/wakelock.framework", @@ -292,6 +293,7 @@ "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/sqlite3.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/sqlite3_flutter_libs.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/url_launcher_ios.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/video_compress.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/video_player_avfoundation.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/video_thumbnail.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/wakelock.framework", diff --git a/packages/stream_chat_v1/lib/channel_list.dart b/packages/stream_chat_v1/lib/channel_list.dart index 25813f0..5c8164e 100644 --- a/packages/stream_chat_v1/lib/channel_list.dart +++ b/packages/stream_chat_v1/lib/channel_list.dart @@ -20,9 +20,21 @@ class ChannelList extends StatefulWidget { class _ChannelList extends State { ScrollController _scrollController = ScrollController(); - TextEditingController? _controller; + late StreamMessageSearchListController _messageSearchListController = + StreamMessageSearchListController( + client: StreamChat.of(context).client, + filter: Filter.in_('members', [StreamChat.of(context).currentUser!.id]), + limit: 5, + searchQuery: '', + sort: [ + SortOption( + 'created_at', + direction: SortOption.ASC, + ), + ], + ); - String _channelQuery = ''; + TextEditingController? _controller; bool _isSearchActive = false; @@ -32,10 +44,11 @@ class _ChannelList extends State { if (_debounce?.isActive ?? false) _debounce!.cancel(); _debounce = Timer(const Duration(milliseconds: 350), () { if (mounted) { + _messageSearchListController.searchQuery = _controller!.text; setState(() { - _channelQuery = _controller!.text; - _isSearchActive = _channelQuery.isNotEmpty; + _isSearchActive = _controller!.text.isNotEmpty; }); + if (_isSearchActive) _messageSearchListController.doInitialLoad(); } }); } @@ -61,12 +74,12 @@ class _ChannelList extends State { _controller?.removeListener(_channelQueryListener); _controller?.dispose(); _scrollController.dispose(); + _channelListController.dispose(); super.dispose(); } @override Widget build(BuildContext context) { - final user = StreamChat.of(context).currentUser; return WillPopScope( onWillPop: () async { if (_isSearchActive) { @@ -98,17 +111,7 @@ class _ChannelList extends State { ], body: _isSearchActive ? StreamMessageSearchListView( - showErrorTile: true, - messageQuery: _channelQuery, - filters: Filter.in_('members', [user!.id]), - sortOptions: [ - SortOption( - 'created_at', - direction: SortOption.ASC, - ), - ], - pullToRefresh: false, - limit: 30, + controller: _messageSearchListController, emptyBuilder: (_) { return LayoutBuilder( builder: (context, viewportConstraints) { @@ -139,24 +142,34 @@ class _ChannelList extends State { }, ); }, - onItemTap: (messageResponse) async { - FocusScope.of(context).requestFocus(FocusNode()); - final client = StreamChat.of(context).client; - final message = messageResponse.message; - final channel = client.channel( - messageResponse.channel!.type, - id: messageResponse.channel!.id, - ); - if (channel.state == null) { - await channel.watch(); - } - Navigator.pushNamed( - context, - Routes.CHANNEL_PAGE, - arguments: ChannelPageArgs( - channel: channel, - initialMessage: message, - ), + itemBuilder: ( + context, + messageResponses, + index, + defaultWidget, + ) { + return defaultWidget.copyWith( + onTap: () async { + final messageResponse = messageResponses[index]; + FocusScope.of(context).requestFocus(FocusNode()); + final client = StreamChat.of(context).client; + final message = messageResponse.message; + final channel = client.channel( + messageResponse.channel!.type, + id: messageResponse.channel!.id, + ); + if (channel.state == null) { + await channel.watch(); + } + Navigator.pushNamed( + context, + Routes.CHANNEL_PAGE, + arguments: ChannelPageArgs( + channel: channel, + initialMessage: message, + ), + ); + }, ); }, ) @@ -166,9 +179,10 @@ class _ChannelList extends State { onRefresh: _channelListController.refresh, child: StreamChannelListView( controller: _channelListController, - itemBuilder: (context, channel, tile) { + itemBuilder: (context, channels, index, defaultWidget) { final chatTheme = StreamChatTheme.of(context); final backgroundColor = chatTheme.colorTheme.inputBg; + final channel = channels[index]; final canDeleteChannel = channel.ownCapabilities .contains(PermissionType.deleteChannel); return Slidable( @@ -249,7 +263,7 @@ class _ChannelList extends State { ), ], ), - child: tile, + child: defaultWidget, ); }, onChannelTap: (channel) { diff --git a/packages/stream_chat_v1/lib/group_info_screen.dart b/packages/stream_chat_v1/lib/group_info_screen.dart index ba70916..e650b07 100644 --- a/packages/stream_chat_v1/lib/group_info_screen.dart +++ b/packages/stream_chat_v1/lib/group_info_screen.dart @@ -704,6 +704,28 @@ class _GroupInfoScreenState extends State { void _buildAddUserModal(context) { var channel = StreamChannel.of(context).channel; + final userListController = StreamUserListController( + client: channel.client, + limit: 25, + filter: Filter.and( + [ + if (_searchController!.text.isNotEmpty) + Filter.autoComplete('name', _userNameQuery), + Filter.notIn('id', [ + StreamChat.of(context).currentUser!.id, + ...channel.state!.members + .map(((e) => e.userId)) + .whereType(), + ]), + ], + ), + sort: [ + SortOption( + 'name', + direction: 1, + ), + ], + ); showDialog( useRootNavigator: false, @@ -721,85 +743,63 @@ class _GroupInfoScreenState extends State { ), clipBehavior: Clip.antiAlias, child: Scaffold( - body: UsersBloc( - child: Column( - children: [ - Padding( - padding: const EdgeInsets.all(16), - child: _buildTextInputSection(modalSetState), - ), - Expanded( - child: StreamUserListView( - selectedUsers: {}, - onUserTap: (user, _) async { - _searchController!.clear(); + body: Column( + children: [ + Padding( + padding: const EdgeInsets.all(16), + child: _buildTextInputSection(modalSetState), + ), + Expanded( + child: StreamUserListView( + controller: userListController, + onUserTap: (user) async { + _searchController!.clear(); - await channel.addMembers([user.id]); - Navigator.pop(context); - setState(() {}); - }, - crossAxisCount: 4, - limit: 25, - filter: Filter.and( - [ - if (_searchController!.text.isNotEmpty) - Filter.autoComplete('name', _userNameQuery), - Filter.notIn('id', [ - StreamChat.of(context).currentUser!.id, - ...channel.state!.members - .map(((e) => e.userId)) - .whereType(), - ]), - ], - ), - sort: [ - SortOption( - 'name', - direction: 1, - ), - ], - emptyBuilder: (_) { - return LayoutBuilder( - builder: (context, viewportConstraints) { - return SingleChildScrollView( - physics: AlwaysScrollableScrollPhysics(), - child: ConstrainedBox( - constraints: BoxConstraints( - minHeight: viewportConstraints.maxHeight, - ), - child: Center( - child: Column( - children: [ - Padding( - padding: const EdgeInsets.all(24), - child: StreamSvgIcon.search( - size: 96, - color: StreamChatTheme.of(context) - .colorTheme - .textLowEmphasis, - ), + await channel.addMembers([user.id]); + Navigator.pop(context); + setState(() {}); + }, + emptyBuilder: (_) { + return LayoutBuilder( + builder: (context, viewportConstraints) { + return SingleChildScrollView( + physics: AlwaysScrollableScrollPhysics(), + child: ConstrainedBox( + constraints: BoxConstraints( + minHeight: viewportConstraints.maxHeight, + ), + child: Center( + child: Column( + children: [ + Padding( + padding: const EdgeInsets.all(24), + child: StreamSvgIcon.search( + size: 96, + color: StreamChatTheme.of(context) + .colorTheme + .textLowEmphasis, ), - Text(AppLocalizations.of(context) - .noUserMatchesTheseKeywords), - ], - ), + ), + Text(AppLocalizations.of(context) + .noUserMatchesTheseKeywords), + ], ), ), - ); - }, - ); - }, - ), + ), + ); + }, + ); + }, ), - ], - ), + ), + ], ), ), ), ); }); }, - ); + ).then((_) => userListController.dispose()); } Widget _buildTextInputSection(modalSetState) { diff --git a/packages/stream_chat_v1/lib/new_chat_screen.dart b/packages/stream_chat_v1/lib/new_chat_screen.dart index ffd9554..1d57d29 100644 --- a/packages/stream_chat_v1/lib/new_chat_screen.dart +++ b/packages/stream_chat_v1/lib/new_chat_screen.dart @@ -19,6 +19,20 @@ class _NewChatScreenState extends State { late TextEditingController _controller; + late final userListController = StreamUserListController( + client: StreamChat.of(context).client, + limit: 25, + filter: Filter.and([ + Filter.notEqual('id', StreamChat.of(context).currentUser!.id), + ]), + sort: [ + SortOption( + 'name', + direction: 1, + ), + ], + ); + ChipInputTextFieldState? get _chipInputTextFieldState => _chipInputTextFieldStateKey.currentState; @@ -45,6 +59,12 @@ class _NewChatScreenState extends State { _userNameQuery = _controller.text; _isSearchActive = _userNameQuery.isNotEmpty; }); + userListController.filter = Filter.and([ + if (_userNameQuery.isNotEmpty) + Filter.autoComplete('name', _userNameQuery), + Filter.notEqual('id', StreamChat.of(context).currentUser!.id), + ]); + userListController.doInitialLoad(); }); } @@ -112,6 +132,7 @@ class _NewChatScreenState extends State { _controller.clear(); _controller.removeListener(_userNameListener); _controller.dispose(); + userListController.dispose(); super.dispose(); } @@ -289,10 +310,10 @@ class _NewChatScreenState extends State { onPanDown: (_) => FocusScope.of(context).unfocus(), child: UsersBloc( child: StreamUserListView( - selectedUsers: _selectedUsers, - groupAlphabetically: - _isSearchActive ? false : true, - onUserTap: (user, _) { + controller: userListController, + // groupAlphabetically: + // _isSearchActive ? false : true, + onUserTap: (user) { _controller.clear(); if (!_selectedUsers.contains(user)) { _chipInputTextFieldState @@ -302,19 +323,17 @@ class _NewChatScreenState extends State { _chipInputTextFieldState!.removeItem(user); } }, - limit: 25, - filter: Filter.and([ - if (_userNameQuery.isNotEmpty) - Filter.autoComplete('name', _userNameQuery), - Filter.notEqual('id', - StreamChat.of(context).currentUser!.id), - ]), - sort: [ - SortOption( - 'name', - direction: 1, - ), - ], + itemBuilder: ( + context, + users, + index, + defaultWidget, + ) { + return defaultWidget.copyWith( + selected: + _selectedUsers.contains(users[index]), + ); + }, emptyBuilder: (_) { return LayoutBuilder( builder: (context, viewportConstraints) { diff --git a/packages/stream_chat_v1/lib/new_group_chat_screen.dart b/packages/stream_chat_v1/lib/new_group_chat_screen.dart index a2a2ec5..ff0c175 100644 --- a/packages/stream_chat_v1/lib/new_group_chat_screen.dart +++ b/packages/stream_chat_v1/lib/new_group_chat_screen.dart @@ -23,6 +23,20 @@ class _NewGroupChatScreenState extends State { Timer? _debounce; + late final userListController = StreamUserListController( + client: StreamChat.of(context).client, + sort: [ + SortOption( + 'name', + direction: 1, + ), + ], + limit: 25, + filter: Filter.and([ + Filter.notEqual('id', StreamChat.of(context).currentUser!.id), + ]), + ); + void _userNameListener() { if (_debounce?.isActive ?? false) _debounce!.cancel(); _debounce = Timer(const Duration(milliseconds: 350), () { @@ -31,6 +45,12 @@ class _NewGroupChatScreenState extends State { _userNameQuery = _controller!.text; _isSearchActive = _userNameQuery.isNotEmpty; }); + userListController.filter = Filter.and([ + if (_userNameQuery.isNotEmpty) + Filter.autoComplete('name', _userNameQuery), + Filter.notEqual('id', StreamChat.of(context).currentUser!.id), + ]); + userListController.doInitialLoad(); } }); } @@ -46,6 +66,7 @@ class _NewGroupChatScreenState extends State { _controller?.clear(); _controller?.removeListener(_userNameListener); _controller?.dispose(); + userListController.dispose(); super.dispose(); } @@ -228,77 +249,66 @@ class _NewGroupChatScreenState extends State { body: GestureDetector( behavior: HitTestBehavior.opaque, onPanDown: (_) => FocusScope.of(context).unfocus(), - child: UsersBloc( - child: StreamUserListView( - selectedUsers: _selectedUsers, - pullToRefresh: false, - groupAlphabetically: _isSearchActive ? false : true, - onUserTap: (user, _) { - if (!_selectedUsers.contains(user)) { - setState(() { - _selectedUsers.add(user); - }); - } else { - setState(() { - _selectedUsers.remove(user); - }); - } - }, - limit: 25, - filter: Filter.and([ - if (_userNameQuery.isNotEmpty) - Filter.autoComplete('name', _userNameQuery), - Filter.notEqual( - 'id', StreamChat.of(context).currentUser!.id), - ]), - sort: [ - SortOption( - 'name', - direction: 1, - ), - ], - emptyBuilder: (_) { - return LayoutBuilder( - builder: (context, viewportConstraints) { - return SingleChildScrollView( - physics: AlwaysScrollableScrollPhysics(), - child: ConstrainedBox( - constraints: BoxConstraints( - minHeight: viewportConstraints.maxHeight, - ), - child: Center( - child: Column( - children: [ - Padding( - padding: const EdgeInsets.all(24), - child: StreamSvgIcon.search( - size: 96, - color: StreamChatTheme.of(context) - .colorTheme - .textLowEmphasis, - ), + child: StreamUserListView( + controller: userListController, + // groupAlphabetically: _isSearchActive ? false : true, + itemBuilder: (context, items, index, defaultWidget) { + return defaultWidget.copyWith( + selected: _selectedUsers.contains(items[index]), + ); + }, + onUserTap: (user) { + if (!_selectedUsers.contains(user)) { + setState(() { + _selectedUsers.add(user); + }); + } else { + setState(() { + _selectedUsers.remove(user); + }); + } + }, + emptyBuilder: (_) { + return LayoutBuilder( + builder: (context, viewportConstraints) { + return SingleChildScrollView( + physics: AlwaysScrollableScrollPhysics(), + child: ConstrainedBox( + constraints: BoxConstraints( + minHeight: viewportConstraints.maxHeight, + ), + child: Center( + child: Column( + children: [ + Padding( + padding: const EdgeInsets.all(24), + child: StreamSvgIcon.search( + size: 96, + color: StreamChatTheme.of(context) + .colorTheme + .textLowEmphasis, ), - Text( - AppLocalizations.of(context) - .noUserMatchesTheseKeywords, - style: StreamChatTheme.of(context) - .textTheme - .footnote - .copyWith( - color: StreamChatTheme.of(context) - .colorTheme - .textLowEmphasis, - ), - ), - ], - ), + ), + Text( + AppLocalizations.of(context) + .noUserMatchesTheseKeywords, + style: StreamChatTheme.of(context) + .textTheme + .footnote + .copyWith( + color: StreamChatTheme.of(context) + .colorTheme + .textLowEmphasis, + ), + ), + ], ), ), - ); - }, - ); - }, - ), + ), + ); + }, + ); + }, ), ), ), diff --git a/packages/stream_chat_v1/lib/user_mentions_page.dart b/packages/stream_chat_v1/lib/user_mentions_page.dart index 4d266a1..3dcbab6 100644 --- a/packages/stream_chat_v1/lib/user_mentions_page.dart +++ b/packages/stream_chat_v1/lib/user_mentions_page.dart @@ -5,85 +5,94 @@ import 'package:stream_chat_flutter/stream_chat_flutter.dart'; import 'channel_page.dart'; -class UserMentionsPage extends StatelessWidget { +class UserMentionsPage extends StatefulWidget { + @override + State createState() => _UserMentionsPageState(); +} + +class _UserMentionsPageState extends State { + late final controller = StreamMessageSearchListController( + client: StreamChat.of(context).client, + filter: Filter.in_('members', [StreamChat.of(context).currentUser!.id]), + messageFilter: Filter.custom( + operator: r'$contains', + key: 'mentioned_users.id', + value: StreamChat.of(context).currentUser!.id, + ), + sort: [ + SortOption( + 'created_at', + direction: SortOption.ASC, + ), + ], + limit: 20, + ); @override Widget build(BuildContext context) { - final user = StreamChat.of(context).currentUser!; - return MessageSearchBloc( - child: StreamMessageSearchListView( - filters: Filter.in_('members', [user.id]), - messageFilters: Filter.custom( - operator: r'$contains', - key: 'mentioned_users.id', - value: user.id, - ), - sortOptions: [ - SortOption( - 'created_at', - direction: SortOption.ASC, - ), - ], - limit: 20, - showResultCount: false, - emptyBuilder: (_) { - return LayoutBuilder( - builder: (context, viewportConstraints) { - return SingleChildScrollView( - physics: AlwaysScrollableScrollPhysics(), - child: ConstrainedBox( - constraints: BoxConstraints( - minHeight: viewportConstraints.maxHeight, - ), - child: Center( - child: Column( - children: [ - Padding( - padding: const EdgeInsets.all(24), - child: StreamSvgIcon.mentions( - size: 96, - color: - StreamChatTheme.of(context).colorTheme.disabled, - ), + return StreamMessageSearchListView( + controller: controller, + emptyBuilder: (_) { + return LayoutBuilder( + builder: (context, viewportConstraints) { + return SingleChildScrollView( + physics: AlwaysScrollableScrollPhysics(), + child: ConstrainedBox( + constraints: BoxConstraints( + minHeight: viewportConstraints.maxHeight, + ), + child: Center( + child: Column( + children: [ + Padding( + padding: const EdgeInsets.all(24), + child: StreamSvgIcon.mentions( + size: 96, + color: + StreamChatTheme.of(context).colorTheme.disabled, ), - Text( - AppLocalizations.of(context).noMentionsExistYet, - style: StreamChatTheme.of(context) - .textTheme - .body - .copyWith( - color: StreamChatTheme.of(context) - .colorTheme - .textLowEmphasis, - ), - ), - ], - ), + ), + Text( + AppLocalizations.of(context).noMentionsExistYet, + style: + StreamChatTheme.of(context).textTheme.body.copyWith( + color: StreamChatTheme.of(context) + .colorTheme + .textLowEmphasis, + ), + ), + ], ), ), - ); - }, - ); - }, - onItemTap: (messageResponse) async { - final client = StreamChat.of(context).client; - final message = messageResponse.message; - final channel = client.channel( - messageResponse.channel!.type, - id: messageResponse.channel!.id, - ); - if (channel.state == null) { - await channel.watch(); - } - Navigator.pushNamed( - context, - Routes.CHANNEL_PAGE, - arguments: ChannelPageArgs( - channel: channel, - initialMessage: message, - ), - ); - }, - ), + ), + ); + }, + ); + }, + onMessageTap: (messageResponse) async { + final client = StreamChat.of(context).client; + final message = messageResponse.message; + final channel = client.channel( + messageResponse.channel!.type, + id: messageResponse.channel!.id, + ); + if (channel.state == null) { + await channel.watch(); + } + Navigator.pushNamed( + context, + Routes.CHANNEL_PAGE, + arguments: ChannelPageArgs( + channel: channel, + initialMessage: message, + ), + ); + }, ); } + + @override + void dispose() { + controller.dispose(); + super.dispose(); + } } From ccfbe367d00eb1e13651a6a64e2fea4dc9810d2c Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Thu, 28 Apr 2022 14:53:29 +0200 Subject: [PATCH 7/9] update lists --- .../stream_chat_v1/lib/new_chat_screen.dart | 133 +++++++++--------- 1 file changed, 65 insertions(+), 68 deletions(-) diff --git a/packages/stream_chat_v1/lib/new_chat_screen.dart b/packages/stream_chat_v1/lib/new_chat_screen.dart index 1d57d29..f0ce098 100644 --- a/packages/stream_chat_v1/lib/new_chat_screen.dart +++ b/packages/stream_chat_v1/lib/new_chat_screen.dart @@ -308,77 +308,74 @@ class _NewChatScreenState extends State { ? GestureDetector( behavior: HitTestBehavior.opaque, onPanDown: (_) => FocusScope.of(context).unfocus(), - child: UsersBloc( - child: StreamUserListView( - controller: userListController, - // groupAlphabetically: - // _isSearchActive ? false : true, - onUserTap: (user) { - _controller.clear(); - if (!_selectedUsers.contains(user)) { - _chipInputTextFieldState - ?..addItem(user) - ..pauseItemAddition(); - } else { - _chipInputTextFieldState!.removeItem(user); - } - }, - itemBuilder: ( - context, - users, - index, - defaultWidget, - ) { - return defaultWidget.copyWith( - selected: - _selectedUsers.contains(users[index]), - ); - }, - emptyBuilder: (_) { - return LayoutBuilder( - builder: (context, viewportConstraints) { - return SingleChildScrollView( - physics: - AlwaysScrollableScrollPhysics(), - child: ConstrainedBox( - constraints: BoxConstraints( - minHeight: - viewportConstraints.maxHeight, - ), - child: Center( - child: Column( - children: [ - Padding( - padding: - const EdgeInsets.all(24), - child: StreamSvgIcon.search( - size: 96, - color: Colors.grey, - ), + child: StreamUserListView( + controller: userListController, + // groupAlphabetically: + // _isSearchActive ? false : true, + onUserTap: (user) { + _controller.clear(); + if (!_selectedUsers.contains(user)) { + _chipInputTextFieldState + ?..addItem(user) + ..pauseItemAddition(); + } else { + _chipInputTextFieldState!.removeItem(user); + } + }, + itemBuilder: ( + context, + users, + index, + defaultWidget, + ) { + return defaultWidget.copyWith( + selected: + _selectedUsers.contains(users[index]), + ); + }, + emptyBuilder: (_) { + return LayoutBuilder( + builder: (context, viewportConstraints) { + return SingleChildScrollView( + physics: AlwaysScrollableScrollPhysics(), + child: ConstrainedBox( + constraints: BoxConstraints( + minHeight: + viewportConstraints.maxHeight, + ), + child: Center( + child: Column( + children: [ + Padding( + padding: + const EdgeInsets.all(24), + child: StreamSvgIcon.search( + size: 96, + color: Colors.grey, ), - Text( - AppLocalizations.of(context) - .noUserMatchesTheseKeywords, - style: StreamChatTheme.of( - context) - .textTheme - .footnote - .copyWith( - color: StreamChatTheme - .of(context) - .colorTheme - .textHighEmphasis - .withOpacity(.5)), - ), - ], - ), + ), + Text( + AppLocalizations.of(context) + .noUserMatchesTheseKeywords, + style: StreamChatTheme.of( + context) + .textTheme + .footnote + .copyWith( + color: StreamChatTheme + .of(context) + .colorTheme + .textHighEmphasis + .withOpacity(.5)), + ), + ], ), ), - ); - }, - ); - }, - ), + ), + ); + }, + ); + }, ), ) : FutureBuilder( From 3e048711f5f98e8919620212eedad21cf550d433 Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Fri, 29 Apr 2022 15:24:35 +0200 Subject: [PATCH 8/9] align with v4 --- .../lib/channel_file_display_screen.dart | 260 ++++++------- packages/stream_chat_v1/lib/channel_list.dart | 50 +-- .../stream_chat_v1/lib/channel_list_page.dart | 4 +- .../lib/channel_media_display_screen.dart | 355 +++++++++--------- packages/stream_chat_v1/lib/channel_page.dart | 2 +- .../stream_chat_v1/lib/chat_info_screen.dart | 73 +--- .../stream_chat_v1/lib/group_info_screen.dart | 309 +++++++-------- .../lib/pinned_messages_screen.dart | 173 +++------ packages/stream_chat_v1/lib/thread_page.dart | 5 +- 9 files changed, 502 insertions(+), 729 deletions(-) diff --git a/packages/stream_chat_v1/lib/channel_file_display_screen.dart b/packages/stream_chat_v1/lib/channel_file_display_screen.dart index 743b3eb..8806f97 100644 --- a/packages/stream_chat_v1/lib/channel_file_display_screen.dart +++ b/packages/stream_chat_v1/lib/channel_file_display_screen.dart @@ -1,52 +1,45 @@ import 'package:example/localizations.dart'; +import 'package:example/routes/routes.dart'; import 'package:flutter/material.dart'; import 'package:stream_chat_flutter/stream_chat_flutter.dart'; +import 'package:video_player/video_player.dart'; + +import 'channel_page.dart'; class ChannelFileDisplayScreen extends StatefulWidget { - /// The sorting used for the channels matching the filters. - /// Sorting is based on field and direction, multiple sorting options can be provided. - /// You can sort based on last_updated, last_message_at, updated_at, created_at or member_count. - /// Direction can be ascending or descending. - final List? sortOptions; - - /// Pagination parameters - /// limit: the number of users to return (max is 30) - /// offset: the offset (max is 1000) - /// message_limit: how many messages should be included to each channel - final PaginationParams paginationParams; - - /// The builder used when the file list is empty. - final WidgetBuilder? emptyBuilder; + final StreamMessageThemeData messageTheme; const ChannelFileDisplayScreen({ - this.sortOptions, - this.paginationParams = const PaginationParams(limit: 20), - this.emptyBuilder, - }); + Key? key, + required this.messageTheme, + }) : super(key: key); @override - _ChannelFileDisplayScreenState createState() => + State createState() => _ChannelFileDisplayScreenState(); } class _ChannelFileDisplayScreenState extends State { - @override - void initState() { - super.initState(); - final messageSearchBloc = MessageSearchBloc.of(context); - messageSearchBloc.search( - filter: Filter.in_( - 'cid', - [StreamChannel.of(context).channel.cid!], + final Map controllerCache = {}; + + late final controller = StreamMessageSearchListController( + client: StreamChat.of(context).client, + filter: Filter.in_( + 'cid', + [StreamChannel.of(context).channel.cid!], + ), + messageFilter: Filter.in_( + 'attachments.type', + ['file'], + ), + sort: [ + SortOption( + 'created_at', + direction: SortOption.ASC, ), - messageFilter: Filter.in_( - 'attachments.type', - ['file'], - ), - sort: widget.sortOptions, - pagination: widget.paginationParams, - ); - } + ], + limit: 20, + ); @override Widget build(BuildContext context) { @@ -58,120 +51,109 @@ class _ChannelFileDisplayScreenState extends State { title: Text( AppLocalizations.of(context).files, style: TextStyle( - color: StreamChatTheme.of(context).colorTheme.textHighEmphasis, - fontSize: 16.0), - ), - leading: Center( - child: InkWell( - onTap: () { - Navigator.of(context).pop(); - }, - child: Container( - width: 24.0, - height: 24.0, - child: StreamSvgIcon.left( - color: StreamChatTheme.of(context).colorTheme.textHighEmphasis, - size: 24.0, - ), - ), + color: StreamChatTheme.of(context).colorTheme.textHighEmphasis, + fontSize: 16.0, ), ), + leading: StreamBackButton(), backgroundColor: StreamChatTheme.of(context).colorTheme.barsBg, ), - body: _buildMediaGrid(), - ); - } - - Widget _buildMediaGrid() { - final messageSearchBloc = MessageSearchBloc.of(context); - - return StreamBuilder>( - builder: (context, snapshot) { - if (snapshot.data == null) { - return Center( - child: const CircularProgressIndicator(), - ); - } - - if (snapshot.data!.isEmpty) { - if (widget.emptyBuilder != null) { - return widget.emptyBuilder!(context); - } - return Center( - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - StreamSvgIcon.files( - size: 136.0, - color: StreamChatTheme.of(context).colorTheme.disabled, - ), - SizedBox(height: 16.0), - Text( - AppLocalizations.of(context).noFiles, - style: TextStyle( - fontSize: 14.0, - color: - StreamChatTheme.of(context).colorTheme.textHighEmphasis, + body: ValueListenableBuilder( + valueListenable: controller, + builder: ( + BuildContext context, + PagedValue value, + Widget? child, + ) { + return value.when( + (items, nextPageKey, error) { + if (items.isEmpty) { + return Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + StreamSvgIcon.files( + size: 136.0, + color: StreamChatTheme.of(context).colorTheme.disabled, + ), + SizedBox(height: 16.0), + Text( + AppLocalizations.of(context).noFiles, + style: TextStyle( + fontSize: 14.0, + color: StreamChatTheme.of(context) + .colorTheme + .textHighEmphasis, + ), + ), + SizedBox(height: 8.0), + Text( + AppLocalizations.of(context).filesAppearHere, + textAlign: TextAlign.center, + style: TextStyle( + fontSize: 14.0, + color: StreamChatTheme.of(context) + .colorTheme + .textHighEmphasis + .withOpacity(0.5), + ), + ), + ], ), - ), - SizedBox(height: 8.0), - Text( - AppLocalizations.of(context).filesAppearHere, - textAlign: TextAlign.center, - style: TextStyle( - fontSize: 14.0, - color: StreamChatTheme.of(context) - .colorTheme - .textHighEmphasis - .withOpacity(0.5), - ), - ), - ], - ), - ); - } + ); + } + final media = {}; - final media = {}; + for (var item in items) { + item.message.attachments + .where((e) => e.type == 'file') + .forEach((e) { + media[e] = item.message; + }); + } - for (var item in snapshot.data!) { - item.message.attachments.where((e) => e.type == 'file').forEach((e) { - media[e] = item.message; - }); - } - - return LazyLoadScrollView( - onEndOfPage: () => messageSearchBloc.search( - filter: Filter.in_( - 'cid', - [StreamChannel.of(context).channel.cid!], - ), - messageFilter: Filter.in_( - 'attachments.type', - ['file'], - ), - sort: widget.sortOptions, - pagination: widget.paginationParams.copyWith( - offset: messageSearchBloc.messageResponses?.length ?? 0, - ), - ), - child: ListView.builder( - itemBuilder: (context, position) { - return Padding( - padding: const EdgeInsets.all(1.0), - child: Padding( - padding: const EdgeInsets.all(8.0), - child: StreamFileAttachment( - message: media.values.toList()[position], - attachment: media.keys.toList()[position], - ), + return LazyLoadScrollView( + onEndOfPage: () async { + if (nextPageKey != null) { + controller.loadMore(nextPageKey); + } + }, + child: ListView.builder( + itemBuilder: (context, position) { + return Padding( + padding: const EdgeInsets.all(1.0), + child: Padding( + padding: const EdgeInsets.all(8.0), + child: StreamFileAttachment( + message: media.values.toList()[position], + attachment: media.keys.toList()[position], + ), + ), + ); + }, + itemCount: media.length, ), ); }, - itemCount: media.length, - ), - ); - }, - stream: messageSearchBloc.messagesStream, + loading: () => Center( + child: const CircularProgressIndicator(), + ), + error: (_) => Offstage(), + ); + }, + ), ); } + + @override + void dispose() { + controller.dispose(); + super.dispose(); + } + + @override + void initState() { + controller.doInitialLoad(); + super.initState(); + } } diff --git a/packages/stream_chat_v1/lib/channel_list.dart b/packages/stream_chat_v1/lib/channel_list.dart index 5c8164e..dcc1e91 100644 --- a/packages/stream_chat_v1/lib/channel_list.dart +++ b/packages/stream_chat_v1/lib/channel_list.dart @@ -278,31 +278,33 @@ class _ChannelList extends State { emptyBuilder: (_) { return Center( child: Padding( - padding: EdgeInsets.all(8), - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Expanded(child: StreamChannelListEmptyWidget()), - TextButton( - onPressed: () { - Navigator.pushNamed( - context, - Routes.NEW_CHAT, - ); - }, - child: Text( - 'Start a chat', - style: StreamChatTheme.of(context) - .textTheme - .bodyBold - .copyWith( - color: StreamChatTheme.of(context) - .colorTheme - .accentPrimary, - ), - ), + padding: const EdgeInsets.all(8), + child: StreamScrollViewEmptyWidget( + emptyIcon: StreamSvgIcon.message( + size: 148, + color: StreamChatTheme.of(context) + .colorTheme + .disabled, + ), + emptyTitle: TextButton( + onPressed: () { + Navigator.pushNamed( + context, + Routes.NEW_CHAT, + ); + }, + child: Text( + 'Start a chat', + style: StreamChatTheme.of(context) + .textTheme + .bodyBold + .copyWith( + color: StreamChatTheme.of(context) + .colorTheme + .accentPrimary, + ), ), - ], + ), ), ), ); diff --git a/packages/stream_chat_v1/lib/channel_list_page.dart b/packages/stream_chat_v1/lib/channel_list_page.dart index af45104..6a9438f 100644 --- a/packages/stream_chat_v1/lib/channel_list_page.dart +++ b/packages/stream_chat_v1/lib/channel_list_page.dart @@ -100,9 +100,7 @@ class _ChannelListPageState extends State { body: IndexedStack( index: _currentIndex, children: [ - MessageSearchBloc( - child: ChannelList(), - ), + ChannelList(), UserMentionsPage(), ], ), diff --git a/packages/stream_chat_v1/lib/channel_media_display_screen.dart b/packages/stream_chat_v1/lib/channel_media_display_screen.dart index 0cfdde6..65c9a5d 100644 --- a/packages/stream_chat_v1/lib/channel_media_display_screen.dart +++ b/packages/stream_chat_v1/lib/channel_media_display_screen.dart @@ -1,61 +1,45 @@ import 'package:example/localizations.dart'; +import 'package:example/routes/routes.dart'; import 'package:flutter/material.dart'; import 'package:stream_chat_flutter/stream_chat_flutter.dart'; import 'package:video_player/video_player.dart'; +import 'channel_page.dart'; + class ChannelMediaDisplayScreen extends StatefulWidget { - /// The sorting used for the channels matching the filters. - /// Sorting is based on field and direction, multiple sorting options can be provided. - /// You can sort based on last_updated, last_message_at, updated_at, created_at or member_count. - /// Direction can be ascending or descending. - final List? sortOptions; - - /// Pagination parameters - /// limit: the number of users to return (max is 30) - /// offset: the offset (max is 1000) - /// message_limit: how many messages should be included to each channel - final PaginationParams paginationParams; - - /// The builder used when the file list is empty. - final WidgetBuilder? emptyBuilder; - - final ShowMessageCallback? onShowMessage; - final StreamMessageThemeData messageTheme; const ChannelMediaDisplayScreen({ + Key? key, required this.messageTheme, - this.sortOptions, - this.paginationParams = const PaginationParams(limit: 20), - this.emptyBuilder, - this.onShowMessage, - }); + }) : super(key: key); @override - _ChannelMediaDisplayScreenState createState() => + State createState() => _ChannelMediaDisplayScreenState(); } class _ChannelMediaDisplayScreenState extends State { - Map controllerCache = {}; + final Map controllerCache = {}; - @override - void initState() { - super.initState(); - final messageSearchBloc = MessageSearchBloc.of(context); - messageSearchBloc.search( - filter: Filter.in_( - 'cid', - [StreamChannel.of(context).channel.cid!], + late final controller = StreamMessageSearchListController( + client: StreamChat.of(context).client, + filter: Filter.in_( + 'cid', + [StreamChannel.of(context).channel.cid!], + ), + messageFilter: Filter.in_( + 'attachments.type', + ['image', 'video'], + ), + sort: [ + SortOption( + 'created_at', + direction: SortOption.ASC, ), - messageFilter: Filter.in_( - 'attachments.type', - ['image', 'video'], - ), - sort: widget.sortOptions, - pagination: widget.paginationParams, - ); - } + ], + limit: 20, + ); @override Widget build(BuildContext context) { @@ -74,160 +58,169 @@ class _ChannelMediaDisplayScreenState extends State { leading: StreamBackButton(), backgroundColor: StreamChatTheme.of(context).colorTheme.barsBg, ), - body: _buildMediaGrid(), - ); - } - - Widget _buildMediaGrid() { - final messageSearchBloc = MessageSearchBloc.of(context); - - return StreamBuilder>( - builder: (context, snapshot) { - if (snapshot.data == null) { - return Center( - child: const CircularProgressIndicator(), - ); - } - - if (snapshot.data!.isEmpty) { - if (widget.emptyBuilder != null) { - return widget.emptyBuilder!(context); - } - return Center( - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - StreamSvgIcon.pictures( - size: 136.0, - color: StreamChatTheme.of(context).colorTheme.disabled, - ), - SizedBox(height: 16.0), - Text( - AppLocalizations.of(context).noMedia, - style: TextStyle( - fontSize: 14.0, - color: - StreamChatTheme.of(context).colorTheme.textHighEmphasis, - ), - ), - SizedBox(height: 8.0), - Text( - AppLocalizations.of(context).photosOrVideosWillAppearHere, - textAlign: TextAlign.center, - style: TextStyle( - fontSize: 14.0, - color: StreamChatTheme.of(context) - .colorTheme - .textHighEmphasis - .withOpacity(0.5), - ), - ), - ], - ), - ); - } - - final media = <_AssetPackage>[]; - - for (var item in snapshot.data!) { - item.message.attachments - .where((e) => - (e.type == 'image' || e.type == 'video') && - e.ogScrapeUrl == null) - .forEach((e) { - VideoPlayerController? controller; - if (e.type == 'video') { - var cachedController = controllerCache[e.assetUrl]; - - if (cachedController == null) { - controller = VideoPlayerController.network(e.assetUrl!); - controller.initialize(); - controllerCache[e.assetUrl] = controller; - } else { - controller = cachedController; - } - } - media.add(_AssetPackage(e, item.message, controller)); - }); - } - - return LazyLoadScrollView( - onEndOfPage: () => messageSearchBloc.search( - filter: Filter.in_( - 'cid', - [StreamChannel.of(context).channel.cid!], - ), - messageFilter: Filter.in_( - 'attachments.type', - ['image', 'video'], - ), - sort: widget.sortOptions, - pagination: widget.paginationParams.copyWith( - offset: messageSearchBloc.messageResponses?.length ?? 0, - ), - ), - child: GridView.builder( - gridDelegate: - SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 3), - itemBuilder: (context, position) { - var channel = StreamChannel.of(context).channel; - return Padding( - padding: const EdgeInsets.all(1.0), - child: InkWell( - onTap: () { - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => StreamChannel( - channel: channel, - child: StreamFullScreenMedia( - mediaAttachmentPackages: media - .map( - (e) => StreamAttachmentPackage( - attachment: e.attachment, - message: e.message, - ), - ) - .toList(), - startIndex: position, - userName: media[position].message.user!.name, - onShowMessage: widget.onShowMessage, - ), + body: ValueListenableBuilder( + valueListenable: controller, + builder: (BuildContext context, + PagedValue value, Widget? child) { + return value.when( + (items, nextPageKey, error) { + if (items.isEmpty) { + return Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + StreamSvgIcon.pictures( + size: 136.0, + color: StreamChatTheme.of(context).colorTheme.disabled, + ), + SizedBox(height: 16.0), + Text( + AppLocalizations.of(context).noMedia, + style: TextStyle( + fontSize: 14.0, + color: StreamChatTheme.of(context) + .colorTheme + .textHighEmphasis, ), ), + SizedBox(height: 8.0), + Text( + AppLocalizations.of(context) + .photosOrVideosWillAppearHere, + textAlign: TextAlign.center, + style: TextStyle( + fontSize: 14.0, + color: StreamChatTheme.of(context) + .colorTheme + .textHighEmphasis + .withOpacity(0.5), + ), + ), + ], + ), + ); + } + final media = <_AssetPackage>[]; + + for (var item in value.asSuccess.items) { + item.message.attachments + .where((e) => + (e.type == 'image' || e.type == 'video') && + e.ogScrapeUrl == null) + .forEach((e) { + VideoPlayerController? controller; + if (e.type == 'video') { + var cachedController = controllerCache[e.assetUrl]; + + if (cachedController == null) { + controller = VideoPlayerController.network(e.assetUrl!); + controller.initialize(); + controllerCache[e.assetUrl] = controller; + } else { + controller = cachedController; + } + } + media.add(_AssetPackage(e, item.message, controller)); + }); + } + + return LazyLoadScrollView( + onEndOfPage: () async { + if (nextPageKey != null) { + controller.loadMore(nextPageKey); + } + }, + child: GridView.builder( + gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( + crossAxisCount: 3), + itemBuilder: (context, position) { + var channel = StreamChannel.of(context).channel; + return Padding( + padding: const EdgeInsets.all(1.0), + child: InkWell( + onTap: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => StreamChannel( + channel: channel, + child: StreamFullScreenMedia( + mediaAttachmentPackages: media + .map( + (e) => StreamAttachmentPackage( + attachment: e.attachment, + message: e.message, + ), + ) + .toList(), + startIndex: position, + userName: media[position].message.user!.name, + onShowMessage: (m, c) async { + final client = + StreamChat.of(context).client; + final message = m; + final channel = client.channel( + c.type, + id: c.id, + ); + if (channel.state == null) { + await channel.watch(); + } + Navigator.pushNamed( + context, + Routes.CHANNEL_PAGE, + arguments: ChannelPageArgs( + channel: channel, + initialMessage: message, + ), + ); + }, + ), + ), + ), + ); + }, + child: media[position].attachment.type == 'image' + ? IgnorePointer( + child: StreamImageAttachment( + attachment: media[position].attachment, + message: media[position].message, + showTitle: false, + size: Size( + MediaQuery.of(context).size.width * 0.8, + MediaQuery.of(context).size.height * 0.3, + ), + messageTheme: widget.messageTheme, + ), + ) + : VideoPlayer(media[position].videoPlayer!), + ), ); }, - child: media[position].attachment.type == 'image' - ? IgnorePointer( - child: StreamImageAttachment( - attachment: media[position].attachment, - message: media[position].message, - showTitle: false, - size: Size( - MediaQuery.of(context).size.width * 0.8, - MediaQuery.of(context).size.height * 0.3, - ), - messageTheme: widget.messageTheme, - ), - ) - : VideoPlayer(media[position].videoPlayer!), + itemCount: media.length, ), ); }, - itemCount: media.length, - ), - ); - }, - stream: messageSearchBloc.messagesStream, + loading: () => Center( + child: const CircularProgressIndicator(), + ), + error: (_) => Offstage(), + ); + }, + ), ); } @override void dispose() { + controller.dispose(); super.dispose(); - for (var c in controllerCache.values) { - c!.dispose(); - } + } + + @override + void initState() { + controller.doInitialLoad(); + super.initState(); } } diff --git a/packages/stream_chat_v1/lib/channel_page.dart b/packages/stream_chat_v1/lib/channel_page.dart index 6cf60e5..e2b2d42 100644 --- a/packages/stream_chat_v1/lib/channel_page.dart +++ b/packages/stream_chat_v1/lib/channel_page.dart @@ -35,7 +35,7 @@ class ChannelPage extends StatefulWidget { class _ChannelPageState extends State { FocusNode? _focusNode; - MessageInputController _messageInputController = MessageInputController(); + StreamMessageInputController _messageInputController = StreamMessageInputController(); @override void initState() { diff --git a/packages/stream_chat_v1/lib/chat_info_screen.dart b/packages/stream_chat_v1/lib/chat_info_screen.dart index 9556840..3860229 100644 --- a/packages/stream_chat_v1/lib/chat_info_screen.dart +++ b/packages/stream_chat_v1/lib/chat_info_screen.dart @@ -218,36 +218,7 @@ class _ChatInfoScreenState extends State { MaterialPageRoute( builder: (context) => StreamChannel( channel: channel, - child: MessageSearchBloc( - child: PinnedMessagesScreen( - messageTheme: widget.messageTheme, - sortOptions: [ - SortOption( - 'created_at', - direction: SortOption.ASC, - ), - ], - onShowMessage: (m, c) async { - final client = StreamChat.of(context).client; - final message = m; - final channel = client.channel( - c.type, - id: c.id, - ); - if (channel.state == null) { - await channel.watch(); - } - Navigator.pushNamed( - context, - Routes.CHANNEL_PAGE, - arguments: ChannelPageArgs( - channel: channel, - initialMessage: message, - ), - ); - }, - ), - ), + child: PinnedMessagesScreen(), ), ), ); @@ -278,35 +249,8 @@ class _ChatInfoScreenState extends State { MaterialPageRoute( builder: (context) => StreamChannel( channel: channel, - child: MessageSearchBloc( - child: ChannelMediaDisplayScreen( - messageTheme: widget.messageTheme, - sortOptions: [ - SortOption( - 'created_at', - direction: SortOption.ASC, - ), - ], - onShowMessage: (m, c) async { - final client = StreamChat.of(context).client; - final message = m; - final channel = client.channel( - c.type, - id: c.id, - ); - if (channel.state == null) { - await channel.watch(); - } - Navigator.pushNamed( - context, - Routes.CHANNEL_PAGE, - arguments: ChannelPageArgs( - channel: channel, - initialMessage: message, - ), - ); - }, - ), + child: ChannelMediaDisplayScreen( + messageTheme: widget.messageTheme, ), ), ), @@ -338,15 +282,8 @@ class _ChatInfoScreenState extends State { MaterialPageRoute( builder: (context) => StreamChannel( channel: channel, - child: MessageSearchBloc( - child: ChannelFileDisplayScreen( - sortOptions: [ - SortOption( - 'created_at', - direction: SortOption.ASC, - ), - ], - ), + child: ChannelFileDisplayScreen( + messageTheme: widget.messageTheme, ), ), ), diff --git a/packages/stream_chat_v1/lib/group_info_screen.dart b/packages/stream_chat_v1/lib/group_info_screen.dart index e650b07..bf5fec2 100644 --- a/packages/stream_chat_v1/lib/group_info_screen.dart +++ b/packages/stream_chat_v1/lib/group_info_screen.dart @@ -40,16 +40,52 @@ class _GroupInfoScreenState extends State { ValueNotifier mutedBool = ValueNotifier(false); + late final channel = StreamChannel.of(context).channel; + + late final userListController = StreamUserListController( + client: StreamChat.of(context).client, + limit: 25, + filter: Filter.and( + [ + if (_searchController!.text.isNotEmpty) + Filter.autoComplete('name', _userNameQuery), + Filter.notIn('id', [ + StreamChat.of(context).currentUser!.id, + ...channel.state!.members + .map(((e) => e.userId)) + .whereType(), + ]), + ], + ), + sort: [ + SortOption( + 'name', + direction: 1, + ), + ], + ); + void _userNameListener() { if (_searchController!.text == _userNameQuery) { return; } if (_debounce?.isActive ?? false) _debounce!.cancel(); _debounce = Timer(const Duration(milliseconds: 350), () { - if (mounted && modalSetStateCallback != null) { - modalSetStateCallback!(() { - _userNameQuery = _searchController!.text; - }); + if (mounted) { + _userNameQuery = _searchController!.text; + userListController.filter = Filter.and( + [ + if (_searchController!.text.isNotEmpty) + Filter.autoComplete('name', _userNameQuery), + Filter.notIn('id', [ + StreamChat.of(context).currentUser!.id, + ...channel.state!.members + .map(((e) => e.userId)) + .whereType(), + ]), + ], + ); + userListController.doInitialLoad(); } }); } @@ -57,25 +93,28 @@ class _GroupInfoScreenState extends State { @override void initState() { super.initState(); - var channel = StreamChannel.of(context); + _nameController = TextEditingController.fromValue( - TextEditingValue( - text: (channel.channel.extraData['name'] as String?) ?? ''), + TextEditingValue(text: (channel.extraData['name'] as String?) ?? ''), ); _searchController = TextEditingController()..addListener(_userNameListener); _nameController!.addListener(() { setState(() {}); }); - mutedBool = ValueNotifier(StreamChannel.of(context).channel.isMuted); + mutedBool = ValueNotifier(channel.isMuted); + } + + @override + void dispose() { + userListController.dispose(); + super.dispose(); } @override Widget build(BuildContext context) { - var channel = StreamChannel.of(context); - return StreamBuilder>( - stream: channel.channel.state!.membersStream, + stream: channel.state!.membersStream, builder: (context, snapshot) { if (!snapshot.hasData) { return Container( @@ -94,7 +133,7 @@ class _GroupInfoScreenState extends State { title: Column( children: [ StreamBuilder( - stream: channel.channelStateStream, + stream: channel.state?.channelStateStream, builder: (context, state) { if (!state.hasData) { return Text( @@ -131,7 +170,7 @@ class _GroupInfoScreenState extends State { height: 3.0, ), Text( - '${channel.channel.memberCount} ${AppLocalizations.of(context).members}, ${snapshot.data?.where((e) => e.user!.online).length ?? 0} ${AppLocalizations.of(context).online}', + '${channel.memberCount} ${AppLocalizations.of(context).members}, ${snapshot.data?.where((e) => e.user!.online).length ?? 0} ${AppLocalizations.of(context).online}', style: TextStyle( color: StreamChatTheme.of(context) .colorTheme @@ -144,7 +183,7 @@ class _GroupInfoScreenState extends State { ), centerTitle: true, actions: [ - if (channel.channel.ownCapabilities + if (channel.ownCapabilities .contains(PermissionType.updateChannelMembers)) StreamNeumorphicButton( child: InkWell( @@ -169,7 +208,7 @@ class _GroupInfoScreenState extends State { height: 8.0, color: StreamChatTheme.of(context).colorTheme.disabled, ), - if (channel.channel.ownCapabilities + if (channel.ownCapabilities .contains(PermissionType.updateChannel)) _buildNameTile(), _buildOptionListTiles(), @@ -336,7 +375,6 @@ class _GroupInfoScreenState extends State { } Widget _buildNameTile() { - var channel = StreamChannel.of(context).channel; var channelName = (channel.extraData['name'] as String?) ?? ''; return Material( @@ -412,7 +450,7 @@ class _GroupInfoScreenState extends State { size: 24.0, ), onTap: () { - StreamChannel.of(context).channel.update({ + channel.update({ 'name': _nameController!.text.trim(), }).catchError((err) { setState(() { @@ -432,8 +470,6 @@ class _GroupInfoScreenState extends State { } Widget _buildOptionListTiles() { - var channel = StreamChannel.of(context); - return Column( children: [ // OptionListTile( @@ -448,10 +484,9 @@ class _GroupInfoScreenState extends State { // ), // onTap: () {}, // ), - if (channel.channel.ownCapabilities - .contains(PermissionType.muteChannel)) + if (channel.ownCapabilities.contains(PermissionType.muteChannel)) StreamBuilder( - stream: StreamChannel.of(context).channel.isMutedStream, + stream: channel.isMutedStream, builder: (context, snapshot) { mutedBool.value = snapshot.data; @@ -482,9 +517,9 @@ class _GroupInfoScreenState extends State { mutedBool.value = val; if (snapshot.data!) { - channel.channel.unmute(); + channel.unmute(); } else { - channel.channel.mute(); + channel.mute(); } }, ); @@ -517,36 +552,7 @@ class _GroupInfoScreenState extends State { MaterialPageRoute( builder: (context) => StreamChannel( channel: channel, - child: MessageSearchBloc( - child: PinnedMessagesScreen( - messageTheme: widget.messageTheme, - sortOptions: [ - SortOption( - 'created_at', - direction: SortOption.ASC, - ), - ], - onShowMessage: (m, c) async { - final client = StreamChat.of(context).client; - final message = m; - final channel = client.channel( - c.type, - id: c.id, - ); - if (channel.state == null) { - await channel.watch(); - } - Navigator.pushNamed( - context, - Routes.CHANNEL_PAGE, - arguments: ChannelPageArgs( - channel: channel, - initialMessage: message, - ), - ); - }, - ), - ), + child: PinnedMessagesScreen(), ), ), ); @@ -578,36 +584,8 @@ class _GroupInfoScreenState extends State { MaterialPageRoute( builder: (context) => StreamChannel( channel: channel, - child: MessageSearchBloc( - child: ChannelMediaDisplayScreen( - messageTheme: widget.messageTheme, - sortOptions: [ - SortOption( - 'created_at', - direction: SortOption.ASC, - ), - ], - paginationParams: PaginationParams(limit: 20), - onShowMessage: (m, c) async { - final client = StreamChat.of(context).client; - final message = m; - final channel = client.channel( - c.type, - id: c.id, - ); - if (channel.state == null) { - await channel.watch(); - } - await Navigator.pushNamed( - context, - Routes.CHANNEL_PAGE, - arguments: ChannelPageArgs( - channel: channel, - initialMessage: message, - ), - ); - }, - ), + child: ChannelMediaDisplayScreen( + messageTheme: widget.messageTheme, ), ), ), @@ -640,25 +618,16 @@ class _GroupInfoScreenState extends State { MaterialPageRoute( builder: (context) => StreamChannel( channel: channel, - child: MessageSearchBloc( - child: ChannelFileDisplayScreen( - sortOptions: [ - SortOption( - 'created_at', - direction: SortOption.ASC, - ), - ], - paginationParams: PaginationParams(limit: 20), - ), + child: ChannelFileDisplayScreen( + messageTheme: widget.messageTheme, ), ), ), ); }, ), - if (!channel.channel.isDistinct && - channel.channel.ownCapabilities - .contains(PermissionType.leaveChannel)) + if (!channel.isDistinct && + channel.ownCapabilities.contains(PermissionType.leaveChannel)) StreamOptionListTile( tileColor: StreamChatTheme.of(context).colorTheme.appBg, separatorColor: StreamChatTheme.of(context).colorTheme.disabled, @@ -703,106 +672,81 @@ class _GroupInfoScreenState extends State { } void _buildAddUserModal(context) { - var channel = StreamChannel.of(context).channel; - final userListController = StreamUserListController( - client: channel.client, - limit: 25, - filter: Filter.and( - [ - if (_searchController!.text.isNotEmpty) - Filter.autoComplete('name', _userNameQuery), - Filter.notIn('id', [ - StreamChat.of(context).currentUser!.id, - ...channel.state!.members - .map(((e) => e.userId)) - .whereType(), - ]), - ], - ), - sort: [ - SortOption( - 'name', - direction: 1, - ), - ], - ); - showDialog( useRootNavigator: false, context: context, barrierColor: StreamChatTheme.of(context).colorTheme.overlay, builder: (context) { - return StatefulBuilder(builder: (context, modalSetState) { - modalSetStateCallback = modalSetState; - return Padding( - padding: EdgeInsets.only(top: 16.0, left: 8.0, right: 8.0), - child: Material( - borderRadius: BorderRadius.only( - topLeft: Radius.circular(16.0), - topRight: Radius.circular(16.0), - ), - clipBehavior: Clip.antiAlias, - child: Scaffold( - body: Column( - children: [ - Padding( - padding: const EdgeInsets.all(16), - child: _buildTextInputSection(modalSetState), - ), - Expanded( - child: StreamUserListView( - controller: userListController, - onUserTap: (user) async { - _searchController!.clear(); + return Padding( + padding: EdgeInsets.only(top: 16.0, left: 8.0, right: 8.0), + child: Material( + borderRadius: BorderRadius.only( + topLeft: Radius.circular(16.0), + topRight: Radius.circular(16.0), + ), + clipBehavior: Clip.antiAlias, + child: Scaffold( + body: Column( + children: [ + Padding( + padding: const EdgeInsets.all(16), + child: _buildTextInputSection(), + ), + Expanded( + child: StreamUserGridView( + controller: userListController, + onUserTap: (user) async { + _searchController!.clear(); - await channel.addMembers([user.id]); - Navigator.pop(context); - setState(() {}); - }, - emptyBuilder: (_) { - return LayoutBuilder( - builder: (context, viewportConstraints) { - return SingleChildScrollView( - physics: AlwaysScrollableScrollPhysics(), - child: ConstrainedBox( - constraints: BoxConstraints( - minHeight: viewportConstraints.maxHeight, - ), - child: Center( - child: Column( - children: [ - Padding( - padding: const EdgeInsets.all(24), - child: StreamSvgIcon.search( - size: 96, - color: StreamChatTheme.of(context) - .colorTheme - .textLowEmphasis, - ), + await channel.addMembers([user.id]); + Navigator.pop(context); + setState(() {}); + }, + emptyBuilder: (_) { + return LayoutBuilder( + builder: (context, viewportConstraints) { + return SingleChildScrollView( + physics: AlwaysScrollableScrollPhysics(), + child: ConstrainedBox( + constraints: BoxConstraints( + minHeight: viewportConstraints.maxHeight, + ), + child: Center( + child: Column( + children: [ + Padding( + padding: const EdgeInsets.all(24), + child: StreamSvgIcon.search( + size: 96, + color: StreamChatTheme.of(context) + .colorTheme + .textLowEmphasis, ), - Text(AppLocalizations.of(context) - .noUserMatchesTheseKeywords), - ], - ), + ), + Text(AppLocalizations.of(context) + .noUserMatchesTheseKeywords), + ], ), ), - ); - }, - ); - }, - ), + ), + ); + }, + ); + }, ), - ], - ), + ), + ], ), ), - ); - }); + ), + ); }, - ).then((_) => userListController.dispose()); + ).whenComplete(() { + _searchController?.clear(); + }); } - Widget _buildTextInputSection(modalSetState) { + Widget _buildTextInputSection() { final theme = StreamChatTheme.of(context); return Column( children: [ @@ -862,7 +806,6 @@ class _GroupInfoScreenState extends State { } void _showUserInfoModal(User? user, bool isUserAdmin) { - var channel = StreamChannel.of(context).channel; final color = StreamChatTheme.of(context).colorTheme.barsBg; showModalBottomSheet( diff --git a/packages/stream_chat_v1/lib/pinned_messages_screen.dart b/packages/stream_chat_v1/lib/pinned_messages_screen.dart index 6c2eaec..7ab6d98 100644 --- a/packages/stream_chat_v1/lib/pinned_messages_screen.dart +++ b/packages/stream_chat_v1/lib/pinned_messages_screen.dart @@ -1,60 +1,34 @@ import 'package:example/localizations.dart'; +import 'package:example/routes/routes.dart'; import 'package:flutter/material.dart'; import 'package:stream_chat_flutter/stream_chat_flutter.dart'; -import 'package:video_player/video_player.dart'; + +import 'channel_page.dart'; class PinnedMessagesScreen extends StatefulWidget { - /// The sorting used for the channels matching the filters. - /// Sorting is based on field and direction, multiple sorting options can be provided. - /// You can sort based on last_updated, last_message_at, updated_at, created_at or member_count. - /// Direction can be ascending or descending. - final List? sortOptions; - - /// Pagination parameters - /// limit: the number of users to return (max is 30) - /// offset: the offset (max is 1000) - /// message_limit: how many messages should be included to each channel - final PaginationParams paginationParams; - - /// The builder used when the file list is empty. - final WidgetBuilder? emptyBuilder; - - final ShowMessageCallback? onShowMessage; - - final StreamMessageThemeData messageTheme; - - const PinnedMessagesScreen({ - required this.messageTheme, - this.sortOptions, - this.paginationParams = const PaginationParams(limit: 20), - this.emptyBuilder, - this.onShowMessage, - }); - @override - _PinnedMessagesScreenState createState() => _PinnedMessagesScreenState(); + State createState() => _PinnedMessagesScreenState(); } class _PinnedMessagesScreenState extends State { - Map controllerCache = {}; - - @override - void initState() { - super.initState(); - final messageSearchBloc = MessageSearchBloc.of(context); - messageSearchBloc.search( - filter: Filter.in_( - 'cid', - [StreamChannel.of(context).channel.cid!], + late final controller = StreamMessageSearchListController( + client: StreamChat.of(context).client, + filter: Filter.in_( + 'cid', + [StreamChannel.of(context).channel.cid!], + ), + messageFilter: Filter.equal( + 'pinned', + true, + ), + sort: [ + SortOption( + 'created_at', + direction: SortOption.ASC, ), - messageFilter: Filter.equal( - 'pinned', - true, - ), - sort: widget.sortOptions, - pagination: widget.paginationParams, - ); - } + ], + limit: 20, + ); @override Widget build(BuildContext context) { @@ -73,25 +47,9 @@ class _PinnedMessagesScreenState extends State { leading: StreamBackButton(), backgroundColor: StreamChatTheme.of(context).colorTheme.barsBg, ), - body: _buildMediaGrid(), - ); - } - - Widget _buildMediaGrid() { - final messageSearchBloc = MessageSearchBloc.of(context); - - return StreamBuilder>( - builder: (context, snapshot) { - if (snapshot.data == null) { - return Center( - child: const CircularProgressIndicator(), - ); - } - - if (snapshot.data!.isEmpty) { - if (widget.emptyBuilder != null) { - return widget.emptyBuilder!(context); - } + body: StreamMessageSearchListView( + controller: controller, + emptyBuilder: (_) { return Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, @@ -140,74 +98,33 @@ class _PinnedMessagesScreenState extends State { ], ), ); - } - - var data = snapshot.data ?? []; - - return LazyLoadScrollView( - onEndOfPage: () => messageSearchBloc.search( - filter: Filter.in_( - 'cid', - [StreamChannel.of(context).channel.cid!], + }, + onMessageTap: (messageResponse) async { + final client = StreamChat.of(context).client; + final message = messageResponse.message; + final channel = client.channel( + messageResponse.channel!.type, + id: messageResponse.channel!.id, + ); + if (channel.state == null) { + await channel.watch(); + } + Navigator.pushNamed( + context, + Routes.CHANNEL_PAGE, + arguments: ChannelPageArgs( + channel: channel, + initialMessage: message, ), - messageFilter: Filter.equal( - 'pinned', - true, - ), - sort: widget.sortOptions, - pagination: widget.paginationParams.copyWith( - offset: messageSearchBloc.messageResponses?.length ?? 0, - ), - ), - child: ListView.builder( - itemBuilder: (context, position) { - var user = data[position].message.user!; - var attachments = data[position].message.attachments; - var text = data[position].message.text ?? ''; - - return ListTile( - leading: StreamUserAvatar( - user: user, - constraints: BoxConstraints.tightFor( - width: 40.0, - height: 40.0, - ), - borderRadius: BorderRadius.circular(28), - ), - title: Text( - user.name, - style: TextStyle( - color: StreamChatTheme.of(context) - .colorTheme - .textHighEmphasis, - fontWeight: FontWeight.bold), - ), - subtitle: Text( - text != '' - ? text - : (attachments.isNotEmpty - ? '${attachments.length} ${attachments.length > 1 ? AppLocalizations.of(context).attachments : AppLocalizations.of(context).attachment}' - : ''), - ), - onTap: () { - widget.onShowMessage?.call(data[position].message, - StreamChannel.of(context).channel); - }, - ); - }, - itemCount: snapshot.data!.length, - ), - ); - }, - stream: messageSearchBloc.messagesStream, + ); + }, + ), ); } @override void dispose() { + controller.dispose(); super.dispose(); - for (var c in controllerCache.values) { - c!.dispose(); - } } } diff --git a/packages/stream_chat_v1/lib/thread_page.dart b/packages/stream_chat_v1/lib/thread_page.dart index 6ffd5e3..3983cb7 100644 --- a/packages/stream_chat_v1/lib/thread_page.dart +++ b/packages/stream_chat_v1/lib/thread_page.dart @@ -19,12 +19,13 @@ class ThreadPage extends StatefulWidget { class _ThreadPageState extends State { FocusNode _focusNode = FocusNode(); - late MessageInputController _messageInputController; + late StreamMessageInputController _messageInputController; @override void initState() { super.initState(); - _messageInputController = MessageInputController(message: widget.parent); + _messageInputController = + StreamMessageInputController(message: widget.parent); } @override From f708020e35f306d591854055ca6f360da8b369b6 Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Fri, 29 Apr 2022 15:27:02 +0200 Subject: [PATCH 9/9] fix analysis --- packages/stream_chat_v1/lib/channel_file_display_screen.dart | 3 --- packages/stream_chat_v1/lib/chat_info_screen.dart | 2 -- packages/stream_chat_v1/lib/group_info_screen.dart | 1 - packages/stream_chat_v1/lib/routes/app_routes.dart | 2 +- 4 files changed, 1 insertion(+), 7 deletions(-) diff --git a/packages/stream_chat_v1/lib/channel_file_display_screen.dart b/packages/stream_chat_v1/lib/channel_file_display_screen.dart index 8806f97..e7be692 100644 --- a/packages/stream_chat_v1/lib/channel_file_display_screen.dart +++ b/packages/stream_chat_v1/lib/channel_file_display_screen.dart @@ -1,11 +1,8 @@ import 'package:example/localizations.dart'; -import 'package:example/routes/routes.dart'; import 'package:flutter/material.dart'; import 'package:stream_chat_flutter/stream_chat_flutter.dart'; import 'package:video_player/video_player.dart'; -import 'channel_page.dart'; - class ChannelFileDisplayScreen extends StatefulWidget { final StreamMessageThemeData messageTheme; diff --git a/packages/stream_chat_v1/lib/chat_info_screen.dart b/packages/stream_chat_v1/lib/chat_info_screen.dart index 3860229..731050d 100644 --- a/packages/stream_chat_v1/lib/chat_info_screen.dart +++ b/packages/stream_chat_v1/lib/chat_info_screen.dart @@ -5,9 +5,7 @@ import 'package:stream_chat_flutter/stream_chat_flutter.dart'; import 'channel_file_display_screen.dart'; import 'channel_media_display_screen.dart'; -import 'channel_page.dart'; import 'pinned_messages_screen.dart'; -import 'routes/routes.dart'; /// Detail screen for a 1:1 chat correspondence class ChatInfoScreen extends StatefulWidget { diff --git a/packages/stream_chat_v1/lib/group_info_screen.dart b/packages/stream_chat_v1/lib/group_info_screen.dart index bf5fec2..529c0a4 100644 --- a/packages/stream_chat_v1/lib/group_info_screen.dart +++ b/packages/stream_chat_v1/lib/group_info_screen.dart @@ -11,7 +11,6 @@ import 'channel_media_display_screen.dart'; import 'channel_page.dart'; import 'chat_info_screen.dart'; import 'pinned_messages_screen.dart'; -import 'routes/routes.dart'; class GroupInfoScreen extends StatefulWidget { final StreamMessageThemeData messageTheme; diff --git a/packages/stream_chat_v1/lib/routes/app_routes.dart b/packages/stream_chat_v1/lib/routes/app_routes.dart index 78593c4..4f913b4 100644 --- a/packages/stream_chat_v1/lib/routes/app_routes.dart +++ b/packages/stream_chat_v1/lib/routes/app_routes.dart @@ -1,4 +1,4 @@ -import 'package:collection/src/iterable_extensions.dart'; +import 'package:collection/collection.dart'; import 'package:example/channel_list_page.dart'; import 'package:flutter/material.dart'; import 'package:stream_chat_flutter/stream_chat_flutter.dart';