added mip changes, capabilities changes

This commit is contained in:
Deven Joshi
2022-01-06 18:34:50 +05:30
parent b59482d310
commit 3edbfc9447
4 changed files with 66 additions and 61 deletions
@@ -34,8 +34,8 @@ class ChannelPage extends StatefulWidget {
} }
class _ChannelPageState extends State<ChannelPage> { class _ChannelPageState extends State<ChannelPage> {
Message? _quotedMessage;
FocusNode? _focusNode; FocusNode? _focusNode;
MessageInputController _messageInputController = MessageInputController();
@override @override
void initState() { void initState() {
@@ -50,7 +50,7 @@ class _ChannelPageState extends State<ChannelPage> {
} }
void _reply(Message message) { void _reply(Message message) {
setState(() => _quotedMessage = message); _messageInputController.quotedMessage = message;
WidgetsBinding.instance!.addPostFrameCallback((timeStamp) { WidgetsBinding.instance!.addPostFrameCallback((timeStamp) {
_focusNode!.requestFocus(); _focusNode!.requestFocus();
}); });
@@ -144,7 +144,6 @@ class _ChannelPageState extends State<ChannelPage> {
threadBuilder: (_, parentMessage) { threadBuilder: (_, parentMessage) {
return ThreadPage(parent: parentMessage!); return ThreadPage(parent: parentMessage!);
}, },
pinPermissions: ['owner', 'admin', 'member'],
), ),
Positioned( Positioned(
bottom: 0, bottom: 0,
@@ -177,11 +176,7 @@ class _ChannelPageState extends State<ChannelPage> {
), ),
MessageInput( MessageInput(
focusNode: _focusNode, focusNode: _focusNode,
quotedMessage: _quotedMessage, messageInputController: _messageInputController,
onQuotedMessageCleared: () {
setState(() => _quotedMessage = null);
_focusNode!.unfocus();
},
), ),
], ],
), ),
@@ -150,7 +150,10 @@ class _GroupInfoScreenState extends State<GroupInfoScreen> {
), ),
centerTitle: true, centerTitle: true,
actions: [ actions: [
if (!channel.channel.isDistinct && isOwner) if (!channel.channel.isDistinct &&
isOwner &&
channel.channel.ownCapabilities
.contains(PermissionType.updateChannelMembers))
StreamNeumorphicButton( StreamNeumorphicButton(
child: InkWell( child: InkWell(
onTap: () { onTap: () {
@@ -365,6 +368,8 @@ class _GroupInfoScreenState extends State<GroupInfoScreen> {
), ),
Expanded( Expanded(
child: TextField( child: TextField(
enabled: channel.ownCapabilities
.contains(PermissionType.updateChannel),
focusNode: _focusNode, focusNode: _focusNode,
controller: _nameController, controller: _nameController,
cursorColor: cursorColor:
@@ -449,47 +454,50 @@ class _GroupInfoScreenState extends State<GroupInfoScreen> {
// ), // ),
// onTap: () {}, // onTap: () {},
// ), // ),
StreamBuilder<bool>( if (channel.channel.ownCapabilities
stream: StreamChannel.of(context).channel.isMutedStream, .contains(PermissionType.muteChannel))
builder: (context, snapshot) { StreamBuilder<bool>(
mutedBool.value = snapshot.data; stream: StreamChannel.of(context).channel.isMutedStream,
builder: (context, snapshot) {
mutedBool.value = snapshot.data;
return OptionListTile( return OptionListTile(
tileColor: StreamChatTheme.of(context).colorTheme.appBg, tileColor: StreamChatTheme.of(context).colorTheme.appBg,
separatorColor: StreamChatTheme.of(context).colorTheme.disabled, separatorColor:
title: AppLocalizations.of(context).muteGroup, StreamChatTheme.of(context).colorTheme.disabled,
titleTextStyle: StreamChatTheme.of(context).textTheme.body, title: AppLocalizations.of(context).muteGroup,
leading: Padding( titleTextStyle: StreamChatTheme.of(context).textTheme.body,
padding: const EdgeInsets.symmetric(horizontal: 16.0), leading: Padding(
child: StreamSvgIcon.mute( padding: const EdgeInsets.symmetric(horizontal: 16.0),
size: 24.0, child: StreamSvgIcon.mute(
color: StreamChatTheme.of(context) size: 24.0,
.colorTheme color: StreamChatTheme.of(context)
.textHighEmphasis .colorTheme
.withOpacity(0.5), .textHighEmphasis
.withOpacity(0.5),
),
), ),
), trailing: snapshot.data == null
trailing: snapshot.data == null ? CircularProgressIndicator()
? CircularProgressIndicator() : ValueListenableBuilder<bool?>(
: ValueListenableBuilder<bool?>( valueListenable: mutedBool,
valueListenable: mutedBool, builder: (context, value, _) {
builder: (context, value, _) { return CupertinoSwitch(
return CupertinoSwitch( value: value!,
value: value!, onChanged: (val) {
onChanged: (val) { mutedBool.value = val;
mutedBool.value = val;
if (snapshot.data!) { if (snapshot.data!) {
channel.channel.unmute(); channel.channel.unmute();
} else { } else {
channel.channel.mute(); channel.channel.mute();
} }
}, },
); );
}), }),
onTap: () {}, onTap: () {},
); );
}), }),
OptionListTile( OptionListTile(
title: AppLocalizations.of(context).pinnedMessages, title: AppLocalizations.of(context).pinnedMessages,
tileColor: StreamChatTheme.of(context).colorTheme.appBg, tileColor: StreamChatTheme.of(context).colorTheme.appBg,
@@ -654,7 +662,9 @@ class _GroupInfoScreenState extends State<GroupInfoScreen> {
); );
}, },
), ),
if (!channel.channel.isDistinct) if (!channel.channel.isDistinct &&
channel.channel.ownCapabilities
.contains(PermissionType.leaveChannel))
OptionListTile( OptionListTile(
tileColor: StreamChatTheme.of(context).colorTheme.appBg, tileColor: StreamChatTheme.of(context).colorTheme.appBg,
separatorColor: StreamChatTheme.of(context).colorTheme.disabled, separatorColor: StreamChatTheme.of(context).colorTheme.disabled,
+9 -9
View File
@@ -18,8 +18,14 @@ class ThreadPage extends StatefulWidget {
} }
class _ThreadPageState extends State<ThreadPage> { class _ThreadPageState extends State<ThreadPage> {
Message? _quotedMessage;
FocusNode _focusNode = FocusNode(); FocusNode _focusNode = FocusNode();
late MessageInputController _messageInputController;
@override
void initState() {
super.initState();
_messageInputController = MessageInputController(message: widget.parent);
}
@override @override
void dispose() { void dispose() {
@@ -28,7 +34,7 @@ class _ThreadPageState extends State<ThreadPage> {
} }
void _reply(Message message) { void _reply(Message message) {
setState(() => _quotedMessage = message); _messageInputController.quotedMessage = message;
WidgetsBinding.instance!.addPostFrameCallback((timeStamp) { WidgetsBinding.instance!.addPostFrameCallback((timeStamp) {
_focusNode.requestFocus(); _focusNode.requestFocus();
}); });
@@ -60,18 +66,12 @@ class _ThreadPageState extends State<ThreadPage> {
}, },
); );
}, },
pinPermissions: ['owner', 'admin', 'member'],
), ),
), ),
if (widget.parent.type != 'deleted') if (widget.parent.type != 'deleted')
MessageInput( MessageInput(
parentMessage: widget.parent,
focusNode: _focusNode, focusNode: _focusNode,
quotedMessage: _quotedMessage, messageInputController: _messageInputController,
onQuotedMessageCleared: () {
setState(() => _quotedMessage = null);
_focusNode.unfocus();
},
), ),
], ],
), ),
+4 -4
View File
@@ -23,7 +23,7 @@ dependencies:
stream_chat_localizations: stream_chat_localizations:
git: git:
url: https://github.com/GetStream/stream-chat-flutter.git url: https://github.com/GetStream/stream-chat-flutter.git
ref: develop ref: feat/capabilities
path: packages/stream_chat_localizations path: packages/stream_chat_localizations
flutter_local_notifications: ^9.0.0 flutter_local_notifications: ^9.0.0
flutter_svg: ^0.23.0 flutter_svg: ^0.23.0
@@ -42,17 +42,17 @@ dependency_overrides:
stream_chat: stream_chat:
git: git:
url: https://github.com/GetStream/stream-chat-flutter.git url: https://github.com/GetStream/stream-chat-flutter.git
ref: develop ref: feat/capabilities
path: packages/stream_chat path: packages/stream_chat
stream_chat_flutter_core: stream_chat_flutter_core:
git: git:
url: https://github.com/GetStream/stream-chat-flutter.git url: https://github.com/GetStream/stream-chat-flutter.git
ref: develop ref: feat/capabilities
path: packages/stream_chat_flutter_core path: packages/stream_chat_flutter_core
stream_chat_flutter: stream_chat_flutter:
git: git:
url: https://github.com/GetStream/stream-chat-flutter.git url: https://github.com/GetStream/stream-chat-flutter.git
ref: develop ref: feat/capabilities
path: packages/stream_chat_flutter path: packages/stream_chat_flutter
flutter: flutter: