Merge pull request #204 from GetStream/feature/flag
feat: Added message flagging
This commit is contained in:
@@ -96,12 +96,16 @@ class ChannelPreview extends StatelessWidget {
|
|||||||
Flexible(child: _buildSubtitle(context)),
|
Flexible(child: _buildSubtitle(context)),
|
||||||
Builder(
|
Builder(
|
||||||
builder: (context) {
|
builder: (context) {
|
||||||
if (channel.state.lastMessage?.user?.id ==
|
final lastMessage = channel.state.messages.lastWhere(
|
||||||
|
(m) => !m.isDeleted && m.shadowed != true,
|
||||||
|
orElse: () => null,
|
||||||
|
);
|
||||||
|
if (lastMessage?.user?.id ==
|
||||||
StreamChat.of(context).user.id) {
|
StreamChat.of(context).user.id) {
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: const EdgeInsets.only(right: 4.0),
|
padding: const EdgeInsets.only(right: 4.0),
|
||||||
child: SendingIndicator(
|
child: SendingIndicator(
|
||||||
message: channel.state.lastMessage,
|
message: lastMessage,
|
||||||
size: StreamChatTheme.of(context)
|
size: StreamChatTheme.of(context)
|
||||||
.channelPreviewTheme
|
.channelPreviewTheme
|
||||||
.indicatorIconSize,
|
.indicatorIconSize,
|
||||||
@@ -110,8 +114,7 @@ class ChannelPreview extends StatelessWidget {
|
|||||||
element.user.id !=
|
element.user.id !=
|
||||||
channel.client.state.user.id)
|
channel.client.state.user.id)
|
||||||
?.where((element) => element.lastRead
|
?.where((element) => element.lastRead
|
||||||
.isAfter(channel
|
.isAfter(lastMessage.createdAt))
|
||||||
.state.lastMessage.createdAt))
|
|
||||||
?.isNotEmpty ==
|
?.isNotEmpty ==
|
||||||
true,
|
true,
|
||||||
),
|
),
|
||||||
@@ -201,16 +204,15 @@ class ChannelPreview extends StatelessWidget {
|
|||||||
stream: channel.state.messagesStream,
|
stream: channel.state.messagesStream,
|
||||||
initialData: channel.state.messages,
|
initialData: channel.state.messages,
|
||||||
builder: (context, snapshot) {
|
builder: (context, snapshot) {
|
||||||
final lastMessage = snapshot.data
|
final lastMessage = snapshot.data?.lastWhere(
|
||||||
?.lastWhere((m) => m.shadowed != true, orElse: () => null);
|
(m) => m.shadowed != true && !m.isDeleted,
|
||||||
|
orElse: () => null);
|
||||||
if (lastMessage == null) {
|
if (lastMessage == null) {
|
||||||
return SizedBox();
|
return SizedBox();
|
||||||
}
|
}
|
||||||
|
|
||||||
var text = lastMessage.text;
|
var text = lastMessage.text;
|
||||||
if (lastMessage.isDeleted) {
|
if (lastMessage.attachments != null) {
|
||||||
text = 'This message was deleted.';
|
|
||||||
} else if (lastMessage.attachments != null) {
|
|
||||||
final parts = <String>[
|
final parts = <String>[
|
||||||
...lastMessage.attachments.map((e) {
|
...lastMessage.attachments.map((e) {
|
||||||
if (e.type == 'image') {
|
if (e.type == 'image') {
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import 'dart:convert';
|
||||||
import 'dart:ui';
|
import 'dart:ui';
|
||||||
|
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
@@ -7,13 +8,14 @@ import 'package:stream_chat/stream_chat.dart';
|
|||||||
import 'package:stream_chat_flutter/src/reaction_picker.dart';
|
import 'package:stream_chat_flutter/src/reaction_picker.dart';
|
||||||
import 'package:stream_chat_flutter/src/stream_channel.dart';
|
import 'package:stream_chat_flutter/src/stream_channel.dart';
|
||||||
import 'package:stream_chat_flutter/src/stream_svg_icon.dart';
|
import 'package:stream_chat_flutter/src/stream_svg_icon.dart';
|
||||||
|
import 'package:stream_chat_flutter/src/utils.dart';
|
||||||
|
|
||||||
import 'message_input.dart';
|
import 'message_input.dart';
|
||||||
import 'message_widget.dart';
|
import 'message_widget.dart';
|
||||||
import 'stream_chat.dart';
|
import 'stream_chat.dart';
|
||||||
import 'stream_chat_theme.dart';
|
import 'stream_chat_theme.dart';
|
||||||
|
|
||||||
class MessageActionsModal extends StatelessWidget {
|
class MessageActionsModal extends StatefulWidget {
|
||||||
final Widget Function(BuildContext, Message) editMessageInputBuilder;
|
final Widget Function(BuildContext, Message) editMessageInputBuilder;
|
||||||
final void Function(Message) onThreadReplyTap;
|
final void Function(Message) onThreadReplyTap;
|
||||||
final void Function(Message) onReplyTap;
|
final void Function(Message) onReplyTap;
|
||||||
@@ -26,6 +28,7 @@ class MessageActionsModal extends StatelessWidget {
|
|||||||
final bool showResendMessage;
|
final bool showResendMessage;
|
||||||
final bool showReplyMessage;
|
final bool showReplyMessage;
|
||||||
final bool showThreadReplyMessage;
|
final bool showThreadReplyMessage;
|
||||||
|
final bool showFlagButton;
|
||||||
final bool reverse;
|
final bool reverse;
|
||||||
final ShapeBorder messageShape;
|
final ShapeBorder messageShape;
|
||||||
final DisplayWidget showUserAvatar;
|
final DisplayWidget showUserAvatar;
|
||||||
@@ -43,22 +46,32 @@ class MessageActionsModal extends StatelessWidget {
|
|||||||
this.showReplyMessage = true,
|
this.showReplyMessage = true,
|
||||||
this.showResendMessage = true,
|
this.showResendMessage = true,
|
||||||
this.showThreadReplyMessage = true,
|
this.showThreadReplyMessage = true,
|
||||||
|
this.showFlagButton = true,
|
||||||
this.showUserAvatar = DisplayWidget.show,
|
this.showUserAvatar = DisplayWidget.show,
|
||||||
this.editMessageInputBuilder,
|
this.editMessageInputBuilder,
|
||||||
this.messageShape,
|
this.messageShape,
|
||||||
this.reverse = false,
|
this.reverse = false,
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
_MessageActionsModalState createState() => _MessageActionsModalState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _MessageActionsModalState extends State<MessageActionsModal> {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
return _showMessageOptionsModal();
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _showMessageOptionsModal() {
|
||||||
final size = MediaQuery.of(context).size;
|
final size = MediaQuery.of(context).size;
|
||||||
final user = StreamChat.of(context).user;
|
final user = StreamChat.of(context).user;
|
||||||
|
|
||||||
final roughMaxSize = 2 * size.width / 3;
|
final roughMaxSize = 2 * size.width / 3;
|
||||||
var messageTextLength = message.text.length;
|
var messageTextLength = widget.message.text.length;
|
||||||
if (message.quotedMessage != null) {
|
if (widget.message.quotedMessage != null) {
|
||||||
var quotedMessageLength = message.quotedMessage.text.length + 40;
|
var quotedMessageLength = widget.message.quotedMessage.text.length + 40;
|
||||||
if (message.quotedMessage.attachments?.isNotEmpty == true) {
|
if (widget.message.quotedMessage.attachments?.isNotEmpty == true) {
|
||||||
quotedMessageLength += 40;
|
quotedMessageLength += 40;
|
||||||
}
|
}
|
||||||
if (quotedMessageLength > messageTextLength) {
|
if (quotedMessageLength > messageTextLength) {
|
||||||
@@ -66,8 +79,8 @@ class MessageActionsModal extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
final roughSentenceSize =
|
final roughSentenceSize =
|
||||||
messageTextLength * messageTheme.messageText.fontSize * 1.2;
|
messageTextLength * widget.messageTheme.messageText.fontSize * 1.2;
|
||||||
final divFactor = message.attachments?.isNotEmpty == true
|
final divFactor = widget.message.attachments?.isNotEmpty == true
|
||||||
? 1
|
? 1
|
||||||
: (roughSentenceSize == 0 ? 1 : (roughSentenceSize / roughMaxSize));
|
: (roughSentenceSize == 0 ? 1 : (roughSentenceSize / roughMaxSize));
|
||||||
|
|
||||||
@@ -92,22 +105,22 @@ class MessageActionsModal extends StatelessWidget {
|
|||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.symmetric(vertical: 8.0),
|
padding: const EdgeInsets.symmetric(vertical: 8.0),
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: reverse
|
crossAxisAlignment: widget.reverse
|
||||||
? CrossAxisAlignment.end
|
? CrossAxisAlignment.end
|
||||||
: CrossAxisAlignment.start,
|
: CrossAxisAlignment.start,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
if (showReactions &&
|
if (widget.showReactions &&
|
||||||
(message.status == MessageSendingStatus.SENT ||
|
(widget.message.status == MessageSendingStatus.SENT ||
|
||||||
message.status == null))
|
widget.message.status == null))
|
||||||
Align(
|
Align(
|
||||||
alignment: Alignment(
|
alignment: Alignment(
|
||||||
user.id == message.user.id
|
user.id == widget.message.user.id
|
||||||
? (divFactor > 1.0 ? 0.0 : (1.0 - divFactor))
|
? (divFactor > 1.0 ? 0.0 : (1.0 - divFactor))
|
||||||
: (divFactor > 1.0 ? 0.0 : -(1.0 - divFactor)),
|
: (divFactor > 1.0 ? 0.0 : -(1.0 - divFactor)),
|
||||||
0.0),
|
0.0),
|
||||||
child: ReactionPicker(
|
child: ReactionPicker(
|
||||||
message: message,
|
message: widget.message,
|
||||||
messageTheme: messageTheme,
|
messageTheme: widget.messageTheme,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
TweenAnimationBuilder<double>(
|
TweenAnimationBuilder<double>(
|
||||||
@@ -119,27 +132,28 @@ class MessageActionsModal extends StatelessWidget {
|
|||||||
child: IgnorePointer(
|
child: IgnorePointer(
|
||||||
child: MessageWidget(
|
child: MessageWidget(
|
||||||
key: Key('MessageWidget'),
|
key: Key('MessageWidget'),
|
||||||
reverse: reverse,
|
reverse: widget.reverse,
|
||||||
message: message.copyWith(
|
message: widget.message.copyWith(
|
||||||
text: message.text.length > 200
|
text: widget.message.text.length > 200
|
||||||
? '${message.text.substring(0, 200)}...'
|
? '${widget.message.text.substring(0, 200)}...'
|
||||||
: message.text,
|
: widget.message.text,
|
||||||
),
|
),
|
||||||
messageTheme: messageTheme,
|
messageTheme: widget.messageTheme,
|
||||||
showReactions: false,
|
showReactions: false,
|
||||||
showUsername: false,
|
showUsername: false,
|
||||||
showThreadReplyIndicator: false,
|
showThreadReplyIndicator: false,
|
||||||
showReplyMessage: false,
|
showReplyMessage: false,
|
||||||
showUserAvatar: showUserAvatar,
|
showUserAvatar: widget.showUserAvatar,
|
||||||
showTimestamp: false,
|
showTimestamp: false,
|
||||||
translateUserAvatar: false,
|
translateUserAvatar: false,
|
||||||
showReactionPickerIndicator: showReactions &&
|
showReactionPickerIndicator:
|
||||||
(message.status ==
|
widget.showReactions &&
|
||||||
MessageSendingStatus.SENT ||
|
(widget.message.status ==
|
||||||
message.status == null),
|
MessageSendingStatus.SENT ||
|
||||||
|
widget.message.status == null),
|
||||||
showInChannelIndicator: false,
|
showInChannelIndicator: false,
|
||||||
showSendingIndicator: false,
|
showSendingIndicator: false,
|
||||||
shape: messageShape,
|
shape: widget.messageShape,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@@ -153,13 +167,13 @@ class MessageActionsModal extends StatelessWidget {
|
|||||||
transform: Matrix4.identity()
|
transform: Matrix4.identity()
|
||||||
..scale(val)
|
..scale(val)
|
||||||
..rotateZ(-1.0 + val),
|
..rotateZ(-1.0 + val),
|
||||||
alignment: reverse
|
alignment: widget.reverse
|
||||||
? Alignment.topRight
|
? Alignment.topRight
|
||||||
: Alignment.topLeft,
|
: Alignment.topLeft,
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: EdgeInsets.only(
|
padding: EdgeInsets.only(
|
||||||
right: reverse ? 16 : 0,
|
right: widget.reverse ? 16 : 0,
|
||||||
left: reverse ? 0 : 48,
|
left: widget.reverse ? 0 : 48,
|
||||||
),
|
),
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
width: MediaQuery.of(context).size.width * 0.75,
|
width: MediaQuery.of(context).size.width * 0.75,
|
||||||
@@ -180,25 +194,29 @@ class MessageActionsModal extends StatelessWidget {
|
|||||||
.greyWhisper,
|
.greyWhisper,
|
||||||
context: context,
|
context: context,
|
||||||
tiles: [
|
tiles: [
|
||||||
if (showReplyMessage &&
|
if (widget.showReplyMessage &&
|
||||||
(message.status ==
|
(widget.message.status ==
|
||||||
MessageSendingStatus.SENT ||
|
MessageSendingStatus.SENT ||
|
||||||
message.status == null) &&
|
widget.message.status ==
|
||||||
message.parentId == null)
|
null) &&
|
||||||
|
widget.message.parentId == null)
|
||||||
_buildReplyButton(context),
|
_buildReplyButton(context),
|
||||||
if (showThreadReplyMessage &&
|
if (widget.showThreadReplyMessage &&
|
||||||
(message.status ==
|
(widget.message.status ==
|
||||||
MessageSendingStatus.SENT ||
|
MessageSendingStatus.SENT ||
|
||||||
message.status == null) &&
|
widget.message.status ==
|
||||||
message.parentId == null)
|
null) &&
|
||||||
|
widget.message.parentId == null)
|
||||||
_buildThreadReplyButton(context),
|
_buildThreadReplyButton(context),
|
||||||
if (showResendMessage)
|
if (widget.showResendMessage)
|
||||||
_buildResendMessage(context),
|
_buildResendMessage(context),
|
||||||
if (showEditMessage)
|
if (widget.showEditMessage)
|
||||||
_buildEditMessage(context),
|
_buildEditMessage(context),
|
||||||
if (showCopyMessage)
|
if (widget.showCopyMessage)
|
||||||
_buildCopyButton(context),
|
_buildCopyButton(context),
|
||||||
if (showDeleteMessage)
|
if (widget.showFlagButton)
|
||||||
|
_buildFlagButton(context),
|
||||||
|
if (widget.showDeleteMessage)
|
||||||
_buildDeleteButton(context),
|
_buildDeleteButton(context),
|
||||||
],
|
],
|
||||||
).toList(),
|
).toList(),
|
||||||
@@ -218,6 +236,188 @@ class MessageActionsModal extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _showFlagDialog() async {
|
||||||
|
final client = StreamChat.of(context).client;
|
||||||
|
|
||||||
|
var answer = await showConfirmationDialog(context,
|
||||||
|
title: 'Flag Message',
|
||||||
|
icon: StreamSvgIcon.flag(
|
||||||
|
color: StreamChatTheme.of(context).colorTheme.accentRed,
|
||||||
|
size: 24.0,
|
||||||
|
),
|
||||||
|
question:
|
||||||
|
'Do you want to send a copy of this message to a\nmoderator for further investigation?',
|
||||||
|
okText: 'FLAG',
|
||||||
|
cancelText: 'CANCEL');
|
||||||
|
|
||||||
|
if (answer) {
|
||||||
|
try {
|
||||||
|
await client.flagMessage(widget.message.id);
|
||||||
|
_showDismissAlert();
|
||||||
|
} catch (err) {
|
||||||
|
if (json.decode(err?.body ?? {})['code'] == 4) {
|
||||||
|
_showDismissAlert();
|
||||||
|
} else {
|
||||||
|
_showErrorAlert();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void _showDeleteDialog() async {
|
||||||
|
var answer = await showConfirmationDialog(context,
|
||||||
|
title: 'Delete message',
|
||||||
|
icon: StreamSvgIcon.flag(
|
||||||
|
color: StreamChatTheme.of(context).colorTheme.accentRed,
|
||||||
|
size: 24.0,
|
||||||
|
),
|
||||||
|
question: 'Are you sure you want to permanently delete this\nmessage?',
|
||||||
|
okText: 'DELETE',
|
||||||
|
cancelText: 'CANCEL');
|
||||||
|
|
||||||
|
if (answer) {
|
||||||
|
try {
|
||||||
|
Navigator.pop(context);
|
||||||
|
StreamChat.of(context).client.deleteMessage(
|
||||||
|
widget.message,
|
||||||
|
StreamChannel.of(context).channel.cid,
|
||||||
|
);
|
||||||
|
} catch (err) {
|
||||||
|
_showErrorAlert();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void _showDismissAlert() {
|
||||||
|
showModalBottomSheet(
|
||||||
|
backgroundColor: StreamChatTheme.of(context).colorTheme.white,
|
||||||
|
context: context,
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.only(
|
||||||
|
topLeft: Radius.circular(16.0),
|
||||||
|
topRight: Radius.circular(16.0),
|
||||||
|
)),
|
||||||
|
builder: (context) {
|
||||||
|
return Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
SizedBox(
|
||||||
|
height: 26.0,
|
||||||
|
),
|
||||||
|
StreamSvgIcon.flag(
|
||||||
|
color: StreamChatTheme.of(context).colorTheme.accentRed,
|
||||||
|
size: 24.0,
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
height: 26.0,
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
'Message flagged',
|
||||||
|
style: StreamChatTheme.of(context).textTheme.headlineBold,
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
height: 7.0,
|
||||||
|
),
|
||||||
|
Text('The message has been reported to a moderator.'),
|
||||||
|
SizedBox(
|
||||||
|
height: 36.0,
|
||||||
|
),
|
||||||
|
Container(
|
||||||
|
color:
|
||||||
|
StreamChatTheme.of(context).colorTheme.black.withOpacity(.08),
|
||||||
|
height: 1.0,
|
||||||
|
),
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
FlatButton(
|
||||||
|
child: Text(
|
||||||
|
'OK',
|
||||||
|
style: StreamChatTheme.of(context)
|
||||||
|
.textTheme
|
||||||
|
.bodyBold
|
||||||
|
.copyWith(
|
||||||
|
color: StreamChatTheme.of(context)
|
||||||
|
.colorTheme
|
||||||
|
.accentBlue),
|
||||||
|
),
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
void _showErrorAlert() {
|
||||||
|
showModalBottomSheet(
|
||||||
|
backgroundColor: StreamChatTheme.of(context).colorTheme.white,
|
||||||
|
context: context,
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.only(
|
||||||
|
topLeft: Radius.circular(16.0),
|
||||||
|
topRight: Radius.circular(16.0),
|
||||||
|
)),
|
||||||
|
builder: (context) {
|
||||||
|
return Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
SizedBox(
|
||||||
|
height: 26.0,
|
||||||
|
),
|
||||||
|
StreamSvgIcon.error(
|
||||||
|
color: StreamChatTheme.of(context).colorTheme.accentRed,
|
||||||
|
size: 24.0,
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
height: 26.0,
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
'Something went wrong',
|
||||||
|
style: StreamChatTheme.of(context).textTheme.headlineBold,
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
height: 7.0,
|
||||||
|
),
|
||||||
|
Text('The operation couldn\'t be completed.'),
|
||||||
|
SizedBox(
|
||||||
|
height: 36.0,
|
||||||
|
),
|
||||||
|
Container(
|
||||||
|
color:
|
||||||
|
StreamChatTheme.of(context).colorTheme.black.withOpacity(.08),
|
||||||
|
height: 1.0,
|
||||||
|
),
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
FlatButton(
|
||||||
|
child: Text(
|
||||||
|
'OK',
|
||||||
|
style: StreamChatTheme.of(context)
|
||||||
|
.textTheme
|
||||||
|
.bodyBold
|
||||||
|
.copyWith(
|
||||||
|
color: StreamChatTheme.of(context)
|
||||||
|
.colorTheme
|
||||||
|
.accentBlue),
|
||||||
|
),
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
Widget _buildReplyButton(BuildContext context) {
|
Widget _buildReplyButton(BuildContext context) {
|
||||||
return ListTile(
|
return ListTile(
|
||||||
dense: true,
|
dense: true,
|
||||||
@@ -235,15 +435,37 @@ class MessageActionsModal extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
if (onReplyTap != null) {
|
if (widget.onReplyTap != null) {
|
||||||
onReplyTap(message);
|
widget.onReplyTap(widget.message);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Widget _buildFlagButton(BuildContext context) {
|
||||||
|
return ListTile(
|
||||||
|
dense: true,
|
||||||
|
title: Row(
|
||||||
|
children: [
|
||||||
|
StreamSvgIcon.icon_flag(
|
||||||
|
color: StreamChatTheme.of(context).primaryIconTheme.color,
|
||||||
|
),
|
||||||
|
const SizedBox(width: 16),
|
||||||
|
Text(
|
||||||
|
'Flag',
|
||||||
|
style: StreamChatTheme.of(context).textTheme.headline,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
onTap: () {
|
||||||
|
_showFlagDialog();
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
Widget _buildDeleteButton(BuildContext context) {
|
Widget _buildDeleteButton(BuildContext context) {
|
||||||
final isDeleteFailed = message.status == MessageSendingStatus.FAILED_DELETE;
|
final isDeleteFailed =
|
||||||
|
widget.message.status == MessageSendingStatus.FAILED_DELETE;
|
||||||
return ListTile(
|
return ListTile(
|
||||||
dense: true,
|
dense: true,
|
||||||
title: Row(
|
title: Row(
|
||||||
@@ -262,11 +484,7 @@ class MessageActionsModal extends StatelessWidget {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
Navigator.pop(context);
|
_showDeleteDialog();
|
||||||
StreamChat.of(context).client.deleteMessage(
|
|
||||||
message,
|
|
||||||
StreamChannel.of(context).channel.cid,
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -288,7 +506,7 @@ class MessageActionsModal extends StatelessWidget {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
await Clipboard.setData(ClipboardData(text: message.text));
|
await Clipboard.setData(ClipboardData(text: widget.message.text));
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@@ -317,7 +535,8 @@ class MessageActionsModal extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildResendMessage(BuildContext context) {
|
Widget _buildResendMessage(BuildContext context) {
|
||||||
final isUpdateFailed = message.status == MessageSendingStatus.FAILED_UPDATE;
|
final isUpdateFailed =
|
||||||
|
widget.message.status == MessageSendingStatus.FAILED_UPDATE;
|
||||||
return ListTile(
|
return ListTile(
|
||||||
dense: true,
|
dense: true,
|
||||||
title: Row(
|
title: Row(
|
||||||
@@ -337,9 +556,9 @@ class MessageActionsModal extends StatelessWidget {
|
|||||||
final client = StreamChat.of(context).client;
|
final client = StreamChat.of(context).client;
|
||||||
final channel = StreamChannel.of(context).channel;
|
final channel = StreamChannel.of(context).channel;
|
||||||
if (isUpdateFailed) {
|
if (isUpdateFailed) {
|
||||||
client.updateMessage(message, channel.cid);
|
client.updateMessage(widget.message, channel.cid);
|
||||||
} else {
|
} else {
|
||||||
channel.sendMessage(message);
|
channel.sendMessage(widget.message);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@@ -396,10 +615,10 @@ class MessageActionsModal extends StatelessWidget {
|
|||||||
padding: EdgeInsets.only(
|
padding: EdgeInsets.only(
|
||||||
bottom: MediaQuery.of(context).viewInsets.bottom,
|
bottom: MediaQuery.of(context).viewInsets.bottom,
|
||||||
),
|
),
|
||||||
child: editMessageInputBuilder != null
|
child: widget.editMessageInputBuilder != null
|
||||||
? editMessageInputBuilder(context, message)
|
? widget.editMessageInputBuilder(context, widget.message)
|
||||||
: MessageInput(
|
: MessageInput(
|
||||||
editMessage: message,
|
editMessage: widget.message,
|
||||||
preMessageSending: (m) {
|
preMessageSending: (m) {
|
||||||
FocusScope.of(context).unfocus();
|
FocusScope.of(context).unfocus();
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
@@ -431,8 +650,8 @@ class MessageActionsModal extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
if (onThreadReplyTap != null) {
|
if (widget.onThreadReplyTap != null) {
|
||||||
onThreadReplyTap(message);
|
widget.onThreadReplyTap(widget.message);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -851,6 +851,7 @@ class _MessageListViewState extends State<MessageListView> {
|
|||||||
showEditMessage: isMyMessage,
|
showEditMessage: isMyMessage,
|
||||||
showDeleteMessage: isMyMessage,
|
showDeleteMessage: isMyMessage,
|
||||||
showThreadReplyMessage: !isThreadMessage,
|
showThreadReplyMessage: !isThreadMessage,
|
||||||
|
showFlagButton: !isMyMessage,
|
||||||
borderSide: isMyMessage ? BorderSide.none : null,
|
borderSide: isMyMessage ? BorderSide.none : null,
|
||||||
onThreadTap: _onThreadTap,
|
onThreadTap: _onThreadTap,
|
||||||
onReplyTap: widget.onReplyTap,
|
onReplyTap: widget.onReplyTap,
|
||||||
|
|||||||
@@ -132,6 +132,7 @@ class MessageWidget extends StatefulWidget {
|
|||||||
final bool showDeleteMessage;
|
final bool showDeleteMessage;
|
||||||
final bool showResendMessage;
|
final bool showResendMessage;
|
||||||
|
|
||||||
|
final bool showFlagButton;
|
||||||
final Map<String, AttachmentBuilder> attachmentBuilders;
|
final Map<String, AttachmentBuilder> attachmentBuilders;
|
||||||
|
|
||||||
/// Center user avatar with bottom of the message
|
/// Center user avatar with bottom of the message
|
||||||
@@ -170,6 +171,7 @@ class MessageWidget extends StatefulWidget {
|
|||||||
this.showThreadReplyMessage = true,
|
this.showThreadReplyMessage = true,
|
||||||
this.showResendMessage = true,
|
this.showResendMessage = true,
|
||||||
this.showCopyMessage = true,
|
this.showCopyMessage = true,
|
||||||
|
this.showFlagButton = true,
|
||||||
this.onUserAvatarTap,
|
this.onUserAvatarTap,
|
||||||
this.onLinkTap,
|
this.onLinkTap,
|
||||||
this.onMessageActions,
|
this.onMessageActions,
|
||||||
@@ -689,6 +691,7 @@ class _MessageWidgetState extends State<MessageWidget> {
|
|||||||
|
|
||||||
void _showMessageActionModalBottomSheet(BuildContext context) {
|
void _showMessageActionModalBottomSheet(BuildContext context) {
|
||||||
final channel = StreamChannel.of(context).channel;
|
final channel = StreamChannel.of(context).channel;
|
||||||
|
|
||||||
showDialog(
|
showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
barrierColor: StreamChatTheme.of(context).colorTheme.overlay,
|
barrierColor: StreamChatTheme.of(context).colorTheme.overlay,
|
||||||
@@ -725,6 +728,7 @@ class _MessageWidgetState extends State<MessageWidget> {
|
|||||||
showThreadReplyMessage: widget.showThreadReplyMessage &&
|
showThreadReplyMessage: widget.showThreadReplyMessage &&
|
||||||
!isFailedState &&
|
!isFailedState &&
|
||||||
widget.onThreadTap != null,
|
widget.onThreadTap != null,
|
||||||
|
showFlagButton: widget.showFlagButton,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -889,4 +889,16 @@ class StreamSvgIcon extends StatelessWidget {
|
|||||||
height: size,
|
height: size,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
factory StreamSvgIcon.icon_flag({
|
||||||
|
double size,
|
||||||
|
Color color,
|
||||||
|
}) {
|
||||||
|
return StreamSvgIcon(
|
||||||
|
assetName: 'icon_flag.svg',
|
||||||
|
color: color,
|
||||||
|
width: size,
|
||||||
|
height: size,
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+87
-9
@@ -67,22 +67,29 @@ Future<bool> showConfirmationDialog(
|
|||||||
FlatButton(
|
FlatButton(
|
||||||
child: Text(
|
child: Text(
|
||||||
cancelText,
|
cancelText,
|
||||||
style: TextStyle(
|
style: StreamChatTheme.of(context)
|
||||||
color: StreamChatTheme.of(context)
|
.textTheme
|
||||||
.colorTheme
|
.bodyBold
|
||||||
.black
|
.copyWith(
|
||||||
.withOpacity(0.5),
|
color: StreamChatTheme.of(context)
|
||||||
fontWeight: FontWeight.w400),
|
.colorTheme
|
||||||
|
.black
|
||||||
|
.withOpacity(0.5)),
|
||||||
),
|
),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop(false);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
FlatButton(
|
FlatButton(
|
||||||
child: Text(
|
child: Text(
|
||||||
okText,
|
okText,
|
||||||
style: TextStyle(
|
style: StreamChatTheme.of(context)
|
||||||
color: Colors.red, fontWeight: FontWeight.w400),
|
.textTheme
|
||||||
|
.bodyBold
|
||||||
|
.copyWith(
|
||||||
|
color: StreamChatTheme.of(context)
|
||||||
|
.colorTheme
|
||||||
|
.accentRed),
|
||||||
),
|
),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Navigator.pop(context, true);
|
Navigator.pop(context, true);
|
||||||
@@ -95,6 +102,77 @@ Future<bool> showConfirmationDialog(
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<bool> showInfoDialog(
|
||||||
|
BuildContext context, {
|
||||||
|
String title,
|
||||||
|
Widget icon,
|
||||||
|
String question,
|
||||||
|
String okText,
|
||||||
|
StreamChatThemeData theme,
|
||||||
|
}) {
|
||||||
|
return showModalBottomSheet(
|
||||||
|
backgroundColor:
|
||||||
|
theme.colorTheme.white ?? StreamChatTheme.of(context).colorTheme.white,
|
||||||
|
context: context,
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.only(
|
||||||
|
topLeft: Radius.circular(16.0),
|
||||||
|
topRight: Radius.circular(16.0),
|
||||||
|
)),
|
||||||
|
builder: (context) {
|
||||||
|
return Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
SizedBox(
|
||||||
|
height: 26.0,
|
||||||
|
),
|
||||||
|
if (icon != null) icon,
|
||||||
|
SizedBox(
|
||||||
|
height: 26.0,
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
title,
|
||||||
|
style: theme.textTheme.headlineBold ??
|
||||||
|
StreamChatTheme.of(context).textTheme.headlineBold,
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
height: 7.0,
|
||||||
|
),
|
||||||
|
Text(question),
|
||||||
|
SizedBox(
|
||||||
|
height: 36.0,
|
||||||
|
),
|
||||||
|
Container(
|
||||||
|
color: theme.colorTheme.black.withOpacity(.08) ??
|
||||||
|
StreamChatTheme.of(context).colorTheme.black.withOpacity(.08),
|
||||||
|
height: 1.0,
|
||||||
|
),
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
FlatButton(
|
||||||
|
child: Text(
|
||||||
|
okText,
|
||||||
|
style: TextStyle(
|
||||||
|
color: theme.colorTheme.black.withOpacity(0.5) ??
|
||||||
|
StreamChatTheme.of(context)
|
||||||
|
.colorTheme
|
||||||
|
.black
|
||||||
|
.withOpacity(0.5),
|
||||||
|
fontWeight: FontWeight.w400),
|
||||||
|
),
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/// Get random png with initials
|
/// Get random png with initials
|
||||||
String getRandomPicUrl(User user) =>
|
String getRandomPicUrl(User user) =>
|
||||||
'https://getstream.io/random_png/?id=${user.id}&name=${user.name}';
|
'https://getstream.io/random_png/?id=${user.id}&name=${user.name}';
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
<svg width="24" height="25" viewBox="0 0 24 25" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<path fill-rule="evenodd" clip-rule="evenodd" d="M5 2.5C4.44772 2.5 4 2.94772 4 3.5V4.5V14.5V21.5C4 22.0523 4.44772 22.5 5 22.5C5.55228 22.5 6 22.0523 6 21.5V14.5H20L18 9.5L20 4.5H6V3.5C6 2.94772 5.55228 2.5 5 2.5ZM6 6.5V12.5H17L16 9.5L17 6.5H6Z" fill="#7A7A7A"/>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 367 B |
Reference in New Issue
Block a user