You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
60 lines
2.0 KiB
Dart
60 lines
2.0 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
class FilledButtonComponent extends StatelessWidget {
|
|
const FilledButtonComponent({
|
|
Key? key,
|
|
this.width,
|
|
required this.label,
|
|
required this.onPressed,
|
|
required this.inProcess,
|
|
this.icon,
|
|
this.alignmentIcon,
|
|
this.color,
|
|
}) : super(key: key);
|
|
|
|
final double? width;
|
|
final String label;
|
|
final Function()? onPressed;
|
|
final IconData? icon;
|
|
final AlignmentGeometry? alignmentIcon;
|
|
final bool inProcess;
|
|
final Color? color;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return SizedBox(
|
|
width: width ?? MediaQuery.of(context).size.width * 0.9,
|
|
height: 70,
|
|
child: ElevatedButton(
|
|
style: ButtonStyle(
|
|
foregroundColor: MaterialStateProperty.all<Color>(Colors.white),
|
|
backgroundColor: MaterialStateProperty.all<Color>(onPressed == null ? Colors.grey : color ?? Theme.of(context).highlightColor),
|
|
shape: MaterialStateProperty.all<RoundedRectangleBorder>(
|
|
RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.circular(20),
|
|
side: BorderSide(color: onPressed == null ? Colors.grey : Theme.of(context).highlightColor),
|
|
),
|
|
),
|
|
elevation: MaterialStateProperty.all(8)),
|
|
child: inProcess
|
|
? const CircularProgressIndicator(
|
|
color: Colors.white,
|
|
)
|
|
: Row(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
Text(label, textScaleFactor: 1.0, style: const TextStyle(fontSize: 16, fontWeight: FontWeight.w700), textAlign: TextAlign.center),
|
|
if (icon != null)
|
|
Container(
|
|
padding: const EdgeInsets.only(left: 10),
|
|
alignment: alignmentIcon,
|
|
child: Icon(icon),
|
|
),
|
|
],
|
|
),
|
|
onPressed: onPressed,
|
|
),
|
|
);
|
|
}
|
|
}
|