add background color option to AnimatedDialogButton
Some checks failed
Pull Request Pipeline / lint (pull_request) Failing after 2m47s
Pull Request Pipeline / test (pull_request) Successful in 2m38s

This commit is contained in:
2026-01-13 21:53:45 +01:00
parent 82ad2b74f8
commit 4019ed083f
2 changed files with 15 additions and 5 deletions

View File

@@ -111,7 +111,8 @@ class _SettingsViewState extends State<SettingsView> {
), ),
AnimatedDialogButton( AnimatedDialogButton(
onPressed: () => Navigator.of(context).pop(true), onPressed: () => Navigator.of(context).pop(true),
child: Text(loc.delete, style: TextStyle(color: CustomTheme.secondaryColor)), child: Text(loc.delete, style: TextStyle(color: CustomTheme.textColor)),
backgroundColor: CustomTheme.secondaryColor,
), ),
], ],
), ),

View File

@@ -8,13 +8,18 @@ import 'package:game_tracker/core/custom_theme.dart';
/// Parameters: /// Parameters:
/// - [onPressed]: Callback function that is triggered when the button is pressed. /// - [onPressed]: Callback function that is triggered when the button is pressed.
/// - [child]: The child widget to be displayed inside the button, typically a text or icon. /// - [child]: The child widget to be displayed inside the button, typically a text or icon.
/// - [backgroundColor]: Optional background color for the button container. If null, uses the standard box color from CustomTheme.
class AnimatedDialogButton extends StatefulWidget { class AnimatedDialogButton extends StatefulWidget {
const AnimatedDialogButton({super.key, required this.onPressed, required this.child}); const AnimatedDialogButton({
super.key,
required this.onPressed,
required this.child,
this.backgroundColor,
});
/// Callback function that is triggered when the button is pressed.
final VoidCallback onPressed; final VoidCallback onPressed;
/// The child widget to be displayed inside the button, typically a text or icon.
final Widget child; final Widget child;
final Color? backgroundColor;
@override @override
State<AnimatedDialogButton> createState() => _AnimatedDialogButtonState(); State<AnimatedDialogButton> createState() => _AnimatedDialogButtonState();
@@ -37,7 +42,11 @@ class _AnimatedDialogButtonState extends State<AnimatedDialogButton> {
opacity: _isPressed ? 0.6 : 1.0, opacity: _isPressed ? 0.6 : 1.0,
duration: const Duration(milliseconds: 100), duration: const Duration(milliseconds: 100),
child: Container( child: Container(
decoration: CustomTheme.standardBoxDecoration, decoration: widget.backgroundColor != null
? CustomTheme.standardBoxDecoration.copyWith(
color: widget.backgroundColor,
)
: CustomTheme.standardBoxDecoration,
padding: const EdgeInsets.symmetric(horizontal: 26, vertical: 6), padding: const EdgeInsets.symmetric(horizontal: 26, vertical: 6),
child: widget.child, child: widget.child,
), ),