diff --git a/packages/stream_chat_flutter/lib/src/attachment/attachment_upload_state_builder.dart b/packages/stream_chat_flutter/lib/src/attachment/attachment_upload_state_builder.dart index e7abac74..825def58 100644 --- a/packages/stream_chat_flutter/lib/src/attachment/attachment_upload_state_builder.dart +++ b/packages/stream_chat_flutter/lib/src/attachment/attachment_upload_state_builder.dart @@ -10,13 +10,7 @@ typedef FailedBuilder = Widget Function(BuildContext, String); /// Widget to display attachment upload state class AttachmentUploadStateBuilder extends StatelessWidget { - final Message message; - final Attachment attachment; - final FailedBuilder? failedBuilder; - final WidgetBuilder? successBuilder; - final InProgressBuilder? inProgressBuilder; - final WidgetBuilder? preparingBuilder; - + /// Constructor for creating an [AttachmentUploadStateBuilder] widget const AttachmentUploadStateBuilder({ Key? key, required this.message, @@ -27,32 +21,46 @@ class AttachmentUploadStateBuilder extends StatelessWidget { this.preparingBuilder, }) : super(key: key); + /// Message which attachment is added to + final Message message; + + /// Attachment in concern + final Attachment attachment; + + /// Widget to display when failed + final FailedBuilder? failedBuilder; + + /// Widget to display when succeeded + final WidgetBuilder? successBuilder; + + /// Widget to display when in progress + final InProgressBuilder? inProgressBuilder; + + /// Widget to display when in prep + final WidgetBuilder? preparingBuilder; + @override Widget build(BuildContext context) { if (message.status == MessageSendingStatus.sent) { - return Offstage(); + return const Offstage(); } final messageId = message.id; final attachmentId = attachment.id; final inProgress = inProgressBuilder ?? - (context, int sent, int total) { - return _InProgressState( - sent: sent, - total: total, - attachmentId: attachmentId, - ); - }; + (context, int sent, int total) => _InProgressState( + sent: sent, + total: total, + attachmentId: attachmentId, + ); final failed = failedBuilder ?? - (context, error) { - return _FailedState( - error: error, - messageId: messageId, - attachmentId: attachmentId, - ); - }; + (context, error) => _FailedState( + error: error, + messageId: messageId, + attachmentId: attachmentId, + ); final success = successBuilder ?? (context) => _SuccessState(); @@ -69,11 +77,6 @@ class AttachmentUploadStateBuilder extends StatelessWidget { } class _IconButton extends StatelessWidget { - final Widget? icon; - final double iconSize; - final VoidCallback? onPressed; - final Color? fillColor; - const _IconButton({ Key? key, this.icon, @@ -82,36 +85,39 @@ class _IconButton extends StatelessWidget { this.fillColor, }) : super(key: key); + final Widget? icon; + final double iconSize; + final VoidCallback? onPressed; + final Color? fillColor; + @override - Widget build(BuildContext context) { - return Container( - height: iconSize, - width: iconSize, - child: RawMaterialButton( - elevation: 0, - highlightElevation: 0, - focusElevation: 0, - hoverElevation: 0, - onPressed: onPressed, - fillColor: - fillColor ?? StreamChatTheme.of(context).colorTheme.overlayDark, - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(16), + Widget build(BuildContext context) => SizedBox( + height: iconSize, + width: iconSize, + child: RawMaterialButton( + elevation: 0, + highlightElevation: 0, + focusElevation: 0, + hoverElevation: 0, + onPressed: onPressed, + fillColor: + fillColor ?? StreamChatTheme.of(context).colorTheme.overlayDark, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(16), + ), + child: icon, ), - child: icon, - ), - ); - } + ); } class _PreparingState extends StatelessWidget { - final String attachmentId; - const _PreparingState({ Key? key, required this.attachmentId, }) : super(key: key); + final String attachmentId; + @override Widget build(BuildContext context) { final channel = StreamChannel.of(context).channel; @@ -141,10 +147,6 @@ class _PreparingState extends StatelessWidget { } class _InProgressState extends StatelessWidget { - final int sent; - final int total; - final String attachmentId; - const _InProgressState({ Key? key, required this.sent, @@ -152,6 +154,10 @@ class _InProgressState extends StatelessWidget { required this.attachmentId, }) : super(key: key); + final int sent; + final int total; + final String attachmentId; + @override Widget build(BuildContext context) { final channel = StreamChannel.of(context).channel; @@ -181,10 +187,6 @@ class _InProgressState extends StatelessWidget { } class _FailedState extends StatelessWidget { - final String? error; - final String messageId; - final String attachmentId; - const _FailedState({ Key? key, this.error, @@ -192,6 +194,10 @@ class _FailedState extends StatelessWidget { required this.attachmentId, }) : super(key: key); + final String? error; + final String messageId; + final String attachmentId; + @override Widget build(BuildContext context) { final channel = StreamChannel.of(context).channel; @@ -235,16 +241,14 @@ class _FailedState extends StatelessWidget { class _SuccessState extends StatelessWidget { @override - Widget build(BuildContext context) { - return Align( - alignment: Alignment.topRight, - child: CircleAvatar( - backgroundColor: StreamChatTheme.of(context).colorTheme.overlayDark, - maxRadius: 12, - child: StreamSvgIcon.check( - color: StreamChatTheme.of(context).colorTheme.white, + Widget build(BuildContext context) => Align( + alignment: Alignment.topRight, + child: CircleAvatar( + backgroundColor: StreamChatTheme.of(context).colorTheme.overlayDark, + maxRadius: 12, + child: StreamSvgIcon.check( + color: StreamChatTheme.of(context).colorTheme.white, + ), ), - ), - ); - } + ); } diff --git a/packages/stream_chat_flutter/lib/src/attachment/attachment_widget.dart b/packages/stream_chat_flutter/lib/src/attachment/attachment_widget.dart index d80109c2..74769057 100644 --- a/packages/stream_chat_flutter/lib/src/attachment/attachment_widget.dart +++ b/packages/stream_chat_flutter/lib/src/attachment/attachment_widget.dart @@ -1,13 +1,17 @@ import 'package:flutter/material.dart'; +import 'package:stream_chat_flutter/stream_chat_flutter.dart'; import 'package:stream_chat_flutter_core/stream_chat_flutter_core.dart'; -import '../stream_chat_theme.dart'; - +/// Enum for identifying type of attachment enum AttachmentSource { + /// Attachment is attached local, + + /// Attachment is uploaded network, } +/// Extension for identifying type of attachment extension AttachmentSourceX on AttachmentSource { /// The [when] method is the equivalent to pattern matching. /// Its prototype depends on the AttachmentSource defined. @@ -25,18 +29,9 @@ extension AttachmentSourceX on AttachmentSource { } } +/// Abstract class for deriving attachment types abstract class AttachmentWidget extends StatelessWidget { - final Size? size; - final AttachmentSource? _source; - final Message message; - final Attachment attachment; - - AttachmentSource get source => - _source ?? - (attachment.file != null - ? AttachmentSource.local - : AttachmentSource.network); - + /// Constructor for creating attachment widget const AttachmentWidget({ Key? key, required this.message, @@ -45,30 +40,48 @@ abstract class AttachmentWidget extends StatelessWidget { AttachmentSource? source, }) : _source = source, super(key: key); + + /// Size of attachments + final Size? size; + final AttachmentSource? _source; + + /// Message which attachment is attached to + final Message message; + + /// Attachment to display + final Attachment attachment; + + /// Getter for source of attachment + AttachmentSource get source => + _source ?? + (attachment.file != null + ? AttachmentSource.local + : AttachmentSource.network); } +/// Widget for building in case of error class AttachmentError extends StatelessWidget { - final Size? size; - + /// Constructor for creating AttachmentError const AttachmentError({ Key? key, this.size, }) : super(key: key); + final Size? size; + @override - Widget build(BuildContext context) { - return Center( - child: Container( - width: size?.width, - height: size?.height, - color: StreamChatTheme.of(context).colorTheme.accentRed.withOpacity(.1), - child: Center( - child: Icon( - Icons.error_outline, - color: StreamChatTheme.of(context).colorTheme.black, + Widget build(BuildContext context) => Center( + child: Container( + width: size?.width, + height: size?.height, + color: + StreamChatTheme.of(context).colorTheme.accentRed.withOpacity(.1), + child: Center( + child: Icon( + Icons.error_outline, + color: StreamChatTheme.of(context).colorTheme.black, + ), ), ), - ), - ); - } + ); } diff --git a/packages/stream_chat_flutter/lib/src/attachment/file_attachment.dart b/packages/stream_chat_flutter/lib/src/attachment/file_attachment.dart index 0ef78d85..c68d72f9 100644 --- a/packages/stream_chat_flutter/lib/src/attachment/file_attachment.dart +++ b/packages/stream_chat_flutter/lib/src/attachment/file_attachment.dart @@ -11,10 +11,7 @@ import '../upload_progress_indicator.dart'; import 'attachment_widget.dart'; class FileAttachment extends AttachmentWidget { - final Widget? title; - final Widget? trailing; - final VoidCallback? onAttachmentTap; - + /// Constructor for creating a widget when attachment is of type 'file' const FileAttachment({ Key? key, required Message message, @@ -30,8 +27,19 @@ class FileAttachment extends AttachmentWidget { size: size, ); + /// Title for attachment + final Widget? title; + + /// Widget for displaying at the end of attachment (such as a download button) + final Widget? trailing; + + /// Callback called when attachment widget is tapped + final VoidCallback? onAttachmentTap; + + /// Check if attachment is a video bool get isVideoAttachment => attachment.title?.mimeType?.type == 'video'; + /// Check if attachment is an image bool get isImageAttachment => attachment.title?.mimeType?.type == 'image'; @override @@ -56,10 +64,10 @@ class FileAttachment extends AttachmentWidget { Container( height: 40, width: 33.33, - margin: EdgeInsets.all(8), + margin: const EdgeInsets.all(8), child: _getFileTypeImage(context), ), - SizedBox(width: 8), + const SizedBox(width: 8), Expanded( child: Column( mainAxisAlignment: MainAxisAlignment.center, @@ -71,12 +79,12 @@ class FileAttachment extends AttachmentWidget { maxLines: 1, overflow: TextOverflow.ellipsis, ), - SizedBox(height: 3), + const SizedBox(height: 3), _buildSubtitle(context), ], ), ), - SizedBox(width: 8), + const SizedBox(width: 8), _buildTrailing(context), ], ), @@ -85,12 +93,10 @@ class FileAttachment extends AttachmentWidget { ); } - ShapeBorder _getDefaultShape(BuildContext context) { - return RoundedRectangleBorder( - side: BorderSide(width: 0, color: Colors.transparent), - borderRadius: BorderRadius.circular(8), - ); - } + ShapeBorder _getDefaultShape(BuildContext context) => RoundedRectangleBorder( + side: const BorderSide(width: 0, color: Colors.transparent), + borderRadius: BorderRadius.circular(8), + ); Widget _getFileTypeImage(BuildContext context) { if (isImageAttachment) { @@ -106,10 +112,8 @@ class FileAttachment extends AttachmentWidget { return Image.memory( attachment.file!.bytes!, fit: BoxFit.cover, - errorBuilder: (_, obj, trace) { - return getFileTypeImage( - attachment.extraData['other'] as String?); - }, + errorBuilder: (_, obj, trace) => + getFileTypeImage(attachment.extraData['other'] as String?), ); }, network: () { @@ -124,10 +128,8 @@ class FileAttachment extends AttachmentWidget { attachment.assetUrl ?? attachment.thumbUrl!, fit: BoxFit.cover, - errorWidget: (_, obj, trace) { - return getFileTypeImage( - attachment.extraData['other'] as String?); - }, + errorWidget: (_, obj, trace) => + getFileTypeImage(attachment.extraData['other'] as String?), placeholder: (_, __) { final image = Image.asset( 'images/placeholder.png', @@ -156,27 +158,23 @@ class FileAttachment extends AttachmentWidget { child: source.when( local: () => VideoThumbnailImage( video: attachment.file!.path!, - placeholderBuilder: (_) { - return Center( - child: Container( - width: 20, - height: 20, - child: const CircularProgressIndicator(), - ), - ); - }, + placeholderBuilder: (_) => const Center( + child: SizedBox( + width: 20, + height: 20, + child: CircularProgressIndicator(), + ), + ), ), network: () => VideoThumbnailImage( video: attachment.assetUrl!, - placeholderBuilder: (_) { - return Center( - child: Container( - width: 20, - height: 20, - child: const CircularProgressIndicator(), - ), - ); - }, + placeholderBuilder: (_) => const Center( + child: SizedBox( + width: 20, + height: 20, + child: CircularProgressIndicator(), + ), + ), ), ), ); @@ -189,22 +187,22 @@ class FileAttachment extends AttachmentWidget { double iconSize = 24.0, VoidCallback? onPressed, Color? fillColor, - }) { - return Container( - height: iconSize, - width: iconSize, - child: RawMaterialButton( - elevation: 0, - highlightElevation: 0, - focusElevation: 0, - hoverElevation: 0, - onPressed: onPressed, - fillColor: fillColor, - shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)), - child: icon, - ), - ); - } + }) => + SizedBox( + height: iconSize, + width: iconSize, + child: RawMaterialButton( + elevation: 0, + highlightElevation: 0, + focusElevation: 0, + hoverElevation: 0, + onPressed: onPressed, + fillColor: fillColor, + shape: + RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)), + child: icon, + ), + ); Widget _buildTrailing(BuildContext context) { final theme = StreamChatTheme.of(context); @@ -281,26 +279,22 @@ class FileAttachment extends AttachmentWidget { color: theme.colorTheme.grey, ); return attachment.uploadState.when( - preparing: () { - return UploadProgressIndicator( - uploaded: 0, - total: double.maxFinite.toInt(), - showBackground: false, - padding: EdgeInsets.zero, - textStyle: textStyle, - progressIndicatorColor: theme.colorTheme.accentBlue, - ); - }, - inProgress: (sent, total) { - return UploadProgressIndicator( - uploaded: sent, - total: total, - showBackground: false, - padding: EdgeInsets.zero, - textStyle: textStyle, - progressIndicatorColor: theme.colorTheme.accentBlue, - ); - }, + preparing: () => UploadProgressIndicator( + uploaded: 0, + total: double.maxFinite.toInt(), + showBackground: false, + padding: EdgeInsets.zero, + textStyle: textStyle, + progressIndicatorColor: theme.colorTheme.accentBlue, + ), + inProgress: (sent, total) => UploadProgressIndicator( + uploaded: sent, + total: total, + showBackground: false, + padding: EdgeInsets.zero, + textStyle: textStyle, + progressIndicatorColor: theme.colorTheme.accentBlue, + ), success: () => Text(fileSize(size), style: textStyle), failed: (_) => Text('UPLOAD ERROR', style: textStyle), ) ?? diff --git a/packages/stream_chat_flutter/lib/src/attachment/giphy_attachment.dart b/packages/stream_chat_flutter/lib/src/attachment/giphy_attachment.dart index 27e98f10..1bbbd54f 100644 --- a/packages/stream_chat_flutter/lib/src/attachment/giphy_attachment.dart +++ b/packages/stream_chat_flutter/lib/src/attachment/giphy_attachment.dart @@ -1,18 +1,13 @@ 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/stream_chat_flutter.dart'; import 'package:stream_chat_flutter_core/stream_chat_flutter_core.dart'; -import '../full_screen_media.dart'; -import '../stream_chat_theme.dart'; -import '../stream_svg_icon.dart'; -import 'attachment_widget.dart'; - +/// Widget for showing a GIF attachment class GiphyAttachment extends AttachmentWidget { - final ShowMessageCallback? onShowMessage; - final ValueChanged? onReturnAction; - final VoidCallback? onAttachmentTap; - + /// Constructor for creating a [GiphyAttachment] widget const GiphyAttachment({ Key? key, required Message message, @@ -28,12 +23,21 @@ class GiphyAttachment extends AttachmentWidget { size: size, ); + /// Callback when show message is tapped + final ShowMessageCallback? onShowMessage; + + /// Callback when attachment is returned to from other screens + final ValueChanged? onReturnAction; + + /// Callback when attachment is tapped + final VoidCallback? onAttachmentTap; + @override Widget build(BuildContext context) { final imageUrl = attachment.thumbUrl ?? attachment.imageUrl ?? attachment.assetUrl; if (imageUrl == null) { - return AttachmentError(); + return const AttachmentError(); } if (attachment.actions.isNotEmpty) { return _buildSendingAttachment(context, imageUrl); @@ -50,10 +54,9 @@ class GiphyAttachment extends AttachmentWidget { color: StreamChatTheme.of(context).colorTheme.white, elevation: 2, clipBehavior: Clip.antiAlias, - shape: RoundedRectangleBorder( + shape: const RoundedRectangleBorder( borderRadius: BorderRadius.only( topRight: Radius.circular(16), - bottomRight: Radius.circular(0), topLeft: Radius.circular(16), bottomLeft: Radius.circular(16), ), @@ -67,12 +70,12 @@ class GiphyAttachment extends AttachmentWidget { child: Row( children: [ StreamSvgIcon.giphyIcon(), - SizedBox(width: 8), - Text( + const SizedBox(width: 8), + const Text( 'Giphy', style: TextStyle(fontWeight: FontWeight.bold), ), - SizedBox(width: 8), + const SizedBox(width: 8), if (attachment.title != null) Flexible( child: Text( @@ -97,19 +100,16 @@ class GiphyAttachment extends AttachmentWidget { child: CachedNetworkImage( height: size?.height, width: size?.width, - placeholder: (_, __) { - return Container( - width: size?.width, - height: size?.height, - child: Center( - child: CircularProgressIndicator(), - ), - ); - }, + placeholder: (_, __) => SizedBox( + width: size?.width, + height: size?.height, + child: const Center( + child: CircularProgressIndicator(), + ), + ), imageUrl: imageUrl, - errorWidget: (context, url, error) { - return AttachmentError(size: size); - }, + errorWidget: (context, url, error) => + AttachmentError(size: size), fit: BoxFit.cover, ), ), @@ -125,7 +125,7 @@ class GiphyAttachment extends AttachmentWidget { Row( children: [ Expanded( - child: Container( + child: SizedBox( height: 50, child: TextButton( onPressed: () { @@ -157,7 +157,7 @@ class GiphyAttachment extends AttachmentWidget { height: 50, ), Expanded( - child: Container( + child: SizedBox( height: 50, child: TextButton( onPressed: () { @@ -190,7 +190,7 @@ class GiphyAttachment extends AttachmentWidget { height: 50, ), Expanded( - child: Container( + child: SizedBox( height: 50, child: TextButton( onPressed: () { @@ -215,7 +215,7 @@ class GiphyAttachment extends AttachmentWidget { ], ), ), - SizedBox(height: 4), + const SizedBox(height: 4), Align( alignment: Alignment.centerRight, child: Padding( @@ -230,7 +230,7 @@ class GiphyAttachment extends AttachmentWidget { .withOpacity(0.5), size: 16, ), - SizedBox( + const SizedBox( width: 8, ), Text( @@ -273,88 +273,86 @@ class GiphyAttachment extends AttachmentWidget { if (res != null) onReturnAction?.call(res); } - Widget _buildSentAttachment(BuildContext context, String imageUrl) { - return Container( - child: GestureDetector( - onTap: () async { - final res = - await Navigator.push(context, MaterialPageRoute(builder: (_) { - final channel = StreamChannel.of(context).channel; - return StreamChannel( - channel: channel, - child: FullScreenMedia( - mediaAttachments: [attachment], - userName: message.user?.name, - message: message, - onShowMessage: onShowMessage, - ), - ); - })); - if (res != null) onReturnAction!(res); - }, - child: Stack( - children: [ - CachedNetworkImage( - height: size?.height, - width: size?.width, - placeholder: (_, __) { - final image = Image.asset( - 'images/placeholder.png', - fit: BoxFit.cover, - package: 'stream_chat_flutter', - ); + Widget _buildSentAttachment(BuildContext context, String imageUrl) => + SizedBox( + child: GestureDetector( + onTap: () async { + final res = + await Navigator.push(context, MaterialPageRoute(builder: (_) { + final channel = StreamChannel.of(context).channel; + return StreamChannel( + channel: channel, + child: FullScreenMedia( + mediaAttachments: [attachment], + userName: message.user?.name, + message: message, + onShowMessage: onShowMessage, + ), + ); + })); + if (res != null) onReturnAction!(res); + }, + child: Stack( + children: [ + CachedNetworkImage( + height: size?.height, + width: size?.width, + placeholder: (_, __) { + final image = Image.asset( + 'images/placeholder.png', + fit: BoxFit.cover, + package: 'stream_chat_flutter', + ); - final colorTheme = StreamChatTheme.of(context).colorTheme; - return Shimmer.fromColors( - baseColor: colorTheme.greyGainsboro, - highlightColor: colorTheme.whiteSmoke, - child: image, - ); - }, - imageUrl: imageUrl, - errorWidget: (context, url, error) { - return AttachmentError(size: size); - }, - fit: BoxFit.cover, - ), - Positioned( - bottom: 8, - left: 8, - child: Material( - color: StreamChatTheme.of(context) - .colorTheme - .black - .withOpacity(.5), - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(12), - ), - child: Padding( - padding: const EdgeInsets.symmetric( - horizontal: 8, - vertical: 4, + final colorTheme = StreamChatTheme.of(context).colorTheme; + return Shimmer.fromColors( + baseColor: colorTheme.greyGainsboro, + highlightColor: colorTheme.whiteSmoke, + child: image, + ); + }, + imageUrl: imageUrl, + errorWidget: (context, url, error) => + AttachmentError(size: size), + fit: BoxFit.cover, + ), + Positioned( + bottom: 8, + left: 8, + child: Material( + color: StreamChatTheme.of(context) + .colorTheme + .black + .withOpacity(.5), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(12), ), - child: Row( - children: [ - StreamSvgIcon.lightning( - color: StreamChatTheme.of(context).colorTheme.white, - size: 16, - ), - Text( - 'GIPHY', - style: TextStyle( + child: Padding( + padding: const EdgeInsets.symmetric( + horizontal: 8, + vertical: 4, + ), + child: Row( + children: [ + StreamSvgIcon.lightning( color: StreamChatTheme.of(context).colorTheme.white, - fontWeight: FontWeight.bold, - fontSize: 11, + size: 16, ), - ), - ], + Text( + 'GIPHY', + style: TextStyle( + color: StreamChatTheme.of(context).colorTheme.white, + fontWeight: FontWeight.bold, + fontSize: 11, + ), + ), + ], + ), ), ), ), - ), - ], + ], + ), ), - ), - ); - } + ); } diff --git a/packages/stream_chat_flutter/lib/src/attachment/image_attachment.dart b/packages/stream_chat_flutter/lib/src/attachment/image_attachment.dart index 652a6826..5c431d6e 100644 --- a/packages/stream_chat_flutter/lib/src/attachment/image_attachment.dart +++ b/packages/stream_chat_flutter/lib/src/attachment/image_attachment.dart @@ -1,21 +1,15 @@ 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_title.dart'; import 'package:stream_chat_flutter/src/attachment/attachment_upload_state_builder.dart'; +import 'package:stream_chat_flutter/src/attachment/attachment_widget.dart'; +import 'package:stream_chat_flutter/stream_chat_flutter.dart'; import 'package:stream_chat_flutter_core/stream_chat_flutter_core.dart'; -import '../full_screen_media.dart'; -import '../stream_chat_theme.dart'; -import 'attachment_title.dart'; -import 'attachment_widget.dart'; - +/// Widget for showing an image attachment class ImageAttachment extends AttachmentWidget { - final MessageTheme messageTheme; - final bool showTitle; - final ShowMessageCallback? onShowMessage; - final ValueChanged? onReturnAction; - final VoidCallback? onAttachmentTap; - + /// Constructor for creating a [ImageAttachment] widget const ImageAttachment({ Key? key, required Message message, @@ -33,6 +27,21 @@ class ImageAttachment extends AttachmentWidget { size: size, ); + /// [MessageTheme] for showing image title + final MessageTheme messageTheme; + + /// Flag for showing title + final bool showTitle; + + /// Callback when show message is tapped + final ShowMessageCallback? onShowMessage; + + /// Callback when attachment is returned to from other screens + final ValueChanged? onReturnAction; + + /// Callback when attachment is tapped + final VoidCallback? onAttachmentTap; + @override Widget build(BuildContext context) => source.when( local: () { diff --git a/packages/stream_chat_flutter/lib/src/attachment/video_attachment.dart b/packages/stream_chat_flutter/lib/src/attachment/video_attachment.dart index f74bba14..b743cda1 100644 --- a/packages/stream_chat_flutter/lib/src/attachment/video_attachment.dart +++ b/packages/stream_chat_flutter/lib/src/attachment/video_attachment.dart @@ -1,18 +1,13 @@ import 'package:flutter/material.dart'; +import 'package:stream_chat_flutter/src/attachment/attachment_title.dart'; +import 'package:stream_chat_flutter/src/attachment/attachment_widget.dart'; import 'package:stream_chat_flutter/src/full_screen_media.dart'; import 'package:stream_chat_flutter/src/video_thumbnail_image.dart'; import 'package:stream_chat_flutter/stream_chat_flutter.dart'; -import 'attachment_title.dart'; -import 'attachment_upload_state_builder.dart'; -import 'attachment_widget.dart'; - +/// Widget for showing a video attachment class VideoAttachment extends AttachmentWidget { - final MessageTheme messageTheme; - final ShowMessageCallback? onShowMessage; - final ValueChanged? onReturnAction; - final VoidCallback? onAttachmentTap; - + /// Constructor for creating a [VideoAttachment] widget const VideoAttachment({ Key? key, required Message message, @@ -29,6 +24,18 @@ class VideoAttachment extends AttachmentWidget { size: size, ); + /// [MessageTheme] for showing title + final MessageTheme messageTheme; + + /// Callback when show message is tapped + final ShowMessageCallback? onShowMessage; + + /// Callback when attachment is returned to from other screens + final ValueChanged? onReturnAction; + + /// Callback when attachment is tapped + final VoidCallback? onAttachmentTap; + @override Widget build(BuildContext context) => source.when( local: () { diff --git a/packages/stream_chat_flutter/lib/src/channel_info.dart b/packages/stream_chat_flutter/lib/src/channel_info.dart index 493729b9..abd1680c 100644 --- a/packages/stream_chat_flutter/lib/src/channel_info.dart +++ b/packages/stream_chat_flutter/lib/src/channel_info.dart @@ -100,7 +100,7 @@ class ChannelInfo extends StatelessWidget { child: CircularProgressIndicator(), ), ), - SizedBox(width: 10), + const SizedBox(width: 10), Text( 'Searching for Network', style: textStyle,