From a7e3839256d0c0725dcdf030766bb5e091ac0127 Mon Sep 17 00:00:00 2001 From: Sahil Kumar Date: Thu, 10 Mar 2022 14:12:01 +0530 Subject: [PATCH] refactor(ui, core): Deprecate v3 Signed-off-by: xsahil03x --- .../stream_chat_flutter/example/lib/main.dart | 8 +- .../example/lib/split_view.dart | 6 +- .../example/lib/tutorial_part_1.dart | 8 +- .../example/lib/tutorial_part_2.dart | 8 +- .../example/lib/tutorial_part_3.dart | 12 +- .../example/lib/tutorial_part_4.dart | 16 +- .../example/lib/tutorial_part_5.dart | 10 +- .../example/lib/tutorial_part_6.dart | 22 +- .../lib/src/attachment/attachment_title.dart | 12 +- .../attachment_upload_state_builder.dart | 16 +- .../lib/src/attachment/attachment_widget.dart | 10 +- .../lib/src/attachment/file_attachment.dart | 16 +- .../lib/src/attachment/giphy_attachment.dart | 16 +- .../lib/src/attachment/image_attachment.dart | 22 +- .../lib/src/attachment/url_attachment.dart | 16 +- .../lib/src/attachment/video_attachment.dart | 26 +- .../lib/src/attachment_actions_modal.dart | 2 +- .../lib/src/back_button.dart | 2 +- .../lib/src/channel_avatar.dart | 6 +- .../lib/src/channel_bottom_sheet.dart | 26 +- .../lib/src/channel_header.dart | 29 +- .../lib/src/channel_info.dart | 18 +- .../lib/src/channel_list_header.dart | 38 +- .../lib/src/channel_list_view.dart | 23 +- .../lib/src/channel_name.dart | 5 +- .../lib/src/channel_preview.dart | 41 +- .../lib/src/commands_overlay.dart | 13 +- .../lib/src/connection_status_builder.dart | 10 +- .../lib/src/date_divider.dart | 12 +- .../lib/src/deleted_message.dart | 16 +- .../lib/src/emoji_overlay.dart | 12 +- .../lib/src/full_screen_media.dart | 20 +- .../lib/src/gallery_footer.dart | 25 +- .../lib/src/gallery_header.dart | 15 +- .../lib/src/gradient_avatar.dart | 16 +- .../lib/src/group_avatar.dart | 17 +- .../lib/src/image_group.dart | 20 +- .../lib/src/info_tile.dart | 12 +- .../lib/src/localization/translations.dart | 24 +- .../lib/src/media_list_view.dart | 36 +- .../lib/src/mention_tile.dart | 101 - .../lib/src/message_action.dart | 12 +- .../lib/src/message_actions_modal.dart | 31 +- .../lib/src/message_input.dart | 2110 +++++++++++++++++ .../src/message_input/countdown_button.dart | 6 +- .../lib/src/message_input/message_input.dart | 52 +- .../stream_attachment_picker.dart | 4 +- .../stream_message_send_button.dart | 6 +- .../lib/src/message_list_view.dart | 46 +- .../lib/src/message_reactions_modal.dart | 22 +- .../lib/src/message_search_item.dart | 20 +- .../lib/src/message_search_list_view.dart | 27 +- .../lib/src/message_text.dart | 16 +- .../lib/src/message_widget.dart | 68 +- .../lib/src/multi_overlay.dart | 10 +- .../lib/src/option_list_tile.dart | 12 +- .../lib/src/quoted_message_widget.dart | 106 +- .../lib/src/reaction_bubble.dart | 14 +- .../lib/src/reaction_icon.dart | 10 +- .../lib/src/reaction_picker.dart | 18 +- .../lib/src/sending_indicator.dart | 12 +- .../lib/src/stream_chat_theme.dart | 162 +- .../lib/src/system_message.dart | 14 +- .../lib/src/theme/avatar_theme.dart | 32 +- .../lib/src/theme/channel_header_theme.dart | 72 +- .../src/theme/channel_list_header_theme.dart | 72 +- .../src/theme/channel_list_view_theme.dart | 66 +- .../lib/src/theme/channel_preview_theme.dart | 68 +- .../lib/src/theme/color_theme.dart | 20 +- .../lib/src/theme/gallery_footer_theme.dart | 62 +- .../lib/src/theme/gallery_header_theme.dart | 62 +- .../lib/src/theme/message_input_theme.dart | 62 +- .../src/theme/message_list_view_theme.dart | 64 +- .../theme/message_search_list_view_theme.dart | 56 +- .../lib/src/theme/message_theme.dart | 38 +- .../lib/src/theme/text_theme.dart | 20 +- .../lib/src/theme/user_list_view_theme.dart | 62 +- .../lib/src/thread_header.dart | 17 +- .../lib/src/typing_indicator.dart | 10 +- .../lib/src/unread_indicator.dart | 12 +- .../lib/src/upload_progress_indicator.dart | 12 +- .../lib/src/user_avatar.dart | 12 +- .../lib/src/user_item.dart | 19 +- .../lib/src/user_list_view.dart | 21 +- .../lib/src/user_mention_tile.dart | 14 +- .../lib/src/user_mentions_overlay.dart | 23 +- .../stream_channel_list_tile.dart | 8 +- .../lib/src/v4/stream_channel_avatar.dart | 6 +- .../v4/stream_channel_info_bottom_sheet.dart | 14 +- .../lib/src/video_service.dart | 5 + .../lib/src/video_thumbnail_image.dart | 23 +- .../lib/src/visible_footnote.dart | 12 +- .../lib/stream_chat_flutter.dart | 1 - .../test/src/attachment_widgets_test.dart | 2 +- .../test/src/back_button_test.dart | 2 +- .../test/src/channel_header_test.dart | 40 +- .../test/src/channel_image_test.dart | 3 +- .../test/src/channel_list_header_test.dart | 19 +- .../test/src/channel_preview_test.dart | 2 +- .../test/src/date_divider_test.dart | 2 +- .../test/src/deleted_message_test.dart | 10 +- .../test/src/full_screen_media_test.dart | 2 +- .../test/src/gradient_avatar_test.dart | 15 +- .../test/src/image_footer_test.dart | 2 +- .../test/src/info_tile_test.dart | 4 +- .../test/src/message_action_modal_test.dart | 34 +- .../test/src/message_input_test.dart | 4 +- .../test/src/message_list_view_test.dart | 10 +- .../src/message_reactions_modal_test.dart | 12 +- .../test/src/message_text_test.dart | 10 +- .../test/src/reaction_bubble_test.dart | 10 +- .../test/src/system_message_test.dart | 8 +- .../test/src/theme/avatar_theme_test.dart | 17 +- .../src/theme/channel_header_theme_test.dart | 38 +- .../theme/channel_list_header_theme_test.dart | 34 +- .../theme/channel_list_view_theme_test.dart | 34 +- .../src/theme/channel_preview_theme_test.dart | 52 +- .../src/theme/gallery_footer_theme_test.dart | 72 +- .../src/theme/gallery_header_theme_test.dart | 40 +- .../src/theme/message_input_theme_test.dart | 64 +- .../theme/message_list_view_theme_test.dart | 46 +- .../message_search_list_view_theme_test.dart | 35 +- .../test/src/theme/message_theme_test.dart | 75 +- .../src/theme/user_list_view_theme_test.dart | 32 +- .../test/src/thread_header_test.dart | 4 +- .../test/src/typing_indicator_test.dart | 2 +- .../test/src/unread_indicator_test.dart | 6 +- .../lib/src/channels_bloc.dart | 5 +- 128 files changed, 3891 insertions(+), 1362 deletions(-) delete mode 100644 packages/stream_chat_flutter/lib/src/mention_tile.dart create mode 100644 packages/stream_chat_flutter/lib/src/message_input.dart diff --git a/packages/stream_chat_flutter/example/lib/main.dart b/packages/stream_chat_flutter/example/lib/main.dart index 6b5a299f..4a7eabf4 100644 --- a/packages/stream_chat_flutter/example/lib/main.dart +++ b/packages/stream_chat_flutter/example/lib/main.dart @@ -87,7 +87,7 @@ class MyApp extends StatelessWidget { /// A list of messages sent in the current channel. /// -/// This is implemented using [MessageListView], a widget that provides query +/// This is implemented using [StreamMessageListView], a widget that provides query /// functionalities fetching the messages from the api and showing them in a /// listView. class ChannelPage extends StatelessWidget { @@ -98,13 +98,13 @@ class ChannelPage extends StatelessWidget { @override Widget build(BuildContext context) => Scaffold( - appBar: const ChannelHeader(), + appBar: const StreamChannelHeader(), body: Column( children: const [ Expanded( - child: MessageListView(), + child: StreamMessageListView(), ), - MessageInput(attachmentLimit: 3), + StreamMessageInput(attachmentLimit: 3), ], ), ); diff --git a/packages/stream_chat_flutter/example/lib/split_view.dart b/packages/stream_chat_flutter/example/lib/split_view.dart index 75b8f64b..6f4c51e6 100644 --- a/packages/stream_chat_flutter/example/lib/split_view.dart +++ b/packages/stream_chat_flutter/example/lib/split_view.dart @@ -125,15 +125,15 @@ class ChannelPage extends StatelessWidget { Widget build(BuildContext context) => Navigator( onGenerateRoute: (settings) => MaterialPageRoute( builder: (context) => Scaffold( - appBar: const ChannelHeader( + appBar: const StreamChannelHeader( showBackButton: false, ), body: Column( children: const [ Expanded( - child: MessageListView(), + child: StreamMessageListView(), ), - MessageInput(), + StreamMessageInput(), ], ), ), diff --git a/packages/stream_chat_flutter/example/lib/tutorial_part_1.dart b/packages/stream_chat_flutter/example/lib/tutorial_part_1.dart index 82acabf9..cd3bb12e 100644 --- a/packages/stream_chat_flutter/example/lib/tutorial_part_1.dart +++ b/packages/stream_chat_flutter/example/lib/tutorial_part_1.dart @@ -27,7 +27,7 @@ import 'package:stream_chat_flutter/stream_chat_flutter.dart'; /// - We make [StreamChat] the root Widget of our application /// /// - We create a single [ChannelPage] widget under [StreamChat] with three -/// widgets: [ChannelHeader], [MessageListView] and [MessageInput] +/// widgets: [StreamChannelHeader], [StreamMessageListView] and [StreamMessageInput] /// /// If you now run the simulator you will see a single channel UI. void main() async { @@ -91,13 +91,13 @@ class ChannelPage extends StatelessWidget { @override Widget build(BuildContext context) => Scaffold( - appBar: const ChannelHeader(), + appBar: const StreamChannelHeader(), body: Column( children: const [ Expanded( - child: MessageListView(), + child: StreamMessageListView(), ), - MessageInput(), + StreamMessageInput(), ], ), ); diff --git a/packages/stream_chat_flutter/example/lib/tutorial_part_2.dart b/packages/stream_chat_flutter/example/lib/tutorial_part_2.dart index 9f718b7e..0ca2356e 100644 --- a/packages/stream_chat_flutter/example/lib/tutorial_part_2.dart +++ b/packages/stream_chat_flutter/example/lib/tutorial_part_2.dart @@ -25,7 +25,7 @@ import 'package:stream_chat_flutter/stream_chat_flutter.dart'; /// The [ChannelListPage] widget retrieves the list of channels based on a /// custom query and ordering. In this case we are showing the list of /// channels in which the current user is a member and we order them based -/// on the time they had a new message. [ChannelListView] handles pagination +/// on the time they had a new message. [StreamChannelListView] handles pagination /// and updates automatically when new channels are created or when a new /// message is added to a channel. void main() async { @@ -118,13 +118,13 @@ class ChannelPage extends StatelessWidget { @override Widget build(BuildContext context) => Scaffold( - appBar: const ChannelHeader(), + appBar: const StreamChannelHeader(), body: Column( children: const [ Expanded( - child: MessageListView(), + child: StreamMessageListView(), ), - MessageInput(), + StreamMessageInput(), ], ), ); diff --git a/packages/stream_chat_flutter/example/lib/tutorial_part_3.dart b/packages/stream_chat_flutter/example/lib/tutorial_part_3.dart index 76447b11..8eb01fbb 100644 --- a/packages/stream_chat_flutter/example/lib/tutorial_part_3.dart +++ b/packages/stream_chat_flutter/example/lib/tutorial_part_3.dart @@ -15,8 +15,8 @@ import 'package:stream_chat_flutter/stream_chat_flutter.dart'; /// We start by changing how channel previews are shown in the channel list /// and include the number of unread messages for each. /// -/// We're passing a custom widget to [ChannelListView.channelPreviewBuilder]; -/// this will override the default [ChannelPreview] and allows you to create +/// We're passing a custom widget to [StreamChannelListView.channelPreviewBuilder]; +/// this will override the default [StreamChannelPreview] and allows you to create /// one yourself. /// /// There are a couple interesting things we do in this widget: @@ -134,7 +134,7 @@ class _ChannelListPageState extends State { channel: channel, ), title: StreamChannelName( - textStyle: ChannelPreviewTheme.of(context).titleStyle!.copyWith( + textStyle: StreamChannelPreviewTheme.of(context).titleStyle!.copyWith( color: StreamChatTheme.of(context) .colorTheme .textHighEmphasis @@ -162,13 +162,13 @@ class ChannelPage extends StatelessWidget { // ignore: prefer_expression_function_bodies Widget build(BuildContext context) { return Scaffold( - appBar: const ChannelHeader(), + appBar: const StreamChannelHeader(), body: Column( children: const [ Expanded( - child: MessageListView(), + child: StreamMessageListView(), ), - MessageInput(), + StreamMessageInput(), ], ), ); diff --git a/packages/stream_chat_flutter/example/lib/tutorial_part_4.dart b/packages/stream_chat_flutter/example/lib/tutorial_part_4.dart index fdea19ba..89aa55f7 100644 --- a/packages/stream_chat_flutter/example/lib/tutorial_part_4.dart +++ b/packages/stream_chat_flutter/example/lib/tutorial_part_4.dart @@ -8,8 +8,8 @@ import 'package:stream_chat_flutter/stream_chat_flutter.dart'; /// to create sub-conversations inside the same channel. /// /// Using threaded conversations is very simple and mostly a matter of -/// plugging the [MessageListView] to another widget that renders the widget. -/// To make this simple, such a widget only needs to build [MessageListView] +/// plugging the [StreamMessageListView] to another widget that renders the widget. +/// To make this simple, such a widget only needs to build [StreamMessageListView] /// with the parent attribute set to the thread’s root message. /// /// Now we can open threads and create new ones as well. If you long-press a @@ -98,17 +98,17 @@ class ChannelPage extends StatelessWidget { @override Widget build(BuildContext context) => Scaffold( - appBar: const ChannelHeader(), + appBar: const StreamChannelHeader(), body: Column( children: [ Expanded( - child: MessageListView( + child: StreamMessageListView( threadBuilder: (_, parentMessage) => ThreadPage( parent: parentMessage, ), ), ), - const MessageInput(), + const StreamMessageInput(), ], ), ); @@ -126,17 +126,17 @@ class ThreadPage extends StatelessWidget { // ignore: prefer_expression_function_bodies Widget build(BuildContext context) { return Scaffold( - appBar: ThreadHeader( + appBar: StreamThreadHeader( parent: parent!, ), body: Column( children: [ Expanded( - child: MessageListView( + child: StreamMessageListView( parentMessage: parent, ), ), - MessageInput( + StreamMessageInput( messageInputController: MessageInputController( message: Message(parentId: parent!.id), ), diff --git a/packages/stream_chat_flutter/example/lib/tutorial_part_5.dart b/packages/stream_chat_flutter/example/lib/tutorial_part_5.dart index 347ceaf4..fd6081f7 100644 --- a/packages/stream_chat_flutter/example/lib/tutorial_part_5.dart +++ b/packages/stream_chat_flutter/example/lib/tutorial_part_5.dart @@ -8,7 +8,7 @@ import 'package:stream_chat_flutter/stream_chat_flutter.dart'; /// the SDK supports easily. /// /// Replacing the built-in message component with your own is done by passing -/// it as a builder function to the [MessageListView] widget. +/// it as a builder function to the [StreamMessageListView] widget. /// /// The message builder function will get the usual [BuildContext] argument /// as well as the [Message] object and its position inside the list. @@ -106,15 +106,15 @@ class ChannelPage extends StatelessWidget { // ignore: prefer_expression_function_bodies Widget build(BuildContext context) { return Scaffold( - appBar: const ChannelHeader(), + appBar: const StreamChannelHeader(), body: Column( children: [ Expanded( - child: MessageListView( + child: StreamMessageListView( messageBuilder: _messageBuilder, ), ), - const MessageInput(), + const StreamMessageInput(), ], ), ); @@ -124,7 +124,7 @@ class ChannelPage extends StatelessWidget { BuildContext context, MessageDetails details, List messages, - MessageWidget _, + StreamMessageWidget _, ) { final message = details.message; final isCurrentUser = diff --git a/packages/stream_chat_flutter/example/lib/tutorial_part_6.dart b/packages/stream_chat_flutter/example/lib/tutorial_part_6.dart index 4bb8e928..6ff1bb64 100644 --- a/packages/stream_chat_flutter/example/lib/tutorial_part_6.dart +++ b/packages/stream_chat_flutter/example/lib/tutorial_part_6.dart @@ -58,24 +58,24 @@ class MyApp extends StatelessWidget { final defaultTheme = StreamChatThemeData.fromTheme(themeData); final colorTheme = defaultTheme.colorTheme; final customTheme = defaultTheme.merge(StreamChatThemeData( - channelPreviewTheme: ChannelPreviewThemeData( - avatarTheme: AvatarThemeData( + channelPreviewTheme: StreamChannelPreviewThemeData( + avatarTheme: StreamAvatarThemeData( borderRadius: BorderRadius.circular(8), ), ), - messageListViewTheme: const MessageListViewThemeData( + messageListViewTheme: const StreamMessageListViewThemeData( backgroundColor: Colors.grey, backgroundImage: DecorationImage( image: AssetImage('assets/background_doodle.png'), fit: BoxFit.cover, ), ), - otherMessageTheme: MessageThemeData( + otherMessageTheme: StreamMessageThemeData( messageBackgroundColor: colorTheme.textHighEmphasis, messageTextStyle: TextStyle( color: colorTheme.barsBg, ), - avatarTheme: AvatarThemeData( + avatarTheme: StreamAvatarThemeData( borderRadius: BorderRadius.circular(8), ), ), @@ -137,17 +137,17 @@ class ChannelPage extends StatelessWidget { @override Widget build(BuildContext context) => Scaffold( - appBar: const ChannelHeader(), + appBar: const StreamChannelHeader(), body: Column( children: [ Expanded( - child: MessageListView( + child: StreamMessageListView( threadBuilder: (_, parentMessage) => ThreadPage( parent: parentMessage, ), ), ), - const MessageInput(), + const StreamMessageInput(), ], ), ); @@ -165,17 +165,17 @@ class ThreadPage extends StatelessWidget { // ignore: prefer_expression_function_bodies Widget build(BuildContext context) { return Scaffold( - appBar: ThreadHeader( + appBar: StreamThreadHeader( parent: parent!, ), body: Column( children: [ Expanded( - child: MessageListView( + child: StreamMessageListView( parentMessage: parent, ), ), - MessageInput( + StreamMessageInput( messageInputController: MessageInputController( message: Message(parentId: parent!.id), ), diff --git a/packages/stream_chat_flutter/lib/src/attachment/attachment_title.dart b/packages/stream_chat_flutter/lib/src/attachment/attachment_title.dart index f1369d49..b1aba4a2 100644 --- a/packages/stream_chat_flutter/lib/src/attachment/attachment_title.dart +++ b/packages/stream_chat_flutter/lib/src/attachment/attachment_title.dart @@ -1,17 +1,23 @@ import 'package:flutter/material.dart'; import 'package:stream_chat_flutter/stream_chat_flutter.dart'; +/// {@macro attachment_title} +@Deprecated("Use 'StreamAttachmentTitle' instead") +typedef AttachmentTitle = StreamAttachmentTitle; + +/// {@template attachment_title} /// Title for attachments -class AttachmentTitle extends StatelessWidget { +/// {@endtemplate} +class StreamAttachmentTitle extends StatelessWidget { /// Supply attachment and theme for constructing title - const AttachmentTitle({ + const StreamAttachmentTitle({ Key? key, required this.attachment, required this.messageTheme, }) : super(key: key); /// Theme to apply to text - final MessageThemeData messageTheme; + final StreamMessageThemeData messageTheme; /// Attachment data to display final Attachment attachment; 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 bd0aacc3..a1aa60bc 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 @@ -9,10 +9,16 @@ typedef InProgressBuilder = Widget Function(BuildContext, int, int); /// Widget to build on failure typedef FailedBuilder = Widget Function(BuildContext, String); +/// {@macro attachment_upload_state_builder} +@Deprecated("Use 'StreamAttachmentsUploadStateBuilder' instead") +typedef AttachmentUploadStateBuilder = StreamAttachmentUploadStateBuilder; + +/// {@template attachment_upload_state_builder} /// Widget to display attachment upload state -class AttachmentUploadStateBuilder extends StatelessWidget { - /// Constructor for creating an [AttachmentUploadStateBuilder] widget - const AttachmentUploadStateBuilder({ +/// {@endtemplate} +class StreamAttachmentUploadStateBuilder extends StatelessWidget { + /// Constructor for creating an [StreamAttachmentUploadStateBuilder] widget + const StreamAttachmentUploadStateBuilder({ Key? key, required this.message, required this.attachment, @@ -137,7 +143,7 @@ class _PreparingState extends StatelessWidget { ), Align( alignment: Alignment.topRight, - child: UploadProgressIndicator( + child: StreamUploadProgressIndicator( uploaded: 0, total: double.maxFinite.toInt(), ), @@ -177,7 +183,7 @@ class _InProgressState extends StatelessWidget { ), Align( alignment: Alignment.topRight, - child: UploadProgressIndicator( + child: StreamUploadProgressIndicator( uploaded: sent, total: total, ), 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 75a890e8..0021fc76 100644 --- a/packages/stream_chat_flutter/lib/src/attachment/attachment_widget.dart +++ b/packages/stream_chat_flutter/lib/src/attachment/attachment_widget.dart @@ -28,10 +28,16 @@ extension AttachmentSourceX on AttachmentSource { } } +/// {@macro attachment_widget} +@Deprecated("Use 'StreamAttachmentWidget' instead") +typedef AttachmentWidget = StreamAttachmentWidget; + +/// {@template attachment_widget} /// Abstract class for deriving attachment types -abstract class AttachmentWidget extends StatelessWidget { +/// {@endtemplate} +abstract class StreamAttachmentWidget extends StatelessWidget { /// Constructor for creating attachment widget - const AttachmentWidget({ + const StreamAttachmentWidget({ Key? key, required this.message, required this.attachment, 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 0b5d580f..6bac62e9 100644 --- a/packages/stream_chat_flutter/lib/src/attachment/file_attachment.dart +++ b/packages/stream_chat_flutter/lib/src/attachment/file_attachment.dart @@ -10,10 +10,16 @@ import 'package:stream_chat_flutter/src/utils.dart'; import 'package:stream_chat_flutter/src/video_thumbnail_image.dart'; import 'package:stream_chat_flutter_core/stream_chat_flutter_core.dart'; +/// {@macro file_attachment} +@Deprecated("Use 'StreamFileAttachment' instead") +typedef FileAttachment = StreamFileAttachment; + +/// {@template file_attachment} /// Widget for displaying file attachments -class FileAttachment extends AttachmentWidget { +/// {@endtemplate} +class StreamFileAttachment extends StreamAttachmentWidget { /// Constructor for creating a widget when attachment is of type 'file' - const FileAttachment({ + const StreamFileAttachment({ Key? key, required Message message, required Attachment attachment, @@ -157,7 +163,7 @@ class FileAttachment extends AttachmentWidget { type: MaterialType.transparency, shape: _getDefaultShape(context), child: source.when( - local: () => VideoThumbnailImage( + local: () => StreamVideoThumbnailImage( fit: BoxFit.cover, video: attachment.file!.path!, placeholderBuilder: (_) => const Center( @@ -168,7 +174,7 @@ class FileAttachment extends AttachmentWidget { ), ), ), - network: () => VideoThumbnailImage( + network: () => StreamVideoThumbnailImage( fit: BoxFit.cover, video: attachment.assetUrl!, placeholderBuilder: (_) => const Center( @@ -278,7 +284,7 @@ class FileAttachment extends AttachmentWidget { ); return attachment.uploadState.when( preparing: () => Text(fileSize(size), style: textStyle), - inProgress: (sent, total) => UploadProgressIndicator( + inProgress: (sent, total) => StreamUploadProgressIndicator( uploaded: sent, total: total, showBackground: false, 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 1974b040..28e14e5e 100644 --- a/packages/stream_chat_flutter/lib/src/attachment/giphy_attachment.dart +++ b/packages/stream_chat_flutter/lib/src/attachment/giphy_attachment.dart @@ -5,10 +5,16 @@ import 'package:stream_chat_flutter/src/attachment/attachment_widget.dart'; import 'package:stream_chat_flutter/src/extension.dart'; import 'package:stream_chat_flutter/stream_chat_flutter.dart'; +/// {@macro giphy_attachment} +@Deprecated("Use 'StreamGiphyAttachment' instead") +typedef GiphyAttachment = StreamGiphyAttachment; + +/// {@template giphy_attachment} /// Widget for showing a GIF attachment -class GiphyAttachment extends AttachmentWidget { - /// Constructor for creating a [GiphyAttachment] widget - const GiphyAttachment({ +/// {@endtemplate} +class StreamGiphyAttachment extends StreamAttachmentWidget { + /// Constructor for creating a [StreamGiphyAttachment] widget + const StreamGiphyAttachment({ Key? key, required Message message, required Attachment attachment, @@ -228,7 +234,7 @@ class GiphyAttachment extends AttachmentWidget { alignment: Alignment.centerRight, child: Padding( padding: EdgeInsets.symmetric(horizontal: 8, vertical: 4), - child: VisibleFootnote(), + child: StreamVisibleFootnote(), ), ), ], @@ -243,7 +249,7 @@ class GiphyAttachment extends AttachmentWidget { final channel = StreamChannel.of(context).channel; return StreamChannel( channel: channel, - child: FullScreenMedia( + child: StreamFullScreenMedia( mediaAttachments: message.attachments, startIndex: message.attachments.indexOf(attachment), userName: message.user?.name, 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 a46ff25c..b6de6bc1 100644 --- a/packages/stream_chat_flutter/lib/src/attachment/image_attachment.dart +++ b/packages/stream_chat_flutter/lib/src/attachment/image_attachment.dart @@ -5,10 +5,16 @@ 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/stream_chat_flutter.dart'; +/// {@macro image_attachment} +@Deprecated("use 'StreamImageAttachment' instead") +typedef ImageAttachment = StreamImageAttachment; + +/// {@template image_attachment} /// Widget for showing an image attachment -class ImageAttachment extends AttachmentWidget { - /// Constructor for creating a [ImageAttachment] widget - const ImageAttachment({ +/// {@endtemplate} +class StreamImageAttachment extends StreamAttachmentWidget { + /// Constructor for creating a [StreamImageAttachment] widget + const StreamImageAttachment({ Key? key, required Message message, required Attachment attachment, @@ -25,8 +31,8 @@ class ImageAttachment extends AttachmentWidget { size: size, ); - /// [MessageThemeData] for showing image title - final MessageThemeData messageTheme; + /// [StreamMessageThemeData] for showing image title + final StreamMessageThemeData messageTheme; /// Flag for showing title final bool showTitle; @@ -137,7 +143,7 @@ class ImageAttachment extends AttachmentWidget { StreamChannel.of(context).channel; return StreamChannel( channel: channel, - child: FullScreenMedia( + child: StreamFullScreenMedia( mediaAttachments: message.attachments, startIndex: message.attachments.indexOf(attachment), @@ -155,7 +161,7 @@ class ImageAttachment extends AttachmentWidget { ), Padding( padding: const EdgeInsets.all(8), - child: AttachmentUploadStateBuilder( + child: StreamAttachmentUploadStateBuilder( message: message, attachment: attachment, ), @@ -166,7 +172,7 @@ class ImageAttachment extends AttachmentWidget { if (showTitle && attachment.title != null) Material( color: messageTheme.messageBackgroundColor, - child: AttachmentTitle( + child: StreamAttachmentTitle( messageTheme: messageTheme, attachment: attachment, ), diff --git a/packages/stream_chat_flutter/lib/src/attachment/url_attachment.dart b/packages/stream_chat_flutter/lib/src/attachment/url_attachment.dart index 8a79ca21..160b87da 100644 --- a/packages/stream_chat_flutter/lib/src/attachment/url_attachment.dart +++ b/packages/stream_chat_flutter/lib/src/attachment/url_attachment.dart @@ -2,10 +2,16 @@ import 'package:cached_network_image/cached_network_image.dart'; import 'package:flutter/material.dart'; import 'package:stream_chat_flutter/stream_chat_flutter.dart'; +/// {@macro url_attachment} +@Deprecated("Use 'StreamUrlAttachment' instead") +typedef UrlAttachment = StreamUrlAttachment; + +/// {@template url_attachment} /// Widget to display URL attachment -class UrlAttachment extends StatelessWidget { - /// Constructor for creating a [UrlAttachment] - const UrlAttachment({ +/// {@endtemplate} +class StreamUrlAttachment extends StatelessWidget { + /// Constructor for creating a [StreamUrlAttachment] + const StreamUrlAttachment({ Key? key, required this.urlAttachment, required this.hostDisplayName, @@ -25,8 +31,8 @@ class UrlAttachment extends StatelessWidget { /// Padding for text final EdgeInsets textPadding; - /// [MessageThemeData] for showing image title - final MessageThemeData messageTheme; + /// [StreamMessageThemeData] for showing image title + final StreamMessageThemeData messageTheme; @override Widget build(BuildContext context) { 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 3df1f451..541f1484 100644 --- a/packages/stream_chat_flutter/lib/src/attachment/video_attachment.dart +++ b/packages/stream_chat_flutter/lib/src/attachment/video_attachment.dart @@ -4,10 +4,16 @@ import 'package:stream_chat_flutter/src/attachment/attachment_widget.dart'; import 'package:stream_chat_flutter/src/video_thumbnail_image.dart'; import 'package:stream_chat_flutter/stream_chat_flutter.dart'; +/// {@macro video_attachment} +@Deprecated("Use 'StreamVideoAttachment' instead") +typedef VideoAttachment = StreamVideoAttachment; + +/// {@template video_attachment} /// Widget for showing a video attachment -class VideoAttachment extends AttachmentWidget { - /// Constructor for creating a [VideoAttachment] widget - const VideoAttachment({ +/// {@endtemplate} +class StreamVideoAttachment extends StreamAttachmentWidget { + /// Constructor for creating a [StreamVideoAttachment] widget + const StreamVideoAttachment({ Key? key, required Message message, required Attachment attachment, @@ -23,8 +29,8 @@ class VideoAttachment extends AttachmentWidget { size: size, ); - /// [MessageThemeData] for showing title - final MessageThemeData messageTheme; + /// [StreamMessageThemeData] for showing title + final StreamMessageThemeData messageTheme; /// Callback when show message is tapped final ShowMessageCallback? onShowMessage; @@ -43,7 +49,7 @@ class VideoAttachment extends AttachmentWidget { } return _buildVideoAttachment( context, - VideoThumbnailImage( + StreamVideoThumbnailImage( video: attachment.file!.path!, height: size?.height, width: size?.width, @@ -58,7 +64,7 @@ class VideoAttachment extends AttachmentWidget { } return _buildVideoAttachment( context, - VideoThumbnailImage( + StreamVideoThumbnailImage( video: attachment.assetUrl!, height: size?.height, width: size?.width, @@ -84,7 +90,7 @@ class VideoAttachment extends AttachmentWidget { MaterialPageRoute( builder: (_) => StreamChannel( channel: channel, - child: FullScreenMedia( + child: StreamFullScreenMedia( mediaAttachments: message.attachments, startIndex: message.attachments.indexOf(attachment), @@ -111,7 +117,7 @@ class VideoAttachment extends AttachmentWidget { ), Padding( padding: const EdgeInsets.all(8), - child: AttachmentUploadStateBuilder( + child: StreamAttachmentUploadStateBuilder( message: message, attachment: attachment, ), @@ -123,7 +129,7 @@ class VideoAttachment extends AttachmentWidget { if (attachment.title != null) Material( color: messageTheme.messageBackgroundColor, - child: AttachmentTitle( + child: StreamAttachmentTitle( messageTheme: messageTheme, attachment: attachment, ), diff --git a/packages/stream_chat_flutter/lib/src/attachment_actions_modal.dart b/packages/stream_chat_flutter/lib/src/attachment_actions_modal.dart index 4fedfc12..41e6fd11 100644 --- a/packages/stream_chat_flutter/lib/src/attachment_actions_modal.dart +++ b/packages/stream_chat_flutter/lib/src/attachment_actions_modal.dart @@ -58,7 +58,7 @@ class AttachmentActionsModal extends StatelessWidget { /// List of custom actions final List customActions; - /// Creates a copy of [MessageWidget] with specified attributes overridden. + /// Creates a copy of [StreamMessageWidget] with specified attributes overridden. AttachmentActionsModal copyWith({ Key? key, int? currentIndex, diff --git a/packages/stream_chat_flutter/lib/src/back_button.dart b/packages/stream_chat_flutter/lib/src/back_button.dart index 08d8dabf..b7cd4552 100644 --- a/packages/stream_chat_flutter/lib/src/back_button.dart +++ b/packages/stream_chat_flutter/lib/src/back_button.dart @@ -50,7 +50,7 @@ class StreamBackButton extends StatelessWidget { Positioned( top: 7, right: 7, - child: UnreadIndicator( + child: StreamUnreadIndicator( cid: cid, ), ), diff --git a/packages/stream_chat_flutter/lib/src/channel_avatar.dart b/packages/stream_chat_flutter/lib/src/channel_avatar.dart index f7c949ee..077302dd 100644 --- a/packages/stream_chat_flutter/lib/src/channel_avatar.dart +++ b/packages/stream_chat_flutter/lib/src/channel_avatar.dart @@ -152,7 +152,7 @@ class ChannelAvatar extends StatelessWidget { return BetterStreamBuilder( stream: streamChat.client.state.currentUserStream.map((it) => it!), initialData: currentUser, - builder: (context, user) => UserAvatar( + builder: (context, user) => StreamUserAvatar( borderRadius: borderRadius ?? previewTheme?.borderRadius, user: user, constraints: constraints ?? previewTheme?.constraints, @@ -175,7 +175,7 @@ class ChannelAvatar extends StatelessWidget { ), ), initialData: member, - builder: (context, member) => UserAvatar( + builder: (context, member) => StreamUserAvatar( borderRadius: borderRadius ?? previewTheme?.borderRadius, user: member.user!, constraints: constraints ?? previewTheme?.constraints, @@ -188,7 +188,7 @@ class ChannelAvatar extends StatelessWidget { } // Group conversation - return GroupAvatar( + return StreamGroupAvatar( members: otherMembers, borderRadius: borderRadius ?? previewTheme?.borderRadius, constraints: constraints ?? previewTheme?.constraints, diff --git a/packages/stream_chat_flutter/lib/src/channel_bottom_sheet.dart b/packages/stream_chat_flutter/lib/src/channel_bottom_sheet.dart index 05d5996e..66438479 100644 --- a/packages/stream_chat_flutter/lib/src/channel_bottom_sheet.dart +++ b/packages/stream_chat_flutter/lib/src/channel_bottom_sheet.dart @@ -4,10 +4,7 @@ import 'package:stream_chat_flutter/src/extension.dart'; import 'package:stream_chat_flutter/stream_chat_flutter.dart'; /// Bottom Sheet with options -@Deprecated( - "'ChannelBottomSheet' is deprecated and shouldn't be used. " - "Please use 'StreamChannelBottomSheet' instead.", -) +@Deprecated("Use 'StreamChannelInfoBottomSheet' instead") class ChannelBottomSheet extends StatefulWidget { /// Constructor for creating bottom sheet const ChannelBottomSheet({Key? key, this.onViewInfoTap}) : super(key: key); @@ -24,7 +21,7 @@ class _ChannelBottomSheetState extends State { bool _showActions = true; late StreamChannelState _streamChannelState; - late ChannelPreviewThemeData _channelPreviewThemeData; + late StreamChannelPreviewThemeData _channelPreviewThemeData; late StreamChatThemeData _streamChatThemeData; late StreamChatState _streamChatState; @@ -58,7 +55,8 @@ class _ChannelBottomSheetState extends State { Center( child: Padding( padding: const EdgeInsets.symmetric(horizontal: 16), - child: ChannelName( + child: StreamChannelName( + channel: channel, textStyle: _streamChatThemeData.textTheme.headlineBold, ), ), @@ -67,7 +65,7 @@ class _ChannelBottomSheetState extends State { height: 5, ), Center( - child: ChannelInfo( + child: StreamChannelInfo( showTypingIndicator: false, channel: _streamChannelState.channel, textStyle: _channelPreviewThemeData.subtitleStyle, @@ -79,7 +77,7 @@ class _ChannelBottomSheetState extends State { if (channel.isDistinct && channel.memberCount == 2) Column( children: [ - UserAvatar( + StreamUserAvatar( user: members .firstWhere( (e) => e.user?.id != userAsMember.user?.id, @@ -122,7 +120,7 @@ class _ChannelBottomSheetState extends State { padding: const EdgeInsets.symmetric(horizontal: 8), child: Column( children: [ - UserAvatar( + StreamUserAvatar( user: members[index].user!, constraints: const BoxConstraints.tightFor( height: 64, @@ -150,7 +148,7 @@ class _ChannelBottomSheetState extends State { const SizedBox( height: 24, ), - OptionListTile( + StreamOptionListTile( leading: Padding( padding: const EdgeInsets.symmetric(horizontal: 16), child: StreamSvgIcon.user( @@ -163,7 +161,7 @@ class _ChannelBottomSheetState extends State { if (!channel.isDistinct && channel.ownCapabilities .contains(PermissionType.leaveChannel)) - OptionListTile( + StreamOptionListTile( leading: Padding( padding: const EdgeInsets.symmetric(horizontal: 16), child: StreamSvgIcon.userRemove( @@ -184,7 +182,7 @@ class _ChannelBottomSheetState extends State { if (isOwner && channel.ownCapabilities .contains(PermissionType.deleteChannel)) - OptionListTile( + StreamOptionListTile( leading: Padding( padding: const EdgeInsets.symmetric(horizontal: 16), child: StreamSvgIcon.delete( @@ -203,7 +201,7 @@ class _ChannelBottomSheetState extends State { }); }, ), - OptionListTile( + StreamOptionListTile( leading: Padding( padding: const EdgeInsets.symmetric(horizontal: 16), child: StreamSvgIcon.closeSmall( @@ -224,7 +222,7 @@ class _ChannelBottomSheetState extends State { void didChangeDependencies() { _streamChannelState = StreamChannel.of(context); _streamChatThemeData = StreamChatTheme.of(context); - _channelPreviewThemeData = ChannelPreviewTheme.of(context); + _channelPreviewThemeData = StreamChannelPreviewTheme.of(context); _streamChatState = StreamChat.of(context); super.didChangeDependencies(); } diff --git a/packages/stream_chat_flutter/lib/src/channel_header.dart b/packages/stream_chat_flutter/lib/src/channel_header.dart index 954aa758..9da8b4f8 100644 --- a/packages/stream_chat_flutter/lib/src/channel_header.dart +++ b/packages/stream_chat_flutter/lib/src/channel_header.dart @@ -4,6 +4,11 @@ import 'package:stream_chat_flutter/src/channel_info.dart'; import 'package:stream_chat_flutter/src/extension.dart'; import 'package:stream_chat_flutter/stream_chat_flutter.dart'; +///{@macro template_name} +@Deprecated("Use 'StreamChannelHeader' instead") +typedef ChannelHeader = StreamChannelHeader; + +/// {@template channel_header} /// ![screenshot](https://raw.githubusercontent.com/GetStream/stream-chat-flutter/master/packages/stream_chat_flutter/screenshots/channel_header.png) /// ![screenshot](https://raw.githubusercontent.com/GetStream/stream-chat-flutter/master/packages/stream_chat_flutter/screenshots/channel_header_paint.png) /// @@ -49,9 +54,11 @@ import 'package:stream_chat_flutter/stream_chat_flutter.dart'; /// The widget components render the ui based on the first ancestor of type /// [StreamChatTheme] and on its [ChannelTheme.channelHeaderTheme] property. /// Modify it to change the widget appearance. -class ChannelHeader extends StatelessWidget implements PreferredSizeWidget { +/// {@endtemplate} +class StreamChannelHeader extends StatelessWidget + implements PreferredSizeWidget { /// Creates a channel header - const ChannelHeader({ + const StreamChannelHeader({ Key? key, this.showBackButton = true, this.onBackPressed, @@ -96,16 +103,16 @@ class ChannelHeader extends StatelessWidget implements PreferredSizeWidget { final Widget? leading; /// AppBar actions - /// By default it shows the [ChannelAvatar] + /// By default it shows the [StreamChannelAvatar] final List? actions; - /// The background color for this [ChannelHeader]. + /// The background color for this [StreamChannelHeader]. final Color? backgroundColor; @override Widget build(BuildContext context) { final channel = StreamChannel.of(context).channel; - final channelHeaderTheme = ChannelHeaderTheme.of(context); + final channelHeaderTheme = StreamChannelHeaderTheme.of(context); final leadingWidget = leading ?? (showBackButton @@ -115,7 +122,7 @@ class ChannelHeader extends StatelessWidget implements PreferredSizeWidget { ) : const SizedBox()); - return ConnectionStatusBuilder( + return StreamConnectionStatusBuilder( statusBuilder: (context, status) { var statusString = ''; var showStatus = true; @@ -135,7 +142,7 @@ class ChannelHeader extends StatelessWidget implements PreferredSizeWidget { final theme = Theme.of(context); - return InfoTile( + return StreamInfoTile( showMessage: showConnectionStateTile && showStatus, message: statusString, child: AppBar( @@ -152,7 +159,8 @@ class ChannelHeader extends StatelessWidget implements PreferredSizeWidget { Padding( padding: const EdgeInsets.only(right: 10), child: Center( - child: ChannelAvatar( + child: StreamChannelAvatar( + channel: channel, borderRadius: channelHeaderTheme.avatarTheme?.borderRadius, constraints: @@ -172,12 +180,13 @@ class ChannelHeader extends StatelessWidget implements PreferredSizeWidget { mainAxisAlignment: MainAxisAlignment.center, children: [ title ?? - ChannelName( + StreamChannelName( + channel: channel, textStyle: channelHeaderTheme.titleStyle, ), const SizedBox(height: 2), subtitle ?? - ChannelInfo( + StreamChannelInfo( showTypingIndicator: showTypingIndicator, channel: channel, textStyle: channelHeaderTheme.subtitleStyle, diff --git a/packages/stream_chat_flutter/lib/src/channel_info.dart b/packages/stream_chat_flutter/lib/src/channel_info.dart index 6a8e0634..b30058b9 100644 --- a/packages/stream_chat_flutter/lib/src/channel_info.dart +++ b/packages/stream_chat_flutter/lib/src/channel_info.dart @@ -3,10 +3,16 @@ import 'package:flutter/material.dart'; import 'package:stream_chat_flutter/src/extension.dart'; import 'package:stream_chat_flutter/stream_chat_flutter.dart'; +/// {@macro channel_info} +@Deprecated("Use 'StreamChannelInfo' instead") +typedef ChannelInfo = StreamChannelInfo; + +/// {@template channel_info} /// Widget which shows channel info -class ChannelInfo extends StatelessWidget { - /// Constructor which creates a [ChannelInfo] widget - const ChannelInfo({ +/// {@endtemplate} +class StreamChannelInfo extends StatelessWidget { + /// Constructor which creates a [StreamChannelInfo] widget + const StreamChannelInfo({ Key? key, required this.channel, this.textStyle, @@ -32,7 +38,7 @@ class ChannelInfo extends StatelessWidget { return BetterStreamBuilder>( stream: channel.state!.membersStream, initialData: channel.state!.members, - builder: (context, data) => ConnectionStatusBuilder( + builder: (context, data) => StreamConnectionStatusBuilder( statusBuilder: (context, status) { switch (status) { case ConnectionStatus.connected: @@ -66,7 +72,7 @@ class ChannelInfo extends StatelessWidget { } alternativeWidget = Text( text, - style: ChannelHeaderTheme.of(context).subtitleStyle, + style: StreamChannelHeaderTheme.of(context).subtitleStyle, ); } else { final userId = StreamChat.of(context).currentUser?.id; @@ -95,7 +101,7 @@ class ChannelInfo extends StatelessWidget { } return Align( - child: TypingIndicator( + child: StreamTypingIndicator( parentId: parentId, style: textStyle, alternativeWidget: alternativeWidget, diff --git a/packages/stream_chat_flutter/lib/src/channel_list_header.dart b/packages/stream_chat_flutter/lib/src/channel_list_header.dart index 6c54ad89..f814a08e 100644 --- a/packages/stream_chat_flutter/lib/src/channel_list_header.dart +++ b/packages/stream_chat_flutter/lib/src/channel_list_header.dart @@ -11,7 +11,11 @@ typedef TitleBuilder = Widget Function( StreamChatClient client, ); -/// +/// {@macro channel_list_header} +@Deprecated("Use 'StreamChannelListHeader' instead") +typedef ChannelListHeader = StreamChannelListHeader; + +/// {@template channel_list_header} /// It shows the current [StreamChatClient] status. /// /// ```dart @@ -43,11 +47,13 @@ typedef TitleBuilder = Widget Function( /// if you don't have it in the widget tree. /// /// The widget components render the ui based on the first ancestor of type -/// [StreamChatTheme] and on its [ChannelListHeaderThemeData] property. +/// [StreamChatTheme] and on its [StreamChannelListHeaderThemeData] property. /// Modify it to change the widget appearance. -class ChannelListHeader extends StatelessWidget implements PreferredSizeWidget { +/// {@endtemplate} +class StreamChannelListHeader extends StatelessWidget + implements PreferredSizeWidget { /// Instantiates a ChannelListHeader - const ChannelListHeader({ + const StreamChannelListHeader({ Key? key, this.client, this.titleBuilder, @@ -91,14 +97,14 @@ class ChannelListHeader extends StatelessWidget implements PreferredSizeWidget { /// By default it shows the new chat button final List? actions; - /// The background color for this [ChannelListHeader]. + /// The background color for this [StreamChannelListHeader]. final Color? backgroundColor; @override Widget build(BuildContext context) { final _client = client ?? StreamChat.of(context).client; final user = _client.state.currentUser; - return ConnectionStatusBuilder( + return StreamConnectionStatusBuilder( statusBuilder: (context, status) { var statusString = ''; var showStatus = true; @@ -117,9 +123,10 @@ class ChannelListHeader extends StatelessWidget implements PreferredSizeWidget { } final chatThemeData = StreamChatTheme.of(context); - final channelListHeaderThemeData = ChannelListHeaderTheme.of(context); + final channelListHeaderThemeData = + StreamChannelListHeaderTheme.of(context); final theme = Theme.of(context); - return InfoTile( + return StreamInfoTile( showMessage: showConnectionStateTile && showStatus, message: statusString, child: AppBar( @@ -135,7 +142,7 @@ class ChannelListHeader extends StatelessWidget implements PreferredSizeWidget { leading: leading ?? Center( child: user != null - ? UserAvatar( + ? StreamUserAvatar( user: user, showOnlineStatus: false, onTap: onUserAvatarTap ?? @@ -156,7 +163,7 @@ class ChannelListHeader extends StatelessWidget implements PreferredSizeWidget { [ StreamNeumorphicButton( child: IconButton( - icon: ConnectionStatusBuilder( + icon: StreamConnectionStatusBuilder( statusBuilder: (context, status) { Color? color; switch (status) { @@ -234,10 +241,11 @@ class ChannelListHeader extends StatelessWidget implements PreferredSizeWidget { const SizedBox(width: 10), Text( context.translations.searchingForNetworkText, - style: ChannelListHeaderTheme.of(context).titleStyle?.copyWith( - fontSize: 16, - fontWeight: FontWeight.bold, - ), + style: + StreamChannelListHeaderTheme.of(context).titleStyle?.copyWith( + fontSize: 16, + fontWeight: FontWeight.bold, + ), ), ], ); @@ -247,7 +255,7 @@ class ChannelListHeader extends StatelessWidget implements PreferredSizeWidget { StreamChatClient client, ) { final chatThemeData = StreamChatTheme.of(context); - final channelListHeaderTheme = ChannelListHeaderTheme.of(context); + final channelListHeaderTheme = StreamChannelListHeaderTheme.of(context); return Row( mainAxisAlignment: MainAxisAlignment.center, children: [ diff --git a/packages/stream_chat_flutter/lib/src/channel_list_view.dart b/packages/stream_chat_flutter/lib/src/channel_list_view.dart index cb581491..1113fda2 100644 --- a/packages/stream_chat_flutter/lib/src/channel_list_view.dart +++ b/packages/stream_chat_flutter/lib/src/channel_list_view.dart @@ -1,7 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_slidable/flutter_slidable.dart'; import 'package:shimmer/shimmer.dart'; -import 'package:stream_chat_flutter/src/channel_bottom_sheet.dart'; import 'package:stream_chat_flutter/src/extension.dart'; import 'package:stream_chat_flutter/stream_chat_flutter.dart'; @@ -11,7 +10,7 @@ typedef ChannelTapCallback = void Function(Channel, Widget?); /// Callback called when tapping on a channel typedef ChannelInfoCallback = void Function(Channel); -/// Builder used to create a custom [ChannelPreview] from a [Channel] +/// Builder used to create a custom [StreamChannelPreview] from a [Channel] typedef ChannelPreviewBuilder = Widget Function(BuildContext, Channel); /// Callback for when 'View Info' is tapped @@ -52,10 +51,7 @@ typedef ViewInfoCallback = void Function(Channel); /// The widget components render the ui based on the first ancestor of /// type [StreamChatTheme]. /// Modify it to change the widget appearance. -@Deprecated( - "'ChannelListView' is deprecated and shouldn't be used. " - "Please use 'StreamChannelListView' instead.", -) +@Deprecated("Use 'StreamChannelListView' instead") class ChannelListView extends StatefulWidget { /// Instantiate a new ChannelListView ChannelListView({ @@ -248,7 +244,8 @@ class _ChannelListViewState extends State { child: child, ); - final backgroundColor = ChannelListViewTheme.of(context).backgroundColor; + final backgroundColor = + StreamChannelListViewTheme.of(context).backgroundColor; if (backgroundColor != null) { return ColoredBox( @@ -550,7 +547,8 @@ class _ChannelListViewState extends State { context: context, builder: (context) => StreamChannel( channel: channel, - child: ChannelBottomSheet( + child: StreamChannelInfoBottomSheet( + channel: channel, onViewInfoTap: () { widget.onViewInfoTap?.call(channel); }, @@ -593,7 +591,7 @@ class _ChannelListViewState extends State { decoration: BoxDecoration( color: chatThemeData.channelListViewTheme.backgroundColor, ), - child: ChannelPreview( + child: StreamChannelPreview( onLongPress: widget.onChannelLongPress, channel: channel, onImageTap: widget.onImageTap != null @@ -639,7 +637,7 @@ class _ChannelListViewState extends State { child: Column( mainAxisSize: MainAxisSize.min, children: [ - ChannelAvatar( + StreamChannelAvatar( channel: channel, borderRadius: BorderRadius.circular(32), selected: selected, @@ -654,8 +652,9 @@ class _ChannelListViewState extends State { padding: const EdgeInsets.symmetric(horizontal: 8), child: StreamChannel( channel: channel, - child: const ChannelName( - textStyle: TextStyle( + child: StreamChannelName( + channel: channel, + textStyle: const TextStyle( fontSize: 12, fontWeight: FontWeight.w600, ), diff --git a/packages/stream_chat_flutter/lib/src/channel_name.dart b/packages/stream_chat_flutter/lib/src/channel_name.dart index 8dd8c054..f496b28a 100644 --- a/packages/stream_chat_flutter/lib/src/channel_name.dart +++ b/packages/stream_chat_flutter/lib/src/channel_name.dart @@ -6,10 +6,7 @@ import 'package:stream_chat_flutter/stream_chat_flutter.dart'; /// /// The widget uses a [StreamBuilder] to render the channel information /// image as soon as it updates. -@Deprecated( - "'ChannelName' is deprecated and shouldn't be used. " - "Please use 'StreamChannelName' instead.", -) +@Deprecated("Use 'StreamChannelName' instead") class ChannelName extends StatelessWidget { /// Instantiate a new ChannelName const ChannelName({ diff --git a/packages/stream_chat_flutter/lib/src/channel_preview.dart b/packages/stream_chat_flutter/lib/src/channel_preview.dart index 125d06fe..1eb28bd2 100644 --- a/packages/stream_chat_flutter/lib/src/channel_preview.dart +++ b/packages/stream_chat_flutter/lib/src/channel_preview.dart @@ -4,6 +4,11 @@ import 'package:flutter/material.dart'; import 'package:stream_chat_flutter/src/extension.dart'; import 'package:stream_chat_flutter/stream_chat_flutter.dart'; +/// {@macro channel_preview} +@Deprecated("Use 'StreamChannelPreview' instead") +typedef ChannelPreview = StreamChannelPreview; + +/// {@template channel_preview} /// ![screenshot](https://raw.githubusercontent.com/GetStream/stream-chat-flutter/master/packages/stream_chat_flutter/screenshots/channel_preview.png) /// ![screenshot](https://raw.githubusercontent.com/GetStream/stream-chat-flutter/master/packages/stream_chat_flutter/screenshots/channel_preview_paint.png) /// @@ -13,14 +18,15 @@ import 'package:stream_chat_flutter/stream_chat_flutter.dart'; /// image as soon as it updates. /// /// Usually you don't use this widget as it's the default channel preview -/// used by [ChannelListView]. +/// used by [StreamChannelListView]. /// /// The widget renders the ui based on the first ancestor of type /// [StreamChatTheme]. /// Modify it to change the widget appearance. -class ChannelPreview extends StatelessWidget { - /// Constructor for creating [ChannelPreview] - const ChannelPreview({ +/// {@endtemplate} +class StreamChannelPreview extends StatelessWidget { + /// Constructor for creating [StreamChannelPreview] + const StreamChannelPreview({ required this.channel, Key? key, this.onTap, @@ -52,7 +58,7 @@ class ChannelPreview extends StatelessWidget { final Widget? subtitle; /// Widget rendering the leading element, by default - /// it shows the [ChannelAvatar] + /// it shows the [StreamChannelAvatar] final Widget? leading; /// Widget rendering the trailing element, @@ -60,12 +66,12 @@ class ChannelPreview extends StatelessWidget { final Widget? trailing; /// Widget rendering the sending indicator, - /// by default it uses the [SendingIndicator] widget + /// by default it uses the [StreamSendingIndicator] widget final Widget? sendingIndicator; @override Widget build(BuildContext context) { - final channelPreviewTheme = ChannelPreviewTheme.of(context); + final channelPreviewTheme = StreamChannelPreviewTheme.of(context); final streamChatState = StreamChat.of(context); return BetterStreamBuilder( stream: channel.isMutedStream, @@ -80,13 +86,18 @@ class ChannelPreview extends StatelessWidget { ), onTap: () => onTap?.call(channel), onLongPress: () => onLongPress?.call(channel), - leading: leading ?? ChannelAvatar(onTap: onImageTap), + leading: leading ?? + StreamChannelAvatar( + channel: channel, + onTap: onImageTap, + ), title: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Flexible( child: title ?? - ChannelName( + StreamChannelName( + channel: channel, textStyle: channelPreviewTheme.titleStyle, ), ), @@ -100,7 +111,7 @@ class ChannelPreview extends StatelessWidget { e.user!.id == channel.client.state.currentUser?.id)) { return const SizedBox(); } - return UnreadIndicator( + return StreamUnreadIndicator( cid: channel.cid, ); }, @@ -136,7 +147,7 @@ class ChannelPreview extends StatelessWidget { ))); final isMessageRead = readList.length >= (channel.memberCount ?? 0) - 1; - return SendingIndicator( + return StreamSendingIndicator( message: lastMessage!, size: channelPreviewTheme.indicatorIconSize, isMessageRead: isMessageRead, @@ -183,13 +194,13 @@ class ChannelPreview extends StatelessWidget { return Text( stringDate, - style: ChannelPreviewTheme.of(context).lastMessageAtStyle, + style: StreamChannelPreviewTheme.of(context).lastMessageAtStyle, ); }, ); Widget _buildSubtitle(BuildContext context) { - final channelPreviewTheme = ChannelPreviewTheme.of(context); + final channelPreviewTheme = StreamChannelPreviewTheme.of(context); if (channel.isMuted) { return Row( crossAxisAlignment: CrossAxisAlignment.end, @@ -204,7 +215,7 @@ class ChannelPreview extends StatelessWidget { ], ); } - return TypingIndicator( + return StreamTypingIndicator( channel: channel, alternativeWidget: _buildLastMessage(context), style: channelPreviewTheme.subtitleStyle, @@ -242,7 +253,7 @@ class ChannelPreview extends StatelessWidget { text = parts.join(' '); - final channelPreviewTheme = ChannelPreviewTheme.of(context); + final channelPreviewTheme = StreamChannelPreviewTheme.of(context); return Text.rich( _getDisplayText( text, diff --git a/packages/stream_chat_flutter/lib/src/commands_overlay.dart b/packages/stream_chat_flutter/lib/src/commands_overlay.dart index 9f8aca1e..6234f696 100644 --- a/packages/stream_chat_flutter/lib/src/commands_overlay.dart +++ b/packages/stream_chat_flutter/lib/src/commands_overlay.dart @@ -2,10 +2,17 @@ import 'package:flutter/material.dart'; import 'package:stream_chat_flutter/src/extension.dart'; import 'package:stream_chat_flutter/stream_chat_flutter.dart'; +/// {@macro commands_overlay} +@Deprecated("Use 'StreamCommandsOverlay' instead") +typedef CommandsOverlay = StreamCommandsOverlay; + +/// {@template commands_overlay} /// Overlay for displaying commands that can be used -class CommandsOverlay extends StatelessWidget { - /// Constructor for creating a [CommandsOverlay] - const CommandsOverlay({ +/// to interact with the channel. +/// {@endtemplate} +class StreamCommandsOverlay extends StatelessWidget { + /// Constructor for creating a [StreamCommandsOverlay] + const StreamCommandsOverlay({ required this.text, required this.onCommandResult, required this.size, diff --git a/packages/stream_chat_flutter/lib/src/connection_status_builder.dart b/packages/stream_chat_flutter/lib/src/connection_status_builder.dart index f0eca9da..6f234547 100644 --- a/packages/stream_chat_flutter/lib/src/connection_status_builder.dart +++ b/packages/stream_chat_flutter/lib/src/connection_status_builder.dart @@ -1,14 +1,20 @@ import 'package:flutter/material.dart'; import 'package:stream_chat_flutter/stream_chat_flutter.dart'; +/// {@macro connection_status_builder} +@Deprecated("Use 'StreamConnectionStatusBuilder' instead") +typedef ConnectionStatusBuilder = StreamConnectionStatusBuilder; + +/// {@template connection_status_builder} /// Widget that builds itself based on the latest snapshot of interaction with /// a [Stream] of type [ConnectionStatus]. /// /// The widget will use the closest [StreamChatClient.wsConnectionStatusStream] /// in case no stream is provided. -class ConnectionStatusBuilder extends StatelessWidget { +/// {@endtemplate} +class StreamConnectionStatusBuilder extends StatelessWidget { /// Creates a new ConnectionStatusBuilder - const ConnectionStatusBuilder({ + const StreamConnectionStatusBuilder({ Key? key, required this.statusBuilder, this.connectionStatusStream, diff --git a/packages/stream_chat_flutter/lib/src/date_divider.dart b/packages/stream_chat_flutter/lib/src/date_divider.dart index c3b48158..64396ceb 100644 --- a/packages/stream_chat_flutter/lib/src/date_divider.dart +++ b/packages/stream_chat_flutter/lib/src/date_divider.dart @@ -3,10 +3,16 @@ import 'package:jiffy/jiffy.dart'; import 'package:stream_chat_flutter/src/extension.dart'; import 'package:stream_chat_flutter/src/stream_chat_theme.dart'; +/// {@macro date_divider} +@Deprecated("Use 'StreamDateDivider' instead") +typedef DateDivider = StreamDateDivider; + +/// {@template date_divider} /// It shows a date divider depending on the date difference -class DateDivider extends StatelessWidget { - /// Constructor for creating a [DateDivider] - const DateDivider({ +/// {@endtemplate} +class StreamDateDivider extends StatelessWidget { + /// Constructor for creating a [StreamDateDivider] + const StreamDateDivider({ Key? key, required this.dateTime, this.uppercase = false, diff --git a/packages/stream_chat_flutter/lib/src/deleted_message.dart b/packages/stream_chat_flutter/lib/src/deleted_message.dart index 09d725bb..667d101d 100644 --- a/packages/stream_chat_flutter/lib/src/deleted_message.dart +++ b/packages/stream_chat_flutter/lib/src/deleted_message.dart @@ -3,10 +3,16 @@ import 'package:stream_chat_flutter/src/extension.dart'; import 'package:stream_chat_flutter/src/stream_chat_theme.dart'; import 'package:stream_chat_flutter/src/theme/themes.dart'; -/// Widget to display deleted message -class DeletedMessage extends StatelessWidget { - /// Constructor to create [DeletedMessage] - const DeletedMessage({ +/// {@macro deleted_message} +@Deprecated("Use 'StreamDeletedMessage' instead") +typedef DeletedMessage = StreamDeletedMessage; + +/// {@template deleted_message} +/// Widget to display deleted message. +/// {@endtemplate} +class StreamDeletedMessage extends StatelessWidget { + /// Constructor to create [StreamDeletedMessage] + const StreamDeletedMessage({ Key? key, required this.messageTheme, this.borderRadiusGeometry, @@ -16,7 +22,7 @@ class DeletedMessage extends StatelessWidget { }) : super(key: key); /// The theme of the message - final MessageThemeData messageTheme; + final StreamMessageThemeData messageTheme; /// The border radius of the message text final BorderRadiusGeometry? borderRadiusGeometry; diff --git a/packages/stream_chat_flutter/lib/src/emoji_overlay.dart b/packages/stream_chat_flutter/lib/src/emoji_overlay.dart index 0a3cb634..b4e50974 100644 --- a/packages/stream_chat_flutter/lib/src/emoji_overlay.dart +++ b/packages/stream_chat_flutter/lib/src/emoji_overlay.dart @@ -4,10 +4,16 @@ import 'package:stream_chat_flutter/src/extension.dart'; import 'package:stream_chat_flutter/stream_chat_flutter.dart'; import 'package:substring_highlight/substring_highlight.dart'; +/// {@macro emoji_overlay} +@Deprecated("Use 'StreamEmojiOverlay' instead") +typedef EmojiOverlay = StreamEmojiOverlay; + +/// {@template emoji_overlay} /// Overlay for displaying emoji that can be used -class EmojiOverlay extends StatelessWidget { - /// Constructor for creating a [EmojiOverlay] - const EmojiOverlay({ +/// {@endtemplate} +class StreamEmojiOverlay extends StatelessWidget { + /// Constructor for creating a [StreamEmojiOverlay] + const StreamEmojiOverlay({ required this.query, required this.onEmojiResult, required this.size, diff --git a/packages/stream_chat_flutter/lib/src/full_screen_media.dart b/packages/stream_chat_flutter/lib/src/full_screen_media.dart index aa185597..0ae3a475 100644 --- a/packages/stream_chat_flutter/lib/src/full_screen_media.dart +++ b/packages/stream_chat_flutter/lib/src/full_screen_media.dart @@ -21,10 +21,16 @@ enum ReturnActionType { /// Callback when show message is tapped typedef ShowMessageCallback = void Function(Message message, Channel channel); +/// {@macro full_screen_media} +@Deprecated("Use 'StreamFullScreenMedia' instead") +typedef FullScreenMedia = StreamFullScreenMedia; + +/// {@template full_screen_media} /// A full screen image widget -class FullScreenMedia extends StatefulWidget { +/// {@endtemplate} +class StreamFullScreenMedia extends StatefulWidget { /// Instantiate a new FullScreenImage - const FullScreenMedia({ + const StreamFullScreenMedia({ Key? key, required this.mediaAttachments, required this.message, @@ -60,10 +66,10 @@ class FullScreenMedia extends StatefulWidget { final bool autoplayVideos; @override - _FullScreenMediaState createState() => _FullScreenMediaState(); + _StreamFullScreenMediaState createState() => _StreamFullScreenMediaState(); } -class _FullScreenMediaState extends State +class _StreamFullScreenMediaState extends State with SingleTickerProviderStateMixin { late final AnimationController _animationController; late final PageController _pageController; @@ -172,7 +178,7 @@ class _FullScreenMediaState extends State ), backgroundDecoration: BoxDecoration( color: ColorTween( - begin: ChannelHeaderTheme.of(context).color, + begin: StreamChannelHeaderTheme.of(context).color, end: Colors.black, ).lerp(_curvedAnimation.value), ), @@ -221,7 +227,7 @@ class _FullScreenMediaState extends State builder: (context, value, child) => Column( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - GalleryHeader( + StreamGalleryHeader( userName: widget.userName, sentAt: context.translations.sentAtText( date: widget.message.createdAt, @@ -242,7 +248,7 @@ class _FullScreenMediaState extends State widget.attachmentActionsModalBuilder, ), if (!widget.message.isEphemeral) - GalleryFooter( + StreamGalleryFooter( currentPage: value, totalPages: widget.mediaAttachments.length, mediaAttachments: widget.mediaAttachments, diff --git a/packages/stream_chat_flutter/lib/src/gallery_footer.dart b/packages/stream_chat_flutter/lib/src/gallery_footer.dart index f189dae3..a137281c 100644 --- a/packages/stream_chat_flutter/lib/src/gallery_footer.dart +++ b/packages/stream_chat_flutter/lib/src/gallery_footer.dart @@ -9,10 +9,17 @@ import 'package:stream_chat_flutter/src/extension.dart'; import 'package:stream_chat_flutter/src/video_thumbnail_image.dart'; import 'package:stream_chat_flutter/stream_chat_flutter.dart'; +/// {@macro gallery_footer} +@Deprecated("Use 'StreamGalleryFooter' instead") +typedef GalleryFooter = StreamGalleryFooter; + +/// {@template gallery_footer} /// Footer widget for media display -class GalleryFooter extends StatefulWidget implements PreferredSizeWidget { +/// {@endtemplate} +class StreamGalleryFooter extends StatefulWidget + implements PreferredSizeWidget { /// Creates a channel header - const GalleryFooter({ + const StreamGalleryFooter({ Key? key, required this.message, this.onBackPressed, @@ -51,22 +58,22 @@ class GalleryFooter extends StatefulWidget implements PreferredSizeWidget { /// Callback when media is selected final ValueChanged? mediaSelectedCallBack; - /// The background color of this [GalleryFooter]. + /// The background color of this [StreamGalleryFooter]. final Color? backgroundColor; @override - _GalleryFooterState createState() => _GalleryFooterState(); + _StreamGalleryFooterState createState() => _StreamGalleryFooterState(); @override final Size preferredSize; } -class _GalleryFooterState extends State { +class _StreamGalleryFooterState extends State { @override Widget build(BuildContext context) { const showShareButton = !kIsWeb; final mediaQueryData = MediaQuery.of(context); - final galleryFooterThemeData = GalleryFooterTheme.of(context); + final galleryFooterThemeData = StreamGalleryFooterTheme.of(context); return SizedBox.fromSize( size: Size( mediaQueryData.size.width, @@ -149,7 +156,7 @@ class _GalleryFooterState extends State { void _showPhotosModal(context) { final chatThemeData = StreamChatTheme.of(context); - final galleryFooterThemeData = GalleryFooterTheme.of(context); + final galleryFooterThemeData = StreamGalleryFooterTheme.of(context); showModalBottomSheet( context: context, barrierColor: galleryFooterThemeData.bottomSheetBarrierColor, @@ -222,7 +229,7 @@ class _GalleryFooterState extends State { onTap: () => widget.mediaSelectedCallBack!(index), child: FittedBox( fit: BoxFit.cover, - child: VideoThumbnailImage( + child: StreamVideoThumbnailImage( video: (attachment.file?.path ?? attachment.assetUrl)!, ), @@ -264,7 +271,7 @@ class _GalleryFooterState extends State { ), ], ), - child: UserAvatar( + child: StreamUserAvatar( user: widget.message.user!, constraints: BoxConstraints.tight(const Size(24, 24)), diff --git a/packages/stream_chat_flutter/lib/src/gallery_header.dart b/packages/stream_chat_flutter/lib/src/gallery_header.dart index 2325af69..9c8650b2 100644 --- a/packages/stream_chat_flutter/lib/src/gallery_header.dart +++ b/packages/stream_chat_flutter/lib/src/gallery_header.dart @@ -15,10 +15,17 @@ typedef AttachmentActionsBuilder = Widget Function( AttachmentActionsModal defaultActionsModal, ); +/// {@macro gallery_header} +@Deprecated("Use 'StreamGalleryHeader' instead") +typedef GalleryHeader = StreamGalleryHeader; + +/// {@template gallery_header} /// Header/AppBar widget for media display screen -class GalleryHeader extends StatelessWidget implements PreferredSizeWidget { +/// {@endtemplate} +class StreamGalleryHeader extends StatelessWidget + implements PreferredSizeWidget { /// Creates a channel header - const GalleryHeader({ + const StreamGalleryHeader({ Key? key, required this.message, this.currentIndex = 0, @@ -62,7 +69,7 @@ class GalleryHeader extends StatelessWidget implements PreferredSizeWidget { /// Stores the current index of media shown final int currentIndex; - /// The background color of this [GalleryHeader]. + /// The background color of this [StreamGalleryHeader]. final Color? backgroundColor; /// Widget builder for attachment actions modal @@ -72,7 +79,7 @@ class GalleryHeader extends StatelessWidget implements PreferredSizeWidget { @override Widget build(BuildContext context) { - final galleryHeaderThemeData = GalleryHeaderTheme.of(context); + final galleryHeaderThemeData = StreamGalleryHeaderTheme.of(context); final theme = Theme.of(context); return AppBar( toolbarTextStyle: theme.textTheme.bodyText2, diff --git a/packages/stream_chat_flutter/lib/src/gradient_avatar.dart b/packages/stream_chat_flutter/lib/src/gradient_avatar.dart index 12824f45..aca07c92 100644 --- a/packages/stream_chat_flutter/lib/src/gradient_avatar.dart +++ b/packages/stream_chat_flutter/lib/src/gradient_avatar.dart @@ -3,10 +3,16 @@ import 'dart:ui' as ui; import 'package:flutter/material.dart'; +/// {@macro gradient_avatar} +@Deprecated("Use 'StreamGradientAvatar' instead") +typedef GradientAvatar = StreamGradientAvatar; + +/// {@template gradient_avatar} /// Fallback user avatar with a polygon gradient overlayed with text -class GradientAvatar extends StatefulWidget { - /// Constructor for [GradientAvatar] - const GradientAvatar({ +/// {@endtemplate} +class StreamGradientAvatar extends StatefulWidget { + /// Constructor for [StreamGradientAvatar] + const StreamGradientAvatar({ Key? key, required this.name, required this.userId, @@ -19,10 +25,10 @@ class GradientAvatar extends StatefulWidget { final String userId; @override - _GradientAvatarState createState() => _GradientAvatarState(); + _StreamGradientAvatarState createState() => _StreamGradientAvatarState(); } -class _GradientAvatarState extends State { +class _StreamGradientAvatarState extends State { @override Widget build(BuildContext context) => Center( child: RepaintBoundary( diff --git a/packages/stream_chat_flutter/lib/src/group_avatar.dart b/packages/stream_chat_flutter/lib/src/group_avatar.dart index e0e87e23..f7efa32d 100644 --- a/packages/stream_chat_flutter/lib/src/group_avatar.dart +++ b/packages/stream_chat_flutter/lib/src/group_avatar.dart @@ -1,10 +1,16 @@ import 'package:flutter/material.dart'; import 'package:stream_chat_flutter/stream_chat_flutter.dart'; +/// {@macro group_avatar} +@Deprecated("Use 'StreamGroupAvatar' instead") +typedef GroupAvatar = StreamGroupAvatar; + +/// {@template group_avatar} /// Widget for constructing a group of images -class GroupAvatar extends StatelessWidget { - /// Constructor for creating a [GroupAvatar] - const GroupAvatar({ +/// {@endtemplate} +class StreamGroupAvatar extends StatelessWidget { + /// Constructor for creating a [StreamGroupAvatar] + const StreamGroupAvatar({ Key? key, this.channel, required this.members, @@ -84,7 +90,7 @@ class GroupAvatar extends StatelessWidget { ), ), initialData: member, - builder: (context, member) => UserAvatar( + builder: (context, member) => StreamUserAvatar( showOnlineStatus: false, user: member.user!, borderRadius: BorderRadius.zero, @@ -122,7 +128,8 @@ class GroupAvatar extends StatelessWidget { ), ), initialData: member, - builder: (context, member) => UserAvatar( + builder: (context, member) => + StreamUserAvatar( showOnlineStatus: false, user: member.user!, borderRadius: BorderRadius.zero, diff --git a/packages/stream_chat_flutter/lib/src/image_group.dart b/packages/stream_chat_flutter/lib/src/image_group.dart index ff67b068..fa723bef 100644 --- a/packages/stream_chat_flutter/lib/src/image_group.dart +++ b/packages/stream_chat_flutter/lib/src/image_group.dart @@ -1,10 +1,16 @@ import 'package:flutter/material.dart'; import 'package:stream_chat_flutter/stream_chat_flutter.dart'; +/// {@macro image_group} +@Deprecated("Use 'StreamImageGroup' instead") +typedef ImageGroup = StreamImageGroup; + +/// {@template image_group} /// Widget for constructing a group of images in message -class ImageGroup extends StatelessWidget { - /// Constructor for creating [ImageGroup] widget - const ImageGroup({ +/// {@endtemplate} +class StreamImageGroup extends StatelessWidget { + /// Constructor for creating [StreamImageGroup] widget + const StreamImageGroup({ Key? key, required this.images, required this.message, @@ -27,8 +33,8 @@ class ImageGroup extends StatelessWidget { /// Message which images are attached to final Message message; - /// [MessageThemeData] to apply to message - final MessageThemeData messageTheme; + /// [StreamMessageThemeData] to apply to message + final StreamMessageThemeData messageTheme; /// Size of iamges final Size size; @@ -129,7 +135,7 @@ class ImageGroup extends StatelessWidget { MaterialPageRoute( builder: (context) => StreamChannel( channel: channel, - child: FullScreenMedia( + child: StreamFullScreenMedia( mediaAttachments: images, startIndex: index, userName: message.user?.name, @@ -142,7 +148,7 @@ class ImageGroup extends StatelessWidget { if (res != null) onReturnAction?.call(res); } - Widget _buildImage(BuildContext context, int index) => ImageAttachment( + Widget _buildImage(BuildContext context, int index) => StreamImageAttachment( attachment: images[index], size: size, message: message, diff --git a/packages/stream_chat_flutter/lib/src/info_tile.dart b/packages/stream_chat_flutter/lib/src/info_tile.dart index 965d4fed..86964bf0 100644 --- a/packages/stream_chat_flutter/lib/src/info_tile.dart +++ b/packages/stream_chat_flutter/lib/src/info_tile.dart @@ -2,10 +2,16 @@ import 'package:flutter/material.dart'; import 'package:flutter_portal/flutter_portal.dart'; import 'package:stream_chat_flutter/src/stream_chat_theme.dart'; +/// {@macro info_tile} +@Deprecated("Use 'StreamInfoTile' instead") +typedef InfoTile = StreamInfoTile; + +/// {@template info_tile} /// Tile to display a message, used in stream chat to display connection status -class InfoTile extends StatelessWidget { - /// Constructor for creating an [InfoTile] widget - const InfoTile({ +/// {@endtemplate} +class StreamInfoTile extends StatelessWidget { + /// Constructor for creating an [StreamInfoTile] widget + const StreamInfoTile({ Key? key, required this.message, required this.child, diff --git a/packages/stream_chat_flutter/lib/src/localization/translations.dart b/packages/stream_chat_flutter/lib/src/localization/translations.dart index ed15dad8..2a87e76d 100644 --- a/packages/stream_chat_flutter/lib/src/localization/translations.dart +++ b/packages/stream_chat_flutter/lib/src/localization/translations.dart @@ -59,7 +59,7 @@ abstract class Translations { /// The error shown when loading messages fails String get loadingMessagesError; - /// The text for showing the result count in [MessageSearchListView] + /// The text for showing the result count in [StreamMessageSearchListView] String resultCountText(int count); /// The text for showing the message is deleted @@ -74,20 +74,20 @@ abstract class Translations { /// The text for showing there are no chats String get emptyChatMessagesText; - /// The text for showing the thread separator in case [MessageListView] + /// The text for showing the thread separator in case [StreamMessageListView] /// contains a parent message String threadSeparatorText(int replyCount); - /// The label for "connected" in [ConnectionStatusBuilder] + /// The label for "connected" in [StreamConnectionStatusBuilder] String get connectedLabel; - /// The label for "disconnected" in [ConnectionStatusBuilder] + /// The label for "disconnected" in [StreamConnectionStatusBuilder] String get disconnectedLabel; - /// The label for "reconnecting" in [ConnectionStatusBuilder] + /// The label for "reconnecting" in [StreamConnectionStatusBuilder] String get reconnectingLabel; - /// The label for also send as direct message "checkbox"" in [MessageInput] + /// The label for also send as direct message "checkbox"" in [StreamMessageInput] String get alsoSendAsDirectMessageLabel; /// The label for search Gif @@ -97,24 +97,24 @@ abstract class Translations { String get sendMessagePermissionError; /// The label for add a comment or send in case of - /// attachments inside [MessageInput] + /// attachments inside [StreamMessageInput] String get addACommentOrSendLabel; - /// The label for write a message in [MessageInput] + /// The label for write a message in [StreamMessageInput] String get writeAMessageLabel; - /// The label for slow mode enabled in [MessageInput] + /// The label for slow mode enabled in [StreamMessageInput] String get slowModeOnLabel; - /// The label for instant commands in [MessageInput] + /// The label for instant commands in [StreamMessageInput] String get instantCommandsLabel; /// The error shown in case the fi"le is too large even after compression - /// while uploading via [MessageInput] + /// while uploading via [StreamMessageInput] String fileTooLargeAfterCompressionError(double limitInMB); /// The error shown in case the file is too large - /// while uploading via [MessageInput] + /// while uploading via [StreamMessageInput] String fileTooLargeError(double limitInMB); /// The text for showing the query while searching for emojis diff --git a/packages/stream_chat_flutter/lib/src/media_list_view.dart b/packages/stream_chat_flutter/lib/src/media_list_view.dart index d5a9233c..6a3d6cdd 100644 --- a/packages/stream_chat_flutter/lib/src/media_list_view.dart +++ b/packages/stream_chat_flutter/lib/src/media_list_view.dart @@ -7,21 +7,16 @@ import 'package:flutter_svg/flutter_svg.dart'; import 'package:photo_manager/photo_manager.dart'; import 'package:stream_chat_flutter/stream_chat_flutter.dart'; -extension on Duration { - String format() { - final s = '$this'.split('.')[0].padLeft(8, '0'); - if (s.startsWith('00:')) { - return s.replaceFirst('00:', ''); - } - - return s; - } -} +/// {@macro media_list_view} +@Deprecated("Use 'StreamMediaListView' instead") +typedef MediaListView = StreamMediaListView; +/// {@template media_list_view} /// Constructs a list of media -class MediaListView extends StatefulWidget { - /// Constructor for creating a [MediaListView] widget - const MediaListView({ +/// {@endtemplate} +class StreamMediaListView extends StatefulWidget { + /// Constructor for creating a [StreamMediaListView] widget + const StreamMediaListView({ Key? key, this.selectedIds = const [], this.onSelect, @@ -34,10 +29,10 @@ class MediaListView extends StatefulWidget { final void Function(AssetEntity media)? onSelect; @override - _MediaListViewState createState() => _MediaListViewState(); + _StreamMediaListViewState createState() => _StreamMediaListViewState(); } -class _MediaListViewState extends State { +class _StreamMediaListViewState extends State { final _media = []; final ScrollController _scrollController = ScrollController(); int _currentPage = 0; @@ -219,3 +214,14 @@ class MediaThumbnailProvider extends ImageProvider { @override String toString() => '$runtimeType("${media.id}")'; } + +extension on Duration { + String format() { + final s = '$this'.split('.')[0].padLeft(8, '0'); + if (s.startsWith('00:')) { + return s.replaceFirst('00:', ''); + } + + return s; + } +} diff --git a/packages/stream_chat_flutter/lib/src/mention_tile.dart b/packages/stream_chat_flutter/lib/src/mention_tile.dart deleted file mode 100644 index c302ccb8..00000000 --- a/packages/stream_chat_flutter/lib/src/mention_tile.dart +++ /dev/null @@ -1,101 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:stream_chat_flutter/stream_chat_flutter.dart'; - -/// This widget is used for showing user tiles for mentions -/// Use [title], [subtitle], [leading], [trailing] for -/// substituting widgets in respective positions -@Deprecated('Use `UserMentionTile` instead. Will be removed in future release') -class MentionTile extends StatelessWidget { - /// Constructor for creating a [MentionTile] widget - const MentionTile( - this.member, { - Key? key, - this.title, - this.subtitle, - this.leading, - this.trailing, - }) : super(key: key); - - /// Member to display in the tile - final Member member; - - /// Widget to display as title - final Widget? title; - - /// Widget to display below [title] - final Widget? subtitle; - - /// Widget at the start of the tile - final Widget? leading; - - /// Widget at the end of tile - final Widget? trailing; - - @override - Widget build(BuildContext context) { - final chatThemeData = StreamChatTheme.of(context); - return SizedBox( - height: 56, - child: Row( - children: [ - const SizedBox( - width: 16, - ), - leading ?? - UserAvatar( - constraints: BoxConstraints.tight( - const Size( - 40, - 40, - ), - ), - user: member.user!, - ), - const SizedBox( - width: 8, - ), - Expanded( - child: Align( - alignment: Alignment.centerLeft, - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - title ?? - Text( - member.user!.name, - maxLines: 1, - overflow: TextOverflow.ellipsis, - style: chatThemeData.textTheme.bodyBold, - ), - const SizedBox( - height: 2, - ), - subtitle ?? - Text( - '@${member.userId}', - maxLines: 1, - overflow: TextOverflow.ellipsis, - style: chatThemeData.textTheme.footnoteBold.copyWith( - color: chatThemeData.colorTheme.textLowEmphasis, - ), - ), - ], - ), - ), - ), - trailing ?? - Padding( - padding: const EdgeInsets.only( - right: 18, - left: 8, - ), - child: StreamSvgIcon.mentions( - color: chatThemeData.colorTheme.accentPrimary, - ), - ), - ], - ), - ); - } -} diff --git a/packages/stream_chat_flutter/lib/src/message_action.dart b/packages/stream_chat_flutter/lib/src/message_action.dart index 49a57b1e..edd732f5 100644 --- a/packages/stream_chat_flutter/lib/src/message_action.dart +++ b/packages/stream_chat_flutter/lib/src/message_action.dart @@ -1,10 +1,16 @@ import 'package:flutter/widgets.dart'; import 'package:stream_chat_flutter/stream_chat_flutter.dart'; +/// {@macro message_action} +@Deprecated("Use 'StreamMessageActions' instead") +typedef MessageAction = StreamMessageAction; + +/// {@template message_action} /// Class describing a message action -class MessageAction { - /// returns a new instance of a [MessageAction] - MessageAction({ +/// {@endtemplate} +class StreamMessageAction { + /// returns a new instance of a [StreamMessageAction] + StreamMessageAction({ this.leading, this.title, this.onTap, diff --git a/packages/stream_chat_flutter/lib/src/message_actions_modal.dart b/packages/stream_chat_flutter/lib/src/message_actions_modal.dart index 154472d7..056e84fc 100644 --- a/packages/stream_chat_flutter/lib/src/message_actions_modal.dart +++ b/packages/stream_chat_flutter/lib/src/message_actions_modal.dart @@ -3,10 +3,16 @@ import 'package:flutter/material.dart'; import 'package:stream_chat_flutter/src/extension.dart'; import 'package:stream_chat_flutter/stream_chat_flutter.dart'; +/// {@macro message_actions_modal} +@Deprecated("Use 'StreamMessageActionsModal' instead") +typedef MessageActionsModal = StreamMessageActionsModal; + +/// {@template message_actions_modal} /// Constructs a modal with actions for a message -class MessageActionsModal extends StatefulWidget { - /// Constructor for creating a [MessageActionsModal] widget - const MessageActionsModal({ +/// {@endtemplate} +class StreamMessageActionsModal extends StatefulWidget { + /// Constructor for creating a [StreamMessageActionsModal] widget + const StreamMessageActionsModal({ Key? key, required this.message, required this.messageWidget, @@ -43,8 +49,8 @@ class MessageActionsModal extends StatefulWidget { /// Message in focus for actions final Message message; - /// [MessageThemeData] for message - final MessageThemeData messageTheme; + /// [StreamMessageThemeData] for message + final StreamMessageThemeData messageTheme; /// Flag for showing reactions final bool? showReactions; @@ -80,13 +86,14 @@ class MessageActionsModal extends StatefulWidget { final bool reverse; /// List of custom actions - final List customActions; + final List customActions; @override - _MessageActionsModalState createState() => _MessageActionsModalState(); + _StreamMessageActionsModalState createState() => + _StreamMessageActionsModalState(); } -class _MessageActionsModalState extends State { +class _StreamMessageActionsModalState extends State { bool _showActions = true; late List _userPermissions; late bool _isMyMessage; @@ -159,7 +166,7 @@ class _MessageActionsModalState extends State { : -(1.2 - divFactor)), 0, ), - child: ReactionPicker( + child: StreamReactionPicker( message: widget.message, ), ), @@ -268,7 +275,7 @@ class _MessageActionsModalState extends State { InkWell _buildCustomAction( BuildContext context, - MessageAction messageAction, + StreamMessageAction messageAction, ) => InkWell( onTap: () { @@ -589,7 +596,7 @@ class _MessageActionsModalState extends State { elevation: 2, clipBehavior: Clip.hardEdge, isScrollControlled: true, - backgroundColor: MessageInputTheme.of(context).inputBackgroundColor, + backgroundColor: StreamMessageInputTheme.of(context).inputBackgroundColor, shape: const RoundedRectangleBorder( borderRadius: BorderRadius.only( topLeft: Radius.circular(16), @@ -631,7 +638,7 @@ class _MessageActionsModalState extends State { if (widget.editMessageInputBuilder != null) widget.editMessageInputBuilder!(context, widget.message) else - MessageInput( + StreamMessageInput( messageInputController: MessageInputController( message: widget.message, ), diff --git a/packages/stream_chat_flutter/lib/src/message_input.dart b/packages/stream_chat_flutter/lib/src/message_input.dart new file mode 100644 index 00000000..dc06fd91 --- /dev/null +++ b/packages/stream_chat_flutter/lib/src/message_input.dart @@ -0,0 +1,2110 @@ +import 'dart:async'; +import 'dart:math'; + +import 'package:cached_network_image/cached_network_image.dart'; +import 'package:collection/collection.dart'; +import 'package:file_picker/file_picker.dart'; +import 'package:flutter/foundation.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_svg/flutter_svg.dart'; +import 'package:image_picker/image_picker.dart'; +import 'package:photo_manager/photo_manager.dart'; +import 'package:shimmer/shimmer.dart'; +import 'package:stream_chat_flutter/src/commands_overlay.dart'; +import 'package:stream_chat_flutter/src/emoji/emoji.dart'; +import 'package:stream_chat_flutter/src/emoji_overlay.dart'; +import 'package:stream_chat_flutter/src/extension.dart'; +import 'package:stream_chat_flutter/src/media_list_view.dart'; +import 'package:stream_chat_flutter/src/multi_overlay.dart'; +import 'package:stream_chat_flutter/src/quoted_message_widget.dart'; +import 'package:stream_chat_flutter/src/user_mentions_overlay.dart'; +import 'package:stream_chat_flutter/src/video_service.dart'; +import 'package:stream_chat_flutter/src/video_thumbnail_image.dart'; +import 'package:stream_chat_flutter/stream_chat_flutter.dart'; +import 'package:video_compress/video_compress.dart'; + +export 'package:video_compress/video_compress.dart' show VideoQuality; + +/// A callback that can be passed to [MessageInput.onError]. +/// +/// This callback should not throw. +/// +/// It exists merely for error reporting, and should not be used otherwise. +typedef ErrorListener = void Function( + Object error, + StackTrace? stackTrace, +); + +/// A callback that can be passed to [MessageInput.onAttachmentLimitExceed]. +/// +/// This callback should not throw. +/// +/// It exists merely for showing custom error, and should not be used otherwise. +typedef AttachmentLimitExceedListener = void Function( + int limit, + String error, +); + +/// Builder for attachment thumbnails +typedef AttachmentThumbnailBuilder = Widget Function( + BuildContext, + Attachment, +); + +/// Builder function for building a mention tile. +typedef MentionTileBuilder = Widget Function( + BuildContext context, + Member member, +); + +/// Builder function for building a user mention tile. +/// +/// Use [StreamUserMentionTile] for the default implementation. +typedef UserMentionTileBuilder = Widget Function( + BuildContext context, + User user, +); + +/// Widget builder for action button. +/// +/// [defaultActionButton] is the default [IconButton] configuration, +/// use [defaultActionButton.copyWith] to easily customize it. +typedef ActionButtonBuilder = Widget Function( + BuildContext context, + IconButton defaultActionButton, +); + +/// Location for actions on the [MessageInput] +enum ActionsLocation { + /// Align to left + left, + + /// Align to right + right, + + /// Align to left but inside the [TextField] + leftInside, + + /// Align to right but inside the [TextField] + rightInside, +} + +/// Default attachments for widget +enum DefaultAttachmentTypes { + /// Image Attachment + image, + + /// Video Attachment + video, + + /// File Attachment + file, +} + +/// Available locations for the sendMessage button relative to the textField +enum SendButtonLocation { + /// inside the textField + inside, + + /// outside the textField + outside, +} + +const _kMinMediaPickerSize = 360.0; + +const _kDefaultMaxAttachmentSize = 20971520; // 20MB in Bytes + +/// Inactive state +/// +/// ![screenshot](https://raw.githubusercontent.com/GetStream/stream-chat-flutter/master/packages/stream_chat_flutter/screenshots/message_input.png) +/// ![screenshot](https://raw.githubusercontent.com/GetStream/stream-chat-flutter/master/packages/stream_chat_flutter/screenshots/message_input_paint.png) +/// +/// Focused state +/// +/// ![screenshot](https://raw.githubusercontent.com/GetStream/stream-chat-flutter/master/packages/stream_chat_flutter/screenshots/message_input2.png) +/// ![screenshot](https://raw.githubusercontent.com/GetStream/stream-chat-flutter/master/packages/stream_chat_flutter/screenshots/message_input2_paint.png) +/// +/// Widget used to enter the message and add attachments +/// +/// ```dart +/// class ChannelPage extends StatelessWidget { +/// const ChannelPage({ +/// Key key, +/// }) : super(key: key); +/// +/// @override +/// Widget build(BuildContext context) { +/// return Scaffold( +/// appBar: ChannelHeader(), +/// body: Column( +/// children: [ +/// Expanded( +/// child: MessageListView( +/// threadBuilder: (_, parentMessage) { +/// return ThreadPage( +/// parent: parentMessage, +/// ); +/// }, +/// ), +/// ), +/// MessageInput(), +/// ], +/// ), +/// ); +/// } +/// } +/// ``` +/// +/// You usually put this widget in the same page of a [StreamMessageListView] +/// as the bottom widget. +/// +/// The widget renders the ui based on the first ancestor of +/// type [StreamChatTheme]. +/// Modify it to change the widget appearance. +@Deprecated("Use 'StreamMessageInput' instead") +class MessageInput extends StatefulWidget { + /// Instantiate a new MessageInput + const MessageInput({ + Key? key, + this.onMessageSent, + this.preMessageSending, + this.parentMessage, + this.editMessage, + this.maxHeight = 150, + this.keyboardType = TextInputType.multiline, + this.disableAttachments = false, + this.initialMessage, + this.textEditingController, + this.actions = const [], + this.actionsLocation = ActionsLocation.left, + this.attachmentThumbnailBuilders, + this.focusNode, + this.quotedMessage, + this.onQuotedMessageCleared, + this.sendButtonLocation = SendButtonLocation.outside, + this.autofocus = false, + this.hideSendAsDm = false, + this.idleSendButton, + this.activeSendButton, + this.showCommandsButton = true, + @Deprecated('''Use `userMentionsTileBuilder` instead. Will be removed in future release''') + this.mentionsTileBuilder, + this.userMentionsTileBuilder, + this.maxAttachmentSize = _kDefaultMaxAttachmentSize, + this.compressedVideoQuality = VideoQuality.DefaultQuality, + this.compressedVideoFrameRate = 30, + this.onError, + this.attachmentLimit = 10, + this.onAttachmentLimitExceed, + this.attachmentButtonBuilder, + this.commandButtonBuilder, + this.customOverlays = const [], + this.mentionAllAppUsers = false, + this.shouldKeepFocusAfterMessage, + }) : assert( + initialMessage == null || editMessage == null, + "Can't provide both `initialMessage` and `editMessage`", + ), + super(key: key); + + /// List of options for showing overlays + final List customOverlays; + + /// Message to edit + final Message? editMessage; + + /// Video quality to use when compressing the videos + final VideoQuality compressedVideoQuality; + + /// Frame rate to use when compressing the videos + final int compressedVideoFrameRate; + + /// Max attachment size in bytes + /// Defaults to 20 MB + /// do not set it if you're using our default CDN + final int maxAttachmentSize; + + /// Message to start with + final Message? initialMessage; + + /// Function called after sending the message + final void Function(Message)? onMessageSent; + + /// Function called right before sending the message + /// Use this to transform the message + final FutureOr Function(Message)? preMessageSending; + + /// Parent message in case of a thread + final Message? parentMessage; + + /// Maximum Height for the TextField to grow before it starts scrolling + final double maxHeight; + + /// The keyboard type assigned to the TextField + final TextInputType keyboardType; + + /// If true the attachments button will not be displayed + final bool disableAttachments; + + /// Use this property to hide/show the commands button + final bool showCommandsButton; + + /// Hide send as dm checkbox + final bool hideSendAsDm; + + /// The text controller of the TextField + final TextEditingController? textEditingController; + + /// List of action widgets + final List actions; + + /// The location of the custom actions + final ActionsLocation actionsLocation; + + /// Map that defines a thumbnail builder for an attachment type + final Map? attachmentThumbnailBuilders; + + /// The focus node associated to the TextField + final FocusNode? focusNode; + + /// + final Message? quotedMessage; + + /// + final VoidCallback? onQuotedMessageCleared; + + /// The location of the send button + final SendButtonLocation sendButtonLocation; + + /// Autofocus property passed to the TextField + final bool autofocus; + + /// Send button widget in an idle state + final Widget? idleSendButton; + + /// Send button widget in an active state + final Widget? activeSendButton; + + /// Customize the tile for the mentions overlay. + final MentionTileBuilder? mentionsTileBuilder; + + /// Customize the tile for the mentions overlay. + final UserMentionTileBuilder? userMentionsTileBuilder; + + /// A callback for error reporting + final ErrorListener? onError; + + /// A limit for the no. of attachments that can be sent with a single message. + final int attachmentLimit; + + /// A callback for when the [attachmentLimit] is exceeded. + /// + /// This will override the default error alert behaviour. + final AttachmentLimitExceedListener? onAttachmentLimitExceed; + + /// Builder for customizing the attachment button. + /// + /// The builder contains the default [IconButton] that can be customized by + /// calling `.copyWith`. + final ActionButtonBuilder? attachmentButtonBuilder; + + /// Builder for customizing the command button. + /// + /// The builder contains the default [IconButton] that can be customized by + /// calling `.copyWith`. + final ActionButtonBuilder? commandButtonBuilder; + + /// When enabled mentions search users across the entire app. + /// + /// Defaults to false. + final bool mentionAllAppUsers; + + /// Defines if the [MessageInput] loses focuses after a message is sent. + /// The default behaviour keeps focus until a command is enabled. + final bool? shouldKeepFocusAfterMessage; + + @override + MessageInputState createState() => MessageInputState(); + + /// Use this method to get the current [StreamChatState] instance + static MessageInputState of(BuildContext context) { + MessageInputState? messageInputState; + messageInputState = context.findAncestorStateOfType(); + assert( + messageInputState != null, + 'You must have a MessageInput widget as ancestor of your widget tree', + ); + return messageInputState!; + } +} + +/// State of [MessageInput] +class MessageInputState extends State { + final _attachments = {}; + final List _mentionedUsers = []; + + final _imagePicker = ImagePicker(); + late final _focusNode = widget.focusNode ?? FocusNode(); + late final _isInternalFocusNode = widget.focusNode == null; + bool _inputEnabled = true; + bool _commandEnabled = false; + bool _showCommandsOverlay = false; + bool _showMentionsOverlay = false; + + Command? _chosenCommand; + bool _actionsShrunk = false; + bool _sendAsDm = false; + bool _openFilePickerSection = false; + int _filePickerIndex = 0; + + /// The editing controller passed to the input TextField + late final TextEditingController textEditingController = + widget.textEditingController ?? TextEditingController(); + + late StreamChatThemeData _streamChatTheme; + late StreamMessageInputThemeData _messageInputTheme; + + bool get _hasQuotedMessage => widget.quotedMessage != null; + + bool get _messageIsPresent => textEditingController.text.trim().isNotEmpty; + + @override + void initState() { + super.initState(); + if (widget.editMessage != null || widget.initialMessage != null) { + _parseExistingMessage(widget.editMessage ?? widget.initialMessage!); + } + textEditingController.addListener(_onChangedDebounced); + _focusNode.addListener(_focusNodeListener); + } + + void _focusNodeListener() { + if (_focusNode.hasFocus) { + _openFilePickerSection = false; + } + } + + int _timeOut = 0; + Timer? _slowModeTimer; + + void _startSlowMode() { + if (!mounted) { + return; + } + final channel = StreamChannel.of(context).channel; + final cooldownStartedAt = channel.cooldownStartedAt; + if (cooldownStartedAt != null) { + final diff = DateTime.now().difference(cooldownStartedAt).inSeconds; + if (diff < channel.cooldown) { + _timeOut = channel.cooldown - diff; + if (_timeOut > 0) { + _slowModeTimer = Timer.periodic(const Duration(seconds: 1), (timer) { + if (_timeOut == 0) { + timer.cancel(); + } else { + if (mounted) { + setState(() => _timeOut -= 1); + } + } + }); + } + } + } + } + + void _stopSlowMode() => _slowModeTimer?.cancel(); + + @override + Widget build(BuildContext context) { + Widget child = DecoratedBox( + decoration: BoxDecoration( + color: _messageInputTheme.inputBackgroundColor, + ), + child: SafeArea( + child: GestureDetector( + onPanUpdate: (details) { + if (details.delta.dy > 0) { + _focusNode.unfocus(); + if (_openFilePickerSection) { + setState(() { + _openFilePickerSection = false; + }); + } + } + }, + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + if (_hasQuotedMessage) + Padding( + padding: const EdgeInsets.fromLTRB(8, 8, 8, 0), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Padding( + padding: const EdgeInsets.all(8), + child: StreamSvgIcon.reply( + color: _streamChatTheme.colorTheme.disabled, + ), + ), + Text( + context.translations.replyToMessageLabel, + style: const TextStyle(fontWeight: FontWeight.bold), + ), + IconButton( + visualDensity: VisualDensity.compact, + icon: StreamSvgIcon.closeSmall(), + onPressed: widget.onQuotedMessageCleared, + ), + ], + ), + ), + Padding( + padding: const EdgeInsets.symmetric(vertical: 8), + child: _buildTextField(context), + ), + if (widget.parentMessage != null && !widget.hideSendAsDm) + Padding( + padding: const EdgeInsets.only( + right: 12, + left: 12, + bottom: 12, + ), + child: _buildDmCheckbox(), + ), + _buildFilePickerSection(), + ], + ), + ), + ), + ); + if (widget.editMessage == null) { + child = Material( + elevation: 8, + child: child, + ); + } + + return StreamMultiOverlay( + childAnchor: Alignment.topCenter, + overlayAnchor: Alignment.bottomCenter, + overlayOptions: [ + OverlayOptions( + visible: _showCommandsOverlay, + widget: _buildCommandsOverlayEntry(), + ), + OverlayOptions( + visible: _focusNode.hasFocus && + textEditingController.text.isNotEmpty && + textEditingController.selection.baseOffset > 0 && + textEditingController.text + .substring( + 0, + textEditingController.selection.baseOffset, + ) + .contains(':'), + widget: _buildEmojiOverlay(), + ), + OverlayOptions( + visible: _showMentionsOverlay, + widget: _buildMentionsOverlayEntry(), + ), + ...widget.customOverlays, + ], + child: child, + ); + } + + Flex _buildTextField(BuildContext context) => Flex( + direction: Axis.horizontal, + children: [ + if (!_commandEnabled && + widget.actionsLocation == ActionsLocation.left) + _buildExpandActionsButton(context), + _buildTextInput(context), + if (!_commandEnabled && + widget.actionsLocation == ActionsLocation.right) + _buildExpandActionsButton(context), + if (widget.sendButtonLocation == SendButtonLocation.outside) + _animateSendButton(context), + ], + ); + + Widget _buildDmCheckbox() => Row( + children: [ + Container( + height: 16, + width: 16, + foregroundDecoration: BoxDecoration( + border: _sendAsDm + ? null + : Border.all( + color: _streamChatTheme.colorTheme.textHighEmphasis + .withOpacity(0.5), + width: 2, + ), + borderRadius: BorderRadius.circular(3), + ), + child: Center( + child: Material( + borderRadius: BorderRadius.circular(3), + color: _sendAsDm + ? _streamChatTheme.colorTheme.accentPrimary + : _streamChatTheme.colorTheme.barsBg, + child: InkWell( + onTap: () { + setState(() { + _sendAsDm = !_sendAsDm; + }); + }, + child: AnimatedCrossFade( + duration: const Duration(milliseconds: 300), + reverseDuration: const Duration(milliseconds: 300), + crossFadeState: _sendAsDm + ? CrossFadeState.showFirst + : CrossFadeState.showSecond, + firstChild: StreamSvgIcon.check( + size: 16, + color: _streamChatTheme.colorTheme.barsBg, + ), + secondChild: const SizedBox( + height: 16, + width: 16, + ), + ), + ), + ), + ), + ), + Padding( + padding: const EdgeInsets.symmetric(horizontal: 12), + child: Text( + context.translations.alsoSendAsDirectMessageLabel, + style: _streamChatTheme.textTheme.footnote.copyWith( + color: _streamChatTheme.colorTheme.textHighEmphasis + .withOpacity(0.5), + ), + ), + ), + ], + ); + + Widget _animateSendButton(BuildContext context) { + late Widget sendButton; + if (_timeOut > 0) { + sendButton = _CountdownButton(count: _timeOut); + } else if (!_messageIsPresent && _attachments.isEmpty) { + sendButton = widget.idleSendButton ?? _buildIdleSendButton(context); + } else { + sendButton = widget.activeSendButton != null + ? InkWell( + onTap: sendMessage, + child: widget.activeSendButton, + ) + : _buildSendButton(context); + } + + return AnimatedSwitcher( + duration: _streamChatTheme.messageInputTheme.sendAnimationDuration!, + child: sendButton, + ); + } + + Widget _buildExpandActionsButton(BuildContext context) { + final channel = StreamChannel.of(context).channel; + return Padding( + padding: const EdgeInsets.symmetric(horizontal: 8), + child: AnimatedCrossFade( + crossFadeState: _actionsShrunk + ? CrossFadeState.showFirst + : CrossFadeState.showSecond, + firstCurve: Curves.easeOut, + secondCurve: Curves.easeIn, + firstChild: IconButton( + onPressed: () { + if (_actionsShrunk) { + setState(() => _actionsShrunk = false); + } + }, + icon: Transform.rotate( + angle: (widget.actionsLocation == ActionsLocation.right || + widget.actionsLocation == ActionsLocation.rightInside) + ? pi + : 0, + child: StreamSvgIcon.emptyCircleLeft( + color: _messageInputTheme.expandButtonColor, + ), + ), + padding: const EdgeInsets.all(0), + constraints: const BoxConstraints.tightFor( + height: 24, + width: 24, + ), + splashRadius: 24, + ), + secondChild: widget.disableAttachments && + !widget.showCommandsButton && + !widget.actions.isNotEmpty + ? const Offstage() + : Wrap( + children: [ + if (!widget.disableAttachments) + _buildAttachmentButton(context), + if (widget.showCommandsButton && + widget.editMessage == null && + channel.state != null && + channel.config?.commands.isNotEmpty == true) + _buildCommandButton(context), + ...widget.actions, + ].insertBetween(const SizedBox(width: 8)), + ), + duration: const Duration(milliseconds: 300), + alignment: Alignment.center, + ), + ); + } + + Expanded _buildTextInput(BuildContext context) { + final margin = (widget.sendButtonLocation == SendButtonLocation.inside + ? const EdgeInsets.only(right: 8) + : EdgeInsets.zero) + + (widget.actionsLocation != ActionsLocation.left || _commandEnabled + ? const EdgeInsets.only(left: 8) + : EdgeInsets.zero); + return Expanded( + child: Container( + clipBehavior: Clip.hardEdge, + margin: margin, + decoration: BoxDecoration( + borderRadius: _messageInputTheme.borderRadius, + gradient: _focusNode.hasFocus + ? _messageInputTheme.activeBorderGradient + : _messageInputTheme.idleBorderGradient, + ), + child: Padding( + padding: const EdgeInsets.all(1.5), + child: DecoratedBox( + decoration: BoxDecoration( + borderRadius: _messageInputTheme.borderRadius, + color: _messageInputTheme.inputBackgroundColor, + ), + child: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + _buildReplyToMessage(), + _buildAttachments(), + LimitedBox( + maxHeight: widget.maxHeight, + child: TextField( + key: const Key('messageInputText'), + enabled: _inputEnabled, + maxLines: null, + onSubmitted: (_) => sendMessage(), + keyboardType: widget.keyboardType, + controller: textEditingController, + focusNode: _focusNode, + style: _messageInputTheme.inputTextStyle, + autofocus: widget.autofocus, + textAlignVertical: TextAlignVertical.center, + decoration: _getInputDecoration(context), + textCapitalization: TextCapitalization.sentences, + ), + ), + ], + ), + ), + ), + ), + ); + } + + InputDecoration _getInputDecoration(BuildContext context) { + final passedDecoration = _messageInputTheme.inputDecoration; + return InputDecoration( + isDense: true, + hintText: _getHint(context), + hintStyle: _messageInputTheme.inputTextStyle!.copyWith( + color: _streamChatTheme.colorTheme.textLowEmphasis, + ), + border: const OutlineInputBorder( + borderSide: BorderSide( + color: Colors.transparent, + ), + ), + focusedBorder: const OutlineInputBorder( + borderSide: BorderSide( + color: Colors.transparent, + ), + ), + enabledBorder: const OutlineInputBorder( + borderSide: BorderSide( + color: Colors.transparent, + ), + ), + errorBorder: const OutlineInputBorder( + borderSide: BorderSide( + color: Colors.transparent, + ), + ), + disabledBorder: const OutlineInputBorder( + borderSide: BorderSide( + color: Colors.transparent, + ), + ), + contentPadding: const EdgeInsets.fromLTRB(16, 12, 13, 11), + prefixIcon: _commandEnabled + ? Row( + mainAxisSize: MainAxisSize.min, + children: [ + Padding( + padding: const EdgeInsets.all(8), + child: Container( + constraints: BoxConstraints.tight(const Size(64, 24)), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(12), + color: _streamChatTheme.colorTheme.accentPrimary, + ), + alignment: Alignment.center, + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + StreamSvgIcon.lightning( + color: Colors.white, + size: 16, + ), + Text( + _chosenCommand?.name.toUpperCase() ?? '', + style: + _streamChatTheme.textTheme.footnoteBold.copyWith( + color: Colors.white, + ), + ), + ], + ), + ), + ), + ], + ) + : (widget.actionsLocation == ActionsLocation.leftInside + ? Row( + mainAxisSize: MainAxisSize.min, + children: [_buildExpandActionsButton(context)], + ) + : null), + suffixIconConstraints: const BoxConstraints.tightFor(height: 40), + prefixIconConstraints: const BoxConstraints.tightFor(height: 40), + suffixIcon: Row( + mainAxisSize: MainAxisSize.min, + children: [ + if (_commandEnabled) + Padding( + padding: const EdgeInsets.only(right: 8), + child: IconButton( + icon: StreamSvgIcon.closeSmall(), + splashRadius: 24, + padding: const EdgeInsets.all(0), + constraints: const BoxConstraints.tightFor( + height: 24, + width: 24, + ), + onPressed: () { + setState(() => _commandEnabled = false); + }, + ), + ), + if (!_commandEnabled && + widget.actionsLocation == ActionsLocation.rightInside) + _buildExpandActionsButton(context), + if (widget.sendButtonLocation == SendButtonLocation.inside) + _animateSendButton(context), + ], + ), + ).merge(passedDecoration); + } + + late final _onChangedDebounced = debounce( + () { + var value = textEditingController.text; + if (!mounted) return; + value = value.trim(); + + final channel = StreamChannel.of(context).channel; + if (value.isNotEmpty) { + // ignore: no-empty-block + channel.keyStroke(widget.parentMessage?.id).catchError((e) {}); + } + + var actionsLength = widget.actions.length; + if (widget.showCommandsButton) actionsLength += 1; + if (!widget.disableAttachments) actionsLength += 1; + + setState(() { + _actionsShrunk = value.isNotEmpty && actionsLength > 1; + }); + + _checkCommands(value, context); + _checkMentions(value, context); + _checkEmoji(value, context); + }, + const Duration(milliseconds: 350), + leading: true, + ); + + String _getHint(BuildContext context) { + if (_commandEnabled && _chosenCommand!.name == 'giphy') { + return context.translations.searchGifLabel; + } + if (_attachments.isNotEmpty) { + return context.translations.addACommentOrSendLabel; + } + if (_timeOut != 0) { + return context.translations.slowModeOnLabel; + } + + return context.translations.writeAMessageLabel; + } + + void _checkEmoji(String s, BuildContext context) { + if (s.isNotEmpty && + textEditingController.selection.baseOffset > 0 && + textEditingController.text + .substring(0, textEditingController.selection.baseOffset) + .contains(':')) { + final textToSelection = textEditingController.text + .substring(0, textEditingController.value.selection.start); + final splits = textToSelection.split(':'); + final query = splits[splits.length - 2].toLowerCase(); + final emoji = Emoji.byName(query); + + if (textToSelection.endsWith(':') && emoji != null) { + _chooseEmoji(splits.sublist(0, splits.length - 1), emoji); + } + } + } + + void _checkMentions(String s, BuildContext context) { + if (s.isNotEmpty && + textEditingController.selection.baseOffset > 0 && + textEditingController.text + .substring(0, textEditingController.selection.baseOffset) + .split(' ') + .last + .contains('@')) { + if (!_showMentionsOverlay) { + setState(() { + _showMentionsOverlay = true; + }); + } + } else if (_showMentionsOverlay) { + setState(() { + _showMentionsOverlay = false; + }); + } + } + + void _checkCommands(String s, BuildContext context) { + if (s.startsWith('/')) { + final allCommands = StreamChannel.of(context).channel.config?.commands; + final command = + allCommands?.firstWhereOrNull((it) => it.name == s.substring(1)); + if (command != null) { + return _setCommand(command); + } else if (!_showCommandsOverlay) { + setState(() { + _showCommandsOverlay = true; + }); + } + } else if (_showCommandsOverlay) { + setState(() { + _showCommandsOverlay = false; + }); + } + } + + Widget _buildCommandsOverlayEntry() { + final text = textEditingController.text.trimLeft(); + + final renderObject = context.findRenderObject() as RenderBox?; + if (renderObject == null) { + return const Offstage(); + } + return StreamCommandsOverlay( + channel: StreamChannel.of(context).channel, + size: Size(renderObject.size.width - 16, 400), + text: text, + onCommandResult: _setCommand, + ); + } + + Widget _buildFilePickerSection() { + final _attachmentContainsFile = + _attachments.values.any((it) => it.type == 'file'); + + final attachmentLimitCrossed = + _attachments.length >= widget.attachmentLimit; + + Color _getIconColor(int index) { + final streamChatThemeData = _streamChatTheme; + switch (index) { + case 0: + return _attachments.isEmpty + ? streamChatThemeData.colorTheme.accentPrimary + : (!_attachmentContainsFile + ? streamChatThemeData.colorTheme.accentPrimary + : streamChatThemeData.colorTheme.textHighEmphasis + .withOpacity(0.2)); + case 1: + return _attachmentContainsFile + ? streamChatThemeData.colorTheme.accentPrimary + : (_attachments.isEmpty + ? streamChatThemeData.colorTheme.textHighEmphasis + .withOpacity(0.5) + : streamChatThemeData.colorTheme.textHighEmphasis + .withOpacity(0.2)); + case 2: + return attachmentLimitCrossed + ? streamChatThemeData.colorTheme.textHighEmphasis.withOpacity(0.2) + : _attachmentContainsFile && _attachments.isNotEmpty + ? streamChatThemeData.colorTheme.textHighEmphasis + .withOpacity(0.2) + : streamChatThemeData.colorTheme.textHighEmphasis + .withOpacity(0.5); + case 3: + return attachmentLimitCrossed + ? streamChatThemeData.colorTheme.textHighEmphasis.withOpacity(0.2) + : _attachmentContainsFile && _attachments.isNotEmpty + ? streamChatThemeData.colorTheme.textHighEmphasis + .withOpacity(0.2) + : streamChatThemeData.colorTheme.textHighEmphasis + .withOpacity(0.5); + default: + return Colors.black; + } + } + + return AnimatedContainer( + duration: _openFilePickerSection + ? const Duration(milliseconds: 300) + : const Duration(), + curve: Curves.easeOut, + height: _openFilePickerSection ? _kMinMediaPickerSize : 0, + child: SingleChildScrollView( + child: SizedBox( + height: _kMinMediaPickerSize, + child: Material( + color: _streamChatTheme.colorTheme.inputBg, + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Row( + children: [ + IconButton( + icon: StreamSvgIcon.pictures( + color: _getIconColor(0), + ), + onPressed: + _attachmentContainsFile && _attachments.isNotEmpty + ? null + : () { + setState(() { + _filePickerIndex = 0; + }); + }, + ), + IconButton( + iconSize: 32, + icon: StreamSvgIcon.files( + color: _getIconColor(1), + ), + onPressed: + !_attachmentContainsFile && _attachments.isNotEmpty + ? null + : () { + pickFile(DefaultAttachmentTypes.file); + }, + ), + IconButton( + icon: StreamSvgIcon.camera( + color: _getIconColor(2), + ), + onPressed: attachmentLimitCrossed || + (_attachmentContainsFile && + _attachments.isNotEmpty) + ? null + : () { + pickFile( + DefaultAttachmentTypes.image, + camera: true, + ); + }, + ), + IconButton( + padding: const EdgeInsets.all(0), + icon: StreamSvgIcon.record( + color: _getIconColor(3), + ), + onPressed: attachmentLimitCrossed || + (_attachmentContainsFile && + _attachments.isNotEmpty) + ? null + : () { + pickFile( + DefaultAttachmentTypes.video, + camera: true, + ); + }, + ), + ], + ), + DecoratedBox( + decoration: BoxDecoration( + color: _streamChatTheme.colorTheme.barsBg, + borderRadius: const BorderRadius.only( + topLeft: Radius.circular(16), + topRight: Radius.circular(16), + ), + ), + child: Center( + child: Padding( + padding: const EdgeInsets.all(8), + child: Container( + width: 40, + height: 4, + decoration: BoxDecoration( + color: _streamChatTheme.colorTheme.inputBg, + borderRadius: BorderRadius.circular(4), + ), + ), + ), + ), + ), + if (_openFilePickerSection) + Expanded( + child: DecoratedBox( + decoration: BoxDecoration( + color: _streamChatTheme.colorTheme.barsBg, + borderRadius: BorderRadius.circular(8), + ), + child: _PickerWidget( + filePickerIndex: _filePickerIndex, + streamChatTheme: _streamChatTheme, + containsFile: _attachmentContainsFile, + selectedMedias: _attachments.keys.toList(), + onAddMoreFilesClick: pickFile, + onMediaSelected: (media) { + if (_attachments.containsKey(media.id)) { + setState(() => _attachments.remove(media.id)); + } else { + _addAssetAttachment(media); + } + }, + ), + ), + ), + ], + ), + ), + ), + ), + ); + } + + void _addAssetAttachment(AssetEntity medium) async { + final mediaFile = await medium.originFile.timeout( + const Duration(seconds: 5), + onTimeout: () => medium.originFile, + ); + + if (mediaFile == null) return; + + var file = AttachmentFile( + path: mediaFile.path, + size: await mediaFile.length(), + bytes: mediaFile.readAsBytesSync(), + ); + + if (file.size! > widget.maxAttachmentSize) { + if (medium.type == AssetType.video && file.path != null) { + final mediaInfo = await StreamVideoService.compressVideo( + file.path!, + frameRate: widget.compressedVideoFrameRate, + quality: widget.compressedVideoQuality, + ); + + if (mediaInfo == null || + mediaInfo.filesize! > widget.maxAttachmentSize) { + _showErrorAlert( + context.translations.fileTooLargeAfterCompressionError( + widget.maxAttachmentSize / (1024 * 1024), + ), + ); + return; + } + file = AttachmentFile( + name: file.name, + size: mediaInfo.filesize, + bytes: await mediaInfo.file?.readAsBytes(), + path: mediaInfo.path, + ); + } else { + _showErrorAlert(context.translations.fileTooLargeError( + widget.maxAttachmentSize / (1024 * 1024), + )); + return; + } + } + + setState(() { + final attachment = Attachment( + id: medium.id, + file: file, + type: medium.type == AssetType.image ? 'image' : 'video', + ); + _addAttachments([attachment]); + }); + } + + Widget _buildMentionsOverlayEntry() { + final channel = StreamChannel.of(context).channel; + if (textEditingController.value.selection.start < 0 || + channel.state == null) { + return const Offstage(); + } + + final splits = textEditingController.text + .substring(0, textEditingController.value.selection.start) + .split('@'); + final query = splits.last.toLowerCase(); + + // ignore: cast_nullable_to_non_nullable + final renderObject = context.findRenderObject() as RenderBox; + + var tileBuilder = widget.userMentionsTileBuilder; + if (tileBuilder == null && widget.mentionsTileBuilder != null) { + tileBuilder = (context, user) { + final member = Member( + user: user, + userId: user.id, + createdAt: user.createdAt, + updatedAt: user.updatedAt, + ); + return widget.mentionsTileBuilder!(context, member); + }; + } + + return LayoutBuilder( + builder: (context, snapshot) => StreamUserMentionsOverlay( + query: query, + mentionAllAppUsers: widget.mentionAllAppUsers, + client: StreamChat.of(context).client, + channel: channel, + size: Size( + renderObject.size.width - 16, + min(400, (snapshot.maxHeight - renderObject.size.height - 16).abs()), + ), + mentionsTileBuilder: tileBuilder, + onMentionUserTap: (user) { + _mentionedUsers.add(user); + splits[splits.length - 1] = user.name; + final rejoin = splits.join('@'); + + textEditingController.value = TextEditingValue( + text: rejoin + + textEditingController.text.substring( + textEditingController.selection.start, + ), + selection: TextSelection.collapsed( + offset: rejoin.length, + ), + ); + _onChangedDebounced.cancel(); + + setState(() => _showMentionsOverlay = false); + }, + ), + ); + } + + Widget _buildEmojiOverlay() { + if (textEditingController.value.selection.baseOffset < 0) { + return const Offstage(); + } + + final splits = textEditingController.text + .substring(0, textEditingController.value.selection.baseOffset) + .split(':'); + + final query = splits.last.toLowerCase(); + // ignore: cast_nullable_to_non_nullable + final renderObject = context.findRenderObject() as RenderBox; + + return StreamEmojiOverlay( + size: Size(renderObject.size.width - 16, 200), + query: query, + onEmojiResult: (emoji) { + _chooseEmoji(splits, emoji); + }, + ); + } + + void _chooseEmoji(List splits, Emoji emoji) { + final rejoin = splits.sublist(0, splits.length - 1).join(':') + emoji.char!; + + textEditingController.value = TextEditingValue( + text: rejoin + + textEditingController.text + .substring(textEditingController.selection.start), + selection: TextSelection.collapsed( + offset: rejoin.length, + ), + ); + } + + void _setCommand(Command c) { + textEditingController.clear(); + setState(() { + _chosenCommand = c; + _commandEnabled = true; + _showCommandsOverlay = false; + }); + } + + Widget _buildReplyToMessage() { + if (!_hasQuotedMessage) return const Offstage(); + final containsUrl = widget.quotedMessage!.attachments + .any((element) => element.titleLink != null); + return StreamQuotedMessageWidget( + reverse: true, + showBorder: !containsUrl, + message: widget.quotedMessage!, + messageTheme: _streamChatTheme.otherMessageTheme, + padding: const EdgeInsets.fromLTRB(8, 8, 8, 0), + ); + } + + Widget _buildAttachments() { + if (_attachments.isEmpty) return const Offstage(); + final fileAttachments = _attachments.values + .where((it) => it.type == 'file') + .toList(growable: false); + final remainingAttachments = _attachments.values + .where((it) => it.type != 'file') + .toList(growable: false); + return Column( + children: [ + if (fileAttachments.isNotEmpty) + Padding( + padding: const EdgeInsets.fromLTRB(8, 8, 8, 0), + child: LimitedBox( + maxHeight: 136, + child: ListView( + reverse: true, + shrinkWrap: true, + children: fileAttachments.reversed + .map( + (e) => ClipRRect( + borderRadius: BorderRadius.circular(10), + child: StreamFileAttachment( + message: Message(), // dummy message + attachment: e, + size: Size( + MediaQuery.of(context).size.width * 0.65, + 56, + ), + trailing: Padding( + padding: const EdgeInsets.all(8), + child: _buildRemoveButton(e), + ), + ), + ), + ) + .insertBetween(const SizedBox(height: 8)), + ), + ), + ), + if (remainingAttachments.isNotEmpty) + Padding( + padding: const EdgeInsets.fromLTRB(8, 8, 8, 0), + child: LimitedBox( + maxHeight: 104, + child: ListView( + scrollDirection: Axis.horizontal, + children: remainingAttachments + .map( + (attachment) => ClipRRect( + borderRadius: BorderRadius.circular(10), + child: Stack( + children: [ + AspectRatio( + aspectRatio: 1, + child: SizedBox( + height: 104, + width: 104, + child: _buildAttachment(attachment), + ), + ), + Positioned( + top: 8, + right: 8, + child: _buildRemoveButton(attachment), + ), + ], + ), + ), + ) + .insertBetween(const SizedBox(width: 8)), + ), + ), + ), + ], + ); + } + + Widget _buildRemoveButton(Attachment attachment) => SizedBox( + height: 24, + width: 24, + child: RawMaterialButton( + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(16), + ), + elevation: 0, + highlightElevation: 0, + focusElevation: 0, + hoverElevation: 0, + onPressed: () { + setState(() => _attachments.remove(attachment.id)); + }, + fillColor: + _streamChatTheme.colorTheme.textHighEmphasis.withOpacity(0.5), + child: Center( + child: StreamSvgIcon.close( + size: 24, + color: _streamChatTheme.colorTheme.barsBg, + ), + ), + ), + ); + + Widget _buildAttachment(Attachment attachment) { + if (widget.attachmentThumbnailBuilders?.containsKey(attachment.type) == + true) { + return widget.attachmentThumbnailBuilders![attachment.type!]!( + context, + attachment, + ); + } + + switch (attachment.type) { + case 'image': + case 'giphy': + return attachment.file != null + ? Image.memory( + attachment.file!.bytes!, + fit: BoxFit.cover, + errorBuilder: (context, _, __) => Image.asset( + 'images/placeholder.png', + package: 'stream_chat_flutter', + ), + ) + : CachedNetworkImage( + imageUrl: attachment.imageUrl ?? + attachment.assetUrl ?? + attachment.thumbUrl!, + fit: BoxFit.cover, + errorWidget: (_, obj, trace) => + getFileTypeImage(attachment.extraData['other'] as String?), + placeholder: (context, _) => Shimmer.fromColors( + baseColor: _streamChatTheme.colorTheme.disabled, + highlightColor: _streamChatTheme.colorTheme.inputBg, + child: Image.asset( + 'images/placeholder.png', + fit: BoxFit.cover, + package: 'stream_chat_flutter', + ), + ), + ); + case 'video': + return Stack( + children: [ + StreamVideoThumbnailImage( + height: 104, + width: 104, + video: (attachment.file?.path ?? attachment.assetUrl)!, + fit: BoxFit.cover, + ), + Positioned( + left: 8, + bottom: 10, + child: SvgPicture.asset( + 'svgs/video_call_icon.svg', + package: 'stream_chat_flutter', + ), + ), + ], + ); + default: + return Container( + color: Colors.black26, + child: const Icon(Icons.insert_drive_file), + ); + } + } + + Widget _buildCommandButton(BuildContext context) { + final s = textEditingController.text.trim(); + final defaultButton = IconButton( + icon: StreamSvgIcon.lightning( + color: s.isNotEmpty + ? _streamChatTheme.colorTheme.disabled + : (_showCommandsOverlay + ? _messageInputTheme.actionButtonColor + : _messageInputTheme.actionButtonIdleColor), + ), + padding: const EdgeInsets.all(0), + constraints: const BoxConstraints.tightFor( + height: 24, + width: 24, + ), + splashRadius: 24, + onPressed: () async { + if (_openFilePickerSection) { + setState(() => _openFilePickerSection = false); + await Future.delayed(const Duration(milliseconds: 300)); + } + + setState(() { + _showCommandsOverlay = !_showCommandsOverlay; + }); + }, + ); + + return widget.commandButtonBuilder?.call(context, defaultButton) ?? + defaultButton; + } + + Widget _buildAttachmentButton(BuildContext context) { + final defaultButton = IconButton( + icon: StreamSvgIcon.attach( + color: _openFilePickerSection + ? _messageInputTheme.actionButtonColor + : _messageInputTheme.actionButtonIdleColor, + ), + padding: const EdgeInsets.all(0), + constraints: const BoxConstraints.tightFor( + height: 24, + width: 24, + ), + splashRadius: 24, + onPressed: () async { + _showCommandsOverlay = false; + _showMentionsOverlay = false; + + if (_openFilePickerSection) { + setState(() => _openFilePickerSection = false); + } else { + showAttachmentModal(); + } + }, + ); + + return widget.attachmentButtonBuilder?.call(context, defaultButton) ?? + defaultButton; + } + + /// Show the attachment modal, making the user choose where to + /// pick a media from + void showAttachmentModal() { + if (_focusNode.hasFocus) { + _focusNode.unfocus(); + } + + if (!kIsWeb) { + setState(() { + _openFilePickerSection = true; + }); + } else { + showModalBottomSheet( + clipBehavior: Clip.hardEdge, + shape: const RoundedRectangleBorder( + borderRadius: BorderRadius.only( + topLeft: Radius.circular(32), + topRight: Radius.circular(32), + ), + ), + context: context, + isScrollControlled: true, + builder: (_) => Column( + mainAxisSize: MainAxisSize.min, + children: [ + ListTile( + title: Text( + context.translations.addAFileLabel, + style: const TextStyle( + fontWeight: FontWeight.bold, + ), + ), + ), + ListTile( + leading: const Icon(Icons.image), + title: Text(context.translations.uploadAPhotoLabel), + onTap: () { + pickFile(DefaultAttachmentTypes.image); + Navigator.pop(context); + }, + ), + ListTile( + leading: const Icon(Icons.video_library), + title: Text(context.translations.uploadAVideoLabel), + onTap: () { + pickFile(DefaultAttachmentTypes.video); + Navigator.pop(context); + }, + ), + ListTile( + leading: const Icon(Icons.insert_drive_file), + title: Text(context.translations.uploadAFileLabel), + onTap: () { + pickFile(DefaultAttachmentTypes.file); + Navigator.pop(context); + }, + ), + ], + ), + ); + } + } + + /// Add an attachment to the sending message + /// Use this to add custom type attachments + /// + /// Note: Only meant to be used from outside the state. + void addAttachment(Attachment attachment) { + setState(() => _addAttachments([attachment])); + } + + /// Adds an attachment to the [_attachments] map + void _addAttachments(Iterable attachments) { + final limit = widget.attachmentLimit; + final length = _attachments.length + attachments.length; + if (length > limit) { + final onAttachmentLimitExceed = widget.onAttachmentLimitExceed; + if (onAttachmentLimitExceed != null) { + return onAttachmentLimitExceed( + widget.attachmentLimit, + context.translations.attachmentLimitExceedError(limit), + ); + } + return _showErrorAlert( + context.translations.attachmentLimitExceedError(limit), + ); + } + for (final attachment in attachments) { + _attachments[attachment.id] = attachment; + } + } + + /// Pick a file from the device + /// If [camera] is true then the camera will open + void pickFile( + DefaultAttachmentTypes fileType, { + bool camera = false, + }) async { + setState(() => _inputEnabled = false); + + AttachmentFile? file; + String? attachmentType; + + if (fileType == DefaultAttachmentTypes.image) { + attachmentType = 'image'; + } else if (fileType == DefaultAttachmentTypes.video) { + attachmentType = 'video'; + } else if (fileType == DefaultAttachmentTypes.file) { + attachmentType = 'file'; + } + + if (camera) { + XFile? pickedFile; + if (fileType == DefaultAttachmentTypes.image) { + pickedFile = await _imagePicker.pickImage(source: ImageSource.camera); + } else if (fileType == DefaultAttachmentTypes.video) { + pickedFile = await _imagePicker.pickVideo(source: ImageSource.camera); + } + if (pickedFile != null) { + final bytes = await pickedFile.readAsBytes(); + file = AttachmentFile( + size: bytes.length, + path: pickedFile.path, + bytes: bytes, + ); + } + } else { + late FileType type; + if (fileType == DefaultAttachmentTypes.image) { + type = FileType.image; + } else if (fileType == DefaultAttachmentTypes.video) { + type = FileType.video; + } else if (fileType == DefaultAttachmentTypes.file) { + type = FileType.any; + } + final res = await FilePicker.platform.pickFiles( + type: type, + ); + if (res?.files.isNotEmpty == true) { + file = res!.files.single.toAttachmentFile; + } + } + + setState(() => _inputEnabled = true); + + if (file == null) return; + + final mimeType = file.name?.mimeType ?? file.path!.split('/').last.mimeType; + + final extraDataMap = {}; + + if (mimeType?.subtype != null) { + extraDataMap['mime_type'] = mimeType!.subtype.toLowerCase(); + } + + extraDataMap['file_size'] = file.size!; + + final attachment = Attachment( + file: file, + type: attachmentType, + uploadState: const UploadState.preparing(), + extraData: extraDataMap, + ); + + if (file.size! > widget.maxAttachmentSize) { + if (attachmentType == 'video' && file.path != null) { + final mediaInfo = await (StreamVideoService.compressVideo( + file.path!, + frameRate: widget.compressedVideoFrameRate, + quality: widget.compressedVideoQuality, + ) as FutureOr); + + if (mediaInfo.filesize! > widget.maxAttachmentSize) { + _showErrorAlert( + context.translations.fileTooLargeAfterCompressionError( + widget.maxAttachmentSize / (1024 * 1024), + ), + ); + return; + } + file = AttachmentFile( + name: file.name, + size: mediaInfo.filesize, + bytes: await mediaInfo.file!.readAsBytes(), + path: mediaInfo.path, + ); + } else { + _showErrorAlert(context.translations.fileTooLargeError( + widget.maxAttachmentSize / (1024 * 1024), + )); + return; + } + } + + setState(() { + _addAttachments([ + attachment.copyWith( + file: file, + extraData: {...attachment.extraData} + ..update('file_size', ((_) => file!.size!)), + ), + ]); + }); + } + + Widget _buildIdleSendButton(BuildContext context) => Padding( + padding: const EdgeInsets.all(8), + child: StreamSvgIcon( + assetName: _getIdleSendIcon(), + color: _messageInputTheme.sendButtonIdleColor, + ), + ); + + Widget _buildSendButton(BuildContext context) => Padding( + padding: const EdgeInsets.all(8), + child: IconButton( + onPressed: sendMessage, + padding: const EdgeInsets.all(0), + splashRadius: 24, + constraints: const BoxConstraints.tightFor( + height: 24, + width: 24, + ), + icon: StreamSvgIcon( + assetName: _getSendIcon(), + color: _messageInputTheme.sendButtonColor, + ), + ), + ); + + String _getIdleSendIcon() { + if (_commandEnabled) { + return 'Icon_search.svg'; + } else { + return 'Icon_circle_right.svg'; + } + } + + String _getSendIcon() { + if (widget.editMessage != null) { + return 'Icon_circle_up.svg'; + } else if (_commandEnabled) { + return 'Icon_search.svg'; + } else { + return 'Icon_circle_up.svg'; + } + } + + /// Sends the current message + Future sendMessage() async { + var text = textEditingController.text.trim(); + if (text.isEmpty && _attachments.isEmpty) { + return; + } + + var shouldKeepFocus = widget.shouldKeepFocusAfterMessage; + + shouldKeepFocus ??= !_commandEnabled; + + if (_commandEnabled) { + text = '${'/${_chosenCommand!.name} '}$text'; + } + + final attachments = [..._attachments.values]; + + textEditingController.clear(); + _attachments.clear(); + widget.onQuotedMessageCleared?.call(); + + setState(() { + _commandEnabled = false; + }); + + Message message; + if (widget.editMessage != null) { + message = widget.editMessage!.copyWith( + text: text, + attachments: attachments, + mentionedUsers: + _mentionedUsers.where((u) => text.contains('@${u.name}')).toList(), + ); + } else { + message = (widget.initialMessage ?? Message()).copyWith( + parentId: widget.parentMessage?.id, + text: text, + attachments: attachments, + mentionedUsers: + _mentionedUsers.where((u) => text.contains('@${u.name}')).toList(), + showInChannel: widget.parentMessage != null ? _sendAsDm : null, + ); + } + + if (widget.quotedMessage != null) { + message = message.copyWith( + quotedMessageId: widget.quotedMessage!.id, + ); + } + + if (widget.preMessageSending != null) { + message = await widget.preMessageSending!(message); + } + + final streamChannel = StreamChannel.of(context); + final channel = streamChannel.channel; + if (!channel.state!.isUpToDate) { + await streamChannel.reloadChannel(); + } + + _mentionedUsers.clear(); + + message = _replaceUserNameWithId(message); + + try { + Future sendingFuture; + if (widget.editMessage == null || + widget.editMessage!.status == MessageSendingStatus.failed || + widget.editMessage!.status == MessageSendingStatus.sending) { + sendingFuture = channel.sendMessage(message); + } else { + sendingFuture = channel.updateMessage(message); + } + + if (shouldKeepFocus) { + FocusScope.of(context).requestFocus(_focusNode); + } else { + FocusScope.of(context).unfocus(); + } + + final resp = await sendingFuture; + if (resp.message?.type == 'error') { + _parseExistingMessage(message); + } + _startSlowMode(); + widget.onMessageSent?.call(resp.message); + } catch (e, stk) { + if (widget.onError != null) { + widget.onError?.call(e, stk); + } else { + rethrow; + } + } + } + + void _showErrorAlert(String description) { + showModalBottomSheet( + backgroundColor: _streamChatTheme.colorTheme.barsBg, + context: context, + shape: const RoundedRectangleBorder( + borderRadius: BorderRadius.only( + topLeft: Radius.circular(16), + topRight: Radius.circular(16), + ), + ), + builder: (context) => Column( + mainAxisSize: MainAxisSize.min, + children: [ + const SizedBox( + height: 26, + ), + StreamSvgIcon.error( + color: _streamChatTheme.colorTheme.accentError, + size: 24, + ), + const SizedBox( + height: 26, + ), + Text( + context.translations.somethingWentWrongError, + style: _streamChatTheme.textTheme.headlineBold, + ), + const SizedBox( + height: 7, + ), + Padding( + padding: const EdgeInsets.symmetric(horizontal: 16), + child: Text( + description, + textAlign: TextAlign.center, + ), + ), + const SizedBox( + height: 36, + ), + Container( + color: + _streamChatTheme.colorTheme.textHighEmphasis.withOpacity(0.08), + height: 1, + ), + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + TextButton( + onPressed: () { + Navigator.of(context).pop(); + }, + child: Text( + context.translations.okLabel, + style: _streamChatTheme.textTheme.bodyBold.copyWith( + color: _streamChatTheme.colorTheme.accentPrimary, + ), + ), + ), + ], + ), + ], + ), + ); + } + + void _parseExistingMessage(Message message) { + final messageText = message.text; + if (messageText != null) textEditingController.text = messageText; + _addAttachments(message.attachments); + } + + @override + void dispose() { + textEditingController.dispose(); + _focusNode.removeListener(_focusNodeListener); + if (_isInternalFocusNode) _focusNode.dispose(); + _stopSlowMode(); + _onChangedDebounced.cancel(); + super.dispose(); + } + + bool _initialized = false; + + @override + void didChangeDependencies() { + _streamChatTheme = StreamChatTheme.of(context); + _messageInputTheme = StreamMessageInputTheme.of(context); + if (widget.editMessage == null) _startSlowMode(); + + if ((widget.editMessage != null || widget.initialMessage != null) && + !_initialized) { + FocusScope.of(context).requestFocus(_focusNode); + _initialized = true; + } + super.didChangeDependencies(); + } +} + +class _PickerWidget extends StatefulWidget { + const _PickerWidget({ + Key? key, + required this.filePickerIndex, + required this.containsFile, + required this.selectedMedias, + required this.onAddMoreFilesClick, + required this.onMediaSelected, + required this.streamChatTheme, + }) : super(key: key); + + final int filePickerIndex; + final bool containsFile; + final List selectedMedias; + final void Function(DefaultAttachmentTypes) onAddMoreFilesClick; + final void Function(AssetEntity) onMediaSelected; + final StreamChatThemeData streamChatTheme; + + @override + _PickerWidgetState createState() => _PickerWidgetState(); +} + +class _PickerWidgetState extends State<_PickerWidget> { + Future? requestPermission; + + @override + void initState() { + super.initState(); + requestPermission = PhotoManager.requestPermission(); + } + + @override + Widget build(BuildContext context) { + if (widget.filePickerIndex != 0) { + return const Offstage(); + } + return FutureBuilder( + future: requestPermission, + builder: (context, snapshot) { + if (!snapshot.hasData) { + return const Offstage(); + } + + if (snapshot.data!) { + if (widget.containsFile) { + return GestureDetector( + onTap: () { + widget.onAddMoreFilesClick(DefaultAttachmentTypes.file); + }, + child: Container( + constraints: const BoxConstraints.expand(), + color: widget.streamChatTheme.colorTheme.inputBg, + alignment: Alignment.center, + child: Text( + context.translations.addMoreFilesLabel, + style: TextStyle( + color: widget.streamChatTheme.colorTheme.accentPrimary, + fontWeight: FontWeight.bold, + ), + ), + ), + ); + } + return StreamMediaListView( + selectedIds: widget.selectedMedias, + onSelect: widget.onMediaSelected, + ); + } + + return InkWell( + onTap: () async { + PhotoManager.openSetting(); + }, + child: Container( + color: widget.streamChatTheme.colorTheme.inputBg, + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + SvgPicture.asset( + 'svgs/icon_picture_empty_state.svg', + package: 'stream_chat_flutter', + height: 140, + color: widget.streamChatTheme.colorTheme.disabled, + ), + Text( + context.translations.enablePhotoAndVideoAccessMessage, + style: widget.streamChatTheme.textTheme.body.copyWith( + color: widget.streamChatTheme.colorTheme.textLowEmphasis, + ), + textAlign: TextAlign.center, + ), + const SizedBox(height: 6), + Center( + child: Text( + context.translations.allowGalleryAccessMessage, + style: widget.streamChatTheme.textTheme.bodyBold.copyWith( + color: widget.streamChatTheme.colorTheme.accentPrimary, + ), + ), + ), + ], + ), + ), + ); + }, + ); + } +} + +class _CountdownButton extends StatelessWidget { + const _CountdownButton({ + Key? key, + required this.count, + }) : super(key: key); + + final int count; + + @override + Widget build(BuildContext context) => Padding( + padding: const EdgeInsets.all(8), + child: DecoratedBox( + decoration: BoxDecoration( + color: StreamChatTheme.of(context).colorTheme.disabled, + shape: BoxShape.circle, + ), + child: SizedBox( + height: 24, + width: 24, + child: Center( + child: Text('$count'), + ), + ), + ), + ); +} + +Message _replaceUserNameWithId(Message message) { + final mentionedUsers = message.mentionedUsers; + if (mentionedUsers.isEmpty) return message; + + var messageTextToSend = message.text; + if (messageTextToSend == null) return message; + + for (final user in mentionedUsers.toSet()) { + final userName = user.name; + messageTextToSend = messageTextToSend!.replaceAll( + '@$userName', + '@${user.id}', + ); + } + + return message.copyWith(text: messageTextToSend); +} diff --git a/packages/stream_chat_flutter/lib/src/message_input/countdown_button.dart b/packages/stream_chat_flutter/lib/src/message_input/countdown_button.dart index 50f18e50..aaf016a3 100644 --- a/packages/stream_chat_flutter/lib/src/message_input/countdown_button.dart +++ b/packages/stream_chat_flutter/lib/src/message_input/countdown_button.dart @@ -2,9 +2,9 @@ import 'package:flutter/material.dart'; import 'package:stream_chat_flutter/stream_chat_flutter.dart'; /// Button for showing visual component of slow mode. -class CountdownButton extends StatelessWidget { - /// Constructor for creating [CountdownButton]. - const CountdownButton({ +class StreamCountdownButton extends StatelessWidget { + /// Constructor for creating [StreamCountdownButton]. + const StreamCountdownButton({ Key? key, required this.count, }) : super(key: key); diff --git a/packages/stream_chat_flutter/lib/src/message_input/message_input.dart b/packages/stream_chat_flutter/lib/src/message_input/message_input.dart index a9f09bbe..e7ec69f1 100644 --- a/packages/stream_chat_flutter/lib/src/message_input/message_input.dart +++ b/packages/stream_chat_flutter/lib/src/message_input/message_input.dart @@ -28,7 +28,7 @@ export 'package:video_compress/video_compress.dart' show VideoQuality; /// A function that returns true if the message is valid and can be sent. typedef MessageValidator = bool Function(Message message); -/// A callback that can be passed to [MessageInput.onError]. +/// A callback that can be passed to [StreamMessageInput.onError]. /// /// This callback should not throw. /// @@ -38,7 +38,7 @@ typedef ErrorListener = void Function( StackTrace? stackTrace, ); -/// A callback that can be passed to [MessageInput.onAttachmentLimitExceed]. +/// A callback that can be passed to [StreamMessageInput.onAttachmentLimitExceed]. /// /// This callback should not throw. /// @@ -63,7 +63,7 @@ typedef MentionTileBuilder = Widget Function( /// Builder function for building a user mention tile. /// -/// Use [UserMentionTile] for the default implementation. +/// Use [StreamUserMentionTile] for the default implementation. typedef UserMentionTileBuilder = Widget Function( BuildContext context, User user, @@ -92,7 +92,7 @@ typedef AttachmentsPickerBuilder = Widget Function( StreamAttachmentPicker defaultPicker, ); -/// Location for actions on the [MessageInput]. +/// Location for actions on the [StreamMessageInput]. enum ActionsLocation { /// Align to left left, @@ -173,14 +173,14 @@ const _kDefaultMaxAttachmentSize = 20971520; // 20MB in Bytes /// } /// ``` /// -/// You usually put this widget in the same page of a [MessageListView] +/// You usually put this widget in the same page of a [StreamMessageListView] /// as the bottom widget. /// /// The widget renders the ui based on the first ancestor of /// type [StreamChatTheme]. Modify it to change the widget appearance. -class MessageInput extends StatefulWidget { +class StreamMessageInput extends StatefulWidget { /// Instantiate a new MessageInput - const MessageInput({ + const StreamMessageInput({ Key? key, this.onMessageSent, this.preMessageSending, @@ -325,7 +325,7 @@ class MessageInput extends StatefulWidget { /// Builder for creating send button final MessageRelatedBuilder? sendButtonBuilder; - /// Defines if the [MessageInput] loses focuses after a message is sent. + /// Defines if the [StreamMessageInput] loses focuses after a message is sent. /// The default behaviour keeps focus until a command is enabled. final bool? shouldKeepFocusAfterMessage; @@ -335,25 +335,25 @@ class MessageInput extends StatefulWidget { /// Restoration ID to save and restore the state of the MessageInput. final String? restorationId; - /// Wrap [MessageInput] with a [SafeArea widget] + /// Wrap [StreamMessageInput] with a [SafeArea widget] final bool? enableSafeArea; - /// Elevation of the [MessageInput] + /// Elevation of the [StreamMessageInput] final double? elevation; - /// Shadow for the [MessageInput] widget + /// Shadow for the [StreamMessageInput] widget final BoxShadow? shadow; static bool _defaultValidator(Message message) => message.text?.isNotEmpty == true || message.attachments.isNotEmpty; @override - MessageInputState createState() => MessageInputState(); + StreamMessageInputState createState() => StreamMessageInputState(); } -/// State of [MessageInput] -class MessageInputState extends State - with RestorationMixin { +/// State of [StreamMessageInput] +class StreamMessageInputState extends State + with RestorationMixin { final _imagePicker = ImagePicker(); late FocusNode _focusNode = widget.focusNode ?? FocusNode(); late final _isInternalFocusNode = widget.focusNode == null; @@ -367,7 +367,7 @@ class MessageInputState extends State bool _openFilePickerSection = false; late StreamChatThemeData _streamChatTheme; - late MessageInputThemeData _messageInputTheme; + late StreamMessageInputThemeData _messageInputTheme; bool get _hasQuotedMessage => _effectiveController.value.quotedMessage != null; @@ -410,7 +410,7 @@ class MessageInputState extends State } @override - void didUpdateWidget(covariant MessageInput oldWidget) { + void didUpdateWidget(covariant StreamMessageInput oldWidget) { super.didUpdateWidget(oldWidget); if (widget.messageInputController == null && oldWidget.messageInputController != null) { @@ -596,7 +596,7 @@ class MessageInputState extends State child: child, ); } - return MultiOverlay( + return StreamMultiOverlay( childAnchor: Alignment.topCenter, overlayAnchor: Alignment.bottomCenter, overlayOptions: [ @@ -1109,7 +1109,7 @@ class MessageInputState extends State if (renderObject == null) { return const Offstage(); } - return CommandsOverlay( + return StreamCommandsOverlay( channel: StreamChannel.of(context).channel, size: Size(renderObject.size.width - 16, 400), text: text, @@ -1170,7 +1170,7 @@ class MessageInputState extends State } return LayoutBuilder( - builder: (context, snapshot) => UserMentionsOverlay( + builder: (context, snapshot) => StreamUserMentionsOverlay( query: query, mentionAllAppUsers: widget.mentionAllAppUsers, client: StreamChat.of(context).client, @@ -1210,7 +1210,7 @@ class MessageInputState extends State // ignore: cast_nullable_to_non_nullable final renderObject = context.findRenderObject() as RenderBox; - return EmojiOverlay( + return StreamEmojiOverlay( size: Size(renderObject.size.width - 16, 200), query: query, onEmojiResult: (emoji) { @@ -1241,7 +1241,7 @@ class MessageInputState extends State if (!_hasQuotedMessage) return const Offstage(); final containsUrl = _effectiveController.value.quotedMessage!.attachments .any((element) => element.titleLink != null); - return QuotedMessageWidget( + return StreamQuotedMessageWidget( reverse: true, showBorder: !containsUrl, message: _effectiveController.value.quotedMessage!, @@ -1275,7 +1275,7 @@ class MessageInputState extends State .map( (e) => ClipRRect( borderRadius: BorderRadius.circular(10), - child: FileAttachment( + child: StreamFileAttachment( message: Message(), // dummy message attachment: e, size: Size( @@ -1397,7 +1397,7 @@ class MessageInputState extends State case 'video': return Stack( children: [ - VideoThumbnailImage( + StreamVideoThumbnailImage( height: 104, width: 104, video: (attachment.file?.path ?? attachment.assetUrl)!, @@ -1640,7 +1640,7 @@ class MessageInputState extends State if (file.size! > widget.maxAttachmentSize) { if (attachmentType == 'video' && file.path != null) { - final mediaInfo = await (VideoService.compressVideo( + final mediaInfo = await (StreamVideoService.compressVideo( file.path!, frameRate: widget.compressedVideoFrameRate, quality: widget.compressedVideoQuality, @@ -1831,7 +1831,7 @@ class MessageInputState extends State @override void didChangeDependencies() { _streamChatTheme = StreamChatTheme.of(context); - _messageInputTheme = MessageInputTheme.of(context); + _messageInputTheme = StreamMessageInputTheme.of(context); super.didChangeDependencies(); } diff --git a/packages/stream_chat_flutter/lib/src/message_input/stream_attachment_picker.dart b/packages/stream_chat_flutter/lib/src/message_input/stream_attachment_picker.dart index 909f9561..1e1b99c7 100644 --- a/packages/stream_chat_flutter/lib/src/message_input/stream_attachment_picker.dart +++ b/packages/stream_chat_flutter/lib/src/message_input/stream_attachment_picker.dart @@ -376,7 +376,7 @@ class _StreamAttachmentPickerState extends State { if (file.size! > widget.maxAttachmentSize) { if (medium.type == AssetType.video && file.path != null) { - final mediaInfo = await (VideoService.compressVideo( + final mediaInfo = await (StreamVideoService.compressVideo( file.path!, frameRate: widget.compressedVideoFrameRate, quality: widget.compressedVideoQuality, @@ -507,7 +507,7 @@ class _PickerWidgetState extends State<_PickerWidget> { ), ); } - return MediaListView( + return StreamMediaListView( selectedIds: widget.selectedMedias, onSelect: widget.onMediaSelected, ); diff --git a/packages/stream_chat_flutter/lib/src/message_input/stream_message_send_button.dart b/packages/stream_chat_flutter/lib/src/message_input/stream_message_send_button.dart index 9916f6f7..67a06f67 100644 --- a/packages/stream_chat_flutter/lib/src/message_input/stream_message_send_button.dart +++ b/packages/stream_chat_flutter/lib/src/message_input/stream_message_send_button.dart @@ -44,7 +44,7 @@ class StreamMessageSendButton extends StatelessWidget { late Widget sendButton; if (timeOut > 0) { - sendButton = CountdownButton(count: timeOut); + sendButton = StreamCountdownButton(count: timeOut); } else if (isIdle) { sendButton = idleSendButton ?? _buildIdleSendButton(context); } else { @@ -63,7 +63,7 @@ class StreamMessageSendButton extends StatelessWidget { } Widget _buildIdleSendButton(BuildContext context) { - final _messageInputTheme = MessageInputTheme.of(context); + final _messageInputTheme = StreamMessageInputTheme.of(context); return Padding( padding: const EdgeInsets.all(8), @@ -75,7 +75,7 @@ class StreamMessageSendButton extends StatelessWidget { } Widget _buildSendButton(BuildContext context) { - final _messageInputTheme = MessageInputTheme.of(context); + final _messageInputTheme = StreamMessageInputTheme.of(context); return Padding( padding: const EdgeInsets.all(8), diff --git a/packages/stream_chat_flutter/lib/src/message_list_view.dart b/packages/stream_chat_flutter/lib/src/message_list_view.dart index e4d67740..d38d7288 100644 --- a/packages/stream_chat_flutter/lib/src/message_list_view.dart +++ b/packages/stream_chat_flutter/lib/src/message_list_view.dart @@ -11,22 +11,22 @@ import 'package:stream_chat_flutter/stream_chat_flutter.dart'; import 'package:visibility_detector/visibility_detector.dart'; /// Widget builder for message -/// [defaultMessageWidget] is the default [MessageWidget] configuration +/// [defaultMessageWidget] is the default [StreamMessageWidget] configuration /// Use [defaultMessageWidget.copyWith] to easily customize it typedef MessageBuilder = Widget Function( BuildContext, MessageDetails, List, - MessageWidget defaultMessageWidget, + StreamMessageWidget defaultMessageWidget, ); /// Widget builder for parent message -/// [defaultMessageWidget] is the default [MessageWidget] configuration +/// [defaultMessageWidget] is the default [StreamMessageWidget] configuration /// Use [defaultMessageWidget.copyWith] to easily customize it typedef ParentMessageBuilder = Widget Function( BuildContext, Message?, - MessageWidget defaultMessageWidget, + StreamMessageWidget defaultMessageWidget, ); /// Widget builder for system message @@ -123,6 +123,11 @@ class MessageDetails { final int index; } +/// {@macro message_list_view} +@Deprecated("Use 'StreamMessageListView' instead") +typedef MessageListView = StreamMessageListView; + +/// {@template message_list_view} /// ![screenshot](https://raw.githubusercontent.com/GetStream/stream-chat-flutter/master/packages/stream_chat_flutter/screenshots/message_listview.png) /// ![screenshot](https://raw.githubusercontent.com/GetStream/stream-chat-flutter/master/packages/stream_chat_flutter/screenshots/message_listview_paint.png) /// @@ -165,9 +170,10 @@ class MessageDetails { /// The widget components render the ui based on the first /// ancestor of type [StreamChatTheme]. /// Modify it to change the widget appearance. -class MessageListView extends StatefulWidget { +/// {@endtemplate} +class StreamMessageListView extends StatefulWidget { /// Instantiate a new MessageListView - const MessageListView({ + const StreamMessageListView({ Key? key, this.showScrollToBottom = true, this.messageBuilder, @@ -330,10 +336,10 @@ class MessageListView extends StatefulWidget { final SpacingWidgetBuilder? spacingWidgetBuilder; @override - _MessageListViewState createState() => _MessageListViewState(); + _StreamMessageListViewState createState() => _StreamMessageListViewState(); } -class _MessageListViewState extends State { +class _StreamMessageListViewState extends State { ItemScrollController? _scrollController; void Function(Message)? _onThreadTap; final ValueNotifier _showScrollToBottom = ValueNotifier(false); @@ -461,7 +467,7 @@ class _MessageListViewState extends State { final child = Stack( alignment: Alignment.center, children: [ - ConnectionStatusBuilder( + StreamConnectionStatusBuilder( statusBuilder: (context, status) { var statusString = ''; var showStatus = true; @@ -478,7 +484,7 @@ class _MessageListViewState extends State { break; } - return InfoTile( + return StreamInfoTile( showMessage: widget.showConnectionStateTile && showStatus, tileAnchor: Alignment.topCenter, childAnchor: Alignment.topCenter, @@ -592,7 +598,7 @@ class _MessageListViewState extends State { ) : Padding( padding: const EdgeInsets.symmetric(vertical: 12), - child: DateDivider( + child: StreamDateDivider( dateTime: nextMessage.createdAt.toLocal(), ), ); @@ -730,8 +736,10 @@ class _MessageListViewState extends State { ], ); - final backgroundColor = MessageListViewTheme.of(context).backgroundColor; - final backgroundImage = MessageListViewTheme.of(context).backgroundImage; + final backgroundColor = + StreamMessageListViewTheme.of(context).backgroundColor; + final backgroundImage = + StreamMessageListViewTheme.of(context).backgroundImage; if (backgroundColor != null || backgroundImage != null) { return Container( @@ -761,7 +769,7 @@ class _MessageListViewState extends State { child: Text( context.translations.threadSeparatorText(replyCount), textAlign: TextAlign.center, - style: ChannelHeaderTheme.of(context).subtitleStyle, + style: StreamChannelHeaderTheme.of(context).subtitleStyle, ), ), ); @@ -815,7 +823,7 @@ class _MessageListViewState extends State { final message = messages[index - 2]; return widget.dateDividerBuilder != null ? widget.dateDividerBuilder!(message.createdAt.toLocal()) - : DateDivider(dateTime: message.createdAt.toLocal()); + : StreamDateDivider(dateTime: message.createdAt.toLocal()); }, ), ); @@ -976,7 +984,7 @@ class _MessageListViewState extends State { final currentUserMember = members.firstWhereOrNull((e) => e.user!.id == currentUser!.id); - final defaultMessageWidget = MessageWidget( + final defaultMessageWidget = StreamMessageWidget( showReplyMessage: false, showResendMessage: false, showThreadReplyMessage: false, @@ -1040,7 +1048,7 @@ class _MessageListViewState extends State { if ((message.type == 'system' || message.type == 'error') && message.text?.isNotEmpty == true) { return widget.systemMessageBuilder?.call(context, message) ?? - SystemMessage( + StreamSystemMessage( message: message, onMessageTap: (message) { if (widget.onSystemMessageTap != null) { @@ -1110,7 +1118,7 @@ class _MessageListViewState extends State { final currentUserMember = members.firstWhereOrNull((e) => e.user!.id == currentUser!.id); - Widget messageWidget = MessageWidget( + Widget messageWidget = StreamMessageWidget( message: message, reverse: isMyMessage, showReactions: !message.isDeleted, @@ -1226,7 +1234,7 @@ class _MessageListViewState extends State { index, ), messages, - messageWidget as MessageWidget, + messageWidget as StreamMessageWidget, ); } diff --git a/packages/stream_chat_flutter/lib/src/message_reactions_modal.dart b/packages/stream_chat_flutter/lib/src/message_reactions_modal.dart index 7568c565..eceba3f2 100644 --- a/packages/stream_chat_flutter/lib/src/message_reactions_modal.dart +++ b/packages/stream_chat_flutter/lib/src/message_reactions_modal.dart @@ -5,10 +5,16 @@ import 'package:stream_chat_flutter/src/extension.dart'; import 'package:stream_chat_flutter/src/reaction_bubble.dart'; import 'package:stream_chat_flutter/stream_chat_flutter.dart'; +/// {@macro message_reactions_modal} +@Deprecated("Use 'StreamMessageReactionsModal' instead") +typedef MessageReactionsModal = StreamMessageReactionsModal; + +/// {@template message_reactions_modal} /// Modal widget for displaying message reactions -class MessageReactionsModal extends StatelessWidget { - /// Constructor for creating a [MessageReactionsModal] reactions - const MessageReactionsModal({ +/// {@endtemplate} +class StreamMessageReactionsModal extends StatelessWidget { + /// Constructor for creating a [StreamMessageReactionsModal] reactions + const StreamMessageReactionsModal({ Key? key, required this.message, required this.messageWidget, @@ -24,8 +30,8 @@ class MessageReactionsModal extends StatelessWidget { /// Message to display reactions of final Message message; - /// [MessageThemeData] to apply to [message] - final MessageThemeData messageTheme; + /// [StreamMessageThemeData] to apply to [message] + final StreamMessageThemeData messageTheme; /// Flag to reverse message final bool reverse; @@ -88,7 +94,7 @@ class MessageReactionsModal extends StatelessWidget { : -(1.2 - divFactor)), 0, ), - child: ReactionPicker( + child: StreamReactionPicker( message: message, ), ), @@ -200,7 +206,7 @@ class MessageReactionsModal extends StatelessWidget { Stack( clipBehavior: Clip.none, children: [ - UserAvatar( + StreamUserAvatar( onTap: onUserAvatarTap, user: reaction.user!, constraints: const BoxConstraints.tightFor( @@ -220,7 +226,7 @@ class MessageReactionsModal extends StatelessWidget { child: Align( alignment: reverse ? Alignment.centerRight : Alignment.centerLeft, - child: ReactionBubble( + child: StreamReactionBubble( reactions: [reaction], flipTail: !reverse, borderColor: diff --git a/packages/stream_chat_flutter/lib/src/message_search_item.dart b/packages/stream_chat_flutter/lib/src/message_search_item.dart index 022ec7ce..fe6d02b7 100644 --- a/packages/stream_chat_flutter/lib/src/message_search_item.dart +++ b/packages/stream_chat_flutter/lib/src/message_search_item.dart @@ -2,17 +2,23 @@ import 'package:flutter/material.dart'; import 'package:stream_chat_flutter/src/extension.dart'; import 'package:stream_chat_flutter/stream_chat_flutter.dart'; +/// {@macro message_search_item} +@Deprecated("Use 'StreamMessageSearchItem' instead") +typedef MessageSearchItem = StreamMessageSearchItem; + +/// {@template message_search_item} /// It shows the current [Message] preview. /// /// Usually you don't use this widget as it's the default item used by -/// [MessageSearchListView]. +/// [StreamMessageSearchListView]. /// /// The widget renders the ui based on the first ancestor of type /// [StreamChatTheme]. /// Modify it to change the widget appearance. -class MessageSearchItem extends StatelessWidget { +/// {@endtemplate} +class StreamMessageSearchItem extends StatelessWidget { /// Instantiate a new MessageSearchItem - const MessageSearchItem({ + const StreamMessageSearchItem({ Key? key, required this.getMessageResponse, this.onTap, @@ -25,7 +31,7 @@ class MessageSearchItem extends StatelessWidget { /// Function called when tapping this widget final VoidCallback? onTap; - /// If true the [MessageSearchItem] will show the current online Status + /// If true the [StreamMessageSearchItem] will show the current online Status final bool showOnlineStatus; @override @@ -34,10 +40,10 @@ class MessageSearchItem extends StatelessWidget { final channel = getMessageResponse.channel; final channelName = channel?.extraData['name']; final user = message.user!; - final channelPreviewTheme = ChannelPreviewTheme.of(context); + final channelPreviewTheme = StreamChannelPreviewTheme.of(context); return ListTile( onTap: onTap, - leading: UserAvatar( + leading: StreamUserAvatar( user: user, showOnlineStatus: showOnlineStatus, constraints: const BoxConstraints.tightFor( @@ -120,7 +126,7 @@ class MessageSearchItem extends StatelessWidget { text = parts.join(' '); } - final channelPreviewTheme = ChannelPreviewTheme.of(context); + final channelPreviewTheme = StreamChannelPreviewTheme.of(context); return Text.rich( _getDisplayText( text!, diff --git a/packages/stream_chat_flutter/lib/src/message_search_list_view.dart b/packages/stream_chat_flutter/lib/src/message_search_list_view.dart index 76ae0e98..380b6545 100644 --- a/packages/stream_chat_flutter/lib/src/message_search_list_view.dart +++ b/packages/stream_chat_flutter/lib/src/message_search_list_view.dart @@ -11,13 +11,17 @@ typedef MessageSearchItemBuilder = Widget Function( GetMessageResponse, ); -/// Builder used when [MessageSearchListView] is empty +/// Builder used when [StreamMessageSearchListView] is empty typedef EmptyMessageSearchBuilder = Widget Function( BuildContext context, String searchQuery, ); -/// +/// {@macro message_search_list_view} +@Deprecated("Use 'StreamMessageSearchListView' instead") +typedef MessageSearchListView = StreamMessageSearchListView; + +/// {@template message_search_list_view} /// It shows the list of searched messages. /// /// ```dart @@ -47,9 +51,10 @@ typedef EmptyMessageSearchBuilder = Widget Function( /// The widget components render the ui based on the first ancestor of type /// [StreamChatTheme]. /// Modify it to change the widget appearance. -class MessageSearchListView extends StatefulWidget { +/// {@endtemplate} +class StreamMessageSearchListView extends StatefulWidget { /// Instantiate a new MessageSearchListView - const MessageSearchListView({ + const StreamMessageSearchListView({ Key? key, required this.filters, this.messageQuery, @@ -96,7 +101,7 @@ class MessageSearchListView extends StatefulWidget { /// Builder used to create a custom item preview final MessageSearchItemBuilder? itemBuilder; - /// Function called when tapping on a [MessageSearchItem] + /// Function called when tapping on a [StreamMessageSearchItem] final MessageSearchItemTapCallback? onItemTap; /// Builder used to create a custom item separator @@ -130,10 +135,12 @@ class MessageSearchListView extends StatefulWidget { final MessageSearchListController? messageSearchListController; @override - _MessageSearchListViewState createState() => _MessageSearchListViewState(); + _StreamMessageSearchListViewState createState() => + _StreamMessageSearchListViewState(); } -class _MessageSearchListViewState extends State { +class _StreamMessageSearchListViewState + extends State { late final _defaultController = MessageSearchListController(); MessageSearchListController get _messageSearchListController => @@ -168,7 +175,7 @@ class _MessageSearchListViewState extends State { if (error is Error) { print(error.stackTrace); } - return InfoTile( + return StreamInfoTile( showMessage: widget.showErrorTile, tileAnchor: Alignment.topCenter, childAnchor: Alignment.topCenter, @@ -195,7 +202,7 @@ class _MessageSearchListViewState extends State { ); final backgroundColor = - MessageSearchListViewTheme.of(context).backgroundColor; + StreamMessageSearchListViewTheme.of(context).backgroundColor; if (backgroundColor != null) { return ColoredBox( @@ -219,7 +226,7 @@ class _MessageSearchListViewState extends State { if (widget.itemBuilder != null) { return widget.itemBuilder!(context, getMessageResponse); } - return MessageSearchItem( + return StreamMessageSearchItem( getMessageResponse: getMessageResponse, onTap: () => widget.onItemTap!(getMessageResponse), ); diff --git a/packages/stream_chat_flutter/lib/src/message_text.dart b/packages/stream_chat_flutter/lib/src/message_text.dart index 4787bb9e..012aa5c7 100644 --- a/packages/stream_chat_flutter/lib/src/message_text.dart +++ b/packages/stream_chat_flutter/lib/src/message_text.dart @@ -3,10 +3,16 @@ import 'package:flutter/material.dart'; import 'package:flutter_markdown/flutter_markdown.dart'; import 'package:stream_chat_flutter/stream_chat_flutter.dart'; +/// {@macro message_text} +@Deprecated("Use 'StreamMessageText' instead") +typedef MessageText = StreamMessageText; + +/// {@template message_text} /// Text widget to display in message -class MessageText extends StatelessWidget { - /// Constructor for creating a [MessageText] widget - const MessageText({ +/// {@endtemplate} +class StreamMessageText extends StatelessWidget { + /// Constructor for creating a [StreamMessageText] widget + const StreamMessageText({ Key? key, required this.message, required this.messageTheme, @@ -23,8 +29,8 @@ class MessageText extends StatelessWidget { /// Callback for when link is tapped final void Function(String)? onLinkTap; - /// [MessageThemeData] whose text theme is to be applied - final MessageThemeData messageTheme; + /// [StreamMessageThemeData] whose text theme is to be applied + final StreamMessageThemeData messageTheme; @override Widget build(BuildContext context) { diff --git a/packages/stream_chat_flutter/lib/src/message_widget.dart b/packages/stream_chat_flutter/lib/src/message_widget.dart index 864c977e..22a7ef18 100644 --- a/packages/stream_chat_flutter/lib/src/message_widget.dart +++ b/packages/stream_chat_flutter/lib/src/message_widget.dart @@ -32,20 +32,26 @@ enum DisplayWidget { show, } +/// {@macro message_widget} +@Deprecated("Use 'StreamMessageWidget' instead") +typedef MessageWidget = StreamMessageWidget; + +/// {@template message_widget} /// ![screenshot](https://raw.githubusercontent.com/GetStream/stream-chat-flutter/master/packages/stream_chat_flutter/screenshots/message_widget.png) /// ![screenshot](https://raw.githubusercontent.com/GetStream/stream-chat-flutter/master/packages/stream_chat_flutter/screenshots/message_widget_paint.png) /// /// It shows a message with reactions, replies and user avatar. /// /// Usually you don't use this widget as it's the default message widget used by -/// [MessageListView]. +/// [StreamMessageListView]. /// /// The widget components render the ui based on the first ancestor of type /// [StreamChatTheme]. /// Modify it to change the widget appearance. -class MessageWidget extends StatefulWidget { - /// - MessageWidget({ +/// {@endtemplate} +class StreamMessageWidget extends StatefulWidget { + /// Creates a new instance of the message widget. + StreamMessageWidget({ Key? key, required this.message, required this.messageTheme, @@ -121,7 +127,7 @@ class MessageWidget extends StatefulWidget { context, Material( color: messageTheme.messageBackgroundColor, - child: ImageGroup( + child: StreamImageGroup( size: Size( mediaQueryData.size.width * 0.8, mediaQueryData.size.height * 0.3, @@ -142,7 +148,7 @@ class MessageWidget extends StatefulWidget { return wrapAttachmentWidget( context, - ImageAttachment( + StreamImageAttachment( attachment: attachments[0], message: message, messageTheme: messageTheme, @@ -172,7 +178,7 @@ class MessageWidget extends StatefulWidget { Column( children: attachments.map((attachment) { final mediaQueryData = MediaQuery.of(context); - return VideoAttachment( + return StreamVideoAttachment( attachment: attachment, messageTheme: messageTheme, size: Size( @@ -204,7 +210,7 @@ class MessageWidget extends StatefulWidget { Column( children: attachments.map((attachment) { final mediaQueryData = MediaQuery.of(context); - return GiphyAttachment( + return StreamGiphyAttachment( attachment: attachment, message: message, size: Size( @@ -240,7 +246,7 @@ class MessageWidget extends StatefulWidget { final mediaQueryData = MediaQuery.of(context); return wrapAttachmentWidget( context, - FileAttachment( + StreamFileAttachment( message: message, attachment: attachment, size: Size( @@ -300,7 +306,7 @@ class MessageWidget extends StatefulWidget { final Message message; /// The message theme - final MessageThemeData messageTheme; + final StreamMessageThemeData messageTheme; /// If true the widget will be mirrored final bool reverse; @@ -356,7 +362,7 @@ class MessageWidget extends StatefulWidget { /// The function called when tapping on a link final void Function(String)? onLinkTap; - /// Used in [MessageReactionsModal] and [MessageActionsModal] + /// Used in [StreamMessageReactionsModal] and [StreamMessageActionsModal] final bool showReactionPickerIndicator; /// List of users who read @@ -417,13 +423,13 @@ class MessageWidget extends StatefulWidget { final void Function(Message)? onMessageTap; /// List of custom actions shown on message long tap - final List customActions; + final List customActions; /// Customize onTap on attachment final void Function(Message message, Attachment attachment)? onAttachmentTap; - /// Creates a copy of [MessageWidget] with specified attributes overridden. - MessageWidget copyWith({ + /// Creates a copy of [StreamMessageWidget] with specified attributes overridden. + StreamMessageWidget copyWith({ Key? key, void Function(User)? onMentionTap, void Function(Message)? onThreadTap, @@ -435,7 +441,7 @@ class MessageWidget extends StatefulWidget { Widget Function(BuildContext, Message)? deletedBottomRowBuilder, void Function(BuildContext, Message)? onMessageActions, Message? message, - MessageThemeData? messageTheme, + StreamMessageThemeData? messageTheme, bool? reverse, ShapeBorder? shape, ShapeBorder? attachmentShape, @@ -473,11 +479,11 @@ class MessageWidget extends StatefulWidget { bool? translateUserAvatar, OnQuotedMessageTap? onQuotedMessageTap, void Function(Message)? onMessageTap, - List? customActions, + List? customActions, void Function(Message message, Attachment attachment)? onAttachmentTap, Widget Function(BuildContext, User)? userAvatarBuilder, }) => - MessageWidget( + StreamMessageWidget( key: key ?? this.key, onMentionTap: onMentionTap ?? this.onMentionTap, onThreadTap: onThreadTap ?? this.onThreadTap, @@ -539,11 +545,11 @@ class MessageWidget extends StatefulWidget { ); @override - _MessageWidgetState createState() => _MessageWidgetState(); + _StreamMessageWidgetState createState() => _StreamMessageWidgetState(); } -class _MessageWidgetState extends State - with AutomaticKeepAliveClientMixin { +class _StreamMessageWidgetState extends State + with AutomaticKeepAliveClientMixin { bool get showThreadReplyIndicator => widget.showThreadReplyIndicator; bool get showSendingIndicator => widget.showSendingIndicator; @@ -717,7 +723,7 @@ class _MessageWidgetState extends State ? 0 : 4.0, ), - child: DeletedMessage( + child: StreamDeletedMessage( borderRadiusGeometry: widget .borderRadiusGeometry, borderSide: @@ -854,7 +860,7 @@ class _MessageWidgetState extends State ? () => widget.onQuotedMessageTap!(widget.message.quotedMessageId) : null; final chatThemeData = _streamChatTheme; - return QuotedMessageWidget( + return StreamQuotedMessageWidget( onTap: onTap, message: widget.message.quotedMessage!, messageTheme: isMyMessage @@ -1008,7 +1014,7 @@ class _MessageWidgetState extends State getWebsiteName(hostName.toLowerCase()) ?? hostName.capitalize(); - return UrlAttachment( + return StreamUrlAttachment( urlAttachment: urlAttachment, hostDisplayName: hostDisplayName, textPadding: widget.textPadding, @@ -1041,7 +1047,7 @@ class _MessageWidgetState extends State child: _shouldShowReactions ? GestureDetector( onTap: () => _showMessageReactionsModalBottomSheet(context), - child: ReactionBubble( + child: StreamReactionBubble( key: ValueKey('${widget.message.id}.reactions'), reverse: widget.reverse, flipTail: widget.reverse, @@ -1072,7 +1078,7 @@ class _MessageWidgetState extends State barrierColor: _streamChatTheme.colorTheme.overlay, builder: (context) => StreamChannel( channel: channel, - child: MessageActionsModal( + child: StreamMessageActionsModal( messageWidget: widget.copyWith( key: const Key('MessageWidget'), message: widget.message.copyWith( @@ -1129,7 +1135,7 @@ class _MessageWidgetState extends State barrierColor: _streamChatTheme.colorTheme.overlay, builder: (context) => StreamChannel( channel: channel, - child: MessageReactionsModal( + child: StreamMessageReactionsModal( messageWidget: widget.copyWith( key: const Key('MessageWidget'), message: widget.message.copyWith( @@ -1246,7 +1252,7 @@ class _MessageWidgetState extends State final channel = StreamChannel.of(context).channel; if (!channel.ownCapabilities.contains(PermissionType.readEvents)) { - return SendingIndicator( + return StreamSendingIndicator( message: message, size: style!.fontSize, ); @@ -1261,7 +1267,7 @@ class _MessageWidgetState extends State (it.lastRead.isAfter(message.createdAt) || it.lastRead.isAtSameMomentAs(message.createdAt))); final isMessageRead = readList.length >= (channel.memberCount ?? 0) - 1; - Widget child = SendingIndicator( + Widget child = StreamSendingIndicator( message: message, isMessageRead: isMessageRead, size: style!.fontSize, @@ -1295,7 +1301,7 @@ class _MessageWidgetState extends State : 0, ), child: widget.userAvatarBuilder?.call(context, widget.message.user!) ?? - UserAvatar( + StreamUserAvatar( user: widget.message.user!, onTap: widget.onUserAvatarTap, constraints: widget.messageTheme.avatarTheme!.constraints, @@ -1313,7 +1319,7 @@ class _MessageWidgetState extends State padding: isOnlyEmoji ? EdgeInsets.zero : widget.textPadding, child: widget.textBuilder != null ? widget.textBuilder!(context, widget.message) - : MessageText( + : StreamMessageText( onLinkTap: widget.onLinkTap, message: widget.message, onMentionTap: widget.onMentionTap, @@ -1430,7 +1436,7 @@ class _ThreadParticipants extends StatelessWidget { color: _streamChatTheme.colorTheme.barsBg, ), padding: const EdgeInsets.all(1), - child: UserAvatar( + child: StreamUserAvatar( user: user, constraints: BoxConstraints.loose(const Size.fromRadius(7)), showOnlineStatus: false, diff --git a/packages/stream_chat_flutter/lib/src/multi_overlay.dart b/packages/stream_chat_flutter/lib/src/multi_overlay.dart index 31b9d5e9..bd1ed387 100644 --- a/packages/stream_chat_flutter/lib/src/multi_overlay.dart +++ b/packages/stream_chat_flutter/lib/src/multi_overlay.dart @@ -2,15 +2,21 @@ import 'package:collection/collection.dart'; import 'package:flutter/widgets.dart'; import 'package:flutter_portal/flutter_portal.dart'; +/// {@macro multi_overlay} +@Deprecated("Use 'StreamMultiOverlay' instead") +typedef MultiOverlay = StreamMultiOverlay; + +/// {@template multi_overlay} /// Widget that renders a single overlay widget from a list of [overlayOptions] /// It shows the first one that is visible -class MultiOverlay extends StatelessWidget { +/// {@endtemplate} +class StreamMultiOverlay extends StatelessWidget { /// Constructs a new MultiOverlay widget /// [overlayOptions] - the list of overlay options /// [overlayAnchor] - the anchor relative to the overlay /// [childAnchor] - the anchor relative to the child /// [child] - the child widget - const MultiOverlay({ + const StreamMultiOverlay({ Key? key, required this.overlayOptions, required this.child, diff --git a/packages/stream_chat_flutter/lib/src/option_list_tile.dart b/packages/stream_chat_flutter/lib/src/option_list_tile.dart index b8daa0e3..185d40f8 100644 --- a/packages/stream_chat_flutter/lib/src/option_list_tile.dart +++ b/packages/stream_chat_flutter/lib/src/option_list_tile.dart @@ -1,10 +1,16 @@ import 'package:flutter/material.dart'; import 'package:stream_chat_flutter/src/stream_chat_theme.dart'; +/// {@macro option_list_tile} +@Deprecated("Use 'StreamOptionListTile' instead") +typedef OptionListTile = StreamOptionListTile; + +/// {@template option_list_tile} /// List tile for [ChannelBottomSheet] -class OptionListTile extends StatelessWidget { - /// Constructor for creating [OptionListTile] - const OptionListTile({ +/// {@endtemplate} +class StreamOptionListTile extends StatelessWidget { + /// Constructor for creating [StreamOptionListTile] + const StreamOptionListTile({ Key? key, required this.title, this.leading, diff --git a/packages/stream_chat_flutter/lib/src/quoted_message_widget.dart b/packages/stream_chat_flutter/lib/src/quoted_message_widget.dart index 131ca60b..81c8b892 100644 --- a/packages/stream_chat_flutter/lib/src/quoted_message_widget.dart +++ b/packages/stream_chat_flutter/lib/src/quoted_message_widget.dart @@ -10,54 +10,14 @@ typedef QuotedMessageAttachmentThumbnailBuilder = Widget Function( Attachment, ); -class _VideoAttachmentThumbnail extends StatefulWidget { - const _VideoAttachmentThumbnail({ - Key? key, - required this.attachment, - this.size = const Size(32, 32), - }) : super(key: key); +/// Widget for the quoted message. +@Deprecated("Use 'StreamQuotedMessageWidget' instead") +typedef QuotedMessageWidget = StreamQuotedMessageWidget; - final Size size; - final Attachment attachment; - - @override - _VideoAttachmentThumbnailState createState() => - _VideoAttachmentThumbnailState(); -} - -class _VideoAttachmentThumbnailState extends State<_VideoAttachmentThumbnail> { - late VideoPlayerController _controller; - - @override - void initState() { - super.initState(); - _controller = VideoPlayerController.network(widget.attachment.assetUrl!) - ..initialize().then((_) { - // ignore: no-empty-block - setState(() {}); //when your thumbnail will show. - }); - } - - @override - void dispose() { - super.dispose(); - _controller.dispose(); - } - - @override - Widget build(BuildContext context) => SizedBox( - height: widget.size.height, - width: widget.size.width, - child: _controller.value.isInitialized - ? VideoPlayer(_controller) - : const CircularProgressIndicator(), - ); -} - -/// -class QuotedMessageWidget extends StatelessWidget { - /// - const QuotedMessageWidget({ +/// Widget for the quoted message. +class StreamQuotedMessageWidget extends StatelessWidget { + /// Creates a new instance of the widget. + const StreamQuotedMessageWidget({ Key? key, required this.message, required this.messageTheme, @@ -73,7 +33,7 @@ class QuotedMessageWidget extends StatelessWidget { final Message message; /// The message theme - final MessageThemeData messageTheme; + final StreamMessageThemeData messageTheme; /// If true the widget will be mirrored final bool reverse; @@ -134,7 +94,7 @@ class QuotedMessageWidget extends StatelessWidget { if (_hasAttachments) _parseAttachments(context), if (msg.text!.isNotEmpty) Flexible( - child: MessageText( + child: StreamMessageText( message: msg, messageTheme: isOnlyEmoji && _containsText ? messageTheme.copyWith( @@ -231,7 +191,7 @@ class QuotedMessageWidget extends StatelessWidget { borderRadius: BorderRadius.circular(8), ); - Widget _buildUserAvatar() => UserAvatar( + Widget _buildUserAvatar() => StreamUserAvatar( user: message.user!, constraints: const BoxConstraints.tightFor( height: 24, @@ -242,7 +202,7 @@ class QuotedMessageWidget extends StatelessWidget { Map get _defaultAttachmentBuilder => { - 'image': (_, attachment) => ImageAttachment( + 'image': (_, attachment) => StreamImageAttachment( attachment: attachment, message: message, messageTheme: messageTheme, @@ -288,3 +248,47 @@ class QuotedMessageWidget extends StatelessWidget { return messageTheme.messageBackgroundColor; } } + +class _VideoAttachmentThumbnail extends StatefulWidget { + const _VideoAttachmentThumbnail({ + Key? key, + required this.attachment, + this.size = const Size(32, 32), + }) : super(key: key); + + final Size size; + final Attachment attachment; + + @override + _VideoAttachmentThumbnailState createState() => + _VideoAttachmentThumbnailState(); +} + +class _VideoAttachmentThumbnailState extends State<_VideoAttachmentThumbnail> { + late VideoPlayerController _controller; + + @override + void initState() { + super.initState(); + _controller = VideoPlayerController.network(widget.attachment.assetUrl!) + ..initialize().then((_) { + // ignore: no-empty-block + setState(() {}); //when your thumbnail will show. + }); + } + + @override + void dispose() { + super.dispose(); + _controller.dispose(); + } + + @override + Widget build(BuildContext context) => SizedBox( + height: widget.size.height, + width: widget.size.width, + child: _controller.value.isInitialized + ? VideoPlayer(_controller) + : const CircularProgressIndicator(), + ); +} diff --git a/packages/stream_chat_flutter/lib/src/reaction_bubble.dart b/packages/stream_chat_flutter/lib/src/reaction_bubble.dart index dd3d5e27..99585001 100644 --- a/packages/stream_chat_flutter/lib/src/reaction_bubble.dart +++ b/packages/stream_chat_flutter/lib/src/reaction_bubble.dart @@ -4,10 +4,16 @@ import 'package:collection/collection.dart' show IterableExtension; import 'package:flutter/material.dart'; import 'package:stream_chat_flutter/stream_chat_flutter.dart'; +/// {@macro reaction_bubble} +@Deprecated("Use 'StreamReactionBubble' instead") +typedef ReactionBubble = StreamReactionBubble; + +/// {@template reaction_bubble} /// Creates reaction bubble widget for displaying over messages -class ReactionBubble extends StatelessWidget { - /// Constructor for creating a [ReactionBubble] - const ReactionBubble({ +/// {@endtemplate} +class StreamReactionBubble extends StatelessWidget { + /// Constructor for creating a [StreamReactionBubble] + const StreamReactionBubble({ Key? key, required this.reactions, required this.borderColor, @@ -111,7 +117,7 @@ class ReactionBubble extends StatelessWidget { } Widget _buildReaction( - List reactionIcons, + List reactionIcons, Reaction reaction, BuildContext context, ) { diff --git a/packages/stream_chat_flutter/lib/src/reaction_icon.dart b/packages/stream_chat_flutter/lib/src/reaction_icon.dart index e675128b..cf2cef81 100644 --- a/packages/stream_chat_flutter/lib/src/reaction_icon.dart +++ b/packages/stream_chat_flutter/lib/src/reaction_icon.dart @@ -1,9 +1,13 @@ import 'package:flutter/material.dart'; /// Reaction icon data -class ReactionIcon { - /// Constructor for creating [ReactionIcon] - ReactionIcon({ +@Deprecated("Use 'StreamReactionIcon' instead") +typedef ReactionIcon = StreamReactionIcon; + +/// Reaction icon data +class StreamReactionIcon { + /// Constructor for creating [StreamReactionIcon] + StreamReactionIcon({ required this.type, required this.builder, }); diff --git a/packages/stream_chat_flutter/lib/src/reaction_picker.dart b/packages/stream_chat_flutter/lib/src/reaction_picker.dart index 2991a1bb..28053c01 100644 --- a/packages/stream_chat_flutter/lib/src/reaction_picker.dart +++ b/packages/stream_chat_flutter/lib/src/reaction_picker.dart @@ -3,16 +3,22 @@ import 'package:flutter/material.dart'; import 'package:stream_chat_flutter/src/extension.dart'; import 'package:stream_chat_flutter/stream_chat_flutter.dart'; +/// {@macro reaction_picker} +@Deprecated("Use 'StreamReactionPicker' instead") +typedef ReactionPicker = StreamReactionPicker; + +/// {@template reaction_picker} /// ![screenshot](https://raw.githubusercontent.com/GetStream/stream-chat-flutter/master/packages/stream_chat_flutter/screenshots/reaction_picker.png) /// ![screenshot](https://raw.githubusercontent.com/GetStream/stream-chat-flutter/master/packages/stream_chat_flutter/screenshots/reaction_picker_paint.png) /// /// It shows a reaction picker /// /// Usually you don't use this widget as it's one of the default widgets used -/// by [MessageWidget.onMessageActions]. -class ReactionPicker extends StatefulWidget { - /// Constructor for creating a [ReactionPicker] widget - const ReactionPicker({ +/// by [StreamMessageWidget.onMessageActions]. +/// {@endtemplate} +class StreamReactionPicker extends StatefulWidget { + /// Constructor for creating a [StreamReactionPicker] widget + const StreamReactionPicker({ Key? key, required this.message, }) : super(key: key); @@ -21,10 +27,10 @@ class ReactionPicker extends StatefulWidget { final Message message; @override - _ReactionPickerState createState() => _ReactionPickerState(); + _StreamReactionPickerState createState() => _StreamReactionPickerState(); } -class _ReactionPickerState extends State +class _StreamReactionPickerState extends State with TickerProviderStateMixin { List animations = []; diff --git a/packages/stream_chat_flutter/lib/src/sending_indicator.dart b/packages/stream_chat_flutter/lib/src/sending_indicator.dart index 7f44e5b8..908c734d 100644 --- a/packages/stream_chat_flutter/lib/src/sending_indicator.dart +++ b/packages/stream_chat_flutter/lib/src/sending_indicator.dart @@ -1,10 +1,16 @@ import 'package:flutter/material.dart'; import 'package:stream_chat_flutter/stream_chat_flutter.dart'; +/// {@macro sending_indicator} +@Deprecated("Use 'StreamSendingIndicator' instead") +typedef SendingIndicator = StreamSendingIndicator; + +/// {@template sending_indicator} /// Used to show the sending status of the message -class SendingIndicator extends StatelessWidget { - /// Constructor for creating a [SendingIndicator] widget - const SendingIndicator({ +/// {@endtemplate} +class StreamSendingIndicator extends StatelessWidget { + /// Constructor for creating a [StreamSendingIndicator] widget + const StreamSendingIndicator({ Key? key, required this.message, this.isMessageRead = false, diff --git a/packages/stream_chat_flutter/lib/src/stream_chat_theme.dart b/packages/stream_chat_flutter/lib/src/stream_chat_theme.dart index 84006f44..32b4830f 100644 --- a/packages/stream_chat_flutter/lib/src/stream_chat_theme.dart +++ b/packages/stream_chat_flutter/lib/src/stream_chat_theme.dart @@ -38,29 +38,29 @@ class StreamChatThemeData { /// Create a theme from scratch factory StreamChatThemeData({ Brightness? brightness, - TextTheme? textTheme, - ColorTheme? colorTheme, - ChannelListHeaderThemeData? channelListHeaderTheme, - ChannelPreviewThemeData? channelPreviewTheme, - ChannelHeaderThemeData? channelHeaderTheme, - MessageThemeData? otherMessageTheme, - MessageThemeData? ownMessageTheme, - MessageInputThemeData? messageInputTheme, + StreamTextTheme? textTheme, + StreamColorTheme? colorTheme, + StreamChannelListHeaderThemeData? channelListHeaderTheme, + StreamChannelPreviewThemeData? channelPreviewTheme, + StreamChannelHeaderThemeData? channelHeaderTheme, + StreamMessageThemeData? otherMessageTheme, + StreamMessageThemeData? ownMessageTheme, + StreamMessageInputThemeData? messageInputTheme, Widget Function(BuildContext, User)? defaultUserImage, Widget Function(BuildContext, User)? placeholderUserImage, IconThemeData? primaryIconTheme, - List? reactionIcons, - GalleryHeaderThemeData? imageHeaderTheme, - GalleryFooterThemeData? imageFooterTheme, - MessageListViewThemeData? messageListViewTheme, - ChannelListViewThemeData? channelListViewTheme, - UserListViewThemeData? userListViewTheme, - MessageSearchListViewThemeData? messageSearchListViewTheme, + List? reactionIcons, + StreamGalleryHeaderThemeData? imageHeaderTheme, + StreamGalleryFooterThemeData? imageFooterTheme, + StreamMessageListViewThemeData? messageListViewTheme, + StreamChannelListViewThemeData? channelListViewTheme, + StreamUserListViewThemeData? userListViewTheme, + StreamMessageSearchListViewThemeData? messageSearchListViewTheme, }) { brightness ??= colorTheme?.brightness ?? Brightness.light; final isDark = brightness == Brightness.dark; - textTheme ??= isDark ? TextTheme.dark() : TextTheme.light(); - colorTheme ??= isDark ? ColorTheme.dark() : ColorTheme.light(); + textTheme ??= isDark ? StreamTextTheme.dark() : StreamTextTheme.light(); + colorTheme ??= isDark ? StreamColorTheme.dark() : StreamColorTheme.light(); final defaultData = StreamChatThemeData.fromColorAndTextTheme( colorTheme, @@ -133,14 +133,14 @@ class StreamChatThemeData { /// Create theme from color and text theme factory StreamChatThemeData.fromColorAndTextTheme( - ColorTheme colorTheme, - TextTheme textTheme, + StreamColorTheme colorTheme, + StreamTextTheme textTheme, ) { final accentColor = colorTheme.accentPrimary; final iconTheme = IconThemeData(color: colorTheme.textHighEmphasis.withOpacity(0.5)); - final channelHeaderTheme = ChannelHeaderThemeData( - avatarTheme: AvatarThemeData( + final channelHeaderTheme = StreamChannelHeaderThemeData( + avatarTheme: StreamAvatarThemeData( borderRadius: BorderRadius.circular(20), constraints: const BoxConstraints.tightFor( height: 40, @@ -153,9 +153,9 @@ class StreamChatThemeData { color: const Color(0xff7A7A7A), ), ); - final channelPreviewTheme = ChannelPreviewThemeData( + final channelPreviewTheme = StreamChannelPreviewThemeData( unreadCounterColor: colorTheme.accentError, - avatarTheme: AvatarThemeData( + avatarTheme: StreamAvatarThemeData( borderRadius: BorderRadius.circular(20), constraints: const BoxConstraints.tightFor( height: 40, @@ -176,14 +176,14 @@ class StreamChatThemeData { colorTheme: colorTheme, primaryIconTheme: iconTheme, defaultUserImage: (context, user) => Center( - child: GradientAvatar( + child: StreamGradientAvatar( name: user.name, userId: user.id, ), ), channelPreviewTheme: channelPreviewTheme, - channelListHeaderTheme: ChannelListHeaderThemeData( - avatarTheme: AvatarThemeData( + channelListHeaderTheme: StreamChannelListHeaderThemeData( + avatarTheme: StreamAvatarThemeData( borderRadius: BorderRadius.circular(20), constraints: const BoxConstraints.tightFor( height: 40, @@ -194,7 +194,7 @@ class StreamChatThemeData { titleStyle: textTheme.headlineBold, ), channelHeaderTheme: channelHeaderTheme, - ownMessageTheme: MessageThemeData( + ownMessageTheme: StreamMessageThemeData( messageAuthorStyle: textTheme.footnote.copyWith(color: colorTheme.textLowEmphasis), messageTextStyle: textTheme.body, @@ -206,7 +206,7 @@ class StreamChatThemeData { reactionsBorderColor: colorTheme.borders, reactionsMaskColor: colorTheme.appBg, messageBorderColor: colorTheme.disabled, - avatarTheme: AvatarThemeData( + avatarTheme: StreamAvatarThemeData( borderRadius: BorderRadius.circular(20), constraints: const BoxConstraints.tightFor( height: 32, @@ -218,7 +218,7 @@ class StreamChatThemeData { ), linkBackgroundColor: colorTheme.linkBg, ), - otherMessageTheme: MessageThemeData( + otherMessageTheme: StreamMessageThemeData( reactionsBackgroundColor: colorTheme.disabled, reactionsBorderColor: colorTheme.barsBg, reactionsMaskColor: colorTheme.appBg, @@ -233,7 +233,7 @@ class StreamChatThemeData { ), messageBackgroundColor: colorTheme.barsBg, messageBorderColor: colorTheme.borders, - avatarTheme: AvatarThemeData( + avatarTheme: StreamAvatarThemeData( borderRadius: BorderRadius.circular(20), constraints: const BoxConstraints.tightFor( height: 32, @@ -242,7 +242,7 @@ class StreamChatThemeData { ), linkBackgroundColor: colorTheme.linkBg, ), - messageInputTheme: MessageInputThemeData( + messageInputTheme: StreamMessageInputThemeData( borderRadius: BorderRadius.circular(20), sendAnimationDuration: const Duration(milliseconds: 300), actionButtonColor: colorTheme.accentPrimary, @@ -267,7 +267,7 @@ class StreamChatThemeData { ), ), reactionIcons: [ - ReactionIcon( + StreamReactionIcon( type: 'love', builder: (context, highlighted, size) { final theme = StreamChatTheme.of(context); @@ -279,7 +279,7 @@ class StreamChatThemeData { ); }, ), - ReactionIcon( + StreamReactionIcon( type: 'like', builder: (context, highlighted, size) { final theme = StreamChatTheme.of(context); @@ -291,7 +291,7 @@ class StreamChatThemeData { ); }, ), - ReactionIcon( + StreamReactionIcon( type: 'sad', builder: (context, highlighted, size) { final theme = StreamChatTheme.of(context); @@ -303,7 +303,7 @@ class StreamChatThemeData { ); }, ), - ReactionIcon( + StreamReactionIcon( type: 'haha', builder: (context, highlighted, size) { final theme = StreamChatTheme.of(context); @@ -315,7 +315,7 @@ class StreamChatThemeData { ); }, ), - ReactionIcon( + StreamReactionIcon( type: 'wow', builder: (context, highlighted, size) { final theme = StreamChatTheme.of(context); @@ -328,7 +328,7 @@ class StreamChatThemeData { }, ), ], - galleryHeaderTheme: GalleryHeaderThemeData( + galleryHeaderTheme: StreamGalleryHeaderThemeData( closeButtonColor: colorTheme.textHighEmphasis, backgroundColor: channelHeaderTheme.color, iconMenuPointColor: colorTheme.textHighEmphasis, @@ -336,7 +336,7 @@ class StreamChatThemeData { subtitleTextStyle: channelPreviewTheme.subtitleStyle, bottomSheetBarrierColor: colorTheme.overlay, ), - galleryFooterTheme: GalleryFooterThemeData( + galleryFooterTheme: StreamGalleryFooterThemeData( backgroundColor: colorTheme.barsBg, shareIconColor: colorTheme.textHighEmphasis, titleTextStyle: textTheme.headlineBold, @@ -346,52 +346,52 @@ class StreamChatThemeData { bottomSheetPhotosTextStyle: textTheme.headlineBold, bottomSheetCloseIconColor: colorTheme.textHighEmphasis, ), - messageListViewTheme: MessageListViewThemeData( + messageListViewTheme: StreamMessageListViewThemeData( backgroundColor: colorTheme.barsBg, ), - channelListViewTheme: ChannelListViewThemeData( + channelListViewTheme: StreamChannelListViewThemeData( backgroundColor: colorTheme.appBg, ), - userListViewTheme: UserListViewThemeData( + userListViewTheme: StreamUserListViewThemeData( backgroundColor: colorTheme.appBg, ), - messageSearchListViewTheme: MessageSearchListViewThemeData( + messageSearchListViewTheme: StreamMessageSearchListViewThemeData( backgroundColor: colorTheme.appBg, ), ); } /// The text themes used in the widgets - final TextTheme textTheme; + final StreamTextTheme textTheme; /// The color themes used in the widgets - final ColorTheme colorTheme; + final StreamColorTheme colorTheme; - /// Theme of the [ChannelPreview] - final ChannelPreviewThemeData channelPreviewTheme; + /// Theme of the [StreamChannelPreview] + final StreamChannelPreviewThemeData channelPreviewTheme; - /// Theme of the [ChannelListHeader] - final ChannelListHeaderThemeData channelListHeaderTheme; + /// Theme of the [StreamChannelListHeader] + final StreamChannelListHeaderThemeData channelListHeaderTheme; /// Theme of the chat widgets dedicated to a channel header - final ChannelHeaderThemeData channelHeaderTheme; + final StreamChannelHeaderThemeData channelHeaderTheme; - /// The default style for [GalleryHeader]s below the overall + /// The default style for [StreamGalleryHeader]s below the overall /// [StreamChatTheme]. - final GalleryHeaderThemeData galleryHeaderTheme; + final StreamGalleryHeaderThemeData galleryHeaderTheme; - /// The default style for [GalleryFooter]s below the overall + /// The default style for [StreamGalleryFooter]s below the overall /// [StreamChatTheme]. - final GalleryFooterThemeData galleryFooterTheme; + final StreamGalleryFooterThemeData galleryFooterTheme; /// Theme of the current user messages - final MessageThemeData ownMessageTheme; + final StreamMessageThemeData ownMessageTheme; /// Theme of other users messages - final MessageThemeData otherMessageTheme; + final StreamMessageThemeData otherMessageTheme; - /// Theme dedicated to the [MessageInput] widget - final MessageInputThemeData messageInputTheme; + /// Theme dedicated to the [StreamMessageInput] widget + final StreamMessageInputThemeData messageInputTheme; /// The widget that will be built when the user image is unavailable final Widget Function(BuildContext, User) defaultUserImage; @@ -403,41 +403,41 @@ class StreamChatThemeData { final IconThemeData primaryIconTheme; /// Assets used for rendering reactions - final List reactionIcons; + final List reactionIcons; - /// Theme configuration for the [MessageListView] widget. - final MessageListViewThemeData messageListViewTheme; + /// Theme configuration for the [StreamMessageListView] widget. + final StreamMessageListViewThemeData messageListViewTheme; - /// Theme configuration for the [ChannelListView] widget. - final ChannelListViewThemeData channelListViewTheme; + /// Theme configuration for the [StreamChannelListView] widget. + final StreamChannelListViewThemeData channelListViewTheme; - /// Theme configuration for the [UserListView] widget. - final UserListViewThemeData userListViewTheme; + /// Theme configuration for the [StreamUserListView] widget. + final StreamUserListViewThemeData userListViewTheme; - /// Theme configuration for the [MessageSearchListView] widget. - final MessageSearchListViewThemeData messageSearchListViewTheme; + /// Theme configuration for the [StreamMessageSearchListView] widget. + final StreamMessageSearchListViewThemeData messageSearchListViewTheme; /// Creates a copy of [StreamChatThemeData] with specified attributes /// overridden. StreamChatThemeData copyWith({ - TextTheme? textTheme, - ColorTheme? colorTheme, - ChannelPreviewThemeData? channelPreviewTheme, - ChannelHeaderThemeData? channelHeaderTheme, - MessageThemeData? ownMessageTheme, - MessageThemeData? otherMessageTheme, - MessageInputThemeData? messageInputTheme, + StreamTextTheme? textTheme, + StreamColorTheme? colorTheme, + StreamChannelPreviewThemeData? channelPreviewTheme, + StreamChannelHeaderThemeData? channelHeaderTheme, + StreamMessageThemeData? ownMessageTheme, + StreamMessageThemeData? otherMessageTheme, + StreamMessageInputThemeData? messageInputTheme, Widget Function(BuildContext, User)? defaultUserImage, Widget Function(BuildContext, User)? placeholderUserImage, IconThemeData? primaryIconTheme, - ChannelListHeaderThemeData? channelListHeaderTheme, - List? reactionIcons, - GalleryHeaderThemeData? galleryHeaderTheme, - GalleryFooterThemeData? galleryFooterTheme, - MessageListViewThemeData? messageListViewTheme, - ChannelListViewThemeData? channelListViewTheme, - UserListViewThemeData? userListViewTheme, - MessageSearchListViewThemeData? messageSearchListViewTheme, + StreamChannelListHeaderThemeData? channelListHeaderTheme, + List? reactionIcons, + StreamGalleryHeaderThemeData? galleryHeaderTheme, + StreamGalleryFooterThemeData? galleryFooterTheme, + StreamMessageListViewThemeData? messageListViewTheme, + StreamChannelListViewThemeData? channelListViewTheme, + StreamUserListViewThemeData? userListViewTheme, + StreamMessageSearchListViewThemeData? messageSearchListViewTheme, }) => StreamChatThemeData.raw( channelListHeaderTheme: diff --git a/packages/stream_chat_flutter/lib/src/system_message.dart b/packages/stream_chat_flutter/lib/src/system_message.dart index 297810b3..4ec10aa4 100644 --- a/packages/stream_chat_flutter/lib/src/system_message.dart +++ b/packages/stream_chat_flutter/lib/src/system_message.dart @@ -1,10 +1,16 @@ import 'package:flutter/material.dart'; import 'package:stream_chat_flutter/stream_chat_flutter.dart'; -/// It shows a date divider depending on the date difference -class SystemMessage extends StatelessWidget { - /// Constructor for creating a [SystemMessage] - const SystemMessage({ +/// {@macro system_message} +@Deprecated("Use 'StreamSystemMessage' instead") +typedef SystemMessage = StreamSystemMessage; + +/// {@template system_message} +/// It shows a widget for the message with a system message type. +/// {@endtemplate} +class StreamSystemMessage extends StatelessWidget { + /// Constructor for creating a [StreamSystemMessage] + const StreamSystemMessage({ Key? key, required this.message, this.onMessageTap, diff --git a/packages/stream_chat_flutter/lib/src/theme/avatar_theme.dart b/packages/stream_chat_flutter/lib/src/theme/avatar_theme.dart index 738fa0de..eb2d79bf 100644 --- a/packages/stream_chat_flutter/lib/src/theme/avatar_theme.dart +++ b/packages/stream_chat_flutter/lib/src/theme/avatar_theme.dart @@ -1,11 +1,17 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; +/// {@macro avatar_theme_data} +@Deprecated("Use 'StreamAvatarThemeData' instead") +typedef AvatarThemeData = StreamAvatarThemeData; + +/// {@template avatar_theme_data} /// A style that overrides the default appearance of various avatar widgets. +/// {@endtemplate} // ignore: prefer-match-file-name -class AvatarThemeData with Diagnosticable { - /// Creates an [AvatarThemeData]. - const AvatarThemeData({ +class StreamAvatarThemeData with Diagnosticable { + /// Creates an [StreamAvatarThemeData]. + const StreamAvatarThemeData({ BoxConstraints? constraints, BorderRadius? borderRadius, }) : _constraints = constraints, @@ -25,12 +31,12 @@ class AvatarThemeData with Diagnosticable { /// Get border radius BorderRadius get borderRadius => _borderRadius ?? BorderRadius.circular(20); - /// Copy this [AvatarThemeData] to another. - AvatarThemeData copyWith({ + /// Copy this [StreamAvatarThemeData] to another. + StreamAvatarThemeData copyWith({ BoxConstraints? constraints, BorderRadius? borderRadius, }) => - AvatarThemeData( + StreamAvatarThemeData( constraints: constraints ?? _constraints, borderRadius: borderRadius ?? _borderRadius, ); @@ -38,12 +44,12 @@ class AvatarThemeData with Diagnosticable { /// Linearly interpolate between two [UserAvatar] themes. /// /// All the properties must be non-null. - AvatarThemeData lerp( - AvatarThemeData a, - AvatarThemeData b, + StreamAvatarThemeData lerp( + StreamAvatarThemeData a, + StreamAvatarThemeData b, double t, ) => - AvatarThemeData( + StreamAvatarThemeData( borderRadius: BorderRadius.lerp(a.borderRadius, b.borderRadius, t), constraints: BoxConstraints.lerp(a.constraints, b.constraints, t), ); @@ -51,7 +57,7 @@ class AvatarThemeData with Diagnosticable { @override bool operator ==(Object other) => identical(this, other) || - other is AvatarThemeData && + other is StreamAvatarThemeData && runtimeType == other.runtimeType && _constraints == other._constraints && _borderRadius == other._borderRadius; @@ -59,8 +65,8 @@ class AvatarThemeData with Diagnosticable { @override int get hashCode => _constraints.hashCode ^ _borderRadius.hashCode; - /// Merges one [AvatarThemeData] with the another - AvatarThemeData merge(AvatarThemeData? other) { + /// Merges one [StreamAvatarThemeData] with the another + StreamAvatarThemeData merge(StreamAvatarThemeData? other) { if (other == null) return this; return copyWith( constraints: other._constraints, diff --git a/packages/stream_chat_flutter/lib/src/theme/channel_header_theme.dart b/packages/stream_chat_flutter/lib/src/theme/channel_header_theme.dart index 63e208e5..aa988c0f 100644 --- a/packages/stream_chat_flutter/lib/src/theme/channel_header_theme.dart +++ b/packages/stream_chat_flutter/lib/src/theme/channel_header_theme.dart @@ -4,27 +4,33 @@ import 'package:stream_chat_flutter/src/stream_chat_theme.dart'; import 'package:stream_chat_flutter/src/theme/avatar_theme.dart'; import 'package:stream_chat_flutter/src/theme/themes.dart'; +/// {@macro channel_header_theme} +@Deprecated("Use 'StreamChannelHeaderTheme' instead") +typedef ChannelHeaderTheme = StreamChannelHeaderTheme; + +/// {@template channel_header_theme} /// Overrides the default style of [ChannelHeader] descendants. /// /// See also: /// -/// * [ChannelHeaderThemeData], which is used to configure this theme. -class ChannelHeaderTheme extends InheritedTheme { - /// Creates a [ChannelHeaderTheme]. +/// * [StreamChannelHeaderThemeData], which is used to configure this theme. +/// {@endtemplate} +class StreamChannelHeaderTheme extends InheritedTheme { + /// Creates a [StreamChannelHeaderTheme]. /// /// The [data] parameter must not be null. - const ChannelHeaderTheme({ + const StreamChannelHeaderTheme({ Key? key, required this.data, required Widget child, }) : super(key: key, child: child); /// The configuration of this theme. - final ChannelHeaderThemeData data; + final StreamChannelHeaderThemeData data; /// The closest instance of this class that encloses the given context. /// - /// If there is no enclosing [ChannelHeaderTheme] widget, then + /// If there is no enclosing [StreamChannelHeaderTheme] widget, then /// [StreamChatThemeData.channelTheme.channelHeaderTheme] is used. /// /// Typical usage is as follows: @@ -32,34 +38,40 @@ class ChannelHeaderTheme extends InheritedTheme { /// ```dart /// final theme = ChannelHeaderTheme.of(context); /// ``` - static ChannelHeaderThemeData of(BuildContext context) { + static StreamChannelHeaderThemeData of(BuildContext context) { final channelHeaderTheme = - context.dependOnInheritedWidgetOfExactType(); + context.dependOnInheritedWidgetOfExactType(); return channelHeaderTheme?.data ?? StreamChatTheme.of(context).channelHeaderTheme; } @override Widget wrap(BuildContext context, Widget child) => - ChannelHeaderTheme(data: data, child: child); + StreamChannelHeaderTheme(data: data, child: child); @override - bool updateShouldNotify(ChannelHeaderTheme oldWidget) => + bool updateShouldNotify(StreamChannelHeaderTheme oldWidget) => data != oldWidget.data; } +/// {@macro channel_header_theme_data} +@Deprecated("Use 'StreamChannelHeaderThemeData' instead") +typedef ChannelHeaderThemeData = StreamChannelHeaderThemeData; + +/// {@template channel_header_theme_data} /// A style that overrides the default appearance of [ChannelHeader]s when used -/// with [ChannelHeaderTheme] or with the overall [StreamChatTheme]'s +/// with [StreamChannelHeaderTheme] or with the overall [StreamChatTheme]'s /// [StreamChatThemeData.channelHeaderTheme]. /// /// See also: /// -/// * [ChannelHeaderTheme], the theme which is configured with this class. +/// * [StreamChannelHeaderTheme], the theme which is configured with this class. /// * [StreamChatThemeData.channelHeaderTheme], which can be used to override /// the default style for [ChannelHeader]s below the overall [StreamChatTheme]. -class ChannelHeaderThemeData with Diagnosticable { - /// Creates a [ChannelHeaderThemeData] - const ChannelHeaderThemeData({ +/// {@endtemplate} +class StreamChannelHeaderThemeData with Diagnosticable { + /// Creates a [StreamChannelHeaderThemeData] + const StreamChannelHeaderThemeData({ this.titleStyle, this.subtitleStyle, this.avatarTheme, @@ -73,43 +85,43 @@ class ChannelHeaderThemeData with Diagnosticable { final TextStyle? subtitleStyle; /// Theme for avatar - final AvatarThemeData? avatarTheme; + final StreamAvatarThemeData? avatarTheme; - /// Color for [ChannelHeaderThemeData] + /// Color for [StreamChannelHeaderThemeData] final Color? color; /// Copy with theme - ChannelHeaderThemeData copyWith({ + StreamChannelHeaderThemeData copyWith({ TextStyle? titleStyle, TextStyle? subtitleStyle, - AvatarThemeData? avatarTheme, + StreamAvatarThemeData? avatarTheme, Color? color, }) => - ChannelHeaderThemeData( + StreamChannelHeaderThemeData( titleStyle: titleStyle ?? this.titleStyle, subtitleStyle: subtitleStyle ?? this.subtitleStyle, avatarTheme: avatarTheme ?? this.avatarTheme, color: color ?? this.color, ); - /// Linearly interpolate between two [ChannelHeaderThemeData]. + /// Linearly interpolate between two [StreamChannelHeaderThemeData]. /// /// All the properties must be non-null. - ChannelHeaderThemeData lerp( - ChannelHeaderThemeData a, - ChannelHeaderThemeData b, + StreamChannelHeaderThemeData lerp( + StreamChannelHeaderThemeData a, + StreamChannelHeaderThemeData b, double t, ) => - ChannelHeaderThemeData( + StreamChannelHeaderThemeData( titleStyle: TextStyle.lerp(a.titleStyle, b.titleStyle, t), subtitleStyle: TextStyle.lerp(a.subtitleStyle, b.subtitleStyle, t), - avatarTheme: - const AvatarThemeData().lerp(a.avatarTheme!, b.avatarTheme!, t), + avatarTheme: const StreamAvatarThemeData() + .lerp(a.avatarTheme!, b.avatarTheme!, t), color: Color.lerp(a.color, b.color, t), ); - /// Merge with other [ChannelHeaderThemeData] - ChannelHeaderThemeData merge(ChannelHeaderThemeData? other) { + /// Merge with other [StreamChannelHeaderThemeData] + StreamChannelHeaderThemeData merge(StreamChannelHeaderThemeData? other) { if (other == null) return this; return copyWith( titleStyle: titleStyle?.merge(other.titleStyle) ?? other.titleStyle, @@ -123,7 +135,7 @@ class ChannelHeaderThemeData with Diagnosticable { @override bool operator ==(Object other) => identical(this, other) || - other is ChannelHeaderThemeData && + other is StreamChannelHeaderThemeData && runtimeType == other.runtimeType && titleStyle == other.titleStyle && subtitleStyle == other.subtitleStyle && diff --git a/packages/stream_chat_flutter/lib/src/theme/channel_list_header_theme.dart b/packages/stream_chat_flutter/lib/src/theme/channel_list_header_theme.dart index 3846232e..7cff2b90 100644 --- a/packages/stream_chat_flutter/lib/src/theme/channel_list_header_theme.dart +++ b/packages/stream_chat_flutter/lib/src/theme/channel_list_header_theme.dart @@ -3,27 +3,33 @@ import 'package:flutter/material.dart'; import 'package:stream_chat_flutter/src/stream_chat_theme.dart'; import 'package:stream_chat_flutter/src/theme/avatar_theme.dart'; +/// {@macro channel_list_header_theme} +@Deprecated("Use 'StreamChannelListHeaderTheme' instead") +typedef ChannelListHeaderTheme = StreamChannelListHeaderTheme; + +/// {@template channel_list_header_theme} /// Overrides the default style of [ChannelListHeader] descendants. /// /// See also: /// -/// * [ChannelListHeaderThemeData], which is used to configure this theme. -class ChannelListHeaderTheme extends InheritedTheme { - /// Creates a [ChannelListHeaderTheme]. +/// * [StreamChannelListHeaderThemeData], which is used to configure this theme. +/// {@endtemplate} +class StreamChannelListHeaderTheme extends InheritedTheme { + /// Creates a [StreamChannelListHeaderTheme]. /// /// The [data] parameter must not be null. - const ChannelListHeaderTheme({ + const StreamChannelListHeaderTheme({ Key? key, required this.data, required Widget child, }) : super(key: key, child: child); /// The configuration of this theme. - final ChannelListHeaderThemeData data; + final StreamChannelListHeaderThemeData data; /// The closest instance of this class that encloses the given context. /// - /// If there is no enclosing [ChannelListHeaderTheme] widget, then + /// If there is no enclosing [StreamChannelListHeaderTheme] widget, then /// [StreamChatThemeData.channelListHeaderTheme] is used. /// /// Typical usage is as follows: @@ -31,26 +37,32 @@ class ChannelListHeaderTheme extends InheritedTheme { /// ```dart /// final theme = ChannelListHeaderTheme.of(context); /// ``` - static ChannelListHeaderThemeData of(BuildContext context) { - final channelListHeaderTheme = - context.dependOnInheritedWidgetOfExactType(); + static StreamChannelListHeaderThemeData of(BuildContext context) { + final channelListHeaderTheme = context + .dependOnInheritedWidgetOfExactType(); return channelListHeaderTheme?.data ?? StreamChatTheme.of(context).channelListHeaderTheme; } @override Widget wrap(BuildContext context, Widget child) => - ChannelListHeaderTheme(data: data, child: child); + StreamChannelListHeaderTheme(data: data, child: child); @override - bool updateShouldNotify(ChannelListHeaderTheme oldWidget) => + bool updateShouldNotify(StreamChannelListHeaderTheme oldWidget) => data != oldWidget.data; } +/// {@macro channel_list_header_theme_data} +@Deprecated("Use ''StreamChannelListHeaderThemeData' instead") +typedef ChannelListHeaderThemeData = StreamChannelListHeaderThemeData; + +/// {@template channel_list_header_theme_data} /// Theme dedicated to the [ChannelListHeader] -class ChannelListHeaderThemeData with Diagnosticable { - /// Returns a new [ChannelListHeaderThemeData] - const ChannelListHeaderThemeData({ +/// {@endtemplate} +class StreamChannelListHeaderThemeData with Diagnosticable { + /// Returns a new [StreamChannelListHeaderThemeData] + const StreamChannelListHeaderThemeData({ this.titleStyle, this.avatarTheme, this.color, @@ -60,39 +72,41 @@ class ChannelListHeaderThemeData with Diagnosticable { final TextStyle? titleStyle; /// Theme dedicated to the userAvatar - final AvatarThemeData? avatarTheme; + final StreamAvatarThemeData? avatarTheme; /// Background color of the appbar final Color? color; - /// Returns a new [ChannelListHeaderThemeData] replacing some of its + /// Returns a new [StreamChannelListHeaderThemeData] replacing some of its /// properties - ChannelListHeaderThemeData copyWith({ + StreamChannelListHeaderThemeData copyWith({ TextStyle? titleStyle, - AvatarThemeData? avatarTheme, + StreamAvatarThemeData? avatarTheme, Color? color, }) => - ChannelListHeaderThemeData( + StreamChannelListHeaderThemeData( titleStyle: titleStyle ?? this.titleStyle, avatarTheme: avatarTheme ?? this.avatarTheme, color: color ?? this.color, ); - /// Linearly interpolate from one [ChannelListHeaderThemeData] to another. - ChannelListHeaderThemeData lerp( - ChannelListHeaderThemeData a, - ChannelListHeaderThemeData b, + /// Linearly interpolate from one [StreamChannelListHeaderThemeData] to another. + StreamChannelListHeaderThemeData lerp( + StreamChannelListHeaderThemeData a, + StreamChannelListHeaderThemeData b, double t, ) => - ChannelListHeaderThemeData( - avatarTheme: - const AvatarThemeData().lerp(a.avatarTheme!, b.avatarTheme!, t), + StreamChannelListHeaderThemeData( + avatarTheme: const StreamAvatarThemeData() + .lerp(a.avatarTheme!, b.avatarTheme!, t), color: Color.lerp(a.color, b.color, t), titleStyle: TextStyle.lerp(a.titleStyle, b.titleStyle, t), ); - /// Merges [this] [ChannelListHeaderThemeData] with the [other] - ChannelListHeaderThemeData merge(ChannelListHeaderThemeData? other) { + /// Merges [this] [StreamChannelListHeaderThemeData] with the [other] + StreamChannelListHeaderThemeData merge( + StreamChannelListHeaderThemeData? other, + ) { if (other == null) return this; return copyWith( titleStyle: titleStyle?.merge(other.titleStyle) ?? other.titleStyle, @@ -104,7 +118,7 @@ class ChannelListHeaderThemeData with Diagnosticable { @override bool operator ==(Object other) => identical(this, other) || - other is ChannelListHeaderThemeData && + other is StreamChannelListHeaderThemeData && runtimeType == other.runtimeType && titleStyle == other.titleStyle && avatarTheme == other.avatarTheme && diff --git a/packages/stream_chat_flutter/lib/src/theme/channel_list_view_theme.dart b/packages/stream_chat_flutter/lib/src/theme/channel_list_view_theme.dart index d310e2bc..4d6bd7d0 100644 --- a/packages/stream_chat_flutter/lib/src/theme/channel_list_view_theme.dart +++ b/packages/stream_chat_flutter/lib/src/theme/channel_list_view_theme.dart @@ -2,27 +2,33 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/widgets.dart'; import 'package:stream_chat_flutter/src/stream_chat_theme.dart'; +/// {@macro channel_list_view_theme} +@Deprecated("Use 'StreamChannelListViewTheme' instead") +typedef ChannelListViewTheme = StreamChannelListViewTheme; + +/// {@template channel_list_view_theme} /// Overrides the default style of [ChannelListView] descendants. /// /// See also: /// -/// * [ChannelListViewThemeData], which is used to configure this theme. -class ChannelListViewTheme extends InheritedTheme { - /// Creates a [ChannelListViewTheme]. +/// * [StreamChannelListViewThemeData], which is used to configure this theme. +/// {@endtemplate} +class StreamChannelListViewTheme extends InheritedTheme { + /// Creates a [StreamChannelListViewTheme]. /// /// The [data] parameter must not be null. - const ChannelListViewTheme({ + const StreamChannelListViewTheme({ Key? key, required this.data, required Widget child, }) : super(key: key, child: child); /// The configuration of this theme. - final ChannelListViewThemeData data; + final StreamChannelListViewThemeData data; /// The closest instance of this class that encloses the given context. /// - /// If there is no enclosing [ChannelListViewTheme] widget, then + /// If there is no enclosing [StreamChannelListViewTheme] widget, then /// [StreamChatThemeData.channelListViewTheme] is used. /// /// Typical usage is as follows: @@ -30,63 +36,69 @@ class ChannelListViewTheme extends InheritedTheme { /// ```dart /// ChannelListViewTheme theme = ChannelListViewTheme.of(context); /// ``` - static ChannelListViewThemeData of(BuildContext context) { - final channelListViewTheme = - context.dependOnInheritedWidgetOfExactType(); + static StreamChannelListViewThemeData of(BuildContext context) { + final channelListViewTheme = context + .dependOnInheritedWidgetOfExactType(); return channelListViewTheme?.data ?? StreamChatTheme.of(context).channelListViewTheme; } @override Widget wrap(BuildContext context, Widget child) => - ChannelListViewTheme(data: data, child: child); + StreamChannelListViewTheme(data: data, child: child); @override - bool updateShouldNotify(ChannelListViewTheme oldWidget) => + bool updateShouldNotify(StreamChannelListViewTheme oldWidget) => data != oldWidget.data; } +/// {@macro channel_list_view_theme_data} +@Deprecated("Use 'StreamChannelListViewThemeData' instead") +typedef ChannelListViewThemeData = StreamChannelListViewThemeData; + +/// {@template channel_list_view_theme_data} /// A style that overrides the default appearance of [ChannelListView]s when -/// used with [ChannelListViewTheme] or with the overall [StreamChatTheme]'s +/// used with [StreamChannelListViewTheme] or with the overall [StreamChatTheme]'s /// [StreamChatThemeData.channelListViewTheme]. /// /// See also: /// -/// * [ChannelListViewTheme], the theme which is configured with this class. +/// * [StreamChannelListViewTheme], the theme which is configured with this class. /// * [StreamChatThemeData.channelListViewTheme], which can be used to override /// the default style for [ChannelListView]s below the overall /// [StreamChatTheme]. -class ChannelListViewThemeData with Diagnosticable { - /// Creates a [ChannelListViewThemeData]. - const ChannelListViewThemeData({ +/// {@endtemplate} +class StreamChannelListViewThemeData with Diagnosticable { + /// Creates a [StreamChannelListViewThemeData]. + const StreamChannelListViewThemeData({ this.backgroundColor, }); /// The color of the [ChannelListView] background. final Color? backgroundColor; - /// Copies this [ChannelListViewThemeData] to another. - ChannelListViewThemeData copyWith({ + /// Copies this [StreamChannelListViewThemeData] to another. + StreamChannelListViewThemeData copyWith({ Color? backgroundColor, }) => - ChannelListViewThemeData( + StreamChannelListViewThemeData( backgroundColor: backgroundColor ?? this.backgroundColor, ); - /// Linearly interpolate between two [ChannelListViewThemeData] themes. + /// Linearly interpolate between two [StreamChannelListViewThemeData] themes. /// /// All the properties must be non-null. - ChannelListViewThemeData lerp( - ChannelListViewThemeData a, - ChannelListViewThemeData b, + StreamChannelListViewThemeData lerp( + StreamChannelListViewThemeData a, + StreamChannelListViewThemeData b, double t, ) => - ChannelListViewThemeData( + StreamChannelListViewThemeData( backgroundColor: Color.lerp(a.backgroundColor, b.backgroundColor, t), ); - /// Merges one [ChannelListViewThemeData] with another. - ChannelListViewThemeData merge(ChannelListViewThemeData? other) { + /// Merges one [StreamChannelListViewThemeData] with another. + StreamChannelListViewThemeData merge(StreamChannelListViewThemeData? other) { if (other == null) return this; return copyWith( backgroundColor: other.backgroundColor, @@ -96,7 +108,7 @@ class ChannelListViewThemeData with Diagnosticable { @override bool operator ==(Object other) => identical(this, other) || - other is ChannelListViewThemeData && + other is StreamChannelListViewThemeData && runtimeType == other.runtimeType && backgroundColor == other.backgroundColor; diff --git a/packages/stream_chat_flutter/lib/src/theme/channel_preview_theme.dart b/packages/stream_chat_flutter/lib/src/theme/channel_preview_theme.dart index ff9ef70c..3df974b2 100644 --- a/packages/stream_chat_flutter/lib/src/theme/channel_preview_theme.dart +++ b/packages/stream_chat_flutter/lib/src/theme/channel_preview_theme.dart @@ -3,27 +3,33 @@ import 'package:flutter/material.dart'; import 'package:stream_chat_flutter/src/stream_chat_theme.dart'; import 'package:stream_chat_flutter/src/theme/avatar_theme.dart'; +/// {@macro channel_preview_theme} +@Deprecated("Use 'StreamChannelPreviewTheme' instead") +typedef ChannelPreviewTheme = StreamChannelPreviewTheme; + +/// {@template channel_preview_theme} /// Overrides the default style of [ChannelPreview] descendants. /// /// See also: /// -/// * [ChannelPreviewThemeData], which is used to configure this theme. -class ChannelPreviewTheme extends InheritedTheme { - /// Creates a [ChannelPreviewTheme]. +/// * [StreamChannelPreviewThemeData], which is used to configure this theme. +/// {@endtemplate} +class StreamChannelPreviewTheme extends InheritedTheme { + /// Creates a [StreamChannelPreviewTheme]. /// /// The [data] parameter must not be null. - const ChannelPreviewTheme({ + const StreamChannelPreviewTheme({ Key? key, required this.data, required Widget child, }) : super(key: key, child: child); /// The configuration of this theme. - final ChannelPreviewThemeData data; + final StreamChannelPreviewThemeData data; /// The closest instance of this class that encloses the given context. /// - /// If there is no enclosing [ChannelPreviewTheme] widget, then + /// If there is no enclosing [StreamChannelPreviewTheme] widget, then /// [StreamChatThemeData.channelPreviewTheme] is used. /// /// Typical usage is as follows: @@ -31,34 +37,40 @@ class ChannelPreviewTheme extends InheritedTheme { /// ```dart /// final theme = ChannelPreviewTheme.of(context); /// ``` - static ChannelPreviewThemeData of(BuildContext context) { + static StreamChannelPreviewThemeData of(BuildContext context) { final channelPreviewTheme = - context.dependOnInheritedWidgetOfExactType(); + context.dependOnInheritedWidgetOfExactType(); return channelPreviewTheme?.data ?? StreamChatTheme.of(context).channelPreviewTheme; } @override Widget wrap(BuildContext context, Widget child) => - ChannelPreviewTheme(data: data, child: child); + StreamChannelPreviewTheme(data: data, child: child); @override - bool updateShouldNotify(ChannelPreviewTheme oldWidget) => + bool updateShouldNotify(StreamChannelPreviewTheme oldWidget) => data != oldWidget.data; } +/// {@macro channel_preview_theme_data} +@Deprecated("Use 'StreamChannelPreviewThemeData' instead") +typedef ChannelPreviewThemeData = StreamChannelPreviewThemeData; + +/// {@template channel_preview_theme_data} /// A style that overrides the default appearance of [ChannelPreview]s when used -/// with [ChannelPreviewTheme] or with the overall [StreamChatTheme]'s +/// with [StreamChannelPreviewTheme] or with the overall [StreamChatTheme]'s /// [StreamChatThemeData.channelPreviewTheme]. /// /// See also: /// -/// * [ChannelPreviewTheme], the theme which is configured with this class. +/// * [StreamChannelPreviewTheme], the theme which is configured with this class. /// * [StreamChatThemeData.channelPreviewTheme], which can be used to override /// the default style for [ChannelHeader]s below the overall [StreamChatTheme]. -class ChannelPreviewThemeData with Diagnosticable { - /// Creates a [ChannelPreviewThemeData]. - const ChannelPreviewThemeData({ +/// {@endtemplate} +class StreamChannelPreviewThemeData with Diagnosticable { + /// Creates a [StreamChannelPreviewThemeData]. + const StreamChannelPreviewThemeData({ this.titleStyle, this.subtitleStyle, this.lastMessageAtStyle, @@ -77,7 +89,7 @@ class ChannelPreviewThemeData with Diagnosticable { final TextStyle? lastMessageAtStyle; /// Avatar theme - final AvatarThemeData? avatarTheme; + final StreamAvatarThemeData? avatarTheme; /// Unread counter color final Color? unreadCounterColor; @@ -86,15 +98,15 @@ class ChannelPreviewThemeData with Diagnosticable { final double? indicatorIconSize; /// Copy with theme - ChannelPreviewThemeData copyWith({ + StreamChannelPreviewThemeData copyWith({ TextStyle? titleStyle, TextStyle? subtitleStyle, TextStyle? lastMessageAtStyle, - AvatarThemeData? avatarTheme, + StreamAvatarThemeData? avatarTheme, Color? unreadCounterColor, double? indicatorIconSize, }) => - ChannelPreviewThemeData( + StreamChannelPreviewThemeData( titleStyle: titleStyle ?? this.titleStyle, subtitleStyle: subtitleStyle ?? this.subtitleStyle, lastMessageAtStyle: lastMessageAtStyle ?? this.lastMessageAtStyle, @@ -103,15 +115,15 @@ class ChannelPreviewThemeData with Diagnosticable { indicatorIconSize: indicatorIconSize ?? this.indicatorIconSize, ); - /// Linearly interpolate one [ChannelPreviewThemeData] to another. - ChannelPreviewThemeData lerp( - ChannelPreviewThemeData a, - ChannelPreviewThemeData b, + /// Linearly interpolate one [StreamChannelPreviewThemeData] to another. + StreamChannelPreviewThemeData lerp( + StreamChannelPreviewThemeData a, + StreamChannelPreviewThemeData b, double t, ) => - ChannelPreviewThemeData( - avatarTheme: - const AvatarThemeData().lerp(a.avatarTheme!, b.avatarTheme!, t), + StreamChannelPreviewThemeData( + avatarTheme: const StreamAvatarThemeData() + .lerp(a.avatarTheme!, b.avatarTheme!, t), indicatorIconSize: a.indicatorIconSize, lastMessageAtStyle: TextStyle.lerp(a.lastMessageAtStyle, b.lastMessageAtStyle, t), @@ -122,7 +134,7 @@ class ChannelPreviewThemeData with Diagnosticable { ); /// Merge with theme - ChannelPreviewThemeData merge(ChannelPreviewThemeData? other) { + StreamChannelPreviewThemeData merge(StreamChannelPreviewThemeData? other) { if (other == null) return this; return copyWith( titleStyle: titleStyle?.merge(other.titleStyle) ?? other.titleStyle, @@ -138,7 +150,7 @@ class ChannelPreviewThemeData with Diagnosticable { @override bool operator ==(Object other) => identical(this, other) || - other is ChannelPreviewThemeData && + other is StreamChannelPreviewThemeData && runtimeType == other.runtimeType && titleStyle == other.titleStyle && subtitleStyle == other.subtitleStyle && diff --git a/packages/stream_chat_flutter/lib/src/theme/color_theme.dart b/packages/stream_chat_flutter/lib/src/theme/color_theme.dart index b32c023f..e0068d59 100644 --- a/packages/stream_chat_flutter/lib/src/theme/color_theme.dart +++ b/packages/stream_chat_flutter/lib/src/theme/color_theme.dart @@ -1,9 +1,15 @@ import 'package:flutter/material.dart'; +/// {@macro color_theme} +@Deprecated("Use 'StreamColorTheme' instead") +typedef ColorTheme = StreamColorTheme; + +/// {@template color_theme} /// Theme that holds colors -class ColorTheme { +/// {@endtemplate} +class StreamColorTheme { /// Initialise with light theme - ColorTheme.light({ + StreamColorTheme.light({ this.textHighEmphasis = const Color(0xff000000), this.textLowEmphasis = const Color(0xff7a7a7a), this.disabled = const Color(0xffdbdbdb), @@ -55,7 +61,7 @@ class ColorTheme { }) : brightness = Brightness.light; /// Initialise with dark theme - ColorTheme.dark({ + StreamColorTheme.dark({ this.textHighEmphasis = const Color(0xffffffff), this.textLowEmphasis = const Color(0xff7a7a7a), this.disabled = const Color(0xff2d2f2f), @@ -169,7 +175,7 @@ class ColorTheme { final Brightness brightness; /// Copy with theme - ColorTheme copyWith({ + StreamColorTheme copyWith({ Brightness brightness = Brightness.light, Color? textHighEmphasis, Color? textLowEmphasis, @@ -192,7 +198,7 @@ class ColorTheme { Gradient? bgGradient, }) => brightness == Brightness.light - ? ColorTheme.light( + ? StreamColorTheme.light( textHighEmphasis: textHighEmphasis ?? this.textHighEmphasis, textLowEmphasis: textLowEmphasis ?? this.textLowEmphasis, disabled: disabled ?? this.disabled, @@ -213,7 +219,7 @@ class ColorTheme { overlayDark: overlayDark ?? this.overlayDark, bgGradient: bgGradient ?? this.bgGradient, ) - : ColorTheme.dark( + : StreamColorTheme.dark( textHighEmphasis: textHighEmphasis ?? this.textHighEmphasis, textLowEmphasis: textLowEmphasis ?? this.textLowEmphasis, disabled: disabled ?? this.disabled, @@ -236,7 +242,7 @@ class ColorTheme { ); /// Merge color theme - ColorTheme merge(ColorTheme? other) { + StreamColorTheme merge(StreamColorTheme? other) { if (other == null) return this; return copyWith( textHighEmphasis: other.textHighEmphasis, diff --git a/packages/stream_chat_flutter/lib/src/theme/gallery_footer_theme.dart b/packages/stream_chat_flutter/lib/src/theme/gallery_footer_theme.dart index a227b830..f68ceb45 100644 --- a/packages/stream_chat_flutter/lib/src/theme/gallery_footer_theme.dart +++ b/packages/stream_chat_flutter/lib/src/theme/gallery_footer_theme.dart @@ -2,27 +2,33 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/widgets.dart'; import 'package:stream_chat_flutter/src/stream_chat_theme.dart'; +/// {@macro gallery_footer_theme} +@Deprecated("Use 'StreamGalleryFooterTheme' instead") +typedef GalleryFooterTheme = StreamGalleryFooterTheme; + +/// {@template gallery_footer_theme} /// Overrides the default style of [GalleryFooter] descendants. /// /// See also: /// -/// * [GalleryFooterThemeData], which is used to configure this theme. -class GalleryFooterTheme extends InheritedTheme { - /// Creates an [GalleryFooterTheme]. +/// * [StreamGalleryFooterThemeData], which is used to configure this theme. +/// {@endtemplate} +class StreamGalleryFooterTheme extends InheritedTheme { + /// Creates an [StreamGalleryFooterTheme]. /// /// The [data] parameter must not be null. - const GalleryFooterTheme({ + const StreamGalleryFooterTheme({ Key? key, required this.data, required Widget child, }) : super(key: key, child: child); /// The configuration of this theme. - final GalleryFooterThemeData data; + final StreamGalleryFooterThemeData data; /// The closest instance of this class that encloses the given context. /// - /// If there is no enclosing [GalleryFooterTheme] widget, then + /// If there is no enclosing [StreamGalleryFooterTheme] widget, then /// [StreamChatThemeData.galleryFooterTheme] is used. /// /// Typical usage is as follows: @@ -30,34 +36,40 @@ class GalleryFooterTheme extends InheritedTheme { /// ```dart /// ImageFooterTheme theme = ImageFooterTheme.of(context); /// ``` - static GalleryFooterThemeData of(BuildContext context) { + static StreamGalleryFooterThemeData of(BuildContext context) { final imageFooterTheme = - context.dependOnInheritedWidgetOfExactType(); + context.dependOnInheritedWidgetOfExactType(); return imageFooterTheme?.data ?? StreamChatTheme.of(context).galleryFooterTheme; } @override Widget wrap(BuildContext context, Widget child) => - GalleryFooterTheme(data: data, child: child); + StreamGalleryFooterTheme(data: data, child: child); @override - bool updateShouldNotify(GalleryFooterTheme oldWidget) => + bool updateShouldNotify(StreamGalleryFooterTheme oldWidget) => data != oldWidget.data; } +/// {@macro gallery_footer_theme_data} +@Deprecated("Use 'StreamGalleryFooterThemeData' instead") +typedef GalleryFooterThemeData = StreamGalleryFooterThemeData; + +/// {@template gallery_footer_theme_data} /// A style that overrides the default appearance of [GalleryFooter]s when used -/// with [GalleryFooterTheme] or with the overall [StreamChatTheme]'s +/// with [StreamGalleryFooterTheme] or with the overall [StreamChatTheme]'s /// [StreamChatThemeData.galleryFooterTheme]. /// /// See also: /// -/// * [GalleryFooterTheme], the theme which is configured with this class. +/// * [StreamGalleryFooterTheme], the theme which is configured with this class. /// * [StreamChatThemeData.galleryFooterTheme], which can be used to override /// the default style for [GalleryFooter]s below the overall [StreamChatTheme]. -class GalleryFooterThemeData with Diagnosticable { - /// Creates an [GalleryFooterThemeData]. - const GalleryFooterThemeData({ +/// {@endtemplate} +class StreamGalleryFooterThemeData with Diagnosticable { + /// Creates an [StreamGalleryFooterThemeData]. + const StreamGalleryFooterThemeData({ this.backgroundColor, this.shareIconColor, this.titleTextStyle, @@ -108,8 +120,8 @@ class GalleryFooterThemeData with Diagnosticable { /// Defaults to [ColorTheme.textHighEmphasis]. final Color? bottomSheetCloseIconColor; - /// Copies this [GalleryFooterThemeData] to another. - GalleryFooterThemeData copyWith({ + /// Copies this [StreamGalleryFooterThemeData] to another. + StreamGalleryFooterThemeData copyWith({ Color? backgroundColor, Color? shareIconColor, TextStyle? titleTextStyle, @@ -119,7 +131,7 @@ class GalleryFooterThemeData with Diagnosticable { TextStyle? bottomSheetPhotosTextStyle, Color? bottomSheetCloseIconColor, }) => - GalleryFooterThemeData( + StreamGalleryFooterThemeData( backgroundColor: backgroundColor ?? this.backgroundColor, shareIconColor: shareIconColor ?? this.shareIconColor, titleTextStyle: titleTextStyle ?? this.titleTextStyle, @@ -137,12 +149,12 @@ class GalleryFooterThemeData with Diagnosticable { /// Linearly interpolate between two [GalleryFooter] themes. /// /// All the properties must be non-null. - GalleryFooterThemeData lerp( - GalleryFooterThemeData a, - GalleryFooterThemeData b, + StreamGalleryFooterThemeData lerp( + StreamGalleryFooterThemeData a, + StreamGalleryFooterThemeData b, double t, ) => - GalleryFooterThemeData( + StreamGalleryFooterThemeData( backgroundColor: Color.lerp(a.backgroundColor, b.backgroundColor, t), shareIconColor: Color.lerp(a.shareIconColor, b.shareIconColor, t), titleTextStyle: TextStyle.lerp(a.titleTextStyle, b.titleTextStyle, t), @@ -167,8 +179,8 @@ class GalleryFooterThemeData with Diagnosticable { ), ); - /// Merges one [GalleryFooterThemeData] with another. - GalleryFooterThemeData merge(GalleryFooterThemeData? other) { + /// Merges one [StreamGalleryFooterThemeData] with another. + StreamGalleryFooterThemeData merge(StreamGalleryFooterThemeData? other) { if (other == null) return this; return copyWith( backgroundColor: other.backgroundColor, @@ -185,7 +197,7 @@ class GalleryFooterThemeData with Diagnosticable { @override bool operator ==(Object other) => identical(this, other) || - other is GalleryFooterThemeData && + other is StreamGalleryFooterThemeData && runtimeType == other.runtimeType && backgroundColor == other.backgroundColor && shareIconColor == other.shareIconColor && diff --git a/packages/stream_chat_flutter/lib/src/theme/gallery_header_theme.dart b/packages/stream_chat_flutter/lib/src/theme/gallery_header_theme.dart index 23402c57..f03ebe9a 100644 --- a/packages/stream_chat_flutter/lib/src/theme/gallery_header_theme.dart +++ b/packages/stream_chat_flutter/lib/src/theme/gallery_header_theme.dart @@ -2,27 +2,33 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/widgets.dart'; import 'package:stream_chat_flutter/src/stream_chat_theme.dart'; +/// {@macro gallery_header_them} +@Deprecated("Use 'StreamGalleryHeaderTheme' instead") +typedef GalleryHeaderTheme = StreamGalleryHeaderTheme; + +/// {@template gallery_header_theme} /// Overrides the default style of [GalleryHeader] descendants. /// /// See also: /// -/// * [GalleryHeaderThemeData], which is used to configure this theme. -class GalleryHeaderTheme extends InheritedTheme { - /// Creates a [GalleryHeaderTheme]. +/// * [StreamGalleryHeaderThemeData], which is used to configure this theme. +/// {@endtemplate} +class StreamGalleryHeaderTheme extends InheritedTheme { + /// Creates a [StreamGalleryHeaderTheme]. /// /// The [data] parameter must not be null. - const GalleryHeaderTheme({ + const StreamGalleryHeaderTheme({ Key? key, required this.data, required Widget child, }) : super(key: key, child: child); /// The configuration of this theme. - final GalleryHeaderThemeData data; + final StreamGalleryHeaderThemeData data; /// The closest instance of this class that encloses the given context. /// - /// If there is no enclosing [GalleryHeaderTheme] widget, then + /// If there is no enclosing [StreamGalleryHeaderTheme] widget, then /// [StreamChatThemeData.galleryHeaderTheme] is used. /// /// Typical usage is as follows: @@ -30,34 +36,40 @@ class GalleryHeaderTheme extends InheritedTheme { /// ```dart /// ImageHeaderTheme theme = ImageHeaderTheme.of(context); /// ``` - static GalleryHeaderThemeData of(BuildContext context) { + static StreamGalleryHeaderThemeData of(BuildContext context) { final galleryHeaderTheme = - context.dependOnInheritedWidgetOfExactType(); + context.dependOnInheritedWidgetOfExactType(); return galleryHeaderTheme?.data ?? StreamChatTheme.of(context).galleryHeaderTheme; } @override Widget wrap(BuildContext context, Widget child) => - GalleryHeaderTheme(data: data, child: child); + StreamGalleryHeaderTheme(data: data, child: child); @override - bool updateShouldNotify(GalleryHeaderTheme oldWidget) => + bool updateShouldNotify(StreamGalleryHeaderTheme oldWidget) => data != oldWidget.data; } +/// {@macro gallery_header_theme_data} +@Deprecated("Use 'StreamGalleryHeaderThemeData' instead") +typedef GalleryHeaderThemeData = StreamGalleryHeaderThemeData; + +/// {@template gallery_header_theme_data} /// A style that overrides the default appearance of [GalleryHeader]s when used -/// with [GalleryHeaderTheme] or with the overall [StreamChatTheme]'s +/// with [StreamGalleryHeaderTheme] or with the overall [StreamChatTheme]'s /// [StreamChatThemeData.galleryHeaderTheme]. /// /// See also: /// -/// * [GalleryHeaderTheme], the theme which is configured with this class. +/// * [StreamGalleryHeaderTheme], the theme which is configured with this class. /// * [StreamChatThemeData.galleryHeaderTheme], which can be used to override /// the default style for [GalleryHeader]s below the overall [StreamChatTheme]. -class GalleryHeaderThemeData with Diagnosticable { - /// Creates an [GalleryHeaderThemeData]. - const GalleryHeaderThemeData({ +/// {@endtemplate} +class StreamGalleryHeaderThemeData with Diagnosticable { + /// Creates an [StreamGalleryHeaderThemeData]. + const StreamGalleryHeaderThemeData({ this.closeButtonColor, this.backgroundColor, this.iconMenuPointColor, @@ -92,8 +104,8 @@ class GalleryHeaderThemeData with Diagnosticable { /// final Color? bottomSheetBarrierColor; - /// Copies this [GalleryHeaderThemeData] to another. - GalleryHeaderThemeData copyWith({ + /// Copies this [StreamGalleryHeaderThemeData] to another. + StreamGalleryHeaderThemeData copyWith({ Color? closeButtonColor, Color? backgroundColor, Color? iconMenuPointColor, @@ -101,7 +113,7 @@ class GalleryHeaderThemeData with Diagnosticable { TextStyle? subtitleTextStyle, Color? bottomSheetBarrierColor, }) => - GalleryHeaderThemeData( + StreamGalleryHeaderThemeData( closeButtonColor: closeButtonColor ?? this.closeButtonColor, backgroundColor: backgroundColor ?? this.backgroundColor, iconMenuPointColor: iconMenuPointColor ?? this.iconMenuPointColor, @@ -114,12 +126,12 @@ class GalleryHeaderThemeData with Diagnosticable { /// Linearly interpolate between two [GalleryHeader] themes. /// /// All the properties must be non-null. - GalleryHeaderThemeData lerp( - GalleryHeaderThemeData a, - GalleryHeaderThemeData b, + StreamGalleryHeaderThemeData lerp( + StreamGalleryHeaderThemeData a, + StreamGalleryHeaderThemeData b, double t, ) => - GalleryHeaderThemeData( + StreamGalleryHeaderThemeData( closeButtonColor: Color.lerp(a.closeButtonColor, b.closeButtonColor, t), backgroundColor: Color.lerp(a.backgroundColor, b.backgroundColor, t), iconMenuPointColor: @@ -131,8 +143,8 @@ class GalleryHeaderThemeData with Diagnosticable { Color.lerp(a.bottomSheetBarrierColor, b.bottomSheetBarrierColor, t), ); - /// Merges one [GalleryHeaderThemeData] with the another - GalleryHeaderThemeData merge(GalleryHeaderThemeData? other) { + /// Merges one [StreamGalleryHeaderThemeData] with the another + StreamGalleryHeaderThemeData merge(StreamGalleryHeaderThemeData? other) { if (other == null) return this; return copyWith( closeButtonColor: other.closeButtonColor, @@ -147,7 +159,7 @@ class GalleryHeaderThemeData with Diagnosticable { @override bool operator ==(Object other) => identical(this, other) || - other is GalleryHeaderThemeData && + other is StreamGalleryHeaderThemeData && runtimeType == other.runtimeType && closeButtonColor == other.closeButtonColor && backgroundColor == other.backgroundColor && diff --git a/packages/stream_chat_flutter/lib/src/theme/message_input_theme.dart b/packages/stream_chat_flutter/lib/src/theme/message_input_theme.dart index 81047d77..c3874ef6 100644 --- a/packages/stream_chat_flutter/lib/src/theme/message_input_theme.dart +++ b/packages/stream_chat_flutter/lib/src/theme/message_input_theme.dart @@ -5,27 +5,33 @@ import 'package:flutter/material.dart'; import 'package:stream_chat_flutter/src/extension.dart'; import 'package:stream_chat_flutter/src/stream_chat_theme.dart'; +/// {@macro message_input_theme} +@Deprecated("Use 'StreamMessageInputTheme' instead") +typedef MessageInputTheme = StreamMessageInputTheme; + +/// {@template message_input_theme} /// Overrides the default style of [MessageInput] descendants. /// /// See also: /// -/// * [MessageInputThemeData], which is used to configure this theme. -class MessageInputTheme extends InheritedTheme { - /// Creates a [MessageInputTheme]. +/// * [StreamMessageInputThemeData], which is used to configure this theme. +/// {@endtemplate} +class StreamMessageInputTheme extends InheritedTheme { + /// Creates a [StreamMessageInputTheme]. /// /// The [data] parameter must not be null. - const MessageInputTheme({ + const StreamMessageInputTheme({ Key? key, required this.data, required Widget child, }) : super(key: key, child: child); /// The configuration of this theme. - final MessageInputThemeData data; + final StreamMessageInputThemeData data; /// The closest instance of this class that encloses the given context. /// - /// If there is no enclosing [MessageInputTheme] widget, then + /// If there is no enclosing [StreamMessageInputTheme] widget, then /// [StreamChatThemeData.messageInputTheme] is used. /// /// Typical usage is as follows: @@ -33,28 +39,34 @@ class MessageInputTheme extends InheritedTheme { /// ```dart /// final theme = MessageInputTheme.of(context); /// ``` - static MessageInputThemeData of(BuildContext context) { + static StreamMessageInputThemeData of(BuildContext context) { final messageInputTheme = - context.dependOnInheritedWidgetOfExactType(); + context.dependOnInheritedWidgetOfExactType(); return messageInputTheme?.data ?? StreamChatTheme.of(context).messageInputTheme; } @override Widget wrap(BuildContext context, Widget child) => - MessageInputTheme(data: data, child: child); + StreamMessageInputTheme(data: data, child: child); @override - bool updateShouldNotify(MessageInputTheme oldWidget) => + bool updateShouldNotify(StreamMessageInputTheme oldWidget) => data != oldWidget.data; } +/// {@macro message_input_theme_data} +@Deprecated("Use 'StreamMessageInputThemeData' instead") +typedef MessageInputThemeData = StreamMessageInputThemeData; + +/// {@template message_input_theme_data} /// A style that overrides the default appearance of [MessageInput] widgets -/// when used with [MessageInputTheme] or with the overall [StreamChatTheme]'s +/// when used with [StreamMessageInputTheme] or with the overall [StreamChatTheme]'s /// [StreamChatThemeData.messageInputTheme]. -class MessageInputThemeData with Diagnosticable { - /// Creates a [MessageInputThemeData]. - const MessageInputThemeData({ +/// {@endtemplate} +class StreamMessageInputThemeData with Diagnosticable { + /// Creates a [StreamMessageInputThemeData]. + const StreamMessageInputThemeData({ this.sendAnimationDuration, this.actionButtonColor, this.sendButtonColor, @@ -121,8 +133,8 @@ class MessageInputThemeData with Diagnosticable { /// Shadow for the [MessageInput] widget final BoxShadow? shadow; - /// Returns a new [MessageInputThemeData] replacing some of its properties - MessageInputThemeData copyWith({ + /// Returns a new [StreamMessageInputThemeData] replacing some of its properties + StreamMessageInputThemeData copyWith({ Duration? sendAnimationDuration, Color? inputBackgroundColor, Color? actionButtonColor, @@ -140,7 +152,7 @@ class MessageInputThemeData with Diagnosticable { double? elevation, BoxShadow? shadow, }) => - MessageInputThemeData( + StreamMessageInputThemeData( sendAnimationDuration: sendAnimationDuration ?? this.sendAnimationDuration, inputBackgroundColor: inputBackgroundColor ?? this.inputBackgroundColor, @@ -161,13 +173,13 @@ class MessageInputThemeData with Diagnosticable { shadow: shadow ?? this.shadow, ); - /// Linearly interpolate from one [MessageInputThemeData] to another. - MessageInputThemeData lerp( - MessageInputThemeData a, - MessageInputThemeData b, + /// Linearly interpolate from one [StreamMessageInputThemeData] to another. + StreamMessageInputThemeData lerp( + StreamMessageInputThemeData a, + StreamMessageInputThemeData b, double t, ) => - MessageInputThemeData( + StreamMessageInputThemeData( actionButtonColor: Color.lerp(a.actionButtonColor, b.actionButtonColor, t), actionButtonIdleColor: @@ -194,8 +206,8 @@ class MessageInputThemeData with Diagnosticable { shadow: BoxShadow.lerp(a.shadow, b.shadow, t), ); - /// Merges [this] [MessageInputThemeData] with the [other] - MessageInputThemeData merge(MessageInputThemeData? other) { + /// Merges [this] [StreamMessageInputThemeData] with the [other] + StreamMessageInputThemeData merge(StreamMessageInputThemeData? other) { if (other == null) return this; return copyWith( sendAnimationDuration: other.sendAnimationDuration, @@ -222,7 +234,7 @@ class MessageInputThemeData with Diagnosticable { @override bool operator ==(Object other) => identical(this, other) || - other is MessageInputThemeData && + other is StreamMessageInputThemeData && runtimeType == other.runtimeType && sendAnimationDuration == other.sendAnimationDuration && sendButtonColor == other.sendButtonColor && diff --git a/packages/stream_chat_flutter/lib/src/theme/message_list_view_theme.dart b/packages/stream_chat_flutter/lib/src/theme/message_list_view_theme.dart index e4857a79..882d4708 100644 --- a/packages/stream_chat_flutter/lib/src/theme/message_list_view_theme.dart +++ b/packages/stream_chat_flutter/lib/src/theme/message_list_view_theme.dart @@ -2,27 +2,33 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/widgets.dart'; import 'package:stream_chat_flutter/src/stream_chat_theme.dart'; +/// {@macro message_list_view_theme} +@Deprecated("Use 'StreamMessageListViewTheme' instead") +typedef MessageListViewTheme = StreamMessageListViewTheme; + +/// {@template message_list_view_theme} /// Overrides the default style of [MessageListView] descendants. /// /// See also: /// -/// * [MessageListViewThemeData], which is used to configure this theme. -class MessageListViewTheme extends InheritedTheme { - /// Creates a [MessageListViewTheme]. +/// * [StreamMessageListViewThemeData], which is used to configure this theme. +/// {@endtemplate} +class StreamMessageListViewTheme extends InheritedTheme { + /// Creates a [StreamMessageListViewTheme]. /// /// The [data] parameter must not be null. - const MessageListViewTheme({ + const StreamMessageListViewTheme({ Key? key, required this.data, required Widget child, }) : super(key: key, child: child); /// The configuration of this theme. - final MessageListViewThemeData data; + final StreamMessageListViewThemeData data; /// The closest instance of this class that encloses the given context. /// - /// If there is no enclosing [MessageListViewTheme] widget, then + /// If there is no enclosing [StreamMessageListViewTheme] widget, then /// [StreamChatThemeData.messageListViewTheme] is used. /// /// Typical usage is as follows: @@ -30,35 +36,41 @@ class MessageListViewTheme extends InheritedTheme { /// ```dart /// MessageListViewTheme theme = MessageListViewTheme.of(context); /// ``` - static MessageListViewThemeData of(BuildContext context) { - final messageListViewTheme = - context.dependOnInheritedWidgetOfExactType(); + static StreamMessageListViewThemeData of(BuildContext context) { + final messageListViewTheme = context + .dependOnInheritedWidgetOfExactType(); return messageListViewTheme?.data ?? StreamChatTheme.of(context).messageListViewTheme; } @override Widget wrap(BuildContext context, Widget child) => - MessageListViewTheme(data: data, child: child); + StreamMessageListViewTheme(data: data, child: child); @override - bool updateShouldNotify(MessageListViewTheme oldWidget) => + bool updateShouldNotify(StreamMessageListViewTheme oldWidget) => data != oldWidget.data; } +/// {@macro message_list_view_theme_data} +@Deprecated("Use 'StreamMessageListViewThemeData' instead") +typedef MessageListViewThemeData = StreamMessageListViewThemeData; + +/// {@template message_list_view_theme_data} /// A style that overrides the default appearance of [MessageListView]s when -/// used with [MessageListViewTheme] or with the overall [StreamChatTheme]'s +/// used with [StreamMessageListViewTheme] or with the overall [StreamChatTheme]'s /// [StreamChatThemeData.messageListViewTheme]. /// /// See also: /// -/// * [MessageListViewTheme], the theme which is configured with this class. +/// * [StreamMessageListViewTheme], the theme which is configured with this class. /// * [StreamChatThemeData.messageListViewTheme], which can be used to override /// the default style for [MessageListView]s below the overall /// [StreamChatTheme]. -class MessageListViewThemeData with Diagnosticable { - /// Creates a [MessageListViewThemeData]. - const MessageListViewThemeData({ +/// {@endtemplate} +class StreamMessageListViewThemeData with Diagnosticable { + /// Creates a [StreamMessageListViewThemeData]. + const StreamMessageListViewThemeData({ this.backgroundColor, this.backgroundImage, }); @@ -69,12 +81,12 @@ class MessageListViewThemeData with Diagnosticable { /// The image of the [MessageListView] background. final DecorationImage? backgroundImage; - /// Copies this [MessageListViewThemeData] to another. - MessageListViewThemeData copyWith({ + /// Copies this [StreamMessageListViewThemeData] to another. + StreamMessageListViewThemeData copyWith({ Color? backgroundColor, DecorationImage? backgroundImage, }) => - MessageListViewThemeData( + StreamMessageListViewThemeData( backgroundColor: backgroundColor ?? this.backgroundColor, backgroundImage: backgroundImage ?? this.backgroundImage, ); @@ -82,18 +94,18 @@ class MessageListViewThemeData with Diagnosticable { /// Linearly interpolate between two [MessageListView] themes. /// /// All the properties must be non-null. - MessageListViewThemeData lerp( - MessageListViewThemeData a, - MessageListViewThemeData b, + StreamMessageListViewThemeData lerp( + StreamMessageListViewThemeData a, + StreamMessageListViewThemeData b, double t, ) => - MessageListViewThemeData( + StreamMessageListViewThemeData( backgroundColor: Color.lerp(a.backgroundColor, b.backgroundColor, t), backgroundImage: t < 0.5 ? a.backgroundImage : b.backgroundImage, ); - /// Merges one [MessageListViewThemeData] with another. - MessageListViewThemeData merge(MessageListViewThemeData? other) { + /// Merges one [StreamMessageListViewThemeData] with another. + StreamMessageListViewThemeData merge(StreamMessageListViewThemeData? other) { if (other == null) return this; return copyWith( backgroundColor: other.backgroundColor, @@ -104,7 +116,7 @@ class MessageListViewThemeData with Diagnosticable { @override bool operator ==(Object other) => identical(this, other) || - other is MessageListViewThemeData && + other is StreamMessageListViewThemeData && runtimeType == other.runtimeType && backgroundColor == other.backgroundColor && backgroundImage == other.backgroundImage; diff --git a/packages/stream_chat_flutter/lib/src/theme/message_search_list_view_theme.dart b/packages/stream_chat_flutter/lib/src/theme/message_search_list_view_theme.dart index 670e05e7..83ef032a 100644 --- a/packages/stream_chat_flutter/lib/src/theme/message_search_list_view_theme.dart +++ b/packages/stream_chat_flutter/lib/src/theme/message_search_list_view_theme.dart @@ -2,23 +2,29 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/widgets.dart'; import 'package:stream_chat_flutter/src/stream_chat_theme.dart'; +/// {@macro message_search_list_view_theme} +@Deprecated("Use 'StreamMessageSearchListViewTheme' instead") +typedef MessageSearchListViewTheme = StreamMessageSearchListViewTheme; + +/// {@template message_search_list_view_theme} /// Overrides the default style of [MessageSearchListView] descendants. /// /// See also: /// /// * [UserListViewThemeData], which is used to configure this theme. -class MessageSearchListViewTheme extends InheritedTheme { +/// {@endtemplate} +class StreamMessageSearchListViewTheme extends InheritedTheme { /// Creates a [UserListViewTheme]. /// /// The [data] parameter must not be null. - const MessageSearchListViewTheme({ + const StreamMessageSearchListViewTheme({ Key? key, required this.data, required Widget child, }) : super(key: key, child: child); /// The configuration of this theme. - final MessageSearchListViewThemeData data; + final StreamMessageSearchListViewThemeData data; /// The closest instance of this class that encloses the given context. /// @@ -30,64 +36,72 @@ class MessageSearchListViewTheme extends InheritedTheme { /// ```dart /// MessageSearchListViewTheme theme = MessageSearchListViewTheme.of(context); /// ``` - static MessageSearchListViewThemeData of(BuildContext context) { + static StreamMessageSearchListViewThemeData of(BuildContext context) { final messageSearchListViewTheme = context - .dependOnInheritedWidgetOfExactType(); + .dependOnInheritedWidgetOfExactType(); return messageSearchListViewTheme?.data ?? StreamChatTheme.of(context).messageSearchListViewTheme; } @override Widget wrap(BuildContext context, Widget child) => - MessageSearchListViewTheme(data: data, child: child); + StreamMessageSearchListViewTheme(data: data, child: child); @override - bool updateShouldNotify(MessageSearchListViewTheme oldWidget) => + bool updateShouldNotify(StreamMessageSearchListViewTheme oldWidget) => data != oldWidget.data; } +/// {@macro message_search_list_view_theme_data} +@Deprecated("Use 'StreamMessageSearchListViewThemeData' instead") +typedef MessageSearchListViewThemeData = StreamMessageSearchListViewThemeData; + +/// {@macro message_search_list_view_theme_data} /// A style that overrides the default appearance of [MessageSearchListView]s /// when used with [MessageSearchListView] or with the overall /// [StreamChatTheme]'s [StreamChatThemeData.messageSearchListViewTheme]. /// /// See also: /// -/// * [MessageSearchListViewTheme], the theme which is configured with this +/// * [StreamMessageSearchListViewTheme], the theme which is configured with this /// class. /// * [StreamChatThemeData.messageSearchListViewTheme], which can be used to /// override the default style for [UserListView]s below the overall /// [StreamChatTheme]. -class MessageSearchListViewThemeData with Diagnosticable { - /// Creates a [MessageSearchListViewThemeData]. - const MessageSearchListViewThemeData({ +/// {@endtemplate} +class StreamMessageSearchListViewThemeData with Diagnosticable { + /// Creates a [StreamMessageSearchListViewThemeData]. + const StreamMessageSearchListViewThemeData({ this.backgroundColor, }); /// The color of the [MessageSearchListView] background. final Color? backgroundColor; - /// Copies this [MessageSearchListViewThemeData] to another. - MessageSearchListViewThemeData copyWith({ + /// Copies this [StreamMessageSearchListViewThemeData] to another. + StreamMessageSearchListViewThemeData copyWith({ Color? backgroundColor, }) => - MessageSearchListViewThemeData( + StreamMessageSearchListViewThemeData( backgroundColor: backgroundColor ?? this.backgroundColor, ); /// Linearly interpolate between two [UserListViewThemeData] themes. /// /// All the properties must be non-null. - MessageSearchListViewThemeData lerp( - MessageSearchListViewThemeData a, - MessageSearchListViewThemeData b, + StreamMessageSearchListViewThemeData lerp( + StreamMessageSearchListViewThemeData a, + StreamMessageSearchListViewThemeData b, double t, ) => - MessageSearchListViewThemeData( + StreamMessageSearchListViewThemeData( backgroundColor: Color.lerp(a.backgroundColor, b.backgroundColor, t), ); - /// Merges one [MessageSearchListViewThemeData] with another. - MessageSearchListViewThemeData merge(MessageSearchListViewThemeData? other) { + /// Merges one [StreamMessageSearchListViewThemeData] with another. + StreamMessageSearchListViewThemeData merge( + StreamMessageSearchListViewThemeData? other, + ) { if (other == null) return this; return copyWith( backgroundColor: other.backgroundColor, @@ -97,7 +111,7 @@ class MessageSearchListViewThemeData with Diagnosticable { @override bool operator ==(Object other) => identical(this, other) || - other is MessageSearchListViewThemeData && + other is StreamMessageSearchListViewThemeData && runtimeType == other.runtimeType && backgroundColor == other.backgroundColor; diff --git a/packages/stream_chat_flutter/lib/src/theme/message_theme.dart b/packages/stream_chat_flutter/lib/src/theme/message_theme.dart index 386a312f..c94c8159 100644 --- a/packages/stream_chat_flutter/lib/src/theme/message_theme.dart +++ b/packages/stream_chat_flutter/lib/src/theme/message_theme.dart @@ -2,11 +2,17 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:stream_chat_flutter/src/theme/avatar_theme.dart'; +/// {@macro message_theme_data} +@Deprecated("Use 'StreamMessageThemeData' instead") +typedef MessageThemeData = StreamMessageThemeData; + +/// {@template message_theme_data} /// Class for getting message theme +/// {@endtemplate} // ignore: prefer-match-file-name -class MessageThemeData with Diagnosticable { - /// Creates a [MessageThemeData]. - const MessageThemeData({ +class StreamMessageThemeData with Diagnosticable { + /// Creates a [StreamMessageThemeData]. + const StreamMessageThemeData({ this.repliesStyle, this.messageTextStyle, this.messageAuthorStyle, @@ -52,13 +58,13 @@ class MessageThemeData with Diagnosticable { final Color? reactionsMaskColor; /// Theme of the avatar - final AvatarThemeData? avatarTheme; + final StreamAvatarThemeData? avatarTheme; /// Background color for messages with url attachments. final Color? linkBackgroundColor; /// Copy with a theme - MessageThemeData copyWith({ + StreamMessageThemeData copyWith({ TextStyle? messageTextStyle, TextStyle? messageAuthorStyle, TextStyle? messageLinksStyle, @@ -66,13 +72,13 @@ class MessageThemeData with Diagnosticable { TextStyle? repliesStyle, Color? messageBackgroundColor, Color? messageBorderColor, - AvatarThemeData? avatarTheme, + StreamAvatarThemeData? avatarTheme, Color? reactionsBackgroundColor, Color? reactionsBorderColor, Color? reactionsMaskColor, Color? linkBackgroundColor, }) => - MessageThemeData( + StreamMessageThemeData( messageTextStyle: messageTextStyle ?? this.messageTextStyle, messageAuthorStyle: messageAuthorStyle ?? this.messageAuthorStyle, messageLinksStyle: messageLinksStyle ?? this.messageLinksStyle, @@ -89,11 +95,15 @@ class MessageThemeData with Diagnosticable { linkBackgroundColor: linkBackgroundColor ?? this.linkBackgroundColor, ); - /// Linearly interpolate from one [MessageThemeData] to another. - MessageThemeData lerp(MessageThemeData a, MessageThemeData b, double t) => - MessageThemeData( - avatarTheme: - const AvatarThemeData().lerp(a.avatarTheme!, b.avatarTheme!, t), + /// Linearly interpolate from one [StreamMessageThemeData] to another. + StreamMessageThemeData lerp( + StreamMessageThemeData a, + StreamMessageThemeData b, + double t, + ) => + StreamMessageThemeData( + avatarTheme: const StreamAvatarThemeData() + .lerp(a.avatarTheme!, b.avatarTheme!, t), createdAtStyle: TextStyle.lerp(a.createdAtStyle, b.createdAtStyle, t), messageAuthorStyle: TextStyle.lerp(a.messageAuthorStyle, b.messageAuthorStyle, t), @@ -120,7 +130,7 @@ class MessageThemeData with Diagnosticable { ); /// Merge with a theme - MessageThemeData merge(MessageThemeData? other) { + StreamMessageThemeData merge(StreamMessageThemeData? other) { if (other == null) return this; return copyWith( messageTextStyle: messageTextStyle?.merge(other.messageTextStyle) ?? @@ -146,7 +156,7 @@ class MessageThemeData with Diagnosticable { @override bool operator ==(Object other) => identical(this, other) || - other is MessageThemeData && + other is StreamMessageThemeData && runtimeType == other.runtimeType && messageTextStyle == other.messageTextStyle && messageAuthorStyle == other.messageAuthorStyle && diff --git a/packages/stream_chat_flutter/lib/src/theme/text_theme.dart b/packages/stream_chat_flutter/lib/src/theme/text_theme.dart index ec70cf83..06ddf2d9 100644 --- a/packages/stream_chat_flutter/lib/src/theme/text_theme.dart +++ b/packages/stream_chat_flutter/lib/src/theme/text_theme.dart @@ -1,9 +1,15 @@ import 'package:flutter/material.dart'; +/// {@macro text_theme} +@Deprecated("Use 'StreamTextTheme' instead") +typedef TextTheme = StreamTextTheme; + +/// {@template text_theme} /// Class for holding text theme -class TextTheme { +/// {@endtemplate} +class StreamTextTheme { /// Initialise light text theme - TextTheme.light({ + StreamTextTheme.light({ this.title = const TextStyle( fontSize: 22, fontWeight: FontWeight.bold, @@ -46,7 +52,7 @@ class TextTheme { }); /// Initialise with dark theme - TextTheme.dark({ + StreamTextTheme.dark({ this.title = const TextStyle( fontSize: 22, fontWeight: FontWeight.bold, @@ -113,7 +119,7 @@ class TextTheme { final TextStyle captionBold; /// Copy with theme - TextTheme copyWith({ + StreamTextTheme copyWith({ Brightness brightness = Brightness.light, TextStyle? body, TextStyle? title, @@ -125,7 +131,7 @@ class TextTheme { TextStyle? captionBold, }) => brightness == Brightness.light - ? TextTheme.light( + ? StreamTextTheme.light( body: body ?? this.body, title: title ?? this.title, headlineBold: headlineBold ?? this.headlineBold, @@ -135,7 +141,7 @@ class TextTheme { footnote: footnote ?? this.footnote, captionBold: captionBold ?? this.captionBold, ) - : TextTheme.dark( + : StreamTextTheme.dark( body: body ?? this.body, title: title ?? this.title, headlineBold: headlineBold ?? this.headlineBold, @@ -147,7 +153,7 @@ class TextTheme { ); /// Merge text theme - TextTheme merge(TextTheme? other) { + StreamTextTheme merge(StreamTextTheme? other) { if (other == null) return this; return copyWith( body: body.merge(other.body), diff --git a/packages/stream_chat_flutter/lib/src/theme/user_list_view_theme.dart b/packages/stream_chat_flutter/lib/src/theme/user_list_view_theme.dart index 0d99ccbd..fb57438b 100644 --- a/packages/stream_chat_flutter/lib/src/theme/user_list_view_theme.dart +++ b/packages/stream_chat_flutter/lib/src/theme/user_list_view_theme.dart @@ -2,27 +2,33 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/widgets.dart'; import 'package:stream_chat_flutter/src/stream_chat_theme.dart'; +/// {@macro user_list_view_theme} +@Deprecated("Use 'StreamUserListViewTheme' instead") +typedef UserListViewTheme = StreamUserListViewTheme; + +/// {@template user_list_view_theme} /// Overrides the default style of [UserListView] descendants. /// /// See also: /// -/// * [UserListViewThemeData], which is used to configure this theme. -class UserListViewTheme extends InheritedTheme { - /// Creates a [UserListViewTheme]. +/// * [StreamUserListViewThemeData], which is used to configure this theme. +/// {@endtemplate} +class StreamUserListViewTheme extends InheritedTheme { + /// Creates a [StreamUserListViewTheme]. /// /// The [data] parameter must not be null. - const UserListViewTheme({ + const StreamUserListViewTheme({ Key? key, required this.data, required Widget child, }) : super(key: key, child: child); /// The configuration of this theme. - final UserListViewThemeData data; + final StreamUserListViewThemeData data; /// The closest instance of this class that encloses the given context. /// - /// If there is no enclosing [UserListViewTheme] widget, then + /// If there is no enclosing [StreamUserListViewTheme] widget, then /// [StreamChatThemeData.userListViewTheme] is used. /// /// Typical usage is as follows: @@ -30,35 +36,41 @@ class UserListViewTheme extends InheritedTheme { /// ```dart /// UserListViewTheme theme = UserListViewTheme.of(context); /// ``` - static UserListViewThemeData of(BuildContext context) { + static StreamUserListViewThemeData of(BuildContext context) { final userListViewTheme = - context.dependOnInheritedWidgetOfExactType(); + context.dependOnInheritedWidgetOfExactType(); return userListViewTheme?.data ?? StreamChatTheme.of(context).userListViewTheme; } @override Widget wrap(BuildContext context, Widget child) => - UserListViewTheme(data: data, child: child); + StreamUserListViewTheme(data: data, child: child); @override - bool updateShouldNotify(UserListViewTheme oldWidget) => + bool updateShouldNotify(StreamUserListViewTheme oldWidget) => data != oldWidget.data; } +/// {@macro user_list_view_theme_data} +@Deprecated("Use 'StreamUserListViewThemeData' instead") +typedef UserListViewThemeData = StreamUserListViewThemeData; + +/// {@template user_list_view_theme_data} /// A style that overrides the default appearance of [UserListView]s when -/// used with [UserListViewTheme] or with the overall [StreamChatTheme]'s +/// used with [StreamUserListViewTheme] or with the overall [StreamChatTheme]'s /// [StreamChatThemeData.userListViewTheme]. /// /// See also: /// -/// * [UserListViewTheme], the theme which is configured with this class. +/// * [StreamUserListViewTheme], the theme which is configured with this class. /// * [StreamChatThemeData.userListViewTheme], which can be used to override /// the default style for [UserListView]s below the overall /// [StreamChatTheme]. -class UserListViewThemeData with Diagnosticable { - /// Creates a [UserListViewThemeData]. - const UserListViewThemeData({ +/// {@endtemplate} +class StreamUserListViewThemeData with Diagnosticable { + /// Creates a [StreamUserListViewThemeData]. + const StreamUserListViewThemeData({ this.backgroundColor, }); @@ -66,27 +78,27 @@ class UserListViewThemeData with Diagnosticable { final Color? backgroundColor; /// Copies this [ChannelListViewThemeData] to another. - UserListViewThemeData copyWith({ + StreamUserListViewThemeData copyWith({ Color? backgroundColor, }) => - UserListViewThemeData( + StreamUserListViewThemeData( backgroundColor: backgroundColor ?? this.backgroundColor, ); - /// Linearly interpolate between two [UserListViewThemeData] themes. + /// Linearly interpolate between two [StreamUserListViewThemeData] themes. /// /// All the properties must be non-null. - UserListViewThemeData lerp( - UserListViewThemeData a, - UserListViewThemeData b, + StreamUserListViewThemeData lerp( + StreamUserListViewThemeData a, + StreamUserListViewThemeData b, double t, ) => - UserListViewThemeData( + StreamUserListViewThemeData( backgroundColor: Color.lerp(a.backgroundColor, b.backgroundColor, t), ); - /// Merges one [UserListViewThemeData] with another. - UserListViewThemeData merge(UserListViewThemeData? other) { + /// Merges one [StreamUserListViewThemeData] with another. + StreamUserListViewThemeData merge(StreamUserListViewThemeData? other) { if (other == null) return this; return copyWith( backgroundColor: other.backgroundColor, @@ -96,7 +108,7 @@ class UserListViewThemeData with Diagnosticable { @override bool operator ==(Object other) => identical(this, other) || - other is UserListViewThemeData && + other is StreamUserListViewThemeData && runtimeType == other.runtimeType && backgroundColor == other.backgroundColor; diff --git a/packages/stream_chat_flutter/lib/src/thread_header.dart b/packages/stream_chat_flutter/lib/src/thread_header.dart index e7a9372f..052e1bcb 100644 --- a/packages/stream_chat_flutter/lib/src/thread_header.dart +++ b/packages/stream_chat_flutter/lib/src/thread_header.dart @@ -3,6 +3,11 @@ import 'package:flutter/services.dart'; import 'package:stream_chat_flutter/src/extension.dart'; import 'package:stream_chat_flutter/stream_chat_flutter.dart'; +/// {@macro thread_header} +@Deprecated("Use 'StreamThreadHeader' instead") +typedef ThreadHeader = StreamThreadHeader; + +/// {@template thread_header} /// ![screenshot](https://raw.githubusercontent.com/GetStream/stream-chat-flutter/master/packages/stream_chat_flutter/screenshots/thread_header.png) /// ![screenshot](https://raw.githubusercontent.com/GetStream/stream-chat-flutter/master/packages/stream_chat_flutter/screenshots/thread_header_paint.png) /// @@ -56,9 +61,11 @@ import 'package:stream_chat_flutter/stream_chat_flutter.dart'; /// The widget components render the ui based on the first ancestor of type /// [StreamChatTheme] and on its [ChannelTheme.channelHeaderTheme] property. /// Modify it to change the widget appearance. -class ThreadHeader extends StatelessWidget implements PreferredSizeWidget { +/// {@endtemplate} +class StreamThreadHeader extends StatelessWidget + implements PreferredSizeWidget { /// Instantiate a new ThreadHeader - const ThreadHeader({ + const StreamThreadHeader({ Key? key, required this.parent, this.showBackButton = true, @@ -102,12 +109,12 @@ class ThreadHeader extends StatelessWidget implements PreferredSizeWidget { /// if a user is typing in this thread final bool showTypingIndicator; - /// The background color of this [ThreadHeader]. + /// The background color of this [StreamThreadHeader]. final Color? backgroundColor; @override Widget build(BuildContext context) { - final channelHeaderTheme = ChannelHeaderTheme.of(context); + final channelHeaderTheme = StreamChannelHeaderTheme.of(context); final defaultSubtitle = subtitle ?? Row( @@ -162,7 +169,7 @@ class ThreadHeader extends StatelessWidget implements PreferredSizeWidget { const SizedBox(height: 2), if (showTypingIndicator) Align( - child: TypingIndicator( + child: StreamTypingIndicator( channel: StreamChannel.of(context).channel, style: channelHeaderTheme.subtitleStyle, parentId: parent.id, diff --git a/packages/stream_chat_flutter/lib/src/typing_indicator.dart b/packages/stream_chat_flutter/lib/src/typing_indicator.dart index 389d1020..1cb3d8eb 100644 --- a/packages/stream_chat_flutter/lib/src/typing_indicator.dart +++ b/packages/stream_chat_flutter/lib/src/typing_indicator.dart @@ -3,10 +3,16 @@ import 'package:lottie/lottie.dart'; import 'package:stream_chat_flutter/src/extension.dart'; import 'package:stream_chat_flutter_core/stream_chat_flutter_core.dart'; +/// {@macro typing_indicator} +@Deprecated("Use 'StreamTypingIndicator' instead") +typedef TypingIndicator = StreamTypingIndicator; + +/// {@template typing_indicator} /// Widget to show the current list of typing users -class TypingIndicator extends StatelessWidget { +/// {@endtemplate} +class StreamTypingIndicator extends StatelessWidget { /// Instantiate a new TypingIndicator - const TypingIndicator({ + const StreamTypingIndicator({ Key? key, this.channel, this.alternativeWidget, diff --git a/packages/stream_chat_flutter/lib/src/unread_indicator.dart b/packages/stream_chat_flutter/lib/src/unread_indicator.dart index 958386d1..bf23db1a 100644 --- a/packages/stream_chat_flutter/lib/src/unread_indicator.dart +++ b/packages/stream_chat_flutter/lib/src/unread_indicator.dart @@ -1,10 +1,16 @@ import 'package:flutter/material.dart'; import 'package:stream_chat_flutter/stream_chat_flutter.dart'; +/// {@macro unread_indicator} +@Deprecated("Use 'StreamUnreadIndicator' instead") +typedef UnreadIndicator = StreamUnreadIndicator; + +/// {@template unread_indicator} /// Widget for showing an unread indicator -class UnreadIndicator extends StatelessWidget { - /// Constructor for creating an [UnreadIndicator] - const UnreadIndicator({ +/// {@endtemplate} +class StreamUnreadIndicator extends StatelessWidget { + /// Constructor for creating an [StreamUnreadIndicator] + const StreamUnreadIndicator({ Key? key, this.cid, }) : super(key: key); diff --git a/packages/stream_chat_flutter/lib/src/upload_progress_indicator.dart b/packages/stream_chat_flutter/lib/src/upload_progress_indicator.dart index b3fe510d..d11e9609 100644 --- a/packages/stream_chat_flutter/lib/src/upload_progress_indicator.dart +++ b/packages/stream_chat_flutter/lib/src/upload_progress_indicator.dart @@ -1,10 +1,16 @@ import 'package:flutter/material.dart'; import 'package:stream_chat_flutter/stream_chat_flutter.dart'; +/// {@macro upload_progress_indicator} +@Deprecated("Use 'StreamUploadProgressIndicator' instead") +typedef UploadProgressIndicator = StreamUploadProgressIndicator; + +/// {@template upload_progress_indicator} /// Widget for showing upload progress -class UploadProgressIndicator extends StatelessWidget { - /// Constructor for creating an [UploadProgressIndicator] - const UploadProgressIndicator({ +/// {@endtemplate} +class StreamUploadProgressIndicator extends StatelessWidget { + /// Constructor for creating an [StreamUploadProgressIndicator] + const StreamUploadProgressIndicator({ Key? key, required this.uploaded, required this.total, diff --git a/packages/stream_chat_flutter/lib/src/user_avatar.dart b/packages/stream_chat_flutter/lib/src/user_avatar.dart index e638685c..8d634039 100644 --- a/packages/stream_chat_flutter/lib/src/user_avatar.dart +++ b/packages/stream_chat_flutter/lib/src/user_avatar.dart @@ -2,10 +2,16 @@ import 'package:cached_network_image/cached_network_image.dart'; import 'package:flutter/material.dart'; import 'package:stream_chat_flutter/stream_chat_flutter.dart'; +/// {@macro user_avatar} +@Deprecated("Use 'StreamUserAvatar' instead") +typedef UserAvatar = StreamUserAvatar; + +/// {@template user_avatar} /// Widget that displays a user avatar -class UserAvatar extends StatelessWidget { - /// Constructor to create a [UserAvatar] - const UserAvatar({ +/// {@endtemplate} +class StreamUserAvatar extends StatelessWidget { + /// Constructor to create a [StreamUserAvatar] + const StreamUserAvatar({ Key? key, required this.user, this.constraints, diff --git a/packages/stream_chat_flutter/lib/src/user_item.dart b/packages/stream_chat_flutter/lib/src/user_item.dart index c0e3482e..74ccacc2 100644 --- a/packages/stream_chat_flutter/lib/src/user_item.dart +++ b/packages/stream_chat_flutter/lib/src/user_item.dart @@ -2,21 +2,26 @@ import 'package:flutter/material.dart'; import 'package:stream_chat_flutter/src/extension.dart'; import 'package:stream_chat_flutter/stream_chat_flutter.dart'; -/// +/// {@macro user_item} +@Deprecated("Use 'StreamUserItem' instead") +typedef UserItem = StreamUserItem; + +/// {@template user_item} /// It shows the current [User] preview. /// /// The widget uses a [StreamBuilder] to render the user information /// image as soon as it updates. /// /// Usually you don't use this widget as it's the default user preview used -/// by [UserListView]. +/// by [StreamUserListView]. /// /// The widget renders the ui based on the first ancestor of type /// [StreamChatTheme]. /// Modify it to change the widget appearance. -class UserItem extends StatelessWidget { +/// {@endtemplate} +class StreamUserItem extends StatelessWidget { /// Instantiate a new UserItem - const UserItem({ + const StreamUserItem({ Key? key, required this.user, this.onTap, @@ -38,10 +43,10 @@ class UserItem extends StatelessWidget { /// The function called when the image is tapped final void Function(User)? onImageTap; - /// If true the [UserItem] will show a trailing checkmark + /// If true the [StreamUserItem] will show a trailing checkmark final bool selected; - /// If true the [UserItem] will show the last seen + /// If true the [StreamUserItem] will show the last seen final bool showLastOnline; @override @@ -58,7 +63,7 @@ class UserItem extends StatelessWidget { onLongPress!(user); } }, - leading: UserAvatar( + leading: StreamUserAvatar( user: user, onTap: (user) { if (onImageTap != null) { diff --git a/packages/stream_chat_flutter/lib/src/user_list_view.dart b/packages/stream_chat_flutter/lib/src/user_list_view.dart index 58af30a7..a604c611 100644 --- a/packages/stream_chat_flutter/lib/src/user_list_view.dart +++ b/packages/stream_chat_flutter/lib/src/user_list_view.dart @@ -8,7 +8,11 @@ typedef UserTapCallback = void Function(User, Widget?); /// Builder used to create a custom [ListUserItem] from a [User] typedef UserItemBuilder = Widget Function(BuildContext, User, bool); -/// +/// {@macro user_list_view} +@Deprecated("Use 'StreamUserListView' instead") +typedef UserListView = StreamUserListView; + +/// {@template user_list_view} /// It shows the list of current users. /// /// ```dart @@ -42,9 +46,10 @@ typedef UserItemBuilder = Widget Function(BuildContext, User, bool); /// The widget components render the ui based on the first ancestor of /// type [StreamChatTheme]. /// Modify it to change the widget appearance. -class UserListView extends StatefulWidget { +/// {@endtemplate} +class StreamUserListView extends StatefulWidget { /// Instantiate a new UserListView - UserListView({ + StreamUserListView({ Key? key, this.filter = const Filter.empty(), this.sort, @@ -160,10 +165,10 @@ class UserListView extends StatefulWidget { final UserListController? userListController; @override - _UserListViewState createState() => _UserListViewState(); + _StreamUserListViewState createState() => _StreamUserListViewState(); } -class _UserListViewState extends State +class _StreamUserListViewState extends State with WidgetsBindingObserver { bool get _isListView => widget.crossAxisCount == 1; @@ -203,7 +208,7 @@ class _UserListViewState extends State userListController: _userListController, ); - final backgroundColor = UserListViewTheme.of(context).backgroundColor; + final backgroundColor = StreamUserListViewTheme.of(context).backgroundColor; Widget child; @@ -332,7 +337,7 @@ class _UserListViewState extends State key: ValueKey('USER-${user.id}'), child: widget.userItemBuilder != null ? widget.userItemBuilder!(context, user, selected) - : UserItem( + : StreamUserItem( user: user, onTap: (user) => widget.onUserTap!(user, widget.userWidget), onLongPress: widget.onUserLongPress, @@ -362,7 +367,7 @@ class _UserListViewState extends State : Column( mainAxisAlignment: MainAxisAlignment.center, children: [ - UserAvatar( + StreamUserAvatar( user: user, borderRadius: BorderRadius.circular(32), selected: selected, diff --git a/packages/stream_chat_flutter/lib/src/user_mention_tile.dart b/packages/stream_chat_flutter/lib/src/user_mention_tile.dart index ff9e145b..b944d912 100644 --- a/packages/stream_chat_flutter/lib/src/user_mention_tile.dart +++ b/packages/stream_chat_flutter/lib/src/user_mention_tile.dart @@ -1,12 +1,18 @@ import 'package:flutter/material.dart'; import 'package:stream_chat_flutter/stream_chat_flutter.dart'; +/// {@macro user_mention_tile} +@Deprecated("Use 'StreamUserMentionTile' instead") +typedef UserMentionTile = StreamUserMentionTile; + +/// {@template user_mention_tile} /// This widget is used for showing user tiles for mentions /// Use [title], [subtitle], [leading], [trailing] for /// substituting widgets in respective positions -class UserMentionTile extends StatelessWidget { - /// Constructor for creating a [UserMentionTile] widget - const UserMentionTile( +/// {@endtemplate} +class StreamUserMentionTile extends StatelessWidget { + /// Constructor for creating a [StreamUserMentionTile] widget + const StreamUserMentionTile( this.user, { Key? key, this.title, @@ -41,7 +47,7 @@ class UserMentionTile extends StatelessWidget { width: 16, ), leading ?? - UserAvatar( + StreamUserAvatar( user: user, constraints: BoxConstraints.tight(const Size(40, 40)), ), diff --git a/packages/stream_chat_flutter/lib/src/user_mentions_overlay.dart b/packages/stream_chat_flutter/lib/src/user_mentions_overlay.dart index e3830231..59c86791 100644 --- a/packages/stream_chat_flutter/lib/src/user_mentions_overlay.dart +++ b/packages/stream_chat_flutter/lib/src/user_mentions_overlay.dart @@ -6,16 +6,22 @@ import 'package:stream_chat_flutter_core/stream_chat_flutter_core.dart'; /// Builder function for building a mention tile. /// -/// Use [UserMentionTile] for the default implementation. +/// Use [StreamUserMentionTile] for the default implementation. typedef MentionTileBuilder = Widget Function( BuildContext context, User user, ); +/// {@macro user_mention_tile} +@Deprecated("Use 'StreamUserMentionsOverlay' instead") +typedef UserMentionsOverlay = StreamUserMentionsOverlay; + +/// {@template user_mentions_overlay} /// Overlay for displaying users that can be mentioned. -class UserMentionsOverlay extends StatefulWidget { - /// Constructor for creating a [UserMentionsOverlay]. - UserMentionsOverlay({ +/// {@endtemplate} +class StreamUserMentionsOverlay extends StatefulWidget { + /// Constructor for creating a [StreamUserMentionsOverlay]. + StreamUserMentionsOverlay({ Key? key, required this.query, required this.channel, @@ -62,10 +68,11 @@ class UserMentionsOverlay extends StatefulWidget { final void Function(User user)? onMentionUserTap; @override - _UserMentionsOverlayState createState() => _UserMentionsOverlayState(); + _StreamUserMentionsOverlayState createState() => + _StreamUserMentionsOverlayState(); } -class _UserMentionsOverlayState extends State { +class _StreamUserMentionsOverlayState extends State { late Future> userMentionsFuture; @override @@ -75,7 +82,7 @@ class _UserMentionsOverlayState extends State { } @override - void didUpdateWidget(covariant UserMentionsOverlay oldWidget) { + void didUpdateWidget(covariant StreamUserMentionsOverlay oldWidget) { super.didUpdateWidget(oldWidget); if (widget.channel != oldWidget.channel || widget.query != oldWidget.query || @@ -116,7 +123,7 @@ class _UserMentionsOverlayState extends State { child: InkWell( onTap: () => widget.onMentionUserTap?.call(user), child: widget.mentionsTileBuilder?.call(context, user) ?? - UserMentionTile(user), + StreamUserMentionTile(user), ), ); }, diff --git a/packages/stream_chat_flutter/lib/src/v4/channel_list_view/stream_channel_list_tile.dart b/packages/stream_chat_flutter/lib/src/v4/channel_list_view/stream_channel_list_tile.dart index f820e040..3b254817 100644 --- a/packages/stream_chat_flutter/lib/src/v4/channel_list_view/stream_channel_list_tile.dart +++ b/packages/stream_chat_flutter/lib/src/v4/channel_list_view/stream_channel_list_tile.dart @@ -131,7 +131,7 @@ class StreamChannelListTile extends StatelessWidget { final channelState = channel.state!; final currentUser = channel.client.state.currentUser!; - final channelPreviewTheme = ChannelPreviewTheme.of(context); + final channelPreviewTheme = StreamChannelPreviewTheme.of(context); final leading = this.leading ?? StreamChannelAvatar( @@ -182,7 +182,7 @@ class StreamChannelListTile extends StatelessWidget { return const Offstage(); } return unreadIndicatorBuilder?.call(context) ?? - UnreadIndicator(cid: channel.cid); + StreamUnreadIndicator(cid: channel.cid); }, ), ], @@ -213,7 +213,7 @@ class StreamChannelListTile extends StatelessWidget { padding: const EdgeInsets.only(right: 4), child: sendingIndicatorBuilder?.call(context, lastMessage) ?? - SendingIndicator( + StreamSendingIndicator( message: lastMessage, size: channelPreviewTheme.indicatorIconSize, isMessageRead: channelState @@ -318,7 +318,7 @@ class ChannelListTileSubtitle extends StatelessWidget { ], ); } - return TypingIndicator( + return StreamTypingIndicator( channel: channel, style: textStyle, alternativeWidget: ChannelLastMessageText( diff --git a/packages/stream_chat_flutter/lib/src/v4/stream_channel_avatar.dart b/packages/stream_chat_flutter/lib/src/v4/stream_channel_avatar.dart index fd07adc8..95cc14f2 100644 --- a/packages/stream_chat_flutter/lib/src/v4/stream_channel_avatar.dart +++ b/packages/stream_chat_flutter/lib/src/v4/stream_channel_avatar.dart @@ -148,7 +148,7 @@ class StreamChannelAvatar extends StatelessWidget { return BetterStreamBuilder( stream: client.currentUserStream.map((it) => it!), initialData: currentUser, - builder: (context, user) => UserAvatar( + builder: (context, user) => StreamUserAvatar( borderRadius: borderRadius ?? previewTheme?.borderRadius, user: user, constraints: constraints ?? previewTheme?.constraints, @@ -171,7 +171,7 @@ class StreamChannelAvatar extends StatelessWidget { ), ), initialData: member, - builder: (context, member) => UserAvatar( + builder: (context, member) => StreamUserAvatar( borderRadius: borderRadius ?? previewTheme?.borderRadius, user: member.user!, constraints: constraints ?? previewTheme?.constraints, @@ -184,7 +184,7 @@ class StreamChannelAvatar extends StatelessWidget { } // Group conversation - return GroupAvatar( + return StreamGroupAvatar( channel: channel, members: otherMembers, borderRadius: borderRadius ?? previewTheme?.borderRadius, diff --git a/packages/stream_chat_flutter/lib/src/v4/stream_channel_info_bottom_sheet.dart b/packages/stream_chat_flutter/lib/src/v4/stream_channel_info_bottom_sheet.dart index 5107131d..1a219e91 100644 --- a/packages/stream_chat_flutter/lib/src/v4/stream_channel_info_bottom_sheet.dart +++ b/packages/stream_chat_flutter/lib/src/v4/stream_channel_info_bottom_sheet.dart @@ -52,7 +52,7 @@ class StreamChannelInfoBottomSheet extends StatelessWidget { Widget build(BuildContext context) { final themeData = StreamChatTheme.of(context); final colorTheme = themeData.colorTheme; - final channelPreviewTheme = ChannelPreviewTheme.of(context); + final channelPreviewTheme = StreamChannelPreviewTheme.of(context); final currentUser = channel.client.state.currentUser; final isOneToOneChannel = channel.isDistinct && channel.memberCount == 2; @@ -84,7 +84,7 @@ class StreamChannelInfoBottomSheet extends StatelessWidget { const SizedBox(height: 5), Center( // TODO: Refactor ChannelInfo - child: ChannelInfo( + child: StreamChannelInfo( showTypingIndicator: false, channel: channel, textStyle: channelPreviewTheme.subtitleStyle, @@ -105,7 +105,7 @@ class StreamChannelInfoBottomSheet extends StatelessWidget { final user = member.user!; return Column( children: [ - UserAvatar( + StreamUserAvatar( user: user, constraints: const BoxConstraints( maxHeight: 64, @@ -132,7 +132,7 @@ class StreamChannelInfoBottomSheet extends StatelessWidget { ), ), const SizedBox(height: 24), - OptionListTile( + StreamOptionListTile( leading: Padding( padding: const EdgeInsets.symmetric(horizontal: 16), child: StreamSvgIcon.user( @@ -143,7 +143,7 @@ class StreamChannelInfoBottomSheet extends StatelessWidget { onTap: onViewInfoTap, ), if (!isOneToOneChannel) - OptionListTile( + StreamOptionListTile( title: context.translations.leaveGroupLabel, leading: Padding( padding: const EdgeInsets.symmetric(horizontal: 16), @@ -154,7 +154,7 @@ class StreamChannelInfoBottomSheet extends StatelessWidget { onTap: onLeaveChannelTap, ), if (isOwner) - OptionListTile( + StreamOptionListTile( leading: Padding( padding: const EdgeInsets.symmetric(horizontal: 16), child: StreamSvgIcon.delete( @@ -165,7 +165,7 @@ class StreamChannelInfoBottomSheet extends StatelessWidget { titleColor: colorTheme.accentError, onTap: onDeleteConversationTap, ), - OptionListTile( + StreamOptionListTile( leading: Padding( padding: const EdgeInsets.symmetric(horizontal: 16), child: StreamSvgIcon.closeSmall( diff --git a/packages/stream_chat_flutter/lib/src/video_service.dart b/packages/stream_chat_flutter/lib/src/video_service.dart index a50a43c8..fb1db9ed 100644 --- a/packages/stream_chat_flutter/lib/src/video_service.dart +++ b/packages/stream_chat_flutter/lib/src/video_service.dart @@ -66,5 +66,10 @@ class _IVideoService { } /// Get instance of [_IVideoService] +@Deprecated("Use 'StreamVideoService' instead") // ignore: non_constant_identifier_names _IVideoService get VideoService => _IVideoService.instance; + +/// Get instance of [_IVideoService] +// ignore: non_constant_identifier_names +_IVideoService get StreamVideoService => _IVideoService.instance; diff --git a/packages/stream_chat_flutter/lib/src/video_thumbnail_image.dart b/packages/stream_chat_flutter/lib/src/video_thumbnail_image.dart index 2286bc3d..4d253da0 100644 --- a/packages/stream_chat_flutter/lib/src/video_thumbnail_image.dart +++ b/packages/stream_chat_flutter/lib/src/video_thumbnail_image.dart @@ -6,10 +6,16 @@ import 'package:stream_chat_flutter/src/video_service.dart'; import 'package:stream_chat_flutter/stream_chat_flutter.dart'; import 'package:video_thumbnail/video_thumbnail.dart'; +/// {@macro video_thumbnail_image} +@Deprecated("Use 'StreamVideoThumbnailImage' instead") +typedef VideoThumbnailImage = StreamVideoThumbnailImage; + +/// {@template video_thumbnail_image} /// Widget for creating video thumbnail image -class VideoThumbnailImage extends StatefulWidget { - /// Constructor for creating [VideoThumbnailImage] - const VideoThumbnailImage({ +/// {@endtemplate} +class StreamVideoThumbnailImage extends StatefulWidget { + /// Constructor for creating [StreamVideoThumbnailImage] + const StreamVideoThumbnailImage({ Key? key, required this.video, this.width, @@ -42,16 +48,17 @@ class VideoThumbnailImage extends StatefulWidget { final WidgetBuilder? placeholderBuilder; @override - _VideoThumbnailImageState createState() => _VideoThumbnailImageState(); + _StreamVideoThumbnailImageState createState() => + _StreamVideoThumbnailImageState(); } -class _VideoThumbnailImageState extends State { +class _StreamVideoThumbnailImageState extends State { late Future thumbnailFuture; late StreamChatThemeData _streamChatTheme; @override void initState() { - thumbnailFuture = VideoService.generateVideoThumbnail( + thumbnailFuture = StreamVideoService.generateVideoThumbnail( video: widget.video, imageFormat: widget.format, ); @@ -65,9 +72,9 @@ class _VideoThumbnailImageState extends State { } @override - void didUpdateWidget(covariant VideoThumbnailImage oldWidget) { + void didUpdateWidget(covariant StreamVideoThumbnailImage oldWidget) { if (oldWidget.video != widget.video || oldWidget.format != widget.format) { - thumbnailFuture = VideoService.generateVideoThumbnail( + thumbnailFuture = StreamVideoService.generateVideoThumbnail( video: widget.video, imageFormat: widget.format, ); diff --git a/packages/stream_chat_flutter/lib/src/visible_footnote.dart b/packages/stream_chat_flutter/lib/src/visible_footnote.dart index 700e22ad..1456de3a 100644 --- a/packages/stream_chat_flutter/lib/src/visible_footnote.dart +++ b/packages/stream_chat_flutter/lib/src/visible_footnote.dart @@ -2,10 +2,16 @@ import 'package:flutter/material.dart'; import 'package:stream_chat_flutter/src/extension.dart'; import 'package:stream_chat_flutter/stream_chat_flutter.dart'; +/// {@macro visible_footnote} +@Deprecated("Use 'StreamVisibleFootnote' instead") +typedef VisibleFootnote = StreamVisibleFootnote; + +/// {@template visible_footnote} /// Widget for displaying a footnote -class VisibleFootnote extends StatelessWidget { - /// Constructor for creating a [VisibleFootnote] - const VisibleFootnote({Key? key}) : super(key: key); +/// {@endtemplate} +class StreamVisibleFootnote extends StatelessWidget { + /// Constructor for creating a [StreamVisibleFootnote] + const StreamVisibleFootnote({Key? key}) : super(key: key); @override Widget build(BuildContext context) { diff --git a/packages/stream_chat_flutter/lib/stream_chat_flutter.dart b/packages/stream_chat_flutter/lib/stream_chat_flutter.dart index 83a31510..cd5c79d6 100644 --- a/packages/stream_chat_flutter/lib/stream_chat_flutter.dart +++ b/packages/stream_chat_flutter/lib/stream_chat_flutter.dart @@ -21,7 +21,6 @@ export 'src/gradient_avatar.dart'; export 'src/info_tile.dart'; export 'src/localization/stream_chat_localizations.dart'; export 'src/localization/translations.dart' show DefaultTranslations; -export 'src/mention_tile.dart'; export 'src/message_action.dart'; export 'src/message_input/countdown_button.dart'; export 'src/message_input/message_input.dart'; diff --git a/packages/stream_chat_flutter/test/src/attachment_widgets_test.dart b/packages/stream_chat_flutter/test/src/attachment_widgets_test.dart index ed4ce267..9747f11d 100644 --- a/packages/stream_chat_flutter/test/src/attachment_widgets_test.dart +++ b/packages/stream_chat_flutter/test/src/attachment_widgets_test.dart @@ -24,7 +24,7 @@ void main() { child: StreamChannel( channel: channel, child: SizedBox( - child: FileAttachment( + child: StreamFileAttachment( size: const Size( 300, 300, diff --git a/packages/stream_chat_flutter/test/src/back_button_test.dart b/packages/stream_chat_flutter/test/src/back_button_test.dart index fca30c5b..f6ec0fc4 100644 --- a/packages/stream_chat_flutter/test/src/back_button_test.dart +++ b/packages/stream_chat_flutter/test/src/back_button_test.dart @@ -136,7 +136,7 @@ void main() { ), ); - expect(find.byType(UnreadIndicator), findsOneWidget); + expect(find.byType(StreamUnreadIndicator), findsOneWidget); }, ); } diff --git a/packages/stream_chat_flutter/test/src/channel_header_test.dart b/packages/stream_chat_flutter/test/src/channel_header_test.dart index 95d2e751..6590ee66 100644 --- a/packages/stream_chat_flutter/test/src/channel_header_test.dart +++ b/packages/stream_chat_flutter/test/src/channel_header_test.dart @@ -58,7 +58,7 @@ void main() { child: StreamChannel( channel: channel, child: const Scaffold( - body: ChannelHeader(), + body: StreamChannelHeader(), ), ), ), @@ -67,7 +67,7 @@ void main() { expect(find.text('test'), findsOneWidget); expect(find.byType(ChannelAvatar), findsOneWidget); expect(find.byType(StreamBackButton), findsOneWidget); - expect(find.byType(ChannelInfo), findsOneWidget); + expect(find.byType(StreamChannelInfo), findsOneWidget); }, ); @@ -124,7 +124,7 @@ void main() { child: StreamChannel( channel: channel, child: const Scaffold( - body: ChannelHeader( + body: StreamChannelHeader( showConnectionStateTile: true, ), ), @@ -132,8 +132,12 @@ void main() { ), )); - expect(tester.widget(find.byType(InfoTile)).showMessage, true); - expect(tester.widget(find.byType(InfoTile)).message, + expect( + tester + .widget(find.byType(StreamInfoTile)) + .showMessage, + true); + expect(tester.widget(find.byType(StreamInfoTile)).message, 'Disconnected'); }, ); @@ -190,7 +194,7 @@ void main() { channel: channel, showLoading: false, child: const Scaffold( - body: ChannelHeader( + body: StreamChannelHeader( showConnectionStateTile: true, ), ), @@ -200,8 +204,12 @@ void main() { await tester.pump(); - expect(tester.widget(find.byType(InfoTile)).showMessage, true); - expect(tester.widget(find.byType(InfoTile)).message, + expect( + tester + .widget(find.byType(StreamInfoTile)) + .showMessage, + true); + expect(tester.widget(find.byType(StreamInfoTile)).message, 'Reconnecting...'); }, ); @@ -257,7 +265,7 @@ void main() { child: StreamChannel( channel: channel, child: const Scaffold( - body: ChannelHeader( + body: StreamChannelHeader( leading: Text('leading'), subtitle: Text('subtitle'), actions: [ @@ -273,7 +281,7 @@ void main() { expect(find.text('test'), findsNothing); expect(find.byType(StreamBackButton), findsNothing); expect(find.byType(ChannelAvatar), findsNothing); - expect(find.byType(ChannelInfo), findsNothing); + expect(find.byType(StreamChannelInfo), findsNothing); expect(find.text('leading'), findsOneWidget); expect(find.text('title'), findsOneWidget); expect(find.text('subtitle'), findsOneWidget); @@ -331,7 +339,7 @@ void main() { child: StreamChannel( channel: channel, child: const Scaffold( - body: ChannelHeader( + body: StreamChannelHeader( showTypingIndicator: false, showBackButton: false, ), @@ -343,10 +351,14 @@ void main() { expect(find.byType(StreamBackButton), findsNothing); expect( tester - .widget(find.byType(ChannelInfo)) + .widget(find.byType(StreamChannelInfo)) .showTypingIndicator, false); - expect(tester.widget(find.byType(InfoTile)).showMessage, false); + expect( + tester + .widget(find.byType(StreamInfoTile)) + .showMessage, + false); }, ); @@ -405,7 +417,7 @@ void main() { child: StreamChannel( channel: channel, child: Scaffold( - body: ChannelHeader( + body: StreamChannelHeader( onBackPressed: () => backPressed = true, onImageTap: () => imageTapped = true, onTitleTap: () => titleTapped = true, diff --git a/packages/stream_chat_flutter/test/src/channel_image_test.dart b/packages/stream_chat_flutter/test/src/channel_image_test.dart index be2ade55..3fc1e718 100644 --- a/packages/stream_chat_flutter/test/src/channel_image_test.dart +++ b/packages/stream_chat_flutter/test/src/channel_image_test.dart @@ -169,7 +169,8 @@ void main() { ), )); - final image = tester.widget(find.byType(GroupAvatar)); + final image = + tester.widget(find.byType(StreamGroupAvatar)); final otherMembers = members.where((it) => it.userId != currentUser.id); expect( image.members.map((it) => it.user?.id), diff --git a/packages/stream_chat_flutter/test/src/channel_list_header_test.dart b/packages/stream_chat_flutter/test/src/channel_list_header_test.dart index a2783067..532d07d6 100644 --- a/packages/stream_chat_flutter/test/src/channel_list_header_test.dart +++ b/packages/stream_chat_flutter/test/src/channel_list_header_test.dart @@ -22,14 +22,15 @@ void main() { home: StreamChat( client: client, child: const Scaffold( - body: ChannelListHeader(), + body: StreamChannelListHeader(), ), ), ), ); await tester.pumpAndSettle(); - final userAvatar = tester.widget(find.byType(UserAvatar)); + final userAvatar = + tester.widget(find.byType(StreamUserAvatar)); expect(userAvatar.user, clientState.currentUser); expect(find.byType(StreamNeumorphicButton), findsOneWidget); expect(find.text('Stream Chat'), findsOneWidget); @@ -52,7 +53,7 @@ void main() { home: StreamChat( client: client, child: const Scaffold( - body: ChannelListHeader( + body: StreamChannelListHeader( showConnectionStateTile: true, ), ), @@ -81,7 +82,7 @@ void main() { home: StreamChat( client: client, child: const Scaffold( - body: ChannelListHeader( + body: StreamChannelListHeader( showConnectionStateTile: true, ), ), @@ -110,7 +111,7 @@ void main() { home: StreamChat( client: client, child: Scaffold( - body: ChannelListHeader( + body: StreamChannelListHeader( titleBuilder: (context, status, client) => const Text('TITLE'), subtitle: const Text('SUBTITLE'), leading: const Text('LEADING'), @@ -150,7 +151,7 @@ void main() { home: StreamChat( client: client, child: Scaffold( - body: ChannelListHeader( + body: StreamChannelListHeader( preNavigationCallback: () { tapped = true; }, @@ -161,7 +162,7 @@ void main() { ); await tester.pump(); - await tester.tap(find.byType(UserAvatar)); + await tester.tap(find.byType(StreamUserAvatar)); expect(tapped, true); }, ); @@ -183,7 +184,7 @@ void main() { home: StreamChat( client: client, child: Scaffold( - body: ChannelListHeader( + body: StreamChannelListHeader( onUserAvatarTap: (u) { tapped++; }, @@ -197,7 +198,7 @@ void main() { ); await tester.pump(); - await tester.tap(find.byType(UserAvatar)); + await tester.tap(find.byType(StreamUserAvatar)); await tester.tap(find.byType(StreamNeumorphicButton)); expect(tapped, 2); }, diff --git a/packages/stream_chat_flutter/test/src/channel_preview_test.dart b/packages/stream_chat_flutter/test/src/channel_preview_test.dart index 47554605..63116196 100644 --- a/packages/stream_chat_flutter/test/src/channel_preview_test.dart +++ b/packages/stream_chat_flutter/test/src/channel_preview_test.dart @@ -71,7 +71,7 @@ void main() { child: StreamChannel( channel: channel, child: Scaffold( - body: ChannelPreview( + body: StreamChannelPreview( channel: channel, ), ), diff --git a/packages/stream_chat_flutter/test/src/date_divider_test.dart b/packages/stream_chat_flutter/test/src/date_divider_test.dart index f84d4dce..59ba4be1 100644 --- a/packages/stream_chat_flutter/test/src/date_divider_test.dart +++ b/packages/stream_chat_flutter/test/src/date_divider_test.dart @@ -19,7 +19,7 @@ void main() { home: StreamChat( client: client, child: Scaffold( - body: DateDivider( + body: StreamDateDivider( dateTime: DateTime.now(), ), ), diff --git a/packages/stream_chat_flutter/test/src/deleted_message_test.dart b/packages/stream_chat_flutter/test/src/deleted_message_test.dart index 0d86e89c..171b993d 100644 --- a/packages/stream_chat_flutter/test/src/deleted_message_test.dart +++ b/packages/stream_chat_flutter/test/src/deleted_message_test.dart @@ -20,8 +20,8 @@ void main() { home: StreamChat( client: client, child: const Scaffold( - body: DeletedMessage( - messageTheme: MessageThemeData( + body: StreamDeletedMessage( + messageTheme: StreamMessageThemeData( createdAtStyle: TextStyle( color: Colors.black, ), @@ -75,7 +75,7 @@ void main() { showLoading: false, channel: channel, child: Center( - child: DeletedMessage( + child: StreamDeletedMessage( messageTheme: theme.ownMessageTheme, ), ), @@ -128,7 +128,7 @@ void main() { showLoading: false, channel: channel, child: Center( - child: DeletedMessage( + child: StreamDeletedMessage( messageTheme: theme.ownMessageTheme, ), ), @@ -181,7 +181,7 @@ void main() { showLoading: false, channel: channel, child: Center( - child: DeletedMessage( + child: StreamDeletedMessage( messageTheme: theme.ownMessageTheme, reverse: true, shape: RoundedRectangleBorder( diff --git a/packages/stream_chat_flutter/test/src/full_screen_media_test.dart b/packages/stream_chat_flutter/test/src/full_screen_media_test.dart index 2d271090..c17df733 100644 --- a/packages/stream_chat_flutter/test/src/full_screen_media_test.dart +++ b/packages/stream_chat_flutter/test/src/full_screen_media_test.dart @@ -68,7 +68,7 @@ void main() { client: client, child: StreamChannel( channel: channel, - child: FullScreenMedia( + child: StreamFullScreenMedia( mediaAttachments: [ Attachment( type: 'image', diff --git a/packages/stream_chat_flutter/test/src/gradient_avatar_test.dart b/packages/stream_chat_flutter/test/src/gradient_avatar_test.dart index 6dcc0e2d..073adc55 100644 --- a/packages/stream_chat_flutter/test/src/gradient_avatar_test.dart +++ b/packages/stream_chat_flutter/test/src/gradient_avatar_test.dart @@ -25,7 +25,8 @@ void main() { child: SizedBox( width: 100, height: 100, - child: GradientAvatar(name: 'demo user', userId: 'demo123'), + child: StreamGradientAvatar( + name: 'demo user', userId: 'demo123'), ), ), ), @@ -33,7 +34,7 @@ void main() { ), ); - expect(find.byType(GradientAvatar), findsOneWidget); + expect(find.byType(StreamGradientAvatar), findsOneWidget); }, ); @@ -47,7 +48,8 @@ void main() { child: SizedBox( width: 100, height: 100, - child: GradientAvatar(name: 'demo user', userId: 'demo123'), + child: + StreamGradientAvatar(name: 'demo user', userId: 'demo123'), ), ), ), @@ -68,7 +70,7 @@ void main() { child: SizedBox( width: 100, height: 100, - child: GradientAvatar(name: 'demo', userId: 'demo1'), + child: StreamGradientAvatar(name: 'demo', userId: 'demo1'), ), ), ), @@ -89,7 +91,7 @@ void main() { child: SizedBox( width: 100, height: 100, - child: GradientAvatar( + child: StreamGradientAvatar( name: 'd123@/d de:\$as', userId: 'demo123', ), @@ -113,7 +115,8 @@ void main() { child: SizedBox( width: 100, height: 100, - child: GradientAvatar(name: '123@/d \$as', userId: 'demo123'), + child: StreamGradientAvatar( + name: '123@/d \$as', userId: 'demo123'), ), ), ), diff --git a/packages/stream_chat_flutter/test/src/image_footer_test.dart b/packages/stream_chat_flutter/test/src/image_footer_test.dart index 434a78d4..7fe611b8 100644 --- a/packages/stream_chat_flutter/test/src/image_footer_test.dart +++ b/packages/stream_chat_flutter/test/src/image_footer_test.dart @@ -37,7 +37,7 @@ void main() { child: WillPopScope( onWillPop: () async => false, child: Scaffold( - body: GalleryFooter( + body: StreamGalleryFooter( message: Message(), ), ), diff --git a/packages/stream_chat_flutter/test/src/info_tile_test.dart b/packages/stream_chat_flutter/test/src/info_tile_test.dart index f175ca9a..e0687964 100644 --- a/packages/stream_chat_flutter/test/src/info_tile_test.dart +++ b/packages/stream_chat_flutter/test/src/info_tile_test.dart @@ -22,7 +22,7 @@ void main() { child: const Scaffold( body: Portal( child: SizedBox( - child: InfoTile( + child: StreamInfoTile( showMessage: true, message: 'message', child: Text('test'), @@ -52,7 +52,7 @@ void main() { child: const Scaffold( body: Portal( child: SizedBox( - child: InfoTile( + child: StreamInfoTile( showMessage: false, message: 'message', child: Text('test'), diff --git a/packages/stream_chat_flutter/test/src/message_action_modal_test.dart b/packages/stream_chat_flutter/test/src/message_action_modal_test.dart index 69e43fba..e0f8dcb3 100644 --- a/packages/stream_chat_flutter/test/src/message_action_modal_test.dart +++ b/packages/stream_chat_flutter/test/src/message_action_modal_test.dart @@ -34,7 +34,7 @@ void main() { child: SizedBox( child: StreamChannel( channel: channel, - child: MessageActionsModal( + child: StreamMessageActionsModal( message: Message( text: 'test', user: User( @@ -88,7 +88,7 @@ void main() { child: SizedBox( child: StreamChannel( channel: channel, - child: MessageActionsModal( + child: StreamMessageActionsModal( showCopyMessage: false, showReplyMessage: false, showThreadReplyMessage: false, @@ -143,7 +143,7 @@ void main() { child: SizedBox( child: StreamChannel( channel: channel, - child: MessageActionsModal( + child: StreamMessageActionsModal( messageWidget: const Text('test'), message: Message( text: 'test', @@ -153,7 +153,7 @@ void main() { ), messageTheme: streamTheme.ownMessageTheme, customActions: [ - MessageAction( + StreamMessageAction( leading: const Icon(Icons.check), title: const Text('title'), onTap: (m) { @@ -203,7 +203,7 @@ void main() { child: SizedBox( child: StreamChannel( channel: channel, - child: MessageActionsModal( + child: StreamMessageActionsModal( messageWidget: const Text('test'), onReplyTap: (m) { tapped = true; @@ -254,7 +254,7 @@ void main() { child: SizedBox( child: StreamChannel( channel: channel, - child: MessageActionsModal( + child: StreamMessageActionsModal( messageWidget: const Text('test'), onThreadReplyTap: (m) { tapped = true; @@ -309,7 +309,7 @@ void main() { showLoading: false, channel: channel, child: SizedBox( - child: MessageActionsModal( + child: StreamMessageActionsModal( messageWidget: const Text('test'), message: Message( text: 'test', @@ -330,7 +330,7 @@ void main() { await tester.pumpAndSettle(); - expect(find.byType(MessageInput), findsOneWidget); + expect(find.byType(StreamMessageInput), findsOneWidget); }, ); @@ -359,7 +359,7 @@ void main() { showLoading: false, channel: channel, child: SizedBox( - child: MessageActionsModal( + child: StreamMessageActionsModal( messageWidget: const Text('test'), editMessageInputBuilder: (context, m) => const Text('test'), message: Message( @@ -412,7 +412,7 @@ void main() { showLoading: false, channel: channel, child: SizedBox( - child: MessageActionsModal( + child: StreamMessageActionsModal( messageWidget: const Text('test'), onCopyTap: (m) => tapped = true, message: Message( @@ -462,7 +462,7 @@ void main() { showLoading: false, channel: channel, child: SizedBox( - child: MessageActionsModal( + child: StreamMessageActionsModal( messageWidget: const Text('test'), message: Message( status: MessageSendingStatus.failed, @@ -512,7 +512,7 @@ void main() { showLoading: false, channel: channel, child: SizedBox( - child: MessageActionsModal( + child: StreamMessageActionsModal( messageWidget: const Text('test'), message: Message( status: MessageSendingStatus.failed_update, @@ -560,7 +560,7 @@ void main() { showLoading: false, channel: channel, child: SizedBox( - child: MessageActionsModal( + child: StreamMessageActionsModal( messageWidget: const Text('test'), message: Message( id: 'testid', @@ -617,7 +617,7 @@ void main() { showLoading: false, channel: channel, child: SizedBox( - child: MessageActionsModal( + child: StreamMessageActionsModal( messageWidget: const Text('test'), message: Message( id: 'testid', @@ -674,7 +674,7 @@ void main() { showLoading: false, channel: channel, child: SizedBox( - child: MessageActionsModal( + child: StreamMessageActionsModal( messageWidget: const Text('test'), message: Message( id: 'testid', @@ -729,7 +729,7 @@ void main() { showLoading: false, channel: channel, child: SizedBox( - child: MessageActionsModal( + child: StreamMessageActionsModal( messageWidget: const Text('test'), message: Message( id: 'testid', @@ -786,7 +786,7 @@ void main() { showLoading: false, channel: channel, child: SizedBox( - child: MessageActionsModal( + child: StreamMessageActionsModal( messageWidget: const Text('test'), message: Message( id: 'testid', diff --git a/packages/stream_chat_flutter/test/src/message_input_test.dart b/packages/stream_chat_flutter/test/src/message_input_test.dart index 62fe0107..cdedc818 100644 --- a/packages/stream_chat_flutter/test/src/message_input_test.dart +++ b/packages/stream_chat_flutter/test/src/message_input_test.dart @@ -59,7 +59,7 @@ void main() { child: StreamChannel( channel: channel, child: const Scaffold( - body: MessageInput(), + body: StreamMessageInput(), ), ), ), @@ -125,7 +125,7 @@ void main() { child: StreamChannel( channel: channel, child: const Scaffold( - body: MessageInput(), + body: StreamMessageInput(), ), ), ), diff --git a/packages/stream_chat_flutter/test/src/message_list_view_test.dart b/packages/stream_chat_flutter/test/src/message_list_view_test.dart index b82d53b3..08e23820 100644 --- a/packages/stream_chat_flutter/test/src/message_list_view_test.dart +++ b/packages/stream_chat_flutter/test/src/message_list_view_test.dart @@ -54,7 +54,7 @@ void main() { client: client, child: StreamChannel( channel: channel, - child: MessageListView( + child: StreamMessageListView( emptyBuilder: (_) => Container(key: emptyWidgetKey), ), ), @@ -63,7 +63,7 @@ void main() { ); await tester.pumpAndSettle(); - expect(find.byType(MessageListView), findsOneWidget); + expect(find.byType(StreamMessageListView), findsOneWidget); expect(find.byKey(emptyWidgetKey), findsOneWidget); }); @@ -92,7 +92,7 @@ void main() { child: StreamChat( client: client, streamChatThemeData: StreamChatThemeData.light().copyWith( - messageListViewTheme: const MessageListViewThemeData( + messageListViewTheme: const StreamMessageListViewThemeData( backgroundColor: Colors.grey, backgroundImage: DecorationImage( image: AssetImage('images/placeholder.png'), @@ -102,7 +102,7 @@ void main() { ), child: StreamChannel( channel: channel, - child: const MessageListView( + child: const StreamMessageListView( key: nonEmptyWidgetKey, ), ), @@ -118,7 +118,7 @@ void main() { widget.decoration is BoxDecoration && (widget.decoration! as BoxDecoration).image != null; - expect(find.byType(MessageListView), findsOneWidget); + expect(find.byType(StreamMessageListView), findsOneWidget); expect(find.byKey(nonEmptyWidgetKey), findsOneWidget); expect( find.byWidgetPredicate( diff --git a/packages/stream_chat_flutter/test/src/message_reactions_modal_test.dart b/packages/stream_chat_flutter/test/src/message_reactions_modal_test.dart index 14877ce7..31812bf2 100644 --- a/packages/stream_chat_flutter/test/src/message_reactions_modal_test.dart +++ b/packages/stream_chat_flutter/test/src/message_reactions_modal_test.dart @@ -36,7 +36,7 @@ void main() { streamChatThemeData: streamTheme, child: StreamChannel( channel: channel, - child: MessageReactionsModal( + child: StreamMessageReactionsModal( messageWidget: const Text( 'test', key: Key('MessageWidget'), @@ -51,9 +51,9 @@ void main() { await tester.pump(const Duration(milliseconds: 1000)); - expect(find.byType(ReactionBubble), findsNothing); + expect(find.byType(StreamReactionBubble), findsNothing); - expect(find.byType(UserAvatar), findsNothing); + expect(find.byType(StreamUserAvatar), findsNothing); }, ); @@ -96,7 +96,7 @@ void main() { streamChatThemeData: streamTheme, child: StreamChannel( channel: channel, - child: MessageReactionsModal( + child: StreamMessageReactionsModal( messageWidget: const Text( 'test', key: Key('MessageWidget'), @@ -116,8 +116,8 @@ void main() { expect(find.byKey(const Key('MessageWidget')), findsOneWidget); - expect(find.byType(ReactionBubble), findsOneWidget); - expect(find.byType(UserAvatar), findsOneWidget); + expect(find.byType(StreamReactionBubble), findsOneWidget); + expect(find.byType(StreamUserAvatar), findsOneWidget); }, ); } diff --git a/packages/stream_chat_flutter/test/src/message_text_test.dart b/packages/stream_chat_flutter/test/src/message_text_test.dart index 57f0a282..8f2d4c10 100644 --- a/packages/stream_chat_flutter/test/src/message_text_test.dart +++ b/packages/stream_chat_flutter/test/src/message_text_test.dart @@ -65,7 +65,7 @@ void main() { child: StreamChannel( channel: channel, child: Scaffold( - body: MessageText( + body: StreamMessageText( message: Message( text: 'demo', ), @@ -84,7 +84,7 @@ void main() { final clientState = MockClientState(); final channel = MockChannel(); final channelState = MockChannelState(); - const messageTheme = MessageThemeData(); + const messageTheme = StreamMessageThemeData(); final currentUser = OwnUser( id: 'sahil', @@ -122,7 +122,7 @@ void main() { child: StreamChannel( channel: channel, child: Scaffold( - body: MessageText( + body: StreamMessageText( message: message, messageTheme: messageTheme, ), @@ -158,7 +158,7 @@ void main() { child: StreamChannel( channel: channel, child: Scaffold( - body: MessageText( + body: StreamMessageText( message: message, messageTheme: messageTheme, ), @@ -221,7 +221,7 @@ cool.'''; child: StreamChannel( channel: channel, child: Scaffold( - body: MessageText( + body: StreamMessageText( message: Message( text: messageText, ), diff --git a/packages/stream_chat_flutter/test/src/reaction_bubble_test.dart b/packages/stream_chat_flutter/test/src/reaction_bubble_test.dart index 6e823b43..50719b17 100644 --- a/packages/stream_chat_flutter/test/src/reaction_bubble_test.dart +++ b/packages/stream_chat_flutter/test/src/reaction_bubble_test.dart @@ -25,7 +25,7 @@ void main() { streamChatThemeData: theme, connectivityStream: Stream.value(ConnectivityResult.mobile), child: SizedBox( - child: ReactionBubble( + child: StreamReactionBubble( reactions: [ Reaction( type: 'like', @@ -62,7 +62,7 @@ void main() { connectivityStream: Stream.value(ConnectivityResult.mobile), child: Container( color: Colors.black, - child: ReactionBubble( + child: StreamReactionBubble( reactions: [ Reaction( type: 'like', @@ -99,7 +99,7 @@ void main() { connectivityStream: Stream.value(ConnectivityResult.mobile), child: Container( color: Colors.black, - child: ReactionBubble( + child: StreamReactionBubble( reactions: [ Reaction( type: 'like', @@ -144,7 +144,7 @@ void main() { connectivityStream: Stream.value(ConnectivityResult.mobile), child: Container( color: Colors.black, - child: ReactionBubble( + child: StreamReactionBubble( reactions: [ Reaction( type: 'like', @@ -187,7 +187,7 @@ void main() { connectivityStream: Stream.value(ConnectivityResult.mobile), streamChatThemeData: StreamChatThemeData.fromTheme(themeData), child: SizedBox( - child: ReactionBubble( + child: StreamReactionBubble( reactions: [ Reaction( type: 'like', diff --git a/packages/stream_chat_flutter/test/src/system_message_test.dart b/packages/stream_chat_flutter/test/src/system_message_test.dart index 24eccdf6..c723ff24 100644 --- a/packages/stream_chat_flutter/test/src/system_message_test.dart +++ b/packages/stream_chat_flutter/test/src/system_message_test.dart @@ -40,7 +40,7 @@ void main() { child: StreamChannel( channel: channel, child: Scaffold( - body: SystemMessage( + body: StreamSystemMessage( onMessageTap: (m) => tapped = true, message: Message( text: 'demo message', @@ -51,7 +51,7 @@ void main() { ), )); - await tester.tap(find.byType(SystemMessage)); + await tester.tap(find.byType(StreamSystemMessage)); expect(find.text('demo message'), findsOneWidget); expect(tapped, true); @@ -94,7 +94,7 @@ void main() { showLoading: false, channel: channel, child: Center( - child: SystemMessage( + child: StreamSystemMessage( message: Message( text: 'demo message', ), @@ -146,7 +146,7 @@ void main() { showLoading: false, channel: channel, child: Center( - child: SystemMessage( + child: StreamSystemMessage( message: Message( text: 'demo message', ), diff --git a/packages/stream_chat_flutter/test/src/theme/avatar_theme_test.dart b/packages/stream_chat_flutter/test/src/theme/avatar_theme_test.dart index 63e6da86..8d055d52 100644 --- a/packages/stream_chat_flutter/test/src/theme/avatar_theme_test.dart +++ b/packages/stream_chat_flutter/test/src/theme/avatar_theme_test.dart @@ -4,22 +4,23 @@ import 'package:stream_chat_flutter/stream_chat_flutter.dart'; void main() { test('AvatarThemeData copyWith, ==, hashCode basics', () { - expect(const AvatarThemeData(), const AvatarThemeData().copyWith()); - expect(const AvatarThemeData().hashCode, - const AvatarThemeData().copyWith().hashCode); + expect(const StreamAvatarThemeData(), + const StreamAvatarThemeData().copyWith()); + expect(const StreamAvatarThemeData().hashCode, + const StreamAvatarThemeData().copyWith().hashCode); }); group('AvatarThemeData lerps correctly', () { test('Lerp completely', () { expect( - const AvatarThemeData() + const StreamAvatarThemeData() .lerp(_avatarThemeDataControl1, _avatarThemeDataControl2, 1), _avatarThemeDataControl2); }); test('Lerp halfway', () { expect( - const AvatarThemeData() + const StreamAvatarThemeData() .lerp(_avatarThemeDataControl1, _avatarThemeDataControl2, 0.5), _avatarThemeDataControlMidLerp); }); @@ -31,9 +32,9 @@ void main() { }); } -const _avatarThemeDataControl1 = AvatarThemeData(); +const _avatarThemeDataControl1 = StreamAvatarThemeData(); -final _avatarThemeDataControlMidLerp = AvatarThemeData( +final _avatarThemeDataControlMidLerp = StreamAvatarThemeData( borderRadius: BorderRadius.circular(16), constraints: const BoxConstraints.tightFor( height: 33, @@ -41,7 +42,7 @@ final _avatarThemeDataControlMidLerp = AvatarThemeData( ), ); -final _avatarThemeDataControl2 = AvatarThemeData( +final _avatarThemeDataControl2 = StreamAvatarThemeData( borderRadius: BorderRadius.circular(12), constraints: const BoxConstraints.tightFor( height: 34, diff --git a/packages/stream_chat_flutter/test/src/theme/channel_header_theme_test.dart b/packages/stream_chat_flutter/test/src/theme/channel_header_theme_test.dart index 475b1084..1b5499dd 100644 --- a/packages/stream_chat_flutter/test/src/theme/channel_header_theme_test.dart +++ b/packages/stream_chat_flutter/test/src/theme/channel_header_theme_test.dart @@ -4,10 +4,10 @@ import 'package:stream_chat_flutter/stream_chat_flutter.dart'; void main() { test('ChannelHeaderThemeData copyWith, ==, hashCode basics', () { - expect(const ChannelHeaderThemeData(), - const ChannelHeaderThemeData().copyWith()); - expect(const ChannelHeaderThemeData().hashCode, - const ChannelHeaderThemeData().copyWith().hashCode); + expect(const StreamChannelHeaderThemeData(), + const StreamChannelHeaderThemeData().copyWith()); + expect(const StreamChannelHeaderThemeData().hashCode, + const StreamChannelHeaderThemeData().copyWith().hashCode); }); group('ChannelHeaderThemeData lerps', () { @@ -15,7 +15,7 @@ void main() { '''Light ChannelHeaderThemeData lerps completely to dark ChannelHeaderThemeData''', () { expect( - const ChannelHeaderThemeData() + const StreamChannelHeaderThemeData() .lerp(_channelThemeControl, _channelThemeControlDark, 1), _channelThemeControlDark); }); @@ -24,7 +24,7 @@ void main() { '''Light ChannelHeaderThemeData lerps halfway to dark ChannelHeaderThemeData''', () { expect( - const ChannelHeaderThemeData() + const StreamChannelHeaderThemeData() .lerp(_channelThemeControl, _channelThemeControlDark, 0.5), _channelThemeControlMidLerp); }); @@ -33,7 +33,7 @@ void main() { '''Dark ChannelHeaderThemeData lerps completely to light ChannelHeaderThemeData''', () { expect( - const ChannelHeaderThemeData() + const StreamChannelHeaderThemeData() .lerp(_channelThemeControlDark, _channelThemeControl, 1), _channelThemeControl); }); @@ -45,8 +45,8 @@ void main() { }); } -final _channelThemeControl = ChannelHeaderThemeData( - avatarTheme: AvatarThemeData( +final _channelThemeControl = StreamChannelHeaderThemeData( + avatarTheme: StreamAvatarThemeData( borderRadius: BorderRadius.circular(20), constraints: const BoxConstraints.tightFor( height: 40, @@ -54,16 +54,16 @@ final _channelThemeControl = ChannelHeaderThemeData( ), ), color: const Color(0xff101418), - titleStyle: TextTheme.light().headlineBold.copyWith( + titleStyle: StreamTextTheme.light().headlineBold.copyWith( color: const Color(0xffffffff), ), - subtitleStyle: TextTheme.light().footnote.copyWith( + subtitleStyle: StreamTextTheme.light().footnote.copyWith( color: const Color(0xff7a7a7a), ), ); -final _channelThemeControlMidLerp = ChannelHeaderThemeData( - avatarTheme: AvatarThemeData( +final _channelThemeControlMidLerp = StreamChannelHeaderThemeData( + avatarTheme: StreamAvatarThemeData( borderRadius: BorderRadius.circular(20), constraints: const BoxConstraints.tightFor( height: 40, @@ -76,22 +76,22 @@ final _channelThemeControlMidLerp = ChannelHeaderThemeData( fontWeight: FontWeight.bold, fontSize: 16, ), - subtitleStyle: TextTheme.light().footnote.copyWith( + subtitleStyle: StreamTextTheme.light().footnote.copyWith( color: const Color(0xff7a7a7a), ), ); -final _channelThemeControlDark = ChannelHeaderThemeData( - avatarTheme: AvatarThemeData( +final _channelThemeControlDark = StreamChannelHeaderThemeData( + avatarTheme: StreamAvatarThemeData( borderRadius: BorderRadius.circular(20), constraints: const BoxConstraints.tightFor( height: 40, width: 40, ), ), - color: ColorTheme.dark().barsBg, - titleStyle: TextTheme.dark().headlineBold, - subtitleStyle: TextTheme.dark().footnote.copyWith( + color: StreamColorTheme.dark().barsBg, + titleStyle: StreamTextTheme.dark().headlineBold, + subtitleStyle: StreamTextTheme.dark().footnote.copyWith( color: const Color(0xff7A7A7A), ), ); diff --git a/packages/stream_chat_flutter/test/src/theme/channel_list_header_theme_test.dart b/packages/stream_chat_flutter/test/src/theme/channel_list_header_theme_test.dart index aa378f3a..14c09706 100644 --- a/packages/stream_chat_flutter/test/src/theme/channel_list_header_theme_test.dart +++ b/packages/stream_chat_flutter/test/src/theme/channel_list_header_theme_test.dart @@ -4,10 +4,10 @@ import 'package:stream_chat_flutter/stream_chat_flutter.dart'; void main() { test('ChannelListHeaderThemeData copyWith, ==, hashCode basics', () { - expect(const ChannelListHeaderThemeData(), - const ChannelListHeaderThemeData().copyWith()); - expect(const ChannelListHeaderThemeData().hashCode, - const ChannelListHeaderThemeData().copyWith().hashCode); + expect(const StreamChannelListHeaderThemeData(), + const StreamChannelListHeaderThemeData().copyWith()); + expect(const StreamChannelListHeaderThemeData().hashCode, + const StreamChannelListHeaderThemeData().copyWith().hashCode); }); group('ChannelListHeaderThemeData lerps', () { @@ -15,7 +15,7 @@ void main() { '''Light ChannelListHeaderThemeData lerps completely to dark ChannelListHeaderThemeData''', () { expect( - const ChannelListHeaderThemeData().lerp( + const StreamChannelListHeaderThemeData().lerp( _channelListHeaderThemeControl, _channelListHeaderThemeControlDark, 1), @@ -26,7 +26,7 @@ void main() { '''Light ChannelListHeaderThemeData lerps halfway to dark ChannelListHeaderThemeData''', () { expect( - const ChannelListHeaderThemeData().lerp( + const StreamChannelListHeaderThemeData().lerp( _channelListHeaderThemeControl, _channelListHeaderThemeControlDark, 0.5), @@ -37,7 +37,7 @@ void main() { '''Dark ChannelListHeaderThemeData lerps completely to light ChannelListHeaderThemeData''', () { expect( - const ChannelListHeaderThemeData().lerp( + const StreamChannelListHeaderThemeData().lerp( _channelListHeaderThemeControlDark, _channelListHeaderThemeControl, 1), @@ -53,20 +53,20 @@ void main() { }); } -final _channelListHeaderThemeControl = ChannelListHeaderThemeData( - avatarTheme: AvatarThemeData( +final _channelListHeaderThemeControl = StreamChannelListHeaderThemeData( + avatarTheme: StreamAvatarThemeData( borderRadius: BorderRadius.circular(20), constraints: const BoxConstraints.tightFor( height: 40, width: 40, ), ), - color: ColorTheme.light().barsBg, - titleStyle: TextTheme.light().headlineBold, + color: StreamColorTheme.light().barsBg, + titleStyle: StreamTextTheme.light().headlineBold, ); -final _channelListHeaderThemeControlMidLerp = ChannelListHeaderThemeData( - avatarTheme: AvatarThemeData( +final _channelListHeaderThemeControlMidLerp = StreamChannelListHeaderThemeData( + avatarTheme: StreamAvatarThemeData( borderRadius: BorderRadius.circular(20), constraints: const BoxConstraints.tightFor( height: 40, @@ -81,14 +81,14 @@ final _channelListHeaderThemeControlMidLerp = ChannelListHeaderThemeData( ), ); -final _channelListHeaderThemeControlDark = ChannelListHeaderThemeData( - avatarTheme: AvatarThemeData( +final _channelListHeaderThemeControlDark = StreamChannelListHeaderThemeData( + avatarTheme: StreamAvatarThemeData( borderRadius: BorderRadius.circular(20), constraints: const BoxConstraints.tightFor( height: 40, width: 40, ), ), - color: ColorTheme.dark().barsBg, - titleStyle: TextTheme.dark().headlineBold, + color: StreamColorTheme.dark().barsBg, + titleStyle: StreamTextTheme.dark().headlineBold, ); diff --git a/packages/stream_chat_flutter/test/src/theme/channel_list_view_theme_test.dart b/packages/stream_chat_flutter/test/src/theme/channel_list_view_theme_test.dart index 079c01e3..37de3140 100644 --- a/packages/stream_chat_flutter/test/src/theme/channel_list_view_theme_test.dart +++ b/packages/stream_chat_flutter/test/src/theme/channel_list_view_theme_test.dart @@ -6,16 +6,18 @@ import '../mocks.dart'; void main() { test('ChannelListViewThemeData copyWith, ==, hashCode basics', () { - expect(const ChannelListViewThemeData(), - const ChannelListViewThemeData().copyWith()); + expect(const StreamChannelListViewThemeData(), + const StreamChannelListViewThemeData().copyWith()); }); test( '''Light ChannelListViewThemeData lerps completely to dark ChannelListViewThemeData''', () { expect( - const ChannelListViewThemeData().lerp(_channelListViewThemeDataControl, - _channelListViewThemeDataControlDark, 1), + const StreamChannelListViewThemeData().lerp( + _channelListViewThemeDataControl, + _channelListViewThemeDataControlDark, + 1), _channelListViewThemeDataControlDark); }); @@ -23,8 +25,10 @@ void main() { '''Light ChannelListViewThemeData lerps halfway to dark ChannelListViewThemeData''', () { expect( - const ChannelListViewThemeData().lerp(_channelListViewThemeDataControl, - _channelListViewThemeDataControlDark, 0.5), + const StreamChannelListViewThemeData().lerp( + _channelListViewThemeDataControl, + _channelListViewThemeDataControlDark, + 0.5), _channelListViewThemeDataControlHalfLerp); }); @@ -32,7 +36,7 @@ void main() { '''Dark ChannelListViewThemeData lerps completely to light ChannelListViewThemeData''', () { expect( - const ChannelListViewThemeData().lerp( + const StreamChannelListViewThemeData().lerp( _channelListViewThemeDataControlDark, _channelListViewThemeDataControl, 1), @@ -70,7 +74,7 @@ void main() { ), ); - final channelListViewTheme = ChannelListViewTheme.of(_context); + final channelListViewTheme = StreamChannelListViewTheme.of(_context); expect(channelListViewTheme.backgroundColor, _channelListViewThemeDataControl.backgroundColor); }); @@ -92,7 +96,7 @@ void main() { return Scaffold( body: StreamChannel( channel: MockChannel(), - child: const MessageListView(), + child: const StreamMessageListView(), ), ); }, @@ -100,20 +104,20 @@ void main() { ), ); - final channelListViewTheme = ChannelListViewTheme.of(_context); + final channelListViewTheme = StreamChannelListViewTheme.of(_context); expect(channelListViewTheme.backgroundColor, _channelListViewThemeDataControlDark.backgroundColor); }); } -final _channelListViewThemeDataControl = ChannelListViewThemeData( - backgroundColor: ColorTheme.light().appBg, +final _channelListViewThemeDataControl = StreamChannelListViewThemeData( + backgroundColor: StreamColorTheme.light().appBg, ); -const _channelListViewThemeDataControlHalfLerp = ChannelListViewThemeData( +const _channelListViewThemeDataControlHalfLerp = StreamChannelListViewThemeData( backgroundColor: Color(0xff818384), ); -final _channelListViewThemeDataControlDark = ChannelListViewThemeData( - backgroundColor: ColorTheme.dark().appBg, +final _channelListViewThemeDataControlDark = StreamChannelListViewThemeData( + backgroundColor: StreamColorTheme.dark().appBg, ); diff --git a/packages/stream_chat_flutter/test/src/theme/channel_preview_theme_test.dart b/packages/stream_chat_flutter/test/src/theme/channel_preview_theme_test.dart index dc5c0529..782be835 100644 --- a/packages/stream_chat_flutter/test/src/theme/channel_preview_theme_test.dart +++ b/packages/stream_chat_flutter/test/src/theme/channel_preview_theme_test.dart @@ -4,10 +4,10 @@ import 'package:stream_chat_flutter/stream_chat_flutter.dart'; void main() { test('ChannelPreviewThemeData copyWith, ==, hashCode basics', () { - expect(const ChannelPreviewThemeData(), - const ChannelPreviewThemeData().copyWith()); - expect(const ChannelPreviewThemeData().hashCode, - const ChannelPreviewThemeData().copyWith().hashCode); + expect(const StreamChannelPreviewThemeData(), + const StreamChannelPreviewThemeData().copyWith()); + expect(const StreamChannelPreviewThemeData().hashCode, + const StreamChannelPreviewThemeData().copyWith().hashCode); }); group('ChannelPreviewThemeData lerps', () { @@ -15,7 +15,7 @@ void main() { '''Light ChannelPreviewThemeData lerps completely to dark ChannelPreviewThemeData''', () { expect( - const ChannelPreviewThemeData().lerp( + const StreamChannelPreviewThemeData().lerp( _channelPreviewThemeControl, _channelPreviewThemeControlDark, 1), _channelPreviewThemeControlDark); }); @@ -24,8 +24,10 @@ void main() { '''Light ChannelPreviewThemeData lerps halfway to dark ChannelPreviewThemeData''', () { expect( - const ChannelPreviewThemeData().lerp(_channelPreviewThemeControl, - _channelPreviewThemeControlDark, 0.5), + const StreamChannelPreviewThemeData().lerp( + _channelPreviewThemeControl, + _channelPreviewThemeControlDark, + 0.5), _channelPreviewThemeControlMidLerp); }); @@ -33,7 +35,7 @@ void main() { '''Dark ChannelPreviewThemeData lerps completely to light ChannelPreviewThemeData''', () { expect( - const ChannelPreviewThemeData().lerp( + const StreamChannelPreviewThemeData().lerp( _channelPreviewThemeControlDark, _channelPreviewThemeControl, 1), _channelPreviewThemeControl); }); @@ -45,28 +47,28 @@ void main() { }); } -final _channelPreviewThemeControl = ChannelPreviewThemeData( - unreadCounterColor: ColorTheme.light().accentError, - avatarTheme: AvatarThemeData( +final _channelPreviewThemeControl = StreamChannelPreviewThemeData( + unreadCounterColor: StreamColorTheme.light().accentError, + avatarTheme: StreamAvatarThemeData( borderRadius: BorderRadius.circular(20), constraints: const BoxConstraints.tightFor( height: 40, width: 40, ), ), - titleStyle: TextTheme.light().bodyBold, - subtitleStyle: TextTheme.light().footnote.copyWith( + titleStyle: StreamTextTheme.light().bodyBold, + subtitleStyle: StreamTextTheme.light().footnote.copyWith( color: const Color(0xff7A7A7A), ), - lastMessageAtStyle: TextTheme.light().footnote.copyWith( - color: ColorTheme.light().textHighEmphasis.withOpacity(0.5), + lastMessageAtStyle: StreamTextTheme.light().footnote.copyWith( + color: StreamColorTheme.light().textHighEmphasis.withOpacity(0.5), ), indicatorIconSize: 16, ); -final _channelPreviewThemeControlMidLerp = ChannelPreviewThemeData( +final _channelPreviewThemeControlMidLerp = StreamChannelPreviewThemeData( unreadCounterColor: const Color(0xffff3742), - avatarTheme: AvatarThemeData( + avatarTheme: StreamAvatarThemeData( borderRadius: BorderRadius.circular(20), constraints: const BoxConstraints.tightFor( height: 40, @@ -82,27 +84,27 @@ final _channelPreviewThemeControlMidLerp = ChannelPreviewThemeData( color: Color(0xff7a7a7a), fontSize: 12, ), - lastMessageAtStyle: TextTheme.light().footnote.copyWith( + lastMessageAtStyle: StreamTextTheme.light().footnote.copyWith( color: const Color(0x807f7f7f).withOpacity(0.5), ), indicatorIconSize: 16, ); -final _channelPreviewThemeControlDark = ChannelPreviewThemeData( - unreadCounterColor: ColorTheme.dark().accentError, - avatarTheme: AvatarThemeData( +final _channelPreviewThemeControlDark = StreamChannelPreviewThemeData( + unreadCounterColor: StreamColorTheme.dark().accentError, + avatarTheme: StreamAvatarThemeData( borderRadius: BorderRadius.circular(20), constraints: const BoxConstraints.tightFor( height: 40, width: 40, ), ), - titleStyle: TextTheme.dark().bodyBold, - subtitleStyle: TextTheme.dark().footnote.copyWith( + titleStyle: StreamTextTheme.dark().bodyBold, + subtitleStyle: StreamTextTheme.dark().footnote.copyWith( color: const Color(0xff7A7A7A), ), - lastMessageAtStyle: TextTheme.dark().footnote.copyWith( - color: ColorTheme.dark().textHighEmphasis.withOpacity(0.5), + lastMessageAtStyle: StreamTextTheme.dark().footnote.copyWith( + color: StreamColorTheme.dark().textHighEmphasis.withOpacity(0.5), ), indicatorIconSize: 16, ); diff --git a/packages/stream_chat_flutter/test/src/theme/gallery_footer_theme_test.dart b/packages/stream_chat_flutter/test/src/theme/gallery_footer_theme_test.dart index 6a73e34e..0193cb35 100644 --- a/packages/stream_chat_flutter/test/src/theme/gallery_footer_theme_test.dart +++ b/packages/stream_chat_flutter/test/src/theme/gallery_footer_theme_test.dart @@ -7,18 +7,20 @@ class MockStreamChatClient extends Mock implements StreamChatClient {} void main() { test('GalleryFooterThemeData copyWith, ==, hashCode basics', () { - expect(const GalleryFooterThemeData(), - const GalleryFooterThemeData().copyWith()); - expect(const GalleryFooterThemeData().hashCode, - const GalleryFooterThemeData().copyWith().hashCode); + expect(const StreamGalleryFooterThemeData(), + const StreamGalleryFooterThemeData().copyWith()); + expect(const StreamGalleryFooterThemeData().hashCode, + const StreamGalleryFooterThemeData().copyWith().hashCode); }); test( '''Light GalleryFooterThemeData lerps completely to dark GalleryFooterThemeData''', () { expect( - const GalleryFooterThemeData().lerp(_galleryFooterThemeDataControl, - _galleryFooterThemeDataControlDark, 1), + const StreamGalleryFooterThemeData().lerp( + _galleryFooterThemeDataControl, + _galleryFooterThemeDataControlDark, + 1), _galleryFooterThemeDataControlDark); }); @@ -26,8 +28,10 @@ void main() { '''Light GalleryFooterThemeData lerps halfway to dark GalleryFooterThemeData''', () { expect( - const GalleryFooterThemeData().lerp(_galleryFooterThemeDataControl, - _galleryFooterThemeDataControlDark, 0.5), + const StreamGalleryFooterThemeData().lerp( + _galleryFooterThemeDataControl, + _galleryFooterThemeDataControlDark, + 0.5), _galleryFooterThemeDataControlMidLerp); }); @@ -35,8 +39,10 @@ void main() { '''Dark GalleryFooterThemeData lerps completely to light GalleryFooterThemeData''', () { expect( - const GalleryFooterThemeData().lerp(_galleryFooterThemeDataControlDark, - _galleryFooterThemeDataControl, 1), + const StreamGalleryFooterThemeData().lerp( + _galleryFooterThemeDataControlDark, + _galleryFooterThemeDataControl, + 1), _galleryFooterThemeDataControl); }); @@ -68,7 +74,7 @@ void main() { builder: (context) { _context = context; return Scaffold( - appBar: GalleryFooter( + appBar: StreamGalleryFooter( message: Message(), ), ); @@ -77,7 +83,7 @@ void main() { ), ); - final imageFooterTheme = GalleryFooterTheme.of(_context); + final imageFooterTheme = StreamGalleryFooterTheme.of(_context); expect(imageFooterTheme.backgroundColor, _galleryFooterThemeDataControl.backgroundColor); expect(imageFooterTheme.shareIconColor, @@ -111,7 +117,7 @@ void main() { builder: (context) { _context = context; return Scaffold( - appBar: GalleryFooter( + appBar: StreamGalleryFooter( message: Message(), ), ); @@ -120,7 +126,7 @@ void main() { ), ); - final imageFooterTheme = GalleryFooterTheme.of(_context); + final imageFooterTheme = StreamGalleryFooterTheme.of(_context); expect(imageFooterTheme.backgroundColor, _galleryFooterThemeDataControlDark.backgroundColor); expect(imageFooterTheme.shareIconColor, @@ -141,19 +147,19 @@ void main() { } // Light theme control -final _galleryFooterThemeDataControl = GalleryFooterThemeData( - backgroundColor: ColorTheme.light().barsBg, - shareIconColor: ColorTheme.light().textHighEmphasis, - titleTextStyle: TextTheme.light().headlineBold, - gridIconButtonColor: ColorTheme.light().textHighEmphasis, - bottomSheetBackgroundColor: ColorTheme.light().barsBg, - bottomSheetBarrierColor: ColorTheme.light().overlay, - bottomSheetCloseIconColor: ColorTheme.light().textHighEmphasis, - bottomSheetPhotosTextStyle: TextTheme.light().headlineBold, +final _galleryFooterThemeDataControl = StreamGalleryFooterThemeData( + backgroundColor: StreamColorTheme.light().barsBg, + shareIconColor: StreamColorTheme.light().textHighEmphasis, + titleTextStyle: StreamTextTheme.light().headlineBold, + gridIconButtonColor: StreamColorTheme.light().textHighEmphasis, + bottomSheetBackgroundColor: StreamColorTheme.light().barsBg, + bottomSheetBarrierColor: StreamColorTheme.light().overlay, + bottomSheetCloseIconColor: StreamColorTheme.light().textHighEmphasis, + bottomSheetPhotosTextStyle: StreamTextTheme.light().headlineBold, ); // Mid-lerp theme control -const _galleryFooterThemeDataControlMidLerp = GalleryFooterThemeData( +const _galleryFooterThemeDataControlMidLerp = StreamGalleryFooterThemeData( backgroundColor: Color(0xff87898b), shareIconColor: Color(0xff7f7f7f), titleTextStyle: TextStyle( @@ -173,13 +179,13 @@ const _galleryFooterThemeDataControlMidLerp = GalleryFooterThemeData( ); // Dark theme control -final _galleryFooterThemeDataControlDark = GalleryFooterThemeData( - backgroundColor: ColorTheme.dark().barsBg, - shareIconColor: ColorTheme.dark().textHighEmphasis, - titleTextStyle: TextTheme.dark().headlineBold, - gridIconButtonColor: ColorTheme.dark().textHighEmphasis, - bottomSheetBackgroundColor: ColorTheme.dark().barsBg, - bottomSheetBarrierColor: ColorTheme.dark().overlay, - bottomSheetCloseIconColor: ColorTheme.dark().textHighEmphasis, - bottomSheetPhotosTextStyle: TextTheme.dark().headlineBold, +final _galleryFooterThemeDataControlDark = StreamGalleryFooterThemeData( + backgroundColor: StreamColorTheme.dark().barsBg, + shareIconColor: StreamColorTheme.dark().textHighEmphasis, + titleTextStyle: StreamTextTheme.dark().headlineBold, + gridIconButtonColor: StreamColorTheme.dark().textHighEmphasis, + bottomSheetBackgroundColor: StreamColorTheme.dark().barsBg, + bottomSheetBarrierColor: StreamColorTheme.dark().overlay, + bottomSheetCloseIconColor: StreamColorTheme.dark().textHighEmphasis, + bottomSheetPhotosTextStyle: StreamTextTheme.dark().headlineBold, ); diff --git a/packages/stream_chat_flutter/test/src/theme/gallery_header_theme_test.dart b/packages/stream_chat_flutter/test/src/theme/gallery_header_theme_test.dart index 534008ba..0ded6bbf 100644 --- a/packages/stream_chat_flutter/test/src/theme/gallery_header_theme_test.dart +++ b/packages/stream_chat_flutter/test/src/theme/gallery_header_theme_test.dart @@ -7,18 +7,20 @@ class MockStreamChatClient extends Mock implements StreamChatClient {} void main() { test('GalleryHeaderThemeData copyWith, ==, hashCode basics', () { - expect(const GalleryHeaderThemeData(), - const GalleryHeaderThemeData().copyWith()); - expect(const GalleryHeaderThemeData().hashCode, - const GalleryHeaderThemeData().copyWith().hashCode); + expect(const StreamGalleryHeaderThemeData(), + const StreamGalleryHeaderThemeData().copyWith()); + expect(const StreamGalleryHeaderThemeData().hashCode, + const StreamGalleryHeaderThemeData().copyWith().hashCode); }); test( '''Light GalleryHeaderThemeData lerps completely to dark GalleryHeaderThemeData''', () { expect( - const GalleryHeaderThemeData().lerp(_galleryHeaderThemeDataControl, - _galleryHeaderThemeDataDarkControl, 1), + const StreamGalleryHeaderThemeData().lerp( + _galleryHeaderThemeDataControl, + _galleryHeaderThemeDataDarkControl, + 1), _galleryHeaderThemeDataDarkControl); }); @@ -26,8 +28,10 @@ void main() { '''Light GalleryHeaderThemeData lerps halfway to dark GalleryHeaderThemeData''', () { expect( - const GalleryHeaderThemeData().lerp(_galleryHeaderThemeDataControl, - _galleryHeaderThemeDataDarkControl, 0.5), + const StreamGalleryHeaderThemeData().lerp( + _galleryHeaderThemeDataControl, + _galleryHeaderThemeDataDarkControl, + 0.5), _galleryHeaderThemeDataHalfLerpControl); }); @@ -35,8 +39,10 @@ void main() { '''Dark GalleryHeaderThemeData lerps completely to light GalleryHeaderThemeData''', () { expect( - const GalleryHeaderThemeData().lerp(_galleryHeaderThemeDataDarkControl, - _galleryHeaderThemeDataControl, 1), + const StreamGalleryHeaderThemeData().lerp( + _galleryHeaderThemeDataDarkControl, + _galleryHeaderThemeDataControl, + 1), _galleryHeaderThemeDataControl); }); @@ -61,7 +67,7 @@ void main() { builder: (context) { _context = context; return Scaffold( - appBar: GalleryHeader( + appBar: StreamGalleryHeader( message: Message(), ), ); @@ -70,7 +76,7 @@ void main() { ), ); - final imageHeaderTheme = GalleryHeaderTheme.of(_context); + final imageHeaderTheme = StreamGalleryHeaderTheme.of(_context); expect(imageHeaderTheme.closeButtonColor, _galleryHeaderThemeDataControl.closeButtonColor); expect(imageHeaderTheme.backgroundColor, @@ -100,7 +106,7 @@ void main() { builder: (context) { _context = context; return Scaffold( - appBar: GalleryHeader( + appBar: StreamGalleryHeader( message: Message(), ), ); @@ -109,7 +115,7 @@ void main() { ), ); - final imageHeaderTheme = GalleryHeaderTheme.of(_context); + final imageHeaderTheme = StreamGalleryHeaderTheme.of(_context); expect(imageHeaderTheme.closeButtonColor, _galleryHeaderThemeDataDarkControl.closeButtonColor); expect(imageHeaderTheme.backgroundColor, @@ -126,7 +132,7 @@ void main() { } // Light theme test control. -final _galleryHeaderThemeDataControl = GalleryHeaderThemeData( +final _galleryHeaderThemeDataControl = StreamGalleryHeaderThemeData( closeButtonColor: const Color(0xff000000), backgroundColor: const Color(0xffffffff), iconMenuPointColor: const Color(0xff000000), @@ -145,7 +151,7 @@ final _galleryHeaderThemeDataControl = GalleryHeaderThemeData( ); // Light theme test control. -final _galleryHeaderThemeDataHalfLerpControl = GalleryHeaderThemeData( +final _galleryHeaderThemeDataHalfLerpControl = StreamGalleryHeaderThemeData( closeButtonColor: const Color(0xff7f7f7f), backgroundColor: const Color(0xff87898b), iconMenuPointColor: const Color(0xff7f7f7f), @@ -164,7 +170,7 @@ final _galleryHeaderThemeDataHalfLerpControl = GalleryHeaderThemeData( ); // Dark theme test control. -final _galleryHeaderThemeDataDarkControl = GalleryHeaderThemeData( +final _galleryHeaderThemeDataDarkControl = StreamGalleryHeaderThemeData( closeButtonColor: const Color(0xffffffff), backgroundColor: const Color(0xff101418), iconMenuPointColor: const Color(0xffffffff), diff --git a/packages/stream_chat_flutter/test/src/theme/message_input_theme_test.dart b/packages/stream_chat_flutter/test/src/theme/message_input_theme_test.dart index c618d65c..3c62baea 100644 --- a/packages/stream_chat_flutter/test/src/theme/message_input_theme_test.dart +++ b/packages/stream_chat_flutter/test/src/theme/message_input_theme_test.dart @@ -4,30 +4,30 @@ import 'package:stream_chat_flutter/stream_chat_flutter.dart'; void main() { test('MessageInputThemeData copyWith, ==, hashCode basics', () { - expect(const MessageInputThemeData(), - const MessageInputThemeData().copyWith()); - expect(const MessageInputThemeData().hashCode, - const MessageInputThemeData().copyWith().hashCode); + expect(const StreamMessageInputThemeData(), + const StreamMessageInputThemeData().copyWith()); + expect(const StreamMessageInputThemeData().hashCode, + const StreamMessageInputThemeData().copyWith().hashCode); }); group('MessageInputThemeData lerps correctly', () { test('Lerp completely from light to dark', () { expect( - const MessageInputThemeData().lerp( + const StreamMessageInputThemeData().lerp( _messageInputThemeControl, _messageInputThemeControlDark, 1), _messageInputThemeControlDark); }); test('Lerp halfway from light to dark', () { expect( - const MessageInputThemeData().lerp( + const StreamMessageInputThemeData().lerp( _messageInputThemeControl, _messageInputThemeControlDark, 0.5), _messageInputThemeControlMidLerp); }); test('Lerp completely from dark to light', () { expect( - const MessageInputThemeData().lerp( + const StreamMessageInputThemeData().lerp( _messageInputThemeControlDark, _messageInputThemeControl, 1), _messageInputThemeControl); }); @@ -39,33 +39,33 @@ void main() { }); } -final _messageInputThemeControl = MessageInputThemeData( +final _messageInputThemeControl = StreamMessageInputThemeData( borderRadius: BorderRadius.circular(20), sendAnimationDuration: const Duration(milliseconds: 300), - actionButtonColor: ColorTheme.light().accentPrimary, - actionButtonIdleColor: ColorTheme.light().textLowEmphasis, - expandButtonColor: ColorTheme.light().accentPrimary, - sendButtonColor: ColorTheme.light().accentPrimary, - sendButtonIdleColor: ColorTheme.light().disabled, - inputBackgroundColor: ColorTheme.light().barsBg, - inputTextStyle: TextTheme.light().body, + actionButtonColor: StreamColorTheme.light().accentPrimary, + actionButtonIdleColor: StreamColorTheme.light().textLowEmphasis, + expandButtonColor: StreamColorTheme.light().accentPrimary, + sendButtonColor: StreamColorTheme.light().accentPrimary, + sendButtonIdleColor: StreamColorTheme.light().disabled, + inputBackgroundColor: StreamColorTheme.light().barsBg, + inputTextStyle: StreamTextTheme.light().body, idleBorderGradient: LinearGradient( stops: const [0.0, 1.0], colors: [ - ColorTheme.light().disabled, - ColorTheme.light().disabled, + StreamColorTheme.light().disabled, + StreamColorTheme.light().disabled, ], ), activeBorderGradient: LinearGradient( stops: const [0.0, 1.0], colors: [ - ColorTheme.light().disabled, - ColorTheme.light().disabled, + StreamColorTheme.light().disabled, + StreamColorTheme.light().disabled, ], ), ); -final _messageInputThemeControlMidLerp = MessageInputThemeData( +final _messageInputThemeControlMidLerp = StreamMessageInputThemeData( borderRadius: BorderRadius.circular(20), sendAnimationDuration: const Duration(milliseconds: 300), inputBackgroundColor: const Color(0xff87898b), @@ -95,28 +95,28 @@ final _messageInputThemeControlMidLerp = MessageInputThemeData( ), ); -final _messageInputThemeControlDark = MessageInputThemeData( +final _messageInputThemeControlDark = StreamMessageInputThemeData( borderRadius: BorderRadius.circular(20), sendAnimationDuration: const Duration(milliseconds: 300), - actionButtonColor: ColorTheme.dark().accentPrimary, - actionButtonIdleColor: ColorTheme.dark().textLowEmphasis, - expandButtonColor: ColorTheme.dark().accentPrimary, - sendButtonColor: ColorTheme.dark().accentPrimary, - sendButtonIdleColor: ColorTheme.dark().disabled, - inputBackgroundColor: ColorTheme.dark().barsBg, - inputTextStyle: TextTheme.dark().body, + actionButtonColor: StreamColorTheme.dark().accentPrimary, + actionButtonIdleColor: StreamColorTheme.dark().textLowEmphasis, + expandButtonColor: StreamColorTheme.dark().accentPrimary, + sendButtonColor: StreamColorTheme.dark().accentPrimary, + sendButtonIdleColor: StreamColorTheme.dark().disabled, + inputBackgroundColor: StreamColorTheme.dark().barsBg, + inputTextStyle: StreamTextTheme.dark().body, idleBorderGradient: LinearGradient( stops: const [0.0, 1.0], colors: [ - ColorTheme.dark().disabled, - ColorTheme.dark().disabled, + StreamColorTheme.dark().disabled, + StreamColorTheme.dark().disabled, ], ), activeBorderGradient: LinearGradient( stops: const [0.0, 1.0], colors: [ - ColorTheme.dark().disabled, - ColorTheme.dark().disabled, + StreamColorTheme.dark().disabled, + StreamColorTheme.dark().disabled, ], ), ); diff --git a/packages/stream_chat_flutter/test/src/theme/message_list_view_theme_test.dart b/packages/stream_chat_flutter/test/src/theme/message_list_view_theme_test.dart index 94becc06..264710ec 100644 --- a/packages/stream_chat_flutter/test/src/theme/message_list_view_theme_test.dart +++ b/packages/stream_chat_flutter/test/src/theme/message_list_view_theme_test.dart @@ -9,18 +9,20 @@ class MockStreamChatClient extends Mock implements StreamChatClient {} void main() { test('MessageListViewThemeData copyWith, ==, hashCode basics', () { - expect(const MessageListViewThemeData(), - const MessageListViewThemeData().copyWith()); - expect(const MessageListViewThemeData().hashCode, - const MessageListViewThemeData().copyWith().hashCode); + expect(const StreamMessageListViewThemeData(), + const StreamMessageListViewThemeData().copyWith()); + expect(const StreamMessageListViewThemeData().hashCode, + const StreamMessageListViewThemeData().copyWith().hashCode); }); test( '''Light MessageListViewThemeData lerps completely to dark MessageListViewThemeData''', () { expect( - const MessageListViewThemeData().lerp(_messageListViewThemeDataControl, - _messageListViewThemeDataControlDark, 1), + const StreamMessageListViewThemeData().lerp( + _messageListViewThemeDataControl, + _messageListViewThemeDataControlDark, + 1), _messageListViewThemeDataControlDark); }); @@ -28,8 +30,10 @@ void main() { '''Light MessageListViewThemeData lerps halfway to dark MessageListViewThemeData''', () { expect( - const MessageListViewThemeData().lerp(_messageListViewThemeDataControl, - _messageListViewThemeDataControlDark, 0.5), + const StreamMessageListViewThemeData().lerp( + _messageListViewThemeDataControl, + _messageListViewThemeDataControlDark, + 0.5), _messageListViewThemeDataControlHalfLerp); }); @@ -37,7 +41,7 @@ void main() { '''Dark MessageListViewThemeData lerps completely to light MessageListViewThemeData''', () { expect( - const MessageListViewThemeData().lerp( + const StreamMessageListViewThemeData().lerp( _messageListViewThemeDataControlDark, _messageListViewThemeDataControl, 1), @@ -67,7 +71,7 @@ void main() { return Scaffold( body: StreamChannel( channel: MockChannel(), - child: const MessageListView(), + child: const StreamMessageListView(), ), ); }, @@ -75,7 +79,7 @@ void main() { ), ); - final messageListViewTheme = MessageListViewTheme.of(_context); + final messageListViewTheme = StreamMessageListViewTheme.of(_context); expect(messageListViewTheme.backgroundColor, _messageListViewThemeDataControl.backgroundColor); }); @@ -97,7 +101,7 @@ void main() { return Scaffold( body: StreamChannel( channel: MockChannel(), - child: const MessageListView(), + child: const StreamMessageListView(), ), ); }, @@ -105,7 +109,7 @@ void main() { ), ); - final messageListViewTheme = MessageListViewTheme.of(_context); + final messageListViewTheme = StreamMessageListViewTheme.of(_context); expect(messageListViewTheme.backgroundColor, _messageListViewThemeDataControlDark.backgroundColor); }); @@ -128,7 +132,7 @@ void main() { return Scaffold( body: StreamChannel( channel: MockChannel(), - child: const MessageListView(), + child: const StreamMessageListView(), ), ); }, @@ -136,25 +140,25 @@ void main() { ), ); - final messageListViewTheme = MessageListViewTheme.of(_context); + final messageListViewTheme = StreamMessageListViewTheme.of(_context); expect(messageListViewTheme.backgroundImage, _messageListViewThemeDataImage.backgroundImage); }); } -final _messageListViewThemeDataControl = MessageListViewThemeData( - backgroundColor: ColorTheme.light().barsBg, +final _messageListViewThemeDataControl = StreamMessageListViewThemeData( + backgroundColor: StreamColorTheme.light().barsBg, ); -const _messageListViewThemeDataControlHalfLerp = MessageListViewThemeData( +const _messageListViewThemeDataControlHalfLerp = StreamMessageListViewThemeData( backgroundColor: Color(0xff87898b), ); -final _messageListViewThemeDataControlDark = MessageListViewThemeData( - backgroundColor: ColorTheme.dark().barsBg, +final _messageListViewThemeDataControlDark = StreamMessageListViewThemeData( + backgroundColor: StreamColorTheme.dark().barsBg, ); -const _messageListViewThemeDataImage = MessageListViewThemeData( +const _messageListViewThemeDataImage = StreamMessageListViewThemeData( backgroundImage: DecorationImage( image: AssetImage('example/assets/background_doodle.png'), fit: BoxFit.cover, diff --git a/packages/stream_chat_flutter/test/src/theme/message_search_list_view_theme_test.dart b/packages/stream_chat_flutter/test/src/theme/message_search_list_view_theme_test.dart index 69c63abe..bbb27463 100644 --- a/packages/stream_chat_flutter/test/src/theme/message_search_list_view_theme_test.dart +++ b/packages/stream_chat_flutter/test/src/theme/message_search_list_view_theme_test.dart @@ -6,17 +6,17 @@ import '../mocks.dart'; void main() { test('MessageSearchListViewThemeData copyWith, ==, hashCode basics', () { - expect(const MessageSearchListViewThemeData(), - const MessageSearchListViewThemeData().copyWith()); - expect(const MessageSearchListViewThemeData().hashCode, - const MessageSearchListViewThemeData().copyWith().hashCode); + expect(const StreamMessageSearchListViewThemeData(), + const StreamMessageSearchListViewThemeData().copyWith()); + expect(const StreamMessageSearchListViewThemeData().hashCode, + const StreamMessageSearchListViewThemeData().copyWith().hashCode); }); test( '''Light MessageSearchListViewThemeData lerps completely to dark MessageSearchListViewThemeData''', () { expect( - const MessageSearchListViewThemeData().lerp( + const StreamMessageSearchListViewThemeData().lerp( _messageSearchListViewThemeDataControl, _messageSearchListViewThemeDataControlDark, 1), @@ -27,7 +27,7 @@ void main() { '''Light MessageSearchListViewThemeData lerps halfway to dark MessageSearchListViewThemeData''', () { expect( - const MessageSearchListViewThemeData().lerp( + const StreamMessageSearchListViewThemeData().lerp( _messageSearchListViewThemeDataControl, _messageSearchListViewThemeDataControlDark, 0.5), @@ -38,7 +38,7 @@ void main() { '''Dark MessageSearchListViewThemeData lerps completely to light MessageSearchListViewThemeData''', () { expect( - const MessageSearchListViewThemeData().lerp( + const StreamMessageSearchListViewThemeData().lerp( _messageSearchListViewThemeDataControlDark, _messageSearchListViewThemeDataControl, 1), @@ -67,7 +67,7 @@ void main() { _context = context; return Scaffold( body: MessageSearchBloc( - child: MessageSearchListView( + child: StreamMessageSearchListView( filters: Filter.in_('members', const ['test_id']), messageQuery: 'test query', ), @@ -78,7 +78,8 @@ void main() { ), ); - final messageSearchListViewTheme = MessageSearchListViewTheme.of(_context); + final messageSearchListViewTheme = + StreamMessageSearchListViewTheme.of(_context); expect(messageSearchListViewTheme.backgroundColor, _messageSearchListViewThemeDataControl.backgroundColor); }); @@ -99,7 +100,7 @@ void main() { _context = context; return Scaffold( body: MessageSearchBloc( - child: MessageSearchListView( + child: StreamMessageSearchListView( filters: Filter.in_('members', const ['test_id']), messageQuery: 'test query', ), @@ -110,22 +111,24 @@ void main() { ), ); - final messageSearchListViewTheme = MessageSearchListViewTheme.of(_context); + final messageSearchListViewTheme = + StreamMessageSearchListViewTheme.of(_context); expect(messageSearchListViewTheme.backgroundColor, _messageSearchListViewThemeDataControlDark.backgroundColor); }); } -final _messageSearchListViewThemeDataControl = MessageSearchListViewThemeData( - backgroundColor: ColorTheme.light().appBg, +final _messageSearchListViewThemeDataControl = + StreamMessageSearchListViewThemeData( + backgroundColor: StreamColorTheme.light().appBg, ); const _messageSearchListViewThemeDataControlHalfLerp = - MessageSearchListViewThemeData( + StreamMessageSearchListViewThemeData( backgroundColor: Color(0xff818384), ); final _messageSearchListViewThemeDataControlDark = - MessageSearchListViewThemeData( - backgroundColor: ColorTheme.dark().appBg, + StreamMessageSearchListViewThemeData( + backgroundColor: StreamColorTheme.dark().appBg, ); diff --git a/packages/stream_chat_flutter/test/src/theme/message_theme_test.dart b/packages/stream_chat_flutter/test/src/theme/message_theme_test.dart index 502be84a..3b6c3a6f 100644 --- a/packages/stream_chat_flutter/test/src/theme/message_theme_test.dart +++ b/packages/stream_chat_flutter/test/src/theme/message_theme_test.dart @@ -4,16 +4,17 @@ import 'package:stream_chat_flutter/stream_chat_flutter.dart'; void main() { test('MessageThemeData copyWith, ==, hashCode basics', () { - expect(const MessageThemeData(), const MessageThemeData().copyWith()); - expect(const MessageThemeData().hashCode, - const MessageThemeData().copyWith().hashCode); + expect(const StreamMessageThemeData(), + const StreamMessageThemeData().copyWith()); + expect(const StreamMessageThemeData().hashCode, + const StreamMessageThemeData().copyWith().hashCode); }); group('MessageThemeData lerps', () { test('''Light MessageThemeData lerps completely to dark MessageThemeData''', () { expect( - const MessageThemeData() + const StreamMessageThemeData() .lerp(_messageThemeControl, _messageThemeControlDark, 1), _messageThemeControlDark); }); @@ -21,7 +22,7 @@ void main() { test('''Dark MessageThemeData lerps completely to light MessageThemeData''', () { expect( - const MessageThemeData() + const StreamMessageThemeData() .lerp(_messageThemeControlDark, _messageThemeControl, 1), _messageThemeControl); }); @@ -33,23 +34,23 @@ void main() { }); } -final _messageThemeControl = MessageThemeData( - messageAuthorStyle: TextTheme.light().footnote.copyWith( - color: ColorTheme.light().textLowEmphasis, +final _messageThemeControl = StreamMessageThemeData( + messageAuthorStyle: StreamTextTheme.light().footnote.copyWith( + color: StreamColorTheme.light().textLowEmphasis, ), - messageTextStyle: TextTheme.light().body, - createdAtStyle: TextTheme.light().footnote.copyWith( - color: ColorTheme.light().textLowEmphasis, + messageTextStyle: StreamTextTheme.light().body, + createdAtStyle: StreamTextTheme.light().footnote.copyWith( + color: StreamColorTheme.light().textLowEmphasis, ), - repliesStyle: TextTheme.light().footnoteBold.copyWith( - color: ColorTheme.light().accentPrimary, + repliesStyle: StreamTextTheme.light().footnoteBold.copyWith( + color: StreamColorTheme.light().accentPrimary, ), - messageBackgroundColor: ColorTheme.light().disabled, - reactionsBackgroundColor: ColorTheme.light().barsBg, - reactionsBorderColor: ColorTheme.light().borders, - reactionsMaskColor: ColorTheme.light().appBg, - messageBorderColor: ColorTheme.light().disabled, - avatarTheme: AvatarThemeData( + messageBackgroundColor: StreamColorTheme.light().disabled, + reactionsBackgroundColor: StreamColorTheme.light().barsBg, + reactionsBorderColor: StreamColorTheme.light().borders, + reactionsMaskColor: StreamColorTheme.light().appBg, + messageBorderColor: StreamColorTheme.light().disabled, + avatarTheme: StreamAvatarThemeData( borderRadius: BorderRadius.circular(20), constraints: const BoxConstraints.tightFor( height: 32, @@ -57,28 +58,28 @@ final _messageThemeControl = MessageThemeData( ), ), messageLinksStyle: TextStyle( - color: ColorTheme.light().accentPrimary, + color: StreamColorTheme.light().accentPrimary, ), - linkBackgroundColor: ColorTheme.light().linkBg, + linkBackgroundColor: StreamColorTheme.light().linkBg, ); -final _messageThemeControlDark = MessageThemeData( - messageAuthorStyle: TextTheme.dark().footnote.copyWith( - color: ColorTheme.dark().textLowEmphasis, +final _messageThemeControlDark = StreamMessageThemeData( + messageAuthorStyle: StreamTextTheme.dark().footnote.copyWith( + color: StreamColorTheme.dark().textLowEmphasis, ), - messageTextStyle: TextTheme.dark().body, - createdAtStyle: TextTheme.dark().footnote.copyWith( - color: ColorTheme.dark().textLowEmphasis, + messageTextStyle: StreamTextTheme.dark().body, + createdAtStyle: StreamTextTheme.dark().footnote.copyWith( + color: StreamColorTheme.dark().textLowEmphasis, ), - repliesStyle: TextTheme.dark().footnoteBold.copyWith( - color: ColorTheme.dark().accentPrimary, + repliesStyle: StreamTextTheme.dark().footnoteBold.copyWith( + color: StreamColorTheme.dark().accentPrimary, ), - messageBackgroundColor: ColorTheme.dark().disabled, - reactionsBackgroundColor: ColorTheme.dark().barsBg, - reactionsBorderColor: ColorTheme.dark().borders, - reactionsMaskColor: ColorTheme.dark().appBg, - messageBorderColor: ColorTheme.dark().disabled, - avatarTheme: AvatarThemeData( + messageBackgroundColor: StreamColorTheme.dark().disabled, + reactionsBackgroundColor: StreamColorTheme.dark().barsBg, + reactionsBorderColor: StreamColorTheme.dark().borders, + reactionsMaskColor: StreamColorTheme.dark().appBg, + messageBorderColor: StreamColorTheme.dark().disabled, + avatarTheme: StreamAvatarThemeData( borderRadius: BorderRadius.circular(20), constraints: const BoxConstraints.tightFor( height: 32, @@ -86,7 +87,7 @@ final _messageThemeControlDark = MessageThemeData( ), ), messageLinksStyle: TextStyle( - color: ColorTheme.dark().accentPrimary, + color: StreamColorTheme.dark().accentPrimary, ), - linkBackgroundColor: ColorTheme.dark().linkBg, + linkBackgroundColor: StreamColorTheme.dark().linkBg, ); diff --git a/packages/stream_chat_flutter/test/src/theme/user_list_view_theme_test.dart b/packages/stream_chat_flutter/test/src/theme/user_list_view_theme_test.dart index 3aa20744..6937f4b9 100644 --- a/packages/stream_chat_flutter/test/src/theme/user_list_view_theme_test.dart +++ b/packages/stream_chat_flutter/test/src/theme/user_list_view_theme_test.dart @@ -6,15 +6,15 @@ import '../mocks.dart'; void main() { test('UserListViewThemeData copyWith, ==, hashCode basics', () { - expect(const UserListViewThemeData(), - const UserListViewThemeData().copyWith()); + expect(const StreamUserListViewThemeData(), + const StreamUserListViewThemeData().copyWith()); }); test( '''Light UserListViewThemeData lerps completely to dark UserListViewThemeData''', () { expect( - const UserListViewThemeData().lerp(_userListViewThemeDataControl, + const StreamUserListViewThemeData().lerp(_userListViewThemeDataControl, _userListViewThemeDataControlDark, 1), _userListViewThemeDataControlDark); }); @@ -23,7 +23,7 @@ void main() { '''Light UserListViewThemeData lerps halfway to dark UserListViewThemeData''', () { expect( - const UserListViewThemeData().lerp(_userListViewThemeDataControl, + const StreamUserListViewThemeData().lerp(_userListViewThemeDataControl, _userListViewThemeDataControlDark, 0.5), _userListViewThemeDataControlHalfLerp); }); @@ -32,8 +32,10 @@ void main() { '''Dark UserListViewThemeData lerps completely to light UserListViewThemeData''', () { expect( - const UserListViewThemeData().lerp(_userListViewThemeDataControlDark, - _userListViewThemeDataControl, 1), + const StreamUserListViewThemeData().lerp( + _userListViewThemeDataControlDark, + _userListViewThemeDataControl, + 1), _userListViewThemeDataControl); }); @@ -58,7 +60,7 @@ void main() { _context = context; return Scaffold( body: UsersBloc( - child: UserListView(), + child: StreamUserListView(), ), ); }, @@ -66,7 +68,7 @@ void main() { ), ); - final userListViewTheme = UserListViewTheme.of(_context); + final userListViewTheme = StreamUserListViewTheme.of(_context); expect(userListViewTheme.backgroundColor, _userListViewThemeDataControl.backgroundColor); }); @@ -87,7 +89,7 @@ void main() { _context = context; return Scaffold( body: UsersBloc( - child: UserListView(), + child: StreamUserListView(), ), ); }, @@ -95,20 +97,20 @@ void main() { ), ); - final userListViewTheme = UserListViewTheme.of(_context); + final userListViewTheme = StreamUserListViewTheme.of(_context); expect(userListViewTheme.backgroundColor, _userListViewThemeDataControlDark.backgroundColor); }); } -final _userListViewThemeDataControl = UserListViewThemeData( - backgroundColor: ColorTheme.light().appBg, +final _userListViewThemeDataControl = StreamUserListViewThemeData( + backgroundColor: StreamColorTheme.light().appBg, ); -const _userListViewThemeDataControlHalfLerp = UserListViewThemeData( +const _userListViewThemeDataControlHalfLerp = StreamUserListViewThemeData( backgroundColor: Color(0xff818384), ); -final _userListViewThemeDataControlDark = UserListViewThemeData( - backgroundColor: ColorTheme.dark().appBg, +final _userListViewThemeDataControlDark = StreamUserListViewThemeData( + backgroundColor: StreamColorTheme.dark().appBg, ); diff --git a/packages/stream_chat_flutter/test/src/thread_header_test.dart b/packages/stream_chat_flutter/test/src/thread_header_test.dart index babe4318..6d1758fa 100644 --- a/packages/stream_chat_flutter/test/src/thread_header_test.dart +++ b/packages/stream_chat_flutter/test/src/thread_header_test.dart @@ -51,7 +51,7 @@ void main() { child: StreamChannel( channel: channel, child: Scaffold( - body: ThreadHeader( + body: StreamThreadHeader( parent: Message(), ), ), @@ -112,7 +112,7 @@ void main() { child: StreamChannel( channel: channel, child: Scaffold( - body: ThreadHeader( + body: StreamThreadHeader( parent: Message(), subtitle: const Text('subtitle'), leading: const Text('leading'), diff --git a/packages/stream_chat_flutter/test/src/typing_indicator_test.dart b/packages/stream_chat_flutter/test/src/typing_indicator_test.dart index 0a98aff7..27b3f977 100644 --- a/packages/stream_chat_flutter/test/src/typing_indicator_test.dart +++ b/packages/stream_chat_flutter/test/src/typing_indicator_test.dart @@ -71,7 +71,7 @@ void main() { child: StreamChannel( channel: channel, child: const Scaffold( - body: TypingIndicator( + body: StreamTypingIndicator( key: typingKey, ), ), diff --git a/packages/stream_chat_flutter/test/src/unread_indicator_test.dart b/packages/stream_chat_flutter/test/src/unread_indicator_test.dart index 00359089..a470fe74 100644 --- a/packages/stream_chat_flutter/test/src/unread_indicator_test.dart +++ b/packages/stream_chat_flutter/test/src/unread_indicator_test.dart @@ -37,7 +37,7 @@ void main() { child: StreamChannel( channel: channel, child: const Scaffold( - body: UnreadIndicator(), + body: StreamUnreadIndicator(), ), ), ), @@ -75,7 +75,7 @@ void main() { child: StreamChannel( channel: channel, child: Scaffold( - body: UnreadIndicator( + body: StreamUnreadIndicator( cid: channel.cid, ), ), @@ -115,7 +115,7 @@ void main() { child: StreamChannel( channel: channel, child: Scaffold( - body: UnreadIndicator( + body: StreamUnreadIndicator( cid: channel.cid, ), ), diff --git a/packages/stream_chat_flutter_core/lib/src/channels_bloc.dart b/packages/stream_chat_flutter_core/lib/src/channels_bloc.dart index 9e7b05d1..76bf3854 100644 --- a/packages/stream_chat_flutter_core/lib/src/channels_bloc.dart +++ b/packages/stream_chat_flutter_core/lib/src/channels_bloc.dart @@ -16,10 +16,7 @@ import 'package:stream_chat_flutter_core/src/stream_controller_extension.dart'; /// using Flutter's [BuildContext]. /// /// API docs: https://getstream.io/chat/docs/flutter-dart/query_channels/ -@Deprecated( - "'ChannelsBloc' is deprecated and shouldn't be used. " - "Please use 'StreamChannelListController' instead.", -) +@Deprecated("Use 'StreamChannelListController' instead") class ChannelsBloc extends StatefulWidget { /// Creates a new [ChannelsBloc]. The parameter [child] must be supplied and /// not null.