Skip to content

Commit 5f13ee1

Browse files
committed
msglist [nfc]: Introduce MarkAsReadAnimation widget
MarkAsReadAnimation is expected to get more complex in the upcoming commits, so it's better to have it in a separate widget.
1 parent c38d6a9 commit 5f13ee1

File tree

1 file changed

+25
-4
lines changed

1 file changed

+25
-4
lines changed

lib/widgets/message_list.dart

+25-4
Original file line numberDiff line numberDiff line change
@@ -505,10 +505,9 @@ class _MarkAsReadWidgetState extends State<MarkAsReadWidget> {
505505

506506
return IgnorePointer(
507507
ignoring: areMessagesRead,
508-
child: AnimatedOpacity(
509-
opacity: areMessagesRead ? 0 : _loading ? 0.5 : 1,
510-
duration: Duration(milliseconds: areMessagesRead ? 2000 : 300),
511-
curve: Curves.easeOut,
508+
child: MarkAsReadAnimation(
509+
loading: _loading,
510+
hidden: areMessagesRead,
512511
child: SizedBox(width: double.infinity,
513512
// Design referenced from:
514513
// https://www.figma.com/file/1JTNtYo9memgW7vV6d0ygq/Zulip-Mobile?type=design&node-id=132-9684&mode=design&t=jJwHzloKJ0TMOG4M-0
@@ -544,6 +543,28 @@ class _MarkAsReadWidgetState extends State<MarkAsReadWidget> {
544543
}
545544
}
546545

546+
class MarkAsReadAnimation extends StatelessWidget {
547+
final bool loading;
548+
final bool hidden;
549+
final Widget child;
550+
551+
const MarkAsReadAnimation({
552+
super.key,
553+
required this.loading,
554+
required this.hidden,
555+
required this.child
556+
});
557+
558+
@override
559+
Widget build(BuildContext context) {
560+
return AnimatedOpacity(
561+
opacity: hidden ? 0 : loading ? 0.5 : 1,
562+
duration: Duration(milliseconds: hidden ? 2000 : 300),
563+
curve: Curves.easeOut,
564+
child: child);
565+
}
566+
}
567+
547568
class RecipientHeader extends StatelessWidget {
548569
const RecipientHeader({super.key, required this.message, required this.narrow});
549570

0 commit comments

Comments
 (0)