77 lines
1.9 KiB
Dart
77 lines
1.9 KiB
Dart
import 'package:flutter/material.dart';
|
|
import '../theme/app_colors.dart';
|
|
|
|
enum RiotzButtonStyle { primary, secondary, outline }
|
|
|
|
class RiotzButton extends StatelessWidget {
|
|
const RiotzButton({
|
|
required this.label,
|
|
required this.onPressed,
|
|
this.style = RiotzButtonStyle.primary,
|
|
this.isLoading = false,
|
|
this.fullWidth = true,
|
|
super.key,
|
|
});
|
|
|
|
final String label;
|
|
final VoidCallback? onPressed;
|
|
final RiotzButtonStyle style;
|
|
final bool isLoading;
|
|
final bool fullWidth;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final theme = Theme.of(context);
|
|
|
|
Widget content = isLoading
|
|
? const SizedBox(
|
|
height: 20,
|
|
width: 20,
|
|
child: CircularProgressIndicator(strokeWidth: 2, color: AppColors.white),
|
|
)
|
|
: Text(label.toUpperCase(), style: theme.textTheme.labelLarge);
|
|
|
|
if (fullWidth) {
|
|
content = Center(child: content);
|
|
}
|
|
|
|
return InkWell(
|
|
onTap: isLoading ? null : onPressed,
|
|
child: AnimatedContainer(
|
|
duration: const Duration(milliseconds: 200),
|
|
padding: const EdgeInsets.symmetric(vertical: 16, horizontal: 24),
|
|
decoration: BoxDecoration(
|
|
color: _getBgColor(),
|
|
border: Border.all(
|
|
color: _getBorderColor(),
|
|
width: 2,
|
|
),
|
|
),
|
|
child: content,
|
|
),
|
|
);
|
|
}
|
|
|
|
Color _getBgColor() {
|
|
switch (style) {
|
|
case RiotzButtonStyle.primary:
|
|
return AppColors.neonRed;
|
|
case RiotzButtonStyle.secondary:
|
|
return AppColors.bloodRed;
|
|
case RiotzButtonStyle.outline:
|
|
return Colors.transparent;
|
|
}
|
|
}
|
|
|
|
Color _getBorderColor() {
|
|
switch (style) {
|
|
case RiotzButtonStyle.primary:
|
|
return AppColors.neonRed;
|
|
case RiotzButtonStyle.secondary:
|
|
return AppColors.bloodRed;
|
|
case RiotzButtonStyle.outline:
|
|
return AppColors.white;
|
|
}
|
|
}
|
|
}
|