1import 'package:flutter/material.dart'; 2 3enum ButtonVariant { solid, outline, tertiary } 4 5class PrimaryButton extends StatelessWidget { 6 const PrimaryButton({ 7 super.key, 8 required this.title, 9 required this.onPressed, 10 this.variant = ButtonVariant.solid, 11 this.disabled = false, 12 }); 13 final String title; 14 final VoidCallback onPressed; 15 final ButtonVariant variant; 16 final bool disabled; 17 18 @override 19 Widget build(BuildContext context) { 20 return SizedBox( 21 width: MediaQuery.of(context).size.width * 0.75, 22 height: 48, 23 child: ElevatedButton( 24 onPressed: disabled ? null : onPressed, 25 style: ElevatedButton.styleFrom( 26 backgroundColor: _getBackgroundColor(), 27 foregroundColor: _getTextColor(), 28 disabledBackgroundColor: _getBackgroundColor().withValues(alpha: 0.5), 29 disabledForegroundColor: _getTextColor().withValues(alpha: 0.5), 30 overlayColor: _getOverlayColor(), 31 splashFactory: NoSplash.splashFactory, 32 shape: RoundedRectangleBorder( 33 borderRadius: BorderRadius.circular(9999), 34 side: _getBorderSide(), 35 ), 36 elevation: variant == ButtonVariant.solid ? 8 : 0, 37 shadowColor: 38 variant == ButtonVariant.solid 39 ? const Color(0xFFD84315).withValues(alpha: 0.4) 40 : Colors.transparent, 41 padding: const EdgeInsets.symmetric(vertical: 12), 42 ), 43 child: Text( 44 title, 45 style: TextStyle( 46 fontSize: variant == ButtonVariant.tertiary ? 14 : 16, 47 fontWeight: 48 variant == ButtonVariant.tertiary 49 ? FontWeight.w500 50 : FontWeight.w600, 51 ), 52 ), 53 ), 54 ); 55 } 56 57 Color _getBackgroundColor() { 58 switch (variant) { 59 case ButtonVariant.solid: 60 return const Color(0xFFFF6B35); 61 case ButtonVariant.outline: 62 return const Color(0xFF5A6B7F).withValues(alpha: 0.1); 63 case ButtonVariant.tertiary: 64 return const Color(0xFF1A1F27); 65 } 66 } 67 68 Color _getTextColor() { 69 switch (variant) { 70 case ButtonVariant.solid: 71 return const Color(0xFF0B0F14); 72 case ButtonVariant.outline: 73 return const Color(0xFFB6C2D2); 74 case ButtonVariant.tertiary: 75 return const Color(0xFF8A96A6); 76 } 77 } 78 79 BorderSide _getBorderSide() { 80 if (variant == ButtonVariant.outline) { 81 return const BorderSide(color: Color(0xFF5A6B7F), width: 2); 82 } 83 return BorderSide.none; 84 } 85 86 Color _getOverlayColor() { 87 switch (variant) { 88 case ButtonVariant.solid: 89 return const Color(0xFFD84315).withValues(alpha: 0.2); 90 case ButtonVariant.outline: 91 return const Color(0xFF5A6B7F).withValues(alpha: 0.15); 92 case ButtonVariant.tertiary: 93 return const Color(0xFF2A3441).withValues(alpha: 0.3); 94 } 95 } 96}