From d65dd3d9838a9fa1075bcfd62460ec52ecb7f87e Mon Sep 17 00:00:00 2001 From: mathiskirchner Date: Tue, 18 Nov 2025 21:42:40 +0100 Subject: [PATCH] Refactor CustomWidthButton to use ButtonStyle enum and CustomTheme - Replaced `borderColor` and `infillColor` parameters with a `buttonStyle` parameter. - Introduced `ButtonStyle` enum (primary/secondary) to control styling. - Updated `CustomWidthButton` to derive colors from `CustomTheme` based on the selected `ButtonStyle`. --- .../widgets/custom_width_button.dart | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/lib/presentation/widgets/custom_width_button.dart b/lib/presentation/widgets/custom_width_button.dart index b336a79..b0b9bd3 100644 --- a/lib/presentation/widgets/custom_width_button.dart +++ b/lib/presentation/widgets/custom_width_button.dart @@ -1,22 +1,23 @@ import 'package:flutter/material.dart'; +import 'package:game_tracker/core/custom_theme.dart'; + +enum ButtonStyle { primary, secondary } class CustomWidthButton extends StatelessWidget { const CustomWidthButton({ super.key, required this.text, - required this.borderColor, - required this.infillColor, this.disabledInfillColor, + this.buttonStyle = ButtonStyle.primary, required this.sizeRelativeToWidth, required this.onPressed, }); final String text; - final Color borderColor; - final Color infillColor; final Color? disabledInfillColor; final double sizeRelativeToWidth; final VoidCallback? onPressed; + final ButtonStyle buttonStyle; @override Widget build(BuildContext context) { @@ -28,8 +29,15 @@ class CustomWidthButton extends StatelessWidget { MediaQuery.sizeOf(context).width * sizeRelativeToWidth, 60, ), - backgroundColor: infillColor, - side: BorderSide(color: borderColor, width: 2), + backgroundColor: buttonStyle == ButtonStyle.primary + ? CustomTheme.primaryColor + : CustomTheme.secondaryColor, + side: BorderSide( + color: buttonStyle == ButtonStyle.primary + ? CustomTheme.primaryColor + : CustomTheme.secondaryColor, + width: 2, + ), shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)), ), child: Text(