[MessageListView] Add messageHighlightColor property

Signed-off-by: Sahil Kumar <[email protected]>
This commit is contained in:
Sahil Kumar
2021-01-06 13:50:30 +05:30
parent cc54b18a14
commit ef4adaea6e
+10 -7
View File
@@ -122,6 +122,7 @@ class MessageListView extends StatefulWidget {
this.itemPositionListener, this.itemPositionListener,
this.onMessageSwiped, this.onMessageSwiped,
this.highlightInitialMessage = false, this.highlightInitialMessage = false,
this.messageHighlightColor,
this.onShowMessage, this.onShowMessage,
}) : super(key: key); }) : super(key: key);
@@ -175,6 +176,9 @@ class MessageListView extends StatefulWidget {
/// Also See [StreamChannel] /// Also See [StreamChannel]
final bool highlightInitialMessage; final bool highlightInitialMessage;
/// Color used while highlighting initial message
final Color messageHighlightColor;
final ShowMessageCallback onShowMessage; final ShowMessageCallback onShowMessage;
@override @override
@@ -845,17 +849,16 @@ class _MessageListViewState extends State<MessageListView> {
if (!initialMessageHighlightComplete && if (!initialMessageHighlightComplete &&
widget.highlightInitialMessage && widget.highlightInitialMessage &&
_isInitialMessage(message.id)) { _isInitialMessage(message.id)) {
final accentColor = Theme.of(context).accentColor; final colorTheme = StreamChatTheme.of(context).colorTheme;
final highlightColor = widget.messageHighlightColor ?? colorTheme.yellow;
child = TweenAnimationBuilder<Color>( child = TweenAnimationBuilder<Color>(
tween: ColorTween( tween: ColorTween(
begin: accentColor.withOpacity(0.7), begin: highlightColor,
end: Colors.transparent, end: colorTheme.white.withOpacity(0),
), ),
duration: const Duration(seconds: 2), duration: const Duration(seconds: 3),
child: child, child: child,
onEnd: () { onEnd: () => initialMessageHighlightComplete = true,
initialMessageHighlightComplete = true;
},
builder: (_, color, child) { builder: (_, color, child) {
return Container( return Container(
color: color, color: color,