@@ -486,10 +486,9 @@ class MarkAsReadWidgetState extends State<MarkAsReadWidget> {
486
486
487
487
return IgnorePointer (
488
488
ignoring: areMessagesRead,
489
- child: AnimatedOpacity (
490
- opacity: areMessagesRead ? 0 : 1 ,
491
- duration: Duration (milliseconds: areMessagesRead ? 2000 : 300 ),
492
- curve: Curves .easeOut,
489
+ child: MarkAsReadAnimation (
490
+ loading: loading,
491
+ hidden: areMessagesRead,
493
492
child: SizedBox (width: double .infinity,
494
493
// Design referenced from:
495
494
// https://www.figma.com/file/1JTNtYo9memgW7vV6d0ygq/Zulip-Mobile?type=design&node-id=132-9684&mode=design&t=jJwHzloKJ0TMOG4M-0
@@ -520,6 +519,49 @@ class MarkAsReadWidgetState extends State<MarkAsReadWidget> {
520
519
}
521
520
}
522
521
522
+ class MarkAsReadAnimation extends StatefulWidget {
523
+ const MarkAsReadAnimation ({
524
+ super .key,
525
+ required this .loading,
526
+ required this .hidden,
527
+ required this .child
528
+ });
529
+
530
+ final bool loading;
531
+ final bool hidden;
532
+ final Widget child;
533
+
534
+ @override
535
+ State <MarkAsReadAnimation > createState () => _MarkAsReadAnimationState ();
536
+ }
537
+
538
+ class _MarkAsReadAnimationState extends State <MarkAsReadAnimation > {
539
+ bool _isPressed = false ;
540
+
541
+ void _setScale (bool isPressed) {
542
+ setState (() {
543
+ _isPressed = isPressed;
544
+ });
545
+ }
546
+
547
+ @override
548
+ Widget build (BuildContext context) {
549
+ return GestureDetector (
550
+ onTapDown: (_) => _setScale (true ),
551
+ onTapUp: (_) => _setScale (false ),
552
+ onTapCancel: () => _setScale (false ),
553
+ child: AnimatedScale (
554
+ scale: _isPressed ? 0.95 : 1 ,
555
+ duration: const Duration (milliseconds: 100 ),
556
+ curve: Curves .easeOut,
557
+ child: AnimatedOpacity (
558
+ opacity: widget.hidden ? 0 : widget.loading ? 0.55 : 1 ,
559
+ duration: const Duration (milliseconds: 500 ),
560
+ curve: Curves .easeOut,
561
+ child: widget.child)));
562
+ }
563
+ }
564
+
523
565
class RecipientHeader extends StatelessWidget {
524
566
const RecipientHeader ({super .key, required this .message, required this .narrow});
525
567
0 commit comments