Merge pull request #578 from GetStream/delete_message_fix
refactor(ui, core): delete_message
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
|
||||
- Added `MessageListView.paginationLimit`
|
||||
- Allow the various ListView widgets to be themed via ThemeData classes
|
||||
- Added `bottomRowBuilder` and `deletedBottomRowBuilder` that build a widget below a `MessageWidget`
|
||||
|
||||
🔄 Changed
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ import 'package:cached_network_image/cached_network_image.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:shimmer/shimmer.dart';
|
||||
import 'package:stream_chat_flutter/src/attachment/attachment_widget.dart';
|
||||
import 'package:stream_chat_flutter/src/visible_footnote.dart';
|
||||
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
||||
import 'package:stream_chat_flutter_core/stream_chat_flutter_core.dart';
|
||||
|
||||
@@ -216,36 +217,11 @@ class GiphyAttachment extends AttachmentWidget {
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Align(
|
||||
const Align(
|
||||
alignment: Alignment.centerRight,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
StreamSvgIcon.eye(
|
||||
color: StreamChatTheme.of(context)
|
||||
.colorTheme
|
||||
.textHighEmphasis
|
||||
.withOpacity(0.5),
|
||||
size: 16,
|
||||
),
|
||||
const SizedBox(
|
||||
width: 8,
|
||||
),
|
||||
Text(
|
||||
'Only visible to you',
|
||||
style: StreamChatTheme.of(context)
|
||||
.textTheme
|
||||
.footnote
|
||||
.copyWith(
|
||||
color: StreamChatTheme.of(context)
|
||||
.colorTheme
|
||||
.textHighEmphasis
|
||||
.withOpacity(0.5)),
|
||||
),
|
||||
],
|
||||
),
|
||||
padding: EdgeInsets.symmetric(horizontal: 8, vertical: 4),
|
||||
child: VisibleFootnote(),
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
@@ -92,6 +92,8 @@ class MessageWidget extends StatefulWidget {
|
||||
this.userAvatarBuilder,
|
||||
this.editMessageInputBuilder,
|
||||
this.textBuilder,
|
||||
this.bottomRowBuilder,
|
||||
this.deletedBottomRowBuilder,
|
||||
this.onReturnAction,
|
||||
Map<String, AttachmentBuilder>? customAttachmentBuilders,
|
||||
this.readList,
|
||||
@@ -275,6 +277,12 @@ class MessageWidget extends StatefulWidget {
|
||||
/// Function called on long press
|
||||
final void Function(BuildContext, Message)? onMessageActions;
|
||||
|
||||
/// Widget builder for building a bottom row below the message
|
||||
final Widget Function(BuildContext, Message)? bottomRowBuilder;
|
||||
|
||||
/// Widget builder for building a bottom row below a deleted message
|
||||
final Widget Function(BuildContext, Message)? deletedBottomRowBuilder;
|
||||
|
||||
/// Widget builder for building user avatar
|
||||
final Widget Function(BuildContext, User)? userAvatarBuilder;
|
||||
|
||||
@@ -410,6 +418,8 @@ class MessageWidget extends StatefulWidget {
|
||||
Widget Function(BuildContext, Message)? editMessageInputBuilder,
|
||||
Widget Function(BuildContext, Message)? textBuilder,
|
||||
Widget Function(BuildContext, Message)? usernameBuilder,
|
||||
Widget Function(BuildContext, Message)? bottomRowBuilder,
|
||||
Widget Function(BuildContext, Message)? deletedBottomRowBuilder,
|
||||
void Function(BuildContext, Message)? onMessageActions,
|
||||
Message? message,
|
||||
MessageTheme? messageTheme,
|
||||
@@ -463,6 +473,9 @@ class MessageWidget extends StatefulWidget {
|
||||
editMessageInputBuilder ?? this.editMessageInputBuilder,
|
||||
textBuilder: textBuilder ?? this.textBuilder,
|
||||
usernameBuilder: usernameBuilder ?? this.usernameBuilder,
|
||||
bottomRowBuilder: bottomRowBuilder ?? this.bottomRowBuilder,
|
||||
deletedBottomRowBuilder:
|
||||
deletedBottomRowBuilder ?? this.deletedBottomRowBuilder,
|
||||
onMessageActions: onMessageActions ?? this.onMessageActions,
|
||||
message: message ?? this.message,
|
||||
messageTheme: messageTheme ?? this.messageTheme,
|
||||
@@ -782,7 +795,11 @@ class _MessageWidgetState extends State<MessageWidget>
|
||||
bottom:
|
||||
isPinned && widget.showPinHighlight ? 6.0 : 0.0,
|
||||
),
|
||||
child: _bottomRow,
|
||||
child: widget.bottomRowBuilder?.call(
|
||||
context,
|
||||
widget.message,
|
||||
) ??
|
||||
_bottomRow,
|
||||
),
|
||||
if (isFailedState)
|
||||
Positioned(
|
||||
@@ -830,22 +847,11 @@ class _MessageWidgetState extends State<MessageWidget>
|
||||
|
||||
Widget get _bottomRow {
|
||||
if (isDeleted) {
|
||||
final chatThemeData = _streamChatTheme;
|
||||
return Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
StreamSvgIcon.eye(
|
||||
color: chatThemeData.colorTheme.textLowEmphasis,
|
||||
size: 16,
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Text(
|
||||
'Only visible to you',
|
||||
style: chatThemeData.textTheme.footnote
|
||||
.copyWith(color: chatThemeData.colorTheme.textLowEmphasis),
|
||||
),
|
||||
],
|
||||
);
|
||||
return widget.deletedBottomRowBuilder?.call(
|
||||
context,
|
||||
widget.message,
|
||||
) ??
|
||||
const Offstage();
|
||||
}
|
||||
|
||||
final children = <Widget>[];
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:stream_chat_flutter/src/stream_chat_theme.dart';
|
||||
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
||||
|
||||
/// Widget for displaying a footnote
|
||||
class VisibleFootnote extends StatelessWidget {
|
||||
/// Constructor for creating a [VisibleFootnote]
|
||||
const VisibleFootnote({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final chatThemeData = StreamChatTheme.of(context);
|
||||
return Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
StreamSvgIcon.eye(
|
||||
color: chatThemeData.colorTheme.textLowEmphasis,
|
||||
size: 16,
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Text(
|
||||
'Only visible to you',
|
||||
style: chatThemeData.textTheme.footnote
|
||||
.copyWith(color: chatThemeData.colorTheme.textLowEmphasis),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -42,3 +42,4 @@ export 'src/user_item.dart';
|
||||
export 'src/user_list_view.dart';
|
||||
export 'src/user_list_view.dart';
|
||||
export 'src/utils.dart';
|
||||
export 'src/visible_footnote.dart';
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
## Upcoming
|
||||
|
||||
🛑️ Breaking Changes from `2.0.0`
|
||||
- Changed default message filter of `MessageListCore`
|
||||
|
||||
✅ Added
|
||||
- Added `MessageListCore.paginationLimit`
|
||||
|
||||
🔄 Changed
|
||||
|
||||
- `StreamChatCore.of(context).user` is now deprecated in favor of `StreamChatCore.of(context).currentUser`.
|
||||
- `StreamChatCore.of(context).userStream` is now deprecated in favor of `StreamChatCore.of(context).currentUserStream`.
|
||||
|
||||
|
||||
@@ -134,8 +134,7 @@ class MessageListCoreState extends State<MessageListCore> {
|
||||
|
||||
bool defaultFilter(Message m) {
|
||||
final isMyMessage = m.user?.id == _currentUser?.id;
|
||||
final isDeletedOrShadowed = m.isDeleted == true || m.shadowed == true;
|
||||
if (isDeletedOrShadowed && !isMyMessage) return false;
|
||||
if (m.shadowed && !isMyMessage) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user