first commit
This commit is contained in:
76
lib/core/widgets/riotz_button.dart
Normal file
76
lib/core/widgets/riotz_button.dart
Normal file
@@ -0,0 +1,76 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user