diff --git a/packages/stream_chat_flutter/CHANGELOG.md b/packages/stream_chat_flutter/CHANGELOG.md index b936a4a1a1..6901c63ac7 100644 --- a/packages/stream_chat_flutter/CHANGELOG.md +++ b/packages/stream_chat_flutter/CHANGELOG.md @@ -8,6 +8,8 @@ - Renamed stream icons to remove the size suffix from the icon names. - Removed `StreamMessageThemeData` (ownMessageTheme and otherMessageTheme) and `StreamMessageInputThemeData` (messageInputTheme). - Removed `AttachmentButton`, `StreamQuotedMessageWidget`, `EditMessageSheet`, `StreamMessageSendButton` and `DesktopReactionsBuilder`. +- Removed `StreamChannelPreviewThemeData` (channelPreviewTheme). +- Removed `StreamChannelGridView`, `StreamChannelGridTile` and `StreamMessageSearchGridView`. ✅ Added 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 9d4bbe7a52..a9db625f1c 100644 --- a/packages/stream_chat_flutter/example/lib/tutorial_part_6.dart +++ b/packages/stream_chat_flutter/example/lib/tutorial_part_6.dart @@ -61,11 +61,6 @@ class MyApp extends StatelessWidget { ); final defaultTheme = StreamChatThemeData.fromTheme(themeData); final customTheme = StreamChatThemeData( - channelPreviewTheme: StreamChannelPreviewThemeData( - avatarTheme: StreamAvatarThemeData( - borderRadius: BorderRadius.circular(8), - ), - ), messageListViewTheme: const StreamMessageListViewThemeData( backgroundColor: Colors.grey, backgroundImage: DecorationImage( diff --git a/packages/stream_chat_flutter/lib/src/bottom_sheets/stream_channel_info_bottom_sheet.dart b/packages/stream_chat_flutter/lib/src/bottom_sheets/stream_channel_info_bottom_sheet.dart index fec613732d..0ad3d609c9 100644 --- a/packages/stream_chat_flutter/lib/src/bottom_sheets/stream_channel_info_bottom_sheet.dart +++ b/packages/stream_chat_flutter/lib/src/bottom_sheets/stream_channel_info_bottom_sheet.dart @@ -43,7 +43,6 @@ class StreamChannelInfoBottomSheet extends StatelessWidget { Widget build(BuildContext context) { final themeData = StreamChatTheme.of(context); final colorTheme = themeData.colorTheme; - final channelPreviewTheme = StreamChannelPreviewTheme.of(context); final currentUser = channel.client.state.currentUser; final isOneToOneChannel = channel.isDistinct && channel.memberCount == 2; @@ -74,7 +73,7 @@ class StreamChannelInfoBottomSheet extends StatelessWidget { child: StreamChannelInfo( showTypingIndicator: false, channel: channel, - textStyle: channelPreviewTheme.subtitleStyle, + textStyle: context.streamTextTheme.captionDefault, ), ), const SizedBox(height: 17), diff --git a/packages/stream_chat_flutter/lib/src/dialogs/channel_info_dialog.dart b/packages/stream_chat_flutter/lib/src/dialogs/channel_info_dialog.dart index dc1991b74c..7fb93904b5 100644 --- a/packages/stream_chat_flutter/lib/src/dialogs/channel_info_dialog.dart +++ b/packages/stream_chat_flutter/lib/src/dialogs/channel_info_dialog.dart @@ -39,7 +39,7 @@ class ChannelInfoDialog extends StatelessWidget { children: [ StreamChannelInfo( channel: channel, - textStyle: StreamChatTheme.of(context).channelPreviewTheme.subtitleStyle, + textStyle: context.streamTextTheme.captionDefault, ), ], ), diff --git a/packages/stream_chat_flutter/lib/src/scroll_view/channel_scroll_view/stream_channel_grid_tile.dart b/packages/stream_chat_flutter/lib/src/scroll_view/channel_scroll_view/stream_channel_grid_tile.dart deleted file mode 100644 index fae5ad9bca..0000000000 --- a/packages/stream_chat_flutter/lib/src/scroll_view/channel_scroll_view/stream_channel_grid_tile.dart +++ /dev/null @@ -1,83 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:stream_chat_flutter/stream_chat_flutter.dart'; - -/// A widget that displays a user. -/// -/// This widget is intended to be used as a Tile in -/// [StreamChannelGridView]. -/// -/// It shows the user's avatar and name. -/// -/// See also: -/// * [StreamChannelGridView] -/// * [StreamUserAvatar] -class StreamChannelGridTile extends StatelessWidget { - /// Creates a new instance of [StreamChannelGridTile] widget. - const StreamChannelGridTile({ - super.key, - required this.channel, - this.child, - this.footer, - this.onTap, - this.onLongPress, - }); - - /// The channel to display. - final Channel channel; - - /// The widget to display in the body of the tile. - final Widget? child; - - /// The widget to display in the footer of the tile. - final Widget? footer; - - /// Called when the user taps this grid tile. - final GestureTapCallback? onTap; - - /// Called when the user long-presses on this grid tile. - final GestureLongPressCallback? onLongPress; - - /// Creates a copy of this tile but with the given fields replaced with - /// the new values. - StreamChannelGridTile copyWith({ - Key? key, - Channel? channel, - Widget? child, - Widget? footer, - GestureTapCallback? onTap, - GestureLongPressCallback? onLongPress, - }) => StreamChannelGridTile( - key: key ?? this.key, - channel: channel ?? this.channel, - footer: footer ?? this.footer, - onTap: onTap ?? this.onTap, - onLongPress: onLongPress ?? this.onLongPress, - child: child ?? this.child, - ); - - @override - Widget build(BuildContext context) { - final channelPreviewTheme = StreamChannelPreviewTheme.of(context); - - final child = this.child ?? StreamChannelAvatar(size: .xl, channel: channel); - - final footer = - this.footer ?? - StreamChannelName( - channel: channel, - textStyle: channelPreviewTheme.titleStyle, - ); - - return InkWell( - onTap: onTap, - onLongPress: onLongPress, - child: Column( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - child, - footer, - ], - ), - ); - } -} diff --git a/packages/stream_chat_flutter/lib/src/scroll_view/channel_scroll_view/stream_channel_grid_view.dart b/packages/stream_chat_flutter/lib/src/scroll_view/channel_scroll_view/stream_channel_grid_view.dart deleted file mode 100644 index 7e767a5ec9..0000000000 --- a/packages/stream_chat_flutter/lib/src/scroll_view/channel_scroll_view/stream_channel_grid_view.dart +++ /dev/null @@ -1,394 +0,0 @@ -import 'package:flutter/gestures.dart'; -import 'package:flutter/material.dart'; -import 'package:stream_chat_flutter/src/scroll_view/stream_scroll_view_error_widget.dart'; -import 'package:stream_chat_flutter/src/scroll_view/stream_scroll_view_load_more_error.dart'; -import 'package:stream_chat_flutter/src/scroll_view/stream_scroll_view_loading_widget.dart'; -import 'package:stream_chat_flutter/stream_chat_flutter.dart'; -import 'package:stream_core_flutter/stream_core_flutter.dart'; - -/// Default grid delegate for [StreamChannelGridView]. -const defaultChannelGridViewDelegate = SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 4); - -/// Signature for the item builder that creates the children of the -/// [StreamChannelGridView]. -typedef StreamChannelGridViewIndexedWidgetBuilder = - StreamScrollViewIndexedWidgetBuilder; - -/// A [GridView] that shows a grid of [User]s, -/// it uses [StreamChannelGridTile] as a default item. -/// -/// Example: -/// -/// ```dart -/// StreamChannelGridView( -/// controller: controller, -/// onChannelTap: (channel) { -/// // Handle channel tap event -/// }, -/// onChannelLongPress: (channel) { -/// // Handle channel long press event -/// }, -/// ) -/// ``` -/// -/// See also: -/// * [StreamChannelGridTile] -/// * [StreamChannelListController] -class StreamChannelGridView extends StatelessWidget { - /// Creates a new instance of [StreamChannelGridView]. - const StreamChannelGridView({ - super.key, - required this.controller, - this.gridDelegate = defaultChannelGridViewDelegate, - this.itemBuilder, - this.emptyBuilder, - this.loadMoreErrorBuilder, - this.loadMoreIndicatorBuilder, - this.loadingBuilder, - this.errorBuilder, - this.onChannelTap, - this.onChannelLongPress, - this.loadMoreTriggerIndex = 3, - this.scrollDirection = Axis.vertical, - this.reverse = false, - this.scrollController, - this.primary, - this.physics, - this.shrinkWrap = false, - this.padding, - this.addAutomaticKeepAlives = true, - this.addRepaintBoundaries = true, - this.addSemanticIndexes = true, - this.cacheExtent, - this.semanticChildCount, - this.dragStartBehavior = DragStartBehavior.start, - this.keyboardDismissBehavior = ScrollViewKeyboardDismissBehavior.manual, - this.restorationId, - this.clipBehavior = Clip.hardEdge, - }); - - /// The [StreamUserListController] used to control the grid of users. - final StreamChannelListController controller; - - /// A delegate that controls the layout of the children within - /// the [PagedValueGridView]. - final SliverGridDelegate gridDelegate; - - /// A builder that is called to build items in the [PagedValueGridView]. - /// - /// The `value` parameter is the [Channel] at this position in the grid. - final StreamChannelGridViewIndexedWidgetBuilder? itemBuilder; - - /// A builder that is called to build the empty state of the grid. - final WidgetBuilder? emptyBuilder; - - /// A builder that is called to build the load more error state of the grid. - final PagedValueScrollViewLoadMoreErrorBuilder? loadMoreErrorBuilder; - - /// A builder that is called to build the load more indicator of the grid. - final WidgetBuilder? loadMoreIndicatorBuilder; - - /// A builder that is called to build the loading state of the grid. - final WidgetBuilder? loadingBuilder; - - /// A builder that is called to build the error state of the grid. - final Widget Function(BuildContext, StreamChatError)? errorBuilder; - - /// Called when the user taps this grid tile. - final void Function(Channel)? onChannelTap; - - /// Called when the user long-presses on this grid tile. - final void Function(Channel)? onChannelLongPress; - - /// The index to take into account when triggering [controller.loadMore]. - final int loadMoreTriggerIndex; - - /// {@template flutter.widgets.scroll_view.scrollDirection} - /// The axis along which the scroll view scrolls. - /// - /// Defaults to [Axis.vertical]. - /// {@endtemplate} - final Axis scrollDirection; - - /// {@template flutter.widgets.scroll_view.reverse} - /// Whether the scroll view scrolls in the reading direction. - /// - /// For example, if the reading direction is left-to-right and - /// [scrollDirection] is [Axis.horizontal], then the scroll view scrolls from - /// left to right when [reverse] is false and from right to left when - /// [reverse] is true. - /// - /// Similarly, if [scrollDirection] is [Axis.vertical], then the scroll view - /// scrolls from top to bottom when [reverse] is false and from bottom to top - /// when [reverse] is true. - /// - /// Defaults to false. - /// {@endtemplate} - final bool reverse; - - /// {@template flutter.widgets.scroll_view.controller} - /// An object that can be used to control the position to which this scroll - /// view is scrolled. - /// - /// Must be null if [primary] is true. - /// - /// A [ScrollController] serves several purposes. It can be used to control - /// the initial scroll position (see [ScrollController.initialScrollOffset]). - /// It can be used to control whether the scroll view should automatically - /// save and restore its scroll position in the [PageStorage] (see - /// [ScrollController.keepScrollOffset]). It can be used to read the current - /// scroll position (see [ScrollController.offset]), or change it (see - /// [ScrollController.animateTo]). - /// {@endtemplate} - final ScrollController? scrollController; - - /// {@template flutter.widgets.scroll_view.primary} - /// Whether this is the primary scroll view associated with the parent - /// [PrimaryScrollController]. - /// - /// When this is true, the scroll view is scrollable even if it does not have - /// sufficient content to actually scroll. Otherwise, by default the user can - /// only scroll the view if it has sufficient content. See [physics]. - /// - /// Also when true, the scroll view is used for default [ScrollAction]s. If a - /// ScrollAction is not handled by - /// an otherwise focused part of the application, - /// the ScrollAction will be evaluated using this scroll view, for example, - /// when executing [Shortcuts] key events like page up and down. - /// - /// On iOS, this also identifies the scroll view that will scroll to top in - /// response to a tap in the status bar. - /// {@endtemplate} - /// - /// Defaults to true when [scrollDirection] is [Axis.vertical] and - /// [controller] is null. - final bool? primary; - - /// {@template flutter.widgets.scroll_view.physics} - /// How the scroll view should respond to user input. - /// - /// For example, determines how the scroll view continues to animate after the - /// user stops dragging the scroll view. - /// - /// Defaults to matching platform conventions. Furthermore, if [primary] is - /// false, then the user cannot scroll if there is insufficient content to - /// scroll, while if [primary] is true, they can always attempt to scroll. - /// - /// To force the scroll view to always be scrollable even if there is - /// insufficient content, as if [primary] was true but without necessarily - /// setting it to true, provide an [AlwaysScrollableScrollPhysics] physics - /// object, as in: - /// - /// ```dart - /// physics: const AlwaysScrollableScrollPhysics(), - /// ``` - /// - /// To force the scroll view to use the default platform conventions and not - /// be scrollable if there is insufficient content, regardless of the value of - /// [primary], provide an explicit [ScrollPhysics] object, as in: - /// - /// ```dart - /// physics: const ScrollPhysics(), - /// ``` - /// - /// The physics can be changed dynamically (by providing a new object in a - /// subsequent build), but new physics will only take effect if the _class_ of - /// the provided object changes. Merely constructing a new instance with a - /// different configuration is insufficient to cause the physics to be - /// reapplied. (This is because the final object used is generated - /// dynamically, which can be relatively expensive, and it would be - /// inefficient to speculatively create this object each frame to see if the - /// physics should be updated.) - /// {@endtemplate} - /// - /// If an explicit [ScrollBehavior] is provided to [scrollBehavior], the - /// [ScrollPhysics] provided by that behavior will take precedence after - /// [physics]. - final ScrollPhysics? physics; - - /// {@template flutter.widgets.scroll_view.shrinkWrap} - /// Whether the extent of the scroll view in the [scrollDirection] should be - /// determined by the contents being viewed. - /// - /// If the scroll view does not shrink wrap, then the scroll view will expand - /// to the maximum allowed size in the [scrollDirection]. If the scroll view - /// has unbounded constraints in the [scrollDirection], then [shrinkWrap] must - /// be true. - /// - /// Shrink wrapping the content of the scroll view is significantly more - /// expensive than expanding to the maximum allowed size because the content - /// can expand and contract during scrolling, which means the size of the - /// scroll view needs to be recomputed whenever the scroll position changes. - /// - /// Defaults to false. - /// {@endtemplate} - final bool shrinkWrap; - - /// The amount of space by which to inset the children. - final EdgeInsetsGeometry? padding; - - /// Whether to wrap each child in an [AutomaticKeepAlive]. - /// - /// Typically, children in lazy list are wrapped in [AutomaticKeepAlive] - /// widgets so that children can use [KeepAliveNotification]s to preserve - /// their state when they would otherwise be garbage collected off-screen. - /// - /// This feature (and [addRepaintBoundaries]) must be disabled if the children - /// are going to manually maintain their [KeepAlive] state. It may also be - /// more efficient to disable this feature if it is known ahead of time that - /// none of the children will ever try to keep themselves alive. - /// - /// Defaults to true. - final bool addAutomaticKeepAlives; - - /// Whether to wrap each child in a [RepaintBoundary]. - /// - /// Typically, children in a scrolling container are wrapped in repaint - /// boundaries so that they do not need to be repainted as the list scrolls. - /// If the children are easy to repaint (e.g., solid color blocks or a short - /// snippet of text), it might be more efficient to not add a repaint boundary - /// and simply repaint the children during scrolling. - /// - /// Defaults to true. - final bool addRepaintBoundaries; - - /// Whether to wrap each child in an [IndexedSemantics]. - /// - /// Typically, children in a scrolling container must be annotated with a - /// semantic index in order to generate the correct accessibility - /// announcements. This should only be set to false if the indexes have - /// already been provided by an [IndexedSemantics] widget. - /// - /// Defaults to true. - /// - /// See also: - /// - /// * [IndexedSemantics], for an explanation of how to manually - /// provide semantic indexes. - final bool addSemanticIndexes; - - /// {@macro flutter.rendering.RenderViewportBase.cacheExtent} - final double? cacheExtent; - - /// The number of children that will contribute semantic information. - /// - /// Some subtypes of [ScrollView] can infer this value automatically. For - /// example [ListView] will use the number of widgets in the child list, - /// while the [ListView.separated] constructor will use half that amount. - /// - /// For [CustomScrollView] and other types which do not receive a builder - /// or list of widgets, the child count must be explicitly provided. If the - /// number is unknown or unbounded this should be left unset or set to null. - /// - /// See also: - /// - /// * [SemanticsConfiguration.scrollChildCount], - /// the corresponding semantics property. - final int? semanticChildCount; - - /// {@macro flutter.widgets.scrollable.dragStartBehavior} - final DragStartBehavior dragStartBehavior; - - /// {@template flutter.widgets.scroll_view.keyboardDismissBehavior} - /// [ScrollViewKeyboardDismissBehavior] the defines how this [ScrollView] will - /// dismiss the keyboard automatically. - /// {@endtemplate} - final ScrollViewKeyboardDismissBehavior keyboardDismissBehavior; - - /// {@macro flutter.widgets.scrollable.restorationId} - final String? restorationId; - - /// {@macro flutter.material.Material.clipBehavior} - /// - /// Defaults to [Clip.hardEdge]. - final Clip clipBehavior; - - @override - Widget build(BuildContext context) { - return PagedValueGridView( - scrollDirection: scrollDirection, - reverse: reverse, - controller: controller, - primary: primary, - physics: physics, - shrinkWrap: shrinkWrap, - padding: padding, - scrollController: scrollController, - addAutomaticKeepAlives: addAutomaticKeepAlives, - addRepaintBoundaries: addRepaintBoundaries, - addSemanticIndexes: addSemanticIndexes, - cacheExtent: cacheExtent, - semanticChildCount: semanticChildCount, - dragStartBehavior: dragStartBehavior, - keyboardDismissBehavior: keyboardDismissBehavior, - restorationId: restorationId, - clipBehavior: clipBehavior, - gridDelegate: gridDelegate, - itemBuilder: (context, channels, index) { - final channel = channels[index]; - final onTap = onChannelTap; - final onLongPress = onChannelLongPress; - - final streamChannelGridTile = StreamChannelGridTile( - channel: channel, - onTap: onTap == null ? null : () => onTap(channel), - onLongPress: onLongPress == null ? null : () => onLongPress(channel), - ); - - return itemBuilder?.call( - context, - channels, - index, - streamChannelGridTile, - ) ?? - streamChannelGridTile; - }, - emptyBuilder: (context) { - final chatThemeData = StreamChatTheme.of(context); - return emptyBuilder?.call(context) ?? - Center( - child: Padding( - padding: const EdgeInsets.all(8), - child: StreamScrollViewEmptyWidget( - emptyIcon: Icon( - context.streamIcons.messageBubbleLarge, - size: 148, - color: chatThemeData.colorTheme.disabled, - ), - emptyTitle: Text( - context.translations.letsStartChattingLabel, - style: chatThemeData.textTheme.headline, - ), - ), - ), - ); - }, - loadMoreErrorBuilder: (context, error) => StreamScrollViewLoadMoreError.grid( - onTap: controller.retry, - error: Text( - context.translations.loadingChannelsError, - textAlign: TextAlign.center, - ), - ), - loadMoreIndicatorBuilder: (context) => Center( - child: Padding( - padding: const EdgeInsets.all(16), - child: StreamLoadingSpinner(), - ), - ), - loadingBuilder: (context) => - loadingBuilder?.call(context) ?? - const Center( - child: StreamScrollViewLoadingWidget(), - ), - errorBuilder: (context, error) => - errorBuilder?.call(context, error) ?? - Center( - child: StreamScrollViewErrorWidget( - errorTitle: Text(context.translations.loadingChannelsError), - onRetryPressed: controller.refresh, - ), - ), - ); - } -} diff --git a/packages/stream_chat_flutter/lib/src/scroll_view/message_search_scroll_view/stream_message_search_grid_view.dart b/packages/stream_chat_flutter/lib/src/scroll_view/message_search_scroll_view/stream_message_search_grid_view.dart deleted file mode 100644 index 6d7d062ac6..0000000000 --- a/packages/stream_chat_flutter/lib/src/scroll_view/message_search_scroll_view/stream_message_search_grid_view.dart +++ /dev/null @@ -1,361 +0,0 @@ -import 'package:flutter/gestures.dart'; -import 'package:flutter/material.dart'; -import 'package:stream_chat_flutter/src/scroll_view/stream_scroll_view_error_widget.dart'; -import 'package:stream_chat_flutter/src/scroll_view/stream_scroll_view_load_more_error.dart'; -import 'package:stream_chat_flutter/src/scroll_view/stream_scroll_view_loading_widget.dart'; -import 'package:stream_chat_flutter/stream_chat_flutter.dart'; -import 'package:stream_core_flutter/stream_core_flutter.dart'; - -/// Default grid delegate for [StreamMessageSearchGridView]. -const defaultMessageSearchGridViewDelegate = SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 4); - -/// Signature for the item builder that creates the children of the -/// [StreamMessageSearchGridView]. -typedef StreamMessageSearchGridViewIndexedWidgetBuilder = PagedValueScrollViewIndexedWidgetBuilder; - -/// A [GridView] that shows a grid of [GetMessageResponse]s, -/// it uses [StreamMessageSearchGridTile] as a default item. -/// -/// Example: -/// -/// ```dart -/// StreamMessageSearchGridView( -/// controller: controller, -/// itemBuilder: (context, messageResponses, index) { -/// return GridTile(message: messageResponses[index]); -/// }, -/// ) -/// ``` -/// -/// See also: -/// * [StreamUserListTile] -/// * [StreamUserListController] -class StreamMessageSearchGridView extends StatelessWidget { - /// Creates a new instance of [StreamMessageSearchGridView]. - const StreamMessageSearchGridView({ - super.key, - required this.controller, - required this.itemBuilder, - this.gridDelegate = defaultMessageSearchGridViewDelegate, - this.emptyBuilder, - this.loadMoreErrorBuilder, - this.loadMoreIndicatorBuilder, - this.loadingBuilder, - this.errorBuilder, - this.loadMoreTriggerIndex = 3, - this.scrollDirection = Axis.vertical, - this.reverse = false, - this.scrollController, - this.primary, - this.physics, - this.shrinkWrap = false, - this.padding, - this.addAutomaticKeepAlives = true, - this.addRepaintBoundaries = true, - this.addSemanticIndexes = true, - this.cacheExtent, - this.semanticChildCount, - this.dragStartBehavior = DragStartBehavior.start, - this.keyboardDismissBehavior = ScrollViewKeyboardDismissBehavior.manual, - this.restorationId, - this.clipBehavior = Clip.hardEdge, - }); - - /// The [StreamUserListController] used to control the grid of users. - final StreamMessageSearchListController controller; - - /// A delegate that controls the layout of the children within - /// the [PagedValueGridView]. - final SliverGridDelegate gridDelegate; - - /// A builder that is called to build items in the [PagedValueGridView]. - /// - /// The `value` parameter is the [GetMessageBuilder] - /// at this position in the grid. - final StreamMessageSearchGridViewIndexedWidgetBuilder itemBuilder; - - /// A builder that is called to build the empty state of the grid. - final WidgetBuilder? emptyBuilder; - - /// A builder that is called to build the load more error state of the grid. - final PagedValueScrollViewLoadMoreErrorBuilder? loadMoreErrorBuilder; - - /// A builder that is called to build the load more indicator of the grid. - final WidgetBuilder? loadMoreIndicatorBuilder; - - /// A builder that is called to build the loading state of the grid. - final WidgetBuilder? loadingBuilder; - - /// A builder that is called to build the error state of the grid. - final Widget Function(BuildContext, StreamChatError)? errorBuilder; - - /// The index to take into account when triggering [controller.loadMore]. - final int loadMoreTriggerIndex; - - /// {@template flutter.widgets.scroll_view.scrollDirection} - /// The axis along which the scroll view scrolls. - /// - /// Defaults to [Axis.vertical]. - /// {@endtemplate} - final Axis scrollDirection; - - /// {@template flutter.widgets.scroll_view.reverse} - /// Whether the scroll view scrolls in the reading direction. - /// - /// For example, if the reading direction is left-to-right and - /// [scrollDirection] is [Axis.horizontal], then the scroll view scrolls from - /// left to right when [reverse] is false and from right to left when - /// [reverse] is true. - /// - /// Similarly, if [scrollDirection] is [Axis.vertical], then the scroll view - /// scrolls from top to bottom when [reverse] is false and from bottom to top - /// when [reverse] is true. - /// - /// Defaults to false. - /// {@endtemplate} - final bool reverse; - - /// {@template flutter.widgets.scroll_view.controller} - /// An object that can be used to control the position to which this scroll - /// view is scrolled. - /// - /// Must be null if [primary] is true. - /// - /// A [ScrollController] serves several purposes. It can be used to control - /// the initial scroll position (see [ScrollController.initialScrollOffset]). - /// It can be used to control whether the scroll view should automatically - /// save and restore its scroll position in the [PageStorage] (see - /// [ScrollController.keepScrollOffset]). It can be used to read the current - /// scroll position (see [ScrollController.offset]), or change it (see - /// [ScrollController.animateTo]). - /// {@endtemplate} - final ScrollController? scrollController; - - /// {@template flutter.widgets.scroll_view.primary} - /// Whether this is the primary scroll view associated with the parent - /// [PrimaryScrollController]. - /// - /// When this is true, the scroll view is scrollable even if it does not have - /// sufficient content to actually scroll. Otherwise, by default the user can - /// only scroll the view if it has sufficient content. See [physics]. - /// - /// Also when true, the scroll view is used for default [ScrollAction]s. If a - /// ScrollAction is not handled by - /// an otherwise focused part of the application, - /// the ScrollAction will be evaluated using this scroll view, for example, - /// when executing [Shortcuts] key events like page up and down. - /// - /// On iOS, this also identifies the scroll view that will scroll to top in - /// response to a tap in the status bar. - /// {@endtemplate} - /// - /// Defaults to true when [scrollDirection] is [Axis.vertical] and - /// [controller] is null. - final bool? primary; - - /// {@template flutter.widgets.scroll_view.physics} - /// How the scroll view should respond to user input. - /// - /// For example, determines how the scroll view continues to animate after the - /// user stops dragging the scroll view. - /// - /// Defaults to matching platform conventions. Furthermore, if [primary] is - /// false, then the user cannot scroll if there is insufficient content to - /// scroll, while if [primary] is true, they can always attempt to scroll. - /// - /// To force the scroll view to always be scrollable even if there is - /// insufficient content, as if [primary] was true but without necessarily - /// setting it to true, provide an [AlwaysScrollableScrollPhysics] physics - /// object, as in: - /// - /// ```dart - /// physics: const AlwaysScrollableScrollPhysics(), - /// ``` - /// - /// To force the scroll view to use the default platform conventions and not - /// be scrollable if there is insufficient content, regardless of the value of - /// [primary], provide an explicit [ScrollPhysics] object, as in: - /// - /// ```dart - /// physics: const ScrollPhysics(), - /// ``` - /// - /// The physics can be changed dynamically (by providing a new object in a - /// subsequent build), but new physics will only take effect if the _class_ of - /// the provided object changes. Merely constructing a new instance with a - /// different configuration is insufficient to cause the physics to be - /// reapplied. (This is because the final object used is generated - /// dynamically, which can be relatively expensive, and it would be - /// inefficient to speculatively create this object each frame to see if the - /// physics should be updated.) - /// {@endtemplate} - /// - /// If an explicit [ScrollBehavior] is provided to [scrollBehavior], the - /// [ScrollPhysics] provided by that behavior will take precedence after - /// [physics]. - final ScrollPhysics? physics; - - /// {@template flutter.widgets.scroll_view.shrinkWrap} - /// Whether the extent of the scroll view in the [scrollDirection] should be - /// determined by the contents being viewed. - /// - /// If the scroll view does not shrink wrap, then the scroll view will expand - /// to the maximum allowed size in the [scrollDirection]. If the scroll view - /// has unbounded constraints in the [scrollDirection], then [shrinkWrap] must - /// be true. - /// - /// Shrink wrapping the content of the scroll view is significantly more - /// expensive than expanding to the maximum allowed size because the content - /// can expand and contract during scrolling, which means the size of the - /// scroll view needs to be recomputed whenever the scroll position changes. - /// - /// Defaults to false. - /// {@endtemplate} - final bool shrinkWrap; - - /// The amount of space by which to inset the children. - final EdgeInsetsGeometry? padding; - - /// Whether to wrap each child in an [AutomaticKeepAlive]. - /// - /// Typically, children in lazy list are wrapped in [AutomaticKeepAlive] - /// widgets so that children can use [KeepAliveNotification]s to preserve - /// their state when they would otherwise be garbage collected off-screen. - /// - /// This feature (and [addRepaintBoundaries]) must be disabled if the children - /// are going to manually maintain their [KeepAlive] state. It may also be - /// more efficient to disable this feature if it is known ahead of time that - /// none of the children will ever try to keep themselves alive. - /// - /// Defaults to true. - final bool addAutomaticKeepAlives; - - /// Whether to wrap each child in a [RepaintBoundary]. - /// - /// Typically, children in a scrolling container are wrapped in repaint - /// boundaries so that they do not need to be repainted as the list scrolls. - /// If the children are easy to repaint (e.g., solid color blocks or a short - /// snippet of text), it might be more efficient to not add a repaint boundary - /// and simply repaint the children during scrolling. - /// - /// Defaults to true. - final bool addRepaintBoundaries; - - /// Whether to wrap each child in an [IndexedSemantics]. - /// - /// Typically, children in a scrolling container must be annotated with a - /// semantic index in order to generate the correct accessibility - /// announcements. This should only be set to false if the indexes have - /// already been provided by an [IndexedSemantics] widget. - /// - /// Defaults to true. - /// - /// See also: - /// - /// * [IndexedSemantics], for an explanation of how to manually - /// provide semantic indexes. - final bool addSemanticIndexes; - - /// {@macro flutter.rendering.RenderViewportBase.cacheExtent} - final double? cacheExtent; - - /// The number of children that will contribute semantic information. - /// - /// Some subtypes of [ScrollView] can infer this value automatically. For - /// example [ListView] will use the number of widgets in the child list, - /// while the [ListView.separated] constructor will use half that amount. - /// - /// For [CustomScrollView] and other types which do not receive a builder - /// or list of widgets, the child count must be explicitly provided. If the - /// number is unknown or unbounded this should be left unset or set to null. - /// - /// See also: - /// - /// * [SemanticsConfiguration.scrollChildCount], - /// the corresponding semantics property. - final int? semanticChildCount; - - /// {@macro flutter.widgets.scrollable.dragStartBehavior} - final DragStartBehavior dragStartBehavior; - - /// {@template flutter.widgets.scroll_view.keyboardDismissBehavior} - /// [ScrollViewKeyboardDismissBehavior] the defines how this [ScrollView] will - /// dismiss the keyboard automatically. - /// {@endtemplate} - final ScrollViewKeyboardDismissBehavior keyboardDismissBehavior; - - /// {@macro flutter.widgets.scrollable.restorationId} - final String? restorationId; - - /// {@macro flutter.material.Material.clipBehavior} - /// - /// Defaults to [Clip.hardEdge]. - final Clip clipBehavior; - - @override - Widget build(BuildContext context) { - return PagedValueGridView( - scrollDirection: scrollDirection, - reverse: reverse, - controller: controller, - primary: primary, - physics: physics, - shrinkWrap: shrinkWrap, - padding: padding, - scrollController: scrollController, - addAutomaticKeepAlives: addAutomaticKeepAlives, - addRepaintBoundaries: addRepaintBoundaries, - addSemanticIndexes: addSemanticIndexes, - cacheExtent: cacheExtent, - semanticChildCount: semanticChildCount, - dragStartBehavior: dragStartBehavior, - keyboardDismissBehavior: keyboardDismissBehavior, - restorationId: restorationId, - clipBehavior: clipBehavior, - gridDelegate: gridDelegate, - itemBuilder: itemBuilder, - emptyBuilder: (context) { - final chatThemeData = StreamChatTheme.of(context); - return emptyBuilder?.call(context) ?? - Center( - child: Padding( - padding: const EdgeInsets.all(8), - child: StreamScrollViewEmptyWidget( - emptyIcon: Icon( - context.streamIcons.messageBubbleLarge, - size: 148, - color: chatThemeData.colorTheme.disabled, - ), - emptyTitle: Text( - context.translations.emptyMessagesText, - style: chatThemeData.textTheme.headline, - ), - ), - ), - ); - }, - loadMoreErrorBuilder: (context, error) => StreamScrollViewLoadMoreError.grid( - onTap: controller.retry, - error: Text(context.translations.loadingMessagesError), - ), - loadMoreIndicatorBuilder: (context) => Center( - child: Padding( - padding: const EdgeInsets.all(16), - child: StreamLoadingSpinner(), - ), - ), - loadingBuilder: (context) => - loadingBuilder?.call(context) ?? - const Center( - child: StreamScrollViewLoadingWidget(), - ), - errorBuilder: (context, error) => - errorBuilder?.call(context, error) ?? - Center( - child: StreamScrollViewErrorWidget( - onRetryPressed: controller.refresh, - ), - ), - ); - } -} diff --git a/packages/stream_chat_flutter/lib/src/scroll_view/message_search_scroll_view/stream_message_search_list_tile.dart b/packages/stream_chat_flutter/lib/src/scroll_view/message_search_scroll_view/stream_message_search_list_tile.dart index 3a9be001a3..1619a53c25 100644 --- a/packages/stream_chat_flutter/lib/src/scroll_view/message_search_scroll_view/stream_message_search_list_tile.dart +++ b/packages/stream_chat_flutter/lib/src/scroll_view/message_search_scroll_view/stream_message_search_list_tile.dart @@ -109,7 +109,6 @@ class StreamMessageSearchListTile extends StatelessWidget { Widget build(BuildContext context) { final message = messageResponse.message; final user = message.user!; - final channelPreviewTheme = StreamChannelPreviewTheme.of(context); final leading = this.leading ?? StreamUserAvatar(size: .lg, user: user); @@ -117,7 +116,7 @@ class StreamMessageSearchListTile extends StatelessWidget { this.title ?? MessageSearchListTileTitle( messageResponse: messageResponse, - textStyle: channelPreviewTheme.titleStyle?.copyWith(overflow: TextOverflow.ellipsis), + textStyle: context.streamTextTheme.metadataEmphasis.copyWith(overflow: TextOverflow.ellipsis), ); final subtitle = @@ -127,14 +126,17 @@ class StreamMessageSearchListTile extends StatelessWidget { Expanded( child: StreamMessagePreviewText( message: message, - textStyle: channelPreviewTheme.subtitleStyle, + textStyle: context.streamTextTheme.metadataDefault.copyWith( + color: context.streamColorScheme.textSecondary, + ), ), ), const SizedBox(width: 16), MessageSearchTileMessageDate( message: message, - textStyle: channelPreviewTheme.lastMessageAtStyle, - formatter: channelPreviewTheme.lastMessageAtFormatter, + textStyle: context.streamTextTheme.metadataDefault.copyWith( + color: context.streamColorScheme.textSecondary, + ), ), ], ); 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 deleted file mode 100644 index 88ea65595e..0000000000 --- a/packages/stream_chat_flutter/lib/src/theme/channel_preview_theme.dart +++ /dev/null @@ -1,194 +0,0 @@ -import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; -import 'package:stream_chat_flutter/src/theme/avatar_theme.dart'; -import 'package:stream_chat_flutter/src/theme/stream_chat_theme.dart'; -import 'package:stream_chat_flutter/src/utils/date_formatter.dart'; - -/// {@template channelPreviewTheme} -/// Overrides the default style of [ChannelPreview] descendants. -/// -/// See also: -/// -/// * [StreamChannelPreviewThemeData], which is used to configure this theme. -/// {@endtemplate} -/// -/// This is deprecated, but currently still used by `StreamChannelInfoBottomSheet`. -@Deprecated('Use StreamChannelListItemTheme instead.') -class StreamChannelPreviewTheme extends InheritedTheme { - /// Creates a [StreamChannelPreviewTheme]. - /// - /// The [data] parameter must not be null. - const StreamChannelPreviewTheme({ - super.key, - required this.data, - required super.child, - }); - - /// The configuration of this theme. - final StreamChannelPreviewThemeData data; - - /// The closest instance of this class that encloses the given context. - /// - /// If there is no enclosing [StreamChannelPreviewTheme] widget, then - /// [StreamChatThemeData.channelPreviewTheme] is used. - /// - /// Typical usage is as follows: - /// - /// ```dart - /// final theme = ChannelPreviewTheme.of(context); - /// ``` - static StreamChannelPreviewThemeData of(BuildContext context) { - final channelPreviewTheme = context.dependOnInheritedWidgetOfExactType(); - return channelPreviewTheme?.data ?? StreamChatTheme.of(context).channelPreviewTheme; - } - - @override - Widget wrap(BuildContext context, Widget child) => StreamChannelPreviewTheme(data: data, child: child); - - @override - bool updateShouldNotify(StreamChannelPreviewTheme oldWidget) => data != oldWidget.data; -} - -/// {@template channelPreviewThemeData} -/// A style that overrides the default appearance of [ChannelPreview]s when used -/// with [StreamChannelPreviewTheme] or with the overall [StreamChatTheme]'s -/// [StreamChatThemeData.channelPreviewTheme]. -/// -/// See also: -/// -/// * [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]. -/// {@endtemplate} -class StreamChannelPreviewThemeData with Diagnosticable { - /// Creates a [StreamChannelPreviewThemeData]. - const StreamChannelPreviewThemeData({ - this.titleStyle, - this.subtitleStyle, - this.lastMessageAtStyle, - this.avatarTheme, - this.unreadCounterColor, - this.indicatorIconSize, - this.lastMessageAtFormatter, - }); - - /// Theme for title - final TextStyle? titleStyle; - - /// Theme for subtitle - final TextStyle? subtitleStyle; - - /// Theme of last message at - final TextStyle? lastMessageAtStyle; - - /// Avatar theme - final StreamAvatarThemeData? avatarTheme; - - /// Unread counter color - final Color? unreadCounterColor; - - /// Indicator icon size - final double? indicatorIconSize; - - /// Formatter for the last message timestamp. - /// - /// If null, uses the default date formatting. - /// - /// Example: - /// ```dart - /// StreamChannelPreviewThemeData( - /// lastMessageAtStyle: TextStyle(...), - /// lastMessageAtFormatter: (context, date) { - /// return Jiffy.parseFromDateTime(date).format('d MMMM'); // "23 May" - /// }, - /// ) - /// ``` - final DateFormatter? lastMessageAtFormatter; - - /// Copy with theme - StreamChannelPreviewThemeData copyWith({ - TextStyle? titleStyle, - TextStyle? subtitleStyle, - TextStyle? lastMessageAtStyle, - StreamAvatarThemeData? avatarTheme, - Color? unreadCounterColor, - double? indicatorIconSize, - DateFormatter? lastMessageAtFormatter, - }) { - return StreamChannelPreviewThemeData( - titleStyle: titleStyle ?? this.titleStyle, - subtitleStyle: subtitleStyle ?? this.subtitleStyle, - lastMessageAtStyle: lastMessageAtStyle ?? this.lastMessageAtStyle, - avatarTheme: avatarTheme ?? this.avatarTheme, - unreadCounterColor: unreadCounterColor ?? this.unreadCounterColor, - indicatorIconSize: indicatorIconSize ?? this.indicatorIconSize, - lastMessageAtFormatter: lastMessageAtFormatter ?? this.lastMessageAtFormatter, - ); - } - - /// Linearly interpolate one [StreamChannelPreviewThemeData] to another. - StreamChannelPreviewThemeData lerp( - StreamChannelPreviewThemeData a, - StreamChannelPreviewThemeData b, - double t, - ) { - return StreamChannelPreviewThemeData( - avatarTheme: const StreamAvatarThemeData().lerp(a.avatarTheme!, b.avatarTheme!, t), - indicatorIconSize: a.indicatorIconSize, - lastMessageAtStyle: TextStyle.lerp(a.lastMessageAtStyle, b.lastMessageAtStyle, t), - subtitleStyle: TextStyle.lerp(a.subtitleStyle, b.subtitleStyle, t), - titleStyle: TextStyle.lerp(a.titleStyle, b.titleStyle, t), - unreadCounterColor: Color.lerp(a.unreadCounterColor, b.unreadCounterColor, t), - lastMessageAtFormatter: t < 0.5 ? a.lastMessageAtFormatter : b.lastMessageAtFormatter, - ); - } - - /// Merge with theme - StreamChannelPreviewThemeData merge(StreamChannelPreviewThemeData? other) { - if (other == null) return this; - return copyWith( - titleStyle: titleStyle?.merge(other.titleStyle) ?? other.titleStyle, - subtitleStyle: subtitleStyle?.merge(other.subtitleStyle) ?? other.subtitleStyle, - lastMessageAtStyle: lastMessageAtStyle?.merge(other.lastMessageAtStyle) ?? other.lastMessageAtStyle, - avatarTheme: avatarTheme?.merge(other.avatarTheme) ?? other.avatarTheme, - unreadCounterColor: other.unreadCounterColor, - lastMessageAtFormatter: other.lastMessageAtFormatter ?? lastMessageAtFormatter, - ); - } - - @override - bool operator ==(Object other) => - identical(this, other) || - other is StreamChannelPreviewThemeData && - runtimeType == other.runtimeType && - titleStyle == other.titleStyle && - subtitleStyle == other.subtitleStyle && - lastMessageAtStyle == other.lastMessageAtStyle && - avatarTheme == other.avatarTheme && - unreadCounterColor == other.unreadCounterColor && - indicatorIconSize == other.indicatorIconSize && - lastMessageAtFormatter == other.lastMessageAtFormatter; - - @override - int get hashCode => - titleStyle.hashCode ^ - subtitleStyle.hashCode ^ - lastMessageAtStyle.hashCode ^ - avatarTheme.hashCode ^ - unreadCounterColor.hashCode ^ - indicatorIconSize.hashCode ^ - lastMessageAtFormatter.hashCode; - - @override - void debugFillProperties(DiagnosticPropertiesBuilder properties) { - super.debugFillProperties(properties); - properties - ..add(DiagnosticsProperty('titleStyle', titleStyle)) - ..add(DiagnosticsProperty('subtitleStyle', subtitleStyle)) - ..add(DiagnosticsProperty('lastMessageAtStyle', lastMessageAtStyle)) - ..add(DiagnosticsProperty('avatarTheme', avatarTheme)) - ..add(ColorProperty('unreadCounterColor', unreadCounterColor)) - ..add(DiagnosticsProperty('lastMessageAtFormatter', lastMessageAtFormatter)); - } -} diff --git a/packages/stream_chat_flutter/lib/src/theme/stream_chat_theme.dart b/packages/stream_chat_flutter/lib/src/theme/stream_chat_theme.dart index 8ae19cb526..5b3f0654ff 100644 --- a/packages/stream_chat_flutter/lib/src/theme/stream_chat_theme.dart +++ b/packages/stream_chat_flutter/lib/src/theme/stream_chat_theme.dart @@ -43,7 +43,6 @@ class StreamChatThemeData { StreamTextTheme? textTheme, StreamColorTheme? colorTheme, StreamChannelListHeaderThemeData? channelListHeaderTheme, - StreamChannelPreviewThemeData? channelPreviewTheme, StreamChannelHeaderThemeData? channelHeaderTheme, Widget Function(BuildContext, User)? defaultUserImage, PlaceholderUserImage? placeholderUserImage, @@ -73,7 +72,6 @@ class StreamChatThemeData { final customizedData = defaultData.copyWith( channelListHeaderTheme: channelListHeaderTheme, - channelPreviewTheme: channelPreviewTheme, channelHeaderTheme: channelHeaderTheme, defaultUserImage: defaultUserImage, placeholderUserImage: placeholderUserImage, @@ -107,7 +105,6 @@ class StreamChatThemeData { required this.textTheme, required this.colorTheme, required this.channelListHeaderTheme, - required this.channelPreviewTheme, required this.channelHeaderTheme, required this.primaryIconTheme, required this.galleryHeaderTheme, @@ -153,31 +150,11 @@ class StreamChatThemeData { ), color: colorTheme.barsBg, ); - final channelPreviewTheme = StreamChannelPreviewThemeData( - unreadCounterColor: colorTheme.accentError, - avatarTheme: StreamAvatarThemeData( - borderRadius: BorderRadius.circular(20), - constraints: const BoxConstraints.tightFor( - height: 40, - width: 40, - ), - ), - titleStyle: textTheme.bodyBold, - subtitleStyle: textTheme.footnote.copyWith( - color: const Color(0xff7A7A7A), - ), - lastMessageAtStyle: textTheme.footnote.copyWith( - // ignore: deprecated_member_use - color: colorTheme.textHighEmphasis.withOpacity(0.5), - ), - indicatorIconSize: 16, - ); return StreamChatThemeData.raw( textTheme: textTheme, colorTheme: colorTheme, primaryIconTheme: iconTheme, - channelPreviewTheme: channelPreviewTheme, channelListHeaderTheme: StreamChannelListHeaderThemeData( avatarTheme: StreamAvatarThemeData( borderRadius: BorderRadius.circular(20), @@ -195,7 +172,6 @@ class StreamChatThemeData { backgroundColor: channelHeaderTheme.color, iconMenuPointColor: colorTheme.textHighEmphasis, titleTextStyle: textTheme.headlineBold, - subtitleTextStyle: channelPreviewTheme.subtitleStyle, bottomSheetBarrierColor: colorTheme.overlay, ), galleryFooterTheme: StreamGalleryFooterThemeData( @@ -338,9 +314,6 @@ class StreamChatThemeData { /// The color themes used in the widgets final StreamColorTheme colorTheme; - /// Theme of the [StreamChannelPreview] - final StreamChannelPreviewThemeData channelPreviewTheme; - /// Theme of the [StreamChannelListHeader] final StreamChannelListHeaderThemeData channelListHeaderTheme; @@ -396,7 +369,6 @@ class StreamChatThemeData { StreamChatThemeData copyWith({ StreamTextTheme? textTheme, StreamColorTheme? colorTheme, - StreamChannelPreviewThemeData? channelPreviewTheme, StreamChannelHeaderThemeData? channelHeaderTheme, Widget Function(BuildContext, User)? defaultUserImage, PlaceholderUserImage? placeholderUserImage, @@ -420,7 +392,6 @@ class StreamChatThemeData { textTheme: this.textTheme.merge(textTheme), colorTheme: this.colorTheme.merge(colorTheme), primaryIconTheme: this.primaryIconTheme.merge(primaryIconTheme), - channelPreviewTheme: this.channelPreviewTheme.merge(channelPreviewTheme), channelHeaderTheme: this.channelHeaderTheme.merge(channelHeaderTheme), galleryHeaderTheme: galleryHeaderTheme ?? this.galleryHeaderTheme, galleryFooterTheme: galleryFooterTheme ?? this.galleryFooterTheme, @@ -445,7 +416,6 @@ class StreamChatThemeData { textTheme: textTheme.merge(other.textTheme), colorTheme: colorTheme.merge(other.colorTheme), primaryIconTheme: other.primaryIconTheme, - channelPreviewTheme: channelPreviewTheme.merge(other.channelPreviewTheme), channelHeaderTheme: channelHeaderTheme.merge(other.channelHeaderTheme), galleryHeaderTheme: galleryHeaderTheme.merge(other.galleryHeaderTheme), galleryFooterTheme: galleryFooterTheme.merge(other.galleryFooterTheme), diff --git a/packages/stream_chat_flutter/lib/src/theme/themes.dart b/packages/stream_chat_flutter/lib/src/theme/themes.dart index 643872e953..3f393d7c93 100644 --- a/packages/stream_chat_flutter/lib/src/theme/themes.dart +++ b/packages/stream_chat_flutter/lib/src/theme/themes.dart @@ -1,7 +1,6 @@ export 'avatar_theme.dart'; export 'channel_header_theme.dart'; export 'channel_list_header_theme.dart'; -export 'channel_preview_theme.dart'; export 'color_theme.dart'; export 'draft_list_tile_theme.dart'; export 'gallery_footer_theme.dart'; diff --git a/packages/stream_chat_flutter/lib/stream_chat_flutter.dart b/packages/stream_chat_flutter/lib/stream_chat_flutter.dart index 64e69f06ef..ea158b5150 100644 --- a/packages/stream_chat_flutter/lib/stream_chat_flutter.dart +++ b/packages/stream_chat_flutter/lib/stream_chat_flutter.dart @@ -169,15 +169,12 @@ export 'src/poll/stream_poll_options_dialog.dart'; export 'src/poll/stream_poll_results_dialog.dart'; export 'src/reactions/detail/reaction_detail_sheet.dart'; export 'src/reactions/picker/reaction_picker.dart'; -export 'src/scroll_view/channel_scroll_view/stream_channel_grid_tile.dart'; -export 'src/scroll_view/channel_scroll_view/stream_channel_grid_view.dart'; export 'src/scroll_view/channel_scroll_view/stream_channel_list_item.dart'; export 'src/scroll_view/channel_scroll_view/stream_channel_list_view.dart'; export 'src/scroll_view/draft_scroll_view/stream_draft_list_tile.dart'; export 'src/scroll_view/draft_scroll_view/stream_draft_list_view.dart'; export 'src/scroll_view/member_scroll_view/stream_member_grid_view.dart'; export 'src/scroll_view/member_scroll_view/stream_member_list_view.dart'; -export 'src/scroll_view/message_search_scroll_view/stream_message_search_grid_view.dart'; export 'src/scroll_view/message_search_scroll_view/stream_message_search_list_tile.dart'; export 'src/scroll_view/message_search_scroll_view/stream_message_search_list_view.dart'; export 'src/scroll_view/photo_gallery/stream_photo_gallery.dart'; diff --git a/packages/stream_chat_flutter/test/src/gallery/goldens/ci/gallery_header_0.png b/packages/stream_chat_flutter/test/src/gallery/goldens/ci/gallery_header_0.png index 82703f3ce5..65c3b1ca9d 100644 Binary files a/packages/stream_chat_flutter/test/src/gallery/goldens/ci/gallery_header_0.png and b/packages/stream_chat_flutter/test/src/gallery/goldens/ci/gallery_header_0.png differ 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 deleted file mode 100644 index b0fd386b2e..0000000000 --- a/packages/stream_chat_flutter/test/src/theme/channel_preview_theme_test.dart +++ /dev/null @@ -1,115 +0,0 @@ -import 'package:flutter/material.dart' hide TextTheme; -import 'package:flutter_test/flutter_test.dart'; -import 'package:stream_chat_flutter/stream_chat_flutter.dart'; - -String _dummyFormatter(BuildContext context, DateTime date) => 'formatted'; - -void main() { - test('ChannelPreviewThemeData copyWith, ==, hashCode basics', () { - expect(const StreamChannelPreviewThemeData(), const StreamChannelPreviewThemeData().copyWith()); - expect(const StreamChannelPreviewThemeData().hashCode, const StreamChannelPreviewThemeData().copyWith().hashCode); - }); - - group('ChannelPreviewThemeData lerps', () { - test('''Light ChannelPreviewThemeData lerps completely to dark ChannelPreviewThemeData''', () { - expect( - const StreamChannelPreviewThemeData().lerp(_channelPreviewThemeControl, _channelPreviewThemeControlDark, 1), - _channelPreviewThemeControlDark, - ); - }); - - test('''Light ChannelPreviewThemeData lerps halfway to dark ChannelPreviewThemeData''', () { - expect( - const StreamChannelPreviewThemeData().lerp( - _channelPreviewThemeControl, - _channelPreviewThemeControlDark, - 0.5, - ), - _channelPreviewThemeControlMidLerp, - // TODO: Remove skip, once we drop support for flutter v3.24.0 - skip: true, - reason: 'Currently failing in flutter v3.27.0 due to new color alpha', - ); - }); - - test('''Dark ChannelPreviewThemeData lerps completely to light ChannelPreviewThemeData''', () { - expect( - const StreamChannelPreviewThemeData().lerp(_channelPreviewThemeControlDark, _channelPreviewThemeControl, 1), - _channelPreviewThemeControl, - ); - }); - }); - - test('Merging dark and light themes results in a dark theme', () { - expect(_channelPreviewThemeControl.merge(_channelPreviewThemeControlDark), _channelPreviewThemeControlDark); - }); -} - -final _channelPreviewThemeControl = StreamChannelPreviewThemeData( - unreadCounterColor: const StreamColorTheme.light().accentError, - avatarTheme: StreamAvatarThemeData( - borderRadius: BorderRadius.circular(20), - constraints: const BoxConstraints.tightFor( - height: 40, - width: 40, - ), - ), - titleStyle: const StreamTextTheme.light().bodyBold, - subtitleStyle: const StreamTextTheme.light().footnote.copyWith( - color: const Color(0xff7A7A7A), - ), - lastMessageAtStyle: const StreamTextTheme.light().footnote.copyWith( - // ignore: deprecated_member_use - color: const StreamColorTheme.light().textHighEmphasis.withOpacity(0.5), - ), - lastMessageAtFormatter: _dummyFormatter, - indicatorIconSize: 16, -); - -final _channelPreviewThemeControlMidLerp = StreamChannelPreviewThemeData( - unreadCounterColor: const Color(0xffff3742), - avatarTheme: StreamAvatarThemeData( - borderRadius: BorderRadius.circular(20), - constraints: const BoxConstraints.tightFor( - height: 40, - width: 40, - ), - ), - titleStyle: const TextStyle( - color: Color(0xff7f7f7f), - fontSize: 14, - fontWeight: FontWeight.w500, - ), - subtitleStyle: const TextStyle( - color: Color(0xff7a7a7a), - fontSize: 12, - fontWeight: FontWeight.w400, - ), - lastMessageAtStyle: const StreamTextTheme.light().footnote.copyWith( - // ignore: deprecated_member_use - color: const Color(0x807f7f7f).withOpacity(0.5), - ), - lastMessageAtFormatter: _dummyFormatter, - indicatorIconSize: 16, -); - -final _channelPreviewThemeControlDark = StreamChannelPreviewThemeData( - unreadCounterColor: const StreamColorTheme.dark().accentError, - avatarTheme: StreamAvatarThemeData( - borderRadius: BorderRadius.circular(20), - constraints: const BoxConstraints.tightFor( - height: 40, - width: 40, - ), - ), - titleStyle: const StreamTextTheme.dark().bodyBold, - subtitleStyle: const StreamTextTheme.dark().footnote.copyWith( - color: const Color(0xff7A7A7A), - ), - lastMessageAtStyle: const StreamTextTheme.dark().footnote.copyWith( - // ignore: deprecated_member_use - color: const StreamColorTheme.dark().textHighEmphasis.withOpacity(0.5), - ), - lastMessageAtFormatter: _dummyFormatter, - indicatorIconSize: 16, -); 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 f3bd223539..3f5a718c99 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 @@ -101,64 +101,43 @@ void main() { } // Light theme test control. -final _galleryHeaderThemeDataControl = StreamGalleryHeaderThemeData( - closeButtonColor: const Color(0xff000000), - backgroundColor: const Color(0xffffffff), - iconMenuPointColor: const Color(0xff000000), - titleTextStyle: const TextStyle( +const _galleryHeaderThemeDataControl = StreamGalleryHeaderThemeData( + closeButtonColor: Color(0xff000000), + backgroundColor: Color(0xffffffff), + iconMenuPointColor: Color(0xff000000), + titleTextStyle: TextStyle( fontSize: 16, fontWeight: FontWeight.w500, color: Colors.black, ), - subtitleTextStyle: - const TextStyle( - fontSize: 12, - color: Colors.black, - fontWeight: FontWeight.w400, - ).copyWith( - color: const Color(0xff7A7A7A), - ), - bottomSheetBarrierColor: const Color.fromRGBO(0, 0, 0, 0.2), + subtitleTextStyle: null, + bottomSheetBarrierColor: Color.fromRGBO(0, 0, 0, 0.2), ); // Light theme test control. -final _galleryHeaderThemeDataHalfLerpControl = StreamGalleryHeaderThemeData( - closeButtonColor: const Color(0xff7f7f7f), - backgroundColor: const Color(0xff88898a), - iconMenuPointColor: const Color(0xff7f7f7f), - titleTextStyle: const TextStyle( +const _galleryHeaderThemeDataHalfLerpControl = StreamGalleryHeaderThemeData( + closeButtonColor: Color(0xff7f7f7f), + backgroundColor: Color(0xff88898a), + iconMenuPointColor: Color(0xff7f7f7f), + titleTextStyle: TextStyle( fontSize: 16, fontWeight: FontWeight.w500, color: Color(0xff7f7f7f), ), - subtitleTextStyle: - const TextStyle( - fontSize: 12, - color: Color(0xff7a7a7a), - fontWeight: FontWeight.w400, - ).copyWith( - color: const Color(0xff7A7A7A), - ), - bottomSheetBarrierColor: const Color(0x4c000000), + subtitleTextStyle: null, + bottomSheetBarrierColor: Color(0x4c000000), ); // Dark theme test control. -final _galleryHeaderThemeDataDarkControl = StreamGalleryHeaderThemeData( - closeButtonColor: const Color(0xffffffff), - backgroundColor: const Color(0xff121416), - iconMenuPointColor: const Color(0xffffffff), - titleTextStyle: const TextStyle( +const _galleryHeaderThemeDataDarkControl = StreamGalleryHeaderThemeData( + closeButtonColor: Color(0xffffffff), + backgroundColor: Color(0xff121416), + iconMenuPointColor: Color(0xffffffff), + titleTextStyle: TextStyle( fontSize: 16, fontWeight: FontWeight.w500, color: Colors.white, ), - subtitleTextStyle: - const TextStyle( - fontSize: 12, - color: Colors.white, - fontWeight: FontWeight.w400, - ).copyWith( - color: const Color(0xff7A7A7A), - ), - bottomSheetBarrierColor: const Color.fromRGBO(0, 0, 0, 0.4), + subtitleTextStyle: null, + bottomSheetBarrierColor: Color.fromRGBO(0, 0, 0, 0.4), );