59 lines
1.7 KiB
Dart
59 lines
1.7 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
/// Custom elevated button for authentication actions
|
|
class AuthButton extends StatelessWidget {
|
|
const AuthButton({
|
|
super.key,
|
|
required this.onPressed,
|
|
required this.text,
|
|
this.isLoading = false,
|
|
this.enabled = true,
|
|
});
|
|
|
|
final VoidCallback? onPressed;
|
|
final String text;
|
|
final bool isLoading;
|
|
final bool enabled;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final theme = Theme.of(context);
|
|
|
|
return SizedBox(
|
|
width: double.infinity,
|
|
height: 50,
|
|
child: ElevatedButton(
|
|
onPressed: (enabled && !isLoading) ? onPressed : null,
|
|
style: ElevatedButton.styleFrom(
|
|
backgroundColor: theme.colorScheme.primary,
|
|
foregroundColor: theme.colorScheme.onPrimary,
|
|
disabledBackgroundColor:
|
|
theme.colorScheme.onSurface.withOpacity(0.12),
|
|
disabledForegroundColor:
|
|
theme.colorScheme.onSurface.withOpacity(0.38),
|
|
elevation: 2,
|
|
shadowColor: theme.colorScheme.primary.withOpacity(0.3),
|
|
),
|
|
child: isLoading
|
|
? SizedBox(
|
|
height: 20,
|
|
width: 20,
|
|
child: CircularProgressIndicator(
|
|
strokeWidth: 2,
|
|
valueColor: AlwaysStoppedAnimation<Color>(
|
|
theme.colorScheme.onPrimary,
|
|
),
|
|
),
|
|
)
|
|
: Text(
|
|
text,
|
|
style: theme.textTheme.titleMedium?.copyWith(
|
|
fontWeight: FontWeight.bold,
|
|
color: theme.colorScheme.onPrimary,
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|