feat: added content & disabled state

This commit is contained in:
2026-05-21 00:06:03 +02:00
parent 4c5ce1aba0
commit ec1182b560

View File

@@ -15,11 +15,12 @@ class AnimatedDialogButton extends StatefulWidget {
this.buttonConstraints,
this.buttonType = ButtonType.primary,
this.isDescructive = false,
this.content,
});
final String buttonText;
final VoidCallback onPressed;
final VoidCallback? onPressed;
final BoxConstraints? buttonConstraints;
@@ -27,6 +28,8 @@ class AnimatedDialogButton extends StatefulWidget {
final bool isDescructive;
final Widget? content;
@override
State<AnimatedDialogButton> createState() => _AnimatedDialogButtonState();
}
@@ -38,8 +41,13 @@ class _AnimatedDialogButtonState extends State<AnimatedDialogButton> {
Widget build(BuildContext context) {
final textStyling = _getTextStyling();
final buttonDecoration = _getButtonDecoration();
final isDisabled = widget.onPressed == null;
return GestureDetector(
return IgnorePointer(
ignoring: isDisabled,
child: Opacity(
opacity: isDisabled ? 0.4 : 1.0,
child: GestureDetector(
onTapDown: (_) => setState(() => _isPressed = true),
onTapUp: (_) => setState(() => _isPressed = false),
onTapCancel: () => setState(() => _isPressed = false),
@@ -54,9 +62,14 @@ class _AnimatedDialogButtonState extends State<AnimatedDialogButton> {
child: Container(
constraints: widget.buttonConstraints,
decoration: buttonDecoration,
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
padding: const EdgeInsets.symmetric(
horizontal: 16,
vertical: 12,
),
margin: const EdgeInsets.symmetric(vertical: 8),
child: Text(
child: widget.buttonText == ''
? widget.content!
: Text(
widget.buttonText,
style: textStyling,
textAlign: TextAlign.center,
@@ -65,6 +78,8 @@ class _AnimatedDialogButtonState extends State<AnimatedDialogButton> {
),
),
),
),
),
);
}