From 93b41588976aea0ae6379c16710aedfe2aa2690e Mon Sep 17 00:00:00 2001 From: Sahil Kumar Date: Fri, 28 Jul 2023 20:04:13 +0530 Subject: [PATCH] refactor: improve fullscreen_media, minor changes. Signed-off-by: xsahil03x --- .../lib/src/attachment/attachment.dart | 3 +- .../lib/src/attachment/attachment_error.dart | 33 ----- .../lib/src/attachment/attachment_title.dart | 51 ------- .../lib/src/attachment/giphy_attachment.dart | 88 ++++-------- .../lib/src/attachment/image_attachment.dart | 28 ---- .../fullscreen_media/full_screen_media.dart | 113 ++------------- .../full_screen_media_desktop.dart | 134 +++--------------- .../gallery_navigation_item.dart | 71 ++++++++++ .../message_input/quoted_message_widget.dart | 11 +- .../lib/stream_chat_flutter.dart | 1 - .../src/attachment/attachment_error_test.dart | 25 ---- .../src/attachment/attachment_title_test.dart | 42 ------ 12 files changed, 135 insertions(+), 465 deletions(-) delete mode 100644 packages/stream_chat_flutter/lib/src/attachment/attachment_error.dart delete mode 100644 packages/stream_chat_flutter/lib/src/attachment/attachment_title.dart create mode 100644 packages/stream_chat_flutter/lib/src/fullscreen_media/gallery_navigation_item.dart delete mode 100644 packages/stream_chat_flutter/test/src/attachment/attachment_error_test.dart delete mode 100644 packages/stream_chat_flutter/test/src/attachment/attachment_title_test.dart diff --git a/packages/stream_chat_flutter/lib/src/attachment/attachment.dart b/packages/stream_chat_flutter/lib/src/attachment/attachment.dart index 2fb98820..0b73a93c 100644 --- a/packages/stream_chat_flutter/lib/src/attachment/attachment.dart +++ b/packages/stream_chat_flutter/lib/src/attachment/attachment.dart @@ -1,6 +1,7 @@ -export 'attachment_error.dart'; export 'attachment_upload_state_builder.dart'; export 'file_attachment.dart'; +export 'gallery_attachment.dart'; export 'giphy_attachment.dart'; export 'image_attachment.dart'; +export 'url_attachment.dart'; export 'video_attachment.dart'; diff --git a/packages/stream_chat_flutter/lib/src/attachment/attachment_error.dart b/packages/stream_chat_flutter/lib/src/attachment/attachment_error.dart deleted file mode 100644 index 85e806e9..00000000 --- a/packages/stream_chat_flutter/lib/src/attachment/attachment_error.dart +++ /dev/null @@ -1,33 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:stream_chat_flutter/stream_chat_flutter.dart'; - -/// {@template attachmentError} -/// Widget for building in case of error -/// {@endtemplate} -class AttachmentError extends StatelessWidget { - /// {@macro attachmentError} - const AttachmentError({ - super.key, - this.constraints, - }); - - /// constraints of error - final BoxConstraints? constraints; - - @override - Widget build(BuildContext context) { - return Center( - child: Container( - constraints: constraints ?? const BoxConstraints.expand(), - color: - StreamChatTheme.of(context).colorTheme.accentError.withOpacity(0.1), - child: Center( - child: Icon( - Icons.error_outline, - color: StreamChatTheme.of(context).colorTheme.textHighEmphasis, - ), - ), - ), - ); - } -} diff --git a/packages/stream_chat_flutter/lib/src/attachment/attachment_title.dart b/packages/stream_chat_flutter/lib/src/attachment/attachment_title.dart deleted file mode 100644 index dc9c34c1..00000000 --- a/packages/stream_chat_flutter/lib/src/attachment/attachment_title.dart +++ /dev/null @@ -1,51 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:stream_chat_flutter/stream_chat_flutter.dart'; - -/// {@template attachmentTitle} -/// Title for attachments -/// {@endtemplate} -class StreamAttachmentTitle extends StatelessWidget { - /// {@macro attachmentTitle} - const StreamAttachmentTitle({ - super.key, - required this.attachment, - required this.messageTheme, - }); - - /// Theme to apply to text - final StreamMessageThemeData messageTheme; - - /// Attachment data to display - final Attachment attachment; - - @override - Widget build(BuildContext context) { - final ogScrapeUrl = attachment.ogScrapeUrl; - return GestureDetector( - onTap: () { - final ogScrapeUrl = attachment.ogScrapeUrl; - if (ogScrapeUrl != null) launchURL(context, ogScrapeUrl); - }, - child: Padding( - padding: const EdgeInsets.all(8), - child: Column( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - if (attachment.title != null) - Text( - attachment.title!, - overflow: TextOverflow.ellipsis, - style: messageTheme.messageTextStyle?.copyWith( - color: StreamChatTheme.of(context).colorTheme.accentPrimary, - fontWeight: FontWeight.bold, - ), - ), - if (ogScrapeUrl != null) - Text(ogScrapeUrl, style: messageTheme.messageTextStyle), - ], - ), - ), - ); - } -} 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 fc995c08..a19e19ff 100644 --- a/packages/stream_chat_flutter/lib/src/attachment/giphy_attachment.dart +++ b/packages/stream_chat_flutter/lib/src/attachment/giphy_attachment.dart @@ -68,67 +68,39 @@ class StreamGiphyAttachment extends StatelessWidget { borderRadius: BorderRadius.circular(14), ); - return Hero( - tag: giphy.id, - child: Container( - constraints: constraints, - clipBehavior: Clip.hardEdge, - decoration: ShapeDecoration(shape: shape), - child: AspectRatio( - aspectRatio: giphySize?.aspectRatio ?? 1, - child: Stack( - alignment: Alignment.center, - children: [ - StreamGiphyAttachmentThumbnail( - type: type, - giphy: giphy, - fit: fit, - width: double.infinity, - height: double.infinity, - ), - if (giphy.uploadState.isSuccess) - const Positioned( - bottom: 8, - left: 8, - child: GiphyChip(), - ) - else - Padding( - padding: const EdgeInsets.all(8), - child: StreamAttachmentUploadStateBuilder( - message: message, - attachment: giphy, - ), + return Container( + constraints: constraints, + clipBehavior: Clip.hardEdge, + decoration: ShapeDecoration(shape: shape), + child: AspectRatio( + aspectRatio: giphySize?.aspectRatio ?? 1, + child: Stack( + alignment: Alignment.center, + children: [ + StreamGiphyAttachmentThumbnail( + type: type, + giphy: giphy, + fit: fit, + width: double.infinity, + height: double.infinity, + ), + if (giphy.uploadState.isSuccess) + const Positioned( + bottom: 8, + left: 8, + child: GiphyChip(), + ) + else + Padding( + padding: const EdgeInsets.all(8), + child: StreamAttachmentUploadStateBuilder( + message: message, + attachment: giphy, ), - ], - ), + ), + ], ), ), ); } - -// Future _onTap(BuildContext context) async { -// if (onAttachmentTap != null) { -// return onAttachmentTap!(); -// } -// -// await Navigator.of(context).push( -// MaterialPageRoute( -// builder: (_) { -// final channel = StreamChannel.of(context).channel; -// return StreamChannel( -// channel: channel, -// child: StreamFullScreenMediaBuilder( -// mediaAttachmentPackages: message.getAttachmentPackageList(), -// startIndex: message.attachments.indexOf(giphy), -// userName: message.user!.name, -// onShowMessage: onShowMessage, -// onReplyMessage: onReplyMessage, -// attachmentActionsModalBuilder: attachmentActionsModalBuilder, -// ), -// ); -// }, -// ), -// ); -// } } 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 386eb2df..5406cb87 100644 --- a/packages/stream_chat_flutter/lib/src/attachment/image_attachment.dart +++ b/packages/stream_chat_flutter/lib/src/attachment/image_attachment.dart @@ -103,31 +103,3 @@ class StreamImageAttachment extends StatelessWidget { ); } } - -// Future _onTap( -// BuildContext context, -// int index, -// ) async { -// if (onAttachmentTap != null) { -// return onAttachmentTap!(); -// } -// -// final channel = StreamChannel.of(context).channel; -// -// Navigator.of(context).push( -// MaterialPageRoute( -// builder: (context) => StreamChannel( -// channel: channel, -// child: StreamFullScreenMediaBuilder( -// mediaAttachmentPackages: message.getAttachmentPackageList(), -// startIndex: index, -// userName: message.user!.name, -// onShowMessage: onShowMessage, -// onReplyMessage: onReplyMessage, -// attachmentActionsModalBuilder: attachmentActionsModalBuilder, -// ), -// ), -// ), -// ); -// } -// } diff --git a/packages/stream_chat_flutter/lib/src/fullscreen_media/full_screen_media.dart b/packages/stream_chat_flutter/lib/src/fullscreen_media/full_screen_media.dart index 80ee4328..938e4dfb 100644 --- a/packages/stream_chat_flutter/lib/src/fullscreen_media/full_screen_media.dart +++ b/packages/stream_chat_flutter/lib/src/fullscreen_media/full_screen_media.dart @@ -2,14 +2,11 @@ import 'dart:async'; import 'dart:io'; import 'package:chewie/chewie.dart'; -import 'package:contextmenu/contextmenu.dart'; -import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:photo_view/photo_view.dart'; -import 'package:stream_chat_flutter/platform_widget_builder/platform_widget_builder.dart'; import 'package:stream_chat_flutter/src/attachment/thumbnail/media_attachment_thumbnail.dart'; -import 'package:stream_chat_flutter/src/context_menu_items/download_menu_item.dart'; import 'package:stream_chat_flutter/src/fullscreen_media/full_screen_media_widget.dart'; +import 'package:stream_chat_flutter/src/fullscreen_media/gallery_navigation_item.dart'; import 'package:stream_chat_flutter/stream_chat_flutter.dart'; import 'package:video_player/video_player.dart'; @@ -291,22 +288,16 @@ class _FullScreenMediaState extends State { ? StreamChannelHeaderTheme.of(context).color : Colors.black, duration: kThemeAnimationDuration, - child: ContextMenuArea( - verticalPadding: 0, - builder: (_) => [ - DownloadMenuItem(attachment: attachment), - ], - child: PhotoView.customChild( - maxScale: PhotoViewComputedScale.covered, - minScale: PhotoViewComputedScale.contained, - backgroundDecoration: const BoxDecoration( - color: Colors.transparent, - ), - child: StreamMediaAttachmentThumbnail( - media: attachment, - width: double.infinity, - height: double.infinity, - ), + child: PhotoView.customChild( + maxScale: PhotoViewComputedScale.covered, + minScale: PhotoViewComputedScale.contained, + backgroundDecoration: const BoxDecoration( + color: Colors.transparent, + ), + child: StreamMediaAttachmentThumbnail( + media: attachment, + width: double.infinity, + height: double.infinity, ), ), ), @@ -318,19 +309,11 @@ class _FullScreenMediaState extends State { child: CircularProgressIndicator.adaptive(), ); } + return InkWell( onTap: switchDisplayingDetail, - child: Padding( - padding: const EdgeInsets.symmetric(vertical: 50), - child: ContextMenuArea( - verticalPadding: 0, - builder: (_) => [ - DownloadMenuItem(attachment: attachment), - ], - child: Chewie( - controller: controller.chewieController!, - ), - ), + child: Chewie( + controller: controller.chewieController!, ), ); } @@ -344,74 +327,6 @@ class _FullScreenMediaState extends State { } } -/// A widget for desktop and web users to be able to navigate left and right -/// through a gallery of images. -class GalleryNavigationItem extends StatelessWidget { - /// Builds a [GalleryNavigationItem]. - const GalleryNavigationItem({ - super.key, - required this.icon, - this.iconSize = 48, - required this.onPressed, - required this.opacityAnimation, - this.left, - this.right, - }); - - /// The icon to display. - final Widget icon; - - /// The size of the icon. - /// - /// Defaults to 48. - final double iconSize; - - /// The callback to perform when the button is clicked. - final VoidCallback onPressed; - - /// The animation for showing & hiding this widget. - final ValueListenable opacityAnimation; - - /// The left-hand placement of the button. - final double? left; - - /// The right-hand placement of the button. - final double? right; - - @override - Widget build(BuildContext context) { - return PlatformWidgetBuilder( - desktop: (_, child) => child, - web: (_, child) => child, - child: Positioned( - left: left, - right: right, - top: MediaQuery.of(context).size.height / 2, - child: ValueListenableBuilder( - valueListenable: opacityAnimation, - builder: (context, shouldShow, child) { - return AnimatedOpacity( - opacity: shouldShow ? 1 : 0, - duration: kThemeAnimationDuration, - child: child, - ); - }, - child: Material( - color: Colors.transparent, - type: MaterialType.circle, - clipBehavior: Clip.antiAlias, - child: IconButton( - icon: icon, - iconSize: iconSize, - onPressed: onPressed, - ), - ), - ), - ), - ); - } -} - /// Class for packaging up things required for videos class VideoPackage { /// Constructor for creating [VideoPackage] diff --git a/packages/stream_chat_flutter/lib/src/fullscreen_media/full_screen_media_desktop.dart b/packages/stream_chat_flutter/lib/src/fullscreen_media/full_screen_media_desktop.dart index bdc6d9cf..b4318f8e 100644 --- a/packages/stream_chat_flutter/lib/src/fullscreen_media/full_screen_media_desktop.dart +++ b/packages/stream_chat_flutter/lib/src/fullscreen_media/full_screen_media_desktop.dart @@ -1,13 +1,13 @@ -import 'package:cached_network_image/cached_network_image.dart'; import 'package:contextmenu/contextmenu.dart'; import 'package:dart_vlc/dart_vlc.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:photo_view/photo_view.dart'; -import 'package:shimmer/shimmer.dart'; import 'package:stream_chat_flutter/platform_widget_builder/platform_widget_builder.dart'; +import 'package:stream_chat_flutter/src/attachment/thumbnail/media_attachment_thumbnail.dart'; import 'package:stream_chat_flutter/src/context_menu_items/download_menu_item.dart'; import 'package:stream_chat_flutter/src/fullscreen_media/full_screen_media_widget.dart'; +import 'package:stream_chat_flutter/src/fullscreen_media/gallery_navigation_item.dart'; import 'package:stream_chat_flutter/stream_chat_flutter.dart'; /// Returns an instance of [FullScreenMediaDesktop]. @@ -310,9 +310,6 @@ class _FullScreenMediaDesktopState extends State { final attachment = currentAttachmentPackage.attachment; if (attachment.type == AttachmentType.image || attachment.type == AttachmentType.giphy) { - final imageUrl = attachment.imageUrl ?? - attachment.assetUrl ?? - attachment.thumbUrl; return ValueListenableBuilder( valueListenable: _isDisplayingDetail, builder: (context, isDisplayingDetail, _) => @@ -324,39 +321,19 @@ class _FullScreenMediaDesktopState extends State { child: ContextMenuArea( verticalPadding: 0, builder: (_) => [ - DownloadMenuItem( - attachment: attachment, - ), + DownloadMenuItem(attachment: attachment), ], - child: PhotoView( - imageProvider: (imageUrl == null && - attachment.localUri != null && - attachment.file?.bytes != null) - ? Image.memory(attachment.file!.bytes!).image - : CachedNetworkImageProvider(imageUrl!), - errorBuilder: (_, __, ___) => const AttachmentError(), - loadingBuilder: (context, _) { - 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.disabled, - highlightColor: colorTheme.inputBg, - child: image, - ); - }, + child: PhotoView.customChild( maxScale: PhotoViewComputedScale.covered, minScale: PhotoViewComputedScale.contained, - heroAttributes: PhotoViewHeroAttributes( - tag: widget.mediaAttachmentPackages, - ), backgroundDecoration: const BoxDecoration( color: Colors.transparent, ), + child: StreamMediaAttachmentThumbnail( + media: attachment, + width: double.infinity, + height: double.infinity, + ), ), ), ), @@ -364,29 +341,18 @@ class _FullScreenMediaDesktopState extends State { } else if (attachment.type == AttachmentType.video) { final package = videoPackages[attachment.id]!; package.player.open( - Playlist( - medias: [ - Media.network(package.attachment.assetUrl), - ], - ), + Media.network(package.attachment.assetUrl), autoStart: widget.autoplayVideos, ); return InkWell( onTap: switchDisplayingDetail, - child: Padding( - padding: const EdgeInsets.symmetric(vertical: 50), - child: ContextMenuArea( - verticalPadding: 0, - builder: (_) => [ - DownloadMenuItem( - attachment: attachment, - ), - ], - child: Video( - player: package.player, - ), - ), + child: ContextMenuArea( + verticalPadding: 0, + builder: (_) => [ + DownloadMenuItem(attachment: attachment), + ], + child: Video(player: package.player), ), ); } @@ -399,74 +365,6 @@ class _FullScreenMediaDesktopState extends State { } } -/// A widget for desktop and web users to be able to navigate left and right -/// through a gallery of images. -class GalleryNavigationItem extends StatelessWidget { - /// Builds a [GalleryNavigationItem]. - const GalleryNavigationItem({ - super.key, - required this.icon, - this.iconSize = 48, - required this.onPressed, - required this.opacityAnimation, - this.left, - this.right, - }); - - /// The icon to display. - final Widget icon; - - /// The size of the icon. - /// - /// Defaults to 48. - final double iconSize; - - /// The callback to perform when the button is clicked. - final VoidCallback onPressed; - - /// The animation for showing & hiding this widget. - final ValueListenable opacityAnimation; - - /// The left-hand placement of the button. - final double? left; - - /// The right-hand placement of the button. - final double? right; - - @override - Widget build(BuildContext context) { - return PlatformWidgetBuilder( - desktop: (_, child) => child, - web: (_, child) => child, - child: Positioned( - left: left, - right: right, - top: MediaQuery.of(context).size.height / 2, - child: ValueListenableBuilder( - valueListenable: opacityAnimation, - builder: (context, shouldShow, child) { - return AnimatedOpacity( - opacity: shouldShow ? 1 : 0, - duration: kThemeAnimationDuration, - child: child, - ); - }, - child: Material( - color: Colors.transparent, - type: MaterialType.circle, - clipBehavior: Clip.antiAlias, - child: IconButton( - icon: icon, - iconSize: iconSize, - onPressed: onPressed, - ), - ), - ), - ), - ); - } -} - /// Class for packaging up things required for videos class DesktopVideoPackage { /// Constructor for creating [VideoPackage] diff --git a/packages/stream_chat_flutter/lib/src/fullscreen_media/gallery_navigation_item.dart b/packages/stream_chat_flutter/lib/src/fullscreen_media/gallery_navigation_item.dart new file mode 100644 index 00000000..5d1af701 --- /dev/null +++ b/packages/stream_chat_flutter/lib/src/fullscreen_media/gallery_navigation_item.dart @@ -0,0 +1,71 @@ +import 'package:flutter/foundation.dart'; +import 'package:flutter/material.dart'; +import 'package:stream_chat_flutter/platform_widget_builder/src/platform_widget_builder.dart'; + +/// A widget for desktop and web users to be able to navigate left and right +/// through a gallery of images. +class GalleryNavigationItem extends StatelessWidget { + /// Builds a [GalleryNavigationItem]. + const GalleryNavigationItem({ + super.key, + required this.icon, + this.iconSize = 48, + required this.onPressed, + required this.opacityAnimation, + this.left, + this.right, + }); + + /// The icon to display. + final Widget icon; + + /// The size of the icon. + /// + /// Defaults to 48. + final double iconSize; + + /// The callback to perform when the button is clicked. + final VoidCallback onPressed; + + /// The animation for showing & hiding this widget. + final ValueListenable opacityAnimation; + + /// The left-hand placement of the button. + final double? left; + + /// The right-hand placement of the button. + final double? right; + + @override + Widget build(BuildContext context) { + return PlatformWidgetBuilder( + desktop: (_, child) => child, + web: (_, child) => child, + child: Positioned( + left: left, + right: right, + top: MediaQuery.of(context).size.height / 2, + child: ValueListenableBuilder( + valueListenable: opacityAnimation, + builder: (context, shouldShow, child) { + return AnimatedOpacity( + opacity: shouldShow ? 1 : 0, + duration: kThemeAnimationDuration, + child: child, + ); + }, + child: Material( + color: Colors.transparent, + type: MaterialType.circle, + clipBehavior: Clip.antiAlias, + child: IconButton( + icon: icon, + iconSize: iconSize, + onPressed: onPressed, + ), + ), + ), + ), + ); + } +} diff --git a/packages/stream_chat_flutter/lib/src/message_input/quoted_message_widget.dart b/packages/stream_chat_flutter/lib/src/message_input/quoted_message_widget.dart index 054d9cc4..83e04cc6 100644 --- a/packages/stream_chat_flutter/lib/src/message_input/quoted_message_widget.dart +++ b/packages/stream_chat_flutter/lib/src/message_input/quoted_message_widget.dart @@ -1,5 +1,4 @@ import 'package:flutter/material.dart'; -import 'package:stream_chat_flutter/platform_widget_builder/platform_widget_builder.dart'; import 'package:stream_chat_flutter/src/attachment/thumbnail/file_attachment_thumbnail.dart'; import 'package:stream_chat_flutter/src/attachment/thumbnail/image_attachment_thumbnail.dart'; import 'package:stream_chat_flutter/src/message_input/clear_input_item_button.dart'; @@ -178,16 +177,10 @@ class _QuotedMessage extends StatelessWidget { } // Add clear button if needed. - if (onQuotedMessageClear != null) { + if (isDesktopDeviceOrWeb && onQuotedMessageClear != null) { children.insert( 0, - PlatformWidgetBuilder( - web: (context, child) => child, - desktop: (context, child) => child, - child: ClearInputItemButton( - onTap: onQuotedMessageClear, - ), - ), + ClearInputItemButton(onTap: onQuotedMessageClear), ); } diff --git a/packages/stream_chat_flutter/lib/stream_chat_flutter.dart b/packages/stream_chat_flutter/lib/stream_chat_flutter.dart index 6b3937be..72470ee9 100644 --- a/packages/stream_chat_flutter/lib/stream_chat_flutter.dart +++ b/packages/stream_chat_flutter/lib/stream_chat_flutter.dart @@ -6,7 +6,6 @@ export 'package:stream_chat_flutter/src/message_widget/quoted_message.dart'; export 'package:stream_chat_flutter_core/stream_chat_flutter_core.dart'; export 'src/attachment/attachment.dart'; -export 'src/attachment/attachment_title.dart'; export 'src/attachment/gallery_attachment.dart'; export 'src/attachment/handler/stream_attachment_handler.dart'; export 'src/attachment/image_attachment.dart'; diff --git a/packages/stream_chat_flutter/test/src/attachment/attachment_error_test.dart b/packages/stream_chat_flutter/test/src/attachment/attachment_error_test.dart deleted file mode 100644 index 6e038505..00000000 --- a/packages/stream_chat_flutter/test/src/attachment/attachment_error_test.dart +++ /dev/null @@ -1,25 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:flutter_test/flutter_test.dart'; -import 'package:stream_chat_flutter/stream_chat_flutter.dart'; - -import '../mocks.dart'; - -void main() { - testWidgets('AttachmentError test', (tester) async { - await tester.pumpWidget( - MaterialApp( - builder: (context, child) => StreamChat( - client: MockClient(), - child: child, - ), - home: const Scaffold( - body: Center( - child: AttachmentError(), - ), - ), - ), - ); - - expect(find.byType(Icon), findsOneWidget); - }); -} diff --git a/packages/stream_chat_flutter/test/src/attachment/attachment_title_test.dart b/packages/stream_chat_flutter/test/src/attachment/attachment_title_test.dart deleted file mode 100644 index bfe1223e..00000000 --- a/packages/stream_chat_flutter/test/src/attachment/attachment_title_test.dart +++ /dev/null @@ -1,42 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:flutter_test/flutter_test.dart'; -import 'package:stream_chat_flutter/stream_chat_flutter.dart'; - -import '../mocks.dart'; - -void main() { - testWidgets('AttachmentTitle renders properly', (tester) async { - final mockClient = MockClient(); - await tester.pumpWidget( - MaterialApp( - builder: (context, child) => StreamChat( - client: mockClient, - streamChatThemeData: StreamChatThemeData.light(), - child: child, - ), - home: Scaffold( - body: Builder( - builder: (context) { - return Center( - child: StreamAttachmentTitle( - attachment: Attachment( - title: 'Test Attachment', - type: 'video', - titleLink: 'https://www.youtube.com/watch?v=lytQi-slT5Y', - ogScrapeUrl: 'https://www.youtube.com/watch?v=lytQi-slT5Y', - ), - messageTheme: StreamChatTheme.of(context).ownMessageTheme, - ), - ); - }, - ), - ), - ), - ); - - expect(find.byType(StreamAttachmentTitle), findsOneWidget); - expect(find.text('Test Attachment'), findsOneWidget); - expect(find.text('https://www.youtube.com/watch?v=lytQi-slT5Y'), - findsOneWidget); - }); -}