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 (
@@ -273,10 +274,10 @@ class ZulipIconButton extends StatelessWidget {
273274 }
274275}
275276
276- /// Apply [Transform.scale] to the child widget when tapped, and reset its scale
277- /// when released, while animating the transitions.
278- class AnimatedScaleOnTap extends StatefulWidget {
279- const AnimatedScaleOnTap ({
277+ /// Apply [Transform.scale] to the child widget on primary pointer-down,
278+ /// and reset its scale on -up or -cancel, with animated transitions.
279+ class AnimatedScaleOnPrimaryPointerDown extends StatefulWidget {
280+ const AnimatedScaleOnPrimaryPointerDown ({
280281 super .key,
281282 required this .scaleEnd,
282283 required this .duration,
@@ -292,10 +293,10 @@ class AnimatedScaleOnTap extends StatefulWidget {
292293 final Widget child;
293294
294295 @override
295- State <AnimatedScaleOnTap > createState () => _AnimatedScaleOnTapState ();
296+ State <AnimatedScaleOnPrimaryPointerDown > createState () => _AnimatedScaleOnPrimaryPointerDownState ();
296297}
297298
298- class _AnimatedScaleOnTapState extends State <AnimatedScaleOnTap > {
299+ class _AnimatedScaleOnPrimaryPointerDownState extends State <AnimatedScaleOnPrimaryPointerDown > {
299300 double _scale = 1 ;
300301
301302 void _changeScale (double scale) {
@@ -306,11 +307,13 @@ class _AnimatedScaleOnTapState extends State<AnimatedScaleOnTap> {
306307
307308 @override
308309 Widget build (BuildContext context) {
309- return GestureDetector (
310+ return Listener (
310311 behavior: HitTestBehavior .translucent,
311- onTapDown: (_) => _changeScale (widget.scaleEnd),
312- onTapUp: (_) => _changeScale (1 ),
313- onTapCancel: () => _changeScale (1 ),
312+ onPointerDown: (PointerDownEvent pointerDownEvent) {
313+ if ((pointerDownEvent.buttons & kPrimaryButton) != 0 ) _changeScale (widget.scaleEnd);
314+ },
315+ onPointerUp: (_) => _changeScale (1 ),
316+ onPointerCancel: (_) => _changeScale (1 ),
314317 child: AnimatedScale (
315318 scale: _scale,
316319 duration: widget.duration,
0 commit comments