Skip to content

Commit

Permalink
docs(ui): document reaction icon customization (#1896)
Browse files Browse the repository at this point in the history
* doc(ui): document reaction icon customization

* chore: fix linting

* Update docusaurus/docs/Flutter/02-stream_chat_flutter/03-custom_widgets/01-customize_message_widget.mdx

Co-authored-by: Deven Joshi <[email protected]>

* chore: update code snippet

---------

Co-authored-by: Deven Joshi <[email protected]>
  • Loading branch information
esarbanis and deven98 authored Apr 11, 2024
1 parent 6c31f8a commit ca92ee0
Show file tree
Hide file tree
Showing 10 changed files with 37 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,32 @@ StreamMessageListView(
),
```

### Providing Custom Reaction Icons

By default the `StreamReactionIcon` widgets provided by the SDK are `love`, `like`, `sad`, `haha`, and `wow`.
However, you can provide your own custom reaction icons by providing a `reactionIcons` parameter to the `StreamChatConfigurationData`.

```dart
StreamChat(
client: client,
streamChatConfigData: StreamChatConfigurationData(
reactionIcons: [
StreamReactionIcon(
type: 'custom',
builder: (context, isHighlighted, iconSize) {
return Icon(
Icons.star,
size: iconSize,
color: isHighlighted ? Colors.red : Colors.black,
);
},
),
]
),
child: //Your widget here
)
```

### Theming

You can customize the `StreamMessageWidget` using the `StreamChatTheme` class, so that you can change the
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'package:flutter/material.dart';
import 'package:stream_chat_flutter/stream_chat_flutter.dart';

/// /// {@template confirmationDialog}
/// {@template confirmationDialog}
/// A dialog that prompts the user to take an action or cancel.
/// {@endtemplate}
class ConfirmationDialog extends StatelessWidget {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import 'package:stream_chat_flutter/src/theme/themes.dart';
import 'package:stream_chat_flutter/src/utils/utils.dart';
import 'package:stream_chat_flutter_core/stream_chat_flutter_core.dart';

/// {@macro streamGalleryHeader}
/// {@template streamGalleryHeader}
/// Header/AppBar widget for media display screen
/// {@endtemplate}
class StreamGalleryHeader extends StatelessWidget
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ class BottomRow extends StatelessWidget {
// textScaleFactor is already applied to the textSpan.
//
// issue: https://github.com/GetStream/stream-chat-flutter/issues/1250
// ignore: deprecated_member_use
data: mediaQueryData.copyWith(textScaleFactor: 1),
child: child,
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ class StreamMessageWidget extends StatefulWidget {
/// with the tap action on the reactions picker.
final OnReactionsTap? onReactionsTap;

/// {@template onReactionsHover}
/// {@macro onReactionsHover}
///
/// Note: Only used in desktop devices (web and desktop).
final OnReactionsHover? onReactionsHover;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ class MediaThumbnailProvider extends ImageProvider<MediaThumbnailProvider> {
}

@override
bool operator ==(dynamic other) {
bool operator ==(Object other) {
if (other is MediaThumbnailProvider) {
return media == other.media &&
size == other.size &&
Expand Down
1 change: 1 addition & 0 deletions packages/stream_chat_flutter/lib/src/stream_chat.dart
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ class StreamChatState extends State<StreamChat> {
final theme = _getTheme(context, widget.streamChatThemeData);
return Theme(
data: Theme.of(context).copyWith(
// ignore: deprecated_member_use
useMaterial3: widget.useMaterial3,
),
child: Portal(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class StreamChatThemeData {
Widget Function(BuildContext, User)? defaultUserImage,
PlaceholderUserImage? placeholderUserImage,
IconThemeData? primaryIconTheme,
@Deprecated('Use StreamChatConfigurationData.reactionIcons instead')
List<StreamReactionIcon>? reactionIcons,
StreamGalleryHeaderThemeData? imageHeaderTheme,
StreamGalleryFooterThemeData? imageFooterTheme,
Expand All @@ -75,6 +76,7 @@ class StreamChatThemeData {
defaultUserImage: defaultUserImage,
placeholderUserImage: placeholderUserImage,
primaryIconTheme: primaryIconTheme,
//ignore: deprecated_member_use_from_same_package
reactionIcons: reactionIcons,
galleryHeaderTheme: imageHeaderTheme,
galleryFooterTheme: imageFooterTheme,
Expand Down Expand Up @@ -330,6 +332,7 @@ class StreamChatThemeData {
PlaceholderUserImage? placeholderUserImage,
IconThemeData? primaryIconTheme,
StreamChannelListHeaderThemeData? channelListHeaderTheme,
@Deprecated('Use StreamChatConfigurationData.reactionIcons instead')
List<StreamReactionIcon>? reactionIcons,
StreamGalleryHeaderThemeData? galleryHeaderTheme,
StreamGalleryFooterThemeData? galleryFooterTheme,
Expand Down
1 change: 1 addition & 0 deletions packages/stream_chat_flutter/lib/src/utils/extensions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ extension InputDecorationX on InputDecoration {
extension BuildContextX on BuildContext {
// ignore: public_member_api_docs
double get textScaleFactor =>
// ignore: deprecated_member_use
MediaQuery.maybeOf(this)?.textScaleFactor ?? 1.0;

/// Retrieves current translations according to locale
Expand Down
2 changes: 1 addition & 1 deletion packages/stream_chat_flutter/lib/src/utils/typedefs.dart
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ typedef AttachmentThumbnailBuilder = Widget Function(
Attachment,
);

/// {@macro mentionTileBuilder}
/// {@template mentionTileBuilder}
/// A widget builder for representing a custom mention tile.
/// {@endtemplate}
typedef MentionTileBuilder = Widget Function(
Expand Down

0 comments on commit ca92ee0

Please sign in to comment.