63 lines
1.6 KiB
Dart
63 lines
1.6 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
class PrimaryButton extends StatelessWidget {
|
|
final String label;
|
|
final VoidCallback onTap;
|
|
final bool busy;
|
|
|
|
const PrimaryButton({
|
|
super.key,
|
|
required this.label,
|
|
required this.onTap,
|
|
this.busy = false,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return SizedBox(
|
|
width: double.infinity,
|
|
|
|
child: Container(
|
|
decoration: BoxDecoration(
|
|
gradient: const LinearGradient(
|
|
colors: [
|
|
Color(0xFF0D47A1), // Blue
|
|
Color(0xFF6A1B9A), // Purple
|
|
],
|
|
begin: Alignment.topLeft,
|
|
end: Alignment.bottomRight,
|
|
),
|
|
borderRadius: BorderRadius.circular(12),
|
|
),
|
|
|
|
child: ElevatedButton(
|
|
onPressed: busy ? null : onTap,
|
|
style: ElevatedButton.styleFrom(
|
|
backgroundColor: Colors
|
|
.transparent, // IMPORTANT: keep transparent to see gradient
|
|
shadowColor: Colors.transparent,
|
|
padding: const EdgeInsets.symmetric(vertical: 14),
|
|
shape: RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.circular(12),
|
|
),
|
|
),
|
|
|
|
child: busy
|
|
? const SizedBox(
|
|
height: 18,
|
|
width: 18,
|
|
child: CircularProgressIndicator(
|
|
strokeWidth: 2,
|
|
color: Colors.white,
|
|
),
|
|
)
|
|
: Text(
|
|
label,
|
|
style: const TextStyle(fontSize: 16, color: Colors.white),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|