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`.
This commit is contained in:
@@ -1,22 +1,23 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:game_tracker/core/custom_theme.dart';
|
||||||
|
|
||||||
|
enum ButtonStyle { primary, secondary }
|
||||||
|
|
||||||
class CustomWidthButton extends StatelessWidget {
|
class CustomWidthButton extends StatelessWidget {
|
||||||
const CustomWidthButton({
|
const CustomWidthButton({
|
||||||
super.key,
|
super.key,
|
||||||
required this.text,
|
required this.text,
|
||||||
required this.borderColor,
|
|
||||||
required this.infillColor,
|
|
||||||
this.disabledInfillColor,
|
this.disabledInfillColor,
|
||||||
|
this.buttonStyle = ButtonStyle.primary,
|
||||||
required this.sizeRelativeToWidth,
|
required this.sizeRelativeToWidth,
|
||||||
required this.onPressed,
|
required this.onPressed,
|
||||||
});
|
});
|
||||||
|
|
||||||
final String text;
|
final String text;
|
||||||
final Color borderColor;
|
|
||||||
final Color infillColor;
|
|
||||||
final Color? disabledInfillColor;
|
final Color? disabledInfillColor;
|
||||||
final double sizeRelativeToWidth;
|
final double sizeRelativeToWidth;
|
||||||
final VoidCallback? onPressed;
|
final VoidCallback? onPressed;
|
||||||
|
final ButtonStyle buttonStyle;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@@ -28,8 +29,15 @@ class CustomWidthButton extends StatelessWidget {
|
|||||||
MediaQuery.sizeOf(context).width * sizeRelativeToWidth,
|
MediaQuery.sizeOf(context).width * sizeRelativeToWidth,
|
||||||
60,
|
60,
|
||||||
),
|
),
|
||||||
backgroundColor: infillColor,
|
backgroundColor: buttonStyle == ButtonStyle.primary
|
||||||
side: BorderSide(color: borderColor, width: 2),
|
? CustomTheme.primaryColor
|
||||||
|
: CustomTheme.secondaryColor,
|
||||||
|
side: BorderSide(
|
||||||
|
color: buttonStyle == ButtonStyle.primary
|
||||||
|
? CustomTheme.primaryColor
|
||||||
|
: CustomTheme.secondaryColor,
|
||||||
|
width: 2,
|
||||||
|
),
|
||||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
|
||||||
),
|
),
|
||||||
child: Text(
|
child: Text(
|
||||||
|
|||||||
Reference in New Issue
Block a user