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: