diff --git a/lib/pangea/widgets/chat/message_toolbar_buttons.dart b/lib/pangea/widgets/chat/message_toolbar_buttons.dart index 3976c7505..12c71e736 100644 --- a/lib/pangea/widgets/chat/message_toolbar_buttons.dart +++ b/lib/pangea/widgets/chat/message_toolbar_buttons.dart @@ -77,6 +77,7 @@ class ToolbarButtons extends StatelessWidget { ), Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.stretch, children: modes.mapIndexed((index, mode) { final enabled = mode.isUnlocked( index, diff --git a/lib/pangea/widgets/pressable_button.dart b/lib/pangea/widgets/pressable_button.dart index b112dff0d..596511adf 100644 --- a/lib/pangea/widgets/pressable_button.dart +++ b/lib/pangea/widgets/pressable_button.dart @@ -1,3 +1,5 @@ +import 'dart:async'; + import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; @@ -5,6 +7,7 @@ class PressableButton extends StatefulWidget { final double width; final double height; final BorderRadius borderRadius; + final double buttonHeight; final bool enabled; final bool depressed; @@ -20,6 +23,7 @@ class PressableButton extends StatefulWidget { required this.child, required this.onPressed, required this.color, + this.buttonHeight = 5, this.enabled = true, this.depressed = false, super.key, @@ -33,6 +37,7 @@ class PressableButtonState extends State with SingleTickerProviderStateMixin { late AnimationController _controller; late Animation _tweenAnimation; + Completer? _animationCompleter; @override void initState() { @@ -41,16 +46,24 @@ class PressableButtonState extends State duration: const Duration(milliseconds: 100), vsync: this, ); - _tweenAnimation = Tween(begin: 5, end: 0).animate(_controller); + _tweenAnimation = + Tween(begin: widget.buttonHeight, end: 0).animate(_controller); } void _onTapDown(TapDownDetails details) { if (!widget.enabled) return; - _controller.forward(); + _animationCompleter = Completer(); + _controller.forward().then((_) { + _animationCompleter?.complete(); + _animationCompleter = null; + }); } - void _onTapUp(TapUpDetails details) { + Future _onTapUp(TapUpDetails details) async { if (!widget.enabled) return; + if (_animationCompleter != null) { + await _animationCompleter!.future; + } _controller.reverse(); widget.onPressed?.call(); HapticFeedback.mediumImpact(); @@ -73,33 +86,30 @@ class PressableButtonState extends State onTapDown: _onTapDown, onTapUp: _onTapUp, onTapCancel: _onTapCancel, - child: SizedBox( - height: 45, - child: Stack( - alignment: Alignment.bottomCenter, - children: [ - Container( - width: widget.width, - height: widget.height, - decoration: BoxDecoration( - color: Color.alphaBlend( - Colors.black.withOpacity(0.25), - widget.color, - ), - borderRadius: widget.borderRadius, + child: Stack( + alignment: Alignment.bottomCenter, + children: [ + Container( + width: widget.width, + height: widget.height, + decoration: BoxDecoration( + color: Color.alphaBlend( + Colors.black.withOpacity(0.25), + widget.color, ), + borderRadius: widget.borderRadius, ), - AnimatedBuilder( - animation: _tweenAnimation, - builder: (context, _) { - return Positioned( - bottom: widget.depressed ? 0 : _tweenAnimation.value, - child: widget.child, - ); - }, - ), - ], - ), + ), + AnimatedBuilder( + animation: _tweenAnimation, + builder: (context, _) { + return Positioned( + bottom: widget.depressed ? 0 : _tweenAnimation.value, + child: widget.child, + ); + }, + ), + ], ), ); }