Merge pull request #1195 from pangeachat/1189-only-the-latest-message-is-clickable

removed redundant enabled parameter from PressableButton, always call…
pull/1544/head
ggurdin 11 months ago committed by GitHub
commit 1894301f87
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

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

@ -103,7 +103,6 @@ class ToolbarButtons extends StatelessWidget {
children: [ children: [
PressableButton( PressableButton(
borderRadius: BorderRadius.circular(20), borderRadius: BorderRadius.circular(20),
enabled: enabled,
depressed: depressed:
!enabled || mode == overlayController.toolbarMode, !enabled || mode == overlayController.toolbarMode,
color: color, color: color,

@ -7,10 +7,10 @@ import 'package:flutter/services.dart';
class PressableButton extends StatefulWidget { class PressableButton extends StatefulWidget {
final BorderRadius borderRadius; final BorderRadius borderRadius;
final double buttonHeight; final double buttonHeight;
final bool enabled;
final bool depressed; final bool depressed;
final Color color; final Color color;
final Widget child; final Widget child;
final void Function()? onPressed; final void Function()? onPressed;
final Stream? triggerAnimation; final Stream? triggerAnimation;
@ -20,7 +20,6 @@ class PressableButton extends StatefulWidget {
required this.onPressed, required this.onPressed,
required this.color, required this.color,
this.buttonHeight = 5, this.buttonHeight = 5,
this.enabled = true,
this.depressed = false, this.depressed = false,
this.triggerAnimation, this.triggerAnimation,
super.key, super.key,
@ -46,7 +45,7 @@ class PressableButtonState extends State<PressableButton>
); );
_tweenAnimation = _tweenAnimation =
Tween<double>(begin: 0, end: widget.buttonHeight).animate(_controller); Tween<double>(begin: 0, end: widget.buttonHeight).animate(_controller);
if (widget.enabled) { if (!widget.depressed) {
_triggerAnimationSubscription = widget.triggerAnimation?.listen((_) { _triggerAnimationSubscription = widget.triggerAnimation?.listen((_) {
_animationCompleter = Completer<void>(); _animationCompleter = Completer<void>();
_animateUp(); _animateUp();
@ -56,14 +55,14 @@ class PressableButtonState extends State<PressableButton>
} }
void _onTapDown(TapDownDetails? details) { void _onTapDown(TapDownDetails? details) {
if (!widget.enabled) return; if (widget.depressed) return;
_animationCompleter = Completer<void>(); _animationCompleter = Completer<void>();
if (!mounted) return; if (!mounted) return;
_animateUp(); _animateUp();
} }
void _animateUp() { void _animateUp() {
if (!widget.enabled || !mounted) return; if (widget.depressed || !mounted) return;
_controller.forward().then((_) { _controller.forward().then((_) {
_animationCompleter?.complete(); _animationCompleter?.complete();
_animationCompleter = null; _animationCompleter = null;
@ -71,8 +70,8 @@ class PressableButtonState extends State<PressableButton>
} }
Future<void> _onTapUp(TapUpDetails? details) async { Future<void> _onTapUp(TapUpDetails? details) async {
if (!widget.enabled || widget.depressed) return;
widget.onPressed?.call(); widget.onPressed?.call();
if (widget.depressed) return;
await _animateDown(); await _animateDown();
} }
@ -87,7 +86,7 @@ class PressableButtonState extends State<PressableButton>
} }
void _onTapCancel() { void _onTapCancel() {
if (!widget.enabled) return; if (widget.depressed) return;
if (mounted) _controller.reverse(); if (mounted) _controller.reverse();
} }
@ -116,7 +115,7 @@ class PressableButtonState extends State<PressableButton>
borderRadius: widget.borderRadius, borderRadius: widget.borderRadius,
), ),
padding: EdgeInsets.only( padding: EdgeInsets.only(
bottom: widget.enabled && !widget.depressed bottom: !widget.depressed
? widget.buttonHeight - _tweenAnimation.value ? widget.buttonHeight - _tweenAnimation.value
: 0, : 0,
), ),

Loading…
Cancel
Save