Skip to content

Commit fd46f9a

Browse files
committed
msg_list [nfc]: Factor out AnimatedUnread Widget
We have basically the same animation going on for both unread marker and mark-as-read button. This factor out the animation into a separate widget, AnimatedUnread, which can be used for both.
1 parent 53853ab commit fd46f9a

File tree

1 file changed

+22
-10
lines changed

1 file changed

+22
-10
lines changed

lib/widgets/message_list.dart

+22-10
Original file line numberDiff line numberDiff line change
@@ -461,10 +461,8 @@ class MarkAsReadWidget extends StatelessWidget {
461461

462462
return IgnorePointer(
463463
ignoring: areMessagesRead,
464-
child: AnimatedOpacity(
465-
opacity: areMessagesRead ? 0 : 1,
466-
duration: Duration(milliseconds: areMessagesRead ? 2000 : 300),
467-
curve: Curves.easeOut,
464+
child: _AnimatedUnread(
465+
isRead: areMessagesRead,
468466
child: SizedBox(width: double.infinity,
469467
// Design referenced from:
470468
// https://www.figma.com/file/1JTNtYo9memgW7vV6d0ygq/Zulip-Mobile?type=design&node-id=132-9684&mode=design&t=jJwHzloKJ0TMOG4M-0
@@ -611,12 +609,8 @@ class _UnreadMarker extends StatelessWidget {
611609
left: 0,
612610
bottom: 0,
613611
width: 4,
614-
child: AnimatedOpacity(
615-
opacity: isRead ? 0 : 1,
616-
// Web uses 2s and 0.3s durations, and a CSS ease-out curve.
617-
// See zulip:web/styles/message_row.css .
618-
duration: Duration(milliseconds: isRead ? 2000 : 300),
619-
curve: Curves.easeOut,
612+
child: _AnimatedUnread(
613+
isRead: isRead,
620614
child: DecoratedBox(
621615
decoration: BoxDecoration(
622616
color: color,
@@ -629,6 +623,24 @@ class _UnreadMarker extends StatelessWidget {
629623
}
630624
}
631625

626+
class _AnimatedUnread extends StatelessWidget {
627+
const _AnimatedUnread({required this.isRead, required this.child});
628+
629+
final bool isRead;
630+
final Widget child;
631+
632+
@override
633+
Widget build(BuildContext context) {
634+
return AnimatedOpacity(
635+
opacity: isRead ? 0 : 1,
636+
// Web uses 2s and 0.3s durations, and a CSS ease-out curve.
637+
// See zulip:web/styles/message_row.css .
638+
duration: Duration(milliseconds: isRead ? 2000 : 300),
639+
curve: Curves.easeOut,
640+
child: child);
641+
}
642+
}
643+
632644
class StreamMessageRecipientHeader extends StatelessWidget {
633645
const StreamMessageRecipientHeader({
634646
super.key,

0 commit comments

Comments
 (0)