Skip to content

Commit 791b703

Browse files
Khader-1gnprice
authored andcommitted
msglist: Use scale animation for mark-as-read button is pressed
1 parent 9b105a3 commit 791b703

File tree

1 file changed

+28
-6
lines changed

1 file changed

+28
-6
lines changed

lib/widgets/message_list.dart

+28-6
Original file line numberDiff line numberDiff line change
@@ -516,6 +516,7 @@ class _MarkAsReadWidgetState extends State<MarkAsReadWidget> {
516516
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 10 - ((48 - 38) / 2)),
517517
child: FilledButton.icon(
518518
style: FilledButton.styleFrom(
519+
splashFactory: NoSplash.splashFactory,
519520
minimumSize: const Size.fromHeight(38),
520521
textStyle:
521522
// Restate [FilledButton]'s default, which inherits from
@@ -543,7 +544,7 @@ class _MarkAsReadWidgetState extends State<MarkAsReadWidget> {
543544
}
544545
}
545546

546-
class MarkAsReadAnimation extends StatelessWidget {
547+
class MarkAsReadAnimation extends StatefulWidget {
547548
final bool loading;
548549
final bool hidden;
549550
final Widget child;
@@ -555,13 +556,34 @@ class MarkAsReadAnimation extends StatelessWidget {
555556
required this.child
556557
});
557558

559+
@override
560+
State<MarkAsReadAnimation> createState() => _MarkAsReadAnimationState();
561+
}
562+
563+
class _MarkAsReadAnimationState extends State<MarkAsReadAnimation> {
564+
bool _isPressed = false;
565+
566+
void _setIsPressed(bool isPressed) {
567+
setState(() {
568+
_isPressed = isPressed;
569+
});
570+
}
571+
558572
@override
559573
Widget build(BuildContext context) {
560-
return AnimatedOpacity(
561-
opacity: hidden ? 0 : loading ? 0.5 : 1,
562-
duration: const Duration(milliseconds: 500),
563-
curve: Curves.easeOut,
564-
child: child);
574+
return GestureDetector(
575+
onTapDown: (_) => _setIsPressed(true),
576+
onTapUp: (_) => _setIsPressed(false),
577+
onTapCancel: () => _setIsPressed(false),
578+
child: AnimatedScale(
579+
scale: _isPressed ? 0.95 : 1,
580+
duration: const Duration(milliseconds: 100),
581+
curve: Curves.easeOut,
582+
child: AnimatedOpacity(
583+
opacity: widget.hidden ? 0 : widget.loading ? 0.5 : 1,
584+
duration: const Duration(milliseconds: 500),
585+
curve: Curves.easeOut,
586+
child: widget.child)));
565587
}
566588
}
567589

0 commit comments

Comments
 (0)