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.
89 lines
2.9 KiB
Dart
89 lines
2.9 KiB
Dart
|
2 months ago
|
import 'package:flutter/material.dart';
|
||
|
|
import 'package:hmg_patient_app_new/core/utils/utils.dart';
|
||
|
|
import 'package:hmg_patient_app_new/extensions/string_extensions.dart';
|
||
|
|
import 'package:hmg_patient_app_new/extensions/widget_extensions.dart';
|
||
|
|
|
||
|
|
class CustomButton extends StatelessWidget {
|
||
|
|
final String text;
|
||
|
|
String? icon;
|
||
|
|
final VoidCallback onPressed;
|
||
|
|
final Color backgroundColor;
|
||
|
|
final Color borderColor;
|
||
|
|
final Color textColor;
|
||
|
|
final double borderRadius;
|
||
|
|
final double borderWidth;
|
||
|
|
final EdgeInsetsGeometry padding;
|
||
|
|
final double fontSize;
|
||
|
|
final String? fontFamily;
|
||
|
|
final FontWeight fontWeight;
|
||
|
|
final bool isDisabled;
|
||
|
|
final Color iconColor;
|
||
|
|
|
||
|
|
CustomButton({
|
||
|
|
Key? key,
|
||
|
|
required this.text,
|
||
|
|
required this.onPressed,
|
||
|
|
this.backgroundColor = const Color(0xFFED1C2B),
|
||
|
|
this.borderColor = const Color(0xFFED1C2B),
|
||
|
|
this.textColor = Colors.white,
|
||
|
|
this.borderRadius = 12,
|
||
|
|
this.borderWidth = 2,
|
||
|
|
this.padding = const EdgeInsets.fromLTRB(8, 10, 8, 10),
|
||
|
|
this.fontSize = 16,
|
||
|
|
this.fontFamily,
|
||
|
|
this.fontWeight = FontWeight.w500,
|
||
|
|
this.isDisabled = false,
|
||
|
|
this.icon,
|
||
|
|
this.iconColor = Colors.white,
|
||
|
|
}) : super(key: key);
|
||
|
|
|
||
|
|
@override
|
||
|
|
Widget build(BuildContext context) {
|
||
|
|
return GestureDetector(
|
||
|
|
onTap: isDisabled ? null : onPressed,
|
||
|
|
child: Container(
|
||
|
|
height: 56,
|
||
|
|
decoration: RoundedRectangleBorder().toSmoothCornerDecoration(
|
||
|
|
color: isDisabled ? Colors.transparent : backgroundColor,
|
||
|
|
borderRadius: borderRadius,
|
||
|
|
side: BorderSide(
|
||
|
|
width: borderWidth,
|
||
|
|
color: isDisabled ? borderColor.withOpacity(0.5) : borderColor,
|
||
|
|
)),
|
||
|
|
child: Padding(
|
||
|
|
padding: padding,
|
||
|
|
child: Row(
|
||
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
||
|
|
children: [
|
||
|
|
if (icon != null)
|
||
|
|
Padding(
|
||
|
|
padding: const EdgeInsets.only(right: 8.0),
|
||
|
|
child: Utils.buildSvgWithAssets(icon: icon!, iconColor: iconColor, isDisabled: isDisabled),
|
||
|
|
),
|
||
|
|
Text(
|
||
|
|
text,
|
||
|
|
style: context.dynamicTextStyle(
|
||
|
|
fontSize: fontSize,
|
||
|
|
color: isDisabled ? textColor.withOpacity(0.5) : textColor,
|
||
|
|
fontWeight: fontWeight,
|
||
|
|
),
|
||
|
|
),
|
||
|
|
],
|
||
|
|
),
|
||
|
|
),
|
||
|
|
)
|
||
|
|
|
||
|
|
// .toSmoothContainer(
|
||
|
|
// smoothness: 1,
|
||
|
|
// side: BorderSide(width: borderWidth, color: backgroundColor),
|
||
|
|
// borderRadius: BorderRadius.circular(borderRadius * 1.2),
|
||
|
|
// foregroundDecoration: BoxDecoration(
|
||
|
|
// color: isDisabled ? backgroundColor.withOpacity(0.5) : Colors.transparent,
|
||
|
|
// borderRadius: BorderRadius.circular(borderRadius),
|
||
|
|
// ),
|
||
|
|
// ),
|
||
|
|
);
|
||
|
|
}
|
||
|
|
}
|