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> {
Message? _quotedMessage;
FocusNode? _focusNode;
MessageInputController _messageInputController = MessageInputController();
@override
void initState() {
@@ -50,7 +50,7 @@ class _ChannelPageState extends State<ChannelPage> {
}
void _reply(Message message) {
setState(() => _quotedMessage = message);
_messageInputController.quotedMessage = message;
WidgetsBinding.instance!.addPostFrameCallback((timeStamp) {
_focusNode!.requestFocus();
});
@@ -144,7 +144,6 @@ class _ChannelPageState extends State<ChannelPage> {
threadBuilder: (_, parentMessage) {
return ThreadPage(parent: parentMessage!);
},
pinPermissions: ['owner', 'admin', 'member'],
),
Positioned(
bottom: 0,
@@ -177,11 +176,7 @@ class _ChannelPageState extends State<ChannelPage> {
),
MessageInput(
focusNode: _focusNode,
quotedMessage: _quotedMessage,
onQuotedMessageCleared: () {
setState(() => _quotedMessage = null);
_focusNode!.unfocus();
},
messageInputController: _messageInputController,
),
],
),
@@ -150,7 +150,10 @@ class _GroupInfoScreenState extends State<GroupInfoScreen> {
),
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<GroupInfoScreen> {
),
Expanded(
child: TextField(
enabled: channel.ownCapabilities
.contains(PermissionType.updateChannel),
focusNode: _focusNode,
controller: _nameController,
cursorColor:
@@ -449,47 +454,50 @@ class _GroupInfoScreenState extends State<GroupInfoScreen> {
// ),
// onTap: () {},
// ),
StreamBuilder<bool>(
stream: StreamChannel.of(context).channel.isMutedStream,
builder: (context, snapshot) {
mutedBool.value = snapshot.data;
if (channel.channel.ownCapabilities
.contains(PermissionType.muteChannel))
StreamBuilder<bool>(
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<bool?>(
valueListenable: mutedBool,
builder: (context, value, _) {
return CupertinoSwitch(
value: value!,
onChanged: (val) {
mutedBool.value = val;
trailing: snapshot.data == null
? CircularProgressIndicator()
: ValueListenableBuilder<bool?>(
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<GroupInfoScreen> {
);
},
),
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,
+9 -9
View File
@@ -18,8 +18,14 @@ class ThreadPage extends StatefulWidget {
}
class _ThreadPageState extends State<ThreadPage> {
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<ThreadPage> {
}
void _reply(Message message) {
setState(() => _quotedMessage = message);
_messageInputController.quotedMessage = message;
WidgetsBinding.instance!.addPostFrameCallback((timeStamp) {
_focusNode.requestFocus();
});
@@ -60,18 +66,12 @@ class _ThreadPageState extends State<ThreadPage> {
},
);
},
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,
),
],
),
+4 -4
View File
@@ -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: