button not working
This commit is contained in:
@@ -7,45 +7,67 @@ class CustomWidthButton extends StatelessWidget {
|
||||
const CustomWidthButton({
|
||||
super.key,
|
||||
required this.text,
|
||||
this.disabledInfillColor,
|
||||
this.buttonStyle = ButtonStyle.primary,
|
||||
required this.sizeRelativeToWidth,
|
||||
required this.onPressed,
|
||||
this.onPressed,
|
||||
});
|
||||
|
||||
final String text;
|
||||
final Color? disabledInfillColor;
|
||||
final double sizeRelativeToWidth;
|
||||
final VoidCallback? onPressed;
|
||||
final ButtonStyle buttonStyle;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
||||
final Color buttonBackgroundColor;
|
||||
final Color disabledBackgroundColor;
|
||||
final Color borderSideColor;
|
||||
final Color disabledBorderSideColor;
|
||||
final Color textcolor;
|
||||
final Color disabledTextColor;
|
||||
|
||||
|
||||
if(buttonStyle == ButtonStyle.primary){
|
||||
buttonBackgroundColor = CustomTheme.primaryColor;
|
||||
disabledBackgroundColor = CustomTheme.primaryColor.withValues(alpha: 0.24);
|
||||
borderSideColor = Colors.transparent;
|
||||
disabledBorderSideColor = Colors.transparent;
|
||||
textcolor = Colors.white;
|
||||
disabledTextColor = Colors.white.withValues(alpha: 0.24);
|
||||
} else{
|
||||
buttonBackgroundColor = Colors.transparent;
|
||||
disabledBackgroundColor = Colors.transparent;
|
||||
borderSideColor = CustomTheme.primaryColor.withValues(alpha: 0.6 );
|
||||
disabledBorderSideColor = Colors.transparent;
|
||||
textcolor = CustomTheme.primaryColor;
|
||||
disabledTextColor = CustomTheme.primaryColor.withValues(alpha: 0.24);
|
||||
}
|
||||
|
||||
|
||||
return ElevatedButton(
|
||||
onPressed: onPressed,
|
||||
style: ElevatedButton.styleFrom(
|
||||
disabledBackgroundColor: disabledInfillColor,
|
||||
disabledBackgroundColor: disabledBackgroundColor,
|
||||
minimumSize: Size(
|
||||
MediaQuery.sizeOf(context).width * sizeRelativeToWidth,
|
||||
60,
|
||||
),
|
||||
backgroundColor: buttonStyle == ButtonStyle.primary
|
||||
? CustomTheme.primaryColor
|
||||
: CustomTheme.secondaryColor,
|
||||
backgroundColor: buttonBackgroundColor,
|
||||
side: BorderSide(
|
||||
color: buttonStyle == ButtonStyle.primary
|
||||
? CustomTheme.primaryColor
|
||||
: CustomTheme.secondaryColor,
|
||||
color: borderSideColor,
|
||||
width: 2,
|
||||
),
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
|
||||
),
|
||||
child: Text(
|
||||
text,
|
||||
style: const TextStyle(
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w500,
|
||||
fontSize: 22,
|
||||
color: Colors.white,
|
||||
color: (onPressed == null)
|
||||
? disabledTextColor
|
||||
: textcolor,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user