updated pressable button widget to prevent it from changing the constraints of its child

pull/1544/head
ggurdin 11 months ago
parent 89e6b0692c
commit 570e933eca
No known key found for this signature in database
GPG Key ID: A01CB41737CBB478

@ -386,6 +386,7 @@ class Message extends StatelessWidget {
(eventID) => eventID == event.eventId,
),
depressed: !isButton,
enabled: isButton,
borderRadius: borderRadius,
onPressed: () {
showToolbar(pangeaMessageEvent);

@ -45,7 +45,7 @@ class PressableButtonState extends State<PressableButton>
vsync: this,
);
_tweenAnimation =
Tween<double>(begin: widget.buttonHeight, end: 0).animate(_controller);
Tween<double>(begin: 0, end: widget.buttonHeight).animate(_controller);
if (widget.enabled) {
_triggerAnimationSubscription = widget.triggerAnimation?.listen((_) {
_animationCompleter = Completer<void>();
@ -63,7 +63,7 @@ class PressableButtonState extends State<PressableButton>
}
void _animateUp() {
if (!mounted) return;
if (!widget.enabled || !mounted) return;
_controller.forward().then((_) {
_animationCompleter?.complete();
_animationCompleter = null;
@ -104,37 +104,32 @@ class PressableButtonState extends State<PressableButton>
onTapDown: _onTapDown,
onTapUp: _onTapUp,
onTapCancel: _onTapCancel,
child: Column(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.end,
children: [
Row(
crossAxisAlignment: CrossAxisAlignment.end,
mainAxisSize: MainAxisSize.min,
children: [
AnimatedBuilder(
animation: _tweenAnimation,
builder: (context, _) {
return Container(
padding: EdgeInsets.only(
bottom: widget.enabled && !widget.depressed
? _tweenAnimation.value
: 0,
),
decoration: BoxDecoration(
color: Color.alphaBlend(
Colors.black.withOpacity(0.25),
widget.color,
),
borderRadius: widget.borderRadius,
),
child: widget.child,
);
},
child: AnimatedBuilder(
animation: _tweenAnimation,
builder: (context, child) {
return Container(
decoration: BoxDecoration(
color: Color.alphaBlend(
Colors.black.withOpacity(0.25),
widget.color,
),
],
borderRadius: widget.borderRadius,
),
padding: EdgeInsets.only(
bottom: widget.enabled && !widget.depressed
? widget.buttonHeight - _tweenAnimation.value
: 0,
),
child: child,
);
},
child: Container(
decoration: BoxDecoration(
color: widget.color,
borderRadius: widget.borderRadius,
),
],
child: widget.child,
),
),
);
}

Loading…
Cancel
Save