From 3edbfc944776b758f2fc89f29ed4957804598684 Mon Sep 17 00:00:00 2001 From: Deven Joshi Date: Thu, 6 Jan 2022 18:34:50 +0530 Subject: [PATCH 1/2] 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/2] 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(), ], ),