67 lines
1.9 KiB
Dart
67 lines
1.9 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
enum ButtonType { primary, secondary, disabled }
|
|
|
|
class GlobalButton extends StatelessWidget {
|
|
final VoidCallback? onPressed;
|
|
final String text;
|
|
final ButtonType type;
|
|
final Color baseColor;
|
|
|
|
const GlobalButton({
|
|
super.key,
|
|
required this.text,
|
|
required this.onPressed,
|
|
this.baseColor = const Color(0xFF0052CC),
|
|
this.type = ButtonType.primary,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final bool isDisabled = type == ButtonType.disabled || onPressed == null;
|
|
|
|
Color backgroundColor;
|
|
Color foregroundColor;
|
|
Color? borderColor;
|
|
|
|
switch (type) {
|
|
case ButtonType.primary:
|
|
backgroundColor = baseColor;
|
|
foregroundColor = Colors.white;
|
|
break;
|
|
case ButtonType.secondary:
|
|
backgroundColor = Colors.white;
|
|
foregroundColor = baseColor;
|
|
borderColor = const Color(0xFF0052CC);
|
|
break;
|
|
case ButtonType.disabled:
|
|
backgroundColor = const Color(0xFFE0E0E0);
|
|
foregroundColor = const Color(0xFF9E9E9E);
|
|
break;
|
|
}
|
|
|
|
return SizedBox(
|
|
width: double.infinity,
|
|
child: ElevatedButton(
|
|
style: ElevatedButton.styleFrom(
|
|
backgroundColor: backgroundColor,
|
|
foregroundColor: foregroundColor,
|
|
elevation: isDisabled ? 0 : 4,
|
|
shadowColor: !isDisabled ? backgroundColor.withValues(alpha: 0.3) : Colors.transparent,
|
|
padding: const EdgeInsets.symmetric(vertical: 16),
|
|
shape: RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.circular(16),
|
|
side: borderColor != null ? BorderSide(color: borderColor, width: 2) : BorderSide.none,
|
|
),
|
|
textStyle: const TextStyle(
|
|
fontSize: 16,
|
|
fontWeight: FontWeight.w600,
|
|
),
|
|
),
|
|
onPressed: isDisabled ? null : onPressed,
|
|
child: Text(text),
|
|
),
|
|
);
|
|
}
|
|
}
|