added docs and reactions modal
This commit is contained in:
@@ -1,37 +1,81 @@
|
|||||||
|
/// Describes capabilities of a user vis-a-vis a channel
|
||||||
class PermissionType {
|
class PermissionType {
|
||||||
static const String sendMessage = "send-message";
|
/// Capability required to send a message in the channel
|
||||||
|
/// Channel is not frozen (or user has UseFrozenChannel permission)
|
||||||
|
/// and user has CreateMessage permission.
|
||||||
|
static const String sendMessage = 'send-message';
|
||||||
|
|
||||||
static const String sendReaction = "send-reaction";
|
/// Capability required to send a message
|
||||||
|
/// Reactions are enabled for the channel, channel is not frozen
|
||||||
|
/// (or user has UseFrozenChannel permission) and user has
|
||||||
|
/// CreateReaction permission
|
||||||
|
static const String sendReaction = 'send-reaction';
|
||||||
|
|
||||||
static const String sendLinks = "send-links";
|
/// Capability required to send links in a channel
|
||||||
|
/// send-message + user has AddLinks permission
|
||||||
|
static const String sendLinks = 'send-links';
|
||||||
|
|
||||||
static const String sendReply = "send-reply";
|
/// Capability required to send thread reply
|
||||||
|
/// send-message + channel has replies enabled
|
||||||
|
static const String sendReply = 'send-reply';
|
||||||
|
|
||||||
static const String freezeChannel = "freeze-channel";
|
/// Capability to freeze a channel
|
||||||
|
/// User has UpdateChannelFrozen permission.
|
||||||
|
/// The name implies freezing,
|
||||||
|
/// but unfreezing is also allowed when this capability is present
|
||||||
|
static const String freezeChannel = 'freeze-channel';
|
||||||
|
|
||||||
static const String setChannelCooldown = "set-channel-cooldown";
|
/// User has UpdateChannelCooldown permission.
|
||||||
|
/// Allows to enable/disable slow mode in the channel
|
||||||
|
static const String setChannelCooldown = 'set-channel-cooldown';
|
||||||
|
|
||||||
static const String leaveChannel = "leave-channel";
|
/// User has RemoveOwnChannelMembership or UpdateChannelMembers permission
|
||||||
|
static const String leaveChannel = 'leave-channel';
|
||||||
|
|
||||||
static const String pinMessage = "pin-message";
|
/// Capability required to pin a message in a channel
|
||||||
|
/// Corresponds to PinMessage permission
|
||||||
|
static const String pinMessage = 'pin-message';
|
||||||
|
|
||||||
static const String deleteAnyMessage = "delete-any-message";
|
/// User has ability to delete any message in the channel
|
||||||
|
/// User has DeleteMessage permission
|
||||||
|
/// which applies to any message in the channel
|
||||||
|
static const String deleteAnyMessage = 'delete-any-message';
|
||||||
|
|
||||||
static const String deleteOwnMessage = "delete-own-message";
|
/// User has ability to delete their own message in the channel
|
||||||
|
/// User has DeleteMessage permission which applies only to owned messages
|
||||||
|
static const String deleteOwnMessage = 'delete-own-message';
|
||||||
|
|
||||||
static const String updateAnyMessage = "update-any-message";
|
/// User has ability to update/edit any message in the channel
|
||||||
|
/// User has UpdateMessage permission which
|
||||||
|
/// applies to any message in the channel
|
||||||
|
static const String updateAnyMessage = 'update-any-message';
|
||||||
|
|
||||||
static const String updateOwnMessage = "update-own-message";
|
/// User has ability to update/edit their own message in the channel
|
||||||
|
/// User has UpdateMessage permission which applies only to owned messages
|
||||||
|
static const String updateOwnMessage = 'update-own-message';
|
||||||
|
|
||||||
static const String searchMessages = "search-messages";
|
/// User can search for message in a channel
|
||||||
|
/// Search feature is enabled (it will also have
|
||||||
|
/// permission check in the future)
|
||||||
|
static const String searchMessages = 'search-messages';
|
||||||
|
|
||||||
static const String sendTypingEvents = "send-typing-events";
|
/// Capability required to send typing events in a channel
|
||||||
|
/// (Typing events are enabled)
|
||||||
|
static const String sendTypingEvents = 'send-typing-events';
|
||||||
|
|
||||||
static const String uploadFile = "upload-file";
|
/// Capability required to upload a file in a channel
|
||||||
|
/// Uploads are enabled and user has UploadAttachment
|
||||||
|
static const String uploadFile = 'upload-file';
|
||||||
|
|
||||||
static const String deleteChannel = "delete-channel";
|
/// Capability required to delete channel
|
||||||
|
/// User has DeleteChannel permission
|
||||||
|
static const String deleteChannel = 'delete-channel';
|
||||||
|
|
||||||
static const String updateChannel = "update-channel";
|
/// Capability required update/edit channel info
|
||||||
|
/// User has UpdateChannel permission
|
||||||
|
static const String updateChannel = 'update-channel';
|
||||||
|
|
||||||
static const String updateChannelMembers = "update-channel-members";
|
/// Capability required to update/edit channel members
|
||||||
|
/// Channel is not distinct and user has UpdateChannelMembers permission
|
||||||
|
static const String updateChannelMembers = 'update-channel-members';
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ class MessageReactionsModal extends StatelessWidget {
|
|||||||
required this.message,
|
required this.message,
|
||||||
required this.messageWidget,
|
required this.messageWidget,
|
||||||
required this.messageTheme,
|
required this.messageTheme,
|
||||||
this.showReactions = true,
|
this.showReactions,
|
||||||
this.reverse = false,
|
this.reverse = false,
|
||||||
this.onUserAvatarTap,
|
this.onUserAvatarTap,
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
@@ -36,7 +36,7 @@ class MessageReactionsModal extends StatelessWidget {
|
|||||||
final bool reverse;
|
final bool reverse;
|
||||||
|
|
||||||
/// Flag to show reactions on message
|
/// Flag to show reactions on message
|
||||||
final bool showReactions;
|
final bool? showReactions;
|
||||||
|
|
||||||
/// Callback when user avatar is tapped
|
/// Callback when user avatar is tapped
|
||||||
final void Function(User)? onUserAvatarTap;
|
final void Function(User)? onUserAvatarTap;
|
||||||
@@ -45,6 +45,16 @@ class MessageReactionsModal extends StatelessWidget {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final size = MediaQuery.of(context).size;
|
final size = MediaQuery.of(context).size;
|
||||||
final user = StreamChat.of(context).currentUser;
|
final user = StreamChat.of(context).currentUser;
|
||||||
|
final _userPermissions = StreamChannel.of(context)
|
||||||
|
.channel
|
||||||
|
.state
|
||||||
|
?.channelState
|
||||||
|
.channel
|
||||||
|
?.ownCapabilities ??
|
||||||
|
[];
|
||||||
|
|
||||||
|
final hasReactionPermission =
|
||||||
|
_userPermissions.contains(PermissionType.sendReaction);
|
||||||
|
|
||||||
final roughMaxSize = size.width * 2 / 3;
|
final roughMaxSize = size.width * 2 / 3;
|
||||||
var messageTextLength = message.text!.length;
|
var messageTextLength = message.text!.length;
|
||||||
@@ -76,7 +86,7 @@ class MessageReactionsModal extends StatelessWidget {
|
|||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
if (showReactions &&
|
if ((showReactions ?? hasReactionPermission) &&
|
||||||
(message.status == MessageSendingStatus.sent))
|
(message.status == MessageSendingStatus.sent))
|
||||||
Align(
|
Align(
|
||||||
alignment: Alignment(
|
alignment: Alignment(
|
||||||
|
|||||||
Reference in New Issue
Block a user