99 lines
3.1 KiB
Dart
99 lines
3.1 KiB
Dart
import 'package:flutter/material.dart';
|
|
import '../../core/constants/colors.dart';
|
|
import '../../core/constants/dimensions.dart';
|
|
|
|
/// Botón primario con gradiente naranja (Sunset Gradient)
|
|
/// Efecto "gominola" o fruto maduro
|
|
class PrimaryButton extends StatelessWidget {
|
|
final String text;
|
|
final VoidCallback? onPressed;
|
|
final bool isLoading;
|
|
final IconData? icon;
|
|
final double? width;
|
|
final double? height;
|
|
|
|
const PrimaryButton({
|
|
super.key,
|
|
required this.text,
|
|
this.onPressed,
|
|
this.isLoading = false,
|
|
this.icon,
|
|
this.width,
|
|
this.height,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Container(
|
|
width: width ?? double.infinity,
|
|
height: height ?? AppDimensions.buttonHeight,
|
|
decoration: BoxDecoration(
|
|
gradient: onPressed != null
|
|
? const LinearGradient(
|
|
begin: Alignment.centerLeft,
|
|
end: Alignment.centerRight,
|
|
colors: AppColors.buttonGradient,
|
|
)
|
|
: LinearGradient(
|
|
begin: Alignment.centerLeft,
|
|
end: Alignment.centerRight,
|
|
colors: [
|
|
AppColors.buttonGradientStart.withValues(alpha: 0.5),
|
|
AppColors.buttonGradientEnd.withValues(alpha: 0.5),
|
|
],
|
|
),
|
|
borderRadius: BorderRadius.circular(AppDimensions.buttonBorderRadius),
|
|
boxShadow: onPressed != null
|
|
? [
|
|
BoxShadow(
|
|
color: AppColors.primaryAction.withValues(alpha: 0.4),
|
|
blurRadius: 12,
|
|
offset: const Offset(0, 6),
|
|
),
|
|
]
|
|
: null,
|
|
),
|
|
child: Material(
|
|
color: Colors.transparent,
|
|
child: InkWell(
|
|
onTap: isLoading ? null : onPressed,
|
|
borderRadius: BorderRadius.circular(AppDimensions.buttonBorderRadius),
|
|
child: Center(
|
|
child: isLoading
|
|
? const SizedBox(
|
|
width: 24,
|
|
height: 24,
|
|
child: CircularProgressIndicator(
|
|
strokeWidth: 2,
|
|
valueColor: AlwaysStoppedAnimation<Color>(Colors.white),
|
|
),
|
|
)
|
|
: Row(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
if (icon != null) ...[
|
|
Icon(
|
|
icon,
|
|
color: Colors.white,
|
|
size: 20,
|
|
),
|
|
const SizedBox(width: 8),
|
|
],
|
|
Text(
|
|
text,
|
|
style: const TextStyle(
|
|
fontFamily: 'Inter',
|
|
fontSize: 16,
|
|
fontWeight: FontWeight.w600,
|
|
color: Colors.white,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|