fix review

This commit is contained in:
Salvatore Giordano
2021-04-30 15:00:51 +02:00
parent 0d12e701a0
commit 5bbe82c7eb
25 changed files with 141 additions and 143 deletions
@@ -204,7 +204,8 @@ class Channel {
/// Channel extra data as a stream /// Channel extra data as a stream
Stream<Map<String, dynamic>> get extraDataStream { Stream<Map<String, dynamic>> get extraDataStream {
_checkInitialized(); _checkInitialized();
return state!.channelStateStream.map( return state!.channelStateStream
.map(
(cs) => cs.channel?.extraData ?? _extraData, (cs) => cs.channel?.extraData ?? _extraData,
); );
} }
@@ -11,7 +11,7 @@ class AttachmentTitle extends StatelessWidget {
required this.messageTheme, required this.messageTheme,
}) : super(key: key); }) : super(key: key);
final MessageTheme? messageTheme; final MessageTheme messageTheme;
final Attachment attachment; final Attachment attachment;
@override @override
@@ -32,7 +32,7 @@ class AttachmentTitle extends StatelessWidget {
Text( Text(
attachment.title!, attachment.title!,
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
style: messageTheme?.messageText?.copyWith( style: messageTheme.messageText?.copyWith(
color: StreamChatTheme.of(context).colorTheme.accentBlue, color: StreamChatTheme.of(context).colorTheme.accentBlue,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
), ),
@@ -47,7 +47,7 @@ class AttachmentTitle extends StatelessWidget {
.toList() .toList()
.reversed .reversed
.join('.'), .join('.'),
style: messageTheme?.messageText, style: messageTheme.messageText,
), ),
], ],
), ),
@@ -155,7 +155,7 @@ class FileAttachment extends AttachmentWidget {
shape: _getDefaultShape(context), shape: _getDefaultShape(context),
child: source.when( child: source.when(
local: () => VideoThumbnailImage( local: () => VideoThumbnailImage(
video: attachment.file?.path, video: attachment.file!.path!,
placeholderBuilder: (_) { placeholderBuilder: (_) {
return Center( return Center(
child: Container( child: Container(
@@ -167,7 +167,7 @@ class FileAttachment extends AttachmentWidget {
}, },
), ),
network: () => VideoThumbnailImage( network: () => VideoThumbnailImage(
video: attachment.assetUrl, video: attachment.assetUrl!,
placeholderBuilder: (_) { placeholderBuilder: (_) {
return Center( return Center(
child: Container( child: Container(
@@ -10,7 +10,7 @@ import 'attachment_title.dart';
import 'attachment_widget.dart'; import 'attachment_widget.dart';
class ImageAttachment extends AttachmentWidget { class ImageAttachment extends AttachmentWidget {
final MessageTheme? messageTheme; final MessageTheme messageTheme;
final bool showTitle; final bool showTitle;
final ShowMessageCallback? onShowMessage; final ShowMessageCallback? onShowMessage;
final ValueChanged<ReturnActionType>? onReturnAction; final ValueChanged<ReturnActionType>? onReturnAction;
@@ -20,8 +20,8 @@ class ImageAttachment extends AttachmentWidget {
Key? key, Key? key,
required Message message, required Message message,
required Attachment attachment, required Attachment attachment,
required this.messageTheme,
Size? size, Size? size,
this.messageTheme,
this.showTitle = false, this.showTitle = false,
this.onShowMessage, this.onShowMessage,
this.onReturnAction, this.onReturnAction,
@@ -157,7 +157,7 @@ class ImageAttachment extends AttachmentWidget {
), ),
if (showTitle && attachment.title != null) if (showTitle && attachment.title != null)
Material( Material(
color: messageTheme?.messageBackgroundColor, color: messageTheme.messageBackgroundColor,
child: AttachmentTitle( child: AttachmentTitle(
messageTheme: messageTheme, messageTheme: messageTheme,
attachment: attachment, attachment: attachment,
@@ -8,7 +8,7 @@ import 'attachment_upload_state_builder.dart';
import 'attachment_widget.dart'; import 'attachment_widget.dart';
class VideoAttachment extends AttachmentWidget { class VideoAttachment extends AttachmentWidget {
final MessageTheme? messageTheme; final MessageTheme messageTheme;
final ShowMessageCallback? onShowMessage; final ShowMessageCallback? onShowMessage;
final ValueChanged<ReturnActionType>? onReturnAction; final ValueChanged<ReturnActionType>? onReturnAction;
final VoidCallback? onAttachmentTap; final VoidCallback? onAttachmentTap;
@@ -17,8 +17,8 @@ class VideoAttachment extends AttachmentWidget {
Key? key, Key? key,
required Message message, required Message message,
required Attachment attachment, required Attachment attachment,
required this.messageTheme,
Size? size, Size? size,
this.messageTheme,
this.onShowMessage, this.onShowMessage,
this.onReturnAction, this.onReturnAction,
this.onAttachmentTap, this.onAttachmentTap,
@@ -39,7 +39,7 @@ class VideoAttachment extends AttachmentWidget {
return _buildVideoAttachment( return _buildVideoAttachment(
context, context,
VideoThumbnailImage( VideoThumbnailImage(
video: attachment.file?.path, video: attachment.file!.path!,
height: size?.height, height: size?.height,
width: size?.width, width: size?.width,
fit: BoxFit.cover, fit: BoxFit.cover,
@@ -54,7 +54,7 @@ class VideoAttachment extends AttachmentWidget {
return _buildVideoAttachment( return _buildVideoAttachment(
context, context,
VideoThumbnailImage( VideoThumbnailImage(
video: attachment.assetUrl, video: attachment.assetUrl!,
height: size?.height, height: size?.height,
width: size?.width, width: size?.width,
fit: BoxFit.cover, fit: BoxFit.cover,
@@ -116,7 +116,7 @@ class VideoAttachment extends AttachmentWidget {
), ),
if (attachment.title != null) if (attachment.title != null)
Material( Material(
color: messageTheme?.messageBackgroundColor, color: messageTheme.messageBackgroundColor,
child: AttachmentTitle( child: AttachmentTitle(
messageTheme: messageTheme, messageTheme: messageTheme,
attachment: attachment, attachment: attachment,
@@ -14,7 +14,7 @@ class DeletedMessage extends StatelessWidget {
}) : super(key: key); }) : super(key: key);
/// The theme of the message /// The theme of the message
final MessageTheme? messageTheme; final MessageTheme messageTheme;
/// The border radius of the message text /// The border radius of the message text
final BorderRadiusGeometry? borderRadiusGeometry; final BorderRadiusGeometry? borderRadiusGeometry;
@@ -34,7 +34,7 @@ class DeletedMessage extends StatelessWidget {
transform: Matrix4.rotationY(reverse ? pi : 0), transform: Matrix4.rotationY(reverse ? pi : 0),
alignment: Alignment.center, alignment: Alignment.center,
child: Material( child: Material(
color: messageTheme?.messageBackgroundColor, color: messageTheme.messageBackgroundColor,
shape: shape ?? shape: shape ??
RoundedRectangleBorder( RoundedRectangleBorder(
borderRadius: borderRadiusGeometry ?? BorderRadius.zero, borderRadius: borderRadiusGeometry ?? BorderRadius.zero,
@@ -61,9 +61,9 @@ class DeletedMessage extends StatelessWidget {
alignment: Alignment.center, alignment: Alignment.center,
child: Text( child: Text(
'Message deleted', 'Message deleted',
style: messageTheme?.messageText?.copyWith( style: messageTheme.messageText?.copyWith(
fontStyle: FontStyle.italic, fontStyle: FontStyle.italic,
color: messageTheme?.createdAt?.color, color: messageTheme.createdAt?.color,
), ),
), ),
), ),
@@ -177,7 +177,6 @@ class _FullScreenMediaState extends State<FullScreenMedia>
Navigator.of(context).pop(); Navigator.of(context).pop();
}, },
message: widget.message, message: widget.message,
urls: widget.mediaAttachments,
currentIndex: _currentPage, currentIndex: _currentPage,
onShowMessage: () { onShowMessage: () {
widget.onShowMessage?.call( widget.onShowMessage?.call(
@@ -221,8 +221,8 @@ class _ImageFooterState extends State<ImageFooter> {
child: FittedBox( child: FittedBox(
fit: BoxFit.cover, fit: BoxFit.cover,
child: VideoThumbnailImage( child: VideoThumbnailImage(
video: attachment.file?.path ?? video: (attachment.file?.path ??
attachment.assetUrl, attachment.assetUrl)!,
), ),
), ),
); );
@@ -15,7 +15,7 @@ class ImageGroup extends StatelessWidget {
final List<Attachment> images; final List<Attachment> images;
final Message message; final Message message;
final MessageTheme? messageTheme; final MessageTheme messageTheme;
final Size size; final Size size;
final ShowMessageCallback? onShowMessage; final ShowMessageCallback? onShowMessage;
@@ -27,15 +27,13 @@ class ImageHeader extends StatelessWidget implements PreferredSizeWidget {
final String userName; final String userName;
final String sentAt; final String sentAt;
final List<Attachment> urls; final int currentIndex;
final currentIndex;
/// Creates a channel header /// Creates a channel header
ImageHeader({ ImageHeader({
Key? key, Key? key,
required this.message, required this.message,
this.urls = const [], this.currentIndex = 0,
this.currentIndex,
this.showBackButton = true, this.showBackButton = true,
this.onBackPressed, this.onBackPressed,
this.onShowMessage, this.onShowMessage,
@@ -20,7 +20,7 @@ class MessageActionsModal extends StatefulWidget {
final OnMessageTap? onThreadReplyTap; final OnMessageTap? onThreadReplyTap;
final OnMessageTap? onReplyTap; final OnMessageTap? onReplyTap;
final Message message; final Message message;
final MessageTheme? messageTheme; final MessageTheme messageTheme;
final bool showReactions; final bool showReactions;
final OnMessageTap? onCopyTap; final OnMessageTap? onCopyTap;
final bool showDeleteMessage; final bool showDeleteMessage;
@@ -92,7 +92,7 @@ class _MessageActionsModalState extends State<MessageActionsModal> {
} }
} }
final roughSentenceSize = messageTextLength * final roughSentenceSize = messageTextLength *
(widget.messageTheme?.messageText?.fontSize ?? 1) * (widget.messageTheme.messageText?.fontSize ?? 1) *
1.2; 1.2;
final divFactor = widget.message.attachments.isNotEmpty == true final divFactor = widget.message.attachments.isNotEmpty == true
? 1 ? 1
@@ -149,7 +149,6 @@ class _MessageActionsModalState extends State<MessageActionsModal> {
0.0), 0.0),
child: ReactionPicker( child: ReactionPicker(
message: widget.message, message: widget.message,
messageTheme: widget.messageTheme,
), ),
), ),
SizedBox(height: 8), SizedBox(height: 8),
@@ -1661,7 +1661,7 @@ class MessageInputState extends State<MessageInput> {
VideoThumbnailImage( VideoThumbnailImage(
height: 104, height: 104,
width: 104, width: 104,
video: attachment.file?.path ?? attachment.assetUrl, video: (attachment.file?.path ?? attachment.assetUrl)!,
fit: BoxFit.cover, fit: BoxFit.cover,
), ),
Positioned( Positioned(
@@ -832,7 +832,7 @@ class _MessageListViewState extends State<MessageListView> {
break; break;
case ReturnActionType.reply: case ReturnActionType.reply:
FocusScope.of(context).unfocus(); FocusScope.of(context).unfocus();
widget.onMessageSwiped!(message); widget.onMessageSwiped?.call(message);
break; break;
} }
}, },
@@ -1008,7 +1008,7 @@ class _MessageListViewState extends State<MessageListView> {
break; break;
case ReturnActionType.reply: case ReturnActionType.reply:
FocusScope.of(context).unfocus(); FocusScope.of(context).unfocus();
widget.onMessageSwiped!(message); widget.onMessageSwiped?.call(message);
break; break;
} }
}, },
@@ -1034,7 +1034,7 @@ class _MessageListViewState extends State<MessageListView> {
child: Swipeable( child: Swipeable(
onSwipeEnd: () { onSwipeEnd: () {
FocusScope.of(context).unfocus(); FocusScope.of(context).unfocus();
widget.onMessageSwiped!(message); widget.onMessageSwiped?.call(message);
}, },
backgroundIcon: StreamSvgIcon.reply( backgroundIcon: StreamSvgIcon.reply(
color: StreamChatTheme.of(context).colorTheme.accentBlue, color: StreamChatTheme.of(context).colorTheme.accentBlue,
@@ -14,7 +14,7 @@ import 'stream_chat_theme.dart';
class MessageReactionsModal extends StatelessWidget { class MessageReactionsModal extends StatelessWidget {
final Message message; final Message message;
final MessageTheme? messageTheme; final MessageTheme messageTheme;
final bool reverse; final bool reverse;
final bool showReactions; final bool showReactions;
final DisplayWidget showUserAvatar; final DisplayWidget showUserAvatar;
@@ -53,7 +53,7 @@ class MessageReactionsModal extends StatelessWidget {
} }
} }
final roughSentenceSize = final roughSentenceSize =
messageTextLength * (messageTheme?.messageText?.fontSize ?? 1) * 1.2; messageTextLength * (messageTheme.messageText?.fontSize ?? 1) * 1.2;
final divFactor = message.attachments.isNotEmpty == true final divFactor = message.attachments.isNotEmpty == true
? 1 ? 1
: (roughSentenceSize == 0 ? 1 : (roughSentenceSize / roughMaxSize)); : (roughSentenceSize == 0 ? 1 : (roughSentenceSize / roughMaxSize));
@@ -105,7 +105,6 @@ class MessageReactionsModal extends StatelessWidget {
0.0), 0.0),
child: ReactionPicker( child: ReactionPicker(
message: message, message: message,
messageTheme: messageTheme,
), ),
), ),
const SizedBox(height: 8), const SizedBox(height: 8),
@@ -244,9 +243,9 @@ class MessageReactionsModal extends StatelessWidget {
child: ReactionBubble( child: ReactionBubble(
reactions: [reaction], reactions: [reaction],
flipTail: !reverse, flipTail: !reverse,
borderColor: messageTheme?.reactionsBorderColor ?? borderColor:
Colors.transparent, messageTheme.reactionsBorderColor ?? Colors.transparent,
backgroundColor: messageTheme?.reactionsBackgroundColor ?? backgroundColor: messageTheme.reactionsBackgroundColor ??
Colors.transparent, Colors.transparent,
maskColor: StreamChatTheme.of(context).colorTheme.white, maskColor: StreamChatTheme.of(context).colorTheme.white,
tailCirclesSpacing: 1, tailCirclesSpacing: 1,
@@ -18,11 +18,11 @@ class MessageText extends StatelessWidget {
final Message message; final Message message;
final void Function(User)? onMentionTap; final void Function(User)? onMentionTap;
final void Function(String)? onLinkTap; final void Function(String)? onLinkTap;
final MessageTheme? messageTheme; final MessageTheme messageTheme;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final text = _replaceMentions(message.text)!.replaceAll('\n', '\\\n'); final text = _replaceMentions(message.text ?? '').replaceAll('\n', '\\\n');
return MarkdownBody( return MarkdownBody(
data: text, data: text,
@@ -55,23 +55,23 @@ class MessageText extends StatelessWidget {
styleSheet: MarkdownStyleSheet.fromTheme( styleSheet: MarkdownStyleSheet.fromTheme(
Theme.of(context).copyWith( Theme.of(context).copyWith(
textTheme: Theme.of(context).textTheme.apply( textTheme: Theme.of(context).textTheme.apply(
bodyColor: messageTheme!.messageText!.color, bodyColor: messageTheme.messageText?.color,
decoration: messageTheme!.messageText!.decoration, decoration: messageTheme.messageText?.decoration,
decorationColor: messageTheme!.messageText!.decorationColor, decorationColor: messageTheme.messageText?.decorationColor,
decorationStyle: messageTheme!.messageText!.decorationStyle, decorationStyle: messageTheme.messageText?.decorationStyle,
fontFamily: messageTheme!.messageText!.fontFamily, fontFamily: messageTheme.messageText?.fontFamily,
), ),
), ),
).copyWith( ).copyWith(
a: messageTheme!.messageLinks, a: messageTheme.messageLinks,
p: messageTheme!.messageText, p: messageTheme.messageText,
), ),
); );
} }
String? _replaceMentions(String? text) { String _replaceMentions(String text) {
message.mentionedUsers.map((u) => u.name).toSet().forEach((userName) { message.mentionedUsers.map((u) => u.name).toSet().forEach((userName) {
text = text!.replaceAll( text = text.replaceAll(
'@$userName', '[@$userName](@${userName.replaceAll(' ', '')})'); '@$userName', '[@$userName](@${userName.replaceAll(' ', '')})');
}); });
return text; return text;
@@ -66,7 +66,7 @@ class MessageWidget extends StatefulWidget {
final Message message; final Message message;
/// The message theme /// The message theme
final MessageTheme? messageTheme; final MessageTheme messageTheme;
/// If true the widget will be mirrored /// If true the widget will be mirrored
final bool reverse; final bool reverse;
@@ -93,7 +93,7 @@ class MessageWidget extends StatefulWidget {
final EdgeInsetsGeometry? padding; final EdgeInsetsGeometry? padding;
/// The internal padding of the message text /// The internal padding of the message text
final EdgeInsetsGeometry textPadding; final EdgeInsets textPadding;
/// The internal padding of an attachment /// The internal padding of an attachment
final EdgeInsetsGeometry attachmentPadding; final EdgeInsetsGeometry attachmentPadding;
@@ -222,7 +222,7 @@ class MessageWidget extends StatefulWidget {
child: wrapAttachmentWidget( child: wrapAttachmentWidget(
context, context,
Material( Material(
color: messageTheme?.messageBackgroundColor, color: messageTheme.messageBackgroundColor,
child: ImageGroup( child: ImageGroup(
size: Size( size: Size(
MediaQuery.of(context).size.width * 0.8, MediaQuery.of(context).size.width * 0.8,
@@ -425,7 +425,7 @@ class _MessageWidgetState extends State<MessageWidget>
Widget build(BuildContext context) { Widget build(BuildContext context) {
super.build(context); super.build(context);
final avatarWidth = final avatarWidth =
widget.messageTheme?.avatarTheme?.constraints.maxWidth ?? 40; widget.messageTheme.avatarTheme?.constraints.maxWidth ?? 40;
var leftPadding = var leftPadding =
widget.showUserAvatar != DisplayWidget.gone ? avatarWidth + 8.5 : 0.5; widget.showUserAvatar != DisplayWidget.gone ? avatarWidth + 8.5 : 0.5;
@@ -544,7 +544,7 @@ class _MessageWidgetState extends State<MessageWidget>
BorderSide( BorderSide(
color: widget color: widget
.messageTheme .messageTheme
?.messageBorderColor ?? .messageBorderColor ??
Colors.grey, Colors.grey,
), ),
borderRadius: widget borderRadius: widget
@@ -702,7 +702,7 @@ class _MessageWidgetState extends State<MessageWidget>
), ),
InkWell( InkWell(
onTap: widget.onThreadTap != null ? onThreadTap : null, onTap: widget.onThreadTap != null ? onThreadTap : null,
child: Text(msg, style: widget.messageTheme?.replies), child: Text(msg, style: widget.messageTheme.replies),
), ),
], ],
if (showUsername) if (showUsername)
@@ -710,13 +710,13 @@ class _MessageWidgetState extends State<MessageWidget>
widget.message.user!.name, widget.message.user!.name,
maxLines: 1, maxLines: 1,
key: usernameKey, key: usernameKey,
style: widget.messageTheme?.messageAuthor, style: widget.messageTheme.messageAuthor,
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
), ),
if (showTimeStamp) if (showTimeStamp)
Text( Text(
Jiffy(widget.message.createdAt.toLocal()).jm, Jiffy(widget.message.createdAt.toLocal()).jm,
style: widget.messageTheme?.createdAt, style: widget.messageTheme.createdAt,
), ),
if (showSendingIndicator) _buildSendingIndicator(), if (showSendingIndicator) _buildSendingIndicator(),
]); ]);
@@ -731,13 +731,13 @@ class _MessageWidgetState extends State<MessageWidget>
Container( Container(
margin: EdgeInsets.only( margin: EdgeInsets.only(
bottom: context.textScaleFactor * bottom: context.textScaleFactor *
((widget.messageTheme?.replies?.fontSize ?? 1) / 2), ((widget.messageTheme.replies?.fontSize ?? 1) / 2),
), ),
child: CustomPaint( child: CustomPaint(
size: Size(16, 32) * context.textScaleFactor, size: Size(16, 32) * context.textScaleFactor,
painter: _ThreadReplyPainter( painter: _ThreadReplyPainter(
context: context, context: context,
color: widget.messageTheme?.messageBorderColor, color: widget.messageTheme.messageBorderColor,
), ),
), ),
), ),
@@ -775,7 +775,7 @@ class _MessageWidgetState extends State<MessageWidget>
return UrlAttachment( return UrlAttachment(
urlAttachment: urlAttachment, urlAttachment: urlAttachment,
hostDisplayName: hostDisplayName, hostDisplayName: hostDisplayName,
textPadding: widget.textPadding as EdgeInsets, textPadding: widget.textPadding,
); );
} }
@@ -830,12 +830,11 @@ class _MessageWidgetState extends State<MessageWidget>
key: ValueKey('${widget.message.id}.reactions'), key: ValueKey('${widget.message.id}.reactions'),
reverse: widget.reverse, reverse: widget.reverse,
flipTail: widget.reverse, flipTail: widget.reverse,
backgroundColor: backgroundColor: widget.messageTheme.reactionsBackgroundColor ??
widget.messageTheme?.reactionsBackgroundColor ??
Colors.transparent,
borderColor: widget.messageTheme?.reactionsBorderColor ??
Colors.transparent, Colors.transparent,
maskColor: widget.messageTheme?.reactionsMaskColor ?? borderColor: widget.messageTheme.reactionsBorderColor ??
Colors.transparent,
maskColor: widget.messageTheme.reactionsMaskColor ??
Colors.transparent, Colors.transparent,
reactions: reactionsList, reactions: reactionsList,
), ),
@@ -1001,7 +1000,7 @@ class _MessageWidgetState extends State<MessageWidget>
} }
Widget _buildSendingIndicator() { Widget _buildSendingIndicator() {
final style = widget.messageTheme?.createdAt; final style = widget.messageTheme.createdAt;
final message = widget.message; final message = widget.message;
if (hasNonUrlAttachments && if (hasNonUrlAttachments &&
@@ -1053,7 +1052,7 @@ class _MessageWidgetState extends State<MessageWidget>
offset: Offset( offset: Offset(
0, 0,
widget.translateUserAvatar widget.translateUserAvatar
? (widget.messageTheme?.avatarTheme?.constraints.maxHeight ?? ? (widget.messageTheme.avatarTheme?.constraints.maxHeight ??
40) / 40) /
2 2
: 0, : 0,
@@ -1061,8 +1060,8 @@ class _MessageWidgetState extends State<MessageWidget>
child: UserAvatar( child: UserAvatar(
user: widget.message.user!, user: widget.message.user!,
onTap: widget.onUserAvatarTap, onTap: widget.onUserAvatarTap,
constraints: widget.messageTheme?.avatarTheme!.constraints, constraints: widget.messageTheme.avatarTheme!.constraints,
borderRadius: widget.messageTheme?.avatarTheme!.borderRadius, borderRadius: widget.messageTheme.avatarTheme!.borderRadius,
showOnlineStatus: false, showOnlineStatus: false,
), ),
), ),
@@ -1085,9 +1084,9 @@ class _MessageWidgetState extends State<MessageWidget>
message: widget.message, message: widget.message,
onMentionTap: widget.onMentionTap, onMentionTap: widget.onMentionTap,
messageTheme: isOnlyEmoji messageTheme: isOnlyEmoji
? widget.messageTheme?.copyWith( ? widget.messageTheme.copyWith(
messageText: messageText:
widget.messageTheme?.messageText!.copyWith( widget.messageTheme.messageText!.copyWith(
fontSize: 42, fontSize: 42,
)) ))
: widget.messageTheme, : widget.messageTheme,
@@ -1103,7 +1102,7 @@ class _MessageWidgetState extends State<MessageWidget>
Color? _getBackgroundColor() { Color? _getBackgroundColor() {
if (hasQuotedMessage) { if (hasQuotedMessage) {
return widget.messageTheme?.messageBackgroundColor; return widget.messageTheme.messageBackgroundColor;
} }
if (hasUrlAttachments) { if (hasUrlAttachments) {
@@ -1118,7 +1117,7 @@ class _MessageWidgetState extends State<MessageWidget>
return Colors.transparent; return Colors.transparent;
} }
return widget.messageTheme?.messageBackgroundColor; return widget.messageTheme.messageBackgroundColor;
} }
void retryMessage(BuildContext context) { void retryMessage(BuildContext context) {
@@ -67,7 +67,7 @@ class QuotedMessageWidget extends StatelessWidget {
final Message message; final Message message;
/// The message theme /// The message theme
final MessageTheme? messageTheme; final MessageTheme messageTheme;
/// If true the widget will be mirrored /// If true the widget will be mirrored
final bool reverse; final bool reverse;
@@ -144,12 +144,12 @@ class QuotedMessageWidget extends StatelessWidget {
child: MessageText( child: MessageText(
message: msg, message: msg,
messageTheme: isOnlyEmoji && _containsText messageTheme: isOnlyEmoji && _containsText
? messageTheme?.copyWith( ? messageTheme.copyWith(
messageText: messageTheme?.messageText?.copyWith( messageText: messageTheme.messageText?.copyWith(
fontSize: 32, fontSize: 32,
)) ))
: messageTheme?.copyWith( : messageTheme.copyWith(
messageText: messageTheme?.messageText?.copyWith( messageText: messageTheme.messageText?.copyWith(
fontSize: 12, fontSize: 12,
)), )),
), ),
@@ -310,6 +310,6 @@ class QuotedMessageWidget extends StatelessWidget {
if (_containsScrapeUrl) { if (_containsScrapeUrl) {
return StreamChatTheme.of(context).colorTheme.blueAlice; return StreamChatTheme.of(context).colorTheme.blueAlice;
} }
return messageTheme?.messageBackgroundColor; return messageTheme.messageBackgroundColor;
} }
} }
@@ -18,11 +18,9 @@ class ReactionPicker extends StatefulWidget {
const ReactionPicker({ const ReactionPicker({
Key? key, Key? key,
required this.message, required this.message,
required this.messageTheme,
}) : super(key: key); }) : super(key: key);
final Message message; final Message message;
final MessageTheme? messageTheme;
@override @override
_ReactionPickerState createState() => _ReactionPickerState(); _ReactionPickerState createState() => _ReactionPickerState();
@@ -32,7 +32,7 @@ import 'package:stream_chat_flutter_core/stream_chat_flutter_core.dart';
/// Use [StreamChat.of] to get the current [StreamChatState] instance. /// Use [StreamChat.of] to get the current [StreamChatState] instance.
class StreamChat extends StatefulWidget { class StreamChat extends StatefulWidget {
final StreamChatClient client; final StreamChatClient client;
final Widget? child; final Widget child;
final StreamChatThemeData? streamChatThemeData; final StreamChatThemeData? streamChatThemeData;
/// The amount of time that will pass before disconnecting the client in the background /// The amount of time that will pass before disconnecting the client in the background
@@ -96,7 +96,7 @@ class StreamChatState extends State<StreamChat> {
client: client, client: client,
onBackgroundEventReceived: widget.onBackgroundEventReceived, onBackgroundEventReceived: widget.onBackgroundEventReceived,
backgroundKeepAlive: widget.backgroundKeepAlive, backgroundKeepAlive: widget.backgroundKeepAlive,
child: widget.child!, child: widget.child,
), ),
); );
}, },
@@ -5,7 +5,7 @@ import 'stream_chat_theme.dart';
class UploadProgressIndicator extends StatelessWidget { class UploadProgressIndicator extends StatelessWidget {
final int uploaded; final int uploaded;
final int total; final int total;
late final Color progressIndicatorColor; final Color progressIndicatorColor;
final EdgeInsetsGeometry padding; final EdgeInsetsGeometry padding;
final bool showBackground; final bool showBackground;
final TextStyle? textStyle; final TextStyle? textStyle;
@@ -14,7 +14,7 @@ class UploadProgressIndicator extends StatelessWidget {
Key? key, Key? key,
required this.uploaded, required this.uploaded,
required this.total, required this.total,
Color? progressIndicatorColor, this.progressIndicatorColor = const Color(0xffb2b2b2),
this.padding = const EdgeInsets.only( this.padding = const EdgeInsets.only(
top: 5, top: 5,
bottom: 5, bottom: 5,
@@ -23,9 +23,7 @@ class UploadProgressIndicator extends StatelessWidget {
), ),
this.showBackground = true, this.showBackground = true,
this.textStyle, this.textStyle,
}) : progressIndicatorColor = }) : super(key: key);
progressIndicatorColor ?? const Color(0xffb2b2b2),
super(key: key);
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@@ -11,16 +11,21 @@ class UrlAttachment extends StatelessWidget {
UrlAttachment({ UrlAttachment({
required this.urlAttachment, required this.urlAttachment,
required this.hostDisplayName, required this.hostDisplayName,
required this.textPadding, this.textPadding = const EdgeInsets.symmetric(
horizontal: 16.0,
vertical: 8.0,
),
}); });
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return GestureDetector( return GestureDetector(
onTap: () => launchURL( onTap: () {
context, launchURL(
urlAttachment.ogScrapeUrl!, context,
), urlAttachment.ogScrapeUrl,
);
},
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch, crossAxisAlignment: CrossAxisAlignment.stretch,
children: [ children: [
+33 -31
View File
@@ -22,10 +22,10 @@ Future<void> launchURL(BuildContext context, String? url) async {
Future<bool?> showConfirmationDialog( Future<bool?> showConfirmationDialog(
BuildContext context, { BuildContext context, {
String? title, required String title,
required String okText,
Widget? icon, Widget? icon,
String? question, String? question,
String? okText,
String? cancelText, String? cancelText,
}) { }) {
return showModalBottomSheet( return showModalBottomSheet(
@@ -46,14 +46,15 @@ Future<bool?> showConfirmationDialog(
if (icon != null) icon, if (icon != null) icon,
SizedBox(height: 26.0), SizedBox(height: 26.0),
Text( Text(
title!, title,
style: StreamChatTheme.of(context).textTheme.headlineBold, style: StreamChatTheme.of(context).textTheme.headlineBold,
), ),
SizedBox(height: 7.0), SizedBox(height: 7.0),
Text( if (question != null)
question!, Text(
textAlign: TextAlign.center, question,
), textAlign: TextAlign.center,
),
SizedBox(height: 36.0), SizedBox(height: 36.0),
Container( Container(
color: effect.color!.withOpacity(effect.alpha ?? 1), color: effect.color!.withOpacity(effect.alpha ?? 1),
@@ -61,27 +62,28 @@ Future<bool?> showConfirmationDialog(
), ),
Row( Row(
children: [ children: [
Flexible( if (cancelText != null)
child: Container( Flexible(
alignment: Alignment.center, child: Container(
child: TextButton( alignment: Alignment.center,
onPressed: () { child: TextButton(
Navigator.of(context).pop(false); onPressed: () {
}, Navigator.of(context).pop(false);
child: Text( },
cancelText!, child: Text(
style: StreamChatTheme.of(context) cancelText,
.textTheme style: StreamChatTheme.of(context)
.bodyBold .textTheme
.copyWith( .bodyBold
color: StreamChatTheme.of(context) .copyWith(
.colorTheme color: StreamChatTheme.of(context)
.black .colorTheme
.withOpacity(0.5)), .black
.withOpacity(0.5)),
),
), ),
), ),
), ),
),
Flexible( Flexible(
child: Container( child: Container(
alignment: Alignment.center, alignment: Alignment.center,
@@ -90,7 +92,7 @@ Future<bool?> showConfirmationDialog(
Navigator.pop(context, true); Navigator.pop(context, true);
}, },
child: Text( child: Text(
okText!, okText,
style: StreamChatTheme.of(context) style: StreamChatTheme.of(context)
.textTheme .textTheme
.bodyBold .bodyBold
@@ -112,10 +114,10 @@ Future<bool?> showConfirmationDialog(
Future<bool?> showInfoDialog( Future<bool?> showInfoDialog(
BuildContext context, { BuildContext context, {
String? title, required String title,
required String okText,
Widget? icon, Widget? icon,
String? details, String? details,
String? okText,
StreamChatThemeData? theme, StreamChatThemeData? theme,
}) { }) {
return showModalBottomSheet( return showModalBottomSheet(
@@ -140,14 +142,14 @@ Future<bool?> showInfoDialog(
height: 26.0, height: 26.0,
), ),
Text( Text(
title!, title,
style: theme?.textTheme.headlineBold ?? style: theme?.textTheme.headlineBold ??
StreamChatTheme.of(context).textTheme.headlineBold, StreamChatTheme.of(context).textTheme.headlineBold,
), ),
SizedBox( SizedBox(
height: 7.0, height: 7.0,
), ),
Text(details!), if (details != null) Text(details),
SizedBox( SizedBox(
height: 36.0, height: 36.0,
), ),
@@ -162,7 +164,7 @@ Future<bool?> showInfoDialog(
Navigator.of(context).pop(); Navigator.of(context).pop();
}, },
child: Text( child: Text(
okText!, okText,
style: TextStyle( style: TextStyle(
color: theme?.colorTheme.black.withOpacity(0.5) ?? color: theme?.colorTheme.black.withOpacity(0.5) ??
StreamChatTheme.of(context).colorTheme.accentBlue, StreamChatTheme.of(context).colorTheme.accentBlue,
@@ -9,7 +9,7 @@ import 'stream_svg_icon.dart';
import 'video_service.dart'; import 'video_service.dart';
class VideoThumbnailImage extends StatefulWidget { class VideoThumbnailImage extends StatefulWidget {
final String? video; final String video;
final double? width; final double? width;
final double? height; final double? height;
final BoxFit? fit; final BoxFit? fit;
@@ -38,7 +38,7 @@ class _VideoThumbnailImageState extends State<VideoThumbnailImage> {
@override @override
void initState() { void initState() {
thumbnailFuture = VideoService.generateVideoThumbnail( thumbnailFuture = VideoService.generateVideoThumbnail(
video: widget.video!, video: widget.video,
imageFormat: widget.format, imageFormat: widget.format,
); );
super.initState(); super.initState();
@@ -48,7 +48,7 @@ class _VideoThumbnailImageState extends State<VideoThumbnailImage> {
void didUpdateWidget(covariant VideoThumbnailImage oldWidget) { void didUpdateWidget(covariant VideoThumbnailImage oldWidget) {
if (oldWidget.video != widget.video || oldWidget.format != widget.format) { if (oldWidget.video != widget.video || oldWidget.format != widget.format) {
thumbnailFuture = VideoService.generateVideoThumbnail( thumbnailFuture = VideoService.generateVideoThumbnail(
video: widget.video!, video: widget.video,
imageFormat: widget.format, imageFormat: widget.format,
); );
} }
@@ -278,7 +278,7 @@ void main() {
builder: (context, child) { builder: (context, child) {
return StreamChat( return StreamChat(
client: client, client: client,
child: child, child: child!,
); );
}, },
home: StreamChannel( home: StreamChannel(
@@ -331,7 +331,7 @@ void main() {
builder: (context, child) { builder: (context, child) {
return StreamChat( return StreamChat(
client: client, client: client,
child: child, child: child!,
); );
}, },
home: StreamChannel( home: StreamChannel(
@@ -381,7 +381,7 @@ void main() {
builder: (context, child) { builder: (context, child) {
return StreamChat( return StreamChat(
client: client, client: client,
child: child, child: child!,
); );
}, },
home: StreamChannel( home: StreamChannel(
@@ -415,7 +415,7 @@ void main() {
builder: (context, child) { builder: (context, child) {
return StreamChat( return StreamChat(
client: client, client: client,
child: child, child: child!,
); );
}, },
home: Container( home: Container(
@@ -472,7 +472,7 @@ void main() {
builder: (context, child) { builder: (context, child) {
return StreamChat( return StreamChat(
client: client, client: client,
child: child, child: child!,
); );
}, },
home: Container( home: Container(
@@ -264,7 +264,7 @@ void main() {
return StreamChat( return StreamChat(
client: client, client: client,
streamChatThemeData: streamTheme, streamChatThemeData: streamTheme,
child: child, child: child!,
); );
}, },
theme: themeData, theme: themeData,
@@ -314,7 +314,7 @@ void main() {
return StreamChat( return StreamChat(
client: client, client: client,
streamChatThemeData: streamTheme, streamChatThemeData: streamTheme,
child: child, child: child!,
); );
}, },
theme: themeData, theme: themeData,
@@ -369,7 +369,7 @@ void main() {
return StreamChat( return StreamChat(
client: client, client: client,
streamChatThemeData: streamTheme, streamChatThemeData: streamTheme,
child: child, child: child!,
); );
}, },
theme: themeData, theme: themeData,
@@ -420,7 +420,7 @@ void main() {
return StreamChat( return StreamChat(
client: client, client: client,
streamChatThemeData: streamTheme, streamChatThemeData: streamTheme,
child: child, child: child!,
); );
}, },
theme: themeData, theme: themeData,
@@ -471,7 +471,7 @@ void main() {
return StreamChat( return StreamChat(
client: client, client: client,
streamChatThemeData: streamTheme, streamChatThemeData: streamTheme,
child: child, child: child!,
); );
}, },
theme: themeData, theme: themeData,
@@ -520,7 +520,7 @@ void main() {
return StreamChat( return StreamChat(
client: client, client: client,
streamChatThemeData: streamTheme, streamChatThemeData: streamTheme,
child: child, child: child!,
); );
}, },
theme: themeData, theme: themeData,
@@ -579,7 +579,7 @@ void main() {
return StreamChat( return StreamChat(
client: client, client: client,
streamChatThemeData: streamTheme, streamChatThemeData: streamTheme,
child: child, child: child!,
); );
}, },
theme: themeData, theme: themeData,
@@ -638,7 +638,7 @@ void main() {
return StreamChat( return StreamChat(
client: client, client: client,
streamChatThemeData: streamTheme, streamChatThemeData: streamTheme,
child: child, child: child!,
); );
}, },
theme: themeData, theme: themeData,
@@ -693,7 +693,7 @@ void main() {
return StreamChat( return StreamChat(
client: client, client: client,
streamChatThemeData: streamTheme, streamChatThemeData: streamTheme,
child: child, child: child!,
); );
}, },
theme: themeData, theme: themeData,
@@ -752,7 +752,7 @@ void main() {
return StreamChat( return StreamChat(
client: client, client: client,
streamChatThemeData: streamTheme, streamChatThemeData: streamTheme,
child: child, child: child!,
); );
}, },
theme: themeData, theme: themeData,