1+ import 'package:flutter/gestures.dart' ;
12import 'package:flutter/material.dart' ;
23
34import 'color.dart' ;
@@ -159,7 +160,7 @@ class ZulipWebUiKitButton extends StatelessWidget {
159160
160161 final labelColor = _labelColor (designVariables);
161162
162- return AnimatedScaleOnTap (
163+ return AnimatedScaleOnPrimaryPointerDown (
163164 scaleEnd: 0.96 ,
164165 duration: Duration (milliseconds: 100 ),
165166 child: TextButton .icon (
@@ -270,10 +271,10 @@ class ZulipIconButton extends StatelessWidget {
270271 }
271272}
272273
273- /// Apply [Transform.scale] to the child widget when tapped, and reset its scale
274- /// when released, while animating the transitions.
275- class AnimatedScaleOnTap extends StatefulWidget {
276- const AnimatedScaleOnTap ({
274+ /// Apply [Transform.scale] to the child widget on primary pointer-down,
275+ /// and reset its scale on -up or -cancel, with animated transitions.
276+ class AnimatedScaleOnPrimaryPointerDown extends StatefulWidget {
277+ const AnimatedScaleOnPrimaryPointerDown ({
277278 super .key,
278279 required this .scaleEnd,
279280 required this .duration,
@@ -289,10 +290,10 @@ class AnimatedScaleOnTap extends StatefulWidget {
289290 final Widget child;
290291
291292 @override
292- State <AnimatedScaleOnTap > createState () => _AnimatedScaleOnTapState ();
293+ State <AnimatedScaleOnPrimaryPointerDown > createState () => _AnimatedScaleOnPrimaryPointerDownState ();
293294}
294295
295- class _AnimatedScaleOnTapState extends State <AnimatedScaleOnTap > {
296+ class _AnimatedScaleOnPrimaryPointerDownState extends State <AnimatedScaleOnPrimaryPointerDown > {
296297 double _scale = 1 ;
297298
298299 void _changeScale (double scale) {
@@ -303,11 +304,13 @@ class _AnimatedScaleOnTapState extends State<AnimatedScaleOnTap> {
303304
304305 @override
305306 Widget build (BuildContext context) {
306- return GestureDetector (
307+ return Listener (
307308 behavior: HitTestBehavior .translucent,
308- onTapDown: (_) => _changeScale (widget.scaleEnd),
309- onTapUp: (_) => _changeScale (1 ),
310- onTapCancel: () => _changeScale (1 ),
309+ onPointerDown: (PointerDownEvent pointerDownEvent) {
310+ if ((pointerDownEvent.buttons & kPrimaryButton) != 0 ) _changeScale (widget.scaleEnd);
311+ },
312+ onPointerUp: (_) => _changeScale (1 ),
313+ onPointerCancel: (_) => _changeScale (1 ),
311314 child: AnimatedScale (
312315 scale: _scale,
313316 duration: widget.duration,
0 commit comments