Skip to content

Commit 76a82f6

Browse files
committed
msglist: Use scale animation for mark-as-read button is pressed
1 parent eb73e49 commit 76a82f6

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
@@ -497,6 +497,7 @@ class MarkAsReadWidgetState extends State<MarkAsReadWidget> {
497497
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 10 - ((48 - 38) / 2)),
498498
child: FilledButton.icon(
499499
style: FilledButton.styleFrom(
500+
splashFactory: NoSplash.splashFactory,
500501
minimumSize: const Size.fromHeight(38),
501502
textStyle:
502503
// Restate [FilledButton]'s default, which inherits from
@@ -522,7 +523,7 @@ class MarkAsReadWidgetState extends State<MarkAsReadWidget> {
522523
}
523524
}
524525

525-
class MarkAsReadAnimation extends StatelessWidget {
526+
class MarkAsReadAnimation extends StatefulWidget {
526527
final bool loading;
527528
final bool hidden;
528529
final Widget child;
@@ -534,13 +535,34 @@ class MarkAsReadAnimation extends StatelessWidget {
534535
required this.child
535536
});
536537

538+
@override
539+
State<MarkAsReadAnimation> createState() => _MarkAsReadAnimationState();
540+
}
541+
542+
class _MarkAsReadAnimationState extends State<MarkAsReadAnimation> {
543+
bool _isPressed = false;
544+
545+
void _setScale(bool isPressed) {
546+
setState(() {
547+
_isPressed = isPressed;
548+
});
549+
}
550+
537551
@override
538552
Widget build(BuildContext context) {
539-
return AnimatedOpacity(
540-
opacity: hidden ? 0 : loading ? 0.5 : 1,
541-
duration: const Duration(milliseconds: 500),
542-
curve: Curves.easeOut,
543-
child: child);
553+
return GestureDetector(
554+
onTapDown: (_) => _setScale(true),
555+
onTapUp: (_) => _setScale(false),
556+
onTapCancel: () => _setScale(false),
557+
child: AnimatedScale(
558+
scale: _isPressed ? 0.95 : 1,
559+
duration: const Duration(milliseconds: 100),
560+
curve: Curves.easeOut,
561+
child: AnimatedOpacity(
562+
opacity: widget.hidden ? 0 : widget.loading ? 0.5 : 1,
563+
duration: const Duration(milliseconds: 500),
564+
curve: Curves.easeOut,
565+
child: widget.child)));
544566
}
545567
}
546568

0 commit comments

Comments
 (0)